Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Titanium Review: Language and Compiler Amir Kamil Titanium Language and Compiler Changes Amir Kamil U.C. Berkeley September.

Similar presentations


Presentation on theme: "1 Titanium Review: Language and Compiler Amir Kamil Titanium Language and Compiler Changes Amir Kamil U.C. Berkeley September."— Presentation transcript:

1 1 Titanium Review: Language and Compiler Amir Kamil Titanium Language and Compiler Changes Amir Kamil http://titanium.cs.berkeley.edu U.C. Berkeley September 9, 2004

2 2 Titanium Review, Sep. 9, 2004 Amir Kamil Summary Language changes Nested classes (Amir) Nested classes in templates (Amir) Templates and inheritance (Amir) Operator overloading (Dan) Complex library (Dan/Kaushik) Macro preprocessor (Dan) Compiler changes Array/domain libraries (Dan/Imran) Various compile-time/runtime improvements (Dan)

3 3 Titanium Review, Sep. 9, 2004 Amir Kamil Nested Classes Local classes have been implemented Various bugs have been fixed Qualified anonymous classes Other minor bugs Titanium now supports almost all Java 1.4 features Exceptions: Dynamic threading (future support planned) Dynamic class loading, reflection Finalization Ordering of static initializers

4 4 Titanium Review, Sep. 9, 2004 Amir Kamil Nested Classes in Templates Motivation Container classes tend to use nested classes heavily Ex: template class Table {... class Entry { k key; v value;... } Nested classes in templates have been implemented

5 5 Titanium Review, Sep. 9, 2004 Amir Kamil Templates and Inheritance Titanium previously did not support templates as supertypes Users requested this feature be added to Titanium Support for templated supertypes required major compiler changes – phases had to be made incremental and postponable

6 6 Titanium Review, Sep. 9, 2004 Amir Kamil Phase-Oriented Compiler Structure Example requiring loop: class A { final static int x = B.y; C z = new C (); } Resolve Supertypes Resolve Types in Body Install Members Install Inherited Members Resolve Names in Body Fold Constants Resolve Templates

7 7 Titanium Review, Sep. 9, 2004 Amir Kamil Incremental Compiler Structure Example requiring expanded loop: class A extends B { // x is inherited from B C z = new C (); } Resolve Supertypes Resolve Types in Body Install Members Install Inherited Members Resolve Names in Body Fold Constants Resolve Templates

8 8 Titanium Review, Sep. 9, 2004 Amir Kamil Operator Overloading Titanium previously had support for operator overloading class A C op/(B x) {... } } a / b  a.op/(b) However, this did not work when a primitive is the left-hand operand 4 / a  4.op/(a)  ERROR Motivating example: complex library (next)

9 9 Titanium Review, Sep. 9, 2004 Amir Kamil Operator Overloading II C++ faced the same problem, chose a solution that gave up dynamic dispatch Titanium decided on a solution that retained dynamic dispatch class A C op/(int x, A y) {... } } 4 / a  a.op/(4, a)

10 10 Titanium Review, Sep. 9, 2004 Amir Kamil Complex Library The complex library defines an immutable Complex type to represent complex numbers, with support for common operations (e.g. abs, conj, sin, cos ) Previously, the following was impossible: Complex x = new Complex(0, 1); Complex y = 4 / x; With the extension to operator overloading, support for such operations has been added

11 11 Titanium Review, Sep. 9, 2004 Amir Kamil Macro Preprocessor Motivation Typedefs #define CONTAINER Vector<Foo<Bar.x + \ Baz.y>.Inner>... Debugging functions #if DEBUGGING #define debug(s) System.out.println(s) #else #define debug(s) #endif Selective compilation tcbuild –D DEBUGGING... Support for C preprocessor added to Titanium

12 12 Titanium Review, Sep. 9, 2004 Amir Kamil Array/Domain Libraries A number of tuning optimizations have been applied to the Titanium array library to increase performance Faster small array copies Faster Titanium array creation and manipulation Reduced loop overheads for short loops over Titanium arrays The domain library has been extensively rewritten to improve performance and fix bugs Imran will talk about this in detail later

13 13 Titanium Review, Sep. 9, 2004 Amir Kamil Other Compiler Improvements The compiler’s dominator algorithm has been replaced, decreasing front-end compile times by up to 75% Various runtime performance improvements have been made to the compiler Improve performance of uncontested locks Improve performance of random number generator Improve performance of static accesses when using pthreads

14 14 Titanium Review, Sep. 9, 2004 Amir Kamil Future Work Fix a few bugs involving wide-pointer backends and nested classes Incrementally add support for Java 1.4 library Rewrite/remove code that depends on missing features Write native code Incorporate Titanium modifications to the 1.0 library Implement dynamic threading Add language support for hierarchical machines (CLUMPS)

15 15 Titanium Review, Sep. 9, 2004 Amir Kamil

16 16 Titanium Review, Sep. 9, 2004 Amir Kamil Java 1.5 Generics Java 1.5 adds generics to the language Titanium’s templates are more general than Java’s generics, so translation should be possible A few generics features unsupported in Titanium and have to be implemented Generic methods void foo(Type x) {... } Type erasure Use Vector instead of Vector


Download ppt "1 Titanium Review: Language and Compiler Amir Kamil Titanium Language and Compiler Changes Amir Kamil U.C. Berkeley September."

Similar presentations


Ads by Google