Plans for X10 2'0 - PowerPoint PPT Presentation

1 / 31
About This Presentation
Title:

Plans for X10 2'0

Description:

Plans for X10 2.0. Nate Nystrom. IBM. Outline. Polyglot 3 [done] X10 1.7 built on P3 [August] ... Polyglot 3. Motivation. Pass scheduler in P2 was a disaster ... – PowerPoint PPT presentation

Number of Views:38
Avg rating:3.0/5.0
Slides: 32
Provided by: hopeC
Category:
Tags: plans | polyglot | x10

less

Transcript and Presenter's Notes

Title: Plans for X10 2'0


1
Plans for X10 2.0
  • Nate Nystrom
  • IBM

2
Outline
  • Polyglot 3 done
  • X10 1.7 built on P3 August
  • X10 2.0 2009

3
Polyglot 3
4
Motivation
  • Pass scheduler in P2 was a disaster
  • Difficult to use and debug, infinite loops
  • Main goal of P3 is to fix the pass scheduler
  • Also cleans up type system code
  • Not backward compatible with P2

5
Changes vs. P2
  • Pass scheduling
  • Lazy references
  • Type system interface
  • Lots of little changes

6
Pass scheduling
  • Passes can now run on AST fragments
  • Simplifies checking of dependent types
  • e.g., to compute type of Field e.f, may run pass
    just on the FieldDecl T f to resolve the type T

7
Lazy references
  • Added level of indirection for references to type
    system objects
  • class LazyRefltTgt implements RefltTgt
  • T get() ... run pass to compute result if
    needed... ...
  • interface MethodDef
  • RefltTypegt returnType()
  • ListltRefltTypegtgt formalTypes() ...

8
Type system changes
  • Split type objects into Uses and Defs
  • class FieldInstance implements UseltFieldDefgt
  • Type type() if (type null) type
    def.type() return type ...
  • Helps with dependent types and generics
    implementations
  • Can apply substitutions to Use without affecting
    Def

9
X10 2.0
10
X10 2.0 Features
  • Scala-like syntax
  • Generics
  • Closures
  • Type inference
  • Redesigned core type system
  • value types, arrays, regions, clocks, ...

11
X10 1.7
  • Scala-like syntax (partial)
  • Generics
  • Closures
  • Type inference (partial)
  • Redesigned core type system
  • value types, arrays, regions, clocks, ...

12
Syntax changes
13
Closures
  • (x Int, y Int) Int gt xy
  • x Boolean gt x
  • () gt new C()
  • gt if (G) return new C() else throw E

14
Operators
  • Can use operators as functions
  • Int., Int.-, Int., ...
  • Boolean., Boolean.!, ...

15
Methods as functions
  • class C
  • def m(x T) ...
  • f C.m.(T) f(y)

16
Function types
  • (Int, Int) gt Int
  • (a ArrayDouble,
  • r Regiona.region.contains(self))
  • gt ArrayDoubleregionr
  • x Int gt Intselfx

17
Array initializers
  • new doubled 0
  • ? new ArrayDouble(d, gt 0)
  • new doubled (p point) Bp
  • ? new ArrayDouble(d, p point(d) gt B(p))

18
Futures
  • future (p) S
  • ? future (p, gt S )

19
Generics in X10
20
Constrained types
  • Types have properties (public final fields)
  • class Region(rank Int, ...)
  • Ce
  • type of all instances of class C such that e is
    true
  • e.g., Regionrank2

21
Type properties
  • Generalize to type properties
  • class ListT def get(i Int) T
  • Type properties are instance members
  • e.T is a type

22
Generic types
  • Constrain the type properties
  • ListTC sugar ListC
  • ListTltC sugar ListC
  • ListTgtC sugar List-C

23
Generic functions
  • Add type parameters to methods
  • class ListT
  • def mapS(f T gt S) ListS
  • ys ListS new ListS()
  • for (x T in this) ys.add(f(x))
  • return ys

24
Where clauses
  • class ListT
  • def appendS(x S)TltS ListS

25
Structural constraints
  • X has var x T
  • X has a field
  • X has def m(T) U
  • X has a method
  • X has def this(T) U
  • X has a constructor

26
Array
  • class ArrayT(dist Dist, ...)
  • def get(p Point(dist.region)) ...
  • def add(a ArrayT(dist))T has def
    add(T,T)T
  • new ArrayT(dist, pgtthis(p)a(p))

27
Translation
  • Translate to template class
  • Type properties represented as run-time type
    object (rtt)
  • class ListT def get(i Int) T ... ...
  • ? class List rtt T class T // dummy class
  • T get(int i) ... ...

28
Template instantiation
  • Load bytecode for List and instantiate
  • class ListDouble
  • rtt T
  • double get(int i) ...
  • Need rtt to implement casts, instanceof for
    dependent types

29
Instanceof
  • Need rtt to implement casts, instanceof for
    dependent types
  • class ListDouble
  • rtt T ...
  • boolean instanceof(Object o)
  • return o instanceof ListDouble
  • ((ListDouble) o).T).equals(T)

30
Object instantiation
  • new ListDoubleselfgt0()
  • ?
  • new ListDouble(Double.getRTT(selfgt0))
  • Need run-time representation of constraints to
    implement casts, instanceof

31
Performance
  • one class instantiation per X10 class
  • one rtt object per X10 type

32
Type defs
  • type StringSet SetString
  • type StringMapT MapString,T
  • type Int(x Int) Intselfx
  • type Int(x Int, y Int) Intxltself,selflty
Write a Comment
User Comments (0)
About PowerShow.com