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

Slides:



Advertisements
Similar presentations
1 Packages: Putting Classes Together. 2 Introduction The main feature of OOP is its ability to support the reuse of code: Extending the classes (via inheritance)
Advertisements

Chapt.2 Machine Architecture Impact of languages –Support – faster, more secure Primitive Operations –e.g. nested subroutine calls »Subroutines implemented.
Objects and Classes David Walker CS 320. Advanced Languages advanced programming features –ML data types, exceptions, modules, objects, concurrency,...
The C ++ Language BY Shery khan. The C++ Language Bjarne Stroupstrup, the language’s creator C++ was designed to provide Simula’s facilities for program.
Incremental Algorithms for Dispatching in Dynamically Typed Languages Yoav Zibin Technion—Israel Institute of Technology Joint work with: Yossi (Joseph)
Overview of Java (continue). Announcements You should have access to your repositories and HW0 If you have problems getting HW0, let me know If you’ve.
George Blank University Lecturer. CS 602 Java and the Web Object Oriented Software Development Using Java Chapter 4.
Objects and Classes David Walker CS 320. Advanced Languages advanced programming features –ML data types, exceptions, modules, objects, concurrency,...
COMP171 Data Structure & Algorithm Tutorial 1 TA: M.Y.Chan.
Exceptions in Java Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Encapsulation by Subprograms and Type Definitions
PSUCS322 HM 1 Languages and Compiler Design II Parameter Passing Material provided by Prof. Jingke Li Stolen with pride and modified by Herb Mayer PSU.
Using ArrayList. Lecture Objectives To understand the foundations behind the ArrayList class Explore some of the methods of the ArrayList class.
ספטמבר 04Copyright Meir Kalech1 C programming Language Chapter 10: Appendices.
1 Generics and Using a Collection Generics / Parameterized Classes Using a Collection Customizing a Collection using Inheritance Inner Classes Use of Exceptions.
Slides prepared by Rose Williams, Binghamton University Chapter 14 Generics and the ArrayList Class.
Chapter 14 Generics and the ArrayList Class Copyright © 2010 Pearson Addison-Wesley. All rights reserved.
Chapter 2: Impact of Machine Architectures What is the Relationship Between Programs, Programming Languages, and Computers.
The Structure of the GNAT Compiler. A target-independent Ada95 front-end for GCC Ada components C components SyntaxSemExpandgigiGCC AST Annotated AST.
Templates. Objectives At the conclusion of this lesson, students should be able to Explain how function templates are used Correctly create a function.
Objects and Classes David Walker CS 320. Advanced Languages advanced programming features –ML data types, exceptions, modules, objects, concurrency,...
Support for Adaptive Computations Applied to Simulation of Fluids in Biological Systems Immersed Boundary Method Simulation in Titanium.
Generative Programming. Generic vs Generative Generic Programming focuses on representing families of domain concepts Generic Programming focuses on representing.
Introduction to Java Programming Language Junji Zhi University of Toronto 1.
Peter Juszczyk CS 492/493 - ISGS. // Is this C# or Java? class TestApp { static void Main() { int counter = 0; counter++; } } The answer is C# - In C#
What Is a Factory Pattern?.  Factories are classes that create or construct something.  In the case of object-oriented code languages, factories construct.
Language Evaluation Criteria
Object Oriented Data Structures
LECTURE LECTURE 17 More on Templates 20 An abstract recipe for producing concrete code.
© Janice Regan, CMPT 128, Jan CMPT 128 Introduction to Computing Science for Engineering Students Creating a program.
Data Structures Using C++ 2E
COP4020 Programming Languages
Introduction to Programming Languages. Problem Solving in Programming.
1 Titanium Review: Domain Library Imran Haque Domain Library Imran Haque U.C. Berkeley September 9, 2004.
SAK 3117 Data Structures Chapter 3: STACKS. Objective To introduce: Stack concepts Stack operations Stack applications CONTENT 3.1 Introduction 3.2 Stack.
CSC 243 – Java Programming, Spring 2013 March 12, 2013 Week 7, Generics.
Algorithm Programming Bar-Ilan University תשס"ח by Moshe Fresko.
Introduction and Features of Java. What is java? Developed by Sun Microsystems (James Gosling) A general-purpose object-oriented language Based on C/C++
ArrayList, Multidimensional Arrays
1 ENERGY 211 / CME 211 Lecture 26 November 19, 2008.
Elements of Computing Systems, Nisan & Schocken, MIT Press, 2005, Chapter 11: Compiler II: Code Generation slide 1www.idc.ac.il/tecs.
Hello.java Program Output 1 public class Hello { 2 public static void main( String [] args ) 3 { 4 System.out.println( “Hello!" ); 5 } // end method main.
Generics and Collections. Introduction Generics New feature of J2SE 5.0 Provide compile-time type safety Catch invalid types at compile time Generic methods.
Generative Programming. Automated Assembly Lines.
Performance Analysis Of Generics In Scientific Computing Laurentiu Dragan Stephen M. Watt Ontario Research Centre for Computer Algebra University of Western.
GPCE'04, Vancouver 1 Towards a General Template Introspection Library in C++ István Zólyomi, Zoltán Porkoláb Department of Programming Languages and Compilers.
Programming in Java Dr. M. Ahmadzadeh. Course Outline (subject to tiny changes) I will cover the following but not necessarily in this order. –Strings.
Aug 9, CMSC 202 ArrayList. Aug 9, What’s an Array List ArrayList is  a class in the standard Java libraries that can hold any type of object.
RUN-Time Organization Compiler phase— Before writing a code generator, we must decide how to marshal the resources of the target machine (instructions,
1 Compiler Construction (CS-636) Muhammad Bilal Bashir UIIT, Rawalpindi.
Inheritance Revisited Other Issues. Multiple Inheritance Also called combination--not permitted in Java, but is used in C++ Also called combination--not.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 9 Inheritance and.
 In the java programming language, a keyword is one of 50 reserved words which have a predefined meaning in the language; because of this,
SOEN 343 Software Design Section H Fall 2006 Dr Greg Butler
JAVA INTRODUCTION. What is Java? 1. Java is a Pure Object – Oriented language 2. Java is developing by existing languages like C and C++. How Java Differs.
STL CSSE 250 Susan Reeder. What is the STL? Standard Template Library Standard C++ Library is an extensible framework which contains components for Language.
CSE 1201 Object Oriented Programming ArrayList 1.
A comparison of C-Sharp and Java Zunaid Jogee Supervisor: T. Stakemire.
Overview of C++ Polymorphism
Compiler Construction CPCS302 Dr. Manal Abdulaziz.
CSC 520 – Advanced Object Oriented Programming, Fall, 2010 Thursday, September 30 Week 5, Generics and Inheritance Techniques, Meyer Ch. 10 & 16.
DGrid: A Library of Large-Scale Distributed Spatial Data Structures Pieter Hooimeijer,
5th MaCS Debrecen On the Turing-Completeness of Generative Metaprograms Zoltán Porkoláb, István Zólyomi Dept. of Programming.
Unit 10 Code Reuse. Key Concepts Abstraction Header files Implementation files Storage classes Exit function Conditional compilation Command-line arguments.
Sung-Dong Kim, Dept. of Computer Engineering, Hansung University Java - Introduction.
CS 363 – Chapter 1 What is a programming language? Kinds of languages
An Overview of Java.
The Procedure Abstraction Part V: Run-time Structures for OOLs
Overview of C++ Polymorphism
SPL – PS1 Introduction to C++.
Presentation transcript:

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

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 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 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 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 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 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 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 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 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 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 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 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 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 Titanium Review, Sep. 9, 2004 Amir Kamil

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