From: <ta...@us...> - 2009-12-25 04:31:27
|
Revision: 12415 http://x10.svn.sourceforge.net/x10/?rev=12415&view=rev Author: tardieu Date: 2009-12-25 04:31:10 +0000 (Fri, 25 Dec 2009) Log Message: ----------- undoing 12414 (buggy) Modified Paths: -------------- trunk/x10.compiler/src/x10/visit/NativeClassVisitor.java trunk/x10.runtime/src-x10/x10/runtime/Lock.x10 trunk/x10.runtime/src-x10/x10/runtime/X10Deque.x10 Modified: trunk/x10.compiler/src/x10/visit/NativeClassVisitor.java =================================================================== --- trunk/x10.compiler/src/x10/visit/NativeClassVisitor.java 2009-12-24 14:06:18 UTC (rev 12414) +++ trunk/x10.compiler/src/x10/visit/NativeClassVisitor.java 2009-12-25 04:31:10 UTC (rev 12415) @@ -11,11 +11,9 @@ import java.util.Collections; import java.util.List; -import polyglot.ast.Assign; import polyglot.ast.CanonicalTypeNode; import polyglot.ast.ClassBody; import polyglot.ast.ClassMember; -import polyglot.ast.ConstructorDecl; import polyglot.ast.Expr; import polyglot.ast.Formal; import polyglot.ast.IntLit; @@ -43,13 +41,10 @@ import polyglot.visit.ContextVisitor; import polyglot.visit.NodeVisitor; import x10.ast.AnnotationNode; -import x10.ast.X10ConstructorDecl; import x10.ast.X10ClassDecl; import x10.ast.X10MethodDecl; import x10.ast.X10NodeFactory; import x10.extension.X10Ext; -import x10.types.X10Def; -import x10.types.X10ConstructorDef; import x10.types.X10ClassDef; import x10.types.X10ClassType; import x10.types.X10Flags; @@ -76,39 +71,48 @@ fieldName = Name.make("__NATIVE_FIELD__"); } - public boolean isNativeDef(X10Def def) throws SemanticException { - Type t = (Type) xts.systemResolver().find(QName.make("x10.compiler.NativeDef")); - List<Type> as = def.annotationsMatching(t); - for (Type at : as) { - String lang = getPropertyInit(at, 0); - if (theLanguage.equals(lang)) { - return true; + public boolean isNativeMethod(X10MethodDef def) { + try { + Type t = (Type) xts.systemResolver().find(QName.make("x10.compiler.NativeDef")); + List<Type> as = def.annotationsMatching(t); + for (Type at : as) { + String lang = getPropertyInit(at, 0); + if (theLanguage.equals(lang)) { + return true; + } } } + catch (SemanticException e) {} return false; } - public String getNativeClassName(X10ClassDef def) throws SemanticException { - Type t = (Type) xts.systemResolver().find(QName.make("x10.compiler.NativeClass")); - List<Type> as = def.annotationsMatching(t); - for (Type at : as) { - String lang = getPropertyInit(at, 0); - if (theLanguage.equals(lang)) { - return getPropertyInit(at, 2); + public String getNativeClassName(X10ClassDef def) { + try { + Type t = (Type) xts.systemResolver().find(QName.make("x10.compiler.NativeClass")); + List<Type> as = def.annotationsMatching(t); + for (Type at : as) { + String lang = getPropertyInit(at, 0); + if (theLanguage.equals(lang)) { + return getPropertyInit(at, 2); + } } } + catch (SemanticException e) {} return null; } - public String getNativeClassPackage(X10ClassDef def) throws SemanticException { - Type t = (Type) xts.systemResolver().find(QName.make("x10.compiler.NativeClass")); - List<Type> as = def.annotationsMatching(t); - for (Type at : as) { - String lang = getPropertyInit(at, 0); - if (theLanguage.equals(lang)) { - return getPropertyInit(at, 1); + public String getNativeClassPackage(X10ClassDef def) { + try { + Type t = (Type) xts.systemResolver().find(QName.make("x10.compiler.NativeClass")); + List<Type> as = def.annotationsMatching(t); + for (Type at : as) { + String lang = getPropertyInit(at, 0); + if (theLanguage.equals(lang)) { + return getPropertyInit(at, 1); + } } } + catch (SemanticException e) {} return null; } @@ -160,21 +164,20 @@ // add field with native type Flags flags = X10Flags.GLOBAL.Private().Final(); FieldDef ff = xts.fieldDef(pos, Types.ref(cf.asType()), flags, Types.ref(ft), fieldName); + ConstructorInstance ci = xts.constructorDef(pos, Types.ref(ft), flags, + Collections.<Ref<? extends Type>>emptyList(), + Collections.<Ref<? extends Type>>emptyList()).asInstance(); CanonicalTypeNode tn = xnf.CanonicalTypeNode(pos, ft); - cm.add(xnf.FieldDecl(pos, xnf.FlagsNode(pos, flags), tn, xnf.Id(pos, fieldName)).fieldDef(ff)); + Expr init = xnf.New(pos, tn, Collections.<Expr>emptyList()).constructorInstance(ci).type(ft); + cm.add(xnf.FieldDecl(pos, xnf.FlagsNode(pos, flags), tn, xnf.Id(pos, fieldName), init).fieldDef(ff)); - Receiver special = xnf.This(pos).type(cf.asType()); - Receiver field = xnf.Field(pos, special, xnf.Id(pos, fieldName)).fieldInstance(ff.asInstance()).type(ft); - - Boolean hasNativeConstructor = false; - - // look for native methods and constructors + // look for @NativeDef methods and native methods for (ClassMember m : cb.members()) { if (m instanceof X10MethodDecl) { X10MethodDecl md = (X10MethodDecl) m; X10MethodDef mf = (X10MethodDef) md.methodDef(); - if (!isNativeDef(mf) && !mf.flags().isNative()) { + if (!isNativeMethod(mf) && !mf.flags().isNative()) { cm.add(m); continue; } @@ -187,11 +190,12 @@ for (Formal f : md.formals()) args.add(xnf.Local(pos, f.name()).localInstance(f.localDef().asInstance()).type(f.type().type())); + // call delegate + Receiver special = xnf.This(pos).type(cf.asType()); + Receiver field = xnf.Field(pos, special, xnf.Id(pos, fieldName)).fieldInstance(ff.asInstance()).type(ft); // HACK: reuse x10 method instance for delegate method but make it global and non-native MethodInstance mi = mf.asInstance(); mi = (MethodInstance) mi.flags(((X10Flags) mi.flags()).Global().clearNative()); - - // call delegate Expr expr = xnf.Call(pos, field, md.name(), args).methodInstance(mi).type(md.returnType().type()); // void vs. non-void methods @@ -208,44 +212,9 @@ cm.add((X10MethodDecl) md.body(xnf.Block(pos, body))); continue; } - - if (m instanceof X10ConstructorDecl) { - X10ConstructorDecl xd = (X10ConstructorDecl) m; - X10ConstructorDef xf = (X10ConstructorDef) xd.constructorDef(); - - if (!isNativeDef(xf) && !xf.flags().isNative()) { - // TODO: check that non-native constructors invoke native constructors - cm.add(m); - continue; - } - - hasNativeConstructor = true; - - if (Report.should_report("nativeclass", 2)) - Report.report(1, "Processing @NativeDef " + xd); - - // turn formals into arguments of delegate call - List<Expr> args = new ArrayList<Expr>(); - for (Formal f : xd.formals()) - args.add(xnf.Local(pos, f.name()).localInstance(f.localDef().asInstance()).type(f.type().type())); - - ConstructorInstance xi = xf.asInstance(); - xi = (ConstructorInstance) xi.flags(((X10Flags) xi.flags()).clearNative()); - Expr init = xnf.New(pos, tn, args).constructorInstance(xi).type(ft); - Stmt body = xnf.Eval(pos, xnf.FieldAssign(pos, special, xnf.Id(pos, fieldName), Assign.ASSIGN, init).fieldInstance(ff.asInstance()).type(ft)); - - xd = (X10ConstructorDecl) xd.flags(xnf.FlagsNode(pos, xd.flags().flags().clearNative())); - xf.setFlags(xf.flags().clearNative()); - cm.add((X10ConstructorDecl) xd.body(xnf.Block(pos, body))); - continue; - } cm.add(m); } - if (!hasNativeConstructor) { - throw new SemanticException("@NativeClass " + cd.name() + " must be declare a native constructor."); - } - return cd.body(cb.members(cm)); } } Modified: trunk/x10.runtime/src-x10/x10/runtime/Lock.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/runtime/Lock.x10 2009-12-24 14:06:18 UTC (rev 12414) +++ trunk/x10.runtime/src-x10/x10/runtime/Lock.x10 2009-12-25 04:31:10 UTC (rev 12415) @@ -20,8 +20,6 @@ @NativeClass("java", "java.util.concurrent.locks", "ReentrantLock") @NativeClass("c++", "x10.runtime", "Lock__ReentrantLock") public class Lock { - public native def this(); - public native def lock():Void; public native def tryLock():Void; Modified: trunk/x10.runtime/src-x10/x10/runtime/X10Deque.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/runtime/X10Deque.x10 2009-12-24 14:06:18 UTC (rev 12414) +++ trunk/x10.runtime/src-x10/x10/runtime/X10Deque.x10 2009-12-25 04:31:10 UTC (rev 12415) @@ -17,8 +17,6 @@ @NativeClass("java", "x10.runtime.impl.java", "Deque") @NativeClass("c++", "x10.runtime", "Deque") public final class X10Deque { - public native def this(); - public native def size():Int; public native def poll():Object; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ta...@us...> - 2009-12-25 23:53:26
|
Revision: 12416 http://x10.svn.sourceforge.net/x10/?rev=12416&view=rev Author: tardieu Date: 2009-12-25 23:53:19 +0000 (Fri, 25 Dec 2009) Log Message: ----------- added support for native constructors and factory methods in @NativeClass classes Modified Paths: -------------- trunk/x10.compiler/src/x10/visit/NativeClassVisitor.java trunk/x10.runtime/src-x10/x10/runtime/Lock.x10 trunk/x10.runtime/src-x10/x10/runtime/X10Deque.x10 Modified: trunk/x10.compiler/src/x10/visit/NativeClassVisitor.java =================================================================== --- trunk/x10.compiler/src/x10/visit/NativeClassVisitor.java 2009-12-25 04:31:10 UTC (rev 12415) +++ trunk/x10.compiler/src/x10/visit/NativeClassVisitor.java 2009-12-25 23:53:19 UTC (rev 12416) @@ -11,12 +11,17 @@ import java.util.Collections; import java.util.List; +import polyglot.ast.Assign; +import polyglot.ast.Call; import polyglot.ast.CanonicalTypeNode; import polyglot.ast.ClassBody; import polyglot.ast.ClassMember; +import polyglot.ast.ConstructorDecl; import polyglot.ast.Expr; import polyglot.ast.Formal; +import polyglot.ast.Id; import polyglot.ast.IntLit; +import polyglot.ast.New; import polyglot.ast.Node; import polyglot.ast.NodeFactory; import polyglot.ast.Receiver; @@ -27,8 +32,10 @@ import polyglot.types.ConstructorInstance; import polyglot.types.ClassDef; import polyglot.types.ClassType; +import polyglot.types.ConstructorDef; import polyglot.types.Flags; import polyglot.types.FieldDef; +import polyglot.types.LocalDef; import polyglot.types.MethodInstance; import polyglot.types.Name; import polyglot.types.QName; @@ -41,10 +48,13 @@ import polyglot.visit.ContextVisitor; import polyglot.visit.NodeVisitor; import x10.ast.AnnotationNode; +import x10.ast.X10ConstructorDecl; import x10.ast.X10ClassDecl; import x10.ast.X10MethodDecl; import x10.ast.X10NodeFactory; import x10.extension.X10Ext; +import x10.types.X10Def; +import x10.types.X10ConstructorDef; import x10.types.X10ClassDef; import x10.types.X10ClassType; import x10.types.X10Flags; @@ -59,64 +69,51 @@ final String theLanguage; final X10TypeSystem xts; final X10NodeFactory xnf; - final Position pos; - final Name fieldName; public NativeClassVisitor(Job job, TypeSystem ts, NodeFactory nf, String theLanguage) { super(job, ts, nf); xts = (X10TypeSystem) ts; xnf = (X10NodeFactory) nf; this.theLanguage = theLanguage; - pos = Position.COMPILER_GENERATED; - fieldName = Name.make("__NATIVE_FIELD__"); } - public boolean isNativeMethod(X10MethodDef def) { - try { - Type t = (Type) xts.systemResolver().find(QName.make("x10.compiler.NativeDef")); - List<Type> as = def.annotationsMatching(t); - for (Type at : as) { - String lang = getPropertyInit(at, 0); - if (theLanguage.equals(lang)) { - return true; - } + protected boolean isNativeDef(X10Def def) throws SemanticException { + Type t = (Type) xts.systemResolver().find(QName.make("x10.compiler.NativeDef")); + List<Type> as = def.annotationsMatching(t); + for (Type at : as) { + String lang = getPropertyInit(at, 0); + if (theLanguage.equals(lang)) { + return true; } } - catch (SemanticException e) {} return false; } - public String getNativeClassName(X10ClassDef def) { - try { - Type t = (Type) xts.systemResolver().find(QName.make("x10.compiler.NativeClass")); - List<Type> as = def.annotationsMatching(t); - for (Type at : as) { - String lang = getPropertyInit(at, 0); - if (theLanguage.equals(lang)) { - return getPropertyInit(at, 2); - } + protected String getNativeClassName(X10ClassDef def) throws SemanticException { + Type t = (Type) xts.systemResolver().find(QName.make("x10.compiler.NativeClass")); + List<Type> as = def.annotationsMatching(t); + for (Type at : as) { + String lang = getPropertyInit(at, 0); + if (theLanguage.equals(lang)) { + return getPropertyInit(at, 2); } } - catch (SemanticException e) {} return null; } - public String getNativeClassPackage(X10ClassDef def) { - try { - Type t = (Type) xts.systemResolver().find(QName.make("x10.compiler.NativeClass")); - List<Type> as = def.annotationsMatching(t); - for (Type at : as) { - String lang = getPropertyInit(at, 0); - if (theLanguage.equals(lang)) { - return getPropertyInit(at, 1); - } + protected String getNativeClassPackage(X10ClassDef def) throws SemanticException { + Type t = (Type) xts.systemResolver().find(QName.make("x10.compiler.NativeClass")); + List<Type> as = def.annotationsMatching(t); + for (Type at : as) { + String lang = getPropertyInit(at, 0); + if (theLanguage.equals(lang)) { + return getPropertyInit(at, 1); } } - catch (SemanticException e) {} return null; } - String getPropertyInit(Type at, int index) throws SemanticException { + protected String getPropertyInit(Type at, int index) throws SemanticException { at = X10TypeMixin.baseType(at); if (at instanceof X10ClassType) { X10ClassType act = (X10ClassType) at; @@ -124,8 +121,7 @@ Expr e = act.propertyInitializer(index); if (e.isConstant() && e.constantValue() instanceof String) { return (String) e.constantValue(); - } - else { + } else { throw new SemanticException("Property initializer for @" + at + " must be a string literal."); } } @@ -133,88 +129,179 @@ return null; } + protected static X10Flags clearNative(Flags flags) { + return X10Flags.toX10Flags(flags).clearX(Flags.NATIVE); + } + protected Node leaveCall(Node parent, Node old, Node n, NodeVisitor v) throws SemanticException { // look for @NativeClass class declarations - if (!(n instanceof X10ClassDecl)) + if (!(n instanceof X10ClassDecl)) return n; - - X10ClassDecl cd = (X10ClassDecl) n; - X10ClassDef cf = (X10ClassDef) cd.classDef(); - String cn = getNativeClassName(cf); - - if (cn == null) + X10ClassDecl cdecl = (X10ClassDecl) n; + X10ClassDef cdef = (X10ClassDef) cdecl.classDef(); + String cname = getNativeClassName(cdef); + + if (cname == null) return n; if (Report.should_report("nativeclass", 1)) - Report.report(1, "Processing @NativeClass " + cd); + Report.report(1, "Processing @NativeClass " + cdecl); - ClassBody cb = cd.body(); - List<ClassMember> cm = new ArrayList<ClassMember>(); + ClassBody cbody = cdecl.body(); + List<ClassMember> cmembers = new ArrayList<ClassMember>(); + Position p = Position.COMPILER_GENERATED; + // create fake def for native class - ClassDef def = xts.createClassDef(); - def.name(Name.make(cn)); - def.kind(ClassDef.TOP_LEVEL); - def.setFromEncodedClassFile(); - def.setFlags(X10Flags.NONE); - def.setPackage(Types.ref(ts.packageForName(QName.make(getNativeClassPackage(cf))))); - ClassType ft = def.asType(); + ClassDef fake = xts.createClassDef(); + fake.name(Name.make(cname)); + fake.kind(ClassDef.TOP_LEVEL); + fake.setFromEncodedClassFile(); + fake.setFlags(X10Flags.NONE); + fake.setPackage(Types.ref(ts.packageForName(QName.make(getNativeClassPackage(cdef))))); // add field with native type - Flags flags = X10Flags.GLOBAL.Private().Final(); - FieldDef ff = xts.fieldDef(pos, Types.ref(cf.asType()), flags, Types.ref(ft), fieldName); - ConstructorInstance ci = xts.constructorDef(pos, Types.ref(ft), flags, - Collections.<Ref<? extends Type>>emptyList(), - Collections.<Ref<? extends Type>>emptyList()).asInstance(); - CanonicalTypeNode tn = xnf.CanonicalTypeNode(pos, ft); - Expr init = xnf.New(pos, tn, Collections.<Expr>emptyList()).constructorInstance(ci).type(ft); - cm.add(xnf.FieldDecl(pos, xnf.FlagsNode(pos, flags), tn, xnf.Id(pos, fieldName), init).fieldDef(ff)); + Name fname = Name.make("__NATIVE_FIELD__"); + Id fid = xnf.Id(p, fname); + ClassType ftype = fake.asType(); + CanonicalTypeNode ftnode = xnf.CanonicalTypeNode(p, ftype); + Flags fflags = X10Flags.GLOBAL.Private().Final(); + FieldDef fdef = xts.fieldDef(p, Types.ref(cdef.asType()), fflags, Types.ref(ftype), fname); + cmembers.add(xnf.FieldDecl(p, xnf.FlagsNode(p, fflags), ftnode, fid).fieldDef(fdef)); - // look for @NativeDef methods and native methods - for (ClassMember m : cb.members()) { + // field selector + Receiver special = xnf.This(p).type(cdef.asType()); + Receiver field = xnf.Field(p, special, fid).fieldInstance(fdef.asInstance()).type(ftype); + + // add copy constructor + ConstructorInstance xinst; + { + Name id0 = Name.make("id0"); + LocalDef ldef = xts.localDef(p, X10Flags.FINAL, Types.ref(ftype), id0); + Expr init = xnf.Local(p, xnf.Id(p, id0)).localInstance(ldef.asInstance()).type(ftype); + Expr assign = xnf.FieldAssign(p, special, fid, Assign.ASSIGN, init).fieldInstance(fdef.asInstance()).type(ftype); + Formal f = xnf.Formal(p, xnf.FlagsNode(p, X10Flags.FINAL), ftnode, xnf.Id(p, id0)).localDef(ldef); + + // super constructor def (noarg) + ConstructorDef sdef = xts.findConstructor(cdecl.superClass().type(), + xts.ConstructorMatcher(cdecl.superClass().type(), Collections.<Type>emptyList(), context)).def(); + + ConstructorDecl xd = xnf.ConstructorDecl(p, + xnf.FlagsNode(p, X10Flags.PRIVATE), + cdecl.name(), + Collections.<Formal>singletonList(f), + Collections.<TypeNode>emptyList(), + xnf.Block(p, + xnf.SuperCall(p, Collections.<Expr>emptyList()).constructorInstance(sdef.asInstance()), + xnf.Eval(p, assign))); + + ConstructorDef xdef = xts.constructorDef(p, + Types.ref(cdef.asType()), + X10Flags.PRIVATE, + Collections.<Ref<? extends Type>>singletonList(Types.ref(ftype)), + Collections.<Ref<? extends Type>>emptyList()); + + cmembers.add(xd.constructorDef(xdef)); + + xinst = xdef.asInstance(); // to be used later + } + + Boolean hasNativeConstructor = false; + + // look for native methods and constructors + for (ClassMember m : cbody.members()) { if (m instanceof X10MethodDecl) { - X10MethodDecl md = (X10MethodDecl) m; - X10MethodDef mf = (X10MethodDef) md.methodDef(); - - if (!isNativeMethod(mf) && !mf.flags().isNative()) { - cm.add(m); + X10MethodDecl mdecl = (X10MethodDecl) m; + X10MethodDef mdef = (X10MethodDef) mdecl.methodDef(); + + if (!isNativeDef(mdef) && !mdef.flags().isNative()) { + cmembers.add(m); continue; } if (Report.should_report("nativeclass", 2)) - Report.report(1, "Processing @NativeDef " + md); + Report.report(1, "Processing @NativeDef " + mdecl); + // clear native flag + mdecl = (X10MethodDecl) mdecl.flags(xnf.FlagsNode(p, clearNative(mdecl.flags().flags()))); + mdef.setFlags(clearNative(mdef.flags())); + // turn formals into arguments of delegate call List<Expr> args = new ArrayList<Expr>(); - for (Formal f : md.formals()) - args.add(xnf.Local(pos, f.name()).localInstance(f.localDef().asInstance()).type(f.type().type())); + for (Formal f : mdecl.formals()) + args.add(xnf.Local(p, f.name()).localInstance(f.localDef().asInstance()).type(f.type().type())); + // reuse x10 method instance for delegate method but make it global to avoid place check + MethodInstance minst = mdef.asInstance(); + minst = (MethodInstance) minst.flags(((X10Flags) minst.flags()).Global()); + // call delegate - Receiver special = xnf.This(pos).type(cf.asType()); - Receiver field = xnf.Field(pos, special, xnf.Id(pos, fieldName)).fieldInstance(ff.asInstance()).type(ft); - // HACK: reuse x10 method instance for delegate method but make it global and non-native - MethodInstance mi = mf.asInstance(); - mi = (MethodInstance) mi.flags(((X10Flags) mi.flags()).Global().clearNative()); - Expr expr = xnf.Call(pos, field, md.name(), args).methodInstance(mi).type(md.returnType().type()); - - // void vs. non-void methods + Receiver target = mdef.flags().isStatic() ? ftnode : field; + Call call = xnf.Call(p, target, mdecl.name(), args); // no type yet + + // void vs factory vs non-void methods Stmt body; - if (md.returnType().type().isVoid()) { - body = xnf.Eval(pos, expr); - } else { - body = xnf.Return(pos, expr); + if (mdecl.returnType().type().isVoid()) { + body = xnf.Eval(p, call.methodInstance(minst).type(ts.Void())); + } else if (mdecl.returnType().type().isSubtype(cdef.asType(), context)) { + // delegate method return native object + minst = minst.returnType(ftype); + + // call copy constructor + New copy = xnf.New(p, + xnf.CanonicalTypeNode(p, Types.ref(cdef.asType())), + Collections.<Expr>singletonList(call.methodInstance(minst).type(ftype))); + body = xnf.Return(p, copy.constructorInstance(xinst).type(cdef.asType())); + } else{ + body = xnf.Return(p, call.methodInstance(minst).type(mdecl.returnType().type())); } + cmembers.add((X10MethodDecl) mdecl.body(xnf.Block(p, body))); + continue; + } + + if (m instanceof X10ConstructorDecl) { + X10ConstructorDecl xdecl = (X10ConstructorDecl) m; + X10ConstructorDef xdef = (X10ConstructorDef) xdecl.constructorDef(); + + if (!isNativeDef(xdef) && !xdef.flags().isNative()) { + // TODO: check that non-native constructors invoke native constructors + cmembers.add(m); + continue; + } + + hasNativeConstructor = true; // good! + + if (Report.should_report("nativeclass", 2)) + Report.report(1, "Processing @NativeDef " + xdecl); + // clear native flag - md = (X10MethodDecl) md.flags(xnf.FlagsNode(pos, md.flags().flags().clearNative())); - mf.setFlags(mf.flags().clearNative()); - cm.add((X10MethodDecl) md.body(xnf.Block(pos, body))); + xdecl = (X10ConstructorDecl) xdecl.flags(xnf.FlagsNode(p, clearNative(xdecl.flags().flags()))); + xdef.setFlags(clearNative(xdef.flags())); + + // turn formals into arguments of delegate call + List<Expr> args = new ArrayList<Expr>(); + for (Formal f : xdecl.formals()) + args.add(xnf.Local(p, f.name()).localInstance(f.localDef().asInstance()).type(f.type().type())); + + // call delegate constructor + Expr init = xnf.New(p, ftnode, args).constructorInstance(xdef.asInstance()).type(ftype); + + // invoke copy constructor + Stmt body = xnf.ThisCall(p, Collections.<Expr>singletonList(init)).constructorInstance(xinst); + + cmembers.add((X10ConstructorDecl) xdecl.body(xnf.Block(p, body))); continue; } - cm.add(m); + + cmembers.add(m); } - - return cd.body(cb.members(cm)); + + if (!hasNativeConstructor) { + throw new SemanticException("@NativeClass " + cdecl.name() + " must be declare a native constructor."); + } + + return cdecl.body(cbody.members(cmembers)); } } Modified: trunk/x10.runtime/src-x10/x10/runtime/Lock.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/runtime/Lock.x10 2009-12-25 04:31:10 UTC (rev 12415) +++ trunk/x10.runtime/src-x10/x10/runtime/Lock.x10 2009-12-25 23:53:19 UTC (rev 12416) @@ -20,6 +20,8 @@ @NativeClass("java", "java.util.concurrent.locks", "ReentrantLock") @NativeClass("c++", "x10.runtime", "Lock__ReentrantLock") public class Lock { + public native def this(); + public native def lock():Void; public native def tryLock():Void; Modified: trunk/x10.runtime/src-x10/x10/runtime/X10Deque.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/runtime/X10Deque.x10 2009-12-25 04:31:10 UTC (rev 12415) +++ trunk/x10.runtime/src-x10/x10/runtime/X10Deque.x10 2009-12-25 23:53:19 UTC (rev 12416) @@ -17,6 +17,8 @@ @NativeClass("java", "x10.runtime.impl.java", "Deque") @NativeClass("c++", "x10.runtime", "Deque") public final class X10Deque { + public native def this(); + public native def size():Int; public native def poll():Object; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <vj...@us...> - 2010-01-07 02:32:23
|
Revision: 12437 http://x10.svn.sourceforge.net/x10/?rev=12437&view=rev Author: vj0 Date: 2010-01-07 02:31:56 +0000 (Thu, 07 Jan 2010) Log Message: ----------- Removed ValueTypes in most places. Removed Nat from the type system. It was defined as Int. Duh. Just changing it to UInt does not work. We have decided to keep Rails indexed by int for ease of code generation for Java. This has a ripple effect -- rank for regions and distributions and points then also stays as Int. Its best to revisit code written using Nat once Nat is purged from the current code base and then reintroduced as UInt. Introduced new default constructor for classes and structs. If the class or struct defines properties, and does not define a constructor, then the default constructor takes the properties as arguments and contains a call to super() followed by a call to property(...) with all the arguments passed in. This is sensible in a lot more places. Modified Paths: -------------- trunk/x10.compiler/src/x10/ast/AssignPropertyCall_c.java trunk/x10.compiler/src/x10/ast/X10Boxed_c.java trunk/x10.compiler/src/x10/ast/X10Call_c.java trunk/x10.compiler/src/x10/ast/X10Cast_c.java trunk/x10.compiler/src/x10/ast/X10ClassDecl_c.java trunk/x10.compiler/src/x10/ast/X10Field_c.java trunk/x10.compiler/src/x10/ast/X10NodeFactory.java trunk/x10.compiler/src/x10/types/X10PrimitiveType_c.java trunk/x10.compiler/src/x10/types/X10TypeEnv_c.java trunk/x10.compiler/src/x10/types/X10TypeSystem.java trunk/x10.compiler/src/x10/types/X10TypeSystem_c.java trunk/x10.runtime/src-cpp/x10/lang/IBox.h trunk/x10.runtime/src-x10/x10/array/BaseArray.x10 trunk/x10.runtime/src-x10/x10/array/BaseDist.x10 trunk/x10.runtime/src-x10/x10/array/BaseRegion.x10 trunk/x10.runtime/src-x10/x10/array/Mat.x10 trunk/x10.runtime/src-x10/x10/array/MatBuilder.x10 trunk/x10.runtime/src-x10/x10/array/PolyMat.x10 trunk/x10.runtime/src-x10/x10/array/PolyMatBuilder.x10 trunk/x10.runtime/src-x10/x10/array/PolyRegion.x10 trunk/x10.runtime/src-x10/x10/array/PolyRegionListBuilder.x10 trunk/x10.runtime/src-x10/x10/array/PolyRow.x10 trunk/x10.runtime/src-x10/x10/array/PolyScanner.x10 trunk/x10.runtime/src-x10/x10/array/RectLayout.x10 trunk/x10.runtime/src-x10/x10/array/RectRegion.x10 trunk/x10.runtime/src-x10/x10/array/Row.x10 trunk/x10.runtime/src-x10/x10/array/UnionRegion.x10 trunk/x10.runtime/src-x10/x10/array/ValRow.x10 trunk/x10.runtime/src-x10/x10/array/VarMat.x10 trunk/x10.runtime/src-x10/x10/array/VarRow.x10 trunk/x10.runtime/src-x10/x10/array/Xform.x10 trunk/x10.runtime/src-x10/x10/array/XformMat.x10 trunk/x10.runtime/src-x10/x10/lang/Array.x10 trunk/x10.runtime/src-x10/x10/lang/Dist.x10 trunk/x10.runtime/src-x10/x10/lang/Future.x10 trunk/x10.runtime/src-x10/x10/lang/Place.x10 trunk/x10.runtime/src-x10/x10/lang/Point.x10 trunk/x10.runtime/src-x10/x10/lang/Region.x10 trunk/x10.runtime/src-x10/x10/lang/String.x10 trunk/x10.runtime/src-x10/x10/lang/System.x10 trunk/x10.runtime/src-x10/x10/lang/_.x10 trunk/x10.runtime/src-x10/x10/runtime/ClockPhases.x10 trunk/x10.runtime/src-x10/x10/runtime/RemoteFinish.x10 trunk/x10.runtime/src-x10/x10/util/ArrayList.x10 trunk/x10.runtime/src-x10/x10/util/GrowableRail.x10 Modified: trunk/x10.compiler/src/x10/ast/AssignPropertyCall_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/AssignPropertyCall_c.java 2010-01-06 20:37:08 UTC (rev 12436) +++ trunk/x10.compiler/src/x10/ast/AssignPropertyCall_c.java 2010-01-07 02:31:56 UTC (rev 12437) @@ -44,6 +44,7 @@ import x10.types.X10ConstructorDef; import x10.types.X10Context; import x10.types.X10ParsedClassType; +import x10.types.X10Type; import x10.types.X10TypeMixin; import x10.types.X10TypeSystem; import x10.types.XTypeTranslator; @@ -135,12 +136,13 @@ position()); } - checkAssignments(tc, pos, thisConstructor, definedProperties); + checkAssignments(tc, pos, thisConstructor, definedProperties, args()); + checkReturnType(tc, pos, thisConstructor, definedProperties); List<Stmt> s = new ArrayList<Stmt>(pSize); for (int i=0; i < aSize; i++) { - // We fudge type checking of the generating code as follows. + // We fudge type checking of the generating code as follows. // X10 Typechecking of the assignment statement is problematic since // the type of the field may have references to other fields, hence may use this, // But this doesn't exist yet. We will check all the properties simultaneously @@ -161,7 +163,22 @@ return nf.AssignPropertyBody(pos, s, thisConstructor, definedProperties).del().typeCheck(tc); } - protected void checkAssignments(ContextVisitor tc, Position pos, X10ConstructorDef thisConstructor, List<FieldInstance> definedProperties) + protected void checkAssignments(ContextVisitor tc, Position pos, X10ConstructorDef thisConstructor, + List<FieldInstance> props, List<Expr> args) + throws SemanticException { + X10TypeSystem xts = (X10TypeSystem) tc.typeSystem(); + // First check that the base types are correct. + for (int i=0; i < args.size(); ++i) { + if (! xts.isSubtype(X10TypeMixin.baseType(args.get(i).type()), X10TypeMixin.baseType(props.get(i).type()))) { + throw new SemanticException("The type " + args.get(i).type() + " of the initializer for property " + props.get(i) + + " is not a subtype of the property type " + props.get(i).type(), position()); + } + } + // Now we check that the constraints are correct. + + + } + protected void checkReturnType(ContextVisitor tc, Position pos, X10ConstructorDef thisConstructor, List<FieldInstance> definedProperties) throws SemanticException { X10TypeSystem ts = (X10TypeSystem) tc.typeSystem(); X10Context ctx = (X10Context) tc.context(); Modified: trunk/x10.compiler/src/x10/ast/X10Boxed_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10Boxed_c.java 2010-01-06 20:37:08 UTC (rev 12436) +++ trunk/x10.compiler/src/x10/ast/X10Boxed_c.java 2010-01-07 02:31:56 UTC (rev 12437) @@ -111,7 +111,7 @@ local = true; - assert ts.isValueType(fromType, context) || ts.isParameterType(fromType); + assert ts.isParameterType(fromType); Name className = Name.makeFresh("Boxed$"); Name xname = Name.make("v"); @@ -280,7 +280,7 @@ X10Context context = (X10Context) tc.context(); // v to I, where I is not a value interface (i.e., a function type) - if (ts.isValueType(fromType, context) && ts.isInterfaceType(toType) && ! ts.isValueType(toType, context)) { + if (ts.isStructType(fromType) && ts.isInterfaceType(toType)) { if (ts.isSubtypeWithValueInterfaces(fromType, toType, tc.context())) { return this.type(toType); } Modified: trunk/x10.compiler/src/x10/ast/X10Call_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10Call_c.java 2010-01-06 20:37:08 UTC (rev 12436) +++ trunk/x10.compiler/src/x10/ast/X10Call_c.java 2010-01-07 02:31:56 UTC (rev 12437) @@ -201,7 +201,7 @@ * @throws SemanticException */ - + SemanticException typeCheckNullTargetException = null; protected Node typeCheckNullTarget(ContextVisitor tc, List<Type> typeArgs, List<Type> argTypes, List<Expr> args) throws SemanticException { // if (typeArgs == null || typeArgs.size()==0) { @@ -244,7 +244,7 @@ TypeNode otn; if (typeArguments().size() > 0) { - otn = nf.AmbMacroTypeNode(position(), null, name(), typeArguments(), Collections.EMPTY_LIST); + otn = nf.AmbMacroTypeNode(position(), null, name(), typeArguments(), Collections.EMPTY_LIST); } else { otn = nf.X10AmbTypeNode(position(), null, name()); @@ -266,7 +266,11 @@ return neu; } } catch (SemanticException z) { + // TBD: Sometimes this is the real error. e.g. the only legitimate target is the + // struct call. We should record this exception and then come back and use this later + // if necessary. // This may have caused some errors to print out. + typeCheckNullTargetException = z; } // } // Otherwise try and find the usual null target method. Modified: trunk/x10.compiler/src/x10/ast/X10Cast_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10Cast_c.java 2010-01-06 20:37:08 UTC (rev 12436) +++ trunk/x10.compiler/src/x10/ast/X10Cast_c.java 2010-01-07 02:31:56 UTC (rev 12437) @@ -319,7 +319,7 @@ // v as Value // -> // (v as Box[Ref]).value as Value - if (ts.isReferenceOrInterfaceType(fromType, context) && (ts.isValueType(toType, context) || ts.isParameterType(toType))) { + if (ts.isReferenceOrInterfaceType(fromType, context) && (ts.isParameterType(toType))) { Expr boxed = expr; if (! ts.typeEquals(baseFrom, boxOfTo, context)) { boxed = check(nf.X10Cast(position(), nf.CanonicalTypeNode(position(), boxOfTo), expr, convert), tc); @@ -354,7 +354,7 @@ } // v to I, where I is not a value interface (i.e., a function type) - if ((ts.isValueType(fromType, context) || ts.isParameterType(fromType)) && ts.isInterfaceType(toType) && ! ts.isValueType(toType, context)) { + if (( ts.isParameterType(fromType)) && ts.isInterfaceType(toType)) { if (ts.isSubtypeWithValueInterfaces(fromType, toType, context)) { return new X10Boxed_c(position(), castType, expr, ConversionType.BOXING).type(toType); } Modified: trunk/x10.compiler/src/x10/ast/X10ClassDecl_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10ClassDecl_c.java 2010-01-06 20:37:08 UTC (rev 12436) +++ trunk/x10.compiler/src/x10/ast/X10ClassDecl_c.java 2010-01-07 02:31:56 UTC (rev 12437) @@ -21,6 +21,7 @@ import polyglot.ast.ClassDecl; import polyglot.ast.ClassDecl_c; import polyglot.ast.ClassMember; +import polyglot.ast.ConstructorCall; import polyglot.ast.ConstructorDecl; import polyglot.ast.Expr; import polyglot.ast.FlagsNode; @@ -965,8 +966,60 @@ protected ConstructorDecl createDefaultConstructor(ClassDef thisType, TypeSystem ts, NodeFactory nf) throws SemanticException { - ConstructorDecl ctor = super.createDefaultConstructor(thisType, ts, nf); - return ctor.name(nf.Id(ctor.name().position(), "this")); + Position pos = body().position().startOf(); + X10NodeFactory xnf = (X10NodeFactory) nf; + Block block = null; + + Ref<? extends Type> superType = thisType.superType(); + Stmt s1 = null; + if (superType != null) { + s1 = nf.SuperCall(pos, Collections.EMPTY_LIST); + } + + Stmt s2=null; + List<TypeParamNode> typeFormals = Collections.EMPTY_LIST; + List<Formal> formals = Collections.EMPTY_LIST; + DepParameterExpr guard = null; + TypeNode returnType = null; + + + if (! properties.isEmpty()) { + // build type parameters. + /* typeFormals = new ArrayList<TypeParamNode>(typeParameters.size()); + List<TypeNode> typeActuals = new ArrayList<TypeNode>(typeParameters.size()); + for (TypeParamNode tp : typeParameters) { + typeFormals.add(xnf.TypeParamNode(pos, tp.name())); + typeActuals.add(xnf.CanonicalTypeNode(pos, tp.type())); + }*/ + + formals = new ArrayList<Formal>(properties.size()); + List<Expr> actuals = new ArrayList<Expr>(properties.size()); + for (PropertyDecl pd: properties) { + Id name = pd.name(); + formals.add(xnf.Formal(pos, nf.FlagsNode(pos, Flags.FINAL), + (TypeNode) pd.type().copy(), name)); + actuals.add(xnf.Local(pos, name)); + } + + guard = classInvariant(); + s2 = xnf.AssignPropertyCall(pos, Collections.EMPTY_LIST, actuals); + // TODO: Check that this works. + returnType = xnf.CanonicalTypeNode(pos, thisType.asType()); + } + block = s2 == null ? (s1 == null ? nf.Block(pos) : nf.Block(pos, s1)) + : (s1 == null ? nf.Block(pos, s2) : nf.Block(pos, s1, s2)); + + ConstructorDecl cd = xnf.X10ConstructorDecl(pos, + nf.FlagsNode(pos, Flags.PUBLIC), + nf.Id(pos, "this"), + returnType, + typeFormals, + formals, + guard, + Collections.EMPTY_LIST, // throwTypes + block); + return cd; + } Modified: trunk/x10.compiler/src/x10/ast/X10Field_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10Field_c.java 2010-01-06 20:37:08 UTC (rev 12436) +++ trunk/x10.compiler/src/x10/ast/X10Field_c.java 2010-01-07 02:31:56 UTC (rev 12437) @@ -86,7 +86,9 @@ X10Type xtType = (X10Type) ((X10Field_c) n).target().type(); if (xtType.isProto()) { - throw new SemanticException("Cannot read fields of the proto value " + throw new SemanticException("Not permitted to read field " + + n + " of proto value " + target() +"." + + ((X10Field_c) n).target()); } } Modified: trunk/x10.compiler/src/x10/ast/X10NodeFactory.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10NodeFactory.java 2010-01-06 20:37:08 UTC (rev 12436) +++ trunk/x10.compiler/src/x10/ast/X10NodeFactory.java 2010-01-07 02:31:56 UTC (rev 12437) @@ -134,7 +134,8 @@ PlaceCast PlaceCast(Position pos, Expr place, Expr target); ConstructorDecl X10ConstructorDecl(Position pos, FlagsNode flags, Id name, - TypeNode returnType, List<TypeParamNode> typeParams, List<Formal> formals, DepParameterExpr guard, List<TypeNode> throwTypes, Block body); + TypeNode returnType, List<TypeParamNode> typeParams, List<Formal> formals, + DepParameterExpr guard, List<TypeNode> throwTypes, Block body); PropertyDecl PropertyDecl(Position pos, FlagsNode flags, TypeNode type, Id name); PropertyDecl PropertyDecl(Position pos, FlagsNode flags, TypeNode type, Id name, Expr init); Special Self(Position pos); Modified: trunk/x10.compiler/src/x10/types/X10PrimitiveType_c.java =================================================================== --- trunk/x10.compiler/src/x10/types/X10PrimitiveType_c.java 2010-01-06 20:37:08 UTC (rev 12436) +++ trunk/x10.compiler/src/x10/types/X10PrimitiveType_c.java 2010-01-07 02:31:56 UTC (rev 12437) @@ -63,10 +63,7 @@ return super.toString(); } - public boolean isValueType() { - X10TypeSystem ts = (X10TypeSystem) typeSystem(); - return ts.isValueType(this, (X10Context) ts.emptyContext()); - } + /** All primitive types are safe. */ public boolean safe() { return true; } Modified: trunk/x10.compiler/src/x10/types/X10TypeEnv_c.java =================================================================== --- trunk/x10.compiler/src/x10/types/X10TypeEnv_c.java 2010-01-06 20:37:08 UTC (rev 12436) +++ trunk/x10.compiler/src/x10/types/X10TypeEnv_c.java 2010-01-07 02:31:56 UTC (rev 12437) @@ -327,7 +327,7 @@ X10Context c = (X10Context) this.context; t = X10TypeMixin.baseType(t); if (t instanceof FunctionType) - return Kind.VALUE; + return Kind.INTERFACE; if (t instanceof ClassType) { ClassType ct = (ClassType) t; if (ct.isAnonymous()) { @@ -338,10 +338,8 @@ else throw new InternalCompilerError(t + " must have either a superclass or a single superinterface."); } - if (X10Flags.toX10Flags(ct.flags()).isValue()) - return Kind.VALUE; if (X10Flags.toX10Flags(ct.flags()).isInterface()) - return Kind.EITHER; + return Kind.INTERFACE; if (X10Flags.toX10Flags(ct.flags()).isStruct()) return Kind.STRUCT; @@ -358,8 +356,6 @@ ; else if (k2 == Kind.EITHER) ; - else if (k == Kind.EITHER && k2 == Kind.VALUE) - k = Kind.VALUE; else if (k == Kind.EITHER && k2 == Kind.STRUCT) k = Kind.STRUCT; else if (k == Kind.EITHER && k2 == Kind.REFERENCE) @@ -960,7 +956,7 @@ } if (allowValueInterfacesHere - || ts. isValueType(parentType, xcontext)) { + ) { if (isSubtype(x, parentType, ancestor, allowValueInterfaces)) { return true; } @@ -1129,7 +1125,8 @@ // return true; if (fromType instanceof NullType) { - return toType.isNull() || ! ts.isValueType(toType, (X10Context) context); + return toType.isNull() || ts.isReferenceOrInterfaceType(toType, (X10Context) context); + } // For now, can always cast to or from a parameter type. @@ -1155,10 +1152,10 @@ if (baseType1 != fromType || baseType2 != toType) return isCastValid(baseType1, baseType2); - if (ts.isValueType(baseType1, (X10Context) context) && ts.isReferenceType(baseType2, (X10Context) context)) + if (ts.isStructType(baseType1) && ts.isReferenceType(baseType2, (X10Context) context)) return false; - if (ts.isReferenceType(baseType1, (X10Context) context) && ts.isValueType(baseType2, (X10Context) context)) + if (ts.isReferenceType(baseType1, (X10Context) context) && ts.isStructType(baseType2)) return false; if (ts.isParameterType(baseType1) || ts.isParameterType(baseType2)) Modified: trunk/x10.compiler/src/x10/types/X10TypeSystem.java =================================================================== --- trunk/x10.compiler/src/x10/types/X10TypeSystem.java 2010-01-06 20:37:08 UTC (rev 12436) +++ trunk/x10.compiler/src/x10/types/X10TypeSystem.java 2010-01-07 02:31:56 UTC (rev 12437) @@ -233,8 +233,6 @@ boolean isPoint(Type me); boolean isPlace(Type me); - - boolean isValueType(Type me, X10Context context); boolean isStructType(Type me); Modified: trunk/x10.compiler/src/x10/types/X10TypeSystem_c.java =================================================================== --- trunk/x10.compiler/src/x10/types/X10TypeSystem_c.java 2010-01-06 20:37:08 UTC (rev 12436) +++ trunk/x10.compiler/src/x10/types/X10TypeSystem_c.java 2010-01-07 02:31:56 UTC (rev 12437) @@ -985,7 +985,7 @@ } static enum Kind { - NEITHER, EITHER, REFERENCE, VALUE, STRUCT + NEITHER, EITHER, REFERENCE, STRUCT, INTERFACE } public Kind kind(Type t, X10Context c) { @@ -999,7 +999,7 @@ public boolean isReferenceOrInterfaceType(Type t, X10Context c) { Kind kind = kind(t, c); - return kind == Kind.REFERENCE || kind == Kind.EITHER; + return kind == Kind.REFERENCE || kind == Kind.INTERFACE; // t = X10TypeMixin.baseType(t); // if (t instanceof ClosureType) // return false; @@ -1027,10 +1027,6 @@ // return isX10BaseSubtype(t, Ref()); } - public boolean isValueType(Type t, X10Context c) { - return false; - //return kind(t, c) == Kind.VALUE; - } public boolean isStructType(Type t) { return kind(t, null) == Kind.STRUCT; Modified: trunk/x10.runtime/src-cpp/x10/lang/IBox.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/IBox.h 2010-01-06 20:37:08 UTC (rev 12436) +++ trunk/x10.runtime/src-cpp/x10/lang/IBox.h 2010-01-07 02:31:56 UTC (rev 12437) @@ -37,6 +37,8 @@ * When that happens, all we need to provide is a */ template <class T> class IBox : public Reference { + protected: + IBox(){ } public: T value; Modified: trunk/x10.runtime/src-x10/x10/array/BaseArray.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/array/BaseArray.x10 2010-01-06 20:37:08 UTC (rev 12436) +++ trunk/x10.runtime/src-x10/x10/array/BaseArray.x10 2010-01-07 02:31:56 UTC (rev 12437) @@ -213,7 +213,7 @@ // scatter val ps:ValRail[Place] = dist.places(); - val results = Rail.make[T](ps.length, (p:nat) => unit); + val results = Rail.make[T](ps.length, (p:Int) => unit); val r = 0..(ps.length-1); @@ -240,7 +240,7 @@ // scatter val ps = dist.places(); - val results = ValRail.make[Future[T]](ps.length, (p:nat) => { + val results = ValRail.make[Future[T]](ps.length, (p:Int) => { future(ps(p)) { var result: T = unit; val a = (this | here) as Array[T](rank); @@ -302,8 +302,8 @@ protected proto global def layout(r: Region): RectLayout { if (r.isEmpty()) { // XXX EmptyLayout class? - val min = ValRail.make[int](r.rank, (nat)=>0); - val max = ValRail.make[int](r.rank, (nat)=>-1); + val min = ValRail.make[int](r.rank, (Int)=>0); + val max = ValRail.make[int](r.rank, (Int)=>-1); return new RectLayout(min, max); } else { return new RectLayout(r.min(), r.max()); Modified: trunk/x10.runtime/src-x10/x10/array/BaseDist.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/array/BaseDist.x10 2010-01-06 20:37:08 UTC (rev 12436) +++ trunk/x10.runtime/src-x10/x10/array/BaseDist.x10 2010-01-07 02:31:56 UTC (rev 12437) @@ -21,10 +21,10 @@ public class BaseDist extends Dist /*implements Map[Place,Region]*/ { // XTENLANG-49 - static type PolyRegion(rank:nat) = PolyRegion{self.rank==rank}; - static type PolyRegionListBuilder(rank:nat) = PolyRegionListBuilder{self.rank==rank}; - static type PolyRow(rank:nat) = PolyRow{self.rank==rank}; - static type PolyMat(rank:nat) = PolyMat{self.rank==rank}; + static type PolyRegion(rank:Int) = PolyRegion{self.rank==rank}; + static type PolyRegionListBuilder(rank:Int) = PolyRegionListBuilder{self.rank==rank}; + static type PolyRow(rank:Int) = PolyRow{self.rank==rank}; + static type PolyMat(rank:Int) = PolyMat{self.rank==rank}; // // factories - place is all applicable places @@ -39,7 +39,7 @@ public static def makeUnique1(ps: Rail[Place]): Dist(1) { // XTENLANG-4 // regions - val init = (i:nat) => Region.makeRectangular(i, i); + val init = (i:Int) => Region.makeRectangular(i, i); val regions = ValRail.make[Region](ps.length, init); // overall region @@ -57,7 +57,7 @@ val min = b.min()(axis); val max = b.max()(axis); - val init = (i:nat) => Region.makeEmpty(r.rank); + val init = (i:Int) => Region.makeEmpty(r.rank); var regions:Rail[Region]! = Rail.make[Region](Place.MAX_PLACES, init); for (var i: int = min, p: int = 0; i<=max; i+=blockSize, p++) { @@ -146,7 +146,7 @@ val ps = this.places; // regions - val init = (i:nat) => (this.regions(i) as Region(rank)).intersection(r); + val init = (i:Int) => (this.regions(i) as Region(rank)).intersection(r); val rs = ValRail.make[Region](this.regions.length, init); return new BaseDist(r, ps, rs); @@ -154,7 +154,7 @@ public global def restriction(p: Place): Dist(rank) { val ps = [p]; - val rs = ValRail.make[Region](1, (nat)=>get(p)); + val rs = ValRail.make[Region](1, (Int)=>get(p)); return new BaseDist(region.intersection(rs(0) as Region(rank)), ps, rs) as Dist(rank); } @@ -174,7 +174,7 @@ val ps = this.places; // regions - val init: (nat) => Region{self.rank==this.rank} = (i:nat):Region{self.rank==this.rank} => { + val init: (Int) => Region{self.rank==this.rank} = (i:Int):Region{self.rank==this.rank} => { val r1 = this.regions(i) as Region(rank); val r2 = that.get(this.places(i)) as Region(rank); return r1.intersection(r2); @@ -196,7 +196,7 @@ val ps = this.places; // regions - val init: (nat)=>Region(rank) = (i:nat): Region(rank) => { + val init: (Int)=>Region(rank) = (i:Int): Region(rank) => { val r1 = this.regions(i) as Region(rank); val r2 = that.get(this.places(i)) as Region(rank); return r1.difference(r2); @@ -217,7 +217,7 @@ val ps = Place.places; // regions - val init = (i:nat): Region(rank) => { + val init = (i:Int): Region(rank) => { val p = ps(i); val r = this.get(p) as Region(rank); // XXXX return r.difference(that.region).union(that.get(p)); @@ -233,7 +233,7 @@ val ps = Place.places; // regions - val init = (i:nat): Region(rank) => { + val init = (i:Int): Region(rank) => { val r1 = that.get(ps(i)) as Region(rank); // XXXX val r2 = this.get(ps(i)) as Region(rank); // XXXX return r2.union(r1); @@ -328,10 +328,10 @@ // compute the map val empty = Region.makeEmpty(rank); - val regionMap = Rail.make[Region](Place.MAX_PLACES, (nat)=>empty); + val regionMap = Rail.make[Region](Place.MAX_PLACES, (Int)=>empty); for (var i: int = 0; i<this.places.length; i++) regionMap(this.places(i).id) = this.regions(i); - this.regionMap = ValRail.make[Region](regionMap.length, (i:nat) => regionMap(i)); + this.regionMap = ValRail.make[Region](regionMap.length, (i:Int) => regionMap(i)); } Modified: trunk/x10.runtime/src-x10/x10/array/BaseRegion.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/array/BaseRegion.x10 2010-01-06 20:37:08 UTC (rev 12436) +++ trunk/x10.runtime/src-x10/x10/array/BaseRegion.x10 2010-01-07 02:31:56 UTC (rev 12437) @@ -19,10 +19,10 @@ abstract public class BaseRegion extends Region { // XTENLANG-49 - static type PolyRegion(rank:nat) = PolyRegion{self.rank==rank}; - static type PolyRegionListBuilder(rank:nat) = PolyRegionListBuilder{self.rank==rank}; - static type PolyRow(rank:nat) = PolyRow{self.rank==rank}; - static type PolyMat(rank:nat) = PolyMat{self.rank==rank}; + static type PolyRegion(rank:Int) = PolyRegion{self.rank==rank}; + static type PolyRegionListBuilder(rank:Int) = PolyRegionListBuilder{self.rank==rank}; + static type PolyRow(rank:Int) = PolyRow{self.rank==rank}; + static type PolyMat(rank:Int) = PolyMat{self.rank==rank}; static type BaseRegion(rank:int) = BaseRegion{self.rank==rank}; Modified: trunk/x10.runtime/src-x10/x10/array/Mat.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/array/Mat.x10 2010-01-06 20:37:08 UTC (rev 12436) +++ trunk/x10.runtime/src-x10/x10/array/Mat.x10 2010-01-07 02:31:56 UTC (rev 12437) @@ -5,17 +5,17 @@ import x10.io.Printer; -public abstract class Mat[+T](rows:nat, cols:nat){T <: Row} - implements (nat)=>T, Iterable[T] { +public abstract class Mat[+T](rows:Int, cols:Int){T <: Row} + implements (Int)=>T, Iterable[T] { private global val mat: ValRail[T]; - public def this(rows: nat, cols: nat, mat:ValRail[T]) { + public def this(rows: Int, cols: Int, mat:ValRail[T]) { property(rows, cols); this.mat = mat; } - public global def apply(i: nat) = mat(i); + public global def apply(i: Int) = mat(i); public global def iterator() = mat.iterator(); Modified: trunk/x10.runtime/src-x10/x10/array/MatBuilder.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/array/MatBuilder.x10 2010-01-06 20:37:08 UTC (rev 12436) +++ trunk/x10.runtime/src-x10/x10/array/MatBuilder.x10 2010-01-07 02:31:56 UTC (rev 12437) @@ -10,12 +10,12 @@ protected val mat: ArrayList[Row]!; protected val cols: int; - public def this(cols: nat) { + public def this(cols: Int) { this.cols = cols; mat = new ArrayList[Row](); } - public def this(rows: nat, cols: nat) { + public def this(rows: Int, cols: Int) { this.cols = cols; val m = new ArrayList[Row](rows); mat = m; @@ -26,7 +26,7 @@ mat.add(row); } - public safe def add(a:(nat)=>int) { + public safe def add(a:(Int)=>int) { mat.add(new VarRow(cols, a)); } @@ -35,19 +35,19 @@ mat(i)(j) = v; } - public safe def setDiagonal(i:nat, j:nat, n:nat, v:(nat)=>int) { + public safe def setDiagonal(i:Int, j:Int, n:Int, v:(Int)=>int) { need(i+n); for (var k:int=0; k<n; k++) mat(i+k)(j+k) = v(k); } - public safe def setColumn(i:nat, j:nat, n:nat, v:(nat)=>int) { + public safe def setColumn(i:Int, j:Int, n:Int, v:(Int)=>int) { need(i+n); for (var k:int=0; k<n; k++) mat(i+k)(j) = v(k); } - public safe def setRow(i:nat, j:nat, n:nat, v:(nat)=>int) { + public safe def setRow(i:Int, j:Int, n:Int, v:(Int)=>int) { need(i+1); for (var k:int=0; k<n; k++) mat(i)(j+k) = v(k); @@ -60,7 +60,7 @@ } public safe def toXformMat() { - return new XformMat(mat.size(), cols, (i:nat,j:nat)=>mat(i)(j)); + return new XformMat(mat.size(), cols, (i:Int,j:Int)=>mat(i)(j)); } } Modified: trunk/x10.runtime/src-x10/x10/array/PolyMat.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/array/PolyMat.x10 2010-01-06 20:37:08 UTC (rev 12436) +++ trunk/x10.runtime/src-x10/x10/array/PolyMat.x10 2010-01-07 02:31:56 UTC (rev 12437) @@ -20,8 +20,8 @@ public class PolyMat(rank: int) extends Mat[PolyRow] { - static type PolyMat(rank:nat) = PolyMat{self.rank==rank}; - static type PolyMatBuilder(rank:nat) = PolyMatBuilder{self.rank==rank}; + static type PolyMat(rank:Int) = PolyMat{self.rank==rank}; + static type PolyMatBuilder(rank:Int) = PolyMatBuilder{self.rank==rank}; // // value @@ -34,8 +34,8 @@ * Low-level constructor. For greater convenience use PolyMatBuilder. */ - public def this(rows: nat, cols: nat, init: (i:nat,j:nat)=>int, isSimplified:boolean) { - super(rows, cols, ValRail.make[PolyRow](rows, (i:nat)=>new PolyRow(cols, (j:nat)=>init(i,j)))); + public def this(rows: Int, cols: Int, init: (i:Int,j:Int)=>int, isSimplified:boolean) { + super(rows, cols, ValRail.make[PolyRow](rows, (i:Int)=>new PolyRow(cols, (j:Int)=>init(i,j)))); property(cols-1); this.isSimplified = isSimplified; } @@ -82,7 +82,7 @@ return this; val pmb = new PolyMatBuilder(rank); - var removed:Rail[boolean]! = Rail.make[boolean](rows, (nat)=>false); // XTENLANG-39 workaround + var removed:Rail[boolean]! = Rail.make[boolean](rows, (Int)=>false); // XTENLANG-39 workaround for (var i: int = 0; i<rows; i++) { val r = this(i); @@ -193,10 +193,10 @@ } global def rectMin(): ValRail[int] - = ValRail.make[int](rank, (i:nat)=>rectMin(i)); + = ValRail.make[int](rank, (i:Int)=>rectMin(i)); global def rectMax(): ValRail[int] - = ValRail.make[int](rank, (i:nat)=>rectMax(i)); + = ValRail.make[int](rank, (i:Int)=>rectMax(i)); global def isZeroBased(): boolean { if (!isRect()) @@ -251,7 +251,7 @@ */ public global operator this * (that: XformMat): PolyMat { - return new PolyMat(this.rows, that.cols, (i:nat,j:nat) => { + return new PolyMat(this.rows, that.cols, (i:Int,j:Int) => { var sum:int = 0; for (var k:int=0; k<this.cols; k++) sum += this(i)(k)*that(k)(j); Modified: trunk/x10.runtime/src-x10/x10/array/PolyMatBuilder.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/array/PolyMatBuilder.x10 2010-01-06 20:37:08 UTC (rev 12436) +++ trunk/x10.runtime/src-x10/x10/array/PolyMatBuilder.x10 2010-01-07 02:31:56 UTC (rev 12437) @@ -17,8 +17,8 @@ public class PolyMatBuilder(rank: int) extends MatBuilder { // XTENLANG-49 - static type PolyMat(rank:nat) = PolyMat{self.rank==rank}; - static type PolyMatBuilder(rank:nat) = PolyMatBuilder{self.rank==rank}; + static type PolyMat(rank:Int) = PolyMat{self.rank==rank}; + static type PolyMatBuilder(rank:Int) = PolyMatBuilder{self.rank==rank}; /** @@ -37,7 +37,7 @@ public def toSortedPolyMat(isSimplified:boolean): PolyMat(rank) { mat.sort(PolyRow.compare.(Row,Row)); - val result = new PolyMat(mat.size(), rank+1, (i:nat,j:nat)=>mat(i)(j), isSimplified); + val result = new PolyMat(mat.size(), rank+1, (i:Int,j:Int)=>mat(i)(j), isSimplified); return result as PolyMat(rank); // XXXX } @@ -69,6 +69,6 @@ coeff = coeff >> 2; } as(rank) = op==LE? -k : k; - add((i:nat) => as(i)); + add((i:Int) => as(i)); } } Modified: trunk/x10.runtime/src-x10/x10/array/PolyRegion.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/array/PolyRegion.x10 2010-01-06 20:37:08 UTC (rev 12436) +++ trunk/x10.runtime/src-x10/x10/array/PolyRegion.x10 2010-01-07 02:31:56 UTC (rev 12437) @@ -20,11 +20,11 @@ public class PolyRegion extends BaseRegion { // XTENLANG-49 - static type PolyRegion(rank:nat) = PolyRegion{self.rank==rank}; - static type PolyRegionListBuilder(rank:nat) = PolyRegionListBuilder{self.rank==rank}; - static type PolyRow(rank:nat) = PolyRow{self.rank==rank}; - static type PolyMat(rank:nat) = PolyMat{self.rank==rank}; - static type UnionRegion(rank:nat) = UnionRegion{self.rank==rank}; + static type PolyRegion(rank:Int) = PolyRegion{self.rank==rank}; + static type PolyRegionListBuilder(rank:Int) = PolyRegionListBuilder{self.rank==rank}; + static type PolyRow(rank:Int) = PolyRow{self.rank==rank}; + static type PolyMat(rank:Int) = PolyMat{self.rank==rank}; + static type UnionRegion(rank:Int) = UnionRegion{self.rank==rank}; // // value Modified: trunk/x10.runtime/src-x10/x10/array/PolyRegionListBuilder.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/array/PolyRegionListBuilder.x10 2010-01-06 20:37:08 UTC (rev 12436) +++ trunk/x10.runtime/src-x10/x10/array/PolyRegionListBuilder.x10 2010-01-07 02:31:56 UTC (rev 12437) @@ -16,11 +16,11 @@ public class PolyRegionListBuilder(rank: int) extends ArrayList[PolyRegion{self.rank==this.rank}] { // XTENLANG-49 - static type PolyRegion(rank:nat) = PolyRegion{self.rank==rank}; - static type PolyRegionListBuilder(rank:nat) = PolyRegionListBuilder{self.rank==rank}; - static type PolyRow(rank:nat) = PolyRow{self.rank==rank}; - static type PolyMat(rank:nat) = PolyMat{self.rank==rank}; - static type UnionRegion(rank:nat) = UnionRegion{self.rank==rank}; + static type PolyRegion(rank:Int) = PolyRegion{self.rank==rank}; + static type PolyRegionListBuilder(rank:Int) = PolyRegionListBuilder{self.rank==rank}; + static type PolyRow(rank:Int) = PolyRow{self.rank==rank}; + static type PolyMat(rank:Int) = PolyMat{self.rank==rank}; + static type UnionRegion(rank:Int) = UnionRegion{self.rank==rank}; public def this(rank: int): PolyRegionListBuilder(rank) { super(); // XTENLANG-31 Modified: trunk/x10.runtime/src-x10/x10/array/PolyRow.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/array/PolyRow.x10 2010-01-06 20:37:08 UTC (rev 12436) +++ trunk/x10.runtime/src-x10/x10/array/PolyRow.x10 2010-01-07 02:31:56 UTC (rev 12437) @@ -19,12 +19,12 @@ * @author bdlucas */ -public class PolyRow(rank:nat) extends ValRow { +public class PolyRow(rank:Int) extends ValRow { - static type PolyRegion(rank:nat) = PolyRegion{self.rank==rank}; - static type PolyRegionListBuilder(rank:nat) = PolyRegionListBuilder{self.rank==rank}; - static type PolyRow(rank:nat) = PolyRow{self.rank==rank}; - static type PolyMat(rank:nat) = PolyMat{self.rank==rank}; + static type PolyRegion(rank:Int) = PolyRegion{self.rank==rank}; + static type PolyRegionListBuilder(rank:Int) = PolyRegionListBuilder{self.rank==rank}; + static type PolyRow(rank:Int) = PolyRow{self.rank==rank}; + static type PolyMat(rank:Int) = PolyMat{self.rank==rank}; // // @@ -39,11 +39,11 @@ } def this(p:Point, k:int) { - super(p.rank+1, (i:nat) => i<p.rank? p(i) : k); + super(p.rank+1, (i:Int) => i<p.rank? p(i) : k); property(p.rank); } - def this(cols:int, init: (i:nat)=>int) { + def this(cols:int, init: (i:Int)=>int) { super(cols, init); property(cols-1); } @@ -122,7 +122,7 @@ */ global def complement(): PolyRow { - val init = (i:nat) => i<rank? -this(i) : -this(rank)+1; + val init = (i:Int) => i<rank? -this(i) : -this(rank)+1; val as = ValRail.make[int](rank+1, init); return new PolyRow(as); } Modified: trunk/x10.runtime/src-x10/x10/array/PolyScanner.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/array/PolyScanner.x10 2010-01-06 20:37:08 UTC (rev 12436) +++ trunk/x10.runtime/src-x10/x10/array/PolyScanner.x10 2010-01-07 02:31:56 UTC (rev 12437) @@ -389,7 +389,7 @@ finish { for (var i:int=min; i<=max; i++) { q(r) = i; - val qq = Rail.make[int](q.length, (i:nat)=>q(i)); + val qq = Rail.make[int](q.length, (i:Int)=>q(i)); async { //Console.OUT.println("async{"); loop(body, p, qq, r+1); @@ -429,7 +429,7 @@ // XXX makes simplifying assumptions about conformance of regions // - make this more general!!! public operator this || (that:PolyScanner!) { - val x = ValRail.make(this.X1.length + that.X1.length, (i:nat) => + val x = ValRail.make(this.X1.length + that.X1.length, (i:Int) => i<this.X1.length? this.X1(i) : that.X1(i-this.X1.length)); return new PolyScanner(this.C, x); } Modified: trunk/x10.runtime/src-x10/x10/array/RectLayout.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/array/RectLayout.x10 2010-01-06 20:37:08 UTC (rev 12436) +++ trunk/x10.runtime/src-x10/x10/array/RectLayout.x10 2010-01-07 02:31:56 UTC (rev 12437) @@ -39,7 +39,7 @@ this.rank = r; this.min = min; - val d0 = ValRail.make[int](r, (i:nat) => max(i) - min(i) + 1); + val d0 = ValRail.make[int](r, (i:Int) => max(i) - min(i) + 1); delta = d0; var size: int = 1; Modified: trunk/x10.runtime/src-x10/x10/array/RectRegion.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/array/RectRegion.x10 2010-01-06 20:37:08 UTC (rev 12436) +++ trunk/x10.runtime/src-x10/x10/array/RectRegion.x10 2010-01-07 02:31:56 UTC (rev 12437) @@ -140,7 +140,7 @@ rank = r.rank; min = r.mat.rectMin(); max = r.mat.rectMax(); - val xx = Rail.make[int](r.rank, (i:nat)=>r.mat.rectMin()(i)); + val xx = Rail.make[int](r.rank, (i:Int)=>r.mat.rectMin()(i)); xx(r.rank-1)--; x = xx; } Modified: trunk/x10.runtime/src-x10/x10/array/Row.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/array/Row.x10 2010-01-06 20:37:08 UTC (rev 12436) +++ trunk/x10.runtime/src-x10/x10/array/Row.x10 2010-01-07 02:31:56 UTC (rev 12437) @@ -7,12 +7,12 @@ import x10.io.StringWriter; -abstract class Row(cols:nat) implements (nat)=>int { +abstract class Row(cols:Int) implements (Int)=>int { - public abstract global def apply(i:nat): int; - public abstract global def set(v:int, i:nat): int; + public abstract global def apply(i:Int): int; + public abstract global def set(v:int, i:Int): int; - protected def this(cols:nat) = property(cols); + protected def this(cols:Int) = property(cols); /** * print a row in both matrix and equation form Modified: trunk/x10.runtime/src-x10/x10/array/UnionRegion.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/array/UnionRegion.x10 2010-01-06 20:37:08 UTC (rev 12436) +++ trunk/x10.runtime/src-x10/x10/array/UnionRegion.x10 2010-01-07 02:31:56 UTC (rev 12437) @@ -17,11 +17,11 @@ public class UnionRegion extends BaseRegion { // XTENLANG-49 - static type PolyRegion(rank:nat) = PolyRegion{self.rank==rank}; - static type PolyRegionListBuilder(rank:nat) = PolyRegionListBuilder{self.rank==rank}; - static type PolyRow(rank:nat) = PolyRow{self.rank==rank}; - static type PolyMat(rank:nat) = PolyMat{self.rank==rank}; - static type UnionRegion(rank:nat) = UnionRegion{self.rank==rank}; + static type PolyRegion(rank:Int) = PolyRegion{self.rank==rank}; + static type PolyRegionListBuilder(rank:Int) = PolyRegionListBuilder{self.rank==rank}; + static type PolyRow(rank:Int) = PolyRow{self.rank==rank}; + static type PolyMat(rank:Int) = PolyMat{self.rank==rank}; + static type UnionRegion(rank:Int) = UnionRegion{self.rank==rank}; // Modified: trunk/x10.runtime/src-x10/x10/array/ValRow.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/array/ValRow.x10 2010-01-06 20:37:08 UTC (rev 12436) +++ trunk/x10.runtime/src-x10/x10/array/ValRow.x10 2010-01-07 02:31:56 UTC (rev 12437) @@ -13,17 +13,17 @@ } public def this(row: Rail[int]!) { - this(row.length, (i:nat) => row(i)); + this(row.length, (i:Int) => row(i)); } - public def this(cols: nat, init: (nat)=>int) { + public def this(cols: Int, init: (Int)=>int) { super(cols); row = ValRail.make[int](cols, init); } - public safe global def apply(i:nat) = row(i); + public safe global def apply(i:Int) = row(i); - public safe global def set(v:int, i:nat):int { + public safe global def set(v:int, i:Int):int { throw new IllegalOperationException("ValRow.set"); } } Modified: trunk/x10.runtime/src-x10/x10/array/VarMat.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/array/VarMat.x10 2010-01-06 20:37:08 UTC (rev 12436) +++ trunk/x10.runtime/src-x10/x10/array/VarMat.x10 2010-01-07 02:31:56 UTC (rev 12437) @@ -5,17 +5,17 @@ final class VarMat extends Mat[VarRow] { - public def this(cols: nat, mat: ValRail[VarRow]) + public def this(cols: Int, mat: ValRail[VarRow]) = super(mat.length, cols, mat); - public def this(rows: nat, cols: nat, init:(nat)=>VarRow) + public def this(rows: Int, cols: Int, init:(Int)=>VarRow) = super(rows, cols, ValRail.make[VarRow](rows, init)); - public def this(rows: nat, cols: nat, init: (i:nat,j:nat)=>int) - = this(rows, cols, (i:nat)=>new VarRow(cols, (j:nat)=>init(i,j))); + public def this(rows: Int, cols: Int, init: (i:Int,j:Int)=>int) + = this(rows, cols, (i:Int)=>new VarRow(cols, (j:Int)=>init(i,j))); - public def this(rows: nat, cols: nat) - = this(rows, cols, (nat)=>new VarRow(cols)); + public def this(rows: Int, cols: Int) + = this(rows, cols, (Int)=>new VarRow(cols)); } Modified: trunk/x10.runtime/src-x10/x10/array/VarRow.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/array/VarRow.x10 2010-01-06 20:37:08 UTC (rev 12436) +++ trunk/x10.runtime/src-x10/x10/array/VarRow.x10 2010-01-07 02:31:56 UTC (rev 12437) @@ -7,18 +7,18 @@ private global val row:Rail[int]!; - public def this(cols: nat, init: (nat)=>int) { + public def this(cols: Int, init: (Int)=>int) { super(cols); row = Rail.make[int](cols, init); } - public def this(cols: nat) { + public def this(cols: Int) { super(cols); row = Rail.make[int](cols); } global def row() = row as Rail[int]!; - public safe global def apply(i:nat) = row()(i); + public safe global def apply(i:Int) = row()(i); - public safe global def set(v:int, i:nat) = (row()(i) = v); + public safe global def set(v:int, i:Int) = (row()(i) = v); } Modified: trunk/x10.runtime/src-x10/x10/array/Xform.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/array/Xform.x10 2010-01-06 20:37:08 UTC (rev 12436) +++ trunk/x10.runtime/src-x10/x10/array/Xform.x10 2010-01-07 02:31:56 UTC (rev 12437) @@ -5,7 +5,7 @@ public abstract class Xform { - public static def transpose(rank:nat, i:nat, j:nat) { + public static def transpose(rank:Int, i:Int, j:Int) { // reverse transform val t = new MatBuilder(rank+1, rank+1); @@ -32,15 +32,15 @@ // reverse transform val t = new MatBuilder(rank+1, 2*rank+1); t.setDiagonal(0, 0, sizes.length, sizes); - t.setDiagonal(0, rank, rank, (nat)=>1); + t.setDiagonal(0, rank, rank, (Int)=>1); t(rank, 2*rank) = 1; val T = t.toXformMat(); // extra constraints val e = new PolyMatBuilder(2*rank); - e.setDiagonal(0, rank, rank, (nat)=>-1); - e.setDiagonal(rank, rank, rank, (nat)=>1); - e.setColumn(rank, 2*rank, rank, (i:nat)=>1-sizes(i)); + e.setDiagonal(0, rank, rank, (Int)=>-1); + e.setDiagonal(rank, rank, rank, (Int)=>1); + e.setColumn(rank, 2*rank, rank, (i:Int)=>1-sizes(i)); val E = e.toSortedPolyMat(true); return new PolyXform(E, T); @@ -52,8 +52,8 @@ // reverse transform val t = new MatBuilder(rank+1, rank+1); - t.setDiagonal(0, 0, rank+1, (nat)=>1); - t.setColumn(0, axis, rank, (i:nat)=>with(i)); + t.setDiagonal(0, 0, rank+1, (Int)=>1); + t.setColumn(0, axis, rank, (i:Int)=>with(i)); val T = t.toXformMat(); // no extra constraints Modified: trunk/x10.runtime/src-x10/x10/array/XformMat.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/array/XformMat.x10 2010-01-06 20:37:08 UTC (rev 12436) +++ trunk/x10.runtime/src-x10/x10/array/XformMat.x10 2010-01-07 02:31:56 UTC (rev 12437) @@ -5,14 +5,14 @@ public final class XformMat extends Mat[ValRow] { - public def this(cols: nat, mat: ValRail[ValRow]) + public def this(cols: Int, mat: ValRail[ValRow]) = super(mat.length, cols, mat); - public def this(rows: nat, cols: nat, init:(nat)=>ValRow) + public def this(rows: Int, cols: Int, init:(Int)=>ValRow) = super(rows, cols, ValRail.make[ValRow](rows, init)); - public def this(rows: nat, cols: nat, init: (i:nat,j:nat)=>int) - = this(rows, cols, (i:nat)=>new ValRow(cols, (j:nat)=>init(i,j))); + public def this(rows: Int, cols: Int, init: (i:Int,j:Int)=>int) + = this(rows, cols, (i:Int)=>new ValRow(cols, (j:Int)=>init(i,j))); /** @@ -20,7 +20,7 @@ */ public global operator this * (that: XformMat): XformMat { - return new XformMat(this.rows, that.cols, (i:nat,j:nat) => { + return new XformMat(this.rows, that.cols, (i:Int,j:Int) => { var sum:int = 0; for (var k:int=0; k<this.cols; k++) sum += this(i)(k)*that(k)(j); @@ -34,7 +34,7 @@ */ public global operator this * (p:Point):Point { - return Point.make(rows-1, (i:nat)=> { + return Point.make(rows-1, (i:Int)=> { var sum:int = this(i)(p.rank); for (var j:int=0; j<p.rank; j++) sum += p(j)*this(i)(j); @@ -47,7 +47,7 @@ * Identity matrix. */ - public static def identity(rank:int) = new XformMat(rank+1, rank+1, (i:nat,j:nat)=>(i==j?1:0)); + public static def identity(rank:int) = new XformMat(rank+1, rank+1, (i:Int,j:Int)=>(i==j?1:0)); } Modified: trunk/x10.runtime/src-x10/x10/lang/Array.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Array.x10 2010-01-06 20:37:08 UTC (rev 12436) +++ trunk/x10.runtime/src-x10/x10/lang/Array.x10 2010-01-07 02:31:56 UTC (rev 12437) @@ -77,7 +77,7 @@ public static def make[T](rail: ValRail[T]): Array[T]{rank==1&&rect&&zeroBased} = BaseArray.makeVar1[T](rail); - public static def make[T](size: nat, init: (Point(1))=>T): Array[T](1) + public static def make[T](size: Int, init: (Point(1))=>T): Array[T](1) = makeVar[T](0..size-1, init) as Array[T](1); public static def makeFast[T](region: Region) Modified: trunk/x10.runtime/src-x10/x10/lang/Dist.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Dist.x10 2010-01-06 20:37:08 UTC (rev 12436) +++ trunk/x10.runtime/src-x10/x10/lang/Dist.x10 2010-01-07 02:31:56 UTC (rev 12437) @@ -28,7 +28,7 @@ , Iterable[Point(region.rank)] { - property rank: nat = region.rank; + property rank: Int = region.rank; property rect: boolean = region.rect; property zeroBased: boolean = region.zeroBased; property rail: boolean = region.rail; Modified: trunk/x10.runtime/src-x10/x10/lang/Future.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Future.x10 2010-01-06 20:37:08 UTC (rev 12436) +++ trunk/x10.runtime/src-x10/x10/lang/Future.x10 2010-01-07 02:31:56 UTC (rev 12437) @@ -13,7 +13,7 @@ * @author Christoph von Praun * @author tardieu */ -public abstract class Future[T] implements ()=>T { +public abstract class Future[+T] implements ()=>T { /** * Wait for the completion of this activity and return the computed value. */ Modified: trunk/x10.runtime/src-x10/x10/lang/Place.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Place.x10 2010-01-06 20:37:08 UTC (rev 12436) +++ trunk/x10.runtime/src-x10/x10/lang/Place.x10 2010-01-07 02:31:56 UTC (rev 12437) @@ -27,7 +27,7 @@ public const NUM_ACCELS = NativeRuntime.MAX_PLACES - NativeRuntime.MAX_HOSTS; public const FIRST_PLACE: Place(0) = places(0) as Place(0); - public def this(id: Int):Place{self.id==id} { property(id); } + public def this(id: Int):Place(id) { property(id); } public static def place(id: Int): Place(id) = places(id) as Place(id); public def next(): Place = next(1); Modified: trunk/x10.runtime/src-x10/x10/lang/Point.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Point.x10 2010-01-06 20:37:08 UTC (rev 12436) +++ trunk/x10.runtime/src-x10/x10/lang/Point.x10 2010-01-07 02:31:56 UTC (rev 12437) @@ -9,25 +9,25 @@ /** * The type <code>Point(rank)</code> represents a point in a - * rank-dimensional space. The coordinates of a point <code>p</code> + * rank-dimensional space. The coordiIntes of a point <code>p</code> * may be accessed individually (with zero-based indexing) using * <code>p(i)</code> because <code>Point</code> implements - * <code>(nat)=>int</code>. The coordinates may also be accessed as a + * <code>(Int)=>int</code>. The coordiIntes may also be accessed as a * Rail[int]. Point arithmetic is supported. * * @author bdlucas * @author vj */ -final public class Point(rank: nat) implements (nat) => Int { +final public class Point(rank: Int) implements (Int) => Int { /** - * Returns the value of the ith coordinate. + * Returns the value of the ith coordiInte. */ - public global safe def apply(i: nat): Int = coords(i); + public global safe def apply(i: Int): Int = coords(i); /** - * Returns the coordinates as a <code>ValRail[Int]</code>. + * Returns the coordiIntes as a <code>ValRail[Int]</code>. */ public global safe def coords(): ValRail[int] = coords; @@ -41,14 +41,14 @@ * Constructs a Point from a Rail[int] */ public static global safe def make(cs: Rail[int]!): Point(cs.length) { - val a = ValRail.make[int](cs.length, (i:nat)=>cs(i)); + val a = ValRail.make[int](cs.length, (i:Int)=>cs(i)); return make(a); } /** * Returns a <code>Point p</code> of rank <code>rank</code> with <code>p(i)=init(i)</code>. */ - public static global safe def make(rank:nat, init:(i:nat)=>int):Point(rank) { + public static global safe def make(rank:Int, init:(i:Int)=>int):Point(rank) { val a = ValRail.make[int](rank, init); return make(a); } @@ -78,65 +78,65 @@ /** The point <code>-p</code> is the same as <code>p</code> with each index negated. */ public global safe operator - this: Point(rank) - = Point.make(rank, (i:nat)=>-this.coords(i)); + = Point.make(rank, (i:Int)=>-this.coords(i)); - /** The ith coordinate of point <code>p+q</code> is <code>p(i)+q(i)</code>. + /** The ith coordiInte of point <code>p+q</code> is <code>p(i)+q(i)</code>. */ public global safe operator this + (that: Point(rank)): Point(rank) = Point.make(rank, (i:Int)=> this.coords(i) + that.coords(i)); - /** The ith coordinate of point <code>p-q</code> is <code>p(i)-q(i)</code>. + /** The ith coordiInte of point <code>p-q</code> is <code>p(i)-q(i)</code>. */ public global safe operator this - (that: Point(rank)): Point(rank) = Point.make(rank, (i:Int)=> this.coords(i) - that.coords(i)); - /** The ith coordinate of point <code>p*q</code> is <code>p(i)*q(i)</code>. + /** The ith coordiInte of point <code>p*q</code> is <code>p(i)*q(i)</code>. */ public global safe operator this * (that: Point(rank)): Point(rank) = Point.make(rank, (i:Int)=> this.coords(i) * that.coords(i)); - /** The ith coordinate of point <code>p/q</code> is <code>p(i)/q(i)</code>. + /** The ith coordiInte of point <code>p/q</code> is <code>p(i)/q(i)</code>. */ public global safe operator this / (that: Point(rank)): Point(rank) = Point.make(rank, (i:Int)=> this.coords(i) / that.coords(i)); - /** The ith coordinate of point <code>p+c</code> is <code>p(i)+c</code>. + /** The ith coordiInte of point <code>p+c</code> is <code>p(i)+c</code>. */ public global safe operator this + (c: int): Point(rank) = Point.make(rank, (i:Int) => this.coords(i) + c); - /** The ith coordinate of point <code>p-c</code> is <code>p(i)-c</code>. + /** The ith coordiInte of point <code>p-c</code> is <code>p(i)-c</code>. */ public global safe operator this - (c: int): Point(rank) = Point.make(rank, (i:Int) => this.coords(i) - c); - /** The ith coordinate of point <code>p*c</code> is <code>p(i)*c</code>. + /** The ith coordiInte of point <code>p*c</code> is <code>p(i)*c</code>. */ public global safe operator this * (c: int): Point(rank) = Point.make(rank, (i:Int) => this.coords(i) * c); - /** The ith coordinate of point <code>p/c</code> is <code>p(i)/c</code>. + /** The ith coordiInte of point <code>p/c</code> is <code>p(i)/c</code>. */ public global safe operator this / (c: int): Point(rank) = Point.make(rank, (i:Int) => this.coords(i) / c); - /** The ith coordinate of point <code>c+p</code> is <code>c+p(i)</code>. + /** The ith coordiInte of point <code>c+p</code> is <code>c+p(i)</code>. */ public global safe operator (c: int) + this: Point(rank) = Point.make(rank, (i:Int) => c + this.coords(i)); - /** The ith coordinate of point <code>c-p</code> is <code>c-p(i)</code>. + /** The ith coordiInte of point <code>c-p</code> is <code>c-p(i)</code>. */ public global safe operator (c: int) - this: Point(rank) = Point.make(rank, (i:Int) => c - this.coords(i)); - /** The ith coordinate of point <code>c*p</code> is <code>c*p(i)</code>. + /** The ith coordiInte of point <code>c*p</code> is <code>c*p(i)</code>. */ public global safe operator (c: int) * this: Point(rank) = Point.make(rank, (i:Int) => c * this.coords(i)); - /** The ith coordinate of point <code>c/p</code> is <code>c/p(i)</code>. + /** The ith coordiInte of point <code>c/p</code> is <code>c/p(i)</code>. */ public global safe operator (c: int) / this: Point(rank) = Point.make(rank, (i:Int) => c / this.coords(i)); @@ -211,7 +211,7 @@ return false; } - /** A point with coordinates <code>i1,..., ik</code> is printed as <code>(i1,.., ik)</code>. + /** A point with coordiIntes <code>i1,..., ik</code> is printed as <code>(i1,.., ik)</code>. */ public global safe def toString() { var s:String = "("; Modified: trunk/x10.runtime/src-x10/x10/lang/Region.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Region.x10 2010-01-06 20:37:08 UTC (rev 12436) +++ trunk/x10.runtime/src-x10/x10/lang/Region.x10 2010-01-07 02:31:56 UTC (rev 12437) @@ -206,14 +206,14 @@ * the ith axis. */ - public global def min(i:nat) = min()(i); + public global def min(i:Int) = min()(i); /** * Returns the upper bound of the bounding box of the region along * the ith axis. */ - public global def max(i:nat) = max()(i); + public global def max(i:Int) = max()(i); // @@ -315,7 +315,7 @@ val count = max-min+1; val baseSize = count/n; val extra = count - baseSize*n; - val result = ValRail.make[Region(1)](n, (i:nat):Region(1) => { + val result = ValRail.make[Region(1)](n, (i:Int):Region(1) => { val start = min + i*baseSize + (i<extra?i:extra); return start..start+baseSize+(i<extra?0:-1); }); Modified: trunk/x10.runtime/src-x10/x10/lang/String.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/String.x10 2010-01-06 20:37:08 UTC (rev 12436) +++ trunk/x10.runtime/src-x10/x10/lang/String.x10 2010-01-07 02:31:56 UTC (rev 12437) @@ -13,7 +13,7 @@ @NativeRep("java", "java.lang.String", "x10.core.BoxedString", null) @NativeRep("c++", "x10aux::ref<x10::lang::String>", "x10::lang::String", null) -public final class String implements (nat) => Char { +public final class String implements (Int) => Char { // TODO: constructors public native def this(): String; public native def this(String): String; @@ -36,11 +36,11 @@ @Native("java", "(#0).charAt(#1)") @Native("c++", "(#0)->charAt(#1)") - public native global def apply(index: nat): Char; + public native global def apply(index: Int): Char; @Native("java", "(#0).charAt(#1)") @Native("c++", "(#0)->charAt(#1)") - public native global def charAt(index: nat): Char; + public native global def charAt(index: Int): Char; @Native("java", "x10.core.RailFactory.<java.lang.Character>makeValRailFromJavaArray(#0.toCharArray())") @Native("c++", "(#0)->chars()") @@ -52,7 +52,7 @@ @Native("java", "#0.substring(#1, #2)") @Native("c++", "(#0)->substring(#1, #2)") - public native global def substring(fromIndex: nat, toIndex: nat): String; + public native global def substring(fromIndex: Int, toIndex: Int): String; @Native("java", "#0.index... [truncated message content] |
From: <ta...@us...> - 2010-01-07 15:28:23
|
Revision: 12447 http://x10.svn.sourceforge.net/x10/?rev=12447&view=rev Author: tardieu Date: 2010-01-07 15:28:16 +0000 (Thu, 07 Jan 2010) Log Message: ----------- merged x10.runtime with x10.lang Modified Paths: -------------- trunk/x10.compiler/data/Main.xcd trunk/x10.compiler/src/x10/types/X10Context_c.java trunk/x10.compiler/src/x10/types/X10TypeSystem_c.java trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java trunk/x10.runtime/src-cpp/Makefile trunk/x10.runtime/src-cpp/x10/lang/Rail.cc trunk/x10.runtime/src-cpp/x10aux/bootstrap.cc trunk/x10.runtime/src-cpp/x10aux/bootstrap.h trunk/x10.runtime/src-cpp/x10aux/init_dispatcher.cc trunk/x10.runtime/src-cpp/x10aux/network.cc trunk/x10.runtime/src-cpp/x10aux/place_local.cc trunk/x10.runtime/src-cpp/x10aux/place_local.h trunk/x10.runtime/src-cpp/x10aux/reference_logger.cc trunk/x10.runtime/src-cpp/x10aux/reference_logger.h trunk/x10.runtime/src-cpp/x10aux/static_init.cc trunk/x10.runtime/src-x10/x10/array/DistArray.x10 trunk/x10.runtime/src-x10/x10/lang/Clock.x10 trunk/x10.runtime/src-x10/x10/lang/Place.x10 trunk/x10.runtime/src-x10/x10/lang/Rail.x10 trunk/x10.runtime/src-x10/x10/lang/System.x10 trunk/x10.runtime/src-x10/x10/util/DistributedRail.x10 Added Paths: ----------- trunk/x10.runtime/src-cpp/x10/lang/PlaceLocalHandle.cc trunk/x10.runtime/src-cpp/x10/lang/PlaceLocalHandle.h trunk/x10.runtime/src-cpp/x10/lang/PlaceLocalHandle.struct_h trunk/x10.runtime/src-cpp/x10/lang/Thread.cc trunk/x10.runtime/src-cpp/x10/lang/Thread.h trunk/x10.runtime/src-x10/x10/lang/Activity.x10 trunk/x10.runtime/src-x10/x10/lang/ClockPhases.x10 trunk/x10.runtime/src-x10/x10/lang/FinishState.x10 trunk/x10.runtime/src-x10/x10/lang/FinishStates.x10 trunk/x10.runtime/src-x10/x10/lang/Future_c.x10 trunk/x10.runtime/src-x10/x10/lang/InterruptedException.x10 trunk/x10.runtime/src-x10/x10/lang/Latch.x10 trunk/x10.runtime/src-x10/x10/lang/Lock.x10 trunk/x10.runtime/src-x10/x10/lang/Monitor.x10 trunk/x10.runtime/src-x10/x10/lang/NativeRuntime.x10 trunk/x10.runtime/src-x10/x10/lang/PlaceLocalHandle.x10 trunk/x10.runtime/src-x10/x10/lang/PlaceLocalStorage.x10 trunk/x10.runtime/src-x10/x10/lang/Pool.x10 trunk/x10.runtime/src-x10/x10/lang/RemoteFinish.x10 trunk/x10.runtime/src-x10/x10/lang/RemoteOperation.x10 trunk/x10.runtime/src-x10/x10/lang/RootFinish.x10 trunk/x10.runtime/src-x10/x10/lang/Runtime.x10 trunk/x10.runtime/src-x10/x10/lang/RuntimeClock.x10 trunk/x10.runtime/src-x10/x10/lang/Semaphore.x10 trunk/x10.runtime/src-x10/x10/lang/Worker.x10 trunk/x10.runtime/src-x10/x10/lang/X10Deque.x10 trunk/x10.runtime/src-x10/x10/lang/X10Thread.x10 Removed Paths: ------------- trunk/x10.runtime/src-cpp/x10/runtime/PlaceLocalHandle.cc trunk/x10.runtime/src-cpp/x10/runtime/PlaceLocalHandle.h trunk/x10.runtime/src-cpp/x10/runtime/PlaceLocalHandle.struct_h trunk/x10.runtime/src-cpp/x10/runtime/Thread.cc trunk/x10.runtime/src-cpp/x10/runtime/Thread.h trunk/x10.runtime/src-x10/x10/lang/Runtime.x10 trunk/x10.runtime/src-x10/x10/runtime/ Modified: trunk/x10.compiler/data/Main.xcd =================================================================== --- trunk/x10.compiler/data/Main.xcd 2010-01-07 14:56:10 UTC (rev 12446) +++ trunk/x10.compiler/data/Main.xcd 2010-01-07 15:28:16 UTC (rev 12447) @@ -5,13 +5,13 @@ // start native runtime new Main().start(args); } - - // called by native runtime inside main x10 thread + + // called by native runtime inside main x10 thread public void main(final x10.core.Rail<java.lang.String> args) { try { - + // start xrx - x10.runtime.Runtime.start( + x10.lang.Runtime.start( // static init activity new x10.core.fun.VoidFun_0_0() { public void apply() { @@ -22,7 +22,7 @@ } }, // body of main activity - new x10.core.fun.VoidFun_0_0() { + new x10.core.fun.VoidFun_0_0() { public void apply() { // catch and rethrow checked exceptions // (closures cannot throw checked exceptions) @@ -30,15 +30,15 @@ // call the original app-main method #2.main(args); } catch (java.lang.RuntimeException e) { - throw e; + throw e; } catch (java.lang.Error e) { - throw e; + throw e; } catch (java.lang.Throwable t) { throw new x10.lang.MultipleExceptions(t); } } }); - + } catch (java.lang.Throwable t) { t.printStackTrace(); } Modified: trunk/x10.compiler/src/x10/types/X10Context_c.java =================================================================== --- trunk/x10.compiler/src/x10/types/X10Context_c.java 2010-01-07 14:56:10 UTC (rev 12446) +++ trunk/x10.compiler/src/x10/types/X10Context_c.java 2010-01-07 15:28:16 UTC (rev 12447) @@ -32,7 +32,7 @@ * Certain methods should not be called if depType is set, e.g. methods to add names, * push scopes etc. These throw an assertion error. * - * Certain methods can be called within a deptype, but the result should be as if they + * Certain methods can be called within a deptype, but the result should be as if they * are called on the outer context. So this is easily dealt with using the pattern * depType == null ? super.Foo(..) : pop.Foo(...) * That is, if this context is not deptype context, run the usual code. Otherwise @@ -92,7 +92,7 @@ public X10Context_c(TypeSystem ts) { super(ts); } - + public List<LocalDef> locals() { if (vars != null) { List<LocalDef> lis = allLocals(); @@ -105,7 +105,7 @@ } return Collections.EMPTY_LIST; } - + public List<LocalDef> allLocals() { if (vars != null) { List<LocalDef> lis = new ArrayList<LocalDef>(vars.values().size()); @@ -125,7 +125,7 @@ } return Collections.EMPTY_LIST; } - + public XRoot thisVar() { if (this.inSuperTypeDeclaration()) { X10ClassDef t = this.supertypeDeclarationType(); @@ -141,14 +141,14 @@ } return null; } - + /* sigma(Gamma) restricted to the variables mentioned in c1,c2 */ public XConstraint constraintProjection(XConstraint... cs) throws XFailure { HashMap<XTerm, XConstraint> m = new HashMap<XTerm, XConstraint>(); - + // add in the real clause of the type of any var mentioned in the constraint list cs XConstraint r = null; - + for (XConstraint ci : cs) { XConstraint ri = constraintProjection(ci, m); if (r == null) @@ -156,15 +156,15 @@ else r.addIn(ri); } - + if (r == null) r = new XConstraint_c(); - - // fold in the current constraint + + // fold in the current constraint XConstraint c1 = currentConstraint(); XConstraint sigma1 = constraintProjection(c1, m); r.addIn(c1); r.addIn(sigma1); - + // fold in the current place constraint XConstraint c2 = currentPlaceTerm == null ? null : currentPlaceTerm.xconstraint(); r.addIn(c2); @@ -177,7 +177,7 @@ r.addIn(c3); XConstraint sigma3 = constraintProjection(c3, m); r.addIn(sigma3); - + // fold in the real clause of the base type Type selfType = this.currentDepType(); if (selfType != null) { @@ -186,10 +186,10 @@ r.addIn(selfConstraint.substitute(r.self(), selfConstraint.self())); } } - + return r; } - + /* sigma(Gamma) restricted to the variables mentioned in c */ private XConstraint constraintProjection(XConstraint c, Map<XTerm,XConstraint> m) throws XFailure { XConstraint r = new XConstraint_c(); @@ -201,14 +201,14 @@ } return r; } - + private XConstraint constraintProjection(XTerm t, Map<XTerm,XConstraint> m) throws XFailure { X10TypeSystem xts = (X10TypeSystem) this.ts; - + XConstraint r = m.get(t); if (r != null) return r; - + // pre-fill the cache to avoid infinite recursion m.put(t, new XConstraint_c()); @@ -284,7 +284,7 @@ } return null; } - + private X10LocalDef getLocal(XLocal f) { XName n = f.name(); if (n instanceof XNameWrapper) { @@ -295,22 +295,22 @@ } return null; } - + protected Ref<TypeConstraint> currentTypeConstraint; - public TypeConstraint currentTypeConstraint() { - if (currentTypeConstraint == null) - return new TypeConstraint_c(); + public TypeConstraint currentTypeConstraint() { + if (currentTypeConstraint == null) + return new TypeConstraint_c(); return currentTypeConstraint.get(); } - public void setCurrentTypeConstraint(Ref<TypeConstraint> c) { - currentTypeConstraint = c; + public void setCurrentTypeConstraint(Ref<TypeConstraint> c) { + currentTypeConstraint = c; } /* protected XConstraint currentPlaceConstraint; - public XConstraint currentPlaceConstraint() { - if (currentPlaceConstraint == null) - return new XConstraint_c(); - return currentPlaceConstraint; + public XConstraint currentPlaceConstraint() { + if (currentPlaceConstraint == null) + return new XConstraint_c(); + return currentPlaceConstraint; } */ protected XConstrainedTerm currentPlaceTerm = null; @@ -320,7 +320,7 @@ currentPlaceTerm = xts.xtypeTranslator().firstPlace(); assert currentPlaceTerm != null; } - + return currentPlaceTerm; } public Context pushPlace(XConstrainedTerm t) { @@ -338,10 +338,10 @@ } return thisPlace; } - + protected XConstraint currentConstraint; // vj: TODO: check if this is the right thing to do. - public XConstraint currentConstraint() { + public XConstraint currentConstraint() { if (currentConstraint == null) { XConstraint c = new XConstraint_c(); if (! inStaticContext()) { @@ -349,10 +349,10 @@ } return c; } - return currentConstraint; + return currentConstraint; } - public void setCurrentConstraint(XConstraint c) { - currentConstraint = c; + public void setCurrentConstraint(XConstraint c) { + currentConstraint = c; } public CodeDef definingCodeDef(Name name) { @@ -386,7 +386,7 @@ protected boolean inAnnotation; protected boolean inAnonObjectScope; protected boolean inAssignment; - + public boolean inSafeCode() { return inSafeCode; } public boolean inSequentialCode() { return inSequentialCode; } public boolean inNonBlockingCode() { return inNonBlockingCode; } @@ -417,7 +417,7 @@ public X10NamedType currentDepType() { return (X10NamedType) Types.get(depType); } - + public Ref<? extends Type> depTypeRef() { return depType; } @@ -456,11 +456,11 @@ if (Report.should_report(TOPICS, 3)) Report.report(3, "find-method " + matcher.signature() + " -> " + currentClass); - + // Override to change the type from C to C{self==this}. Type t = currentClass; X10TypeSystem xts = (X10TypeSystem) ts; - + XRoot thisVar = null; if (XTypeTranslator.THIS_VAR) { CodeDef cd = this.currentCode(); @@ -487,7 +487,7 @@ throw new SemanticException("Method " + matcher.signature() + " not found."); } - + /** * Looks up a method with name "name" and arguments compatible with * "argTypes". @@ -496,14 +496,14 @@ MethodInstance result = depType == null ? superFindMethod(matcher) : pop().findMethod(matcher); return result; } - + /** * Gets a local variable of a particular name. */ public LocalInstance findLocal(Name name) throws SemanticException { return depType == null ? super.findLocal(name) : pop().findLocal(name); } - + public ClassType type() { return type; } /** @@ -511,7 +511,7 @@ */ public ClassType findFieldScope(Name name) throws SemanticException { VarInstance<?> vi = findVariableInThisScope(name); - + if (vi instanceof FieldInstance) { ClassType result = type; if (result != null) @@ -525,11 +525,11 @@ if (result != null) return result; } - + if (vi == null && outer != null) { return outer.findFieldScope(name); } - + throw new SemanticException("Field " + name + " not found."); } @@ -598,11 +598,11 @@ || q.equals(QName.make("x10.lang.Boolean")) || q.equals(QName.make("x10.lang.Object")) || q.equals(QName.make("x10.lang.Ref")) - || q.equals(QName.make("x10.runtime.NativeRuntime")); - + || q.equals(QName.make("x10.lang.NativeRuntime")); + } public Context pushClass(ClassDef classScope, ClassType type) { - //System.err.println("Pushing class" + classScope); + //System.err.println("Pushing class " + classScope); assert (depType == null); XConstrainedTerm currentHere = null; if (! (inBootLoads(classScope)) ){ @@ -611,10 +611,14 @@ } //XConstrainedTerm currentHere = currentPlaceTerm(); X10Context_c result = (X10Context_c) super.pushClass(classScope, type); - - if ( (type.kind() == ClassDef.ANONYMOUS) || ! type.toString().startsWith("x10.lang.")) + + if ( (type.kind() == ClassDef.ANONYMOUS) || ! ( + type.toString().startsWith("x10.lang.Boolean") || + type.toString().startsWith("x10.lang.Object") + + )) try { - XTerm thisLoc = ((X10TypeSystem) typeSystem()).homeVar(((X10ClassDef) classScope).thisVar(), + XTerm thisLoc = ((X10TypeSystem) typeSystem()).homeVar(((X10ClassDef) classScope).thisVar(), this); if (currentHere != null) { XConstraint r = currentHere== null ? null : currentHere.constraint().copy(); @@ -622,13 +626,13 @@ result.thisPlace = XConstrainedTerm.make(thisLoc, r); } //instantiate(currentHere.constraint().copy(), thisLoc); - + } catch (XFailure f) { - throw new InternalError("Unexpected failure when realizing thisPlace constraint" + + throw new InternalError("Unexpected failure when realizing thisPlace constraint" + currentHere); } - - return result; + + return result; } /** @@ -647,7 +651,7 @@ c.setSequentialCode(); return c; } - + public X10Context pushAssignment() { if (depType != null) assert (depType == null); @@ -687,7 +691,7 @@ public boolean inCode() { return depType == null ? super.inCode() : pop().inCode(); } - + public boolean inAssignment() { return inAssignment; } @@ -879,8 +883,8 @@ } public String toString() { - return "(" + (depType != null ? "depType " + depType : kind.toString()) - + (currentConstraint !=null ? " constraint " + currentConstraint : "") + return "(" + (depType != null ? "depType " + depType : kind.toString()) + + (currentConstraint !=null ? " constraint " + currentConstraint : "") + (" place=" + currentPlaceTerm) + (" thisPlace=" + thisPlace) + " "+ mapsToString() + " " + outer + ")"; Modified: trunk/x10.compiler/src/x10/types/X10TypeSystem_c.java =================================================================== --- trunk/x10.compiler/src/x10/types/X10TypeSystem_c.java 2010-01-07 14:56:10 UTC (rev 12446) +++ trunk/x10.compiler/src/x10/types/X10TypeSystem_c.java 2010-01-07 15:28:16 UTC (rev 12447) @@ -367,10 +367,10 @@ } // Instantiate the super type on the new parameters. - X10ClassType sup = (X10ClassType) closureBaseInterfaceDef(numTypeParams, - numValueParams, - ci.returnType().isVoid(), - def.formalNames(), + X10ClassType sup = (X10ClassType) closureBaseInterfaceDef(numTypeParams, + numValueParams, + ci.returnType().isVoid(), + def.formalNames(), def.guard()) .asType(); @@ -383,11 +383,11 @@ return cd; } - public X10ClassDef closureBaseInterfaceDef(final int numTypeParams, final int numValueParams, + public X10ClassDef closureBaseInterfaceDef(final int numTypeParams, final int numValueParams, final boolean isVoid) { return closureBaseInterfaceDef(numTypeParams, numValueParams, isVoid, null, null); } - + /** * Synthetically generated interface for the function types. * @param numTypeParams @@ -397,10 +397,10 @@ * @param guard * @return */ - public X10ClassDef closureBaseInterfaceDef(final int numTypeParams, - final int numValueParams, - final boolean isVoid, - List<LocalDef> formalNames, + public X10ClassDef closureBaseInterfaceDef(final int numTypeParams, + final int numValueParams, + final boolean isVoid, + List<LocalDef> formalNames, final Ref<XConstraint> guard) { final X10TypeSystem xts = this; final Position pos = Position.COMPILER_GENERATED; @@ -422,7 +422,7 @@ X10ClassDef cd = (X10ClassDef) new X10ClassDef_c(this, null) { @Override - public boolean isFunction() { + public boolean isFunction() { return true; } @Override @@ -488,27 +488,27 @@ if (formalNames == null) { formalNames = dummyLocalDefs(argTypes); } - X10MethodDef mi = methodDef(pos, Types.ref(ct), + X10MethodDef mi = methodDef(pos, Types.ref(ct), Flags.PUBLIC.Abstract(), Types.ref(rt), - Name.make("apply"), - typeParams, - argTypes, + Name.make("apply"), + typeParams, + argTypes, thisVar, - formalNames, - guard, - null, - Collections.EMPTY_LIST, + formalNames, + guard, + null, + Collections.EMPTY_LIST, null); cd.addMethod(mi); return cd; } - - - - - - + + + + + + public List<LocalDef> dummyLocalDefs(List<Ref<? extends Type>> types) { List<LocalDef> list = new ArrayList<LocalDef>(); for (int i = 0; i < types.size(); i++) { @@ -1027,7 +1027,7 @@ // return isX10BaseSubtype(t, Ref()); } - + public boolean isStructType(Type t) { return kind(t, null) == Kind.STRUCT; } @@ -1076,7 +1076,7 @@ public List<X10ClassType> allImplementedInterfaces(X10ClassType c) { return allImplementedInterfaces(c, true); } - + public List<X10ClassType> allImplementedInterfaces(X10ClassType c, boolean checkSuperClasses) { List<X10ClassType> ans = new ArrayList<X10ClassType>(); allImplementedInterfaces(c, checkSuperClasses, ans); @@ -1100,12 +1100,12 @@ } if (checkSuperClasses && c.superClass() != null) { - allImplementedInterfaces((X10ClassType)X10TypeMixin.baseType(c.superClass()), + allImplementedInterfaces((X10ClassType)X10TypeMixin.baseType(c.superClass()), checkSuperClasses, l); } for (Type parent : c.interfaces()) { - allImplementedInterfaces((X10ClassType)X10TypeMixin.baseType(parent), + allImplementedInterfaces((X10ClassType)X10TypeMixin.baseType(parent), checkSuperClasses, l); } } @@ -1181,7 +1181,7 @@ protected final X10Flags X10_FIELD_VARIABLE_FLAGS = (X10Flags) legalFieldFlags(); @Override - public MethodDef methodDef(Position pos, Ref<? extends StructType> container, Flags flags, + public MethodDef methodDef(Position pos, Ref<? extends StructType> container, Flags flags, Ref<? extends Type> returnType, Name name, List<Ref<? extends Type>> argTypes, List<Ref<? extends Type>> excTypes) { @@ -1246,15 +1246,15 @@ Ref<? extends Type> returnType, List<Ref<? extends Type>> argTypes, XRoot thisVar, List<LocalDef> formalNames, Ref<XConstraint> guard, List<Ref<? extends Type>> throwTypes) { - return new ClosureDef_c(this, p, typeContainer, methodContainer, returnType, + return new ClosureDef_c(this, p, typeContainer, methodContainer, returnType, argTypes, thisVar, formalNames, guard, throwTypes); } - public FunctionType closureType(Position p, Ref<? extends Type> returnType, - // List<Ref<? extends Type>> typeParams, + public FunctionType closureType(Position p, Ref<? extends Type> returnType, + // List<Ref<? extends Type>> typeParams, List<Ref<? extends Type>> argTypes, - List<LocalDef> formalNames, Ref<XConstraint> guard, - // Ref<TypeConstraint> typeGuard, + List<LocalDef> formalNames, Ref<XConstraint> guard, + // Ref<TypeConstraint> typeGuard, List<Ref<? extends Type>> throwTypes) { Type rt = Types.get(returnType); X10ClassDef def = closureBaseInterfaceDef(0 /*typeParams.size()*/, argTypes.size(), rt.isVoid(), formalNames, guard); @@ -1438,7 +1438,7 @@ // return XOBJECT_; // } - + public Type Object() { if (OBJECT_ == null) OBJECT_ = load("x10.lang.Object"); @@ -1450,7 +1450,7 @@ return CLASS_; return CLASS_ = load("x10.lang.Class"); } - + Type ANY_ = null; public Type Any() { if (ANY_ != null) @@ -1469,7 +1469,7 @@ } Type STRUCT_ = null; public Type Struct() { - if (STRUCT_ != null) + if (STRUCT_ != null) return STRUCT_; return STRUCT_ = x10.util.Struct.makeDef(this).asType(); } @@ -1637,7 +1637,7 @@ public Type Runtime() { if (runtimeType_ == null) - runtimeType_ = load("x10.runtime.Runtime"); // java file + runtimeType_ = load("x10.lang.Runtime"); // java file return runtimeType_; } @@ -1796,7 +1796,7 @@ public boolean isValRail(Type t) { return hasSameClassDef(t, ValRail()); } - + public boolean isValRailOf(Type t, Type p) { if (!isValRail(t)) return false; List<Type> ta = ((X10ClassType)X10TypeMixin.baseType(t)).typeArguments(); @@ -1842,11 +1842,11 @@ public boolean isAny(Type me) { return typeEquals(me, Any(), emptyContext()); } - + public boolean isStruct(Type me) { return typeEquals(me, Struct(), emptyContext()); } - + public boolean isClock(Type me) { return isSubtype(me, Clock(), emptyContext()); } @@ -1896,7 +1896,7 @@ return v; } - + protected XTypeTranslator xtt = new XTypeTranslator(this); public XTypeTranslator xtypeTranslator() { @@ -2221,7 +2221,7 @@ Ref<? extends ClassType> container) { assert_(container); - // access for the default constructor is determined by the + // access for the default constructor is determined by the // access of the containing class. See the JLS, 2nd Ed., 8.8.7. Flags access = Flags.NONE; Flags flags = container.get().flags(); @@ -2229,10 +2229,10 @@ access = access.Private(); } if (flags.isProtected()) { - access = access.Protected(); + access = access.Protected(); } if (flags.isPublic()) { - access = access.Public(); + access = access.Public(); } return constructorDef(pos, container, access, Collections.<Ref<? extends Type>>emptyList(), @@ -2249,7 +2249,7 @@ String fullNameWithThis = "this#this"; XName thisName = new XNameWrapper<Object>(new Object(), fullNameWithThis); XRoot thisVar = XTerms.makeLocal(thisName); - + return constructorDef(pos, container, flags, Types.ref(Types.get(container)), Collections.EMPTY_LIST, argTypes, thisVar, dummyLocalDefs(argTypes), null, null, throwTypes); } @@ -2259,7 +2259,7 @@ assert_(container); assert_(argTypes); assert_(excTypes); - + X10ClassType t = (X10ClassType) Types.get(returnType); assert t != null : "Cannot set return type of constructor to " + t; if (t==null) @@ -2288,8 +2288,8 @@ o.setDefAnnotations(newATs); } - + public boolean clausesConsistent(x10.constraint.XConstraint c1, x10.constraint.XConstraint c2, Context context) { X10TypeEnv env = env(context); return env.clausesConsistent(c1, c2); @@ -2346,7 +2346,7 @@ X10MethodMatcher m = (X10MethodMatcher) matcher; List<MethodInstance> candidates = new ArrayList<MethodInstance>(); - + List<Type> types = env(matcher.context()).upperBounds(container, true); for (Type t : types) { List<MethodInstance> ms = super.findAcceptableMethods(t, matcher); @@ -2398,24 +2398,24 @@ if (fi == null) return null; - Type c = container != null - ? container + Type c = container != null + ? container : fi.container(); XVar v = X10TypeMixin.selfVarBinding(c); // ensureBound should have been called on container. - + X10TypeSystem ts = (X10TypeSystem) fi.typeSystem(); XRoot oldThis = fi.x10Def().thisVar(); if (oldThis != null && v == null) assert false; - // TODO: vj: 08/11/09 + // TODO: vj: 08/11/09 // Shouldnt we be setting thisVar on the type? Type t = fi.type(); Type rt = fi.rightType(); if (v != null && oldThis != null) { - t = Subst.subst(t, (new XVar[] { v }), + t = Subst.subst(t, (new XVar[] { v }), (new XRoot[] { oldThis }), new Type[] {}, new ParameterType[] {}); - rt = Subst.subst(rt, (new XVar[] { v }), (new XRoot[] { oldThis }), + rt = Subst.subst(rt, (new XVar[] { v }), (new XRoot[] { oldThis }), new Type[] {}, new ParameterType[] {}); rt = X10TypeMixin.setThisVar(rt, v); } @@ -2493,7 +2493,7 @@ protected List<Type> typeArgs; protected List<Expr> args; - + protected X10ConstructorMatcher(Type container, List<Type> argTypes, Context context) { this(container, Collections.EMPTY_LIST, argTypes, context); } @@ -2501,15 +2501,15 @@ protected X10ConstructorMatcher(Type container, List<Type> typeArgs, List<Type> argTypes, Context context) { this(container, typeArgs, null, argTypes, context); } - - protected X10ConstructorMatcher(Type container, List<Type> typeArgs, List<Expr> args, + + protected X10ConstructorMatcher(Type container, List<Type> typeArgs, List<Expr> args, List<Type> argTypes, Context context) { super(container, argTypes, context); this.typeArgs = typeArgs; this.args = args; } - + public List<Type> arguments() { return argTypes; } @@ -2527,7 +2527,7 @@ X10ConstructorInstance xmi = (X10ConstructorInstance) ci; Type c = container != null ? container : xmi.container(); if (typeArgs.isEmpty() || typeArgs.size() == xmi.typeParameters().size()) - return X10MethodInstance_c.inferAndCheckAndInstantiate((X10Context) c.typeSystem().emptyContext(), + return X10MethodInstance_c.inferAndCheckAndInstantiate((X10Context) c.typeSystem().emptyContext(), xmi, c, typeArgs, argTypes); } return null; @@ -2634,7 +2634,7 @@ X10Context xc = (X10Context) context; return env(context).isSubtypeWithValueInterfaces(t1, t2); } - + // Returns the number of bytes required to represent the type, or null if unknown (e.g. involves an address somehow) // Note for rails and valrails this returns the size of 1 element, this will have to be scaled // by the number of elements to get the true figure. @@ -2653,32 +2653,32 @@ } return null; } - + public boolean isAtPlace(Receiver r, Expr place, X10Context xc) { XConstraint_c c = new XConstraint_c(); XTerm placeTerm = xtypeTranslator().trans(c, place, xc); - if (placeTerm == null) + if (placeTerm == null) return false; return isAtPlace(r, placeTerm, xc); } - + public boolean isAtPlace(Receiver r, XTerm placeTerm, X10Context xc) { // If the code is executing in a global context then // no receiver can be local. if (placeTerm.equals(globalPlace())) return false; - + try { XConstraint pc = xc.currentPlaceTerm().xconstraint(); Type rType = r.type(); - XTerm target = X10TypeMixin.selfVarBinding(rType); // + XTerm target = X10TypeMixin.selfVarBinding(rType); // if (target == null) { target = xtypeTranslator().trans(pc, r, xc); if (target == null) // The receiver is not named. So make up a new name. // The only thing we know about the name is that it is of rType, target = XConstraint_c.genEQV(); - } + } // rType = X10TypeMixin.setSelfVar(rType, (XVar) target); rType = Subst.subst(rType, target, (XRoot) X10TypeMixin.selfVar(rType)); assert xc.currentPlaceTerm() != null; @@ -2709,7 +2709,7 @@ return false; } - + public XConstraint isHereConstraint(Receiver r, X10Context xc) { XConstraint pc = new XConstraint_c(); @@ -2724,24 +2724,24 @@ } protected XConstraint isHereConstraint(XConstraint pc, XTerm target, X10Context xc) { try { - XTerm eloc = xtypeTranslator().trans(pc, target, + XTerm eloc = xtypeTranslator().trans(pc, target, ((StructType) Object()).fieldNamed(homeName())); pc.addBinding(eloc, xc.currentPlaceTerm()); } catch (XFailure z) { pc.setInconsistent(); - } + } return pc; } public XTerm homeVar(XTerm target, X10Context xc) { XConstraint pc = new XConstraint_c(); - return xtypeTranslator().trans(pc, target, + return xtypeTranslator().trans(pc, target, ((StructType) Object()).fieldNamed(homeName())); } public XTerm locVar(Receiver r, X10Context xc) { XConstraint pc = new XConstraint_c(); XTerm target = xtypeTranslator().trans(pc, r, xc); if (target == null) return null; - return xtypeTranslator().trans(pc, target, + return xtypeTranslator().trans(pc, target, ((StructType) Object()).fieldNamed(homeName())); } public XConstrainedTerm globalPlace() { @@ -2750,8 +2750,8 @@ public boolean isHere(Receiver r, X10Context xc) { return isAtPlace(r, xc.currentPlaceTerm().term(), xc); } - - + + public FieldInstance findField(Type container, TypeSystem_c.FieldMatcher matcher) throws SemanticException { container = X10TypeMixin.ensureSelfBound(container); @@ -2765,12 +2765,12 @@ // First, try to determine if there in fact a struct in scope with the given name. TypeNode otn = new X10ParsedName(nf, ts, Position.COMPILER_GENERATED, name).toType();// // nf.AmbDepTypeNode(position(), null, name(), typeArguments, Collections.EMPTY_LIST, null); - + TypeNode tn = (TypeNode) otn.visit(tb); - + // First ensure that there is a type associated with tn. tn = (TypeNode) tn.disambiguate(tc); - + // ok, if we made it this far, then there is a type. Check that it is a struct. Type t = tn.type(); t = ts.expandMacros(t); @@ -2785,13 +2785,13 @@ public List<Type> abstractSuperInterfaces(Type t) { List<Type> result = super.abstractSuperInterfaces(t); // A work-around for the current transient state of the system in which - // Object is an interface. + // Object is an interface. if (isStructType(t)) { result.remove(Object()); } return result; } - + Name homeName = Name.make("home"); public Name homeName() { return homeName;} } Modified: trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java =================================================================== --- trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java 2010-01-07 14:56:10 UTC (rev 12446) +++ trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java 2010-01-07 15:28:16 UTC (rev 12447) @@ -498,7 +498,7 @@ } else { sw.write(retType + " " + className + "::" + methodName + "() {"); } - + sw.newline(4); sw.begin(0); sw.write("_I_(\"Doing initialisation for class: "+className+"\");"); sw.newline(); for (ClassMember member : members) { @@ -626,7 +626,7 @@ classHeader = classHeader.substring(0, classHeader.length()-StreamWrapper.Header.length()); return classHeader+StreamWrapper.Struct; } - + void processClass(X10ClassDecl_c n) { X10CPPContext_c context = (X10CPPContext_c) tr.context(); X10ClassDef def = (X10ClassDef) n.classDef(); @@ -655,8 +655,8 @@ sh = sw.getNewStream(StreamWrapper.Struct); context.structHeader = sh; } - - // Implementation stream. + + // Implementation stream. // In generic context, in .h, but after the logical header stream. // In non-generic context, in .cc ClassifiedStream w = sw.getNewStream(def.typeParameters().size() != 0 ? StreamWrapper.Header : StreamWrapper.CC, false); @@ -679,7 +679,7 @@ g.write("#ifndef "+cguard+"_GENERICS"); g.newline(); g.write("#define "+cguard+"_GENERICS"); g.newline(); - + String sheader = isStruct ? getStructHeader(def.asType()) : ""; String sguard = isStruct ? getHeaderGuard(sheader) : ""; if (isStruct) { @@ -734,7 +734,7 @@ sh.writeln("#include <" + header + ">"); sh.writeln("#undef "+guard+"_NODEPS"); } - + ArrayList<ClassType> types = new ArrayList<ClassType>(); Set<ClassType> dupes = new HashSet<ClassType>(); dupes.add(ct); @@ -770,7 +770,7 @@ } } } - + // If any instance fields are struct types, then include the .struct_h List<FieldInstance> fields = def.asType().fields(); if (!fields.isEmpty()) { @@ -855,7 +855,7 @@ emitter.printHeader(n, sh, tr); sh.allowBreak(0, " "); sh.write("{"); sh.newline(4); sh.begin(0); - + emitter.printHeaderForStructMethods(n, h, tr); h.write(" {"); h.newline(4); h.begin(0); } else { @@ -876,7 +876,7 @@ } h.end(); h.newline(0); - h.writeln("};"); + h.writeln("};"); ((X10CPPTranslator)tr).setContext(n.enterChildScope(n.body(), context)); // FIXME @@ -910,7 +910,7 @@ sh.write("#endif // " + sguard); sh.newline(0); sh.forceNewline(0); } - + g.write("#endif // "+cguard+"_GENERICS"); g.newline(); if (inTemplate) { @@ -1188,7 +1188,7 @@ sw.newline(); emitter.printRTTDefn(currentClass, sw); - } + } private void visitClassBody(ClassBody_c n, X10CPPContext_c context, X10ClassType currentClass, X10ClassType superClass, @@ -1197,7 +1197,7 @@ h.write("public:"); h.newline(); - h.write("RTT_H_DECLS_CLASS"); + h.write("RTT_H_DECLS_CLASS"); h.newline(); h.forceNewline(); sw.begin(0); for (PropertyDecl p : context.classProperties()) { @@ -1242,7 +1242,7 @@ emitter.printRTTDefn(currentClass, sw); } - + private void visitStructBody(ClassBody_c n, X10CPPContext_c context, X10ClassType currentClass, X10ClassType superClass, X10TypeSystem xts) { @@ -1253,14 +1253,14 @@ sh.write("public:"); sh.newline(); - sh.write("RTT_H_DECLS_STRUCT"); + sh.write("RTT_H_DECLS_STRUCT"); sh.newline(); sh.forceNewline(); sh.write(Emitter.translateType(currentClass, false)+"* operator->() { return this; }"); sh.newline(); sh.forceNewline(); - + h.write("public:"); h.newline(); - + sw.begin(0); for (PropertyDecl p : context.classProperties()) { n.print(p, sw, tr); @@ -1276,11 +1276,11 @@ h.write("static "+VOID + " " + INSTANCE_INIT + "("+className+" *this_);"); h.newline(); h.forceNewline(); - + if (extractInits(currentClass, INSTANCE_INIT, VOID, members)) { context.hasInits = true; } - + ClassMember prev = null; for (ClassMember member : members) { if ((member instanceof polyglot.ast.CodeDecl) || (prev instanceof polyglot.ast.CodeDecl)) { @@ -1289,24 +1289,24 @@ } prev = member; n.printBlock(member, sw, tr); - + // HACK for struct toString. See comment below. if (member instanceof MethodDecl_c) { MethodDecl_c mdecl = (MethodDecl_c)member; - if (!mdecl.flags().flags().isAbstract() && + if (!mdecl.flags().flags().isAbstract() && mdecl.name().id().toString().equals("toString") && - mdecl.formals().isEmpty() && - !mdecl.flags().flags().isStatic() && + mdecl.formals().isEmpty() && + !mdecl.flags().flags().isStatic() && xts.typeBaseEquals(xts.String(), mdecl.returnType().type(), context)) { seenToString = true; } if (mdecl.name().id().toString().equals("hashCode") && - mdecl.formals().isEmpty() && - !mdecl.flags().flags().isStatic() && + mdecl.formals().isEmpty() && + !mdecl.flags().flags().isStatic() && xts.typeBaseEquals(xts.Int(), mdecl.returnType().type(), context)) { seenHashCode = true; } - + } } @@ -1338,7 +1338,7 @@ for (FieldInstance fi : currentClass.fields()) { if (!fi.flags().isStatic()) { String name = fi.name().toString(); - sw.write("if (!" + STRUCT_EQUALS + "(this->"+ mangled_field_name(name) + sw.write("if (!" + STRUCT_EQUALS + "(this->"+ mangled_field_name(name) + ", that->"+ mangled_field_name(name) + "))"); sw.newline(4); sw.begin(0); @@ -1352,21 +1352,21 @@ sw.newline(); sw.write("}"); sw.newline(); - + emitter.generateStructSerializationMethods(currentClass, sw); sw.forceNewline(); } - + // Deal with the methods of Any. - + // We must define them all in the struct_methods class so they can be picked up by the ITables // FIXME: The home method should call Place_methods::make(here) instead of doing a C++ level construction. - h.writeln("static x10_boolean at("+Emitter.translateType(currentClass, false)+" this_, x10aux::ref<x10::lang::Ref> obj) { return true; }"); + h.writeln("static x10_boolean at("+Emitter.translateType(currentClass, false)+" this_, x10aux::ref<x10::lang::Ref> obj) { return true; }"); h.writeln("static x10_boolean at("+Emitter.translateType(currentClass, false)+" this_, x10::lang::Place place) { return true; }"); h.writeln("static x10::lang::Place home("+Emitter.translateType(currentClass, false)+" this_) { /* FIXME: Should probably call Place_methods::make, but don't want to include Place.h */ x10::lang::Place tmp; tmp->FMGL(id)=x10aux::here; return tmp; }"); - h.writeln("static x10aux::ref<x10::lang::String> typeName("+Emitter.translateType(currentClass, false)+" this_) { return this_->typeName(); }"); - - // All types support toString. If there is no user-defined toString, then we define one here. + h.writeln("static x10aux::ref<x10::lang::String> typeName("+Emitter.translateType(currentClass, false)+" this_) { return this_->typeName(); }"); + + // All types support toString. If there is no user-defined toString, then we define one here. // We also have to define a redirection method so that toString is actually defined // on the struct class, not just in the structMethods. This is to fit in with // how toString is used in x10aux::basic_functions. @@ -1390,7 +1390,7 @@ sw.writeln("}"); sw.forceNewline(); h.writeln("static x10aux::ref<x10::lang::String> toString("+Emitter.translateType(currentClass, false)+" this_) { return this_->toString(); }"); } - + // HACKS for hashCode. To be removed once Equality is implemented. if (seenHashCode) { // define redirection method @@ -1410,7 +1410,7 @@ sw.writeln("x10_int result = 0;"); if (superClass != null) { sw.writeln("result = " + Emitter.translateType(superClass)+ "::hashCode();"); - } + } for (FieldInstance fi : currentClass.fields()) { if (!fi.flags().isStatic()) { String name = fi.name().toString(); @@ -1422,7 +1422,7 @@ sw.end(); sw.newline(); sw.writeln("}"); sw.forceNewline(); } - + // define typeName sh.writeln("x10aux::ref<x10::lang::String> typeName();"); sh.forceNewline(); emitter.printTemplateSignature(currentClass.typeArguments(), sw); @@ -1488,14 +1488,14 @@ args +=", "; } thunkParams = chevrons(args); - } - + } + /* ITables declarations */ sh.writeln("static x10aux::itable_entry _itables["+(numInterfaces+1)+"];"); sh.forceNewline(); sh.writeln("x10aux::itable_entry* _getITables() { return _itables; }"); sh.forceNewline(); sh.writeln("static x10aux::itable_entry _iboxitables["+(numInterfaces+1)+"];"); sh.forceNewline(); sh.writeln("x10aux::itable_entry* _getIBoxITables() { return _iboxitables; }"); sh.forceNewline(); - + /* ITables initialization */ int itableNum = 0; for (Type interfaceType : allInterfaces) { @@ -1521,7 +1521,7 @@ } } } - + private void generateProxiesForOverriddenMethods(X10CPPContext_c context, X10ClassType currentClass, X10ClassType superClass, X10TypeSystem xts, String maybeVirtual, ClassifiedStream h, @@ -1666,9 +1666,9 @@ public static String createMainStub(String container) { StringBuilder sb = new StringBuilder(); - sb.append("#include <x10/runtime/Runtime.h>\n"); + sb.append("#include <x10/lang/Runtime.h>\n"); sb.append("#include <x10aux/bootstrap.h>\n"); - String mainTypeArgs = "x10::runtime::Runtime," + container; + String mainTypeArgs = "x10::lang::Runtime," + container; sb.append("extern \"C\" { int main(int ac, char **av) { return x10aux::template_main"+chevrons(mainTypeArgs)+"(ac,av); } }\n"); return sb.toString(); } @@ -1776,7 +1776,7 @@ sw.popCurrentStream(); h.write(";") ; h.newline(); h.forceNewline(); - + emitter.printHeader(dec, sw, tr, true, false, "void"); X10ConstructorInstance ci = (X10ConstructorInstance) dec.constructorDef().asInstance(); if (dec.body() == null) { @@ -1806,7 +1806,7 @@ if (context.hasInits) { // then, run x10 instance field initialisers if (container.isX10Struct()) { - sw.write(INSTANCE_INIT+"(this_);"); sw.newline(); + sw.write(INSTANCE_INIT+"(this_);"); sw.newline(); } else { sw.write("this->"+INSTANCE_INIT+"();"); sw.newline(); } @@ -1827,9 +1827,9 @@ } } else if (call.kind() == ConstructorCall.THIS) { if (container.isX10Struct()) { - sw.write(CONSTRUCTOR+"("); + sw.write(CONSTRUCTOR+"("); } else { - sw.write("this->"+CONSTRUCTOR+"("); + sw.write("this->"+CONSTRUCTOR+"("); } } if (call.arguments().size() > 0) { @@ -1896,7 +1896,7 @@ b.write("}"); b.newline(); b.forceNewline(); } - + sw.newline(); sw.forceNewline(); } @@ -2718,7 +2718,7 @@ Type fType = mi.formalTypes().get(counter); // HACK: Don't inject cases if the method is defined on x10.lang.Object. // Compensates for front-end resolving methods invoked on unconstrained type parameters to Object. - if (!xts.typeEquals(mi.container(), xts.Object(), context) && + if (!xts.typeEquals(mi.container(), xts.Object(), context) && !xts.typeEquals(fType, a.type(), context) && !(xts.isParameterType(fType) && a.type().isNull())) { a = cast(a, fType); } @@ -2731,7 +2731,7 @@ emitNativeAnnotation(pat, mi.typeParameters(), target, args); return; } - + // the cast is because our generated member function may use a more general // return type because c++ does not support covariant smartptr returns Type ret_type = emitter.findRootMethodReturnType(md, null, mi); @@ -2754,7 +2754,7 @@ sw.write(","); dangling = ")"; targetGenerated = true; - } + } sw.write(Emitter.structMethodClass(clsType, true, true)+"::"+mangled_method_name(n.name().id().toString())); emitter.printTemplateInstantiation(mi, sw); sw.write("("); @@ -2767,7 +2767,7 @@ voidTemplateInstantiation(clsType.typeArguments().size())+ "::"+mangled_method_name(n.name().id().toString())); emitter.printTemplateInstantiation(mi, sw); - sw.write("("); + sw.write("("); } else { assert false : "Unexpected target of struct method call "+target; } @@ -2817,7 +2817,7 @@ return; } } - + boolean assoc = !(target instanceof New_c || target instanceof Binary_c); if (!isInterfaceInvoke) { if (needsPlaceCheck) sw.write("x10aux::placeCheck("); @@ -2828,7 +2828,7 @@ sw.write("->"); } - + } } else if (target instanceof TypeNode || target instanceof AmbReceiver) { n.print(target, sw, tr); @@ -2867,7 +2867,7 @@ sw.write(dangling); sw.end(); } - + if (needsCast) { sw.write(")"); } @@ -3118,12 +3118,12 @@ X10CPPContext_c context = (X10CPPContext_c) tr.context(); X10TypeSystem xts = (X10TypeSystem)context.typeSystem(); ConstructorInstance constructor = n.constructorInstance(); - + if (n.qualifier() != null) throw new InternalCompilerError("Qualified new not supported"); if (n.body() != null) throw new InternalCompilerError("Anonymous innner classes should have been removed."); - + List<Expr> coercedArgs = new ArrayList<Expr>(); int counter = 0; for (Expr a : n.arguments()) { @@ -3134,7 +3134,7 @@ coercedArgs.add(a); counter++; } - + if (xts.isStructType(n.objectType().type())) { sw.write(Emitter.structMethodClass(n.objectType().type().toClass(), true, true)+"::"+MAKE+"("); } else { @@ -3618,7 +3618,7 @@ sw.write("{"); sw.newline(4); sw.begin(0); - + String name = "__i" + form.name(); String itableName = name+"_itable"; String iteratorType = Emitter.translateType(xts.Iterator(form.type().type()), false); @@ -3894,7 +3894,7 @@ inc.write("}"); inc.newline(); inc.forceNewline(); generateClosureSerializationFunctions(c, cnamet, inc, n.body()); - + inc.write(cname+"("+SERIALIZATION_MARKER+") { }"); inc.newline(); inc.forceNewline(); @@ -4295,7 +4295,7 @@ if (needsNullCheck) sw.write(")"); sw.write("->apply("); } - + sw.begin(0); boolean first = true; for (Expr e : args) { Modified: trunk/x10.runtime/src-cpp/Makefile =================================================================== --- trunk/x10.runtime/src-cpp/Makefile 2010-01-07 14:56:10 UTC (rev 12446) +++ trunk/x10.runtime/src-cpp/Makefile 2010-01-07 15:28:16 UTC (rev 12447) @@ -251,8 +251,8 @@ x10/lang/ValRail.o \ x10/runtime/Deque.o \ x10/runtime/Lock__ReentrantLock.o \ - x10/runtime/PlaceLocalHandle.o \ - x10/runtime/Thread.o \ + x10/lang/PlaceLocalHandle.o \ + x10/lang/Thread.o \ x10/util/GrowableRail.o \ x10/util/concurrent/atomic/AtomicBoolean.o \ x10/util/concurrent/atomic/AtomicInteger.o \ Copied: trunk/x10.runtime/src-cpp/x10/lang/PlaceLocalHandle.cc (from rev 12442, trunk/x10.runtime/src-cpp/x10/runtime/PlaceLocalHandle.cc) =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/PlaceLocalHandle.cc (rev 0) +++ trunk/x10.runtime/src-cpp/x10/lang/PlaceLocalHandle.cc 2010-01-07 15:28:16 UTC (rev 12447) @@ -0,0 +1,25 @@ +#include <x10aux/config.h> +#include <x10aux/alloc.h> +#include <x10aux/RTT.h> + +#include <x10/lang/PlaceLocalHandle.h> + +using namespace x10aux; +using namespace x10::lang; + +namespace x10 { + namespace lang { + + x10aux::RuntimeType PlaceLocalHandle<void>::rtt; + + void + _initRTTHelper_PlaceLocalHandle(RuntimeType *location, const RuntimeType *rtt) { + const RuntimeType* params[1] = { rtt }; + RuntimeType::Variance variances[1] = { RuntimeType::invariant }; + const RuntimeType *canonical = x10aux::getRTT<PlaceLocalHandle<void> >(); + const char *name = alloc_printf("x10.lang.PlaceLocalHandle[+%s]",rtt->name()); + location->init(canonical, name, 0, NULL, 1, params, variances); + } + } +} + Copied: trunk/x10.runtime/src-cpp/x10/lang/PlaceLocalHandle.h (from rev 12442, trunk/x10.runtime/src-cpp/x10/runtime/PlaceLocalHandle.h) =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/PlaceLocalHandle.h (rev 0) +++ trunk/x10.runtime/src-cpp/x10/lang/PlaceLocalHandle.h 2010-01-07 15:28:16 UTC (rev 12447) @@ -0,0 +1,15 @@ +#ifndef X10_LANG_PLACELOCALHANDLE_H +#define X10_LANG_PLACELOCALHANDLE_H + +#include <x10rt.h> + +#include <x10/lang/PlaceLocalHandle.struct_h> + +namespace x10 { + namespace lang { + namespace PlaceLocalHandle_ns { + } + } +} +#endif + Copied: trunk/x10.runtime/src-cpp/x10/lang/PlaceLocalHandle.struct_h (from rev 12442, trunk/x10.runtime/src-cpp/x10/runtime/PlaceLocalHandle.struct_h) =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/PlaceLocalHandle.struct_h (rev 0) +++ trunk/x10.runtime/src-cpp/x10/lang/PlaceLocalHandle.struct_h 2010-01-07 15:28:16 UTC (rev 12447) @@ -0,0 +1,99 @@ +#ifndef X10_LANG_PLACELOCALHANDLE_STRUCT_H +#define X10_LANG_PLACELOCALHANDLE_STRUCT_H + +#include <x10rt.h> + +#include <x10/lang/String.h> + +namespace x10 { + namespace lang { + + void _initRTTHelper_PlaceLocalHandle(x10aux::RuntimeType *location, const x10aux::RuntimeType *rtt); + + template <class T> class PlaceLocalHandle { + public: + RTT_H_DECLS_STRUCT + + T FMGL(localStorage); + x10_int FMGL(id); + bool FMGL(cached); + + PlaceLocalHandle<T>* operator->() { return this; } + + static PlaceLocalHandle<T> createHandle() { + PlaceLocalHandle<T> result; + x10_int id = x10aux::place_local::nextId(); + result.FMGL(id) = id; + result.FMGL(cached) = false; + return result; + } + + void set(T newVal) { + assert(!FMGL(cached)); + FMGL(localStorage) = newVal; + FMGL(cached) = true; + T *tmp = x10aux::alloc<T>(); + *tmp = newVal; + x10aux::place_local::registerData(FMGL(id), (void*)tmp); + } + + T get() { + if (!FMGL(cached)) { + T *tmp = (T*)(x10aux::place_local::lookupData(FMGL(id))); + FMGL(localStorage) = *tmp; + FMGL(cached) = true; + } + return FMGL(localStorage); + } + + x10aux::ref<x10::lang::String> toString() { + if (FMGL(cached)) { + return x10aux::to_string(FMGL(localStorage)); + } else { + return x10::lang::String::Lit("PlaceLocalHandle(uncached data)"); + } + } + + x10_int hashCode() { + return x10aux::hash_code(FMGL(id)); + } + + + x10_boolean _struct_equals(PlaceLocalHandle<T> that) { + return FMGL(id) == that->FMGL(id); + } + + static void _serialize(PlaceLocalHandle<T> this_, x10aux::serialization_buffer &buf); + + static PlaceLocalHandle<T> _deserialize(x10aux::deserialization_buffer& buf); + }; + + template <> class PlaceLocalHandle<void> { + public: + static x10aux::RuntimeType rtt; + static const x10aux::RuntimeType* getRTT() { return &rtt; } + }; + + template<class T> void PlaceLocalHandle<T>::_initRTT() { + rtt.canonical = &rtt; + x10::lang::_initRTTHelper_PlaceLocalHandle(&rtt, x10aux::getRTT<T>()); + } + + template<class T> x10aux::RuntimeType PlaceLocalHandle<T>::rtt; + + template <class T> void PlaceLocalHandle<T>::_serialize(PlaceLocalHandle<T> this_, x10aux::serialization_buffer &buf) { + // NOTE specialized semantics. Only id is serialized, cached and localStorage are place local! + buf.write(this_->FMGL(id)); + } + + template<class T> PlaceLocalHandle<T> PlaceLocalHandle<T>::_deserialize(x10aux::deserialization_buffer& buf) { + // NOTE specialized semantics. Only id is serialized, cached is automatically set to false; will be looked up on first use. + PlaceLocalHandle<T> this_; + this_->FMGL(id) = buf.read<x10_int>(); + this_->FMGL(cached) = false; + return this_; + } + } +} +#endif + Modified: trunk/x10.runtime/src-cpp/x10/lang/Rail.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Rail.cc 2010-01-07 14:56:10 UTC (rev 12446) +++ trunk/x10.runtime/src-cpp/x10/lang/Rail.cc 2010-01-07 15:28:16 UTC (rev 12447) @@ -4,8 +4,8 @@ #include <x10/lang/Ref.h> #include <x10/lang/Rail.h> -#include <x10/runtime/Runtime.h> -#include <x10/runtime/FinishStates.h> +#include <x10/lang/Runtime.h> +#include <x10/lang/FinishStates.h> using namespace x10aux; @@ -30,19 +30,19 @@ void x10::lang::Rail_notifyEnclosingFinish(deserialization_buffer& buf) { ref<Reference> fs = buf.read<ref<Reference> >(); - ref<x10::runtime::Runtime> rt = x10::runtime::Runtime::FMGL(runtime)->get(); + ref<x10::lang::Runtime> rt = x10::lang::Runtime::FMGL(runtime)->get(); // olivier says the incr should be just after the notifySubActivitySpawn - (fs.operator->()->*(findITable<x10::runtime::FinishState>(fs->_getITables())->notifyActivityCreation))(); - (fs.operator->()->*(findITable<x10::runtime::FinishState>(fs->_getITables())->notifyActivityTermination))(); + (fs.operator->()->*(findITable<x10::lang::FinishState>(fs->_getITables())->notifyActivityCreation))(); + (fs.operator->()->*(findITable<x10::lang::FinishState>(fs->_getITables())->notifyActivityTermination))(); } void x10::lang::Rail_serialize_finish_state (place dst, serialization_buffer &buf) { // dst is the place where the finish update will occur, i.e. where the notifier runs dst = x10aux::parent(dst); - ref<x10::runtime::Runtime> rt = x10::runtime::Runtime::FMGL(runtime)->get(); + ref<x10::lang::Runtime> rt = x10::lang::Runtime::FMGL(runtime)->get(); ref<Reference> fs = rt->currentState(); - (fs.operator->()->*(findITable<x10::runtime::FinishState>(fs->_getITables())->notifySubActivitySpawn))(x10::lang::Place_methods::_make(dst)); + (fs.operator->()->*(findITable<x10::lang::FinishState>(fs->_getITables())->notifySubActivitySpawn))(x10::lang::Place_methods::_make(dst)); buf.write(fs); } Copied: trunk/x10.runtime/src-cpp/x10/lang/Thread.cc (from rev 12446, trunk/x10.runtime/src-cpp/x10/runtime/Thread.cc) =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Thread.cc (rev 0) +++ trunk/x10.runtime/src-cpp/x10/lang/Thread.cc 2010-01-07 15:28:16 UTC (rev 12447) @@ -0,0 +1,484 @@ +/* + * (c) Copyright IBM Corporation 2008 + * + * $Id$ + * This file is part of XRX/C++ native layer implementation. + */ + +/** + * Implementation file for the low level thread interface. + */ + +#include <x10aux/config.h> +#include <x10aux/alloc.h> +#include <x10aux/throw.h> + +#include <x10/lang/Thread.h> + +#include <x10/lang/String.h> + +#include <x10/runtime/Debug.h> +#include <x10/lang/InterruptedException.h> +#include <x10/runtime/IllegalThreadStateException.h> +#include <x10/lang/Worker.h> + +#include <unistd.h> +#include <errno.h> +#include <sstream> +#include <signal.h> +#include <sys/time.h> + +#ifdef __CYGWIN__ +#define pthread_attr_setguardsize(A,B) do { (void)A; (void)B; } while(0) +#define PTHREAD_STACK_MIN 0 +#define pthread_attr_setstacksize(A,B) do { (void)A; (void)B; } while(0) +#endif + +using namespace x10::lang; +using namespace x10::runtime; +using namespace x10aux; +using namespace std; + + +// initialize static data members +ref<Thread> Thread::__current_thread = null; +long x10::lang::Thread::__thread_cnt = 0; +pthread_key_t Thread::__thread_mapper = 0; +x10_boolean Thread::__thread_mapper_inited = false; + +// Thread start routine. +void* +x10::lang::Thread::thread_start_routine(void *arg) +{ + // simply call the run method of the invoking thread object + __xrxDPrStart(); + Thread *tp = (Thread *)arg; + + // store this object reference in the place wide mapper key + if (__thread_mapper_inited) { + pthread_setspecific(__thread_mapper, arg); + } + pthread_mutex_lock(&(tp->__thread_start_lock)); + while (tp->__thread_already_started == false) { + pthread_cond_wait(&(tp->__thread_start_cond), &(tp->__thread_start_lock)); + } + pthread_mutex_unlock(&(tp->__thread_start_lock)); + // this thread is now running + tp->__thread_running = true; + + ref<Reference> taskBody = nullCheck(tp->__taskBody); + (taskBody.operator->()->*(x10aux::findITable<VoidFun_0_0>(taskBody->_getITables())->apply))(); + + // finished running + tp->__thread_running = false; + __xrxDPrEnd(); + pthread_exit(NULL); + return NULL; // quell compiler warning +} + + +ref<Thread> +Thread::_make(ref<x10::lang::VoidFun_0_0> task, ref<x10::lang::String> name) { + ... [truncated message content] |
From: <bti...@us...> - 2010-01-07 22:32:27
|
Revision: 12455 http://x10.svn.sourceforge.net/x10/?rev=12455&view=rev Author: btibbitts Date: 2010-01-07 22:32:20 +0000 (Thu, 07 Jan 2010) Log Message: ----------- bump version Modified Paths: -------------- trunk/x10.common/META-INF/MANIFEST.MF trunk/x10.compiler/META-INF/MANIFEST.MF trunk/x10.constraints/META-INF/MANIFEST.MF trunk/x10.runtime/META-INF/MANIFEST.MF Modified: trunk/x10.common/META-INF/MANIFEST.MF =================================================================== --- trunk/x10.common/META-INF/MANIFEST.MF 2010-01-07 22:17:37 UTC (rev 12454) +++ trunk/x10.common/META-INF/MANIFEST.MF 2010-01-07 22:32:20 UTC (rev 12455) @@ -2,5 +2,5 @@ Bundle-ManifestVersion: 2 Bundle-Name: X10 Common components Bundle-SymbolicName: x10.common -Bundle-Version: 2.0.0 +Bundle-Version: 2.0.1 Export-Package: x10.config Modified: trunk/x10.compiler/META-INF/MANIFEST.MF =================================================================== --- trunk/x10.compiler/META-INF/MANIFEST.MF 2010-01-07 22:17:37 UTC (rev 12454) +++ trunk/x10.compiler/META-INF/MANIFEST.MF 2010-01-07 22:32:20 UTC (rev 12455) @@ -2,7 +2,7 @@ Bundle-ManifestVersion: 2 Bundle-Name: X10 compiler Bundle-SymbolicName: x10.compiler -Bundle-Version: 2.0.0 +Bundle-Version: 2.0.1 Bundle-Localization: plugin Require-Bundle: x10.common, x10.constraints, Modified: trunk/x10.constraints/META-INF/MANIFEST.MF =================================================================== --- trunk/x10.constraints/META-INF/MANIFEST.MF 2010-01-07 22:17:37 UTC (rev 12454) +++ trunk/x10.constraints/META-INF/MANIFEST.MF 2010-01-07 22:32:20 UTC (rev 12455) @@ -2,5 +2,5 @@ Bundle-ManifestVersion: 2 Bundle-Name: X10 Constraints Bundle-SymbolicName: x10.constraints -Bundle-Version: 2.0.0 +Bundle-Version: 2.0.1 Export-Package: x10.constraint Modified: trunk/x10.runtime/META-INF/MANIFEST.MF =================================================================== --- trunk/x10.runtime/META-INF/MANIFEST.MF 2010-01-07 22:17:37 UTC (rev 12454) +++ trunk/x10.runtime/META-INF/MANIFEST.MF 2010-01-07 22:32:20 UTC (rev 12455) @@ -2,7 +2,7 @@ Bundle-ManifestVersion: 2 Bundle-Name: X10 runtime Bundle-SymbolicName: x10.runtime -Bundle-Version: 2.0.0 +Bundle-Version: 2.0.1 Eclipse-AutoStart: true Bundle-Vendor: rf...@wa... Require-Bundle: x10.common, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ta...@us...> - 2010-01-08 03:24:12
|
Revision: 12458 http://x10.svn.sourceforge.net/x10/?rev=12458&view=rev Author: tardieu Date: 2010-01-08 03:24:01 +0000 (Fri, 08 Jan 2010) Log Message: ----------- removed all "non-essential" toplevel classes and interfaces from x10.lang (e.g. Lock, FinishState) by nesting them into the Runtime class Modified Paths: -------------- trunk/x10.compiler/src/x10/visit/Desugarer.java trunk/x10.runtime/src-cpp/x10/lang/Rail.cc trunk/x10.runtime/src-cpp/x10/lang/Thread.cc trunk/x10.runtime/src-cpp/x10/lang/Thread.h trunk/x10.runtime/src-cpp/x10aux/network.cc trunk/x10.runtime/src-cpp/x10aux/place_local.cc trunk/x10.runtime/src-cpp/x10aux/place_local.h trunk/x10.runtime/src-cpp/x10aux/reference_logger.cc trunk/x10.runtime/src-cpp/x10aux/reference_logger.h trunk/x10.runtime/src-x10/x10/lang/Future.x10 trunk/x10.runtime/src-x10/x10/lang/Place.x10 trunk/x10.runtime/src-x10/x10/lang/Runtime.x10 trunk/x10.runtime/src-x10/x10/lang/System.x10 trunk/x10.runtime/src-x10/x10/util/DistributedRail.x10 Added Paths: ----------- trunk/x10.runtime/src-x10/x10/compiler/RemoteOperation.x10 Removed Paths: ------------- trunk/x10.runtime/src-x10/x10/lang/Activity.x10 trunk/x10.runtime/src-x10/x10/lang/ClockPhases.x10 trunk/x10.runtime/src-x10/x10/lang/FinishState.x10 trunk/x10.runtime/src-x10/x10/lang/FinishStates.x10 trunk/x10.runtime/src-x10/x10/lang/Latch.x10 trunk/x10.runtime/src-x10/x10/lang/Lock.x10 trunk/x10.runtime/src-x10/x10/lang/Monitor.x10 trunk/x10.runtime/src-x10/x10/lang/Mortal.x10 trunk/x10.runtime/src-x10/x10/lang/NativeRuntime.x10 trunk/x10.runtime/src-x10/x10/lang/Pool.x10 trunk/x10.runtime/src-x10/x10/lang/RemoteFinish.x10 trunk/x10.runtime/src-x10/x10/lang/RemoteOperation.x10 trunk/x10.runtime/src-x10/x10/lang/RootFinish.x10 trunk/x10.runtime/src-x10/x10/lang/Semaphore.x10 trunk/x10.runtime/src-x10/x10/lang/Worker.x10 trunk/x10.runtime/src-x10/x10/lang/X10Deque.x10 trunk/x10.runtime/src-x10/x10/lang/X10Thread.x10 Modified: trunk/x10.compiler/src/x10/visit/Desugarer.java =================================================================== --- trunk/x10.compiler/src/x10/visit/Desugarer.java 2010-01-07 23:33:57 UTC (rev 12457) +++ trunk/x10.compiler/src/x10/visit/Desugarer.java 2010-01-08 03:24:01 UTC (rev 12458) @@ -200,13 +200,13 @@ return visitRemoteClosure(e, EVAL_AT, e.place()); } - + private Expr visitRemoteClosure(Closure c, Name implName, Expr place) throws SemanticException { Position pos = c.position(); if (xts.isImplicitCastValid(place.type(), xts.Object(), context)) { place = synth.makeFieldAccess(pos,place, xts.homeName(), xContext()); } - + List<TypeNode> typeArgs = Arrays.asList(new TypeNode[] { c.returnType() }); Position bPos = c.body().position(); ClosureDef cDef = c.closureDef().position(bPos); @@ -218,8 +218,8 @@ xts.Place(), cDef.asType() })); // List<Type> tArgs = Arrays.asList(new Type[] { fDef.returnType().get() }); - - Expr result = synth.makeStaticCall(pos, xts.Runtime(), implName, + + Expr result = synth.makeStaticCall(pos, xts.Runtime(), implName, typeArgs, args, c.type(), xContext()); return result; } @@ -228,11 +228,11 @@ if (xts.isImplicitCastValid(place.type(), xts.Object(), context)) { place = synth.makeFieldAccess(pos,place, xts.homeName(), xContext()); } - Closure closure = + Closure closure = synth.makeClosure(body.position(), xts.Void(), synth.toBlock(body), xContext()); Stmt result = xnf.Eval(pos, - synth.makeStaticCall(pos, xts.Runtime(), RUN_AT, - Arrays.asList(new Expr[] { place, closure }), xts.Void(), + synth.makeStaticCall(pos, xts.Runtime(), RUN_AT, + Arrays.asList(new Expr[] { place, closure }), xts.Void(), xContext())); return result; } @@ -278,7 +278,7 @@ private static final Name XOR = Name.make("xor"); private static final Name FENCE = Name.make("fence"); private static final QName IMMEDIATE = QName.make("x10.compiler.Immediate"); - private static final QName REMOTE_OPERATION = QName.make("x10.runtime.RemoteOperation"); + private static final QName REMOTE_OPERATION = QName.make("x10.compiler.RemoteOperation"); /** * Recognize the following pattern: @@ -291,7 +291,7 @@ * and compile it into an optimized remote operation. * @param a the async statement * @return an invocation of the remote operation, or null if no match - * @throws SemanticException + * @throws SemanticException * TODO: move into a separate pass! */ private Stmt specializeAsync(Node old, Async a) throws SemanticException { @@ -348,17 +348,17 @@ if (xts.isImplicitCastValid(place.type(), xts.Object(), context)) { place = synth.makeFieldAccess(pos,place, xts.homeName(), xContext()); } - if (clocks.size() == 0) + if (clocks.size() == 0) return async(pos, body, place); Type clockRailType = xts.ValRail(xts.Clock()); Tuple clockRail = (Tuple) xnf.Tuple(pos, clocks).type(clockRailType); - - return makeAsyncBody(pos, new ArrayList<Expr>(Arrays.asList(new Expr[] { place, clockRail })), + + return makeAsyncBody(pos, new ArrayList<Expr>(Arrays.asList(new Expr[] { place, clockRail })), new ArrayList<Type>(Arrays.asList(new Type[] { xts.Place(), clockRailType})), body); } - + private Stmt async(Position pos, Stmt body, Expr place) throws SemanticException { List<Expr> l = new ArrayList<Expr>(1); l.add(place); @@ -366,34 +366,34 @@ t.add(xts.Place()); return makeAsyncBody(pos, l, t, body); } - + private Stmt async(Position pos, Stmt body, List clocks) throws SemanticException { - if (clocks.size() == 0) + if (clocks.size() == 0) return async(pos, body); Type clockRailType = xts.ValRail(xts.Clock()); Tuple clockRail = (Tuple) xnf.Tuple(pos, clocks).type(clockRailType); - return makeAsyncBody(pos, new ArrayList<Expr>(Arrays.asList(new Expr[] { clockRail })), + return makeAsyncBody(pos, new ArrayList<Expr>(Arrays.asList(new Expr[] { clockRail })), new ArrayList<Type>(Arrays.asList(new Type[] { clockRailType})), body); } - + private Stmt async(Position pos, Stmt body) throws SemanticException { - return makeAsyncBody(pos, new LinkedList<Expr>(), + return makeAsyncBody(pos, new LinkedList<Expr>(), new LinkedList<Type>(), body); } - + private Stmt makeAsyncBody(Position pos, List<Expr> exprs, List<Type> types, Stmt body) throws SemanticException { - Closure closure = synth.makeClosure(body.position(), xts.Void(), + Closure closure = synth.makeClosure(body.position(), xts.Void(), synth.toBlock(body), xContext()); exprs.add(closure); types.add(closure.closureDef().asType()); Stmt result = xnf.Eval(pos, - synth.makeStaticCall(pos, xts.Runtime(), RUN_ASYNC, exprs, + synth.makeStaticCall(pos, xts.Runtime(), RUN_ASYNC, exprs, xts.Void(), types, xContext())); return result; } // end Async - + private Expr visitHere(Here h) throws SemanticException { Position pos = h.position(); return call(pos, HERE, xts.Place()); @@ -410,24 +410,24 @@ Block finallyBlock = xnf.Block(pos, xnf.Eval(pos, call(pos, RELEASE, xts.Void()))); return xnf.Try(pos, tryBlock, new LinkedList(), finallyBlock); } - + private Stmt visitAwait(Await a) throws SemanticException { Position pos = a.position(); - return xnf.Try(pos, - xnf.Block(pos, - xnf.Eval(pos, call(pos, LOCK, xts.Void())), - xnf.While(pos, - xnf.Unary(pos, a.expr(), Unary.NOT), + return xnf.Try(pos, + xnf.Block(pos, + xnf.Eval(pos, call(pos, LOCK, xts.Void())), + xnf.While(pos, + xnf.Unary(pos, a.expr(), Unary.NOT), xnf.Eval(pos, call(pos, AWAIT, xts.Void())))), - Collections.EMPTY_LIST, - xnf.Block(pos, + Collections.EMPTY_LIST, + xnf.Block(pos, xnf.Eval(pos, call(pos, RELEASE, xts.Void())))); } - + private Stmt wrap(Position pos, Stmt s) { return s.reachable() ? xnf.Block(pos, s, xnf.Break(pos)) : s; } - + private Stmt visitWhen(When w) throws SemanticException { Position pos = w.position(); Block body = xnf.Block(pos, xnf.If(pos, w.expr(), wrap(pos, w.stmt()))); @@ -435,16 +435,16 @@ body = body.append(xnf.If(pos, (Expr) w.exprs().get(i), wrap(pos, (Stmt) w.stmts().get(i)))); } body = body.append(xnf.Eval(pos, call(pos, AWAIT, xts.Void()))); - Block tryBlock = xnf.Block(pos, xnf.Eval(pos, call(pos, LOCK, xts.Void())), + Block tryBlock = xnf.Block(pos, xnf.Eval(pos, call(pos, LOCK, xts.Void())), xnf.While(pos, xnf.BooleanLit(pos, true), body)); Block finallyBlock = xnf.Block(pos, xnf.Eval(pos, call(pos, RELEASE, xts.Void()))); return xnf.Try(pos, tryBlock, Collections.EMPTY_LIST, finallyBlock); } - + private Expr call(Position pos, Name name, Type returnType) throws SemanticException { return synth.makeStaticCall(pos, xts.Runtime(), name, returnType, xContext()); } - + private Stmt specializeFinish(Finish f) throws SemanticException { if (!hasAnnotation(f, QName.make("x10.compiler.Immediate"))) return null; @@ -457,16 +457,16 @@ private Stmt visitFinish(Finish f) throws SemanticException { Position pos = f.position(); Name tmp = getTmp(); - + Stmt specializedFinish = specializeFinish(f); if (specializedFinish != null) return specializedFinish; - + // TODO: merge with the call() function MethodInstance mi = xts.findMethod(xts.Runtime(), xts.MethodMatcher(xts.Runtime(), PUSH_EXCEPTION, Collections.singletonList(xts.Throwable()), context)); LocalDef lDef = xts.localDef(pos, xts.NoFlags(), Types.ref(xts.Throwable()), tmp); - Formal formal = xnf.Formal(pos, xnf.FlagsNode(pos, xts.NoFlags()), + Formal formal = xnf.Formal(pos, xnf.FlagsNode(pos, xts.NoFlags()), xnf.CanonicalTypeNode(pos, xts.Throwable()), xnf.Id(pos, tmp)).localDef(lDef); Expr local = xnf.Local(pos, xnf.Id(pos, tmp)).localInstance(lDef.asInstance()).type(xts.Throwable()); Expr call = xnf.X10Call(pos, xnf.CanonicalTypeNode(pos, xts.Runtime()), @@ -502,7 +502,7 @@ domain = xnf.Field(pos, domain, xnf.Id(pos, DIST)).fieldInstance(fDist).type(dType); } LocalDef lDef = xts.localDef(pos, xts.Final(), Types.ref(dType), tmp); - LocalDecl local = xnf.LocalDecl(pos, xnf.FlagsNode(pos, xts.Final()), + LocalDecl local = xnf.LocalDecl(pos, xnf.FlagsNode(pos, xts.Final()), xnf.CanonicalTypeNode(pos, dType), xnf.Id(pos, tmp), domain).localDef(lDef); X10Formal formal = (X10Formal) a.formal(); Type fType = formal.type().type(); @@ -533,7 +533,7 @@ xts.MethodMatcher(fType, CONVERT_IMPLICITLY, Collections.singletonList(intRail), context)); assert (cnv.flags().isStatic()); - index.add(xnf.Call(bpos, xnf.CanonicalTypeNode(bpos, fType), + index.add(xnf.Call(bpos, xnf.CanonicalTypeNode(bpos, fType), xnf.Id(bpos, CONVERT_IMPLICITLY), xnf.Tuple(bpos, vars).type(intRail)).methodInstance(cnv).type(fType)); } @@ -559,7 +559,7 @@ private Expr visitBinary(X10Binary_c n) throws SemanticException { Position pos = n.position(); - + Call c = X10Binary_c.desugarBinaryOp(n, this); if (c != null) { return c; @@ -571,7 +571,7 @@ /** * Same as xnf.Assign(...), but also set the appropriate type objects, which the * node factory screws up. - * @throws SemanticException + * @throws SemanticException */ private Assign assign(Position pos, Expr e, Assign.Operator asgn, Expr val) throws SemanticException { Assign a = (Assign) xnf.Assign(pos, e, asgn, val).type(e.type()); @@ -650,7 +650,7 @@ if (c != null) { return c; } - + return n; } @@ -812,7 +812,7 @@ return xnf.ClosureCall(pos, c, Collections.singletonList(cast)).closureInstance(ci).type(ot); } - // e instanceof T{c} -> ((x:F)=>x instanceof T && c[self/x as T])(e) + // e instanceof T{c} -> ((x:F)=>x instanceof T && c[self/x as T])(e) private Expr visitInstanceof(X10Instanceof_c n) throws SemanticException { Position pos = n.position(); Expr e = n.expr(); Modified: trunk/x10.runtime/src-cpp/x10/lang/Rail.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Rail.cc 2010-01-07 23:33:57 UTC (rev 12457) +++ trunk/x10.runtime/src-cpp/x10/lang/Rail.cc 2010-01-08 03:24:01 UTC (rev 12458) @@ -5,7 +5,7 @@ #include <x10/lang/Ref.h> #include <x10/lang/Rail.h> #include <x10/lang/Runtime.h> -#include <x10/lang/FinishStates.h> +#include <x10/lang/Runtime__FinishStates.h> using namespace x10aux; @@ -32,8 +32,8 @@ ref<Reference> fs = buf.read<ref<Reference> >(); ref<x10::lang::Runtime> rt = x10::lang::Runtime::FMGL(runtime)->get(); // olivier says the incr should be just after the notifySubActivitySpawn - (fs.operator->()->*(findITable<x10::lang::FinishState>(fs->_getITables())->notifyActivityCreation))(); - (fs.operator->()->*(findITable<x10::lang::FinishState>(fs->_getITables())->notifyActivityTermination))(); + (fs.operator->()->*(findITable<x10::lang::Runtime__FinishState>(fs->_getITables())->notifyActivityCreation))(); + (fs.operator->()->*(findITable<x10::lang::Runtime__FinishState>(fs->_getITables())->notifyActivityTermination))(); } void x10::lang::Rail_serialize_finish_state (place dst, serialization_buffer &buf) @@ -42,7 +42,7 @@ dst = x10aux::parent(dst); ref<x10::lang::Runtime> rt = x10::lang::Runtime::FMGL(runtime)->get(); ref<Reference> fs = rt->currentState(); - (fs.operator->()->*(findITable<x10::lang::FinishState>(fs->_getITables())->notifySubActivitySpawn))(x10::lang::Place_methods::_make(dst)); + (fs.operator->()->*(findITable<x10::lang::Runtime__FinishState>(fs->_getITables())->notifySubActivitySpawn))(x10::lang::Place_methods::_make(dst)); buf.write(fs); } Modified: trunk/x10.runtime/src-cpp/x10/lang/Thread.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Thread.cc 2010-01-07 23:33:57 UTC (rev 12457) +++ trunk/x10.runtime/src-cpp/x10/lang/Thread.cc 2010-01-08 03:24:01 UTC (rev 12458) @@ -20,7 +20,7 @@ #include <x10/lang/Debug.h> #include <x10/lang/InterruptedException.h> #include <x10/lang/IllegalThreadStateException.h> -#include <x10/lang/Worker.h> +#include <x10/lang/Runtime__Worker.h> #include <unistd.h> #include <errno.h> @@ -430,7 +430,7 @@ } // Returns the current worker. -ref<Worker> +ref<Runtime__Worker> Thread::worker(void) { return __current_worker; @@ -444,7 +444,7 @@ // Set the current worker. void -Thread::worker(ref<Worker> worker) +Thread::worker(ref<Runtime__Worker> worker) { __current_worker = worker; } Modified: trunk/x10.runtime/src-cpp/x10/lang/Thread.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Thread.h 2010-01-07 23:33:57 UTC (rev 12457) +++ trunk/x10.runtime/src-cpp/x10/lang/Thread.h 2010-01-08 03:24:01 UTC (rev 12458) @@ -21,7 +21,7 @@ namespace lang { class String; class Reference; - class Worker; + class Runtime__Worker; // execution thread condition & associated lock pair typedef struct { @@ -168,13 +168,13 @@ void unpark(); // Returns the current worker. - x10aux::ref<x10::lang::Worker> worker(void); + x10aux::ref<x10::lang::Runtime__Worker> worker(void); // Returns the current location. x10_int locInt(void); // Set the current worker. - void worker(x10aux::ref<x10::lang::Worker> worker); + void worker(x10aux::ref<x10::lang::Runtime__Worker> worker); // Returns this thread's name. const x10aux::ref<x10::lang::String> name(void); @@ -210,7 +210,7 @@ private: // the current worker - x10aux::ref<x10::lang::Worker> __current_worker; + x10aux::ref<x10::lang::Runtime__Worker> __current_worker; // the current thread static x10aux::ref<Thread> __current_thread; // internal thread id counter (monotonically increasing only) Modified: trunk/x10.runtime/src-cpp/x10aux/network.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/network.cc 2010-01-07 23:33:57 UTC (rev 12457) +++ trunk/x10.runtime/src-cpp/x10aux/network.cc 2010-01-08 03:24:01 UTC (rev 12458) @@ -286,8 +286,8 @@ x10aux::deserialization_buffer buf(static_cast<char*>(p.msg)); x10aux::ref<x10::lang::Reference> fs = buf.read<x10aux::ref<x10::lang::Reference> >(); x10aux::ref<x10::lang::Runtime> rt = x10::lang::Runtime::FMGL(runtime)->get(); - (fs.operator->()->*(x10aux::findITable<x10::lang::FinishState>(fs->_getITables())->notifyActivityCreation))(); - (fs.operator->()->*(x10aux::findITable<x10::lang::FinishState>(fs->_getITables())->notifyActivityTermination))(); + (fs.operator->()->*(x10aux::findITable<x10::lang::Runtime__FinishState>(fs->_getITables())->notifyActivityCreation))(); + (fs.operator->()->*(x10aux::findITable<x10::lang::Runtime__FinishState>(fs->_getITables())->notifyActivityTermination))(); } x10aux::msg_type x10aux::register_async_handler (const char *cubin, const char *kernel) Modified: trunk/x10.runtime/src-cpp/x10aux/place_local.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/place_local.cc 2010-01-07 23:33:57 UTC (rev 12457) +++ trunk/x10.runtime/src-cpp/x10aux/place_local.cc 2010-01-08 03:24:01 UTC (rev 12458) @@ -2,7 +2,7 @@ #include <x10aux/place_local.h> #include <x10aux/basic_functions.h> -#include <x10/lang/Lock.h> +#include <x10/lang/Lock__ReentrantLock.h> using namespace x10::lang; using namespace x10aux; @@ -13,10 +13,10 @@ x10_int place_local::_nextId; place_local::Bucket **place_local::_buckets; void **place_local::_fastData; -x10aux::ref<x10::lang::Lock> place_local::_lock; +x10aux::ref<x10::lang::Lock__ReentrantLock> place_local::_lock; void place_local::initialize() { - _lock = Lock::_make(); + _lock = Lock__ReentrantLock::_make(); _nextId = 0; _buckets = alloc<Bucket*>(NUM_BUCKETS*sizeof(Bucket*)); Modified: trunk/x10.runtime/src-cpp/x10aux/place_local.h =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/place_local.h 2010-01-07 23:33:57 UTC (rev 12457) +++ trunk/x10.runtime/src-cpp/x10aux/place_local.h 2010-01-08 03:24:01 UTC (rev 12458) @@ -6,7 +6,7 @@ namespace x10 { namespace lang { - class Lock; + class Lock__ReentrantLock; } } @@ -24,7 +24,7 @@ static x10_int _nextId; static Bucket **_buckets; static void** _fastData; - static x10aux::ref<x10::lang::Lock> _lock; + static x10aux::ref<x10::lang::Lock__ReentrantLock> _lock; public: static void initialize(); Modified: trunk/x10.runtime/src-cpp/x10aux/reference_logger.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/reference_logger.cc 2010-01-07 23:33:57 UTC (rev 12457) +++ trunk/x10.runtime/src-cpp/x10aux/reference_logger.cc 2010-01-08 03:24:01 UTC (rev 12458) @@ -1,6 +1,6 @@ #include <x10aux/reference_logger.h> -#include <x10/lang/Lock.h> +#include <x10/lang/Lock__ReentrantLock.h> using namespace x10::lang; using namespace x10aux; @@ -15,7 +15,7 @@ ReferenceLogger *x10aux::ReferenceLogger::it = new (x10aux::alloc<ReferenceLogger>()) ReferenceLogger(); ReferenceLogger::ReferenceLogger() { - _lock = Lock::_make(); + _lock = Lock__ReentrantLock::_make(); _buckets = x10aux::alloc<Bucket*>(NUM_BUCKETS*sizeof(Bucket*)); memset(_buckets, 0, NUM_BUCKETS*sizeof(Bucket*)); } Modified: trunk/x10.runtime/src-cpp/x10aux/reference_logger.h =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/reference_logger.h 2010-01-07 23:33:57 UTC (rev 12457) +++ trunk/x10.runtime/src-cpp/x10aux/reference_logger.h 2010-01-08 03:24:01 UTC (rev 12458) @@ -6,7 +6,7 @@ namespace x10 { namespace lang { - class Lock; + class Lock__ReentrantLock; } } @@ -27,7 +27,7 @@ void *_reference; Bucket *_next; }; - x10aux::ref<x10::lang::Lock> _lock; + x10aux::ref<x10::lang::Lock__ReentrantLock> _lock; Bucket **_buckets; public: Copied: trunk/x10.runtime/src-x10/x10/compiler/RemoteOperation.x10 (from rev 12452, trunk/x10.runtime/src-x10/x10/lang/RemoteOperation.x10) =================================================================== --- trunk/x10.runtime/src-x10/x10/compiler/RemoteOperation.x10 (rev 0) +++ trunk/x10.runtime/src-x10/x10/compiler/RemoteOperation.x10 2010-01-08 03:24:01 UTC (rev 12458) @@ -0,0 +1,27 @@ +/* + * + * (C) Copyright IBM Corporation 2006-2008. + * + * This file is part of X10 Language. + * + */ + +package x10.compiler; + +/** + * @author igor + */ +public final class RemoteOperation { + // FIXME: HACK + @Native("c++", "x10rt_remote_xor((#1)->FMGL(id),((((x10_ulong)x10aux::get_remote_ref((#2).operator->())) + sizeof(x10::lang::Rail<x10_long>)+7)&~0x7) + ((#3)*sizeof(x10_long)),#4)") + public static def xor(p:Place, r:Rail[Long]/*!p*/, i:Int, v:Long) { + async (p) { + (r as Rail[Long]!)(i) ^= v; + } + } + + @Native("c++", "x10rt_remote_op_fence()") + public static def fence() { } +} + +// vim:shiftwidth=4:tabstop=4:expandtab Deleted: trunk/x10.runtime/src-x10/x10/lang/Activity.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Activity.x10 2010-01-07 23:33:57 UTC (rev 12457) +++ trunk/x10.runtime/src-x10/x10/lang/Activity.x10 2010-01-08 03:24:01 UTC (rev 12458) @@ -1,77 +0,0 @@ -/* - * - * (C) Copyright IBM Corporation 2006-2008. - * - * This file is part of X10 Language. - * - */ - -package x10.lang; - -import x10.util.Stack; - -/** - * @author tardieu - */ -public class Activity { - /** - * the finish state governing the execution of this activity (may be remote) - */ - val finishState:FinishState; - - /** - * safe to run pending jobs while waiting for a finish (temporary) - */ - val safe:Boolean; - - /** - * The user-specified code for this activity. - */ - private val body:()=>Void; - - /** - * The mapping from registered clocks to phases for this activity. - * Lazily created. - */ - var clockPhases:ClockPhases!; - - /** - * The finish states for the finish statements currently executed by this activity. - * Lazily created. - */ - var finishStack:Stack[FinishState!]!; - - /** - * Create activity. - */ - def this(body:()=>Void, finishState:FinishState, safe:Boolean) { - this.finishState = finishState; - this.safe = safe; - finishState.notifyActivityCreation(); - this.body = body; - } - - /** - * Create clocked activity. - */ - def this(body:()=>Void, finishState:FinishState, clocks:ValRail[Clock], phases:ValRail[Int]) { - this(body, finishState, false); - clockPhases = ClockPhases.make(clocks, phases); - } - - /** - * Run activity. - */ - def run():Void { - try { - body(); - } catch (t:Throwable) { - finishState.pushException(t); - } - if (null != clockPhases) clockPhases.drop(); - finishState.notifyActivityTermination(); - NativeRuntime.dealloc(body); - } -} - -// vim:shiftwidth=4:tabstop=4:expandtab Deleted: trunk/x10.runtime/src-x10/x10/lang/ClockPhases.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/ClockPhases.x10 2010-01-07 23:33:57 UTC (rev 12457) +++ trunk/x10.runtime/src-x10/x10/lang/ClockPhases.x10 2010-01-08 03:24:01 UTC (rev 12458) @@ -1,37 +0,0 @@ -/* - * - * (C) Copyright IBM Corporation 2006-2008. - * - * This file is part of X10 Language. - * - */ - -package x10.lang; - -import x10.util.HashMap; - -/** - * @author tardieu - */ -class ClockPhases extends HashMap[Clock,Int] { - static def make(clocks:ValRail[Clock], phases:ValRail[Int]) { - val clockPhases = new ClockPhases(); - for(var i:Int = 0; i < clocks.length; i++) clockPhases.put(clocks(i), phases(i)); - return clockPhases; - } - - def register(clocks:ValRail[Clock]) { - return ValRail.make[Int](clocks.length, (i:Int)=>(clocks(i)).register()); - } - - def next() { - for(clock:Clock in keySet()) clock.resumeUnsafe(); - for(clock:Clock in keySet()) clock.nextUnsafe(); - } - - def drop() { - for(clock:Clock in keySet()) clock.dropUnsafe(); - } -} - -// vim:shiftwidth=4:tabstop=4:expandtab Deleted: trunk/x10.runtime/src-x10/x10/lang/FinishState.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/FinishState.x10 2010-01-07 23:33:57 UTC (rev 12457) +++ trunk/x10.runtime/src-x10/x10/lang/FinishState.x10 2010-01-08 03:24:01 UTC (rev 12458) @@ -1,43 +0,0 @@ -/* - * - * (C) Copyright IBM Corporation 2006-2008 - * - * This file is part of X10 Language. - * - */ - -package x10.lang; - -/** - * @author tardieu - */ -interface FinishState { - - /** - * An activity is spawned under this finish (called by spawner). - */ - global def notifySubActivitySpawn(place:Place):Void; - - /** - * An activity is created under this finish (called by spawnee). - */ - global def notifyActivityCreation():Void; - - /** - * An activity created under this finish has terminated. - * Also called be the activity governing the finish when it completes the finish body. - */ - global def notifyActivityTermination():Void; - - /** - * Push an exception onto the stack. - */ - global def pushException(t:Throwable):Void; - - /** - * Wait for pending subactivities to complete. - */ - def waitForFinish(safe:Boolean):Void; -} - -// vim:shiftwidth=4:tabstop=4:expandtab Deleted: trunk/x10.runtime/src-x10/x10/lang/FinishStates.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/FinishStates.x10 2010-01-07 23:33:57 UTC (rev 12457) +++ trunk/x10.runtime/src-x10/x10/lang/FinishStates.x10 2010-01-08 03:24:01 UTC (rev 12458) @@ -1,36 +0,0 @@ -/* - * - * (C) Copyright IBM Corporation 2006-2008. - * - * This file is part of X10 Language. - * - */ - -package x10.lang; - -import x10.util.concurrent.atomic.AtomicInteger; -import x10.util.HashMap; - -/** - * @author tardieu - */ -class FinishStates implements (RootFinish)=>RemoteFinish { - - private val map = new HashMap[RootFinish, RemoteFinish!](); - private val lock = new Lock(); - - public def apply(rootFinish:RootFinish):RemoteFinish { - lock.lock(); - val finishState = map.getOrElse(rootFinish, null); - if (null != finishState) { - lock.unlock(); - return finishState; - } - val remoteFinish = new RemoteFinish(); - map.put(rootFinish, remoteFinish); - lock.unlock(); - return remoteFinish; - } -} - -// vim:shiftwidth=4:tabstop=4:expandtab Modified: trunk/x10.runtime/src-x10/x10/lang/Future.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Future.x10 2010-01-07 23:33:57 UTC (rev 12457) +++ trunk/x10.runtime/src-x10/x10/lang/Future.x10 2010-01-08 03:24:01 UTC (rev 12458) @@ -20,7 +20,7 @@ /** * Latch for signaling and wait */ - private global val latch = new Latch(); + private global val latch = new Runtime.Latch(); /** * Set if the activity terminated with an exception. Deleted: trunk/x10.runtime/src-x10/x10/lang/Latch.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Latch.x10 2010-01-07 23:33:57 UTC (rev 12457) +++ trunk/x10.runtime/src-x10/x10/lang/Latch.x10 2010-01-08 03:24:01 UTC (rev 12458) @@ -1,36 +0,0 @@ -/* - * - * (C) Copyright IBM Corporation 2006-2008. - * - * This file is part of X10 Language. - * - */ - -package x10.lang; - -/** - * Boolean latch - * @author tardieu - */ -class Latch extends Monitor implements ()=>Boolean { - private var state:Boolean = false; - - public def release():Void { - lock(); - state = true; - super.release(); - } - - public def await():Void { - // avoid locking if state == true - if (!state) { - lock(); - while (!state) super.await(); - unlock(); - } - } - - public def apply():Boolean = state; // memory model? -} - -// vim:shiftwidth=4:tabstop=4:expandtab Deleted: trunk/x10.runtime/src-x10/x10/lang/Lock.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Lock.x10 2010-01-07 23:33:57 UTC (rev 12457) +++ trunk/x10.runtime/src-x10/x10/lang/Lock.x10 2010-01-08 03:24:01 UTC (rev 12458) @@ -1,34 +0,0 @@ -/* - * - * (C) Copyright IBM Corporation 2008 - * - * This file is part of X10 runtime. It is - * governed by the licence under which - * X10 is released. - * - */ -package x10.lang; - -import x10.compiler.NativeClass; -import x10.compiler.NativeDef; - -/** - * A low-level lock that provides a subset of - * the functionality of java.util.concurrent.locks.ReentrantLock. - * The API is subsetted to that which is also supported by pthread_mutex. - */ -@NativeClass("java", "java.util.concurrent.locks", "ReentrantLock") -@NativeClass("c++", "x10.lang", "Lock__ReentrantLock") -public class Lock { - public native def this(); - - public native def lock():Void; - - public native def tryLock():Void; - - public native def unlock():Void; - - public native def getHoldCount():Int; -} - -// vim:shiftwidth=4:tabstop=4:expandtab Deleted: trunk/x10.runtime/src-x10/x10/lang/Monitor.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Monitor.x10 2010-01-07 23:33:57 UTC (rev 12457) +++ trunk/x10.runtime/src-x10/x10/lang/Monitor.x10 2010-01-08 03:24:01 UTC (rev 12458) @@ -1,56 +0,0 @@ -/* - * - * (C) Copyright IBM Corporation 2006-2008. - * - * This file is part of X10 Language. - * - */ - -package x10.lang; - -import x10.util.Stack; - -/** - * Lock with wait/notify capability implemented using park/unpark - * @author tardieu - */ -class Monitor extends Lock { - /** - * Parked threads - */ - private val threads = new Stack[X10Thread](); - - /** - * Park calling thread - * Increment blocked thread count - * Must be called while holding the lock - * Must not be called while holding the lock more than once - */ - def await():Void { - Runtime.increaseParallelism(); - val thread = X10Thread.currentThread(); - threads.push(thread); - while (threads.contains(thread)) { - unlock(); - Runtime.park(); - lock(); - } - } - - /** - * Unpark every thread - * Decrement blocked thread count - * Release the lock - * Must be called while holding the lock - */ - def release():Void { - val size = threads.size(); - if (size > 0) { - Runtime.decreaseParallelism(size); - for (var i:Int = 0; i<size; i++) Runtime.unpark(threads.pop()); - } - unlock(); - } -} - -// vim:shiftwidth=4:tabstop=4:expandtab Deleted: trunk/x10.runtime/src-x10/x10/lang/Mortal.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Mortal.x10 2010-01-07 23:33:57 UTC (rev 12457) +++ trunk/x10.runtime/src-x10/x10/lang/Mortal.x10 2010-01-08 03:24:01 UTC (rev 12458) @@ -1,15 +0,0 @@ -/* - * - * (C) Copyright IBM Corporation 2006-2008. - * - * This file is part of X10 Language. - * - */ - -package x10.lang; - -/** - * A mortal object is garbage collected when there are no remaining local refs even if remote refs might still exist - */ -public interface Mortal { -} Deleted: trunk/x10.runtime/src-x10/x10/lang/NativeRuntime.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/NativeRuntime.x10 2010-01-07 23:33:57 UTC (rev 12457) +++ trunk/x10.runtime/src-x10/x10/lang/NativeRuntime.x10 2010-01-08 03:24:01 UTC (rev 12458) @@ -1,172 +0,0 @@ -/* - * - * (C) Copyright IBM Corporation 2006-2008. - * - * This file is part of X10 Language. - * - */ -package x10.lang; - -import x10.compiler.Native; -import x10.compiler.NativeRep; - -/** - * Interface with native runtime - * @author tardieu - */ -public class NativeRuntime { - - @Native("java", "java.lang.System.out.println(#1)") - @Native("c++", "x10aux::system_utils::println((#1)->toString()->c_str())") - public native static def println(o:Object) : Void; - - /** - * Set system exit code - */ - @Native("java", "x10.runtime.impl.java.Runtime.setExitCode(#1)") - @Native("c++", "(x10aux::exitCode = (#1))") - public static def setExitCode(code: int): void {} - - // Configuration options - - @Native("java", "x10.runtime.impl.java.Runtime.PLACE_CHECKS") - @Native("c++", "(x10_boolean) false") - public const PLACE_CHECKS = true; - - @Native("java", "x10.runtime.impl.java.Runtime.NO_STEALS") - @Native("c++", "x10aux::no_steals()") - public const NO_STEALS = false; - - @Native("java", "x10.runtime.impl.java.Runtime.MAX_PLACES") - @Native("c++", "x10aux::num_places") - public const MAX_PLACES = 4; - - @Native("java", "x10.runtime.impl.java.Runtime.MAX_PLACES") - @Native("c++", "x10aux::num_hosts") - public const MAX_HOSTS = 4; - - @Native("java", "x10.runtime.impl.java.Runtime.INIT_THREADS") - @Native("c++", "x10aux::num_threads()") - public const INIT_THREADS = 1; - - @Native("java", "x10.runtime.impl.java.Runtime.STATIC_THREADS") - @Native("c++", "x10aux::static_threads()") - public const STATIC_THREADS = false; - - /** - * Find number of children under a place. - * For hosts, this returns the number of accelerators at that host. - * For accelerators, it returns 0. - */ - @Native("c++", "x10aux::num_children(#1)") - public static def numChildren(id:Int) = 0; - - /** - * Returns whether a place is a host. - */ - @Native("c++", "x10aux::is_host(#1)") - public static def isHost(id:Int) = true; - - /** - * Returns whether a place is an SPE of a Cell CPU. - */ - @Native("c++", "x10aux::is_spe(#1)") - public static def isSPE(id:Int) = false; - - /** - * Returns whether a place is a CUDA GPU. - */ - @Native("c++", "x10aux::is_cuda(#1)") - public static def isCUDA(id:Int) = false; - - /** - * Find parent of a place. - * For hosts, this returns the host itself. - * For accelerators, it is the host of the accelerator. - */ - @Native("c++", "x10aux::parent(#1)") - public static def parent(id:Int) = id; - - /** - * Iterate over the children of a place. - * Use i between 0 and numChildren(p)-1 inclusive. - * Throws BadPlaceException if i invalid. - */ - @Native("c++", "x10aux::child(#1,#2)") - public static def child(p:Int, i:Int):Int { throw new BadPlaceException(); } - - /** - * Return the index of a given child, within a place. - * Throws BadPlaceException if given place is not a child. - */ - @Native("c++", "x10aux::child_index(#1)") - public static def childIndex(id:Int):Int { throw new BadPlaceException(); } - - /** - * Run body at place(id). - * May be implemented synchronously or asynchronously. - * Body cannot spawn activities, use clocks, or raise exceptions. - */ - @Native("java", "x10.runtime.impl.java.Runtime.runAt(#1, #2)") - @Native("c++", "x10aux::run_at(#1, #2)") - public static def runAt(id:Int, body:()=>Void):Void { body(); } - - /** - * Java: run body synchronously at place(id) in the same node as the current place. - * C++: run body. (no need for a native implementation) - */ - @Native("java", "x10.runtime.impl.java.Runtime.runAt(#1, #2)") - public static def runAtLocal(id:Int, body:()=>Void):Void { body(); } - - /** - * Return true if place(id) is in the current node. - */ - @Native("java", "x10.runtime.impl.java.Runtime.local(#1)") - public static def local(id:Int):Boolean = id == here.id; - - /** - * Process one incoming message if any (non-blocking). - */ - @Native("c++", "x10aux::event_probe()") - public static def event_probe():Void {} - - /** Accessors for native performance counters - */ - @Native("c++","x10aux::asyncs_sent") - static def getAsyncsSent() = 0 as Long; - - @Native("c++","x10aux::asyncs_sent = #1") - static def setAsyncsSent(v:Long) { } - - @Native("c++","x10aux::asyncs_received") - static def getAsyncsReceived() = 0 as Long; - - @Native("c++","x10aux::asyncs_received = #1") - static def setAsyncsReceived(v:Long) { } - - @Native("c++","x10aux::serialized_bytes") - static def getSerializedBytes() = 0 as Long; - - @Native("c++","x10aux::serialized_bytes = #1") - static def setSerializedBytes(v:Long) { } - - @Native("c++","x10aux::deserialized_bytes") - static def getDeserializedBytes() = 0 as Long; - - @Native("c++","x10aux::deserialized_bytes = #1") - static def setDeserializedBytes(v:Long) { } - - @Native("c++", "x10::lang::Ref::dealloc_object((x10::lang::Ref*)#1.operator->())") - public static def deallocObject (o:Object) { } - - @Native("c++", "x10aux::dealloc(#4.operator->())") - public static def dealloc[T] (o:()=>T) { } - - @Native("c++", "x10aux::dealloc(#1.operator->())") - public static def dealloc (o:()=>Void) { } - - @Native("c++", "x10aux::DeserializationDispatcher::registerHandlers()") - public static def registerHandlers() {} -} - -// vim:shiftwidth=4:tabstop=4:expandtab Modified: trunk/x10.runtime/src-x10/x10/lang/Place.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Place.x10 2010-01-07 23:33:57 UTC (rev 12457) +++ trunk/x10.runtime/src-x10/x10/lang/Place.x10 2010-01-08 03:24:01 UTC (rev 12458) @@ -16,13 +16,13 @@ * @author Dave Cunningham */ public final struct Place(id: Int) implements Equals { - public const MAX_PLACES = NativeRuntime.MAX_HOSTS; + public const MAX_PLACES = Runtime.MAX_HOSTS; public const places = ValRail.make[Place](MAX_PLACES, ((id: Int) => Place(id))); public const children = ValRail.make[ValRail[Place]]( - NativeRuntime.MAX_PLACES, - (p: Int) => ValRail.make[Place](NativeRuntime.numChildren(p), - (i:Int) => Place(NativeRuntime.child(p,i)))); - public const NUM_ACCELS = NativeRuntime.MAX_PLACES - NativeRuntime.MAX_HOSTS; + Runtime.MAX_PLACES, + (p: Int) => ValRail.make[Place](Runtime.numChildren(p), + (i:Int) => Place(Runtime.child(p,i)))); + public const NUM_ACCELS = Runtime.MAX_PLACES - Runtime.MAX_HOSTS; public const FIRST_PLACE: Place(0) = places(0) as Place(0); public def this(id: Int):Place(id) { property(id); } @@ -33,7 +33,7 @@ public def prev(i: Int): Place = next(-i); public def next(i: Int): Place { // -1 % n == -1, not n-1, so need to add n - if (NativeRuntime.isHost(id)) { + if (Runtime.isHost(id)) { val k = (id + i % MAX_PLACES + MAX_PLACES) % MAX_PLACES; return place(k); } @@ -44,22 +44,22 @@ public def isFirst(): Boolean = id == 0; public def isLast(): Boolean = id == MAX_PLACES - 1; - public def isHost(): Boolean = NativeRuntime.isHost(id); - public def isSPE(): Boolean = NativeRuntime.isSPE(id); - public def isCUDA(): Boolean = NativeRuntime.isCUDA(id); + public def isHost(): Boolean = Runtime.isHost(id); + public def isSPE(): Boolean = Runtime.isSPE(id); + public def isCUDA(): Boolean = Runtime.isCUDA(id); - public def numChildren() = NativeRuntime.numChildren(id); - public def child(i:Int) = Place(NativeRuntime.child(id,i)); + public def numChildren() = Runtime.numChildren(id); + public def child(i:Int) = Place(Runtime.child(id,i)); public def children() = children(id); - public def parent() = places(NativeRuntime.parent(id)); + public def parent() = places(Runtime.parent(id)); public def childIndex() { if (isHost()) { throw new BadPlaceException(); } - return NativeRuntime.childIndex(id); + return Runtime.childIndex(id); } public global safe def toString() = "(Place " + this.id + ")"; Deleted: trunk/x10.runtime/src-x10/x10/lang/Pool.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Pool.x10 2010-01-07 23:33:57 UTC (rev 12457) +++ trunk/x10.runtime/src-x10/x10/lang/Pool.x10 2010-01-08 03:24:01 UTC (rev 12458) @@ -1,137 +0,0 @@ -/* - * - * (C) Copyright IBM Corporation 2006-2008. - * - * This file is part of X10 Language. - * - */ - -package x10.lang; - -import x10.util.Random; - -/** - * @author tardieu - */ -public class Pool implements ()=>Void { - private val latch:Latch!; - private var size:Int; // the number of workers in the pool - - private var spares:Int = 0; // the number of spare workers in the pool - - private val lock = new Lock(); - - private val semaphore = new Semaphore(0); - - // an upper bound on the number of workers - private const MAX = 1000; - - // the workers in the pool - private val workers:Rail[Worker!]!; - - // the threads in the pool - private val threads:Rail[X10Thread!]!; - - def this(latch:Latch!, size:Int) { - this.latch = latch; - this.size = size; - val workers = Rail.make[Worker!](MAX); - val threads = Rail.make[X10Thread!](size); - - // worker for the master thread - val master = new Worker(latch, 0); - workers(0) = master; - threads(0) = X10Thread.currentThread(); - X10Thread.currentThread().worker(master); - - // other workers - for (var i:Int = 1; i<size; i++) { - val worker = new Worker(latch, i); - workers(i) = worker; - threads(i) = new X10Thread(worker.apply.(), "thread-" + i); - threads(i).worker(worker); - } - this.workers = workers; - this.threads = threads; - } - - public def apply():Void { - val s = size; - for (var i:Int = 1; i<s; i++) { - threads(i).start(); - } - workers(0)(); - while (size > 0) X10Thread.park(); - } - - - // all methods are local - - // notify the pool a worker is about to execute a blocking operation - def increase():Void { - lock.lock(); - if (spares > 0) { - // if a spare is available increase parallelism - spares--; - lock.unlock(); - semaphore.release(); - } else { - // allocate and start a new worker - val i = size++; - lock.unlock(); - assert (i < MAX); - if (i >= MAX) { - NativeRuntime.println("TOO MANY THREADS... ABORTING"); - System.exit(1); - } - val worker = new Worker(latch as Latch!, i); - workers(i) = worker; - val thread = new X10Thread(worker.apply.(), "thread-" + i); - thread.worker(worker); - thread.start(); - } - } - - // notify the pool a worker resumed execution after a blocking operation - def decrease(n:Int):Void { - // increase number or spares - lock.lock(); - spares += n; - lock.unlock(); - // reduce parallelism - semaphore.reduce(n); - } - - // release permit (called by worker upon termination) - def release() { - semaphore.release(); - lock.lock(); - size--; - if (size == 0) threads(0).unpark(); - lock.unlock(); - } - - // scan workers for activity to steal - def scan(random:Random!, latch:Latch!, block:Boolean):Activity { - var activity:Activity = null; - var next:Int = random.nextInt(size); - for (;;) { - NativeRuntime.event_probe(); - if (null != workers(next)) { // avoid race with increase method - activity = workers(next).steal(); - } - if (null != activity || latch()) return activity; - if (semaphore.available() < 0) { - if (block) { - semaphore.release(); - semaphore.acquire(); - } else { - return activity; - } - } - if (++next == size) next = 0; - } - } -} - -// vim:shiftwidth=4:tabstop=4:expandtab Deleted: trunk/x10.runtime/src-x10/x10/lang/RemoteFinish.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/RemoteFinish.x10 2010-01-07 23:33:57 UTC (rev 12457) +++ trunk/x10.runtime/src-x10/x10/lang/RemoteFinish.x10 2010-01-08 03:24:01 UTC (rev 12458) @@ -1,125 +0,0 @@ -/* - * - * (C) Copyright IBM Corporation 2006-2008 - * - * This file is part of X10 Language. - * - */ - -package x10.lang; - -import x10.util.Pair; -import x10.util.Stack; -import x10.util.concurrent.atomic.AtomicInteger; -import x10.compiler.Native; - -/** - * @author tardieu - */ -class RemoteFinish { - /** - * The Exception Stack is used to collect exceptions - * issued when activities associated with this finish state terminate abruptly. - */ - private var exceptions:Stack[Throwable]!; - - /** - * The monitor is used to serialize updates to the finish state. - */ - private val lock = new Lock(); - - /** - * Keep track of the number of activities associated with this finish state. - */ - private val counts = Rail.make[Int](Place.MAX_PLACES, (Int)=>0) as Rail[Int]!; - - private val message = Rail.make[Int](Place.MAX_PLACES, (Int)=>here.id) as Rail[Int]!; - private var length:Int = 1; - - private var count:AtomicInteger = new AtomicInteger(0); - - public def notifyActivityCreation():Void { - count.getAndIncrement(); - } - - /** - * An activity created under this finish has been created. Increment the count - * associated with the finish. - */ - public def notifySubActivitySpawn(place:Place):Void { - lock.lock(); - if (counts(place.id)++ == 0 && here.id != place.id) { - message(length++) = place.id; - } - lock.unlock(); - } - - /** - * An activity created under this finish has terminated. - */ - public def notifyActivityTermination(r:RootFinish):Void { - lock.lock(); - counts(here.id)--; - if (count.decrementAndGet() > 0) { - lock.unlock(); - return; - } - val e = exceptions; - exceptions = null; - if (2*length > Place.MAX_PLACES) { - val m = counts as ValRail[Int]; - for (var i:Int=0; i<Place.MAX_PLACES; i++) counts(i) = 0; - length = 1; - lock.unlock(); - if (null != e) { - val t:Throwable; - if (e.size() == 1) { - t = e.peek(); - } else { - t = new MultipleExceptions(e); - } - val closure = () => { (r as RootFinish!).notify(m, t); NativeRuntime.deallocObject(m); }; - NativeRuntime.runAt(r.home.id, closure); - NativeRuntime.dealloc(closure); - } else { - val closure = () => { (r as RootFinish!).notify(m); NativeRuntime.deallocObject(m); }; - NativeRuntime.runAt(r.home.id, closure); - NativeRuntime.dealloc(closure); - } - NativeRuntime.deallocObject(m); - } else { - val m = ValRail.make[Pair[Int,Int]](length, (i:Int)=>Pair[Int,Int](message(i), counts(message(i)))); - for (var i:Int=0; i<Place.MAX_PLACES; i++) counts(i) = 0; - length = 1; - lock.unlock(); - if (null != e) { - val t:Throwable; - if (e.size() == 1) { - t = e.peek(); - } else { - t = new MultipleExceptions(e); - } - val closure = () => { (r as RootFinish!).notify2(m, t); NativeRuntime.deallocObject(m); }; - NativeRuntime.runAt(r.home.id, closure); - NativeRuntime.dealloc(closure); - } else { - val closure = () => { (r as RootFinish!).notify2(m) ; NativeRuntime.deallocObject(m); }; - NativeRuntime.runAt(r.home.id, closure); - NativeRuntime.dealloc(closure); - } - NativeRuntime.deallocObject(m); - } - } - - /** - * Push an exception onto the stack. - */ - public def pushException(t:Throwable):Void { - lock.lock(); - if (null == exceptions) exceptions = new Stack[Throwable](); - exceptions.push(t); - lock.unlock(); - } -} - -// vim:shiftwidth=4:tabstop=4:expandtab Deleted: trunk/x10.runtime/src-x10/x10/lang/RemoteOperation.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/RemoteOperation.x10 2010-01-07 23:33:57 UTC (rev 12457) +++ trunk/x10.runtime/src-x10/x10/lang/RemoteOperation.x10 2010-01-08 03:24:01 UTC (rev 12458) @@ -1,29 +0,0 @@ -/* - * - * (C) Copyright IBM Corporation 2006-2008. - * - * This file is part of X10 Language. - * - */ - -package x10.lang; - -import x10.compiler.Native; - -/** - * @author igor - */ -public final class RemoteOperation { - // FIXME: HACK - @Native("c++", "x10rt_remote_xor((#1)->FMGL(id),((((x10_ulong)x10aux::get_remote_ref((#2).operator->())) + sizeof(x10::lang::Rail<x10_long>)+7)&~0x7) + ((#3)*sizeof(x10_long)),#4)") - public static def xor(p:Place, r:Rail[Long]/*!p*/, i:Int, v:Long) { - async (p) { - (r as Rail[Long]!)(i) ^= v; - } - } - - @Native("c++", "x10rt_remote_op_fence()") - public static def fence() { } -} - -// vim:shiftwidth=4:tabstop=4:expandtab Deleted: trunk/x10.runtime/src-x10/x10/lang/RootFinish.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/RootFinish.x10 2010-01-07 23:33:57 UTC (rev 12457) +++ trunk/x10.runtime/src-x10/x10/lang/RootFinish.x10 2010-01-08 03:24:01 UTC (rev 12458) @@ -1,135 +0,0 @@ -/* - * - * (C) Copyright IBM Corporation 2006-2008 - * - * This file is part of X10 Language. - * - */ - -package x10.lang; - -import x10.util.Pair; -import x10.util.Stack; - -/** - * @author tardieu - */ -class RootFinish extends Latch implements FinishState, Mortal { - private val counts:Rail[Int]!; - private var exceptions:Stack[Throwable]!; - - def this() { - val c = Rail.make[Int](Place.MAX_PLACES, (Int)=>0); - c(here.id) = 1; - counts = c; - } - - private def notifySubActivitySpawnLocal(place:Place):Void { - lock(); - counts(place.parent().id)++; - unlock(); - } - - private def notifyActivityTerminationLocal():Void { - lock(); - counts(here.id)--; - for(var i:Int=0; i<Place.MAX_PLACES; i++) { - if (counts(i) != 0) { - unlock(); - return; - } - } - release(); - unlock(); - } - - private def pushExceptionLocal(t:Throwable):Void { - lock(); - if (null == exceptions) exceptions = new Stack[Throwable](); - exceptions.push(t); - unlock(); - } - - public def waitForFinish(safe:Boolean):Void { - if (!NativeRuntime.NO_STEALS && safe) Runtime.join(this); - await(); - if (null != exceptions) { - if (exceptions.size() == 1) { - val t = exceptions.peek(); - if (t instanceof Error) { - throw t as Error; - } - if (t instanceof RuntimeException) { - throw t as RuntimeException; - } - } - throw new MultipleExceptions(exceptions); - } - } - - def notify(rail:ValRail[Int]!):Void { - var b:Boolean = true; - lock(); - for(var i:Int=0; i<Place.MAX_PLACES; i++) { - counts(i) += rail(i); - if (counts(i) != 0) b = false; - } - if (b) release(); - unlock(); - } - - def notify2(rail:ValRail[Pair[Int,Int]]!):Void { - lock(); - for(var i:Int=0; i<rail.length; i++) { - counts(rail(i).first) += rail(i).second; - } - for(var i:Int=0; i<Place.MAX_PLACES; i++) { - if (counts(i) != 0) { - unlock(); - return; - } - } - release(); - unlock(); - } - - def notify(rail:ValRail[Int]!, t:Throwable):Void { - pushExceptionLocal(t); - notify(rail); - } - - def notify2(rail:ValRail[Pair[Int,Int]]!, t:Throwable):Void { - pushExceptionLocal(t); - notify2(rail); - } - - public global def notifySubActivitySpawn(place:Place):Void { - if (here.equals(home)) { - (this as RootFinish!).notifySubActivitySpawnLocal(place); - } else { - Runtime.proxy(this).notifySubActivitySpawn(place); - } - } - - public global def notifyActivityCreation():Void { - if (!here.equals(home)) Runtime.proxy(this).notifyActivityCreation(); - } - - public global def notifyActivityTermination():Void { - if (here.equals(home)) { - (this as RootFinish!).notifyActivityTerminationLocal(); - } else { - Runtime.proxy(this).notifyActivityTermination(this); - } - } - - public global def pushException(t:Throwable):Void { - if (here.equals(home)) { - (this as RootFinish!).pushExceptionLocal(t); - } else { - Runtime.proxy(this).pushException(t); - } - } -} - -// vim:shiftwidth=4:tabstop=4:expandtab Modified: trunk/x10.runtime/src-x10/x10/lang/Runtime.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Runtime.x10 2010-01-07 23:33:57 UTC (rev 12457) +++ trunk/x10.runtime/src-x10/x10/lang/Runtime.x10 2010-01-08 03:24:01 UTC (rev 12458) @@ -8,19 +8,917 @@ package x10.lang; +import x10.compiler.Native; +import x10.compiler.NativeClass; +import x10.compiler.NativeDef; import x10.util.HashMap; +import x10.util.Pair; import x10.util.Random; import x10.util.Stack; - import x10.util.concurrent.atomic.AtomicInteger; -import x10.io.Console; - /** * @author tardieu */ public final class Runtime { + @Native("java", "java.lang.System.out.println(#1)") + @Native("c++", "x10aux::system_utils::println((#1)->toString()->c_str())") + public native static def println(o:Object) : Void; + + /** + * Set system exit code + */ + @Native("java", "x10.runtime.impl.java.Runtime.setExitCode(#1)") + @Native("c++", "(x10aux::exitCode = (#1))") + public static def setExitCode(code: int): void {} + + // Configuration options + + @Native("java", "x10.runtime.impl.java.Runtime.PLACE_CHECKS") + @Native("c++", "(x10_boolean) false") + public const PLACE_CHECKS = true; + + @Native("java", "x10.runtime.impl.java.Runtime.NO_STEALS") + @Native("c++", "x10aux::no_steals()") + public const NO_STEALS = false; + + @Native("java", "x10.runtime.impl.java.Runtime.MAX_PLACES") + @Native("c++", "x10aux::num_places") + public const MAX_PLACES = 4; + + @Native("java", "x10.runtime.impl.java.Runtime.MAX_PLACES") + @Native("c++", "x10aux::num_hosts") + public const MAX_HOSTS = 4; + + @Native("java", "x10.runtime.impl.java.Runtime.INIT_THREADS") + @Native("c++", "x10aux::num_threads()") + public const INIT_THREADS = 1; + + @Native("java", "x10.runtime.impl.java.Runtime.STATIC_THREADS") + @Native("c++", "x10aux::static_threads()") + public const STATIC_THREADS = false; + + /** + * Find number of children under a place. + * For hosts, this returns the number of accelerators at that host. + * For accelerators, it returns 0. + */ + @Native("c++", "x10aux::num_children(#1)") + public static def numChildren(id:Int) = 0; + + /** + * Returns whether a place is a host. + */ + @Native("c++", "x10aux::is_host(#1)") + public static def isHost(id:Int) = true; + + /** + * Returns whether a place is an SPE of a Cell CPU. + */ + @Native("c++", "x10aux::is_spe(#1)") + public static def isSPE(id:Int) = false; + + /** + * Returns whether a place is a CUDA GPU. + */ + @Native("c++", "x10aux::is_cuda(#1)") + public static def isCUDA(id:Int) = false; + + /** + * Find parent of a place. + * For hosts, this returns the host itself. + * For accelerators, it is the host of the accelerator. + */ + @Native("c++", "x10aux::parent(#1)") + public static def parent(id:Int) = id; + + /** + * Iterate over the children of a place. + * Use i between 0 and numChildren(p)-1 inclusive. + * Throws BadPlaceException if i invalid. + */ + @Native("c++", "x10aux::child(#1,#2)") + public static def child(p:Int, i:Int):Int { throw new BadPlaceException(); } + + /** + * Return the index of a given child, within a place. + * Throws BadPlaceException if given place is not a child. + */ + @Native("c++", "x10aux::child_index(#1)") + public static def childIndex(id:Int):Int { throw new BadPlaceException(); } + + /** + * Run body at place(id). + * May be implemented synchronously or asynchronously. + * Body cannot spawn activities, use clocks, or raise exceptions. + */ + @Native("java", "x10.runtime.impl.java.Runtime.runAt(#1, #2)") + @Native("c++", "x10aux::run_at(#1, #2)") + public static def runAt(id:Int, body:()=>Void):Void { body(); } + + /** + * Java: run body synchronously at place(id) in the same node as the current place. + * C++: run body. (no need for a native implementation) + */ + @Native("java", "x10.runtime.impl.java.Runtime.runAt(#1, #2)") + public static def runAtLocal(id:Int, body:()=>Void):Void { body(); } + + /** + * Return true if place(id) is in the current node. + */ + @Native("java", "x10.runtime.impl.java.Runtime.local(#1)") + public static def local(id:Int):Boolean = id == here.id; + + /** + * Process one incoming message if any (non-blocking). + */ + @Native("c++", "x10aux::event_probe()") + public static def event_probe():Void {} + + /** Acce... [truncated message content] |
From: <dgr...@us...> - 2010-01-08 22:39:57
|
Revision: 12472 http://x10.svn.sourceforge.net/x10/?rev=12472&view=rev Author: dgrove-oss Date: 2010-01-08 22:39:45 +0000 (Fri, 08 Jan 2010) Log Message: ----------- WIP in cleaning up C++ object model so that Ref/Object can be merged into Object. Also fix bug in C++ codegen found by Olivier for Struct constructors where one constructor calls another constructor of the same Struct. Modified Paths: -------------- trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java trunk/x10.runtime/src-cpp/x10/lang/Deque.cc trunk/x10.runtime/src-cpp/x10/lang/Deque.h trunk/x10.runtime/src-cpp/x10/lang/Object.cc trunk/x10.runtime/src-cpp/x10/lang/Object.h trunk/x10.runtime/src-cpp/x10/lang/Rail.cc trunk/x10.runtime/src-cpp/x10/lang/Rail.h trunk/x10.runtime/src-cpp/x10/lang/Ref.cc trunk/x10.runtime/src-cpp/x10/lang/Ref.h trunk/x10.runtime/src-cpp/x10/lang/String.cc trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicReference.h trunk/x10.runtime/src-cpp/x10aux/basic_functions.cc trunk/x10.runtime/src-cpp/x10aux/network.cc Modified: trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java =================================================================== --- trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java 2010-01-08 20:50:25 UTC (rev 12471) +++ trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java 2010-01-08 22:39:45 UTC (rev 12472) @@ -1827,7 +1827,8 @@ } } else if (call.kind() == ConstructorCall.THIS) { if (container.isX10Struct()) { - sw.write(CONSTRUCTOR+"("); + sw.write(CONSTRUCTOR+"(this_"); + if (call.arguments().size() > 0) sw.write(", "); } else { sw.write("this->"+CONSTRUCTOR+"("); } @@ -3629,11 +3630,11 @@ boolean needsPlaceCheck = !xf.isGlobal() && needsPlaceCheck(domain, context); boolean needsNullCheck = needsNullCheck(domain); if (mi.container().toClass().flags().isInterface()) { - sw.write(make_ref("x10::lang::Object") + " " + name + " = "+iteratorTypeRef+"("); - invokeInterface(n, domain, Collections.EMPTY_LIST, make_ref("x10::lang::Object"), xts.Iterable(form.type().type()), mi, needsPlaceCheck, needsNullCheck); + sw.write(make_ref("x10::lang::Reference") + " " + name + " = "+iteratorTypeRef+"("); + invokeInterface(n, domain, Collections.EMPTY_LIST, make_ref("x10::lang::Reference"), xts.Iterable(form.type().type()), mi, needsPlaceCheck, needsNullCheck); sw.write(");"); sw.newline(); } else { - sw.write(make_ref("x10::lang::Object") + " " + name + " = ("); + sw.write(make_ref("x10::lang::Reference") + " " + name + " = ("); if (needsPlaceCheck) sw.write("x10aux::placeCheck("); if (needsNullCheck) sw.write("x10aux::nullCheck("); n.print(domain, sw, tr); @@ -3647,7 +3648,7 @@ sw.begin(0); sw.write(";"); sw.allowBreak(2, " "); - sw.write("(((x10::lang::Object*)("+name+".operator->()))->*("+itableName+"->hasNext))();"); + sw.write("(((x10::lang::Reference*)("+name+".operator->()))->*("+itableName+"->hasNext))();"); sw.allowBreak(2, " "); sw.end(); @@ -3658,7 +3659,7 @@ sw.write(";"); sw.newline(); sw.write(mangled_non_method_name(form.name().id().toString())); - sw.write(" = (((x10::lang::Object*)("+name+".operator->()))->*("+itableName+"->next))();"); + sw.write(" = (((x10::lang::Reference*)("+name+".operator->()))->*("+itableName+"->next))();"); sw.newline(); for (Iterator li = n.locals().iterator(); li.hasNext(); ) { Stmt l = (Stmt) li.next(); Modified: trunk/x10.runtime/src-cpp/x10/lang/Deque.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Deque.cc 2010-01-08 20:50:25 UTC (rev 12471) +++ trunk/x10.runtime/src-cpp/x10/lang/Deque.cc 2010-01-08 22:39:45 UTC (rev 12472) @@ -57,7 +57,7 @@ int newMask = newSize - 1; do { int oldIndex = b & oldMask; - Object *t = (Object*)(oldQ->data[oldIndex]); + Reference *t = (Reference*)(oldQ->data[oldIndex]); if (t != NULL && !casSlotNull(oldQ, oldIndex, t)) { t = NULL; } @@ -65,7 +65,7 @@ } while (++b != bf); } -void Deque::push(x10aux::ref<x10::lang::Object> t) { +void Deque::push(x10aux::ref<x10::lang::Reference> t) { Slots *q = queue; int mask = q->capacity - 1; int s = sp; @@ -78,14 +78,14 @@ } } -ref<Object> Deque::steal() { - Object *t; +ref<Reference> Deque::steal() { + Reference *t; Slots *q; int i; int b; if (sp != (b = base) && (q = queue) != NULL && // must read q after b - (t = ((Object*)q->data[i = (q->capacity - 1) & b])) != NULL && + (t = ((Reference*)q->data[i = (q->capacity - 1) & b])) != NULL && casSlotNull(q, i, t)) { base = b + 1; return t; @@ -93,13 +93,13 @@ return null; } -ref<Object> Deque::poll() { +ref<Reference> Deque::poll() { int s = sp; while (s != base) { Slots *q = queue; int mask = q->capacity - 1; int i = (s - 1) & mask; - Object *t = (Object*)(q->data[i]); + Reference *t = (Reference*)(q->data[i]); if (t == NULL || !casSlotNull(q, i, t)) break; storeSp(s - 1); Modified: trunk/x10.runtime/src-cpp/x10/lang/Deque.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Deque.h 2010-01-08 20:50:25 UTC (rev 12471) +++ trunk/x10.runtime/src-cpp/x10/lang/Deque.h 2010-01-08 22:39:45 UTC (rev 12472) @@ -53,7 +53,7 @@ * Add in store-order the given task at given slot of q. * Caller must ensure q is nonnull and index is in range. */ - inline void setSlot(Slots *q, int i, x10::lang::Object *t) { + inline void setSlot(Slots *q, int i, x10::lang::Reference *t) { q->data[i] = t; x10aux::atomic_ops::store_store_barrier(); } @@ -63,7 +63,7 @@ * CAS given slot of q to null. Caller must ensure q is nonnull * and index is in range. */ - inline bool casSlotNull(Slots *q, int i, x10::lang::Object* t) { + inline bool casSlotNull(Slots *q, int i, x10::lang::Reference* t) { return x10aux::atomic_ops::compareAndSet_ptr(&(q->data[i]), t, NULL) == t; } @@ -87,27 +87,27 @@ * Pushes a task. Called only by current thread. * @param t the task. Caller must ensure nonnull */ - void push(x10aux::ref<x10::lang::Object> t); + void push(x10aux::ref<x10::lang::Reference> t); /** * Tries to take a task from the base of the queue, failing if * either empty or contended. * @return a task, or null if none or contended. */ - x10aux::ref<x10::lang::Object> steal(); + x10aux::ref<x10::lang::Reference> steal(); /** * Returns a popped task, or null if empty. Ensures active status * if nonnull. Called only by current thread. */ - x10aux::ref<x10::lang::Object> poll(); + x10aux::ref<x10::lang::Reference> poll(); /** * Returns next task to pop. */ - inline x10aux::ref<x10::lang::Object> peekTask() { + inline x10aux::ref<x10::lang::Reference> peekTask() { Slots *q = queue; - return q == NULL ? NULL : (x10::lang::Object*)(q->data[(sp - 1) & (q->capacity - 1)]); + return q == NULL ? NULL : (x10::lang::Reference*)(q->data[(sp - 1) & (q->capacity - 1)]); } /** Modified: trunk/x10.runtime/src-cpp/x10/lang/Object.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Object.cc 2010-01-08 20:50:25 UTC (rev 12471) +++ trunk/x10.runtime/src-cpp/x10/lang/Object.cc 2010-01-08 22:39:45 UTC (rev 12472) @@ -7,14 +7,14 @@ using namespace x10::lang; using namespace x10aux; -x10aux::RuntimeType x10::lang::Object::rtt; +x10aux::RuntimeType x10::lang::SomeObject::rtt; -void Object::_initRTT() { +void SomeObject::_initRTT() { rtt.init(&rtt, "x10.lang.Object", 0, NULL, 0, NULL, NULL); } -itable_entry Object::_itables[1] = { itable_entry(NULL, (void*)x10aux::getRTT<Object>()) }; +itable_entry SomeObject::_itables[1] = { itable_entry(NULL, (void*)x10aux::getRTT<SomeObject>()) }; // vim:tabstop=4:shiftwidth=4:expandtab Modified: trunk/x10.runtime/src-cpp/x10/lang/Object.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Object.h 2010-01-08 20:50:25 UTC (rev 12471) +++ trunk/x10.runtime/src-cpp/x10/lang/Object.h 2010-01-08 22:39:45 UTC (rev 12472) @@ -11,7 +11,7 @@ class Ref; class Any; - class Object : public Reference { + class SomeObject : public Reference { private: static x10aux::itable_entry _itables[1]; @@ -20,9 +20,9 @@ virtual x10aux::itable_entry* _getITables() { return _itables; } - Object(){ } + SomeObject(){ } - virtual ~Object() { } + virtual ~SomeObject() { } virtual x10_int hashCode() = 0; Modified: trunk/x10.runtime/src-cpp/x10/lang/Rail.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Rail.cc 2010-01-08 20:50:25 UTC (rev 12471) +++ trunk/x10.runtime/src-cpp/x10/lang/Rail.cc 2010-01-08 22:39:45 UTC (rev 12472) @@ -46,7 +46,7 @@ buf.write(fs); } -void x10::lang::Rail_serializeAndSendPut(Place dst_place_, ref<Object> df, x10_ubyte code, +void x10::lang::Rail_serializeAndSendPut(Place dst_place_, ref<Reference> df, x10_ubyte code, serialization_id_t _id, void* data, size_t size) { serialization_buffer buf; @@ -57,7 +57,7 @@ x10aux::send_put(dst_place_.FMGL(id), _id, buf, data, size); } -void x10::lang::Rail_serializeAndSendGet(Place src_place_, ref<Object> df, x10_ubyte code, +void x10::lang::Rail_serializeAndSendGet(Place src_place_, ref<Reference> df, x10_ubyte code, serialization_id_t _id, void* data, size_t size) { serialization_buffer buf; Modified: trunk/x10.runtime/src-cpp/x10/lang/Rail.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Rail.h 2010-01-08 20:50:25 UTC (rev 12471) +++ trunk/x10.runtime/src-cpp/x10/lang/Rail.h 2010-01-08 22:39:45 UTC (rev 12472) @@ -179,11 +179,11 @@ void Rail_serialize_finish_state(x10aux::place dst_place, x10aux::serialization_buffer& buf); - void Rail_serializeAndSendPut(x10::lang::Place dst_place_, x10aux::ref<x10::lang::Object> df, + void Rail_serializeAndSendPut(x10::lang::Place dst_place_, x10aux::ref<x10::lang::Reference> df, x10_ubyte code, x10aux::serialization_id_t _id, void* data, size_t size); - void Rail_serializeAndSendGet(x10::lang::Place dst_place_, x10aux::ref<x10::lang::Object> df, + void Rail_serializeAndSendGet(x10::lang::Place dst_place_, x10aux::ref<x10::lang::Reference> df, x10_ubyte code, x10aux::serialization_id_t _id, void* data, size_t size); Modified: trunk/x10.runtime/src-cpp/x10/lang/Ref.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Ref.cc 2010-01-08 20:50:25 UTC (rev 12471) +++ trunk/x10.runtime/src-cpp/x10/lang/Ref.cc 2010-01-08 22:39:45 UTC (rev 12472) @@ -99,6 +99,6 @@ } -RTT_CC_DECLS1(Ref, "x10.lang.Ref", Object) +RTT_CC_DECLS1(Ref, "x10.lang.Ref", SomeObject) // vim:tabstop=4:shiftwidth=4:expandtab Modified: trunk/x10.runtime/src-cpp/x10/lang/Ref.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Ref.h 2010-01-08 20:50:25 UTC (rev 12471) +++ trunk/x10.runtime/src-cpp/x10/lang/Ref.h 2010-01-08 22:39:45 UTC (rev 12472) @@ -22,7 +22,7 @@ class String; - class Ref : public Object { + class Ref : public SomeObject { public: RTT_H_DECLS_CLASS; @@ -102,7 +102,7 @@ virtual x10aux::ref<x10::lang::String> typeName(); // Needed for linking - do not override - virtual x10_boolean _struct_equals(x10aux::ref<Object> other) { + virtual x10_boolean _struct_equals(x10aux::ref<Ref> other) { if (other == x10aux::ref<Ref>(this)) return true; if (this->location == x10aux::here) return false; // already tested above if (other->location == this->location && Modified: trunk/x10.runtime/src-cpp/x10/lang/String.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/String.cc 2010-01-08 20:50:25 UTC (rev 12471) +++ trunk/x10.runtime/src-cpp/x10/lang/String.cc 2010-01-08 22:39:45 UTC (rev 12472) @@ -183,7 +183,7 @@ continue; } nullCheck(parms); - const ref<Object> p = parms->operator[](i); + const ref<Reference> p = parms->operator[](i); char* buf = NULL; if (p.isNull()) { ss << (buf = x10aux::alloc_printf(fmt, "null")); // FIXME: Ignore nulls for now @@ -241,7 +241,7 @@ continue; } placeCheck(nullCheck(parms)); - const ref<Object> p = parms->operator[](i); + const ref<Reference> p = parms->operator[](i); char* buf = NULL; if (p.isNull()) { ss << (buf = x10aux::alloc_printf(fmt, "null")); // FIXME: Ignore nulls for now Modified: trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicReference.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicReference.h 2010-01-08 20:50:25 UTC (rev 12471) +++ trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicReference.h 2010-01-08 22:39:45 UTC (rev 12472) @@ -151,7 +151,7 @@ template<class T> const x10aux::serialization_id_t AtomicReference<T>::_serialization_id = - x10aux::DeserializationDispatcher::addDeserializer(AtomicReference<T>::template _deserializer<Object>); + x10aux::DeserializationDispatcher::addDeserializer(AtomicReference<T>::template _deserializer<Reference>); template<> class AtomicReference<void> { public: Modified: trunk/x10.runtime/src-cpp/x10aux/basic_functions.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/basic_functions.cc 2010-01-08 20:50:25 UTC (rev 12471) +++ trunk/x10.runtime/src-cpp/x10aux/basic_functions.cc 2010-01-08 22:39:45 UTC (rev 12472) @@ -96,11 +96,7 @@ x10_boolean x10aux::general_equals_impl(x10aux::ref<x10::lang::Any> x, x10aux::ref<x10::lang::Any> y) { nullCheck(x); - // TODO: HACK: FIXME: This is not correct. - // We should be pulling the itable for Equals (once everyone implements it...) - // and using it to do the dispatch. - // This will not work for IBox<S>. - x10aux::ref<x10::lang::Object> xAsObj(x); + x10aux::ref<x10::lang::Reference> xAsObj(x); return xAsObj->equals(y); } Modified: trunk/x10.runtime/src-cpp/x10aux/network.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/network.cc 2010-01-08 20:50:25 UTC (rev 12471) +++ trunk/x10.runtime/src-cpp/x10aux/network.cc 2010-01-08 22:39:45 UTC (rev 12472) @@ -151,7 +151,7 @@ struct x10_runtime_Runtime__closure__6__hack : x10::lang::Closure { static const x10aux::serialization_id_t _serialization_id; x10aux::ref<x10::lang::VoidFun_0_0> body; - x10aux::ref<x10::lang::Object> fs; + x10aux::ref<x10::lang::Reference> fs; }; void x10aux::run_at(x10aux::place p, x10aux::ref<Reference> body) { @@ -195,13 +195,13 @@ x10aux::ref<x10::lang::Reference> real_body = body_->body; - x10aux::ref<x10::lang::Object> fs = body_->fs; + x10aux::ref<x10::lang::Reference> fs = body_->fs; serialization_id_t real_sid = real_body->_get_serialization_id(); msg_type real_id = DeserializationDispatcher::getMsgType(real_sid); _X_(ANSI_BOLD<<ANSI_X10RT<<"This is actually a kernel: "<<ANSI_RESET - <<ref<Object>(real_body)->toString()->c_str()<<" id "<<real_id + <<ref<Reference>(real_body)->toString()->c_str()<<" id "<<real_id <<" sid "<<real_sid<<" at GPU: "<<p); buf.write(fs); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dgr...@us...> - 2010-01-09 04:06:26
|
Revision: 12476 http://x10.svn.sourceforge.net/x10/?rev=12476&view=rev Author: dgrove-oss Date: 2010-01-09 04:06:03 +0000 (Sat, 09 Jan 2010) Log Message: ----------- rename x10::lang::Ref to x10::lang::Object Modified Paths: -------------- trunk/x10.compiler/src/x10cpp/visit/Emitter.java trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java trunk/x10.runtime/src-cpp/Makefile trunk/x10.runtime/src-cpp/x10/io/FileReader__FileInputStream.cc trunk/x10.runtime/src-cpp/x10/io/FileWriter__FileOutputStream.cc trunk/x10.runtime/src-cpp/x10/io/File__NativeFile.cc trunk/x10.runtime/src-cpp/x10/io/File__NativeFile.h trunk/x10.runtime/src-cpp/x10/io/InputStreamReader__InputStream.cc trunk/x10.runtime/src-cpp/x10/io/InputStreamReader__InputStream.h trunk/x10.runtime/src-cpp/x10/io/OutputStreamWriter__OutputStream.cc trunk/x10.runtime/src-cpp/x10/io/OutputStreamWriter__OutputStream.h trunk/x10.runtime/src-cpp/x10/lang/Any.cc trunk/x10.runtime/src-cpp/x10/lang/Any.h trunk/x10.runtime/src-cpp/x10/lang/Closure.cc trunk/x10.runtime/src-cpp/x10/lang/Closure.h trunk/x10.runtime/src-cpp/x10/lang/Deque.cc trunk/x10.runtime/src-cpp/x10/lang/Deque.h trunk/x10.runtime/src-cpp/x10/lang/Fun_0_0.h trunk/x10.runtime/src-cpp/x10/lang/Fun_0_1.h trunk/x10.runtime/src-cpp/x10/lang/Fun_0_2.h trunk/x10.runtime/src-cpp/x10/lang/Fun_0_3.h trunk/x10.runtime/src-cpp/x10/lang/Fun_0_4.h trunk/x10.runtime/src-cpp/x10/lang/Fun_0_5.h trunk/x10.runtime/src-cpp/x10/lang/Fun_0_6.h trunk/x10.runtime/src-cpp/x10/lang/Fun_0_7.h trunk/x10.runtime/src-cpp/x10/lang/Fun_0_8.h trunk/x10.runtime/src-cpp/x10/lang/Fun_0_9.h trunk/x10.runtime/src-cpp/x10/lang/Lock__ReentrantLock.cc trunk/x10.runtime/src-cpp/x10/lang/Lock__ReentrantLock.h trunk/x10.runtime/src-cpp/x10/lang/Rail.cc trunk/x10.runtime/src-cpp/x10/lang/Rail.h trunk/x10.runtime/src-cpp/x10/lang/Reference.cc trunk/x10.runtime/src-cpp/x10/lang/String.cc trunk/x10.runtime/src-cpp/x10/lang/String.h trunk/x10.runtime/src-cpp/x10/lang/Thread.cc trunk/x10.runtime/src-cpp/x10/lang/Thread.h trunk/x10.runtime/src-cpp/x10/lang/Throwable.cc trunk/x10.runtime/src-cpp/x10/lang/Throwable.h trunk/x10.runtime/src-cpp/x10/lang/ValRail.cc trunk/x10.runtime/src-cpp/x10/lang/ValRail.h trunk/x10.runtime/src-cpp/x10/lang/VoidFun_0_0.h trunk/x10.runtime/src-cpp/x10/lang/VoidFun_0_1.h trunk/x10.runtime/src-cpp/x10/lang/VoidFun_0_2.h trunk/x10.runtime/src-cpp/x10/lang/VoidFun_0_3.h trunk/x10.runtime/src-cpp/x10/lang/VoidFun_0_4.h trunk/x10.runtime/src-cpp/x10/lang/VoidFun_0_5.h trunk/x10.runtime/src-cpp/x10/lang/VoidFun_0_6.h trunk/x10.runtime/src-cpp/x10/lang/VoidFun_0_7.h trunk/x10.runtime/src-cpp/x10/lang/VoidFun_0_8.h trunk/x10.runtime/src-cpp/x10/lang/VoidFun_0_9.h trunk/x10.runtime/src-cpp/x10/util/GrowableRail.cc trunk/x10.runtime/src-cpp/x10/util/GrowableRail.h trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicBoolean.cc trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicBoolean.h trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicInteger.cc trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicInteger.h trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicLong.cc trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicLong.h trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicReference.cc trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicReference.h trunk/x10.runtime/src-cpp/x10aux/deserialization_dispatcher.cc trunk/x10.runtime/src-cpp/x10aux/deserialization_dispatcher.h trunk/x10.runtime/src-cpp/x10aux/rail_utils.h trunk/x10.runtime/src-cpp/x10aux/static_init.cc trunk/x10.runtime/src-cpp/x10aux/static_init.h trunk/x10.runtime/src-x10/x10/lang/Object.x10 trunk/x10.runtime/src-x10/x10/lang/Runtime.x10 Added Paths: ----------- trunk/x10.runtime/src-cpp/x10/lang/Object.cc trunk/x10.runtime/src-cpp/x10/lang/Object.h Removed Paths: ------------- trunk/x10.runtime/src-cpp/x10/lang/Object.cc trunk/x10.runtime/src-cpp/x10/lang/Object.h trunk/x10.runtime/src-cpp/x10/lang/Ref.cc trunk/x10.runtime/src-cpp/x10/lang/Ref.h Modified: trunk/x10.compiler/src/x10cpp/visit/Emitter.java =================================================================== --- trunk/x10.compiler/src/x10cpp/visit/Emitter.java 2010-01-09 02:34:42 UTC (rev 12475) +++ trunk/x10.compiler/src/x10cpp/visit/Emitter.java 2010-01-09 04:06:03 UTC (rev 12476) @@ -1012,15 +1012,15 @@ sw.write("template<class __T> "); sw.write(make_ref("__T")+" "+klass+"::"+DESERIALIZE_METHOD+"("+DESERIALIZATION_BUFFER+"& buf) {"); sw.newline(4); sw.begin(0); - sw.writeln("x10::lang::Ref::_reference_state rr = " + - "x10::lang::Ref::_deserialize_reference_state(buf);"); + sw.writeln("x10::lang::Object::_reference_state rr = " + + "x10::lang::Object::_deserialize_reference_state(buf);"); sw.writeln(make_ref(klass)+" this_;"); sw.write("if (rr.ref != 0) {"); sw.newline(4); sw.begin(0); sw.write("this_ = "+klass+"::"+template+DESERIALIZER_METHOD+chevrons(klass)+"(buf);"); sw.end(); sw.newline(); sw.writeln("}"); - sw.write("return x10::lang::Ref::_finalize_reference"+chevrons("__T")+"(this_, rr);"); + sw.write("return x10::lang::Object::_finalize_reference"+chevrons("__T")+"(this_, rr);"); sw.end(); sw.newline(); sw.writeln("}"); sw.forceNewline(); sw.popCurrentStream(); Modified: trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java =================================================================== --- trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java 2010-01-09 02:34:42 UTC (rev 12475) +++ trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java 2010-01-09 04:06:03 UTC (rev 12476) @@ -1361,7 +1361,7 @@ // We must define them all in the struct_methods class so they can be picked up by the ITables // FIXME: The home method should call Place_methods::make(here) instead of doing a C++ level construction. - h.writeln("static x10_boolean at("+Emitter.translateType(currentClass, false)+" this_, x10aux::ref<x10::lang::Ref> obj) { return true; }"); + h.writeln("static x10_boolean at("+Emitter.translateType(currentClass, false)+" this_, x10aux::ref<x10::lang::Object> obj) { return true; }"); h.writeln("static x10_boolean at("+Emitter.translateType(currentClass, false)+" this_, x10::lang::Place place) { return true; }"); h.writeln("static x10::lang::Place home("+Emitter.translateType(currentClass, false)+" this_) { /* FIXME: Should probably call Place_methods::make, but don't want to include Place.h */ x10::lang::Place tmp; tmp->FMGL(id)=x10aux::here; return tmp; }"); h.writeln("static x10aux::ref<x10::lang::String> typeName("+Emitter.translateType(currentClass, false)+" this_) { return this_->typeName(); }"); Modified: trunk/x10.runtime/src-cpp/Makefile =================================================================== --- trunk/x10.runtime/src-cpp/Makefile 2010-01-09 02:34:42 UTC (rev 12475) +++ trunk/x10.runtime/src-cpp/Makefile 2010-01-09 04:06:03 UTC (rev 12476) @@ -243,7 +243,6 @@ x10/lang/Fun.o \ x10/lang/Object.o \ x10/lang/Rail.o \ - x10/lang/Ref.o \ x10/lang/Reference.o \ x10/lang/String.o \ x10/lang/Struct.o \ Modified: trunk/x10.runtime/src-cpp/x10/io/FileReader__FileInputStream.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/io/FileReader__FileInputStream.cc 2010-01-09 02:34:42 UTC (rev 12475) +++ trunk/x10.runtime/src-cpp/x10/io/FileReader__FileInputStream.cc 2010-01-09 04:06:03 UTC (rev 12476) @@ -15,7 +15,7 @@ } const x10aux::serialization_id_t FileReader__FileInputStream::_serialization_id = - x10aux::DeserializationDispatcher::addDeserializer(FileReader__FileInputStream::_deserializer<x10::lang::Ref>); + x10aux::DeserializationDispatcher::addDeserializer(FileReader__FileInputStream::_deserializer<x10::lang::Object>); void FileReader__FileInputStream::_serialize_body(x10aux::serialization_buffer& buf) { InputStreamReader__InputStream::_serialize_body(buf); Modified: trunk/x10.runtime/src-cpp/x10/io/FileWriter__FileOutputStream.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/io/FileWriter__FileOutputStream.cc 2010-01-09 02:34:42 UTC (rev 12475) +++ trunk/x10.runtime/src-cpp/x10/io/FileWriter__FileOutputStream.cc 2010-01-09 04:06:03 UTC (rev 12476) @@ -18,7 +18,7 @@ } const x10aux::serialization_id_t FileWriter__FileOutputStream::_serialization_id = - x10aux::DeserializationDispatcher::addDeserializer(FileWriter__FileOutputStream::_deserializer<x10::lang::Ref>); + x10aux::DeserializationDispatcher::addDeserializer(FileWriter__FileOutputStream::_deserializer<x10::lang::Object>); void FileWriter__FileOutputStream::_serialize_body(x10aux::serialization_buffer& buf) { OutputStreamWriter__OutputStream::_serialize_body(buf); Modified: trunk/x10.runtime/src-cpp/x10/io/File__NativeFile.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/io/File__NativeFile.cc 2010-01-09 02:34:42 UTC (rev 12475) +++ trunk/x10.runtime/src-cpp/x10/io/File__NativeFile.cc 2010-01-09 04:06:03 UTC (rev 12476) @@ -21,17 +21,17 @@ } void File__NativeFile::_serialize_body(serialization_buffer &buf) { - this->Ref::_serialize_body(buf); + this->Object::_serialize_body(buf); } void File__NativeFile::_deserialize_body(deserialization_buffer& buf) { - this->Ref::_deserialize_body(buf); + this->Object::_deserialize_body(buf); } const x10aux::serialization_id_t File__NativeFile::_serialization_id = - x10aux::DeserializationDispatcher::addDeserializer(File__NativeFile::_deserializer<Ref>); + x10aux::DeserializationDispatcher::addDeserializer(File__NativeFile::_deserializer<Object>); -RTT_CC_DECLS1(File__NativeFile, "x10.io.File.NativeFile", Ref) +RTT_CC_DECLS1(File__NativeFile, "x10.io.File.NativeFile", Object) x10aux::ref<String> File__NativeFile::getAbsolutePath() { Modified: trunk/x10.runtime/src-cpp/x10/io/File__NativeFile.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/io/File__NativeFile.h 2010-01-09 02:34:42 UTC (rev 12475) +++ trunk/x10.runtime/src-cpp/x10/io/File__NativeFile.h 2010-01-09 04:06:03 UTC (rev 12476) @@ -4,7 +4,7 @@ #include <x10aux/config.h> #include <x10aux/serialization.h> -#include <x10/lang/Ref.h> +#include <x10/lang/Object.h> #include <x10/lang/String.h> @@ -16,7 +16,7 @@ namespace io { - class File__NativeFile : public x10::lang::Ref { + class File__NativeFile : public x10::lang::Object { public: RTT_H_DECLS_CLASS; @@ -28,7 +28,7 @@ static x10aux::ref<File__NativeFile> _make(x10aux::ref<x10::lang::String> s); x10aux::ref<File__NativeFile> _constructor(x10aux::ref<x10::lang::String> s) { - this->x10::lang::Ref::_constructor(); + this->x10::lang::Object::_constructor(); path = s; return this; } Modified: trunk/x10.runtime/src-cpp/x10/io/InputStreamReader__InputStream.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/io/InputStreamReader__InputStream.cc 2010-01-09 02:34:42 UTC (rev 12475) +++ trunk/x10.runtime/src-cpp/x10/io/InputStreamReader__InputStream.cc 2010-01-09 04:06:03 UTC (rev 12476) @@ -26,13 +26,13 @@ } void InputStreamReader__InputStream::_serialize_body(x10aux::serialization_buffer& buf) { - x10::lang::Ref::_serialize_body(buf); + x10::lang::Object::_serialize_body(buf); } void InputStreamReader__InputStream::_deserialize_body(x10aux::deserialization_buffer& buf) { - x10::lang::Ref::_deserialize_body(buf); + x10::lang::Object::_deserialize_body(buf); } -RTT_CC_DECLS1(InputStreamReader__InputStream, "x10.io.InputStreamReader.InputStream", Ref) +RTT_CC_DECLS1(InputStreamReader__InputStream, "x10.io.InputStreamReader.InputStream", Object) // vim:tabstop=4:shiftwidth=4:expandtab Modified: trunk/x10.runtime/src-cpp/x10/io/InputStreamReader__InputStream.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/io/InputStreamReader__InputStream.h 2010-01-09 02:34:42 UTC (rev 12475) +++ trunk/x10.runtime/src-cpp/x10/io/InputStreamReader__InputStream.h 2010-01-09 04:06:03 UTC (rev 12476) @@ -1,7 +1,7 @@ #ifndef X10_IO_NATIVEINPUTSTREAM_H #define X10_IO_NATIVEINPUTSTREAM_H -#include <x10/lang/Ref.h> +#include <x10/lang/Object.h> namespace x10 { @@ -11,7 +11,7 @@ namespace io { - class InputStreamReader__InputStream : public x10::lang::Ref { + class InputStreamReader__InputStream : public x10::lang::Object { public: RTT_H_DECLS_CLASS; @@ -23,7 +23,7 @@ public: x10aux::ref<InputStreamReader__InputStream> _constructor() { - this->x10::lang::Ref::_constructor(); + this->x10::lang::Object::_constructor(); return this; } Modified: trunk/x10.runtime/src-cpp/x10/io/OutputStreamWriter__OutputStream.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/io/OutputStreamWriter__OutputStream.cc 2010-01-09 02:34:42 UTC (rev 12475) +++ trunk/x10.runtime/src-cpp/x10/io/OutputStreamWriter__OutputStream.cc 2010-01-09 04:06:03 UTC (rev 12476) @@ -36,13 +36,13 @@ } void OutputStreamWriter__OutputStream::_serialize_body(x10aux::serialization_buffer& buf) { - x10::lang::Ref::_serialize_body(buf); + x10::lang::Object::_serialize_body(buf); } void OutputStreamWriter__OutputStream::_deserialize_body(x10aux::deserialization_buffer& buf) { - x10::lang::Ref::_deserialize_body(buf); + x10::lang::Object::_deserialize_body(buf); } -RTT_CC_DECLS1(OutputStreamWriter__OutputStream, "x10.io.OutputStreamWriter.OutputStream", Ref) +RTT_CC_DECLS1(OutputStreamWriter__OutputStream, "x10.io.OutputStreamWriter.OutputStream", Object) // vim:tabstop=4:shiftwidth=4:expandtab Modified: trunk/x10.runtime/src-cpp/x10/io/OutputStreamWriter__OutputStream.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/io/OutputStreamWriter__OutputStream.h 2010-01-09 02:34:42 UTC (rev 12475) +++ trunk/x10.runtime/src-cpp/x10/io/OutputStreamWriter__OutputStream.h 2010-01-09 04:06:03 UTC (rev 12476) @@ -1,7 +1,7 @@ #ifndef X10_IO_OUTPUTSTREAM_H #define X10_IO_OUTPUTSTREAM_H -#include <x10/lang/Ref.h> +#include <x10/lang/Object.h> namespace x10 { @@ -12,7 +12,7 @@ namespace io { - class OutputStreamWriter__OutputStream : public x10::lang::Ref { + class OutputStreamWriter__OutputStream : public x10::lang::Object { public: RTT_H_DECLS_CLASS; @@ -20,7 +20,7 @@ public: x10aux::ref<OutputStreamWriter__OutputStream> _constructor() { - this->x10::lang::Ref::_constructor(); + this->x10::lang::Object::_constructor(); return this; } Modified: trunk/x10.runtime/src-cpp/x10/lang/Any.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Any.cc 2010-01-09 02:34:42 UTC (rev 12475) +++ trunk/x10.runtime/src-cpp/x10/lang/Any.cc 2010-01-09 04:06:03 UTC (rev 12476) @@ -2,7 +2,6 @@ #include <x10aux/alloc.h> #include <x10/lang/Any.h> -#include <x10/lang/Ref.h> x10aux::RuntimeType x10::lang::Any::rtt; Modified: trunk/x10.runtime/src-cpp/x10/lang/Any.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Any.h 2010-01-09 02:34:42 UTC (rev 12475) +++ trunk/x10.runtime/src-cpp/x10/lang/Any.h 2010-01-09 04:06:03 UTC (rev 12476) @@ -12,7 +12,7 @@ namespace x10 { namespace lang { - class Ref; + class Object; class String; class Any { @@ -20,13 +20,13 @@ RTT_H_DECLS_INTERFACE template <class I> struct itable { - itable(x10_boolean (I::*_m0__at)(x10aux::ref<x10::lang::Ref>), + itable(x10_boolean (I::*_m0__at)(x10aux::ref<x10::lang::Object>), x10_boolean (I::*_m1__at)(x10::lang::Place), x10::lang::Place (I::*home)(), x10aux::ref<x10::lang::String> (I::*toString)(), x10aux::ref<x10::lang::String> (I::*typeName)()) : _m0__at(_m0__at), _m1__at(_m1__at), home(home), toString(toString), typeName(typeName) {} - x10_boolean (I::*_m0__at)(x10aux::ref<x10::lang::Ref>); + x10_boolean (I::*_m0__at)(x10aux::ref<x10::lang::Object>); x10_boolean (I::*_m1__at)(x10::lang::Place); x10::lang::Place (I::*home)(); x10aux::ref<x10::lang::String> (I::*toString)(); Modified: trunk/x10.runtime/src-cpp/x10/lang/Closure.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Closure.cc 2010-01-09 02:34:42 UTC (rev 12475) +++ trunk/x10.runtime/src-cpp/x10/lang/Closure.cc 2010-01-09 04:06:03 UTC (rev 12476) @@ -20,7 +20,7 @@ this_->_serialize_body(buf); } -x10_boolean Closure::at(x10aux::ref<x10::lang::Ref> o) { +x10_boolean Closure::at(x10aux::ref<x10::lang::Object> o) { return location == o->location; } Modified: trunk/x10.runtime/src-cpp/x10/lang/Closure.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Closure.h 2010-01-09 02:34:42 UTC (rev 12475) +++ trunk/x10.runtime/src-cpp/x10/lang/Closure.h 2010-01-09 04:06:03 UTC (rev 12476) @@ -47,7 +47,7 @@ return location == p->FMGL(id); } - virtual x10_boolean at(x10aux::ref<x10::lang::Ref> o); + virtual x10_boolean at(x10aux::ref<x10::lang::Object> o); virtual x10::lang::Place home(); Modified: trunk/x10.runtime/src-cpp/x10/lang/Deque.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Deque.cc 2010-01-09 02:34:42 UTC (rev 12475) +++ trunk/x10.runtime/src-cpp/x10/lang/Deque.cc 2010-01-09 04:06:03 UTC (rev 12476) @@ -25,7 +25,7 @@ } ref<Deque> Deque::_constructor() { - this->x10::lang::Ref::_constructor(); + this->x10::lang::Object::_constructor(); queue = x10aux::alloc<Slots>(); queue->capacity = INITIAL_QUEUE_CAPACITY; queue->data = x10aux::alloc<volatile void*>(INITIAL_QUEUE_CAPACITY * sizeof(void*)); @@ -36,7 +36,7 @@ } const serialization_id_t Deque::_serialization_id = - DeserializationDispatcher::addDeserializer(Deque::_deserializer<Ref>); + DeserializationDispatcher::addDeserializer(Deque::_deserializer<Object>); void Deque::growQueue() { Slots *oldQ = queue; @@ -109,14 +109,14 @@ } void Deque::_serialize_body(serialization_buffer &buf) { - this->Ref::_serialize_body(buf); + this->Object::_serialize_body(buf); } void Deque::_deserialize_body(deserialization_buffer& buf) { - this->Ref::_deserialize_body(buf); + this->Object::_deserialize_body(buf); } -RTT_CC_DECLS1(Deque, "x10.lang.Deque", Ref) +RTT_CC_DECLS1(Deque, "x10.lang.Deque", Object) // vim:tabstop=4:shiftwidth=4:expandtab Modified: trunk/x10.runtime/src-cpp/x10/lang/Deque.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Deque.h 2010-01-09 02:34:42 UTC (rev 12475) +++ trunk/x10.runtime/src-cpp/x10/lang/Deque.h 2010-01-09 04:06:03 UTC (rev 12476) @@ -8,7 +8,7 @@ #define X10_LANG_DEQUE_H #include <x10rt.h> -#include <x10/lang/Ref.h> +#include <x10/lang/Object.h> #include <x10aux/serialization.h> namespace x10 { @@ -22,7 +22,7 @@ * Expert Group and released to the public domain, as explained at * http://creativecommons.org/licenses/publicdomain */ - class Deque : public x10::lang::Ref { + class Deque : public x10::lang::Object { public: RTT_H_DECLS_CLASS; Modified: trunk/x10.runtime/src-cpp/x10/lang/Fun_0_0.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Fun_0_0.h 2010-01-09 02:34:42 UTC (rev 12475) +++ trunk/x10.runtime/src-cpp/x10/lang/Fun_0_0.h 2010-01-09 04:06:03 UTC (rev 12476) @@ -18,14 +18,14 @@ template <class I> struct itable { itable(R(I::*apply)(), - x10_boolean (I::*_m0__at)(x10aux::ref<x10::lang::Ref>), + x10_boolean (I::*_m0__at)(x10aux::ref<x10::lang::Object>), x10_boolean (I::*_m1__at)(x10::lang::Place), x10::lang::Place (I::*home)(), x10aux::ref<x10::lang::String> (I::*toString)(), x10aux::ref<x10::lang::String> (I::*typeName)() ) : apply(apply), _m0__at(_m0__at), _m1__at(_m1__at), home(home), toString(toString), typeName(typeName) {} R (I::*apply)(); - x10_boolean (I::*_m0__at)(x10aux::ref<x10::lang::Ref>); + x10_boolean (I::*_m0__at)(x10aux::ref<x10::lang::Object>); x10_boolean (I::*_m1__at)(x10::lang::Place); x10::lang::Place (I::*home)(); x10aux::ref<x10::lang::String> (I::*toString)(); Modified: trunk/x10.runtime/src-cpp/x10/lang/Fun_0_1.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Fun_0_1.h 2010-01-09 02:34:42 UTC (rev 12475) +++ trunk/x10.runtime/src-cpp/x10/lang/Fun_0_1.h 2010-01-09 04:06:03 UTC (rev 12476) @@ -20,14 +20,14 @@ template <class I> struct itable { itable(R (I::*apply)(P1), - x10_boolean (I::*_m0__at)(x10aux::ref<x10::lang::Ref>), + x10_boolean (I::*_m0__at)(x10aux::ref<x10::lang::Object>), x10_boolean (I::*_m1__at)(x10::lang::Place), x10::lang::Place (I::*home)(), x10aux::ref<x10::lang::String> (I::*toString)(), x10aux::ref<x10::lang::String> (I::*typeName)() ) : apply(apply), _m0__at(_m0__at), _m1__at(_m1__at), home(home), toString(toString), typeName(typeName) {} R (I::*apply)(P1); - x10_boolean (I::*_m0__at)(x10aux::ref<x10::lang::Ref>); + x10_boolean (I::*_m0__at)(x10aux::ref<x10::lang::Object>); x10_boolean (I::*_m1__at)(x10::lang::Place); x10::lang::Place (I::*home)(); x10aux::ref<x10::lang::String> (I::*toString)(); Modified: trunk/x10.runtime/src-cpp/x10/lang/Fun_0_2.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Fun_0_2.h 2010-01-09 02:34:42 UTC (rev 12475) +++ trunk/x10.runtime/src-cpp/x10/lang/Fun_0_2.h 2010-01-09 04:06:03 UTC (rev 12476) @@ -21,14 +21,14 @@ template <class I> struct itable { itable(R(I::*apply)(P1,P2), - x10_boolean (I::*_m0__at)(x10aux::ref<x10::lang::Ref>), + x10_boolean (I::*_m0__at)(x10aux::ref<x10::lang::Object>), x10_boolean (I::*_m1__at)(x10::lang::Place), x10::lang::Place (I::*home)(), x10aux::ref<x10::lang::String> (I::*toString)(), x10aux::ref<x10::lang::String> (I::*typeName)() ) : apply(apply), _m0__at(_m0__at), _m1__at(_m1__at), home(home), toString(toString), typeName(typeName) {} R (I::*apply)(P1,P2); - x10_boolean (I::*_m0__at)(x10aux::ref<x10::lang::Ref>); + x10_boolean (I::*_m0__at)(x10aux::ref<x10::lang::Object>); x10_boolean (I::*_m1__at)(x10::lang::Place); x10::lang::Place (I::*home)(); x10aux::ref<x10::lang::String> (I::*toString)(); Modified: trunk/x10.runtime/src-cpp/x10/lang/Fun_0_3.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Fun_0_3.h 2010-01-09 02:34:42 UTC (rev 12475) +++ trunk/x10.runtime/src-cpp/x10/lang/Fun_0_3.h 2010-01-09 04:06:03 UTC (rev 12476) @@ -22,14 +22,14 @@ template <class I> struct itable { itable(R(I::*apply)(P1,P2,P3), - x10_boolean (I::*_m0__at)(x10aux::ref<x10::lang::Ref>), + x10_boolean (I::*_m0__at)(x10aux::ref<x10::lang::Object>), x10_boolean (I::*_m1__at)(x10::lang::Place), x10::lang::Place (I::*home)(), x10aux::ref<x10::lang::String> (I::*toString)(), x10aux::ref<x10::lang::String> (I::*typeName)() ) : apply(apply), _m0__at(_m0__at), _m1__at(_m1__at), home(home), toString(toString), typeName(typeName) {} R (I::*apply)(P1,P2,P3); - x10_boolean (I::*_m0__at)(x10aux::ref<x10::lang::Ref>); + x10_boolean (I::*_m0__at)(x10aux::ref<x10::lang::Object>); x10_boolean (I::*_m1__at)(x10::lang::Place); x10::lang::Place (I::*home)(); x10aux::ref<x10::lang::String> (I::*toString)(); Modified: trunk/x10.runtime/src-cpp/x10/lang/Fun_0_4.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Fun_0_4.h 2010-01-09 02:34:42 UTC (rev 12475) +++ trunk/x10.runtime/src-cpp/x10/lang/Fun_0_4.h 2010-01-09 04:06:03 UTC (rev 12476) @@ -23,14 +23,14 @@ template <class I> struct itable { itable(R(I::*apply)(P1,P2,P3,P4), - x10_boolean (I::*_m0__at)(x10aux::ref<x10::lang::Ref>), + x10_boolean (I::*_m0__at)(x10aux::ref<x10::lang::Object>), x10_boolean (I::*_m1__at)(x10::lang::Place), x10::lang::Place (I::*home)(), x10aux::ref<x10::lang::String> (I::*toString)(), x10aux::ref<x10::lang::String> (I::*typeName)() ) : apply(apply), _m0__at(_m0__at), _m1__at(_m1__at), home(home), toString(toString), typeName(typeName) {} R (I::*apply)(P1,P2,P3,P4); - x10_boolean (I::*_m0__at)(x10aux::ref<x10::lang::Ref>); + x10_boolean (I::*_m0__at)(x10aux::ref<x10::lang::Object>); x10_boolean (I::*_m1__at)(x10::lang::Place); x10::lang::Place (I::*home)(); x10aux::ref<x10::lang::String> (I::*toString)(); Modified: trunk/x10.runtime/src-cpp/x10/lang/Fun_0_5.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Fun_0_5.h 2010-01-09 02:34:42 UTC (rev 12475) +++ trunk/x10.runtime/src-cpp/x10/lang/Fun_0_5.h 2010-01-09 04:06:03 UTC (rev 12476) @@ -24,14 +24,14 @@ template <class I> struct itable { itable(R(I::*apply)(P1,P2,P3,P4,P5), - x10_boolean (I::*_m0__at)(x10aux::ref<x10::lang::Ref>), + x10_boolean (I::*_m0__at)(x10aux::ref<x10::lang::Object>), x10_boolean (I::*_m1__at)(x10::lang::Place), x10::lang::Place (I::*home)(), x10aux::ref<x10::lang::String> (I::*toString)(), x10aux::ref<x10::lang::String> (I::*typeName)() ) : apply(apply), _m0__at(_m0__at), _m1__at(_m1__at), home(home), toString(toString), typeName(typeName) {} R (I::*apply)(P1,P2,P3,P4,P5); - x10_boolean (I::*_m0__at)(x10aux::ref<x10::lang::Ref>); + x10_boolean (I::*_m0__at)(x10aux::ref<x10::lang::Object>); x10_boolean (I::*_m1__at)(x10::lang::Place); x10::lang::Place (I::*home)(); x10aux::ref<x10::lang::String> (I::*toString)(); Modified: trunk/x10.runtime/src-cpp/x10/lang/Fun_0_6.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Fun_0_6.h 2010-01-09 02:34:42 UTC (rev 12475) +++ trunk/x10.runtime/src-cpp/x10/lang/Fun_0_6.h 2010-01-09 04:06:03 UTC (rev 12476) @@ -25,14 +25,14 @@ template <class I> struct itable { itable(R(I::*apply)(P1,P2,P3,P4,P5,P6), - x10_boolean (I::*_m0__at)(x10aux::ref<x10::lang::Ref>), + x10_boolean (I::*_m0__at)(x10aux::ref<x10::lang::Object>), x10_boolean (I::*_m1__at)(x10::lang::Place), x10::lang::Place (I::*home)(), x10aux::ref<x10::lang::String> (I::*toString)(), x10aux::ref<x10::lang::String> (I::*typeName)() ) : apply(apply), _m0__at(_m0__at), _m1__at(_m1__at), home(home), toString(toString), typeName(typeName) {} R (I::*apply)(P1,P2,P3,P4,P5,P6); - x10_boolean (I::*_m0__at)(x10aux::ref<x10::lang::Ref>); + x10_boolean (I::*_m0__at)(x10aux::ref<x10::lang::Object>); x10_boolean (I::*_m1__at)(x10::lang::Place); x10::lang::Place (I::*home)(); x10aux::ref<x10::lang::String> (I::*toString)(); Modified: trunk/x10.runtime/src-cpp/x10/lang/Fun_0_7.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Fun_0_7.h 2010-01-09 02:34:42 UTC (rev 12475) +++ trunk/x10.runtime/src-cpp/x10/lang/Fun_0_7.h 2010-01-09 04:06:03 UTC (rev 12476) @@ -25,14 +25,14 @@ template <class I> struct itable { itable(R(I::*apply)(P1,P2,P3,P4,P5,P6,P7), - x10_boolean (I::*_m0__at)(x10aux::ref<x10::lang::Ref>), + x10_boolean (I::*_m0__at)(x10aux::ref<x10::lang::Object>), x10_boolean (I::*_m1__at)(x10::lang::Place), x10::lang::Place (I::*home)(), x10aux::ref<x10::lang::String> (I::*toString)(), x10aux::ref<x10::lang::String> (I::*typeName)() ) : apply(apply), _m0__at(_m0__at), _m1__at(_m1__at), home(home), toString(toString), typeName(typeName) {} R (I::*apply)(P1,P2,P3,P4,P5,P6,P7); - x10_boolean (I::*_m0__at)(x10aux::ref<x10::lang::Ref>); + x10_boolean (I::*_m0__at)(x10aux::ref<x10::lang::Object>); x10_boolean (I::*_m1__at)(x10::lang::Place); x10::lang::Place (I::*home)(); x10aux::ref<x10::lang::String> (I::*toString)(); Modified: trunk/x10.runtime/src-cpp/x10/lang/Fun_0_8.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Fun_0_8.h 2010-01-09 02:34:42 UTC (rev 12475) +++ trunk/x10.runtime/src-cpp/x10/lang/Fun_0_8.h 2010-01-09 04:06:03 UTC (rev 12476) @@ -26,14 +26,14 @@ template <class I> struct itable { itable(R(I::*apply)(P1,P2,P3,P4,P5,P6,P7,P8), - x10_boolean (I::*_m0__at)(x10aux::ref<x10::lang::Ref>), + x10_boolean (I::*_m0__at)(x10aux::ref<x10::lang::Object>), x10_boolean (I::*_m1__at)(x10::lang::Place), x10::lang::Place (I::*home)(), x10aux::ref<x10::lang::String> (I::*toString)(), x10aux::ref<x10::lang::String> (I::*typeName)() ) : apply(apply), _m0__at(_m0__at), _m1__at(_m1__at), home(home), toString(toString), typeName(typeName) {} R (I::*apply)(P1,P2,P3,P4,P5,P6,P7,P8); - x10_boolean (I::*_m0__at)(x10aux::ref<x10::lang::Ref>); + x10_boolean (I::*_m0__at)(x10aux::ref<x10::lang::Object>); x10_boolean (I::*_m1__at)(x10::lang::Place); x10::lang::Place (I::*home)(); x10aux::ref<x10::lang::String> (I::*toString)(); Modified: trunk/x10.runtime/src-cpp/x10/lang/Fun_0_9.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Fun_0_9.h 2010-01-09 02:34:42 UTC (rev 12475) +++ trunk/x10.runtime/src-cpp/x10/lang/Fun_0_9.h 2010-01-09 04:06:03 UTC (rev 12476) @@ -27,14 +27,14 @@ template <class I> struct itable { itable(R(I::*apply)(P1,P2,P3,P4,P5,P6,P7,P8,P9), - x10_boolean (I::*_m0__at)(x10aux::ref<x10::lang::Ref>), + x10_boolean (I::*_m0__at)(x10aux::ref<x10::lang::Object>), x10_boolean (I::*_m1__at)(x10::lang::Place), x10::lang::Place (I::*home)(), x10aux::ref<x10::lang::String> (I::*toString)(), x10aux::ref<x10::lang::String> (I::*typeName)() ) : apply(apply), _m0__at(_m0__at), _m1__at(_m1__at), home(home), toString(toString), typeName(typeName) {} R (I::*apply)(P1,P2,P3,P4,P5,P6,P7,P8,P9); - x10_boolean (I::*_m0__at)(x10aux::ref<x10::lang::Ref>); + x10_boolean (I::*_m0__at)(x10aux::ref<x10::lang::Object>); x10_boolean (I::*_m1__at)(x10::lang::Place); x10::lang::Place (I::*home)(); x10aux::ref<x10::lang::String> (I::*toString)(); Modified: trunk/x10.runtime/src-cpp/x10/lang/Lock__ReentrantLock.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Lock__ReentrantLock.cc 2010-01-09 02:34:42 UTC (rev 12475) +++ trunk/x10.runtime/src-cpp/x10/lang/Lock__ReentrantLock.cc 2010-01-09 04:06:03 UTC (rev 12476) @@ -29,7 +29,7 @@ x10aux::ref<Lock__ReentrantLock> Lock__ReentrantLock::_make() { x10aux::ref<Lock__ReentrantLock> this_ = new (x10aux::alloc<Lock__ReentrantLock>()) Lock__ReentrantLock(); - this_->x10::lang::Ref::_constructor(); + this_->x10::lang::Object::_constructor(); this_->initialize(); return this_; } @@ -168,6 +168,6 @@ */ } -RTT_CC_DECLS1(Lock__ReentrantLock, "x10.lang.Lock__ReentrantLock", Ref) +RTT_CC_DECLS1(Lock__ReentrantLock, "x10.lang.Lock__ReentrantLock", Object) // vim:tabstop=4:shiftwidth=4:expandtab Modified: trunk/x10.runtime/src-cpp/x10/lang/Lock__ReentrantLock.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Lock__ReentrantLock.h 2010-01-09 02:34:42 UTC (rev 12475) +++ trunk/x10.runtime/src-cpp/x10/lang/Lock__ReentrantLock.h 2010-01-09 04:06:03 UTC (rev 12476) @@ -7,7 +7,7 @@ #ifndef X10_LANG_LOCK__REENTRANT_LOCK_H #define X10_LANG_LOCK__REENTRANT_LOCK_H -#include <x10/lang/Ref.h> +#include <x10/lang/Object.h> #include <pthread.h> @@ -24,7 +24,7 @@ * is not owned by another thread. The method will return * immediately if the calling thread already owns the lock. */ - class Lock__ReentrantLock : public x10::lang::Ref { + class Lock__ReentrantLock : public x10::lang::Object { public: RTT_H_DECLS_CLASS; Deleted: trunk/x10.runtime/src-cpp/x10/lang/Object.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Object.cc 2010-01-09 02:34:42 UTC (rev 12475) +++ trunk/x10.runtime/src-cpp/x10/lang/Object.cc 2010-01-09 04:06:03 UTC (rev 12476) @@ -1,9 +0,0 @@ -#include <x10aux/config.h> -#include <x10aux/alloc.h> - -#include <x10/lang/Object.h> - -using namespace x10::lang; -using namespace x10aux; - -// vim:tabstop=4:shiftwidth=4:expandtab Copied: trunk/x10.runtime/src-cpp/x10/lang/Object.cc (from rev 12475, trunk/x10.runtime/src-cpp/x10/lang/Ref.cc) =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Object.cc (rev 0) +++ trunk/x10.runtime/src-cpp/x10/lang/Object.cc 2010-01-09 04:06:03 UTC (rev 12476) @@ -0,0 +1,109 @@ +#include <x10aux/ref.h> +#include <x10aux/alloc.h> + +#include <x10/lang/Object.h> +#include <x10/lang/String.h> +#include <x10/lang/Place.h> + +using namespace x10::lang; +using namespace x10aux; + +x10aux::ref<Object> +Object::_make() { + return (new (x10aux::alloc<Object>()) Object())->_constructor(); +} + +x10::lang::Place x10::lang::Object::home() { + return x10::lang::Place_methods::_make(location); +} + +x10_int x10::lang::Object::hashCode() { + // STEP 1: Figure out the address to use as for the object. + void *v; + if (this->location == x10aux::here) { + v = (void*)this; + } else { + v = (void*)x10aux::get_remote_ref(this); + } + + // STEP 2: Combine the bits of the pointer into a 32 bit integer. + // Note: intentionally not doing some type-punning pointer thing here as + // the behavior of that is somewhat underdefined and tends to expose + // "interesting" behavior in C++ compilers (especially at high optimization level). + uint64_t v2 = (uint64_t)v; + x10_int lower = (x10_int)(v2 & 0xffffffff); + x10_int upper = (x10_int)(v2 >> 32); + x10_int hc = lower ^ upper; + return hc; +} + +x10aux::ref<x10::lang::String> x10::lang::Object::toString() { + return String::Lit(alloc_printf("%s@%p",this->_type()->name(),(void*)this)); +} + +x10aux::ref<x10::lang::String> x10::lang::Object::typeName() { + return x10::lang::String::Lit(_type()->name()); +} + +const serialization_id_t Object::_serialization_id = + DeserializationDispatcher::addDeserializer(Object::_deserializer<Object>); + +void Object::_serialize(ref<Object> this_, serialization_buffer &buf) +{ + serialization_id_t id = this_.isNull() ? 0 : this_->_get_serialization_id(); + _S_("Serializing a "<<ANSI_SER<<ANSI_BOLD<<"class id "<<id<<ANSI_RESET<<" to buf: "<<&buf); + buf.write(id); + // FIXME: maybe optimize nulls by moving the call below into the conditional? + _serialize_reference(this_, buf); + if (!this_.isNull()) { + _S_("Serializing the "<<ANSI_SER<<"class body"<<ANSI_RESET<<" to buf: "<<&buf); + this_->_serialize_body(buf); + } +} + +const serialization_id_t Object::_interface_serialization_id = + DeserializationDispatcher::addDeserializer(Object::_deserialize<Object>); + +void Object::_serialize_interface(serialization_buffer &buf) +{ + _serialize(this, buf); +} + +void Object::_serialize_reference(ref<Object> this_, serialization_buffer &buf) +{ + bool isNull = this_.isNull(); + x10_int loc = isNull ? 0 : this_->location; + buf.write(loc); + if (isNull) { + _S_("Serializing a "<<ANSI_SER<<ANSI_BOLD<<"null reference"<<ANSI_RESET<<" to buf: "<<&buf); + buf.write((x10_addr_t)0); + } else if (loc == x10aux::here) { + _S_("Serialising a "<<ANSI_SER<<ANSI_BOLD<<"local Object"<<ANSI_RESET<< + " object of type "<<this_->_type()->name()); + buf.write((x10_addr_t)(size_t)this_.operator->()); + } else { + _S_("Serialising a "<<ANSI_SER<<ANSI_BOLD<<"remote Object"<<ANSI_RESET<< + " object of type "<<this_->_type()->name()<<" (loc="<<loc<<")"); + x10_addr_t tmp = get_remote_ref(this_.operator->()); + buf.write(tmp); + } +} + +void Object::dealloc_object(Object* obj) { + _M_("Attempting to dealloc object "<<(void*)obj<<", location="<<obj->location); + obj->_destructor(); + if (obj->location == x10aux::here) + dealloc(obj); + else + dealloc_remote(obj); +} + +x10aux::RuntimeType x10::lang::Object::rtt; + +void x10::lang::Object::_initRTT() { + rtt.init(&rtt, "x10.lang.Object", 0, NULL, 0, NULL, NULL); +} + +itable_entry Object::_itables[1] = { itable_entry(NULL, (void*)x10aux::getRTT<Object>()) }; + +// vim:tabstop=4:shiftwidth=4:expandtab Deleted: trunk/x10.runtime/src-cpp/x10/lang/Object.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Object.h 2010-01-09 02:34:42 UTC (rev 12475) +++ trunk/x10.runtime/src-cpp/x10/lang/Object.h 2010-01-09 04:06:03 UTC (rev 12476) @@ -1,15 +0,0 @@ -#ifndef X10_LANG_OBJECT_H -#define X10_LANG_OBJECT_H - -#include <x10/lang/Reference.h> - -namespace x10 { - namespace lang { - class SomeObject : public Reference { - public: - }; - } -} - -#endif -// vim:tabstop=4:shiftwidth=4:expandtab:textwidth=100 Copied: trunk/x10.runtime/src-cpp/x10/lang/Object.h (from rev 12475, trunk/x10.runtime/src-cpp/x10/lang/Ref.h) =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Object.h (rev 0) +++ trunk/x10.runtime/src-cpp/x10/lang/Object.h 2010-01-09 04:06:03 UTC (rev 12476) @@ -0,0 +1,172 @@ +#ifndef X10_LANG_OBJECT_H +#define X10_LANG_OBJECT_H + +#include <x10aux/config.h> +#include <x10aux/ref.h> +#include <x10aux/RTT.h> +#include <x10aux/serialization.h> + +#include <x10/lang/Reference.h> + +#define X10_LANG_PLACE_H_NODEPS +#include <x10/lang/Place.struct_h> +#undef X10_LANG_PLACE_H_NODEPS + +#define X10_LANG_ANY_H_NODEPS +#include <x10/lang/Any.h> +#undef X10_LANG_ANY_H_NODEPS + +namespace x10 { + namespace lang { + + class String; + + class Object : public Reference { + private: + static x10aux::itable_entry _itables[1]; + + public: + RTT_H_DECLS_CLASS; + + virtual x10aux::itable_entry* _getITables() { return _itables; } + + static x10aux::ref<Object> _make(); + + x10aux::ref<Object> _constructor() { + location = x10aux::here; + return this; + } + + static const x10aux::serialization_id_t _serialization_id; + + static void _serialize(x10aux::ref<Object> this_, + x10aux::serialization_buffer &buf); + + static const x10aux::serialization_id_t _interface_serialization_id; + // Do not override + virtual x10aux::serialization_id_t _get_interface_serialization_id() { + _S_("===> Object's _get_interface_serialization_id() called"); + return _interface_serialization_id; + } + // Do not override + virtual void _serialize_interface(x10aux::serialization_buffer &buf); + + // A helper method for serializing reference state + // Client responsible for checking for null + static void _serialize_reference(x10aux::ref<Object> this_, + x10aux::serialization_buffer &buf); + + virtual x10aux::serialization_id_t _get_serialization_id() { return _serialization_id; }; + + virtual void _serialize_body(x10aux::serialization_buffer &buf) { } + + template<class T> static x10aux::ref<T> _deserializer(x10aux::deserialization_buffer &); + + template<class T> static x10aux::ref<T> _deserialize(x10aux::deserialization_buffer &buf); + + struct _reference_state { + x10_int loc; + x10aux::x10_addr_t ref; + }; + // A helper method for deserializing reference state + // Client responsible for checking for null + static Object::_reference_state _deserialize_reference_state(x10aux::deserialization_buffer &buf) { + _reference_state rr; + rr.loc = buf.read<x10_int>(); + rr.ref = buf.read<x10aux::x10_addr_t>(); + if (rr.ref == 0) { + _S_("Deserializing a "<<ANSI_SER<<ANSI_BOLD<<"null reference"<<ANSI_RESET<<" from buf: "<<&buf); + } + return rr; + } + + // A helper method for computing the final deserialized reference + // res is ignored if rr.ref is null, and could even be uninitialized + // res is freed if rr.loc is here + template<class R> static x10aux::ref<R> _finalize_reference(x10aux::ref<Object> res, Object::_reference_state rr); + + virtual void _deserialize_body(x10aux::deserialization_buffer &buf) { } + + template<class T> friend class x10aux::ref; + + virtual x10_int hashCode(); + + virtual x10aux::ref<String> toString(); + + virtual x10_boolean at(x10::lang::Place p) { + return location == p->FMGL(id); + } + + virtual x10_boolean at(x10aux::ref<x10::lang::Object> o) { + return location == o->location; + } + + virtual x10::lang::Place home(); + + virtual x10aux::ref<x10::lang::String> typeName(); + + // Needed for linking - do not override + virtual x10_boolean _struct_equals(x10aux::ref<Object> other) { + if (other == x10aux::ref<Object>(this)) return true; + if (this->location == x10aux::here) return false; // already tested above + if (other->location == this->location && + x10aux::get_remote_ref(other.operator->()) == x10aux::get_remote_ref(this)) + { + return true; + } + return false; + } + + // Like the destructor, but called only by dealloc_object() + // Needed only for native classes that have alloc'ed state + virtual void _destructor() { } + + static void dealloc_object(Object*); + }; + + template<class T> x10aux::ref<T> Object::_deserializer(x10aux::deserialization_buffer &buf) { + x10aux::ref<Object> this_ = new (x10aux::alloc_remote<Object>()) Object(); + buf.record_reference(this_); + this_->_deserialize_body(buf); + return this_; + } + + template<class T> x10aux::ref<T> Object::_deserialize(x10aux::deserialization_buffer &buf) { + // extract the id + x10aux::serialization_id_t id = buf.read<x10aux::serialization_id_t>(); + _reference_state rr = _deserialize_reference_state(buf); + x10aux::ref<Object> res; + if (rr.ref != 0) { + _S_("Deserializing a "<<ANSI_SER<<ANSI_BOLD<<"class"<<ANSI_RESET<< + " (with id "<<id<<") at "<<rr.loc<<" from buf: "<<&buf); + // execute a callback to instantiate the right concrete class + res = x10aux::DeserializationDispatcher::create<T>(buf, id); + } + // res is uninitialized if rr.ref is null + return _finalize_reference<T>(res, rr); + } + + // Given a deserialized object pointer (allocated with alloc_remote) and + // remote reference info, return the reference to the right object + template<class R> x10aux::ref<R> Object::_finalize_reference(x10aux::ref<Object> obj, Object::_reference_state rr) { + if (rr.ref == 0) { + return x10aux::null; + } + if (rr.loc == x10aux::here) { // a remote object coming home to roost + _S_("\ta local object come home"); + x10aux::dealloc_remote(obj.operator->()); + return static_cast<R*>((void*)(size_t)rr.ref); + } + _S_("Deserialized a "<<ANSI_SER<<ANSI_BOLD<<"class"<<ANSI_RESET<< + " "<<obj->_type()->name()); + obj->location = rr.loc; + x10aux::set_remote_ref(obj.operator->(), rr.ref); + return obj; + } + + } +} + + +#endif +// vim:tabstop=4:shiftwidth=4:expandtab Modified: trunk/x10.runtime/src-cpp/x10/lang/Rail.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Rail.cc 2010-01-09 02:34:42 UTC (rev 12475) +++ trunk/x10.runtime/src-cpp/x10/lang/Rail.cc 2010-01-09 04:06:03 UTC (rev 12476) @@ -2,7 +2,7 @@ #include <x10aux/alloc.h> #include <x10aux/RTT.h> -#include <x10/lang/Ref.h> +#include <x10/lang/Object.h> #include <x10/lang/Rail.h> #include <x10/lang/Runtime.h> #include <x10/lang/Runtime__FinishStates.h> @@ -17,7 +17,7 @@ void _initRTTHelper_Rail(RuntimeType *location, const RuntimeType *element, const RuntimeType *p1, const RuntimeType *p2) { - const RuntimeType *parents[3] = { Ref::getRTT(), p1, p2 }; + const RuntimeType *parents[3] = { Object::getRTT(), p1, p2 }; const RuntimeType *params[1] = { element }; RuntimeType::Variance variances[1] = { RuntimeType::invariant }; const RuntimeType *canonical = x10aux::getRTT<Rail<void> >(); Modified: trunk/x10.runtime/src-cpp/x10/lang/Rail.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Rail.h 2010-01-09 02:34:42 UTC (rev 12475) +++ trunk/x10.runtime/src-cpp/x10/lang/Rail.h 2010-01-09 04:06:03 UTC (rev 12476) @@ -7,7 +7,7 @@ #include <x10aux/rail_utils.h> #include <x10aux/itables.h> -#include <x10/lang/Ref.h> +#include <x10/lang/Object.h> #include <x10/lang/Place.struct_h> #include <x10/util/Pair.struct_h> @@ -35,7 +35,7 @@ const x10aux::RuntimeType *p1, const x10aux::RuntimeType *p2); - template<class T> class Rail : public Ref { + template<class T> class Rail : public Object { public: RTT_H_DECLS_CLASS; @@ -86,7 +86,7 @@ #if 0 virtual x10aux::ref<ValRail<T> > view (void) { ValRail<T>* rail = new (x10aux::alloc<ValRail<T> >()) ValRail<T>(FMGL(length),_data); - rail->x10::lang::Ref::_constructor(); + rail->x10::lang::Object::_constructor(); return rail; } #endif @@ -422,7 +422,7 @@ _X_("Finding a rail for cuda copyTo ("<<(int)code<<")"); switch (code) { case 0: { - Ref::_reference_state rr = Ref::_deserialize_reference_state(buf); + Object::_reference_state rr = Object::_deserialize_reference_state(buf); // doesn't work because we don't know what gpu we're going to // assert(rr.loc == here); addr = rr.ref; @@ -446,7 +446,7 @@ _X_("Completing a rail cuda copyTo ("<<(int)code<<")"); switch (code) { case 0: { - Ref::_reference_state rr = Ref::_deserialize_reference_state(buf); + Object::_reference_state rr = Object::_deserialize_reference_state(buf); buf.read<x10_int>(); buf.read<x10_int>(); Rail_notifyEnclosingFinish(buf); @@ -699,7 +699,7 @@ _X_("Finding a rail for copyFrom ("<<(int)code<<")"); switch (code) { case 0: { // get rail+offset explicitly - Ref::_reference_state rr = Ref::_deserialize_reference_state(buf); + Object::_reference_state rr = Object::_deserialize_reference_state(buf); // doesn't work because we don't know what gpu we're going to // assert(rr.loc == here); addr = rr.ref; @@ -830,12 +830,12 @@ template<class T> const x10aux::serialization_id_t Rail<T>::_serialization_id = x10aux::DeserializationDispatcher - ::addDeserializer(Rail<T>::template _deserializer<Ref>); + ::addDeserializer(Rail<T>::template _deserializer<Object>); // Specialized serialization template <class T> void Rail<T>::_serialize(x10aux::ref<Rail<T> > this_, x10aux::serialization_buffer &buf) { - Ref::_serialize_reference(this_, buf); + Object::_serialize_reference(this_, buf); if (this_ != x10aux::null) { this_->_serialize_body(buf); } @@ -844,12 +844,12 @@ template <class T> void Rail<T>::_serialize_body(x10aux::serialization_buffer &buf) { x10_int length = this->FMGL(length); buf.write(length); - this->Ref::_serialize_body(buf); // intentional change of order + this->Object::_serialize_body(buf); // intentional change of order } template <class T> void Rail<T>::_deserialize_body(x10aux::deserialization_buffer &buf) { // length read out earlier, in _deserializer() - this->Ref::_deserialize_body(buf); + this->Object::_deserialize_body(buf); } template <class T> template<class S> x10aux::ref<S> Rail<T>::_deserializer(x10aux::deserialization_buffer &buf) { @@ -865,12 +865,12 @@ // Specialized deserialization template <class T> template<class S> x10aux::ref<S> Rail<T>::_deserialize(x10aux::deserialization_buffer &buf) { - Ref::_reference_state rr = Ref::_deserialize_reference_state(buf); + Object::_reference_state rr = Object::_deserialize_reference_state(buf); R this_; if (rr.ref != 0) { this_ = Rail<T>::template _deserializer<Rail<T> >(buf); } - return Ref::_finalize_reference<T>(this_, rr); + return Object::_finalize_reference<T>(this_, rr); } } } Deleted: trunk/x10.runtime/src-cpp/x10/lang/Ref.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Ref.cc 2010-01-09 02:34:42 UTC (rev 12475) +++ trunk/x10.runtime/src-cpp/x10/lang/Ref.cc 2010-01-09 04:06:03 UTC (rev 12476) @@ -1,109 +0,0 @@ -#include <x10aux/ref.h> -#include <x10aux/alloc.h> - -#include <x10/lang/Ref.h> -#include <x10/lang/String.h> -#include <x10/lang/Place.h> - -using namespace x10::lang; -using namespace x10aux; - -x10aux::ref<Ref> -Ref::_make() { - return (new (x10aux::alloc<Ref>()) Ref())->_constructor(); -} - -x10::lang::Place x10::lang::Ref::home() { - return x10::lang::Place_methods::_make(location); -} - -x10_int x10::lang::Ref::hashCode() { - // STEP 1: Figure out the address to use as for the object. - void *v; - if (this->location == x10aux::here) { - v = (void*)this; - } else { - v = (void*)x10aux::get_remote_ref(this); - } - - // STEP 2: Combine the bits of the pointer into a 32 bit integer. - // Note: intentionally not doing some type-punning pointer thing here as - // the behavior of that is somewhat underdefined and tends to expose - // "interesting" behavior in C++ compilers (especially at high optimization level). - uint64_t v2 = (uint64_t)v; - x10_int lower = (x10_int)(v2 & 0xffffffff); - x10_int upper = (x10_int)(v2 >> 32); - x10_int hc = lower ^ upper; - return hc; -} - -x10aux::ref<x10::lang::String> x10::lang::Ref::toString() { - return String::Lit(alloc_printf("%s@%p",this->_type()->name(),(void*)this)); -} - -x10aux::ref<x10::lang::String> x10::lang::Ref::typeName() { - return x10::lang::String::Lit(_type()->name()); -} - -const serialization_id_t Ref::_serialization_id = - DeserializationDispatcher::addDeserializer(Ref::_deserializer<Ref>); - -void Ref::_serialize(ref<Ref> this_, serialization_buffer &buf) -{ - serialization_id_t id = this_.isNull() ? 0 : this_->_get_serialization_id(); - _S_("Serializing a "<<ANSI_SER<<ANSI_BOLD<<"class id "<<id<<ANSI_RESET<<" to buf: "<<&buf); - buf.write(id); - // FIXME: maybe optimize nulls by moving the call below into the conditional? - _serialize_reference(this_, buf); - if (!this_.isNull()) { - _S_("Serializing the "<<ANSI_SER<<"class body"<<ANSI_RESET<<" to buf: "<<&buf); - this_->_serialize_body(buf); - } -} - -const serialization_id_t Ref::_interface_serialization_id = - DeserializationDispatcher::addDeserializer(Ref::_deserialize<Ref>); - -void Ref::_serialize_interface(serialization_buffer &buf) -{ - _serialize(this, buf); -} - -void Ref::_serialize_reference(ref<Ref> this_, serialization_buffer &buf) -{ - bool isNull = this_.isNull(); - x10_int loc = isNull ? 0 : this_->location; - buf.write(loc); - if (isNull) { - _S_("Serializing a "<<ANSI_SER<<ANSI_BOLD<<"null reference"<<ANSI_RESET<<" to buf: "<<&buf); - buf.write((x10_addr_t)0); - } else if (loc == x10aux::here) { - _S_("Serialising a "<<ANSI_SER<<ANSI_BOLD<<"local Ref"<<ANSI_RESET<< - " object of type "<<this_->_type()->name()); - buf.write((x10_addr_t)(size_t)this_.operator->()); - } else { - _S_("Serialising a "<<ANSI_SER<<ANSI_BOLD<<"remote Ref"<<ANSI_RESET<< - " object of type "<<this_->_type()->name()<<" (loc="<<loc<<")"); - x10_addr_t tmp = get_remote_ref(this_.operator->()); - buf.write(tmp); - } -} - -void Ref::dealloc_object(Ref* obj) { - _M_("Attempting to dealloc object "<<(void*)obj<<", location="<<obj->location); - obj->_destructor(); - if (obj->location == x10aux::here) - dealloc(obj); - else - dealloc_remote(obj); -} - -x10aux::RuntimeType x10::lang::Ref::rtt; - -void x10::lang::Ref::_initRTT() { - rtt.init(&rtt, "x10.lang.Object", 0, NULL, 0, NULL, NULL); -} - -itable_entry Ref::_itables[1] = { itable_entry(NULL, (void*)x10aux::getRTT<Ref>()) }; - -// vim:tabstop=4:shiftwidth=4:expandtab Deleted: trunk/x10.runtime/src-cpp/x10/lang/Ref.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Ref.h 2010-01-09 02:34:42 UTC (rev 12475) +++ trunk/x10.runtime/src-cpp/x10/lang/Ref.h 2010-01-09 04:06:03 UTC (rev 12476) @@ -1,173 +0,0 @@ -#ifndef X10_LANG_REF_H -#define X10_LANG_REF_H - -#include <x10aux/config.h> -#include <x10aux/ref.h> -#include <x10aux/RTT.h> -#include <x10aux/serialization.h> - -#include <x10/lang/Object.h> - -#define X10_LANG_PLACE_H_NODEPS -#include <x10/lang/Place.struct_h> -#undef X10_LANG_PLACE_H_NODEPS - -#define X10_LANG_ANY_H_NODEPS -#include <x10/lang/Any.h> -#undef X10_LANG_ANY_H_NODEPS - -namespace x10 { - - namespace lang { - - class String; - - class Ref : public SomeObject { - private: - static x10aux::itable_entry _itables[1]; - - public: - RTT_H_DECLS_CLASS; - - virtual x10aux::itable_entry* _getITables() { return _itables; } - - static x10aux::ref<Ref> _make(); - - x10aux::ref<Ref> _constructor() { - location = x10aux::here; - return this; - } - - static const x10aux::serialization_id_t _serialization_id; - - static void _serialize(x10aux::ref<Ref> this_, - x10aux::serialization_buffer &buf); - - static const x10aux::serialization_id_t _interface_serialization_id; - // Do not override - virtual x10aux::serialization_id_t _get_interface_serialization_id() { - _S_("===> Ref's _get_interface_serialization_id() called"); - return _interface_serialization_id; - } - // Do not override - virtual void _serialize_interface(x10aux::serialization_buffer &buf); - - // A helper method for serializing reference state - // Client responsible for checking for null - static void _serialize_reference(x10aux::ref<Ref> this_, - x10aux::serialization_buffer &buf); - - virtual x10aux::serialization_id_t _get_serialization_id() { return _serialization_id; }; - - virtual void _serialize_body(x10aux:... [truncated message content] |
From: <ta...@us...> - 2010-01-09 04:35:10
|
Revision: 12477 http://x10.svn.sourceforge.net/x10/?rev=12477&view=rev Author: tardieu Date: 2010-01-09 04:34:59 +0000 (Sat, 09 Jan 2010) Log Message: ----------- added support for @NativeClass structs and type parameters replace @NativeRep PlaceLocalHandle with @NativeClass Modified Paths: -------------- trunk/x10.compiler/src/x10/visit/NativeClassVisitor.java trunk/x10.runtime/src-cpp/Makefile trunk/x10.runtime/src-cpp/x10/lang/Rail.cc trunk/x10.runtime/src-cpp/x10aux/network.cc trunk/x10.runtime/src-java/x10/runtime/impl/java/PlaceLocalHandle.java trunk/x10.runtime/src-x10/x10/lang/PlaceLocalHandle.x10 Added Paths: ----------- trunk/x10.runtime/src-cpp/x10/lang/PlaceLocalHandle_Impl.cc trunk/x10.runtime/src-cpp/x10/lang/PlaceLocalHandle_Impl.h trunk/x10.runtime/src-cpp/x10/lang/PlaceLocalHandle_Impl.struct_h Removed Paths: ------------- trunk/x10.runtime/src-cpp/x10/lang/PlaceLocalHandle.cc trunk/x10.runtime/src-cpp/x10/lang/PlaceLocalHandle.h trunk/x10.runtime/src-cpp/x10/lang/PlaceLocalHandle.struct_h Modified: trunk/x10.compiler/src/x10/visit/NativeClassVisitor.java =================================================================== --- trunk/x10.compiler/src/x10/visit/NativeClassVisitor.java 2010-01-09 04:06:03 UTC (rev 12476) +++ trunk/x10.compiler/src/x10/visit/NativeClassVisitor.java 2010-01-09 04:34:59 UTC (rev 12477) @@ -53,6 +53,7 @@ import x10.ast.X10MethodDecl; import x10.ast.X10NodeFactory; import x10.extension.X10Ext; +import x10.types.ParameterType; import x10.types.X10Def; import x10.types.X10ConstructorDef; import x10.types.X10ClassDef; @@ -154,13 +155,25 @@ Position p = Position.COMPILER_GENERATED; // create fake def for native class - ClassDef fake = xts.createClassDef(); + X10ClassDef fake = (X10ClassDef) xts.createClassDef(); fake.name(Name.make(cname)); fake.kind(ClassDef.TOP_LEVEL); fake.setFromEncodedClassFile(); - fake.setFlags(X10Flags.NONE); + if (cdef.isStruct()) { + fake.setFlags(X10Flags.STRUCT); + } else { + fake.setFlags(X10Flags.NONE); + } fake.setPackage(Types.ref(ts.packageForName(QName.make(getNativeClassPackage(cdef))))); + java.util.Iterator<ParameterType> ps = cdef.typeParameters().iterator(); + java.util.Iterator<ParameterType.Variance> vs = cdef.variances().iterator(); + while (ps.hasNext()) { + ParameterType pp = ps.next(); + ParameterType.Variance vv = vs.next(); + fake.addTypeParameter(pp, vv); + } + // add field with native type Name fname = Name.make("__NATIVE_FIELD__"); Id fid = xnf.Id(p, fname); @@ -169,6 +182,7 @@ Flags fflags = X10Flags.GLOBAL.Private().Final(); FieldDef fdef = xts.fieldDef(p, Types.ref(cdef.asType()), fflags, Types.ref(ftype), fname); cmembers.add(xnf.FieldDecl(p, xnf.FlagsNode(p, fflags), ftnode, fid).fieldDef(fdef)); + cdef.addField(fdef); // field selector Receiver special = xnf.This(p).type(cdef.asType()); @@ -187,7 +201,7 @@ ConstructorDef sdef = xts.findConstructor(cdecl.superClass().type(), xts.ConstructorMatcher(cdecl.superClass().type(), Collections.<Type>emptyList(), context)).def(); - ConstructorDecl xd = xnf.ConstructorDecl(p, + X10ConstructorDecl xd = (X10ConstructorDecl) xnf.ConstructorDecl(p, xnf.FlagsNode(p, X10Flags.PRIVATE), cdecl.name(), Collections.<Formal>singletonList(f), @@ -195,6 +209,8 @@ xnf.Block(p, xnf.SuperCall(p, Collections.<Expr>emptyList()).constructorInstance(sdef.asInstance()), xnf.Eval(p, assign))); + xd.typeParameters(cdecl.typeParameters()); + xd.returnType(ftnode); ConstructorDef xdef = xts.constructorDef(p, Types.ref(cdef.asType()), @@ -235,6 +251,7 @@ // reuse x10 method instance for delegate method but make it global to avoid place check MethodInstance minst = mdef.asInstance(); minst = (MethodInstance) minst.flags(((X10Flags) minst.flags()).Global()); + minst = (MethodInstance) minst.container(ftype); // call delegate Receiver target = mdef.flags().isStatic() ? ftnode : field; @@ -299,7 +316,7 @@ } if (!hasNativeConstructor) { - throw new SemanticException("@NativeClass " + cdecl.name() + " must be declare a native constructor."); + throw new SemanticException("@NativeClass " + cdecl.name() + " must declare a native constructor."); } return cdecl.body(cbody.members(cmembers)); Modified: trunk/x10.runtime/src-cpp/Makefile =================================================================== --- trunk/x10.runtime/src-cpp/Makefile 2010-01-09 04:06:03 UTC (rev 12476) +++ trunk/x10.runtime/src-cpp/Makefile 2010-01-09 04:34:59 UTC (rev 12477) @@ -250,7 +250,7 @@ x10/lang/ValRail.o \ x10/lang/Deque.o \ x10/lang/Lock__ReentrantLock.o \ - x10/lang/PlaceLocalHandle.o \ + x10/lang/PlaceLocalHandle_Impl.o \ x10/lang/Thread.o \ x10/util/GrowableRail.o \ x10/util/concurrent/atomic/AtomicBoolean.o \ Deleted: trunk/x10.runtime/src-cpp/x10/lang/PlaceLocalHandle.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/PlaceLocalHandle.cc 2010-01-09 04:06:03 UTC (rev 12476) +++ trunk/x10.runtime/src-cpp/x10/lang/PlaceLocalHandle.cc 2010-01-09 04:34:59 UTC (rev 12477) @@ -1,25 +0,0 @@ -#include <x10aux/config.h> -#include <x10aux/alloc.h> -#include <x10aux/RTT.h> - -#include <x10/lang/PlaceLocalHandle.h> - -using namespace x10aux; -using namespace x10::lang; - -namespace x10 { - namespace lang { - - x10aux::RuntimeType PlaceLocalHandle<void>::rtt; - - void - _initRTTHelper_PlaceLocalHandle(RuntimeType *location, const RuntimeType *rtt) { - const RuntimeType* params[1] = { rtt }; - RuntimeType::Variance variances[1] = { RuntimeType::invariant }; - const RuntimeType *canonical = x10aux::getRTT<PlaceLocalHandle<void> >(); - const char *name = alloc_printf("x10.lang.PlaceLocalHandle[+%s]",rtt->name()); - location->init(canonical, name, 0, NULL, 1, params, variances); - } - } -} - Deleted: trunk/x10.runtime/src-cpp/x10/lang/PlaceLocalHandle.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/PlaceLocalHandle.h 2010-01-09 04:06:03 UTC (rev 12476) +++ trunk/x10.runtime/src-cpp/x10/lang/PlaceLocalHandle.h 2010-01-09 04:34:59 UTC (rev 12477) @@ -1,15 +0,0 @@ -#ifndef X10_LANG_PLACELOCALHANDLE_H -#define X10_LANG_PLACELOCALHANDLE_H - -#include <x10rt.h> - -#include <x10/lang/PlaceLocalHandle.struct_h> - -namespace x10 { - namespace lang { - namespace PlaceLocalHandle_ns { - } - } -} -#endif - Deleted: trunk/x10.runtime/src-cpp/x10/lang/PlaceLocalHandle.struct_h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/PlaceLocalHandle.struct_h 2010-01-09 04:06:03 UTC (rev 12476) +++ trunk/x10.runtime/src-cpp/x10/lang/PlaceLocalHandle.struct_h 2010-01-09 04:34:59 UTC (rev 12477) @@ -1,99 +0,0 @@ -#ifndef X10_LANG_PLACELOCALHANDLE_STRUCT_H -#define X10_LANG_PLACELOCALHANDLE_STRUCT_H - -#include <x10rt.h> - -#include <x10/lang/String.h> - -namespace x10 { - namespace lang { - - void _initRTTHelper_PlaceLocalHandle(x10aux::RuntimeType *location, const x10aux::RuntimeType *rtt); - - template <class T> class PlaceLocalHandle { - public: - RTT_H_DECLS_STRUCT - - T FMGL(localStorage); - x10_int FMGL(id); - bool FMGL(cached); - - PlaceLocalHandle<T>* operator->() { return this; } - - static PlaceLocalHandle<T> createHandle() { - PlaceLocalHandle<T> result; - x10_int id = x10aux::place_local::nextId(); - result.FMGL(id) = id; - result.FMGL(cached) = false; - return result; - } - - void set(T newVal) { - assert(!FMGL(cached)); - FMGL(localStorage) = newVal; - FMGL(cached) = true; - T *tmp = x10aux::alloc<T>(); - *tmp = newVal; - x10aux::place_local::registerData(FMGL(id), (void*)tmp); - } - - T get() { - if (!FMGL(cached)) { - T *tmp = (T*)(x10aux::place_local::lookupData(FMGL(id))); - FMGL(localStorage) = *tmp; - FMGL(cached) = true; - } - return FMGL(localStorage); - } - - x10aux::ref<x10::lang::String> toString() { - if (FMGL(cached)) { - return x10aux::to_string(FMGL(localStorage)); - } else { - return x10::lang::String::Lit("PlaceLocalHandle(uncached data)"); - } - } - - x10_int hashCode() { - return x10aux::hash_code(FMGL(id)); - } - - - x10_boolean _struct_equals(PlaceLocalHandle<T> that) { - return FMGL(id) == that->FMGL(id); - } - - static void _serialize(PlaceLocalHandle<T> this_, x10aux::serialization_buffer &buf); - - static PlaceLocalHandle<T> _deserialize(x10aux::deserialization_buffer& buf); - }; - - template <> class PlaceLocalHandle<void> { - public: - static x10aux::RuntimeType rtt; - static const x10aux::RuntimeType* getRTT() { return &rtt; } - }; - - template<class T> void PlaceLocalHandle<T>::_initRTT() { - rtt.canonical = &rtt; - x10::lang::_initRTTHelper_PlaceLocalHandle(&rtt, x10aux::getRTT<T>()); - } - - template<class T> x10aux::RuntimeType PlaceLocalHandle<T>::rtt; - - template <class T> void PlaceLocalHandle<T>::_serialize(PlaceLocalHandle<T> this_, x10aux::serialization_buffer &buf) { - // NOTE specialized semantics. Only id is serialized, cached and localStorage are place local! - buf.write(this_->FMGL(id)); - } - - template<class T> PlaceLocalHandle<T> PlaceLocalHandle<T>::_deserialize(x10aux::deserialization_buffer& buf) { - // NOTE specialized semantics. Only id is serialized, cached is automatically set to false; will be looked up on first use. - PlaceLocalHandle<T> this_; - this_->FMGL(id) = buf.read<x10_int>(); - this_->FMGL(cached) = false; - return this_; - } - } -} -#endif - Copied: trunk/x10.runtime/src-cpp/x10/lang/PlaceLocalHandle_Impl.cc (from rev 12466, trunk/x10.runtime/src-cpp/x10/lang/PlaceLocalHandle.cc) =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/PlaceLocalHandle_Impl.cc (rev 0) +++ trunk/x10.runtime/src-cpp/x10/lang/PlaceLocalHandle_Impl.cc 2010-01-09 04:34:59 UTC (rev 12477) @@ -0,0 +1,25 @@ +#include <x10aux/config.h> +#include <x10aux/alloc.h> +#include <x10aux/RTT.h> + +#include <x10/lang/PlaceLocalHandle_Impl.h> + +using namespace x10aux; +using namespace x10::lang; + +namespace x10 { + namespace lang { + + x10aux::RuntimeType PlaceLocalHandle_Impl<void>::rtt; + + void + _initRTTHelper_PlaceLocalHandle_Impl(RuntimeType *location, const RuntimeType *rtt) { + const RuntimeType* params[1] = { rtt }; + RuntimeType::Variance variances[1] = { RuntimeType::invariant }; + const RuntimeType *canonical = x10aux::getRTT<PlaceLocalHandle_Impl<void> >(); + const char *name = alloc_printf("x10.lang.PlaceLocalHandle_Impl[+%s]",rtt->name()); + location->init(canonical, name, 0, NULL, 1, params, variances); + } + } +} + Copied: trunk/x10.runtime/src-cpp/x10/lang/PlaceLocalHandle_Impl.h (from rev 12466, trunk/x10.runtime/src-cpp/x10/lang/PlaceLocalHandle.h) =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/PlaceLocalHandle_Impl.h (rev 0) +++ trunk/x10.runtime/src-cpp/x10/lang/PlaceLocalHandle_Impl.h 2010-01-09 04:34:59 UTC (rev 12477) @@ -0,0 +1,15 @@ +#ifndef X10_LANG_PLACELOCALHANDLE_IMPL_H +#define X10_LANG_PLACELOCALHANDLE_IMPL_H + +#include <x10rt.h> + +#include <x10/lang/PlaceLocalHandle_Impl.struct_h> + +namespace x10 { + namespace lang { + namespace PlaceLocalHandle_Impl_ns { + } + } +} +#endif + Copied: trunk/x10.runtime/src-cpp/x10/lang/PlaceLocalHandle_Impl.struct_h (from rev 12466, trunk/x10.runtime/src-cpp/x10/lang/PlaceLocalHandle.struct_h) =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/PlaceLocalHandle_Impl.struct_h (rev 0) +++ trunk/x10.runtime/src-cpp/x10/lang/PlaceLocalHandle_Impl.struct_h 2010-01-09 04:34:59 UTC (rev 12477) @@ -0,0 +1,118 @@ +#ifndef X10_LANG_PLACELOCALHANDLE_IMPL_STRUCT_H +#define X10_LANG_PLACELOCALHANDLE_IMPL_STRUCT_H + +#include <x10rt.h> + +#include <x10/lang/String.h> + +namespace x10 { + namespace lang { + + void _initRTTHelper_PlaceLocalHandle_Impl(x10aux::RuntimeType *location, const x10aux::RuntimeType *rtt); + + template <class T> class PlaceLocalHandle_Impl { + public: + RTT_H_DECLS_STRUCT + + T FMGL(localStorage); + x10_int FMGL(id); + bool FMGL(cached); + + PlaceLocalHandle_Impl<T>* operator->() { return this; } + + void set(T newVal) { + assert(!FMGL(cached)); + FMGL(localStorage) = newVal; + FMGL(cached) = true; + T *tmp = x10aux::alloc<T>(); + *tmp = newVal; + x10aux::place_local::registerData(FMGL(id), (void*)tmp); + } + + T apply() { + if (!FMGL(cached)) { + T *tmp = (T*)(x10aux::place_local::lookupData(FMGL(id))); + FMGL(localStorage) = *tmp; + FMGL(cached) = true; + } + return FMGL(localStorage); + } + + x10aux::ref<x10::lang::String> toString() { + if (FMGL(cached)) { + return x10aux::to_string(FMGL(localStorage)); + } else { + return x10::lang::String::Lit("PlaceLocalHandle_Impl(uncached data)"); + } + } + + x10_int hashCode() { + return x10aux::hash_code(FMGL(id)); + } + + + x10_boolean _struct_equals(PlaceLocalHandle_Impl<T> that) { + return FMGL(id) == that->FMGL(id); + } + + static void _serialize(PlaceLocalHandle_Impl<T> this_, x10aux::serialization_buffer &buf); + + static PlaceLocalHandle_Impl<T> _deserialize(x10aux::deserialization_buffer& buf); + }; + + template <> class PlaceLocalHandle_Impl<void> { + public: + static x10aux::RuntimeType rtt; + static const x10aux::RuntimeType* getRTT() { return &rtt; } + }; + + template<class T> void PlaceLocalHandle_Impl<T>::_initRTT() { + rtt.canonical = &rtt; + x10::lang::_initRTTHelper_PlaceLocalHandle_Impl(&rtt, x10aux::getRTT<T>()); + } + + template<class T> x10aux::RuntimeType PlaceLocalHandle_Impl<T>::rtt; + + template <class T> void PlaceLocalHandle_Impl<T>::_serialize(PlaceLocalHandle_Impl<T> this_, x10aux::serialization_buffer &buf) { + // NOTE specialized semantics. Only id is serialized, cached and localStorage are place local! + buf.write(this_->FMGL(id)); + } + + template<class T> PlaceLocalHandle_Impl<T> PlaceLocalHandle_Impl<T>::_deserialize(x10aux::deserialization_buffer& buf) { + // NOTE specialized semantics. Only id is serialized, cached is automatically set to false; will be looked up on first use. + PlaceLocalHandle_Impl<T> this_; + this_->FMGL(id) = buf.read<x10_int>(); + this_->FMGL(cached) = false; + return this_; + } + + template <class T> class PlaceLocalHandle_Impl_methods { + public: + static PlaceLocalHandle_Impl<T> _make() { + PlaceLocalHandle_Impl<T> result; + x10_int id = x10aux::place_local::nextId(); + result.FMGL(id) = id; + result.FMGL(cached) = false; + return result; + } + + static T apply(PlaceLocalHandle_Impl<T> this_) { + return this_.apply(); + } + + static void set(PlaceLocalHandle_Impl<T> this_, T newVal) { + this_.set(newVal); + } + + static x10_int hashCode(PlaceLocalHandle_Impl<T> this_) { + return this_.hashCode(); + } + + static x10aux::ref<x10::lang::String> toString(PlaceLocalHandle_Impl<T> this_) { + return this_.toString(); + } + }; + } +} +#endif + Modified: trunk/x10.runtime/src-cpp/x10/lang/Rail.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Rail.cc 2010-01-09 04:06:03 UTC (rev 12476) +++ trunk/x10.runtime/src-cpp/x10/lang/Rail.cc 2010-01-09 04:34:59 UTC (rev 12477) @@ -30,7 +30,7 @@ void x10::lang::Rail_notifyEnclosingFinish(deserialization_buffer& buf) { ref<Reference> fs = buf.read<ref<Reference> >(); - ref<x10::lang::Runtime> rt = x10::lang::Runtime::FMGL(runtime)->get(); + ref<x10::lang::Runtime> rt = x10::lang::PlaceLocalHandle_methods<x10aux::ref<x10::lang::Runtime> >::apply(x10::lang::Runtime::FMGL(runtime)); // olivier says the incr should be just after the notifySubActivitySpawn (fs.operator->()->*(findITable<x10::lang::Runtime__FinishState>(fs->_getITables())->notifyActivityCreation))(); (fs.operator->()->*(findITable<x10::lang::Runtime__FinishState>(fs->_getITables())->notifyActivityTermination))(); @@ -40,7 +40,7 @@ { // dst is the place where the finish update will occur, i.e. where the notifier runs dst = x10aux::parent(dst); - ref<x10::lang::Runtime> rt = x10::lang::Runtime::FMGL(runtime)->get(); + ref<x10::lang::Runtime> rt = x10::lang::PlaceLocalHandle_methods<x10aux::ref<x10::lang::Runtime> >::apply(x10::lang::Runtime::FMGL(runtime)); ref<Reference> fs = rt->currentState(); (fs.operator->()->*(findITable<x10::lang::Runtime__FinishState>(fs->_getITables())->notifySubActivitySpawn))(x10::lang::Place_methods::_make(dst)); buf.write(fs); Modified: trunk/x10.runtime/src-cpp/x10aux/network.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/network.cc 2010-01-09 04:06:03 UTC (rev 12476) +++ trunk/x10.runtime/src-cpp/x10aux/network.cc 2010-01-09 04:34:59 UTC (rev 12477) @@ -285,7 +285,7 @@ remote_free(p.dest_place, (x10_ulong)(size_t)env); x10aux::deserialization_buffer buf(static_cast<char*>(p.msg)); x10aux::ref<x10::lang::Reference> fs = buf.read<x10aux::ref<x10::lang::Reference> >(); - x10aux::ref<x10::lang::Runtime> rt = x10::lang::Runtime::FMGL(runtime)->get(); + x10aux::ref<x10::lang::Runtime> rt = x10::lang::PlaceLocalHandle_methods<x10aux::ref<x10::lang::Runtime> >::apply(x10::lang::Runtime::FMGL(runtime)); (fs.operator->()->*(x10aux::findITable<x10::lang::Runtime__FinishState>(fs->_getITables())->notifyActivityCreation))(); (fs.operator->()->*(x10aux::findITable<x10::lang::Runtime__FinishState>(fs->_getITables())->notifyActivityTermination))(); } Modified: trunk/x10.runtime/src-java/x10/runtime/impl/java/PlaceLocalHandle.java =================================================================== --- trunk/x10.runtime/src-java/x10/runtime/impl/java/PlaceLocalHandle.java 2010-01-09 04:06:03 UTC (rev 12476) +++ trunk/x10.runtime/src-java/x10/runtime/impl/java/PlaceLocalHandle.java 2010-01-09 04:34:59 UTC (rev 12477) @@ -17,11 +17,11 @@ public final class PlaceLocalHandle<T>{ private final Object[] objects; - private PlaceLocalHandle() { + public PlaceLocalHandle(Object t) { objects = new Object[Runtime.MAX_PLACES]; } - public T get() { + public T apply() { int here = Thread.currentThread().home(); Object data = objects[here]; assert data != null : "At "+here+": get called on uninitialized local object"; @@ -33,8 +33,4 @@ assert objects[here] == null : "At "+here+" set called on already initialized local object"; objects[here] = data; } - - public static <T> PlaceLocalHandle<T> createHandle() { - return new PlaceLocalHandle<T>(); - } } Modified: trunk/x10.runtime/src-x10/x10/lang/PlaceLocalHandle.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/PlaceLocalHandle.x10 2010-01-09 04:06:03 UTC (rev 12476) +++ trunk/x10.runtime/src-x10/x10/lang/PlaceLocalHandle.x10 2010-01-09 04:34:59 UTC (rev 12477) @@ -9,7 +9,7 @@ package x10.lang; import x10.compiler.Native; -import x10.compiler.NativeRep; +import x10.compiler.NativeClass; /** * A PlaceLocalHandle is used in conjunction with the PlaceLocalStorage @@ -32,45 +32,34 @@ * using the particular PlaceLocalHandle (mapping the same object at * multiple places or mapping distinct object at each place).</p> */ -@NativeRep("c++", "x10::lang::PlaceLocalHandle<#1 >", "x10::lang::PlaceLocalHandle<#1 >", null) -@NativeRep("java", "x10.runtime.impl.java.PlaceLocalHandle<#1>", null, null) +@NativeClass("c++", "x10.lang", "PlaceLocalHandle_Impl") +@NativeClass("java", "x10.runtime.impl.java", "PlaceLocalHandle") public final struct PlaceLocalHandle[T]{T <: Object} { - /** - * @return the object mapped to the handle at the current place - */ - // TODO: make everyone use apply() instead - @Native("c++", "(#0)->get()") - @Native("java", "#0.get()") - public native safe def get():T!; + public native def this(); - @Native("c++", "(#0)->get()") - @Native("java", "#0.get()") - public native safe def apply():T!; + /** + * @return the object mapped to the handle at the current place + */ + public native safe def apply():T!; - @Native("c++", "(#0)->hashCode()") - @Native("java", "#0.hashCode()") - public native safe def hashCode():int; + // TODO: make everyone use apply() instead + public safe def get():T! = apply(); - @Native("c++", "(#0)->toString()") - @Native("java", "#0.toString()") - public global safe native def toString():String; + // Only to be used by create methods in PlaceLocalStorage + public native def set(newVal:T!):void; - // Only to be used by create methods in PlaceLocalStorage - @Native("c++", "(#0)->set(#1)") - @Native("java", "#0.set(#1)") - native def set(newVal:T!):void; + // Only to be used by create methods in PlaceLocalStorage + static def createHandle[T]():PlaceLocalHandle[T] = PlaceLocalHandle[T](); - // Only to be used by create methods in PlaceLocalStorage - @Native("c++", "x10::lang::PlaceLocalHandle<#1 >::createHandle()") - @Native("java", "x10.runtime.impl.java.PlaceLocalHandle.createHandle()") - static native def createHandle[T]():PlaceLocalHandle[T]; + public native safe def hashCode():int; + public global safe native def toString():String; - @Native("java", "x10.lang.System.copyTo(#0,#1,#2,#3)") - @Native("c++", "x10::lang::System::copyTo(#0,#1,#2,#3)") - public native def copyTo (dst:Place, len:Int, notifier:()=>Void) : Void; - + // TODO: fix guard and cast + public def copyTo[U](dst:Place, len:Int, notifier:()=>Void)/* {T<:Rail[U]} */:Void { + x10.lang.System.copyTo[U](this as Any as PlaceLocalHandle[Rail[U]], dst, len, notifier); + } } // vim:shiftwidth=4:tabstop=4:expandtab This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ta...@us...> - 2010-01-09 17:36:57
|
Revision: 12479 http://x10.svn.sourceforge.net/x10/?rev=12479&view=rev Author: tardieu Date: 2010-01-09 17:36:50 +0000 (Sat, 09 Jan 2010) Log Message: ----------- merged PlaceLocalHandle and PlaceLocalStorage Modified Paths: -------------- trunk/x10.runtime/src-x10/x10/array/DistArray.x10 trunk/x10.runtime/src-x10/x10/lang/PlaceLocalHandle.x10 trunk/x10.runtime/src-x10/x10/lang/Runtime.x10 trunk/x10.runtime/src-x10/x10/lang/System.x10 trunk/x10.runtime/src-x10/x10/util/DistributedRail.x10 trunk/x10.tests/examples/Misc/FRASimpleDist.x10 Removed Paths: ------------- trunk/x10.runtime/src-x10/x10/lang/PlaceLocalStorage.x10 Modified: trunk/x10.runtime/src-x10/x10/array/DistArray.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/array/DistArray.x10 2010-01-09 17:36:18 UTC (rev 12478) +++ trunk/x10.runtime/src-x10/x10/array/DistArray.x10 2010-01-09 17:36:50 UTC (rev 12479) @@ -23,8 +23,8 @@ }; private global val localHandle:PlaceLocalHandle[LocalState[T]]; - final protected global def raw():Rail[T]! = localHandle.get().raw; - final protected global def layout() = localHandle.get().layout; + final protected global def raw():Rail[T]! = localHandle().raw; + final protected global def layout() = localHandle().layout; // // high-performance methods here to facilitate inlining @@ -104,7 +104,7 @@ return new LocalState[T](localLayout, localRaw); }; - localHandle = PlaceLocalStorage.createDistributedObject[LocalState[T]](dist, plsInit); + localHandle = PlaceLocalHandle.make[LocalState[T]](dist, plsInit); } def this(dist: Dist): DistArray[T]{self.dist==dist} { super(dist); @@ -117,7 +117,7 @@ return new LocalState[T](localLayout, localRaw); }; - localHandle = PlaceLocalStorage.createDistributedObject[LocalState[T]](dist, plsInit); + localHandle = PlaceLocalHandle.make[LocalState[T]](dist, plsInit); } @@ -134,8 +134,8 @@ def this(a: DistArray[T], d: Dist) { super(d); - localHandle = PlaceLocalStorage.createDistributedObject[LocalState[T]](d, - () => a.localHandle.get()); + localHandle = PlaceLocalHandle.make[LocalState[T]](d, + () => a.localHandle()); } } Modified: trunk/x10.runtime/src-x10/x10/lang/PlaceLocalHandle.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/PlaceLocalHandle.x10 2010-01-09 17:36:18 UTC (rev 12478) +++ trunk/x10.runtime/src-x10/x10/lang/PlaceLocalHandle.x10 2010-01-09 17:36:50 UTC (rev 12479) @@ -8,15 +8,9 @@ package x10.lang; -import x10.compiler.Native; import x10.compiler.NativeClass; /** - * A PlaceLocalHandle is used in conjunction with the PlaceLocalStorage - * facility to create, name, manage, and destory the place-local storage of - * a distributed object. PlaceLocalHandles are created internally by the - * PlaceLocalStorage service; they cannot be directly created by application code.</p> - * * The primary operation on a PlaceLocalHandle is to use it to access an object * on the current place. If the current place is not part of the distribution * over which the PlaceLocalHandle is defined, a BadPlaceException will be thrown.</p> @@ -36,30 +30,44 @@ @NativeClass("java", "x10.runtime.impl.java", "PlaceLocalHandle") public final struct PlaceLocalHandle[T]{T <: Object} { - public native def this(); + // Only to be used by make method and Runtime class + native def this(); /** * @return the object mapped to the handle at the current place */ - public native safe def apply():T!; + public safe native def apply():T!; - // TODO: make everyone use apply() instead - public safe def get():T! = apply(); + // Only to be used by make method and Runtime class + native def set(newVal:T!):Void; - // Only to be used by create methods in PlaceLocalStorage - public native def set(newVal:T!):void; + public safe native def hashCode():Int; - // Only to be used by create methods in PlaceLocalStorage - static def createHandle[T]():PlaceLocalHandle[T] = PlaceLocalHandle[T](); + public safe native def toString():String; - public native safe def hashCode():int; - - public global safe native def toString():String; - // TODO: fix guard and cast public def copyTo[U](dst:Place, len:Int, notifier:()=>Void)/* {T<:Rail[U]} */:Void { x10.lang.System.copyTo[U](this as Any as PlaceLocalHandle[Rail[U]], dst, len, notifier); } + + /** + * Create a distributed object with local state of type T + * at each place in the argument distribution. The local object will be initialized + * by evaluating init at each place. When this method returns, the local objects + * will be initialized and available via the returned PlaceLocalHandle instance + * at every place in the distribution. + * + * @param dist A distribution specifiying the places where local objects should be created. + * @param init the initialization closure used to create the local object. + * @return a PlaceLocalHandle that can be used to access the local objects. + */ + public static def make[T](dist:Dist, init:()=>T!){T <: Object}:PlaceLocalHandle[T] { + val handle = at(Place.FIRST_PLACE) PlaceLocalHandle[T](); + finish for (p in dist.places()) { + async (p) handle.set(init()); + } + return handle; + } } // vim:shiftwidth=4:tabstop=4:expandtab Deleted: trunk/x10.runtime/src-x10/x10/lang/PlaceLocalStorage.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/PlaceLocalStorage.x10 2010-01-09 17:36:18 UTC (rev 12478) +++ trunk/x10.runtime/src-x10/x10/lang/PlaceLocalStorage.x10 2010-01-09 17:36:50 UTC (rev 12479) @@ -1,40 +0,0 @@ -/* - * - * (C) Copyright IBM Corporation 2006-2009. - * - * This file is part of X10 Language. - * - */ - -package x10.lang; - -/** - * Runtime service routines to create, manage, and destory place-local storage. - */ -public final class PlaceLocalStorage { - - /** - * Create a distributed object with local state of type T - * at each place in the argument distribution. The local object will be initialized - * by evaluating init at each place. When this method returns, the local objects - * will be initialized and available via the returned PlaceLocalHandle instance - * at every place in the distribution. - * - * @param dist A distribution specifiying the places where local objects should be created. - * @param init the initialization closure used to create the local object. - * @return a PlaceLocalHandle that can be used to access the local objects. - */ - public static def make[T](dist:Dist, init:()=>T!){T <: Object}:PlaceLocalHandle[T] { - val handle = at(Place.FIRST_PLACE) PlaceLocalHandle.createHandle[T](); - finish for (p in dist.places()) { - async (p) handle.set(init()); - } - return handle; - } - - // TODO: make everyone use 'make' - public static def createDistributedObject[T](dist:Dist, init:()=>T!){T <: Object}:PlaceLocalHandle[T] - = make[T](dist, init); -} - -// vim:shiftwidth=4:tabstop=4:expandtab Modified: trunk/x10.runtime/src-x10/x10/lang/Runtime.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Runtime.x10 2010-01-09 17:36:18 UTC (rev 12478) +++ trunk/x10.runtime/src-x10/x10/lang/Runtime.x10 2010-01-09 17:36:50 UTC (rev 12479) @@ -940,7 +940,7 @@ /** * The runtime instance associated with each place */ - private const runtime = PlaceLocalHandle.createHandle[Runtime](); + private const runtime = PlaceLocalHandle[Runtime](); static def proxy(rootFinish:RootFinish) = runtime().finishStates(rootFinish); Modified: trunk/x10.runtime/src-x10/x10/lang/System.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/System.x10 2010-01-09 17:36:18 UTC (rev 12478) +++ trunk/x10.runtime/src-x10/x10/lang/System.x10 2010-01-09 17:36:50 UTC (rev 12479) @@ -130,7 +130,7 @@ public static def copyTo[T] (srcRail:Rail[T]!, srcIndex:Int, dst:Place, dstHandle:PlaceLocalHandle[Rail[T]]!, dstIndex:Int, size:Int) { - val finder = ()=> Pair[Rail[T],Int](dstHandle.get(), dstIndex); + val finder = ()=> Pair[Rail[T],Int](dstHandle(), dstIndex); srcRail.copyTo[T](srcIndex, dst, finder, size); Runtime.dealloc(finder); } @@ -139,7 +139,7 @@ public static def copyTo[T] (srcRail:Rail[T]!, srcIndex:Int, dst:Place, dstHandle:PlaceLocalHandle[Rail[T]]!, dstIndex:Int, size:Int, notifier:()=>Void) { - val finder = ()=> Pair[Rail[T],Int](dstHandle.get(), dstIndex); + val finder = ()=> Pair[Rail[T],Int](dstHandle(), dstIndex); srcRail.copyTo[T](srcIndex, dst, finder, size, notifier); Runtime.dealloc(finder); Runtime.dealloc(notifier); @@ -149,8 +149,8 @@ // Also it is arguably a simpler interface because it has one less param public static def copyTo[T] (handle:PlaceLocalHandle[Rail[T]]!, dst:Place, size:Int, notifier:()=>Void) { - val finder = ()=>Pair[Rail[T],Int](handle.get(), 0); - handle.get().copyTo[T](0, dst, finder, size, notifier); + val finder = ()=>Pair[Rail[T],Int](handle(), 0); + handle().copyTo[T](0, dst, finder, size, notifier); Runtime.dealloc(finder); Runtime.dealloc(notifier); } Modified: trunk/x10.runtime/src-x10/x10/util/DistributedRail.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/util/DistributedRail.x10 2010-01-09 17:36:18 UTC (rev 12478) +++ trunk/x10.runtime/src-x10/x10/util/DistributedRail.x10 2010-01-09 17:36:50 UTC (rev 12479) @@ -10,15 +10,15 @@ public final class DistributedRail[T] implements Settable[Int,T], Iterable[T] { global val data : PlaceLocalHandle[Rail[T]]; global val firstPlace : Place; - global val localRails = PlaceLocalStorage.createDistributedObject[HashMap[Runtime.Activity, Rail[T]!]](Dist.makeUnique(), ()=>new HashMap[Runtime.Activity, Rail[T]!]()); + global val localRails = PlaceLocalHandle.make[HashMap[Runtime.Activity, Rail[T]!]](Dist.makeUnique(), ()=>new HashMap[Runtime.Activity, Rail[T]!]()); global val original : ValRail[T]; global val original_len : Int; - global val done = PlaceLocalStorage.createDistributedObject[Cell[Boolean]](Dist.makeUnique(), ()=>new Cell[Boolean](false)); + global val done = PlaceLocalHandle.make[Cell[Boolean]](Dist.makeUnique(), ()=>new Cell[Boolean](false)); public def this (len:Int, init:ValRail[T]) { val vr = ValRail.make(len, init); - data = PlaceLocalStorage.createDistributedObject[Rail[T]](Dist.makeUnique(), ()=>Rail.make(len,vr)); + data = PlaceLocalHandle.make[Rail[T]](Dist.makeUnique(), ()=>Rail.make(len,vr)); firstPlace = here; original = vr; original_len = len; @@ -26,7 +26,7 @@ public def this (len:Int, init:(Int)=>T) { val vr = ValRail.make(len, init); - data = PlaceLocalStorage.createDistributedObject[Rail[T]](Dist.makeUnique(), ()=>Rail.make(len,vr)); + data = PlaceLocalHandle.make[Rail[T]](Dist.makeUnique(), ()=>Rail.make(len,vr)); firstPlace = here; original = vr; original_len = len; @@ -36,18 +36,18 @@ public global safe def apply () { val a = Runtime.activity(); - val r = localRails.get().getOrElse(a, null); + val r = localRails().getOrElse(a, null); if (r==null) { val r_ = Rail.make(original_len, original); - localRails.get().put(a, r_); + localRails().put(a, r_); return r_; } return r; } - public global safe def get() = data.get(); + public global safe def get() = data(); - public global safe def drop() { localRails.get().remove(Runtime.activity()); } + public global safe def drop() { localRails().remove(Runtime.activity()); } public global safe def apply (i:Int) = this()(i); @@ -56,9 +56,9 @@ public global safe def iterator () = this().iterator(); private global def reduceLocal (op:(T,T)=>T) { - val master = data.get(); + val master = data(); var first:Boolean = true; - for (e in localRails.get().entries()) { + for (e in localRails().entries()) { val r = e.getValue(); if (first) { finish r.copyTo(0, master, 0, r.length); @@ -73,12 +73,12 @@ private global def reduceGlobal (op:(T,T)=>T) { if (firstPlace!=here) { - val local_ = data.get(); + val local_ = data(); { val local = local_ as ValRail[T]; val data_ = data; at (firstPlace) { - val master = data_.get(); + val master = data_(); atomic for (var i:Int=0 ; i<master.length ; ++i) { master(i) = op(master(i), local(i)); } @@ -86,15 +86,15 @@ } next; // every place has transmitted contents to master val handle = data; // avoid 'this' being serialised - finish local_.copyFrom[T](0, firstPlace, ()=>Pair[Rail[T],Int](handle.get(),0), local_.length); + finish local_.copyFrom[T](0, firstPlace, ()=>Pair[Rail[T],Int](handle(),0), local_.length); } else { next; } } private global def bcastLocal (op:(T,T)=>T) { - val master = data.get(); - for (e in localRails.get().entries()) { + val master = data(); + for (e in localRails().entries()) { val r = e.getValue(); finish r.copyFrom(0, master, 0, r.length); } @@ -104,9 +104,9 @@ public global def collectiveReduce (op:(T,T)=>T) { var i_won:Boolean = false; atomic { - if (!done.get().value) { + if (!done().value) { i_won = true; - done.get().value = true; + done().value = true; } } next; // activity rails populated at this place @@ -116,7 +116,7 @@ next; // every place has local rail populated reduceGlobal(op); // there's one 'next' in here too bcastLocal(op); - done.get().value = false; + done().value = false; } else { next; next; Modified: trunk/x10.tests/examples/Misc/FRASimpleDist.x10 =================================================================== --- trunk/x10.tests/examples/Misc/FRASimpleDist.x10 2010-01-09 17:36:18 UTC (rev 12478) +++ trunk/x10.tests/examples/Misc/FRASimpleDist.x10 2010-01-09 17:36:50 UTC (rev 12479) @@ -3,15 +3,15 @@ import x10.util.Timer; class LocalTable { - + val a: Rail[long]{self.at(this)}; val mask: int; - + def this(size:int) { mask = size-1; a = Rail.make[long](size, (i:int)=>i as long); } - + public def update(ran:long) { //a(ran&mask as int) ^= ran; val index = ran&mask as int; @@ -64,7 +64,7 @@ val placeId = ((ran>>logLocalTableSize) & (Place.MAX_PLACES-1)) as int; val valran = ran; async (Place.places(placeId)) { - tables.get().update(valran); + tables().update(valran); } ran = (ran << 1) ^ (ran<0L ? POLY : 0L); } @@ -85,7 +85,7 @@ val num_updates = 4*tableSize; // create local tables - val tables = PlaceLocalStorage.createDistributedObject[LocalTable](Dist.makeUnique(), () => new LocalTable(localTableSize)); + val tables = PlaceLocalHandle.make[LocalTable](Dist.makeUnique(), () => new LocalTable(localTableSize)); // print some info println("Main table size = 2^" +logLocalTableSize + "*" + Place.MAX_PLACES+" = " + tableSize+ " words"); @@ -107,7 +107,7 @@ val result = Array.make[Int](Dist.makeUnique(), (Point)=>0); for (var i:int=0; i<Place.MAX_PLACES; i++) { async (Place.places(i)) { - val table = tables.get(); + val table = tables(); var err:int = 0; for (var j:int=0; j<table.a.length; j++) { if (table.a(j) != j) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ipe...@us...> - 2010-01-11 04:01:54
|
Revision: 12485 http://x10.svn.sourceforge.net/x10/?rev=12485&view=rev Author: ipeshansky Date: 2010-01-11 04:01:47 +0000 (Mon, 11 Jan 2010) Log Message: ----------- Fix XTENLANG-880: - Carry over @Native annotations to the synthetic Struct class. - Add missing Struct methods to the C++ implementation of Struct. Modified Paths: -------------- trunk/x10.compiler/src/x10/util/Struct.java trunk/x10.runtime/src-cpp/x10/lang/Struct.h Modified: trunk/x10.compiler/src/x10/util/Struct.java =================================================================== --- trunk/x10.compiler/src/x10/util/Struct.java 2010-01-11 02:51:07 UTC (rev 12484) +++ trunk/x10.compiler/src/x10/util/Struct.java 2010-01-11 04:01:47 UTC (rev 12485) @@ -38,265 +38,276 @@ import x10.types.X10TypeSystem_c; public class Struct { - public static X10ClassDef makeDef(final X10TypeSystem_c xts) { - - final Position pos = Position.COMPILER_GENERATED; + public static X10ClassDef makeDef(final X10TypeSystem_c xts) { - String name = "Struct"; - X10ClassDef cd = (X10ClassDef) new X10ClassDef_c(xts, null) { - - @Override - public ClassType asType() { - if (asType == null) { - X10ClassDef cd = this; - asType = new X10ParsedClassType_c(this); - } - return asType; - } - }; + final Position pos = Position.COMPILER_GENERATED; - cd.position(pos); - cd.name(Name.make(name)); - try { - cd.setPackage(Types.ref(xts.packageForName(QName.make("x10.lang")))); - } - catch (SemanticException e) { - assert false; - } + String name = "Struct"; + X10ClassDef cd = (X10ClassDef) new X10ClassDef_c(xts, null) { + @Override + public ClassType asType() { + if (asType == null) { + X10ClassDef cd = this; + asType = new X10ParsedClassType_c(this); + } + return asType; + } + }; - QName fullName = QName.make("x10.lang", name); - cd.kind(ClassDef.TOP_LEVEL); - cd.superType(null); // base class has no superclass + cd.position(pos); + cd.name(Name.make(name)); + try { + cd.setPackage(Types.ref(xts.packageForName(QName.make("x10.lang")))); + } + catch (SemanticException e) { + assert false; + } + + QName fullName = QName.make("x10.lang", name); + cd.kind(ClassDef.TOP_LEVEL); + cd.superType(null); // base class has no superclass - cd.setInterfaces(Collections.<Ref<? extends Type>> singletonList(xts.lazyAny())); - cd.flags(X10Flags.toX10Flags(Flags.PUBLIC.Abstract()).Struct()); + cd.setInterfaces(Collections.<Ref<? extends Type>> singletonList(xts.lazyAny())); + cd.flags(X10Flags.toX10Flags(Flags.PUBLIC.Abstract()).Struct()); + // NOTE: don't call cd.asType() until after the type parameters are + // added. + X10ParsedClassType ct = (X10ParsedClassType) cd.asType(); + xts.systemResolver().install(fullName, ct); - // NOTE: don't call cd.asType() until after the type parameters are - // added. - X10ParsedClassType ct = (X10ParsedClassType) cd.asType(); - xts.systemResolver().install(fullName, ct); + String fullNameWithThis = fullName + "#this"; + //String fullNameWithThis = "this"; + XName thisName = new XNameWrapper<Object>(new Object(), fullNameWithThis); + XRoot thisVar = XTerms.makeLocal(thisName); - String fullNameWithThis = fullName + "#this"; - //String fullNameWithThis = "this"; - XName thisName = new XNameWrapper<Object>(new Object(), fullNameWithThis); - XRoot thisVar = XTerms.makeLocal(thisName); + final LazyRef<X10ParsedClassType> PLACE = Types.lazyRef(null); + PLACE.setResolver(new Runnable() { + public void run() { + PLACE.update((X10ParsedClassType) xts.Place()); + } + }); + final LazyRef<X10ParsedClassType> STRING = Types.lazyRef(null); + STRING.setResolver(new Runnable() { + public void run() { + STRING.update((X10ParsedClassType) xts.String()); + } + }); + final LazyRef<X10ParsedClassType> BOOLEAN = Types.lazyRef(null); + BOOLEAN.setResolver(new Runnable() { + public void run() { + BOOLEAN.update((X10ParsedClassType) xts.Boolean()); + } + }); + final LazyRef<X10ParsedClassType> OBJECT = Types.lazyRef(null); + OBJECT.setResolver(new Runnable() { + public void run() { + OBJECT.update((X10ParsedClassType) xts.Object()); + } + }); + X10ConstructorDef ci = (X10ConstructorDef) xts.constructorDef(pos, Types.ref(ct), Flags.PUBLIC.Native(), + Collections.EMPTY_LIST, + Collections.EMPTY_LIST); + cd.addConstructor(ci); - final LazyRef<X10ParsedClassType> PLACE = Types.lazyRef(null); - PLACE.setResolver(new Runnable() { - public void run() { - PLACE.update((X10ParsedClassType) xts.Place()); - } - }); - final LazyRef<X10ParsedClassType> STRING = Types.lazyRef(null); - STRING.setResolver(new Runnable() { - public void run() { - STRING.update((X10ParsedClassType) xts.String()); - } - }); - final LazyRef<X10ParsedClassType> BOOLEAN = Types.lazyRef(null); - BOOLEAN.setResolver(new Runnable() { - public void run() { - BOOLEAN.update((X10ParsedClassType) xts.Boolean()); - } - }); - final LazyRef<X10ParsedClassType> OBJECT = Types.lazyRef(null); - OBJECT.setResolver(new Runnable() { - public void run() { - OBJECT.update((X10ParsedClassType) xts.Object()); - } - }); - X10ConstructorDef ci = (X10ConstructorDef) xts.constructorDef(pos, Types.ref(ct), Flags.PUBLIC.Native(), - Collections.EMPTY_LIST, - Collections.EMPTY_LIST); - cd.addConstructor(ci); - - X10MethodDef mi; - List<Expr> list; - X10ClassType ann; + X10MethodDef mi; + List<Expr> list; + X10ClassType ann; - // @Native("java", "x10.lang.Place.place(x10.core.Ref.home(#0))") - // property def home():Place - mi = xts.methodDef(pos, Types.ref(ct), - X10Flags.toX10Flags(Flags.PUBLIC.Native()).Property().Global().Safe(), - PLACE, - xts.homeName(), - Collections.EMPTY_LIST, - Collections.EMPTY_LIST, - thisVar, - Collections.EMPTY_LIST, - null, - null, - Collections.EMPTY_LIST, - null); - final LazyRef<X10ParsedClassType> NATIVE_LOC = Types.lazyRef(null); - NATIVE_LOC.setResolver(new Runnable() { - public void run() { - List<Expr> list = new ArrayList<Expr>(2); - list.add(new X10StringLit_c(pos, "java")); - list.add(new X10StringLit_c(pos, "x10.lang.Place.place(x10.core.Ref.home(#0))")); - X10ParsedClassType ann= (X10ParsedClassType) ((X10ParsedClassType) xts.NativeType()).propertyInitializers(list); - NATIVE_LOC.update(ann); - } - }); - mi.setDefAnnotations(Collections.<Ref<? extends Type>> singletonList(NATIVE_LOC)); - cd.addMethod(mi); + // @Native("java", "x10.lang.Place.place(x10.core.Ref.home(#0))") + // property def home():Place + mi = xts.methodDef(pos, Types.ref(ct), + X10Flags.toX10Flags(Flags.PUBLIC.Native()).Property().Global().Safe(), + PLACE, + xts.homeName(), + Collections.EMPTY_LIST, + Collections.EMPTY_LIST, + thisVar, + Collections.EMPTY_LIST, + null, + null, + Collections.EMPTY_LIST, + null); + final LazyRef<X10ParsedClassType> NATIVE_LOC = Types.lazyRef(null); + NATIVE_LOC.setResolver(new Runnable() { + public void run() { + List<Expr> list = new ArrayList<Expr>(2); + list.add(new X10StringLit_c(pos, "java")); + list.add(new X10StringLit_c(pos, "x10.lang.Place.place(x10.core.Ref.home(#0))")); + X10ParsedClassType ann= (X10ParsedClassType) ((X10ParsedClassType) xts.NativeType()).propertyInitializers(list); + NATIVE_LOC.update(ann); + } + }); + mi.setDefAnnotations(Collections.<Ref<? extends Type>> singletonList(NATIVE_LOC)); + cd.addMethod(mi); - // @Native("java", "x10.core.Ref.at(#0, #1)") - // property def at(p:Object):boolean; - List<LocalDef> parameters = xts.dummyLocalDefs(Collections.<Ref<? extends Type>> singletonList(OBJECT)); - mi = xts.methodDef(pos, Types.ref(ct), - X10Flags.toX10Flags(Flags.PUBLIC.Native()).Property().Safe(), - BOOLEAN, - Name.make("at"), - Collections.EMPTY_LIST, - Collections.<Ref<? extends Type>> singletonList(OBJECT), - thisVar, - parameters, - null, - null, - Collections.EMPTY_LIST, - null); - final LazyRef<X10ParsedClassType> NATIVE_AT_1 = Types.lazyRef(null); - NATIVE_AT_1.setResolver(new Runnable() { - public void run() { - List<Expr> list = new ArrayList<Expr>(2); - list.add(new X10StringLit_c(pos, "java")); - list.add(new X10StringLit_c(pos, "x10.core.Ref.at(#0, #1)")); - X10ParsedClassType ann= (X10ParsedClassType) ((X10ParsedClassType) xts.NativeType()).propertyInitializers(list); - NATIVE_AT_1.update(ann); - } - }); - mi.setDefAnnotations(Collections.<Ref<? extends Type>> singletonList(NATIVE_AT_1)); - cd.addMethod(mi); + // @Native("java", "x10.core.Ref.at(#0, #1)") + // property def at(p:Object):boolean; + List<LocalDef> parameters = xts.dummyLocalDefs(Collections.<Ref<? extends Type>> singletonList(OBJECT)); + mi = xts.methodDef(pos, Types.ref(ct), + X10Flags.toX10Flags(Flags.PUBLIC.Native()).Property().Safe(), + BOOLEAN, + Name.make("at"), + Collections.EMPTY_LIST, + Collections.<Ref<? extends Type>> singletonList(OBJECT), + thisVar, + parameters, + null, + null, + Collections.EMPTY_LIST, + null); + final LazyRef<X10ParsedClassType> NATIVE_AT_1 = Types.lazyRef(null); + NATIVE_AT_1.setResolver(new Runnable() { + public void run() { + List<Expr> list = new ArrayList<Expr>(2); + list.add(new X10StringLit_c(pos, "java")); + list.add(new X10StringLit_c(pos, "x10.core.Ref.at(#0, #1)")); + X10ParsedClassType ann= (X10ParsedClassType) ((X10ParsedClassType) xts.NativeType()).propertyInitializers(list); + NATIVE_AT_1.update(ann); + } + }); + mi.setDefAnnotations(Collections.<Ref<? extends Type>> singletonList(NATIVE_AT_1)); + cd.addMethod(mi); - // @Native("java", "x10.core.Ref.typeName(#0)") - // native final global safe def typeName():String; - mi = xts.methodDef(pos, - Types.ref(ct), - X10Flags.toX10Flags(Flags.PUBLIC.Native().Final()).Global().Safe(), - STRING, - Name.make("typeName"), - Collections.EMPTY_LIST, - Collections.EMPTY_LIST, - thisVar, - Collections.EMPTY_LIST, - null, - null, - Collections.EMPTY_LIST, - null - ); - final LazyRef<X10ParsedClassType> NATIVE_TYPE_NAME = Types.lazyRef(null); - NATIVE_TYPE_NAME.setResolver(new Runnable() { - public void run() { - List<Expr> list = new ArrayList<Expr>(2); - list.add(new X10StringLit_c(pos, "java")); - list.add(new X10StringLit_c(pos, "x10.core.Ref.typeName(#0)")); - X10ParsedClassType ann= (X10ParsedClassType) ((X10ParsedClassType) xts.NativeType()).propertyInitializers(list); - NATIVE_TYPE_NAME.update(ann); - } - }); - - mi.setDefAnnotations(Collections.<Ref<? extends Type>> singletonList(NATIVE_TYPE_NAME)); - cd.addMethod(mi); + // @Native("java", "x10.core.Ref.typeName(#0)") + // @Native("c++", "x10aux::type_name(#0)") + // native final global safe def typeName():String; + mi = xts.methodDef(pos, + Types.ref(ct), + X10Flags.toX10Flags(Flags.PUBLIC.Native().Final()).Global().Safe(), + STRING, + Name.make("typeName"), + Collections.EMPTY_LIST, + Collections.EMPTY_LIST, + thisVar, + Collections.EMPTY_LIST, + null, + null, + Collections.EMPTY_LIST, + null + ); + final LazyRef<X10ParsedClassType> NATIVE_TYPE_NAME = Types.lazyRef(null); + NATIVE_TYPE_NAME.setResolver(new Runnable() { + public void run() { + List<Expr> list = new ArrayList<Expr>(2); + list.add(new X10StringLit_c(pos, "java")); + list.add(new X10StringLit_c(pos, "x10.core.Ref.typeName(#0)")); + X10ParsedClassType ann= (X10ParsedClassType) ((X10ParsedClassType) xts.NativeType()).propertyInitializers(list); + NATIVE_TYPE_NAME.update(ann); + } + }); + final LazyRef<X10ParsedClassType> NATIVE_CPP_TYPE_NAME = Types.lazyRef(null); + NATIVE_CPP_TYPE_NAME.setResolver(new Runnable() { + public void run() { + List<Expr> list = new ArrayList<Expr>(2); + list.add(new X10StringLit_c(pos, "c++")); + list.add(new X10StringLit_c(pos, "x10aux::type_name(#0)")); + X10ParsedClassType ann= (X10ParsedClassType) ((X10ParsedClassType) xts.NativeType()).propertyInitializers(list); + NATIVE_CPP_TYPE_NAME.update(ann); + } + }); - // @Native("java", "\"<struct>\"") - // native global safe def toString():String; - mi = xts.methodDef(pos, - Types.ref(ct), - X10Flags.toX10Flags(Flags.PUBLIC.Native()).Global().Safe(), - STRING, - Name.make("toString"), - Collections.EMPTY_LIST, - Collections.EMPTY_LIST, - thisVar, - Collections.EMPTY_LIST, - null, - null, - Collections.EMPTY_LIST, - null - ); - final LazyRef<X10ParsedClassType> NATIVE_TYPE_NAME2 = Types.lazyRef(null); - NATIVE_TYPE_NAME2.setResolver(new Runnable() { - public void run() { - List<Expr> list = new ArrayList<Expr>(2); - list.add(new X10StringLit_c(pos, "java")); - list.add(new X10StringLit_c(pos, "\"<struct>\"")); - X10ParsedClassType ann= (X10ParsedClassType) ((X10ParsedClassType) xts.NativeType()).propertyInitializers(list); - NATIVE_TYPE_NAME2.update(ann); - } - }); - - mi.setDefAnnotations(Collections.<Ref<? extends Type>> singletonList(NATIVE_TYPE_NAME2)); - cd.addMethod(mi); + List<Ref<? extends Type>> tn_ann = new ArrayList<Ref<? extends Type>>(); + tn_ann.add(NATIVE_TYPE_NAME); + tn_ann.add(NATIVE_CPP_TYPE_NAME); + mi.setDefAnnotations(tn_ann); + //mi.setDefAnnotations(Collections.<Ref<? extends Type>> singletonList(NATIVE_TYPE_NAME)); + cd.addMethod(mi); - - + // @Native("java", "\"<struct>\"") + // native global safe def toString():String; + mi = xts.methodDef(pos, + Types.ref(ct), + X10Flags.toX10Flags(Flags.PUBLIC.Native()).Global().Safe(), + STRING, + Name.make("toString"), + Collections.EMPTY_LIST, + Collections.EMPTY_LIST, + thisVar, + Collections.EMPTY_LIST, + null, + null, + Collections.EMPTY_LIST, + null + ); + final LazyRef<X10ParsedClassType> NATIVE_TYPE_NAME2 = Types.lazyRef(null); + NATIVE_TYPE_NAME2.setResolver(new Runnable() { + public void run() { + List<Expr> list = new ArrayList<Expr>(2); + list.add(new X10StringLit_c(pos, "java")); + list.add(new X10StringLit_c(pos, "\"<struct>\"")); + X10ParsedClassType ann= (X10ParsedClassType) ((X10ParsedClassType) xts.NativeType()).propertyInitializers(list); + NATIVE_TYPE_NAME2.update(ann); + } + }); + + mi.setDefAnnotations(Collections.<Ref<? extends Type>> singletonList(NATIVE_TYPE_NAME2)); + cd.addMethod(mi); + // @Native("java", "x10.core.Ref.at(#0, #1.id)") // property def at(p:Place):boolean; - parameters = xts.dummyLocalDefs(Collections.<Ref<? extends Type>> singletonList(PLACE)); - mi = xts.methodDef(pos, Types.ref(ct), - X10Flags.toX10Flags(Flags.PUBLIC.Native()).Property().Safe(), - BOOLEAN, - Name.make("at"), - Collections.EMPTY_LIST, - Collections.<Ref<? extends Type>> singletonList(PLACE), - thisVar, - parameters, - null, - null, - Collections.EMPTY_LIST, - null); - final LazyRef<X10ParsedClassType> NATIVE_AT_2 = Types.lazyRef(null); - NATIVE_AT_2.setResolver(new Runnable() { - public void run() { - List<Expr> list = new ArrayList<Expr>(2); - list.add(new X10StringLit_c(pos, "java")); - list.add(new X10StringLit_c(pos, "x10.core.Ref.at(#0, #1.id)")); - X10ParsedClassType ann= (X10ParsedClassType) ((X10ParsedClassType) xts.NativeType()).propertyInitializers(list); - NATIVE_AT_2.update(ann); - } - }); - mi.setDefAnnotations(Collections.<Ref<? extends Type>> singletonList(NATIVE_AT_2)); - cd.addMethod(mi); - - //@NativeRep("java", "x10.core.Struct", null, null) - final LazyRef<X10ParsedClassType> NATIVE_REP = Types.lazyRef(null); - NATIVE_REP.setResolver(new Runnable() { - public void run() { - List<Expr> list = new ArrayList<Expr>(4); - list.add(new X10StringLit_c(pos, "java")); - list.add(new X10StringLit_c(pos, "x10.core.Struct")); - list.add(null); - list.add(null); - X10ParsedClassType ann = (X10ParsedClassType) ((X10ParsedClassType) xts.NativeRep()).propertyInitializers(list); - - NATIVE_REP.update(ann); - } - }); - - - //@NativeRep("c++", "x10::lang::Struct", "x10::lang::Struct", null) - final LazyRef<X10ParsedClassType> NATIVE_REP_CPP = Types.lazyRef(null); - NATIVE_REP_CPP.setResolver(new Runnable() { - public void run() { - List<Expr> list = new ArrayList<Expr>(4); - list.add(new X10StringLit_c(pos, "c++")); - list.add(new X10StringLit_c(pos, "x10::lang::Struct")); - list.add(new X10StringLit_c(pos, "x10::lang::Struct")); - list.add(null); - X10ParsedClassType ann = (X10ParsedClassType) ((X10ParsedClassType) xts.NativeRep()).propertyInitializers(list); + parameters = xts.dummyLocalDefs(Collections.<Ref<? extends Type>> singletonList(PLACE)); + mi = xts.methodDef(pos, Types.ref(ct), + X10Flags.toX10Flags(Flags.PUBLIC.Native()).Property().Safe(), + BOOLEAN, + Name.make("at"), + Collections.EMPTY_LIST, + Collections.<Ref<? extends Type>> singletonList(PLACE), + thisVar, + parameters, + null, + null, + Collections.EMPTY_LIST, + null); + final LazyRef<X10ParsedClassType> NATIVE_AT_2 = Types.lazyRef(null); + NATIVE_AT_2.setResolver(new Runnable() { + public void run() { + List<Expr> list = new ArrayList<Expr>(2); + list.add(new X10StringLit_c(pos, "java")); + list.add(new X10StringLit_c(pos, "x10.core.Ref.at(#0, #1.id)")); + X10ParsedClassType ann= (X10ParsedClassType) ((X10ParsedClassType) xts.NativeType()).propertyInitializers(list); + NATIVE_AT_2.update(ann); + } + }); + mi.setDefAnnotations(Collections.<Ref<? extends Type>> singletonList(NATIVE_AT_2)); + cd.addMethod(mi); - NATIVE_REP_CPP.update(ann); - } - }); - - List<Ref<? extends Type>> cd_ann = new ArrayList<Ref<? extends Type>>(); - cd_ann.add(NATIVE_REP); - cd_ann.add(NATIVE_REP_CPP); - cd.setDefAnnotations(cd_ann); -// cd.setDefAnnotations(Collections.<Ref<? extends Type>> singletonList(NATIVE_REP)); - return cd; + //@NativeRep("java", "x10.core.Struct", null, null) + final LazyRef<X10ParsedClassType> NATIVE_REP = Types.lazyRef(null); + NATIVE_REP.setResolver(new Runnable() { + public void run() { + List<Expr> list = new ArrayList<Expr>(4); + list.add(new X10StringLit_c(pos, "java")); + list.add(new X10StringLit_c(pos, "x10.core.Struct")); + list.add(null); + list.add(null); + X10ParsedClassType ann = (X10ParsedClassType) ((X10ParsedClassType) xts.NativeRep()).propertyInitializers(list); + + NATIVE_REP.update(ann); + } + }); + + + //@NativeRep("c++", "x10::lang::Struct", "x10::lang::Struct", null) + final LazyRef<X10ParsedClassType> NATIVE_REP_CPP = Types.lazyRef(null); + NATIVE_REP_CPP.setResolver(new Runnable() { + public void run() { + List<Expr> list = new ArrayList<Expr>(4); + list.add(new X10StringLit_c(pos, "c++")); + list.add(new X10StringLit_c(pos, "x10::lang::Struct")); + list.add(new X10StringLit_c(pos, "x10::lang::Struct")); + list.add(null); + X10ParsedClassType ann = (X10ParsedClassType) ((X10ParsedClassType) xts.NativeRep()).propertyInitializers(list); + + NATIVE_REP_CPP.update(ann); + } + }); + + List<Ref<? extends Type>> cd_ann = new ArrayList<Ref<? extends Type>>(); + cd_ann.add(NATIVE_REP); + cd_ann.add(NATIVE_REP_CPP); + cd.setDefAnnotations(cd_ann); + //cd.setDefAnnotations(Collections.<Ref<? extends Type>> singletonList(NATIVE_REP)); + return cd; } } Modified: trunk/x10.runtime/src-cpp/x10/lang/Struct.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Struct.h 2010-01-11 02:51:07 UTC (rev 12484) +++ trunk/x10.runtime/src-cpp/x10/lang/Struct.h 2010-01-11 04:01:47 UTC (rev 12485) @@ -6,12 +6,16 @@ namespace x10 { namespace lang { + struct Place; + class Struct_methods { public: static void _instance_init(x10::lang::Struct *this_); static void _constructor(x10::lang::Struct *this_); + template<class T> static x10::lang::Place home(T v); + template<class T> static x10_boolean at(T v, x10aux::ref<x10::lang::Object> p); + template<class T> static x10_boolean at(T v, x10::lang::Place p); }; - } } #endif // X10_LANG_STRUCT_H @@ -22,4 +26,31 @@ } } +#ifndef X10_LANG_STRUCT_H_NODEPS +#define X10_LANG_STRUCT_H_NODEPS +#include <x10/lang/Place.h> +#ifndef X10_LANG_STRUCT_H_IMPLEMENTATION +#define X10_LANG_STRUCT_H_IMPLEMENTATION + +namespace x10 { + namespace lang { + + template<class T> inline Place Struct_methods::home(T v) { + return Place_methods::place((x10_int) x10aux::here); + } + + template<class T> inline x10_boolean Struct_methods::at(T v, x10aux::ref<Object> p) { + return x10aux::here == p->location; + } + + template<class T> inline x10_boolean Struct_methods::at(T v, Place p) { + return x10aux::here == p->FMGL(id); + } + + } +} + +#endif // X10_LANG_STRUCT_H_IMPLEMENTATION +#endif // X10_LANG_STRUCT_H_NODEPS + // vim:tabstop=4:shiftwidth=4:expandtab:textwidth=100 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ta...@us...> - 2010-01-11 16:31:05
|
Revision: 12490 http://x10.svn.sourceforge.net/x10/?rev=12490&view=rev Author: tardieu Date: 2010-01-11 16:30:48 +0000 (Mon, 11 Jan 2010) Log Message: ----------- moved setExitCode from Runtime to System Modified Paths: -------------- trunk/x10.runtime/src-x10/x10/lang/Runtime.x10 trunk/x10.runtime/src-x10/x10/lang/System.x10 trunk/x10.tests/examples/x10lib/harness/x10Test.x10 Modified: trunk/x10.runtime/src-x10/x10/lang/Runtime.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Runtime.x10 2010-01-11 16:30:08 UTC (rev 12489) +++ trunk/x10.runtime/src-x10/x10/lang/Runtime.x10 2010-01-11 16:30:48 UTC (rev 12490) @@ -26,13 +26,6 @@ @Native("c++", "x10aux::system_utils::println((#1)->toString()->c_str())") public native static def println(o:Object) : Void; - /** - * Set system exit code - */ - @Native("java", "x10.runtime.impl.java.Runtime.setExitCode(#1)") - @Native("c++", "(x10aux::exitCode = (#1))") - public static def setExitCode(code: int): void {} - // Configuration options @Native("java", "x10.runtime.impl.java.Runtime.PLACE_CHECKS") Modified: trunk/x10.runtime/src-x10/x10/lang/System.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/System.x10 2010-01-11 16:30:08 UTC (rev 12489) +++ trunk/x10.runtime/src-x10/x10/lang/System.x10 2010-01-11 16:30:48 UTC (rev 12490) @@ -27,6 +27,13 @@ public static def exit() = exit(-1); /** + * Set system exit code + */ + @Native("java", "x10.runtime.impl.java.Runtime.setExitCode(#1)") + @Native("c++", "(x10aux::exitCode = (#1))") + public static def setExitCode(code: int): void {} + + /** * Provides an estimate in bytes of the size of the X10 heap * allocated to the current place. The accuracy of this estimate * is highly dependent on the implementation details of the Modified: trunk/x10.tests/examples/x10lib/harness/x10Test.x10 =================================================================== --- trunk/x10.tests/examples/x10lib/harness/x10Test.x10 2010-01-11 16:30:08 UTC (rev 12489) +++ trunk/x10.tests/examples/x10lib/harness/x10Test.x10 2010-01-11 16:30:48 UTC (rev 12490) @@ -47,12 +47,12 @@ public static def success(): void = { println(PREFIX+"Test succeeded."); - x10.lang.Runtime.setExitCode(0); + System.setExitCode(0); } public static def failure(): void = { println(PREFIX+"Test failed."); - x10.lang.Runtime.setExitCode(1); + System.setExitCode(1); } protected static def reportResult(b: boolean): void = { @@ -87,7 +87,7 @@ protected var result: boolean; protected def check[T](test:String, actual:T, expected:T) = { result = actual == expected; - println(test + (result ? " succeeds: got " + println(test + (result ? " succeeds: got " : " fails: exepected " + expected + ", got " ) + actual); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ta...@us...> - 2010-01-11 18:20:33
|
Revision: 12497 http://x10.svn.sourceforge.net/x10/?rev=12497&view=rev Author: tardieu Date: 2010-01-11 18:20:26 +0000 (Mon, 11 Jan 2010) Log Message: ----------- restored top-level Activity class moved sleep method from Runtime to Activity updated test cases made Lock, Pool, and Deque non-public Runtime is now free of user-level entry points. Modified Paths: -------------- trunk/x10.runtime/src-x10/x10/lang/Runtime.x10 trunk/x10.runtime/src-x10/x10/util/DistributedRail.x10 trunk/x10.tests/examples/Constructs/Clock/ClockPascal.x10 trunk/x10.tests/examples/Constructs/Clock/ClockPascal2.x10 trunk/x10.tests/examples/Constructs/Clock/ClockTest12.x10 trunk/x10.tests/examples/Constructs/Clock/ClockTest15.x10 trunk/x10.tests/examples/Constructs/Finish/FinishTest2.x10 trunk/x10.tests/examples/Constructs/Future/FutureDeadlock_MustFailTimeout.x10 trunk/x10.tests/examples/Constructs/Future/FutureForce.x10 trunk/x10.tests/examples/Constructs/Future/FutureTest3.x10 trunk/x10.tests/examples/Constructs/Future/FutureTest5.x10 Added Paths: ----------- trunk/x10.runtime/src-x10/x10/lang/Activity.x10 Added: trunk/x10.runtime/src-x10/x10/lang/Activity.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Activity.x10 (rev 0) +++ trunk/x10.runtime/src-x10/x10/lang/Activity.x10 2010-01-11 18:20:26 UTC (rev 12497) @@ -0,0 +1,96 @@ +/* + * + * (C) Copyright IBM Corporation 2006-2008. + * + * This file is part of X10 Language. + * + */ + +package x10.lang; + +import x10.util.Stack; + +/** + * @author tardieu + */ +public class Activity { + + /** + * Sleep for the specified number of milliseconds. + * [IP] NOTE: Unlike Java, x10 sleep() simply exits when interrupted. + * @param millis the number of milliseconds to sleep + * @return true if completed normally, false if interrupted + */ + public static def sleep(millis:long):Boolean { + try { + Runtime.increaseParallelism(); + Runtime.Thread.sleep(millis); + Runtime.decreaseParallelism(1); + return true; + } catch (e:InterruptedException) { + Runtime.decreaseParallelism(1); + return false; + } + } + + /** + * the finish state governing the execution of this activity (may be remote) + */ + val finishState:Runtime.FinishState; + + /** + * safe to run pending jobs while waiting for a finish (temporary) + */ + val safe:Boolean; + + /** + * The user-specified code for this activity. + */ + private val body:()=>Void; + + /** + * The mapping from registered clocks to phases for this activity. + * Lazily created. + */ + var clockPhases:Runtime.ClockPhases!; + + /** + * The finish states for the finish statements currently executed by this activity. + * Lazily created. + */ + var finishStack:Stack[Runtime.FinishState!]!; + + /** + * Create activity. + */ + def this(body:()=>Void, finishState:Runtime.FinishState, safe:Boolean) { + this.finishState = finishState; + this.safe = safe; + finishState.notifyActivityCreation(); + this.body = body; + } + + /** + * Create clocked activity. + */ + def this(body:()=>Void, finishState:Runtime.FinishState, clocks:ValRail[Clock], phases:ValRail[Int]) { + this(body, finishState, false); + clockPhases = Runtime.ClockPhases.make(clocks, phases); + } + + /** + * Run activity. + */ + def run():Void { + try { + body(); + } catch (t:Throwable) { + finishState.pushException(t); + } + if (null != clockPhases) clockPhases.drop(); + finishState.notifyActivityTermination(); + Runtime.dealloc(body); + } +} + +// vim:shiftwidth=4:tabstop=4:expandtab Modified: trunk/x10.runtime/src-x10/x10/lang/Runtime.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Runtime.x10 2010-01-11 18:14:08 UTC (rev 12496) +++ trunk/x10.runtime/src-x10/x10/lang/Runtime.x10 2010-01-11 18:20:26 UTC (rev 12497) @@ -170,7 +170,7 @@ @NativeClass("java", "x10.runtime.impl.java", "Deque") @NativeClass("c++", "x10.lang", "Deque") - public static final class Deque { + static final class Deque { public native def this(); public native def size():Int; @@ -185,7 +185,7 @@ @NativeClass("java", "java.util.concurrent.locks", "ReentrantLock") @NativeClass("c++", "x10.lang", "Lock__ReentrantLock") - public static class Lock { + static class Lock { public native def this(); public native def lock():Void; @@ -656,68 +656,6 @@ } - public static class Activity { - /** - * the finish state governing the execution of this activity (may be remote) - */ - val finishState:FinishState; - - /** - * safe to run pending jobs while waiting for a finish (temporary) - */ - val safe:Boolean; - - /** - * The user-specified code for this activity. - */ - private val body:()=>Void; - - /** - * The mapping from registered clocks to phases for this activity. - * Lazily created. - */ - var clockPhases:ClockPhases!; - - /** - * The finish states for the finish statements currently executed by this activity. - * Lazily created. - */ - var finishStack:Stack[FinishState!]!; - - /** - * Create activity. - */ - def this(body:()=>Void, finishState:FinishState, safe:Boolean) { - this.finishState = finishState; - this.safe = safe; - finishState.notifyActivityCreation(); - this.body = body; - } - - /** - * Create clocked activity. - */ - def this(body:()=>Void, finishState:FinishState, clocks:ValRail[Clock], phases:ValRail[Int]) { - this(body, finishState, false); - clockPhases = ClockPhases.make(clocks, phases); - } - - /** - * Run activity. - */ - def run():Void { - try { - body(); - } catch (t:Throwable) { - finishState.pushException(t); - } - if (null != clockPhases) clockPhases.drop(); - finishState.notifyActivityTermination(); - dealloc(body); - } - } - - final static class Worker implements ()=>Void { val latch:Latch!; // release the latch to stop the worker @@ -791,7 +729,7 @@ } - public static class Pool implements ()=>Void { + static class Pool implements ()=>Void { private val latch:Latch!; private var size:Int; // the number of workers in the pool @@ -1186,27 +1124,6 @@ } - // sleep - - /** - * Sleep for the specified number of milliseconds. - * [IP] NOTE: Unlike Java, x10 sleep() simply exits when interrupted. - * @param millis the number of milliseconds to sleep - * @return true if completed normally, false if interrupted - */ - public static def sleep(millis:long):Boolean { - try { - increaseParallelism(); - Thread.sleep(millis); - decreaseParallelism(1); - return true; - } catch (e:InterruptedException) { - decreaseParallelism(1); - return false; - } - } - - // clocks /** Modified: trunk/x10.runtime/src-x10/x10/util/DistributedRail.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/util/DistributedRail.x10 2010-01-11 18:14:08 UTC (rev 12496) +++ trunk/x10.runtime/src-x10/x10/util/DistributedRail.x10 2010-01-11 18:20:26 UTC (rev 12497) @@ -10,7 +10,7 @@ public final class DistributedRail[T] implements Settable[Int,T], Iterable[T] { global val data : PlaceLocalHandle[Rail[T]]; global val firstPlace : Place; - global val localRails = PlaceLocalHandle.make[HashMap[Runtime.Activity, Rail[T]!]](Dist.makeUnique(), ()=>new HashMap[Runtime.Activity, Rail[T]!]()); + global val localRails = PlaceLocalHandle.make[HashMap[Activity, Rail[T]!]](Dist.makeUnique(), ()=>new HashMap[Activity, Rail[T]!]()); global val original : ValRail[T]; global val original_len : Int; Modified: trunk/x10.tests/examples/Constructs/Clock/ClockPascal.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Clock/ClockPascal.x10 2010-01-11 18:14:08 UTC (rev 12496) +++ trunk/x10.tests/examples/Constructs/Clock/ClockPascal.x10 2010-01-11 18:20:26 UTC (rev 12497) @@ -117,7 +117,7 @@ static def randDelay(var millis: int): void = { var n: int; atomic n = rand.nextInt(millis); - x10.lang.Runtime.sleep(n); + Activity.sleep(n); } public const startTime: long = System.currentTimeMillis(); Modified: trunk/x10.tests/examples/Constructs/Clock/ClockPascal2.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Clock/ClockPascal2.x10 2010-01-11 18:14:08 UTC (rev 12496) +++ trunk/x10.tests/examples/Constructs/Clock/ClockPascal2.x10 2010-01-11 18:20:26 UTC (rev 12497) @@ -106,7 +106,7 @@ static def randDelay(var millis: int): void = { var n: int; atomic n = rand.nextInt(millis); - x10.lang.Runtime.sleep(n); + Activity.sleep(n); } public const startTime: long = System.currentTimeMillis(); Modified: trunk/x10.tests/examples/Constructs/Clock/ClockTest12.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Clock/ClockTest12.x10 2010-01-11 18:14:08 UTC (rev 12496) +++ trunk/x10.tests/examples/Constructs/Clock/ClockTest12.x10 2010-01-11 18:20:26 UTC (rev 12497) @@ -31,21 +31,21 @@ def taskA(var id: int, val c: Clock): void = { var tmp: int; - x10.lang.Runtime.sleep(1000); + Activity.sleep(1000); atomic tmp = phase; x10.io.Console.OUT.println(id+" observed current phase = "+tmp); chk(tmp == 0); c.resume(); // 1st next advances in activity #2 - x10.lang.Runtime.sleep(1000); + Activity.sleep(1000); c.resume(); // not an error, still in phase 0 when (phase > 0) { x10.io.Console.OUT.println(id+" observed future phase = "+phase); chk(phase == 1); - x10.lang.Runtime.sleep(5000); + Activity.sleep(5000); chk(phase == 1); // cannot go beyond next phase } next; - x10.lang.Runtime.sleep(1000); + Activity.sleep(1000); atomic tmp = phase; x10.io.Console.OUT.println(id+" observed current phase = "+tmp); chk(tmp == 1); @@ -55,7 +55,7 @@ when (phase>1) { x10.io.Console.OUT.println(id+" observed future phase = "+phase); chk(phase == 2); - x10.lang.Runtime.sleep(5000); + Activity.sleep(5000); chk(phase == 2); // cannot go beyond next phase } next; Modified: trunk/x10.tests/examples/Constructs/Clock/ClockTest15.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Clock/ClockTest15.x10 2010-01-11 18:14:08 UTC (rev 12496) +++ trunk/x10.tests/examples/Constructs/Clock/ClockTest15.x10 2010-01-11 18:20:26 UTC (rev 12497) @@ -94,7 +94,7 @@ next; } /* A3 */ async (here) clocked (b) { - x10.lang.Runtime.sleep(5000); + Activity.sleep(5000); atomic x++; next; var tmp: int; Modified: trunk/x10.tests/examples/Constructs/Finish/FinishTest2.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Finish/FinishTest2.x10 2010-01-11 18:14:08 UTC (rev 12496) +++ trunk/x10.tests/examples/Constructs/Finish/FinishTest2.x10 2010-01-11 18:20:26 UTC (rev 12497) @@ -24,7 +24,7 @@ async (here) { atomic foo = 42; x10.io.Console.OUT.print("waiting ..."); - x10.lang.Runtime.sleep(2000); + Activity.sleep(2000); x10.io.Console.OUT.println("done."); atomic flag = true; } Modified: trunk/x10.tests/examples/Constructs/Future/FutureDeadlock_MustFailTimeout.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Future/FutureDeadlock_MustFailTimeout.x10 2010-01-11 18:14:08 UTC (rev 12496) +++ trunk/x10.tests/examples/Constructs/Future/FutureDeadlock_MustFailTimeout.x10 2010-01-11 18:20:26 UTC (rev 12497) @@ -37,7 +37,7 @@ var f2: Box[Future[Int]] = null; def a1(): Int = { - x10.lang.Runtime.sleep(5000); // to make deadlock occur deterministically + Activity.sleep(5000); // to make deadlock occur deterministically var tmpf: Box[Future[Int]] = null; atomic tmpf = f2; x10.io.Console.OUT.println("Activity #1 about to force "+tmpf+" to wait for #2 to complete"); @@ -45,7 +45,7 @@ } def a2(): int = { - x10.lang.Runtime.sleep(5000); // to make deadlock occur deterministically + Activity.sleep(5000); // to make deadlock occur deterministically var tmpf: Box[Future[Int]] = null; atomic tmpf = f1; x10.io.Console.OUT.println("Activity #2 about to force "+tmpf+" to wait for #1 to complete"); Modified: trunk/x10.tests/examples/Constructs/Future/FutureForce.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Future/FutureForce.x10 2010-01-11 18:14:08 UTC (rev 12496) +++ trunk/x10.tests/examples/Constructs/Future/FutureForce.x10 2010-01-11 18:20:26 UTC (rev 12497) @@ -18,7 +18,7 @@ public def bar(): Int = { x10.io.Console.OUT.print("waiting ..."); - x10.lang.Runtime.sleep(2000); + Activity.sleep(2000); x10.io.Console.OUT.println("done."); atomic flag = true; return 42; Modified: trunk/x10.tests/examples/Constructs/Future/FutureTest3.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Future/FutureTest3.x10 2010-01-11 18:14:08 UTC (rev 12496) +++ trunk/x10.tests/examples/Constructs/Future/FutureTest3.x10 2010-01-11 18:20:26 UTC (rev 12497) @@ -29,7 +29,7 @@ */ def m1(val A: Array[int](1), val K: int): int = { foreach (val (i): Point in A) { - x10.lang.Runtime.sleep(3000); + Activity.sleep(3000); atomic A(i) += 1; } var t: int; @@ -43,7 +43,7 @@ */ def m2(val A: Array[int](1), val K: int): int = { foreach (val p(i): Point in A) { - x10.lang.Runtime.sleep(3000); + Activity.sleep(3000); atomic A(i) += 1; atomic A(OUTOFRANGE) = -1; } Modified: trunk/x10.tests/examples/Constructs/Future/FutureTest5.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Future/FutureTest5.x10 2010-01-11 18:14:08 UTC (rev 12496) +++ trunk/x10.tests/examples/Constructs/Future/FutureTest5.x10 2010-01-11 18:20:26 UTC (rev 12497) @@ -38,7 +38,7 @@ val t1 = future (here) { 42 } ; atomic fut = t1 as Box[Future[Int]]; if (del) - x10.lang.Runtime.sleep(500); + Activity.sleep(500); }; var t2: Future[Int]; when (fut != null) { t2 = fut as Future[Int]; } @@ -68,7 +68,7 @@ val t1= future (here) { 42 } ; atomic fut = t1 as Box[Future[Int]]; if (del) - x10.lang.Runtime.sleep(500); + Activity.sleep(500); } finish async (here) { var t2: Future[Int]; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bti...@us...> - 2010-01-12 02:15:33
|
Revision: 12509 http://x10.svn.sourceforge.net/x10/?rev=12509&view=rev Author: btibbitts Date: 2010-01-12 02:15:25 +0000 (Tue, 12 Jan 2010) Log Message: ----------- Script changes to allow .qualifier to be appended to versions, which is replaced by a timestamp during the build. Modified Paths: -------------- trunk/x10.effects/exportPlugin.xml trunk/x10.runtime/exportPlugin.xml Modified: trunk/x10.effects/exportPlugin.xml =================================================================== --- trunk/x10.effects/exportPlugin.xml 2010-01-12 02:14:22 UTC (rev 12508) +++ trunk/x10.effects/exportPlugin.xml 2010-01-12 02:15:25 UTC (rev 12509) @@ -5,7 +5,7 @@ <!-- ================================================================================= --> - <target name="plugin.jar" depends="init,javaInit" unless="${plugin.jar.name}" description="Create jar: ${plugin.jar.name}."> + <target name="plugin.jar" depends="init,javaInit,munge.manifest" unless="${plugin.jar.name}" description="Create jar: ${plugin.jar.name}."> <delete dir="${temp.folder}/${plugin.jar.name}.bin"/> <mkdir dir="${temp.folder}/${plugin.jar.name}.bin"/> <!-- compile the source code --> @@ -25,7 +25,7 @@ <echo message="done copying resources"/> <mkdir dir="${build.result.folder}"/> <jar destfile="${build.result.folder}/${plugin.jar.name}" basedir="${temp.folder}/${plugin.jar.name}.bin" - manifest="META-INF/MANIFEST.MF"/> + manifest="${temp.folder}/MANIFEST.MF"/> <delete dir="${temp.folder}/${plugin.jar.name}.bin"/> </target> </project> Modified: trunk/x10.runtime/exportPlugin.xml =================================================================== --- trunk/x10.runtime/exportPlugin.xml 2010-01-12 02:14:22 UTC (rev 12508) +++ trunk/x10.runtime/exportPlugin.xml 2010-01-12 02:15:25 UTC (rev 12509) @@ -6,7 +6,7 @@ <!-- ================================================================================= --> - <target name="plugin.jar" depends="init,javaInit" unless="${plugin.jar.name}" description="Create jar: ${plugin.jar.name}."> + <target name="plugin.jar" depends="init,javaInit,munge.manifest" unless="${plugin.jar.name}" description="Create jar: ${plugin.jar.name}."> <delete dir="${temp.folder}/${plugin.jar.name}.bin"/> <mkdir dir="${temp.folder}/${plugin.jar.name}.bin"/> <mkdir dir="${build.result.folder}"/> @@ -16,7 +16,7 @@ <mkdir dir="${gen}"/> <echo message="gen=${gen}"/> <ant antfile="build.xml" target="build-xrx"/> - <jar jarfile="${build.result.folder}/${plugin.jar.name}" manifest="META-INF/MANIFEST.MF" > + <jar jarfile="${build.result.folder}/${plugin.jar.name}" manifest="${temp.folder}/MANIFEST.MF" > <fileset dir="${build}" includes="x10/**/*.class" excludes="${jar}"/> <fileset dir="${build}/gen" includes="x10/**/*.class" excludes="${jar}"/> <fileset dir="${basedir}/src-x10" includes="x10/**" excludes="${jar}"/> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ta...@us...> - 2010-01-12 16:39:06
|
Revision: 12539 http://x10.svn.sourceforge.net/x10/?rev=12539&view=rev Author: tardieu Date: 2010-01-12 16:38:50 +0000 (Tue, 12 Jan 2010) Log Message: ----------- fixed runAt name clash (2nd try) fixed Desugarer confusing placeId and place Modified Paths: -------------- trunk/x10.compiler/src/x10/visit/Desugarer.java trunk/x10.runtime/src-x10/x10/lang/Runtime.x10 trunk/x10.runtime/src-x10/x10/lang/System.x10 Modified: trunk/x10.compiler/src/x10/visit/Desugarer.java =================================================================== --- trunk/x10.compiler/src/x10/visit/Desugarer.java 2010-01-12 16:29:20 UTC (rev 12538) +++ trunk/x10.compiler/src/x10/visit/Desugarer.java 2010-01-12 16:38:50 UTC (rev 12539) @@ -234,12 +234,11 @@ private Stmt atStmt(Position pos, Stmt body, Expr place) throws SemanticException { place = getPlace(pos, place); - Expr placeId = synth.makeFieldAccess(pos, place, Name.make("id"), xContext()); Closure closure = synth.makeClosure(body.position(), xts.Void(), synth.toBlock(body), xContext()); Stmt result = xnf.Eval(pos, synth.makeStaticCall(pos, xts.Runtime(), RUN_AT, - Arrays.asList(new Expr[] { placeId, closure }), xts.Void(), + Arrays.asList(new Expr[] { place, closure }), xts.Void(), xContext())); return result; } Modified: trunk/x10.runtime/src-x10/x10/lang/Runtime.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Runtime.x10 2010-01-12 16:29:20 UTC (rev 12538) +++ trunk/x10.runtime/src-x10/x10/lang/Runtime.x10 2010-01-12 16:38:50 UTC (rev 12539) @@ -47,7 +47,7 @@ */ @Native("java", "x10.runtime.impl.java.Runtime.runAt(#1, #2)") @Native("c++", "x10aux::run_at(#1, #2)") - public static def runAt(id:Int, body:()=>Void):Void { body(); } + public static def runAtNative(id:Int, body:()=>Void):Void { body(); } /** * Java: run body synchronously at place(id) in the same node as the current place. @@ -517,11 +517,11 @@ t = new MultipleExceptions(e); } val closure = () => { (r as RootFinish!).notify(m, t); deallocObject(m); }; - runAt(r.home.id, closure); + runAtNative(r.home.id, closure); dealloc(closure); } else { val closure = () => { (r as RootFinish!).notify(m); deallocObject(m); }; - runAt(r.home.id, closure); + runAtNative(r.home.id, closure); dealloc(closure); } deallocObject(m); @@ -538,11 +538,11 @@ t = new MultipleExceptions(e); } val closure = () => { (r as RootFinish!).notify2(m, t); deallocObject(m); }; - runAt(r.home.id, closure); + runAtNative(r.home.id, closure); dealloc(closure); } else { val closure = () => { (r as RootFinish!).notify2(m) ; deallocObject(m); }; - runAt(r.home.id, closure); + runAtNative(r.home.id, closure); dealloc(closure); } deallocObject(m); @@ -856,7 +856,7 @@ pool(); if (!isLocal(Place.MAX_PLACES - 1)) { for (var i:Int=1; i<Place.MAX_PLACES; i++) { - runAt(i, worker().latch.release.()); + runAtNative(i, worker().latch.release.()); } } rootFinish.waitForFinish(false); @@ -889,7 +889,7 @@ execute(new Activity(body, state, clocks, phases)); } else { val c = ()=>execute(new Activity(body, state, clocks, phases)); - runAt(place.id, c); + runAtNative(place.id, c); } } @@ -907,7 +907,7 @@ } else { closure = ()=>execute(new Activity(body, state, false)); } - runAt(place.id, closure); + runAtNative(place.id, closure); dealloc(closure); } } @@ -933,7 +933,7 @@ val latch = new Latch(); } - public static def runAtPlace(place:Place, body:()=>Void):Void { + public static def runAt(place:Place, body:()=>Void):Void { val box = new RemoteControl(); async (place) { try { @@ -957,14 +957,6 @@ } } - public static def runAt(place:Place, body:()=>Void):Void { - runAtPlace(place, body); - } - - public static def runAt(place:Object, body:()=>Void):Void { - runAtPlace(place.home, body); - } - /** * Eval at expression */ @@ -1002,8 +994,6 @@ return box.t.value; } - public static def evalAt[T](place:Object, eval:()=>T):T = evalAt[T](place.home, eval); - /** * Eval future expression */ Modified: trunk/x10.runtime/src-x10/x10/lang/System.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/System.x10 2010-01-12 16:29:20 UTC (rev 12538) +++ trunk/x10.runtime/src-x10/x10/lang/System.x10 2010-01-12 16:38:50 UTC (rev 12539) @@ -121,7 +121,7 @@ // this version is optimised to use a single async for the whole rail // it could be further optimised to send only the part of the rail needed val to_serialize = src as ValRail[T]; - Runtime.runAt(dst_place.id, ()=>{ + Runtime.runAtNative(dst_place.id, ()=>{ val pair = dst_finder(); val dst = pair.first; val dst_off = pair.second; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dgr...@us...> - 2010-01-12 21:03:33
|
Revision: 12553 http://x10.svn.sourceforge.net/x10/?rev=12553&view=rev Author: dgrove-oss Date: 2010-01-12 21:03:26 +0000 (Tue, 12 Jan 2010) Log Message: ----------- More changes for equals being defined on Any in C++ backend. With this change, a couple of the programs in dist/samples are compiling & running again. The implementation of equals(Any) on user-defined structs is still not correct, but since none of the code depends on it working that is not a fatal problem. Will work on fixing code to generate proper implementation next. Modified Paths: -------------- trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java trunk/x10.runtime/src-cpp/x10/lang/Struct.struct_h trunk/x10.runtime/src-cpp/x10/lang/ValRail.h trunk/x10.runtime/src-cpp/x10aux/basic_functions.cc trunk/x10.runtime/src-cpp/x10aux/basic_functions.h Modified: trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java =================================================================== --- trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java 2010-01-12 20:50:03 UTC (rev 12552) +++ trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java 2010-01-12 21:03:26 UTC (rev 12553) @@ -1380,8 +1380,28 @@ h.writeln("static x10aux::ref<x10::lang::String> typeName("+Emitter.translateType(currentClass, false)+" this_) { return this_->typeName(); }"); // All types support equals(Any). If there is no user-defined equals, then we define one here. - if (!seenEquals) { - h.writeln("static x10_boolean equals("+Emitter.translateType(currentClass, false)+" this_, x10aux::ref<x10::lang::Any> that) { return false; /* FIXME. This is wrong */}"); + // We also have to define a redirection method from the struct itself to the implementation + // in struct_methods to support usage patterns of equals in x10aux. + if (seenEquals) { + // define redirection method + sh.writeln("x10_boolean equals(x10aux::ref<x10::lang::Any>);"); sh.forceNewline(); + emitter.printTemplateSignature(currentClass.typeArguments(), sw); + sw.write("x10_boolean "+ Emitter.translateType(currentClass, false)+ "::equals(x10aux::ref<x10::lang::Any> that) {"); + sw.newline(4); sw.begin(0); + sw.write("return "+Emitter.structMethodClass(currentClass, true, true)+"::equals(*this, that);"); + sw.end(); sw.newline(); + sw.writeln("}"); + } else { + // define default equals that redirects to struct_equals + sh.writeln("x10_boolean equals(x10aux::ref<x10::lang::Any> that);"); sh.forceNewline(); + emitter.printTemplateSignature(currentClass.typeArguments(), sw); + sw.write("x10_boolean "+ Emitter.translateType(currentClass, false)+ "::equals(x10aux::ref<x10::lang::Any>) {"); + sw.newline(4); sw.begin(0); + sw.write("return false; /* TODO, this is completely wrong. */"); + sw.end(); sw.newline(); + sw.writeln("}"); sw.forceNewline(); + + h.writeln("static x10_boolean equals("+Emitter.translateType(currentClass, false)+" this_, x10aux::ref<x10::lang::Any> that) { return this_->equals(that); }"); } // All types support toString. If there is no user-defined toString, then we define one here. Modified: trunk/x10.runtime/src-cpp/x10/lang/Struct.struct_h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Struct.struct_h 2010-01-12 20:50:03 UTC (rev 12552) +++ trunk/x10.runtime/src-cpp/x10/lang/Struct.struct_h 2010-01-12 21:03:26 UTC (rev 12553) @@ -11,6 +11,7 @@ namespace lang { class String; + class Any; class Struct { public: Modified: trunk/x10.runtime/src-cpp/x10/lang/ValRail.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/ValRail.h 2010-01-12 20:50:03 UTC (rev 12552) +++ trunk/x10.runtime/src-cpp/x10/lang/ValRail.h 2010-01-12 21:03:26 UTC (rev 12553) @@ -155,7 +155,7 @@ x10aux::ref<ValRail<T> > that = (x10aux::ref<ValRail<T> >)other; if (this->FMGL(length) != that->FMGL(length)) return false; for (int i=0; i<this->FMGL(length); i++) { - if (!x10aux::equals(this->_data[i], that->_data[i])) return false; + if (!x10aux::equals(this->_data[i], x10aux::class_cast_unchecked<x10aux::ref<x10::lang::Any> >(that->_data[i]))) return false; } return true; } Modified: trunk/x10.runtime/src-cpp/x10aux/basic_functions.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/basic_functions.cc 2010-01-12 20:50:03 UTC (rev 12552) +++ trunk/x10.runtime/src-cpp/x10aux/basic_functions.cc 2010-01-12 21:03:26 UTC (rev 12553) @@ -94,11 +94,5 @@ return String::Lit(v_); } -x10_boolean x10aux::general_equals_impl(x10aux::ref<x10::lang::Any> x, x10aux::ref<x10::lang::Any> y) { - nullCheck(x); - x10aux::ref<x10::lang::Reference> xAsObj(x); - return xAsObj->equals(y); -} - // vim:tabstop=4:shiftwidth=4:expandtab Modified: trunk/x10.runtime/src-cpp/x10aux/basic_functions.h =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/basic_functions.h 2010-01-12 20:50:03 UTC (rev 12552) +++ trunk/x10.runtime/src-cpp/x10aux/basic_functions.h 2010-01-12 21:03:26 UTC (rev 12553) @@ -19,17 +19,16 @@ return x10::lang::String::Lit(getRTT<T>()->name()); } - x10_boolean general_equals_impl(ref<x10::lang::Any> x, ref<x10::lang::Any> y); - - template<class T, class U> - class Equals { - public: static inline x10_boolean _(ref<T> x, ref<U> y) { return general_equals_impl(x, y); } - }; - // covers all heap-allocated values (Objects, Functions, Structs boxes to interface types) - template<class T, class U> - inline x10_boolean equals(ref<T> x, ref<U> y) { return Equals<T, U>::_(x, y); } + template<class T> inline x10_boolean equals(ref<T> x, ref<x10::lang::Any> y) { + ref<x10::lang::Reference> xAsRef(x); + return xAsRef->equals(y); + } + // covers all X10 Structs that are not built-in C++ types and NativeRep'ed + template<class T> inline x10_boolean equals(T x, ref<x10::lang::Any> y) { return x->equals(y); } + + // Cover all X10 Structs that are built-in C++ types inline x10_boolean equals(x10_boolean x, ref<x10::lang::Any> y) { ref<x10::lang::Reference> yAsRef(y); if (yAsRef->_type()->equals(getRTT<x10_boolean>())) { @@ -150,10 +149,6 @@ } } - // covers Primitive - template<class T, class U> - inline x10_boolean equals(T x, U y) { return x->_struct_equals(y); } - inline x10_boolean equals(const x10_double x, const x10_double y) { return x==y; } inline x10_boolean equals(const x10_float x, const x10_float y) { return x==y; } inline x10_boolean equals(const x10_long x, const x10_long y) { return x==y; } @@ -167,6 +162,7 @@ inline x10_boolean equals(const x10_char x, const x10_char y) { return x.v==y.v; } inline x10_boolean equals(const x10_boolean x, const x10_boolean y) { return x==y; } + template<class T, class U> inline x10_boolean struct_equals(ref<T> x, ref<U> y) { if (x.isNull()) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dgr...@us...> - 2010-01-15 19:34:14
|
Revision: 12643 http://x10.svn.sourceforge.net/x10/?rev=12643&view=rev Author: dgrove-oss Date: 2010-01-15 19:34:03 +0000 (Fri, 15 Jan 2010) Log Message: ----------- Rename the x10.types package in x10.runtime/src-java to x10.rtt. This avoids a potential name clash/inclusion problem with the other x10.types package in x10.compiler. Modified Paths: -------------- trunk/x10.compiler/data/AtExpr.xcd trunk/x10.compiler/data/Future.xcd trunk/x10.compiler/data/cast_deptype.xcd trunk/x10.compiler/data/equalsequals.xcd trunk/x10.compiler/data/notequalsequals.xcd trunk/x10.compiler/data/primitive_cast_deptype.xcd trunk/x10.compiler/src/x10/emitter/Emitter.java trunk/x10.compiler/src/x10/emitter/RuntimeTypeExpander.java trunk/x10.compiler/src/x10/visit/X10PrettyPrinterVisitor.java trunk/x10.runtime/src-java/x10/core/Any.java trunk/x10.runtime/src-java/x10/core/AnyRail.java trunk/x10.runtime/src-java/x10/core/Box.java trunk/x10.runtime/src-java/x10/core/BoxInt.java trunk/x10.runtime/src-java/x10/core/BoxedBoolean.java trunk/x10.runtime/src-java/x10/core/BoxedByte.java trunk/x10.runtime/src-java/x10/core/BoxedChar.java trunk/x10.runtime/src-java/x10/core/BoxedDouble.java trunk/x10.runtime/src-java/x10/core/BoxedFloat.java trunk/x10.runtime/src-java/x10/core/BoxedInt.java trunk/x10.runtime/src-java/x10/core/BoxedLong.java trunk/x10.runtime/src-java/x10/core/BoxedShort.java trunk/x10.runtime/src-java/x10/core/BoxedString.java trunk/x10.runtime/src-java/x10/core/GrowableRail.java trunk/x10.runtime/src-java/x10/core/Rail.java trunk/x10.runtime/src-java/x10/core/RailFactory.java trunk/x10.runtime/src-java/x10/core/Ref.java trunk/x10.runtime/src-java/x10/core/Struct.java trunk/x10.runtime/src-java/x10/core/ThrowableUtilities.java trunk/x10.runtime/src-java/x10/core/ValRail.java trunk/x10.runtime/src-java/x10/core/Value.java trunk/x10.runtime/src-java/x10/core/fun/Fun_0_0.java trunk/x10.runtime/src-java/x10/core/fun/Fun_0_1.java trunk/x10.runtime/src-java/x10/core/fun/Fun_0_2.java trunk/x10.runtime/src-java/x10/core/fun/Fun_0_3.java trunk/x10.runtime/src-java/x10/core/fun/Fun_0_4.java trunk/x10.runtime/src-java/x10/core/fun/Fun_0_5.java trunk/x10.runtime/src-java/x10/core/fun/Fun_0_6.java trunk/x10.runtime/src-java/x10/core/fun/Fun_0_7.java trunk/x10.runtime/src-java/x10/core/fun/Fun_0_8.java trunk/x10.runtime/src-java/x10/core/fun/Fun_0_9.java trunk/x10.runtime/src-java/x10/core/fun/VoidFun_0_0.java trunk/x10.runtime/src-java/x10/core/fun/VoidFun_0_1.java trunk/x10.runtime/src-java/x10/core/fun/VoidFun_0_2.java trunk/x10.runtime/src-java/x10/core/fun/VoidFun_0_3.java trunk/x10.runtime/src-java/x10/core/fun/VoidFun_0_4.java trunk/x10.runtime/src-java/x10/core/fun/VoidFun_0_5.java trunk/x10.runtime/src-java/x10/core/fun/VoidFun_0_6.java trunk/x10.runtime/src-java/x10/core/fun/VoidFun_0_7.java trunk/x10.runtime/src-java/x10/core/fun/VoidFun_0_8.java trunk/x10.runtime/src-java/x10/core/fun/VoidFun_0_9.java trunk/x10.runtime/src-java/x10/rtt/BooleanType.java trunk/x10.runtime/src-java/x10/rtt/ByteType.java trunk/x10.runtime/src-java/x10/rtt/CharType.java trunk/x10.runtime/src-java/x10/rtt/ConstrainedType.java trunk/x10.runtime/src-java/x10/rtt/DoubleType.java trunk/x10.runtime/src-java/x10/rtt/Equality.java trunk/x10.runtime/src-java/x10/rtt/FloatType.java trunk/x10.runtime/src-java/x10/rtt/IntType.java trunk/x10.runtime/src-java/x10/rtt/LongType.java trunk/x10.runtime/src-java/x10/rtt/RuntimeType.java trunk/x10.runtime/src-java/x10/rtt/ShortType.java trunk/x10.runtime/src-java/x10/rtt/Type.java trunk/x10.runtime/src-java/x10/rtt/Types.java trunk/x10.runtime/src-java/x10/rtt/UByteType.java trunk/x10.runtime/src-java/x10/rtt/UIntType.java trunk/x10.runtime/src-java/x10/rtt/ULongType.java trunk/x10.runtime/src-java/x10/rtt/UShortType.java trunk/x10.runtime/src-x10/x10/lang/Boolean.x10 trunk/x10.runtime/src-x10/x10/lang/Byte.x10 trunk/x10.runtime/src-x10/x10/lang/Char.x10 trunk/x10.runtime/src-x10/x10/lang/Double.x10 trunk/x10.runtime/src-x10/x10/lang/Float.x10 trunk/x10.runtime/src-x10/x10/lang/Int.x10 trunk/x10.runtime/src-x10/x10/lang/Long.x10 trunk/x10.runtime/src-x10/x10/lang/Short.x10 trunk/x10.runtime/src-x10/x10/lang/UByte.x10 trunk/x10.runtime/src-x10/x10/lang/UInt.x10 trunk/x10.runtime/src-x10/x10/lang/ULong.x10 trunk/x10.runtime/src-x10/x10/lang/UShort.x10 Added Paths: ----------- trunk/x10.runtime/src-java/x10/rtt/ Removed Paths: ------------- trunk/x10.runtime/src-java/x10/types/ Modified: trunk/x10.compiler/data/AtExpr.xcd =================================================================== --- trunk/x10.compiler/data/AtExpr.xcd 2010-01-15 19:33:15 UTC (rev 12642) +++ trunk/x10.compiler/data/AtExpr.xcd 2010-01-15 19:34:03 UTC (rev 12643) @@ -4,7 +4,7 @@ public #1 apply() { #2 } - public x10.types.Type<?> rtt_x10$lang$Fun_0_0_U() { + public x10.rtt.Type<?> rtt_x10$lang$Fun_0_0_U() { return #3; } }) Modified: trunk/x10.compiler/data/Future.xcd =================================================================== --- trunk/x10.compiler/data/Future.xcd 2010-01-15 19:33:15 UTC (rev 12642) +++ trunk/x10.compiler/data/Future.xcd 2010-01-15 19:34:03 UTC (rev 12643) @@ -4,7 +4,7 @@ public #1 apply() { #2 } - public x10.types.Type<?> rtt_x10$lang$Fun_0_0_U() { + public x10.rtt.Type<?> rtt_x10$lang$Fun_0_0_U() { return #3; } }, "future-#4") Modified: trunk/x10.compiler/data/cast_deptype.xcd =================================================================== --- trunk/x10.compiler/data/cast_deptype.xcd 2010-01-15 19:33:15 UTC (rev 12642) +++ trunk/x10.compiler/data/cast_deptype.xcd 2010-01-15 19:34:03 UTC (rev 12643) @@ -2,7 +2,7 @@ (new java.lang.Object() { final #0 cast(#0 self) { if (self==null) return null; - x10.types.Type rtt = #2; + x10.rtt.Type rtt = #2; if (rtt != null && ! rtt.instanceof$(self)) throw new java.lang.ClassCastException(); boolean sat = #3; if (! sat) throw new java.lang.ClassCastException(); Modified: trunk/x10.compiler/data/equalsequals.xcd =================================================================== --- trunk/x10.compiler/data/equalsequals.xcd 2010-01-15 19:33:15 UTC (rev 12642) +++ trunk/x10.compiler/data/equalsequals.xcd 2010-01-15 19:34:03 UTC (rev 12643) @@ -1,2 +1,2 @@ // SYNOPSIS: #0 == #1 (for values, also works for reference == operations) -x10.types.Equality.equalsequals(#0,#1) +x10.rtt.Equality.equalsequals(#0,#1) Modified: trunk/x10.compiler/data/notequalsequals.xcd =================================================================== --- trunk/x10.compiler/data/notequalsequals.xcd 2010-01-15 19:33:15 UTC (rev 12642) +++ trunk/x10.compiler/data/notequalsequals.xcd 2010-01-15 19:34:03 UTC (rev 12643) @@ -1,2 +1,2 @@ // SYNOPSIS: #0 != #1 (for values, also works for reference != operations) -(!x10.types.Equality.equalsequals(#0,#1)) +(!x10.rtt.Equality.equalsequals(#0,#1)) Modified: trunk/x10.compiler/data/primitive_cast_deptype.xcd =================================================================== --- trunk/x10.compiler/data/primitive_cast_deptype.xcd 2010-01-15 19:33:15 UTC (rev 12642) +++ trunk/x10.compiler/data/primitive_cast_deptype.xcd 2010-01-15 19:34:03 UTC (rev 12643) @@ -1,7 +1,7 @@ // SYNOPSIS: (#0) #1 #0=type #1=object #2=runtime type #3=depclause (new java.lang.Object() { final #0 cast(#0 self) { - x10.types.Type rtt = #2; + x10.rtt.Type rtt = #2; if (rtt != null && ! rtt.instanceof$(self)) throw new java.lang.ClassCastException(); boolean sat = #3; if (! sat) throw new java.lang.ClassCastException(); Modified: trunk/x10.compiler/src/x10/emitter/Emitter.java =================================================================== --- trunk/x10.compiler/src/x10/emitter/Emitter.java 2010-01-15 19:33:15 UTC (rev 12642) +++ trunk/x10.compiler/src/x10/emitter/Emitter.java 2010-01-15 19:34:03 UTC (rev 12643) @@ -620,7 +620,7 @@ w.write(")"); } else if (term instanceof XTypeLit_c) { - w.write("new x10.types.ConstrainedType.XTypeLit_c("); + w.write("new x10.rtt.ConstrainedType.XTypeLit_c("); w.begin(0); new RuntimeTypeExpander(this, ((XTypeLit_c)term).type()).expand(tr); w.end(); @@ -990,7 +990,7 @@ ParameterType pt = def.typeParameters().get(i); ParameterType.Variance var = def.variances().get(i); - w.write("public x10.types.Type<?> " + "rtt_" + mangle(def.fullName()) + "_"); + w.write("public x10.rtt.Type<?> " + "rtt_" + mangle(def.fullName()) + "_"); w.write(mangleIdentifier(pt.name()).toString()); w.write("()"); @@ -1035,7 +1035,7 @@ for (int i = 0; i < idef.typeParameters().size(); i++) { ParameterType pt = idef.typeParameters().get(i); - w.write("public x10.types.Type<?> " + "rtt_" + mangle(idef.fullName()) + "_"); + w.write("public x10.rtt.Type<?> " + "rtt_" + mangle(idef.fullName()) + "_"); w.write(mangleIdentifier(pt.name()).toString()); w.write("() { "); @@ -1271,9 +1271,9 @@ boolean isConstrained = def.classInvariant() != null && !def.classInvariant().get().valid(); - String superClass = "x10.types.RuntimeType"; + String superClass = "x10.rtt.RuntimeType"; if (X10PrettyPrinterVisitor.serialize_runtime_constraints && isConstrained) { // constrained type; treat specially - superClass = "x10.types.ConstrainedType"; + superClass = "x10.rtt.ConstrainedType"; } if (def.asType().isGloballyAccessible()) { @@ -1321,7 +1321,7 @@ } for (int i = 0; i < def.typeParameters().size(); i++) { ParameterType pt = def.typeParameters().get(i); - w.write("public final x10.types.Type "); + w.write("public final x10.rtt.Type "); w.write(Emitter.mangleIdentifier(pt.name()).toString()); w.write(";"); w.newline(); @@ -1333,7 +1333,7 @@ ParameterType pt = def.typeParameters().get(i); if (i != 0) w.write(", "); - w.write("final x10.types.Type "); + w.write("final x10.rtt.Type "); w.write(Emitter.mangleIdentifier(pt.name()).toString()); } @@ -1342,7 +1342,7 @@ w.write("super("); if (X10PrettyPrinterVisitor.serialize_runtime_constraints && isConstrained) { // constrained type; treat specially - w.write("new x10.types.RuntimeType<"); + w.write("new x10.rtt.RuntimeType<"); printType(def.asType(), X10PrettyPrinterVisitor.BOX_PRIMITIVES); w.write(">("); printType(def.asType(), X10PrettyPrinterVisitor.BOX_PRIMITIVES); @@ -1443,13 +1443,13 @@ generateRTType(mt.x10Def()); } - w.write("public java.util.List<x10.types.Type<?>> getTypeParameters() {"); + w.write("public java.util.List<x10.rtt.Type<?>> getTypeParameters() {"); w.newline(); w.begin(4); if (def.typeParameters().isEmpty()) w.write("return null;"); else { - w.write("return java.util.Arrays.asList(new x10.types.Type<?>[] { "); + w.write("return java.util.Arrays.asList(new x10.rtt.Type<?>[] { "); w.newline(); w.begin(4); for (int i = 0; i < def.typeParameters().size(); i++) { @@ -1478,7 +1478,7 @@ tr.print(parent, e, w); w.write(")"); - // w.write("x10.types.Types.<"); + // w.write("x10.rtt.Types.<"); // printType(t, flags | BOX_PRIMITIVES); // w.write(">javacast("); // tr.print(parent, e, w); @@ -1490,7 +1490,7 @@ w.write(") "); e.expand(tr); w.write(")"); - // w.write("x10.types.Types.<"); + // w.write("x10.rtt.Types.<"); // printType(t, flags | BOX_PRIMITIVES); // w.write(">javacast("); // e.expand(tr); @@ -1502,7 +1502,7 @@ w.write(") "); w.write(e); w.write(")"); - // w.write("x10.types.Types.<"); + // w.write("x10.rtt.Types.<"); // printType(t, flags | BOX_PRIMITIVES); // w.write(">javacast("); // w.write(e); @@ -1581,7 +1581,7 @@ tr.print(parent, e, w); w.write(")"); -// w.write("x10.types.Types.<"); +// w.write("x10.rtt.Types.<"); // printType(expected, PRINT_TYPE_PARAMS | BOX_PRIMITIVES); // w.write(">javacast("); // tr.print(parent, e, w); Modified: trunk/x10.compiler/src/x10/emitter/RuntimeTypeExpander.java =================================================================== --- trunk/x10.compiler/src/x10/emitter/RuntimeTypeExpander.java 2010-01-15 19:33:15 UTC (rev 12642) +++ trunk/x10.compiler/src/x10/emitter/RuntimeTypeExpander.java 2010-01-15 19:34:03 UTC (rev 12643) @@ -92,7 +92,7 @@ // Check for @NativeRep with null RTT class if (pat == null && er.getJavaRep(cd) != null) { - er.w.write("x10.types.Types.runtimeType("); + er.w.write("x10.rtt.Types.runtimeType("); er.printType(at, 0); er.w.write(".class"); er.w.write(")"); @@ -144,7 +144,7 @@ Type base = ct.baseType().get(); if (X10PrettyPrinterVisitor.serialize_runtime_constraints) { XConstraint constraint = ct.constraint().get(); - er.w.write("new x10.types.ConstrainedType("); + er.w.write("new x10.rtt.ConstrainedType("); new RuntimeTypeExpander(er, base).expand(tr); er.w.write(", "); er.w.write("null, "); @@ -157,7 +157,7 @@ return; } - er.w.write("x10.types.Types.runtimeType("); + er.w.write("x10.rtt.Types.runtimeType("); er.printType(at, 0); er.w.write(".class"); er.w.write(")"); @@ -165,21 +165,21 @@ String typeof(Type t) { if (t.isBoolean()) - return "x10.types.Types.BOOLEAN"; + return "x10.rtt.Types.BOOLEAN"; if (t.isByte()) - return "x10.types.Types.BYTE"; + return "x10.rtt.Types.BYTE"; if (t.isShort()) - return "x10.types.Types.SHORT"; + return "x10.rtt.Types.SHORT"; if (t.isChar()) - return "x10.types.Types.CHAR"; + return "x10.rtt.Types.CHAR"; if (t.isInt()) - return "x10.types.Types.INT"; + return "x10.rtt.Types.INT"; if (t.isLong()) - return "x10.types.Types.LONG"; + return "x10.rtt.Types.LONG"; if (t.isFloat()) - return "x10.types.Types.FLOAT"; + return "x10.rtt.Types.FLOAT"; if (t.isDouble()) - return "x10.types.Types.DOUBLE"; + return "x10.rtt.Types.DOUBLE"; return null; } } \ No newline at end of file Modified: trunk/x10.compiler/src/x10/visit/X10PrettyPrinterVisitor.java =================================================================== --- trunk/x10.compiler/src/x10/visit/X10PrettyPrinterVisitor.java 2010-01-15 19:33:15 UTC (rev 12642) +++ trunk/x10.compiler/src/x10/visit/X10PrettyPrinterVisitor.java 2010-01-15 19:34:03 UTC (rev 12643) @@ -181,7 +181,7 @@ * @author vj Refactored Emitter out. */ public class X10PrettyPrinterVisitor extends X10DelegatingVisitor { - public static final String X10_RUNTIME_TYPE_CLASS = "x10.types.Type"; + public static final String X10_RUNTIME_TYPE_CLASS = "x10.rtt.Type"; public static final String X10_FUN_CLASS_PREFIX = "x10.core.fun.Fun"; public static final String X10_RUNTIME_CLASS = "x10.runtime.impl.java.Runtime"; Modified: trunk/x10.runtime/src-java/x10/core/Any.java =================================================================== --- trunk/x10.runtime/src-java/x10/core/Any.java 2010-01-15 19:33:15 UTC (rev 12642) +++ trunk/x10.runtime/src-java/x10/core/Any.java 2010-01-15 19:34:03 UTC (rev 12643) @@ -8,8 +8,8 @@ package x10.core; -import x10.types.RuntimeType; -import x10.types.Type; +import x10.rtt.RuntimeType; +import x10.rtt.Type; // Base interface of all X10 entities. public interface Any { Modified: trunk/x10.runtime/src-java/x10/core/AnyRail.java =================================================================== --- trunk/x10.runtime/src-java/x10/core/AnyRail.java 2010-01-15 19:33:15 UTC (rev 12642) +++ trunk/x10.runtime/src-java/x10/core/AnyRail.java 2010-01-15 19:34:03 UTC (rev 12643) @@ -11,7 +11,7 @@ import x10.core.Iterator; import x10.core.Iterable; import x10.core.fun.Fun_0_1; -import x10.types.Type; +import x10.rtt.Type; public interface AnyRail<T> extends Indexable<Integer,T>, Fun_0_1<Integer,T>, Iterable<T> { public Iterator<T> iterator(); Modified: trunk/x10.runtime/src-java/x10/core/Box.java =================================================================== --- trunk/x10.runtime/src-java/x10/core/Box.java 2010-01-15 19:33:15 UTC (rev 12642) +++ trunk/x10.runtime/src-java/x10/core/Box.java 2010-01-15 19:34:03 UTC (rev 12643) @@ -8,9 +8,9 @@ package x10.core; -import x10.types.Equality; -import x10.types.RuntimeType; -import x10.types.Type; +import x10.rtt.Equality; +import x10.rtt.RuntimeType; +import x10.rtt.Type; public class Box<T> extends Ref { protected final Type<T> type; Modified: trunk/x10.runtime/src-java/x10/core/BoxInt.java =================================================================== --- trunk/x10.runtime/src-java/x10/core/BoxInt.java 2010-01-15 19:33:15 UTC (rev 12642) +++ trunk/x10.runtime/src-java/x10/core/BoxInt.java 2010-01-15 19:34:03 UTC (rev 12643) @@ -8,10 +8,10 @@ package x10.core; -import x10.types.Equality; -import x10.types.RuntimeType; -import x10.types.Type; -import x10.types.Types; +import x10.rtt.Equality; +import x10.rtt.RuntimeType; +import x10.rtt.Type; +import x10.rtt.Types; public class BoxInt extends Box<Integer> { public BoxInt(int v) { Modified: trunk/x10.runtime/src-java/x10/core/BoxedBoolean.java =================================================================== --- trunk/x10.runtime/src-java/x10/core/BoxedBoolean.java 2010-01-15 19:33:15 UTC (rev 12642) +++ trunk/x10.runtime/src-java/x10/core/BoxedBoolean.java 2010-01-15 19:34:03 UTC (rev 12643) @@ -3,7 +3,7 @@ */ package x10.core; -import x10.types.Types; +import x10.rtt.Types; public class BoxedBoolean<T> extends Box<Boolean> { public BoxedBoolean(boolean v) { Modified: trunk/x10.runtime/src-java/x10/core/BoxedByte.java =================================================================== --- trunk/x10.runtime/src-java/x10/core/BoxedByte.java 2010-01-15 19:33:15 UTC (rev 12642) +++ trunk/x10.runtime/src-java/x10/core/BoxedByte.java 2010-01-15 19:34:03 UTC (rev 12643) @@ -3,7 +3,7 @@ */ package x10.core; -import x10.types.Types; +import x10.rtt.Types; public class BoxedByte<T> extends Box<Byte> { public BoxedByte(byte v) { Modified: trunk/x10.runtime/src-java/x10/core/BoxedChar.java =================================================================== --- trunk/x10.runtime/src-java/x10/core/BoxedChar.java 2010-01-15 19:33:15 UTC (rev 12642) +++ trunk/x10.runtime/src-java/x10/core/BoxedChar.java 2010-01-15 19:34:03 UTC (rev 12643) @@ -3,7 +3,7 @@ */ package x10.core; -import x10.types.Types; +import x10.rtt.Types; public class BoxedChar<T> extends Box<Character> { public BoxedChar(char v) { Modified: trunk/x10.runtime/src-java/x10/core/BoxedDouble.java =================================================================== --- trunk/x10.runtime/src-java/x10/core/BoxedDouble.java 2010-01-15 19:33:15 UTC (rev 12642) +++ trunk/x10.runtime/src-java/x10/core/BoxedDouble.java 2010-01-15 19:34:03 UTC (rev 12643) @@ -3,7 +3,7 @@ */ package x10.core; -import x10.types.Types; +import x10.rtt.Types; public class BoxedDouble<T> extends Box<Double> { public BoxedDouble(double v) { Modified: trunk/x10.runtime/src-java/x10/core/BoxedFloat.java =================================================================== --- trunk/x10.runtime/src-java/x10/core/BoxedFloat.java 2010-01-15 19:33:15 UTC (rev 12642) +++ trunk/x10.runtime/src-java/x10/core/BoxedFloat.java 2010-01-15 19:34:03 UTC (rev 12643) @@ -3,7 +3,7 @@ */ package x10.core; -import x10.types.Types; +import x10.rtt.Types; public class BoxedFloat<T> extends Box<Float> { public BoxedFloat(float v) { Modified: trunk/x10.runtime/src-java/x10/core/BoxedInt.java =================================================================== --- trunk/x10.runtime/src-java/x10/core/BoxedInt.java 2010-01-15 19:33:15 UTC (rev 12642) +++ trunk/x10.runtime/src-java/x10/core/BoxedInt.java 2010-01-15 19:34:03 UTC (rev 12643) @@ -3,7 +3,7 @@ */ package x10.core; -import x10.types.Types; +import x10.rtt.Types; public class BoxedInt<T> extends Box<Integer> { public BoxedInt(int v) { Modified: trunk/x10.runtime/src-java/x10/core/BoxedLong.java =================================================================== --- trunk/x10.runtime/src-java/x10/core/BoxedLong.java 2010-01-15 19:33:15 UTC (rev 12642) +++ trunk/x10.runtime/src-java/x10/core/BoxedLong.java 2010-01-15 19:34:03 UTC (rev 12643) @@ -3,7 +3,7 @@ */ package x10.core; -import x10.types.Types; +import x10.rtt.Types; public class BoxedLong<T> extends Box<Long> { public BoxedLong(long v) { Modified: trunk/x10.runtime/src-java/x10/core/BoxedShort.java =================================================================== --- trunk/x10.runtime/src-java/x10/core/BoxedShort.java 2010-01-15 19:33:15 UTC (rev 12642) +++ trunk/x10.runtime/src-java/x10/core/BoxedShort.java 2010-01-15 19:34:03 UTC (rev 12643) @@ -3,7 +3,7 @@ */ package x10.core; -import x10.types.Types; +import x10.rtt.Types; public class BoxedShort<T> extends Box<Short> { public BoxedShort(short v) { Modified: trunk/x10.runtime/src-java/x10/core/BoxedString.java =================================================================== --- trunk/x10.runtime/src-java/x10/core/BoxedString.java 2010-01-15 19:33:15 UTC (rev 12642) +++ trunk/x10.runtime/src-java/x10/core/BoxedString.java 2010-01-15 19:34:03 UTC (rev 12643) @@ -3,7 +3,7 @@ */ package x10.core; -import x10.types.RuntimeType; +import x10.rtt.RuntimeType; public class BoxedString<T> extends Box<String> { public BoxedString(String v) { Modified: trunk/x10.runtime/src-java/x10/core/GrowableRail.java =================================================================== --- trunk/x10.runtime/src-java/x10/core/GrowableRail.java 2010-01-15 19:33:15 UTC (rev 12642) +++ trunk/x10.runtime/src-java/x10/core/GrowableRail.java 2010-01-15 19:34:03 UTC (rev 12643) @@ -2,8 +2,8 @@ import x10.core.fun.Fun_0_1; -import x10.types.Type; -import x10.types.Types; +import x10.rtt.Type; +import x10.rtt.Types; import x10.core.Iterable; import x10.core.Iterator; @@ -175,7 +175,7 @@ // Runtime type information // - static public class RTT extends x10.types.RuntimeType<GrowableRail<?>> { + static public class RTT extends x10.rtt.RuntimeType<GrowableRail<?>> { Type<?> type; public RTT(Type<?> type) { Modified: trunk/x10.runtime/src-java/x10/core/Rail.java =================================================================== --- trunk/x10.runtime/src-java/x10/core/Rail.java 2010-01-15 19:33:15 UTC (rev 12642) +++ trunk/x10.runtime/src-java/x10/core/Rail.java 2010-01-15 19:34:03 UTC (rev 12643) @@ -9,8 +9,8 @@ package x10.core; import x10.core.fun.Fun_0_1; -import x10.types.Type; -import x10.types.Types; +import x10.rtt.Type; +import x10.rtt.Types; public final class Rail<T> extends Ref implements AnyRail<T>, Settable<Integer,T> { public final int length; @@ -175,7 +175,7 @@ // Runtime type information // - static public class RTT<T> extends x10.types.RuntimeType<Rail<T>> { + static public class RTT<T> extends x10.rtt.RuntimeType<Rail<T>> { Type<T> type; public RTT(Type<T> type) { Modified: trunk/x10.runtime/src-java/x10/core/RailFactory.java =================================================================== --- trunk/x10.runtime/src-java/x10/core/RailFactory.java 2010-01-15 19:33:15 UTC (rev 12642) +++ trunk/x10.runtime/src-java/x10/core/RailFactory.java 2010-01-15 19:34:03 UTC (rev 12643) @@ -9,9 +9,9 @@ package x10.core; import x10.core.fun.Fun_0_1; -import x10.types.RuntimeType; -import x10.types.Type; -import x10.types.Types; +import x10.rtt.RuntimeType; +import x10.rtt.Type; +import x10.rtt.Types; public class RailFactory { public static <T> ValRail<T> makeValRail(Type<T> type, int length, Fun_0_1<Integer,T> init) { Modified: trunk/x10.runtime/src-java/x10/core/Ref.java =================================================================== --- trunk/x10.runtime/src-java/x10/core/Ref.java 2010-01-15 19:33:15 UTC (rev 12642) +++ trunk/x10.runtime/src-java/x10/core/Ref.java 2010-01-15 19:34:03 UTC (rev 12643) @@ -8,9 +8,9 @@ package x10.core; +import x10.rtt.RuntimeType; +import x10.rtt.Type; import x10.runtime.impl.java.Thread; -import x10.types.RuntimeType; -import x10.types.Type; // Base class of all X10 ref objects -- should be generated, but we need this class to get Box to compile. Modified: trunk/x10.runtime/src-java/x10/core/Struct.java =================================================================== --- trunk/x10.runtime/src-java/x10/core/Struct.java 2010-01-15 19:33:15 UTC (rev 12642) +++ trunk/x10.runtime/src-java/x10/core/Struct.java 2010-01-15 19:34:03 UTC (rev 12643) @@ -4,9 +4,9 @@ import java.lang.reflect.Field; import java.lang.reflect.Modifier; -import x10.types.Equality; -import x10.types.RuntimeType; -import x10.types.Type; +import x10.rtt.Equality; +import x10.rtt.RuntimeType; +import x10.rtt.Type; // Base class for all X10 structs public abstract class Struct implements Any { Modified: trunk/x10.runtime/src-java/x10/core/ThrowableUtilities.java =================================================================== --- trunk/x10.runtime/src-java/x10/core/ThrowableUtilities.java 2010-01-15 19:33:15 UTC (rev 12642) +++ trunk/x10.runtime/src-java/x10/core/ThrowableUtilities.java 2010-01-15 19:34:03 UTC (rev 12643) @@ -1,6 +1,6 @@ package x10.core; -import x10.types.*; +import x10.rtt.*; public class ThrowableUtilities { Modified: trunk/x10.runtime/src-java/x10/core/ValRail.java =================================================================== --- trunk/x10.runtime/src-java/x10/core/ValRail.java 2010-01-15 19:33:15 UTC (rev 12642) +++ trunk/x10.runtime/src-java/x10/core/ValRail.java 2010-01-15 19:34:03 UTC (rev 12643) @@ -9,8 +9,8 @@ package x10.core; import x10.core.fun.Fun_0_1; -import x10.types.Type; -import x10.types.Types; +import x10.rtt.Type; +import x10.rtt.Types; public final class ValRail<T> implements AnyRail<T> { public final int length; @@ -182,7 +182,7 @@ // Runtime type information // - static public class RTT<T> extends x10.types.RuntimeType<ValRail<T>> { + static public class RTT<T> extends x10.rtt.RuntimeType<ValRail<T>> { Type<T> type; public RTT(Type<T> type) { Modified: trunk/x10.runtime/src-java/x10/core/Value.java =================================================================== --- trunk/x10.runtime/src-java/x10/core/Value.java 2010-01-15 19:33:15 UTC (rev 12642) +++ trunk/x10.runtime/src-java/x10/core/Value.java 2010-01-15 19:34:03 UTC (rev 12643) @@ -12,9 +12,9 @@ import java.lang.reflect.Field; import java.lang.reflect.Modifier; -import x10.types.Equality; -import x10.types.RuntimeType; -import x10.types.Type; +import x10.rtt.Equality; +import x10.rtt.RuntimeType; +import x10.rtt.Type; // Base class of all X10 value objects -- should be generated, but we need this class to get Box to compile. public class Value { Modified: trunk/x10.runtime/src-java/x10/core/fun/Fun_0_0.java =================================================================== --- trunk/x10.runtime/src-java/x10/core/fun/Fun_0_0.java 2010-01-15 19:33:15 UTC (rev 12642) +++ trunk/x10.runtime/src-java/x10/core/fun/Fun_0_0.java 2010-01-15 19:34:03 UTC (rev 12643) @@ -8,8 +8,8 @@ package x10.core.fun; -import x10.types.RuntimeType; -import x10.types.Type; +import x10.rtt.RuntimeType; +import x10.rtt.Type; public interface Fun_0_0<U> { Modified: trunk/x10.runtime/src-java/x10/core/fun/Fun_0_1.java =================================================================== --- trunk/x10.runtime/src-java/x10/core/fun/Fun_0_1.java 2010-01-15 19:33:15 UTC (rev 12642) +++ trunk/x10.runtime/src-java/x10/core/fun/Fun_0_1.java 2010-01-15 19:34:03 UTC (rev 12643) @@ -8,8 +8,8 @@ package x10.core.fun; -import x10.types.RuntimeType; -import x10.types.Type; +import x10.rtt.RuntimeType; +import x10.rtt.Type; public interface Fun_0_1<T1,U> { U apply(T1 o); Modified: trunk/x10.runtime/src-java/x10/core/fun/Fun_0_2.java =================================================================== --- trunk/x10.runtime/src-java/x10/core/fun/Fun_0_2.java 2010-01-15 19:33:15 UTC (rev 12642) +++ trunk/x10.runtime/src-java/x10/core/fun/Fun_0_2.java 2010-01-15 19:34:03 UTC (rev 12643) @@ -8,8 +8,8 @@ package x10.core.fun; -import x10.types.RuntimeType; -import x10.types.Type; +import x10.rtt.RuntimeType; +import x10.rtt.Type; public interface Fun_0_2<T1,T2,U> { U apply(T1 o1, T2 o2); Modified: trunk/x10.runtime/src-java/x10/core/fun/Fun_0_3.java =================================================================== --- trunk/x10.runtime/src-java/x10/core/fun/Fun_0_3.java 2010-01-15 19:33:15 UTC (rev 12642) +++ trunk/x10.runtime/src-java/x10/core/fun/Fun_0_3.java 2010-01-15 19:34:03 UTC (rev 12643) @@ -8,8 +8,8 @@ package x10.core.fun; -import x10.types.RuntimeType; -import x10.types.Type; +import x10.rtt.RuntimeType; +import x10.rtt.Type; public interface Fun_0_3<T1,T2,T3,U> { U apply(T1 o1, T2 o2, T3 o3); Modified: trunk/x10.runtime/src-java/x10/core/fun/Fun_0_4.java =================================================================== --- trunk/x10.runtime/src-java/x10/core/fun/Fun_0_4.java 2010-01-15 19:33:15 UTC (rev 12642) +++ trunk/x10.runtime/src-java/x10/core/fun/Fun_0_4.java 2010-01-15 19:34:03 UTC (rev 12643) @@ -8,8 +8,8 @@ package x10.core.fun; -import x10.types.RuntimeType; -import x10.types.Type; +import x10.rtt.RuntimeType; +import x10.rtt.Type; public interface Fun_0_4<T1,T2,T3,T4,U> { U apply(T1 o1, T2 o2, T3 o3, T4 o4); Modified: trunk/x10.runtime/src-java/x10/core/fun/Fun_0_5.java =================================================================== --- trunk/x10.runtime/src-java/x10/core/fun/Fun_0_5.java 2010-01-15 19:33:15 UTC (rev 12642) +++ trunk/x10.runtime/src-java/x10/core/fun/Fun_0_5.java 2010-01-15 19:34:03 UTC (rev 12643) @@ -8,8 +8,8 @@ package x10.core.fun; -import x10.types.RuntimeType; -import x10.types.Type; +import x10.rtt.RuntimeType; +import x10.rtt.Type; public interface Fun_0_5<T1,T2,T3,T4,T5,U> { U apply(T1 o1, T2 o2, T3 o3, T4 o4, T5 o5); Modified: trunk/x10.runtime/src-java/x10/core/fun/Fun_0_6.java =================================================================== --- trunk/x10.runtime/src-java/x10/core/fun/Fun_0_6.java 2010-01-15 19:33:15 UTC (rev 12642) +++ trunk/x10.runtime/src-java/x10/core/fun/Fun_0_6.java 2010-01-15 19:34:03 UTC (rev 12643) @@ -8,8 +8,8 @@ package x10.core.fun; -import x10.types.RuntimeType; -import x10.types.Type; +import x10.rtt.RuntimeType; +import x10.rtt.Type; public interface Fun_0_6<T1,T2,T3,T4,T5,T6,U> { U apply(T1 o1, T2 o2, T3 o3, T4 o4, T5 o5, T6 o6); Modified: trunk/x10.runtime/src-java/x10/core/fun/Fun_0_7.java =================================================================== --- trunk/x10.runtime/src-java/x10/core/fun/Fun_0_7.java 2010-01-15 19:33:15 UTC (rev 12642) +++ trunk/x10.runtime/src-java/x10/core/fun/Fun_0_7.java 2010-01-15 19:34:03 UTC (rev 12643) @@ -8,8 +8,8 @@ package x10.core.fun; -import x10.types.RuntimeType; -import x10.types.Type; +import x10.rtt.RuntimeType; +import x10.rtt.Type; public interface Fun_0_7<T1,T2,T3,T4,T5,T6,T7,U> { U apply(T1 o1, T2 o2, T3 o3, T4 o4, T5 o5, T6 o6, T7 o7); Modified: trunk/x10.runtime/src-java/x10/core/fun/Fun_0_8.java =================================================================== --- trunk/x10.runtime/src-java/x10/core/fun/Fun_0_8.java 2010-01-15 19:33:15 UTC (rev 12642) +++ trunk/x10.runtime/src-java/x10/core/fun/Fun_0_8.java 2010-01-15 19:34:03 UTC (rev 12643) @@ -8,8 +8,8 @@ package x10.core.fun; -import x10.types.RuntimeType; -import x10.types.Type; +import x10.rtt.RuntimeType; +import x10.rtt.Type; public interface Fun_0_8<T1,T2,T3,T4,T5,T6,T7,T8,U> { U apply(T1 o1, T2 o2, T3 o3, T4 o4, T5 o5, T6 o6, T7 o7, T8 o8); Modified: trunk/x10.runtime/src-java/x10/core/fun/Fun_0_9.java =================================================================== --- trunk/x10.runtime/src-java/x10/core/fun/Fun_0_9.java 2010-01-15 19:33:15 UTC (rev 12642) +++ trunk/x10.runtime/src-java/x10/core/fun/Fun_0_9.java 2010-01-15 19:34:03 UTC (rev 12643) @@ -8,8 +8,8 @@ package x10.core.fun; -import x10.types.RuntimeType; -import x10.types.Type; +import x10.rtt.RuntimeType; +import x10.rtt.Type; public interface Fun_0_9<T1,T2,T3,T4,T5,T6,T7,T8,T9,U> { U apply(T1 o1, T2 o2, T3 o3, T4 o4, T5 o5, T6 o6, T7 o7, T8 o8, T9 o9); Modified: trunk/x10.runtime/src-java/x10/core/fun/VoidFun_0_0.java =================================================================== --- trunk/x10.runtime/src-java/x10/core/fun/VoidFun_0_0.java 2010-01-15 19:33:15 UTC (rev 12642) +++ trunk/x10.runtime/src-java/x10/core/fun/VoidFun_0_0.java 2010-01-15 19:34:03 UTC (rev 12643) @@ -8,7 +8,7 @@ package x10.core.fun; -import x10.types.RuntimeType; +import x10.rtt.RuntimeType; public interface VoidFun_0_0 { void apply(); Modified: trunk/x10.runtime/src-java/x10/core/fun/VoidFun_0_1.java =================================================================== --- trunk/x10.runtime/src-java/x10/core/fun/VoidFun_0_1.java 2010-01-15 19:33:15 UTC (rev 12642) +++ trunk/x10.runtime/src-java/x10/core/fun/VoidFun_0_1.java 2010-01-15 19:34:03 UTC (rev 12643) @@ -8,8 +8,8 @@ package x10.core.fun; -import x10.types.RuntimeType; -import x10.types.Type; +import x10.rtt.RuntimeType; +import x10.rtt.Type; public interface VoidFun_0_1<T1> { void apply(T1 o); Modified: trunk/x10.runtime/src-java/x10/core/fun/VoidFun_0_2.java =================================================================== --- trunk/x10.runtime/src-java/x10/core/fun/VoidFun_0_2.java 2010-01-15 19:33:15 UTC (rev 12642) +++ trunk/x10.runtime/src-java/x10/core/fun/VoidFun_0_2.java 2010-01-15 19:34:03 UTC (rev 12643) @@ -8,8 +8,8 @@ package x10.core.fun; -import x10.types.RuntimeType; -import x10.types.Type; +import x10.rtt.RuntimeType; +import x10.rtt.Type; public interface VoidFun_0_2<T1,T2> { void apply(T1 o1, T2 o2); Modified: trunk/x10.runtime/src-java/x10/core/fun/VoidFun_0_3.java =================================================================== --- trunk/x10.runtime/src-java/x10/core/fun/VoidFun_0_3.java 2010-01-15 19:33:15 UTC (rev 12642) +++ trunk/x10.runtime/src-java/x10/core/fun/VoidFun_0_3.java 2010-01-15 19:34:03 UTC (rev 12643) @@ -8,8 +8,8 @@ package x10.core.fun; -import x10.types.RuntimeType; -import x10.types.Type; +import x10.rtt.RuntimeType; +import x10.rtt.Type; public interface VoidFun_0_3<T1,T2,T3> { void apply(T1 o1, T2 o2, T3 o3); Modified: trunk/x10.runtime/src-java/x10/core/fun/VoidFun_0_4.java =================================================================== --- trunk/x10.runtime/src-java/x10/core/fun/VoidFun_0_4.java 2010-01-15 19:33:15 UTC (rev 12642) +++ trunk/x10.runtime/src-java/x10/core/fun/VoidFun_0_4.java 2010-01-15 19:34:03 UTC (rev 12643) @@ -8,8 +8,8 @@ package x10.core.fun; -import x10.types.RuntimeType; -import x10.types.Type; +import x10.rtt.RuntimeType; +import x10.rtt.Type; public interface VoidFun_0_4<T1,T2,T3,T4> { void apply(T1 o1, T2 o2, T3 o3, T4 o4); Modified: trunk/x10.runtime/src-java/x10/core/fun/VoidFun_0_5.java =================================================================== --- trunk/x10.runtime/src-java/x10/core/fun/VoidFun_0_5.java 2010-01-15 19:33:15 UTC (rev 12642) +++ trunk/x10.runtime/src-java/x10/core/fun/VoidFun_0_5.java 2010-01-15 19:34:03 UTC (rev 12643) @@ -8,8 +8,8 @@ package x10.core.fun; -import x10.types.RuntimeType; -import x10.types.Type; +import x10.rtt.RuntimeType; +import x10.rtt.Type; public interface VoidFun_0_5<T1,T2,T3,T4,T5> { void apply(T1 o1, T2 o2, T3 o3, T4 o4, T5 o5); Modified: trunk/x10.runtime/src-java/x10/core/fun/VoidFun_0_6.java =================================================================== --- trunk/x10.runtime/src-java/x10/core/fun/VoidFun_0_6.java 2010-01-15 19:33:15 UTC (rev 12642) +++ trunk/x10.runtime/src-java/x10/core/fun/VoidFun_0_6.java 2010-01-15 19:34:03 UTC (rev 12643) @@ -8,8 +8,8 @@ package x10.core.fun; -import x10.types.RuntimeType; -import x10.types.Type; +import x10.rtt.RuntimeType; +import x10.rtt.Type; public interface VoidFun_0_6<T1,T2,T3,T4,T5,T6> { void apply(T1 o1, T2 o2, T3 o3, T4 o4, T5 o5, T6 o6); Modified: trunk/x10.runtime/src-java/x10/core/fun/VoidFun_0_7.java =================================================================== --- trunk/x10.runtime/src-java/x10/core/fun/VoidFun_0_7.java 2010-01-15 19:33:15 UTC (rev 12642) +++ trunk/x10.runtime/src-java/x10/core/fun/VoidFun_0_7.java 2010-01-15 19:34:03 UTC (rev 12643) @@ -8,8 +8,8 @@ package x10.core.fun; -import x10.types.RuntimeType; -import x10.types.Type; +import x10.rtt.RuntimeType; +import x10.rtt.Type; public interface VoidFun_0_7<T1,T2,T3,T4,T5,T6,T7> { void apply(T1 o1, T2 o2, T3 o3, T4 o4, T5 o5, T6 o6, T7 o7); Modified: trunk/x10.runtime/src-java/x10/core/fun/VoidFun_0_8.java =================================================================== --- trunk/x10.runtime/src-java/x10/core/fun/VoidFun_0_8.java 2010-01-15 19:33:15 UTC (rev 12642) +++ trunk/x10.runtime/src-java/x10/core/fun/VoidFun_0_8.java 2010-01-15 19:34:03 UTC (rev 12643) @@ -8,8 +8,8 @@ package x10.core.fun; -import x10.types.RuntimeType; -import x10.types.Type; +import x10.rtt.RuntimeType; +import x10.rtt.Type; public interface VoidFun_0_8<T1,T2,T3,T4,T5,T6,T7,T8> { void apply(T1 o1, T2 o2, T3 o3, T4 o4, T5 o5, T6 o6, T7 o7, T8 o8); Modified: trunk/x10.runtime/src-java/x10/core/fun/VoidFun_0_9.java =================================================================== --- trunk/x10.runtime/src-java/x10/core/fun/VoidFun_0_9.java 2010-01-15 19:33:15 UTC (rev 12642) +++ trunk/x10.runtime/src-java/x10/core/fun/VoidFun_0_9.java 2010-01-15 19:34:03 UTC (rev 12643) @@ -8,8 +8,8 @@ package x10.core.fun; -import x10.types.RuntimeType; -import x10.types.Type; +import x10.rtt.RuntimeType; +import x10.rtt.Type; public interface VoidFun_0_9<T1,T2,T3,T4,T5,T6,T7,T8,T9> { void apply(T1 o1, T2 o2, T3 o3, T4 o4, T5 o5, T6 o6, T7 o7, T8 o8, T9 o9); Modified: trunk/x10.runtime/src-java/x10/rtt/BooleanType.java =================================================================== --- trunk/x10.runtime/src-java/x10/types/BooleanType.java 2010-01-15 04:18:16 UTC (rev 12632) +++ trunk/x10.runtime/src-java/x10/rtt/BooleanType.java 2010-01-15 19:34:03 UTC (rev 12643) @@ -6,7 +6,7 @@ * */ -package x10.types; +package x10.rtt; import x10.core.fun.Fun_0_1; import x10.core.fun.Fun_0_2; Modified: trunk/x10.runtime/src-java/x10/rtt/ByteType.java =================================================================== --- trunk/x10.runtime/src-java/x10/types/ByteType.java 2010-01-15 04:18:16 UTC (rev 12632) +++ trunk/x10.runtime/src-java/x10/rtt/ByteType.java 2010-01-15 19:34:03 UTC (rev 12643) @@ -6,7 +6,7 @@ * */ -package x10.types; +package x10.rtt; import x10.core.fun.Fun_0_1; import x10.core.fun.Fun_0_2; Modified: trunk/x10.runtime/src-java/x10/rtt/CharType.java =================================================================== --- trunk/x10.runtime/src-java/x10/types/CharType.java 2010-01-15 04:18:16 UTC (rev 12632) +++ trunk/x10.runtime/src-java/x10/rtt/CharType.java 2010-01-15 19:34:03 UTC (rev 12643) @@ -6,7 +6,7 @@ * */ -package x10.types; +package x10.rtt; import x10.core.fun.Fun_0_1; import x10.core.fun.Fun_0_2; Modified: trunk/x10.runtime/src-java/x10/rtt/ConstrainedType.java =================================================================== --- trunk/x10.runtime/src-java/x10/types/ConstrainedType.java 2010-01-15 04:18:16 UTC (rev 12632) +++ trunk/x10.runtime/src-java/x10/rtt/ConstrainedType.java 2010-01-15 19:34:03 UTC (rev 12643) @@ -6,7 +6,7 @@ * */ -package x10.types; +package x10.rtt; import java.util.ArrayList; import java.util.Arrays; Modified: trunk/x10.runtime/src-java/x10/rtt/DoubleType.java =================================================================== --- trunk/x10.runtime/src-java/x10/types/DoubleType.java 2010-01-15 04:18:16 UTC (rev 12632) +++ trunk/x10.runtime/src-java/x10/rtt/DoubleType.java 2010-01-15 19:34:03 UTC (rev 12643) @@ -6,7 +6,7 @@ * */ -package x10.types; +package x10.rtt; import x10.core.fun.Fun_0_1; import x10.core.fun.Fun_0_2; Modified: trunk/x10.runtime/src-java/x10/rtt/Equality.java =================================================================== --- trunk/x10.runtime/src-java/x10/types/Equality.java 2010-01-15 04:18:16 UTC (rev 12632) +++ trunk/x10.runtime/src-java/x10/rtt/Equality.java 2010-01-15 19:34:03 UTC (rev 12643) @@ -6,7 +6,7 @@ * */ -package x10.types; +package x10.rtt; import x10.core.Box; import x10.core.Ref; Modified: trunk/x10.runtime/src-java/x10/rtt/FloatType.java =================================================================== --- trunk/x10.runtime/src-java/x10/types/FloatType.java 2010-01-15 04:18:16 UTC (rev 12632) +++ trunk/x10.runtime/src-java/x10/rtt/FloatType.java 2010-01-15 19:34:03 UTC (rev 12643) @@ -6,7 +6,7 @@ * */ -package x10.types; +package x10.rtt; import x10.core.fun.Fun_0_1; import x10.core.fun.Fun_0_2; Modified: trunk/x10.runtime/src-java/x10/rtt/IntType.java =================================================================== --- trunk/x10.runtime/src-java/x10/types/IntType.java 2010-01-15 04:18:16 UTC (rev 12632) +++ trunk/x10.runtime/src-java/x10/rtt/IntType.java 2010-01-15 19:34:03 UTC (rev 12643) @@ -6,7 +6,7 @@ * */ -package x10.types; +package x10.rtt; import x10.core.fun.Fun_0_1; import x10.core.fun.Fun_0_2; Modified: trunk/x10.runtime/src-java/x10/rtt/LongType.java =================================================================== --- trunk/x10.runtime/src-java/x10/types/LongType.java 2010-01-15 04:18:16 UTC (rev 12632) +++ trunk/x10.runtime/src-java/x10/rtt/LongType.java 2010-01-15 19:34:03 UTC (rev 12643) @@ -6,7 +6,7 @@ * */ -package x10.types; +package x10.rtt; import x10.core.fun.Fun_0_1; import x10.core.fun.Fun_0_2; Modified: trunk/x10.runtime/src-java/x10/rtt/RuntimeType.java =================================================================== --- trunk/x10.runtime/src-java/x10/types/RuntimeType.java 2010-01-15 04:18:16 UTC (rev 12632) +++ trunk/x10.runtime/src-java/x10/rtt/RuntimeType.java 2010-01-15 19:34:03 UTC (rev 12643) @@ -9,7 +9,7 @@ * */ -package x10.types; +package x10.rtt; import java.util.List; Modified: trunk/x10.runtime/src-java/x10/rtt/ShortType.java =================================================================== --- trunk/x10.runtime/src-java/x10/types/ShortType.java 2010-01-15 04:18:16 UTC (rev 12632) +++ trunk/x10.runtime/src-java/x10/rtt/ShortType.java 2010-01-15 19:34:03 UTC (rev 12643) @@ -6,7 +6,7 @@ * */ -package x10.types; +package x10.rtt; import x10.core.fun.Fun_0_1; import x10.core.fun.Fun_0_2; Modified: trunk/x10.runtime/src-java/x10/rtt/Type.java =================================================================== --- trunk/x10.runtime/src-java/x10/types/Type.java 2010-01-15 04:18:16 UTC (rev 12632) +++ trunk/x10.runtime/src-java/x10/rtt/Type.java 2010-01-15 19:34:03 UTC (rev 12643) @@ -6,7 +6,7 @@ * */ -package x10.types; +package x10.rtt; import x10.core.fun.Fun_0_1; import x10.core.fun.Fun_0_2; Modified: trunk/x10.runtime/src-java/x10/rtt/Types.java =================================================================== --- trunk/x10.runtime/src-java/x10/types/Types.java 2010-01-15 04:18:16 UTC (rev 12632) +++ trunk/x10.runtime/src-java/x10/rtt/Types.java 2010-01-15 19:34:03 UTC (rev 12643) @@ -6,7 +6,7 @@ * */ -package x10.types; +package x10.rtt; public class Types { Modified: trunk/x10.runtime/src-java/x10/rtt/UByteType.java =================================================================== --- trunk/x10.runtime/src-java/x10/types/UByteType.java 2010-01-15 04:18:16 UTC (rev 12632) +++ trunk/x10.runtime/src-java/x10/rtt/UByteType.java 2010-01-15 19:34:03 UTC (rev 12643) @@ -6,7 +6,7 @@ * */ -package x10.types; +package x10.rtt; import x10.core.fun.Fun_0_1; import x10.core.fun.Fun_0_2; Modified: trunk/x10.runtime/src-java/x10/rtt/UIntType.java =================================================================== --- trunk/x10.runtime/src-java/x10/types/UIntType.java 2010-01-15 04:18:16 UTC (rev 12632) +++ trunk/x10.runtime/src-java/x10/rtt/UIntType.java 2010-01-15 19:34:03 UTC (rev 12643) @@ -6,7 +6,7 @@ * */ -package x10.types; +package x10.rtt; import x10.core.fun.Fun_0_1; import x10.core.fun.Fun_0_2; Modified: trunk/x10.runtime/src-java/x10/rtt/ULongType.java =================================================================== --- trunk/x10.runtime/src-java/x10/types/ULongType.java 2010-01-15 04:18:16 UTC (rev 12632) +++ trunk/x10.runtime/src-java/x10/rtt/ULongType.java 2010-01-15 19:34:03 UTC (rev 12643) @@ -6,7 +6,7 @@ * */ -package x10.types; +package x10.rtt; import x10.core.fun.Fun_0_1; import x10.core.fun.Fun_0_2; Modified: trunk/x10.runtime/src-java/x10/rtt/UShortType.java =================================================================== --- trunk/x10.runtime/src-java/x10/types/UShortType.java 2010-01-15 04:18:16 UTC (rev 12632) +++ trunk/x10.runtime/src-java/x10/rtt/UShortType.java 2010-01-15 19:34:03 UTC (rev 12643) @@ -6,7 +6,7 @@ * */ -package x10.types; +package x10.rtt; import x10.core.fun.Fun_0_1; import x10.core.fun.Fun_0_2; Modified: trunk/x10.runtime/src-x10/x10/lang/Boolean.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Boolean.x10 2010-01-15 19:33:15 UTC (rev 12642) +++ trunk/x10.runtime/src-x10/x10/lang/Boolean.x10 2010-01-15 19:34:03 UTC (rev 12643) @@ -11,7 +11,7 @@ import x10.compiler.Native; import x10.compiler.NativeRep; -@NativeRep("java", "boolean", "x10.core.BoxedBoolean", "x10.types.Type.BOOLEAN") +@NativeRep("java", "boolean", "x10.core.BoxedBoolean", "x10.rtt.Type.BOOLEAN") @NativeRep("c++", "x10_boolean", "x10_boolean", null) public final struct Boolean { @@ -52,7 +52,7 @@ @Native("c++", "x10aux::equals(#0,#1)") public global safe native def equals(x:Any):Boolean; - @Native("java", "x10.types.Equality.equalsequals(#0, #1)") + @Native("java", "x10.rtt.Equality.equalsequals(#0, #1)") @Native("c++", "x10aux::equals(#0,#1)") public global safe native def equals(x:Boolean):Boolean; Modified: trunk/x10.runtime/src-x10/x10/lang/Byte.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Byte.x10 2010-01-15 19:33:15 UTC (rev 12642) +++ trunk/x10.runtime/src-x10/x10/lang/Byte.x10 2010-01-15 19:34:03 UTC (rev 12643) @@ -11,7 +11,7 @@ import x10.compiler.Native; import x10.compiler.NativeRep; -@NativeRep("java", "byte", "x10.core.BoxedByte", "x10.types.Type.BYTE") +@NativeRep("java", "byte", "x10.core.BoxedByte", "x10.rtt.Type.BYTE") @NativeRep("c++", "x10_byte", "x10_byte", null) public final struct Byte { @Native("java", "((#1) < (#2))") @@ -158,11 +158,11 @@ @Native("c++", "x10aux::byte_utils::parseByte(#1)") public native static def parseByte(String): Byte throws NumberFormatException; - @Native("java", "x10.types.Equality.equalsequals(#0, #1)") + @Native("java", "x10.rtt.Equality.equalsequals(#0, #1)") @Native("c++", "x10aux::equals(#0,#1)") public global safe native def equals(x:Any):Boolean; - @Native("java", "x10.types.Equality.equalsequals(#0, #1)") + @Native("java", "x10.rtt.Equality.equalsequals(#0, #1)") @Native("c++", "x10aux::equals(#0,#1)") public global safe native def equals(x:Byte):Boolean; } Modified: trunk/x10.runtime/src-x10/x10/lang/Char.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Char.x10 2010-01-15 19:33:15 UTC (rev 12642) +++ trunk/x10.runtime/src-x10/x10/lang/Char.x10 2010-01-15 19:34:03 UTC (rev 12643) @@ -11,7 +11,7 @@ import x10.compiler.Native; import x10.compiler.NativeRep; -@NativeRep("java", "char", "x10.core.BoxedChar", "x10.types.Type.CHAR") +@NativeRep("java", "char", "x10.core.BoxedChar", "x10.rtt.Type.CHAR") @NativeRep("c++", "x10_char", "x10_char", null) public final struct Char { @Native("java", "((char) (#1))") @@ -130,11 +130,11 @@ @Native("c++", "x10aux::char_utils::reverseBytes(#0)") public native def reverseBytes(): Char; - @Native("java", "x10.types.Equality.equalsequals(#0, #1)") + @Native("java", "x10.rtt.Equality.equalsequals(#0, #1)") @Native("c++", "x10aux::equals(#0,#1)") public global safe native def equals(x:Any):Boolean; - @Native("java", "x10.types.Equality.equalsequals(#0, #1)") + @Native("java", "x10.rtt.Equality.equalsequals(#0, #1)") @Native("c++", "x10aux::equals(#0,#1)") public global safe native def equals(x:Char):Boolean; } Modified: trunk/x10.runtime/src-x10/x10/lang/Double.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Double.x10 2010-01-15 19:33:15 UTC (rev 12642) +++ trunk/x10.runtime/src-x10/x10/lang/Double.x10 2010-01-15 19:34:03 UTC (rev 12643) @@ -11,7 +11,7 @@ import x10.compiler.Native; import x10.compiler.NativeRep; -@NativeRep("java", "double", "x10.core.BoxedDouble", "x10.types.Types.DOUBLE") +@NativeRep("java", "double", "x10.core.BoxedDouble", "x10.rtt.Types.DOUBLE") @NativeRep("c++", "x10_double", "x10_double", null) public final struct Double { @Native("java", "((#1) < (#2))") @@ -132,11 +132,11 @@ @Native("c++", "x10aux::double_utils::fromLongBits(#1)") public static native def fromLongBits(Long): Double; - @Native("java", "x10.types.Equality.equalsequals(#0, #1)") + @Native("java", "x10.rtt.Equality.equalsequals(#0, #1)") @Native("c++", "x10aux::equals(#0,#1)") public global safe native def equals(x:Any):Boolean; - @Native("java", "x10.types.Equality.equalsequals(#0, #1)") + @Native("java", "x10.rtt.Equality.equalsequals(#0, #1)") @Native("c++", "x10aux::equals(#0,#1)") public global safe native def equals(x:Double):Boolean; } Modified: trunk/x10.runtime/src-x10/x10/lang/Float.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Float.x10 2010-01-15 19:33:15 UTC (rev 12642) +++ trunk/x10.runtime/src-x10/x10/lang/Float.x10 2010-01-15 19:34:03 UTC (rev 12643) @@ -11,7 +11,7 @@ import x10.compiler.Native; import x10.compiler.NativeRep; -@NativeRep("java", "float", "x10.core.BoxedFloat", "x10.types.Type.FLOAT") +@NativeRep("java", "float", "x10.core.BoxedFloat", "x10.rtt.Type.FLOAT") @NativeRep("c++", "x10_float", "x10_float", null) public final struct Float { @Native("java", "((#1) < (#2))") @@ -134,11 +134,11 @@ @Native("c++", "x10aux::float_utils::fromIntBits(#1)") public static native def fromIntBits(Int): Float; - @Native("java", "x10.types.Equality.equalsequals(#0, #1)") + @Native("java", "x10.rtt.Equality.equalsequals(#0, #1)") @Native("c++", "x10aux::equals(#0,#1)") public global safe native def equals(x:Any):Boolean; - @Native("java", "x10.types.Equality.equalsequals(#0, #1)") + @Native("java", "x10.rtt.Equality.equalsequals(#0, #1)") @Native("c++", "x10aux::equals(#0,#1)") public global safe native def equals(x:Float):Boolean; } Modified: trunk/x10.runtime/src-x10/x10/lang/Int.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Int.x10 2010-01-15 19:33:15 UTC (rev 12642) +++ trunk/x10.runtime/src-x10/x10/lang/Int.x10 2010-01-15 19:34:03 UTC (rev 12643) @@ -11,7 +11,7 @@ import x10.compiler.Native; import x10.compiler.NativeRep; -@NativeRep("java", "int", "x10.core.BoxedInt", "x10.types.Type.INT") +@NativeRep("java", "int", "x10.core.BoxedInt", "x10.rtt.Type.INT") // v-- when used @NativeRep("c++", "x10_int", "x10_int", null) // ^ when constructed @@ -201,11 +201,11 @@ @Native("c++", "x10aux::int_utils::reverseBytes(#0)") public native def reverseBytes(): Int; - @Native("java", "x10.types.Equality.equalsequals(#0, #1)") + @Native("java", "x10.rtt.Equality.equalsequals(#0, #1)") @Native("c++", "x10aux::equals(#0,#1)") public global safe native def equals(x:Any):Boolean; - @Native("java", "x10.types.Equality.equalsequals(#0, #1)") + @Native("java", "x10.rtt.Equality.equalsequals(#0, #1)") @Native("c++", "x10aux::equals(#0,#1)") public global safe native def equals(x:Int):Boolean; } Modified: trunk/x10.runtime/src-x10/x10/lang/Long.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Long.x10 2010-01-15 19:33:15 UTC (rev 12642) +++ trunk/x10.runtime/src-x10/x10/lang/Long.x10 2010-01-15 19:34:03 UTC (rev 12643) @@ -11,7 +11,7 @@ import x10.compiler.Native; import x10.compiler.NativeRep; -@NativeRep("java", "long", "x10.core.BoxedLong", "x10.types.Type.LONG") +@NativeRep("java", "long", "x10.core.BoxedLong", "x10.rtt.Type.LONG") @NativeRep("c++", "x10_long", "x10_long", null) public final struct Long { @Native("java", "((#1) < (#2))") @@ -199,11 +199,11 @@ @Native("c++", "x10aux::long_utils::reverseBytes(#0)") public native def reverseBytes(): Long; - @Native("java", "x10.types.Equality.equalsequals(#0, #1)") + @Native("java", "x10.rtt.Equality.equalsequals(#0, #1)") @Native("c++", "x10aux::equals(#0,#1)") public global safe native def equals(x:Any):Boolean; - @Native("java", "x10.types.Equality.equalsequals(#0, #1)") + @Native("java", "x10.rtt.Equality.equalsequals(#0, #1)") @Native("c++", "x10aux::equals(#0,#1)") public global safe native def equals(x:Long):Boolean; } Modified: trunk/x10.runtime/src-x10/x10/lang/Short.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Short.x10 2010-01-15 19:33:15 UTC (rev 12642) +++ trunk/x10.runtime/src-x10/x10/lang/Short.x10 2010-01-15 19:34:03 UTC (rev 12643) @@ -11,7 +11,7 @@ import x10.compiler.Native; import x10.compiler.NativeRep; -@NativeRep("java", "short", "x10.core.BoxedShort", "x10.types.Type.SHORT") +@NativeRep("java", "short", "x10.core.BoxedShort", "x10.rtt.Type.SHORT") @NativeRep("c++", "x10_short", "x10_short", null) public final struct Short { @Native("java", "((#1) < (#2))") @@ -162,11 +162,11 @@ @Native("c++", "x10aux::short_utils::reverseBytes(#0)") public native def reverseBytes(): Short; - @Native("java", "x10.types.Equality.equalsequals(#0, #1)") + @Native("java", "x10.rtt.Equality.equalsequals(#0, #1)") @Native("c++", "x10aux::equals(#0,#1)") public global safe native def equals(x:Any):Boolean; - @Native("java", "x10.types.Equality.equalsequals(#0, #1)") + @Native("java", "x10.rtt.Equality.equalsequals(#0, #1)") @Native("c++", "x10aux::equals(#0,#1)") public global safe native def equals(x:Short):Boolean; } Modified: trunk/x10.runtime/src-x10/x10/lang/UByte.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/UByte.x10 2010-01-15 19:33:15 UTC (rev 12642) +++ trunk/x10.runtime/src-x10/x10/lang/UByte.x10 2010-01-15 19:34:03 UTC (rev 12643) @@ -11,7 +11,7 @@ import x10.compiler.Native; import x10.compiler.NativeRep; -@NativeRep("java", "byte", "x10.core.BoxedShort", "x10.types.Types.UBYTE") +@NativeRep("java", "byte", "x10.core.BoxedShort", "x10.rtt.Types.UBYTE") // v-- when used @NativeRep("c++", "x10_ubyte", "x10_ubyte", null) // ^ when constructed @@ -202,11 +202,11 @@ @Native("c++", "x10aux::int_utils::reverseBytes(#0)") public native def reverseBytes(): UByte; - @Native("java", "x10.types.Equality.equalsequals(#0, #1)") + @Native("java", "x10.rtt.Equality.equalsequals(#0, #1)") @Native("c++", "x10aux::equals(#0,#1)") public global safe native def equals(x:Any):Boolean; - @Native("java", "x10.types.Equality.equalsequals(#0, #1)") + @Native("java", "x10.rtt.Equality.equalsequals(#0, #1)") @Native("c++", "x10aux::equals(#0,#1)") public global safe native def equals(x:UByte):Boolean; } Modified: trunk/x10.runtime/src-x10/x10/lang/UInt.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/UInt.x10 2010-01-15 19:33:15 UTC (rev 12642) +++ trunk/x10.runtime/src-x10/x10/lang/UInt.x10 2010-01-15 19:34:03 UTC (rev 12643) @@ -11,7 +11,7 @@ import x10.compiler.Native; import x10.compiler.NativeRep; -@NativeRep("java", "int", "x10.core.BoxedInt", "x10.types.Types.UINT") +@NativeRep("java", "int", "x10.core.BoxedInt", "x10.rtt.Types.UINT") // v-- when used @NativeRep("c++", "x10_uint", "x10_uint", null) // ^ when constructed @@ -212,11 +212,11 @@ @Native("c++", "x10aux::int_utils::reverseBytes(#0)") public native def reverseBytes(): Int; - @Native("java", "x10.types.Equality.equalsequals(#0, #1)") + @Native("java", "x10.rtt.Equality.equalsequals(#0, #1)") @Native("c++", "x10aux::equals(#0,#1)") public global safe native def equals(x:Any):Boolean; - @Native("java", "x10.types.Equality.equalsequals(#0, #1)") + @Native("java", "x10.rtt.Equality.equalsequals(#0, #1)") @Native("c++", "x10aux::equals(#0,#1)") public global safe native def equals(x:UInt):Boolean; } Modified: trunk/x10.runtime/src-x10/x10/lang/ULong.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/ULong.x10 2010-01-15 19:33:15 UTC (rev 12642) +++ trunk/x10.runtime/src-x10/x10/lang/ULong.x10 2010-01-15 19:34:03 UTC (rev 12643) @@ -11,7 +11,7 @@ import x10.compiler.Native; import x10.compiler.NativeRep; -@NativeRep("java", "long", "x10.core.BoxedLong", "x10.types.Types.ULONG") +@NativeRep("java", "long", "x10.core.BoxedLong", "x10.rtt.Types.ULONG") // v-- when used @NativeRep("c++", "x10_ulong", "x10_ulong", null) // ^ when constructed @@ -205,11 +205,11 @@ @Native("c++", "x10aux::int_utils::reverseBytes(#0)") public native def reverseBytes(): ULong; - @Native("java", "x10.types.Equality.equalsequals(#0, #1)") + @Native("java", "x10.rtt.Equality.equalsequals(#0, #1)") @Native("c++", "x10aux::equals(#0,#1)") public global safe native def equals(x:Any):Boolean; - @Native("java", "x10.types.Equality.equalsequals(#0, #1)") + @Native("java", "x10.rtt.Equality.equalsequals(#0, #1)") @Native("c++", "x10aux::equals(#0,#1)") public global safe native def equals(x:ULong):Boolean; } Modified: trunk/x10.runtime/src-x10/x10/lang/UShort.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/UShort.x10 2010-01-15 19:33:15 UTC (rev 12642) +++ trunk/x10.runtime/src-x10/x10/lang/UShort.x10 2010-01-15 19:34:03 UTC (rev 12643) @@ -11,7 +11,7 @@ import x10.compiler.Native; import x10.compiler.NativeRep; -@NativeRep("java", "short", "x10.core.BoxedShort", "x10.types.Types.USHORT") +@NativeRep("java", "short", "x10.core.BoxedShort", "x10.rtt.Types.USHORT") // v-- when used @NativeRep("c++", "x10_ushort", "x10_ushort", null) // ^ when constructed @@ -2... [truncated message content] |
From: <vj...@us...> - 2010-01-16 16:28:44
|
Revision: 12513 http://x10.svn.sourceforge.net/x10/?rev=12513&view=rev Author: vj0 Date: 2010-01-12 12:14:36 +0000 (Tue, 12 Jan 2010) Log Message: ----------- Fixes XTENLANG-756. -- A one-line mistake in place-checking code that meant that place checks were not performed on receivers of interface types. This caused a number of place-type bugs to surface in XRX. Fixed them per my understanding -- needs to be reviewed by Olivier. -- Fixed X10TypeEnv_c.typeBounds so that it is aligned with the new type system. The includeObject flag should be ignored. Every type parameter now takes Any as an upper bound. Fixes a traceback that arose because of a ClassCastException when processing an ambiguous proto types. Proto is handled as a flag. This flag needs to be recorded on the ambiguous type, and then communicated to the resolveed top. Fixed a bug in proto type checking so that proto return types for constructors are now permitted. Restructured closure code -- moved various AST generators and type generators into x10.util.ClosureSynthesizer. Started to document the surprisingly brittle code for processing closures. Needs to be cleaned up and redesigned. Fixed home processing in Desugarer to align with recent changes to XRX which broke this piece of code. This now breaks the C++ backend -- apparently home() is not defined yet on structs? (Should be easy to fix.) Fixed inscrutable error message that was triggered when processing a non-static typedef. Fixed closure types toString so that the annoying "<anonymous subtype of ...>" is replaced by "...". Modified Paths: -------------- trunk/x10.compiler/src/x10/ast/AmbMacroTypeNode_c.java trunk/x10.compiler/src/x10/ast/Closure.java trunk/x10.compiler/src/x10/ast/Closure_c.java trunk/x10.compiler/src/x10/ast/ForLoop_c.java trunk/x10.compiler/src/x10/ast/PlacedClosure_c.java trunk/x10.compiler/src/x10/ast/X10AmbTypeNode_c.java trunk/x10.compiler/src/x10/ast/X10Call_c.java trunk/x10.compiler/src/x10/ast/X10CanonicalTypeNode.java trunk/x10.compiler/src/x10/ast/X10ClassDecl_c.java trunk/x10.compiler/src/x10/ast/X10FieldAssign_c.java trunk/x10.compiler/src/x10/ast/X10New_c.java trunk/x10.compiler/src/x10/types/ClosureDef.java trunk/x10.compiler/src/x10/types/ClosureType_c.java trunk/x10.compiler/src/x10/types/TypeDefAsMacroTypeTransform.java trunk/x10.compiler/src/x10/types/X10ClassDef_c.java trunk/x10.compiler/src/x10/types/X10Context_c.java trunk/x10.compiler/src/x10/types/X10TypeEnv_c.java trunk/x10.compiler/src/x10/types/X10TypeSystem.java trunk/x10.compiler/src/x10/types/X10TypeSystem_c.java trunk/x10.compiler/src/x10/util/Synthesizer.java trunk/x10.compiler/src/x10/visit/Desugarer.java trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java trunk/x10.runtime/src-x10/x10/io/ByteWriter.x10 trunk/x10.runtime/src-x10/x10/lang/Equals.x10 trunk/x10.runtime/src-x10/x10/util/AbstractCollection.x10 trunk/x10.runtime/src-x10/x10/util/Collection.x10 trunk/x10.runtime/src-x10/x10/util/DistributedRail.x10 trunk/x10.runtime/src-x10/x10/util/MapIterator.x10 trunk/x10.runtime/src-x10/x10/util/MapSet.x10 Added Paths: ----------- trunk/x10.compiler/src/x10/util/ClosureSynthesizer.java Property Changed: ---------------- trunk/x10.compiler/src/x10/ast/ Property changes on: trunk/x10.compiler/src/x10/ast ___________________________________________________________________ Modified: svn:ignore - *.local + *.local X10Loop_cprs.xml X10Loop_csym.xml X10Loop_c.l Modified: trunk/x10.compiler/src/x10/ast/AmbMacroTypeNode_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/AmbMacroTypeNode_c.java 2010-01-12 05:46:20 UTC (rev 12512) +++ trunk/x10.compiler/src/x10/ast/AmbMacroTypeNode_c.java 2010-01-12 12:14:36 UTC (rev 12513) @@ -23,6 +23,7 @@ import polyglot.ast.TypeNode_c; import polyglot.frontend.Globals; import polyglot.frontend.Goal; +import polyglot.types.Flags; import polyglot.types.LazyRef; import polyglot.types.LocalDef; import polyglot.types.Name; @@ -30,6 +31,7 @@ import polyglot.types.Ref; import polyglot.types.SemanticException; import polyglot.types.Type; +import polyglot.types.Types; import polyglot.types.UnknownType; import polyglot.util.CodeWriter; import polyglot.util.CollectionUtil; @@ -52,11 +54,12 @@ import x10.types.X10ClassType; import x10.types.X10Context; import x10.types.X10ParsedClassType; +import x10.types.X10Type; import x10.types.X10TypeMixin; import x10.types.X10TypeSystem; -public class AmbMacroTypeNode_c extends TypeNode_c implements AmbMacroTypeNode { +public class AmbMacroTypeNode_c extends TypeNode_c implements AmbMacroTypeNode, AddFlags { protected Prefix prefix; protected Id name; @@ -104,6 +107,10 @@ public List<Expr> args() { return this.args; } + Flags flags; + public void addFlags(Flags f) { + this.flags = f; + } public AmbMacroTypeNode args(List<Expr> args) { AmbMacroTypeNode_c n = (AmbMacroTypeNode_c) copy(); n.args = TypedList.copyAndCheck(args, Expr.class, true); @@ -350,7 +357,11 @@ } } } - + if (n.flags != null) { + t = ((X10Type) t).setFlags(flags); + n.flags = null; + } + // Update the symbol with the base type so that if we try to get the type while checking the constraint, we don't get a cyclic // dependency error, but instead get a less precise type. sym.update(t); @@ -404,12 +415,14 @@ } Node postprocess(CanonicalTypeNode result, AmbMacroTypeNode_c n, ContextVisitor childtc) throws SemanticException { - n = (AmbMacroTypeNode_c) X10Del_c.visitAnnotations(n, childtc); - - result = (CanonicalTypeNode) ((X10Del) result.del()).annotations(((X10Del) n.del()).annotations()); - result = (CanonicalTypeNode) ((X10Del) result.del()).setComment(((X10Del) n.del()).comment()); + n = (AmbMacroTypeNode_c) X10Del_c.visitAnnotations(n, childtc); - return result.del().typeCheck(childtc); + result = (CanonicalTypeNode) ((X10Del) result.del()).annotations(((X10Del) n.del()).annotations()); + result = (CanonicalTypeNode) ((X10Del) result.del()).setComment(((X10Del) n.del()).comment()); + result = (CanonicalTypeNode) result.del().typeCheck(childtc); + + + return result; } public Node exceptionCheck(ExceptionChecker ec) throws SemanticException { Modified: trunk/x10.compiler/src/x10/ast/Closure.java =================================================================== --- trunk/x10.compiler/src/x10/ast/Closure.java 2010-01-12 05:46:20 UTC (rev 12512) +++ trunk/x10.compiler/src/x10/ast/Closure.java 2010-01-12 12:14:36 UTC (rev 12513) @@ -20,6 +20,12 @@ import polyglot.util.Position; import x10.types.ClosureDef; +/** + * A Closure AST node represents a closure literal in the source text. Its type is a Closuredef. + * + * @author vj + * + */ public interface Closure extends Expr, CodeBlock { // List<TypeParamNode> typeParameters(); Modified: trunk/x10.compiler/src/x10/ast/Closure_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/Closure_c.java 2010-01-12 05:46:20 UTC (rev 12512) +++ trunk/x10.compiler/src/x10/ast/Closure_c.java 2010-01-12 12:14:36 UTC (rev 12513) @@ -63,7 +63,18 @@ import x10.types.X10MemberDef; import x10.types.X10TypeMixin; import x10.types.X10TypeSystem; +import x10.types.X10TypeSystem_c; +import x10.util.ClosureSynthesizer; +/** + * An implementation of a closure literal in the source text. + * + * It has associated with it a ClosurDef. + * + * Its type is an anonymous class that implements the Fun_m_n synthesized interface associated with ClosureDef. + * @author vj + * + */ public class Closure_c extends Expr_c implements Closure { // List<TypeParamNode> typeParameters; List<Formal> formals; @@ -364,7 +375,7 @@ @Override public Node typeCheck(ContextVisitor tc) throws SemanticException { - X10TypeSystem x10ts = (X10TypeSystem) tc.typeSystem(); + X10TypeSystem_c xts = (X10TypeSystem_c) tc.typeSystem(); Context c = tc.context(); Closure_c n = this; @@ -374,7 +385,7 @@ Type t = tn.type(); if (! t.isThrowable()) { throw new SemanticException("Type \"" + t + - "\" is not a subclass of \"" + x10ts.Throwable() + "\".", + "\" is not a subclass of \"" + xts.Throwable() + "\".", tn.position()); } } @@ -383,20 +394,18 @@ NodeFactory nf = tc.nodeFactory(); TypeSystem ts = tc.typeSystem(); // Body had no return statement. Set to void. - Type t; - if (! (((Ref<Type>) n.returnType().typeRef()).getCached() instanceof UnknownType)) { - t = ((Ref<Type>) n.returnType().typeRef()).getCached(); - } - else { + Ref<Type> tr=((Ref<Type>) n.returnType().typeRef()); + Type t = tr.getCached(); + if (t instanceof UnknownType) { t = ts.Void(); } - ((Ref<Type>) n.returnType().typeRef()).update(t); + tr.update(t); n = (Closure_c) n.returnType(nf.CanonicalTypeNode(n.returnType().position(), t)); } // Create an anonymous subclass of the closure type. ClosureDef def = n.closureDef; - ClassDef cd = x10ts.closureAnonymousClassDef(def); + ClassDef cd = ClosureSynthesizer.closureAnonymousClassDef(xts, def); return n.type(cd.asType()); } @@ -493,7 +502,7 @@ if (iter.hasNext()) sb.append(", "); } sb.append(")"); - sb.append(guard); + sb.append(guard==null?"{}":guard); sb.append(": "); sb.append(returnType.toString()); if (throwTypes.size() > 0) { Modified: trunk/x10.compiler/src/x10/ast/ForLoop_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/ForLoop_c.java 2010-01-12 05:46:20 UTC (rev 12512) +++ trunk/x10.compiler/src/x10/ast/ForLoop_c.java 2010-01-12 12:14:36 UTC (rev 12513) @@ -69,6 +69,9 @@ return succs; } + public Node typeCheck(TypeChecker tc) throws SemanticException { + return super.typeCheck(tc); + } /** Type check the statement. */ // public Node typeCheck(TypeChecker tc) throws SemanticException { // ForLoop_c n = (ForLoop_c) super.typeCheck(tc); Modified: trunk/x10.compiler/src/x10/ast/PlacedClosure_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/PlacedClosure_c.java 2010-01-12 05:46:20 UTC (rev 12512) +++ trunk/x10.compiler/src/x10/ast/PlacedClosure_c.java 2010-01-12 12:14:36 UTC (rev 12513) @@ -99,8 +99,7 @@ public static XConstrainedTerm computePlaceTerm( Expr place, X10Context xc, X10TypeSystem ts ) throws SemanticException { - //System.err.println("PlacedClosure_c: Golden! evaluating placeterm for " + this); - Type placeType = place.type(); + Type placeType = place.type(); XConstraint d = X10TypeMixin.xclause(placeType); d = (d==null) ? new XConstraint_c() : d.copy(); XConstraint pc = null; @@ -120,7 +119,7 @@ term + " and constraint " + d + "."); } } else { - boolean placeIsRef = ts.isImplicitCastValid(placeType, ts.Object(), xc); + boolean placeIsRef = true; // ts.isImplicitCastValid(placeType, ts.Object(), xc); if (placeIsRef) { XTerm src = ts.xtypeTranslator().trans(pc, place, xc); if (src == null) { Modified: trunk/x10.compiler/src/x10/ast/X10AmbTypeNode_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10AmbTypeNode_c.java 2010-01-12 05:46:20 UTC (rev 12512) +++ trunk/x10.compiler/src/x10/ast/X10AmbTypeNode_c.java 2010-01-12 12:14:36 UTC (rev 12513) @@ -139,7 +139,7 @@ } } else if (prefix instanceof Expr) { - throw new InternalCompilerError("non-static type members not implemented", pos); + throw new SemanticException("Non-static type members not implemented: " + prefix + " cannot be understood.", pos); } if (typeDefContainer != null) { Modified: trunk/x10.compiler/src/x10/ast/X10Call_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10Call_c.java 2010-01-12 05:46:20 UTC (rev 12512) +++ trunk/x10.compiler/src/x10/ast/X10Call_c.java 2010-01-12 12:14:36 UTC (rev 12513) @@ -587,8 +587,9 @@ Receiver target = target(); - // Method invocations on structs and values are always permitted - if (! ts.isSubtype(target.type(), ts.Object(), xc)) + // Method invocations on structs are always permitted + if (ts.isStructType(target.type())) + //if (! (ts.isSubtype(target.type(), ts.Object(), xc) || ts.isInterfaceType(target.type()))) return; Modified: trunk/x10.compiler/src/x10/ast/X10CanonicalTypeNode.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10CanonicalTypeNode.java 2010-01-12 05:46:20 UTC (rev 12512) +++ trunk/x10.compiler/src/x10/ast/X10CanonicalTypeNode.java 2010-01-12 12:14:36 UTC (rev 12513) @@ -10,7 +10,7 @@ import polyglot.ast.CanonicalTypeNode; -public interface X10CanonicalTypeNode extends CanonicalTypeNode { +public interface X10CanonicalTypeNode extends CanonicalTypeNode, AddFlags { public DepParameterExpr constraintExpr(); public X10CanonicalTypeNode constraintExpr(DepParameterExpr e); } Modified: trunk/x10.compiler/src/x10/ast/X10ClassDecl_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10ClassDecl_c.java 2010-01-12 05:46:20 UTC (rev 12512) +++ trunk/x10.compiler/src/x10/ast/X10ClassDecl_c.java 2010-01-12 12:14:36 UTC (rev 12513) @@ -93,6 +93,7 @@ import x10.types.ParameterType; import x10.types.TypeConstraint; import x10.types.TypeConstraint_c; +import x10.types.TypeDef; import x10.types.X10ClassDef; import x10.types.X10ClassDef_c; import x10.types.X10ClassType; @@ -677,6 +678,15 @@ } } + // Check for instance type definitions -- these are not supported. + for (TypeDef def : ((X10ClassDef) type).memberTypes()) { + MacroType mt = def.asType(); + if (mt.container() != null && !mt.flags().isStatic()) { + throw new SemanticException("Illegal type def " + mt + ": type-defs must be static.", def.position()); + } + } + + Map<X10ClassDef,X10ClassType> map = new HashMap<X10ClassDef, X10ClassType>(); for (X10ClassType ct : supers) { X10ClassType t = map.get(ct.x10Def()); Modified: trunk/x10.compiler/src/x10/ast/X10FieldAssign_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10FieldAssign_c.java 2010-01-12 05:46:20 UTC (rev 12512) +++ trunk/x10.compiler/src/x10/ast/X10FieldAssign_c.java 2010-01-12 12:14:36 UTC (rev 12513) @@ -80,6 +80,7 @@ n.checkFieldPlaceType(tc); n= (X10FieldAssign_c) n.type(t); + return n; } return X10LocalAssign_c.typeCheckAssign(n, tc); Modified: trunk/x10.compiler/src/x10/ast/X10New_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10New_c.java 2010-01-12 05:46:20 UTC (rev 12512) +++ trunk/x10.compiler/src/x10/ast/X10New_c.java 2010-01-12 12:14:36 UTC (rev 12513) @@ -501,9 +501,13 @@ } X10TypeSystem ts = (X10TypeSystem) tc.typeSystem(); - Type tp = ci.returnType(); - - if (!ts.isSubtype(tp, t, tc.context())) { + X10Type tp = (X10Type) ci.returnType(); + X10Type tp1 = (X10Type) tp.copy(); + if (tp1.isProto()) { + tp1 = tp1.clearFlags(X10Flags.PROTO); + } + + if (!ts.isSubtype(tp1, t, tc.context())) { throw new SemanticException("Constructor return type " + tp + " is not a subtype of " + t + ".", position()); } Modified: trunk/x10.compiler/src/x10/types/ClosureDef.java =================================================================== --- trunk/x10.compiler/src/x10/types/ClosureDef.java 2010-01-12 05:46:20 UTC (rev 12512) +++ trunk/x10.compiler/src/x10/types/ClosureDef.java 2010-01-12 12:14:36 UTC (rev 12513) @@ -21,6 +21,15 @@ import x10.constraint.XConstraint; import x10.constraint.XTerm; +/** + * A ClosureDef represents the type information for a closure: + * its formal parameters, + * its return types, + * throw types + * a placeterm representing the place at which the body of this function is intended to execute. + * @author vj + * + */ public interface ClosureDef extends FunctionDef, X10Def, X10ProcedureDef { ClosureInstance asInstance(); Modified: trunk/x10.compiler/src/x10/types/ClosureType_c.java =================================================================== --- trunk/x10.compiler/src/x10/types/ClosureType_c.java 2010-01-12 05:46:20 UTC (rev 12512) +++ trunk/x10.compiler/src/x10/types/ClosureType_c.java 2010-01-12 12:14:36 UTC (rev 12513) @@ -93,7 +93,8 @@ sb.append(", "); sb.append(t); } - return "(" + sb.toString() + ")" + guard() + "=> " + mi.returnType(); + XConstraint guard = guard(); + return "(" + sb.toString() + ")" + (guard==null? "{}" : guard) + "=> " + mi.returnType(); } @Override Modified: trunk/x10.compiler/src/x10/types/TypeDefAsMacroTypeTransform.java =================================================================== --- trunk/x10.compiler/src/x10/types/TypeDefAsMacroTypeTransform.java 2010-01-12 05:46:20 UTC (rev 12512) +++ trunk/x10.compiler/src/x10/types/TypeDefAsMacroTypeTransform.java 2010-01-12 12:14:36 UTC (rev 12513) @@ -13,12 +13,15 @@ import polyglot.util.Transformation; public class TypeDefAsMacroTypeTransform implements Transformation<TypeDef, Type> { + public TypeDefAsMacroTypeTransform() { + } + public Type transform(TypeDef def) { X10TypeSystem xts = (X10TypeSystem) def.typeSystem(); MacroType mt = def.asType(); - if (mt.container() != null && !mt.flags().isStatic()) { + /*if (mt.container() != null && !mt.flags().isStatic()) { throw new InternalCompilerError("non-static member typedefs are unimplemented"); - } + }*/ return mt; } } Modified: trunk/x10.compiler/src/x10/types/X10ClassDef_c.java =================================================================== --- trunk/x10.compiler/src/x10/types/X10ClassDef_c.java 2010-01-12 05:46:20 UTC (rev 12512) +++ trunk/x10.compiler/src/x10/types/X10ClassDef_c.java 2010-01-12 12:14:36 UTC (rev 12513) @@ -14,9 +14,12 @@ import java.util.List; import polyglot.frontend.Source; +import polyglot.types.ClassDef; import polyglot.types.ClassDef_c; import polyglot.types.FieldDef; import polyglot.types.LazyRef_c; +import polyglot.types.Name; +import polyglot.types.Package; import polyglot.types.QName; import polyglot.types.Ref; import polyglot.types.Ref_c; @@ -333,4 +336,32 @@ public boolean isFunction() { return false; } + public String toString() { + Name name = name(); + + if (kind() == null) { + return "<unknown class " + name + ">"; + } + + if (kind() == ANONYMOUS) { + if (interfaces != null && ! interfaces.isEmpty()) { + return isFunction() ? "" + interfaces.get(0) : "<anonymous subtype of " + interfaces.get(0) + ">"; + } + if (superType != null) { + return "<anonymous subclass of " + superType + ">"; + } + } + + if (kind() == TOP_LEVEL) { + Package p = Types.get(package_()); + return (p != null ? p.toString() + "." : "") + name; + } + else if (kind() == MEMBER) { + ClassDef outer = Types.get(outer()); + return (outer != null ? outer.toString() + "." : "") + name; + } + else { + return name.toString(); + } + } } Modified: trunk/x10.compiler/src/x10/types/X10Context_c.java =================================================================== --- trunk/x10.compiler/src/x10/types/X10Context_c.java 2010-01-12 05:46:20 UTC (rev 12512) +++ trunk/x10.compiler/src/x10/types/X10Context_c.java 2010-01-12 12:14:36 UTC (rev 12513) @@ -59,6 +59,7 @@ import polyglot.types.ImportTable; import polyglot.types.LocalDef; import polyglot.types.LocalInstance; +import polyglot.types.Matcher; import polyglot.types.MethodInstance; import polyglot.types.Name; import polyglot.types.Named; @@ -895,4 +896,6 @@ public Name getNewVarName() { return Name.make(MAGIC_VAR_PREFIX + (varCount++)); } + + } Modified: trunk/x10.compiler/src/x10/types/X10TypeEnv_c.java =================================================================== --- trunk/x10.compiler/src/x10/types/X10TypeEnv_c.java 2010-01-12 05:46:20 UTC (rev 12512) +++ trunk/x10.compiler/src/x10/types/X10TypeEnv_c.java 2010-01-12 12:14:36 UTC (rev 12513) @@ -449,11 +449,12 @@ } if (kind == Bound.UPPER && result.isEmpty()) - if (includeObject) + return Collections.<Type>singletonList(ts.Any()); + /* if (includeObject) return Collections.<Type>singletonList(ts.Object()); else return Collections.<Type>emptyList(); - + */ return new ArrayList<Type>(result); } @@ -1982,7 +1983,7 @@ if (acceptable.size() == 0) { if (error == null) { - error = new NoMemberException(NoMemberException.CONSTRUCTOR, "No valid constructor found for " + container + matcher.signature() + "."); + error = new NoMemberException(NoMemberException.CONSTRUCTOR, "No valid constructor found for " + matcher.signature() + "."); } throw error; Modified: trunk/x10.compiler/src/x10/types/X10TypeSystem.java =================================================================== --- trunk/x10.compiler/src/x10/types/X10TypeSystem.java 2010-01-12 05:46:20 UTC (rev 12512) +++ trunk/x10.compiler/src/x10/types/X10TypeSystem.java 2010-01-12 12:14:36 UTC (rev 12513) @@ -332,7 +332,7 @@ boolean isFunctionType(Type type); - X10ClassDef closureAnonymousClassDef(ClosureDef def); + // List<ClosureType> getFunctionSupertypes(Type type, X10Context context); Modified: trunk/x10.compiler/src/x10/types/X10TypeSystem_c.java =================================================================== --- trunk/x10.compiler/src/x10/types/X10TypeSystem_c.java 2010-01-12 05:46:20 UTC (rev 12512) +++ trunk/x10.compiler/src/x10/types/X10TypeSystem_c.java 2010-01-12 12:14:36 UTC (rev 12513) @@ -92,6 +92,7 @@ import x10.constraint.XTerms; import x10.constraint.XVar; import x10.parser.X10ParsedName; +import x10.util.ClosureSynthesizer; /** * A TypeSystem implementation for X10. @@ -340,175 +341,8 @@ throw new NoClassException(name.toString(), container); } - public X10ClassDef closureAnonymousClassDef(final ClosureDef def) { - final X10TypeSystem xts = this; - final Position pos = def.position(); - - X10ClassDef cd = new X10ClassDef_c(this, null); - - cd.position(pos); - cd.name(null); - cd.setPackage(null); - cd.kind(ClassDef.ANONYMOUS); - cd.flags(Flags.NONE); - - int numTypeParams = def.typeParameters().size(); - int numValueParams = def.formalTypes().size(); - - // Add type parameters. - List<Ref<? extends Type>> typeParams = new ArrayList<Ref<? extends Type>>(); - List<Type> typeArgs = new ArrayList<Type>(); - - ClosureInstance ci = (ClosureInstance) def.asInstance(); - typeArgs.addAll(ci.formalTypes()); - - if (!ci.returnType().isVoid()) { - typeArgs.add(ci.returnType()); - } - - // Instantiate the super type on the new parameters. - X10ClassType sup = (X10ClassType) closureBaseInterfaceDef(numTypeParams, - numValueParams, - ci.returnType().isVoid(), - def.formalNames(), - def.guard()) - .asType(); - - assert sup.x10Def().typeParameters().size() == typeArgs.size() : def + ", " + sup + ", " + typeArgs; - sup = sup.typeArguments(typeArgs); - - // cd.superType(Types.ref(Value())); // Closures are values. - cd.addInterface(Types.ref(sup)); - - return cd; - } - - public X10ClassDef closureBaseInterfaceDef(final int numTypeParams, final int numValueParams, - final boolean isVoid) { - return closureBaseInterfaceDef(numTypeParams, numValueParams, isVoid, null, null); - } - - /** - * Synthetically generated interface for the function types. - * @param numTypeParams - * @param numValueParams - * @param isVoid - * @param formalNames - * @param guard - * @return - */ - public X10ClassDef closureBaseInterfaceDef(final int numTypeParams, - final int numValueParams, - final boolean isVoid, - List<LocalDef> formalNames, - final Ref<XConstraint> guard) { - final X10TypeSystem xts = this; - final Position pos = Position.COMPILER_GENERATED; - - String name = "Fun_" + numTypeParams + "_" + numValueParams; - - if (isVoid) { - name = "Void" + name; - } - - // Check if the class has already been defined. - QName fullName = QName.make("x10.lang", name); - Named n = xts.systemResolver().check(fullName); - - if (n instanceof X10ClassType) { - X10ClassType ct = (X10ClassType) n; - return ct.x10Def(); - } - - X10ClassDef cd = (X10ClassDef) new X10ClassDef_c(this, null) { - @Override - public boolean isFunction() { - return true; - } - @Override - public ClassType asType() { - if (asType == null) { - X10ClassDef cd = this; - asType = new ClosureType_c(xts, pos, this); - } - return asType; - } - }; - - cd.position(pos); - cd.name(Name.make(name)); - try { - cd.setPackage(Types.ref(xts.packageForName(fullName.qualifier()))); - } - catch (SemanticException e) { - assert false; - } - - cd.kind(ClassDef.TOP_LEVEL); - cd.superType(null); // interfaces have no superclass - // Functions implement the Any interface. - cd.setInterfaces(Collections.<Ref<? extends Type>> singletonList(Types.ref(Any()))); - cd.flags(X10Flags.toX10Flags(Flags.PUBLIC.Abstract().Interface())); - - final List<Ref<? extends Type>> typeParams = new ArrayList<Ref<? extends Type>>(); - final List<Ref<? extends Type>> argTypes = new ArrayList<Ref<? extends Type>>(); - - for (int i = 0; i < numTypeParams; i++) { - Type t = new ParameterType_c(xts, pos, Name.make("X" + i), Types.ref(cd)); - typeParams.add(Types.ref(t)); - } - - for (int i = 0; i < numValueParams; i++) { - ParameterType t = new ParameterType_c(xts, pos, Name.make("Z" + (i + 1)), Types.ref(cd)); - argTypes.add(Types.ref(t)); - cd.addTypeParameter(t, ParameterType.Variance.CONTRAVARIANT); - } - - Type rt = null; - - if (!isVoid) { - ParameterType returnType = new ParameterType_c(xts, pos, Name.make("U"), Types.ref(cd)); - cd.addTypeParameter(returnType, ParameterType.Variance.COVARIANT); - rt = returnType; - } - else { - rt = Void(); - } - - // NOTE: don't call cd.asType() until after the type parameters are - // added. - FunctionType ct = (FunctionType) cd.asType(); - xts.systemResolver().install(fullName, ct); - - String fullNameWithThis = fullName + "#this"; - //String fullNameWithThis = "this"; - XName thisName = new XNameWrapper<Object>(new Object(), fullNameWithThis); - XRoot thisVar = XTerms.makeLocal(thisName); - - if (formalNames == null) { - formalNames = dummyLocalDefs(argTypes); - } - X10MethodDef mi = methodDef(pos, Types.ref(ct), - Flags.PUBLIC.Abstract(), Types.ref(rt), - Name.make("apply"), - typeParams, - argTypes, - thisVar, - formalNames, - guard, - null, - Collections.EMPTY_LIST, - null); - cd.addMethod(mi); - - return cd; - } - - - - - - + + public List<LocalDef> dummyLocalDefs(List<Ref<? extends Type>> types) { List<LocalDef> list = new ArrayList<LocalDef>(); for (int i = 0; i < types.size(); i++) { @@ -723,6 +557,15 @@ return new X10MostSpecificComparator<S, T>(matcher, context); } + private boolean contains(Collection<X10Type> c, X10Type x) { + Context cxt = emptyContext(); + for (X10Type t : c) { + if (typeEquals(t, x, cxt)) { + return true; + } + } + return false; + } public MacroType findTypeDef(Type container, TypeDefMatcher matcher, Context context) throws SemanticException { List<MacroType> acceptable = findAcceptableTypeDefs(container, matcher, context); @@ -732,7 +575,22 @@ Collection<MacroType> maximal = findMostSpecificProcedures(acceptable, (Matcher) matcher, context); + if (maximal.size() > 1) { // remove references that resolve to the same type. + Collection<Type> reduced = Collections.EMPTY_LIST; + Collection<MacroType> max2 = Collections.EMPTY_LIST; + for (MacroType mt : maximal) { + Type expanded = X10TypeMixin.baseType(mt); + if (! reduced.contains(expanded)) { + reduced.add(expanded); + max2.add(mt); + } + } + maximal = max2; + } + if (maximal.size() > 1) { + + StringBuffer sb = new StringBuffer(); for (Iterator<MacroType> i = maximal.iterator(); i.hasNext();) { MacroType ma = (MacroType) i.next(); @@ -1027,7 +885,7 @@ // return isX10BaseSubtype(t, Ref()); } - + public boolean isStructType(Type t) { return kind(t, null) == Kind.STRUCT; } @@ -1076,7 +934,7 @@ public List<X10ClassType> allImplementedInterfaces(X10ClassType c) { return allImplementedInterfaces(c, true); } - + public List<X10ClassType> allImplementedInterfaces(X10ClassType c, boolean checkSuperClasses) { List<X10ClassType> ans = new ArrayList<X10ClassType>(); allImplementedInterfaces(c, checkSuperClasses, ans); @@ -1100,12 +958,12 @@ } if (checkSuperClasses && c.superClass() != null) { - allImplementedInterfaces((X10ClassType)X10TypeMixin.baseType(c.superClass()), + allImplementedInterfaces((X10ClassType)X10TypeMixin.baseType(c.superClass()), checkSuperClasses, l); } for (Type parent : c.interfaces()) { - allImplementedInterfaces((X10ClassType)X10TypeMixin.baseType(parent), + allImplementedInterfaces((X10ClassType)X10TypeMixin.baseType(parent), checkSuperClasses, l); } } @@ -1181,7 +1039,7 @@ protected final X10Flags X10_FIELD_VARIABLE_FLAGS = (X10Flags) legalFieldFlags(); @Override - public MethodDef methodDef(Position pos, Ref<? extends StructType> container, Flags flags, + public MethodDef methodDef(Position pos, Ref<? extends StructType> container, Flags flags, Ref<? extends Type> returnType, Name name, List<Ref<? extends Type>> argTypes, List<Ref<? extends Type>> excTypes) { @@ -1246,18 +1104,18 @@ Ref<? extends Type> returnType, List<Ref<? extends Type>> argTypes, XRoot thisVar, List<LocalDef> formalNames, Ref<XConstraint> guard, List<Ref<? extends Type>> throwTypes) { - return new ClosureDef_c(this, p, typeContainer, methodContainer, returnType, + return new ClosureDef_c(this, p, typeContainer, methodContainer, returnType, argTypes, thisVar, formalNames, guard, throwTypes); } - public FunctionType closureType(Position p, Ref<? extends Type> returnType, - // List<Ref<? extends Type>> typeParams, + public FunctionType closureType(Position p, Ref<? extends Type> returnType, + // List<Ref<? extends Type>> typeParams, List<Ref<? extends Type>> argTypes, - List<LocalDef> formalNames, Ref<XConstraint> guard, - // Ref<TypeConstraint> typeGuard, + List<LocalDef> formalNames, Ref<XConstraint> guard, + // Ref<TypeConstraint> typeGuard, List<Ref<? extends Type>> throwTypes) { Type rt = Types.get(returnType); - X10ClassDef def = closureBaseInterfaceDef(0 /*typeParams.size()*/, argTypes.size(), rt.isVoid(), formalNames, guard); + X10ClassDef def = ClosureSynthesizer.closureBaseInterfaceDef(this, 0 /*typeParams.size()*/, argTypes.size(), rt.isVoid(), formalNames, guard); FunctionType ct = (FunctionType) def.asType(); List<Type> typeArgs = new ArrayList<Type>(); for (Ref<? extends Type> ref : argTypes) { @@ -1438,7 +1296,7 @@ // return XOBJECT_; // } - + public Type Object() { if (OBJECT_ == null) OBJECT_ = load("x10.lang.Object"); @@ -1450,7 +1308,7 @@ return CLASS_; return CLASS_ = load("x10.lang.Class"); } - + Type ANY_ = null; public Type Any() { if (ANY_ != null) @@ -1469,7 +1327,7 @@ } Type STRUCT_ = null; public Type Struct() { - if (STRUCT_ != null) + if (STRUCT_ != null) return STRUCT_; return STRUCT_ = x10.util.Struct.makeDef(this).asType(); } @@ -1796,7 +1654,7 @@ public boolean isValRail(Type t) { return hasSameClassDef(t, ValRail()); } - + public boolean isValRailOf(Type t, Type p) { if (!isValRail(t)) return false; List<Type> ta = ((X10ClassType)X10TypeMixin.baseType(t)).typeArguments(); @@ -1842,11 +1700,11 @@ public boolean isAny(Type me) { return typeEquals(me, Any(), emptyContext()); } - + public boolean isStruct(Type me) { return typeEquals(me, Struct(), emptyContext()); } - + public boolean isClock(Type me) { return isSubtype(me, Clock(), emptyContext()); } @@ -1896,7 +1754,7 @@ return v; } - + protected XTypeTranslator xtt = new XTypeTranslator(this); public XTypeTranslator xtypeTranslator() { @@ -2221,7 +2079,7 @@ Ref<? extends ClassType> container) { assert_(container); - // access for the default constructor is determined by the + // access for the default constructor is determined by the // access of the containing class. See the JLS, 2nd Ed., 8.8.7. Flags access = Flags.NONE; Flags flags = container.get().flags(); @@ -2229,10 +2087,10 @@ access = access.Private(); } if (flags.isProtected()) { - access = access.Protected(); + access = access.Protected(); } if (flags.isPublic()) { - access = access.Public(); + access = access.Public(); } return constructorDef(pos, container, access, Collections.<Ref<? extends Type>>emptyList(), @@ -2249,7 +2107,7 @@ String fullNameWithThis = "this#this"; XName thisName = new XNameWrapper<Object>(new Object(), fullNameWithThis); XRoot thisVar = XTerms.makeLocal(thisName); - + return constructorDef(pos, container, flags, Types.ref(Types.get(container)), Collections.EMPTY_LIST, argTypes, thisVar, dummyLocalDefs(argTypes), null, null, throwTypes); } @@ -2259,7 +2117,7 @@ assert_(container); assert_(argTypes); assert_(excTypes); - + X10ClassType t = (X10ClassType) Types.get(returnType); assert t != null : "Cannot set return type of constructor to " + t; if (t==null) @@ -2288,8 +2146,8 @@ o.setDefAnnotations(newATs); } + - public boolean clausesConsistent(x10.constraint.XConstraint c1, x10.constraint.XConstraint c2, Context context) { X10TypeEnv env = env(context); return env.clausesConsistent(c1, c2); @@ -2346,7 +2204,7 @@ X10MethodMatcher m = (X10MethodMatcher) matcher; List<MethodInstance> candidates = new ArrayList<MethodInstance>(); - + List<Type> types = env(matcher.context()).upperBounds(container, true); for (Type t : types) { List<MethodInstance> ms = super.findAcceptableMethods(t, matcher); @@ -2398,24 +2256,24 @@ if (fi == null) return null; - Type c = container != null - ? container + Type c = container != null + ? container : fi.container(); XVar v = X10TypeMixin.selfVarBinding(c); // ensureBound should have been called on container. - + X10TypeSystem ts = (X10TypeSystem) fi.typeSystem(); XRoot oldThis = fi.x10Def().thisVar(); if (oldThis != null && v == null) assert false; - // TODO: vj: 08/11/09 + // TODO: vj: 08/11/09 // Shouldnt we be setting thisVar on the type? Type t = fi.type(); Type rt = fi.rightType(); if (v != null && oldThis != null) { - t = Subst.subst(t, (new XVar[] { v }), + t = Subst.subst(t, (new XVar[] { v }), (new XRoot[] { oldThis }), new Type[] {}, new ParameterType[] {}); - rt = Subst.subst(rt, (new XVar[] { v }), (new XRoot[] { oldThis }), + rt = Subst.subst(rt, (new XVar[] { v }), (new XRoot[] { oldThis }), new Type[] {}, new ParameterType[] {}); rt = X10TypeMixin.setThisVar(rt, v); } @@ -2493,7 +2351,7 @@ protected List<Type> typeArgs; protected List<Expr> args; - + protected X10ConstructorMatcher(Type container, List<Type> argTypes, Context context) { this(container, Collections.EMPTY_LIST, argTypes, context); } @@ -2501,15 +2359,15 @@ protected X10ConstructorMatcher(Type container, List<Type> typeArgs, List<Type> argTypes, Context context) { this(container, typeArgs, null, argTypes, context); } - - protected X10ConstructorMatcher(Type container, List<Type> typeArgs, List<Expr> args, + + protected X10ConstructorMatcher(Type container, List<Type> typeArgs, List<Expr> args, List<Type> argTypes, Context context) { super(container, argTypes, context); this.typeArgs = typeArgs; this.args = args; } + - public List<Type> arguments() { return argTypes; } @@ -2527,7 +2385,7 @@ X10ConstructorInstance xmi = (X10ConstructorInstance) ci; Type c = container != null ? container : xmi.container(); if (typeArgs.isEmpty() || typeArgs.size() == xmi.typeParameters().size()) - return X10MethodInstance_c.inferAndCheckAndInstantiate((X10Context) c.typeSystem().emptyContext(), + return X10MethodInstance_c.inferAndCheckAndInstantiate((X10Context) c.typeSystem().emptyContext(), xmi, c, typeArgs, argTypes); } return null; @@ -2634,7 +2492,7 @@ X10Context xc = (X10Context) context; return env(context).isSubtypeWithValueInterfaces(t1, t2); } - + // Returns the number of bytes required to represent the type, or null if unknown (e.g. involves an address somehow) // Note for rails and valrails this returns the size of 1 element, this will have to be scaled // by the number of elements to get the true figure. @@ -2653,32 +2511,32 @@ } return null; } - + public boolean isAtPlace(Receiver r, Expr place, X10Context xc) { XConstraint_c c = new XConstraint_c(); XTerm placeTerm = xtypeTranslator().trans(c, place, xc); - if (placeTerm == null) + if (placeTerm == null) return false; return isAtPlace(r, placeTerm, xc); } - + public boolean isAtPlace(Receiver r, XTerm placeTerm, X10Context xc) { // If the code is executing in a global context then // no receiver can be local. if (placeTerm.equals(globalPlace())) return false; - + try { XConstraint pc = xc.currentPlaceTerm().xconstraint(); Type rType = r.type(); - XTerm target = X10TypeMixin.selfVarBinding(rType); // + XTerm target = X10TypeMixin.selfVarBinding(rType); // if (target == null) { target = xtypeTranslator().trans(pc, r, xc); if (target == null) // The receiver is not named. So make up a new name. // The only thing we know about the name is that it is of rType, target = XConstraint_c.genEQV(); - } + } // rType = X10TypeMixin.setSelfVar(rType, (XVar) target); rType = Subst.subst(rType, target, (XRoot) X10TypeMixin.selfVar(rType)); assert xc.currentPlaceTerm() != null; @@ -2709,7 +2567,7 @@ return false; } - + public XConstraint isHereConstraint(Receiver r, X10Context xc) { XConstraint pc = new XConstraint_c(); @@ -2724,24 +2582,24 @@ } protected XConstraint isHereConstraint(XConstraint pc, XTerm target, X10Context xc) { try { - XTerm eloc = xtypeTranslator().trans(pc, target, + XTerm eloc = xtypeTranslator().trans(pc, target, ((StructType) Object()).fieldNamed(homeName())); pc.addBinding(eloc, xc.currentPlaceTerm()); } catch (XFailure z) { pc.setInconsistent(); - } + } return pc; } public XTerm homeVar(XTerm target, X10Context xc) { XConstraint pc = new XConstraint_c(); - return xtypeTranslator().trans(pc, target, + return xtypeTranslator().trans(pc, target, ((StructType) Object()).fieldNamed(homeName())); } public XTerm locVar(Receiver r, X10Context xc) { XConstraint pc = new XConstraint_c(); XTerm target = xtypeTranslator().trans(pc, r, xc); if (target == null) return null; - return xtypeTranslator().trans(pc, target, + return xtypeTranslator().trans(pc, target, ((StructType) Object()).fieldNamed(homeName())); } public XConstrainedTerm globalPlace() { @@ -2750,8 +2608,8 @@ public boolean isHere(Receiver r, X10Context xc) { return isAtPlace(r, xc.currentPlaceTerm().term(), xc); } - - + + public FieldInstance findField(Type container, TypeSystem_c.FieldMatcher matcher) throws SemanticException { container = X10TypeMixin.ensureSelfBound(container); @@ -2765,12 +2623,12 @@ // First, try to determine if there in fact a struct in scope with the given name. TypeNode otn = new X10ParsedName(nf, ts, Position.COMPILER_GENERATED, name).toType();// // nf.AmbDepTypeNode(position(), null, name(), typeArguments, Collections.EMPTY_LIST, null); - + TypeNode tn = (TypeNode) otn.visit(tb); - + // First ensure that there is a type associated with tn. tn = (TypeNode) tn.disambiguate(tc); - + // ok, if we made it this far, then there is a type. Check that it is a struct. Type t = tn.type(); t = ts.expandMacros(t); @@ -2785,13 +2643,13 @@ public List<Type> abstractSuperInterfaces(Type t) { List<Type> result = super.abstractSuperInterfaces(t); // A work-around for the current transient state of the system in which - // Object is an interface. + // Object is an interface. if (isStructType(t)) { result.remove(Object()); } return result; } - + Name homeName = Name.make("home"); public Name homeName() { return homeName;} } Added: trunk/x10.compiler/src/x10/util/ClosureSynthesizer.java =================================================================== --- trunk/x10.compiler/src/x10/util/ClosureSynthesizer.java (rev 0) +++ trunk/x10.compiler/src/x10/util/ClosureSynthesizer.java 2010-01-12 12:14:36 UTC (rev 12513) @@ -0,0 +1,271 @@ +package x10.util; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import polyglot.ast.Block; +import polyglot.ast.Formal; +import polyglot.types.ClassDef; +import polyglot.types.ClassType; +import polyglot.types.Flags; +import polyglot.types.LocalDef; +import polyglot.types.Name; +import polyglot.types.Named; +import polyglot.types.QName; +import polyglot.types.Ref; +import polyglot.types.SemanticException; +import polyglot.types.Type; +import polyglot.types.Types; +import polyglot.util.Position; +import x10.ast.Closure; +import x10.ast.X10NodeFactory; +import x10.constraint.XConstraint; +import x10.constraint.XName; +import x10.constraint.XNameWrapper; +import x10.constraint.XRoot; +import x10.constraint.XTerms; +import x10.types.ClosureDef; +import x10.types.ClosureInstance; +import x10.types.ClosureType_c; +import x10.types.FunctionType; +import x10.types.ParameterType; +import x10.types.ParameterType_c; +import x10.types.X10ClassDef; +import x10.types.X10ClassDef_c; +import x10.types.X10ClassType; +import x10.types.X10Context; +import x10.types.X10Flags; +import x10.types.X10MethodDef; +import x10.types.X10TypeSystem; +import x10.types.X10TypeSystem_c; + +public class ClosureSynthesizer { + + /** Return an instance of the AST node, Closure, representing a closure (parms):retType => body. + * This is treated as if it were defined by + * new Fun_n_m + * The type of this node is an anonymous class implementing the interface + * + * @param xts + * @param xnf + * @param pos + * @param retType + * @param parms + * @param body + * @param context + * @return + */ + public static Closure makeClosure(X10TypeSystem_c xts, X10NodeFactory xnf, Position pos, Type retType, + List<Formal> parms, Block body, + X10Context context) { + List<Ref<? extends Type>> fTypes = new ArrayList<Ref<? extends Type>>(); + List<LocalDef> fNames = new ArrayList<LocalDef>(); + for (Formal f : parms) { + fTypes.add(Types.ref(f.type().type())); + fNames.add(f.localDef()); + } + ClosureDef cDef = xts.closureDef(pos, Types.ref(context.currentClass()), + Types.ref(context.currentCode().asInstance()), + Types.ref(retType), + // Collections.EMPTY_LIST, + fTypes, + (XRoot) null, + fNames, + null, + // null, + Collections.EMPTY_LIST); + Closure closure = (Closure) xnf.Closure(pos, //Collections.EMPTY_LIST, + parms, + null, + xnf.CanonicalTypeNode(pos, retType), + Collections.EMPTY_LIST, body) + .closureDef(cDef) + .type(closureAnonymousClassDef((X10TypeSystem_c) xts, cDef).asType()); + return closure; + } + /** + * Return the type of an anonymous class implementing a given closure + * type, def. + * @param xts + * @param def + * @return + */ + public static X10ClassDef closureAnonymousClassDef(final X10TypeSystem_c xts, final ClosureDef def) { + + final Position pos = def.position(); + + X10ClassDef cd = new X10ClassDef_c(xts, null) { + @Override + public boolean isFunction() { + return true; + } + }; + + cd.position(pos); + cd.name(null); + cd.setPackage(null); + cd.kind(ClassDef.ANONYMOUS); + cd.flags(Flags.NONE); + + int numTypeParams = def.typeParameters().size(); + int numValueParams = def.formalTypes().size(); + + // Add type parameters. + List<Ref<? extends Type>> typeParams = new ArrayList<Ref<? extends Type>>(); + List<Type> typeArgs = new ArrayList<Type>(); + + ClosureInstance ci = (ClosureInstance) def.asInstance(); + typeArgs.addAll(ci.formalTypes()); + + if (!ci.returnType().isVoid()) { + typeArgs.add(ci.returnType()); + } + + // Instantiate the super type on the new parameters. + X10ClassType sup = (X10ClassType) closureBaseInterfaceDef(xts, numTypeParams, + numValueParams, + ci.returnType().isVoid(), + def.formalNames(), + def.guard()) + .asType(); + + assert sup.x10Def().typeParameters().size() == typeArgs.size() : def + ", " + sup + ", " + typeArgs; + sup = sup.typeArguments(typeArgs); + cd.addInterface(Types.ref(sup)); + + return cd; + } + public static X10ClassDef closureBaseInterfaceDef(final X10TypeSystem_c xts, final int numTypeParams, final int numValueParams, + final boolean isVoid) { + return ClosureSynthesizer.closureBaseInterfaceDef(xts, numTypeParams, numValueParams, isVoid, null, null); + } + + /** + * Synthetic generated interface for the function types. Mimics an X10 source level definition of + * the following interface, where numTypeParams=m, and numValueParams=n. + * + * + * package x10.lang; + * public interface Fun_m_n extends Any ( + * + * public abstract def apply[X1,..,Xm,-Z1,..,-Zn,+U](formalNames){guard}:U; + * or: + * public abstract def apply[X1,..,Xm,-Z1,..,-Zn](formalNames){guard}:Void; + * } + * + * + * @param numTypeParams + * @param numValueParams + * @param isVoid + * @param formalNames + * @param guard + * @return + */ + public static X10ClassDef closureBaseInterfaceDef(final X10TypeSystem_c xts, final int numTypeParams, + final int numValueParams, + final boolean isVoid, + List<LocalDef> formalNames, + final Ref<XConstraint> guard) { + final Position pos = Position.COMPILER_GENERATED; + + String name = "Fun_" + numTypeParams + "_" + numValueParams; + + if (isVoid) { + name = "Void" + name; + } + + // Check if the class has already been defined. + QName fullName = QName.make("x10.lang", name); + Named n = xts.systemResolver().check(fullName); + + if (n instanceof X10ClassType) { + X10ClassType ct = (X10ClassType) n; + return ct.x10Def(); + } + + X10ClassDef cd = (X10ClassDef) new X10ClassDef_c(xts, null) { + @Override + public boolean isFunction() { + return true; + } + @Override + public ClassType asType() { + if (asType == null) { + X10ClassDef cd = this; + asType = new ClosureType_c(xts, pos, this); + } + return asType; + } + }; + + cd.position(pos); + cd.name(Name.make(name)); + try { + cd.setPackage(Types.ref(xts.packageForName(fullName.qualifier()))); + } + catch (SemanticException e) { + assert false; + } + + cd.kind(ClassDef.TOP_LEVEL); + cd.superType(null); // interfaces have no superclass + // Functions implement the Any interface. + cd.setInterfaces(Collections.<Ref<? extends Type>> singletonList(Types.ref(xts.Any()))); + cd.flags(X10Flags.toX10Flags(Flags.PUBLIC.Abstract().Interface())); + + final List<Ref<? extends Type>> typeParams = new ArrayList<Ref<? extends Type>>(); + final List<Ref<? extends Type>> argTypes = new ArrayList<Ref<? extends Type>>(); + + for (int i = 0; i < numTypeParams; i++) { + Type t = new ParameterType_c(xts, pos, Name.make("X" + i), Types.ref(cd)); + typeParams.add(Types.ref(t)); + } + + for (int i = 0; i < numValueParams; i++) { + ParameterType t = new ParameterType_c(xts, pos, Name.make("Z" + (i + 1)), Types.ref(cd)); + argTypes.add(Types.ref(t)); + cd.addTypeParameter(t, ParameterType.Variance.CONTRAVARIANT); + } + + Type rt = null; + + if (!isVoid) { + ParameterType returnType = new ParameterType_c(xts, pos, Name.make("U"), Types.ref(cd)); + cd.addTypeParameter(returnType, ParameterType.Variance.COVARIANT); + rt = returnType; + } + else { + rt = xts.Void(); + } + + // NOTE: don't call cd.asType() until after the type parameters are + // added. + FunctionType ct = (FunctionType) cd.asType(); + xts.systemResolver().install(fullName, ct); + + String fullNameWithThis = fullName + "#this"; + //String fullNameWithThis = "this"; + XName thisName = new XNameWrapper<Object>(new Object(), fullNameWithThis); + XRoot thisVar = XTerms.makeLocal(thisName); + + if (formalNames == null) { + formalNames = xts.dummyLocalDefs(argTypes); + } + X10MethodDef mi = xts.methodDef(pos, Types.ref(ct), + Flags.PUBLIC.Abstract(), Types.ref(rt), + Name.make("apply"), + typeParams, + argTypes, + thisVar, + formalNames, + guard, + null, + Collections.EMPTY_LIST, + null); + cd.addMethod(mi); + + return cd; + } + +} Modified: trunk/x10.compiler/src/x10/util/Synthesizer.java =================================================================== --- trunk/x10.compiler/src/x10/util/Synthesizer.java 2010-01-12 05:46:20 UTC (rev 12512) +++ trunk/x10.compiler/src/x10/util/Synthesizer.java 2010-01-12 12:14:36 UTC (rev 12513) @@ -375,38 +375,57 @@ } - public Closure makeClosure(Position pos, Type retType, Block body, - X10Context context) { + public Call makeInstanceCall(Position pos, + Receiver receiver, + Name name, + List<TypeNode> typeArgsN, + List<Expr> args, + Type returnType, + List<Type> argTypes, + X10Context xc) throws SemanticException { + + List<Type> typeArgs = new ArrayList<Type>(); + for (TypeNode t : typeArgsN) typeArgs.add(t.type()); + MethodInstance mi = xts.findMethod(receiver.type(), + xts.MethodMatcher(receiver.type(), name, typeArgs, argTypes, xc)); + Call result= (Call) xnf.X10Call(pos, + receiver, + xnf.Id(pos, name), + typeArgsN, + args) + .methodInstance(mi) + .type(returnType); + return result; + + } + /** + * Return a synthesized AST node for (parms):retType => body, at the given position and context. + * @param pos + * @param retType + * @param parms + * @param body + * @param context + * @return + */ + public Closure makeClosure(Position pos, Type retType, List<Formal> parms, Block body, X10Context context) { + return ClosureSynthesizer.makeClosure((X10TypeSystem_c) xts, xnf, pos, retType, parms, body, context); + } + + /** + * Return a synthesized AST node for ():retType => body, at the given position and context. + * @param pos + * @param retType + * @param parms + * @param body + * @param context + * @return + */ + + public Closure makeClosure(Position pos, Type retType, Block body, X10Context context) { return makeClosure(pos, retType, Collections.EMPTY_LIST, body, context); } - public Closure makeClosure(Position pos, Type retType, List<Formal> parms, Block body, - X10Context context) { - List<Ref<? extends Type>> fTypes = new ArrayList<Ref<? extends Type>>(); - List<LocalDef> fNames = new ArrayList<LocalDef>(); - for (Formal f : parms) { - fTypes.add(Types.ref(f.type().type())); - fNames.add(f.localDef()); - } - ClosureDef cDef = xts.closureDef(pos, Types.ref(context.currentClass()), - Types.ref(context.currentCode().asInstance()), - Types.ref(retType), - // Collections.EMPTY_LIST, - fTypes, - (XRoot) null, - fNames, - null, - // null, - Collections.EMPTY_LIST); - Closure closure = (Closure) xnf.Closure(pos, //Collections.EMPTY_LIST, - parms, - null, - xnf.CanonicalTypeNode(pos, retType), - Collections.EMPTY_LIST, body) - .closureDef(cDef) - .type(xts.closureAnonymousClassDef(cDef).asType()); - return closure; - } + public Block toBlock(Stmt body) { return body instanceof Block ? (Block) body : xnf.Block(body.position(), body); } Modified: trunk/x10.compiler/src/x10/visit/Desugarer.java =================================================================== --- trunk/x10.compiler/src/x10/visit/Desugarer.java 2010-01-12 05:46:20 UTC (rev 12512) +++ trunk/x10.compiler/src/x10/visit/Desugarer.java 2010-01-12 12:14:36 UTC (rev 12513) @@ -94,6 +94,7 @@ import x10.types.X10TypeMixin; import x10.types.X10TypeSystem; import x10.types.X10TypeSystem_c; +import x10.util.ClosureSynthesizer; import x10.util.Synthesizer; /** @@ -200,19 +201,26 @@ return visitRemoteClosure(e, EVAL_AT, e.place()); } - + Expr getPlace(Position pos, Expr place) throws SemanticException{ + if (! xts.isImplicitCastValid(place.type(), xts.Place(), context)) { + place = synth.makeInstanceCall(pos, place, xts.homeName(), + Collections.EMPTY_LIST, + Collections.EMPTY_LIST, + xts.Place(), + Collections.EMPTY_LIST, + xContext()); + } + return place; + } private Expr visitRemoteClosure(Closure c, Name implName, Expr place) throws SemanticException { Position pos = c.position(); - if (xts.isImplicitCastValid(place.type(), xts.Object(), context)) { - place = synth.makeFieldAccess(pos,place, xts.homeName(), xContext()); - } - + place = getPlace(pos, place); List<TypeNode> typeArgs = Arrays.asList(new TypeNode[] { c.returnType() }); Position bPos = c.body().position(); ClosureDef cDef = c.closureDef().position(bPos); Expr closure = xnf.Closure(c, bPos) .closureDef(cDef) - .type(xts.closureAnonymousClassDef(cDef).asType()); + .type(ClosureSynthesizer.closureAnonymousClassDef((X10TypeSystem_c) xts, cDef).asType()); List<Expr> args = new ArrayList<Expr>(Arrays.asList(new Expr[] { place, closure })); List<Type> mArgs = new ArrayList<Type>(Arrays.asList(new Type[] { xts.Place(), cDef.asType() @@ -225,14 +233,13 @@ } private Stmt atStmt(Position pos, Stmt body, Expr place) throws SemanticException { - if (xts.isImplicitCastValid(place.type(), xts.Object(), context)) { - place = synth.makeFieldAccess(pos,place, xts.homeName(), xContext()); - } + place = getPlace(pos, place); + Expr placeId = synth.makeFieldAccess(pos, place, Name.make("id"), xContext()); Closure closure = synth.makeClosure(body.position(), xts.Void(), synth.toBlock(body), xContext()); Stmt result = xnf.Eval(pos, synth.makeStaticCall(pos, xts.Runtime(), RUN_AT, - Arrays.asList(new Expr[] { place, closure }), xts.Void(), + Arrays.asList(new Expr[] { placeId, closure }), xts.Void(), xContext())); return result; } Modified: trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java =================================================================== --- trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java 2010-01-12 05:46:20 UTC (rev 12512) +++ trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java 2010-01-12 12:14:36 UTC (rev 12513) @@ -215,6 +215,7 @@ import x10.visit.Stati... [truncated message content] |
From: <dgr...@us...> - 2010-01-22 04:23:44
|
Revision: 12676 http://x10.svn.sourceforge.net/x10/?rev=12676&view=rev Author: dgrove-oss Date: 2010-01-22 04:23:36 +0000 (Fri, 22 Jan 2010) Log Message: ----------- Vijay's patch for XTENLANG-902 with some minor additions to files in x10.runtime/src-cpp from me to fix handwritten code in C++ runtime system to (a) enable Rail/ValRail<Any> to be created (missing serialization code in Any) (b) change String.format to take Rail/ValRail<Any> instead of Rail/ValRail<Object> Much of the String format implementations are stubbed out. I will fix tomorrow as part of the work for XTENLANG-818. Modified Paths: -------------- trunk/x10.compiler/src/x10/ExtensionInfo.java trunk/x10.compiler/src/x10/ast/X10Boxed_c.java trunk/x10.compiler/src/x10/ast/X10Cast_c.java trunk/x10.compiler/src/x10/types/X10TypeSystem.java trunk/x10.compiler/src/x10/types/X10TypeSystem_c.java trunk/x10.compiler/src/x10/visit/X10PrettyPrinterVisitor.java trunk/x10.runtime/src-cpp/x10/lang/Any.h trunk/x10.runtime/src-cpp/x10/lang/String.cc trunk/x10.runtime/src-cpp/x10/lang/String.h trunk/x10.runtime/src-java/x10/core/GrowableRail.java trunk/x10.runtime/src-java/x10/core/Rail.java trunk/x10.runtime/src-java/x10/core/ValRail.java trunk/x10.runtime/src-java/x10/rtt/Equality.java trunk/x10.runtime/src-java/x10/rtt/RuntimeType.java trunk/x10.runtime/src-x10/x10/array/PolyMat.x10 trunk/x10.runtime/src-x10/x10/io/Printer.x10 trunk/x10.runtime/src-x10/x10/io/ReaderIterator.x10 trunk/x10.runtime/src-x10/x10/lang/Boolean.x10 trunk/x10.runtime/src-x10/x10/lang/Clock.x10 trunk/x10.runtime/src-x10/x10/lang/Runtime.x10 trunk/x10.runtime/src-x10/x10/lang/String.x10 trunk/x10.runtime/src-x10/x10/lang/_.x10 trunk/x10.tests/examples/Constructs/Cast/InlineConstraint.x10 trunk/x10.tests/examples/Constructs/Cast/PrimitiveDependentTypeCast/AssignmentIntLitteralToConstrainedInt.x10 trunk/x10.tests/examples/Constructs/Cast/PrimitiveDependentTypeCast/AssignmentIntLitteralToConstrainedInt_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Cast/PrimitiveDependentTypeCast/AssignmentPrimitiveConstrainedIdentity.x10 trunk/x10.tests/examples/Constructs/Cast/PrimitiveDependentTypeCast/CastNullToNullablePrimitive.x10 trunk/x10.tests/examples/Constructs/Cast/PrimitiveDependentTypeCast/CastNullToNullablePrimitiveConstrained.x10 trunk/x10.tests/examples/Constructs/Cast/PrimitiveDependentTypeCast/CastNullToNullableReference.x10 trunk/x10.tests/examples/Constructs/Cast/PrimitiveDependentTypeCast/CastNullablePrimitiveToPrimitive.x10 trunk/x10.tests/examples/Constructs/Cast/PrimitiveDependentTypeCast/UnboxNullablePrimitive.x10 trunk/x10.tests/examples/Constructs/Cast/PrimitiveDependentTypeCast/UnboxNullablePrimitiveConstrained.x10 trunk/x10.tests/examples/Constructs/Cast/PrimitiveDependentTypeCast/UnboxNullablePrimitiveConstrained2_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Cast/PrimitiveDependentTypeCast/UnboxPrimitive.x10 trunk/x10.tests/examples/Constructs/Cast/PrimitiveDependentTypeCast/UnboxPrimitiveConstrained.x10 trunk/x10.tests/examples/Constructs/Cast/PrimitiveDependentTypeCast/UnboxPrimitiveConstrained1_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Cast/PrimitiveDependentTypeCast/UnboxPrimitiveConstrained2_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Cast/ReferenceDependentTypeCast/DynamicCast4_MethodReturn.x10.new trunk/x10.tests/examples/Constructs/Cast/ReferenceDependentTypeCast/X10DepTypeClassOne.x10.new Added Paths: ----------- trunk/x10.runtime/src-x10/x10/util/Box.x10 trunk/x10.tests/examples/Constructs/Cast/PrimitiveDependentTypeCast/CastIn3ToAny3AndBack.x10 trunk/x10.tests/examples/Constructs/Cast/PrimitiveDependentTypeCast/CastInt3ToAnyAndBack.x10 trunk/x10.tests/examples/Constructs/Cast/PrimitiveDependentTypeCast/CastInt5ToAnyAndInt3.x10 trunk/x10.tests/examples/Constructs/Cast/PrimitiveDependentTypeCast/CastIntToAnyAndBack.x10 trunk/x10.tests/examples/Constructs/Cast/ReferenceDependentTypeCast/DynamicCast4_MethodReturn.x10 trunk/x10.tests/examples/Constructs/Cast/ReferenceDependentTypeCast/X10DepTypeClassOne.x10 Removed Paths: ------------- trunk/x10.runtime/src-java/x10/core/Box.java trunk/x10.runtime/src-java/x10/core/BoxInt.java trunk/x10.runtime/src-java/x10/core/BoxedBoolean.java trunk/x10.runtime/src-java/x10/core/BoxedByte.java trunk/x10.runtime/src-java/x10/core/BoxedChar.java trunk/x10.runtime/src-java/x10/core/BoxedDouble.java trunk/x10.runtime/src-java/x10/core/BoxedFloat.java trunk/x10.runtime/src-java/x10/core/BoxedInt.java trunk/x10.runtime/src-java/x10/core/BoxedLong.java trunk/x10.runtime/src-java/x10/core/BoxedShort.java trunk/x10.runtime/src-java/x10/core/BoxedString.java trunk/x10.runtime/src-java/x10/core/Value.java trunk/x10.runtime/src-x10/x10/lang/Box.x10 trunk/x10.tests/examples/Constructs/Cast/PrimitiveDependentTypeCast/CastBoxedToNullablePrimitive.x10 trunk/x10.tests/examples/Constructs/Cast/PrimitiveDependentTypeCast/CastBoxedToNullablePrimitiveConstrained.x10 trunk/x10.tests/examples/Constructs/Cast/PrimitiveDependentTypeCast/CastBoxedToNullablePrimitiveConstrained2.x10 trunk/x10.tests/examples/Constructs/Cast/PrimitiveDependentTypeCast/CastBoxedToPrimitive.x10 trunk/x10.tests/examples/Constructs/Cast/PrimitiveDependentTypeCast/CastBoxedToPrimitive2.x10 trunk/x10.tests/examples/Constructs/Cast/PrimitiveDependentTypeCast/CastBoxedToPrimitiveConstrained1.x10 trunk/x10.tests/examples/Constructs/Cast/PrimitiveDependentTypeCast/CastBoxedToPrimitiveConstrained2.x10 trunk/x10.tests/examples/Constructs/Cast/ReferenceDependentTypeCast/X10DepTypeSubClassOne.x10.new trunk/x10.tests/examples/Constructs/Cast/ReferenceDependentTypeCast/X10InterfaceOne.x10.new Modified: trunk/x10.compiler/src/x10/ExtensionInfo.java =================================================================== --- trunk/x10.compiler/src/x10/ExtensionInfo.java 2010-01-22 03:44:31 UTC (rev 12675) +++ trunk/x10.compiler/src/x10/ExtensionInfo.java 2010-01-22 04:23:36 UTC (rev 12676) @@ -261,7 +261,7 @@ goals.add(TypeChecked(job)); goals.add(ReassembleAST(job)); - goals.add(X10Boxed(job)); + // goals.add(X10Boxed(job)); goals.add(X10Casted(job)); goals.add(MoveFieldInitializers(job)); goals.add(ConformanceChecked(job)); Modified: trunk/x10.compiler/src/x10/ast/X10Boxed_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10Boxed_c.java 2010-01-22 03:44:31 UTC (rev 12675) +++ trunk/x10.compiler/src/x10/ast/X10Boxed_c.java 2010-01-22 04:23:36 UTC (rev 12676) @@ -79,12 +79,12 @@ assert ts.isInterfaceType(toType); - if (ts.typeEquals(toType, ts.Object(), context)) { + /* if (ts.typeEquals(toType, ts.Object(), context)) { Position pos = this.position(); Type t = ts.boxOf(Types.ref(expr.type())); return X10Cast_c.check(nf.New(pos, nf.CanonicalTypeNode(pos, Types.ref(t)), Collections.singletonList(expr)), tc); } - +*/ boolean local = false; Type fromType = e.type(); Type fromBase = X10TypeMixin.baseType(fromType); @@ -116,7 +116,7 @@ Name className = Name.makeFresh("Boxed$"); Name xname = Name.make("v"); - Type superType = ts.boxOf(Types.ref(fromType)); + Type superType = fromType; // ts.boxOf(Types.ref(fromType)); List<ClassMember> members = new ArrayList<ClassMember>(); Modified: trunk/x10.compiler/src/x10/ast/X10Cast_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10Cast_c.java 2010-01-22 03:44:31 UTC (rev 12675) +++ trunk/x10.compiler/src/x10/ast/X10Cast_c.java 2010-01-22 04:23:36 UTC (rev 12676) @@ -312,29 +312,29 @@ // } // } - Type boxOfTo = ts.boxOf(Types.ref(toType)); - Type boxOfFrom = ts.boxOf(Types.ref(fromType)); + // Type boxOfTo = ts.boxOf(Types.ref(toType)); + // Type boxOfFrom = ts.boxOf(Types.ref(fromType)); // v: Ref // v as Value // -> // (v as Box[Ref]).value as Value - if (ts.isReferenceOrInterfaceType(fromType, context) && (ts.isParameterType(toType))) { + /* if (ts.isReferenceOrInterfaceType(fromType, context) && (ts.isParameterType(toType))) { Expr boxed = expr; if (! ts.typeEquals(baseFrom, boxOfTo, context)) { boxed = check(nf.X10Cast(position(), nf.CanonicalTypeNode(position(), boxOfTo), expr, convert), tc); return check(nf.X10Cast(position(), nf.CanonicalTypeNode(position(), toType), boxed, convert), tc); } - } + }*/ - if (convert != ConversionType.UNKNOWN_IMPLICIT_CONVERSION && ts.typeEquals(baseFrom, boxOfTo, context)) { + /* if (convert != ConversionType.UNKNOWN_IMPLICIT_CONVERSION && ts.typeEquals(baseFrom, boxOfTo, context)) { // System.out.println("UNBOXING " + expr + " from " + fromType + " to " + toType); Expr unboxed = check(nf.Field(position(), expr, nf.Id(position(), Name.make("value"))), tc); return check(nf.X10Cast(position(), nf.CanonicalTypeNode(position(), toType), unboxed, convert), tc); - } + }*/ // v to I, where I is not a value interface (i.e., a function type) - if (ts.isParameterType(fromType) && ts.typeBaseEquals(toType, ts.Object(), context)) { + /* if (ts.isParameterType(fromType) && ts.typeBaseEquals(toType, ts.Object(), context)) { if (ts.isSubtypeWithValueInterfaces(fromType, toType, context)) { // TypeBuilder tb = new TypeBuilder(tc.job(), ts, nf); // tb = tb.pushPackage(tc.context().package_()); @@ -352,7 +352,7 @@ return check(boxed, tc); } } - +*/ // v to I, where I is not a value interface (i.e., a function type) if (( ts.isParameterType(fromType)) && ts.isInterfaceType(toType)) { if (ts.isSubtypeWithValueInterfaces(fromType, toType, context)) { Modified: trunk/x10.compiler/src/x10/types/X10TypeSystem.java =================================================================== --- trunk/x10.compiler/src/x10/types/X10TypeSystem.java 2010-01-22 03:44:31 UTC (rev 12675) +++ trunk/x10.compiler/src/x10/types/X10TypeSystem.java 2010-01-22 04:23:36 UTC (rev 12676) @@ -323,13 +323,13 @@ Type ULong(); - /** x10.lang.Box */ + /** x10.lang.Box * Type Box(); Type boxOf(Ref<? extends Type> base); boolean isBox(Type type); - +*/ boolean isFunctionType(Type type); Modified: trunk/x10.compiler/src/x10/types/X10TypeSystem_c.java =================================================================== --- trunk/x10.compiler/src/x10/types/X10TypeSystem_c.java 2010-01-22 03:44:31 UTC (rev 12675) +++ trunk/x10.compiler/src/x10/types/X10TypeSystem_c.java 2010-01-22 04:23:36 UTC (rev 12676) @@ -709,6 +709,8 @@ @Override protected ClassType load(String name) { + if (name.equals("x10.lang.Box") || name.equals("Box")) + new Error("Loading Box??").printStackTrace(); QName qualName = QName.make(name); try { return (ClassType) typeForName(qualName); @@ -762,7 +764,7 @@ } */ - private X10ParsedClassType boxType_; + /* private X10ParsedClassType boxType_; public Type Box() { if (boxType_ == null) @@ -773,7 +775,7 @@ public Type boxOf(Ref<? extends Type> base) { return boxOf(Position.COMPILER_GENERATED, base); } - +*/ public List<Type> superTypes(ObjectType t) { Type sup = t.superClass(); if (sup == null) @@ -830,9 +832,9 @@ return (xt instanceof FunctionType) || ((X10ClassDef) xt.def()).isFunction(); } - public boolean isBox(Type t) { + /* public boolean isBox(Type t) { return hasSameClassDef(t, this.Box()); - } + }*/ public boolean isInterfaceType(Type t) { t = X10TypeMixin.baseType(t); @@ -1067,8 +1069,9 @@ * nullableType() -- the name is misleading. */ public Type boxOf(Position pos, Ref<? extends Type> type) { - X10ParsedClassType box = (X10ParsedClassType) Box(); - return X10TypeMixin.instantiate(box, type); + return type.get(); + // X10ParsedClassType box = (X10ParsedClassType) Box(); + // return X10TypeMixin.instantiate(box, type); } X10ParsedClassType futureType_; Modified: trunk/x10.compiler/src/x10/visit/X10PrettyPrinterVisitor.java =================================================================== --- trunk/x10.compiler/src/x10/visit/X10PrettyPrinterVisitor.java 2010-01-22 03:44:31 UTC (rev 12675) +++ trunk/x10.compiler/src/x10/visit/X10PrettyPrinterVisitor.java 2010-01-22 04:23:36 UTC (rev 12676) @@ -691,7 +691,8 @@ xct.restoreAnonObjectScope(inAnonObjectScope); } else - if (((X10TypeSystem) type.typeSystem()).isAny(type) && (t.isBoolean() || t.isNumeric())) { + if (((X10TypeSystem) type.typeSystem()).isAny(X10TypeMixin.baseType(type)) + && (t.isBoolean() || t.isNumeric())) { if (t.isBoolean()) { er.dumpCodeString("((Boolean) #0).booleanValue()", expr); } else if (t.isInt()) { Modified: trunk/x10.runtime/src-cpp/x10/lang/Any.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Any.h 2010-01-22 03:44:31 UTC (rev 12675) +++ trunk/x10.runtime/src-cpp/x10/lang/Any.h 2010-01-22 04:23:36 UTC (rev 12676) @@ -37,6 +37,15 @@ x10aux::ref<x10::lang::String> (I::*toString)(); x10aux::ref<x10::lang::String> (I::*typeName)(); }; + + static void _serialize(x10aux::ref<Any> this_, + x10aux::serialization_buffer &buf) { + x10::lang::Reference::_serialize(this_, buf); + } + + template<class T> static x10aux::ref<T> _deserialize(x10aux::deserialization_buffer &buf) { + return x10::lang::Reference::_deserialize<T>(buf); + } }; } } Modified: trunk/x10.runtime/src-cpp/x10/lang/String.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/String.cc 2010-01-22 03:44:31 UTC (rev 12675) +++ trunk/x10.runtime/src-cpp/x10/lang/String.cc 2010-01-22 04:23:36 UTC (rev 12676) @@ -9,7 +9,6 @@ #include <x10/lang/String.h> #include <x10/lang/Rail.h> -#include <x10/lang/Box.h> #include <cstdarg> #include <sstream> @@ -166,7 +165,7 @@ } // TODO: DG: itables: refactor to share the code. -ref<String> String::format(ref<String> format, ref<ValRail<ref<Object> > > parms) { +ref<String> String::format(ref<String> format, ref<ValRail<ref<Any> > > parms) { std::ostringstream ss; nullCheck(format); char* fmt = const_cast<char*>(format->c_str()); @@ -189,6 +188,7 @@ ss << (buf = x10aux::alloc_printf(fmt, "null")); // FIXME: Ignore nulls for now } else if (x10aux::instanceof<ref<String> >(p)) { ss << (buf = x10aux::alloc_printf(fmt, class_cast<ref<String> >(p)->c_str())); + /* FIXME: XTENLANG-818: } else if (x10aux::instanceof<ref<Box<x10_boolean> > >(p)) { ref<Box<x10_boolean> > tmp = class_cast<ref<Box<x10_boolean> > >(p); ss << (buf = x10aux::alloc_printf(fmt, tmp->FMGL(value))); @@ -213,6 +213,7 @@ } else if (x10aux::instanceof<ref<Box<x10_double> > >(p)) { ref<Box<x10_double> > tmp = class_cast<ref<Box<x10_double> > >(p); ss << (buf = x10aux::alloc_printf(fmt, tmp->FMGL(value))); + */ } else { ss << (buf = x10aux::alloc_printf(fmt, p->toString()->c_str())); } @@ -224,7 +225,7 @@ return String::Lit(ss.str().c_str()); } -ref<String> String::format(ref<String> format, ref<Rail<ref<Object> > > parms) { +ref<String> String::format(ref<String> format, ref<Rail<ref<Any> > > parms) { std::ostringstream ss; nullCheck(format); char* fmt = const_cast<char*>(format->c_str()); @@ -247,6 +248,7 @@ ss << (buf = x10aux::alloc_printf(fmt, "null")); // FIXME: Ignore nulls for now } else if (x10aux::instanceof<ref<String> >(p)) { ss << (buf = x10aux::alloc_printf(fmt, class_cast<ref<String> >(p)->c_str())); + /* FIXME: XTENLANG-818: } else if (x10aux::instanceof<ref<Box<x10_boolean> > >(p)) { ref<Box<x10_boolean> > tmp = class_cast<ref<Box<x10_boolean> > >(p); ss << (buf = x10aux::alloc_printf(fmt, tmp->FMGL(value))); @@ -271,6 +273,7 @@ } else if (x10aux::instanceof<ref<Box<x10_double> > >(p)) { ref<Box<x10_double> > tmp = class_cast<ref<Box<x10_double> > >(p); ss << (buf = x10aux::alloc_printf(fmt, tmp->FMGL(value))); + */ } if (buf != NULL) dealloc(buf); Modified: trunk/x10.runtime/src-cpp/x10/lang/String.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/String.h 2010-01-22 03:44:31 UTC (rev 12675) +++ trunk/x10.runtime/src-cpp/x10/lang/String.h 2010-01-22 04:23:36 UTC (rev 12676) @@ -121,10 +121,10 @@ virtual void _destructor(); static x10aux::ref<String> format(x10aux::ref<String> format, - x10aux::ref<ValRail<x10aux::ref<Object> > > parms); + x10aux::ref<ValRail<x10aux::ref<Any> > > parms); static x10aux::ref<String> format(x10aux::ref<String> format, - x10aux::ref<Rail<x10aux::ref<Object> > > parms); + x10aux::ref<Rail<x10aux::ref<Any> > > parms); virtual x10_boolean equals(x10aux::ref<x10::lang::Any> p0); Deleted: trunk/x10.runtime/src-java/x10/core/Box.java =================================================================== --- trunk/x10.runtime/src-java/x10/core/Box.java 2010-01-22 03:44:31 UTC (rev 12675) +++ trunk/x10.runtime/src-java/x10/core/Box.java 2010-01-22 04:23:36 UTC (rev 12676) @@ -1,128 +0,0 @@ -/* - * - * (C) Copyright IBM Corporation 2006-2008. - * - * This file is part of X10 Language. - * - */ - -package x10.core; - -import x10.rtt.Equality; -import x10.rtt.RuntimeType; -import x10.rtt.Type; - -public class Box<T> extends Ref { - protected final Type<T> type; - protected final T value; - - public static class RTT<T> extends RuntimeType<Box<T>> { - Type<T> type; - - public RTT(Type<?> type) { - super(Box.class); - this.type = (Type<T>) type; - } - - @Override - public boolean instanceof$(Object o) { - return o instanceof Box && ((Box) o).type.isSubtype(type); - } - - @Override - public boolean isSubtype(Type<?> o) { - if (o instanceof Box.RTT) { - Box.RTT other = (Box.RTT) o; - return type.isSubtype(other.type); - } - return super.isSubtype(o); - } - } - - protected Box(Type<?> type, T v) { - assert v != null; - this.value = v; - this.type = (Type<T>) type; - } -// protected Box(Type<T> type, T v) { -// assert v != null; -// this.value = v; -// this.type = type; -// } - - public static Box<Boolean> make(Type<Boolean> type, boolean v) { return new BoxedBoolean(v); } - public static Box<Byte> make(Type<Byte> type, byte v) { return new BoxedByte(v); } - public static Box<Short> make(Type<Short> type, short v) { return new BoxedShort(v); } - public static Box<Character> make(Type<Character> type, char v) { return new BoxedChar(v); } - public static Box<Integer> make(Type<Integer> type, int v) { return new BoxedInt(v); } - public static Box<Long> make(Type<Long> type, long v) { return new BoxedLong(v); } - public static Box<Float> make(Type<Float> type, float v) { return new BoxedFloat(v); } - public static Box<Double> make(Type<Double> type, double v) { return new BoxedDouble(v); } - - public static <S> Ref make(Type<S> type, S v) { - if (v == null) - return null; - if (v instanceof Box) { - Box<?> box = (Box<?>) v; - if (type.instanceof$(box.value())) { - return make(type, (S) box.value()); - } - else { - throw new ClassCastException(); - } - } - if (v instanceof Ref) - return (Ref) v; - if (v instanceof Value) - return ((Value) v).box$(); - if (v instanceof String) - return new BoxedString((String) v); - if (v instanceof Boolean) - return new BoxedBoolean((Boolean) v); - if (v instanceof Byte) - return new BoxedByte((Byte) v); - if (v instanceof Character) - return new BoxedChar((Character) v); - if (v instanceof Short) - return new BoxedShort((Short) v); - if (v instanceof Integer) - return new BoxedInt((Integer) v); - if (v instanceof Long) - return new BoxedLong((Long) v); - if (v instanceof Float) - return new BoxedFloat((Float) v); - if (v instanceof Double) - return new BoxedDouble((Double) v); - - // TOOD: Throwable - - return new Box<S>(type, v); - } - - public T value() { return value; } - - public static <T> T unbox(Box<T> box) { - if (box != null) { - return box.value(); - } - throw new ClassCastException(); - } - - public boolean equals(Object o) { - if (o == null) - return false; - if (o instanceof Box) - return Equality.equalsequals(value, ((Box<?>) o).value); - if (Equality.equalsequals(value, o)) - return true; - return false; - } - - public int hashCode() { - return value.hashCode(); - } - - public String toString() { - return value.toString(); - } -} Deleted: trunk/x10.runtime/src-java/x10/core/BoxInt.java =================================================================== --- trunk/x10.runtime/src-java/x10/core/BoxInt.java 2010-01-22 03:44:31 UTC (rev 12675) +++ trunk/x10.runtime/src-java/x10/core/BoxInt.java 2010-01-22 04:23:36 UTC (rev 12676) @@ -1,28 +0,0 @@ -/* - * - * (C) Copyright IBM Corporation 2006-2008. - * - * This file is part of X10 Language. - * - */ - -package x10.core; - -import x10.rtt.Equality; -import x10.rtt.RuntimeType; -import x10.rtt.Type; -import x10.rtt.Types; - -public class BoxInt extends Box<Integer> { - public BoxInt(int v) { - super(Types.INT, v); - } - - public int hashCode() { - return value.hashCode(); - } - - public String toString() { - return value.toString(); - } -} Deleted: trunk/x10.runtime/src-java/x10/core/BoxedBoolean.java =================================================================== --- trunk/x10.runtime/src-java/x10/core/BoxedBoolean.java 2010-01-22 03:44:31 UTC (rev 12675) +++ trunk/x10.runtime/src-java/x10/core/BoxedBoolean.java 2010-01-22 04:23:36 UTC (rev 12676) @@ -1,12 +0,0 @@ -/** - * - */ -package x10.core; - -import x10.rtt.Types; - -public class BoxedBoolean<T> extends Box<Boolean> { - public BoxedBoolean(boolean v) { - super(Types.BOOLEAN, v); - } -} \ No newline at end of file Deleted: trunk/x10.runtime/src-java/x10/core/BoxedByte.java =================================================================== --- trunk/x10.runtime/src-java/x10/core/BoxedByte.java 2010-01-22 03:44:31 UTC (rev 12675) +++ trunk/x10.runtime/src-java/x10/core/BoxedByte.java 2010-01-22 04:23:36 UTC (rev 12676) @@ -1,32 +0,0 @@ -/** - * - */ -package x10.core; - -import x10.rtt.Types; - -public class BoxedByte<T> extends Box<Byte> { - public BoxedByte(byte v) { - super(Types.BYTE, v); - } - - public String toString(Integer radix) { - return java.lang.Integer.toString(this.value, radix); - } - - public String toHexString() { - return java.lang.Integer.toHexString(this.value); - } - - public String toOctalString() { - return java.lang.Integer.toOctalString(this.value); - } - - public String toBinaryString() { - return java.lang.Integer.toBinaryString(this.value); - } - - public String toString() { - return java.lang.Byte.toString(this.value); - } -} \ No newline at end of file Deleted: trunk/x10.runtime/src-java/x10/core/BoxedChar.java =================================================================== --- trunk/x10.runtime/src-java/x10/core/BoxedChar.java 2010-01-22 03:44:31 UTC (rev 12675) +++ trunk/x10.runtime/src-java/x10/core/BoxedChar.java 2010-01-22 04:23:36 UTC (rev 12676) @@ -1,67 +0,0 @@ -/** - * - */ -package x10.core; - -import x10.rtt.Types; - -public class BoxedChar<T> extends Box<Character> { - public BoxedChar(char v) { - super(Types.CHAR, v); - } - - public Boolean isLowerCase() { - return java.lang.Character.isLowerCase(this.value); - } - public Boolean isUpperCase() { - return java.lang.Character.isUpperCase(this.value); - } - public Boolean isTitleCase() { - return java.lang.Character.isTitleCase(this.value); - } - public Boolean isDigit() { - return java.lang.Character.isDigit(this.value); - } - public Boolean isLetter() { - return java.lang.Character.isLetter(this.value); - } - public Boolean isLetterOrDigit() { - return java.lang.Character.isLetterOrDigit(this.value); - } - public Boolean isUnicodeIdentifierStart() { - return java.lang.Character.isUnicodeIdentifierStart(this.value); - } - public Boolean isUnicodeIdentifierPart() { - return java.lang.Character.isUnicodeIdentifierPart(this.value); - } - public Boolean isIdentifierIgnorable() { - return java.lang.Character.isIdentifierIgnorable(this.value); - } - public Boolean isSpace() { - return java.lang.Character.isSpace(this.value); - } - public Boolean isSpaceChar() { - return java.lang.Character.isSpaceChar(this.value); - } - public Boolean isWhitespace() { - return java.lang.Character.isWhitespace(this.value); - } - public Boolean isISOControl() { - return java.lang.Character.isISOControl(this.value); - } - public Character toLowerCase() { - return java.lang.Character.toLowerCase(this.value); - } - public Character toUpperCase() { - return java.lang.Character.toUpperCase(this.value); - } - public Character toTitleCase() { - return java.lang.Character.toTitleCase(this.value); - } - public Integer ord() { - return (Integer) ((int) this.value); - } - public Character reverseBytes() { - return java.lang.Character.reverseBytes(this.value); - } -} \ No newline at end of file Deleted: trunk/x10.runtime/src-java/x10/core/BoxedDouble.java =================================================================== --- trunk/x10.runtime/src-java/x10/core/BoxedDouble.java 2010-01-22 03:44:31 UTC (rev 12675) +++ trunk/x10.runtime/src-java/x10/core/BoxedDouble.java 2010-01-22 04:23:36 UTC (rev 12676) @@ -1,33 +0,0 @@ -/** - * - */ -package x10.core; - -import x10.rtt.Types; - -public class BoxedDouble<T> extends Box<Double> { - public BoxedDouble(double v) { - super(Types.DOUBLE, v); - } - - public String toHexString() { - return java.lang.Double.toHexString(this.value); - } - public String toString() { - return java.lang.Double.toString(this.value); - } - public Boolean isNaN() { - return java.lang.Double.isNaN(this.value); - } - public Boolean isInfinite() { - return java.lang.Double.isInfinite(this.value); - } - - public Long toIntBits() { - return java.lang.Double.doubleToLongBits(this.value); - } - public Long toRawIntBits() { - return java.lang.Double.doubleToRawLongBits(this.value); - } - -} \ No newline at end of file Deleted: trunk/x10.runtime/src-java/x10/core/BoxedFloat.java =================================================================== --- trunk/x10.runtime/src-java/x10/core/BoxedFloat.java 2010-01-22 03:44:31 UTC (rev 12675) +++ trunk/x10.runtime/src-java/x10/core/BoxedFloat.java 2010-01-22 04:23:36 UTC (rev 12676) @@ -1,32 +0,0 @@ -/** - * - */ -package x10.core; - -import x10.rtt.Types; - -public class BoxedFloat<T> extends Box<Float> { - public BoxedFloat(float v) { - super(Types.FLOAT, v); - } - - public String toHexString() { - return java.lang.Float.toHexString(this.value); - } - public String toString() { - return java.lang.Float.toString(this.value); - } - public Boolean isNaN() { - return java.lang.Float.isNaN(this.value); - } - public Boolean isInfinite() { - return java.lang.Float.isInfinite(this.value); - } - - public Integer toIntBits() { - return java.lang.Float.floatToIntBits(this.value); - } - public Integer toRawIntBits() { - return java.lang.Float.floatToRawIntBits(this.value); - } -} \ No newline at end of file Deleted: trunk/x10.runtime/src-java/x10/core/BoxedInt.java =================================================================== --- trunk/x10.runtime/src-java/x10/core/BoxedInt.java 2010-01-22 03:44:31 UTC (rev 12675) +++ trunk/x10.runtime/src-java/x10/core/BoxedInt.java 2010-01-22 04:23:36 UTC (rev 12676) @@ -1,72 +0,0 @@ -/** - * - */ -package x10.core; - -import x10.rtt.Types; - -public class BoxedInt<T> extends Box<Integer> { - public BoxedInt(int v) { - super(Types.INT, v); - } - - public String toString(Integer radix) { - return Integer.toString(this.value, radix); - } - - public String toHexString() { - return Integer.toHexString(this.value); - } - - public String toOctalString() { - return Integer.toOctalString(this.value); - } - - public String toBinaryString() { - return Integer.toBinaryString(this.value); - } - - public String toString() { - return Integer.toString(this.value); - } - - public Integer highestOneBit() { - return Integer.highestOneBit(this.value); - } - - public Integer lowestOneBit() { - return Integer.lowestOneBit(this.value); - } - - public Integer numberOfLeadingZeros() { - return Integer.numberOfLeadingZeros(this.value); - } - - public Integer numberOfTrailingZeros() { - return Integer.numberOfTrailingZeros(this.value); - } - - public Integer bitCount() { - return Integer.bitCount(this.value); - } - - public Integer rotateLeft(Integer bits) { - return Integer.rotateLeft(this.value, bits); - } - - public Integer rotateRight(Integer bits) { - return Integer.rotateRight(this.value, bits); - } - - public Integer reverse() { - return Integer.reverse(this.value); - } - - public Integer signum() { - return Integer.signum(this.value); - } - - public Integer reverseBytes() { - return Integer.reverseBytes(this.value); - } -} \ No newline at end of file Deleted: trunk/x10.runtime/src-java/x10/core/BoxedLong.java =================================================================== --- trunk/x10.runtime/src-java/x10/core/BoxedLong.java 2010-01-22 03:44:31 UTC (rev 12675) +++ trunk/x10.runtime/src-java/x10/core/BoxedLong.java 2010-01-22 04:23:36 UTC (rev 12676) @@ -1,73 +0,0 @@ -/** - * - */ -package x10.core; - -import x10.rtt.Types; - -public class BoxedLong<T> extends Box<Long> { - public BoxedLong(long v) { - super(Types.LONG, v); - } - - public String toString(Integer radix) { - return Long.toString(this.value, radix); - } - - public String toHexString() { - return Long.toHexString(this.value); - } - - public String toOctalString() { - return Long.toOctalString(this.value); - } - - public String toBinaryString() { - return Long.toBinaryString(this.value); - } - - public String toString() { - return Long.toString(this.value); - } - - public Long highestOneBit() { - return Long.highestOneBit(this.value); - } - - public Long lowestOneBit() { - return Long.lowestOneBit(this.value); - } - - public Integer numberOfLeadingZeros() { - return Long.numberOfLeadingZeros(this.value); - } - - public Integer numberOfTrailingZeros() { - return Long.numberOfTrailingZeros(this.value); - } - - public Integer bitCount() { - return Long.bitCount(this.value); - } - - public Long rotateLeft(Integer bits) { - return Long.rotateLeft(this.value, bits); - } - - public Long rotateRight(Integer bits) { - return Long.rotateRight(this.value, bits); - } - - public Long reverse() { - return Long.reverse(this.value); - } - - public Integer signum() { - return Long.signum(this.value); - } - - public Long reverseBytes() { - return Long.reverseBytes(this.value); - } - -} \ No newline at end of file Deleted: trunk/x10.runtime/src-java/x10/core/BoxedShort.java =================================================================== --- trunk/x10.runtime/src-java/x10/core/BoxedShort.java 2010-01-22 03:44:31 UTC (rev 12675) +++ trunk/x10.runtime/src-java/x10/core/BoxedShort.java 2010-01-22 04:23:36 UTC (rev 12676) @@ -1,36 +0,0 @@ -/** - * - */ -package x10.core; - -import x10.rtt.Types; - -public class BoxedShort<T> extends Box<Short> { - public BoxedShort(short v) { - super(Types.SHORT, v); - } - - public String toString(Integer radix) { - return java.lang.Integer.toString(this.value, radix); - } - - public String toHexString() { - return java.lang.Integer.toHexString(this.value); - } - - public String toOctalString() { - return java.lang.Integer.toOctalString(this.value); - } - - public String toBinaryString() { - return java.lang.Integer.toBinaryString(this.value); - } - - public String toString() { - return java.lang.Short.toString(this.value); - } - - public Short reverseBytes() { - return java.lang.Short.reverseBytes(this.value); - } -} \ No newline at end of file Deleted: trunk/x10.runtime/src-java/x10/core/BoxedString.java =================================================================== --- trunk/x10.runtime/src-java/x10/core/BoxedString.java 2010-01-22 03:44:31 UTC (rev 12675) +++ trunk/x10.runtime/src-java/x10/core/BoxedString.java 2010-01-22 04:23:36 UTC (rev 12676) @@ -1,28 +0,0 @@ -/** - * - */ -package x10.core; - -import x10.rtt.RuntimeType; - -public class BoxedString<T> extends Box<String> { - public BoxedString(String v) { - super(new RuntimeType<String>(String.class), v); - } - - public Integer length() { - return this.value.length(); - } - - public Character apply(Integer i) { - return this.value.charAt(i); - } - - public Character charAt(Integer i) { - return this.value.charAt(i); - } - - public String substring(Integer fromIndex, Integer toIndex) { - return this.value.substring(fromIndex, toIndex); - } -} \ No newline at end of file Modified: trunk/x10.runtime/src-java/x10/core/GrowableRail.java =================================================================== --- trunk/x10.runtime/src-java/x10/core/GrowableRail.java 2010-01-22 03:44:31 UTC (rev 12675) +++ trunk/x10.runtime/src-java/x10/core/GrowableRail.java 2010-01-22 04:23:36 UTC (rev 12676) @@ -127,49 +127,9 @@ return elementType; } - @Override - public Ref box$() { - return new BoxedGrowableRail(elementType, this); - } - public static class BoxedGrowableRail<T> extends Box<GrowableRail<T>> implements Indexable<Integer,T>, Fun_0_1<Integer,T>, Iterable<T>, Settable<Integer,T> { - public BoxedGrowableRail(Type<T> T, GrowableRail<T> v) { - super(new GrowableRail.RTT(T), v); - } + - public T apply(Integer o) { - return this.value.apply(o); - } - - public Type<?> rtt_x10$lang$Fun_0_1_U() { - throw new RuntimeException(); - } - - public Type<?> rtt_x10$lang$Fun_0_1_Z1() { - throw new RuntimeException(); - } - - public Iterator<T> iterator() { - return this.value.iterator(); - } - - public T set(T v, Integer i) { - return this.value.set(v, i); - } - - public Integer length() { - return this.value.length(); - } - - public void add(T v) { - this.value.add(v); - } - - public void removeLast() { - this.value.removeLast(); - } - } - // // Runtime type information Modified: trunk/x10.runtime/src-java/x10/core/Rail.java =================================================================== --- trunk/x10.runtime/src-java/x10/core/Rail.java 2010-01-22 03:44:31 UTC (rev 12675) +++ trunk/x10.runtime/src-java/x10/core/Rail.java 2010-01-22 04:23:36 UTC (rev 12676) @@ -144,33 +144,8 @@ // boxed rail // - @Override - public Ref box$() { - return new BoxedRail(type, this); - } - - public static class BoxedRail<T> extends Box<Rail<T>> implements Indexable<Integer,T>, Fun_0_1<Integer,T>, Settable<Integer,T> { - public BoxedRail(Type<T> T, Rail<T> v) { - super(new Rail.RTT(T), v); - } + - public T apply(Integer o) { - return this.value.apply(o); - } - - public Type<?> rtt_x10$lang$Fun_0_1_U() { - throw new RuntimeException(); - } - - public Type<?> rtt_x10$lang$Fun_0_1_Z1() { - throw new RuntimeException(); - } - - public T set(T v, Integer i) { - return this.value.set(v, i); - } - } - // // Runtime type information // Modified: trunk/x10.runtime/src-java/x10/core/ValRail.java =================================================================== --- trunk/x10.runtime/src-java/x10/core/ValRail.java 2010-01-22 03:44:31 UTC (rev 12675) +++ trunk/x10.runtime/src-java/x10/core/ValRail.java 2010-01-22 04:23:36 UTC (rev 12676) @@ -149,36 +149,9 @@ return value.toString(); } + // - // boxed rail - // - - // @Override - public Ref box$() { - return new BoxedValRail(type, this); - } - - public static class BoxedValRail<T> extends Box<ValRail<T>> implements Indexable<Integer,T>, Fun_0_1<Integer,T> { - public BoxedValRail(Type<T> T, ValRail<T> v) { - super(new ValRail.RTT(T), v); - } - - public T apply(Integer o) { - return this.value.apply(o); - } - - public Type<?> rtt_x10$lang$Fun_0_1_U() { - throw new RuntimeException(); - } - - public Type<?> rtt_x10$lang$Fun_0_1_Z1() { - throw new RuntimeException(); - } - } - - - // // Runtime type information // Deleted: trunk/x10.runtime/src-java/x10/core/Value.java =================================================================== --- trunk/x10.runtime/src-java/x10/core/Value.java 2010-01-22 03:44:31 UTC (rev 12675) +++ trunk/x10.runtime/src-java/x10/core/Value.java 2010-01-22 04:23:36 UTC (rev 12676) @@ -1,153 +0,0 @@ -/* - * - * (C) Copyright IBM Corporation 2006-2008. - * - * This file is part of X10 Language. - * - */ - -package x10.core; - -import java.lang.reflect.Array; -import java.lang.reflect.Field; -import java.lang.reflect.Modifier; - -import x10.rtt.Equality; -import x10.rtt.RuntimeType; -import x10.rtt.Type; - -// Base class of all X10 value objects -- should be generated, but we need this class to get Box to compile. -public class Value { - - public static class RTT extends RuntimeType<Value> { - public static final RTT it = new RTT(); - - public RTT() { - super(Value.class); - } - - @Override - public boolean instanceof$(Object o) { - return o instanceof Value; - } - } - - public static class BoxedValue extends Box<Value> { - BoxedValue(Value v) { - super(Value.RTT.it, v); - } - } - - public Ref box$() { - return new BoxedValue(this); - } - - public boolean equals(Object o) { - if (o instanceof Value) - return this.equals((Value) o); - return false; - } - - public boolean equals(Ref o) { - return false; - } - - public boolean equals(Value o) { - return structEquals(o); - } - - public int hashCode() { - return structHash(); - } - - public final int structHash() { - Class<?> c = this.getClass(); - Object o = this; - int hash = 17; - try { - while (c != null) { - Field[] fs = c.getDeclaredFields(); - for (int i = fs.length - 1; i >= 0; i--) { - Field f = fs[i]; - if (Modifier.isStatic(f.getModifiers())) - continue; - if (Type.class.isAssignableFrom(f.getType())) - continue; - f.setAccessible(true); - if (f.getType().isPrimitive()) { - hash = hash * 37 + f.get(o).hashCode(); - } - else if (f.getType().isArray()) { - java.lang.Object a = f.get(o); - int len = Array.getLength(a); - for (int j = 0; j < len; j++) { - hash = hash * 37 + Array.get(a, j).hashCode(); - } - } - else { - // I assume here that value types are immutable - // and can thus not contain mutually recursive - // structures. If that is wrong, we would have to do - // more work here to avoid dying with a StackOverflow. - hash = hash * 37 + f.get(o).hashCode(); - } - } - c = c.getSuperclass(); - } - } - catch (IllegalAccessException iae) { - throw new Error(iae); // fatal, should never happen - } - return hash; - } - - public final boolean structEquals(Object o) { - if (o == null) - return false; - if (o == this) - return true; - Class<?> c = this.getClass(); - Object o1 = this; - Object o2 = o; - if (c != o2.getClass()) - return false; - try { - while (c != null) { - Field[] fs = c.getDeclaredFields(); - for (int i = fs.length - 1; i >= 0; i--) { - Field f = fs[i]; - if (Modifier.isStatic(f.getModifiers())) - continue; - f.setAccessible(true); - Object a1 = f.get(o1); - Object a2 = f.get(o2); - if (f.getType().isPrimitive()) { - if (!Equality.equalsequals(a1, a2)) - return false; - } - else if (f.getType().isArray()) { - int len = Array.getLength(a1); - if (len != Array.getLength(a2)) - return false; - for (int j = 0; j < len; j++) - if (!Equality.equalsequals(Array.get(a1, j), Array.get(a2, j))) - return false; - } - else { - // I assume here that value types are immutable - // and can thus not contain mutually recursive - // structures. If that is wrong, we would have to do - // more work here to avoid dying with a StackOverflow. - if (!Equality.equalsequals(a1, a2)) - return false; - } - } - c = c.getSuperclass(); - } - } - catch (IllegalAccessException iae) { - throw new Error(iae); // fatal, should never happen - } - return true; - } -} Modified: trunk/x10.runtime/src-java/x10/rtt/Equality.java =================================================================== --- trunk/x10.runtime/src-java/x10/rtt/Equality.java 2010-01-22 03:44:31 UTC (rev 12675) +++ trunk/x10.runtime/src-java/x10/rtt/Equality.java 2010-01-22 04:23:36 UTC (rev 12676) @@ -8,9 +8,9 @@ package x10.rtt; -import x10.core.Box; + import x10.core.Ref; -import x10.core.Value; + import x10.core.Struct; public class Equality { @@ -82,7 +82,7 @@ } } public static boolean equalsequals(Struct a, Struct b) { return a.structEquals(b); } - public static boolean equalsequals(Value a, Value b) { return a.structEquals(b); } + // public static boolean equalsequals(Value a, Value b) { return a.structEquals(b); } public static boolean equalsequals(Ref a, Ref b) { return a == b; } public static boolean equalsequals(Object a, boolean b) { return equalsequals(a, (Object) b); } @@ -107,7 +107,7 @@ if (a instanceof Number && b instanceof Number) return equalsNumbers(a, b); if (a instanceof Comparable) return ((Comparable) a).compareTo(b) == 0; - if (a instanceof Value) return ((Value) a).structEquals(b); + // if (a instanceof Value) return ((Value) a).structEquals(b); if (a instanceof Struct) return ((Struct) a).structEquals(b); return false; Modified: trunk/x10.runtime/src-java/x10/rtt/RuntimeType.java =================================================================== --- trunk/x10.runtime/src-java/x10/rtt/RuntimeType.java 2010-01-22 03:44:31 UTC (rev 12675) +++ trunk/x10.runtime/src-java/x10/rtt/RuntimeType.java 2010-01-22 04:23:36 UTC (rev 12676) @@ -14,7 +14,6 @@ import java.util.List; import x10.core.Ref; -import x10.core.Value; import x10.core.fun.Fun_0_1; import x10.core.fun.Fun_0_2; import x10.constraint.XConstraint; @@ -78,9 +77,10 @@ public T zeroValue() { // null for ref types, otherwise complain - if (!x10.runtime.impl.java.Configuration.NULL_DEFAULT_VALUE && Value.class.isAssignableFrom(c)) { + /* if (!x10.runtime.impl.java.Configuration.NULL_DEFAULT_VALUE + && Value.class.isAssignableFrom(c)) { throw new UnsupportedOperationException(); - } + }*/ return null; } Modified: trunk/x10.runtime/src-x10/x10/array/PolyMat.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/array/PolyMat.x10 2010-01-22 03:44:31 UTC (rev 12675) +++ trunk/x10.runtime/src-x10/x10/array/PolyMat.x10 2010-01-22 04:23:36 UTC (rev 12676) @@ -55,13 +55,13 @@ return this; val pmb = new PolyMatBuilder(rank); - var last: Box[PolyRow] = null; + var last: PolyRow = null; for (next:PolyRow in this) { if (last!=null && !next.isParallel(last as PolyRow)) pmb.add(last as PolyRow); - last = new Box[PolyRow](next); + last = next; } - pmb.add(last.value); + pmb.add(last); return pmb.toSortedPolyMat(false); } Modified: trunk/x10.runtime/src-x10/x10/io/Printer.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/io/Printer.x10 2010-01-22 03:44:31 UTC (rev 12675) +++ trunk/x10.runtime/src-x10/x10/io/Printer.x10 2010-01-22 04:23:36 UTC (rev 12676) @@ -51,16 +51,21 @@ public global def printf(fmt: String): Void { printf(fmt, []); } - public global def printf(fmt: String, o1: Object): Void { printf(fmt, [o1]); } - public global def printf(fmt: String, o1: Object, o2: Object): Void { printf(fmt, [o1,o2]); } - public global def printf(fmt: String, o1: Object, o2: Object, o3: Object): Void { printf(fmt, [o1,o2,o3]); } - public global def printf(fmt: String, o1: Object, o2: Object, o3: Object, o4: Object): Void { printf(fmt, [o1,o2,o3,o4]); } - public global def printf(fmt: String, o1: Object, o2: Object, o3: Object, o4: Object, o5: Object): Void { printf(fmt, [o1,o2,o3,o4,o5]); } - public global def printf(fmt: String, o1: Object, o2: Object, o3: Object, o4: Object, o5: Object, o6: Object): Void { printf(fmt, [o1,o2,o3,o4,o5,o6]); } + public global def printf(fmt: String, o1: Any): Void { printf(fmt, [o1]); } + public global def printf(fmt: String, o1: Any, o2: Any): Void { printf(fmt, [o1,o2]); } + public global def printf(fmt: String, o1: Any, o2: Any, o3: Any): Void { printf(fmt, [o1,o2,o3]); } + public global def printf(fmt: String, o1: Any, o2: Any, o3: Any, o4: Any): Void { + printf(fmt, [o1,o2,o3,o4]); + } + public global def printf(fmt: String, o1: Any, o2: Any, o3: Any, o4: Any, o5: Any): Void { + printf(fmt, [o1,o2,o3,o4,o5]); + } + public global def printf(fmt: String, o1: Any, o2: Any, o3: Any, o4: Any, o5: Any, o6: Any): Void { + printf(fmt, [o1,o2,o3,o4,o5,o6]); + } + public global def printf(fmt: String, args: Rail[Any]): Void { print(String.format(fmt, args)); } + public global def printf(fmt: String, args: ValRail[Any]): Void { print(String.format(fmt, args)); } - public global def printf(fmt: String, args: Rail[Object]): Void { print(String.format(fmt, args)); } - public global def printf(fmt: String, args: ValRail[Object]): Void { print(String.format(fmt, args)); } - public global def flush(): Void { try { Modified: trunk/x10.runtime/src-x10/x10/io/ReaderIterator.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/io/ReaderIterator.x10 2010-01-22 03:44:31 UTC (rev 12675) +++ trunk/x10.runtime/src-x10/x10/io/ReaderIterator.x10 2010-01-22 04:23:36 UTC (rev 12676) @@ -9,7 +9,7 @@ package x10.io; import x10.util.NoSuchElementException; - +import x10.util.Box; /** * Usage: * @@ -32,7 +32,7 @@ public def this(m: Marshal[T], r: Reader) { this.m = m; this.r = r; - this.next = null; + // this.next = null; } /** Allow the iterator to be used in a for loop. */ @@ -41,7 +41,7 @@ public def next(): T = { if (! hasNext()) throw new NoSuchElementException(); - val x: T = next as T; + val x: T = next.value; next = null; return x; } @@ -50,7 +50,7 @@ if (next == null) { try { val x: T = r.read[T](m); - next = x as Box[T]; + next = new Box[T](x); } catch (IOException) { return false; Modified: trunk/x10.runtime/src-x10/x10/lang/Boolean.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Boolean.x10 2010-01-22 03:44:31 UTC (rev 12675) +++ trunk/x10.runtime/src-x10/x10/lang/Boolean.x10 2010-01-22 04:23:36 UTC (rev 12676) @@ -48,7 +48,7 @@ @Native("c++", "x10aux::boolean_utils::parseBoolean(#1)") public native static def parseBoolean(String): Boolean; - @Native("java", "((((#2) instanceof boolean) && #1 == ((boolean)#2)) || (((#2) instanceof x10.core.BoxedBoolean) && #1 == ((x10.core.BoxedBoolean) #2).value.value))") + @Native("java", "((((#2) instanceof boolean) && #1 == ((boolean)#2)) || (((#2) instanceof Boolean) && #1 == ((Boolean) #2).booleanValue()))") @Native("c++", "x10aux::equals(#0,#1)") public global safe native def equals(x:Any):Boolean; Deleted: trunk/x10.runtime/src-x10/x10/lang/Box.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Box.x10 2010-01-22 03:44:31 UTC (rev 12675) +++ trunk/x10.runtime/src-x10/x10/lang/Box.x10 2010-01-22 04:23:36 UTC (rev 12676) @@ -1,29 +0,0 @@ -package x10.lang; - -import x10.compiler.Native; -import x10.compiler.NativeRep; - -public final class Box[+T](value: T) { - public def this(x: T) { property(x); } - - public global safe def hashCode(): int = value.hashCode(); - - public global safe def toString(): String = value.toString(); - - public global safe def equals(x:Any): Boolean { - if (x == null) { - return false; - } - if (x instanceof T) { - val y = x as T; - return value.equals(y); - } - if (x instanceof Box[T]) { - val y = (x as Box[T]).value; - return value.equals(y); - } - return false; - } - - public static operator[T](x:T):Box[T] = new Box[T](x); -} Modified: trunk/x10.runtime/src-x10/x10/lang/Clock.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Clock.x10 2010-01-22 03:44:31 UTC (rev 12675) +++ trunk/x10.runtime/src-x10/x10/lang/Clock.x10 2010-01-22 04:23:36 UTC (rev 12676) @@ -30,11 +30,11 @@ property(name); } - private global def get() = Runtime.clockPhases().get(this) as Int; + private global def get() = Runtime.clockPhases().get(this).value; private global def put(ph:Int) = Runtime.clockPhases().put(this, ph); - private global def remove() = Runtime.clockPhases().remove(this) as Int; + private global def remove() = Runtime.clockPhases().remove(this).value; private atomic def resumeLocal() { if (--alive == 0) { Modified: trunk/x10.runtime/src-x10/x10/lang/Runtime.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Runtime.x10 2010-01-22 03:44:31 UTC (rev 12675) +++ trunk/x10.runtime/src-x10/x10/lang/Runtime.x10 2010-01-22 04:23:36 UTC (rev 12676) @@ -16,7 +16,7 @@ import x10.util.Random; import x10.util.Stack; import x10.util.concurrent.atomic.AtomicInteger; - +import x10.util.Box; /** * @author tardieu */ @@ -941,7 +941,7 @@ async (box) box.latch.release(); } catch (e:Throwable) { async (box) { - box.e = e; + box.e = new Box[Throwable](e); box.latch.release(); } } @@ -949,7 +949,7 @@ if (!NO_STEALS && safe()) worker().join(box.latch); box.latch.await(); if (null != box.e) { - val x = box.e as Throwable; + val x = box.e.value; if (x instanceof Error) throw x as Error; if (x instanceof RuntimeException) @@ -985,7 +985,7 @@ if (!NO_STEALS && safe()) worker().join(box.latch); box.latch.await(); if (null != box.e) { - val x = box.e as Throwable; + val x = box.e.value; if (x instanceof Error) throw x as Error; if (x instanceof RuntimeException) Modified: trunk/x10.runtime/src-x10/x10/lang/String.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/String.x10 2010-01-22 03:44:31 UTC (rev 12675) +++ trunk/x10.runtime/src-x10/x10/lang/String.x10 2010-01-22 04:23:36 UTC (rev 12676) @@ -78,11 +78,11 @@ @Native("c++", "x10aux::safe_to_string(#4)") public native static def valueOf[T](T):String; - @Native("java", "java.lang.String.format(#1, new Object() { final Object[] unbox(Object[] a) { Object[] b = new Object[a.length]; for (int i = 0; i < a.length; i++) { if (a[i] instanceof x10.lang.Box) b[i] = ((x10.lang.Box) a[i]).value(); else b[i] = a[i]; } return b; } }.unbox(#2.getBoxedArray()))") + @Native("java", "java.lang.String.format(#1, #2.getBoxedArray())") @Native("c++", "x10::lang::String::format(#1,#2)") - public native static def format(fmt: String, Rail[Object]): String; + public native static def format(fmt: String, Rail[Any]): String; - @Native("java", "java.lang.String.format(#1, new Object() { final Object[] unbox(Object[] a) { Object[] b = new Object[a.length]; for (int i = 0; i < a.length; i++) { if (a[i] instanceof x10.lang.Box) b[i] = ((x10.lang.Box) a[i]).value(); else b[i] = a[i]; } return b; } }.unbox(#2.getBoxedArray()))") + @Native("java", "java.lang.String.format(#1, #2.getBoxedArray())") @Native("c++", "x10::lang::String::format(#1,#2)") - public native static def format(fmt: String, ValRail[Object]): String; + public native static def format(fmt: String, ValRail[Any]): String; } Modified: trunk/x10.runtime/src-x10/x10/lang/_.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/_.x10 2010-01-22 03:44:31 UTC (rev 12675) +++ trunk/x10.runtime/src-x10/x10/lang/_.x10 2010-01-22 04:23:36 UTC (rev 12676) @@ -31,6 +31,7 @@ public static type Float(b:Float) = Float{self==b}; public static type Double(b:Double) = Double{self==b}; public static type String(s:String) = String{self==s}; + public static type Any(x:Any) = Any{self==x}; public static type signed = Int; Added: trunk/x10.runtime/src-x10/x10/util/Box.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/util/Box.x10 (rev 0) +++ trunk/x10.runtime/src-x10/x10/util/Box.x10 2010-01-22 04:23:36 UTC (rev 12676) @@ -0,0 +1,27 @@ +package x10.util; + +public final class Box[+T](value: T) implements ()=> T { + public def this(x: T) { property(x); } + + public def apply()=value; + public global safe def hashCode(): int = value.hashCode(); + + public global safe def toString(): String = value.toString(); + + public global safe def equals(x:Any): Boolean { + if (x == null) { + return false; + } + if (x instanceof T) { + val y = x as T; + return value.equals(y); + } + if (x instanceof Box[T]) { + val y = (x as Box[T]).value; + return value.equals(y); + } + return false; + } + + public static operator[T](x:T):Box[T] = new Box[T](x); +} Property changes on: trunk/x10.runtime/src-x10/x10/util/Box.x10 ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Modified: trunk/x10.tests/examples/Constructs/Cast/InlineConstraint.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Cast/InlineConstraint.x10 2010-01-22 03:44:31 UTC (rev 12675) +++ trunk/x10.tests/examples/Constructs/Cast/InlineConstraint.x10 2010-01-22 04:23:36 UTC (rev 12676) @@ -13,24 +13,24 @@ public def run() { val v:Object = 0..5; var result:boolean=true; - val c = v instanceof Region{self.rank==1}; + val c = v instanceof Region(1); if (!c) { Console.OUT.println("v instanceof Region{self.rank==1} failed."); result=false; } - val d = v instanceof Region{self.rank==2}; + val d = v instanceof Region(2); if (d) { Console.OUT.println("WTF, it's a two-dimensional region?!"); result=false; } try { - val e = v as Region{self.rank==1}; + val e = v as Region(1); } catch (ClassCastException) { Console.OUT.println("WTF, cast to a single-dimensional region failed?!"); result=false; } try { - val f = v as Region{self.rank==2}; + val f = v as Region(2); Console.OUT.println("WTF, cast to a two-dimensional region succeeded?!"); result = false; } catch (ClassCastException) { Modified: trunk/x10.tests/examples/Constructs/Cast/PrimitiveDependentTypeCast/AssignmentIntLitteralToConstrainedInt.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Cast/PrimitiveDependentTypeCast/AssignmentIntLitteralToConstrainedInt.x10 2010-01-22 03:44:31 UTC (rev 12675) +++ trunk/x10.tests/examples/Constructs/Cast/PrimitiveDependentTypeCast/AssignmentIntLitteralToConstrainedInt.x10 2010-01-22 04:23:36 UTC (rev 12676) @@ -16,8 +16,8 @@ public def run(): boolean = { try { - var i: int{self == 0} = 0; - i = 0; + val j = 1 as Int(0); + }catch (e: Throwable) { return false; } @@ -25,7 +25,7 @@ return true; } - public static def main(var args: Rail[String]): void = { + public static def main(Rail[String]){ new AssignmentIntLitteralToConstrainedInt().execute(); } Modified: trunk/x10.tests/examples/Constructs/Cast/PrimitiveDependentTypeCast/AssignmentIntLitteralToConstrainedInt_MustFailCompile.x10 ===============================================================... [truncated message content] |
From: <spa...@us...> - 2010-01-22 05:48:46
|
Revision: 12677 http://x10.svn.sourceforge.net/x10/?rev=12677&view=rev Author: sparksparkspark Date: 2010-01-22 05:48:40 +0000 (Fri, 22 Jan 2010) Log Message: ----------- First hack at getting CUDA working again Modified Paths: -------------- trunk/x10.compiler/src/x10cuda/visit/CUDACodeGenerator.java trunk/x10.runtime/src-cpp/x10aux/network.cc Modified: trunk/x10.compiler/src/x10cuda/visit/CUDACodeGenerator.java =================================================================== --- trunk/x10.compiler/src/x10cuda/visit/CUDACodeGenerator.java 2010-01-22 04:23:36 UTC (rev 12676) +++ trunk/x10.compiler/src/x10cuda/visit/CUDACodeGenerator.java 2010-01-22 05:48:40 UTC (rev 12677) @@ -506,7 +506,7 @@ assert async_target_type_node.nameString().equals("Runtime"); // FIXME: // proper // error - assert async_call.arguments().size() == 2 : async_call.arguments(); // FIXME: + assert async_call.arguments().size() == 1 : async_call.arguments(); // FIXME: // proper // error Expr async_arg = async_call.arguments().get(0); Modified: trunk/x10.runtime/src-cpp/x10aux/network.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/network.cc 2010-01-22 04:23:36 UTC (rev 12676) +++ trunk/x10.runtime/src-cpp/x10aux/network.cc 2010-01-22 05:48:40 UTC (rev 12677) @@ -148,8 +148,7 @@ }; */ -struct x10_runtime_Runtime__closure__6__hack : x10::lang::Closure { - static const x10aux::serialization_id_t _serialization_id; +struct nightmarish_hack : x10::lang::Closure { x10aux::ref<x10::lang::VoidFun_0_0> body; x10aux::ref<x10::lang::Reference> fs; }; @@ -191,12 +190,15 @@ sid == x10_runtime_Runtime__closure__5::_serialization_id); */ - x10aux::ref<x10_runtime_Runtime__closure__6__hack> body_ = body; + x10aux::ref<nightmarish_hack> body_ = body; - x10aux::ref<x10::lang::Reference> real_body = body_->body; - x10aux::ref<x10::lang::Reference> fs = body_->fs; + x10aux::ref<nightmarish_hack> almost_there = body_->body; + + x10aux::ref<x10::lang::Reference> real_body = almost_there->body; + x10aux::ref<x10::lang::Reference> fs = almost_there->fs; + serialization_id_t real_sid = real_body->_get_serialization_id(); msg_type real_id = DeserializationDispatcher::getMsgType(real_sid); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <vj...@us...> - 2010-01-25 09:28:42
|
Revision: 12699 http://x10.svn.sourceforge.net/x10/?rev=12699&view=rev Author: vj0 Date: 2010-01-25 09:28:34 +0000 (Mon, 25 Jan 2010) Log Message: ----------- Fixed XTENlANG-926. Cleaning up the X10 type system. Remove behavesLike constraints and supporting methods. Removed Flags from X10Types, in favor of explicit processing of proto and struct. Got rid of X10TypeMixin.makeRef(X10Type). Removed X10Type, X10UknownType, X10TypeObject. Created Proto and X10Struct interfaces. These interfaces are implemented by X10ClassType and ConstrainedType. Proto defines methods for getting the base type of a Proto type and for making a Proto type. Similarly for X10Struct. Modified Paths: -------------- trunk/x10.compiler/src/x10/ast/AmbDepTypeNode_c.java trunk/x10.compiler/src/x10/ast/AmbMacroTypeNode_c.java trunk/x10.compiler/src/x10/ast/AssignPropertyCall_c.java trunk/x10.compiler/src/x10/ast/ForLoop_c.java trunk/x10.compiler/src/x10/ast/X10AmbTypeNode_c.java trunk/x10.compiler/src/x10/ast/X10BooleanLit_c.java trunk/x10.compiler/src/x10/ast/X10Call_c.java trunk/x10.compiler/src/x10/ast/X10CanonicalTypeNode_c.java trunk/x10.compiler/src/x10/ast/X10ClassDecl_c.java trunk/x10.compiler/src/x10/ast/X10Conditional_c.java trunk/x10.compiler/src/x10/ast/X10ConstructorCall_c.java trunk/x10.compiler/src/x10/ast/X10ConstructorDecl_c.java trunk/x10.compiler/src/x10/ast/X10FieldAssign_c.java trunk/x10.compiler/src/x10/ast/X10FieldDecl_c.java trunk/x10.compiler/src/x10/ast/X10Field_c.java trunk/x10.compiler/src/x10/ast/X10FloatLit_c.java trunk/x10.compiler/src/x10/ast/X10Formal_c.java trunk/x10.compiler/src/x10/ast/X10IntLit_c.java trunk/x10.compiler/src/x10/ast/X10Loop_c.java trunk/x10.compiler/src/x10/ast/X10MethodDecl_c.java trunk/x10.compiler/src/x10/ast/X10New_c.java trunk/x10.compiler/src/x10/ast/X10Special_c.java trunk/x10.compiler/src/x10/ast/X10StringLit_c.java trunk/x10.compiler/src/x10/optimizations/ForLoopOptimizer.java trunk/x10.compiler/src/x10/query/QueryEngine.java trunk/x10.compiler/src/x10/types/ConstrainedType.java trunk/x10.compiler/src/x10/types/ConstrainedType_c.java trunk/x10.compiler/src/x10/types/MacroType_c.java trunk/x10.compiler/src/x10/types/ParameterType_c.java trunk/x10.compiler/src/x10/types/ParametrizedType_c.java trunk/x10.compiler/src/x10/types/SubtypeConstraint.java trunk/x10.compiler/src/x10/types/SubtypeConstraint_c.java trunk/x10.compiler/src/x10/types/TypeConstraint_c.java trunk/x10.compiler/src/x10/types/X10ClassType.java trunk/x10.compiler/src/x10/types/X10ConstructorDef_c.java trunk/x10.compiler/src/x10/types/X10FieldInstance.java trunk/x10.compiler/src/x10/types/X10Flags.java trunk/x10.compiler/src/x10/types/X10LocalInstance.java trunk/x10.compiler/src/x10/types/X10MethodInstance_c.java trunk/x10.compiler/src/x10/types/X10NamedType.java trunk/x10.compiler/src/x10/types/X10NullType.java trunk/x10.compiler/src/x10/types/X10NullType_c.java trunk/x10.compiler/src/x10/types/X10ParsedClassType_c.java trunk/x10.compiler/src/x10/types/X10PrimitiveType_c.java trunk/x10.compiler/src/x10/types/X10ProcedureInstance.java trunk/x10.compiler/src/x10/types/X10TypeEnv.java trunk/x10.compiler/src/x10/types/X10TypeEnv_c.java trunk/x10.compiler/src/x10/types/X10TypeMixin.java trunk/x10.compiler/src/x10/types/X10TypeSystem.java trunk/x10.compiler/src/x10/types/X10TypeSystem_c.java trunk/x10.compiler/src/x10/types/X10UnknownType_c.java trunk/x10.compiler/src/x10/types/XTypeTranslator.java trunk/x10.compiler/src/x10/util/Synthesizer.java trunk/x10.compiler/src/x10/visit/AssignPropertyChecker.java trunk/x10.compiler/src/x10/visit/X10PrettyPrinterVisitor.java trunk/x10.compiler/src/x10cpp/visit/Emitter.java trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java trunk/x10.tests/examples/Constructs/Finish/FinishTest1.x10 Added Paths: ----------- trunk/x10.compiler/src/x10/types/Proto.java trunk/x10.compiler/src/x10/types/X10Struct.java trunk/x10.tests/examples/Constructs/Inference/LCA1.x10 trunk/x10.tests/examples/Constructs/Inference/LCAClassAClassB.x10 trunk/x10.tests/examples/Constructs/Inference/LCAClassAStructB.x10 trunk/x10.tests/examples/Constructs/Inference/LCAClassAStructB_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Inference/LCAClassASubclassB.x10 Removed Paths: ------------- trunk/x10.compiler/src/x10/types/X10Type.java trunk/x10.compiler/src/x10/types/X10TypeObject.java trunk/x10.compiler/src/x10/types/X10UnknownType.java Modified: trunk/x10.compiler/src/x10/ast/AmbDepTypeNode_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/AmbDepTypeNode_c.java 2010-01-25 05:46:37 UTC (rev 12698) +++ trunk/x10.compiler/src/x10/ast/AmbDepTypeNode_c.java 2010-01-25 09:28:34 UTC (rev 12699) @@ -38,7 +38,6 @@ import x10.types.TypeConstraint; import x10.types.X10ClassType; import x10.types.X10Context; -import x10.types.X10Type; import x10.types.X10TypeMixin; import x10.types.X10TypeSystem; @@ -130,7 +129,7 @@ XConstraint c = Types.get(dep.valueConstraint()); t = X10TypeMixin.xclause(t, c); if (flags != null) { - t = ((X10Type) t).setFlags(flags); + t = X10TypeMixin.processFlags(flags, t); flags = null; } Modified: trunk/x10.compiler/src/x10/ast/AmbMacroTypeNode_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/AmbMacroTypeNode_c.java 2010-01-25 05:46:37 UTC (rev 12698) +++ trunk/x10.compiler/src/x10/ast/AmbMacroTypeNode_c.java 2010-01-25 09:28:34 UTC (rev 12699) @@ -54,7 +54,6 @@ import x10.types.X10ClassType; import x10.types.X10Context; import x10.types.X10ParsedClassType; -import x10.types.X10Type; import x10.types.X10TypeMixin; import x10.types.X10TypeSystem; @@ -358,7 +357,7 @@ } } if (n.flags != null) { - t = ((X10Type) t).setFlags(flags); + t = X10TypeMixin.processFlags(flags, t); n.flags = null; } Modified: trunk/x10.compiler/src/x10/ast/AssignPropertyCall_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/AssignPropertyCall_c.java 2010-01-25 05:46:37 UTC (rev 12698) +++ trunk/x10.compiler/src/x10/ast/AssignPropertyCall_c.java 2010-01-25 09:28:34 UTC (rev 12699) @@ -44,7 +44,6 @@ import x10.types.X10ConstructorDef; import x10.types.X10Context; import x10.types.X10ParsedClassType; -import x10.types.X10Type; import x10.types.X10TypeMixin; import x10.types.X10TypeSystem; import x10.types.XTypeTranslator; Modified: trunk/x10.compiler/src/x10/ast/ForLoop_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/ForLoop_c.java 2010-01-25 05:46:37 UTC (rev 12698) +++ trunk/x10.compiler/src/x10/ast/ForLoop_c.java 2010-01-25 09:28:34 UTC (rev 12699) @@ -29,7 +29,6 @@ import polyglot.visit.TypeChecker; import x10.ast.X10Loop.LoopKind; import x10.types.X10MethodInstance; -import x10.types.X10Type; import x10.types.X10TypeSystem; /** Modified: trunk/x10.compiler/src/x10/ast/X10AmbTypeNode_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10AmbTypeNode_c.java 2010-01-25 05:46:37 UTC (rev 12698) +++ trunk/x10.compiler/src/x10/ast/X10AmbTypeNode_c.java 2010-01-25 09:28:34 UTC (rev 12699) @@ -39,7 +39,6 @@ import x10.types.X10Context; import x10.types.X10Flags; import x10.types.X10ParsedClassType; -import x10.types.X10Type; import x10.types.X10TypeMixin; import x10.types.X10TypeSystem; @@ -168,7 +167,7 @@ if (n instanceof TypeNode) { TypeNode tn = (TypeNode) n; LazyRef<Type> sym = (LazyRef<Type>) type; - X10Type t2 = (X10Type) tn.type(); + Type t2 = tn.type(); /* if (t2 instanceof X10ParsedClassType) { X10ParsedClassType ct = (X10ParsedClassType) tn.type(); @@ -204,8 +203,8 @@ Flags f = ((X10AmbTypeNode_c) n).flags; if (f != null) { LazyRef<Type> sym = (LazyRef<Type>) result.typeRef(); - X10Type t = (X10Type) Types.get(sym); - t = t.setFlags(f); + Type t = Types.get(sym); + t = X10TypeMixin.processFlags(f, t); sym.update(t); } return AmbDepTypeNode_c.postprocess(result, n, childtc); Modified: trunk/x10.compiler/src/x10/ast/X10BooleanLit_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10BooleanLit_c.java 2010-01-25 05:46:37 UTC (rev 12698) +++ trunk/x10.compiler/src/x10/ast/X10BooleanLit_c.java 2010-01-25 09:28:34 UTC (rev 12699) @@ -21,7 +21,7 @@ import x10.constraint.XFailure; import x10.constraint.XTerm; import x10.types.X10Context; -import x10.types.X10Type; + import x10.types.X10TypeMixin; import x10.types.X10TypeSystem; import x10.types.XTypeTranslator; @@ -43,7 +43,7 @@ /** Type check the expression. */ public Node typeCheck(ContextVisitor tc) throws SemanticException { X10TypeSystem xts = (X10TypeSystem) tc.typeSystem(); - X10Type Boolean = (X10Type) xts.Boolean(); + Type Boolean = xts.Boolean(); XConstraint c = new XConstraint_c(); XTerm term = xts.xtypeTranslator().trans(c, this.type(Boolean), (X10Context) tc.context()); Modified: trunk/x10.compiler/src/x10/ast/X10Call_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10Call_c.java 2010-01-25 05:46:37 UTC (rev 12698) +++ trunk/x10.compiler/src/x10/ast/X10Call_c.java 2010-01-25 09:28:34 UTC (rev 12699) @@ -68,7 +68,7 @@ import x10.types.X10MemberDef; import x10.types.X10MethodDef; import x10.types.X10MethodInstance; -import x10.types.X10Type; + import x10.types.X10TypeMixin; import x10.types.X10TypeSystem; import x10.types.X10TypeSystem_c; @@ -255,7 +255,7 @@ else { otn = tn2; } - if (X10TypeMixin.isStruct(otn.type())) { + if (X10TypeMixin.isX10Struct(otn.type())) { X10New_c neu = (X10New_c) nf.X10New(position(), otn, Collections.EMPTY_LIST, args); neu.setStructConstructorCall(); @@ -312,11 +312,12 @@ // different from mi.container(). mi.container() returns a super type // of the class we want. Type scope = c.findMethodScope(name.id()); - XRoot this_ = getThis(scope); - if (this_ != null) - scope = X10TypeMixin.setSelfVar(scope, this_); + if (! ts.typeEquals(scope, c.currentClass(), c)) { + XRoot this_ = getThis(scope); + if (this_ != null) + scope = X10TypeMixin.setSelfVar(scope, this_); r = (Special) nf.This(position().startOf(), nf.CanonicalTypeNode(position().startOf(), scope)).del().typeCheck(tc); } @@ -335,7 +336,7 @@ } void checkProtoMethod() throws SemanticException { - if (((X10Type) target().type()).isProto() + if (X10TypeMixin.isProto(target().type()) && ! X10Flags.toX10Flags(methodInstance().flags()).isProto() ) throw new SemanticException(methodInstance() @@ -622,8 +623,8 @@ throw new SemanticException(mi + ": Only sequential methods can be called from sequential code.", position()); if (c.inLocalCode() - && ! (mi.isSafe() || flags.isRooted() || flags.isExtern())) - throw new SemanticException(mi + ": Only rooted methods can be called from rooted code.", + && ! (mi.isSafe() || flags.isPinned() || flags.isExtern())) + throw new SemanticException(mi + ": Only pinned methods can be called from pinned code.", position()); } } Modified: trunk/x10.compiler/src/x10/ast/X10CanonicalTypeNode_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10CanonicalTypeNode_c.java 2010-01-25 05:46:37 UTC (rev 12698) +++ trunk/x10.compiler/src/x10/ast/X10CanonicalTypeNode_c.java 2010-01-25 09:28:34 UTC (rev 12699) @@ -42,7 +42,7 @@ import x10.types.X10ClassType; import x10.types.X10Context; import x10.types.X10Flags; -import x10.types.X10Type; + import x10.types.X10TypeMixin; import x10.types.X10TypeSystem; @@ -94,16 +94,13 @@ X10Context c = (X10Context) tc.context(); X10TypeSystem ts = (X10TypeSystem) tc.typeSystem(); + // Expand, and transfer flags from the type node to the type. Type t = Types.get(type); t = ts.expandMacros(t); - X10Type xt = (X10Type) t; + Type xt = t; if (flags != null) { - X10Flags xflags = X10Flags.toX10Flags(flags); - X10Flags f = X10Flags.toX10Flags( xt.flags()); - if (f == null) - f = (X10Flags) X10Flags.toX10Flags(Flags.NONE); - xt = xt.setFlags(flags); + xt = X10TypeMixin.processFlags(X10Flags.toX10Flags(flags), xt); flags = null; } ((Ref<Type>) type).update(xt); Modified: trunk/x10.compiler/src/x10/ast/X10ClassDecl_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10ClassDecl_c.java 2010-01-25 05:46:37 UTC (rev 12698) +++ trunk/x10.compiler/src/x10/ast/X10ClassDecl_c.java 2010-01-25 09:28:34 UTC (rev 12699) @@ -104,7 +104,7 @@ import x10.types.X10MethodDef; import x10.types.X10MethodInstance; import x10.types.X10ParsedClassType; -import x10.types.X10Type; + import x10.types.X10TypeMixin; import x10.types.X10TypeSystem; import x10.types.X10TypeSystem_c; @@ -633,7 +633,8 @@ if (type.superType() != null) { if (((X10ClassDef) type).isStruct()) { - if (! ((X10Type) type.superType().get()).isX10Struct()) { + if (! (X10TypeMixin.isX10Struct(type.superType().get()))) { + throw new SemanticException(type.superType() + " cannot be the superclass for " + type + "; a struct must subclass a struct.",position()); @@ -731,7 +732,7 @@ t + "; not a class.", superClass != null ? superClass.position() : position()); } - if (((X10Type) t).isProto()) { + if (X10TypeMixin.isProto(t)) { throw new SemanticException("proto supertypes are not permitted.", superClass().position()); } @@ -748,10 +749,10 @@ throw new SemanticException("Cannot " + s + " type " + t + "; not an interface.", position()); } - if (((X10Type) t).isProto()) { + if (X10TypeMixin.isProto(t)) throw new SemanticException("Cannot implement " + t + "; proto interfaces are illegal.", position()); - } + ts.checkCycles((ReferenceType) t); } } Modified: trunk/x10.compiler/src/x10/ast/X10Conditional_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10Conditional_c.java 2010-01-25 05:46:37 UTC (rev 12698) +++ trunk/x10.compiler/src/x10/ast/X10Conditional_c.java 2010-01-25 09:28:34 UTC (rev 12699) @@ -38,7 +38,7 @@ import x10.constraint.XConstraint; import x10.types.X10Context; import x10.types.X10NamedType; -import x10.types.X10Type; + import x10.types.X10TypeMixin; import x10.types.X10TypeSystem; import x10.visit.ExprFlattener; @@ -74,8 +74,8 @@ Expr e1 = consequent; Expr e2 = alternative; - X10Type t1 = (X10Type) e1.type(); - X10Type t2 = (X10Type) e2.type(); + Type t1 = e1.type(); + Type t2 = e2.type(); // From the JLS, section: // If the second and third operands have the same type (which may be Modified: trunk/x10.compiler/src/x10/ast/X10ConstructorCall_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10ConstructorCall_c.java 2010-01-25 05:46:37 UTC (rev 12698) +++ trunk/x10.compiler/src/x10/ast/X10ConstructorCall_c.java 2010-01-25 09:28:34 UTC (rev 12699) @@ -48,7 +48,7 @@ import x10.types.X10ConstructorDef; import x10.types.X10ConstructorInstance; import x10.types.X10MethodInstance; -import x10.types.X10Type; + import x10.types.X10TypeMixin; import x10.types.X10TypeSystem; import x10.types.X10TypeSystem_c; @@ -122,8 +122,8 @@ Type superType = ct.superClass(); if (superType == null) { // this can happen for structs, and for Object - X10Type type = (X10Type) context.currentClass(); - if (X10TypeMixin.isStruct(type) + Type type = context.currentClass(); + if (X10TypeMixin.isX10Struct(type) || ts.typeEquals(type, ts.Object(), tc.context())) { // the super() call inserted by the parser needs to be thrown out X10NodeFactory nf = (X10NodeFactory) tc.nodeFactory(); Modified: trunk/x10.compiler/src/x10/ast/X10ConstructorDecl_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10ConstructorDecl_c.java 2010-01-25 05:46:37 UTC (rev 12698) +++ trunk/x10.compiler/src/x10/ast/X10ConstructorDecl_c.java 2010-01-25 09:28:34 UTC (rev 12699) @@ -57,7 +57,7 @@ import x10.types.X10Flags; import x10.types.X10MemberDef; import x10.types.X10ProcedureDef; -import x10.types.X10Type; + import x10.types.X10TypeMixin; import x10.types.X10TypeSystem; /** @@ -287,7 +287,7 @@ for (Formal n : formals) { Ref<Type> ref = (Ref<Type>) n.type().typeRef(); - X10Type newType = (X10Type) ref.get(); + Type newType = ref.get(); // Fold the formal's constraint into the guard. XVar var = xts.xtypeTranslator().trans(n.localDef().asInstance()); @@ -307,7 +307,7 @@ // Fold this's constraint (the class invariant) into the guard. { - X10Type t = (X10Type) tc.context().currentClass(); + Type t = tc.context().currentClass(); XConstraint dep = X10TypeMixin.xclause(t); if (c != null && dep != null) { XRoot thisVar = ((X10MemberDef) constructorDef()).thisVar(); @@ -357,15 +357,15 @@ ((Ref<Type>) nnci.returnType()).update(r.type()); // Report.report(1, "X10MethodDecl_c: typeoverride mi= " + nn.methodInstance()); - Type retTypeBase = X10TypeMixin.baseTypeWithoutProto(r.type()); + /* Type retTypeBase = X10TypeMixin.baseOfProto(r.type()); //Type clazz = ((X10Type) X10TypeMixin.baseType(Types.get(nnci.container()))).addFlags(X10Flags.ROOTED); - Type clazz = X10TypeMixin.baseTypeWithoutProto(Types.get(nnci.container())); + Type clazz = X10TypeMixin.baseOfProto(Types.get(nnci.container())); if (! xts.typeEquals(retTypeBase, clazz, tc.context())) { throw new SemanticException("The return type of the constructor (" + retTypeBase + ") must be derived from" + " the type of the class (" + clazz + ") on which the constructor is defined.", position()); - } + }*/ // Step III. Check the body. // We must do it with the correct mi -- the return type will be @@ -397,7 +397,7 @@ } n = (X10ConstructorDecl_c) (super.typeCheck(tc)); - X10TypeMixin.protoTypeCheck(n.formals(), (X10Type) n.returnType().type(), + X10TypeMixin.protoTypeCheck(n.formals(), n.returnType().type(), n.position(), false); return n; } @@ -406,7 +406,8 @@ X10ConstructorDecl_c n = (X10ConstructorDecl_c) super.conformanceCheck(tc); X10TypeSystem ts = (X10TypeSystem) tc.typeSystem(); - Type retTypeBase = ((X10Type) X10TypeMixin.baseTypeWithoutProto(n.returnType().type())); + Type retTypeBase = X10TypeMixin.baseOfProto(n.returnType().type()); + retTypeBase = X10TypeMixin.baseType(retTypeBase); XConstraint c = X10TypeMixin.xclause(n.returnType().type()); X10ConstructorDef nnci = (X10ConstructorDef) n.constructorDef(); Modified: trunk/x10.compiler/src/x10/ast/X10FieldAssign_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10FieldAssign_c.java 2010-01-25 05:46:37 UTC (rev 12698) +++ trunk/x10.compiler/src/x10/ast/X10FieldAssign_c.java 2010-01-25 09:28:34 UTC (rev 12699) @@ -23,9 +23,10 @@ import polyglot.util.InternalCompilerError; import polyglot.util.Position; import polyglot.visit.ContextVisitor; +import x10.types.X10ClassType; import x10.types.X10Context; import x10.types.X10Flags; -import x10.types.X10Type; + import x10.types.X10TypeMixin; public class X10FieldAssign_c extends FieldAssign_c { @@ -45,21 +46,21 @@ TypeSystem ts = tc.typeSystem(); X10FieldAssign_c n = (X10FieldAssign_c) typeCheckLeft(tc); - X10Type t = (X10Type) n.leftType(); - X10Type targetType = (X10Type) n.target().type(); + Type t = n.leftType(); + Type targetType = n.target().type(); if (t == null) - t = (X10Type) ts.unknownType(n.position()); + t = ts.unknownType(n.position()); Expr right = n.right(); Assign.Operator op = n.operator(); - X10Type s = (X10Type) right.type(); + Type s = right.type(); // Check the proto condition. - if (s.isProto()) { - if (! targetType.isProto()) { + if (X10TypeMixin.isProto(s)) { + if (! X10TypeMixin.isProto(targetType)) { throw new SemanticException("The receiver " + this.target() + " does not have a proto type; hence " + this.right() + @@ -71,7 +72,7 @@ + " assign the proto value " + this.right() + " to a field.", position()); } - s = s.clearFlags(X10Flags.PROTO); + s = X10TypeMixin.baseOfProto(s); if (! (ts.isSubtype(s, t, tc.context()))) { throw new SemanticException("Cannot assign " + s + " to " + t + ".", n.position()); Modified: trunk/x10.compiler/src/x10/ast/X10FieldDecl_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10FieldDecl_c.java 2010-01-25 05:46:37 UTC (rev 12698) +++ trunk/x10.compiler/src/x10/ast/X10FieldDecl_c.java 2010-01-25 09:28:34 UTC (rev 12699) @@ -52,7 +52,7 @@ import x10.types.X10FieldDef; import x10.types.X10Flags; import x10.types.X10InitializerDef; -import x10.types.X10Type; + import x10.types.X10TypeMixin; import x10.types.X10TypeSystem; @@ -102,15 +102,14 @@ throw new SemanticException("Cannot declare a non-final field in a value class.", position()); } */ - if (ref instanceof X10Type) { - X10Type container = (X10Type) ref; - if (container.isX10Struct()) { + + if (X10TypeMixin.isX10Struct(ref)) { X10Flags x10flags = X10Flags.toX10Flags(fi.flags()); if (! x10flags.isFinal()) throw new SemanticException("Illegal " + fi + "; structs cannot have var fields.", position()); } - } + checkVariance(tc); X10MethodDecl_c.checkVisibility(tc.typeSystem(), context, this); @@ -264,17 +263,17 @@ @Override public Node typeCheck(ContextVisitor tc) throws SemanticException { - X10Type type = (X10Type) this.type().type(); + Type type = this.type().type(); if (type.isVoid()) throw new SemanticException("Field cannot have type " + this.type().type() + ".", position()); - if (type.isProto()) { + if (X10TypeMixin.isProto(type)) { throw new SemanticException("Field cannot have type " + this.type().type() + " (a proto type).", position()); } - if (X10TypeMixin.isStruct(fieldDef().container().get()) && + if (X10TypeMixin.isX10Struct(fieldDef().container().get()) && ! X10Flags.toX10Flags(fieldDef().flags()).isFinal()) { throw new SemanticException("A struct may not have var fields.", position()); Modified: trunk/x10.compiler/src/x10/ast/X10Field_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10Field_c.java 2010-01-25 05:46:37 UTC (rev 12698) +++ trunk/x10.compiler/src/x10/ast/X10Field_c.java 2010-01-25 09:28:34 UTC (rev 12699) @@ -51,7 +51,7 @@ import x10.types.X10Flags; import x10.types.X10MemberDef; import x10.types.X10MethodInstance; -import x10.types.X10Type; + import x10.types.X10TypeMixin; import x10.types.X10TypeSystem; @@ -84,8 +84,8 @@ if (! ((X10Context) tc.context()).inAssignment()) { if (n instanceof X10Field_c) { - X10Type xtType = (X10Type) ((X10Field_c) n).target().type(); - if (xtType.isProto()) { + Type xtType = ((X10Field_c) n).target().type(); + if (X10TypeMixin.isProto(xtType)) { throw new SemanticException("Not permitted to read field " + n + " of proto value " + target() +"." Modified: trunk/x10.compiler/src/x10/ast/X10FloatLit_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10FloatLit_c.java 2010-01-25 05:46:37 UTC (rev 12698) +++ trunk/x10.compiler/src/x10/ast/X10FloatLit_c.java 2010-01-25 09:28:34 UTC (rev 12699) @@ -21,7 +21,7 @@ import x10.constraint.XFailure; import x10.constraint.XTerm; import x10.types.X10Context; -import x10.types.X10Type; + import x10.types.X10TypeMixin; import x10.types.X10TypeSystem; import x10.types.XTypeTranslator; @@ -45,7 +45,7 @@ } public Node typeCheck(ContextVisitor tc) throws SemanticException { X10TypeSystem xts = (X10TypeSystem) tc.typeSystem(); - X10Type Type = (X10Type) (kind==FLOAT ? xts.Float() : xts.Double()); + Type Type = (kind==FLOAT ? xts.Float() : xts.Double()); XConstraint c = new XConstraint_c(); XTerm term = xts.xtypeTranslator().trans(c, this.type(Type), (X10Context) tc.context()); Modified: trunk/x10.compiler/src/x10/ast/X10Formal_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10Formal_c.java 2010-01-25 05:46:37 UTC (rev 12698) +++ trunk/x10.compiler/src/x10/ast/X10Formal_c.java 2010-01-25 09:28:34 UTC (rev 12699) @@ -54,7 +54,7 @@ import x10.types.X10LocalDef; import x10.types.X10LocalInstance; import x10.types.X10MethodInstance; -import x10.types.X10Type; + import x10.types.X10TypeMixin; import x10.types.X10TypeSystem; import x10.visit.X10PrettyPrinterVisitor; Modified: trunk/x10.compiler/src/x10/ast/X10IntLit_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10IntLit_c.java 2010-01-25 05:46:37 UTC (rev 12698) +++ trunk/x10.compiler/src/x10/ast/X10IntLit_c.java 2010-01-25 09:28:34 UTC (rev 12699) @@ -22,7 +22,7 @@ import x10.constraint.XFailure; import x10.constraint.XTerm; import x10.types.X10Context; -import x10.types.X10Type; + import x10.types.X10TypeMixin; import x10.types.X10TypeSystem; import x10.types.XTypeTranslator; Modified: trunk/x10.compiler/src/x10/ast/X10Loop_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10Loop_c.java 2010-01-25 05:46:37 UTC (rev 12698) +++ trunk/x10.compiler/src/x10/ast/X10Loop_c.java 2010-01-25 09:28:34 UTC (rev 12699) @@ -58,7 +58,7 @@ import x10.types.X10FieldInstance; import x10.types.X10LocalDef; import x10.types.X10MethodInstance; -import x10.types.X10Type; + import x10.types.X10TypeEnv; import x10.types.X10TypeEnv_c; import x10.types.X10TypeMixin; @@ -130,7 +130,7 @@ if (domain.type() instanceof UnknownType) { throw new SemanticException(); } - X10Type domainType = (X10Type) domain.type(); + Type domainType = domain.type(); Formal formal = (Formal) this.visitChild(this.formal, tc1); @@ -156,10 +156,10 @@ public Node typeCheckNode(ContextVisitor tc) throws SemanticException { NodeFactory nf = tc.nodeFactory(); X10TypeSystem ts = (X10TypeSystem) tc.typeSystem(); - X10Type domainType = (X10Type) domainTypeRef.get(); + Type domainType = domainTypeRef.get(); if (domainType == null ) { // aha, in this case the type inferencer did not run, since an explicit type was givem. - domainType = (X10Type) domain.type(); + domainType = domain.type(); } Type formalType = formal.declType(); Type Iterable = ts.Iterable(formalType); @@ -329,11 +329,11 @@ // obligation (Iterable[indexType] <: domainType) is satisfied. LazyRef<Type> domainTypeRef = Types.lazyRef(null); - public X10Type domainType() { - X10Type domainType = (X10Type) domainTypeRef.get(); + public Type domainType() { + Type domainType = domainTypeRef.get(); if (domainType == null ) { // aha, in this case the type inferencer did not run, since an explicit type was givem. - domainType = (X10Type) domain.type(); + domainType = domain.type(); } return domainType; } Modified: trunk/x10.compiler/src/x10/ast/X10MethodDecl_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10MethodDecl_c.java 2010-01-25 05:46:37 UTC (rev 12698) +++ trunk/x10.compiler/src/x10/ast/X10MethodDecl_c.java 2010-01-25 09:28:34 UTC (rev 12699) @@ -99,7 +99,7 @@ import x10.types.X10MethodDef; import x10.types.X10MethodInstance; import x10.types.X10ProcedureDef; -import x10.types.X10Type; + import x10.types.X10TypeMixin; import x10.types.X10TypeSystem; import x10.types.XTypeTranslator; @@ -423,7 +423,7 @@ dupFormalCheck(typeParameters, formals); - X10TypeMixin.protoTypeCheck(formals(), (X10Type) returnType().type(), position(), + X10TypeMixin.protoTypeCheck(formals(), returnType().type(), position(), true); return n; @@ -860,7 +860,7 @@ for (Formal n : formals) { Ref<Type> ref = (Ref<Type>) n.type().typeRef(); - X10Type newType = (X10Type) ref.get(); + Type newType = ref.get(); // Fold the formal's constraint into the guard. XVar var = xts.xtypeTranslator().trans(n.localDef().asInstance()); @@ -880,7 +880,7 @@ // Fold this's constraint (the class invariant) into the guard. { - X10Type t = (X10Type) tc.context().currentClass(); + Type t = tc.context().currentClass(); XConstraint dep = X10TypeMixin.xclause(t); if (c != null && dep != null) { XRoot thisVar = ((X10MemberDef) methodDef()).thisVar(); Modified: trunk/x10.compiler/src/x10/ast/X10New_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10New_c.java 2010-01-25 05:46:37 UTC (rev 12698) +++ trunk/x10.compiler/src/x10/ast/X10New_c.java 2010-01-25 09:28:34 UTC (rev 12699) @@ -58,7 +58,6 @@ import x10.types.X10Context; import x10.types.X10Flags; import x10.types.X10ParsedClassType_c; -import x10.types.X10Type; import x10.types.X10TypeMixin; import x10.types.X10TypeSystem; import x10.types.X10TypeSystem_c; @@ -501,10 +500,10 @@ } X10TypeSystem ts = (X10TypeSystem) tc.typeSystem(); - X10Type tp = (X10Type) ci.returnType(); - X10Type tp1 = (X10Type) tp.copy(); - if (tp1.isProto()) { - tp1 = tp1.clearFlags(X10Flags.PROTO); + Type tp = ci.returnType(); + Type tp1 = (Type) tp.copy(); + if (X10TypeMixin.isProto(tp1)) { + tp1 = X10TypeMixin.baseOfProto(tp1); } if (!ts.isSubtype(tp1, t, tc.context())) { Modified: trunk/x10.compiler/src/x10/ast/X10Special_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10Special_c.java 2010-01-25 05:46:37 UTC (rev 12698) +++ trunk/x10.compiler/src/x10/ast/X10Special_c.java 2010-01-25 09:28:34 UTC (rev 12699) @@ -30,7 +30,7 @@ import x10.types.X10Flags; import x10.types.X10MethodDef; import x10.types.X10ProcedureDef; -import x10.types.X10Type; + import x10.types.X10TypeMixin; import x10.types.X10TypeSystem; import x10.types.XTypeTranslator; @@ -70,7 +70,7 @@ return type(tt); } - ClassType t = null; + Type t = null; if (qualifier == null) { // an unqualified "this" @@ -92,36 +92,39 @@ returnType = ts.expandMacros(returnType); // Set the type of this to be proto T, where T is the return // type of the constructor. + returnType = X10TypeMixin.makeProto(returnType); + /* if (returnType.isClass()) { - t = X10TypeMixin.makeProto((X10Type) returnType).toClass(); + t = (ClassType) X10TypeMixin.makeProto(returnType); } else { throw new SemanticException("Constructor return type is not a class type.", cd.position()); - } + }*/ } else // Check if this is a proto method, then the type of this needs // to be set to proto C if (c.currentCode() instanceof X10MethodDef) { X10MethodDef cd = (X10MethodDef) c.currentCode(); if (cd.isProto()) { - t = X10TypeMixin.makeProto((X10Type) t).toClass(); + t = X10TypeMixin.makeProto(t); } } } else { if (qualifier.type().isClass()) { - t = qualifier.type().toClass(); + ClassType ct = qualifier.type().toClass(); + t=ct; CodeDef cd = c.currentCode(); - if (!c.currentClass().hasEnclosingInstance(t)) { + if (!c.currentClass().hasEnclosingInstance(ct)) { throw new SemanticException("The nested class \"" + c.currentClass() + "\" does not have " + "an enclosing instance of type \"" + - t + "\".", qualifier.position()); + ct + "\".", qualifier.position()); } if (cd instanceof X10ConstructorDef || (cd instanceof X10MethodDef && ((X10MethodDef) cd).isProto())) - t = X10TypeMixin.makeProto((X10Type) t).toClass(); + t = X10TypeMixin.makeProto(ct); } else { @@ -161,8 +164,9 @@ result = (X10Special) type(tt); } else if (kind == SUPER) { - Type tt = X10TypeMixin.baseType(t.superClass()); - XConstraint cc = X10TypeMixin.xclause(t.superClass()); + Type superClass = X10TypeMixin.superClass(t); + Type tt = X10TypeMixin.baseType(superClass); + XConstraint cc = X10TypeMixin.xclause(superClass); cc = cc == null ? new XConstraint_c() : cc.copy(); try { cc.addSelfBinding((XVar) xts.xtypeTranslator().trans(cc, this, c)); @@ -203,7 +207,7 @@ if (qualifier != null) typeString = qualifier.toString(); else { - X10Type type = (X10Type) type(); + Type type = type(); if (type != null) { ClassType k = type.toClass(); if (k != null) Modified: trunk/x10.compiler/src/x10/ast/X10StringLit_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10StringLit_c.java 2010-01-25 05:46:37 UTC (rev 12698) +++ trunk/x10.compiler/src/x10/ast/X10StringLit_c.java 2010-01-25 09:28:34 UTC (rev 12699) @@ -21,7 +21,7 @@ import x10.constraint.XFailure; import x10.constraint.XTerm; import x10.types.X10Context; -import x10.types.X10Type; + import x10.types.X10TypeMixin; import x10.types.X10TypeSystem; import x10.types.XTypeTranslator; @@ -41,17 +41,17 @@ } public Node typeCheck(ContextVisitor tc) throws SemanticException { X10TypeSystem xts= (X10TypeSystem) tc.typeSystem(); - X10Type Type = (X10Type) xts.String(); - - XConstraint c = new XConstraint_c(); - XTerm term = xts.xtypeTranslator().trans(c, this.type(Type), (X10Context) tc.context()); - try { - c.addSelfBinding(term); - } - catch (XFailure e) { - } - Type newType = X10TypeMixin.xclause(Type, c); - return type(newType); - } + Type Type = xts.String(); + XConstraint c = new XConstraint_c(); + XTerm term = xts.xtypeTranslator().trans(c, this.type(Type), (X10Context) tc.context()); + try { + c.addSelfBinding(term); + } + catch (XFailure e) { + } + Type newType = X10TypeMixin.xclause(Type, c); + return type(newType); + } + } Modified: trunk/x10.compiler/src/x10/optimizations/ForLoopOptimizer.java =================================================================== --- trunk/x10.compiler/src/x10/optimizations/ForLoopOptimizer.java 2010-01-25 05:46:37 UTC (rev 12698) +++ trunk/x10.compiler/src/x10/optimizations/ForLoopOptimizer.java 2010-01-25 09:28:34 UTC (rev 12699) @@ -39,7 +39,6 @@ import x10.constraint.XTerms; import x10.constraint.XVar; import x10.types.X10Context; -import x10.types.X10Type; import x10.types.X10TypeMixin; import x10.types.X10TypeSystem; import x10.util.Synthesizer; @@ -67,7 +66,7 @@ public Node visitForLoop(ForLoop_c loop) throws SemanticException { Synthesizer syn = new Synthesizer(xnf, xts); - X10Type domainType = loop.domainType(); + Type domainType = loop.domainType(); XVar var = XTerms.makeEQV("self"); Type regionType = syn.addRankConstraint(xts.Region(), var, 1, xts); regionType = syn.addRectConstraint(regionType, var); Modified: trunk/x10.compiler/src/x10/query/QueryEngine.java =================================================================== --- trunk/x10.compiler/src/x10/query/QueryEngine.java 2010-01-25 05:46:37 UTC (rev 12698) +++ trunk/x10.compiler/src/x10/query/QueryEngine.java 2010-01-25 09:28:34 UTC (rev 12699) @@ -21,7 +21,6 @@ import x10.ast.SettableAssign; import x10.types.X10ClassType; import x10.types.X10Context; -import x10.types.X10Type; import x10.types.X10TypeMixin; import x10.types.X10TypeSystem; Modified: trunk/x10.compiler/src/x10/types/ConstrainedType.java =================================================================== --- trunk/x10.compiler/src/x10/types/ConstrainedType.java 2010-01-25 05:46:37 UTC (rev 12698) +++ trunk/x10.compiler/src/x10/types/ConstrainedType.java 2010-01-25 09:28:34 UTC (rev 12699) @@ -20,7 +20,7 @@ import x10.constraint.XConstraint; import x10.constraint.XConstraint_c; -public interface ConstrainedType extends ObjectType, X10NamedType, X10ThisVar { +public interface ConstrainedType extends ObjectType, X10NamedType, Proto, X10Struct, X10ThisVar { Ref<? extends Type> baseType(); ConstrainedType baseType(Ref<? extends Type> baseType); Modified: trunk/x10.compiler/src/x10/types/ConstrainedType_c.java =================================================================== --- trunk/x10.compiler/src/x10/types/ConstrainedType_c.java 2010-01-25 05:46:37 UTC (rev 12698) +++ trunk/x10.compiler/src/x10/types/ConstrainedType_c.java 2010-01-25 09:28:34 UTC (rev 12699) @@ -85,7 +85,7 @@ return baseType; } - public X10Type clearFlags(Flags f) { + /*public X10Type clearFlags(Flags f) { ConstrainedType_c c = (ConstrainedType_c) this.copy(); X10Type t = (X10Type) Types.get(c.baseType); if (t==null) @@ -95,17 +95,39 @@ // ((Ref<Type>)c.baseType).update(t); return c; } + */ + public Proto baseOfProto() { + Type t = Types.get(baseType); + assert t!=null; + if (! X10TypeMixin.isProto(t)) + return this; + ConstrainedType_c c = (ConstrainedType_c) this.copy(); + c.baseType = Types.ref(X10TypeMixin.baseOfProto(t)); + return c; + } + public Proto makeProto() { + Type t = Types.get(baseType); + assert t!=null; + if (X10TypeMixin.isProto(t)) + return this; + ConstrainedType_c c = (ConstrainedType_c) this.copy(); + c.baseType = Types.ref(X10TypeMixin.makeProto(t)); + return c; + + } - public X10Type setFlags(Flags f) { + public X10Struct makeX10Struct() { + Type t = Types.get(baseType); + assert t!=null; + if (X10TypeMixin.isX10Struct(t)) + return this; ConstrainedType_c c = (ConstrainedType_c) this.copy(); - X10Type t = (X10Type) Types.get(c.baseType); - if (t==null) - throw new InternalCompilerError("Cannot set flags " + f + " on null type."); - t = t.setFlags(f); - //((Ref<Type>)c.baseType).update(t); + c.baseType = Types.ref(X10TypeMixin.makeX10Struct(t)); return c; + } - + + /* public Flags flags() { X10Type t = (X10Type) Types.get(this.baseType); assert t != null : "Cannot get flags on null type."; @@ -113,7 +135,7 @@ throw new InternalCompilerError("Cannot get flags on null type."); return t.flags(); } - + */ public ConstrainedType baseType(Ref<? extends Type> baseType) { ConstrainedType_c n = (ConstrainedType_c) copy(); n.baseType = baseType; @@ -199,9 +221,9 @@ } - public boolean safe() { - return ((X10Type) baseType.get()).safe(); - } + /*public boolean isSafe() { + return ((X10Type) baseType.get()).isSafe(); + }*/ @Override public String toString() { @@ -362,19 +384,15 @@ public boolean isX10Struct() { - X10Type base = (X10Type) baseType.get(); - return base.isX10Struct(); + return X10TypeMixin.isX10Struct(baseType.get()); } - /*public boolean isRooted() { - X10Type base = (X10Type) baseType.get(); - return base.isRooted(); - }*/ - public boolean isProto() { - X10Type base = (X10Type) baseType.get(); - return base.isProto(); + + public boolean isProto() { + return X10TypeMixin.isProto(baseType.get()); } + @Override public boolean isClass() { Type base = baseType.get(); @@ -424,7 +442,7 @@ Type base = baseType.get(); base.print(w); } - public boolean equalsNoFlag(X10Type t2) { + public boolean equalsNoFlag(Type t2) { return false; } Modified: trunk/x10.compiler/src/x10/types/MacroType_c.java =================================================================== --- trunk/x10.compiler/src/x10/types/MacroType_c.java 2010-01-25 05:46:37 UTC (rev 12698) +++ trunk/x10.compiler/src/x10/types/MacroType_c.java 2010-01-25 09:28:34 UTC (rev 12699) @@ -47,6 +47,11 @@ import x10.constraint.XTerms; import x10.constraint.XVar; +/** + * Represents a type definition + * + * @author njnystrom + */ public class MacroType_c extends ParametrizedType_c implements MacroType { Ref<TypeDef> def; @@ -89,7 +94,7 @@ return ((X10TypeSystem) typeSystem()).isStructType(this); } - public X10Type setFlags(Flags f) { + public Type setFlags(Flags f) { X10Flags xf = X10Flags.toX10Flags(f); MacroType_c c = (MacroType_c) this.copy(); if (c.flags == null) @@ -99,7 +104,7 @@ : ((xf.isStruct()) ? X10Flags.toX10Flags(c.flags).Struct() : c.flags); return c; } - public X10Type clearFlags(Flags f) { + public Type clearFlags(Flags f) { MacroType_c c = (MacroType_c) this.copy(); if (c.flags == null) c.flags = X10Flags.toX10Flags(Flags.NONE); @@ -233,7 +238,8 @@ public Type definedType() { if (definedType == null) return Types.get(def().definedType()); - return ((X10Type) Types.get(definedType)).setFlags(flags()); + Type t = X10TypeMixin.processFlags(flags(), Types.get(definedType)); + return t; } public Ref<? extends Type> definedTypeRef() { if (definedType == null) @@ -411,7 +417,7 @@ public boolean throwsSubset(ProcedureInstance<TypeDef> pi) { return true; } - public boolean equalsNoFlag(X10Type t2) { + public boolean equalsNoFlag(Type t2) { return false; } } Modified: trunk/x10.compiler/src/x10/types/ParameterType_c.java =================================================================== --- trunk/x10.compiler/src/x10/types/ParameterType_c.java 2010-01-25 05:46:37 UTC (rev 12698) +++ trunk/x10.compiler/src/x10/types/ParameterType_c.java 2010-01-25 09:28:34 UTC (rev 12699) @@ -53,7 +53,7 @@ return name.toString(); } - public boolean safe() { + public boolean isSafe() { return false; } @@ -75,23 +75,8 @@ n.def = def; return n; } - // begin Flagged mixin - public Flags flags() { return Flags.NONE;} - public X10Type setFlags(Flags flags) { - assert false : "Canot set flags on ParameterType_c"; - throw new InternalCompilerError("Cannot set flags on " + this); - } - public X10Type clearFlags(Flags flags) { - return this; - } + + public boolean permitsNull() { return false;} + - public boolean isRooted() { return false; } - public boolean isProto() { return false; } - public boolean isX10Struct() { - return ((X10TypeSystem) typeSystem()).isStructType(this); - } - // end Flagged mixin - public boolean equalsNoFlag(X10Type t2) { - return this == t2; - } } Modified: trunk/x10.compiler/src/x10/types/ParametrizedType_c.java =================================================================== --- trunk/x10.compiler/src/x10/types/ParametrizedType_c.java 2010-01-25 05:46:37 UTC (rev 12698) +++ trunk/x10.compiler/src/x10/types/ParametrizedType_c.java 2010-01-25 09:28:34 UTC (rev 12699) @@ -82,7 +82,7 @@ return t; } - public boolean safe() { + public boolean isSafe() { return true; } Added: trunk/x10.compiler/src/x10/types/Proto.java =================================================================== --- trunk/x10.compiler/src/x10/types/Proto.java (rev 0) +++ trunk/x10.compiler/src/x10/types/Proto.java 2010-01-25 09:28:34 UTC (rev 12699) @@ -0,0 +1,26 @@ +package x10.types; + +import polyglot.types.Type; + + +/** + * Interface implemented by types that may be proto types, viz ConstrainedType or X10ClassType. + * + * @author vj + * + */ +public interface Proto extends Type { + + boolean isProto(); + + /** + * Return T if this is proto T; else return this. + * @return + */ + Proto baseOfProto(); + + /** + * @return this if this is proto T; else proto this + */ + Proto makeProto(); +} Modified: trunk/x10.compiler/src/x10/types/SubtypeConstraint.java =================================================================== --- trunk/x10.compiler/src/x10/types/SubtypeConstraint.java 2010-01-25 05:46:37 UTC (rev 12698) +++ trunk/x10.compiler/src/x10/types/SubtypeConstraint.java 2010-01-25 09:28:34 UTC (rev 12699) @@ -11,11 +11,10 @@ static int SUBTYPE_KIND=0; // <: static int EQUAL_KIND =1; // == - static int BEHAVES_LIKE_KIND = 2; // <| + boolean isEqualityConstraint(); boolean isSubtypeConstraint(); - boolean isBehavesLikeConstraint(); boolean isKind(int kind); Type subtype(); Modified: trunk/x10.compiler/src/x10/types/SubtypeConstraint_c.java =================================================================== --- trunk/x10.compiler/src/x10/types/SubtypeConstraint_c.java 2010-01-25 05:46:37 UTC (rev 12698) +++ trunk/x10.compiler/src/x10/types/SubtypeConstraint_c.java 2010-01-25 09:28:34 UTC (rev 12699) @@ -40,9 +40,7 @@ public boolean isSubtypeConstraint() { return KIND==SubtypeConstraint.SUBTYPE_KIND; } - public boolean isBehavesLikeConstraint() { - return KIND==SubtypeConstraint.BEHAVES_LIKE_KIND; - } + public boolean isKind(int k) { return k==KIND;} public int kind() { return KIND;} Modified: trunk/x10.compiler/src/x10/types/TypeConstraint_c.java =================================================================== --- trunk/x10.compiler/src/x10/types/TypeConstraint_c.java 2010-01-25 05:46:37 UTC (rev 12698) +++ trunk/x10.compiler/src/x10/types/TypeConstraint_c.java 2010-01-25 09:28:34 UTC (rev 12699) @@ -78,11 +78,7 @@ return false; } } - else if (t.isBehavesLikeConstraint()) { - if (!xts.behavesLike(t.subtype(), t.supertype(), xc)) { - return false; - } - } + } return true; } Modified: trunk/x10.compiler/src/x10/types/X10ClassType.java =================================================================== --- trunk/x10.compiler/src/x10/types/X10ClassType.java 2010-01-25 05:46:37 UTC (rev 12698) +++ trunk/x10.compiler/src/x10/types/X10ClassType.java 2010-01-25 09:28:34 UTC (rev 12699) @@ -27,42 +27,43 @@ /** The representative of ClassType in the X10 type hierarchy. * * A class is a reference; arrays are examples of references which are not classes. - * (This is inherited from Java. Needs to be fixed in The Great X01 2.0 Type Redesign. * * @author vj * */ -public interface X10ClassType extends ClassType, X10Type, X10Use<X10ClassDef> { +public interface X10ClassType extends ClassType, Proto, X10Struct, X10Use<X10ClassDef> { - /** Property initializers, used in annotations. */ - List<Expr> propertyInitializers(); - Expr propertyInitializer(int i); - X10ClassType propertyInitializers(List<Expr> inits); - - boolean isIdentityInstantiation(); - - /** - * The list of properties of the class. - * @return - */ - List<FieldInstance> properties(); + /** Property initializers, used in annotations. */ + List<Expr> propertyInitializers(); + Expr propertyInitializer(int i); + X10ClassType propertyInitializers(List<Expr> inits); - /** - * The sublist of properties defined at this class. - * All and exactly the properties in this list need to be - * set in each constructor using a property(...) construct. - * @return - */ - List<FieldInstance> definedProperties(); + boolean isIdentityInstantiation(); - List<Type> typeArguments(); - X10ClassType typeArguments(List<Type> typeArgs); - - boolean hasParams(); - List<Type> typeMembers(); + /** + * The list of properties of the class. + * @return + */ + List<FieldInstance> properties(); - MacroType typeMemberMatching(Matcher<Named> matcher); - - boolean isJavaType(); + /** + * The sublist of properties defined at this class. + * All and exactly the properties in this list need to be + * set in each constructor using a property(...) construct. + * @return + */ + List<FieldInstance> definedProperties(); + List<Type> typeArguments(); + X10ClassType typeArguments(List<Type> typeArgs); + + boolean hasParams(); + List<Type> typeMembers(); + + MacroType typeMemberMatching(Matcher<Named> matcher); + + boolean isJavaType(); + + + } Modified: trunk/x10.compiler/src/x10/types/X10ConstructorDef_c.java =================================================================== --- trunk/x10.compiler/src/x10/types/X10ConstructorDef_c.java 2010-01-25 05:46:37 UTC (rev 12698) +++ trunk/x10.compiler/src/x10/types/X10ConstructorDef_c.java 2010-01-25 09:28:34 UTC (rev 12699) @@ -31,7 +31,7 @@ /** * An X10ConstructorDef_c varies from a ConstructorDef_c only in that it - * maintains a returnType. Note that in X10 2.0 the returnType is rooted. + * maintains a returnType. * * If an explicit returnType is not declared in the constructor * then the returnType is simply a noClause variant of the container. Modified: trunk/x10.compiler/src/x10/types/X10FieldInstance.java =================================================================== --- trunk/x10.compiler/src/x10/types/X10FieldInstance.java 2010-01-25 05:46:37 UTC (rev 12698) +++ trunk/x10.compiler/src/x10/types/X10FieldInstance.java 2010-01-25 09:28:34 UTC (rev 12699) @@ -13,6 +13,7 @@ import polyglot.types.Type; import x10.constraint.XConstraint; +import polyglot.types.TypeObject; /** * Represents information about a Property. A property has the same * attributes as a Field, except that it is always public, instance and final @@ -20,7 +21,7 @@ * @author vj * */ -public interface X10FieldInstance extends FieldInstance, X10TypeObject, X10Use<X10FieldDef> { +public interface X10FieldInstance extends FieldInstance, TypeObject, X10Use<X10FieldDef> { public static final String MAGIC_PROPERTY_NAME = "propertyNames$"; public static final String MAGIC_CI_PROPERTY_NAME = "classInvariant$"; Modified: trunk/x10.compiler/src/x10/types/X10Flags.java =================================================================== --- trunk/x10.compiler/src/x10/types/X10Flags.java 2010-01-25 05:46:37 UTC (rev 12698) +++ trunk/x10.compiler/src/x10/types/X10Flags.java 2010-01-25 09:28:34 UTC (rev 12699) @@ -40,6 +40,7 @@ // public static final Flags ROOTED = createFlag("rooted", null); public static final Flags STRUCT = createFlag("struct", null); public static final Flags PROTO = createFlag("proto", null); + public static final Flags PINNED = createFlag("pinned", null); /** * Return a new Flags object with a new name. Should be called only once per @@ -67,11 +68,9 @@ * @return */ public static X10Flags toX10Flags(Flags f) { - if (f instanceof X10Flags) - return (X10Flags) f; - X10Flags result = new X10Flags(); - return result.setX(f); - + if (f instanceof X10Flags) + return (X10Flags) f; + return new X10Flags().setX(f == null? Flags.NONE : f); } public static boolean isX10Flag(Flags f) { @@ -349,15 +348,7 @@ return contains(GLOBAL) || contains(PROPERTY); } - - /** - * Return true if <code>this</code> has the <code>global</code> flag set. - */ - public boolean isRooted() { - return ! contains(GLOBAL); - } - /** * Return a copy of this <code>this</code> with the <code>struct</code> flag * set. */ @@ -588,6 +579,38 @@ } /** + * Return a copy of this <code>this</code> with the <code>pinned</code> + * flag set. + * + * @param flags + * TODO + */ + public X10Flags Pinned() { + return setX(PINNED); + } + + /** + * Return a copy of this <code>this</code> with the <code>pinned</code> + * flag clear. + * + * @param flags + * TODO + */ + public X10Flags clearPinned() { + return clearX(PINNED); + } + + /** + * Return true if <code>this</code> has the <code>pinned</code> flag + * set. + * + * @param flags + * TODO + */ + public boolean isPinned() { + return contains(PINNED); + } + /** * Return "" if no flags set, or toString() + " " if some flags are set. */ public String translate() { Modified: trunk/x10.compiler/src/x10/types/X10LocalInstance.java =================================================================== --- trunk/x10.compiler/src/x10/types/X10LocalInstance.java 2010-01-25 05:46:37 UTC (rev 12698) +++ trunk/x10.compiler/src/x10/types/X10LocalInstance.java 2010-01-25 09:28:34 UTC (rev 12699) @@ -12,12 +12,13 @@ import polyglot.types.LocalInstance; import polyglot.types.Type; +import polyglot.types.TypeObject; /** * @author vj * */ -public interface X10LocalInstance extends LocalInstance, X10TypeObject, X10Use<X10LocalDef> { +public interface X10LocalInstance extends LocalInstance, TypeObject, X10Use<X10LocalDef> { /** Type of the local with self==FI. */ Type rightType(); } Modified: trunk/x10.compiler/src/x10/types/X10MethodInstance_c.java =================================================================== --- trunk/x10.compiler/src/x10/types/X10MethodInstance_c.java 2010-01-25 05:46:37 UTC (rev 12698) +++ trunk/x10.compiler/src/x10/types/X10MethodInstance_c.java 2010-01-25 09:28:34 UTC (rev 12699) @@ -155,7 +155,7 @@ ConstrainedType ct = (ConstrainedType) o; return transform(Types.get(ct.baseType())); } - return ((X10Type) o); + return o; } } @@ -354,15 +354,15 @@ } return false; } - public boolean isSafe() { + /* public boolean isSafe() { StructType container = this.container(); assert container instanceof X10ParsedClassType : container + " for " + this; - boolean result = ((X10ParsedClassType) container).safe(); + boolean result = ((X10ParsedClassType) container).isSafe(); if (result) return true; X10Flags f = X10Flags.toX10Flags(flags()); result = f.isSafe(); return result; - } + }*/ protected static String myListToString(List l) { StringBuffer sb = new StringBuffer(); @@ -1279,6 +1279,9 @@ return xthis; } + public boolean isSafe() { + return X10Flags.toX10Flags(flags()).isSafe(); + } static private String toString( XVar[] ys) { String s = ""; for (XVar x : ys) s += x.toString() + " "; Modified: trunk/x10.compiler/src/x10/types/X10NamedType.java =================================================================== --- trunk/x10.compiler/src/x10/types/X10NamedType.java 2010-01-25 05:46:37 UTC (rev 12698) +++ trunk/x10.compiler/src/x10/types/X10NamedType.java 2010-01-25 09:28:34 UTC (rev 12699) @@ -12,8 +12,9 @@ * Examples of such types are X10PrimitiveTypes, X10ParsedClassTypes, X10ArrayTypes. */ import polyglot.types.Named; +import polyglot.types.Type; -public interface X10NamedType extends Named, X10Type { +public interface X10NamedType extends Named, Type { } Modified: trunk/x10.compiler/src/x10/types/X10NullType.java =================================================================== --- trunk/x10.compiler/src/x10/types/X10NullType.java 2010-01-25 05:46:37 UTC (rev 12698) +++ trunk/x10.compiler/src/x10/types/X10NullType.java 2010-01-25 09:28:34 UTC (rev 12699) @@ -18,6 +18,6 @@ /** * @author vj */ -public interface X10NullType extends X10Type, NullType { +public interface X10NullType extends NullType { } Modified: trunk/x10.compiler/src/x10/types/X10NullType_c.java =================================================================== --- trunk/x10.compiler/src/x10/types/X10NullType_c.java 2010-01-25 05:46:37 UTC (rev 12698) +++ trunk/x10.compiler/src/x10/types/X10NullType_c.java 2010-01-25 09:28:34 UTC (rev 12699) @@ -13,38 +13,26 @@ import polyglot.ast.FlagsNode; import polyglot.types.Flags; +import polyglot.types.Type; import polyglot.types.NullType_c; import polyglot.types.TypeSystem; import polyglot.util.InternalCompilerError; /** Every X10 term must have a type. This is the type of the X10 term null. + * * Note that there is no X10 type called Null; only the term null. + * + * Extends Polyglot's NullType_c with methods necessary for X10Type. * @author vj * */ public class X10NullType_c extends NullType_c implements X10NullType { public X10NullType_c( TypeSystem ts ) {super(ts);} - public boolean safe() { return true;} - - public Flags flags() { - return Flags.NONE; - } - public X10Type setFlags(Flags flags) { - assert false : "Cannot set flags on X10NullType"; - throw new InternalCompilerError("Cannot set flags on X10NullType."); - - } - public X10Type clearFlags(Flags f) { - return this; - } - public String toString() { - return "null"; - } + public boolean isSafe() { return true;} public boolean isRooted() { return false; } public boolean isProto() { return false; } public boolean isX10Struct() { return false; } - public boolean equalsNoFlag(X10Type t2) { - return this == t2; - } + public boolean equalsNoFlag(Type t2) { return this == t2; } + public boolean permitsNull() { return true;} } Modified: trunk/x10.compiler/src/x10/types/X10ParsedClassType_c.java =================================================================== --- trunk/x10.compiler/src/x10/types/X10ParsedClassType_c.java 2010-01-25 05:46:37 UTC (rev 12698) +++ trunk/x10.compile... [truncated message content] |
From: <bti...@us...> - 2010-01-26 18:26:10
|
Revision: 12707 http://x10.svn.sourceforge.net/x10/?rev=12707&view=rev Author: btibbitts Date: 2010-01-26 18:25:51 +0000 (Tue, 26 Jan 2010) Log Message: ----------- update to new build scripts Modified Paths: -------------- trunk/x10.common/exportPlugin.xml trunk/x10.compiler/exportPlugin.xml trunk/x10.constraints/exportPlugin.xml trunk/x10.effects/exportPlugin.xml trunk/x10.runtime/exportPlugin.xml Modified: trunk/x10.common/exportPlugin.xml =================================================================== --- trunk/x10.common/exportPlugin.xml 2010-01-26 15:30:43 UTC (rev 12706) +++ trunk/x10.common/exportPlugin.xml 2010-01-26 18:25:51 UTC (rev 12707) @@ -1,29 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <project name="x10.common" default="build.update.jar" basedir="."> - <import file="../org.eclipse.imp.x10dt.feature/buildCommon.xml"/> + <import file="../org.eclipse.imp.x10dt.update/buildCommon.xml"/> <import file="../org.eclipse.imp.x10dt.update/buildPluginCommon.xml"/> - <!-- ================================================================================= --> - - <target name="plugin.jar" depends="init,javaInit,munge.manifest" unless="${plugin.jar.name}" description="Create jar: ${plugin.jar.name}."> - <delete dir="${temp.folder}/${plugin.jar.name}.bin"/> - <mkdir dir="${temp.folder}/${plugin.jar.name}.bin"/> - <!-- compile the source code --> - <javac destdir="${temp.folder}/${plugin.jar.name}.bin" failonerror="${javacFailOnError}" verbose="${javacVerbose}" debug="${javacDebugInfo}" includeAntRuntime="no" bootclasspath="${bootclasspath}" source="${javacSource}" target="${javacTarget}" > - <compilerarg line="${compilerArg}"/> - <classpath> - <pathelement path="${plugin.dependencies}"/> - <pathelement path="${eclipse.build.path}"/> - </classpath> - <src path="src/"/> - </javac> - <!-- Copy necessary resources --> - <copy todir="${temp.folder}/${plugin.jar.name}.bin" failonerror="true" overwrite="false"> - <fileset dir="src/" excludes="**/*.java,**/package.htm*"/> - </copy> - <mkdir dir="${build.result.folder}"/> - <jar destfile="${build.result.folder}/${plugin.jar.name}" basedir="${temp.folder}/${plugin.jar.name}.bin" - manifest="${temp.folder}/MANIFEST.MF"/> - <delete dir="${temp.folder}/${plugin.jar.name}.bin"/> - </target> </project> Modified: trunk/x10.compiler/exportPlugin.xml =================================================================== --- trunk/x10.compiler/exportPlugin.xml 2010-01-26 15:30:43 UTC (rev 12706) +++ trunk/x10.compiler/exportPlugin.xml 2010-01-26 18:25:51 UTC (rev 12707) @@ -1,37 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <project name="x10.compiler" default="build.update.jar" basedir="."> - <import file="../org.eclipse.imp.x10dt.feature/buildCommon.xml"/> + <import file="../org.eclipse.imp.x10dt.update/buildCommon.xml"/> <import file="../org.eclipse.imp.x10dt.update/buildPluginCommon.xml"/> - <!-- ================================================================================= --> - - <target name="plugin.jar" depends="init,javaInit,munge.manifest" unless="${plugin.jar.name}" description="Create jar: ${plugin.jar.name}."> - <delete dir="${temp.folder}/${plugin.jar.name}.bin"/> - <mkdir dir="${temp.folder}/${plugin.jar.name}.bin"/> - <!-- compile the source code --> - <javac destdir="${temp.folder}/${plugin.jar.name}.bin" failonerror="${javacFailOnError}" verbose="${javacVerbose}" debug="${javacDebugInfo}" includeAntRuntime="no" bootclasspath="${bootclasspath}" source="${javacSource}" target="${javacTarget}"> - <compilerarg line="${compilerArg}"/> - <classpath> - <pathelement path="${plugin.dependencies}"/> - <pathelement path="${eclipse.build.path}"/> - </classpath> - <src path="src/"/> - </javac> - <!-- Copy necessary resources --> - <mkdir dir="${temp.folder}/${plugin.jar.name}.bin/data"/> - <copy todir="${temp.folder}/${plugin.jar.name}.bin/data" failonerror="true" overwrite="false"> - <fileset dir="data" includes="**/*"/> - </copy> - <mkdir dir="${temp.folder}/${plugin.jar.name}.bin/etc"/> - <copy todir="${temp.folder}/${plugin.jar.name}.bin/etc" failonerror="true" overwrite="false"> - <fileset dir="etc" includes="**/*.cfg"/> - </copy> - <copy todir="${temp.folder}/${plugin.name}.jar.bin" failonerror="true" overwrite="false"> - <fileset dir="src/" excludes="**/*.java,**/package.htm*"/> - </copy> - <mkdir dir="${build.result.folder}"/> - <jar destfile="${build.result.folder}/${plugin.jar.name}" basedir="${temp.folder}/${plugin.jar.name}.bin" - manifest="${temp.folder}/MANIFEST.MF"/> - <delete dir="${temp.folder}/${plugin.jar.name}.bin"/> - </target> </project> Modified: trunk/x10.constraints/exportPlugin.xml =================================================================== --- trunk/x10.constraints/exportPlugin.xml 2010-01-26 15:30:43 UTC (rev 12706) +++ trunk/x10.constraints/exportPlugin.xml 2010-01-26 18:25:51 UTC (rev 12707) @@ -1,29 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <project name="x10.constraints" default="build.update.jar" basedir="."> - <import file="../org.eclipse.imp.x10dt.feature/buildCommon.xml"/> + <import file="../org.eclipse.imp.x10dt.update/buildCommon.xml"/> <import file="../org.eclipse.imp.x10dt.update/buildPluginCommon.xml"/> - <!-- ================================================================================= --> - - <target name="plugin.jar" depends="init,javaInit,munge.manifest" unless="${plugin.jar.name}" description="Create jar: ${plugin.jar.name}."> - <delete dir="${temp.folder}/${plugin.jar.name}.bin"/> - <mkdir dir="${temp.folder}/${plugin.jar.name}.bin"/> - <!-- compile the source code --> - <javac destdir="${temp.folder}/${plugin.jar.name}.bin" failonerror="${javacFailOnError}" verbose="${javacVerbose}" debug="${javacDebugInfo}" includeAntRuntime="no" bootclasspath="${bootclasspath}" source="${javacSource}" target="${javacTarget}" > - <compilerarg line="${compilerArg}"/> - <classpath> - <pathelement path="${plugin.dependencies}"/> - <pathelement path="${eclipse.build.path}"/> - </classpath> - <src path="src/"/> - </javac> - <!-- Copy necessary resources --> - <copy todir="${temp.folder}/${plugin.jar.name}.bin" failonerror="true" overwrite="false"> - <fileset dir="src/" excludes="**/*.java,**/package.htm*"/> - </copy> - <mkdir dir="${build.result.folder}"/> - <jar destfile="${build.result.folder}/${plugin.jar.name}" basedir="${temp.folder}/${plugin.jar.name}.bin" - manifest="${temp.folder}/MANIFEST.MF"/> - <delete dir="${temp.folder}/${plugin.jar.name}.bin"/> - </target> </project> Modified: trunk/x10.effects/exportPlugin.xml =================================================================== --- trunk/x10.effects/exportPlugin.xml 2010-01-26 15:30:43 UTC (rev 12706) +++ trunk/x10.effects/exportPlugin.xml 2010-01-26 18:25:51 UTC (rev 12707) @@ -1,31 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <project name="x10.effects" default="build.update.jar" basedir="."> - <import file="../org.eclipse.imp.x10dt.feature/buildCommon.xml"/> + <import file="../org.eclipse.imp.x10dt.update/buildCommon.xml"/> <import file="../org.eclipse.imp.x10dt.update/buildPluginCommon.xml"/> - <!-- ================================================================================= --> - - <target name="plugin.jar" depends="init,javaInit,munge.manifest" unless="${plugin.jar.name}" description="Create jar: ${plugin.jar.name}."> - <delete dir="${temp.folder}/${plugin.jar.name}.bin"/> - <mkdir dir="${temp.folder}/${plugin.jar.name}.bin"/> - <!-- compile the source code --> - <javac destdir="${temp.folder}/${plugin.jar.name}.bin" failonerror="${javacFailOnError}" verbose="${javacVerbose}" debug="${javacDebugInfo}" includeAntRuntime="no" bootclasspath="${bootclasspath}" source="1.5" target="1.5"> - <compilerarg line="${compilerArg}"/> - <classpath> - <pathelement path="${plugin.dependencies}"/> - <pathelement path="${eclipse.build.path}"/> - </classpath> - <src path="src/"/> - </javac> - <!-- Copy necessary resources --> - <echo message="copying resources"/> - <copy todir="${temp.folder}/${plugin.jar.name}.bin" failonerror="true" overwrite="false"> - <fileset dir="src/" excludes="**/*.java,**/package.htm*"/> - </copy> - <echo message="done copying resources"/> - <mkdir dir="${build.result.folder}"/> - <jar destfile="${build.result.folder}/${plugin.jar.name}" basedir="${temp.folder}/${plugin.jar.name}.bin" - manifest="${temp.folder}/MANIFEST.MF"/> - <delete dir="${temp.folder}/${plugin.jar.name}.bin"/> - </target> </project> Modified: trunk/x10.runtime/exportPlugin.xml =================================================================== --- trunk/x10.runtime/exportPlugin.xml 2010-01-26 15:30:43 UTC (rev 12706) +++ trunk/x10.runtime/exportPlugin.xml 2010-01-26 18:25:51 UTC (rev 12707) @@ -1,11 +1,11 @@ <?xml version="1.0" encoding="UTF-8"?> <project name="x10.runtime" default="build.update.jar" basedir="."> - <import file="../org.eclipse.imp.x10dt.feature/buildCommon.xml"/> + <import file="../org.eclipse.imp.x10dt.update/buildCommon.xml"/> <import file="../org.eclipse.imp.x10dt.update/buildPluginCommon.xml"/> <!-- ================================================================================= --> - + <!-- BRT: is this left here explicitly? --> <target name="plugin.jar" depends="init,javaInit,munge.manifest" unless="${plugin.jar.name}" description="Create jar: ${plugin.jar.name}."> <delete dir="${temp.folder}/${plugin.jar.name}.bin"/> <mkdir dir="${temp.folder}/${plugin.jar.name}.bin"/> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dgr...@us...> - 2010-01-27 17:01:44
|
Revision: 12750 http://x10.svn.sourceforge.net/x10/?rev=12750&view=rev Author: dgrove-oss Date: 2010-01-27 17:01:38 +0000 (Wed, 27 Jan 2010) Log Message: ----------- Intorduce an explicit C++ level class to stand for the NullType instead of using x10::lang::Reference. This enables us to get an RTT object for the NullType while still maintaining the useful implementation invariant that there is no RTT for x10::lang::Reference because it does not exist at the X10 level. Modified Paths: -------------- trunk/x10.compiler/src/x10cpp/visit/Emitter.java trunk/x10.runtime/src-cpp/x10/lang/Reference.cc trunk/x10.runtime/src-cpp/x10/lang/Reference.h trunk/x10.runtime/src-cpp/x10aux/ref.h Modified: trunk/x10.compiler/src/x10cpp/visit/Emitter.java =================================================================== --- trunk/x10.compiler/src/x10cpp/visit/Emitter.java 2010-01-27 16:36:04 UTC (rev 12749) +++ trunk/x10.compiler/src/x10cpp/visit/Emitter.java 2010-01-27 17:01:38 UTC (rev 12750) @@ -301,7 +301,7 @@ name = ((ParameterType)type).name().toString(); return mangled_parameter_type_name(name); // parameter types shouldn't be refs } else if (type.isNull()) { - return "x10aux::NullType"; // typedef to something sensible + return "x10aux::ref<x10::lang::NullType>"; // typedef to something sensible } else assert false : type; // unhandled type. assert (name != null); Modified: trunk/x10.runtime/src-cpp/x10/lang/Reference.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Reference.cc 2010-01-27 16:36:04 UTC (rev 12749) +++ trunk/x10.runtime/src-cpp/x10/lang/Reference.cc 2010-01-27 17:01:38 UTC (rev 12750) @@ -40,4 +40,10 @@ } } +x10aux::RuntimeType x10::lang::NullType::rtt; + +void x10::lang::NullType::_initRTT() { + rtt.init(&rtt, "null", 0, NULL, 0, NULL, NULL); +} + // vim:tabstop=4:shiftwidth=4:expandtab Modified: trunk/x10.runtime/src-cpp/x10/lang/Reference.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Reference.h 2010-01-27 16:36:04 UTC (rev 12749) +++ trunk/x10.runtime/src-cpp/x10/lang/Reference.h 2010-01-27 17:01:38 UTC (rev 12750) @@ -116,6 +116,20 @@ " (expecting id " << id << ") from buf: "<<&buf); return x10aux::DeserializationDispatcher::create<T>(buf); } + + /** + * This is a class that exists only at the C++ implementation level, + * not at the X10 language level. It's only real purpose is to + * provide a C++ level type for x10aux::NullType and therefore permit + * a unique RTT object to be associated with the X10 value null. + * + * This is an abstract class because no instance of it will ever be + * created (we use NULL as the value for X10's null). + */ + class NullType : public Reference { + public: + RTT_H_DECLS_CLASS; + }; } } Modified: trunk/x10.runtime/src-cpp/x10aux/ref.h =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/ref.h 2010-01-27 16:36:04 UTC (rev 12749) +++ trunk/x10.runtime/src-cpp/x10aux/ref.h 2010-01-27 17:01:38 UTC (rev 12750) @@ -9,7 +9,7 @@ #include <x10aux/RTT.h> #include <x10aux/network.h> -namespace x10 { namespace lang { class Reference; } } +namespace x10 { namespace lang { class NullType; } } namespace x10aux { @@ -181,9 +181,8 @@ return obj; } - // will be initialised to null - typedef ref<x10::lang::Reference> NullType; - static NullType null; + // will be initialised to NULL + static ref<x10::lang::NullType> null; template<class F, class T> bool operator!=(F f, T t) { return !(f == t); } // comparison of a primitive with a ref This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <spa...@us...> - 2010-01-28 20:45:31
|
Revision: 12763 http://x10.svn.sourceforge.net/x10/?rev=12763&view=rev Author: sparksparkspark Date: 2010-01-28 20:45:24 +0000 (Thu, 28 Jan 2010) Log Message: ----------- Olivier wanted ByRef Modified Paths: -------------- trunk/x10.compiler/src/x10cpp/visit/Emitter.java Added Paths: ----------- trunk/x10.runtime/src-x10/x10/compiler/ByRef.x10 Modified: trunk/x10.compiler/src/x10cpp/visit/Emitter.java =================================================================== --- trunk/x10.compiler/src/x10cpp/visit/Emitter.java 2010-01-28 20:08:30 UTC (rev 12762) +++ trunk/x10.compiler/src/x10cpp/visit/Emitter.java 2010-01-28 20:45:24 UTC (rev 12763) @@ -586,6 +586,20 @@ // h.write("const "); printType(n.type().type(), h); h.write(" "); + X10TypeSystem xts = (X10TypeSystem) tr.typeSystem(); + Type param_type = n.type().type(); + param_type = X10TypeMixin.baseType(param_type); + if (param_type instanceof X10ClassType) { + X10ClassType c = (X10ClassType)param_type; + if (c.isX10Struct()) { + try { + Type annotation = (Type) xts.systemResolver().find(QName.make("x10.compiler.ByRef")); + if (!c.annotationsMatching(annotation).isEmpty()) h.write("&"); + } catch (SemanticException e) { + assert false : e; + } + } + } h.write(mangled_non_method_name(n.name().id().toString())); h.end(); } Added: trunk/x10.runtime/src-x10/x10/compiler/ByRef.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/compiler/ByRef.x10 (rev 0) +++ trunk/x10.runtime/src-x10/x10/compiler/ByRef.x10 2010-01-28 20:45:24 UTC (rev 12763) @@ -0,0 +1,15 @@ +/* + * + * (C) Copyright IBM Corporation 2006-2008. + * + * This file is part of X10 Language. + * + */ + +package x10.compiler; + +/** An annotation on a struct that instructs the C++ backend to pass instances + * of this struct by reference and not value. + * @author Dave Cunningham + */ +public interface ByRef { }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dgr...@us...> - 2010-01-28 21:44:02
|
Revision: 12766 http://x10.svn.sourceforge.net/x10/?rev=12766&view=rev Author: dgrove-oss Date: 2010-01-28 21:43:55 +0000 (Thu, 28 Jan 2010) Log Message: ----------- Fix a number of problems related to the C++ backend's RTT infrastructure. (1) Change initialization protocol for RTTs to eliminate a variety of race conditions that could result in partially initialized RTT objects being returned from the getRTT function. (2) Construct the name() of parameterized RTTs lazily instead of eagerly. This eliminates CYCLIC_RTT ever being shown as the name() of an RTT. (3) Fix the order of covariant/contravariant declrations in the various initRTT routines of Run.cc so that it matches the order of type parameters (args, then return). (4) Add special case to subtypeOf so that NullType will be treated as a subtype of any type that is a subtype of Object. (5) Fix bug in itable initialization for Closures to ensure that the closure RTT is actually initialized. The combination of these changes is enough to get the HPCC RA benchmark running again. Modified Paths: -------------- trunk/x10.compiler/src/x10cpp/visit/Emitter.java trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java trunk/x10.runtime/src-cpp/x10/lang/Any.cc trunk/x10.runtime/src-cpp/x10/lang/Fun.cc trunk/x10.runtime/src-cpp/x10/lang/Fun_0_0.h trunk/x10.runtime/src-cpp/x10/lang/Fun_0_1.h trunk/x10.runtime/src-cpp/x10/lang/Fun_0_2.h trunk/x10.runtime/src-cpp/x10/lang/Fun_0_3.h trunk/x10.runtime/src-cpp/x10/lang/Fun_0_4.h trunk/x10.runtime/src-cpp/x10/lang/Fun_0_5.h trunk/x10.runtime/src-cpp/x10/lang/Fun_0_6.h trunk/x10.runtime/src-cpp/x10/lang/Fun_0_7.h trunk/x10.runtime/src-cpp/x10/lang/Fun_0_8.h trunk/x10.runtime/src-cpp/x10/lang/Fun_0_9.h trunk/x10.runtime/src-cpp/x10/lang/PlaceLocalHandle_Impl.cc trunk/x10.runtime/src-cpp/x10/lang/PlaceLocalHandle_Impl.struct_h trunk/x10.runtime/src-cpp/x10/lang/Rail.cc trunk/x10.runtime/src-cpp/x10/lang/Rail.h trunk/x10.runtime/src-cpp/x10/lang/Reference.cc trunk/x10.runtime/src-cpp/x10/lang/Struct.cc trunk/x10.runtime/src-cpp/x10/lang/ValRail.cc trunk/x10.runtime/src-cpp/x10/lang/ValRail.h trunk/x10.runtime/src-cpp/x10/lang/VoidFun_0_1.h trunk/x10.runtime/src-cpp/x10/lang/VoidFun_0_2.h trunk/x10.runtime/src-cpp/x10/lang/VoidFun_0_3.h trunk/x10.runtime/src-cpp/x10/lang/VoidFun_0_4.h trunk/x10.runtime/src-cpp/x10/lang/VoidFun_0_5.h trunk/x10.runtime/src-cpp/x10/lang/VoidFun_0_6.h trunk/x10.runtime/src-cpp/x10/lang/VoidFun_0_7.h trunk/x10.runtime/src-cpp/x10/lang/VoidFun_0_8.h trunk/x10.runtime/src-cpp/x10/lang/VoidFun_0_9.h trunk/x10.runtime/src-cpp/x10/util/GrowableRail.cc trunk/x10.runtime/src-cpp/x10/util/GrowableRail.h trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicReference.cc trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicReference.h trunk/x10.runtime/src-cpp/x10aux/RTT.cc trunk/x10.runtime/src-cpp/x10aux/RTT.h Modified: trunk/x10.compiler/src/x10cpp/visit/Emitter.java =================================================================== --- trunk/x10.compiler/src/x10cpp/visit/Emitter.java 2010-01-28 20:48:10 UTC (rev 12765) +++ trunk/x10.compiler/src/x10cpp/visit/Emitter.java 2010-01-28 21:43:55 UTC (rev 12766) @@ -625,7 +625,6 @@ boolean first = true; h.write("x10aux::RuntimeType "+translateType(ct)+"::rtt;"); h.newline(); h.write("void "+translateType(ct)+"::_initRTT() {"); h.newline(4); h.begin(0); - h.write("rtt.canonical = &rtt;"); h.newline(); if (numParents > 0) { h.write("const x10aux::RuntimeType* parents["+numParents+"] = { "); if (ct.superClass() != null) { @@ -655,7 +654,6 @@ printTemplateSignature(ct.typeArguments(), h); h.write("void "+translateType(ct)+"::_initRTT() {"); h.newline(4); h.begin(0); - h.write("rtt.canonical = &rtt;"); h.newline(); if (numParents > 0) { h.write("const x10aux::RuntimeType* parents["+numParents+"] = { "); if (ct.superClass() != null) { @@ -697,18 +695,8 @@ h.write("const x10aux::RuntimeType *canonical = x10aux::getRTT"+chevrons(translateType(MessagePassingCodeGenerator.getStaticMemberContainer(ct),false))+"();"); h.newline(); - h.write("const char *name = "); h.newline(4); - h.write("x10aux::alloc_printf("); h.begin(0); - h.write("\""+x10name+"["); - for (int i=0; i<numTypeParams; i++) { - h.write(i > 0 ? ",%s" : "%s"); - } - h.write("]\""); - for (int i=0; i<numTypeParams; i++) { - h.write(", params["+i+"]->name()"); h.newline(); - } - h.write(");") ; h.end(); h.newline(); - h.write("rtt.init(canonical, name, "+numParents+", parents, "+numTypeParams+", params, variances);"); h.end(); h.newline(); + h.write("const char *baseName = \""+x10name+"\";"); h.newline(); + h.write("rtt.init(canonical, baseName, "+numParents+", parents, "+numTypeParams+", params, variances);"); h.end(); h.newline(); h.write("}"); h.newline(); } h.newline(); Modified: trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java =================================================================== --- trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java 2010-01-28 20:48:10 UTC (rev 12765) +++ trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java 2010-01-28 21:43:55 UTC (rev 12766) @@ -4037,16 +4037,9 @@ if (in_template_closure) emitter.printTemplateSignature(freeTypeParams, inc); inc.write("x10aux::itable_entry "+cnamet+"::_itables[2] = {"); - inc.write("x10aux::itable_entry(&"+superType+"::rtt, &"+cnamet+"::_itable),"); + inc.write("x10aux::itable_entry(x10aux::getRTT"+chevrons(superType)+"(), &"+cnamet+"::_itable),"); inc.write("x10aux::itable_entry(NULL, NULL)};"); inc.newline(); - /* - if (in_template_closure) - emitter.printTemplateSignature(freeTypeParams, inc); - inc.write("x10aux::RuntimeType * "+cnamet+"::rtt = const_cast<x10aux::RuntimeType *>(x10aux::getRTT"+chevrons(superType)+"());"); - inc.newline(); inc.forceNewline(); - */ - generateClosureDeserializationIdDef(inc, cnamet, freeTypeParams, hostClassName, n.body()); if (in_template_closure) { Modified: trunk/x10.runtime/src-cpp/x10/lang/Any.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Any.cc 2010-01-28 20:48:10 UTC (rev 12765) +++ trunk/x10.runtime/src-cpp/x10/lang/Any.cc 2010-01-28 21:43:55 UTC (rev 12766) @@ -6,7 +6,6 @@ x10aux::RuntimeType x10::lang::Any::rtt; void x10::lang::Any::_initRTT() { - rtt.canonical = &(Any::rtt); rtt.init(&rtt, "x10.lang.Any", 0, NULL, 0, NULL, NULL); } Modified: trunk/x10.runtime/src-cpp/x10/lang/Fun.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Fun.cc 2010-01-28 20:48:10 UTC (rev 12765) +++ trunk/x10.runtime/src-cpp/x10/lang/Fun.cc 2010-01-28 21:43:55 UTC (rev 12766) @@ -53,7 +53,6 @@ void VoidFun_0_0::_initRTT() { - rtt.canonical = &(VoidFun_0_0::rtt); rtt.init(&rtt, "x10::lang::VoidFun_0_0", 0, NULL, 0, NULL, NULL); } @@ -62,17 +61,15 @@ const RuntimeType* params[1] = { rtt0 }; RuntimeType::Variance variances[1] = { RuntimeType::covariant }; const RuntimeType* canonical = getRTT<Fun_0_0<void> >(); - const char *name = alloc_printf("x10.lang.Fun_0_0[%s]",rtt0->name()); - location->init(canonical, name, 0, NULL, 1, params, variances); + location->init(canonical, "x10.lang.Fun_0_0", 0, NULL, 1, params, variances); } void _initRTTHelper_Fun_0_1(RuntimeType *location, const RuntimeType *rtt0, const RuntimeType *rtt1) { const RuntimeType* params[2] = { rtt0, rtt1 }; - RuntimeType::Variance variances[2] = { RuntimeType::covariant, RuntimeType::contravariant }; + RuntimeType::Variance variances[2] = { RuntimeType::contravariant, RuntimeType::covariant }; const RuntimeType* canonical = getRTT<Fun_0_1<void, void> >(); - const char *name = alloc_printf("x10.lang.Fun_0_1[%s,%s]", rtt0->name(), rtt1->name()); - location->init(canonical, name, 0, NULL, 2, params, variances); + location->init(canonical, "x10.lang.Fun_0_1", 0, NULL, 2, params, variances); } void @@ -81,11 +78,9 @@ const RuntimeType *rtt1, const RuntimeType *rtt2) { const RuntimeType* params[3] = { rtt0, rtt1, rtt2 }; - RuntimeType::Variance variances[] = { RuntimeType::covariant, RuntimeType::contravariant, RuntimeType::contravariant }; - const char *name = alloc_printf("x10.lang.Fun_0_2[%s,%s,%s]", - rtt0->name(), rtt1->name(), rtt2->name()); + RuntimeType::Variance variances[] = { RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::covariant }; const RuntimeType* canonical = getRTT<Fun_0_2<void, void, void> >(); - location->init(canonical, name, 0, NULL, 3, params, variances); + location->init(canonical, "x10.lang.Fun_0_2", 0, NULL, 3, params, variances); } void @@ -95,11 +90,9 @@ const RuntimeType *rtt2, const RuntimeType *rtt3) { const RuntimeType* params[4] = { rtt0, rtt1, rtt2, rtt3 }; - RuntimeType::Variance variances[4] = { RuntimeType::covariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant }; - const char *name = alloc_printf("x10.lang.Fun_0_3[%s,%s,%s,%s]", - rtt0->name(), rtt1->name(), rtt2->name(), rtt3->name()); + RuntimeType::Variance variances[4] = { RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::covariant }; const RuntimeType* canonical = getRTT<Fun_0_3<void, void, void, void> >(); - location->init(canonical, name, 0, NULL, 4, params, variances); + location->init(canonical, "x10.lang.Fun_0_3", 0, NULL, 4, params, variances); } void @@ -110,11 +103,9 @@ const RuntimeType *rtt3, const RuntimeType *rtt4) { const RuntimeType* params[5] = { rtt0, rtt1, rtt2, rtt3, rtt4 }; - RuntimeType::Variance variances[5] = { RuntimeType::covariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant }; + RuntimeType::Variance variances[5] = { RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::covariant }; const RuntimeType* canonical = getRTT<Fun_0_4<void, void, void, void, void> >(); - const char *name = alloc_printf("x10.lang.Fun_0_4[%s,%s,%s,%s,%s]", - rtt0->name(), rtt1->name(), rtt2->name(), rtt3->name(), rtt4->name()); - location->init(canonical, name, 0, NULL, 5, params, variances); + location->init(canonical, "x10.lang.Fun_0_4", 0, NULL, 5, params, variances); } void @@ -126,13 +117,10 @@ const RuntimeType *rtt4, const RuntimeType *rtt5) { const RuntimeType* params[6] = { rtt0, rtt1, rtt2, rtt3, rtt4, rtt5 }; - RuntimeType::Variance variances[6] = { RuntimeType::covariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, - RuntimeType::contravariant }; + RuntimeType::Variance variances[6] = { RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, + RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::covariant }; const RuntimeType* canonical = getRTT<Fun_0_5<void, void, void, void, void, void> >(); - const char *name = alloc_printf("x10.lang.Fun_0_5[%s,%s,%s,%s,%s,%s]", - rtt0->name(), rtt1->name(), rtt2->name(), rtt3->name(), - rtt4->name(), rtt5->name()); - location->init(canonical, name, 0, NULL, 6, params, variances); + location->init(canonical, "x10.lang.Fun_0_5", 0, NULL, 6, params, variances); } void @@ -145,13 +133,11 @@ const RuntimeType *rtt5, const RuntimeType *rtt6) { const RuntimeType* params[7] = { rtt0, rtt1, rtt2, rtt3, rtt4, rtt5, rtt6 }; - RuntimeType::Variance variances[7] = { RuntimeType::covariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, - RuntimeType::contravariant, RuntimeType::contravariant }; + RuntimeType::Variance variances[7] = { RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, + RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, + RuntimeType::covariant }; const RuntimeType* canonical = getRTT<Fun_0_6<void, void, void, void, void, void, void> >(); - const char *name = alloc_printf("x10.lang.Fun_0_6[%s,%s,%s,%s,%s,%s,%s]", - rtt0->name(), rtt1->name(), rtt2->name(), rtt3->name(), - rtt4->name(), rtt5->name(), rtt6->name()); - location->init(canonical, name, 0, NULL, 7, params, variances); + location->init(canonical, "x10.lang.Fun_0_6", 0, NULL, 7, params, variances); } void @@ -165,13 +151,11 @@ const RuntimeType *rtt6, const RuntimeType *rtt7) { const RuntimeType* params[8] = { rtt0, rtt1, rtt2, rtt3, rtt4, rtt5, rtt6, rtt7 }; - RuntimeType::Variance variances[8] = { RuntimeType::covariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, - RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant }; + RuntimeType::Variance variances[8] = { RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, + RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, + RuntimeType::contravariant, RuntimeType::covariant }; const RuntimeType* canonical = getRTT<Fun_0_7<void, void, void, void, void, void, void, void> >(); - const char *name = alloc_printf("x10.lang.Fun_0_7[%s,%s,%s,%s,%s,%s,%s,%s]", - rtt0->name(), rtt1->name(), rtt2->name(), rtt3->name(), - rtt4->name(), rtt5->name(), rtt6->name(), rtt7->name()); - location->init(canonical, name, 0, NULL, 8, params, variances); + location->init(canonical, "x10.lang.Fun_0_7", 0, NULL, 8, params, variances); } void @@ -186,13 +170,11 @@ const RuntimeType *rtt7, const RuntimeType *rtt8) { const RuntimeType* params[9] = { rtt0, rtt1, rtt2, rtt3, rtt4, rtt5, rtt6, rtt7, rtt8 }; - RuntimeType::Variance variances[9] = { RuntimeType::covariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, - RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant }; + RuntimeType::Variance variances[9] = { RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, + RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, + RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::covariant }; const RuntimeType* canonical = getRTT<Fun_0_8<void, void, void, void, void, void, void, void, void> >(); - const char *name = alloc_printf("x10.lang.Fun_0_8[%s,%s,%s,%s,%s,%s,%s,%s,%s]", - rtt0->name(), rtt1->name(), rtt2->name(), rtt3->name(), - rtt4->name(), rtt5->name(), rtt6->name(), rtt7->name(), rtt8->name()); - location->init(canonical, name, 0, NULL, 9, params, variances); + location->init(canonical, "x10.lang.Fun_0_8", 0, NULL, 9, params, variances); } void @@ -208,13 +190,12 @@ const RuntimeType *rtt8, const RuntimeType *rtt9) { const RuntimeType* params[10] = { rtt0, rtt1, rtt2, rtt3, rtt4, rtt5, rtt6, rtt7, rtt8, rtt9 }; - RuntimeType::Variance variances[10] = { RuntimeType::covariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, - RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant }; + RuntimeType::Variance variances[10] = { RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, + RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, + RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, + RuntimeType::covariant }; const RuntimeType* canonical = getRTT<Fun_0_9<void, void, void, void, void, void, void, void, void, void> >(); - const char *name = alloc_printf("x10.lang.Fun_0_9[%s,%s,%s,%s,%s,%s,%s,%s,%s,%s]", - rtt0->name(), rtt1->name(), rtt2->name(), rtt3->name(), - rtt4->name(), rtt5->name(), rtt6->name(), rtt7->name(), rtt8->name(), rtt9->name()); - location->init(canonical, name, 0, NULL, 10, params, variances); + location->init(canonical, "x10.lang.Fun_0_9", 0, NULL, 10, params, variances); } void @@ -222,8 +203,7 @@ const RuntimeType* params[1] = { rtt1 }; RuntimeType::Variance variances[] = { RuntimeType::contravariant }; const RuntimeType* canonical = getRTT<VoidFun_0_1<void> >(); - const char *name = alloc_printf("x10.lang.VoidFun_0_1[%s]", rtt1->name()); - location->init(canonical, name, 0, NULL, 1, params, variances); + location->init(canonical, "x10.lang.VoidFun_0_1", 0, NULL, 1, params, variances); } void @@ -233,9 +213,7 @@ const RuntimeType* params[2] = { rtt1, rtt2 }; RuntimeType::Variance variances[2] = { RuntimeType::contravariant, RuntimeType::contravariant }; const RuntimeType* canonical = getRTT<VoidFun_0_2<void, void> >(); - const char *name = alloc_printf("x10.lang.VoidFun_0_2[%s,%s]", - rtt1->name(), rtt2->name()); - location->init(canonical, name, 0, NULL, 2, params, variances); + location->init(canonical, "x10.lang.VoidFun_0_2", 0, NULL, 2, params, variances); } void @@ -246,9 +224,7 @@ const RuntimeType* params[3] = { rtt1, rtt2, rtt3 }; RuntimeType::Variance variances[3] = { RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant }; const RuntimeType* canonical = getRTT<VoidFun_0_3<void, void, void> >(); - const char *name = alloc_printf("x10.lang.VoidFun_0_3[%s,%s,%s]", - rtt1->name(), rtt2->name(), rtt3->name()); - location->init(canonical, name, 0, NULL, 3, params, variances); + location->init(canonical, "x10.lang.VoidFun_0_3", 0, NULL, 3, params, variances); } void @@ -260,9 +236,7 @@ const RuntimeType* params[4] = { rtt1, rtt2, rtt3, rtt4 }; RuntimeType::Variance variances[4] = { RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant }; const RuntimeType* canonical = getRTT<VoidFun_0_4<void, void, void, void> >(); - const char *name = alloc_printf("x10.lang.VoidFun_0_4[%s,%s,%s,%s]", - rtt1->name(), rtt2->name(), rtt3->name(), rtt4->name()); - location->init(canonical, name, 0, NULL, 4, params, variances); + location->init(canonical, "x10.lang.VoidFun_0_4", 0, NULL, 4, params, variances); } void @@ -275,10 +249,7 @@ const RuntimeType* params[5] = { rtt1, rtt2, rtt3, rtt4, rtt5 }; RuntimeType::Variance variances[5] = { RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant }; const RuntimeType* canonical = getRTT<VoidFun_0_5<void, void, void, void, void> >(); - const char *name = alloc_printf("x10.lang.VoidFun_0_5[%s,%s,%s,%s,%s]", - rtt1->name(), rtt2->name(), rtt3->name(), - rtt4->name(), rtt5->name()); - location->init(canonical, name, 0, NULL, 5, params, variances); + location->init(canonical, "x10.lang.VoidFun_0_5", 0, NULL, 5, params, variances); } void @@ -293,10 +264,7 @@ RuntimeType::Variance variances[6] = { RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant }; const RuntimeType* canonical = getRTT<VoidFun_0_6<void, void, void, void, void, void> >(); - const char *name = alloc_printf("x10.lang.VoidFun_0_6[%s,%s,%s,%s,%s,%s]", - rtt1->name(), rtt2->name(), rtt3->name(), - rtt4->name(), rtt5->name(), rtt6->name()); - location->init(canonical, name, 0, NULL, 6, params, variances); + location->init(canonical, "x10.lang.VoidFun_0_6", 0, NULL, 6, params, variances); } void @@ -312,10 +280,7 @@ RuntimeType::Variance variances[7] = { RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant }; const RuntimeType* canonical = getRTT<VoidFun_0_7<void, void, void, void, void, void, void> >(); - const char *name = alloc_printf("x10.lang.VoidFun_0_7[%s,%s,%s,%s,%s,%s,%s]", - rtt1->name(), rtt2->name(), rtt3->name(), - rtt4->name(), rtt5->name(), rtt6->name(), rtt7->name()); - location->init(canonical, name, 0, NULL, 7, params, variances); + location->init(canonical, "x10.lang.VoidFun_0_7", 0, NULL, 7, params, variances); } void @@ -332,11 +297,7 @@ RuntimeType::Variance variances[8] = { RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant }; const RuntimeType* canonical = getRTT<VoidFun_0_8<void, void, void, void, void, void, void, void> >(); - const char *name = alloc_printf("x10.lang.VoidFun_0_8[%s,%s,%s,%s,%s,%s,%s,%s]", - rtt1->name(), rtt2->name(), rtt3->name(), - rtt4->name(), rtt5->name(), rtt6->name(), - rtt7->name(), rtt8->name()); - location->init(canonical, name, 0, NULL, 8, params, variances); + location->init(canonical, "x10.lang.VoidFun_0_8", 0, NULL, 8, params, variances); } void @@ -354,11 +315,7 @@ RuntimeType::Variance variances[9] = { RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant }; const RuntimeType* canonical = getRTT<VoidFun_0_9<void, void, void, void, void, void, void, void, void> >(); - const char *name = alloc_printf("x10.lang.VoidFun_0_9[%s,%s,%s,%s,%s,%s,%s,%s,%s]", - rtt1->name(), rtt2->name(), rtt3->name(), - rtt4->name(), rtt5->name(), rtt6->name(), - rtt7->name(), rtt8->name(), rtt9->name()); - location->init(canonical, name, 0, NULL, 9, params, variances); + location->init(canonical, "x10.lang.VoidFun_0_9", 0, NULL, 9, params, variances); } } } Modified: trunk/x10.runtime/src-cpp/x10/lang/Fun_0_0.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Fun_0_0.h 2010-01-28 20:48:10 UTC (rev 12765) +++ trunk/x10.runtime/src-cpp/x10/lang/Fun_0_0.h 2010-01-28 21:43:55 UTC (rev 12766) @@ -38,7 +38,6 @@ }; template<class R> void Fun_0_0<R>::_initRTT() { - rtt.canonical = &rtt; x10::lang::_initRTTHelper_Fun_0_0(&rtt, x10aux::getRTT<R>()); } Modified: trunk/x10.runtime/src-cpp/x10/lang/Fun_0_1.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Fun_0_1.h 2010-01-28 20:48:10 UTC (rev 12765) +++ trunk/x10.runtime/src-cpp/x10/lang/Fun_0_1.h 2010-01-28 21:43:55 UTC (rev 12766) @@ -40,7 +40,6 @@ }; template<class P1, class R> void Fun_0_1<P1,R>::_initRTT() { - rtt.canonical = &rtt; x10::lang::_initRTTHelper_Fun_0_1(&rtt, x10aux::getRTT<P1>(), x10aux::getRTT<R>()); } Modified: trunk/x10.runtime/src-cpp/x10/lang/Fun_0_2.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Fun_0_2.h 2010-01-28 20:48:10 UTC (rev 12765) +++ trunk/x10.runtime/src-cpp/x10/lang/Fun_0_2.h 2010-01-28 21:43:55 UTC (rev 12766) @@ -41,7 +41,6 @@ }; template<class P1, class P2, class R> void Fun_0_2<P1,P2,R>::_initRTT() { - rtt.canonical = &rtt; x10::lang::_initRTTHelper_Fun_0_2(&rtt, x10aux::getRTT<P1>(), x10aux::getRTT<P2>(), x10aux::getRTT<R>()); } Modified: trunk/x10.runtime/src-cpp/x10/lang/Fun_0_3.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Fun_0_3.h 2010-01-28 20:48:10 UTC (rev 12765) +++ trunk/x10.runtime/src-cpp/x10/lang/Fun_0_3.h 2010-01-28 21:43:55 UTC (rev 12766) @@ -42,7 +42,6 @@ }; template<class P1, class P2, class P3, class R> void Fun_0_3<P1,P2,P3,R>::_initRTT() { - rtt.canonical = &rtt; x10::lang::_initRTTHelper_Fun_0_3(&rtt, x10aux::getRTT<P1>(), x10aux::getRTT<P2>(), x10aux::getRTT<P3>(), x10aux::getRTT<R>()); } Modified: trunk/x10.runtime/src-cpp/x10/lang/Fun_0_4.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Fun_0_4.h 2010-01-28 20:48:10 UTC (rev 12765) +++ trunk/x10.runtime/src-cpp/x10/lang/Fun_0_4.h 2010-01-28 21:43:55 UTC (rev 12766) @@ -44,7 +44,6 @@ template<class P1, class P2, class P3, class P4, class R> void Fun_0_4<P1,P2,P3,P4,R>::_initRTT() { - rtt.canonical = &rtt; x10::lang::_initRTTHelper_Fun_0_4(&rtt, x10aux::getRTT<P1>(), x10aux::getRTT<P2>(), x10aux::getRTT<P3>(), x10aux::getRTT<P4>(), x10aux::getRTT<R>()); Modified: trunk/x10.runtime/src-cpp/x10/lang/Fun_0_5.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Fun_0_5.h 2010-01-28 20:48:10 UTC (rev 12765) +++ trunk/x10.runtime/src-cpp/x10/lang/Fun_0_5.h 2010-01-28 21:43:55 UTC (rev 12766) @@ -45,7 +45,6 @@ template<class P1, class P2, class P3, class P4, class P5, class R> void Fun_0_5<P1,P2,P3,P4,P5,R>::_initRTT() { - rtt.canonical = &rtt; x10::lang::_initRTTHelper_Fun_0_5(&rtt, x10aux::getRTT<P1>(), x10aux::getRTT<P2>(), x10aux::getRTT<P3>(), x10aux::getRTT<P4>(), x10aux::getRTT<P5>(), x10aux::getRTT<R>()); Modified: trunk/x10.runtime/src-cpp/x10/lang/Fun_0_6.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Fun_0_6.h 2010-01-28 20:48:10 UTC (rev 12765) +++ trunk/x10.runtime/src-cpp/x10/lang/Fun_0_6.h 2010-01-28 21:43:55 UTC (rev 12766) @@ -46,7 +46,6 @@ template<class P1, class P2, class P3, class P4, class P5, class P6, class R> void Fun_0_6<P1,P2,P3,P4,P5,P6,R>::_initRTT() { - rtt.canonical = &rtt; x10::lang::_initRTTHelper_Fun_0_6(&rtt, x10aux::getRTT<P1>(), x10aux::getRTT<P2>(), x10aux::getRTT<P3>(), x10aux::getRTT<P4>(), x10aux::getRTT<P5>(), x10aux::getRTT<P6>(), Modified: trunk/x10.runtime/src-cpp/x10/lang/Fun_0_7.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Fun_0_7.h 2010-01-28 20:48:10 UTC (rev 12765) +++ trunk/x10.runtime/src-cpp/x10/lang/Fun_0_7.h 2010-01-28 21:43:55 UTC (rev 12766) @@ -46,7 +46,6 @@ template<class P1, class P2, class P3, class P4, class P5, class P6, class P7, class R> void Fun_0_7<P1,P2,P3,P4,P5,P6,P7,R>::_initRTT() { - rtt.canonical = &rtt; x10::lang::_initRTTHelper_Fun_0_7(&rtt, x10aux::getRTT<P1>(), x10aux::getRTT<P2>(), x10aux::getRTT<P3>(), x10aux::getRTT<P4>(), x10aux::getRTT<P5>(), x10aux::getRTT<P6>(), Modified: trunk/x10.runtime/src-cpp/x10/lang/Fun_0_8.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Fun_0_8.h 2010-01-28 20:48:10 UTC (rev 12765) +++ trunk/x10.runtime/src-cpp/x10/lang/Fun_0_8.h 2010-01-28 21:43:55 UTC (rev 12766) @@ -47,7 +47,6 @@ template<class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class R> void Fun_0_8<P1,P2,P3,P4,P5,P6,P7,P8,R>::_initRTT() { - rtt.canonical = &rtt; x10::lang::_initRTTHelper_Fun_0_8(&rtt, x10aux::getRTT<P1>(), x10aux::getRTT<P2>(), x10aux::getRTT<P3>(), x10aux::getRTT<P4>(), x10aux::getRTT<P5>(), x10aux::getRTT<P6>(), Modified: trunk/x10.runtime/src-cpp/x10/lang/Fun_0_9.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Fun_0_9.h 2010-01-28 20:48:10 UTC (rev 12765) +++ trunk/x10.runtime/src-cpp/x10/lang/Fun_0_9.h 2010-01-28 21:43:55 UTC (rev 12766) @@ -48,7 +48,6 @@ template<class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9, class R> void Fun_0_9<P1,P2,P3,P4,P5,P6,P7,P8,P9,R>::_initRTT() { - rtt.canonical = &rtt; x10::lang::_initRTTHelper_Fun_0_9(&rtt, x10aux::getRTT<P1>(), x10aux::getRTT<P2>(), x10aux::getRTT<P3>(), x10aux::getRTT<P4>(), x10aux::getRTT<P5>(), x10aux::getRTT<P6>(), Modified: trunk/x10.runtime/src-cpp/x10/lang/PlaceLocalHandle_Impl.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/PlaceLocalHandle_Impl.cc 2010-01-28 20:48:10 UTC (rev 12765) +++ trunk/x10.runtime/src-cpp/x10/lang/PlaceLocalHandle_Impl.cc 2010-01-28 21:43:55 UTC (rev 12766) @@ -17,8 +17,7 @@ const RuntimeType* params[1] = { rtt }; RuntimeType::Variance variances[1] = { RuntimeType::invariant }; const RuntimeType *canonical = x10aux::getRTT<PlaceLocalHandle_Impl<void> >(); - const char *name = alloc_printf("x10.lang.PlaceLocalHandle_Impl[+%s]",rtt->name()); - location->init(canonical, name, 0, NULL, 1, params, variances); + location->init(canonical, "x10.lang.PlaceLocalHandle_Impl", 0, NULL, 1, params, variances); } } } Modified: trunk/x10.runtime/src-cpp/x10/lang/PlaceLocalHandle_Impl.struct_h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/PlaceLocalHandle_Impl.struct_h 2010-01-28 20:48:10 UTC (rev 12765) +++ trunk/x10.runtime/src-cpp/x10/lang/PlaceLocalHandle_Impl.struct_h 2010-01-28 21:43:55 UTC (rev 12766) @@ -67,7 +67,6 @@ }; template<class T> void PlaceLocalHandle_Impl<T>::_initRTT() { - rtt.canonical = &rtt; x10::lang::_initRTTHelper_PlaceLocalHandle_Impl(&rtt, x10aux::getRTT<T>()); } Modified: trunk/x10.runtime/src-cpp/x10/lang/Rail.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Rail.cc 2010-01-28 20:48:10 UTC (rev 12765) +++ trunk/x10.runtime/src-cpp/x10/lang/Rail.cc 2010-01-28 21:43:55 UTC (rev 12766) @@ -21,8 +21,7 @@ const RuntimeType *params[1] = { element }; RuntimeType::Variance variances[1] = { RuntimeType::invariant }; const RuntimeType *canonical = x10aux::getRTT<Rail<void> >(); - const char *name = alloc_printf("x10.lang.Rail[%s]", element->name()); - location->init(canonical, name, 3, parents, 1, params, variances); + location->init(canonical, "x10.lang.Rail", 3, parents, 1, params, variances); } } } Modified: trunk/x10.runtime/src-cpp/x10/lang/Rail.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Rail.h 2010-01-28 20:48:10 UTC (rev 12765) +++ trunk/x10.runtime/src-cpp/x10/lang/Rail.h 2010-01-28 21:43:55 UTC (rev 12766) @@ -216,7 +216,6 @@ namespace lang { template<class T> void Rail<T>::_initRTT() { - rtt.canonical = &rtt; x10::lang::_initRTTHelper_Rail(&rtt, x10aux::getRTT<T>(), x10aux::getRTT<Settable<x10_int,T> >(), x10aux::getRTT<Iterable<T> >()); Modified: trunk/x10.runtime/src-cpp/x10/lang/Reference.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Reference.cc 2010-01-28 20:48:10 UTC (rev 12765) +++ trunk/x10.runtime/src-cpp/x10/lang/Reference.cc 2010-01-28 21:43:55 UTC (rev 12766) @@ -43,7 +43,7 @@ x10aux::RuntimeType x10::lang::NullType::rtt; void x10::lang::NullType::_initRTT() { - rtt.init(&rtt, "null", 0, NULL, 0, NULL, NULL); + rtt.init(&rtt, "Null", 0, NULL, 0, NULL, NULL); } // vim:tabstop=4:shiftwidth=4:expandtab Modified: trunk/x10.runtime/src-cpp/x10/lang/Struct.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Struct.cc 2010-01-28 20:48:10 UTC (rev 12765) +++ trunk/x10.runtime/src-cpp/x10/lang/Struct.cc 2010-01-28 21:43:55 UTC (rev 12766) @@ -26,7 +26,6 @@ RuntimeType Struct::rtt; void Struct::_initRTT() { - rtt.canonical = &rtt; rtt.init(&rtt, "x10.lang.Struct", 0, NULL, 0, NULL, NULL); } Modified: trunk/x10.runtime/src-cpp/x10/lang/ValRail.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/ValRail.cc 2010-01-28 20:48:10 UTC (rev 12765) +++ trunk/x10.runtime/src-cpp/x10/lang/ValRail.cc 2010-01-28 21:43:55 UTC (rev 12766) @@ -19,8 +19,7 @@ const RuntimeType *params[1] = { element }; RuntimeType::Variance variances[1] = { RuntimeType::covariant }; const RuntimeType *canonical = x10aux::getRTT<ValRail<void> >(); - const char *name = alloc_printf("x10.lang.ValRail[+%s]", element->name()); - location->init(canonical, name, 3, parents, 1, params, variances); + location->init(canonical, "x10.lang.ValRail", 3, parents, 1, params, variances); } } } Modified: trunk/x10.runtime/src-cpp/x10/lang/ValRail.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/ValRail.h 2010-01-28 20:48:10 UTC (rev 12765) +++ trunk/x10.runtime/src-cpp/x10/lang/ValRail.h 2010-01-28 21:43:55 UTC (rev 12766) @@ -111,7 +111,6 @@ ::addDeserializer(ValRail<T>::template _deserializer<Object>); template<class T> void ValRail<T>::_initRTT() { - rtt.canonical = &rtt; x10::lang::_initRTTHelper_ValRail(&rtt, x10aux::getRTT<T>(), x10aux::getRTT<Fun_0_1<x10_int,T> >(), x10aux::getRTT<Iterable<T> >()); Modified: trunk/x10.runtime/src-cpp/x10/lang/VoidFun_0_1.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/VoidFun_0_1.h 2010-01-28 20:48:10 UTC (rev 12765) +++ trunk/x10.runtime/src-cpp/x10/lang/VoidFun_0_1.h 2010-01-28 21:43:55 UTC (rev 12766) @@ -39,7 +39,6 @@ }; template<class P1> void VoidFun_0_1<P1>::_initRTT() { - rtt.canonical = &rtt; x10::lang::_initRTTHelper_VoidFun_0_1(&rtt, x10aux::getRTT<P1>()); } Modified: trunk/x10.runtime/src-cpp/x10/lang/VoidFun_0_2.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/VoidFun_0_2.h 2010-01-28 20:48:10 UTC (rev 12765) +++ trunk/x10.runtime/src-cpp/x10/lang/VoidFun_0_2.h 2010-01-28 21:43:55 UTC (rev 12766) @@ -40,7 +40,6 @@ }; template<class P1, class P2> void VoidFun_0_2<P1,P2>::_initRTT() { - rtt.canonical = &rtt; x10::lang::_initRTTHelper_VoidFun_0_2(&rtt, x10aux::getRTT<P1>(), x10aux::getRTT<P2>()); } Modified: trunk/x10.runtime/src-cpp/x10/lang/VoidFun_0_3.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/VoidFun_0_3.h 2010-01-28 20:48:10 UTC (rev 12765) +++ trunk/x10.runtime/src-cpp/x10/lang/VoidFun_0_3.h 2010-01-28 21:43:55 UTC (rev 12766) @@ -41,7 +41,6 @@ }; template<class P1, class P2, class P3> void VoidFun_0_3<P1,P2,P3>::_initRTT() { - rtt.canonical = &rtt; x10::lang::_initRTTHelper_VoidFun_0_3(&rtt, x10aux::getRTT<P1>(), x10aux::getRTT<P2>(), x10aux::getRTT<P3>()); } Modified: trunk/x10.runtime/src-cpp/x10/lang/VoidFun_0_4.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/VoidFun_0_4.h 2010-01-28 20:48:10 UTC (rev 12765) +++ trunk/x10.runtime/src-cpp/x10/lang/VoidFun_0_4.h 2010-01-28 21:43:55 UTC (rev 12766) @@ -43,7 +43,6 @@ template<class P1, class P2, class P3, class P4> void VoidFun_0_4<P1,P2,P3,P4>::_initRTT() { - rtt.canonical = &rtt; x10::lang::_initRTTHelper_VoidFun_0_4(&rtt, x10aux::getRTT<P1>(), x10aux::getRTT<P2>(), x10aux::getRTT<P3>(), x10aux::getRTT<P4>()); } Modified: trunk/x10.runtime/src-cpp/x10/lang/VoidFun_0_5.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/VoidFun_0_5.h 2010-01-28 20:48:10 UTC (rev 12765) +++ trunk/x10.runtime/src-cpp/x10/lang/VoidFun_0_5.h 2010-01-28 21:43:55 UTC (rev 12766) @@ -44,7 +44,6 @@ template<class P1, class P2, class P3, class P4, class P5> void VoidFun_0_5<P1,P2,P3,P4,P5>::_initRTT() { - rtt.canonical = &rtt; x10::lang::_initRTTHelper_VoidFun_0_5(&rtt, x10aux::getRTT<P1>(), x10aux::getRTT<P2>(), x10aux::getRTT<P3>(), x10aux::getRTT<P4>(), x10aux::getRTT<P5>()); Modified: trunk/x10.runtime/src-cpp/x10/lang/VoidFun_0_6.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/VoidFun_0_6.h 2010-01-28 20:48:10 UTC (rev 12765) +++ trunk/x10.runtime/src-cpp/x10/lang/VoidFun_0_6.h 2010-01-28 21:43:55 UTC (rev 12766) @@ -45,7 +45,6 @@ template<class P1, class P2, class P3, class P4, class P5, class P6> void VoidFun_0_6<P1,P2,P3,P4,P5,P6>::_initRTT() { - rtt.canonical = &rtt; x10::lang::_initRTTHelper_VoidFun_0_6(&rtt, x10aux::getRTT<P1>(), x10aux::getRTT<P2>(), x10aux::getRTT<P3>(), x10aux::getRTT<P4>(), x10aux::getRTT<P5>(), x10aux::getRTT<P6>()); Modified: trunk/x10.runtime/src-cpp/x10/lang/VoidFun_0_7.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/VoidFun_0_7.h 2010-01-28 20:48:10 UTC (rev 12765) +++ trunk/x10.runtime/src-cpp/x10/lang/VoidFun_0_7.h 2010-01-28 21:43:55 UTC (rev 12766) @@ -46,7 +46,6 @@ template<class P1, class P2, class P3, class P4, class P5, class P6, class P7> void VoidFun_0_7<P1,P2,P3,P4,P5,P6,P7>::_initRTT() { - rtt.canonical = &rtt; x10::lang::_initRTTHelper_VoidFun_0_7(&rtt, x10aux::getRTT<P1>(), x10aux::getRTT<P2>(), x10aux::getRTT<P3>(), x10aux::getRTT<P4>(), x10aux::getRTT<P5>(), x10aux::getRTT<P6>(), Modified: trunk/x10.runtime/src-cpp/x10/lang/VoidFun_0_8.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/VoidFun_0_8.h 2010-01-28 20:48:10 UTC (rev 12765) +++ trunk/x10.runtime/src-cpp/x10/lang/VoidFun_0_8.h 2010-01-28 21:43:55 UTC (rev 12766) @@ -47,7 +47,6 @@ template<class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8> void VoidFun_0_8<P1,P2,P3,P4,P5,P6,P7,P8>::_initRTT() { - rtt.canonical = &rtt; x10::lang::_initRTTHelper_VoidFun_0_8(&rtt, x10aux::getRTT<P1>(), x10aux::getRTT<P2>(), x10aux::getRTT<P3>(), x10aux::getRTT<P4>(), x10aux::getRTT<P5>(), x10aux::getRTT<P6>(), Modified: trunk/x10.runtime/src-cpp/x10/lang/VoidFun_0_9.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/VoidFun_0_9.h 2010-01-28 20:48:10 UTC (rev 12765) +++ trunk/x10.runtime/src-cpp/x10/lang/VoidFun_0_9.h 2010-01-28 21:43:55 UTC (rev 12766) @@ -48,7 +48,6 @@ template<class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9> void VoidFun_0_9<P1,P2,P3,P4,P5,P6,P7,P8,P9>::_initRTT() { - rtt.canonical = &rtt; x10::lang::_initRTTHelper_VoidFun_0_9(&rtt, x10aux::getRTT<P1>(), x10aux::getRTT<P2>(), x10aux::getRTT<P3>(), x10aux::getRTT<P4>(), x10aux::getRTT<P5>(), x10aux::getRTT<P6>(), Modified: trunk/x10.runtime/src-cpp/x10/util/GrowableRail.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/util/GrowableRail.cc 2010-01-28 20:48:10 UTC (rev 12765) +++ trunk/x10.runtime/src-cpp/x10/util/GrowableRail.cc 2010-01-28 21:43:55 UTC (rev 12766) @@ -19,8 +19,7 @@ const RuntimeType* params[1] = { element }; RuntimeType::Variance variances[1] = { RuntimeType::invariant }; const RuntimeType *canonical = x10aux::getRTT<GrowableRail<void> >(); - const char *name = alloc_printf("x10.lang.GrowableRail[%s]", element->name()); - location->init(canonical, name, 1, parents, 1, params, variances); + location->init(canonical, "x10.lang.GrowableRail", 1, parents, 1, params, variances); } } } Modified: trunk/x10.runtime/src-cpp/x10/util/GrowableRail.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/util/GrowableRail.h 2010-01-28 20:48:10 UTC (rev 12765) +++ trunk/x10.runtime/src-cpp/x10/util/GrowableRail.h 2010-01-28 21:43:55 UTC (rev 12766) @@ -176,7 +176,6 @@ template<class T> x10_int GrowableRail<T>::size() { return _array->FMGL(length); } template<class T> void GrowableRail<T>::_initRTT() { - rtt.canonical = &rtt; x10::util::_initRTTHelper_GrowableRail(&rtt, x10aux::getRTT<T>()); } Modified: trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicReference.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicReference.cc 2010-01-28 20:48:10 UTC (rev 12765) +++ trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicReference.cc 2010-01-28 21:43:55 UTC (rev 12766) @@ -21,8 +21,7 @@ const RuntimeType* params[1] = { rtt }; RuntimeType::Variance variances[1] = { RuntimeType::invariant }; const RuntimeType *canonical = x10aux::getRTT<AtomicReference<void> >(); - const char *name = alloc_printf("x10.util.concurrent.atomic.AtomicReference[%s]",rtt->name()); - location->init(canonical, name, 1, parents, 1, params, variances); + location->init(canonical, "x10.util.concurrent.atomic.AtomicReference", 1, parents, 1, params, variances); } } } Modified: trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicReference.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicReference.h 2010-01-28 20:48:10 UTC (rev 12765) +++ trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicReference.h 2010-01-28 21:43:55 UTC (rev 12766) @@ -123,7 +123,6 @@ } template<class T> void AtomicReference<T>::_initRTT() { - rtt.canonical = &rtt; x10::util::concurrent::atomic::_initRTTHelper_AtomicReference(&rtt, x10aux::getRTT<T>()); } Modified: trunk/x10.runtime/src-cpp/x10aux/RTT.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/RTT.cc 2010-01-28 20:48:10 UTC (rev 12765) +++ trunk/x10.runtime/src-cpp/x10aux/RTT.cc 2010-01-28 21:43:55 UTC (rev 12766) @@ -4,18 +4,42 @@ #include <x10aux/atomic_ops.h> #include <x10/lang/Reference.h> +#include <x10/lang/Lock__ReentrantLock.h> #include <cstdarg> using namespace x10aux; using namespace x10::lang; +const char *RuntimeType::name() const { + if (NULL == fullTypeName) { + assert(paramsc > 0); // if paramssc == 0, then fullTypeName is set to baseName in initRTT(); + std::ostringstream ss; + ss << baseName; + ss << "["; + for (int i=0; i<paramsc; i++) { + if (i>0) ss << ", "; + ss << params[i]->name(); + } + ss << "]"; + const_cast<RuntimeType*>(this)->fullTypeName = ss.str().c_str(); + } + + return fullTypeName; +} + bool RuntimeType::subtypeOf(const RuntimeType * const other) const { // Checks to try to catch partially initialized RTT objects before we use them. - assert(canonical != NULL); - assert(other->canonical != NULL); + assert(isInitialized); + assert(other->isInitialized); if (equals(other)) return true; // trivial case + + // the NullType should be considered a subtype of any type that extends x10.lang.Object. + if (equals(getRTT<x10::lang::NullType>())) { + if (other->subtypeOf(getRTT<x10::lang::Object>())) return true; + } + if (paramsc > 0 && canonical->equals(other->canonical)) { // Different instances of the same generic type (since canonical is equal). // this->subtypeOf(other) will be true exactly when the type parameters @@ -58,12 +82,33 @@ return other->_type()->equals(this); } -void RuntimeType::init(const RuntimeType *canonical_, const char* typeName_, +void RuntimeType::init(const RuntimeType *canonical_, const char* baseName_, int parentsc_, const RuntimeType** parents_, int paramsc_, const RuntimeType** params_, Variance* variances_) { + // Ensure that at most one thread is doing any RTT initialization at a time. + // This is overkill, since many RTT's have nothing to do with each other and + // RTT initialization is idempotent. However, we want to make sure that if + // a thread asks for an RTT, it gets a fully initialized RTT before it starts + // operating on it and we don't get a race with multiple threads partially + // initializing an RTT. + while (initRTTLock.isNull()) { + ref<x10::lang::Lock__ReentrantLock> tmpLock = x10::lang::Lock__ReentrantLock::_make(); + x10aux::atomic_ops::store_load_barrier(); + atomic_ops::compareAndSet_ptr((volatile void**)(&initRTTLock), NULL, tmpLock.operator->()); + } + initRTTLock->lock(); + + if (canonical != NULL) { + if (isInitialized) return; // another thread finished the job while this thread was blocked on initRTTLock. + // We should only get here if there is a cyclic intialization in progress. + // We don't have a 100% foolproof way to be sure that is what is happening, so + // just hope that is what is happening and return. + return; + } + canonical = canonical_; - typeName = typeName_; + baseName = baseName_; parentsc = parentsc_; paramsc = paramsc_; containsPtrs = true; // TODO: Eventually the compiler should analyze structs and where possible set containsPtrs for their RTT's to false. @@ -85,8 +130,12 @@ } else { params = NULL; variances = NULL; + fullTypeName = baseName; } + x10aux::atomic_ops::store_load_barrier(); + isInitialized = true; // must come after the store_load_barrier + initRTTLock->lock(); } void RuntimeType::initBooleanType() { @@ -151,4 +200,6 @@ RuntimeType RuntimeType::UIntType; RuntimeType RuntimeType::ULongType; +x10aux::ref<x10::lang::Lock__ReentrantLock> RuntimeType::initRTTLock; + // vim:tabstop=4:shiftwidth=4:expandtab Modified: trunk/x10.runtime/src-cpp/x10aux/RTT.h =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/RTT.h 2010-01-28 20:48:10 UTC (rev 12765) +++ trunk/x10.runtime/src-cpp/x10aux/RTT.h 2010-01-28 21:43:55 UTC (rev 12766) @@ -2,28 +2,28 @@ #define X10AUX_RTT_H #include <x10aux/config.h> +#include <assert.h> /* Macro to use in class declaration for boilerplate RTT junk */ #define RTT_H_DECLS_CLASS \ static x10aux::RuntimeType rtt; \ - static const x10aux::RuntimeType* getRTT() { if (NULL == rtt.canonical) _initRTT(); return &rtt; } \ + static const x10aux::RuntimeType* getRTT() { if (!rtt.isInitialized) _initRTT(); return &rtt; } \ static void _initRTT(); \ virtual const x10aux::RuntimeType *_type() const { return getRTT(); } #define RTT_H_DECLS_STRUCT \ static x10aux::RuntimeType rtt; \ - static const x10aux::RuntimeType* getRTT() { if (NULL == rtt.canonical) _initRTT(); return &rtt; } \ + static const x10aux::RuntimeType* getRTT() { if (!rtt.isInitialized) _initRTT(); return &rtt; } \ static void _initRTT(); \ #define RTT_H_DECLS_INTERFACE \ static x10aux::RuntimeType rtt; \ - static const x10aux::RuntimeType* getRTT() { if (NULL == rtt.canonical) _initRTT(); return &rtt; } \ + static const x10aux::RuntimeType* getRTT() { if (!rtt.isInitialized) _initRTT(); return &rtt; } \ static void _initRTT(); #define RTT_CC_DECLS1(TYPE,NAME,P1) \ x10aux::RuntimeType TYPE::rtt; \ void TYPE::_initRTT() { \ - rtt.canonical = &(TYPE::rtt); \ const x10aux::RuntimeType* parents[1] = {P1::getRTT()}; \ rtt.init(&rtt, NAME, 1, parents, 0, NULL, NULL); \ } @@ -31,6 +31,7 @@ namespace x10 { namespace lang { class Reference; + class Lock__ReentrantLock; } } @@ -39,6 +40,9 @@ template<class T> class ref; class RuntimeType { + private: + static x10aux::ref<x10::lang::Lock__ReentrantLock> initRTTLock; + public: /* * RTT objects for all builtin primitive types. @@ -62,19 +66,19 @@ const RuntimeType *canonical; int parentsc; int paramsc; - bool containsPtrs; + bool containsPtrs; + bool isInitialized; const RuntimeType **parents; const RuntimeType **params; Variance *variances; - const char* typeName; + const char* fullTypeName; + const char* baseName; - void init(const RuntimeType* canonical_, const char* typeName_, + void init(const RuntimeType* canonical_, const char* baseName_, int parsentsc_, const RuntimeType** parents_, int paramsc_, const RuntimeType** params_, Variance* variances_); - // TODO: If we constructed the names lazily instead of passing the fully - // constructed char* to init, then I think we could completely avoid this problem. - const char *name() const { return NULL == typeName ? "CYCLIC RTT" : typeName; } + const char *name() const; bool subtypeOf(const RuntimeType * const other) const; @@ -117,73 +121,73 @@ } // specializations of getRTT template for primitive types template<> inline const x10aux::RuntimeType *getRTT<x10_boolean>() { - if (NULL == x10aux::RuntimeType::BooleanType.canonical) { + if (!x10aux::RuntimeType::BooleanType.isInitialized) { x10aux::RuntimeType::initBooleanType(); } return &x10aux::RuntimeType::BooleanType; } template<> inline const x10aux::RuntimeType *getRTT<x10_byte>() { - if (NULL == x10aux::RuntimeType::ByteType.canonical) { + if (!x10aux::RuntimeType::ByteType.isInitialized) { x10aux::RuntimeType::initByteType(); } return &x10aux::RuntimeType::ByteType; } template<> inline const x10aux::RuntimeType *getRTT<x10_char>() { - if (NULL == x10aux::RuntimeType::CharType.canonical) { + if (!x10aux::RuntimeType::CharType.isInitialized) { x10aux::RuntimeType::initCharType(); } return &x10aux::RuntimeType::CharType; } template<> inline const x10aux::RuntimeType *getRTT<x10_short>() { - if (NULL == x10aux::RuntimeType::ShortType.canonical) { + if (!x10aux::RuntimeType::ShortType.isInitialized) { x10aux::RuntimeType::initShortType(); } return &x10aux::RuntimeType::ShortType; } template<> inline const x10aux::RuntimeType *getRTT<x10_int>() { - if (NULL == x10aux::RuntimeType::IntType.canonical) { + if (!x10aux::RuntimeType::IntType.isInitialized) { x10aux::RuntimeType::initIntType(); } return &x10aux::RuntimeType::IntType; } template<> inline const x10aux::RuntimeType *getRTT<x10_float>() { - if (NULL == x10aux::RuntimeType::FloatType.canonical) { + if (!x10aux::RuntimeType::FloatType.isInitialized) { x10aux::RuntimeType::initFloatType(); } return &x10aux::RuntimeType::FloatType; } template<> inline const x10aux::RuntimeType *getRTT<x10_long>() { - if (NULL == x10aux::RuntimeType::LongType.canonical) { + if (!x10aux::RuntimeType::LongType.isInitialized) { x10aux::RuntimeType::initLongType(); } return &x10aux::RuntimeType::LongType; } template<> inline const x10aux::RuntimeType *getRTT<x10_double>() { - if (NULL == x10aux::RuntimeType::DoubleType.canonical) { + if (!x10aux::RuntimeType::DoubleType.isInitialized) { x10aux::RuntimeType::initDoubleType(); } return &x10aux::RuntimeType::DoubleType; } template<> inline const x10aux::RuntimeType *getRTT<x10_ubyte>() { - if (NULL == x10aux::RuntimeType::UByteType.canonical) { + if (!x10aux::RuntimeType::UByteType.isInitialized) { x10aux::RuntimeType::initUByteType(); } return &x10aux::RuntimeType::UByteType; } template<> inline const x10aux::RuntimeType *getRTT<x10_ushort>() { - if (NULL == x10aux::RuntimeType::UShortType.canonical) { + if (!x10aux::RuntimeType::UShortType.isInitialized) { x10aux::RuntimeType::initUShortType(); } return &x10aux::RuntimeType::UShortType; } template<> inline const x10aux::RuntimeType *getRTT<x10_uint>() { - if (NULL == x10aux::RuntimeType::UIntType.canonical) { + if (!x10aux::RuntimeType::UIntType.isInitialized) { x10aux::RuntimeType::initUIntType(); } return &x10aux::RuntimeType::UIntType; } template<> inline const x10aux::RuntimeType *getRTT<x10_ulong>() { - if (NULL == x10aux::RuntimeType::ULongType.canonical) { + if (!x10aux::RuntimeType::ULongType.isInitialized) { x10aux::RuntimeType::initULongType(); } return &x10aux::RuntimeType::ULongType; @@ -192,7 +196,7 @@ // This is different to getRTT because it distinguishes between T and ref<T> template<class T> struct TypeName { static con... [truncated message content] |