From: <ipe...@us...> - 2009-09-30 22:14:23
|
Revision: 11325 http://x10.svn.sourceforge.net/x10/?rev=11325&view=rev Author: ipeshansky Date: 2009-09-30 22:14:16 +0000 (Wed, 30 Sep 2009) Log Message: ----------- Initial fix for XTENLANG-530: For every static field f the compiler generates an accessor method, f__get() a volatile status field, f__status a local initializer, f__do_init() a global initializer, f__init() (which invokes f__do_init() in place 0) a broadcast id f__id a broadcast deserializer function f__deserialize(). Fields are initialized on first access. Fields use "when" to synchronize initialization so a circular initialization dependency results in deadlock. Static initializer blocks are disabled in codegen, but not yet in the parser. Removed _static_init methods from all classes. initialize_xrx() now initializes the necessary fields individually. LIMITATION: does not work for struct fields. Async deserializers can now return null (which will cause the closure to be ignored). Plus minor tweaks of codegen and C++ implementation. Modified Paths: -------------- trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java trunk/x10.compiler/src/x10cpp/visit/SharedVarsMethods.java trunk/x10.compiler/src/x10cpp/visit/X10CPPTranslator.java trunk/x10.runtime/src-cpp/Makefile trunk/x10.runtime/src-cpp/x10/lang/Box.h trunk/x10.runtime/src-cpp/x10/lang/Ref.h trunk/x10.runtime/src-cpp/x10/lang/Throwable.h trunk/x10.runtime/src-cpp/x10/lang/Value.h trunk/x10.runtime/src-cpp/x10/runtime/Lock.h trunk/x10.runtime/src-cpp/x10/runtime/Thread.h trunk/x10.runtime/src-cpp/x10/util/GrowableRail.h trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicBoolean.h trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicInteger.h trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicLong.h trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicReference.h trunk/x10.runtime/src-cpp/x10aux/bootstrap.cc trunk/x10.runtime/src-cpp/x10aux/deserialization_dispatcher.cc trunk/x10.runtime/src-cpp/x10aux/deserialization_dispatcher.h trunk/x10.runtime/src-cpp/x10aux/network.cc trunk/x10.runtime/src-cpp/x10aux/serialization.cc trunk/x10.runtime/src-cpp/x10rt17.h Added Paths: ----------- trunk/x10.runtime/src-cpp/x10aux/static_init.cc trunk/x10.runtime/src-cpp/x10aux/static_init.h Modified: trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java =================================================================== --- trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java 2009-09-30 22:13:57 UTC (rev 11324) +++ trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java 2009-09-30 22:14:16 UTC (rev 11325) @@ -34,7 +34,6 @@ import static x10cpp.visit.SharedVarsMethods.SERIALIZE_BODY_METHOD; import static x10cpp.visit.SharedVarsMethods.SERIALIZE_ID_METHOD; import static x10cpp.visit.SharedVarsMethods.SERIALIZE_METHOD; -import static x10cpp.visit.SharedVarsMethods.STATIC_INIT; import static x10cpp.visit.SharedVarsMethods.STRUCT_EQUALS; import static x10cpp.visit.SharedVarsMethods.STRUCT_EQUALS_METHOD; import static x10cpp.visit.SharedVarsMethods.THIS; @@ -317,26 +316,25 @@ fd.init().type().isChar() || fd.init().type().isNull())); } - // FIXME: Consolidate with extractInits() - private boolean extractGenericStaticDecls(X10ClassDef cd, ClassifiedStream w) { + private void extractGenericStaticDecls(X10ClassDef cd, ClassifiedStream h) { + if (cd.typeParameters().size() == 0) return; + X10CPPContext_c context = (X10CPPContext_c) tr.context(); - if (cd.typeParameters().size() == 0) - return false; - w.write("template <> class "); - w.write(mangled_non_method_name(cd.name().toString())); - w.write(voidTemplateInstantiation(cd.typeParameters().size())); + h.write("template <> class "); + h.write(mangled_non_method_name(cd.name().toString())); + h.write(voidTemplateInstantiation(cd.typeParameters().size())); if (cd.superType() != null) { - w.write(" : public "); + h.write(" : public "); X10ClassDef sdef = ((X10ClassType) cd.superType().get()).x10Def(); X10ClassType stype = (X10ClassType) sdef.asType(); - w.write(Emitter.translateType(getStaticMemberContainer(stype), false)); + h.write(Emitter.translateType(getStaticMemberContainer(stype), false)); } - w.allowBreak(0, " "); - w.write("{"); - w.newline(4); w.begin(0); - w.write("public:"); w.newline(); - w.write("static x10aux::RuntimeType rtt;"); w.newline(); - w.write("static const x10aux::RuntimeType* getRTT() { return & rtt; }"); w.newline(); + h.allowBreak(0, " "); + h.write("{"); + h.newline(4); h.begin(0); + h.write("public:"); h.newline(); + h.write("static x10aux::RuntimeType rtt;"); h.newline(); + h.write("static const x10aux::RuntimeType* getRTT() { return & rtt; }"); h.newline(); // First process all classes for (ClassMember dec : context.pendingStaticDecls()) { if (dec instanceof ClassDecl_c) { @@ -348,12 +346,12 @@ // emit no c++ code as this is a native rep class continue; } - emitter.printTemplateSignature(((X10ClassType)def.asType()).typeArguments(), w); - w.write("class "); - w.write(Emitter.mangled_non_method_name(cdecl.name().id().toString())); - w.write(";"); + emitter.printTemplateSignature(((X10ClassType)def.asType()).typeArguments(), h); + h.write("class "); + h.write(Emitter.mangled_non_method_name(cdecl.name().id().toString())); + h.write(";"); ((X10CPPTranslator)tr).setContext(context); // FIXME - w.newline(); + h.newline(); } } // Then process all fields and methods @@ -361,31 +359,28 @@ if (dec instanceof FieldDecl_c) { FieldDecl_c fd = (FieldDecl_c) dec; ((X10CPPTranslator)tr).setContext(fd.enterScope(context)); // FIXME - sw.pushCurrentStream(w); - emitter.printHeader(fd, w, tr, false); + sw.pushCurrentStream(h); + emitter.printHeader(fd, h, tr, false); sw.popCurrentStream(); - w.write(";"); + h.write(";"); ((X10CPPTranslator)tr).setContext(context); // FIXME } else if (dec instanceof MethodDecl_c) { MethodDecl_c md = (MethodDecl_c) dec; ((X10CPPTranslator)tr).setContext(md.enterScope(context)); // FIXME - sw.pushCurrentStream(w); + sw.pushCurrentStream(h); emitter.printHeader(md, sw, tr, false); sw.popCurrentStream(); - w.write(";"); + h.write(";"); ((X10CPPTranslator)tr).setContext(context); // FIXME } - w.newline(); w.forceNewline(); + h.newline(); h.forceNewline(); } - w.write((((X10ClassType)cd.asType()).isX10Struct() ? "" : "static ") + VOID + " " + STATIC_INIT + "();"); - w.newline(); w.forceNewline(); - w.end(); w.newline(); - w.write("};"); - w.newline(); - return true; + extractGenericStaticInits(cd); + h.end(); h.newline(); + h.write("};"); + h.newline(); } - // FIXME: Consolidate with extractInits() private void extractGenericStaticInits(X10ClassDef cd) { // Always write non-template static decls into the implementation file ClassifiedStream save_w = sw.currentStream(); @@ -396,7 +391,6 @@ w.forceNewline(0); X10CPPContext_c context = (X10CPPContext_c) tr.context(); - ArrayList<FieldDecl_c> inits = new ArrayList<FieldDecl_c>(); String container = translate_mangled_FQN(cd.fullName().toString())+voidTemplateInstantiation(cd.typeParameters().size()); sw.write("x10aux::RuntimeType "+container+"::rtt;"); sw.newline(); @@ -410,15 +404,18 @@ sw.write(mangled_field_name(fd.name().id().toString())); // [DC] want these to occur in the static initialiser instead // [IP] except for the ones that use a literal init - otherwise switch is broken - if (isGlobalInit(fd)) { + boolean globalInit = isGlobalInit(fd); + if (globalInit) { sw.write(" ="); sw.allowBreak(2, " "); fd.print(fd.init(), sw, tr); - } else if (fd.init() != null) { - inits.add(fd); } sw.write(";"); sw.newline(); + if (!globalInit && fd.init() != null) { + generateStaticFieldInitializer(fd, container, sw); + } + generateStaticFieldSupportCode(fd, container, globalInit, sw); ((X10CPPTranslator)tr).setContext(context); // FIXME } else if (dec instanceof MethodDecl_c) { MethodDecl_c md = (MethodDecl_c) dec; @@ -455,42 +452,18 @@ ((X10CPPTranslator)tr).setContext(context); // FIXME if (templateMethod) sw.popCurrentStream(); + } else if (dec instanceof Initializer_c) { + assert (false) : ("Static initializer alert!"); } else if (dec instanceof X10ClassDecl_c) { assert (false) : ("Nested class alert!"); - } } - sw.write(VOID + " " + container + "::" + STATIC_INIT + "() {"); - sw.newline(4); sw.begin(0); - sw.write("static bool done = false;"); sw.newline(); - sw.write("if (done) return;"); sw.newline(); - sw.write("done = true;"); sw.newline(); - sw.write("_I_(\"Doing static initialisation for class: "+container+"\");"); sw.newline(); - if (cd.superType() != null) { - X10ClassDef superDef = ((X10ClassType) X10TypeMixin.baseType(cd.superType().get())).x10Def(); - String superContainer = translate_mangled_FQN(superDef.fullName().toString())+voidTemplateInstantiation(superDef.typeParameters().size()); - sw.write(superContainer + "::" + STATIC_INIT + "();"); - sw.newline(); - } - for (FieldDecl_c fd : inits) { - assert (fd.init() != null); - sw.write(mangled_field_name(fd.name().id().toString())+" ="); - sw.allowBreak(2, " "); - fd.print(fd.init(), sw, tr); - sw.write(";"); - sw.newline(); - } - //w.write("return NULL;"); - sw.end(); sw.newline(); - sw.write("}"); sw.newline(); - sw.write("static " + VOID_PTR + " __init__"+getUniqueId_() +" __attribute__((__unused__)) = x10aux::InitDispatcher::addInitializer(" + container + "::" + STATIC_INIT + ")"+ ";"); - sw.newline(); sw.forceNewline(0); - + sw.forceNewline(); sw.popCurrentStream(); } private boolean extractInits(X10ClassType currentClass, String methodName, - String retType, List<ClassMember> members, boolean staticInits) + String retType, List<ClassMember> members) { String className = Emitter.translateType(currentClass); boolean sawInit = false; @@ -501,30 +474,12 @@ sw.write(retType + " " + className + "::" + methodName + "() {"); } sw.newline(4); sw.begin(0); - if (staticInits) { - sw.write("static bool done = false;"); sw.newline(); - sw.write("if (done) return;"); sw.newline(); - sw.write("done = true;"); sw.newline(); - sw.write("_I_(\"Doing static initialisation for class: "+className+"\");"); sw.newline(); - if (currentClass.superClass() != null) { - X10ClassDef superDef = ((X10ClassType) X10TypeMixin.baseType(currentClass.superClass())).x10Def(); - if (currentClass.isX10Struct()) { - String superContainer = Emitter.structNameSpace(currentClass.superClass().toClass(), true); - sw.write(superContainer + "::" + methodName + "();"); - } else { - String superContainer = translate_mangled_FQN(superDef.fullName().toString())+voidTemplateInstantiation(superDef.typeParameters().size()); - sw.write(superContainer + "::" + methodName + "();"); - } - sw.newline(); - } - } else { - sw.write("_I_(\"Doing initialisation for class: "+className+"\");"); sw.newline(); - } + sw.write("_I_(\"Doing initialisation for class: "+className+"\");"); sw.newline(); for (ClassMember member : members) { + if (member.memberDef().flags().isStatic()) + continue; if (!(member instanceof Initializer_c) && !(member instanceof FieldDecl_c)) continue; - if (member.memberDef().flags().isStatic() != staticInits) - continue; if (member instanceof FieldDecl_c && (((FieldDecl_c)member).init() == null || query.isSyntheticField(((FieldDecl_c)member).name().id().toString()))) @@ -549,11 +504,9 @@ X10CPPContext_c context = (X10CPPContext_c) tr.context(); ((X10CPPTranslator)tr).setContext(dec.enterScope(context)); // FIXME X10TypeSystem_c xts = (X10TypeSystem_c) tr.typeSystem(); - if (!staticInits) { - VarInstance ti = xts.localDef(Position.COMPILER_GENERATED, Flags.FINAL, - Types.ref(currentClass), Name.make(THIS)).asInstance(); - context.addVariable(ti); - } + VarInstance ti = xts.localDef(Position.COMPILER_GENERATED, Flags.FINAL, + Types.ref(currentClass), Name.make(THIS)).asInstance(); + context.addVariable(ti); Expr init = (Expr) dec.init(); assert (init != null); sw.write(mangled_field_name(dec.name().id().toString())); @@ -901,13 +854,8 @@ } ((X10CPPTranslator)tr).setContext(n.enterChildScope(n.body(), context)); // FIXME - /* - * TODO: [IP] Add comment about dependences between the method calls. - */ - if (extractGenericStaticDecls(def, h)) { - extractGenericStaticInits(def); - } + extractGenericStaticDecls(def, h); /* * See comment about resetStateForClass() above. @@ -1204,7 +1152,7 @@ h.write(VOID + " " + INSTANCE_INIT + "();"); h.newline(); h.forceNewline(); - if (extractInits(currentClass, INSTANCE_INIT, VOID, members, false)) { + if (extractInits(currentClass, INSTANCE_INIT, VOID, members)) { context.hasInits = true; } @@ -1213,8 +1161,6 @@ n.printBlock(member, sw, tr); } } - - generateStaticInitForClass(currentClass, h, members, className); } sw.end(); @@ -1247,7 +1193,7 @@ h.write(VOID + " " + INSTANCE_INIT + "();"); h.newline(); h.forceNewline(); - if (extractInits(currentClass, INSTANCE_INIT, VOID, members, false)) { + if (extractInits(currentClass, INSTANCE_INIT, VOID, members)) { context.hasInits = true; } @@ -1267,7 +1213,6 @@ superClass, xts, "virtual ", h, members); } - generateStaticInitForClass(currentClass, h, members, className); } sw.end(); @@ -1299,7 +1244,7 @@ h.write(VOID + " " + INSTANCE_INIT + "();"); h.newline(); h.forceNewline(); - if (extractInits(currentClass, INSTANCE_INIT, VOID, members, false)) { + if (extractInits(currentClass, INSTANCE_INIT, VOID, members)) { context.hasInits = true; } @@ -1379,8 +1324,6 @@ sw.write("}"); sw.newline(); - generateStaticInitForClass(currentClass, h, members, className); - emitter.generateValueSerializationMethods(currentClass, sw); } @@ -1420,7 +1363,7 @@ sh.forceNewline(); Emitter.openStructNamespaces(sw, currentClass.fullName()); sw.newline(); - if (extractInits(currentClass, INSTANCE_INIT, VOID, members, false)) { + if (extractInits(currentClass, INSTANCE_INIT, VOID, members)) { context.hasInits = true; } Emitter.closeNamespaces(sw, currentClass.fullName()); sw.newline(); sw.forceNewline(); @@ -1477,8 +1420,6 @@ sw.newline(); sw.write("}"); sw.newline(); - - generateStaticInitForClass(currentClass, h, members, className); emitter.generateStructSerializationMethods(currentClass, sw); } @@ -1644,34 +1585,35 @@ } } - private void generateStaticInitForClass(X10ClassType currentClass, - ClassifiedStream h, List<ClassMember> members, String className) { - if (currentClass.isX10Struct()) { - // declare static init function in header - h.writeln(VOID + " " + STATIC_INIT + "();"); - Emitter.openStructNamespaces(sw, currentClass.fullName()); sw.newline(); - if (extractInits(currentClass, STATIC_INIT, VOID, members, true)) { - // define field that triggers initalisation-time registration of - // static init function - sw.write("static " + VOID_PTR + " __init__"+getUniqueId_() + - " __attribute__((__unused__)) = x10aux::InitDispatcher::addInitializer(" +STATIC_INIT + ")" + ";"); - sw.newline(); sw.forceNewline(0); - } - Emitter.closeNamespaces(sw, currentClass.fullName()); sw.newline(); sw.forceNewline(); - } else { - // declare static init function in header - h.write("static " + VOID + " " + STATIC_INIT + "();"); - h.newline(); - if (extractInits(currentClass, STATIC_INIT, VOID, members, true)) { - // define field that triggers initalisation-time registration of - // static init function - sw.write("static " + VOID_PTR + " __init__"+getUniqueId_() + - " __attribute__((__unused__)) = x10aux::InitDispatcher::addInitializer(" + - className+"::"+STATIC_INIT + ")" + ";"); - sw.newline(); sw.forceNewline(0); - } - } - } + // TODO: use this to update static field init generation for structs +// private void generateStaticInitForClass(X10ClassType currentClass, +// ClassifiedStream h, List<ClassMember> members, String className) { +// if (currentClass.isX10Struct()) { +// // declare static init function in header +// h.writeln(VOID + " " + STATIC_INIT + "();"); +// Emitter.openStructNamespaces(sw, currentClass.fullName()); sw.newline(); +// if (extractInits(currentClass, STATIC_INIT, VOID, members, true)) { +// // define field that triggers initalisation-time registration of +// // static init function +// sw.write("static " + VOID_PTR + " __init__"+getUniqueId_() + +// " __attribute__((__unused__)) = x10aux::InitDispatcher::addInitializer(" +STATIC_INIT + ")" + ";"); +// sw.newline(); sw.forceNewline(0); +// } +// Emitter.closeNamespaces(sw, currentClass.fullName()); sw.newline(); sw.forceNewline(); +// } else { +// // declare static init function in header +// h.write("static " + VOID + " " + STATIC_INIT + "();"); +// h.newline(); +// if (extractInits(currentClass, STATIC_INIT, VOID, members, true)) { +// // define field that triggers initalisation-time registration of +// // static init function +// sw.write("static " + VOID_PTR + " __init__"+getUniqueId_() + +// " __attribute__((__unused__)) = x10aux::InitDispatcher::addInitializer(" + +// className+"::"+STATIC_INIT + ")" + ";"); +// sw.newline(); sw.forceNewline(0); +// } +// } +// } String defaultValue(Type type) { return type.isPrimitive() ? "0" : "x10aux::null"; @@ -1960,25 +1902,238 @@ emitter.printHeader(dec, sw, tr, true); // [DC] disabled because I want this done through the static initialisation framework // [IP] re-enabled for a very limited set of cases, namely literal inits - if (isGlobalInit(dec)) { + boolean globalInit = isGlobalInit(dec); + if (globalInit) { sw.write(" ="); sw.allowBreak(2, " "); dec.print(dec.init(), sw, tr); } sw.write(";"); sw.newline(); + String container = Emitter.translateType(dec.fieldDef().asInstance().container()); + if (!globalInit) { + generateStaticFieldInitializer(dec, container, sw); + } + generateStaticFieldSupportCode(dec, container, globalInit, sw); sw.forceNewline(); } } + private static final String STATIC_FIELD_ACCESSOR_SUFFIX = "__get"; + private static final String STATIC_FIELD_STATUS_SUFFIX = "__status"; + private static final String STATIC_FIELD_INITIALIZER_SUFFIX = "__init"; + private static final String STATIC_FIELD_REAL_INIT_SUFFIX = "__do_init"; + private static final String STATIC_FIELD_BROADCASTID_SUFFIX = "__id"; + private static final String STATIC_FIELD_DESERIALIZER_SUFFIX = "__deserialize"; + private static final String STATIC_FIELD_UNINITIALIZED = "x10aux::UNINITIALIZED"; + private static final String STATIC_FIELD_INITIALIZING = "x10aux::INITIALIZING"; + private static final String STATIC_FIELD_INITIALIZED = "x10aux::INITIALIZED"; + + /** + * Generate an initializer method for a given field declaration. + */ + private void generateStaticFieldInitializer(FieldDecl_c dec, String container, StreamWrapper sw) { + // FIXME: handle structs + String name = dec.name().id().toString(); + String fname = mangled_field_name(name); + String status = mangled_field_name(name+STATIC_FIELD_STATUS_SUFFIX); + String init_nb = mangled_field_name(name+STATIC_FIELD_REAL_INIT_SUFFIX); + String init = mangled_field_name(name+STATIC_FIELD_INITIALIZER_SUFFIX); + String id = mangled_field_name(name+STATIC_FIELD_BROADCASTID_SUFFIX); + ClassifiedStream h = sw.header(); + sw.pushCurrentStream(h); + // declare the actual field initializer + h.write("static void "); + h.write(init_nb); + h.write("();"); + h.newline(); + // declare the on-demand field initializer + h.write("static void "); + h.write(init); + h.write("();"); + h.newline(); + sw.popCurrentStream(); + // define the actual field initializer + sw.write("void "); + sw.write(container + "::" + init_nb); + sw.write("() {"); + sw.newline(4); sw.begin(0); + // set the status (ok to do here because either we are in single-threaded + // mode, or we will have already set the status to INITIALIZING atomically) + sw.write(status + " = " + STATIC_FIELD_INITIALIZING + ";"); + sw.newline(); + // initialize the field + sw.write("_I_(\"Doing static initialisation for field: "+container+"."+fname+"\");"); sw.newline(); + String val = getId(); + emitter.printType(dec.type().type(), sw); + sw.allowBreak(2, 2, " ", 1); + sw.write(val + " ="); + sw.allowBreak(2, 2, " ", 1); + dec.print(dec.init(), sw, tr); + sw.write(";"); + sw.newline(); + // copy into the field + sw.write(fname + " = " + val + ";"); + sw.newline(); + // update the status + sw.write(status + " = " + STATIC_FIELD_INITIALIZED + ";"); + sw.end(); sw.newline(); + sw.write("}"); + sw.newline(); + // define the on-demand field initializer + sw.write("void "); + sw.write(container + "::" + init); + sw.write("() {"); + sw.newline(4); sw.begin(0); + sw.write("if (x10aux::here == 0) {"); + sw.newline(4); sw.begin(0); + sw.newline(); + // (atomically) check that the field is uninitialized + String tmp = getId(); + sw.write("x10aux::status " + tmp + " ="); + sw.allowBreak(2, 2, " ", 1); + sw.write("(x10aux::status)x10aux::atomic_ops::compareAndSet_32((volatile x10_int*)&" + + status + ", (x10_int)" + STATIC_FIELD_UNINITIALIZED + + ", (x10_int)" + STATIC_FIELD_INITIALIZING + ");"); + sw.newline(); + sw.write("if (" + tmp + " != " + STATIC_FIELD_UNINITIALIZED + ") goto WAIT;"); + sw.newline(); + // invoke the initializer + sw.write(init_nb + "();"); + sw.newline(); + // broadcast the new value + sw.write("x10aux::StaticInitBroadcastDispatcher::broadcastStaticField("); + sw.begin(0); + sw.write(fname); + sw.write(","); + sw.allowBreak(0, 2, " ", 1); + sw.write(id); + sw.end(); + sw.write(");"); + sw.newline(); + sw.write("// Notify all waiting threads"); + sw.newline(); + sw.write("x10::runtime::Runtime::lock(); x10::runtime::Runtime::release();"); + sw.end(); sw.newline(); + sw.write("}"); sw.newline(); + sw.write("WAIT:"); sw.newline(); + sw.write("while ("+status+" != " + STATIC_FIELD_INITIALIZED + ") x10::runtime::Runtime::await();"); + sw.end(); sw.newline(); + sw.write("}"); + sw.newline(); + sw.write("static " + VOID_PTR + " __init__"+getUniqueId_() +" __attribute__((__unused__)) = x10aux::InitDispatcher::addInitializer(" + container + "::" + init + ")"+ ";"); + sw.newline(); sw.forceNewline(0); + } + + /** + * Generates the accessor method and the initialization flag for a given + * field declaration. + * TODO: some of this should really be done before codegen. + */ + private void generateStaticFieldSupportCode(FieldDecl_c dec, String container, boolean globalInit, StreamWrapper sw) { + // FIXME: handle structs + String name = dec.name().id().toString(); + String fname = mangled_field_name(name); + String status = mangled_field_name(name+STATIC_FIELD_STATUS_SUFFIX); + String accessor = mangled_field_name(name+STATIC_FIELD_ACCESSOR_SUFFIX); + String init = mangled_field_name(name+STATIC_FIELD_INITIALIZER_SUFFIX); + String deserializer = mangled_field_name(name+STATIC_FIELD_DESERIALIZER_SUFFIX); + String id = mangled_field_name(name+STATIC_FIELD_BROADCASTID_SUFFIX); + X10TypeSystem_c xts = (X10TypeSystem_c) tr.typeSystem(); + ClassifiedStream h = sw.header(); + sw.pushCurrentStream(h); + if (!globalInit) { + // declare the initialization flag + h.write("static volatile x10aux::status "); + h.write(status); + h.write(";"); + h.newline(); + } + // declare (and define) the accessor method + h.write("static "); + emitter.printType(dec.type().type(), h); + h.allowBreak(2, 2, " ", 1); + h.write(accessor); + h.write("() {"); + h.newline(4); h.begin(0); + if (!globalInit) { + h.write("if ("+status+" != " + STATIC_FIELD_INITIALIZED + ") {"); + h.newline(4); h.begin(0); + h.write(init + "();"); + h.end(); h.newline(); + h.write("}"); + h.newline(); + } + h.write("return "); + h.write(container+"::"); + h.write(fname); + h.write(";"); + h.end(); h.newline(); + h.write("}"); + h.newline(); + sw.popCurrentStream(); + if (!globalInit) { + sw.pushCurrentStream(h); + // declare the deserializer method + h.write("static "+Emitter.translateType(xts.Object(), true)); + h.allowBreak(2, 2, " ", 1); + h.write(deserializer + "(" + DESERIALIZATION_BUFFER + " &buf);"); + h.newline(); + // declare the broadcast id + h.write("static const x10aux::serialization_id_t "+id+";"); + h.newline(); h.forceNewline(); + sw.popCurrentStream(); + // define the initialization flag + sw.write("volatile x10aux::status "); + sw.write(container+"::"); + sw.write(status); + sw.write(";"); + sw.newline(); + // define the deserializer method + sw.write("// extract value from a buffer"); sw.newline(); + sw.write(Emitter.translateType(xts.Object(), true)); + sw.allowBreak(2, 2, " ", 1); + sw.write(container + "::" + deserializer + "(" + DESERIALIZATION_BUFFER + " &buf) {"); + sw.newline(4); sw.begin(0); + sw.write(fname+" ="); + sw.allowBreak(2, 2, " ", 1); + sw.write("buf.read"+chevrons(Emitter.translateType(dec.type().type(), true))+"();"); + sw.newline(); + sw.write(container+"::"+status+" = " + STATIC_FIELD_INITIALIZED + ";"); + sw.newline(); + sw.write("// Notify all waiting threads"); + sw.newline(); + sw.write("x10::runtime::Runtime::lock(); x10::runtime::Runtime::release();"); + sw.newline(); + sw.write("return x10aux::null;"); + sw.end(); sw.newline(); + sw.write("}"); + sw.newline(); + // define the broadcast id + sw.write("const x10aux::serialization_id_t " + container + "::"+id + " ="); + sw.allowBreak(2, 2, " ", 1); + sw.write("x10aux::StaticInitBroadcastDispatcher::addRoutine(" + container + "::" + deserializer + ");"); + sw.newline(); + } + } + public void visit(PropertyDecl_c n) { super.visit(n); } public void visit(Initializer_c n) { - if (n.flags().flags().isStatic()) { - // Ignore -- this will have been processed earlier - } + X10CPPContext_c context = (X10CPPContext_c) tr.context(); + if (n.flags().flags().isStatic()) { + assert (false) : ("Static initializer alert!"); + } + if (((X10ClassDef) context.currentClassDef()).typeParameters().size() != 0 && + n.flags().flags().isStatic()) + { + context.pendingStaticDecls().add(n); + return; + } else { + // Ignore -- this will have been processed earlier + } } @@ -2247,9 +2402,9 @@ sw.newline(0); sw.begin(0); sw.newline(); } - sw.newline(); + sw.newline(4); sw.begin(0); n.print(n.body(), sw, tr); - sw.newline(); + sw.end(); sw.newline(); if (label != null) { sw.newline(0); sw.write(label + "_next_ : ;"); @@ -2664,6 +2819,7 @@ //sw.write("->"); } } + String name = n.name().id().toString(); assert (target != null); if (target instanceof Expr) { if (fi.flags().isStatic()) { @@ -2673,7 +2829,7 @@ sw.write(Emitter.translateType(target.type())); sw.write("::"); sw.allowBreak(2, 3, "", 0); - sw.write(mangled_field_name(n.name().id().toString())); + sw.write(mangled_field_name(name)); sw.write(")"); sw.end(); return; @@ -2694,7 +2850,11 @@ sw.write("->"); } sw.allowBreak(2, 3, "", 0); - sw.write(mangled_field_name(n.name().id().toString())); + if (!n.fieldInstance().flags().isStatic()) { + sw.write(mangled_field_name(name)); + } else { + sw.write(mangled_field_name(name+STATIC_FIELD_ACCESSOR_SUFFIX) + "()"); + } sw.end(); } Modified: trunk/x10.compiler/src/x10cpp/visit/SharedVarsMethods.java =================================================================== --- trunk/x10.compiler/src/x10cpp/visit/SharedVarsMethods.java 2009-09-30 22:13:57 UTC (rev 11324) +++ trunk/x10.compiler/src/x10cpp/visit/SharedVarsMethods.java 2009-09-30 22:14:16 UTC (rev 11325) @@ -68,7 +68,6 @@ static final String INSTANCE_INIT = "_instance_init"; // instance field initialisers static final String CONSTRUCTOR = "_constructor"; static final String MAKE = "_make"; - static final String STATIC_INIT = "_static_init"; // static field initialisers static final String SERIALIZATION_ID_FIELD = "_serialization_id"; static final String SERIALIZATION_MARKER = "x10aux::SERIALIZATION_MARKER"; static final String SERIALIZATION_BUFFER = "x10aux::serialization_buffer"; Modified: trunk/x10.compiler/src/x10cpp/visit/X10CPPTranslator.java =================================================================== --- trunk/x10.compiler/src/x10cpp/visit/X10CPPTranslator.java 2009-09-30 22:13:57 UTC (rev 11324) +++ trunk/x10.compiler/src/x10cpp/visit/X10CPPTranslator.java 2009-09-30 22:14:16 UTC (rev 11325) @@ -409,7 +409,7 @@ if (map.isEmpty()) return; sw.forceNewline(); - String lnmName = Emitter.translate_mangled_FQN(pkg).replace("::","_")+"_"+Emitter.mangled_non_method_name(className); + String lnmName = Emitter.translate_mangled_FQN(pkg, "_")+"_"+Emitter.mangled_non_method_name(className); // sw.write("struct LNMAP_"+lnmName+"_"+ext+" { static const char* map; };"); // sw.newline(); // sw.write("const char* LNMAP_"+lnmName+"_"+ext+"::map = \""); Modified: trunk/x10.runtime/src-cpp/Makefile =================================================================== --- trunk/x10.runtime/src-cpp/Makefile 2009-09-30 22:13:57 UTC (rev 11324) +++ trunk/x10.runtime/src-cpp/Makefile 2009-09-30 22:14:16 UTC (rev 11325) @@ -168,6 +168,7 @@ x10aux/double_utils.o \ x10aux/int_utils.o \ x10aux/init_dispatcher.o \ + x10aux/static_init.o \ x10aux/itables.o \ x10aux/io/FILEPtrInputStream.o \ x10aux/io/FILEPtrOutputStream.o \ Modified: trunk/x10.runtime/src-cpp/x10/lang/Box.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Box.h 2009-09-30 22:13:57 UTC (rev 11324) +++ trunk/x10.runtime/src-cpp/x10/lang/Box.h 2009-09-30 22:14:16 UTC (rev 11325) @@ -46,8 +46,6 @@ }; template <> class Box<void> : public Ref { - public: - static void _static_init() { } }; template<class T> void Box<T>::_initRTT() { Modified: trunk/x10.runtime/src-cpp/x10/lang/Ref.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Ref.h 2009-09-30 22:13:57 UTC (rev 11324) +++ trunk/x10.runtime/src-cpp/x10/lang/Ref.h 2009-09-30 22:14:16 UTC (rev 11325) @@ -65,8 +65,6 @@ if (other == x10aux::ref<Ref>(this)) return true; return false; } - - static void _static_init() { } }; } Modified: trunk/x10.runtime/src-cpp/x10/lang/Throwable.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Throwable.h 2009-09-30 22:13:57 UTC (rev 11324) +++ trunk/x10.runtime/src-cpp/x10/lang/Throwable.h 2009-09-30 22:14:16 UTC (rev 11325) @@ -69,8 +69,6 @@ template<class T> static x10aux::ref<T> _deserializer(x10aux::deserialization_buffer &buf); void _deserialize_body(x10aux::deserialization_buffer &buf); - - static void _static_init() { } }; template<class T> x10aux::ref<T> Throwable::_deserializer(x10aux::deserialization_buffer &buf){ Modified: trunk/x10.runtime/src-cpp/x10/lang/Value.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Value.h 2009-09-30 22:13:57 UTC (rev 11324) +++ trunk/x10.runtime/src-cpp/x10/lang/Value.h 2009-09-30 22:14:16 UTC (rev 11325) @@ -57,8 +57,6 @@ } virtual x10_boolean _struct_equals(x10aux::ref<Object> other); - - static void _static_init() { } }; template<class T> x10aux::ref<T> Value::_deserialize(x10aux::deserialization_buffer &buf){ Modified: trunk/x10.runtime/src-cpp/x10/runtime/Lock.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/runtime/Lock.h 2009-09-30 22:13:57 UTC (rev 11324) +++ trunk/x10.runtime/src-cpp/x10/runtime/Lock.h 2009-09-30 22:14:16 UTC (rev 11325) @@ -79,10 +79,6 @@ */ x10_int getHoldCount(); - static void _static_init() { - x10::lang::Ref::_static_init(); - } - private: // lock id pthread_mutex_t __lock; Modified: trunk/x10.runtime/src-cpp/x10/runtime/Thread.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/runtime/Thread.h 2009-09-30 22:13:57 UTC (rev 11324) +++ trunk/x10.runtime/src-cpp/x10/runtime/Thread.h 2009-09-30 22:14:16 UTC (rev 11325) @@ -180,10 +180,6 @@ // Changes the name of this thread to be equal to the argument name. void setName(const x10aux::ref<x10::lang::String> name); - static void _static_init() { - x10::lang::Ref::_static_init(); - } - protected: // Helper method to initialize a Thread object. void thread_init(x10aux::ref<x10::lang::VoidFun_0_0> task, Modified: trunk/x10.runtime/src-cpp/x10/util/GrowableRail.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/util/GrowableRail.h 2009-09-30 22:13:57 UTC (rev 11324) +++ trunk/x10.runtime/src-cpp/x10/util/GrowableRail.h 2009-09-30 22:14:16 UTC (rev 11325) @@ -127,10 +127,6 @@ } x10_int size() { return _array->FMGL(length); } - - static void _static_init() { - x10::lang::Ref::_static_init(); - } }; template<class T> void GrowableRail<T>::_initRTT() { Modified: trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicBoolean.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicBoolean.h 2009-09-30 22:13:57 UTC (rev 11324) +++ trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicBoolean.h 2009-09-30 22:14:16 UTC (rev 11325) @@ -64,10 +64,6 @@ x10aux::ref<x10::lang::String> toString() { return x10aux::boolean_utils::toString(_val); } - - static void _static_init() { - x10::lang::Ref::_static_init(); - } }; } } Modified: trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicInteger.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicInteger.h 2009-09-30 22:13:57 UTC (rev 11324) +++ trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicInteger.h 2009-09-30 22:14:16 UTC (rev 11325) @@ -96,10 +96,6 @@ x10_double doubleValue() { return (x10_double)_val; } - - static void _static_init() { - x10::lang::Ref::_static_init(); - } }; } } Modified: trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicLong.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicLong.h 2009-09-30 22:13:57 UTC (rev 11324) +++ trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicLong.h 2009-09-30 22:14:16 UTC (rev 11325) @@ -96,10 +96,6 @@ x10_double doubleValue() { return (x10_double)_val; } - - static void _static_init() { - x10::lang::Ref::_static_init(); - } }; } } Modified: trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicReference.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicReference.h 2009-09-30 22:13:57 UTC (rev 11324) +++ trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicReference.h 2009-09-30 22:14:16 UTC (rev 11325) @@ -51,10 +51,6 @@ T getAndSet(T val); virtual x10aux::ref<x10::lang::String> toString(); - - static void _static_init() { - x10::lang::Ref::_static_init(); - } }; template<class T> x10aux::ref<AtomicReference<T > > AtomicReference<T >::_make() { Modified: trunk/x10.runtime/src-cpp/x10aux/bootstrap.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/bootstrap.cc 2009-09-30 22:13:57 UTC (rev 11324) +++ trunk/x10.runtime/src-cpp/x10aux/bootstrap.cc 2009-09-30 22:14:16 UTC (rev 11325) @@ -17,9 +17,13 @@ }; void x10aux::initialize_xrx() { - x10::lang::Place::_static_init(); - x10::runtime::Runtime::_static_init(); - x10::io::Console::_static_init(); + x10::lang::Place::FMGL(MAX_PLACES__do_init)(); + x10::lang::Place::FMGL(places__do_init)(); + x10::lang::Place::FMGL(FIRST_PLACE__do_init)(); + x10::runtime::Runtime::FMGL(runtime__do_init)(); + x10::io::Console::FMGL(OUT__do_init)(); + x10::io::Console::FMGL(ERR__do_init)(); + x10::io::Console::FMGL(IN__do_init)(); } Modified: trunk/x10.runtime/src-cpp/x10aux/deserialization_dispatcher.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/deserialization_dispatcher.cc 2009-09-30 22:13:57 UTC (rev 11324) +++ trunk/x10.runtime/src-cpp/x10aux/deserialization_dispatcher.cc 2009-09-30 22:14:16 UTC (rev 11325) @@ -2,6 +2,7 @@ #include <x10aux/deserialization_dispatcher.h> #include <x10aux/serialization.h> #include <x10aux/network.h> +#include <x10aux/alloc.h> #include <assert.h> @@ -100,7 +101,7 @@ } void DeserializationDispatcher::registerHandlers_ () { - for (int i=0 ; i<next_id ; ++i) { + for (size_t i=0 ; i<next_id ; ++i) { if (i<deser_sz && deser_v[i]) { _S_("(DeserializationDispatcher registered id "<<i<<" as an async)"); x10aux::register_async_handler(i); Modified: trunk/x10.runtime/src-cpp/x10aux/deserialization_dispatcher.h =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/deserialization_dispatcher.h 2009-09-30 22:13:57 UTC (rev 11324) +++ trunk/x10.runtime/src-cpp/x10aux/deserialization_dispatcher.h 2009-09-30 22:14:16 UTC (rev 11325) @@ -3,7 +3,6 @@ #include <x10aux/config.h> -#include <x10aux/alloc.h> #include <x10aux/ref.h> namespace x10 { namespace lang { class Object; } } @@ -51,23 +50,23 @@ template<class T> static ref<T> create(deserialization_buffer &buf); template<class T> static ref<T> create(deserialization_buffer &buf, - x10aux::serialization_id_t id); + serialization_id_t id); ref<x10::lang::Object> create_(deserialization_buffer &buf); - ref<x10::lang::Object> create_(deserialization_buffer &buf, x10aux::serialization_id_t id); + ref<x10::lang::Object> create_(deserialization_buffer &buf, serialization_id_t id); static serialization_id_t addDeserializer(Deserializer deser, bool is_async=false); serialization_id_t addDeserializer_(Deserializer deser, bool is_async); static serialization_id_t addPutBufferFinder(BufferFinder bfinder); serialization_id_t addPutBufferFinder_(BufferFinder bfinder); - static BufferFinder getPutBufferFinder(x10aux::serialization_id_t id); - BufferFinder getPutBufferFinder_(x10aux::serialization_id_t id); + static BufferFinder getPutBufferFinder(serialization_id_t id); + BufferFinder getPutBufferFinder_(serialization_id_t id); static serialization_id_t addGetBufferFinder(BufferFinder bfinder); serialization_id_t addGetBufferFinder_(BufferFinder bfinder); - static BufferFinder getGetBufferFinder(x10aux::serialization_id_t id); - BufferFinder getGetBufferFinder_(x10aux::serialization_id_t id); + static BufferFinder getGetBufferFinder(serialization_id_t id); + BufferFinder getGetBufferFinder_(serialization_id_t id); static void registerHandlers(); void registerHandlers_(); @@ -82,7 +81,7 @@ } template<class T> ref<T> DeserializationDispatcher::create(deserialization_buffer &buf, - x10aux::serialization_id_t id) { + serialization_id_t id) { return static_cast<ref<T> >(it->create_(buf,id)); } Modified: trunk/x10.runtime/src-cpp/x10aux/network.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/network.cc 2009-09-30 22:13:57 UTC (rev 11324) +++ trunk/x10.runtime/src-cpp/x10aux/network.cc 2009-09-30 22:14:16 UTC (rev 11325) @@ -81,6 +81,7 @@ assert(buf.consumed() <= p.len); _X_("The deserialised async was: "<<async->toString()); deserialized_bytes += buf.consumed() ; asyncs_received++; + if (async.isNull()) return; (async.operator->()->*(findITable<VoidFun_0_0>(async->_getITables())->apply))(); } Modified: trunk/x10.runtime/src-cpp/x10aux/serialization.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/serialization.cc 2009-09-30 22:13:57 UTC (rev 11324) +++ trunk/x10.runtime/src-cpp/x10aux/serialization.cc 2009-09-30 22:14:16 UTC (rev 11325) @@ -40,7 +40,7 @@ serialization_buffer::serialization_buffer (void) // do not use GC - : buffer(NULL), limit(NULL), cursor(NULL), realloc_func(x10aux::msg_realloc) + : realloc_func(x10aux::msg_realloc), buffer(NULL), limit(NULL), cursor(NULL) { } void serialization_buffer::grow (void) { Added: trunk/x10.runtime/src-cpp/x10aux/static_init.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/static_init.cc (rev 0) +++ trunk/x10.runtime/src-cpp/x10aux/static_init.cc 2009-09-30 22:14:16 UTC (rev 11325) @@ -0,0 +1,39 @@ +#include <x10aux/config.h> +#include <x10aux/static_init.h> +#include <x10aux/alloc.h> +#include <x10aux/network.h> + +#include <assert.h> +#include <time.h> + +using namespace x10aux; +using namespace x10::lang; + +DeserializationDispatcher *StaticInitBroadcastDispatcher::it; + +serialization_id_t StaticInitBroadcastDispatcher::addRoutine(Deserializer init) { + if (NULL == it) { + it = new (alloc<DeserializationDispatcher>()) DeserializationDispatcher(); + } + return it->addDeserializer_(init, false); +} + +ref<Object> StaticInitBroadcastDispatcher::dispatch(deserialization_buffer &buf) { + assert (NULL != it); + serialization_id_t init_id = buf.read<serialization_id_t>(); + return it->create_(buf, init_id); +} + +serialization_id_t const StaticInitBroadcastDispatcher::STATIC_BROADCAST_ID = + DeserializationDispatcher::addDeserializer(StaticInitBroadcastDispatcher::dispatch, true); + +void StaticInitBroadcastDispatcher::doBroadcast(serialization_id_t id, char* the_buf, x10_uint sz) { + for (x10_uint place = 1; place < x10rt_nplaces(); place++) { + x10rt_msg_params p = {place, id, the_buf, sz}; + // avoid giving x10rt a NULL message to keep things simple for implementers + if (p.msg==NULL) p.msg = x10rt_msg_realloc(NULL,0,16); + x10rt_send_msg(p); + } +} + +// vim:tabstop=4:shiftwidth=4:expandtab Added: trunk/x10.runtime/src-cpp/x10aux/static_init.h =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/static_init.h (rev 0) +++ trunk/x10.runtime/src-cpp/x10aux/static_init.h 2009-09-30 22:14:16 UTC (rev 11325) @@ -0,0 +1,47 @@ +#ifndef X10AUX_STATIC_INIT_H +#define X10AUX_STATIC_INIT_H + +#include <x10aux/config.h> + +#include <x10aux/deserialization_dispatcher.h> +#include <x10aux/serialization.h> +#include <x10aux/network.h> + +namespace x10aux { + + class StaticInitBroadcastDispatcher { + protected: + static DeserializationDispatcher *it; + static serialization_id_t const STATIC_BROADCAST_ID; + static void doBroadcast(serialization_id_t id, char* the_buf, x10_uint sz); + + public: + static serialization_id_t addRoutine(Deserializer init); + static ref<x10::lang::Object> dispatch(deserialization_buffer& buf); + template<class C> static void broadcastStaticField(C f, serialization_id_t id); + }; + + template<class C> + void StaticInitBroadcastDispatcher::broadcastStaticField(C f, serialization_id_t id) { + serialization_buffer buf; + addr_map m; + buf.write(id, m); + buf.write(f, m); + x10_uint sz = buf.length(); + serialized_bytes += sz; asyncs_sent++; + char *the_buf = buf.steal(); + doBroadcast(STATIC_BROADCAST_ID, the_buf, sz); + } + + template<> inline const char *typeName<StaticInitBroadcastDispatcher>() + { return "StaticInitBroadcastDispatcher"; } + + enum status { + UNINITIALIZED = 0, + INITIALIZING, + INITIALIZED + }; +} + +#endif +// vim:tabstop=4:shiftwidth=4:expandtab Modified: trunk/x10.runtime/src-cpp/x10rt17.h =================================================================== --- trunk/x10.runtime/src-cpp/x10rt17.h 2009-09-30 22:13:57 UTC (rev 11324) +++ trunk/x10.runtime/src-cpp/x10rt17.h 2009-09-30 22:14:16 UTC (rev 11325) @@ -18,6 +18,7 @@ #include <x10aux/RTT.h> #include <x10aux/assert.h> #include <x10aux/init_dispatcher.h> +#include <x10aux/static_init.h> #include <x10aux/hash.h> #include <x10aux/basic_functions.h> #include <x10aux/atomic_ops.h> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ipe...@us...> - 2009-10-01 19:35:43
|
Revision: 11328 http://x10.svn.sourceforge.net/x10/?rev=11328&view=rev Author: ipeshansky Date: 2009-10-01 19:35:33 +0000 (Thu, 01 Oct 2009) Log Message: ----------- Fix codegen bug where x10::runtime::Runtime was not found. Fix interaction with standalone x10rt implementation (avoid serialization if running with 1 place). Fix compiler warning in deserialization_dispatcher. Modified Paths: -------------- trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java trunk/x10.runtime/src-cpp/x10aux/deserialization_dispatcher.h trunk/x10.runtime/src-cpp/x10aux/static_init.cc trunk/x10.runtime/src-cpp/x10aux/static_init.h Modified: trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java =================================================================== --- trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java 2009-09-30 22:26:24 UTC (rev 11327) +++ trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java 2009-10-01 19:35:33 UTC (rev 11328) @@ -1928,6 +1928,8 @@ private static final String STATIC_FIELD_UNINITIALIZED = "x10aux::UNINITIALIZED"; private static final String STATIC_FIELD_INITIALIZING = "x10aux::INITIALIZING"; private static final String STATIC_FIELD_INITIALIZED = "x10aux::INITIALIZED"; + private static final String STATIC_INIT_AWAIT = "x10aux::StaticInitBroadcastDispatcher::await"; + private static final String STATIC_INIT_NOTIFY_ALL = "x10aux::StaticInitBroadcastDispatcher::notify"; /** * Generate an initializer method for a given field declaration. @@ -2013,11 +2015,11 @@ sw.newline(); sw.write("// Notify all waiting threads"); sw.newline(); - sw.write("x10::runtime::Runtime::lock(); x10::runtime::Runtime::release();"); + sw.write(STATIC_INIT_NOTIFY_ALL + "();"); sw.end(); sw.newline(); sw.write("}"); sw.newline(); sw.write("WAIT:"); sw.newline(); - sw.write("while ("+status+" != " + STATIC_FIELD_INITIALIZED + ") x10::runtime::Runtime::await();"); + sw.write("while ("+status+" != " + STATIC_FIELD_INITIALIZED + ") " + STATIC_INIT_AWAIT + "();"); sw.end(); sw.newline(); sw.write("}"); sw.newline(); @@ -2103,7 +2105,7 @@ sw.newline(); sw.write("// Notify all waiting threads"); sw.newline(); - sw.write("x10::runtime::Runtime::lock(); x10::runtime::Runtime::release();"); + sw.write(STATIC_INIT_NOTIFY_ALL + "();"); sw.newline(); sw.write("return x10aux::null;"); sw.end(); sw.newline(); Modified: trunk/x10.runtime/src-cpp/x10aux/deserialization_dispatcher.h =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/deserialization_dispatcher.h 2009-09-30 22:26:24 UTC (rev 11327) +++ trunk/x10.runtime/src-cpp/x10aux/deserialization_dispatcher.h 2009-10-01 19:35:33 UTC (rev 11328) @@ -35,7 +35,7 @@ Deserializer *deser_v; size_t deser_sz; - int next_id; + size_t next_id; public: DeserializationDispatcher () : put_bfinder_v(NULL), put_bfinder_sz(0), Modified: trunk/x10.runtime/src-cpp/x10aux/static_init.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/static_init.cc 2009-09-30 22:26:24 UTC (rev 11327) +++ trunk/x10.runtime/src-cpp/x10aux/static_init.cc 2009-10-01 19:35:33 UTC (rev 11328) @@ -3,6 +3,8 @@ #include <x10aux/alloc.h> #include <x10aux/network.h> +#include <x10/runtime/Runtime.h> + #include <assert.h> #include <time.h> @@ -36,4 +38,13 @@ } } +void StaticInitBroadcastDispatcher::await() { + x10::runtime::Runtime::await(); +} + +void StaticInitBroadcastDispatcher::notify() { + x10::runtime::Runtime::lock(); + x10::runtime::Runtime::release(); +} + // vim:tabstop=4:shiftwidth=4:expandtab Modified: trunk/x10.runtime/src-cpp/x10aux/static_init.h =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/static_init.h 2009-09-30 22:26:24 UTC (rev 11327) +++ trunk/x10.runtime/src-cpp/x10aux/static_init.h 2009-10-01 19:35:33 UTC (rev 11328) @@ -19,10 +19,13 @@ static serialization_id_t addRoutine(Deserializer init); static ref<x10::lang::Object> dispatch(deserialization_buffer& buf); template<class C> static void broadcastStaticField(C f, serialization_id_t id); + static void await(); + static void notify(); }; template<class C> void StaticInitBroadcastDispatcher::broadcastStaticField(C f, serialization_id_t id) { + if (num_places == 1) return; serialization_buffer buf; addr_map m; buf.write(id, m); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ipe...@us...> - 2009-10-02 13:42:52
|
Revision: 11332 http://x10.svn.sourceforge.net/x10/?rev=11332&view=rev Author: ipeshansky Date: 2009-10-02 13:42:46 +0000 (Fri, 02 Oct 2009) Log Message: ----------- Make sure the compiler JAR only get generated if any of the files changed. Fix sourcepath in XRX build rule. Modified Paths: -------------- trunk/x10.compiler/build.xml trunk/x10.runtime/src-cpp/Makefile Modified: trunk/x10.compiler/build.xml =================================================================== --- trunk/x10.compiler/build.xml 2009-10-02 02:22:34 UTC (rev 11331) +++ trunk/x10.compiler/build.xml 2009-10-02 13:42:46 UTC (rev 11332) @@ -75,7 +75,7 @@ <!--<globmapper from="*.java" to="${build}/*.class" handledirsep="true"/>--> </uptodate> </target> - <target name="jar" depends="build,check-jar"> + <target name="jar" depends="build,check-jar" unless="compiler.uptodate"> <jar jarfile="${build}/${jar}"> <fileset refid="compiler.classes"/> <fileset refid="constraints.classes"/> Modified: trunk/x10.runtime/src-cpp/Makefile =================================================================== --- trunk/x10.runtime/src-cpp/Makefile 2009-10-02 02:22:34 UTC (rev 11331) +++ trunk/x10.runtime/src-cpp/Makefile 2009-10-02 13:42:46 UTC (rev 11332) @@ -135,7 +135,7 @@ gen/all-cpp-generated: $(XRXFILES) $(INSTDIR)/lib/x10c.jar @echo "Regenerating XRX cc/h/inc files" mkdir -p gen - "$(INSTDIR)"/bin/x10c++ -c $(X10CPPFLAGS) -sourcepath . -d ../src-cpp/gen \ + "$(INSTDIR)"/bin/x10c++ -c $(X10CPPFLAGS) -sourcepath ../src-x10 -d ../src-cpp/gen \ $(if $(filter %.jar,$?),$(XRXFILES),$?); touch $@ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ipe...@us...> - 2009-10-02 14:40:11
|
Revision: 11336 http://x10.svn.sourceforge.net/x10/?rev=11336&view=rev Author: ipeshansky Date: 2009-10-02 14:40:00 +0000 (Fri, 02 Oct 2009) Log Message: ----------- Execute static initializers in a separate activity. Spawn each initializer as a separate async (in the C++ backend). Minor tweak to initialization tracing. Modified Paths: -------------- trunk/x10.compiler/data/Main.xcd trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java 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-x10/x10/runtime/Runtime.x10 Modified: trunk/x10.compiler/data/Main.xcd =================================================================== --- trunk/x10.compiler/data/Main.xcd 2009-10-02 14:37:04 UTC (rev 11335) +++ trunk/x10.compiler/data/Main.xcd 2009-10-02 14:40:00 UTC (rev 11336) @@ -12,14 +12,18 @@ // start xrx x10.runtime.Runtime.start( - // body of main activity - new x10.core.fun.VoidFun_0_0() { + // static init activity + new x10.core.fun.VoidFun_0_0() { public void apply() { // preload classes if (Boolean.getBoolean("x10.PRELOAD_CLASSES")) { x10.runtime.impl.java.PreLoader.preLoad(this.getClass().getEnclosingClass(), Boolean.getBoolean("x10.PRELOAD_STRINGS")); } - + } + }, + // body of main activity + new x10.core.fun.VoidFun_0_0() { + public void apply() { // catch and rethrow checked exceptions // (closures cannot throw checked exceptions) try { Modified: trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java =================================================================== --- trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java 2009-10-02 14:37:04 UTC (rev 11335) +++ trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java 2009-10-02 14:40:00 UTC (rev 11336) @@ -1922,7 +1922,7 @@ sw.write(status + " = " + STATIC_FIELD_INITIALIZING + ";"); sw.newline(); // initialize the field - sw.write("_I_(\"Doing static initialisation for field: "+container+"."+fname+"\");"); sw.newline(); + sw.write("_I_(\"Doing static initialisation for field: "+container+"."+name+"\");"); sw.newline(); String val = getId(); emitter.printType(dec.type().type(), sw); sw.allowBreak(2, 2, " ", 1); Modified: trunk/x10.runtime/src-cpp/x10aux/bootstrap.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/bootstrap.cc 2009-10-02 14:37:04 UTC (rev 11335) +++ trunk/x10.runtime/src-cpp/x10aux/bootstrap.cc 2009-10-02 14:40:00 UTC (rev 11336) @@ -9,13 +9,20 @@ x10_int x10aux::exitCode = 0; +x10::lang::VoidFun_0_0::itable<StaticInitClosure> StaticInitClosure::_itable(&StaticInitClosure::apply); + +x10aux::itable_entry StaticInitClosure::_itables[2] = { + x10aux::itable_entry(&x10::lang::VoidFun_0_0::rtt, &_itable), + x10aux::itable_entry(NULL, NULL) +}; + x10::lang::VoidFun_0_0::itable<BootStrapClosure> BootStrapClosure::_itable(&BootStrapClosure::apply); x10aux::itable_entry BootStrapClosure::_itables[2] = { x10aux::itable_entry(&x10::lang::VoidFun_0_0::rtt, &_itable), x10aux::itable_entry(NULL, NULL) }; - + void x10aux::initialize_xrx() { x10::lang::Place::FMGL(MAX_PLACES__do_init)(); x10::lang::Place::FMGL(places__do_init)(); Modified: trunk/x10.runtime/src-cpp/x10aux/bootstrap.h =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/bootstrap.h 2009-10-02 14:37:04 UTC (rev 11335) +++ trunk/x10.runtime/src-cpp/x10aux/bootstrap.h 2009-10-02 14:40:00 UTC (rev 11336) @@ -26,9 +26,38 @@ namespace x10aux { + class StaticInitClosure : public x10::lang::Value + { + public: + + static x10::lang::VoidFun_0_0::itable<StaticInitClosure> _itable; + static x10aux::itable_entry _itables[2]; + + virtual x10aux::itable_entry* _getITables() { return _itables; } + + // closure body + void apply () { + // Initialise the static fields of x10 classes. + x10aux::InitDispatcher::runInitializers(); + } + + StaticInitClosure() { } + + virtual x10_boolean _struct_equals(x10aux::ref<x10::lang::Object> p0) { + return false; // FIXME: should we be able to compare function types structurally? + } + + const x10aux::RuntimeType *_type() const {return x10aux::getRTT<x10::lang::VoidFun_0_0>();} + + ref<x10::lang::String> toString() { + return x10::lang::String::Lit("x10aux::StaticInitClosure ("__FILELINE__")"); + } + + }; + typedef void (*ApplicationMainFunction)(ref<x10::lang::Rail<ref<x10::lang::String> > >); - class BootStrapClosure : public x10::lang::Value + class BootStrapClosure : public x10::lang::Value { protected: @@ -38,14 +67,11 @@ static x10::lang::VoidFun_0_0::itable<BootStrapClosure> _itable; static x10aux::itable_entry _itables[2]; - + virtual x10aux::itable_entry* _getITables() { return _itables; } - + // closure body void apply () { - // Initialise the static fields of x10 classes. - x10aux::InitDispatcher::runInitializers(); - // Invoke the application main(). main(args); } @@ -74,7 +100,7 @@ GC_INIT(); #endif x10aux::place_local::initialize(); - + x10aux::ref<x10::lang::Rail<x10aux::ref<x10::lang::String> > > args = x10aux::convert_args(ac, av); @@ -92,13 +118,19 @@ x10::runtime::Thread::_make(x10aux::null, x10::lang::String::Lit("thread-main")); x10aux::initialize_xrx(); + // Construct closure to invoke the static initialisers at place 0 + x10aux::ref<x10::lang::VoidFun_0_0> init_closure = + x10aux::ref<StaticInitClosure>(new (x10aux::alloc<x10::lang::VoidFun_0_0>(sizeof(x10aux::StaticInitClosure))) + x10aux::StaticInitClosure()); + // Construct closure to invoke the user's "public static def main(Rail[String]) : Void" // if at place 0 otherwise wait for asyncs. x10aux::ref<x10::lang::VoidFun_0_0> main_closure = x10aux::ref<BootStrapClosure>(new (x10aux::alloc<x10::lang::VoidFun_0_0>(sizeof(x10aux::BootStrapClosure))) x10aux::BootStrapClosure(T::main,args)); - - Runtime::start(main_closure); // use XRX + + Runtime::start(init_closure, main_closure); // use XRX + //init_closure->apply(); // bypass XRX //main_closure->apply(); // bypass XRX //sleep(3); Modified: trunk/x10.runtime/src-cpp/x10aux/init_dispatcher.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/init_dispatcher.cc 2009-10-02 14:37:04 UTC (rev 11335) +++ trunk/x10.runtime/src-cpp/x10aux/init_dispatcher.cc 2009-10-02 14:40:00 UTC (rev 11336) @@ -1,5 +1,6 @@ #include <x10aux/config.h> #include <x10aux/init_dispatcher.h> +#include <x10/runtime/Runtime.h> #include <stdio.h> @@ -15,10 +16,51 @@ } } +class InitClosure : public x10::lang::Value +{ + protected: + Initializer init; + + public: + + static x10::lang::VoidFun_0_0::itable<InitClosure> _itable; + static x10aux::itable_entry _itables[2]; + + virtual x10aux::itable_entry* _getITables() { return _itables; } + + // closure body + void apply () { + init(); + } + + InitClosure(Initializer i) : init(i) { } + + virtual x10_boolean _struct_equals(x10aux::ref<x10::lang::Object> p0) { + return false; // FIXME: should we be able to compare function types structurally? + } + + const x10aux::RuntimeType *_type() const {return x10aux::getRTT<x10::lang::VoidFun_0_0>();} + + ref<x10::lang::String> toString() { + return x10::lang::String::Lit("x10aux::InitClosure ("__FILELINE__")"); + } +}; + +x10::lang::VoidFun_0_0::itable<InitClosure> InitClosure::_itable(&InitClosure::apply); + +x10aux::itable_entry InitClosure::_itables[2] = { + x10aux::itable_entry(&x10::lang::VoidFun_0_0::rtt, &_itable), + x10aux::itable_entry(NULL, NULL) +}; + + void InitDispatcher::runInitializers_() { for (int i=0 ; i<initc ; ++i) { - initv[i](); + x10aux::ref<x10::lang::VoidFun_0_0> init_closure = + x10aux::ref<InitClosure>(new (x10aux::alloc<x10::lang::VoidFun_0_0>(sizeof(InitClosure))) + InitClosure(initv[i])); + x10::runtime::Runtime::runAsync(init_closure); } initc = -1; } Modified: trunk/x10.runtime/src-x10/x10/runtime/Runtime.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/runtime/Runtime.x10 2009-10-02 14:37:04 UTC (rev 11335) +++ trunk/x10.runtime/src-x10/x10/runtime/Runtime.x10 2009-10-02 14:40:00 UTC (rev 11336) @@ -76,7 +76,7 @@ /** * Run main activity in a finish */ - public static def start(body:()=>Void):Void { + public static def start(init:()=>Void, body:()=>Void):Void { val rootFinish = new RootFinish(); val pool = new Pool(rootFinish, NativeRuntime.INIT_THREADS); try { @@ -86,7 +86,7 @@ } } if (Thread.currentThread().locInt() == 0) { - execute(new Activity(body, rootFinish, true)); + execute(new Activity(()=>{finish init(); body();}, rootFinish, true)); pool(); if (!NativeRuntime.local(Place.MAX_PLACES - 1)) { for (var i:Int=1; i<Place.MAX_PLACES; i++) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <vj...@us...> - 2009-10-04 16:19:30
|
Revision: 11341 http://x10.svn.sourceforge.net/x10/?rev=11341&view=rev Author: vj0 Date: 2009-10-04 16:19:22 +0000 (Sun, 04 Oct 2009) Log Message: ----------- Fixed the parser and supporting routines so that a struct S can now be named as just S instead of as "struct S". Also fixed a bug in checking overridden methods. The X10 compiler front-end was not catching final methods being overridden. Modified Paths: -------------- trunk/x10.compiler/src/x10/ast/X10AmbTypeNode_c.java trunk/x10.compiler/src/x10/ast/X10Call_c.java trunk/x10.compiler/src/x10/parser/X10Parser.java trunk/x10.compiler/src/x10/parser/X10Parserprs.java trunk/x10.compiler/src/x10/parser/X10Parsersym.java trunk/x10.compiler/src/x10/parser/x10.g trunk/x10.compiler/src/x10/types/X10ParsedClassType_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-x10/x10/lang/Complex.x10 Modified: trunk/x10.compiler/src/x10/ast/X10AmbTypeNode_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10AmbTypeNode_c.java 2009-10-04 02:13:10 UTC (rev 11340) +++ trunk/x10.compiler/src/x10/ast/X10AmbTypeNode_c.java 2009-10-04 16:19:22 UTC (rev 11341) @@ -169,20 +169,13 @@ TypeNode tn = (TypeNode) n; LazyRef<Type> sym = (LazyRef<Type>) type; X10Type t2 = (X10Type) tn.type(); - if (X10Flags.toX10Flags(t2.flags()).isStruct()) { - - if (flags == null || ! X10Flags.toX10Flags(flags).isStruct()) { - t2 = X10TypeMixin.makeRef(t2); - } - } - sym.update(t2); - - if (t2 instanceof X10ParsedClassType) { + + /* if (t2 instanceof X10ParsedClassType) { X10ParsedClassType ct = (X10ParsedClassType) tn.type(); if (ct.x10Def().typeParameters().size() != 0) { throw new SemanticException("Invalid type " + ct + "; incorrect number of type arguments.", position()); } - } + }*/ // Reset the resolver goal to one that can run when the ref is deserialized. Goal resolver = Globals.Scheduler().LookupGlobalType(sym); Modified: trunk/x10.compiler/src/x10/ast/X10Call_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10Call_c.java 2009-10-04 02:13:10 UTC (rev 11340) +++ trunk/x10.compiler/src/x10/ast/X10Call_c.java 2009-10-04 16:19:22 UTC (rev 11341) @@ -13,6 +13,7 @@ import java.util.List; import java.util.Map; +import polyglot.ast.AmbTypeNode; import polyglot.ast.Call; import polyglot.ast.Call_c; import polyglot.ast.ClassBody; @@ -56,6 +57,7 @@ import polyglot.visit.NodeVisitor; import polyglot.visit.TypeBuilder; import polyglot.visit.TypeChecker; +import x10.constraint.XConstraint; import x10.constraint.XLocal; import x10.constraint.XRoot; import x10.parser.X10ParsedName; @@ -188,6 +190,7 @@ return result; } + /** * First try for a struct constructor, and then look for a static method. @@ -198,25 +201,50 @@ * @return * @throws SemanticException */ + protected Node typeCheckNullTarget(ContextVisitor tc, List<Type> typeArgs, List<Type> argTypes, List<Expr> args) throws SemanticException { - if (typeArgs == null || typeArgs.size()==0) { + // if (typeArgs == null || typeArgs.size()==0) { // This could possibly be an invocation of a constructor for a struct. try { X10NodeFactory nf = (X10NodeFactory) tc.nodeFactory(); X10TypeSystem ts = (X10TypeSystem) tc.typeSystem(); Context c = tc.context(); - - TypeBuilder tb = new TypeBuilder(tc.job(), ts, nf); - TypeNode tn = new X10ParsedName(nf, ts, position(), name()).toType(); + // TODO: Actually, determine if there is a struct with the given name, + // and able to accept given typeargs and args. + ts.existsStructWithName(name(), tc); + /* + // ok so it is a struct type. Now create the return type. + tn = nf.AmbDepTypeNode(position(), null, name(), typeArguments, Collections.EMPTY_LIST, null); + ContextVisitor childtc = tc; + tn = (TypeNode) this.visitChild(tn, childtc); + if (tn.type() instanceof UnknownType) { // bail + throw new SemanticException(); + } + + t = tn.type(); + t = ts.expandMacros(t); + + xc = X10TypeMixin.xclause(t); + t = X10TypeMixin.baseType(t); + + if (!(ts.isStructType(t))) { // bail + throw new SemanticException(); + } + tn = (TypeNode) tn.visit(tb); // First ensure that there is a type associated with tn. tn = (TypeNode) tn.disambiguate(tc); - ((AddFlags) tn).addFlags(X10Flags.STRUCT); - - X10New_c call = (X10New_c) nf.New(position(), null, tn, args, null); + tn = (TypeNode) tn.typeCheck(tc); + Type t = tn.type(); + t = ts.expandMacros(t); + tn = tn.typeRef(Types.lazyRef(t)); + */ + TypeBuilder tb = new TypeBuilder(tc.job(), ts, nf); + TypeNode otn = new X10ParsedName(nf, ts, position(), name()).toType();// + X10New_c call = (X10New_c) nf.X10New(position(), otn, typeArguments, args); call.setStructConstructorCall(); call = (X10New_c) call.visit(tb); @@ -233,7 +261,6 @@ call = (X10New_c) call.tryVisit(tc1); if (tc1.errorQueue().errorCount() == 0) { - if (! (ts.isStructType(call.type()))) { StructType ct = call.constructorInstance().def().container().get(); throw new SemanticException("Cannot use struct constructors for non-struct class " + ct, @@ -245,7 +272,7 @@ } catch (SemanticException z) { // This may have caused some errors to print out. } - } + // } // Otherwise try and find the usual null target method. return typeCheckNullTargetForMethod(tc, typeArgs, argTypes); } Modified: trunk/x10.compiler/src/x10/parser/X10Parser.java =================================================================== --- trunk/x10.compiler/src/x10/parser/X10Parser.java 2009-10-04 02:13:10 UTC (rev 11340) +++ trunk/x10.compiler/src/x10/parser/X10Parser.java 2009-10-04 16:19:22 UTC (rev 11341) @@ -1877,7 +1877,7 @@ } // - // Rule 46: Type ::= struct ConstrainedType + // Rule 46: Type ::= proto ConstrainedType // case 46: { //#line 1256 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" @@ -1885,55 +1885,41 @@ TypeNode ConstrainedType = (TypeNode) getRhsSym(2); //#line 1256 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" AddFlags tn = (AddFlags) ConstrainedType; - tn.addFlags(X10Flags.STRUCT); - setResult(tn); - break; - } - - // - // Rule 47: Type ::= proto ConstrainedType - // - case 47: { - //#line 1263 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1261 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" - TypeNode ConstrainedType = (TypeNode) getRhsSym(2); - //#line 1263 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" - AddFlags tn = (AddFlags) ConstrainedType; tn.addFlags(X10Flags.PROTO); setResult(tn); break; } // - // Rule 48: FunctionType ::= TypeArgumentsopt ( FormalParameterListopt ) WhereClauseopt Throwsopt => Type + // Rule 47: FunctionType ::= TypeArgumentsopt ( FormalParameterListopt ) WhereClauseopt Throwsopt => Type // - case 48: { - //#line 1271 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1269 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + case 47: { + //#line 1264 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1262 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" List TypeArgumentsopt = (List) getRhsSym(1); - //#line 1269 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1262 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" List FormalParameterListopt = (List) getRhsSym(3); - //#line 1269 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1262 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" DepParameterExpr WhereClauseopt = (DepParameterExpr) getRhsSym(5); - //#line 1269 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1262 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" List Throwsopt = (List) getRhsSym(6); - //#line 1269 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1262 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" TypeNode Type = (TypeNode) getRhsSym(8); - //#line 1271 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1264 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" setResult(nf.FunctionTypeNode(pos(), TypeArgumentsopt, FormalParameterListopt, WhereClauseopt, Type, Throwsopt)); break; } // - // Rule 53: AnnotatedType ::= Type Annotations + // Rule 52: AnnotatedType ::= Type Annotations // - case 53: { - //#line 1280 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1278 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + case 52: { + //#line 1273 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1271 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" TypeNode Type = (TypeNode) getRhsSym(1); - //#line 1278 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1271 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" List Annotations = (List) getRhsSym(2); - //#line 1280 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1273 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" TypeNode tn = Type; tn = (TypeNode) ((X10Ext) tn.ext()).annotations((List<AnnotationNode>) Annotations); setResult(tn); @@ -1941,25 +1927,25 @@ } // - // Rule 56: ConstrainedType ::= ( Type ) + // Rule 55: ConstrainedType ::= ( Type ) // - case 56: { - //#line 1290 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1288 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + case 55: { + //#line 1283 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1281 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" TypeNode Type = (TypeNode) getRhsSym(2); - //#line 1290 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1283 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" setResult(Type); break; } // - // Rule 57: PlaceType ::= PlaceExpression + // Rule 56: PlaceType ::= PlaceExpression // - case 57: { - //#line 1296 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1294 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + case 56: { + //#line 1289 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1287 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" Expr PlaceExpression = (Expr) getRhsSym(1); - //#line 1296 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1289 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" setResult(nf.Binary(pos(), nf.Field(pos(), nf.This(pos()), nf.Id(pos(), "loc")), Binary.EQ, PlaceExpression)); @@ -1967,21 +1953,21 @@ } // - // Rule 58: NamedType ::= Primary . Identifier TypeArgumentsopt Argumentsopt DepParametersopt + // Rule 57: NamedType ::= Primary . Identifier TypeArgumentsopt Argumentsopt DepParametersopt // - case 58: { - //#line 1304 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1302 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + case 57: { + //#line 1297 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1295 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" Expr Primary = (Expr) getRhsSym(1); - //#line 1302 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1295 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" Id Identifier = (Id) getRhsSym(3); - //#line 1302 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1295 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" List TypeArgumentsopt = (List) getRhsSym(4); - //#line 1302 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1295 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" List Argumentsopt = (List) getRhsSym(5); - //#line 1302 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1295 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" DepParameterExpr DepParametersopt = (DepParameterExpr) getRhsSym(6); - //#line 1304 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1297 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" TypeNode type = nf.X10AmbTypeNode(pos(), Primary, Identifier); // TODO: place constraint if (DepParametersopt != null || (TypeArgumentsopt != null && ! TypeArgumentsopt.isEmpty()) || (Argumentsopt != null && ! Argumentsopt.isEmpty())) { @@ -1992,19 +1978,19 @@ } // - // Rule 59: NamedType ::= TypeName TypeArgumentsopt Argumentsopt DepParametersopt + // Rule 58: NamedType ::= TypeName TypeArgumentsopt Argumentsopt DepParametersopt // - case 59: { - //#line 1315 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1313 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + case 58: { + //#line 1308 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1306 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" ParsedName TypeName = (ParsedName) getRhsSym(1); - //#line 1313 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1306 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" List TypeArgumentsopt = (List) getRhsSym(2); - //#line 1313 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1306 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" List Argumentsopt = (List) getRhsSym(3); - //#line 1313 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1306 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" DepParameterExpr DepParametersopt = (DepParameterExpr) getRhsSym(4); - //#line 1315 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1308 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" TypeNode type; if (TypeName.name.id().toString().equals("void")) { @@ -2029,120 +2015,120 @@ } // - // Rule 60: DepParameters ::= { ExistentialListopt Conjunction } + // Rule 59: DepParameters ::= { ExistentialListopt Conjunction } // - case 60: { - //#line 1341 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1339 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + case 59: { + //#line 1334 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1332 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" List ExistentialListopt = (List) getRhsSym(2); - //#line 1339 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1332 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" List Conjunction = (List) getRhsSym(3); - //#line 1341 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1334 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" setResult(nf.DepParameterExpr(pos(), ExistentialListopt, Conjunction)); break; } // - // Rule 61: DepParameters ::= ! PlaceType + // Rule 60: DepParameters ::= ! PlaceType // - case 61: { - //#line 1346 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1344 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + case 60: { + //#line 1339 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1337 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" Expr PlaceType = (Expr) getRhsSym(2); - //#line 1346 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1339 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" Expr placeClause = nf.Call(pos(), nf.Self(pos()), nf.Id(pos(), "at"), PlaceType); setResult(nf.DepParameterExpr(pos(), null, Collections.singletonList(placeClause))); break; } // - // Rule 62: DepParameters ::= ! + // Rule 61: DepParameters ::= ! // - case 62: { - //#line 1352 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + case 61: { + //#line 1345 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1352 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1345 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" Expr placeClause = nf.Call(pos(), nf.Self(pos()), nf.Id(pos(), "at"), nf.AmbHereThis(pos())); setResult(nf.DepParameterExpr(pos(), null, Collections.singletonList(placeClause))); break; } // - // Rule 63: DepParameters ::= ! PlaceType { ExistentialListopt Conjunction } + // Rule 62: DepParameters ::= ! PlaceType { ExistentialListopt Conjunction } // - case 63: { - //#line 1358 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1356 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + case 62: { + //#line 1351 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1349 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" Expr PlaceType = (Expr) getRhsSym(2); - //#line 1356 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1349 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" List ExistentialListopt = (List) getRhsSym(4); - //#line 1356 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1349 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" List Conjunction = (List) getRhsSym(5); - //#line 1358 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1351 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" Expr placeClause = nf.Call(pos(), nf.Self(pos()), nf.Id(pos(), "at"), PlaceType); setResult(nf.DepParameterExpr(pos(), ExistentialListopt, CollectionUtil.append(Conjunction, Collections.singletonList(placeClause)))); break; } // - // Rule 64: DepParameters ::= ! { ExistentialListopt Conjunction } + // Rule 63: DepParameters ::= ! { ExistentialListopt Conjunction } // - case 64: { - //#line 1364 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1362 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + case 63: { + //#line 1357 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1355 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" List ExistentialListopt = (List) getRhsSym(3); - //#line 1362 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1355 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" List Conjunction = (List) getRhsSym(4); - //#line 1364 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1357 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" Expr placeClause = nf.Call(pos(), nf.Self(pos()), nf.Id(pos(), "at"), nf.AmbHereThis(pos())); setResult(nf.DepParameterExpr(pos(), ExistentialListopt, CollectionUtil.append(Conjunction, Collections.singletonList(placeClause)))); break; } // - // Rule 65: TypeParamsWithVariance ::= [ TypeParamWithVarianceList ] + // Rule 64: TypeParamsWithVariance ::= [ TypeParamWithVarianceList ] // - case 65: { - //#line 1372 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1370 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + case 64: { + //#line 1365 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1363 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" List TypeParamWithVarianceList = (List) getRhsSym(2); - //#line 1372 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1365 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" setResult(TypeParamWithVarianceList); break; } // - // Rule 66: TypeParameters ::= [ TypeParameterList ] + // Rule 65: TypeParameters ::= [ TypeParameterList ] // - case 66: { - //#line 1378 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1376 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + case 65: { + //#line 1371 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1369 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" List TypeParameterList = (List) getRhsSym(2); - //#line 1378 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1371 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" setResult(TypeParameterList); break; } // - // Rule 67: FormalParameters ::= ( FormalParameterListopt ) + // Rule 66: FormalParameters ::= ( FormalParameterListopt ) // - case 67: { - //#line 1383 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1381 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + case 66: { + //#line 1376 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1374 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" List FormalParameterListopt = (List) getRhsSym(2); - //#line 1383 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1376 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" setResult(FormalParameterListopt); break; } // - // Rule 68: Conjunction ::= Expression + // Rule 67: Conjunction ::= Expression // - case 68: { - //#line 1389 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1387 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + case 67: { + //#line 1382 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1380 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" Expr Expression = (Expr) getRhsSym(1); - //#line 1389 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1382 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" List l = new ArrayList(); l.add(Expression); setResult(l); @@ -2150,90 +2136,90 @@ } // - // Rule 69: Conjunction ::= Conjunction , Expression + // Rule 68: Conjunction ::= Conjunction , Expression // - case 69: { - //#line 1396 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1394 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + case 68: { + //#line 1389 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1387 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" List Conjunction = (List) getRhsSym(1); - //#line 1394 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1387 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" Expr Expression = (Expr) getRhsSym(3); - //#line 1396 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1389 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" Conjunction.add(Expression); break; } // - // Rule 70: SubtypeConstraint ::= Type$t1 <: Type$t2 + // Rule 69: SubtypeConstraint ::= Type$t1 <: Type$t2 // - case 70: { - //#line 1402 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1400 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + case 69: { + //#line 1395 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1393 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" TypeNode t1 = (TypeNode) getRhsSym(1); - //#line 1400 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1393 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" TypeNode t2 = (TypeNode) getRhsSym(3); - //#line 1402 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1395 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" setResult(nf.SubtypeTest(pos(), t1, t2, false)); break; } // - // Rule 71: SubtypeConstraint ::= Type$t1 :> Type$t2 + // Rule 70: SubtypeConstraint ::= Type$t1 :> Type$t2 // - case 71: { - //#line 1407 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1405 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + case 70: { + //#line 1400 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1398 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" TypeNode t1 = (TypeNode) getRhsSym(1); - //#line 1405 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1398 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" TypeNode t2 = (TypeNode) getRhsSym(3); - //#line 1407 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1400 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" setResult(nf.SubtypeTest(pos(), t2, t1, false)); break; } // - // Rule 72: WhereClause ::= DepParameters + // Rule 71: WhereClause ::= DepParameters // - case 72: { - //#line 1413 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1411 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + case 71: { + //#line 1406 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1404 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" DepParameterExpr DepParameters = (DepParameterExpr) getRhsSym(1); - //#line 1413 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1406 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" setResult(DepParameters); break; } // - // Rule 73: ExistentialListopt ::= $Empty + // Rule 72: ExistentialListopt ::= $Empty // - case 73: { - //#line 1419 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + case 72: { + //#line 1412 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1419 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1412 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" setResult(new ArrayList()); break; } // - // Rule 74: ExistentialListopt ::= ExistentialList ; + // Rule 73: ExistentialListopt ::= ExistentialList ; // - case 74: { - //#line 1424 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1422 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + case 73: { + //#line 1417 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1415 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" List ExistentialList = (List) getRhsSym(1); - //#line 1424 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1417 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" setResult(ExistentialList); break; } // - // Rule 75: ExistentialList ::= FormalParameter + // Rule 74: ExistentialList ::= FormalParameter // - case 75: { - //#line 1430 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1428 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + case 74: { + //#line 1423 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1421 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" X10Formal FormalParameter = (X10Formal) getRhsSym(1); - //#line 1430 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1423 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" List l = new TypedList(new LinkedList(), Formal.class, false); l.add(FormalParameter.flags(nf.FlagsNode(pos(), Flags.FINAL))); setResult(l); @@ -2241,41 +2227,41 @@ } // - // Rule 76: ExistentialList ::= ExistentialList ; FormalParameter + // Rule 75: ExistentialList ::= ExistentialList ; FormalParameter // - case 76: { - //#line 1437 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1435 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + case 75: { + //#line 1430 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1428 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" List ExistentialList = (List) getRhsSym(1); - //#line 1435 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1428 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" X10Formal FormalParameter = (X10Formal) getRhsSym(3); - //#line 1437 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1430 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" ExistentialList.add(FormalParameter.flags(nf.FlagsNode(pos(), Flags.FINAL))); break; } // - // Rule 79: NormalClassDeclaration ::= ClassModifiersopt class Identifier TypeParamsWithVarianceopt Propertiesopt WhereClauseopt Superopt Interfacesopt ClassBody + // Rule 78: NormalClassDeclaration ::= ClassModifiersopt class Identifier TypeParamsWithVarianceopt Propertiesopt WhereClauseopt Superopt Interfacesopt ClassBody // - case 79: { - //#line 1448 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1446 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + case 78: { + //#line 1441 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1439 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" List ClassModifiersopt = (List) getRhsSym(1); - //#line 1446 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1439 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" Id Identifier = (Id) getRhsSym(3); - //#line 1446 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1439 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" List TypeParamsWithVarianceopt = (List) getRhsSym(4); - //#line 1446 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1439 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" List Propertiesopt = (List) getRhsSym(5); - //#line 1446 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1439 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" DepParameterExpr WhereClauseopt = (DepParameterExpr) getRhsSym(6); - //#line 1446 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1439 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" TypeNode Superopt = (TypeNode) getRhsSym(7); - //#line 1446 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1439 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" List Interfacesopt = (List) getRhsSym(8); - //#line 1446 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1439 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" ClassBody ClassBody = (ClassBody) getRhsSym(9); - //#line 1448 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1441 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" checkTypeName(Identifier); List TypeParametersopt = TypeParamsWithVarianceopt; List/*<PropertyDecl>*/ props = Propertiesopt; @@ -2290,27 +2276,27 @@ } // - // Rule 80: ValueClassDeclaration ::= ClassModifiersopt value Identifier TypeParamsWithVarianceopt Propertiesopt WhereClauseopt Superopt Interfacesopt ClassBody + // Rule 79: ValueClassDeclaration ::= ClassModifiersopt value Identifier TypeParamsWithVarianceopt Propertiesopt WhereClauseopt Superopt Interfacesopt ClassBody // - case 80: { - //#line 1463 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1461 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + case 79: { + //#line 1456 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1454 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" List ClassModifiersopt = (List) getRhsSym(1); - //#line 1461 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1454 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" Id Identifier = (Id) getRhsSym(3); - //#line 1461 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1454 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" List TypeParamsWithVarianceopt = (List) getRhsSym(4); - //#line 1461 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1454 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" List Propertiesopt = (List) getRhsSym(5); - //#line 1461 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1454 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" DepParameterExpr WhereClauseopt = (DepParameterExpr) getRhsSym(6); - //#line 1461 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1454 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" TypeNode Superopt = (TypeNode) getRhsSym(7); - //#line 1461 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1454 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" List Interfacesopt = (List) getRhsSym(8); - //#line 1461 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1454 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" ClassBody ClassBody = (ClassBody) getRhsSym(9); - //#line 1463 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1456 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" checkTypeName(Identifier); List TypeParametersopt = TypeParamsWithVarianceopt; List props = Propertiesopt; @@ -2324,27 +2310,27 @@ } // - // Rule 81: ValueClassDeclaration ::= ClassModifiersopt struct Identifier TypeParamsWithVarianceopt Propertiesopt WhereClauseopt Superopt Interfacesopt ClassBody + // Rule 80: ValueClassDeclaration ::= ClassModifiersopt struct Identifier TypeParamsWithVarianceopt Propertiesopt WhereClauseopt Superopt Interfacesopt ClassBody // - case 81: { - //#line 1477 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1475 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + case 80: { + //#line 1470 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1468 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" List ClassModifiersopt = (List) getRhsSym(1); - //#line 1475 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1468 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" Id Identifier = (Id) getRhsSym(3); - //#line 1475 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1468 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" List TypeParamsWithVarianceopt = (List) getRhsSym(4); - //#line 1475 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1468 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" List Propertiesopt = (List) getRhsSym(5); - //#line 1475 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1468 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" DepParameterExpr WhereClauseopt = (DepParameterExpr) getRhsSym(6); - //#line 1475 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1468 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" TypeNode Superopt = (TypeNode) getRhsSym(7); - //#line 1475 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1468 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" List Interfacesopt = (List) getRhsSym(8); - //#line 1475 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1468 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" ClassBody ClassBody = (ClassBody) getRhsSym(9); - //#line 1477 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1470 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" checkTypeName(Identifier); List TypeParametersopt = TypeParamsWithVarianceopt; List props = Propertiesopt; @@ -2358,25 +2344,25 @@ } // - // Rule 82: ConstructorDeclaration ::= ConstructorModifiersopt def this TypeParametersopt FormalParameters WhereClauseopt ResultTypeopt Throwsopt ConstructorBody + // Rule 81: ConstructorDeclaration ::= ConstructorModifiersopt def this TypeParametersopt FormalParameters WhereClauseopt ResultTypeopt Throwsopt ConstructorBody // - case 82: { - //#line 1491 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1489 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + case 81: { + //#line 1484 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1482 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" List ConstructorModifiersopt = (List) getRhsSym(1); - //#line 1489 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1482 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" List TypeParametersopt = (List) getRhsSym(4); - //#line 1489 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1482 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" List FormalParameters = (List) getRhsSym(5); - //#line 1489 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1482 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" DepParameterExpr WhereClauseopt = (DepParameterExpr) getRhsSym(6); - //#line 1489 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1482 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" TypeNode ResultTypeopt = (TypeNode) getRhsSym(7); - //#line 1489 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1482 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" List Throwsopt = (List) getRhsSym(8); - //#line 1489 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1482 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" Block ConstructorBody = (Block) getRhsSym(9); - //#line 1491 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1484 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" ConstructorDecl cd = nf.X10ConstructorDecl(pos(), extractFlags(ConstructorModifiersopt), nf.Id(pos(3), "this"), @@ -2392,98 +2378,84 @@ } // - // Rule 83: Super ::= extends ClassType + // Rule 82: Super ::= extends ClassType // - case 83: { - //#line 1507 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1505 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + case 82: { + //#line 1500 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1498 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" TypeNode ClassType = (TypeNode) getRhsSym(2); - //#line 1507 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1500 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" setResult(ClassType); break; } // - // Rule 84: Super ::= extends struct ClassType + // Rule 83: FieldKeyword ::= val // - case 84: { - //#line 1512 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1510 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" - TypeNode ClassType = (TypeNode) getRhsSym(3); - //#line 1512 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" - AddFlags tn = (AddFlags) ClassType; - tn.addFlags(X10Flags.STRUCT); - setResult(tn); - break; - } - - // - // Rule 85: FieldKeyword ::= val - // - case 85: { - //#line 1520 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + case 83: { + //#line 1506 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1520 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1506 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" setResult(Collections.singletonList(nf.FlagsNode(pos(), Flags.FINAL))); break; } // - // Rule 86: FieldKeyword ::= var + // Rule 84: FieldKeyword ::= var // - case 86: { - //#line 1525 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + case 84: { + //#line 1511 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1525 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1511 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" setResult(Collections.singletonList(nf.FlagsNode(pos(), Flags.NONE))); break; } // - // Rule 87: FieldKeyword ::= const + // Rule 85: FieldKeyword ::= const // - case 87: { - //#line 1530 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + case 85: { + //#line 1516 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1530 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1516 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" setResult(Collections.singletonList(nf.FlagsNode(pos(), Flags.FINAL.Static()))); break; } // - // Rule 88: VarKeyword ::= val + // Rule 86: VarKeyword ::= val // - case 88: { - //#line 1538 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + case 86: { + //#line 1524 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1538 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1524 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" setResult(Collections.singletonList(nf.FlagsNode(pos(), Flags.FINAL))); break; } // - // Rule 89: VarKeyword ::= var + // Rule 87: VarKeyword ::= var // - case 89: { - //#line 1543 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + case 87: { + //#line 1529 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1543 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1529 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" setResult(Collections.singletonList(nf.FlagsNode(pos(), Flags.NONE))); break; } // - // Rule 90: FieldDeclaration ::= FieldModifiersopt FieldKeyword FieldDeclarators ; + // Rule 88: FieldDeclaration ::= FieldModifiersopt FieldKeyword FieldDeclarators ; // - case 90: { - //#line 1550 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1548 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + case 88: { + //#line 1536 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1534 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" List FieldModifiersopt = (List) getRhsSym(1); - //#line 1548 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1534 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" List FieldKeyword = (List) getRhsSym(2); - //#line 1548 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1534 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" List FieldDeclarators = (List) getRhsSym(3); - //#line 1550 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1536 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" FlagsNode fn = extractFlags(FieldModifiersopt, FieldKeyword); List l = new TypedList(new LinkedList(), ClassMember.class, false); @@ -2507,15 +2479,15 @@ } // - // Rule 91: FieldDeclaration ::= FieldModifiersopt FieldDeclarators ; + // Rule 89: FieldDeclaration ::= FieldModifiersopt FieldDeclarators ; // - case 91: { - //#line 1574 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1572 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + case 89: { + //#line 1560 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1558 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" List FieldModifiersopt = (List) getRhsSym(1); - //#line 1572 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1558 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" List FieldDeclarators = (List) getRhsSym(2); - //#line 1574 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1560 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" List FieldKeyword = Collections.singletonList(nf.FlagsNode(pos(), Flags.FINAL)); FlagsNode fn = extractFlags(FieldModifiersopt, FieldKeyword); @@ -2540,68 +2512,68 @@ } // - // Rule 121: IfThenStatement ::= if ( Expression ) Statement + // Rule 119: IfThenStatement ::= if ( Expression ) Statement // - case 121: { - //#line 1633 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1631 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + case 119: { + //#line 1619 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1617 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" Expr Expression = (Expr) getRhsSym(3); - //#line 1631 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1617 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" Stmt Statement = (Stmt) getRhsSym(5); - //#line 1633 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1619 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" setResult(nf.If(pos(), Expression, Statement)); break; } // - // Rule 122: IfThenElseStatement ::= if ( Expression ) Statement$s1 else Statement$s2 + // Rule 120: IfThenElseStatement ::= if ( Expression ) Statement$s1 else Statement$s2 // - case 122: { - //#line 1639 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1637 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + case 120: { + //#line 1625 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1623 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" Expr Expression = (Expr) getRhsSym(3); - //#line 1637 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1623 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" Stmt s1 = (Stmt) getRhsSym(5); - //#line 1637 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1623 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" Stmt s2 = (Stmt) getRhsSym(7); - //#line 1639 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1625 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" setResult(nf.If(pos(), Expression, s1, s2)); break; } // - // Rule 123: EmptyStatement ::= ; + // Rule 121: EmptyStatement ::= ; // - case 123: { - //#line 1645 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + case 121: { + //#line 1631 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1645 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1631 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" setResult(nf.Empty(pos())); break; } // - // Rule 124: LabeledStatement ::= Identifier : LoopStatement + // Rule 122: LabeledStatement ::= Identifier : LoopStatement // - case 124: { - //#line 1651 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1649 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + case 122: { + //#line 1637 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1635 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" Id Identifier = (Id) getRhsSym(1); - //#line 1649 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1635 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" Stmt LoopStatement = (Stmt) getRhsSym(3); - //#line 1651 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1637 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" setResult(nf.Labeled(pos(), Identifier, LoopStatement)); break; } // - // Rule 130: ExpressionStatement ::= StatementExpression ; + // Rule 128: ExpressionStatement ::= StatementExpression ; // - case 130: { - //#line 1663 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1661 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + case 128: { + //#line 1649 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1647 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" Expr StatementExpression = (Expr) getRhsSym(1); - //#line 1663 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1649 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" boolean eval = true; if (StatementExpression instanceof X10Call) { X10Call c = (X10Call) StatementExpression; @@ -2624,85 +2596,85 @@ } // - // Rule 138: AssertStatement ::= assert Expression ; + // Rule 136: AssertStatement ::= assert Expression ; // - case 138: { - //#line 1694 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1692 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + case 136: { + //#line 1680 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1678 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" Expr Expression = (Expr) getRhsSym(2); - //#line 1694 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1680 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" setResult(nf.Assert(pos(), Expression)); break; } // - ... [truncated message content] |
From: <dgr...@us...> - 2009-10-05 02:49:52
|
Revision: 11350 http://x10.svn.sourceforge.net/x10/?rev=11350&view=rev Author: dgrove-oss Date: 2009-10-05 02:49:33 +0000 (Mon, 05 Oct 2009) Log Message: ----------- We're no longer attempting to use g++ 4.1 as a post-compiler, so remove various hacks that were used to workaround the g++ 4.1 bug related to expression statements (XTENLANG-461). Modified Paths: -------------- trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java trunk/x10.runtime/src-cpp/x10aux/ref.h Modified: trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java =================================================================== --- trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java 2009-10-05 01:56:40 UTC (rev 11349) +++ trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java 2009-10-05 02:49:33 UTC (rev 11350) @@ -2703,13 +2703,8 @@ sw.write("x10aux::nullCheck("); n.printSubExpr((Expr) target, assoc, sw, tr); sw.write(needsPlaceCheck ? ")); " : "); "); - if (ret_type.isVoid()) { - sw.write("(_.operator->()->*(x10aux::findITable"+chevrons(Emitter.translateType(clsType, false))+"(_->_getITables())->"+itable.mangledName(mi)+"))"); - dangling = "; }))"; - } else { - sw.write("x10aux::GXX_ICE_Workaround"+chevrons(Emitter.translateType(ret_type, true))+"::_((_.operator->()->*(x10aux::findITable"+chevrons(Emitter.translateType(clsType, false))+"(_->_getITables())->"+itable.mangledName(mi)+"))"); - dangling = "); }))"; - } + sw.write("(_.operator->()->*(x10aux::findITable"+chevrons(Emitter.translateType(clsType, false))+"(_->_getITables())->"+itable.mangledName(mi)+"))"); + dangling = "; }))"; } } @@ -3301,7 +3296,7 @@ sw.write("x10aux::ref<x10::lang::Object> " + name + " = "+iteratorTypeRef); sw.write("(__extension__ ({ x10aux::ref<x10::lang::Object> _1 = x10aux::placeCheck(x10aux::nullCheck("); n.print(domain, sw, tr); - sw.write(")); x10aux::GXX_ICE_Workaround"+chevrons(iteratorTypeRef)+"::_((_1.operator->()->*(x10aux::findITable"+chevrons(iterableType)+"(_1->_getITables())->iterator))()); }));"); sw.newline(); + sw.write(")); (_1.operator->()->*(x10aux::findITable"+chevrons(iterableType)+"(_1->_getITables())->iterator))(); }));"); sw.newline(); sw.write((doubleTemplate ? "typename " : "")+iteratorType+"::"+(doubleTemplate ? "template ":"")+"itable<x10::lang::Object> *"+itableName+" = x10aux::findITable"+chevrons(iteratorType)+"("+name+"->_getITables());"); sw.newline(); sw.write("for ("); @@ -3822,14 +3817,6 @@ if (!retType.isVoid()) { sw.newline(); sw.write(ret); - X10TypeSystem_c xts = (X10TypeSystem_c) tr.typeSystem(); - // Workaround for a g++ ICE (XTENLANG-461) - if (retType.isClass() && - (xts.isSubtype(retType, xts.Ref(), tr.context()) || - retType.toClass().flags().isInterface())) - { - sw.write(".operator->()"); - } sw.write(";"); } ctx.finalizeClosureInstance(); @@ -3875,7 +3862,7 @@ if (lit != null || (t.isClass() && t.toClass().flags().isInterface())) { sw.write("(__extension__ ({ x10aux::ref<x10::lang::Object> _ = x10aux::placeCheck(x10aux::nullCheck("); c.printSubExpr(target, sw, tr); - sw.write(")); "+(mi.returnType().isVoid() ? "" : "x10aux::GXX_ICE_Workaround"+chevrons(Emitter.translateType(mi.returnType(), true))+"::_")+"((_.operator->()->*(x10aux::findITable"+chevrons(Emitter.translateType(target.type(), false))+"(_->_getITables())->apply))(");; + sw.write(")); "+"((_.operator->()->*(x10aux::findITable"+chevrons(Emitter.translateType(target.type(), false))+"(_->_getITables())->apply))(");; terminate = ");}))"; } else { sw.write("x10aux::placeCheck(x10aux::nullCheck("); Modified: trunk/x10.runtime/src-cpp/x10aux/ref.h =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/ref.h 2009-10-05 01:56:40 UTC (rev 11349) +++ trunk/x10.runtime/src-cpp/x10aux/ref.h 2009-10-05 02:49:33 UTC (rev 11350) @@ -169,18 +169,6 @@ return obj; } - // Hack around g++ 4.1 bugs with statement expression. - // See XTENLANG-461. -#if defined(__GNUC__) - template <class T> inline ref<T> nullCheck(T* obj) { - return nullCheck(x10aux::ref<T>(obj)); - } - - template <class T> inline ref<T> placeCheck(T* obj) { - return placeCheck(x10aux::ref<T>(obj)); - } -#endif - // will be initialised to null typedef ref<x10::lang::Object> NullType; static NullType null; @@ -219,15 +207,6 @@ return location(ptr.operator->()); } - // Hack around g++ 4.1 bugs with statement expression. - // See XTENLANG-461. -#if defined(__GNUC__) - template<class T> class GXX_ICE_Workaround { public: static inline T _(T v) { return v; } }; - template<class T> class GXX_ICE_Workaround<ref<T> > { public: static inline T* _(ref<T> v) { return v.operator->(); } }; -#else - template<class T> class GXX_ICE_Workaround { public: static inline T _(T v) { return v; } }; -#endif - } //namespace x10 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dgr...@us...> - 2009-10-05 22:03:34
|
Revision: 11357 http://x10.svn.sourceforge.net/x10/?rev=11357&view=rev Author: dgrove-oss Date: 2009-10-05 22:03:22 +0000 (Mon, 05 Oct 2009) Log Message: ----------- (1) Generate hashCode redirection and default hashCode methods for structs (approx. same hack as toString committed in r11340). (2) Steps towards getting the rest of the code base to the point where x10.runtime.RID could become a struct instead of a Value. (a) Tweaks to c++ @Native annotations for hashCode, toString, and className. (b) Changes definition of equals so that Ref and Value are both collapsed into a single method that takes an Object (instead of a pair of overloeded methods). Change was necessary to make progress on getting calls to equals in HashMap to do the right thing when HashMap is used with struct version of RID as the key. I tested FRASimpleDist, HelloWorldPar, and MontyPi and they all ran ok with the change in the definition in equals. It's entirely possible that some test cases are going to break (but I think those are exactly the test cases that are going to have to break as we move to the 2.0 object model where Value disappears and Object becomes a class instead of an interface). Note: RID being a struct still doesn't work due to additional issues in equals that need further work. Continuing along this path... Modified Paths: -------------- trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java 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/RailIterator.h trunk/x10.runtime/src-cpp/x10/lang/Ref.h trunk/x10.runtime/src-cpp/x10/lang/Value.cc trunk/x10.runtime/src-cpp/x10/lang/Value.h trunk/x10.runtime/src-cpp/x10aux/basic_functions.h trunk/x10.runtime/src-x10/x10/lang/Box.x10 trunk/x10.runtime/src-x10/x10/lang/Object.x10 trunk/x10.runtime/src-x10/x10/lang/Primitive.x10 trunk/x10.runtime/src-x10/x10/lang/Ref.x10 trunk/x10.runtime/src-x10/x10/lang/String.x10 trunk/x10.runtime/src-x10/x10/lang/Value.x10 Modified: trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java =================================================================== --- trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java 2009-10-05 21:44:40 UTC (rev 11356) +++ trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java 2009-10-05 22:03:22 UTC (rev 11357) @@ -1146,6 +1146,12 @@ h.write("return x10::lang::Object::"+DESERIALIZE_METHOD+"<__T>(buf);"); h.end(); h.newline(); h.write("}"); h.newline(); h.forceNewline(); + /* equals redirection method: Something of an interface type is a subclass of Object even if C++ doesn't know that... */ + h.write("x10_boolean equals(x10aux::ref<x10::lang::Object> that) {"); h.newline(4); h.begin(0); + h.write("return x10aux::class_cast_unchecked<x10aux::ref<x10::lang::Object> >(this)->equals(that);"); + h.end(); h.newline(); + h.write("}"); h.newline(); h.forceNewline(); + if (!members.isEmpty()) { String className = Emitter.translateType(currentClass); @@ -1338,6 +1344,7 @@ ClassifiedStream sh = context.structHeader; ClassifiedStream h = sw.header(); boolean seenToString = false; // HACK for struct toString. See comment below. + boolean seenHashCode = false; // HACK. Same basic issue as toString... sh.write("public:"); sh.newline(); @@ -1387,6 +1394,13 @@ xts.typeBaseEquals(xts.String(), mdecl.returnType().type(), context)) { seenToString = true; } + if (mdecl.name().id().toString().equals("hashCode") && + mdecl.formals().isEmpty() && + !mdecl.flags().flags().isStatic() && + xts.typeBaseEquals(xts.Int(), mdecl.returnType().type(), context)) { + seenHashCode = true; + } + } } @@ -1463,7 +1477,35 @@ sw.end(); sw.newline(); sw.writeln("}"); sw.forceNewline(); } - + if (seenHashCode) { + // define redirection method + sh.writeln("x10_int hashCode();"); sh.forceNewline(); + sw.write("x10_int "+ Emitter.translateType(currentClass, false)+ "::hashCode() {"); + sw.newline(4); sw.begin(0); + sw.write("return "+Emitter.structMethodClass(currentClass, true)+"::hashCode(*this);"); + sw.end(); sw.newline(); + sw.writeln("}"); + } else { + // define default hashCode by hashing all fields. + sh.writeln("x10_int hashCode();"); sh.forceNewline(); + sw.write("x10_int "+ Emitter.translateType(currentClass, false)+ "::hashCode() {"); + sw.newline(4); sw.begin(0); + 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(); + // TODO: better hash code combining function here! + sw.writeln("result += x10aux::hash_code(this->"+mangled_field_name(name)+");"); + } + } + sw.writeln("return result;"); + sw.end(); sw.newline(); + sw.writeln("}"); sw.forceNewline(); + } + sw.end(); sw.newline(); @@ -2607,13 +2649,6 @@ counter++; } - // [IP] FIXME: accommodate the frontend hack for the equals method - if (mi.name() == Name.make("equals") && args.size() == 1 && mi.typeParameters().size() == 0 && - xts.isParameterType(mi.formalTypes().get(0))) - { - args.set(0, cast(args.get(0), xts.Object())); - } - String pat = getCppImplForDef(md); if (pat != null) { emitNativeAnnotation(pat, mi.typeParameters(), target, args); Modified: trunk/x10.runtime/src-cpp/x10/lang/Object.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Object.cc 2009-10-05 21:44:40 UTC (rev 11356) +++ trunk/x10.runtime/src-cpp/x10/lang/Object.cc 2009-10-05 22:03:22 UTC (rev 11357) @@ -26,12 +26,7 @@ } x10_boolean Object::equals(x10aux::ref<Object> other) { - if (x10aux::instanceof<Value>(other)) - return this->equals(x10aux::ref<Value>(reinterpret_cast<Value*>(other.operator->()))); - if (x10aux::instanceof<Ref>(other)) - return this->equals(x10aux::ref<Ref>(reinterpret_cast<Ref*>(other.operator->()))); - assert (false && "Unknown reference type"); - return false; + return this->_struct_equals(other); } x10aux::RuntimeType x10::lang::Object::rtt; Modified: trunk/x10.runtime/src-cpp/x10/lang/Object.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Object.h 2009-10-05 21:44:40 UTC (rev 11356) +++ trunk/x10.runtime/src-cpp/x10/lang/Object.h 2009-10-05 22:03:22 UTC (rev 11357) @@ -53,10 +53,8 @@ template<class T> static x10aux::ref<T> _deserialize(x10aux::deserialization_buffer &buf); - x10_boolean equals(x10aux::ref<Object> other); + virtual x10_boolean equals(x10aux::ref<Object> other); - virtual x10_boolean equals(x10aux::ref<Ref> other) = 0; - virtual x10_boolean equals(x10aux::ref<Value> other) = 0; virtual x10_int hashCode() = 0; virtual x10aux::ref<String> toString() = 0; Modified: trunk/x10.runtime/src-cpp/x10/lang/RailIterator.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/RailIterator.h 2009-10-05 21:44:40 UTC (rev 11356) +++ trunk/x10.runtime/src-cpp/x10/lang/RailIterator.h 2009-10-05 22:03:22 UTC (rev 11357) @@ -44,7 +44,7 @@ virtual x10_int hashCode() { return 0; } - virtual x10_boolean equals(x10aux::ref<Ref> other) { + virtual x10_boolean equals(x10aux::ref<Object> other) { if (!x10aux::concrete_instanceof<RailIterator>(other)) return false; x10aux::ref<RailIterator> other_i = other; if (other_i->data != data) return false; @@ -52,10 +52,6 @@ return true; } - virtual x10_boolean equals(x10aux::ref<Value> other) { - return this->Ref::equals(other); - } - virtual x10aux::ref<String> toString() { return new (x10aux::alloc<String>()) String(); } Modified: trunk/x10.runtime/src-cpp/x10/lang/Ref.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Ref.h 2009-10-05 21:44:40 UTC (rev 11356) +++ trunk/x10.runtime/src-cpp/x10/lang/Ref.h 2009-10-05 22:03:22 UTC (rev 11357) @@ -51,15 +51,6 @@ virtual x10aux::ref<String> toString(); - virtual x10_boolean equals(x10aux::ref<Ref> other) { - if (other == x10aux::ref<Ref>(this)) return true; - return false; - } - - virtual x10_boolean equals(x10aux::ref<Value> other) { - return false; - } - // Needed for linking - do not override virtual x10_boolean _struct_equals(x10aux::ref<Object> other) { if (other == x10aux::ref<Ref>(this)) return true; Modified: trunk/x10.runtime/src-cpp/x10/lang/Value.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Value.cc 2009-10-05 21:44:40 UTC (rev 11356) +++ trunk/x10.runtime/src-cpp/x10/lang/Value.cc 2009-10-05 22:03:22 UTC (rev 11357) @@ -31,13 +31,6 @@ } x10_boolean -Value::equals(x10aux::ref<Value> other) { - if (other == x10aux::ref<Value>(this)) return true; - if (!x10aux::instanceof<Value>(other)) return false; - return this->_struct_equals(other); -} - -x10_boolean Value::_struct_equals(x10aux::ref<Object> other) { if (!_type()->concreteInstanceOf(other)) return false; Modified: trunk/x10.runtime/src-cpp/x10/lang/Value.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Value.h 2009-10-05 21:44:40 UTC (rev 11356) +++ trunk/x10.runtime/src-cpp/x10/lang/Value.h 2009-10-05 22:03:22 UTC (rev 11357) @@ -50,12 +50,6 @@ virtual x10aux::ref<String> toString(); - virtual x10_boolean equals(x10aux::ref<Value> other); - - virtual x10_boolean equals(x10aux::ref<Ref> other) { - return false; - } - virtual x10_boolean _struct_equals(x10aux::ref<Object> other); }; Modified: trunk/x10.runtime/src-cpp/x10aux/basic_functions.h =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/basic_functions.h 2009-10-05 21:44:40 UTC (rev 11356) +++ trunk/x10.runtime/src-cpp/x10aux/basic_functions.h 2009-10-05 22:03:22 UTC (rev 11357) @@ -55,11 +55,6 @@ public: static inline x10_boolean _(ref<T> x, ref<U> y) { return nullCheck(x)->equals(y); } }; - template<class T> - class Equals<T, x10::lang::Object> { - public: static inline x10_boolean _(ref<T> x, ref<x10::lang::Object> y) { return nullCheck(x)->x10::lang::Object::equals(y); } - }; - template<class T, class U> inline x10_boolean equals(ref<T> x, ref<U> y) { return Equals<T, U>::_(x, y); } @@ -212,7 +207,11 @@ template<class T> inline x10_int hash_code(ref<T> x) { return nullCheck(x)->hashCode(); } - + + template<class T> inline x10_int hash_code(T x) { + return x->hashCode(); + } + inline x10_int hash_code(const x10_double x) { return hash(reinterpret_cast<const unsigned char*>(&x), sizeof(x)); } Modified: trunk/x10.runtime/src-x10/x10/lang/Box.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Box.x10 2009-10-05 21:44:40 UTC (rev 11356) +++ trunk/x10.runtime/src-x10/x10/lang/Box.x10 2009-10-05 22:03:22 UTC (rev 11357) @@ -14,7 +14,8 @@ public def toString(): String = value.toString(); @Native("c++", "x10aux::equals(#0,#1)") - public def equals(x: Value): Boolean { + public def equals(x:Object): Boolean { + if (x instanceof Value) { if (value instanceof Ref) { val v: Ref! = value; return v.equals(x); @@ -24,10 +25,7 @@ return value.equals(y); } return false; - } - - @Native("c++", "x10aux::equals(#0,#1)") - public def equals(x: Ref): Boolean { + } else { if (x == null) { return false; } @@ -44,5 +42,6 @@ return value.equals(y); } return false; + } } } Modified: trunk/x10.runtime/src-x10/x10/lang/Object.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Object.x10 2009-10-05 21:44:40 UTC (rev 11356) +++ trunk/x10.runtime/src-x10/x10/lang/Object.x10 2009-10-05 22:03:22 UTC (rev 11357) @@ -15,23 +15,19 @@ @NativeRep("c++", "x10aux::ref<x10::lang::Object>", "x10::lang::Object", null) public interface Object { @Native("java", "#0.equals(#1)") - @Native("c++", "x10aux::equals(x10aux::class_cast<x10aux::ref<x10::lang::Object> >(#0), #1)") - public def equals(Ref): Boolean; + @Native("c++", "x10aux::equals(#0, #1)") + public def equals(Object): Boolean; - @Native("java", "#0.equals(#1)") - @Native("c++", "x10aux::equals(x10aux::class_cast<x10aux::ref<x10::lang::Object> >(#0), #1)") - public def equals(Value): Boolean; - @Native("java", "#0.hashCode()") - @Native("c++", "x10aux::hash_code(x10aux::class_cast<x10aux::ref<x10::lang::Object> >(#0))") + @Native("c++", "x10aux::hash_code(#0)") public def hashCode(): Int; @Native("java", "#0.toString()") - @Native("c++", "x10aux::to_string(x10aux::class_cast<x10aux::ref<x10::lang::Object> >(#0))") + @Native("c++", "x10aux::to_string(#0)") public def toString(): String; @Native("java", "#0.getClass().toString()") - @Native("c++", "x10aux::class_name(x10aux::class_cast<x10aux::ref<x10::lang::Object> >(#0))") + @Native("c++", "x10aux::class_name(#0)") public def className(): String; @Native("java", "x10.lang.Place.place(#0.location())") Modified: trunk/x10.runtime/src-x10/x10/lang/Primitive.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Primitive.x10 2009-10-05 21:44:40 UTC (rev 11356) +++ trunk/x10.runtime/src-x10/x10/lang/Primitive.x10 2009-10-05 22:03:22 UTC (rev 11357) @@ -10,4 +10,6 @@ public abstract struct Primitive { public final def equals(x:Object)=false; + + public final def equals[T](x:T) = this == x; } Modified: trunk/x10.runtime/src-x10/x10/lang/Ref.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Ref.x10 2009-10-05 21:44:40 UTC (rev 11356) +++ trunk/x10.runtime/src-x10/x10/lang/Ref.x10 2009-10-05 22:03:22 UTC (rev 11357) @@ -33,12 +33,8 @@ @Native("java", "#0.equals(#1)") @Native("c++", "x10aux::equals(#0,#1)") - public native def equals(Ref): boolean; + public native def equals(Object): boolean; - @Native("java", "#0.equals(#1)") - @Native("c++", "x10aux::equals(#0,#1)") - public native def equals(Value): boolean; - @Native("java", "#0.hashCode()") @Native("c++", "x10aux::hash_code(#0)") public native def hashCode() : Int; Modified: trunk/x10.runtime/src-x10/x10/lang/String.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/String.x10 2009-10-05 21:44:40 UTC (rev 11356) +++ trunk/x10.runtime/src-x10/x10/lang/String.x10 2009-10-05 22:03:22 UTC (rev 11357) @@ -20,12 +20,8 @@ @Native("java", "(#0).equals(#1)") @Native("c++", "x10aux::equals(#0,#1)") - public native def equals(Ref): boolean; + public native def equals(Object): boolean; - @Native("java", "(#0).equals(#1)") - @Native("c++", "x10aux::equals(#0,#1)") - public native def equals(Value): boolean; - @Native("java", "(#0).hashCode()") @Native("c++", "x10aux::hash_code(#0)") public native def hashCode(): int; Modified: trunk/x10.runtime/src-x10/x10/lang/Value.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Value.x10 2009-10-05 21:44:40 UTC (rev 11356) +++ trunk/x10.runtime/src-x10/x10/lang/Value.x10 2009-10-05 22:03:22 UTC (rev 11357) @@ -19,12 +19,8 @@ public value Value /* @EQ implements Equals[Value] */ implements Object { @Native("java", "#0.equals(#1)") @Native("c++", "x10aux::equals(#0,#1)") - public native def equals(Value): boolean; + public native def equals(Object): boolean; - @Native("java", "#0.equals(#1)") - @Native("c++", "x10aux::equals(#0,#1)") - public native def equals(Ref): boolean; - @Native("java", "#0.hashCode()") @Native("c++", "x10aux::hash_code(#0)") public native def hashCode(): Int; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dgr...@us...> - 2009-10-06 02:03:33
|
Revision: 11358 http://x10.svn.sourceforge.net/x10/?rev=11358&view=rev Author: dgrove-oss Date: 2009-10-06 02:03:26 +0000 (Tue, 06 Oct 2009) Log Message: ----------- workaround XTENLANG-554 by (1) not casting the actual to the formal type of the argument at a call if we are invoking a method defined in x10.lang.Object (the only such method is equals) (2) then compensating for that, modify the equals methods in Region, Dist, BaseRegion, BaseDist, and RectRegion to accept arguments of type Object and do the necessary instanceof/checkcast operations to have the same behavior as before. Modified Paths: -------------- trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java 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/RectRegion.x10 trunk/x10.runtime/src-x10/x10/lang/Dist.x10 trunk/x10.runtime/src-x10/x10/lang/Region.x10 Modified: trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java =================================================================== --- trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java 2009-10-05 22:03:22 UTC (rev 11357) +++ trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java 2009-10-06 02:03:26 UTC (rev 11358) @@ -2643,8 +2643,12 @@ int counter = 0; for (Expr a : n.arguments()) { Type fType = mi.formalTypes().get(counter); - if (!xts.typeEquals(fType, a.type(), context) && !(xts.isParameterType(fType) && a.type().isNull())) + // 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) && + !xts.typeEquals(fType, a.type(), context) && !(xts.isParameterType(fType) && a.type().isNull())) { a = cast(a, fType); + } args.add(a); counter++; } Modified: trunk/x10.runtime/src-x10/x10/array/BaseDist.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/array/BaseDist.x10 2009-10-05 22:03:22 UTC (rev 11357) +++ trunk/x10.runtime/src-x10/x10/array/BaseDist.x10 2009-10-06 02:03:26 UTC (rev 11358) @@ -279,7 +279,9 @@ return places(0); } - public def equals(that: Dist/*(rank)*/): boolean { + public def equals(thatObj:Object /* Dist/*(rank)*/): boolean { + if (!(thatObj instanceof Dist)) return false; /* FIXME: EQUALS HACK */ + val that:Dist = thatObj as Dist; /* FIXME: EQUALS HACK */ for (p:Place in Place.places) if (!this.get(p).equals(that.get(p))) return false; Modified: trunk/x10.runtime/src-x10/x10/array/BaseRegion.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/array/BaseRegion.x10 2009-10-05 22:03:22 UTC (rev 11357) +++ trunk/x10.runtime/src-x10/x10/array/BaseRegion.x10 2009-10-06 02:03:26 UTC (rev 11358) @@ -171,7 +171,8 @@ return that.difference(this).isEmpty(); } - public def equals(that: Region/*(rank)*/): boolean { // XTENLANG-??? + public def equals(that:Object /* Region/ *(rank)*/): boolean { // XTENLANG-??? + if (!(that instanceof Region)) return false; /* FIXME: EQUALS HACK */ val t = that as Region(rank); return this.contains(t/*that*/) && t/*that*/.contains(this); } Modified: trunk/x10.runtime/src-x10/x10/array/RectRegion.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/array/RectRegion.x10 2009-10-05 22:03:22 UTC (rev 11357) +++ trunk/x10.runtime/src-x10/x10/array/RectRegion.x10 2009-10-06 02:03:26 UTC (rev 11358) @@ -226,7 +226,9 @@ // XTENLANG-28 - public def equals(that: Region): boolean { + public def equals(thatObj:Object): boolean { + if (!(thatObj instanceof Region)) return false; /* EQUALS HACK */ + val that:Region = thatObj as Region; // we only handle rect==rect if (!(that instanceof RectRegion)) Modified: trunk/x10.runtime/src-x10/x10/lang/Dist.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Dist.x10 2009-10-05 22:03:22 UTC (rev 11357) +++ trunk/x10.runtime/src-x10/x10/lang/Dist.x10 2009-10-06 02:03:26 UTC (rev 11358) @@ -293,10 +293,10 @@ * Returns true iff both distributions are defined over the same * regions, and map every point in that region to the same place. */ + // FIXME: EQUALS HACK + // abstract public def equals(that: Dist/*(rank) */): boolean; + // - abstract public def equals(that: Dist/*(rank)*/): boolean; - - // // other geometric ops // Modified: trunk/x10.runtime/src-x10/x10/lang/Region.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Region.x10 2009-10-05 22:03:22 UTC (rev 11357) +++ trunk/x10.runtime/src-x10/x10/lang/Region.x10 2009-10-06 02:03:26 UTC (rev 11358) @@ -376,7 +376,9 @@ // abstract public def contains(that: Region(rank)): boolean; - abstract public def equals(that: Region/*(rank)*/): boolean; // XTENLANG-??? + // FIXME: EQUALS HACK + // abstract public def equals(that: Region/*(rank)*/): boolean; + // abstract public def contains(p: Point): boolean; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <vj...@us...> - 2009-10-06 09:54:52
|
Revision: 11359 http://x10.svn.sourceforge.net/x10/?rev=11359&view=rev Author: vj0 Date: 2009-10-06 09:54:38 +0000 (Tue, 06 Oct 2009) Log Message: ----------- An unconstrained type parameter T is unrelated to x10.lang.Object. Modified Paths: -------------- trunk/x10.compiler/src/x10/types/X10TypeEnv_c.java Added Paths: ----------- trunk/x10.tests/examples/Constructs/XtenTwoOhTypeSsytem/ trunk/x10.tests/examples/Constructs/XtenTwoOhTypeSsytem/ObjectIsNotParameterType2_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/XtenTwoOhTypeSsytem/ObjectIsNotParameterType3_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/XtenTwoOhTypeSsytem/ObjectIsNotParameterType4_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/XtenTwoOhTypeSsytem/ObjectIsNotParameterType_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/XtenTwoOhTypeSsytem/ParameterTypeIsNotObject2_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/XtenTwoOhTypeSsytem/ParameterTypeIsNotObject3_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/XtenTwoOhTypeSsytem/ParameterTypeIsNotObject4_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/XtenTwoOhTypeSsytem/ParameterTypeIsNotObject_MustFailCompile.x10 Modified: trunk/x10.compiler/src/x10/types/X10TypeEnv_c.java =================================================================== --- trunk/x10.compiler/src/x10/types/X10TypeEnv_c.java 2009-10-06 02:03:26 UTC (rev 11358) +++ trunk/x10.compiler/src/x10/types/X10TypeEnv_c.java 2009-10-06 09:54:38 UTC (rev 11359) @@ -948,9 +948,12 @@ } } + /* + * Do not allowValueInterfaces. A type parameter T is not a subtype of Object. + */ if (t1 instanceof ParameterType) { - for (Type s1 : upperTypeBounds(t1, allowValueInterfaces)) { - if (isSubtype(x, s1, t2, allowValueInterfaces)) + for (Type s1 : upperTypeBounds(t1, false)) { + if (isSubtype(x, s1, t2, false)) return true; } } Added: trunk/x10.tests/examples/Constructs/XtenTwoOhTypeSsytem/ObjectIsNotParameterType2_MustFailCompile.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/XtenTwoOhTypeSsytem/ObjectIsNotParameterType2_MustFailCompile.x10 (rev 0) +++ trunk/x10.tests/examples/Constructs/XtenTwoOhTypeSsytem/ObjectIsNotParameterType2_MustFailCompile.x10 2009-10-06 09:54:38 UTC (rev 11359) @@ -0,0 +1,32 @@ +/* + * + * (C) Copyright IBM Corporation 2006 + * + * This file is part of X10 Test. + * + */ +import harness.x10Test; + +/** + * A value of an unconstrained type parameter T cannot be assigned to a variable of type Object. + * Testing assignment to a field. + * + * @author vj + */ +public class ObjectIsNotParameterType2_MustFailCompile extends x10Test { + class GenericWrapper[T] { + var dummy:Object = null; + public def testAssign(x:T) { + // bad!! + x=dummy; + } + } + + public def run()=true; + + public static def main(Rail[String]) { + new ObjectIsNotParameterType2_MustFailCompile().execute(); + } + + +} Added: trunk/x10.tests/examples/Constructs/XtenTwoOhTypeSsytem/ObjectIsNotParameterType3_MustFailCompile.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/XtenTwoOhTypeSsytem/ObjectIsNotParameterType3_MustFailCompile.x10 (rev 0) +++ trunk/x10.tests/examples/Constructs/XtenTwoOhTypeSsytem/ObjectIsNotParameterType3_MustFailCompile.x10 2009-10-06 09:54:38 UTC (rev 11359) @@ -0,0 +1,27 @@ +/* + * + * (C) Copyright IBM Corporation 2006 + * + * This file is part of X10 Test. + * + */ +import harness.x10Test; + +/** + * A value of an unconstrained type parameter T cannot be assigned to a variable of type Object. + * Testing return value from a method. + * + * @author vj + */ +public class ObjectIsNotParameterType3_MustFailCompile extends x10Test { + class GenericWrapper[T] { + public def testAssign(x:Object):T = x; + } + public def run()=true; + + public static def main(Rail[String]) { + new ObjectIsNotParameterType3_MustFailCompile().execute(); + } + + +} Added: trunk/x10.tests/examples/Constructs/XtenTwoOhTypeSsytem/ObjectIsNotParameterType4_MustFailCompile.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/XtenTwoOhTypeSsytem/ObjectIsNotParameterType4_MustFailCompile.x10 (rev 0) +++ trunk/x10.tests/examples/Constructs/XtenTwoOhTypeSsytem/ObjectIsNotParameterType4_MustFailCompile.x10 2009-10-06 09:54:38 UTC (rev 11359) @@ -0,0 +1,30 @@ +/* + * + * (C) Copyright IBM Corporation 2006 + * + * This file is part of X10 Test. + * + */ +import harness.x10Test; + +/** + * A value of an unconstrained type parameter T cannot be assigned to a variable of type Object. + * Testing method invocation. + * + * @author vj + */ +public class ObjectIsNotParameterType4_MustFailCompile extends x10Test { + class GenericWrapper[T] { + incomplete def m(x:T):Void; + public def testAssign(y:Object) { + m(y); + } + } + public def run()=true; + + public static def main(Rail[String]) { + new ObjectIsNotParameterType4_MustFailCompile().execute(); + } + + +} Added: trunk/x10.tests/examples/Constructs/XtenTwoOhTypeSsytem/ObjectIsNotParameterType_MustFailCompile.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/XtenTwoOhTypeSsytem/ObjectIsNotParameterType_MustFailCompile.x10 (rev 0) +++ trunk/x10.tests/examples/Constructs/XtenTwoOhTypeSsytem/ObjectIsNotParameterType_MustFailCompile.x10 2009-10-06 09:54:38 UTC (rev 11359) @@ -0,0 +1,31 @@ +/* + * + * (C) Copyright IBM Corporation 2006 + * + * This file is part of X10 Test. + * + */ +import harness.x10Test; + +/** + * A value of an unconstrained type parameter T cannot be assigned to a variable of type Object. + * + * @author vj + */ +public class ObjectIsNotParameterType_MustFailCompile extends x10Test { + class GenericWrapper[T] { + public def testAssign(x:T) { + var dummy:Object = null; + // bad!! + x=dummy; + } + } + + public def run()=true; + + public static def main(Rail[String]) { + new ObjectIsNotParameterType_MustFailCompile().execute(); + } + + +} Added: trunk/x10.tests/examples/Constructs/XtenTwoOhTypeSsytem/ParameterTypeIsNotObject2_MustFailCompile.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/XtenTwoOhTypeSsytem/ParameterTypeIsNotObject2_MustFailCompile.x10 (rev 0) +++ trunk/x10.tests/examples/Constructs/XtenTwoOhTypeSsytem/ParameterTypeIsNotObject2_MustFailCompile.x10 2009-10-06 09:54:38 UTC (rev 11359) @@ -0,0 +1,32 @@ +/* + * + * (C) Copyright IBM Corporation 2006 + * + * This file is part of X10 Test. + * + */ +import harness.x10Test; + +/** + * A value of an unconstrained type parameter T cannot be assigned to a variable of type Object. + * Testing assignment to a field. + * + * @author vj + */ +public class ParameterTypeIsNotObject2_MustFailCompile extends x10Test { + class GenericWrapper[T] { + var dummy:Object = null; + public def testAssign(x:T) { + // bad!! + dummy = x; + } + } + + public def run()=true; + + public static def main(Rail[String]) { + new ParameterTypeIsNotObject2_MustFailCompile().execute(); + } + + +} Added: trunk/x10.tests/examples/Constructs/XtenTwoOhTypeSsytem/ParameterTypeIsNotObject3_MustFailCompile.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/XtenTwoOhTypeSsytem/ParameterTypeIsNotObject3_MustFailCompile.x10 (rev 0) +++ trunk/x10.tests/examples/Constructs/XtenTwoOhTypeSsytem/ParameterTypeIsNotObject3_MustFailCompile.x10 2009-10-06 09:54:38 UTC (rev 11359) @@ -0,0 +1,27 @@ +/* + * + * (C) Copyright IBM Corporation 2006 + * + * This file is part of X10 Test. + * + */ +import harness.x10Test; + +/** + * A value of an unconstrained type parameter T cannot be assigned to a variable of type Object. + * Testing return value from a method. + * + * @author vj + */ +public class ParameterTypeIsNotObject3_MustFailCompile extends x10Test { + class GenericWrapper[T] { + public def testAssign(x:T):Object = x; + } + public def run()=true; + + public static def main(Rail[String]) { + new ParameterTypeIsNotObject3_MustFailCompile().execute(); + } + + +} Added: trunk/x10.tests/examples/Constructs/XtenTwoOhTypeSsytem/ParameterTypeIsNotObject4_MustFailCompile.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/XtenTwoOhTypeSsytem/ParameterTypeIsNotObject4_MustFailCompile.x10 (rev 0) +++ trunk/x10.tests/examples/Constructs/XtenTwoOhTypeSsytem/ParameterTypeIsNotObject4_MustFailCompile.x10 2009-10-06 09:54:38 UTC (rev 11359) @@ -0,0 +1,30 @@ +/* + * + * (C) Copyright IBM Corporation 2006 + * + * This file is part of X10 Test. + * + */ +import harness.x10Test; + +/** + * A value of an unconstrained type parameter T cannot be assigned to a variable of type Object. + * Testing method invocation. + * + * @author vj + */ +public class ParameterTypeIsNotObject4_MustFailCompile extends x10Test { + class GenericWrapper[T] { + incomplete def m(x:Object):Void; + public def testAssign(y:T) { + m(y); + } + } + public def run()=true; + + public static def main(Rail[String]) { + new ParameterTypeIsNotObject4_MustFailCompile().execute(); + } + + +} Added: trunk/x10.tests/examples/Constructs/XtenTwoOhTypeSsytem/ParameterTypeIsNotObject_MustFailCompile.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/XtenTwoOhTypeSsytem/ParameterTypeIsNotObject_MustFailCompile.x10 (rev 0) +++ trunk/x10.tests/examples/Constructs/XtenTwoOhTypeSsytem/ParameterTypeIsNotObject_MustFailCompile.x10 2009-10-06 09:54:38 UTC (rev 11359) @@ -0,0 +1,31 @@ +/* + * + * (C) Copyright IBM Corporation 2006 + * + * This file is part of X10 Test. + * + */ +import harness.x10Test; + +/** + * A value of an unconstrained type parameter T cannot be assigned to a variable of type Object. + * + * @author vj + */ +public class ParameterTypeIsNotObject_MustFailCompile extends x10Test { + class GenericWrapper[T] { + public def testAssign(x:T) { + var dummy:Object = null; + // bad!! + dummy = x; + } + } + + public def run()=true; + + public static def main(Rail[String]) { + new ParameterTypeIsNotObject_MustFailCompile().execute(); + } + + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dgr...@us...> - 2009-10-06 18:44:54
|
Revision: 11366 http://x10.svn.sourceforge.net/x10/?rev=11366&view=rev Author: dgrove-oss Date: 2009-10-06 18:44:45 +0000 (Tue, 06 Oct 2009) Log Message: ----------- Fixes to allow all of the built-in primitives except for Int to be declared as structs instead of values. Changing int to be a struct tickles a bug in the typechecker. Will work with Vijay to fix it and then will convert Int to be a struct as well. Modified Paths: -------------- trunk/x10.dist/samples/FRASimpleDist.x10 trunk/x10.runtime/src-x10/x10/array/PolyScanner.x10 trunk/x10.runtime/src-x10/x10/array/Row.x10 trunk/x10.runtime/src-x10/x10/io/Printer.x10 trunk/x10.runtime/src-x10/x10/io/StringWriter.x10 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/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 trunk/x10.runtime/src-x10/x10/util/StringBuilder.x10 Modified: trunk/x10.dist/samples/FRASimpleDist.x10 =================================================================== --- trunk/x10.dist/samples/FRASimpleDist.x10 2009-10-06 14:51:33 UTC (rev 11365) +++ trunk/x10.dist/samples/FRASimpleDist.x10 2009-10-06 18:44:45 UTC (rev 11366) @@ -106,8 +106,8 @@ // print statistics val GUPs = (cpuTime > 0.0 ? 1.0 / cpuTime : -1.0) * num_updates / 1e9; - Console.OUT.printf("CPU time used = %.2f seconds\n", cpuTime); - Console.OUT.printf("%.6f Billion(10^9) Updates per second (GUP/s)\n", GUPs); + Console.OUT.println("CPU time used = "+cpuTime+" seconds"); + Console.OUT.println(GUPs+" Billion(10^9) Updates per second (GUP/s)"); // repeat for testing. randomAccessUpdate(num_updates, logLocalTableSize, tables); Modified: trunk/x10.runtime/src-x10/x10/array/PolyScanner.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/array/PolyScanner.x10 2009-10-06 14:51:33 UTC (rev 11365) +++ trunk/x10.runtime/src-x10/x10/array/PolyScanner.x10 2009-10-06 18:44:45 UTC (rev 11366) @@ -448,26 +448,26 @@ public def printInfo2(ps: Printer): void { for (var k: int = 0; k<myMin.length; k++) { - ps.printf("axis %d\n", k); - ps.printf(" min\n"); + ps.println("axis "+k); + ps.println(" min"); for (var l: int = 0; l<myMin(k).rows; l++) { - ps.printf(" "); + ps.print(" "); for (var m: int = 0; m<myMin(k)(l).cols; m++) - ps.printf(" %3d", myMin(k)(l)(m)); - ps.printf(" sum"); + ps.print(" "+myMin(k)(l)(m)); + ps.print(" sum"); for (var m: int = 0; m<minSum(k)(l).cols; m++) - ps.printf(" %3d", minSum(k)(l)(m)); - ps.printf("\n"); + ps.print(" "+minSum(k)(l)(m)); + ps.print("\n"); } ps.printf(" max\n"); for (var l: int = 0; l<myMax(k).rows; l++) { - ps.printf(" "); + ps.print(" "); for (var m: int = 0; m<myMax(k)(l).cols; m++) - ps.printf(" %3d", myMax(k)(l)(m)); - ps.printf(" sum"); + ps.print(" "+myMax(k)(l)(m)); + ps.print(" sum"); for (var m: int = 0; m<maxSum(k)(l).cols; m++) - ps.printf(" %3d", maxSum(k)(l)(m)); - ps.printf("\n"); + ps.print(" "+maxSum(k)(l)(m)); + ps.println(); } } } Modified: trunk/x10.runtime/src-x10/x10/array/Row.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/array/Row.x10 2009-10-06 14:51:33 UTC (rev 11365) +++ trunk/x10.runtime/src-x10/x10/array/Row.x10 2009-10-06 18:44:45 UTC (rev 11366) @@ -19,14 +19,14 @@ */ public def printInfo(ps: Printer, row:int) { - ps.printf("["); + ps.print("["); for (var i: int = 0; i<cols; i++) { - ps.printf("%4d", this(i)); - if (i==cols-2) ps.printf(" |"); + ps.print(this(i)); + if (i==cols-2) ps.print(" |"); } - ps.printf(" ] "); + ps.print(" ] "); printEqn(ps, " ", row); - ps.printf("\n"); + ps.println(); } /** @@ -51,7 +51,7 @@ first = false; } val c = this(cols-1); - if (c!=0||first) ps.printf((c>=0&&!first?"+":"") + c); + if (c!=0||first) ps.print((c>=0&&!first?"+":"") + c); } public def toString(): String { Modified: trunk/x10.runtime/src-x10/x10/io/Printer.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/io/Printer.x10 2009-10-06 14:51:33 UTC (rev 11365) +++ trunk/x10.runtime/src-x10/x10/io/Printer.x10 2009-10-06 18:44:45 UTC (rev 11366) @@ -31,14 +31,14 @@ public def println(): Void = print(NEWLINE as Box[Char]); - public def print(o: Object): Void { + public def print(o:Object): Void { if (o == null) print("null"); else print(o.toString()); } - public def print(s: String): Void { + public def print(s:String): Void { try { val b = s.bytes(); write(b, 0, b.length); @@ -48,15 +48,103 @@ } } + public def print(x:Boolean) { + try { + writeBoolean(x); + } catch (e:IOException) { + throw new IORuntimeException(e.getMessage()); + } + } + public def print(x:Byte) { + try { + writeByte(x); + } catch (e:IOException) { + throw new IORuntimeException(e.getMessage()); + } + } + public def print(x:Char) { + try { + writeChar(x); + } catch (e:IOException) { + throw new IORuntimeException(e.getMessage()); + } + } + public def print(x:Short) { + try { + writeShort(x); + } catch (e:IOException) { + throw new IORuntimeException(e.getMessage()); + } + } + public def print(x:Int) { + try { + writeInt(x); + } catch (e:IOException) { + throw new IORuntimeException(e.getMessage()); + } + } + public def print(x:Long) { + try { + writeLong(x); + } catch (e:IOException) { + throw new IORuntimeException(e.getMessage()); + } + } + public def print(x:Float) { + try { + writeFloat(x); + } catch (e:IOException) { + throw new IORuntimeException(e.getMessage()); + } + } + public def print(x:Double) { + try { + writeDouble(x); + } catch (e:IOException) { + throw new IORuntimeException(e.getMessage()); + } + } + public def println(o: Object): Void { print(o); println(); } - public def println(s: String): Void { print(s); println(); } + public def println(x:Boolean) { + print(x); + println(); + } + public def println(x:Byte) { + print(x); + println(); + } + public def println(x:Char) { + print(x); + println(); + } + public def println(x:Short) { + print(x); + println(); + } + public def println(x:Int) { + print(x); + println(); + } + public def println(x:Long) { + print(x); + println(); + } + public def println(x:Float) { + print(x); + println(); + } + public def println(x:Double) { + print(x); + println(); + } public def printf(fmt: String): Void { printf(fmt, []); } public def printf(fmt: String, o1: Object): Void { printf(fmt, [o1]); } Modified: trunk/x10.runtime/src-x10/x10/io/StringWriter.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/io/StringWriter.x10 2009-10-06 14:51:33 UTC (rev 11365) +++ trunk/x10.runtime/src-x10/x10/io/StringWriter.x10 2009-10-06 18:44:45 UTC (rev 11366) @@ -17,7 +17,7 @@ def b() = b as StringBuilder!; public def this() { this.b = new StringBuilder(); } - public def write(x: Byte): Void { b().add((x as Byte) as Char); } + public def write(x:Byte): Void { b().add((x as Byte) as Char); } public def size() = b().length(); public def toString() = b().toString(); Modified: trunk/x10.runtime/src-x10/x10/lang/Boolean.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Boolean.x10 2009-10-06 14:51:33 UTC (rev 11365) +++ trunk/x10.runtime/src-x10/x10/lang/Boolean.x10 2009-10-06 18:44:45 UTC (rev 11366) @@ -13,7 +13,7 @@ @NativeRep("java", "boolean", "x10.core.BoxedBoolean", "x10.types.Type.BOOLEAN") @NativeRep("c++", "x10_boolean", "x10_boolean", null) -public final value Boolean { +public final struct Boolean { @Native("java", "!(#1)") @Native("c++", "!(#1)") Modified: trunk/x10.runtime/src-x10/x10/lang/Byte.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Byte.x10 2009-10-06 14:51:33 UTC (rev 11365) +++ trunk/x10.runtime/src-x10/x10/lang/Byte.x10 2009-10-06 18:44:45 UTC (rev 11366) @@ -13,7 +13,7 @@ @NativeRep("java", "byte", "x10.core.BoxedByte", "x10.types.Type.BYTE") @NativeRep("c++", "x10_byte", "x10_byte", null) -public final value Byte { +public final struct Byte { @Native("java", "((#1) < (#2))") @Native("c++", "((#1) < (#2))") public native static safe operator (x:Byte) < (y:Byte): Boolean; Modified: trunk/x10.runtime/src-x10/x10/lang/Char.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Char.x10 2009-10-06 14:51:33 UTC (rev 11365) +++ trunk/x10.runtime/src-x10/x10/lang/Char.x10 2009-10-06 18:44:45 UTC (rev 11366) @@ -13,7 +13,7 @@ @NativeRep("java", "char", "x10.core.BoxedChar", "x10.types.Type.CHAR") @NativeRep("c++", "x10_char", "x10_char", null) -public final value Char { +public final struct Char { @Native("java", "((char) (#1))") @Native("c++", "((x10_char) (char) (#1))") public native static safe operator (x:Byte) as Char; @@ -59,6 +59,10 @@ @Native("c++", "((#1) >= (#2))") public native static safe operator (x:Char) >= (y:Char): Boolean; + @Native("java", "java.lang.Character.toString(#0)") + @Native("c++", "x10aux::to_string(#0)") + public native def toString(): String; + // Duplicate the methods from java.lang.Character, changing static methods to non-static. // We'll ignore the code point methods for now and just include the isXXX ones. Modified: trunk/x10.runtime/src-x10/x10/lang/Double.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Double.x10 2009-10-06 14:51:33 UTC (rev 11365) +++ trunk/x10.runtime/src-x10/x10/lang/Double.x10 2009-10-06 18:44:45 UTC (rev 11366) @@ -13,7 +13,7 @@ @NativeRep("java", "double", "x10.core.BoxedDouble", "x10.types.Types.DOUBLE") @NativeRep("c++", "x10_double", "x10_double", null) -public final value Double { +public final struct Double { @Native("java", "((#1) < (#2))") @Native("c++", "((#1) < (#2))") public native static safe operator (x:Double) < (y:Double): Boolean; Modified: trunk/x10.runtime/src-x10/x10/lang/Float.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Float.x10 2009-10-06 14:51:33 UTC (rev 11365) +++ trunk/x10.runtime/src-x10/x10/lang/Float.x10 2009-10-06 18:44:45 UTC (rev 11366) @@ -13,7 +13,7 @@ @NativeRep("java", "float", "x10.core.BoxedFloat", "x10.types.Type.FLOAT") @NativeRep("c++", "x10_float", "x10_float", null) -public final value Float { +public final struct Float { @Native("java", "((#1) < (#2))") @Native("c++", "((#1) < (#2))") public native static safe operator (x:Float) < (y:Float): Boolean; Modified: trunk/x10.runtime/src-x10/x10/lang/Long.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Long.x10 2009-10-06 14:51:33 UTC (rev 11365) +++ trunk/x10.runtime/src-x10/x10/lang/Long.x10 2009-10-06 18:44:45 UTC (rev 11366) @@ -13,7 +13,7 @@ @NativeRep("java", "long", "x10.core.BoxedLong", "x10.types.Type.LONG") @NativeRep("c++", "x10_long", "x10_long", null) -public final value Long { +public final struct Long { @Native("java", "((#1) < (#2))") @Native("c++", "((#1) < (#2))") public native static safe operator (x:Long) < (y:Long): Boolean; Modified: trunk/x10.runtime/src-x10/x10/lang/Short.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Short.x10 2009-10-06 14:51:33 UTC (rev 11365) +++ trunk/x10.runtime/src-x10/x10/lang/Short.x10 2009-10-06 18:44:45 UTC (rev 11366) @@ -13,7 +13,7 @@ @NativeRep("java", "short", "x10.core.BoxedShort", "x10.types.Type.SHORT") @NativeRep("c++", "x10_short", "x10_short", null) -public final value Short { +public final struct Short { @Native("java", "((#1) < (#2))") @Native("c++", "((#1) < (#2))") public native static safe operator (x:Short) < (y:Short): Boolean; Modified: trunk/x10.runtime/src-x10/x10/lang/UByte.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/UByte.x10 2009-10-06 14:51:33 UTC (rev 11365) +++ trunk/x10.runtime/src-x10/x10/lang/UByte.x10 2009-10-06 18:44:45 UTC (rev 11366) @@ -15,7 +15,7 @@ // v-- when used @NativeRep("c++", "uint8_t", "uint8_t", null) // ^ when constructed -public final value UByte { +public final struct UByte { @Native("java", "x10.core.Unsigned.lt(#1, #2)") @Native("c++", "((#1) < (#2))") public native static safe operator (x:UByte) < (y:UByte): Boolean; Modified: trunk/x10.runtime/src-x10/x10/lang/UInt.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/UInt.x10 2009-10-06 14:51:33 UTC (rev 11365) +++ trunk/x10.runtime/src-x10/x10/lang/UInt.x10 2009-10-06 18:44:45 UTC (rev 11366) @@ -15,7 +15,7 @@ // v-- when used @NativeRep("c++", "uint32_t", "uint32_t", null) // ^ when constructed -public final value UInt { +public final struct UInt { // Binary and unary operations and conversions are built-in. No need to declare them here. @Native("java", "x10.core.Unsigned.lt(#1, #2)") Modified: trunk/x10.runtime/src-x10/x10/lang/ULong.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/ULong.x10 2009-10-06 14:51:33 UTC (rev 11365) +++ trunk/x10.runtime/src-x10/x10/lang/ULong.x10 2009-10-06 18:44:45 UTC (rev 11366) @@ -15,7 +15,7 @@ // v-- when used @NativeRep("c++", "uint64_t", "uint64_t", null) // ^ when constructed -public final value ULong { +public final struct ULong { // Binary and unary operations and conversions are built-in. No need to declare them here. @Native("java", "x10.core.Unsigned.lt(#1, #2)") Modified: trunk/x10.runtime/src-x10/x10/lang/UShort.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/UShort.x10 2009-10-06 14:51:33 UTC (rev 11365) +++ trunk/x10.runtime/src-x10/x10/lang/UShort.x10 2009-10-06 18:44:45 UTC (rev 11366) @@ -15,7 +15,7 @@ // v-- when used @NativeRep("c++", "uint16_t", "uint16_t", null) // ^ when constructed -public final value UShort { +public final struct UShort { // Binary and unary operations and conversions are built-in. No need to declare them here. @Native("java", "x10.core.Unsigned.lt(#1, #2)") Modified: trunk/x10.runtime/src-x10/x10/util/StringBuilder.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/util/StringBuilder.x10 2009-10-06 14:51:33 UTC (rev 11365) +++ trunk/x10.runtime/src-x10/x10/util/StringBuilder.x10 2009-10-06 18:44:45 UTC (rev 11366) @@ -9,12 +9,21 @@ buf = new ValRailBuilder[Char](); } - public def add(o: Object): StringBuilder { + public def add(o:Object): StringBuilder { if (o == null) return addString("null"); else return addString(o.toString()); } + + public def add(x:Boolean) = addString(x.toString()); + public def add(x:Byte) = addString(x.toString()); + public def add(x:Char) = addString(x.toString()); + public def add(x:Short) = addString(x.toString()); + public def add(x:Int) = addString(x.toString()); + public def add(x:Long) = addString(x.toString()); + public def add(x:Float) = addString(x.toString()); + public def add(x:Double) = addString(x.toString()); protected def addString(s: String): StringBuilder { for (var i: int = 0; i < s.length(); i++) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dgr...@us...> - 2009-10-07 17:45:55
|
Revision: 11380 http://x10.svn.sourceforge.net/x10/?rev=11380&view=rev Author: dgrove-oss Date: 2009-10-07 17:45:48 +0000 (Wed, 07 Oct 2009) Log Message: ----------- Import IfTask from JikesRVM project to simplify conditional execution in ant build files. Modified Paths: -------------- trunk/x10.runtime/build.xml Added Paths: ----------- trunk/x10.common/contrib/ant/IfTask.java Added: trunk/x10.common/contrib/ant/IfTask.java =================================================================== --- trunk/x10.common/contrib/ant/IfTask.java (rev 0) +++ trunk/x10.common/contrib/ant/IfTask.java 2009-10-07 17:45:48 UTC (rev 11380) @@ -0,0 +1,59 @@ +/* + * This file is part of the Jikes RVM project (http://jikesrvm.org). + * + * This file is licensed to You under the Eclipse Public License (EPL); + * You may not use this file except in compliance with the License. You + * may obtain a copy of the License at + * + * http://www.opensource.org/licenses/eclipse-1.0.php + * + * See the COPYRIGHT.txt file distributed with this work for information + * regarding copyright ownership. + */ + +import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.Task; +import org.apache.tools.ant.taskdefs.MacroDef; +import org.apache.tools.ant.taskdefs.MacroInstance; +import org.apache.tools.ant.taskdefs.condition.Condition; +import org.apache.tools.ant.taskdefs.condition.ConditionBase; + +/** + * The if task makes it easier to performs some tasks conditionally. + * It contains a nested condition and associated sequential task. + */ +public class IfTask + extends Task { + private MacroDef macroDef; + private ConditionSet conditions = new ConditionSet(); + + public ConditionSet createConditions() { return conditions; } + + public MacroDef.NestedSequential createSequential() { + macroDef = new MacroDef(); + macroDef.setProject(getProject()); + return macroDef.createSequential(); + } + + public void execute() { + validate(); + + if (conditions.getCondition().eval()) { + final MacroInstance i = new MacroInstance(); + i.setProject(getProject()); + i.setOwningTarget(getOwningTarget()); + i.setMacroDef(macroDef); + i.execute(); + } + } + + private void validate() { + if (!conditions.containsSingleCondition()) throw new BuildException("Must specify exactly one condition."); + if (null == macroDef) throw new BuildException("Must specify a sequential task to execute."); + } + + public static class ConditionSet extends ConditionBase { + public boolean containsSingleCondition() { return 1 == super.countConditions(); } + public Condition getCondition() { return (Condition) getConditions().nextElement(); } + } +} Modified: trunk/x10.runtime/build.xml =================================================================== --- trunk/x10.runtime/build.xml 2009-10-07 14:54:02 UTC (rev 11379) +++ trunk/x10.runtime/build.xml 2009-10-07 17:45:48 UTC (rev 11380) @@ -45,6 +45,7 @@ <javac destdir="${build}" source="1.5" target="1.5" debug="on" nowarn="on"> <src path="${x10.common.location}/contrib/ant"/> <include name="Ejc.java"/> + <include name="IfTask.java"/> <classpath> <path refid="project.classpath"/> </classpath> @@ -58,6 +59,9 @@ </taskdef> <!-- use ECJ instead of javac (needs ecj.jar on the classpath) --> <!--<property name="build.compiler" value="${ejc.compiler}"/>--> + + <!-- allow simpler specification of conditional tasks --> + <taskdef name="if" classname ="IfTask" classpath="${build}" /> </target> <!-- Determine whether or not we should be building with GC enabled --> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dgr...@us...> - 2009-10-07 21:19:37
|
Revision: 11386 http://x10.svn.sourceforge.net/x10/?rev=11386&view=rev Author: dgrove-oss Date: 2009-10-07 21:19:30 +0000 (Wed, 07 Oct 2009) Log Message: ----------- rename className to typeName to match current struct design. adjust templates so that x10aux::type_name will work for structs (tested by manually adding a typeName() native method to a struct). Add temporary definitions of typeName to the built-in primitives (Boolean, Int, etc). Once the front-end changes are made so that typeName is defined on all types, these native methods can be removed because the general mechanism for structs will work for them too. Modified Paths: -------------- trunk/x10.runtime/src-cpp/x10aux/basic_functions.h trunk/x10.runtime/src-x10/x10/array/PolyScanner.x10 trunk/x10.runtime/src-x10/x10/array/PolyXform.x10 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/Object.x10 trunk/x10.runtime/src-x10/x10/lang/Ref.x10 trunk/x10.runtime/src-x10/x10/lang/Short.x10 trunk/x10.runtime/src-x10/x10/lang/String.x10 trunk/x10.runtime/src-x10/x10/lang/Throwable.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 trunk/x10.runtime/src-x10/x10/lang/Value.x10 trunk/x10.tests/examples/Benchmarks/Benchmark.x10 trunk/x10.tests/examples/Constructs/Array/Array1DCodeGen.x10 trunk/x10.tests/examples/Constructs/Array/TestArray.x10 trunk/x10.tests/examples/Constructs/Distribution/TestDist.x10 trunk/x10.tests/examples/Constructs/Point/TestPoint.x10 trunk/x10.tests/examples/Constructs/Region/TestRegion.x10 trunk/x10.tests/examples/Issues/XTENLANG_242.x10 Modified: trunk/x10.runtime/src-cpp/x10aux/basic_functions.h =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/basic_functions.h 2009-10-07 20:06:56 UTC (rev 11385) +++ trunk/x10.runtime/src-cpp/x10aux/basic_functions.h 2009-10-07 21:19:30 UTC (rev 11386) @@ -8,47 +8,14 @@ namespace x10aux { - template<class T> inline ref<x10::lang::String> class_name(ref<T> x) { + template<class T> inline ref<x10::lang::String> type_name(ref<T> x) { x10aux::nullCheck(x); return x10::lang::String::Lit(((const T*)x.operator->())->_type()->name()); } - inline ref<x10::lang::String> class_name(const x10_double) { - return x10::lang::String::Lit(getRTT<x10_double>()->name()); + template<typename T> inline ref<x10::lang::String> type_name(T x) { + return x10::lang::String::Lit(getRTT<T>()->name()); } - inline ref<x10::lang::String> class_name(const x10_float) { - return x10::lang::String::Lit(getRTT<x10_float>()->name()); - } - inline ref<x10::lang::String> class_name(const x10_long) { - return x10::lang::String::Lit(getRTT<x10_long>()->name()); - } - inline ref<x10::lang::String> class_name(const x10_int) { - return x10::lang::String::Lit(getRTT<x10_int>()->name()); - } - inline ref<x10::lang::String> class_name(const x10_short) { - return x10::lang::String::Lit(getRTT<x10_short>()->name()); - } - inline ref<x10::lang::String> class_name(const x10_byte) { - return x10::lang::String::Lit(getRTT<x10_byte>()->name()); - } - inline ref<x10::lang::String> class_name(const x10_ulong) { - return x10::lang::String::Lit(getRTT<x10_ulong>()->name()); - } - inline ref<x10::lang::String> class_name(const x10_uint) { - return x10::lang::String::Lit(getRTT<x10_uint>()->name()); - } - inline ref<x10::lang::String> class_name(const x10_ushort) { - return x10::lang::String::Lit(getRTT<x10_ushort>()->name()); - } - inline ref<x10::lang::String> class_name(const x10_ubyte) { - return x10::lang::String::Lit(getRTT<x10_ubyte>()->name()); - } - inline ref<x10::lang::String> class_name(const x10_char) { - return x10::lang::String::Lit(getRTT<x10_char>()->name()); - } - inline ref<x10::lang::String> class_name(const x10_boolean) { - return x10::lang::String::Lit(getRTT<x10_boolean>()->name()); - } template<class T, class U> class Equals { Modified: trunk/x10.runtime/src-x10/x10/array/PolyScanner.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/array/PolyScanner.x10 2009-10-07 20:06:56 UTC (rev 11385) +++ trunk/x10.runtime/src-x10/x10/array/PolyScanner.x10 2009-10-07 21:19:30 UTC (rev 11386) @@ -422,7 +422,7 @@ val p = that as PolyXform; return new PolyScanner((C*p.T)||p.E, X1(0)*p.T); } else { - throw new UnsupportedOperationException(this.className() + ".xform(" + that.className() + ")"); + throw new UnsupportedOperationException(this.typeName() + ".xform(" + that.typeName() + ")"); } } Modified: trunk/x10.runtime/src-x10/x10/array/PolyXform.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/array/PolyXform.x10 2009-10-07 20:06:56 UTC (rev 11385) +++ trunk/x10.runtime/src-x10/x10/array/PolyXform.x10 2009-10-07 21:19:30 UTC (rev 11386) @@ -14,7 +14,7 @@ val p = that as PolyXform!; return new PolyXform(this.E||p.E, this.T*p.T); } else { - throw new UnsupportedOperationException(this.className() + ".xform(" + that.className() + ")"); + throw new UnsupportedOperationException(this.typeName() + ".xform(" + that.typeName() + ")"); } } } Modified: trunk/x10.runtime/src-x10/x10/lang/Boolean.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Boolean.x10 2009-10-07 20:06:56 UTC (rev 11385) +++ trunk/x10.runtime/src-x10/x10/lang/Boolean.x10 2009-10-07 21:19:30 UTC (rev 11386) @@ -44,6 +44,10 @@ @Native("c++", "x10aux::to_string(#0)") public native def toString(): String; + @Native("java", "#0.getClass().toString()") + @Native("c++", "x10aux::type_name(#0)") + public native def typeName(): String; + @Native("java", "java.lang.Boolean.parseBoolean(#1)") @Native("c++", "x10aux::boolean_utils::parseBoolean(#1)") public native static def parseBoolean(String): Boolean; Modified: trunk/x10.runtime/src-x10/x10/lang/Byte.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Byte.x10 2009-10-07 20:06:56 UTC (rev 11385) +++ trunk/x10.runtime/src-x10/x10/lang/Byte.x10 2009-10-07 21:19:30 UTC (rev 11386) @@ -147,6 +147,10 @@ @Native("c++", "x10aux::to_string(#0)") public native def toString(): String; + @Native("java", "#0.getClass().toString()") + @Native("c++", "x10aux::type_name(#0)") + public native def typeName(): String; + @Native("java", "java.lang.Byte.parseByte(#1, #2)") @Native("c++", "x10aux::byte_utils::parseByte(#1, #2)") public native static def parseByte(String, radix: Int): Byte throws NumberFormatException; Modified: trunk/x10.runtime/src-x10/x10/lang/Char.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Char.x10 2009-10-07 20:06:56 UTC (rev 11385) +++ trunk/x10.runtime/src-x10/x10/lang/Char.x10 2009-10-07 21:19:30 UTC (rev 11386) @@ -63,6 +63,10 @@ @Native("c++", "x10aux::to_string(#0)") public native def toString(): String; + @Native("java", "#0.getClass().toString()") + @Native("c++", "x10aux::type_name(#0)") + public native def typeName(): String; + // Duplicate the methods from java.lang.Character, changing static methods to non-static. // We'll ignore the code point methods for now and just include the isXXX ones. Modified: trunk/x10.runtime/src-x10/x10/lang/Double.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Double.x10 2009-10-07 20:06:56 UTC (rev 11385) +++ trunk/x10.runtime/src-x10/x10/lang/Double.x10 2009-10-07 21:19:30 UTC (rev 11386) @@ -107,6 +107,10 @@ @Native("c++", "x10aux::to_string(#0)") public native def toString(): String; + @Native("java", "#0.getClass().toString()") + @Native("c++", "x10aux::type_name(#0)") + public native def typeName(): String; + @Native("java", "java.lang.Double.parseDouble(#1)") @Native("c++", "x10aux::double_utils::parseDouble(#1)") public native static def parseDouble(String): Double throws NumberFormatException; Modified: trunk/x10.runtime/src-x10/x10/lang/Float.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Float.x10 2009-10-07 20:06:56 UTC (rev 11385) +++ trunk/x10.runtime/src-x10/x10/lang/Float.x10 2009-10-07 21:19:30 UTC (rev 11386) @@ -109,6 +109,10 @@ @Native("c++", "x10aux::to_string(#0)") public native def toString(): String; + @Native("java", "#0.getClass().toString()") + @Native("c++", "x10aux::type_name(#0)") + public native def typeName(): String; + @Native("java", "java.lang.Float.parseFloat(#1)") @Native("c++", "x10aux::float_utils::parseFloat(#1)") public native static def parseFloat(String): Float throws NumberFormatException; Modified: trunk/x10.runtime/src-x10/x10/lang/Int.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Int.x10 2009-10-07 20:06:56 UTC (rev 11385) +++ trunk/x10.runtime/src-x10/x10/lang/Int.x10 2009-10-07 21:19:30 UTC (rev 11386) @@ -137,6 +137,10 @@ @Native("c++", "x10aux::to_string(#0)") public native def toString(): String; + @Native("java", "#0.getClass().toString()") + @Native("c++", "x10aux::type_name(#0)") + public native def typeName(): String; + @Native("java", "java.lang.Integer.toString(#0, #1)") @Native("c++", "x10aux::int_utils::toString(#0, #1)") public native def toString(radix: Int): String; Modified: trunk/x10.runtime/src-x10/x10/lang/Long.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Long.x10 2009-10-07 20:06:56 UTC (rev 11385) +++ trunk/x10.runtime/src-x10/x10/lang/Long.x10 2009-10-07 21:19:30 UTC (rev 11386) @@ -147,6 +147,10 @@ @Native("c++", "x10aux::to_string(#0)") public native def toString(): String; + @Native("java", "#0.getClass().toString()") + @Native("c++", "x10aux::type_name(#0)") + public native def typeName(): String; + @Native("java", "java.lang.Long.parseLong(#1, #2)") @Native("c++", "x10aux::long_utils::parseLong(#1, #2)") public native static def parseLong(String, radix: Int): Long throws NumberFormatException; Modified: trunk/x10.runtime/src-x10/x10/lang/Object.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Object.x10 2009-10-07 20:06:56 UTC (rev 11385) +++ trunk/x10.runtime/src-x10/x10/lang/Object.x10 2009-10-07 21:19:30 UTC (rev 11386) @@ -27,8 +27,8 @@ public def toString(): String; @Native("java", "#0.getClass().toString()") - @Native("c++", "x10aux::class_name(#0)") - public def className(): String; + @Native("c++", "x10aux::type_name(#0)") + public def typeName(): String; @Native("java", "x10.lang.Place.place(#0.location())") @Native("c++", "x10::lang::Place::place(x10aux::location(#0))") Modified: trunk/x10.runtime/src-x10/x10/lang/Ref.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Ref.x10 2009-10-07 20:06:56 UTC (rev 11385) +++ trunk/x10.runtime/src-x10/x10/lang/Ref.x10 2009-10-07 21:19:30 UTC (rev 11386) @@ -44,8 +44,8 @@ public native def toString() : String; @Native("java", "#0.getClass().getName()") - @Native("c++", "x10aux::class_name(#0)") - public native def className() : String; + @Native("c++", "x10aux::type_name(#0)") + public native def typeName() : String; @Native("java", "#0.location()") @Native("c++", "x10::lang::Place::place(x10aux::location(#0))") Modified: trunk/x10.runtime/src-x10/x10/lang/Short.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Short.x10 2009-10-07 20:06:56 UTC (rev 11385) +++ trunk/x10.runtime/src-x10/x10/lang/Short.x10 2009-10-07 21:19:30 UTC (rev 11386) @@ -147,6 +147,10 @@ @Native("c++", "x10aux::to_string(#0)") public native def toString(): String; + @Native("java", "#0.getClass().toString()") + @Native("c++", "x10aux::type_name(#0)") + public native def typeName(): String; + @Native("java", "java.lang.Short.parseShort(#1, #2)") @Native("c++", "x10aux::short_utils::parseShort(#1, #2)") public native static def parseShort(String, radix: Int): Short throws NumberFormatException; Modified: trunk/x10.runtime/src-x10/x10/lang/String.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/String.x10 2009-10-07 20:06:56 UTC (rev 11385) +++ trunk/x10.runtime/src-x10/x10/lang/String.x10 2009-10-07 21:19:30 UTC (rev 11386) @@ -32,7 +32,7 @@ @Native("java", "\"x10.lang.String\"") @Native("c++", "x10::lang::String::Lit((#0)->_type()->name())") - public native def className():String; + public native def typeName():String; @Native("java", "#0.length()") @Native("c++", "#0->length()") Modified: trunk/x10.runtime/src-x10/x10/lang/Throwable.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Throwable.x10 2009-10-07 20:06:56 UTC (rev 11385) +++ trunk/x10.runtime/src-x10/x10/lang/Throwable.x10 2009-10-07 21:19:30 UTC (rev 11386) @@ -49,7 +49,7 @@ @Native("java", "#0.toString()") @Native("c++", "x10aux::to_string(#0)") - public def toString() = className() + ": " + getMessage(); + public def toString() = typeName() + ": " + getMessage(); @Native("java", "x10.core.ThrowableUtilities.getStackTrace(#0)") @Native("c++", "(#0)->getStackTrace()") Modified: trunk/x10.runtime/src-x10/x10/lang/UByte.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/UByte.x10 2009-10-07 20:06:56 UTC (rev 11385) +++ trunk/x10.runtime/src-x10/x10/lang/UByte.x10 2009-10-07 21:19:30 UTC (rev 11386) @@ -133,6 +133,10 @@ @Native("c++", "0xffU") public const MAX_VALUE = 0xff; + @Native("java", "#0.getClass().toString()") + @Native("c++", "x10aux::type_name(#0)") + public native def typeName(): String; + @Native("java", "java.lang.Integer.toString(#0 & 0xff)") @Native("c++", "x10aux::to_string(#0)") public native def toString(): String; Modified: trunk/x10.runtime/src-x10/x10/lang/UInt.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/UInt.x10 2009-10-07 20:06:56 UTC (rev 11385) +++ trunk/x10.runtime/src-x10/x10/lang/UInt.x10 2009-10-07 21:19:30 UTC (rev 11386) @@ -144,6 +144,10 @@ @Native("c++", "0xffffffffU") public const MAX_VALUE = 0xffffffff; + @Native("java", "#0.getClass().toString()") + @Native("c++", "x10aux::type_name(#0)") + public native def typeName(): String; + @Native("java", "java.lang.Long.toString(#0 & 0xffffffffL)") @Native("c++", "x10aux::to_string(#0)") public native def toString(): String; Modified: trunk/x10.runtime/src-x10/x10/lang/ULong.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/ULong.x10 2009-10-07 20:06:56 UTC (rev 11385) +++ trunk/x10.runtime/src-x10/x10/lang/ULong.x10 2009-10-07 21:19:30 UTC (rev 11386) @@ -140,6 +140,10 @@ @Native("c++", "x10aux::to_string(#0)") public native def toString(): String; + @Native("java", "#0.getClass().toString()") + @Native("c++", "x10aux::type_name(#0)") + public native def typeName(): String; + @Native("java", "java.lang.Long.toString(#0 & 0xffffffffffffffffL, #1)") @Native("c++", "x10aux::int_utils::toString(#0, #1)") public native def toString(radix: Int): String; Modified: trunk/x10.runtime/src-x10/x10/lang/UShort.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/UShort.x10 2009-10-07 20:06:56 UTC (rev 11385) +++ trunk/x10.runtime/src-x10/x10/lang/UShort.x10 2009-10-07 21:19:30 UTC (rev 11386) @@ -143,6 +143,10 @@ @Native("c++", "x10aux::int_utils::toString(#0, #1)") public native def toString(radix: Int): String; + @Native("java", "#0.getClass().toString()") + @Native("c++", "x10aux::type_name(#0)") + public native def typeName(): String; + @Native("java", "java.lang.Integer.toHexString(#0)") @Native("c++", "x10aux::int_utils::toHexString(#0)") public native def toHexString(): String; Modified: trunk/x10.runtime/src-x10/x10/lang/Value.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Value.x10 2009-10-07 20:06:56 UTC (rev 11385) +++ trunk/x10.runtime/src-x10/x10/lang/Value.x10 2009-10-07 21:19:30 UTC (rev 11386) @@ -30,8 +30,8 @@ public native def toString(): String; @Native("java", "#0.getClass().toString()") - @Native("c++", "x10aux::class_name(#0)") - public native def className(): String; + @Native("c++", "x10aux::type_name(#0)") + public native def typeName(): String; @Native("java", "x10.runtime.Runtime.here()") @Native("c++", "x10::lang::Place::place(x10aux::here)") Modified: trunk/x10.tests/examples/Benchmarks/Benchmark.x10 =================================================================== --- trunk/x10.tests/examples/Benchmarks/Benchmark.x10 2009-10-07 20:06:56 UTC (rev 11385) +++ trunk/x10.tests/examples/Benchmarks/Benchmark.x10 2009-10-07 21:19:30 UTC (rev 11386) @@ -77,13 +77,13 @@ // if (ops<1e6) out.printf("%.3g kop/s\n", ops/1e3); // else if (ops<1e9) out.printf("%.3g Mop/s\n", ops/1e6); // else out.printf("%.3g Gop/s\n", ops/1e9); - // out.printf("test=%s lg=x10-%s ops=%g\n", className(), lg, ops); + // out.printf("test=%s lg=x10-%s ops=%g\n", typeName(), lg, ops); out.println("time: "+avg+"; count: "+count+"; min/time: "+min/avg); if (ops<1e6) out.println(ops/1e3 + "g kop/s"); else if (ops<1e9) out.println(ops/1e6 + " Mop/s"); else out.println(ops/1e9 + " Gop/s"); - out.printf("test=%s lg=x10-%s ops=%g\n", className(), lg, ops); + out.printf("test=%s lg=x10-%s ops=%g\n", typeName(), lg, ops); // test succeeded return true; Modified: trunk/x10.tests/examples/Constructs/Array/Array1DCodeGen.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Array/Array1DCodeGen.x10 2009-10-07 20:06:56 UTC (rev 11385) +++ trunk/x10.tests/examples/Constructs/Array/Array1DCodeGen.x10 2009-10-07 21:19:30 UTC (rev 11386) @@ -46,7 +46,7 @@ val a = Array.make[double](Dist.makeConstant(R, here)); val b = Array.make[double](Dist.makeConstant(R, here)); - x10.io.Console.OUT.println("runtime type of 3dZeroBasedRect array is " + a.className()); + x10.io.Console.OUT.println("runtime type of 3dZeroBasedRect array is " + a.typeName()); val result = matgen(a,b); val S = [0..9, 0..9, 0..9] as Region; @@ -54,7 +54,7 @@ val bb = Array.make[double](Dist.makeConstant(S, here)); var result1: double = matgen(aa,bb); - x10.io.Console.OUT.println("runtime type of unknown array is " + aa.className()); + x10.io.Console.OUT.println("runtime type of unknown array is " + aa.typeName()); x10.io.Console.OUT.println("results are " + result + " " + result1); var diff: double = result-result1; Modified: trunk/x10.tests/examples/Constructs/Array/TestArray.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Array/TestArray.x10 2009-10-07 20:06:56 UTC (rev 11385) +++ trunk/x10.tests/examples/Constructs/Array/TestArray.x10 2009-10-07 21:19:30 UTC (rev 11386) @@ -10,7 +10,7 @@ var os: StringWriter; var out: Printer; - val testName = className(); + val testName = typeName(); def this() { System.setProperty("line.separator", "\n"); Modified: trunk/x10.tests/examples/Constructs/Distribution/TestDist.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Distribution/TestDist.x10 2009-10-07 20:06:56 UTC (rev 11385) +++ trunk/x10.tests/examples/Constructs/Distribution/TestDist.x10 2009-10-07 21:19:30 UTC (rev 11386) @@ -10,7 +10,7 @@ var os: StringWriter; var out: Printer; - val testName = className(); + val testName = typeName(); def this() { System.setProperty("line.separator", "\n"); Modified: trunk/x10.tests/examples/Constructs/Point/TestPoint.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Point/TestPoint.x10 2009-10-07 20:06:56 UTC (rev 11385) +++ trunk/x10.tests/examples/Constructs/Point/TestPoint.x10 2009-10-07 21:19:30 UTC (rev 11386) @@ -7,7 +7,7 @@ var os: StringWriter; var out: Printer; - val testName = className().substring(6,className().length()); + val testName = typeName().substring(6,typeName().length()); def this() { System.setProperty("line.separator", "\n"); Modified: trunk/x10.tests/examples/Constructs/Region/TestRegion.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Region/TestRegion.x10 2009-10-07 20:06:56 UTC (rev 11385) +++ trunk/x10.tests/examples/Constructs/Region/TestRegion.x10 2009-10-07 21:19:30 UTC (rev 11386) @@ -12,7 +12,7 @@ var out: Printer; def testName() { - var cn:String = className(); + var cn:String = typeName(); val init = cn.substring(0,6); // XTENLANG-??? if (init.equals("class ")) cn = cn.substring(6, cn.length()); Modified: trunk/x10.tests/examples/Issues/XTENLANG_242.x10 =================================================================== --- trunk/x10.tests/examples/Issues/XTENLANG_242.x10 2009-10-07 20:06:56 UTC (rev 11385) +++ trunk/x10.tests/examples/Issues/XTENLANG_242.x10 2009-10-07 21:19:30 UTC (rev 11386) @@ -8,8 +8,8 @@ */ class A { - val name1 = className(); - def name2() = className(); + val name1 = typeName(); + def name2() = typeName(); } class B extends A {} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <vj...@us...> - 2009-10-08 21:54:08
|
Revision: 11405 http://x10.svn.sourceforge.net/x10/?rev=11405&view=rev Author: vj0 Date: 2009-10-08 21:54:00 +0000 (Thu, 08 Oct 2009) Log Message: ----------- Hack around a problem with recursively defined real constraints. Modified Paths: -------------- trunk/x10.compiler/src/x10/types/X10ClassDef_c.java trunk/x10.runtime/src-x10/x10/lang/Int.x10 trunk/x10.runtime/src-x10/x10/lang/Place.x10 Modified: trunk/x10.compiler/src/x10/types/X10ClassDef_c.java =================================================================== --- trunk/x10.compiler/src/x10/types/X10ClassDef_c.java 2009-10-08 21:07:07 UTC (rev 11404) +++ trunk/x10.compiler/src/x10/types/X10ClassDef_c.java 2009-10-08 21:54:00 UTC (rev 11405) @@ -144,10 +144,11 @@ public XConstraint getRootClause() { if (rootClause == null) { if (computing) { - this.rootClause = Types.<XConstraint>ref(new XConstraint_c()); + /*this.rootClause = Types.<XConstraint>ref(new XConstraint_c()); this.rootClauseInvalid = new SemanticException("The real clause of " + this + " depends upon itself.", position()); - return rootClause.get(); + return rootClause.get();*/ + return new XConstraint_c(); } computing = true; Modified: trunk/x10.runtime/src-x10/x10/lang/Int.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Int.x10 2009-10-08 21:07:07 UTC (rev 11404) +++ trunk/x10.runtime/src-x10/x10/lang/Int.x10 2009-10-08 21:54:00 UTC (rev 11405) @@ -15,7 +15,7 @@ // v-- when used @NativeRep("c++", "x10_int", "x10_int", null) // ^ when constructed -public final value Int { +public struct Int { @Native("java", "((#1) < (#2))") @Native("c++", "((#1) < (#2))") public native static safe operator (x:Int) < (y:Int): Boolean; Modified: trunk/x10.runtime/src-x10/x10/lang/Place.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Place.x10 2009-10-08 21:07:07 UTC (rev 11404) +++ trunk/x10.runtime/src-x10/x10/lang/Place.x10 2009-10-08 21:54:00 UTC (rev 11405) @@ -14,7 +14,7 @@ * @author tardieu * @author vj */ -public final value Place(id: int) { +public final struct Place(id: int) { public const MAX_PLACES = x10.runtime.NativeRuntime.MAX_PLACES; public const places = Rail.makeVal[Place](MAX_PLACES, ((id: int) => new Place(id))); public const FIRST_PLACE: Place(0) = places(0) as Place(0); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <vj...@us...> - 2009-10-10 03:08:23
|
Revision: 11407 http://x10.svn.sourceforge.net/x10/?rev=11407&view=rev Author: vj0 Date: 2009-10-10 03:08:14 +0000 (Sat, 10 Oct 2009) Log Message: ----------- Removed super clause for structs. Removed Primitive. Type-checking works for structs with interfaces. Modified Paths: -------------- trunk/x10.compiler/src/x10/ast/X10ClassDecl_c.java trunk/x10.compiler/src/x10/ast/X10ConstructorCall_c.java trunk/x10.compiler/src/x10/ast/X10FieldDecl_c.java trunk/x10.compiler/src/x10/parser/X10Parser.java trunk/x10.compiler/src/x10/parser/X10Parserprs.java trunk/x10.compiler/src/x10/parser/x10.g 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/runtime/PlaceLocalHandle.struct_h trunk/x10.runtime/src-x10/x10/lang/String.x10 Added Paths: ----------- trunk/x10.compiler/src/x10/types/X10ConstructorInstance_c.l trunk/x10.tests/examples/Constructs/Structs/FinalMethod.jl trunk/x10.tests/examples/Constructs/XtenTwoOhTypeSsytem/PrimitiveIsNotParameterType_MustFailCompile.x10 Removed Paths: ------------- trunk/x10.runtime/src-x10/x10/lang/Primitive.x10 trunk/x10.tests/examples/Constructs/Structs/StructCannotHaveNonFinalMethods_MustFailCompile.x10 Modified: trunk/x10.compiler/src/x10/ast/X10ClassDecl_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10ClassDecl_c.java 2009-10-09 16:09:33 UTC (rev 11406) +++ trunk/x10.compiler/src/x10/ast/X10ClassDecl_c.java 2009-10-10 03:08:14 UTC (rev 11407) @@ -212,9 +212,6 @@ else if (thisType.fullName().equals(QName.make("x10.lang.Value"))) { thisType.superType(null); } - else if (thisType.fullName().equals(QName.make("x10.lang.Primitive"))) { - thisType.superType(null); - } else if (thisType.fullName().equals(QName.make("x10.lang.Object"))) { thisType.superType(null); } @@ -229,13 +226,8 @@ }); thisType.superType(superRef); } - else if (superClass == null && X10Flags.toX10Flags(flags().flags()).isStruct()) { - superRef.setResolver(new Runnable() { - public void run() { - superRef.update(xts.Primitive()); - } - }); - thisType.superType(superRef); + else if (superClass == null && X10Flags.toX10Flags(flags().flags()).isStruct()) { + thisType.superType(null); } else if (superClass == null) { superRef.setResolver(new Runnable() { Modified: trunk/x10.compiler/src/x10/ast/X10ConstructorCall_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10ConstructorCall_c.java 2009-10-09 16:09:33 UTC (rev 11406) +++ trunk/x10.compiler/src/x10/ast/X10ConstructorCall_c.java 2009-10-10 03:08:14 UTC (rev 11407) @@ -11,6 +11,7 @@ package x10.ast; +import java.awt.Container; import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; @@ -32,9 +33,11 @@ import polyglot.types.Matcher; import polyglot.types.QName; import polyglot.types.SemanticException; +import polyglot.types.StructType; import polyglot.types.Type; import polyglot.types.TypeSystem; import polyglot.types.Types; +import polyglot.util.InternalCompilerError; import polyglot.util.Pair; import polyglot.util.Position; import polyglot.visit.ContextVisitor; @@ -45,6 +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; @@ -119,6 +123,18 @@ Context context = tc.context(); ClassType ct = context.currentClass(); Type superType = ct.superClass(); + if (superType == null) { + // this can happen for structs, and for Object + X10Type type = (X10Type) context.currentClass(); + if (X10TypeMixin.isStruct(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(); + return nf.Empty(Position.COMPILER_GENERATED); + } + throw new InternalCompilerError("Unexpected null supertype for " + + this, position()); + } // The qualifier specifies the enclosing instance of this inner class. // The type of the qualifier must be the outer class of this Modified: trunk/x10.compiler/src/x10/ast/X10FieldDecl_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10FieldDecl_c.java 2009-10-09 16:09:33 UTC (rev 11406) +++ trunk/x10.compiler/src/x10/ast/X10FieldDecl_c.java 2009-10-10 03:08:14 UTC (rev 11407) @@ -53,6 +53,7 @@ import x10.types.X10Flags; import x10.types.X10InitializerDef; import x10.types.X10Type; +import x10.types.X10TypeMixin; import x10.types.X10TypeSystem; public class X10FieldDecl_c extends FieldDecl_c implements X10FieldDecl { @@ -263,15 +264,22 @@ @Override public Node typeCheck(ContextVisitor tc) throws SemanticException { + X10Type type = (X10Type) this.type().type(); - if (this.type().type().isVoid()) + if (type.isVoid()) throw new SemanticException("Field cannot have type " + this.type().type() + ".", position()); - if (((X10Type)this.type().type()).isProto()) { + if (type.isProto()) { throw new SemanticException("Field cannot have type " + this.type().type() + " (a proto type).", position()); } + if (X10TypeMixin.isStruct(fieldDef().container().get()) && + ! X10Flags.toX10Flags(fieldDef().flags()).isFinal()) { + throw new SemanticException("A struct may not have var fields.", + position()); + } + X10TypeSystem ts = (X10TypeSystem) tc.typeSystem(); X10NodeFactory nf = (X10NodeFactory) tc.nodeFactory(); X10Context context = (X10Context) tc.context(); @@ -319,7 +327,7 @@ "initializer \"" + init.type() + "\" does not match that of " + "the declaration \"" + - type.type() + "\".", + type + "\".", init.position()); } } Modified: trunk/x10.compiler/src/x10/parser/X10Parser.java =================================================================== --- trunk/x10.compiler/src/x10/parser/X10Parser.java 2009-10-09 16:09:33 UTC (rev 11406) +++ trunk/x10.compiler/src/x10/parser/X10Parser.java 2009-10-10 03:08:14 UTC (rev 11407) @@ -2310,7 +2310,7 @@ } // - // Rule 80: ValueClassDeclaration ::= ClassModifiersopt struct Identifier TypeParamsWithVarianceopt Propertiesopt WhereClauseopt Superopt Interfacesopt ClassBody + // Rule 80: ValueClassDeclaration ::= ClassModifiersopt struct Identifier TypeParamsWithVarianceopt Propertiesopt WhereClauseopt Interfacesopt ClassBody // case 80: { //#line 1470 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" @@ -2325,11 +2325,9 @@ //#line 1468 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" DepParameterExpr WhereClauseopt = (DepParameterExpr) getRhsSym(6); //#line 1468 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" - TypeNode Superopt = (TypeNode) getRhsSym(7); + List Interfacesopt = (List) getRhsSym(7); //#line 1468 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" - List Interfacesopt = (List) getRhsSym(8); - //#line 1468 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" - ClassBody ClassBody = (ClassBody) getRhsSym(9); + ClassBody ClassBody = (ClassBody) getRhsSym(8); //#line 1470 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" checkTypeName(Identifier); List TypeParametersopt = TypeParamsWithVarianceopt; @@ -2337,7 +2335,7 @@ DepParameterExpr ci = WhereClauseopt; ClassDecl cd = (nf.X10ClassDecl(pos(getLeftSpan(), getRightSpan()), extractFlags(ClassModifiersopt, X10Flags.STRUCT), Identifier, TypeParametersopt, - props, ci, Superopt, Interfacesopt, ClassBody)); + props, ci, null, Interfacesopt, ClassBody)); cd = (ClassDecl) ((X10Ext) cd.ext()).annotations(extractAnnotations(ClassModifiersopt)); setResult(cd); break; Modified: trunk/x10.compiler/src/x10/parser/X10Parserprs.java =================================================================== --- trunk/x10.compiler/src/x10/parser/X10Parserprs.java 2009-10-09 16:09:33 UTC (rev 11406) +++ trunk/x10.compiler/src/x10/parser/X10Parserprs.java 2009-10-10 03:08:14 UTC (rev 11407) @@ -20,13 +20,13 @@ public final static int MAX_NAME_LENGTH = 31; public final int getMaxNameLength() { return MAX_NAME_LENGTH; } - public final static int NUM_STATES = 738; + public final static int NUM_STATES = 737; public final int getNumStates() { return NUM_STATES; } public final static int NT_OFFSET = 149; public final int getNtOffset() { return NT_OFFSET; } - public final static int LA_STATE_OFFSET = 15247; + public final static int LA_STATE_OFFSET = 15253; public final int getLaStateOffset() { return LA_STATE_OFFSET; } public final static int MAX_LA = 1; @@ -56,10 +56,10 @@ public final static int EOLT_SYMBOL = 141; public final int getEoltSymbol() { return EOLT_SYMBOL; } - public final static int ACCEPT_ACTION = 12535; + public final static int ACCEPT_ACTION = 12541; public final int getAcceptAction() { return ACCEPT_ACTION; } - public final static int ERROR_ACTION = 14583; + public final static int ERROR_ACTION = 14589; public final int getErrorAction() { return ERROR_ACTION; } public final static boolean BACKTRACK = true; @@ -101,9 +101,9 @@ 0,0,0,0,1,0,1,0,0,0, 0,0,0,0,0,0,0,0,1,0, 1,1,0,0,0,1,1,0,0,0, - 0,1,0,0,1,0,0,1,1,0, - 0,0,0,1,0,0,0,0,0,0, - 0,0,0,0,0,1,1,0,1,0, + 0,1,0,0,1,0,0,1,0,0, + 0,1,0,0,0,0,0,0,0,0, + 0,0,0,1,1,1,0,1,0,0, 0,1,0,1,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0, 0,1,0,0,1,0,0,1,0,0, @@ -134,9 +134,9 @@ 153,203,224,231,232,20,41,42,67,79, 186,223,131,132,197,205,213,24,29,30, 38,43,44,65,85,86,87,165,175,204, - 207,212,48,53,59,63,64,72,77,78, - 83,130,148,149,152,154,164,190,198,200, - 202,219,253,26,36,39,60,61,80,81, + 207,212,48,53,59,63,64,72,78,130, + 148,149,152,154,164,190,198,200,202,219, + 253,26,36,39,60,61,77,80,81,83, 88,129,137,140,143,147,157,158,180,182, 184,185,194,195,196,199,201,216,218,220, 222,228,2,4,8,21,25,37,45,46, @@ -181,7 +181,7 @@ 9,9,6,1,1,2,8,1,1,1, 3,2,1,1,3,1,6,4,4,2, 1,6,5,3,3,3,1,3,3,3, - 1,0,2,1,3,1,1,9,9,9, + 1,0,2,1,3,1,1,9,9,8, 9,2,1,1,1,1,1,4,3,1, 1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1, @@ -243,321 +243,321 @@ 0,1,0,1,-245,1,2,3,4,5, 6,7,8,9,10,11,12,13,14,15, 16,17,18,19,-18,-2,22,23,24,25, - 26,27,-455,-462,-6,3,3,3,-163,1, - 2,37,38,-369,20,21,3,-4,-8,1, - 2,19,4,-421,1,2,-432,1,2,-10, - 1,2,58,-169,-389,61,62,63,64,65, - 66,67,68,69,70,71,72,-12,-91,75, + 26,27,-455,-4,-435,3,-421,1,2,-658, + -19,37,38,-369,20,21,3,-12,-8,1, + 2,19,4,-163,1,2,-54,-498,1,2, + 20,21,58,-13,-389,61,62,63,64,65, + 66,67,68,69,70,71,72,-14,-506,75, 76,77,78,79,80,81,82,83,84,85, 86,87,88,89,90,91,92,93,94,95, - 96,97,-3,-13,61,62,63,-24,104,105, - 3,107,108,-452,-576,111,112,113,114,115, - 116,58,-54,119,-370,-14,-15,3,124,125, - 66,67,68,69,70,71,72,133,-11,1, - 2,109,4,-16,-258,1,2,-17,-435,-241, - 1,2,148,-312,1,2,3,4,5,6, + 96,97,-3,-15,61,62,63,-9,104,105, + -275,107,108,74,-159,111,112,113,114,115, + 116,-370,-22,119,3,-487,1,2,124,125, + 66,67,68,69,70,71,72,133,99,100, + -593,109,20,21,-258,1,2,-10,1,2, + -86,-16,148,-312,1,2,3,4,5,6, 7,8,9,10,11,12,13,14,15,16, - 17,18,19,135,-21,22,23,24,25,26, - 27,-36,-19,145,3,61,62,63,-25,-26, - 37,38,-445,1,2,-486,1,2,145,-28, - -659,145,20,21,151,172,174,151,-29,166, - -27,58,105,3,61,62,63,64,65,66, - 67,68,69,70,71,72,170,-30,75,76, + 17,18,19,59,60,22,23,24,25,26, + 27,145,61,62,63,-43,-6,151,135,3, + 37,38,135,-169,-528,1,2,-304,145,-11, + 1,2,-452,4,172,20,21,164,151,-187, + -27,58,173,3,61,62,63,64,65,66, + 67,68,69,70,71,72,169,171,75,76, 77,78,79,80,81,82,83,84,85,86, 87,88,89,90,91,92,93,94,95,96, - 97,-75,196,205,3,177,-685,104,105,3, - 107,108,-31,204,111,112,113,114,115,116, - 19,-32,119,-118,74,19,3,124,125,201, - 216,-260,1,2,135,104,133,-390,1,2, - 166,189,19,191,192,173,-527,1,2,99, - 100,148,-596,1,2,3,4,5,6,7, + 97,58,195,205,197,58,-684,104,105,3, + 107,108,228,-444,111,112,113,114,115,116, + -146,121,119,3,134,19,151,124,125,-17, + 216,171,-260,1,2,164,133,-437,-390,1, + 2,189,-21,191,192,217,189,-25,191,192, + 160,148,-596,1,2,3,4,5,6,7, 8,9,10,11,12,13,14,15,16,17, - 18,19,208,210,22,23,24,25,26,27, - 74,-82,188,123,232,-259,234,-188,-22,37, - 38,-326,1,2,-159,-33,151,-9,-403,1, - 2,-242,1,2,-304,99,100,213,20,21, - 58,-243,170,61,62,63,64,65,66,67, - 68,69,70,71,72,175,228,75,76,77, + 18,19,59,60,22,23,24,25,26,27, + 74,-82,188,123,232,126,234,-188,129,37, + 38,-26,-432,1,2,-241,1,2,-47,1, + 2,204,-242,1,2,99,100,213,-576,219, + 58,167,-457,61,62,63,64,65,66,67, + 68,69,70,71,72,181,-299,75,76,77, 78,79,80,81,82,83,84,85,86,87, 88,89,90,91,92,93,94,95,96,97, - -464,1,2,59,60,74,104,105,-43,107, - 108,-275,58,111,112,113,114,115,116,-505, - 59,119,135,-508,1,2,124,125,20,21, - 99,100,-307,1,2,133,134,-664,1,2, + -465,1,2,-28,-69,74,104,105,-111,107, + 108,-29,210,111,112,113,114,115,116,-30, + -31,119,-298,135,20,21,124,125,20,21, + 99,100,-307,1,2,133,134,-663,1,2, 3,4,5,6,7,8,9,10,11,12, - 13,14,15,16,17,18,19,106,171,22, - 23,24,25,26,27,169,-273,-374,187,-286, - 1,2,-34,138,37,38,-69,181,143,142, - -335,144,195,-338,197,-86,145,-47,1,2, - -48,1,2,212,-35,58,20,21,61,62, + 13,14,15,16,17,18,19,169,106,22, + 23,24,25,26,27,-273,-286,1,2,187, + -392,1,2,186,37,38,-443,1,2,142, + 135,144,-32,195,-335,197,-33,145,-48,1, + 2,-34,130,151,212,58,-503,121,61,62, 63,64,65,66,67,68,69,70,71,72, - -37,170,75,76,77,78,79,80,81,82, + 168,-636,75,76,77,78,79,80,81,82, 83,84,85,86,87,88,89,90,91,92, - 93,94,95,96,97,187,189,196,191,192, - 74,104,105,-379,107,108,-343,-111,111,112, - 113,114,115,116,74,-611,119,74,135,-39, - -574,124,125,-362,-606,99,100,20,21,169, - 133,-308,1,2,-522,106,-399,1,2,99, - 100,181,99,100,173,148,-703,1,2,3, + 93,94,95,96,97,-308,1,2,196,74, + -379,104,105,121,107,108,-338,-35,111,112, + 113,114,115,116,58,-91,119,-37,74,-39, + -574,124,125,-40,99,100,208,167,-41,58, + 133,-606,106,-509,1,2,106,-399,1,2, + -532,181,106,99,100,148,-702,1,2,3, 4,5,6,7,8,9,10,11,12,13, - 14,15,16,17,18,19,121,43,22,23, - 24,25,26,27,-344,215,-126,185,-345,3, - 74,-636,59,37,38,-392,1,2,-50,1, - 2,164,165,-593,74,19,217,-507,1,2, - -571,1,2,-40,58,99,100,61,62,63, + 14,15,16,17,18,19,230,-42,22,23, + 24,25,26,27,43,215,-75,185,-343,3, + 74,110,-344,37,38,-447,1,2,-49,-345, + -50,1,2,-635,74,19,-92,1,2,-52, + -326,1,2,-53,58,99,100,61,62,63, 64,65,66,67,68,69,70,71,72,99, 100,75,76,77,78,79,80,81,82,83, 84,85,86,87,88,89,90,91,92,93, - 94,95,96,97,-127,-257,126,3,74,129, - 104,105,74,107,108,74,-393,111,112,113, - 114,115,116,19,130,119,-92,1,2,-276, - 124,125,-114,99,100,-187,-41,99,100,133, - 99,100,-96,1,2,-97,1,2,43,186, - 175,106,20,21,148,-329,1,2,3,4, + 94,95,96,97,-36,-339,126,3,3,129, + 104,105,74,107,108,-674,74,111,112,113, + 114,115,116,74,19,119,126,74,135,129, + 124,125,-257,-445,1,2,-243,99,100,133, + 185,99,100,-403,1,2,186,-569,99,100, + 175,106,99,100,148,-329,1,2,3,4, 5,6,7,8,9,10,11,12,13,14, - 15,16,17,18,19,59,185,22,23,24, - 25,26,27,-167,188,-346,3,134,-42,226, - 227,-202,37,38,3,-443,1,2,-98,1, - 2,-49,19,-447,1,2,-487,1,2,-38, - 19,-146,3,58,3,162,61,62,63,64, - 65,66,67,68,69,70,71,72,171,169, + 15,16,17,18,19,43,201,22,23,24, + 25,26,27,-276,-55,188,226,227,-571,1, + 2,-118,37,38,3,59,-488,1,2,-96, + 1,2,-362,-164,-24,145,3,3,104,-38, + 19,-56,3,58,109,-609,61,62,63,64, + 65,66,67,68,69,70,71,72,168,-610, 75,76,77,78,79,80,81,82,83,84, 85,86,87,88,89,90,91,92,93,94, - 95,96,97,-52,-53,-638,-99,1,2,104, - 105,126,107,108,129,-55,111,112,113,114, - 115,116,219,-56,119,-498,1,2,-57,124, + 95,96,97,-97,1,2,196,-57,43,104, + 105,59,107,108,61,-58,111,112,113,114, + 115,116,43,126,119,-61,129,172,-67,124, 125,-628,1,2,3,4,5,6,7,8, 9,10,11,12,13,14,15,16,17,18, - 19,106,173,22,23,24,25,26,27,106, - -130,206,106,104,105,130,107,108,37,38, - 111,112,113,114,115,116,-100,1,2,74, - 20,21,123,-101,1,2,127,128,153,58, + 19,168,106,22,23,24,25,26,27,105, + -68,-72,207,104,105,200,107,108,37,38, + 111,112,113,114,115,116,-98,1,2,214, + 187,-489,123,-99,1,2,127,128,206,58, 131,132,61,62,63,64,65,66,67,68, - 69,70,71,72,99,100,75,76,77,78, + 69,70,71,72,171,167,75,76,77,78, 79,80,81,82,83,84,85,86,87,88, - 89,90,91,92,93,94,95,96,97,-524, - -625,106,-102,1,2,104,105,-465,107,108, - 3,-58,111,112,113,114,115,116,-61,190, - 119,-103,1,2,-67,124,125,-174,1,2, + 89,90,91,92,93,94,95,96,97,-525, + -625,-508,1,2,-463,104,105,3,107,108, + 59,60,111,112,113,114,115,116,-73,190, + 119,-100,1,2,-74,124,125,-174,1,2, 3,4,5,6,7,8,9,10,11,12, 13,14,15,16,17,18,19,20,21,22, 23,24,25,26,27,28,29,30,31,32, 33,34,35,36,37,38,39,40,41,42, 43,44,45,46,47,48,49,50,51,52, - 53,54,55,56,57,-109,1,2,61,62, + 53,54,55,56,57,-101,1,2,61,62, 63,-180,1,2,3,4,5,6,7,8, 9,10,11,12,13,14,15,16,17,18, 19,20,21,22,23,24,25,26,27,28, 29,30,31,32,33,34,35,36,101,130, 39,40,41,42,134,44,45,46,47,48, - -115,1,2,136,-68,118,-72,120,-51,1, - 2,-73,4,5,6,7,8,9,10,11, - 12,13,14,15,16,17,18,-74,20,21, - -123,1,2,-213,1,2,28,29,30,31, - 32,-298,155,-83,1,2,3,4,5,6, + -102,1,2,-76,-77,118,-78,120,-51,1, + 2,-79,4,5,6,7,8,9,10,11, + 12,13,14,15,16,17,18,-80,20,21, + 169,-103,1,2,170,-81,28,29,30,31, + 32,-87,155,-83,1,2,3,4,5,6, 7,8,9,10,11,12,13,14,15,16, 17,18,19,20,21,22,23,24,25,26, 27,28,29,30,31,32,33,34,35,36, 37,38,39,40,41,42,43,44,45,46, 47,48,49,50,51,52,53,54,55,56, - 57,-502,-609,-189,61,62,63,-157,1,2, + 57,-109,1,2,61,62,63,-157,1,2, 3,4,5,6,7,8,9,10,11,12, 13,14,15,16,17,18,19,20,21,22, 23,24,25,26,27,28,29,30,31,32, - 33,34,35,36,101,43,39,40,41,42, - -639,44,45,46,47,-641,-76,149,-644,58, - -670,118,121,120,-60,1,2,3,4,5, + 33,34,35,36,101,-88,39,40,41,42, + -637,44,45,46,47,-638,-89,149,-640,-90, + -643,118,-93,120,-60,1,2,3,4,5, 6,7,8,9,10,11,12,13,14,15, 16,17,18,19,20,21,22,23,24,25, 26,27,28,29,30,31,32,33,34,35, 36,37,38,39,40,41,42,43,44,45, 46,47,48,49,50,51,52,53,54,55, - 56,57,-204,-172,74,3,-254,1,2,74, - -190,-191,74,-222,74,-77,3,73,-78,-164, - -79,19,3,20,21,142,-80,144,-525,99, - 100,-81,19,-531,99,100,-87,99,100,99, - 100,-88,98,-158,1,2,3,4,5,6, + 56,57,-114,-94,74,-115,1,2,-126,74, + -189,3,74,-127,74,-190,3,73,-123,1, + 2,-500,20,21,-213,1,2,19,-374,99, + 100,-526,19,-95,99,100,-104,99,100,99, + 100,-105,98,-158,1,2,3,4,5,6, 7,8,9,10,11,12,13,14,15,16, 17,18,19,20,21,22,23,24,25,26, 27,28,29,30,31,32,33,34,35,36, - 61,-89,39,40,41,42,-680,44,45,46, - -341,1,2,149,-171,1,2,3,4,5, + 59,60,39,40,41,42,-669,44,45,46, + -254,1,2,149,-171,1,2,3,4,5, 6,7,8,9,10,11,12,13,14,15, 16,17,18,19,20,21,22,23,24,25, 26,27,28,29,30,31,32,33,34,35, 36,37,38,39,40,41,42,43,44,45, 46,47,48,49,50,51,52,53,54,55, - 56,57,142,142,144,144,-184,-269,130,126, - 74,-90,129,-194,-690,1,2,73,4,5, + 56,57,142,-106,144,-107,-108,142,-110,144, + 74,130,-199,-130,-689,1,2,73,4,5, 6,7,8,9,10,11,12,13,14,15, - 16,17,18,20,21,99,100,-299,-342,1, - 2,-93,98,-155,1,2,3,4,5,6, + 16,17,18,20,21,99,100,-341,1,2, + 162,163,98,-155,1,2,3,4,5,6, 7,8,9,10,11,12,13,14,15,16, 17,18,19,20,21,22,23,24,25,26, 27,28,29,30,31,32,33,34,35,36, - 74,74,39,40,41,42,-94,44,45,-684, - -363,1,2,149,-176,1,2,3,4,5, + -184,-112,39,40,41,42,-116,44,45,-342, + 1,2,-117,149,-176,1,2,3,4,5, 6,7,8,9,10,11,12,13,14,15, 16,17,18,19,20,21,22,23,24,25, 26,27,28,29,30,31,32,33,34,35, 36,37,38,39,40,41,42,43,44,45, 46,47,48,49,50,51,52,53,54,55, - 56,57,-95,-686,-402,1,2,-437,121,-104, - -511,1,2,74,-689,1,2,73,4,5, + 56,57,-125,-679,74,-363,1,2,-269,-611, + -499,1,2,-172,-688,1,2,73,4,5, 6,7,8,9,10,11,12,13,14,15, - 16,17,18,-578,178,178,-105,-106,99,100, - 176,-418,98,-291,1,2,3,4,5,6, + 16,17,18,20,21,-578,-129,175,174,-191, + -131,-393,98,-291,1,2,3,4,5,6, 7,8,9,10,11,12,13,14,15,16, - 17,18,19,-610,-107,22,23,24,25,26, - 27,-537,1,2,-543,1,2,74,-108,65, - 37,38,-546,1,2,-339,-110,-692,3,-552, - 1,2,-199,149,-586,1,2,-599,1,2, - 59,58,99,100,19,241,43,64,65,66, - 67,68,69,70,71,72,106,230,75,76, + 17,18,19,201,-162,22,23,24,25,26, + 27,-512,1,2,-538,1,2,74,-165,65, + 37,38,74,-544,1,2,-547,1,2,-553, + 1,2,-166,149,-586,1,2,-599,1,2, + 59,58,99,100,-591,241,176,64,65,66, + 67,68,69,70,71,72,106,-418,75,76, 77,78,79,80,81,82,83,84,85,86, 87,88,89,90,91,92,93,94,95,96, 97,-292,1,2,3,4,5,6,7,8, 9,10,11,12,13,14,15,16,17,18, - 19,74,-200,22,23,24,25,26,27,-112, - -223,-234,-224,3,-116,3,-117,106,37,38, - 106,-274,20,21,-125,-129,99,100,106,19, - 176,19,-131,186,109,106,-710,164,165,58, - 106,20,21,106,-162,64,65,66,67,68, - 69,70,71,72,200,-165,75,76,77,78, + 19,-614,58,22,23,24,25,26,27,-173, + -234,-167,-202,-183,3,3,59,106,37,38, + 106,142,173,144,176,-683,-192,-195,174,106, + 19,19,106,-685,-196,106,-691,162,163,58, + 106,-709,-197,106,43,64,65,66,67,68, + 69,70,71,72,200,-198,75,76,77,78, 79,80,81,82,83,84,85,86,87,88, 89,90,91,92,93,94,95,96,97,-297, 1,2,3,4,5,6,7,8,9,10, - 11,12,13,14,15,16,17,18,19,174, - -569,22,23,24,25,26,27,-400,-226,177, - 74,3,-229,102,103,3,37,38,-353,-246, - -249,-252,3,3,3,-166,-173,19,-530,1, - 2,19,207,201,-183,99,100,58,19,19, - 19,-192,-195,64,65,66,67,68,69,70, - 71,72,-444,-196,75,76,77,78,79,80, + 11,12,13,14,15,16,17,18,19,74, + -194,22,23,24,25,26,27,74,-200,-353, + 74,-204,102,103,3,74,37,38,-203,-222, + 20,21,3,-223,99,100,3,-205,20,21, + 19,-661,99,100,-206,99,100,58,19,-456, + 99,100,19,64,65,66,67,68,69,70, + 71,72,-404,-207,75,76,77,78,79,80, 81,82,83,84,85,86,87,88,89,90, 91,92,93,94,95,96,97,-309,1,2, 3,4,5,6,7,8,9,10,11,12, - 13,14,15,16,17,18,19,-288,-197,22, - 23,24,25,26,27,-272,-279,-315,3,3, - -333,59,60,-518,37,38,3,20,21,-521, - 102,103,3,-662,19,19,126,20,21,129, - 20,21,19,-457,-459,58,-488,-198,19,-581, - -203,64,65,66,67,68,69,70,71,72, - -499,-205,75,76,77,78,79,80,81,82, + 13,14,15,16,17,18,19,-575,59,22, + 23,24,25,26,27,-224,-226,-229,3,3, + 3,102,103,-246,37,38,3,-249,-252,-272, + 3,3,3,-208,19,19,19,-402,1,2, + -274,-209,19,102,103,58,19,19,19,-405, + -406,64,65,66,67,68,69,70,71,72, + 20,21,75,76,77,78,79,80,81,82, 83,84,85,86,87,88,89,90,91,92, 93,94,95,96,97,-373,1,2,3,4, 5,6,7,8,9,10,11,12,13,14, - 15,16,17,18,19,59,60,22,23,24, - 25,26,27,-532,1,2,-575,-577,-533,59, - 60,3,37,38,-665,-566,209,-568,3,-635, - 3,-667,3,-669,-206,102,103,19,-712,1, - 2,-460,-207,58,19,-208,19,-209,19,64, - 65,66,67,68,69,70,71,72,-529,242, + 15,16,17,18,19,-288,-210,22,23,24, + 25,26,27,-279,-315,-211,3,-333,-531,1, + 2,159,37,38,-212,20,21,-519,166,-214, + 3,-215,19,126,20,21,129,20,21,-533, + 1,2,-216,58,-530,-217,19,-218,-581,64, + 65,66,67,68,69,70,71,72,-459,-219, 75,76,77,78,79,80,81,82,83,84, 85,86,87,88,89,90,91,92,93,94, 95,96,97,-425,1,2,3,4,5,6, 7,8,9,10,11,12,13,14,15,16, - 17,18,19,160,160,22,23,24,25,26, - 27,168,168,164,165,-675,-210,59,60,-674, - 37,38,-683,-211,-694,-212,102,103,-697,-214, - -215,-216,-217,102,103,102,103,-218,-219,-705, - -220,58,126,126,-591,129,129,64,65,66, - 67,68,69,70,71,72,-544,-221,75,76, + 17,18,19,59,60,22,23,24,25,26, + 27,-400,-522,-524,-534,3,3,3,-664,-466, + 37,38,3,-666,-220,-567,177,177,3,180, + 180,19,19,19,-668,-711,1,2,-221,-673, + -225,58,-545,-227,19,-228,-230,64,65,66, + 67,68,69,70,71,72,-461,-231,75,76, 77,78,79,80,81,82,83,84,85,86, 87,88,89,90,91,92,93,94,95,96, - 97,-491,1,2,3,4,5,6,7,8, + 97,-492,1,2,3,4,5,6,7,8, 9,10,11,12,13,14,15,16,17,18, - 19,160,58,22,23,24,25,26,27,168, - -225,-227,-700,-228,-701,59,60,-702,37,38, - -707,102,103,-709,102,103,102,103,-715,-230, - 102,103,20,21,20,21,-231,20,21,58, - -553,102,103,-232,-233,64,65,66,67,68, - 69,70,71,72,-554,-237,75,76,77,78, + 19,59,60,22,23,24,25,26,27,-577, + 162,163,-605,-699,-232,3,-682,159,37,38, + 102,103,-693,-700,166,102,103,-696,-233,-704, + -237,19,-238,20,21,-240,102,103,-706,58, + -554,102,103,20,21,64,65,66,67,68, + 69,70,71,72,-555,136,75,76,77,78, 79,80,81,82,83,84,85,86,87,88, - 89,90,91,92,93,94,95,96,97,-493, + 89,90,91,92,93,94,95,96,97,-494, 1,2,3,4,5,6,7,8,9,10, 11,12,13,14,15,16,17,18,19,59, - 60,22,23,24,25,26,27,-721,-238,-240, - -614,-247,-722,59,60,200,37,38,-725,-248, - -250,-251,102,103,-253,102,103,20,21,214, - 102,103,20,21,-255,-256,-264,58,-579,-265, - -271,-277,-282,64,65,66,67,68,69,70, - 71,72,-588,43,75,76,77,78,79,80, + 60,22,23,24,25,26,27,-701,-247,-248, + -250,-251,-253,59,60,159,37,38,102,103, + 209,-708,166,-714,102,103,-255,20,21,102, + 103,102,103,-256,-264,126,-724,58,129,-514, + 102,103,-265,64,65,66,67,68,69,70, + 71,72,-579,242,75,76,77,78,79,80, 81,82,83,84,85,86,87,88,89,90, - 91,92,93,94,95,96,97,-500,1,2, + 91,92,93,94,95,96,97,-501,1,2, 3,4,5,6,7,8,9,10,11,12, - 13,14,15,16,17,18,19,59,60,22, - 23,24,25,26,27,-283,-285,-290,-293,-294, - -295,59,60,-296,37,38,-300,-301,-302,-303, - 102,103,-310,-313,-314,-316,-317,-318,-319,-320, - -321,-322,-323,-324,-325,58,-602,-327,-328,-334, - -337,64,65,66,67,68,69,70,71,72, - -608,-340,75,76,77,78,79,80,81,82, + 13,14,15,16,17,18,19,-720,59,22, + 23,24,25,26,27,-271,-277,-721,-282,-283, + -285,59,60,-290,37,38,-293,20,21,-294, + -295,-296,-300,102,103,102,103,20,21,-301, + -302,-303,-310,-313,-314,58,-588,-316,102,103, + -317,64,65,66,67,68,69,70,71,72, + -602,-318,75,76,77,78,79,80,81,82, 83,84,85,86,87,88,89,90,91,92, - 93,94,95,96,97,-501,1,2,3,4, + 93,94,95,96,97,-502,1,2,3,4, 5,6,7,8,9,10,11,12,13,14, 15,16,17,18,19,59,60,22,23,24, - 25,26,27,-348,-349,-350,-351,-354,-358,59, - 60,-359,37,38,-364,-365,-366,-367,-368,-371, - -380,-381,-382,-383,-384,-385,-387,-388,-391,-396, - -397,-398,-401,58,-616,-408,-409,-410,-411,64, - 65,66,67,68,69,70,71,72,-620,-413, + 25,26,27,-319,-320,-321,-322,-323,-324,59, + 60,-325,37,38,-327,-328,-334,-337,-340,-348, + -349,-350,-351,-354,-358,-359,-364,-365,-366,-367, + -368,-371,-380,58,-608,-381,-382,-383,-384,64, + 65,66,67,68,69,70,71,72,-616,-385, 75,76,77,78,79,80,81,82,83,84, 85,86,87,88,89,90,91,92,93,94, - 95,96,97,-539,1,2,3,4,5,6, + 95,96,97,-540,1,2,3,4,5,6, 7,8,9,10,11,12,13,14,15,16, 17,18,19,59,60,22,23,24,25,26, - 27,-414,-416,-417,-420,-422,-424,59,60,-426, - 37,38,-427,-428,-429,-430,-431,-433,-434,-436, - -438,-439,-441,-442,-446,-448,-453,-461,-463,-466, - -467,58,-623,-469,-470,-471,-472,64,65,66, - 67,68,69,70,71,72,-629,-473,75,76, + 27,-387,-388,-391,-396,-397,-398,59,60,-401, + 37,38,-408,-409,-410,-411,-413,-414,-416,-417, + -420,-422,-424,-426,-427,-428,-429,-430,-431,-433, + -434,58,-620,-436,-438,-439,-441,64,65,66, + 67,68,69,70,71,72,-623,-442,75,76, 77,78,79,80,81,82,83,84,85,86, 87,88,89,90,91,92,93,94,95,96, 97,-583,1,2,3,4,5,6,7,8, 9,10,11,12,13,14,15,16,17,18, - 19,59,60,22,23,24,25,26,27,-474, - -475,-476,-477,-478,-483,59,60,-484,37,38, - -490,-506,-509,-510,-512,-514,-516,-517,-526,-528, - -534,-535,-536,-538,-540,-541,-542,-545,-547,58, - -456,-548,-637,-549,-550,64,65,66,67,68, - 69,70,71,72,-647,-556,75,76,77,78, + 19,59,60,22,23,24,25,26,27,-446, + -448,-453,-462,-464,-467,59,60,-468,37,38, + -470,-471,-472,-473,-474,-475,-476,-477,-478,-479, + -484,-485,-491,-507,-510,-511,-513,-515,-517,58, + -629,-518,-523,-527,-529,64,65,66,67,68, + 69,70,71,72,-646,-535,75,76,77,78, 79,80,81,82,83,84,85,86,87,88, 89,90,91,92,93,94,95,96,97,-590, 1,2,3,4,5,6,7,8,9,10, 11,12,13,14,15,16,17,18,19,59, - 58,22,23,24,25,26,27,-557,-559,-560, - -561,-562,-563,59,60,-564,37,38,-567,-570, - -572,-573,-580,-585,-587,-589,-592,-594,-598,-600, - -601,-604,-612,-618,-619,-621,-622,58,-649,-624, - -626,-627,-630,64,65,66,67,68,69,70, - 71,72,110,-651,75,76,77,78,79,80, + 60,22,23,24,25,26,27,-536,-537,-539, + -541,-542,-543,59,60,-546,37,38,-548,-549, + -550,-551,-557,-558,-560,-561,-562,-563,-564,-565, + -570,-572,-573,-580,-585,-587,-589,58,-648,-592, + -594,-598,-600,64,65,66,67,68,69,70, + 71,72,-650,-601,75,76,77,78,79,80, 81,82,83,84,85,86,87,88,89,90, 91,92,93,94,95,96,97,-615,1,2, 3,4,5,6,7,8,9,10,11,12, 13,14,15,16,17,18,19,59,60,22, - 23,24,25,26,27,-632,-633,-640,-643,-646, - -648,-654,59,60,37,38,-658,-661,-663,-668, - -673,-678,-691,-699,-711,-713,-714,-726,-727,-728, - -729,-731,-734,-735,-736,58,-653,-737,-738,0, - 0,64,65,66,67,68,69,70,71,72, - -655,0,75,76,77,78,79,80,81,82, + 23,24,25,26,27,-604,-612,-618,-619,-621, + -622,59,60,-624,37,38,-626,-627,-630,-632, + -633,-639,-642,-645,-647,-653,-657,-660,-662,-667, + -672,-677,-690,-698,-710,58,-652,-712,-713,-725, + -726,64,65,66,67,68,69,70,71,72, + -654,-727,75,76,77,78,79,80,81,82, 83,84,85,86,87,88,89,90,91,92, 93,94,95,96,97,-617,1,2,3,4, 5,6,7,8,9,10,11,12,13,14, 15,16,17,18,19,59,60,22,23,24, - 25,26,27,0,0,0,0,0,0,59, - 60,0,37,38,0,0,0,0,0,0, + 25,26,27,-728,-730,-733,-734,-735,-736,59, + 60,-737,37,38,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0, - 0,0,0,58,0,0,0,0,0,64, - 65,66,67,68,69,70,71,72,-513,0, + 0,0,0,58,-559,0,0,0,0,64, + 65,66,67,68,69,70,71,72,0,0, 75,76,77,78,79,80,81,82,83,84, 85,86,87,88,89,90,91,92,93,94, - 95,96,97,-645,1,2,3,4,5,6, + 95,96,97,-644,1,2,3,4,5,6, 7,8,9,10,11,12,13,14,15,16, - 17,18,19,-404,-261,22,23,24,25,26, - 27,-405,-262,-263,-406,-468,0,59,3,0, - 37,38,0,-480,0,0,0,0,0,0, + 17,18,19,59,-259,22,23,24,25,26, + 27,-346,-261,-262,-263,-481,-469,0,-482,3, + 37,38,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,-1,0,0, 3,58,0,0,0,0,0,64,65,66, 67,68,69,70,71,72,19,0,75,76, @@ -569,10 +569,10 @@ 29,30,31,32,33,34,35,36,37,38, 39,40,41,42,43,44,45,46,47,48, 49,50,51,52,53,54,55,56,57,0, - 0,0,138,0,0,0,109,143,0,0, - 138,138,137,130,73,143,143,0,0,0, - 0,0,159,0,161,0,0,0,0,0, - 159,0,161,159,0,161,153,0,0,98, + 0,130,138,0,0,130,109,143,130,0, + 138,138,138,137,73,143,143,143,0,0, + 0,0,0,0,153,0,0,0,153,0, + 0,153,0,0,0,0,0,0,0,98, -44,1,2,3,4,5,6,7,8,9, 10,11,12,13,14,15,16,17,18,19, 20,21,22,23,24,25,26,27,28,29, @@ -621,7 +621,7 @@ 54,55,56,57,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,73, 0,0,0,0,0,0,0,0,0,0, - 0,-481,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0, 0,0,0,0,98,-160,1,2,3,4, 5,6,7,8,9,10,11,12,13,14, 15,16,17,18,19,20,21,22,23,24, @@ -634,15 +634,15 @@ 27,28,29,30,31,32,33,34,35,36, 37,38,39,40,41,42,43,44,45,46, 47,48,49,50,51,52,53,54,55,56, - 57,130,0,0,0,0,0,0,0,0, + 57,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,73,0,0,0, - -657,0,0,0,153,0,-558,0,-660,0, - -671,0,-682,0,-693,0,0,0,0,0, + -656,0,0,0,0,0,0,0,-659,0, + -670,0,-681,0,-692,0,0,0,0,0, 155,98,-156,1,2,3,4,5,6,7, 8,9,10,11,12,13,14,15,16,17, 18,19,20,21,22,23,24,25,26,27, 28,29,30,31,32,33,34,35,36,59, - 60,39,40,41,42,59,44,59,60,59, + 60,39,40,41,42,0,44,59,60,59, 60,59,60,59,60,0,211,-193,1,2, 3,4,5,6,7,8,9,10,11,12, 13,14,15,16,17,18,19,20,21,22, @@ -722,13 +722,13 @@ 0,0,0,0,0,0,0,0,0,0, 0,0,0,73,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,98,-492, + 0,0,0,0,0,0,0,0,98,-493, 1,2,3,4,5,6,7,8,9,10, 11,12,13,14,15,16,17,18,19,20, 21,22,23,24,25,26,27,28,29,30, 31,32,33,34,35,36,37,38,39,40, 41,42,43,44,45,46,47,48,49,50, - 51,52,53,54,55,56,57,-652,1,2, + 51,52,53,54,55,56,57,-651,1,2, 3,4,5,6,7,8,9,10,11,12, 13,14,15,16,17,18,19,20,21,22, 23,24,25,26,27,28,29,30,31,32, @@ -739,37 +739,17 @@ 14,15,16,17,18,19,20,21,22,23, 24,25,26,27,28,29,30,31,32,33, 34,35,36,0,0,39,40,41,42,0, - 0,0,163,-720,1,2,3,4,5,6, - 7,8,9,10,11,12,13,14,15,16, - 17,18,19,20,21,22,23,24,25,26, - 27,28,29,30,31,32,33,34,35,36, - 37,38,39,40,41,42,43,44,45,46, - 47,48,49,50,51,52,53,54,55,56, - 57,0,0,0,167,0,0,0,229,0, - 0,0,0,0,0,0,73,0,0,0, - 0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0, - 0,98,-723,1,2,3,4,5,6,7, - 8,9,10,11,12,13,14,15,16,17, - 18,19,20,21,22,23,24,25,26,27, - 28,29,30,31,32,33,34,35,36,37, - 38,39,40,41,42,43,44,45,46,47, - 48,49,50,51,52,53,54,55,56,57, - 0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,73,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0, - 98,-732,1,2,3,4,5,6,7,8, + 161,-719,1,2,3,4,5,6,7,8, 9,10,11,12,13,14,15,16,17,18, 19,20,21,22,23,24,25,26,27,28, 29,30,31,32,33,34,35,36,37,38, 39,40,41,42,43,44,45,46,47,48, 49,50,51,52,53,54,55,56,57,0, - 0,0,0,0,0,0,0,0,0,0, + 0,0,165,0,0,0,0,0,229,0, 0,0,0,0,73,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,98, - -733,1,2,3,4,5,6,7,8,9, + -722,1,2,3,4,5,6,7,8,9, 10,11,12,13,14,15,16,17,18,19, 20,21,22,23,24,25,26,27,28,29, 30,31,32,33,34,35,36,37,38,39, @@ -778,7 +758,7 @@ 0,0,0,0,0,0,0,0,0,0, 0,0,0,73,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,98,-132, + 0,0,0,0,0,0,0,0,98,-731, 1,2,3,4,5,6,7,8,9,10, 11,12,13,14,15,16,17,18,19,20, 21,22,23,24,25,26,27,28,29,30, @@ -786,658 +766,678 @@ 41,42,43,44,45,46,47,48,49,50, 51,52,53,54,55,56,57,0,0,0, 0,0,0,0,0,0,0,0,0,0, - 0,0,73,-133,1,2,3,4,5,6, - 7,8,9,10,11,12,13,14,15,16, - 17,18,19,20,21,22,23,24,25,26, - 27,28,29,30,31,32,33,34,35,36, - 37,38,39,40,41,42,43,44,45,46, - 47,48,49,50,51,52,53,54,55,56, - 57,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,73,-178,1,2, + 0,0,73,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,98,-732,1, + 2,3,4,5,6,7,8,9,10,11, + 12,13,14,15,16,17,18,19,20,21, + 22,23,24,25,26,27,28,29,30,31, + 32,33,34,35,36,37,38,39,40,41, + 42,43,44,45,46,47,48,49,50,51, + 52,53,54,55,56,57,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0, + 0,73,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,98,-132,1,2, 3,4,5,6,7,8,9,10,11,12, 13,14,15,16,17,18,19,20,21,22, 23,24,25,26,27,28,29,30,31,32, 33,34,35,36,37,38,39,40,41,42, 43,44,45,46,47,48,49,50,51,52, - 53,54,55,56,57,-239,1,2,3,4, + 53,54,55,56,57,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0, + 73,-133,1,2,3,4,5,6,7,8, + 9,10,11,12,13,14,15,16,17,18, + 19,20,21,22,23,24,25,26,27,28, + 29,30,31,32,33,34,35,36,37,38, + 39,40,41,42,43,44,45,46,47,48, + 49,50,51,52,53,54,55,56,57,0, + 0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,73,-178,1,2,3,4, 5,6,7,8,9,10,11,12,13,14, 15,16,17,18,19,20,21,22,23,24, 25,26,27,28,29,30,31,32,33,34, 35,36,37,38,39,40,41,42,43,44, 45,46,47,48,49,50,51,52,53,54, - 55,56,57,-140,1,2,3,4,5,6, + 55,56,57,-239,1,2,3,4,5,6, 7,8,9,10,11,12,13,14,15,16, - 17,18,19,0,0,22,23,24,25,26, - 27,0,0,0,0,0,33,34,35,36, - 0,0,155,-280,1,2,3,4,5,6, - 7,8,9,10,11,12,13,14,15,16, 17,18,19,20,21,22,23,24,25,26, 27,28,29,30,31,32,33,34,35,36, 37,38,39,40,41,42,43,44,45,46, 47,48,49,50,51,52,53,54,55,56, - 57,0,157,-287,1,2,3,4,5,6, - 7,8,9,10,11,12,13,14,15,16, - 17,18,19,20,21,22,23,24,25,26, - 27,28,29,30,31,32,33,34,35,36, - 37,38,39,40,41,42,43,44,45,46, - 47,48,49,50,51,52,53,54,55,56, - 57,-141,1,2,3,4,5,6,7,8, + 57,-140,1,2,3,4,5,6,7,8, 9,10,11,12,13,14,15,16,17,18, 19,0,0,22,23,24,25,26,27,0, 0,0,0,0,33,34,35,36,0,0, - 157,-306,1,2,3,4,5,6,7,8, + 155,-280,1,2,3,4,5,6,7,8, 9,10,11,12,13,14,15,16,17,18, 19,20,21,22,23,24,25,26,27,28, 29,30,31,32,33,34,35,36,37,38, 39,40,41,42,43,44,45,46,47,48, 49,50,51,52,53,54,55,56,57,0, - 0,0,0,0,0,0,0,0,0,0, - 167,-360,1,2,3,4,5,6,7,8, + 157,-287,1,2,3,4,5,6,7,8, 9,10,11,12,13,14,15,16,17,18, 19,20,21,22,23,24,25,26,27,28, 29,30,31,32,33,34,35,36,37,38, 39,40,41,42,43,44,45,46,47,48, - 49,50,51,52,53,54,55,56,57,-332, + 49,50,51,52,53,54,55,56,57,-141, 1,2,3,4,5,6,7,8,9,10, - 11,12,13,14,15,16,17,18,19,20, - 21,22,23,24,25,26,27,28,29,30, - 31,32,33,34,35,36,0,0,39,40, - 41,42,43,44,45,46,47,48,49,50, - 51,52,53,54,183,-148,1,2,3,4, - 5,6,7,8,9,10,11,12,13,14, - 15,16,17,18,19,20,21,22,23,24, - 25,26,27,28,29,30,31,32,33,34, - 35,36,0,0,39,40,41,42,157,-375, + 11,12,13,14,15,16,17,18,19,0, + 0,22,23,24,25,26,27,0,0,0, + 0,0,33,34,35,36,0,0,157,-306, 1,2,3,4,5,6,7,8,9,10, 11,12,13,14,15,16,17,18,19,20, 21,22,23,24,25,26,27,28,29,30, 31,32,33,34,35,36,37,38,39,40, 41,42,43,44,45,46,47,48,49,50, - 51,52,53,54,55,56,57,-495,1,2, + 51,52,53,54,55,56,57,0,0,0, + 0,0,0,0,0,0,165,-360,1,2, 3,4,5,6,7,8,9,10,11,12, 13,14,15,16,17,18,19,20,21,22, 23,24,25,26,27,28,29,30,31,32, 33,34,35,36,37,38,39,40,41,42, 43,44,45,46,47,48,49,50,51,52, - 53,54,55,56,57,-151,1,2,3,4, + 53,54,55,56,57,-332,1,2,3,4, 5,6,7,8,9,10,11,12,13,14, - 15,16,17,18,19,0,0,22,23,24, - 25,26,27,0,0,0,0,0,33,34, - 35,36,0,0,39,40,0,0,0,0, - 0,0,163,-515,1,2,3,4,5,6, + 15,16,17,18,19,20,21,22,23,24, + 25,26,27,28,29,30,31,32,33,34, + 35,36,0,0,39,40,41,42,43,44, + 45,46,47,48,49,50,51,52,53,54, + 0,0,183,-151,1,2,3,4,5,6, 7,8,9,10,11,12,13,14,15,16, + 17,18,19,0,0,22,23,24,25,26, + 27,0,0,0,0,0,33,34,35,36, + 0,0,39,40,157,-375,1,2,3,4, + 5,6,7,8,9,10,11,12,13,14, + 15,16,17,18,19,20,21,22,23,24, + 25,26,27,28,29,30,31,32,33,34, + 35,36,37,38,39,40,41,42,43,44, + 45,46,47,48,49,50,51,52,53,54, + 55,56,57,-496,1,2,3,4,5,6, + 7,8,9,10,11,12,13,14,15,16, 17,18,19,20,21,22,23,24,25,26, 27,28,29,30,31,32,33,34,35,36, 37,38,39,40,41,42,43,44,45,46, 47,48,49,50,51,52,53,54,55,56, - 57,0,0,-696,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0, - 183,-152,1,2,3,4,5,6,7,8, + 57,-148,1,2,3,4,5,6,7,8, 9,10,11,12,13,14,15,16,17,18, - 19,0,0,22,23,24,25,26,27,0, - 0,0,0,0,33,34,35,36,0,0, - 39,40,59,60,0,122,-555,1,2,3, - 4,5,6,7,8,9,10,11,12,13, - 14,15,16,17,18,19,20,21,22,23, - 24,25,26,27,28,29,30,31,32,33, - 34,35,36,37,38,39,40,41,42,43, - 44,45,46,47,48,49,50,51,52,53, - 54,55,56,57,-582,1,2,3,4,5, - 6,7,8,9,10,11,12,13,14,15, - 16,17,18,19,20,21,22,23,24,25, - 26,27,28,29,30,31,32,33,34,35, - 36,37,38,39,40,41,42,43,44,45, - 46,47,48,49,50,51,52,53,54,55, - 56,57,0,0,0,0,0,0,122,-595, - 1,2,3,4,5,6,7,8,9,10, - 11,12,13,14,15,16,17,18,19,20, - 21,22,23,24,25,26,27,28,29,30, - 31,32,33,34,35,36,37,38,39,40, - 41,42,43,44,45,46,47,48,49,50, - 51,52,53,54,55,56,57,-139,1,2, + 19,20,21,22,23,24,25,26,27,28, + 29,30,31,32,33,34,35,36,0,0, + 39,40,41,42,0,0,161,-516,1,2, 3,4,5,6,7,8,9,10,11,12, - 13,14,15,16,17,18,19,0,0,22, - 23,24,25,26,27,0,0,0,0,0, - 33,34,35,36,0,0,39,163,0,-603, - 1,2,3,4,5,6,7,8,9,10, - 11,12,13,14,15,16,17,18,19,20, - 21,22,23,24,25,26,27,28,29,30, - 31,32,33,34,35,36,37,38,39,40, - 41,42,43,44,45,46,47,48,49,50, - 51,52,53,54,55,56,57,-607,1,2, - 3,4,5,6,7,8,9,10,11,12, 13,14,15,16,17,18,19,20,21,22, 23,24,25,26,27,28,29,30,31,32, 33,34,35,36,37,38,39,40,41,42, 43,44,45,46,47,48,49,50,51,52, - 53,54,55,56,57,-698,0,-704,0,0, - 221,122,-153,1,2,3,4,5,6,7, - 8,9,10,11,12,13,14,15,16,17, - 18,19,0,0,22,23,24,25,26,27, - 0,0,0,0,0,33,34,35,36,0, - 0,39,40,0,0,0,0,0,0,0, - 0,0,0,0,59,60,59,60,0,122, - -631,1,2,3,4,5,6,7,8,9, + 53,54,55,56,57,-152,1,2,3,4, + 5,6,7,8,9,10,11,12,13,14, + 15,16,17,18,19,0,183,22,23,24, + 25,26,27,0,0,0,0,0,33,34, + 35,36,0,0,39,40,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,122, + -556,1,2,3,4,5,6,7,8,9, 10,11,12,13,14,15,16,17,18,19, 20,21,22,23,24,25,26,27,28,29, 30,31,32,33,34,35,36,37,38,39, 40,41,42,43,44,45,46,47,48,49, - 50,51,52,53,54,55,56,57,-634,1, + 50,51,52,53,54,55,56,57,-582,1, 2,3,4,5,6,7,8,9,10,11, 12,13,14,15,16,17,18,19,20,21, 22,23,24,25,26,27,28,29,30,31, 32,33,34,35,36,37,38,39,40,41, 42,43,44,45,46,47,48,49,50,51, - 52,53,54,55,56,57,-719,0,0,0, - 0,0,122,-154,1,2,3,4,5,6, + 52,53,54,55,56,57,0,0,0,0, + 0,0,122,-595,1,2,3,4,5,6, 7,8,9,10,11,12,13,14,15,16, - 17,18,19,0,0,22,23,24,25,26, - 27,0,0,0,0,0,33,34,35,36, - 0,0,39,40,0,0,0,0,0,0, - 0,0,0,0,0,59,60,0,0,0, - 122,-650,1,2,3,4,5,6,7,8, - 9,10,11,12,13,14,15,16,17,18, - 19,20,21,22,23,24,25,26,27,28, - 29,30,31,32,33,34,35,36,37,38, - 39,40,41,42,43,44,45,46,47,48, - 49,50,51,52,53,54,55,56,57,-676, - 1,2,3,4,5,6,7,8,9,10, - 11,12,13,14,15,16,17,18,19,20, - 21,22,23,24,25,26,27,28,29,30, - 31,32,33,34,35,36,37,38,39,40, - 41,42,43,44,45,46,47,48,49,50, - 51,52,53,54,55,56,57,0,0,0, - 0,0,0,122,-20,1,2,3,4,5, - 6,7,8,9,10,11,12,13,14,15, - 16,17,18,19,20,21,22,23,24,25, - 26,27,28,29,30,31,32,33,34,35, - 36,37,38,39,40,41,42,43,44,45, - 46,47,48,49,50,51,52,53,54,55, - 56,57,-149,1,2,3,4,5,6,7, - 8,9,10,11,12,13,14,15,16,17, - 18,19,0,0,22,23,24,25,26,27, - 0,0,0,0,0,33,34,35,36,0, - 0,39,0,0,0,0,167,-119,1,2, - 3,4,5,6,7,8,9,10,11,12, - 13,14,15,16,17,18,19,20,21,22, - 23,24,25,26,27,28,29,30,31,32, - 33,34,35,36,37,38,39,40,41,42, - 43,44,45,46,47,48,49,50,51,52, - 53,54,55,56,57,-122,1,2,3,4, - 5,6,7,8,9,10,11,12,13,14, - 15,16,17,18,19,20,21,22,23,24, - 25,26,27,28,29,30,31,32,33,34, - 35,36,37,38,39,40,41,42,43,44, - 45,46,47,48,49,50,51,52,53,54, - 55,56,57,-124,1,2,3,4,5,6, - 7,8,9,10,11,12,13,14,15,16, 17,18,19,20,21,22,23,24,25,26, 27,28,29,30,31,32,33,34,35,36, 37,38,39,40,41,42,43,44,45,46, 47,48,49,50,51,52,53,54,55,56, - 57,-179,1,2,3,4,5,6,7,8, + 57,-142,1,2,3,4,5,6,7,8, 9,10,11,12,13,14,15,16,17,18, - 19,20,21,22,23,24,25,26,27,28, - 29,30,31,32,33,34,35,36,37,38, - 39,40,41,42,43,44,45,46,47,48, - 49,50,51,52,53,54,55,56,57,-182, - 1,2,3,4,5,6,7,8,9,10, - 11,12,13,14,15,16,17,18,19,20, - 21,22,23,24,25,26,27,28,29,30, - 31,32,33,34,35,36,37,38,39,40, - 41,42,43,44,45,46,47,48,49,50, - 51,52,53,54,55,56,57,-186,1,2, - 3,4,5,6,7,8,9,10,11,12, - 13,14,15,16,17,18,19,20,21,22, - 23,24,25,26,27,28,29,30,31,32, - 33,34,35,36,37,38,39,40,41,42, - 43,44,45,46,47,48,49,50,51,52, - 53,54,55,56,57,-289,1,2,3,4, - 5 - }; - }; - - public interface BaseCheck1 { - public final static short baseCheck1[] = { - 6,7,8,9,10,11,12,13,14,15, - 16,17,18,19,20,21,22,23,24,25, - 26,27,28,29,30,31,32,33,34,35, - 36,37,38,39,40,41,42,43,44,45, - 46,47,48,49,50,51,52,53,54,55, - 56,57,-305,1,2,3,4,5,6,7, - 8,9,10,11,12,13,14,15,16,17, - 18,19,20,21,22,23,24,25,26,27, - 28,29,30,31,32,33,34,35,36,37, - 38,39,40,41,42,43,44,45,46,47, - 48,49,50,51,52,53,54,55,56,57, - -311,1,2,3,4,5,6,7,8,9, + 19,0,0,22,23,24,25,26,27,0, + 0,0,0,0,33,34,35,36,0,161, + -603,1,2,3,4,5,6,7,8,9, 10,11,12,13,14,15,16,17,18,19, 20,21,22,23,24,25,26,27,28,29, 30,31,32,33,34,35,36,37,38,39, 40,41,42,43,44,45,46,47,48,49, - 50,51,52,53,54,55,56,57,-355,1, + 50,51,52,53,54,55,56,57,-607,1, 2,3,4,5,6,7,8,9,10,11, 12,13,14,15,16,17,18,19,20,21, 22,23,24,25,26,27,28,29,30,31, 32,33,34,35,36,37,38,39,40,41, 42,43,44,45,46,47,48,49,50,51, - 52,53,54,55,56,57,-356,1,2,3, - 4,5,6,7,8,9,10,11,12,13, - 14,15,16,17,18,19,20,21,22,23, - 24,25,26,27,28,29,30,31,32,33, - 34,35,36,37,38,39,40,41,42,43, - 44,45,46,47,48,49,50,51,52,53, - 54,55,56,57,-361,1,2,3,4,5, + 52,53,54,55,56,57,-695,0,-697,0, + 0,0,122,0,221,-153,1,2,3,4, + 5,6,7,8,9,10,11,12,13,14, + 15,16,17,18,19,0,0,22,23,24, + 25,26,27,0,0,0,0,0,33,34, + 35,36,0,0,39,40,0,0,0,0, + 0,0,0,0,0,59,60,59,60,0, + 122,-631,1,2,3,4,5,6,7,8, + 9,10,11,12,13,14,15,16,17,18, + 19,20,21,22,23,24,25,26,27,28, + 29,30,31,32,33,34,35,36,37,38, + 39,40,41,42,43,44,45,46,47,48, + 49,50,51,52,53,54,55,56,57,-634, + 1,2,3,4,5,6,7,8,9,10, + 11,12,13,14,15,16,17,18,19,20, + 21,22,23,24,25,26,27,28,29,30, + 31,32,33,34,35,36,37,38,39,40, + 41,42,43,44,45,46,47,48,49,50, + 51,52,53,54,55,56,57,-703,0,-718, + 0,0,0,122,-154,1,2,3,4,5, 6,7,8,9,10,11,12,13,14,15, - 16,17,18,19,20,21,22,23,24,25, - 26,27,28,29,30,31,32,33,34,35, - 36,37,38,39,40,41,42,43,44,45, - 46,47,48,49,50,51,52,53,54,55, - 56,57,-372,1,2,3,4,5,6,7, + 16,17,18,19,0,0,22,23,24,25, + 26,27,0,0,0,0,0,33,34,35, + 36,0,0,39,40,0,0,0,0,0, + 0,0,0,0,0,0,59,60,59,60, + 0,122,-649,1,2,3,4,5,6,7, 8,9,10,11,12,13,14,15,16,17, 18,19,20,21,22,23,24,25,26,27, 28,29,30,31,32,33,34,35,36,37, 38,39,40,41,42,43,44,45,46,47, 48,49,50,51,52,53,54,55,56,57, - -377,1,2,3,4,5,6,7,8,9, + -675,1,2,3,4,5,6,7,8,9, 10,11,12,13,14,15,16,17,18,19, 20,21,22,23,24,25,26,27,28,29, 30,31,32,33,34,35,36,37,38,39, 40,41,42,43,44,45,46,47,48,49, - 50,51,52,53,54,55,56,57,-378,1, - 2,3,4,5,6,7,8,9,10,11, - 12,13,14,15,16,17,18,19,20,21, - 22,23,24,25,26,27,28,29,30,31, - 32,33,34,35,36,37,38,39,40,41, - 42,43,44,45,46,47,48,49,50,51, - 52,53,54,55,56,57,-386,1,2,3, + 50,51,52,53,54,55,56,57,0,0, + 0,0,0,0,122,-20,1,2,3,4, + 5,6,7,8,9,10,11,12,13,14, + 15,16,17,18,19,20,21,22,23,24, + 25,26,27,28,29,30,31,32,33,34, + 35,36,37,38,39,40,41,42,43,44, + 45,46,47,48,49,50,51,52,53,54, + 55,56,57,-139,1,2,3,4,5,6, + 7,8,9,10,11,12,13,14,15,16, + 17,18,19,0,0,22,23,24,25,26, + 27,0,0,0,0,0,33,34,35,36, + 0,0,39,0,0,165,-119,1,2,3, 4,5,6,7,8,9,10,11,12,13, 14,15,16,17,18,19,20,21,22,23, 24,25,26,27,28,29,30,31,32,33, 34,35,36,37,38,39,40,41,42,43, 44,45,46,47,48,49,50,51,52,53, - 54,55,56,57,-423,1,2,3,4,5, + 54,55,56,57,-122,1,2,3,4,5, 6,7,8,9,10,11,12,13,14,15, 16,17,18,19,20,21,22,23,24,25, 26,27,28,29,30,31,32,33,34,35, 36,37,38,39,40,41,42,43,44,45, 46,47,48,49,50,51,52,53,54,55, - 56,57,-440,1,2,3,4,5,6,7, + 56,57,-124,1,2,3,4,5,6,7, 8,9,10,11,12,13,14,15,16,17, 18,19,20,21,22,23,24,25,26,27, 28,29,30,31,32,33,34,35,36,37, 38,39,40,41,42,43,44,45,46,47, 48,49,50,51,52,53,54,55,56,57, - -485,1,2,3,4,5,6,7,8,9, + -179,1,2,3,4,5,6,7,8,9, 10,11,12,13,14,15,16,17,18,19, 20,21,22,23,24,25,26,27,28,29, 30,31,32,33,34,35,36,37,38,39, 40,41,42,43,44,45,46,47,48,49, - 50,51,52,53,54,55,56,57,-489,1, + 50,51,52,53,54,55,56,57,-182,1, 2,3,4,5,6,7,8,9,10,11, 12,13,14,15,16,17,18,19,20,21, 22,23,24,25,26,27,28,29,30,31, 32,33,34,35,36,37,38,39,40,41, 42,43,44,45,46,47,48,49,50,51, - 52,53,54,55,56,57,-494,1,2,3, + 52,53,54,55,56,57,-186,1,2,3, 4,5,6,7,8,9,10,11,12,13, 14,15,16,17,18,19,20,21,22,23, 24,25,26,27,28,29,30,31,32,33, 34,35,36,37,38,39,40,41,42,43, 44,45,46,47,48,49,50,51,52,53, - 54,55,56,57,-504,1,2,3,4,5, + 54,55,56,57,-289,1,2,3,4,5, 6,7,8,9,10,11,12,13,14,15, - 16,17,18,19,20,21,22,23,24,25, - 26,27,28,29,30,31,32,33,34,35, - 36,37,38,39,40,41,42,43,44,45, - 46,47,48,49,50,51,52,53,54,55, - 56,57,-84,1,2,3,4,5,6,7, - 8,9,10,11,12,13,14,15,16,17, - 18,19,20,21,22,23,24,25,26,27, - 28,29,30,31,32,33,34,35,36,0, - 0,39,40,41,42,43,44,45,46,47, - 48,49,50,51,52,53,54,55,-142,1, - 2,3,4,5,6,7,8,9,10,11, - 12,13,14,15,16,17,18,19,0,0, - 22,23,24,25,26,27,0,0,0,0, - 0,33,34,35,36,0,0,0,0,0, + 16 + }; + }; + + public interface BaseCheck1 { + public final static short baseCheck1[] = { + 17,18,19,20,21,22,23,24,25,26, + 27,28,29,30,31,32,33,34,35,36, + 37,38,39,40,41,42,43,44,45,46, + 47,48,49,50,51,52,53,54,55,56, + 57,-305,1,2,3,4,5,6,7,8, + 9,10,11,12,13,14,15,16,17,18, + 19,20,21,22,23,24,25,26,27,28, + 29,30,31,32,33,34,35,36,37,38, + 39,40,41,42,43,44,45,46,47,48, + 49,50,51,52,53,54,55,56,57,-311, + 1,2,3,4,5,6,7,8,9,10, + 11,12,13,14,15,16,17,18,19,20, + 21,22,23,24,25,26,27,28,29,30, + 31,32,33,34,35,36,37,38,39,40, + 41,42,43,44,45,46,47,48,49,50, + 51,52,53,54,55,56,57,-355,1,2, + 3,4,5,6,7,8,9,10,11,12, + 13,14,15,16,17,18,19,20,21,22, + 23,24,25,26,27,28,29,30,31,32, + 33,34,35,36,37,38,39,40,41,42, + 43,44,45,46,47,48,49,50,51,52, + 53,54,55,56,57,-356,1,2,3,4, + 5,6,7,8,9,10,11,12,13,14, + 15,16,17,18,19,20,21,22,23,24, + 25,26,27,28,29,30,31,32,33,34, + 35,36,37,38,39,40,41,42,43,44, + 45,46,47,48,49,50,51,52,53,54, + 55,56,57,-361,1,2,3,4,5,6, + 7,8,9,10,11,12,13,14,15,16, + 17,18,19,20,21,22,23,24,25,26, + 27,28,29,30,31,32,33,34,35,36, + 37,38,39,40,41,42,43,44,45,46, + 47,48,49,50,51,52,53,54,55,56, + 57,-372,1,2,3,4,5,6,7,8, + 9,10,11,12,13,14,15,16,17,18, + 19,20,21,... [truncated message content] |
From: <bti...@us...> - 2009-10-12 14:34:44
|
Revision: 11420 http://x10.svn.sourceforge.net/x10/?rev=11420&view=rev Author: btibbitts Date: 2009-10-12 14:34:28 +0000 (Mon, 12 Oct 2009) Log Message: ----------- bump versions to 2.0 Modified Paths: -------------- trunk/x10.common/META-INF/MANIFEST.MF trunk/x10.compiler/META-INF/MANIFEST.MF trunk/x10.constraints/META-INF/MANIFEST.MF Modified: trunk/x10.common/META-INF/MANIFEST.MF =================================================================== --- trunk/x10.common/META-INF/MANIFEST.MF 2009-10-12 14:11:17 UTC (rev 11419) +++ trunk/x10.common/META-INF/MANIFEST.MF 2009-10-12 14:34:28 UTC (rev 11420) @@ -2,5 +2,5 @@ Bundle-ManifestVersion: 2 Bundle-Name: Common Bundle-SymbolicName: x10.common -Bundle-Version: 1.7.5.0 +Bundle-Version: 2.0.0 Export-Package: x10.config Modified: trunk/x10.compiler/META-INF/MANIFEST.MF =================================================================== --- trunk/x10.compiler/META-INF/MANIFEST.MF 2009-10-12 14:11:17 UTC (rev 11419) +++ trunk/x10.compiler/META-INF/MANIFEST.MF 2009-10-12 14:34:28 UTC (rev 11420) @@ -2,12 +2,12 @@ Bundle-ManifestVersion: 2 Bundle-Name: X10 compiler Bundle-SymbolicName: x10.compiler -Bundle-Version: 1.7.5.0 +Bundle-Version: 2.0.0 Bundle-Localization: plugin Require-Bundle: x10.common, x10.constraints, - lpg.runtime, - polyglot3 + polyglot3, + lpg.runtime;bundle-version="2.0.17" Export-Package: x10, x10.ast, x10.emitter, Modified: trunk/x10.constraints/META-INF/MANIFEST.MF =================================================================== --- trunk/x10.constraints/META-INF/MANIFEST.MF 2009-10-12 14:11:17 UTC (rev 11419) +++ trunk/x10.constraints/META-INF/MANIFEST.MF 2009-10-12 14:34:28 UTC (rev 11420) @@ -2,5 +2,5 @@ Bundle-ManifestVersion: 2 Bundle-Name: Constraints Bundle-SymbolicName: x10.constraints -Bundle-Version: 1.7.5.0 +Bundle-Version: 2.0.0 Export-Package: x10.constraint This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ipe...@us...> - 2009-10-12 21:53:30
|
Revision: 11432 http://x10.svn.sourceforge.net/x10/?rev=11432&view=rev Author: ipeshansky Date: 2009-10-12 21:53:24 +0000 (Mon, 12 Oct 2009) Log Message: ----------- Fix a codegen bug for generic structs. Restore x10.util.Pair to its pristine state. Modified Paths: -------------- trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java trunk/x10.runtime/src-x10/x10/util/Pair.x10 Modified: trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java =================================================================== --- trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java 2009-10-12 20:49:05 UTC (rev 11431) +++ trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java 2009-10-12 21:53:24 UTC (rev 11432) @@ -322,7 +322,7 @@ X10CPPContext_c context = (X10CPPContext_c) tr.context(); h.write("template <> class "); if (cd.isStruct()) { - h.write(Emitter.structMethodClass(cd.asType().toClass(), true, false)); + h.write(Emitter.structMethodClass(cd.asType().toClass(), false, false)); } else { h.write(mangled_non_method_name(cd.name().toString())); } Modified: trunk/x10.runtime/src-x10/x10/util/Pair.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/util/Pair.x10 2009-10-12 20:49:05 UTC (rev 11431) +++ trunk/x10.runtime/src-x10/x10/util/Pair.x10 2009-10-12 21:53:24 UTC (rev 11432) @@ -11,10 +11,6 @@ /** * This struct allows treating a pair of values as a single value, for example when returning from a method. */ -public struct Pair { -} - -/* public struct Pair[T,U] { public val first:T; public val second:U; @@ -28,4 +24,3 @@ return "(" + first + ", " + second + ")"; } } -*/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <spa...@us...> - 2009-10-14 02:04:29
|
Revision: 11457 http://x10.svn.sourceforge.net/x10/?rev=11457&view=rev Author: sparksparkspark Date: 2009-10-14 02:04:17 +0000 (Wed, 14 Oct 2009) Log Message: ----------- 1) Fix RTT codegen bug for structs with generics (by "fix" i mean "change things randomly until the error disappeared") 2) Make buffer finder closure in copyTo return rail and offset using Pair[Rail[T],Int] Modified Paths: -------------- trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java trunk/x10.runtime/src-x10/x10/lang/Rail.x10 trunk/x10.runtime/src-x10/x10/lang/System.x10 Modified: trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java =================================================================== --- trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java 2009-10-13 23:39:22 UTC (rev 11456) +++ trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java 2009-10-14 02:04:17 UTC (rev 11457) @@ -316,12 +316,15 @@ fd.init().type().isChar() || fd.init().type().isNull())); } - private void extractGenericStaticDecls(X10ClassDef cd, ClassifiedStream h) { + private void extractGenericStaticDecls(X10ClassDef cd, ClassifiedStream h) { + extractGenericStaticDecls(cd, h, true); + } + private void extractGenericStaticDecls(X10ClassDef cd, ClassifiedStream h, boolean struct_methods) { if (cd.typeParameters().size() == 0) return; X10CPPContext_c context = (X10CPPContext_c) tr.context(); h.write("template <> class "); - if (cd.isStruct()) { + if (struct_methods && cd.isStruct()) { h.write(Emitter.structMethodClass(cd.asType().toClass(), false, false)); } else { h.write(mangled_non_method_name(cd.name().toString())); @@ -337,57 +340,59 @@ h.write("{"); h.newline(4); h.begin(0); h.write("public:"); h.newline(); - if (!cd.isStruct()) { + if (!struct_methods || !cd.isStruct()) { h.write("static x10aux::RuntimeType rtt;"); h.newline(); h.write("static const x10aux::RuntimeType* getRTT() { return & rtt; }"); h.newline(); } // First process all classes - for (ClassMember dec : context.pendingStaticDecls()) { - if (dec instanceof ClassDecl_c) { - assert false : "nested class alert! "+cd.position(); - ClassDecl_c cdecl = (ClassDecl_c) dec; - ((X10CPPTranslator)tr).setContext(cdecl.enterScope(context)); // FIXME - X10ClassDef def = (X10ClassDef) cdecl.classDef(); - if (getCppRep(def) != null) { - // emit no c++ code as this is a native rep class - continue; - } - emitter.printTemplateSignature(((X10ClassType)def.asType()).typeArguments(), h); - h.write("class "); - h.write(Emitter.mangled_non_method_name(cdecl.name().id().toString())); - h.write(";"); - ((X10CPPTranslator)tr).setContext(context); // FIXME - h.newline(); - } - } - // Then process all fields and methods - for (ClassMember dec : context.pendingStaticDecls()) { - if (dec instanceof FieldDecl_c) { - FieldDecl_c fd = (FieldDecl_c) dec; - ((X10CPPTranslator)tr).setContext(fd.enterScope(context)); // FIXME - sw.pushCurrentStream(h); - emitter.printHeader(fd, h, tr, false); - sw.popCurrentStream(); - h.write(";"); - ((X10CPPTranslator)tr).setContext(context); // FIXME - } else if (dec instanceof MethodDecl_c) { - MethodDecl_c md = (MethodDecl_c) dec; - ((X10CPPTranslator)tr).setContext(md.enterScope(context)); // FIXME - sw.pushCurrentStream(h); - emitter.printHeader(md, sw, tr, false); - sw.popCurrentStream(); - h.write(";"); - ((X10CPPTranslator)tr).setContext(context); // FIXME - } - h.newline(); h.forceNewline(); - } - extractGenericStaticInits(cd); + if (struct_methods || !cd.isStruct()) { + for (ClassMember dec : context.pendingStaticDecls()) { + if (dec instanceof ClassDecl_c) { + assert false : "nested class alert! "+cd.position(); + ClassDecl_c cdecl = (ClassDecl_c) dec; + ((X10CPPTranslator)tr).setContext(cdecl.enterScope(context)); // FIXME + X10ClassDef def = (X10ClassDef) cdecl.classDef(); + if (getCppRep(def) != null) { + // emit no c++ code as this is a native rep class + continue; + } + emitter.printTemplateSignature(((X10ClassType)def.asType()).typeArguments(), h); + h.write("class "); + h.write(Emitter.mangled_non_method_name(cdecl.name().id().toString())); + h.write(";"); + ((X10CPPTranslator)tr).setContext(context); // FIXME + h.newline(); + } + } + // Then process all fields and methods + for (ClassMember dec : context.pendingStaticDecls()) { + if (dec instanceof FieldDecl_c) { + FieldDecl_c fd = (FieldDecl_c) dec; + ((X10CPPTranslator)tr).setContext(fd.enterScope(context)); // FIXME + sw.pushCurrentStream(h); + emitter.printHeader(fd, h, tr, false); + sw.popCurrentStream(); + h.write(";"); + ((X10CPPTranslator)tr).setContext(context); // FIXME + } else if (dec instanceof MethodDecl_c) { + MethodDecl_c md = (MethodDecl_c) dec; + ((X10CPPTranslator)tr).setContext(md.enterScope(context)); // FIXME + sw.pushCurrentStream(h); + emitter.printHeader(md, sw, tr, false); + sw.popCurrentStream(); + h.write(";"); + ((X10CPPTranslator)tr).setContext(context); // FIXME + } + h.newline(); h.forceNewline(); + } + } + extractGenericStaticInits(cd, struct_methods); h.end(); h.newline(); h.write("};"); h.newline(); } - private void extractGenericStaticInits(X10ClassDef cd) { + private void extractGenericStaticInits(X10ClassDef cd, boolean struct_methods) { // Always write non-template static decls into the implementation file ClassifiedStream save_w = sw.currentStream(); ClassifiedStream w = sw.getNewStream(StreamWrapper.CC, false); @@ -398,76 +403,78 @@ X10CPPContext_c context = (X10CPPContext_c) tr.context(); X10ClassType declClass = (X10ClassType)cd.asType().toClass(); - String declClassName = declClass.isX10Struct() ? Emitter.structMethodClass(declClass, true, false) : translate_mangled_FQN(cd.fullName().toString()); + String declClassName = (struct_methods && declClass.isX10Struct()) ? Emitter.structMethodClass(declClass, true, false) : translate_mangled_FQN(cd.fullName().toString()); String container = declClassName+voidTemplateInstantiation(cd.typeParameters().size()); - if (!cd.isStruct()) { + if (!struct_methods || !cd.isStruct()) { sw.write("x10aux::RuntimeType "+container+"::rtt;"); sw.newline(); } - for (ClassMember dec : context.pendingStaticDecls()) { - if (dec instanceof FieldDecl_c) { - FieldDecl_c fd = (FieldDecl_c) dec; - ((X10CPPTranslator)tr).setContext(fd.enterScope(context)); // FIXME - emitter.printType(fd.type().type(), sw); - sw.allowBreak(2, " "); - sw.write(container+"::"); - sw.write(mangled_field_name(fd.name().id().toString())); - // [DC] want these to occur in the static initialiser instead - // [IP] except for the ones that use a literal init - otherwise switch is broken - boolean globalInit = isGlobalInit(fd); - if (globalInit) { - sw.write(" ="); - sw.allowBreak(2, " "); - fd.print(fd.init(), sw, tr); - } - sw.write(";"); - sw.newline(); - if (!globalInit && fd.init() != null) { - generateStaticFieldInitializer(fd, container, sw); - } - generateStaticFieldSupportCode(fd, container, globalInit, sw); - ((X10CPPTranslator)tr).setContext(context); // FIXME - } else if (dec instanceof MethodDecl_c) { - MethodDecl_c md = (MethodDecl_c) dec; - X10MethodDef def = (X10MethodDef)md.methodDef(); - boolean templateMethod = def.typeParameters().size() != 0; - if (templateMethod) - sw.pushCurrentStream(save_w); - ((X10CPPTranslator)tr).setContext(md.enterScope(context)); // FIXME - if (query.isMainMethod(md)) - processMain((X10ClassType) cd.asType()); - emitter.printTemplateSignature(toTypeList(def.typeParameters()), sw); - emitter.printType(md.returnType().type(), sw); - sw.allowBreak(2, " "); - sw.write(container+"::"); - sw.write(mangled_method_name(md.name().id().toString()) + "("); - sw.begin(0); - boolean first = true; - for (Formal f : md.formals()) { - if (first) { - first = false; - } else { - sw.write(","); - sw.allowBreak(0, " "); - } - md.print(f, sw, tr); - } - sw.end(); - sw.write(")"); - if (md.body() != null) { - sw.allowBreak(0, " "); - md.printBlock(md.body(), sw, tr); - } - sw.newline(); - ((X10CPPTranslator)tr).setContext(context); // FIXME - if (templateMethod) - sw.popCurrentStream(); - } else if (dec instanceof Initializer_c) { - assert (false) : ("Static initializer alert!"); - } else if (dec instanceof X10ClassDecl_c) { - assert (false) : ("Nested class alert!"); - } - } + if (struct_methods || !cd.isStruct()) { + for (ClassMember dec : context.pendingStaticDecls()) { + if (dec instanceof FieldDecl_c) { + FieldDecl_c fd = (FieldDecl_c) dec; + ((X10CPPTranslator)tr).setContext(fd.enterScope(context)); // FIXME + emitter.printType(fd.type().type(), sw); + sw.allowBreak(2, " "); + sw.write(container+"::"); + sw.write(mangled_field_name(fd.name().id().toString())); + // [DC] want these to occur in the static initialiser instead + // [IP] except for the ones that use a literal init - otherwise switch is broken + boolean globalInit = isGlobalInit(fd); + if (globalInit) { + sw.write(" ="); + sw.allowBreak(2, " "); + fd.print(fd.init(), sw, tr); + } + sw.write(";"); + sw.newline(); + if (!globalInit && fd.init() != null) { + generateStaticFieldInitializer(fd, container, sw); + } + generateStaticFieldSupportCode(fd, container, globalInit, sw); + ((X10CPPTranslator)tr).setContext(context); // FIXME + } else if (dec instanceof MethodDecl_c) { + MethodDecl_c md = (MethodDecl_c) dec; + X10MethodDef def = (X10MethodDef)md.methodDef(); + boolean templateMethod = def.typeParameters().size() != 0; + if (templateMethod) + sw.pushCurrentStream(save_w); + ((X10CPPTranslator)tr).setContext(md.enterScope(context)); // FIXME + if (query.isMainMethod(md)) + processMain((X10ClassType) cd.asType()); + emitter.printTemplateSignature(toTypeList(def.typeParameters()), sw); + emitter.printType(md.returnType().type(), sw); + sw.allowBreak(2, " "); + sw.write(container+"::"); + sw.write(mangled_method_name(md.name().id().toString()) + "("); + sw.begin(0); + boolean first = true; + for (Formal f : md.formals()) { + if (first) { + first = false; + } else { + sw.write(","); + sw.allowBreak(0, " "); + } + md.print(f, sw, tr); + } + sw.end(); + sw.write(")"); + if (md.body() != null) { + sw.allowBreak(0, " "); + md.printBlock(md.body(), sw, tr); + } + sw.newline(); + ((X10CPPTranslator)tr).setContext(context); // FIXME + if (templateMethod) + sw.popCurrentStream(); + } else if (dec instanceof Initializer_c) { + assert (false) : ("Static initializer alert!"); + } else if (dec instanceof X10ClassDecl_c) { + assert (false) : ("Nested class alert!"); + } + } + } sw.forceNewline(); sw.popCurrentStream(); } @@ -855,6 +862,7 @@ sh.end(); sh.newline(0); sh.writeln("};"); + extractGenericStaticDecls(def, sh, false); } h.end(); h.newline(0); Modified: trunk/x10.runtime/src-x10/x10/lang/Rail.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Rail.x10 2009-10-13 23:39:22 UTC (rev 11456) +++ trunk/x10.runtime/src-x10/x10/lang/Rail.x10 2009-10-14 02:04:17 UTC (rev 11457) @@ -10,6 +10,7 @@ import x10.compiler.Native; import x10.compiler.NativeRep; +import x10.util.Pair; @NativeRep("java", "x10.core.Rail<#1>", "x10.core.Rail.BoxedRail", "new x10.core.Rail.RTT(#2)") @NativeRep("c++", "x10aux::ref<x10::lang::Rail<#1 > >", "x10::lang::Rail<#1 >", null) @@ -75,7 +76,7 @@ @Native("c++", "x10::lang::System::copyTo(#0,#1,#2,#3,#4)") //@Native("c++", "(#0)->copyTo(#1,#2,#3,#4)") public native def copyTo (src_off:Int, - dst_place:Place, dst_finder:()=>Rail[T], + dst_place:Place, dst_finder:()=>Pair[Rail[T],Int], len:Int) : Void; /* FIXME: This interface is not possible to define properly without structs: Modified: trunk/x10.runtime/src-x10/x10/lang/System.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/System.x10 2009-10-13 23:39:22 UTC (rev 11456) +++ trunk/x10.runtime/src-x10/x10/lang/System.x10 2009-10-14 02:04:17 UTC (rev 11457) @@ -11,6 +11,7 @@ import x10.compiler.Native; import x10.io.Console; import x10.util.Timer; +import x10.util.Pair; public class System { @@ -73,15 +74,16 @@ // FIXME: this ought to be in Rail but @Native system does not allow this static public def copyTo[T] (src:Rail[T], src_off:Int, - dst_place:Place, dst_finder:()=>Rail[T]{self.at(here)}, + dst_place:Place, dst_finder:()=>Pair[Rail[T]{self.at(here)},Int], len:Int) { // semantics allows an async per rail element inside a single finish // 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]; at (dst_place) { - val dst = dst_finder(); - val dst_off = 0; // FIXME: should come from dst_finder + val pair = dst_finder(); + val dst = pair.first; + val dst_off = pair.second; //TODO: implement optimisation in backend so we can use: for ((i):Point(1) in 0..len-1) { for (var i:Int=0 ; i<len ; ++i) { dst(dst_off+i) = to_serialize(src_off+i); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ipe...@us...> - 2009-10-15 04:25:13
|
Revision: 11484 http://x10.svn.sourceforge.net/x10/?rev=11484&view=rev Author: ipeshansky Date: 2009-10-15 04:25:03 +0000 (Thu, 15 Oct 2009) Log Message: ----------- Implement X10 2.0 object serialization semantics (XTENLANG-428). - global field serialization - global method invocation - remote object allocation - every object now has a location field - we no longer tag pointers Disable serialization tracing from C++ static init code Re-enable duplicate address detection Minor formatting tweaks Modified Paths: -------------- trunk/x10.compiler/src/x10cpp/visit/Emitter.java trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java 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/lang/Box.cc trunk/x10.runtime/src-cpp/x10/lang/Box.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/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/lang/String.h trunk/x10.runtime/src-cpp/x10/lang/Throwable.cc trunk/x10.runtime/src-cpp/x10/lang/Value.cc trunk/x10.runtime/src-cpp/x10/lang/Value.h trunk/x10.runtime/src-cpp/x10/runtime/Deque.cc trunk/x10.runtime/src-cpp/x10/runtime/Deque.h trunk/x10.runtime/src-cpp/x10/runtime/Thread.cc trunk/x10.runtime/src-cpp/x10/runtime/Thread.h 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/x10aux/alloc.h trunk/x10.runtime/src-cpp/x10aux/basic_functions.h trunk/x10.runtime/src-cpp/x10aux/deserialization_dispatcher.cc trunk/x10.runtime/src-cpp/x10aux/ref.cc trunk/x10.runtime/src-cpp/x10aux/ref.h trunk/x10.runtime/src-cpp/x10aux/serialization.h trunk/x10.runtime/src-x10/x10/lang/Ref.x10 Modified: trunk/x10.compiler/src/x10cpp/visit/Emitter.java =================================================================== --- trunk/x10.compiler/src/x10cpp/visit/Emitter.java 2009-10-15 03:28:05 UTC (rev 11483) +++ trunk/x10.compiler/src/x10cpp/visit/Emitter.java 2009-10-15 04:25:03 UTC (rev 11484) @@ -937,7 +937,7 @@ h.write(make_ref("__T")+" "+DESERIALIZER_METHOD+"("+DESERIALIZATION_BUFFER+"& buf) {"); h.newline(4) ; h.begin(0); h.write(make_ref(klass)+" this_ = "+ - "new (x10aux::alloc<"+klass+" >()) "+klass+"();"); h.newline(); + "new (x10aux::alloc"+chevrons(klass)+"()) "+klass+"();"); h.newline(); h.write("this_->"+DESERIALIZE_BODY_METHOD+"(buf);"); h.newline(); h.write("return this_;"); h.end(); h.newline(); @@ -973,7 +973,7 @@ if (f.flags().isStatic() || query.isSyntheticField(f.name().toString())) continue; String fieldName = mangled_field_name(f.name().toString()); - w.write(fieldName+" = buf.read<"+translateType(f.type(),true)+" >();"); + w.write(fieldName+" = buf.read"+chevrons(translateType(f.type(),true))+"();"); } w.end(); w.newline(); w.write("}"); @@ -981,6 +981,145 @@ w.forceNewline(); } + void generateClassSerializationMethods(ClassType type, StreamWrapper sw) { + X10ClassType ct = (X10ClassType) type.toClass(); + X10TypeSystem ts = (X10TypeSystem) type.typeSystem(); + X10CPPContext_c context = (X10CPPContext_c) tr.context(); + ClassifiedStream w = sw.body(); + ClassifiedStream h = sw.header(); + h.forceNewline(); + + h.write("// Serialization"); h.newline(); + String klass = translateType(type); + + if (!type.flags().isAbstract()) { + // _serialization_id + h.write("public: static const x10aux::serialization_id_t "+SERIALIZATION_ID_FIELD+";"); h.newline(); + h.forceNewline(); + printTemplateSignature(ct.typeArguments(), w); + w.write("const x10aux::serialization_id_t "+klass+"::"+SERIALIZATION_ID_FIELD+" = "); + w.newline(4); + w.write("x10aux::DeserializationDispatcher::addDeserializer("); + String template = context.inTemplate() ? "template " : ""; + w.write(klass+"::"+template+DESERIALIZER_METHOD+chevrons(translateType(ts.Object()))+");"); + w.newline(); w.forceNewline(); + } + + // _serialize() + if (!type.flags().isAbstract()) { + if (type.flags().isFinal()) { + h.write("public: "); + h.write("static void "+SERIALIZE_METHOD+"("); h.begin(0); + h.write(make_ref(klass)+" this_,"); h.newline(); + h.write(SERIALIZATION_BUFFER+"& buf,"); h.newline(); + h.write("x10aux::addr_map& m) {"); h.end(); h.newline(4); h.begin(0); + h.write( "if (this_ == x10aux::null) {"); h.newline(4); h.begin(0); + h.write( klass+" v;"); h.newline(); // needed when we serialise uninitialised values + h.write( "v._serialize_body(buf, m);"); h.end(); h.newline(); + h.write( "} else {"); h.newline(4); h.begin(0); + h.write( "this_->_serialize_body(buf, m);"); h.end(); h.newline(); + h.write( "}"); h.end(); h.newline(); + h.write("}"); h.newline(); + h.forceNewline(); + } + } + + // _serialize_id() + if (!type.flags().isAbstract()) { + h.write("public: "); + if (!type.flags().isFinal()) + h.write("virtual "); + h.write("x10aux::serialization_id_t "+SERIALIZE_ID_METHOD+"() {"); + h.newline(4); h.begin(0); + h.write(" return "+SERIALIZATION_ID_FIELD+";"); h.end(); h.newline(); + h.write("}"); h.newline(); + h.forceNewline(); + } + + + // _serialize_body() + h.write("public: "); + if (!type.flags().isFinal()) + h.write("virtual "); + h.write("void "+SERIALIZE_BODY_METHOD+"("+SERIALIZATION_BUFFER+"& buf, x10aux::addr_map& m);"); + h.newline(0); h.forceNewline(); + + printTemplateSignature(ct.typeArguments(), w); + w.write("void "+klass+"::"+SERIALIZE_BODY_METHOD+ + "("+SERIALIZATION_BUFFER+"& buf, x10aux::addr_map& m) {"); + w.newline(4); w.begin(0); + Type parent = type.superClass(); + if (parent != null && parent.isClass()) { + w.write(translateType(parent)+"::"+SERIALIZE_BODY_METHOD+"(buf, m);"); + w.newline(); + } + for (int i = 0; i < type.fields().size(); i++) { + if (i != 0) + w.newline(); + FieldInstance f = (FieldInstance) type.fields().get(i); + if (f.flags().isStatic() || query.isSyntheticField(f.name().toString())) + continue; + if (!X10Flags.toX10Flags(f.flags()).isGlobal()) // only serialize global fields of classes + continue; + String fieldName = mangled_field_name(f.name().toString()); + w.write("buf.write(this->"+fieldName+",m);"); w.newline(); + } + w.end(); w.newline(); + w.write("}"); + w.newline(); w.forceNewline(); + + if (!type.flags().isAbstract()) { + // _deserialize() + h.write("public: template<class __T> static "); + h.write(make_ref("__T")+" "+DESERIALIZER_METHOD+"("+DESERIALIZATION_BUFFER+"& buf) {"); + h.newline(4) ; h.begin(0); + h.write(make_ref(klass)+" this_ = "+ + "new (x10aux::remote_alloc"+chevrons(klass)+"()) "+klass+"();"); h.newline(); + h.write("this_->"+DESERIALIZE_BODY_METHOD+"(buf);"); h.newline(); + h.write("return this_;"); + h.end(); h.newline(); + h.write("}"); h.newline(); h.forceNewline(); + } + + if (!type.flags().isAbstract()) { + if (type.flags().isFinal()) { + // _deserialize() + h.write("public: template<class __T> static "); + h.write(make_ref("__T")+" "+DESERIALIZE_METHOD+"("+DESERIALIZATION_BUFFER+"& buf) {"); + h.newline(4) ; h.begin(0); + h.write("return "+DESERIALIZER_METHOD+"<__T>(buf);"); + h.end(); h.newline(); + h.write("}"); h.newline(); h.forceNewline(); + } + } + + // _deserialize_body() + h.write("public: "); + h.write("void "+DESERIALIZE_BODY_METHOD+"("+DESERIALIZATION_BUFFER+"& buf);"); h.newline(0); + printTemplateSignature(ct.typeArguments(), w); + w.write("void "+klass+"::"+DESERIALIZE_BODY_METHOD+"("+DESERIALIZATION_BUFFER+"& buf) {"); + w.newline(4); w.begin(0); + if (parent != null && parent.isClass()) { + w.write(translateType(parent)+"::"+DESERIALIZE_BODY_METHOD+"(buf);"); + w.newline(); + } + for (int i = 0; i < type.fields().size(); i++) { + if (i != 0) + w.newline(); + FieldInstance f = (FieldInstance) type.fields().get(i); + if (f.flags().isStatic() || query.isSyntheticField(f.name().toString())) + continue; + if (!X10Flags.toX10Flags(f.flags()).isGlobal()) // only serialize global fields of classes + continue; + String fieldName = mangled_field_name(f.name().toString()); + w.write(fieldName+" = buf.read"+chevrons(translateType(f.type(),true))+"();"); + } + w.end(); w.newline(); + w.write("}"); + w.newline(); + w.forceNewline(); + } + void generateStructSerializationMethods(ClassType type, StreamWrapper sw) { X10ClassType ct = (X10ClassType) type.toClass(); X10TypeSystem ts = (X10TypeSystem) type.typeSystem(); @@ -1041,7 +1180,7 @@ if (f.flags().isStatic() || query.isSyntheticField(f.name().toString())) continue; String fieldName = mangled_field_name(f.name().toString()); - w.write(fieldName+" = buf.read<"+translateType(f.type(),true)+" >();"); + w.write(fieldName+" = buf.read"+chevrons(translateType(f.type(),true))+"();"); } w.end(); w.newline(); w.write("}"); Modified: trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java =================================================================== --- trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java 2009-10-15 03:28:05 UTC (rev 11483) +++ trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java 2009-10-15 04:25:03 UTC (rev 11484) @@ -1235,6 +1235,7 @@ superClass, xts, "virtual ", h, members); } + emitter.generateClassSerializationMethods(currentClass, sw); } sw.end(); Modified: trunk/x10.runtime/src-cpp/x10/io/File__NativeFile.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/io/File__NativeFile.cc 2009-10-15 03:28:05 UTC (rev 11483) +++ trunk/x10.runtime/src-cpp/x10/io/File__NativeFile.cc 2009-10-15 04:25:03 UTC (rev 11484) @@ -20,6 +20,9 @@ return (new (x10aux::alloc<File__NativeFile>()) File__NativeFile())->_constructor(s); } +const x10aux::serialization_id_t File__NativeFile::_serialization_id = + x10aux::DeserializationDispatcher::addDeserializer(File__NativeFile::_deserializer<Object>); + RTT_CC_DECLS1(File__NativeFile, "x10.io.File.NativeFile", Ref) x10aux::ref<String> Modified: trunk/x10.runtime/src-cpp/x10/io/File__NativeFile.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/io/File__NativeFile.h 2009-10-15 03:28:05 UTC (rev 11483) +++ trunk/x10.runtime/src-cpp/x10/io/File__NativeFile.h 2009-10-15 04:25:03 UTC (rev 11484) @@ -2,6 +2,7 @@ #define X10_IO_NATIVEFILE_H #include <x10aux/config.h> +#include <x10aux/serialization.h> #include <x10/lang/Ref.h> @@ -27,10 +28,29 @@ 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(); path = s; return this; } + static const x10aux::serialization_id_t _serialization_id; + + virtual x10aux::serialization_id_t _get_serialization_id() { return _serialization_id; }; + + virtual void _serialize_body(x10aux::serialization_buffer &buf, x10aux::addr_map &m) { + this->x10::lang::Ref::_serialize_body(buf, m); + } + + template<class T> static x10aux::ref<T> _deserializer(x10aux::deserialization_buffer &buf) { + x10aux::ref<File__NativeFile> this_ = new (x10aux::remote_alloc<File__NativeFile>()) File__NativeFile(); + this_->_deserialize_body(buf); + return this_; + } + + void _deserialize_body(x10aux::deserialization_buffer& buf) { + this->x10::lang::Ref::_deserialize_body(buf); + } + virtual x10aux::ref<x10::lang::String> getPath() { return path; } virtual x10aux::ref<x10::lang::String> getAbsolutePath(); Modified: trunk/x10.runtime/src-cpp/x10/lang/Box.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Box.cc 2009-10-15 03:28:05 UTC (rev 11483) +++ trunk/x10.runtime/src-cpp/x10/lang/Box.cc 2009-10-15 04:25:03 UTC (rev 11484) @@ -21,3 +21,4 @@ } } +// vim:tabstop=4:shiftwidth=4:expandtab Modified: trunk/x10.runtime/src-cpp/x10/lang/Box.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Box.h 2009-10-15 03:28:05 UTC (rev 11483) +++ trunk/x10.runtime/src-cpp/x10/lang/Box.h 2009-10-15 04:25:03 UTC (rev 11484) @@ -5,6 +5,7 @@ #include <x10aux/config.h> #include <x10aux/RTT.h> #include <x10aux/basic_functions.h> +#include <x10aux/serialization.h> #include <x10/lang/Ref.h> @@ -14,6 +15,7 @@ namespace lang { + class Object; class String; void _initRTTHelper_Box(x10aux::RuntimeType *location, const x10aux::RuntimeType *rtt); @@ -27,10 +29,29 @@ } x10aux::ref<Box<T> > _constructor(T contents_) { + this->Ref::_constructor(); FMGL(value) = contents_; return this; } + static const x10aux::serialization_id_t _serialization_id; + + virtual x10aux::serialization_id_t _get_serialization_id() { return _serialization_id; }; + + virtual void _serialize_body(x10aux::serialization_buffer &buf, x10aux::addr_map &m) { + this->x10::lang::Ref::_serialize_body(buf, m); + } + + template<class U> static x10aux::ref<U> _deserializer(x10aux::deserialization_buffer &buf) { + x10aux::ref<Box> this_ = new (x10aux::remote_alloc<Box>()) Box(); + this_->_deserialize_body(buf); + return this_; + } + + void _deserialize_body(x10aux::deserialization_buffer& buf) { + this->x10::lang::Ref::_deserialize_body(buf); + } + virtual T get() { return FMGL(value); } @@ -45,6 +66,9 @@ }; + template<class T> const x10aux::serialization_id_t Box<T>::_serialization_id = + x10aux::DeserializationDispatcher::addDeserializer(Box<T>::template _deserializer<Object>); + template <> class Box<void> : public Ref { }; Modified: trunk/x10.runtime/src-cpp/x10/lang/Object.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Object.cc 2009-10-15 03:28:05 UTC (rev 11483) +++ trunk/x10.runtime/src-cpp/x10/lang/Object.cc 2009-10-15 04:25:03 UTC (rev 11484) @@ -13,14 +13,9 @@ x10aux::serialization_buffer &buf, x10aux::addr_map &m) { - if (x10aux::remote_ref::is_remote(this_.operator->()) || this_.isNull()) { - // cannot dispatch for these "addresses", handle here - buf.write(Ref::_serialization_id,m); - buf.write(x10aux::remote_ref::make(this_.operator->()),m); - return; - } - _S_("Serializing an "<<ANSI_SER<<ANSI_BOLD<<"interface id"<<ANSI_RESET<<" to buf: "<<&buf); - buf.write(this_->_get_serialization_id(),m); + x10aux::serialization_id_t id = this_->_get_serialization_id(); + _S_("Serializing an "<<ANSI_SER<<ANSI_BOLD<<"interface id "<<id<<ANSI_RESET<<" to buf: "<<&buf); + buf.write(id,m); _S_("Serializing the "<<ANSI_SER<<"interface body"<<ANSI_RESET<<" to buf: "<<&buf); this_->_serialize_body(buf, m); } Modified: trunk/x10.runtime/src-cpp/x10/lang/Object.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Object.h 2009-10-15 03:28:05 UTC (rev 11483) +++ trunk/x10.runtime/src-cpp/x10/lang/Object.h 2009-10-15 04:25:03 UTC (rev 11484) @@ -18,13 +18,15 @@ class Value; class Object { - private: + private: static x10aux::itable_entry _itables[1]; - public: + public: RTT_H_DECLS_CLASS virtual x10aux::itable_entry* _getITables() { return _itables; } + + x10_int location; Object(){ } Modified: trunk/x10.runtime/src-cpp/x10/lang/Ref.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Ref.cc 2009-10-15 03:28:05 UTC (rev 11483) +++ trunk/x10.runtime/src-cpp/x10/lang/Ref.cc 2009-10-15 04:25:03 UTC (rev 11484) @@ -30,7 +30,7 @@ } const serialization_id_t Ref::_serialization_id = - DeserializationDispatcher::addDeserializer(Ref::_deserialize<Object>); + DeserializationDispatcher::addDeserializer(Ref::_deserializer<Object>); RTT_CC_DECLS1(Ref, "x10.lang.Ref", Object) Modified: trunk/x10.runtime/src-cpp/x10/lang/Ref.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Ref.h 2009-10-15 03:28:05 UTC (rev 11483) +++ trunk/x10.runtime/src-cpp/x10/lang/Ref.h 2009-10-15 04:25:03 UTC (rev 11484) @@ -20,31 +20,69 @@ static x10aux::ref<Ref> _make(); - x10aux::ref<Ref> _constructor() { return this; } + x10aux::ref<Ref> _constructor() { + location = x10aux::here; + return this; + } static const x10aux::serialization_id_t _serialization_id; + // FIXME: optimize refs coming home static void _serialize(x10aux::ref<Ref> this_, x10aux::serialization_buffer &buf, x10aux::addr_map &m) { - // don't send an id, just serialise the ref (null/local/remote -- we don't care) - x10aux::remote_ref tmp = x10aux::remote_ref::make(this_.operator->()); - buf.write(tmp,m); + x10aux::serialization_id_t id = this_->_get_serialization_id(); + _S_("Serializing a "<<ANSI_SER<<ANSI_BOLD<<"class id "<<id<<ANSI_RESET<<" to buf: "<<&buf); + buf.write(id, m); + _S_("Serializing the "<<ANSI_SER<<"class body"<<ANSI_RESET<<" to buf: "<<&buf); + this_->_serialize_body(buf, m); } virtual x10aux::serialization_id_t _get_serialization_id() { return _serialization_id; }; + // WARNING: this code interacts with the code in _deserialize virtual void _serialize_body(x10aux::serialization_buffer &buf, x10aux::addr_map &m) { - _S_("Serialising a local Ref object of type "<<_type()->name()); - x10aux::remote_ref tmp = x10aux::remote_ref::make(this); - buf.write(tmp,m); + buf.write(this->location, m); + if (this->location == x10aux::here) { + _S_("Serialising a local Ref object of type "<<_type()->name()); + buf.write((x10aux::x10_addr_t)(size_t)this, m); + } else { + _S_("Serialising a remote Ref object of type "<<_type()->name()); + void* tmp = x10aux::remote_ref::get_remote_ref(this); + buf.write((x10aux::x10_addr_t)(size_t)tmp, m); + } }; - template<class T> static x10aux::ref<T> _deserialize(x10aux::deserialization_buffer &buf){ - return (T*)x10aux::remote_ref::take(buf.read<x10aux::remote_ref>()); + template<class T> static x10aux::ref<T> _deserializer(x10aux::deserialization_buffer &); + + // WARNING: this code interacts with the code in _serialize_body + template<class T> static x10aux::ref<T> _deserialize(x10aux::deserialization_buffer &buf) { + x10aux::serialization_id_t id = buf.read<x10aux::serialization_id_t>(); + x10_int loc = buf.peek<x10_int>(); + _S_("Attempting to deserialize a "<<ANSI_SER<<ANSI_BOLD<<"ref"<<ANSI_RESET<< + " (with id "<<id<<") at "<<loc<<" from buf: "<<&buf); + if (loc == x10aux::here) { // a remote object coming home to roost + _S_("\ta local object come home"); + x10aux::ref<T> ref = x10aux::DeserializationDispatcher::create<T>(buf, id); // consume the buffer + T* ptr = static_cast<T*>(x10aux::remote_ref::get_remote_ref(ref.operator->())); + //x10aux::dealloc(ref.operator->()); + return ptr; + } + // extract the id and execute a callback to instantiate the right concrete class + _S_("Deserializing a "<<ANSI_SER<<ANSI_BOLD<<"class"<<ANSI_RESET<< + " (with id "<<id<<") from buf: "<<&buf); + return x10aux::DeserializationDispatcher::create<T>(buf, id); } + virtual void _deserialize_body(x10aux::deserialization_buffer &buf) { + _S_("Deserialising a Ref object of type "<<_type()->name()); + this->location = buf.read<x10_int>(); + //assert (this->location != x10aux::here); // FIXME: optimize refs coming home and re-enable + void* ref = (void*)(size_t)buf.read<x10aux::x10_addr_t>(); + x10aux::remote_ref::set_remote_ref(this, ref); + }; + template<class T> friend class x10aux::ref; virtual x10_int hashCode(); @@ -54,10 +92,22 @@ // Needed for linking - do not override virtual x10_boolean _struct_equals(x10aux::ref<Object> other) { if (other == x10aux::ref<Ref>(this)) return true; + if (this->location == x10aux::here) return false; // already tested above + if (other->location == this->location && + x10aux::remote_ref::get_remote_ref(other.operator->()) == x10aux::remote_ref::get_remote_ref(this)) + { + return true; + } return false; } }; + template<class T> x10aux::ref<T> Ref::_deserializer(x10aux::deserialization_buffer &buf) { + x10aux::ref<Ref> this_ = new (x10aux::remote_alloc<Ref>()) Ref(); + this_->_deserialize_body(buf); + return this_; + } + } } Modified: trunk/x10.runtime/src-cpp/x10/lang/String.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/String.cc 2009-10-15 03:28:05 UTC (rev 11483) +++ trunk/x10.runtime/src-cpp/x10/lang/String.cc 2009-10-15 04:25:03 UTC (rev 11484) @@ -289,6 +289,7 @@ void String::_serialize_body(x10aux::serialization_buffer& buf, x10aux::addr_map &m) { + this->Value::_serialize_body(buf, m); // only support strings that are shorter than 4billion chars x10_int sz = FMGL(content_length); buf.write(sz,m); Modified: trunk/x10.runtime/src-cpp/x10/lang/String.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/String.h 2009-10-15 03:28:05 UTC (rev 11483) +++ trunk/x10.runtime/src-cpp/x10/lang/String.h 2009-10-15 04:25:03 UTC (rev 11484) @@ -34,6 +34,7 @@ // names that also ought not to be freed. static x10aux::ref<String> _make(const char *content, bool steal = false); x10aux::ref<String> _constructor(const char *content, std::size_t content_length) { + this->Value::_constructor(); this->FMGL(content) = content; this->FMGL(content_length) = content_length; return this; Modified: trunk/x10.runtime/src-cpp/x10/lang/Throwable.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Throwable.cc 2009-10-15 03:28:05 UTC (rev 11483) +++ trunk/x10.runtime/src-cpp/x10/lang/Throwable.cc 2009-10-15 04:25:03 UTC (rev 11484) @@ -37,12 +37,14 @@ void Throwable::_serialize_body(x10aux::serialization_buffer &buf, x10aux::addr_map &m) { + this->Value::_serialize_body(buf, m); buf.write(FMGL(cause),m); buf.write(FMGL(message),m); } void Throwable::_deserialize_body(x10aux::deserialization_buffer &buf) { + this->Value::_deserialize_body(buf); FMGL(cause) = buf.read<x10aux::ref<Box<x10aux::ref<Throwable> > > >(); FMGL(message) = buf.read<x10aux::ref<String> >(); } @@ -70,6 +72,7 @@ x10aux::ref<Throwable> Throwable::_constructor(x10aux::ref<String> message, x10aux::ref<Throwable> cause) { + this->Value::_constructor(); if (message==x10aux::null) { //hack, value types aren't supposed to be null this->FMGL(message) = String::Lit(""); } else { Modified: trunk/x10.runtime/src-cpp/x10/lang/Value.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Value.cc 2009-10-15 03:28:05 UTC (rev 11483) +++ trunk/x10.runtime/src-cpp/x10/lang/Value.cc 2009-10-15 04:25:03 UTC (rev 11484) @@ -15,9 +15,10 @@ void Value::_serialize(x10aux::ref<Value> this_, x10aux::serialization_buffer &buf, x10aux::addr_map &m) -{ - _S_("Serializing a "<<ANSI_SER<<ANSI_BOLD<<"value id"<<ANSI_RESET<<" to buf: "<<&buf); - buf.write(this_->_get_serialization_id(),m); +{ + x10aux::serialization_id_t id = this_->_get_serialization_id(); + _S_("Serializing a "<<ANSI_SER<<ANSI_BOLD<<"value id "<<id<<ANSI_RESET<<" to buf: "<<&buf); + buf.write(id,m); _S_("Serializing the "<<ANSI_SER<<"value body"<<ANSI_RESET<<" to buf: "<<&buf); this_->_serialize_body(buf, m); } Modified: trunk/x10.runtime/src-cpp/x10/lang/Value.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Value.h 2009-10-15 03:28:05 UTC (rev 11483) +++ trunk/x10.runtime/src-cpp/x10/lang/Value.h 2009-10-15 04:25:03 UTC (rev 11484) @@ -17,6 +17,10 @@ public: RTT_H_DECLS_CLASS + Value() { + location = x10aux::here; + } + static x10aux::ref<Value> _make(); x10aux::ref<Value> _constructor() { return this; } @@ -61,7 +65,7 @@ } template<class T> x10aux::ref<T> Value::_deserializer(x10aux::deserialization_buffer &) { - x10aux::ref<Value> this_ = new (x10aux::alloc<Value>())Value(); + x10aux::ref<Value> this_ = new (x10aux::alloc<Value>()) Value(); return this_; } } Modified: trunk/x10.runtime/src-cpp/x10/runtime/Deque.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/runtime/Deque.cc 2009-10-15 03:28:05 UTC (rev 11483) +++ trunk/x10.runtime/src-cpp/x10/runtime/Deque.cc 2009-10-15 04:25:03 UTC (rev 11484) @@ -26,6 +26,7 @@ } ref<Deque> Deque::_constructor() { + this->x10::lang::Ref::_constructor(); queue = x10aux::alloc<Slots>(); queue->capacity = INITIAL_QUEUE_CAPACITY; queue->data = x10aux::alloc<volatile void*>(INITIAL_QUEUE_CAPACITY * sizeof(void*)); @@ -35,6 +36,9 @@ return this; } +const serialization_id_t Deque::_serialization_id = + DeserializationDispatcher::addDeserializer(Deque::_deserializer<Object>); + void Deque::growQueue() { Slots *oldQ = queue; int oldSize = oldQ->capacity; Modified: trunk/x10.runtime/src-cpp/x10/runtime/Deque.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/runtime/Deque.h 2009-10-15 03:28:05 UTC (rev 11483) +++ trunk/x10.runtime/src-cpp/x10/runtime/Deque.h 2009-10-15 04:25:03 UTC (rev 11484) @@ -9,6 +9,7 @@ #include <x10rt17.h> #include <x10/lang/Ref.h> +#include <x10aux/serialization.h> namespace x10 { namespace runtime { @@ -29,6 +30,24 @@ x10aux::ref<Deque> _constructor(); + static const x10aux::serialization_id_t _serialization_id; + + virtual x10aux::serialization_id_t _get_serialization_id() { return _serialization_id; }; + + virtual void _serialize_body(x10aux::serialization_buffer &buf, x10aux::addr_map &m) { + this->x10::lang::Ref::_serialize_body(buf, m); + } + + template<class T> static x10aux::ref<T> _deserializer(x10aux::deserialization_buffer &buf) { + x10aux::ref<Deque> this_ = new (x10aux::remote_alloc<Deque>()) Deque(); + this_->_deserialize_body(buf); + return this_; + } + + void _deserialize_body(x10aux::deserialization_buffer& buf) { + this->x10::lang::Ref::_deserialize_body(buf); + } + private: struct Slots { public: Modified: trunk/x10.runtime/src-cpp/x10/runtime/Thread.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/runtime/Thread.cc 2009-10-15 03:28:05 UTC (rev 11483) +++ trunk/x10.runtime/src-cpp/x10/runtime/Thread.cc 2009-10-15 04:25:03 UTC (rev 11484) @@ -82,7 +82,10 @@ return (new (alloc<Thread>()) Thread())->_constructor(task,name); } +const serialization_id_t Thread::_serialization_id = + DeserializationDispatcher::addDeserializer(Thread::_deserializer<Object>); + // Helper method to initialize a Thread object. void Thread::thread_init(ref<VoidFun_0_0> task, const ref<String> name) Modified: trunk/x10.runtime/src-cpp/x10/runtime/Thread.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/runtime/Thread.h 2009-10-15 03:28:05 UTC (rev 11483) +++ trunk/x10.runtime/src-cpp/x10/runtime/Thread.h 2009-10-15 04:25:03 UTC (rev 11484) @@ -13,6 +13,7 @@ #include <x10/lang/Ref.h> #include <x10/lang/String.h> #include <x10/lang/VoidFun_0_0.h> +#include <x10aux/serialization.h> #include <pthread.h> @@ -59,10 +60,29 @@ x10aux::ref<Thread> _constructor(x10aux::ref<x10::lang::VoidFun_0_0> task, x10aux::ref<x10::lang::String> name) { + this->x10::lang::Ref::_constructor(); thread_init(task, name); return this; } + static const x10aux::serialization_id_t _serialization_id; + + virtual x10aux::serialization_id_t _get_serialization_id() { return _serialization_id; }; + + virtual void _serialize_body(x10aux::serialization_buffer &buf, x10aux::addr_map &m) { + this->x10::lang::Ref::_serialize_body(buf, m); + } + + template<class T> static x10aux::ref<T> _deserializer(x10aux::deserialization_buffer &buf) { + x10aux::ref<Thread> this_ = new (x10aux::remote_alloc<Thread>()) Thread(); + this_->_deserialize_body(buf); + return this_; + } + + void _deserialize_body(x10aux::deserialization_buffer& buf) { + this->x10::lang::Ref::_deserialize_body(buf); + } + // destructor ~Thread(); Modified: trunk/x10.runtime/src-cpp/x10/util/GrowableRail.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/util/GrowableRail.h 2009-10-15 03:28:05 UTC (rev 11483) +++ trunk/x10.runtime/src-cpp/x10/util/GrowableRail.h 2009-10-15 04:25:03 UTC (rev 11484) @@ -6,6 +6,7 @@ #include <x10aux/RTT.h> #include <x10aux/rail_utils.h> #include <x10aux/ref.h> +#include <x10aux/serialization.h> #include <x10/lang/Ref.h> #include <x10/lang/Rail.h> @@ -35,12 +36,30 @@ return this->_constructor(1); } x10aux::ref<GrowableRail> _constructor(x10_int size) { - this->Ref::_constructor(); + this->x10::lang::Ref::_constructor(); _array = x10::lang::Rail<T>::make(size); _len = 0; return this; } + static const x10aux::serialization_id_t _serialization_id; + + virtual x10aux::serialization_id_t _get_serialization_id() { return _serialization_id; }; + + virtual void _serialize_body(x10aux::serialization_buffer &buf, x10aux::addr_map &m) { + this->x10::lang::Ref::_serialize_body(buf, m); + } + + template<class U> static x10aux::ref<U> _deserializer(x10aux::deserialization_buffer &buf) { + x10aux::ref<GrowableRail> this_ = new (x10aux::remote_alloc<GrowableRail>()) GrowableRail(); + this_->_deserialize_body(buf); + return this_; + } + + void _deserialize_body(x10aux::deserialization_buffer& buf) { + this->x10::lang::Ref::_deserialize_body(buf); + } + T set(T v, x10_int i) { grow(i+1); return (*_array)[i] = v; @@ -136,6 +155,9 @@ template<class T> x10aux::RuntimeType GrowableRail<T>::rtt; + template<class T> const x10aux::serialization_id_t GrowableRail<T>::_serialization_id = + x10aux::DeserializationDispatcher::addDeserializer(GrowableRail<T>::template _deserializer<Object>); + template<> class GrowableRail<void> { public: static x10aux::RuntimeType rtt; Modified: trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicBoolean.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicBoolean.cc 2009-10-15 03:28:05 UTC (rev 11483) +++ trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicBoolean.cc 2009-10-15 04:25:03 UTC (rev 11484) @@ -23,6 +23,9 @@ return this_; } +const x10aux::serialization_id_t AtomicBoolean::_serialization_id = + x10aux::DeserializationDispatcher::addDeserializer(AtomicBoolean::_deserializer<Object>); + RTT_CC_DECLS1(AtomicBoolean, "x10.util.concurrent.atomic.AtomicBoolean", Ref) // vim:tabstop=4:shiftwidth=4:expandtab Modified: trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicBoolean.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicBoolean.h 2009-10-15 03:28:05 UTC (rev 11483) +++ trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicBoolean.h 2009-10-15 04:25:03 UTC (rev 11484) @@ -9,6 +9,7 @@ #include <x10rt17.h> #include <x10/lang/Ref.h> +#include <x10aux/serialization.h> namespace x10 { namespace util { @@ -26,8 +27,31 @@ static x10aux::ref<AtomicBoolean> _make(x10_boolean val); protected: - x10aux::ref<AtomicBoolean> _constructor(x10_boolean val) { _val = (val ? 1 :0); return this; } + x10aux::ref<AtomicBoolean> _constructor(x10_boolean val) { + this->x10::lang::Ref::_constructor(); + _val = (val ? 1 :0); + return this; + } + public: + static const x10aux::serialization_id_t _serialization_id; + + virtual x10aux::serialization_id_t _get_serialization_id() { return _serialization_id; }; + + virtual void _serialize_body(x10aux::serialization_buffer &buf, x10aux::addr_map &m) { + this->x10::lang::Ref::_serialize_body(buf, m); + } + + template<class T> static x10aux::ref<T> _deserializer(x10aux::deserialization_buffer &buf) { + x10aux::ref<AtomicBoolean> this_ = new (x10aux::remote_alloc<AtomicBoolean>()) AtomicBoolean(); + this_->_deserialize_body(buf); + return this_; + } + + void _deserialize_body(x10aux::deserialization_buffer& buf) { + this->x10::lang::Ref::_deserialize_body(buf); + } + private: /* * Am x10_int that is constrained to a 0/1 and interpret as an x10_ boolean. Modified: trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicInteger.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicInteger.cc 2009-10-15 03:28:05 UTC (rev 11483) +++ trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicInteger.cc 2009-10-15 04:25:03 UTC (rev 11484) @@ -23,6 +23,9 @@ return this_; } +const x10aux::serialization_id_t AtomicInteger::_serialization_id = + x10aux::DeserializationDispatcher::addDeserializer(AtomicInteger::_deserializer<Object>); + RTT_CC_DECLS1(AtomicInteger, "x10.util.concurrent.atomic.AtomicInteger", Ref) // vim:tabstop=4:shiftwidth=4:expandtab Modified: trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicInteger.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicInteger.h 2009-10-15 03:28:05 UTC (rev 11483) +++ trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicInteger.h 2009-10-15 04:25:03 UTC (rev 11484) @@ -9,6 +9,7 @@ #include <x10rt17.h> #include <x10/lang/Ref.h> +#include <x10aux/serialization.h> namespace x10 { namespace util { @@ -26,8 +27,31 @@ static x10aux::ref<AtomicInteger> _make(x10_int val); protected: - x10aux::ref<AtomicInteger> _constructor(x10_int val) { _val = val; return this; } + x10aux::ref<AtomicInteger> _constructor(x10_int val) { + this->x10::lang::Ref::_constructor(); + _val = val; + return this; + } + public: + static const x10aux::serialization_id_t _serialization_id; + + virtual x10aux::serialization_id_t _get_serialization_id() { return _serialization_id; }; + + virtual void _serialize_body(x10aux::serialization_buffer &buf, x10aux::addr_map &m) { + this->x10::lang::Ref::_serialize_body(buf, m); + } + + template<class T> static x10aux::ref<T> _deserializer(x10aux::deserialization_buffer &buf) { + x10aux::ref<AtomicInteger> this_ = new (x10aux::remote_alloc<AtomicInteger>()) AtomicInteger(); + this_->_deserialize_body(buf); + return this_; + } + + void _deserialize_body(x10aux::deserialization_buffer& buf) { + this->x10::lang::Ref::_deserialize_body(buf); + } + private: volatile x10_int _val; Modified: trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicLong.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicLong.cc 2009-10-15 03:28:05 UTC (rev 11483) +++ trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicLong.cc 2009-10-15 04:25:03 UTC (rev 11484) @@ -23,6 +23,9 @@ return this_; } +const x10aux::serialization_id_t AtomicLong::_serialization_id = + x10aux::DeserializationDispatcher::addDeserializer(AtomicLong::_deserializer<Object>); + RTT_CC_DECLS1(AtomicLong, "x10.util.concurrent.atomic.AtomicLong", Ref) // vim:tabstop=4:shiftwidth=4:expandtab Modified: trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicLong.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicLong.h 2009-10-15 03:28:05 UTC (rev 11483) +++ trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicLong.h 2009-10-15 04:25:03 UTC (rev 11484) @@ -9,6 +9,7 @@ #include <x10rt17.h> #include <x10/lang/Ref.h> +#include <x10aux/serialization.h> namespace x10 { namespace util { @@ -26,8 +27,31 @@ static x10aux::ref<AtomicLong> _make(x10_long val); protected: - x10aux::ref<AtomicLong> _constructor(x10_long val) { _val = val; return this; } + x10aux::ref<AtomicLong> _constructor(x10_long val) { + this->x10::lang::Ref::_constructor(); + _val = val; + return this; + } + public: + static const x10aux::serialization_id_t _serialization_id; + + virtual x10aux::serialization_id_t _get_serialization_id() { return _serialization_id; }; + + virtual void _serialize_body(x10aux::serialization_buffer &buf, x10aux::addr_map &m) { + this->x10::lang::Ref::_serialize_body(buf, m); + } + + template<class T> static x10aux::ref<T> _deserializer(x10aux::deserialization_buffer &buf) { + x10aux::ref<AtomicLong> this_ = new (x10aux::remote_alloc<AtomicLong>()) AtomicLong(); + this_->_deserialize_body(buf); + return this_; + } + + void _deserialize_body(x10aux::deserialization_buffer& buf) { + this->x10::lang::Ref::_deserialize_body(buf); + } + private: volatile x10_long _val; Modified: trunk/x10.runtime/src-cpp/x10aux/alloc.h =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/alloc.h 2009-10-15 03:28:05 UTC (rev 11483) +++ trunk/x10.runtime/src-cpp/x10aux/alloc.h 2009-10-15 04:25:03 UTC (rev 11484) @@ -66,6 +66,13 @@ return ret; } + // Allocate an object with a void* prepended to it + template<class T> T* remote_alloc() { + _M_("Allocating a remote object of type " << TYPENAME(T)); + T* ret = alloc<T>(sizeof(T)+sizeof(void*)); + return (T*)(((char*)ret)+sizeof(void*)); + } + template<class T> T* realloc(T* src, size_t dsz) { _M_("Reallocing chunk " << (void*)src << " of type " << TYPENAME(T)); #ifdef X10_USE_BDWGC Modified: trunk/x10.runtime/src-cpp/x10aux/basic_functions.h =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/basic_functions.h 2009-10-15 03:28:05 UTC (rev 11483) +++ trunk/x10.runtime/src-cpp/x10aux/basic_functions.h 2009-10-15 04:25:03 UTC (rev 11484) @@ -100,8 +100,8 @@ return y.isNull(); } else if (y.isNull()) { return false; // x != null, needed for remote refs - } else if (remote_ref::is_remote(x.operator->()) || remote_ref::is_remote(y.operator->())) { - return remote_ref::equals(x.operator->(), y.operator->()); + //} else if (remote_ref::is_remote(x.operator->()) || remote_ref::is_remote(y.operator->())) { + // return remote_ref::equals(x.operator->(), y.operator->()); } else { ref<x10::lang::Object> xAsObj = x; ref<x10::lang::Object> yAsObj = y; Modified: trunk/x10.runtime/src-cpp/x10aux/deserialization_dispatcher.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/deserialization_dispatcher.cc 2009-10-15 03:28:05 UTC (rev 11483) +++ trunk/x10.runtime/src-cpp/x10aux/deserialization_dispatcher.cc 2009-10-15 04:25:03 UTC (rev 11484) @@ -40,8 +40,8 @@ } deser_v[next_id] = deser; serialization_id_t r = next_id++; - _S_("DeserializationDispatcher registered the following handler for id: " - <<r<<": "<<std::hex<<(size_t)deser<<std::dec); + //_S_("DeserializationDispatcher registered the following handler for id: " + // <<r<<": "<<std::hex<<(size_t)deser<<std::dec); (void) is_async; // TODO: use two numbering schemes return r; } @@ -68,8 +68,8 @@ put_bfinder_v[next_id] = bfinder; put_notifier_v[next_id] = notifier; serialization_id_t r = next_id++; - _S_("DeserializationDispatcher registered the following put handler for id: " - <<r<<": "<<std::hex<<(size_t)bfinder<<std::dec); + //_S_("DeserializationDispatcher registered the following put handler for id: " + // <<r<<": "<<std::hex<<(size_t)bfinder<<std::dec); return r; } @@ -103,8 +103,8 @@ get_bfinder_v[next_id] = bfinder; get_notifier_v[next_id] = notifier; serialization_id_t r = next_id++; - _S_("DeserializationDispatcher registered the following get handler for id: " - <<r<<": "<<std::hex<<(size_t)bfinder<<std::dec); + //_S_("DeserializationDispatcher registered the following get handler for id: " + // <<r<<": "<<std::hex<<(size_t)bfinder<<std::dec); return r; } @@ -124,15 +124,15 @@ void DeserializationDispatcher::registerHandlers_ () { for (size_t i=0 ; i<next_id ; ++i) { if (i<deser_sz && deser_v[i]) { - _S_("(DeserializationDispatcher registered id "<<i<<" as an async)"); + //_S_("(DeserializationDispatcher registered id "<<i<<" as an async)"); x10aux::register_async_handler(i); } if (i<put_sz && put_bfinder_v[i]) { - _S_("(DeserializationDispatcher registered id "<<i<<" as a put)"); + //_S_("(DeserializationDispatcher registered id "<<i<<" as a put)"); x10aux::register_put_handler(i); } if (i<get_sz && get_bfinder_v[i]) { - _S_("(DeserializationDispatcher registered id "<<i<<" as a get)"); + //_S_("(DeserializationDispatcher registered id "<<i<<" as a get)"); x10aux::register_get_handler(i); } } Modified: trunk/x10.runtime/src-cpp/x10aux/ref.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/ref.cc 2009-10-15 03:28:05 UTC (rev 11483) +++ trunk/x10.runtime/src-cpp/x10aux/ref.cc 2009-10-15 04:25:03 UTC (rev 11484) @@ -17,34 +17,38 @@ void x10aux::throwBPE() { throwException<BadPlaceException>(); } -remote_ref remote_ref::make (void *ptr, bool immortalize) { - if (remote_ref::is_remote(ptr)) return *strip(ptr); - #if defined(X10_USE_BDWGC) || defined(X10_DEBUG_REFERENCE_LOGGER) - if (immortalize) { - ReferenceLogger::log(ptr); - } - #endif - remote_ref r = { x10aux::here, (size_t)ptr }; - return r; +x10_int x10aux::location(x10aux::ref<x10::lang::Object> obj) { + return obj->location; } -void *remote_ref::take (remote_ref r) { - if (r.loc==x10aux::here) return (void*)(size_t)r.addr; - if (r.addr==0) return NULL; - return mask(new remote_ref(r)); -} +//remote_ref remote_ref::make (void *ptr, bool immortalize) { +// if (remote_ref::is_remote(ptr)) return *strip(ptr); +// #if defined(X10_USE_BDWGC) || defined(X10_DEBUG_REFERENCE_LOGGER) +// if (immortalize) { +// ReferenceLogger::log(ptr); +// } +// #endif +// remote_ref r = { x10aux::here, (size_t)ptr }; +// return r; +//} -x10_int x10aux::location (void *ptr) { - if (remote_ref::is_remote(ptr)) return remote_ref::strip(ptr)->loc; - return x10aux::here; -} +//void *remote_ref::take (remote_ref r) { +// if (r.loc==x10aux::here) return (void*)(size_t)r.addr; +// if (r.addr==0) return NULL; +// return mask(new remote_ref(r)); +//} -bool remote_ref::equals (void *ptr1, void *ptr2) { - if (!remote_ref::is_remote(ptr1) || !remote_ref::is_remote(ptr2)) - return false; - remote_ref *r1 = remote_ref::strip(ptr1); - remote_ref *r2 = remote_ref::strip(ptr2); - return r1->loc==r2->loc && r1->addr==r2->addr; -} +//x10_int x10aux::location (void *ptr) { +// if (remote_ref::is_remote(ptr)) return remote_ref::strip(ptr)->loc; +// return x10aux::here; +//} +//bool remote_ref::equals (void *ptr1, void *ptr2) { +// if (!remote_ref::is_remote(ptr1) || !remote_ref::is_remote(ptr2)) +// return false; +// remote_ref *r1 = remote_ref::strip(ptr1); +// remote_ref *r2 = remote_ref::strip(ptr2); +// return r1->loc==r2->loc && r1->addr==r2->addr; +//} + // vim:tabstop=4:shiftwidth=4:expandtab Modified: trunk/x10.runtime/src-cpp/x10aux/ref.h =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/ref.h 2009-10-15 03:28:05 UTC (rev 11483) +++ trunk/x10.runtime/src-cpp/x10aux/ref.h 2009-10-15 04:25:03 UTC (rev 11484) @@ -12,29 +12,34 @@ namespace x10aux { + typedef x10_ulong x10_addr_t; + struct remote_ref { - static bool is_remote (void *ref) { return ((size_t)ref) & 1; } - static remote_ref *strip (void *ref) { return (remote_ref*)(((size_t)ref) & ~1); } - static void *mask (remote_ref *ref) { return (void*)(((size_t)ref) | 1); } + static void* get_remote_ref (void *obj) { return *(void**)(((char*)obj)-sizeof(void*)); } + static void set_remote_ref (void *obj, void *ref) { *(void**)(((char*)obj)-sizeof(void*)) = ref; } - x10_int loc; - x10_ulong addr; + //static bool is_remote (void *ref) { return ((size_t)ref) & 1; } + //static remote_ref *strip (void *ref) { return (remote_ref*)(((size_t)ref) & ~1); } + //static void *mask (remote_ref *ref) { return (void*)(((size_t)ref) | 1); } - // take a (possibly masked) pointer and provide a remote_ref struct for serialisation - static remote_ref make (void *ptr, bool immortalize=true); + //x10_int loc; + //x10_addr_t addr; - // take a remote_ref struct (presumably from the wire) and create a local representation - static void *take (remote_ref r); + //// take a (possibly masked) pointer and provide a remote_ref struct for serialisation + //static remote_ref make (void *ptr, bool immortalize=true); - // compare two (masked) remote_ref pointers - static bool equals (void *ptr1, void *ptr2); + //// take a remote_ref struct (presumably from the wire) and create a local representation + //static void *take (remote_ref r); + + //// compare two (masked) remote_ref pointers + //static bool equals (void *ptr1, void *ptr2); }; - #ifndef NO_IOSTREAM - inline std::ostream &operator<<(std::ostream &o, const remote_ref &rr) { - return o << "rr("<<rr.addr<<"@"<<rr.loc<<")"; - } - #endif + //#ifndef NO_IOSTREAM + //inline std::ostream &operator<<(std::ostream &o, const remote_ref &rr) { + // return o << "rr("<<rr.addr<<"@"<<rr.loc<<")"; + //} + //#endif class __ref { protected: @@ -151,6 +156,8 @@ } #endif + x10_int location (ref<x10::lang::Object> obj); + void throwNPE() X10_PRAGMA_NORETURN; void throwBPE() X10_PRAGMA_NORETURN; @@ -164,7 +171,8 @@ template <class T> inline ref<T> placeCheck(ref<T> obj) { #if !defined(NO_PLACE_CHECKS) && !defined(NO_EXCEPTIONS) - if (remote_ref::is_remote(obj.operator->())) throwBPE(); + //if (remote_ref::is_remote(obj.operator->())) throwBPE(); + if (location(obj) != here) throwBPE(); #endif return obj; } @@ -201,12 +209,6 @@ template<class T> bool operator==(const ref<T>& _ref, x10_uint i) { return false; } template<class T> bool operator==(const ref<T>& _ref, x10_ulong l) { return false; } - x10_int location (void *ptr); - - template<class T> x10_int location (x10aux::ref<T> ptr) { - return location(ptr.operator->()); - } - } //namespace x10 Modified: trunk/x10.runtime/src-cpp/x10aux/serialization.h =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/serialization.h 2009-10-15 03:28:05 UTC (rev 11483) +++ trunk/x10.runtime/src-cpp/x10aux/serialization.h 2009-10-15 04:25:03 UTC (rev 11484) @@ -129,9 +129,11 @@ // [DC] instead of threading this around everywhere, why don't we encapsulate it within the // serialization_buffer? That way the serialiation buffer always has it available, and noone // else has to be troubled by it. + // [IP] if we had proper cycle handling, we could. As it stands now, we have to be able to + // handle two refs to the same object being written into the same buffer. For that we need + // to reset the addr_map between them (but only up to a certain point). That code is too + // complex to implement right now. class addr_map { -#if 0 -NOT USED AT PRESENT int _size; const void** _ptrs; int _top; @@ -139,15 +141,18 @@ void _add(const void* ptr); bool _find(const void* ptr); public: - addr_map(int init_size = 4) : _size(init_size), _ptrs(new (x10aux::alloc<const -void*>((init_size)*sizeof(const void*)))const void*[init_size]), _top(0) { } + addr_map(int init_size = 4) : + _size(init_size), + _ptrs(new (x10aux::alloc<const void*>((init_size)*sizeof(const void*))) + const void*[init_size]), + _top(0) + { } template<class T> bool ensure_unique(const ref<T>& r) { return ensure_unique((void*) r.get()); } bool ensure_unique(const void* p); void reset() { _top = 0; assert (false); } ~addr_map() { x10aux::dealloc(_ptrs); } -#endif }; @@ -184,7 +189,6 @@ assert(buffer==NULL); } - void grow (void); size_t length (void) { return cursor - buffer; } @@ -192,7 +196,7 @@ char *steal() { char *buf = buffer; buffer = NULL; return buf; } - // default case for primitives and other things that never contain pointers + // Default case for primitives and other things that never contain pointers template<class T> struct Write; template<class T> struct Write<ref<T> >; template<typename T> void write(const T &val, addr_map &m); @@ -233,16 +237,17 @@ PRIMITIVE_WRITE(x10_ulong) PRIMITIVE_WRITE(x10_float) PRIMITIVE_WRITE(x10_double) - PRIMITIVE_WRITE(remote_ref) + //PRIMITIVE_WRITE(x10_addr_t) // already defined above + //PRIMITIVE_WRITE(remote_ref) - // case for references e.g. ref<Object>, + // Case for references e.g. ref<Object>, template<class T> struct serialization_buffer::Write<ref<T> > { static void _(serialization_buffer &buf, ref<T> val, addr_map &m); }; template<class T> void serialization_buffer::Write<ref<T> >::_(serialization_buffer &buf, ref<T> val, addr_map &m) { _S_("Serializing a "<<ANSI_SER<<ANSI_BOLD<<TYPENAME(T)<<ANSI_RESET<<" into buf: "<<&buf); - //depends what T is (interface/Ref/Value/FinalValue/Closure) + // Depends what T is (interface/Ref/Closure) T::_serialize(val,buf,m); } @@ -258,19 +263,22 @@ const char* cursor; public: - // we use the same buffers for serializing and deserializing so the - // const cast is necessary - // note that a serialization_buffer created this way can only be used for deserializing deserialization_buffer(const char *buffer_) : buffer(buffer_), cursor(buffer_) { } size_t consumed (void) { return cursor - buffer; } - // default case for primitives and other things that never contain pointers + // Default case for primitives and other things that never contain pointers template<class T> struct Read; template<class T> struct Read<ref<T> >; template<typename T> GPUSAFE T read(); + template<typename T> GPUSAFE T peek() { + const char* saved_cursor = cursor; + T val = read<T>(); + cursor = saved_cursor; + return val; + } }; // Case for non-refs (includes simple primitives like x10_int and all structs) @@ -280,6 +288,7 @@ // General case for structs template<class T> T deserialization_buffer::Read<T>::_(deserialization_buffer &buf) { _S_("Deserializing a "<<ANSI_SER<<ANSI_BOLD<<TYPENAME(T)<<ANSI_RESET<<" from buf: "<<&buf); + // Dispatch because we don't know what it is return T::_deserialize(buf); } @@ -307,15 +316,16 @@ PRIMITIVE_READ(x10_ulong) PRIMITIVE_READ(x10_float) PRIMITIVE_READ(x10_double) - PRIMITIVE_READ(remote_ref) + //PRIMITIVE_READ(x10_addr_t) // already defined above + //PRIMITIVE_READ(remote_ref) - // case for references e.g. ref<Object>, + // Case for references e.g. ref<Object>, template<class T> struct deserialization_buffer::Read<ref<T> > { GPUSAFE static ref<T> _(deserialization_buffer &buf); }; template<class T> ref<T> deserialization_buffer::Read<ref<T> >::_(deserialization_buffer &buf) { - //dispatch because we don't know what it is _S_("Deserializing a "<<ANSI_SER<<ANSI_BOLD<<TYPENAME(T)<<ANSI_RESET<<" from buf: "<<&buf); + // Dispatch because we don't know what it is return T::template _deserialize<T>(buf); } Modified: trunk/x10.runtime/src-x10/x10/lang/Ref.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Ref.x10 2009-10-15 03:28:05 UTC (rev 11483) +++ trunk/x10.runtime/src-x10/x10/lang/Ref.x10 2009-10-15 04:25:03 UTC (rev 11484) @@ -18,8 +18,8 @@ @NativeRep("c++", "x10aux::ref<x10::lang::Ref>", "x10::lang::Ref", null) public class Ref( @Native("java", "x10.lang.Place.place(#0.location())") - @Native("c++", "x10::lang::Place_methods::place(x10aux::location(#0))") - location: Place) + @Native("c++", "x10::lang::Place_methods::place((#0)->location)") + location: Place) /* @EQ implements Equals[Ref] */ implements Object { @@ -48,15 +48,15 @@ public native def typeName() : String; @Native("java", "#0.location()") - @Native("c++", "x10::lang::Place_methods::place(x10aux::location(#0))") + @Native("c++", "x10::lang::Place_methods::place((#0)->location)") public property def loc() = location; @Native("java", "#0.at(#1.id)") - @Native("c++", "(x10aux::location(#0) == (#1)->FMGL(id))") + @Native("c++", "((#0)->location == (#1)->FMGL(id))") public property def at(p:Place) = location==p; @Native("java", "#0.at(#1)") - @Native("c++", "(x10aux::location(#0) == x10aux::location(#1)... [truncated message content] |
From: <ipe...@us...> - 2009-10-17 20:50:19
|
Revision: 11519 http://x10.svn.sourceforge.net/x10/?rev=11519&view=rev Author: ipeshansky Date: 2009-10-17 19:38:57 +0000 (Sat, 17 Oct 2009) Log Message: ----------- Add specialized serialization for final classes Rename remote_alloc to alloc_remote Add dealloc_remote and use it when deserializing Refs Always use x10_addr_t to store a remote ref Outline serialization implementation out of the Ref class Set location and ref separately, outside of Ref::_serialize_body() Modified Paths: -------------- trunk/x10.compiler/src/x10cpp/visit/Emitter.java trunk/x10.runtime/src-cpp/x10/io/File__NativeFile.h trunk/x10.runtime/src-cpp/x10/lang/Box.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/runtime/Deque.h trunk/x10.runtime/src-cpp/x10/runtime/Thread.h trunk/x10.runtime/src-cpp/x10/util/GrowableRail.h trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicBoolean.h trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicInteger.h trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicLong.h trunk/x10.runtime/src-cpp/x10aux/alloc.h trunk/x10.runtime/src-cpp/x10aux/config.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 2009-10-17 18:48:51 UTC (rev 11518) +++ trunk/x10.compiler/src/x10cpp/visit/Emitter.java 2009-10-17 19:38:57 UTC (rev 11519) @@ -1005,6 +1005,21 @@ w.newline(); w.forceNewline(); } + if (type.flags().isFinal()) { + // _serialize() + h.write("public: "); + h.write("static void "+SERIALIZE_METHOD+"("); h.begin(0); + h.write(make_ref(klass)+" this_,"); h.newline(); + h.write(SERIALIZATION_BUFFER+"& buf,"); h.newline(); + h.write("x10aux::addr_map& m) {"); h.end(); h.newline(4); h.begin(0); + h.write( "_serialize_reference(this_, buf, m);"); h.newline(); + h.write( "if (this_ != x10aux::null) {"); h.newline(4); h.begin(0); + h.write( "this_->_serialize_body(buf, m);"); h.end(); h.newline(); + h.write( "}"); h.end(); h.newline(); + h.write("}"); h.newline(); + h.forceNewline(); + } + // _serialize_id() if (!type.flags().isAbstract()) { h.write("public: "); @@ -1053,15 +1068,31 @@ // _deserialize() h.write("public: template<class __T> static "); h.write(make_ref("__T")+" "+DESERIALIZER_METHOD+"("+DESERIALIZATION_BUFFER+"& buf) {"); - h.newline(4) ; h.begin(0); + h.newline(4); h.begin(0); h.write(make_ref(klass)+" this_ = "+ - "new (x10aux::remote_alloc"+chevrons(klass)+"()) "+klass+"();"); h.newline(); + "new (x10aux::alloc_remote"+chevrons(klass)+"()) "+klass+"();"); h.newline(); h.write("this_->"+DESERIALIZE_BODY_METHOD+"(buf);"); h.newline(); h.write("return this_;"); h.end(); h.newline(); h.write("}"); h.newline(); h.forceNewline(); } + if (type.flags().isFinal()) { + // _deserialize() + h.write("public: template<class __T> static "); + h.write(make_ref("__T")+" "+DESERIALIZE_METHOD+"("+DESERIALIZATION_BUFFER+"& buf) {"); + h.newline(4); h.begin(0); + h.write( make_ref(klass)+" this_ = _deserialize_reference"+chevrons(klass)+"(buf);"); + h.newline(); + h.write( "if (this_ != x10aux::null && this_->location != x10aux::here) {"); + h.newline(4); h.begin(0); + h.write( "this_->_deserialize_body(buf);"); h.end(); h.newline(); + h.write( "}"); h.newline(); + h.write( "return this_;"); + h.end(); h.newline(); + h.write("}"); h.newline(); h.forceNewline(); + } + // _deserialize_body() h.write("public: "); h.write("void "+DESERIALIZE_BODY_METHOD+"("+DESERIALIZATION_BUFFER+"& buf);"); h.newline(0); Modified: trunk/x10.runtime/src-cpp/x10/io/File__NativeFile.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/io/File__NativeFile.h 2009-10-17 18:48:51 UTC (rev 11518) +++ trunk/x10.runtime/src-cpp/x10/io/File__NativeFile.h 2009-10-17 19:38:57 UTC (rev 11519) @@ -42,7 +42,7 @@ } template<class T> static x10aux::ref<T> _deserializer(x10aux::deserialization_buffer &buf) { - x10aux::ref<File__NativeFile> this_ = new (x10aux::remote_alloc<File__NativeFile>()) File__NativeFile(); + x10aux::ref<File__NativeFile> this_ = new (x10aux::alloc_remote<File__NativeFile>()) File__NativeFile(); this_->_deserialize_body(buf); return this_; } Modified: trunk/x10.runtime/src-cpp/x10/lang/Box.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Box.h 2009-10-17 18:48:51 UTC (rev 11518) +++ trunk/x10.runtime/src-cpp/x10/lang/Box.h 2009-10-17 19:38:57 UTC (rev 11519) @@ -43,7 +43,7 @@ } template<class U> static x10aux::ref<U> _deserializer(x10aux::deserialization_buffer &buf) { - x10aux::ref<Box> this_ = new (x10aux::remote_alloc<Box>()) Box(); + x10aux::ref<Box> this_ = new (x10aux::alloc_remote<Box>()) Box(); this_->_deserialize_body(buf); return this_; } Modified: trunk/x10.runtime/src-cpp/x10/lang/Ref.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Ref.cc 2009-10-17 18:48:51 UTC (rev 11518) +++ trunk/x10.runtime/src-cpp/x10/lang/Ref.cc 2009-10-17 19:38:57 UTC (rev 11519) @@ -32,6 +32,61 @@ const serialization_id_t Ref::_serialization_id = DeserializationDispatcher::addDeserializer(Ref::_deserializer<Object>); +// FIXME: optimize refs coming home +void Ref::_serialize(ref<Ref> this_, serialization_buffer &buf, addr_map &m) +{ + 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, m); + // FIXME: maybe optimize nulls? + //if (!this_.isNull()) { + // FIXME: factor out common code with _serialize_reference + bool isNull = this_.isNull(); + x10_int loc = isNull ? 0 : this_->location; + buf.write(loc, m); + if (isNull) { + _S_("Serializing a "<<ANSI_SER<<ANSI_BOLD<<"null reference"<<ANSI_RESET<<" to buf: "<<&buf); + buf.write((x10_addr_t)0, m); + return; + } 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->(), m); + } 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, m); + } + _S_("Serializing the "<<ANSI_SER<<"class body"<<ANSI_RESET<<" to buf: "<<&buf); + this_->_serialize_body(buf, m); + //} +} + +// FIXME: factor out common code with _serialize +void Ref::_serialize_reference(ref<Ref> this_, serialization_buffer &buf, addr_map &m) +{ + _S_("Serializing an untyped "<<ANSI_SER<<ANSI_BOLD<<"reference"<<ANSI_RESET<<" to buf: "<<&buf); + bool isNull = this_.isNull(); + x10_int loc = isNull ? 0 : this_->location; + buf.write(loc, m); + if (isNull) { + _S_("Serializing a "<<ANSI_SER<<ANSI_BOLD<<"null reference"<<ANSI_RESET<<" to buf: "<<&buf); + buf.write((x10_addr_t)0, m); + return; + } 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->(), m); + } 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, m); + } +} + + RTT_CC_DECLS1(Ref, "x10.lang.Ref", Object) // 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 2009-10-17 18:48:51 UTC (rev 11518) +++ trunk/x10.runtime/src-cpp/x10/lang/Ref.h 2009-10-17 19:38:57 UTC (rev 11519) @@ -27,71 +27,28 @@ static const x10aux::serialization_id_t _serialization_id; - // FIXME: optimize refs coming home static void _serialize(x10aux::ref<Ref> this_, x10aux::serialization_buffer &buf, - x10aux::addr_map &m) - { - if (this_.isNull()) { - _S_("Serializing a "<<ANSI_SER<<ANSI_BOLD<<"null reference"<<ANSI_RESET<<" to buf: "<<&buf); - buf.write((x10aux::serialization_id_t)0, m); - return; - } - x10aux::serialization_id_t id = this_->_get_serialization_id(); - _S_("Serializing a "<<ANSI_SER<<ANSI_BOLD<<"class id "<<id<<ANSI_RESET<<" to buf: "<<&buf); - buf.write(id, m); - _S_("Serializing the "<<ANSI_SER<<"class body"<<ANSI_RESET<<" to buf: "<<&buf); - this_->_serialize_body(buf, m); - } + x10aux::addr_map &m); + // A helper method for serializing a final ref with no global state + static void _serialize_reference(x10aux::ref<Ref> this_, + x10aux::serialization_buffer &buf, + x10aux::addr_map &m); + virtual x10aux::serialization_id_t _get_serialization_id() { return _serialization_id; }; - // WARNING: this code interacts with the code in _deserialize - virtual void _serialize_body(x10aux::serialization_buffer &buf, x10aux::addr_map &m) { - buf.write(this->location, m); - if (this->location == x10aux::here) { - _S_("Serialising a local Ref object of type "<<_type()->name()); - buf.write((x10aux::x10_addr_t)(size_t)this, m); - } else { - _S_("Serialising a remote Ref object of type "<<_type()->name()); - void* tmp = x10aux::remote_ref::get_remote_ref(this); - buf.write((x10aux::x10_addr_t)(size_t)tmp, m); - } - }; + virtual void _serialize_body(x10aux::serialization_buffer &buf, x10aux::addr_map &m) { } template<class T> static x10aux::ref<T> _deserializer(x10aux::deserialization_buffer &); - // WARNING: this code interacts with the code in _serialize_body - template<class T> static x10aux::ref<T> _deserialize(x10aux::deserialization_buffer &buf) { - x10aux::serialization_id_t id = buf.read<x10aux::serialization_id_t>(); - if (id == 0) { - _S_("Deserializing a "<<ANSI_SER<<ANSI_BOLD<<"null reference"<<ANSI_RESET<<" from buf: "<<&buf); - return x10aux::null; - } - x10_int loc = buf.peek<x10_int>(); - _S_("Attempting to deserialize a "<<ANSI_SER<<ANSI_BOLD<<"ref"<<ANSI_RESET<< - " (with id "<<id<<") at "<<loc<<" from buf: "<<&buf); - if (loc == x10aux::here) { // a remote object coming home to roost - _S_("\ta local object come home"); - x10aux::ref<T> ref = x10aux::DeserializationDispatcher::create<T>(buf, id); // consume the buffer - T* ptr = static_cast<T*>(x10aux::remote_ref::get_remote_ref(ref.operator->())); - //x10aux::dealloc(ref.operator->()); - return ptr; - } - // extract the id and execute a callback to instantiate the right concrete class - _S_("Deserializing a "<<ANSI_SER<<ANSI_BOLD<<"class"<<ANSI_RESET<< - " (with id "<<id<<") from buf: "<<&buf); - return x10aux::DeserializationDispatcher::create<T>(buf, id); - } + template<class T> static x10aux::ref<T> _deserialize(x10aux::deserialization_buffer &buf); - virtual void _deserialize_body(x10aux::deserialization_buffer &buf) { - _S_("Deserialising a Ref object of type "<<_type()->name()); - this->location = buf.read<x10_int>(); - //assert (this->location != x10aux::here); // FIXME: optimize refs coming home and re-enable - void* ref = (void*)(size_t)buf.read<x10aux::x10_addr_t>(); - x10aux::remote_ref::set_remote_ref(this, ref); - }; + // A helper method for deserializing a final ref with no global state + template<class R> static x10aux::ref<R> _deserialize_reference(x10aux::deserialization_buffer &buf); + virtual void _deserialize_body(x10aux::deserialization_buffer &buf) { } + template<class T> friend class x10aux::ref; virtual x10_int hashCode(); @@ -103,7 +60,7 @@ if (other == x10aux::ref<Ref>(this)) return true; if (this->location == x10aux::here) return false; // already tested above if (other->location == this->location && - x10aux::remote_ref::get_remote_ref(other.operator->()) == x10aux::remote_ref::get_remote_ref(this)) + x10aux::get_remote_ref(other.operator->()) == x10aux::get_remote_ref(this)) { return true; } @@ -112,11 +69,61 @@ }; template<class T> x10aux::ref<T> Ref::_deserializer(x10aux::deserialization_buffer &buf) { - x10aux::ref<Ref> this_ = new (x10aux::remote_alloc<Ref>()) Ref(); + x10aux::ref<Ref> this_ = new (x10aux::alloc_remote<Ref>()) Ref(); this_->_deserialize_body(buf); return this_; } + template<class T> x10aux::ref<T> Ref::_deserialize(x10aux::deserialization_buffer &buf) { + x10aux::serialization_id_t id = buf.read<x10aux::serialization_id_t>(); + // FIXME: factor out common code with _deserialize_reference + x10_int loc = buf.read<x10_int>(); + x10aux::x10_addr_t ref = buf.read<x10aux::x10_addr_t>(); + if (ref == 0 /*TODO: id == 0*/) { + _S_("Deserializing a "<<ANSI_SER<<ANSI_BOLD<<"null reference"<<ANSI_RESET<<" from buf: "<<&buf); + return x10aux::null; + } + _S_("Attempting to deserialize a "<<ANSI_SER<<ANSI_BOLD<<"ref"<<ANSI_RESET<< + " (with id "<<id<<") at "<<loc<<" from buf: "<<&buf); + if (loc == x10aux::here) { // a remote object coming home to roost + _S_("\ta local object come home"); + x10aux::ref<T> obj = x10aux::DeserializationDispatcher::create<T>(buf, id); // consume the buffer + T* ptr = static_cast<T*>((void*)(size_t)ref); + //x10aux::dealloc_remote(obj.operator->()); + return ptr; + } + // extract the id and execute a callback to instantiate the right concrete class + _S_("Deserializing a "<<ANSI_SER<<ANSI_BOLD<<"class"<<ANSI_RESET<< + " (with id "<<id<<") from buf: "<<&buf); + x10aux::ref<Ref> obj = x10aux::DeserializationDispatcher::create<T>(buf, id); + obj->location = loc; + x10aux::set_remote_ref(obj.operator->(), ref); + return obj; + } + + // FIXME: factor out common code with _deserialize + template<class R> x10aux::ref<R> Ref::_deserialize_reference(x10aux::deserialization_buffer &buf) { + x10_int loc = buf.read<x10_int>(); + x10aux::x10_addr_t ref = buf.read<x10aux::x10_addr_t>(); + if (ref == 0 /*TODO: id == 0*/) { + _S_("Deserializing a "<<ANSI_SER<<ANSI_BOLD<<"null reference"<<ANSI_RESET<<" from buf: "<<&buf); + return x10aux::null; + } + _S_("Attempting to deserialize a "<<ANSI_SER<<ANSI_BOLD<<"ref"<<ANSI_RESET<< + " of type "<<TYPENAME(R)<<" at "<<loc<<" from buf: "<<&buf); + if (loc == x10aux::here) { // a remote object coming home to roost + _S_("\ta local object come home"); + // Nothing left in the buffer (if _serialize_reference was used to serialize the object) + return static_cast<R*>((void*)(size_t)ref); + } + x10aux::ref<R> obj = new (x10aux::alloc_remote<R>()) R(); + _S_("Deserializing a "<<ANSI_SER<<ANSI_BOLD<<"class"<<ANSI_RESET<< + " "<<obj->_type()->name()<<" from buf: "<<&buf); + obj->location = loc; + x10aux::set_remote_ref(obj.operator->(), ref); + return obj; + } + } } Modified: trunk/x10.runtime/src-cpp/x10/runtime/Deque.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/runtime/Deque.h 2009-10-17 18:48:51 UTC (rev 11518) +++ trunk/x10.runtime/src-cpp/x10/runtime/Deque.h 2009-10-17 19:38:57 UTC (rev 11519) @@ -39,7 +39,7 @@ } template<class T> static x10aux::ref<T> _deserializer(x10aux::deserialization_buffer &buf) { - x10aux::ref<Deque> this_ = new (x10aux::remote_alloc<Deque>()) Deque(); + x10aux::ref<Deque> this_ = new (x10aux::alloc_remote<Deque>()) Deque(); this_->_deserialize_body(buf); return this_; } Modified: trunk/x10.runtime/src-cpp/x10/runtime/Thread.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/runtime/Thread.h 2009-10-17 18:48:51 UTC (rev 11518) +++ trunk/x10.runtime/src-cpp/x10/runtime/Thread.h 2009-10-17 19:38:57 UTC (rev 11519) @@ -74,7 +74,7 @@ } template<class T> static x10aux::ref<T> _deserializer(x10aux::deserialization_buffer &buf) { - x10aux::ref<Thread> this_ = new (x10aux::remote_alloc<Thread>()) Thread(); + x10aux::ref<Thread> this_ = new (x10aux::alloc_remote<Thread>()) Thread(); this_->_deserialize_body(buf); return this_; } Modified: trunk/x10.runtime/src-cpp/x10/util/GrowableRail.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/util/GrowableRail.h 2009-10-17 18:48:51 UTC (rev 11518) +++ trunk/x10.runtime/src-cpp/x10/util/GrowableRail.h 2009-10-17 19:38:57 UTC (rev 11519) @@ -45,7 +45,7 @@ } template<class U> static x10aux::ref<U> _deserializer(x10aux::deserialization_buffer &buf) { - x10aux::ref<GrowableRail> this_ = new (x10aux::remote_alloc<GrowableRail>()) GrowableRail(); + x10aux::ref<GrowableRail> this_ = new (x10aux::alloc_remote<GrowableRail>()) GrowableRail(); this_->_deserialize_body(buf); return this_; } Modified: trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicBoolean.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicBoolean.h 2009-10-17 18:48:51 UTC (rev 11518) +++ trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicBoolean.h 2009-10-17 19:38:57 UTC (rev 11519) @@ -43,7 +43,7 @@ } template<class T> static x10aux::ref<T> _deserializer(x10aux::deserialization_buffer &buf) { - x10aux::ref<AtomicBoolean> this_ = new (x10aux::remote_alloc<AtomicBoolean>()) AtomicBoolean(); + x10aux::ref<AtomicBoolean> this_ = new (x10aux::alloc_remote<AtomicBoolean>()) AtomicBoolean(); this_->_deserialize_body(buf); return this_; } Modified: trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicInteger.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicInteger.h 2009-10-17 18:48:51 UTC (rev 11518) +++ trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicInteger.h 2009-10-17 19:38:57 UTC (rev 11519) @@ -43,7 +43,7 @@ } template<class T> static x10aux::ref<T> _deserializer(x10aux::deserialization_buffer &buf) { - x10aux::ref<AtomicInteger> this_ = new (x10aux::remote_alloc<AtomicInteger>()) AtomicInteger(); + x10aux::ref<AtomicInteger> this_ = new (x10aux::alloc_remote<AtomicInteger>()) AtomicInteger(); this_->_deserialize_body(buf); return this_; } Modified: trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicLong.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicLong.h 2009-10-17 18:48:51 UTC (rev 11518) +++ trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicLong.h 2009-10-17 19:38:57 UTC (rev 11519) @@ -43,7 +43,7 @@ } template<class T> static x10aux::ref<T> _deserializer(x10aux::deserialization_buffer &buf) { - x10aux::ref<AtomicLong> this_ = new (x10aux::remote_alloc<AtomicLong>()) AtomicLong(); + x10aux::ref<AtomicLong> this_ = new (x10aux::alloc_remote<AtomicLong>()) AtomicLong(); this_->_deserialize_body(buf); return this_; } Modified: trunk/x10.runtime/src-cpp/x10aux/alloc.h =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/alloc.h 2009-10-17 18:48:51 UTC (rev 11518) +++ trunk/x10.runtime/src-cpp/x10aux/alloc.h 2009-10-17 19:38:57 UTC (rev 11519) @@ -66,11 +66,11 @@ return ret; } - // Allocate an object with a void* prepended to it - template<class T> T* remote_alloc() { + // Allocate an object with an x10_addr_t prepended to it + template<class T> T* alloc_remote() { _M_("Allocating a remote object of type " << TYPENAME(T)); - T* ret = alloc<T>(sizeof(T)+sizeof(void*)); - return (T*)(((char*)ret)+sizeof(void*)); + T* ret = alloc<T>(sizeof(T)+sizeof(x10_addr_t)); + return (T*)(((char*)ret)+sizeof(x10_addr_t)); } template<class T> T* realloc(T* src, size_t dsz) { @@ -101,6 +101,13 @@ #endif } + // Deallocate an object with an x10_addr_t prepended to it + template<class T> void dealloc_remote(const T* obj_) { + _M_("Freeing a remote object of type " << TYPENAME(T)); + const T* obj = (const T*)(((const char*)obj_)-sizeof(x10_addr_t)); + dealloc(obj); + } + } #endif Modified: trunk/x10.runtime/src-cpp/x10aux/config.h =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/config.h 2009-10-17 18:48:51 UTC (rev 11518) +++ trunk/x10.runtime/src-cpp/x10aux/config.h 2009-10-17 19:38:57 UTC (rev 11519) @@ -106,6 +106,8 @@ namespace x10aux { + typedef x10_ulong x10_addr_t; + extern bool init_config_bools_done; void init_config_bools (void); extern bool use_ansi_colors_; Modified: trunk/x10.runtime/src-cpp/x10aux/ref.h =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/ref.h 2009-10-17 18:48:51 UTC (rev 11518) +++ trunk/x10.runtime/src-cpp/x10aux/ref.h 2009-10-17 19:38:57 UTC (rev 11519) @@ -12,12 +12,14 @@ namespace x10aux { - typedef x10_ulong x10_addr_t; + inline x10_addr_t get_remote_ref(void *obj) { + return *(x10_addr_t*)(((char*)obj)-sizeof(x10_addr_t)); + } + inline void set_remote_ref(void *obj, x10_addr_t ref) { + *(x10_addr_t*)(((char*)obj)-sizeof(x10_addr_t)) = ref; + } struct remote_ref { - static void* get_remote_ref (void *obj) { return *(void**)(((char*)obj)-sizeof(void*)); } - static void set_remote_ref (void *obj, void *ref) { *(void**)(((char*)obj)-sizeof(void*)) = ref; } - //static bool is_remote (void *ref) { return ((size_t)ref) & 1; } //static remote_ref *strip (void *ref) { return (remote_ref*)(((size_t)ref) & ~1); } //static void *mask (remote_ref *ref) { return (void*)(((size_t)ref) | 1); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ipe...@us...> - 2009-10-19 02:33:32
|
Revision: 11526 http://x10.svn.sourceforge.net/x10/?rev=11526&view=rev Author: ipeshansky Date: 2009-10-19 02:33:24 +0000 (Mon, 19 Oct 2009) Log Message: ----------- Code size and build time optimizations: - Outline serialization methods and constructors from headers. - Outline boxing/unboxing cast specializations. - Outline copyTo support methods in Rail. Modified Paths: -------------- trunk/x10.compiler/src/x10cpp/visit/Emitter.java trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java 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/lang/Box.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/runtime/Deque.cc trunk/x10.runtime/src-cpp/x10/runtime/Deque.h trunk/x10.runtime/src-cpp/x10/runtime/Thread.cc trunk/x10.runtime/src-cpp/x10/runtime/Thread.h 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/class_cast.cc trunk/x10.runtime/src-cpp/x10aux/class_cast.h Modified: trunk/x10.compiler/src/x10cpp/visit/Emitter.java =================================================================== --- trunk/x10.compiler/src/x10cpp/visit/Emitter.java 2009-10-18 23:01:07 UTC (rev 11525) +++ trunk/x10.compiler/src/x10cpp/visit/Emitter.java 2009-10-19 02:33:24 UTC (rev 11526) @@ -1067,14 +1067,18 @@ if (!type.flags().isAbstract()) { // _deserialize() h.write("public: template<class __T> static "); - h.write(make_ref("__T")+" "+DESERIALIZER_METHOD+"("+DESERIALIZATION_BUFFER+"& buf) {"); - h.newline(4); h.begin(0); - h.write(make_ref(klass)+" this_ = "+ - "new (x10aux::alloc_remote"+chevrons(klass)+"()) "+klass+"();"); h.newline(); - h.write("this_->"+DESERIALIZE_BODY_METHOD+"(buf);"); h.newline(); - h.write("return this_;"); - h.end(); h.newline(); - h.write("}"); h.newline(); h.forceNewline(); + h.write(make_ref("__T")+" "+DESERIALIZER_METHOD+"("+DESERIALIZATION_BUFFER+"& buf);"); + h.newline(); h.forceNewline(); + printTemplateSignature(ct.typeArguments(), w); + w.write("template<class __T> "); + w.write(make_ref("__T")+" "+klass+"::"+DESERIALIZER_METHOD+"("+DESERIALIZATION_BUFFER+"& buf) {"); + w.newline(4); w.begin(0); + w.write(make_ref(klass)+" this_ = "+ + "new (x10aux::alloc_remote"+chevrons(klass)+"()) "+klass+"();"); w.newline(); + w.write("this_->"+DESERIALIZE_BODY_METHOD+"(buf);"); w.newline(); + w.write("return this_;"); + w.end(); w.newline(); + w.write("}"); w.newline(); w.forceNewline(); } if (type.flags().isFinal()) { Modified: trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java =================================================================== --- trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java 2009-10-18 23:01:07 UTC (rev 11525) +++ trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java 2009-10-19 02:33:24 UTC (rev 11526) @@ -1910,29 +1910,36 @@ sw.pushCurrentStream(h); emitter.printHeader(dec, sw, tr, false, true, container.isX10Struct() ? typeName : make_ref(typeName)); sw.popCurrentStream(); - h.allowBreak(0, " "); h.write("{"); h.newline(4); h.begin(0); + ClassifiedStream b = h; + if (!container.isX10Struct()) { + h.write(";"); + h.newline(); h.forceNewline(); + b = sw.body(); + emitter.printHeader(dec, sw, tr, true, true, make_ref(typeName)); + } + b.allowBreak(0, " "); b.write("{"); b.newline(4); b.begin(0); if (container.isX10Struct()) { - h.write(typeName+" this_; "); h.newline(); - h.write(CONSTRUCTOR+"(&this_"); - if (!dec.formals().isEmpty()) h.write(", "); + b.write(typeName+" this_; "); b.newline(); + b.write(CONSTRUCTOR+"(&this_"); + if (!dec.formals().isEmpty()) b.write(", "); } else { - h.write(make_ref(typeName)+" this_ = "+ - "new (x10aux::alloc"+chevrons(typeName)+"()) "+typeName+"();"); h.newline(); - h.write("this_->"+CONSTRUCTOR+"("); + b.write(make_ref(typeName)+" this_ = "+ + "new (x10aux::alloc"+chevrons(typeName)+"()) "+typeName+"();"); b.newline(); + b.write("this_->"+CONSTRUCTOR+"("); } for (Iterator<Formal> i = dec.formals().iterator(); i.hasNext(); ) { Formal f = i.next(); - h.write(mangled_non_method_name(f.name().id().toString())); + b.write(mangled_non_method_name(f.name().id().toString())); if (i.hasNext()) { - h.write(","); - h.allowBreak(0, " "); + b.write(","); + b.allowBreak(0, " "); } } - h.write(");"); h.newline(); - h.write("return this_;"); - h.end(); h.newline(); - h.write("}"); h.newline(); - h.forceNewline(); + b.write(");"); b.newline(); + b.write("return this_;"); + b.end(); b.newline(); + b.write("}"); b.newline(); + b.forceNewline(); } sw.newline(); sw.forceNewline(); Modified: trunk/x10.runtime/src-cpp/x10/io/File__NativeFile.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/io/File__NativeFile.cc 2009-10-18 23:01:07 UTC (rev 11525) +++ trunk/x10.runtime/src-cpp/x10/io/File__NativeFile.cc 2009-10-19 02:33:24 UTC (rev 11526) @@ -20,6 +20,14 @@ return (new (x10aux::alloc<File__NativeFile>()) File__NativeFile())->_constructor(s); } +void File__NativeFile::_serialize_body(serialization_buffer &buf, addr_map &m) { + this->Ref::_serialize_body(buf, m); +} + +void File__NativeFile::_deserialize_body(deserialization_buffer& buf) { + this->Ref::_deserialize_body(buf); +} + const x10aux::serialization_id_t File__NativeFile::_serialization_id = x10aux::DeserializationDispatcher::addDeserializer(File__NativeFile::_deserializer<Object>); Modified: trunk/x10.runtime/src-cpp/x10/io/File__NativeFile.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/io/File__NativeFile.h 2009-10-18 23:01:07 UTC (rev 11525) +++ trunk/x10.runtime/src-cpp/x10/io/File__NativeFile.h 2009-10-19 02:33:24 UTC (rev 11526) @@ -37,19 +37,11 @@ virtual x10aux::serialization_id_t _get_serialization_id() { return _serialization_id; }; - virtual void _serialize_body(x10aux::serialization_buffer &buf, x10aux::addr_map &m) { - this->x10::lang::Ref::_serialize_body(buf, m); - } + virtual void _serialize_body(x10aux::serialization_buffer &buf, x10aux::addr_map &m); - template<class T> static x10aux::ref<T> _deserializer(x10aux::deserialization_buffer &buf) { - x10aux::ref<File__NativeFile> this_ = new (x10aux::alloc_remote<File__NativeFile>()) File__NativeFile(); - this_->_deserialize_body(buf); - return this_; - } + template<class T> static x10aux::ref<T> _deserializer(x10aux::deserialization_buffer &buf); - void _deserialize_body(x10aux::deserialization_buffer& buf) { - this->x10::lang::Ref::_deserialize_body(buf); - } + virtual void _deserialize_body(x10aux::deserialization_buffer& buf); virtual x10aux::ref<x10::lang::String> getPath() { return path; } @@ -77,6 +69,12 @@ }; + template<class T> x10aux::ref<T> File__NativeFile::_deserializer(x10aux::deserialization_buffer &buf) { + x10aux::ref<File__NativeFile> this_ = new (x10aux::alloc_remote<File__NativeFile>()) File__NativeFile(); + this_->_deserialize_body(buf); + return this_; + } + } } Modified: trunk/x10.runtime/src-cpp/x10/lang/Box.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Box.h 2009-10-18 23:01:07 UTC (rev 11525) +++ trunk/x10.runtime/src-cpp/x10/lang/Box.h 2009-10-19 02:33:24 UTC (rev 11526) @@ -24,11 +24,11 @@ public: RTT_H_DECLS_CLASS; - static x10aux::ref<Box<T> > _make(T contents_) { + static inline x10aux::ref<Box<T> > _make(T contents_) { return (new (x10aux::alloc<Box<T> >())Box<T>())->_constructor(contents_); } - x10aux::ref<Box<T> > _constructor(T contents_) { + inline x10aux::ref<Box<T> > _constructor(T contents_) { this->Ref::_constructor(); FMGL(value) = contents_; return this; @@ -36,21 +36,13 @@ static const x10aux::serialization_id_t _serialization_id; - virtual x10aux::serialization_id_t _get_serialization_id() { return _serialization_id; }; + virtual inline x10aux::serialization_id_t _get_serialization_id() { return _serialization_id; } - virtual void _serialize_body(x10aux::serialization_buffer &buf, x10aux::addr_map &m) { - this->x10::lang::Ref::_serialize_body(buf, m); - } + virtual void _serialize_body(x10aux::serialization_buffer &buf, x10aux::addr_map &m); - template<class U> static x10aux::ref<U> _deserializer(x10aux::deserialization_buffer &buf) { - x10aux::ref<Box> this_ = new (x10aux::alloc_remote<Box>()) Box(); - this_->_deserialize_body(buf); - return this_; - } + template<class U> static x10aux::ref<U> _deserializer(x10aux::deserialization_buffer &buf); - void _deserialize_body(x10aux::deserialization_buffer& buf) { - this->x10::lang::Ref::_deserialize_body(buf); - } + virtual void _deserialize_body(x10aux::deserialization_buffer& buf); virtual T get() { return FMGL(value); @@ -69,6 +61,20 @@ template<class T> const x10aux::serialization_id_t Box<T>::_serialization_id = x10aux::DeserializationDispatcher::addDeserializer(Box<T>::template _deserializer<Object>); + template<class T> void Box<T>::_serialize_body(x10aux::serialization_buffer &buf, x10aux::addr_map &m) { + this->x10::lang::Ref::_serialize_body(buf, m); + } + + template<class T> template<class U> x10aux::ref<U> Box<T>::_deserializer(x10aux::deserialization_buffer &buf) { + x10aux::ref<Box> this_ = new (x10aux::alloc_remote<Box>()) Box(); + this_->_deserialize_body(buf); + return this_; + } + + template<class T> void Box<T>::_deserialize_body(x10aux::deserialization_buffer& buf) { + this->x10::lang::Ref::_deserialize_body(buf); + } + template <> class Box<void> : public Ref { }; Modified: trunk/x10.runtime/src-cpp/x10/lang/Rail.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Rail.cc 2009-10-18 23:01:07 UTC (rev 11525) +++ trunk/x10.runtime/src-cpp/x10/lang/Rail.cc 2009-10-19 02:33:24 UTC (rev 11526) @@ -4,6 +4,8 @@ #include <x10/lang/Ref.h> #include <x10/lang/Rail.h> +#include <x10/runtime/Runtime.h> +#include <x10/runtime/FinishStates.h> using namespace x10aux; @@ -24,3 +26,30 @@ } } } + +void x10::lang::Rail_notifyEnclosingFinish(deserialization_buffer& buf) { + x10::runtime::RID rid = buf.read<x10::runtime::RID>(); + ref<x10::runtime::Runtime> rt = x10::runtime::Runtime::runtime(); + ref<Object> fs = rt->FMGL(finishStates)->get(rid); + (fs.operator->()->*(findITable<x10::runtime::FinishState>(fs->_getITables())->incr))(); + (fs.operator->()->*(findITable<x10::runtime::FinishState>(fs->_getITables())->notifySubActivityTermination))(); +} + +void x10::lang::Rail_serializeAndSend(Place dst_place_, ref<Object> df, serialization_id_t _id, void* data, size_t size) { + x10_int dst_place = dst_place_.FMGL(id); + serialization_buffer buf; + addr_map m; + buf.realloc_func = x10aux::put_realloc; + x10_byte code = 1; + buf.write(code, m); + buf.write(df, m); + ref<x10::runtime::Runtime> rt = x10::runtime::Runtime::runtime(); + ref<Object> fs = rt->currentState(); + (fs.operator->()->*(findITable<x10::runtime::FinishState>(fs->_getITables())->notifySubActivitySpawn))(dst_place_); + x10::runtime::Runtime::runtime()->FMGL(finishStates)->put(fs); + x10::runtime::RID rid = (fs.operator->()->*(findITable<x10::runtime::FinishState>(fs->_getITables())->rid))(); + buf.write(rid, m); + x10aux::send_put(dst_place, _id, buf, data, size); +} + +// vim:tabstop=4:shiftwidth=4:expandtab Modified: trunk/x10.runtime/src-cpp/x10/lang/Rail.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Rail.h 2009-10-18 23:01:07 UTC (rev 11525) +++ trunk/x10.runtime/src-cpp/x10/lang/Rail.h 2009-10-19 02:33:24 UTC (rev 11526) @@ -132,6 +132,10 @@ virtual x10aux::ref<String> toString() { return x10aux::railToString<T,Rail<T> >(this); } }; + void Rail_notifyEnclosingFinish(x10aux::deserialization_buffer& buf); + + void Rail_serializeAndSend(x10::lang::Place dst_place_, x10aux::ref<x10::lang::Object> df, x10aux::serialization_id_t _id, void* data, size_t size); + template<class T> x10aux::RuntimeType Rail<T>::rtt; template<> class Rail<void> { @@ -148,8 +152,6 @@ // #include <x10/lang/System.h> // causes cycle #include <x10/lang/VoidFun_0_0.h> #include <x10/lang/Fun_0_0.h> -#include <x10/runtime/Runtime.h> -#include <x10/runtime/FinishStates.h> #include <x10aux/itables.h> #ifndef X10_LANG_RAIL_H_IMPLEMENTATION #define X10_LANG_RAIL_H_IMPLEMENTATION @@ -270,11 +272,7 @@ case 1: { x10aux::ref<Object> bf = buf.read<x10aux::ref<Fun_0_0<R> > >(); x10aux::dealloc(bf.operator->()); - x10::runtime::RID rid = buf.read<x10::runtime::RID>(); - x10aux::ref<x10::runtime::Runtime> rt = x10::runtime::Runtime::runtime(); - x10aux::ref<Object> fs = rt->FMGL(finishStates)->get(rid); - (fs.operator->()->*(x10aux::findITable<x10::runtime::FinishState>(fs->_getITables())->incr))(); - (fs.operator->()->*(x10aux::findITable<x10::runtime::FinishState>(fs->_getITables())->notifySubActivityTermination))(); + Rail_notifyEnclosingFinish(buf); break; } // case 2 on death row @@ -330,8 +328,8 @@ template <class T> void Rail<T>::copyTo (x10_int src_off, x10::lang::Place dst_place_, - x10aux::ref<Fun_0_0<x10::util::Pair<x10aux::ref<Rail<T> >, - x10_int> > > dst_finder, + x10aux::ref<Fun_0_0<x10::util::Pair<x10aux::ref<Rail<T> >, + x10_int> > > dst_finder, x10_int len) { typedef x10aux::ref<Rail<T> > R; @@ -359,21 +357,7 @@ } return; } - x10aux::serialization_buffer buf; - x10aux::addr_map m; - buf.realloc_func = x10aux::put_realloc; - x10_byte code = 1; - buf.write(code, m); - buf.write(df, m); - x10aux::ref<x10::runtime::Runtime> rt = x10::runtime::Runtime::runtime(); - x10aux::ref<Object> fs = rt->currentState(); - (fs.operator->()->*(x10aux::findITable<x10::runtime::FinishState>(fs->_getITables())->notifySubActivitySpawn))(dst_place_); - x10::runtime::Runtime::runtime()->FMGL(finishStates)->put(fs); - x10::runtime::RID rid = (fs.operator->()->*(x10aux::findITable<x10::runtime::FinishState>(fs->_getITables())->rid))(); - buf.write(rid, m); - x10aux::send_put(dst_place, _copy_to_serialization_id, - buf, &_data[src_off], len * sizeof(T)); - + Rail_serializeAndSend(dst_place_, df, _copy_to_serialization_id, &_data[src_off], len * sizeof(T)); } Modified: trunk/x10.runtime/src-cpp/x10/lang/Ref.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Ref.cc 2009-10-18 23:01:07 UTC (rev 11525) +++ trunk/x10.runtime/src-cpp/x10/lang/Ref.cc 2009-10-19 02:33:24 UTC (rev 11526) @@ -26,7 +26,7 @@ } x10aux::ref<x10::lang::String> x10::lang::Ref::toString() { - return String::Lit(alloc_printf("%s@%x",this->_type()->name(),(std::size_t)this)); + return String::Lit(alloc_printf("%s@%lx",this->_type()->name(),(std::size_t)this)); } const serialization_id_t Ref::_serialization_id = Modified: trunk/x10.runtime/src-cpp/x10/runtime/Deque.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/runtime/Deque.cc 2009-10-18 23:01:07 UTC (rev 11525) +++ trunk/x10.runtime/src-cpp/x10/runtime/Deque.cc 2009-10-19 02:33:24 UTC (rev 11526) @@ -108,7 +108,15 @@ } return NULL; } - + +void Deque::_serialize_body(serialization_buffer &buf, addr_map &m) { + this->Ref::_serialize_body(buf, m); +} + +void Deque::_deserialize_body(deserialization_buffer& buf) { + this->Ref::_deserialize_body(buf); +} + RTT_CC_DECLS1(Deque, "x10.runtime.Deque", Ref) Modified: trunk/x10.runtime/src-cpp/x10/runtime/Deque.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/runtime/Deque.h 2009-10-18 23:01:07 UTC (rev 11525) +++ trunk/x10.runtime/src-cpp/x10/runtime/Deque.h 2009-10-19 02:33:24 UTC (rev 11526) @@ -34,19 +34,11 @@ virtual x10aux::serialization_id_t _get_serialization_id() { return _serialization_id; }; - virtual void _serialize_body(x10aux::serialization_buffer &buf, x10aux::addr_map &m) { - this->x10::lang::Ref::_serialize_body(buf, m); - } + virtual void _serialize_body(x10aux::serialization_buffer &buf, x10aux::addr_map &m); - template<class T> static x10aux::ref<T> _deserializer(x10aux::deserialization_buffer &buf) { - x10aux::ref<Deque> this_ = new (x10aux::alloc_remote<Deque>()) Deque(); - this_->_deserialize_body(buf); - return this_; - } + template<class T> static x10aux::ref<T> _deserializer(x10aux::deserialization_buffer &buf); - void _deserialize_body(x10aux::deserialization_buffer& buf) { - this->x10::lang::Ref::_deserialize_body(buf); - } + virtual void _deserialize_body(x10aux::deserialization_buffer& buf); private: struct Slots { @@ -157,6 +149,12 @@ */ volatile int base; }; + + template<class T> x10aux::ref<T> Deque::_deserializer(x10aux::deserialization_buffer &buf) { + x10aux::ref<Deque> this_ = new (x10aux::alloc_remote<Deque>()) Deque(); + this_->_deserialize_body(buf); + return this_; + } } } Modified: trunk/x10.runtime/src-cpp/x10/runtime/Thread.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/runtime/Thread.cc 2009-10-18 23:01:07 UTC (rev 11525) +++ trunk/x10.runtime/src-cpp/x10/runtime/Thread.cc 2009-10-19 02:33:24 UTC (rev 11526) @@ -465,6 +465,14 @@ __thread_name = name; } +void Thread::_serialize_body(serialization_buffer &buf, addr_map &m) { + this->Ref::_serialize_body(buf, m); +} + +void Thread::_deserialize_body(deserialization_buffer& buf) { + this->Ref::_deserialize_body(buf); +} + RTT_CC_DECLS1(Thread, "x10.runtime.Thread", Ref) // vim:tabstop=4:shiftwidth=4:expandtab Modified: trunk/x10.runtime/src-cpp/x10/runtime/Thread.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/runtime/Thread.h 2009-10-18 23:01:07 UTC (rev 11525) +++ trunk/x10.runtime/src-cpp/x10/runtime/Thread.h 2009-10-19 02:33:24 UTC (rev 11526) @@ -69,19 +69,11 @@ virtual x10aux::serialization_id_t _get_serialization_id() { return _serialization_id; }; - virtual void _serialize_body(x10aux::serialization_buffer &buf, x10aux::addr_map &m) { - this->x10::lang::Ref::_serialize_body(buf, m); - } + virtual void _serialize_body(x10aux::serialization_buffer &buf, x10aux::addr_map &m); - template<class T> static x10aux::ref<T> _deserializer(x10aux::deserialization_buffer &buf) { - x10aux::ref<Thread> this_ = new (x10aux::alloc_remote<Thread>()) Thread(); - this_->_deserialize_body(buf); - return this_; - } + template<class T> static x10aux::ref<T> _deserializer(x10aux::deserialization_buffer &buf); - void _deserialize_body(x10aux::deserialization_buffer& buf) { - this->x10::lang::Ref::_deserialize_body(buf); - } + virtual void _deserialize_body(x10aux::deserialization_buffer& buf); // destructor ~Thread(); @@ -249,6 +241,12 @@ static pthread_key_t __thread_mapper; static x10_boolean __thread_mapper_inited; }; + + template<class T> x10aux::ref<T> Thread::_deserializer(x10aux::deserialization_buffer &buf) { + x10aux::ref<Thread> this_ = new (x10aux::alloc_remote<Thread>()) Thread(); + this_->_deserialize_body(buf); + return this_; + } } } Modified: trunk/x10.runtime/src-cpp/x10/util/GrowableRail.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/util/GrowableRail.h 2009-10-18 23:01:07 UTC (rev 11525) +++ trunk/x10.runtime/src-cpp/x10/util/GrowableRail.h 2009-10-19 02:33:24 UTC (rev 11526) @@ -40,19 +40,11 @@ virtual x10aux::serialization_id_t _get_serialization_id() { return _serialization_id; }; - virtual void _serialize_body(x10aux::serialization_buffer &buf, x10aux::addr_map &m) { - this->x10::lang::Ref::_serialize_body(buf, m); - } + virtual void _serialize_body(x10aux::serialization_buffer &buf, x10aux::addr_map &m); - template<class U> static x10aux::ref<U> _deserializer(x10aux::deserialization_buffer &buf) { - x10aux::ref<GrowableRail> this_ = new (x10aux::alloc_remote<GrowableRail>()) GrowableRail(); - this_->_deserialize_body(buf); - return this_; - } + template<class U> static x10aux::ref<U> _deserializer(x10aux::deserialization_buffer &buf); - void _deserialize_body(x10aux::deserialization_buffer& buf) { - this->x10::lang::Ref::_deserialize_body(buf); - } + virtual void _deserialize_body(x10aux::deserialization_buffer& buf); T set(T v, x10_int i); @@ -188,6 +180,20 @@ template<class T> x10aux::RuntimeType GrowableRail<T>::rtt; + template<class T> void GrowableRail<T>::_serialize_body(x10aux::serialization_buffer &buf, x10aux::addr_map &m) { + this->x10::lang::Ref::_serialize_body(buf, m); + } + + template<class T> template<class U> x10aux::ref<U> GrowableRail<T>::_deserializer(x10aux::deserialization_buffer &buf) { + x10aux::ref<GrowableRail> this_ = new (x10aux::alloc_remote<GrowableRail>()) GrowableRail(); + this_->_deserialize_body(buf); + return this_; + } + + template<class T> void GrowableRail<T>::_deserialize_body(x10aux::deserialization_buffer& buf) { + this->x10::lang::Ref::_deserialize_body(buf); + } + template<class T> const x10aux::serialization_id_t GrowableRail<T>::_serialization_id = x10aux::DeserializationDispatcher::addDeserializer(GrowableRail<T>::template _deserializer<Object>); Modified: trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicBoolean.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicBoolean.cc 2009-10-18 23:01:07 UTC (rev 11525) +++ trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicBoolean.cc 2009-10-19 02:33:24 UTC (rev 11526) @@ -23,6 +23,14 @@ return this_; } +void AtomicBoolean::_serialize_body(x10aux::serialization_buffer &buf, x10aux::addr_map &m) { + this->Ref::_serialize_body(buf, m); +} + +void AtomicBoolean::_deserialize_body(x10aux::deserialization_buffer& buf) { + this->Ref::_deserialize_body(buf); +} + const x10aux::serialization_id_t AtomicBoolean::_serialization_id = x10aux::DeserializationDispatcher::addDeserializer(AtomicBoolean::_deserializer<Object>); Modified: trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicBoolean.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicBoolean.h 2009-10-18 23:01:07 UTC (rev 11525) +++ trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicBoolean.h 2009-10-19 02:33:24 UTC (rev 11526) @@ -38,23 +38,15 @@ virtual x10aux::serialization_id_t _get_serialization_id() { return _serialization_id; }; - virtual void _serialize_body(x10aux::serialization_buffer &buf, x10aux::addr_map &m) { - this->x10::lang::Ref::_serialize_body(buf, m); - } + virtual void _serialize_body(x10aux::serialization_buffer &buf, x10aux::addr_map &m); - template<class T> static x10aux::ref<T> _deserializer(x10aux::deserialization_buffer &buf) { - x10aux::ref<AtomicBoolean> this_ = new (x10aux::alloc_remote<AtomicBoolean>()) AtomicBoolean(); - this_->_deserialize_body(buf); - return this_; - } + template<class T> static x10aux::ref<T> _deserializer(x10aux::deserialization_buffer &buf); - void _deserialize_body(x10aux::deserialization_buffer& buf) { - this->x10::lang::Ref::_deserialize_body(buf); - } + virtual void _deserialize_body(x10aux::deserialization_buffer& buf); private: /* - * Am x10_int that is constrained to a 0/1 and interpret as an x10_ boolean. + * An x10_int that is constrained to a 0/1 and interpreted as an x10_boolean. * We do this so that we know that compareAndSet_32 can work on the whole memory word. */ volatile x10_int _val; @@ -89,6 +81,12 @@ return x10aux::boolean_utils::toString(_val); } }; + + template<class T> x10aux::ref<T> AtomicBoolean::_deserializer(x10aux::deserialization_buffer &buf) { + x10aux::ref<AtomicBoolean> this_ = new (x10aux::alloc_remote<AtomicBoolean>()) AtomicBoolean(); + this_->_deserialize_body(buf); + return this_; + } } } } Modified: trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicInteger.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicInteger.cc 2009-10-18 23:01:07 UTC (rev 11525) +++ trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicInteger.cc 2009-10-19 02:33:24 UTC (rev 11526) @@ -23,6 +23,14 @@ return this_; } +void AtomicInteger::_serialize_body(x10aux::serialization_buffer &buf, x10aux::addr_map &m) { + this->Ref::_serialize_body(buf, m); +} + +void AtomicInteger::_deserialize_body(x10aux::deserialization_buffer& buf) { + this->Ref::_deserialize_body(buf); +} + const x10aux::serialization_id_t AtomicInteger::_serialization_id = x10aux::DeserializationDispatcher::addDeserializer(AtomicInteger::_deserializer<Object>); Modified: trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicInteger.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicInteger.h 2009-10-18 23:01:07 UTC (rev 11525) +++ trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicInteger.h 2009-10-19 02:33:24 UTC (rev 11526) @@ -38,19 +38,11 @@ virtual x10aux::serialization_id_t _get_serialization_id() { return _serialization_id; }; - virtual void _serialize_body(x10aux::serialization_buffer &buf, x10aux::addr_map &m) { - this->x10::lang::Ref::_serialize_body(buf, m); - } + virtual void _serialize_body(x10aux::serialization_buffer &buf, x10aux::addr_map &m); - template<class T> static x10aux::ref<T> _deserializer(x10aux::deserialization_buffer &buf) { - x10aux::ref<AtomicInteger> this_ = new (x10aux::alloc_remote<AtomicInteger>()) AtomicInteger(); - this_->_deserialize_body(buf); - return this_; - } + template<class T> static x10aux::ref<T> _deserializer(x10aux::deserialization_buffer &buf); - void _deserialize_body(x10aux::deserialization_buffer& buf) { - this->x10::lang::Ref::_deserialize_body(buf); - } + virtual void _deserialize_body(x10aux::deserialization_buffer& buf); private: volatile x10_int _val; @@ -121,6 +113,12 @@ return (x10_double)_val; } }; + + template<class T> x10aux::ref<T> AtomicInteger::_deserializer(x10aux::deserialization_buffer &buf) { + x10aux::ref<AtomicInteger> this_ = new (x10aux::alloc_remote<AtomicInteger>()) AtomicInteger(); + this_->_deserialize_body(buf); + return this_; + } } } } Modified: trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicLong.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicLong.cc 2009-10-18 23:01:07 UTC (rev 11525) +++ trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicLong.cc 2009-10-19 02:33:24 UTC (rev 11526) @@ -23,6 +23,14 @@ return this_; } +void AtomicLong::_serialize_body(x10aux::serialization_buffer &buf, x10aux::addr_map &m) { + this->Ref::_serialize_body(buf, m); +} + +void AtomicLong::_deserialize_body(x10aux::deserialization_buffer& buf) { + this->Ref::_deserialize_body(buf); +} + const x10aux::serialization_id_t AtomicLong::_serialization_id = x10aux::DeserializationDispatcher::addDeserializer(AtomicLong::_deserializer<Object>); Modified: trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicLong.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicLong.h 2009-10-18 23:01:07 UTC (rev 11525) +++ trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicLong.h 2009-10-19 02:33:24 UTC (rev 11526) @@ -38,19 +38,11 @@ virtual x10aux::serialization_id_t _get_serialization_id() { return _serialization_id; }; - virtual void _serialize_body(x10aux::serialization_buffer &buf, x10aux::addr_map &m) { - this->x10::lang::Ref::_serialize_body(buf, m); - } + virtual void _serialize_body(x10aux::serialization_buffer &buf, x10aux::addr_map &m); - template<class T> static x10aux::ref<T> _deserializer(x10aux::deserialization_buffer &buf) { - x10aux::ref<AtomicLong> this_ = new (x10aux::alloc_remote<AtomicLong>()) AtomicLong(); - this_->_deserialize_body(buf); - return this_; - } + template<class T> static x10aux::ref<T> _deserializer(x10aux::deserialization_buffer &buf); - void _deserialize_body(x10aux::deserialization_buffer& buf) { - this->x10::lang::Ref::_deserialize_body(buf); - } + virtual void _deserialize_body(x10aux::deserialization_buffer& buf); private: volatile x10_long _val; @@ -121,6 +113,12 @@ return (x10_double)_val; } }; + + template<class T> x10aux::ref<T> AtomicLong::_deserializer(x10aux::deserialization_buffer &buf) { + x10aux::ref<AtomicLong> this_ = new (x10aux::alloc_remote<AtomicLong>()) AtomicLong(); + this_->_deserialize_body(buf); + return this_; + } } } } Modified: trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicReference.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicReference.cc 2009-10-18 23:01:07 UTC (rev 11525) +++ trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicReference.cc 2009-10-19 02:33:24 UTC (rev 11526) @@ -1,3 +1,9 @@ +/* + * (c) Copyright IBM Corporation 2009 + * + * This file is part of XRX/C++ native layer implementation. + */ + #include <x10/util/concurrent/atomic/AtomicReference.h> using namespace x10aux; Modified: trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicReference.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicReference.h 2009-10-18 23:01:07 UTC (rev 11525) +++ trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicReference.h 2009-10-19 02:33:24 UTC (rev 11526) @@ -33,10 +33,28 @@ public: RTT_H_DECLS_CLASS; - static x10aux::ref<AtomicReference<T > > _make(); - static x10aux::ref<AtomicReference<T > > _make(T val); + static x10aux::ref<AtomicReference<T> > _make(); + static x10aux::ref<AtomicReference<T> > _make(T val); private: + x10aux::ref<AtomicReference<T> > _constructor(x10::lang::Ref *data) { + this->x10::lang::Ref::_constructor(); + _data = data; + return this; + } + + public: + static const x10aux::serialization_id_t _serialization_id; + + virtual x10aux::serialization_id_t _get_serialization_id() { return _serialization_id; }; + + virtual void _serialize_body(x10aux::serialization_buffer &buf, x10aux::addr_map &m); + + template<class U> static x10aux::ref<U> _deserializer(x10aux::deserialization_buffer &buf); + + virtual void _deserialize_body(x10aux::deserialization_buffer& buf); + + private: volatile x10::lang::Ref* _data; public: @@ -53,16 +71,16 @@ virtual x10aux::ref<x10::lang::String> toString(); }; - template<class T> x10aux::ref<AtomicReference<T > > AtomicReference<T >::_make() { - x10aux::ref<AtomicReference<T > > result = (new (x10aux::alloc<AtomicReference<T > >())AtomicReference<T >()); - result->_data = NULL; + template<class T> x10aux::ref<AtomicReference<T> > AtomicReference<T>::_make() { + x10aux::ref<AtomicReference<T> > result = (new (x10aux::alloc<AtomicReference<T> >())AtomicReference<T>()); + result->_constructor(NULL); return result; } - template<class T> x10aux::ref<AtomicReference<T > > AtomicReference<T >::_make(T val) { - x10aux::ref<AtomicReference<T > > result = (new (x10aux::alloc<AtomicReference<T > >())AtomicReference<T >()); + template<class T> x10aux::ref<AtomicReference<T> > AtomicReference<T>::_make(T val) { + x10aux::ref<AtomicReference<T> > result = (new (x10aux::alloc<AtomicReference<T> >())AtomicReference<T>()); x10::lang::Ref *tmp = val.get(); /* Does two things: gets backing S* ptr from ref<S> and upcasts S* to Ref* */ - result->_data = tmp; + result->_constructor(tmp); return result; } @@ -98,20 +116,42 @@ return res; } - template<class T> x10aux::ref<x10::lang::String> AtomicReference<T >::toString() { + template<class T> x10aux::ref<x10::lang::String> AtomicReference<T>::toString() { x10::lang::Ref* tmp = (x10::lang::Ref*)_data; /* drops volatile */ x10aux::ref<x10::lang::Ref> tmp2 = tmp; /* boxes to ref */ T tmp3 = tmp2; /* downcast from ref<Ref> to T (ref<S) */ return x10aux::safe_to_string(tmp3); } - template<class T> void AtomicReference<T >::_initRTT() { + template<class T> void AtomicReference<T>::_initRTT() { rtt.canonical = &rtt; x10::util::concurrent::atomic::_initRTTHelper_AtomicReference(&rtt, x10aux::getRTT<T>()); } - template<class T> x10aux::RuntimeType AtomicReference<T >::rtt; + template<class T> x10aux::RuntimeType AtomicReference<T>::rtt; + template<class T> void + AtomicReference<T>::_serialize_body(x10aux::serialization_buffer &buf, x10aux::addr_map &m) { + this->Ref::_serialize_body(buf, m); + } + + template<class T> void + AtomicReference<T>::_deserialize_body(x10aux::deserialization_buffer& buf) { + this->Ref::_deserialize_body(buf); + } + + template<class T> template<class U> x10aux::ref<U> + AtomicReference<T>::_deserializer(x10aux::deserialization_buffer &buf) { + x10aux::ref<AtomicReference<T> > this_ = + new (x10aux::alloc_remote<AtomicReference<T> >()) AtomicReference<T> (); + this_->_deserialize_body(buf); + return this_; + } + + template<class T> + const x10aux::serialization_id_t AtomicReference<T>::_serialization_id = + x10aux::DeserializationDispatcher::addDeserializer(AtomicReference<T>::template _deserializer<Object>); + template<> class AtomicReference<void> { public: static x10aux::RuntimeType rtt; Modified: trunk/x10.runtime/src-cpp/x10aux/class_cast.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/class_cast.cc 2009-10-18 23:01:07 UTC (rev 11525) +++ trunk/x10.runtime/src-cpp/x10aux/class_cast.cc 2009-10-19 02:33:24 UTC (rev 11526) @@ -13,4 +13,81 @@ throwException<x10::lang::ClassCastException>(); } +// Box primitives on casting to interfaces +#define PRIMITIVE_INTERFACE_CAST(T,F) \ + GPUSAFE ref<T> ClassCastNotBothRef<ref<T>,F>::_ (F obj, bool checked) { \ + _CAST_(TYPENAME(F) <<" converted to "<<TYPENAME(ref<T>)); \ + return class_cast<ref<T> >(box(obj), checked); \ + } +PRIMITIVE_INTERFACE_CAST(x10::lang::Object, x10_boolean) +PRIMITIVE_INTERFACE_CAST(x10::lang::Object, x10_byte) +PRIMITIVE_INTERFACE_CAST(x10::lang::Object, x10_char) +PRIMITIVE_INTERFACE_CAST(x10::lang::Object, x10_short) +PRIMITIVE_INTERFACE_CAST(x10::lang::Object, x10_int) +PRIMITIVE_INTERFACE_CAST(x10::lang::Object, x10_long) +PRIMITIVE_INTERFACE_CAST(x10::lang::Object, x10_ubyte) +PRIMITIVE_INTERFACE_CAST(x10::lang::Object, x10_ushort) +PRIMITIVE_INTERFACE_CAST(x10::lang::Object, x10_uint) +PRIMITIVE_INTERFACE_CAST(x10::lang::Object, x10_ulong) +PRIMITIVE_INTERFACE_CAST(x10::lang::Object, x10_float) +PRIMITIVE_INTERFACE_CAST(x10::lang::Object, x10_double) +PRIMITIVE_INTERFACE_CAST(x10::lang::Ref, x10_boolean) +PRIMITIVE_INTERFACE_CAST(x10::lang::Ref, x10_byte) +PRIMITIVE_INTERFACE_CAST(x10::lang::Ref, x10_char) +PRIMITIVE_INTERFACE_CAST(x10::lang::Ref, x10_short) +PRIMITIVE_INTERFACE_CAST(x10::lang::Ref, x10_int) +PRIMITIVE_INTERFACE_CAST(x10::lang::Ref, x10_long) +PRIMITIVE_INTERFACE_CAST(x10::lang::Ref, x10_ubyte) +PRIMITIVE_INTERFACE_CAST(x10::lang::Ref, x10_ushort) +PRIMITIVE_INTERFACE_CAST(x10::lang::Ref, x10_uint) +PRIMITIVE_INTERFACE_CAST(x10::lang::Ref, x10_ulong) +PRIMITIVE_INTERFACE_CAST(x10::lang::Ref, x10_float) +PRIMITIVE_INTERFACE_CAST(x10::lang::Ref, x10_double) + +// Unbox primitives on down-casting from interfaces +#define INTERFACE_PRIMITIVE_CAST(T,F) \ + GPUSAFE T ClassCastNotBothRef<T,ref<F> >::_ (ref<F> obj, bool checked) { \ + _CAST_(TYPENAME(ref<F>) <<" converted to "<<TYPENAME(T)); \ + return unbox(class_cast<ref<x10::lang::Box<T> > >(obj, checked)); \ + } +INTERFACE_PRIMITIVE_CAST(x10_boolean, x10::lang::Object) +INTERFACE_PRIMITIVE_CAST(x10_byte, x10::lang::Object) +INTERFACE_PRIMITIVE_CAST(x10_char, x10::lang::Object) +INTERFACE_PRIMITIVE_CAST(x10_short, x10::lang::Object) +INTERFACE_PRIMITIVE_CAST(x10_int, x10::lang::Object) +INTERFACE_PRIMITIVE_CAST(x10_long, x10::lang::Object) +INTERFACE_PRIMITIVE_CAST(x10_float, x10::lang::Object) +INTERFACE_PRIMITIVE_CAST(x10_double, x10::lang::Object) +INTERFACE_PRIMITIVE_CAST(x10_ubyte, x10::lang::Object) +INTERFACE_PRIMITIVE_CAST(x10_ushort, x10::lang::Object) +INTERFACE_PRIMITIVE_CAST(x10_uint, x10::lang::Object) +INTERFACE_PRIMITIVE_CAST(x10_ulong, x10::lang::Object) + +#define PRIMITIVE_VALUE_CAST(P) \ +ref<x10::lang::Value> ClassCastNotBothRef<ref<x10::lang::Value>,P>::_(P obj, bool checked) { \ + _CAST_("converted to value: "<<CAST_TRACER<P>(obj)<<" of type "<<TYPENAME(P)); \ + return ref<x10::lang::Value>(new (x10aux::alloc<ValueBox<P> >()) ValueBox<P>(obj)); \ +} +#define VALUE_PRIMITIVE_CAST(P) \ +P ClassCastNotBothRef<P,ref<x10::lang::Value> >::_(ref<x10::lang::Value> obj, bool checked) { \ + _CAST_("converted from value: "<<CAST_TRACER<ref<x10::lang::Value> >(obj)<<" of type "<<TYPENAME(P)); \ + return ref<ValueBox<P> >(obj)->v; \ +} +#define PRIMITIVE_VALUE_CAST2(P) \ + PRIMITIVE_VALUE_CAST(P) \ + VALUE_PRIMITIVE_CAST(P) +PRIMITIVE_VALUE_CAST2(x10_boolean) +PRIMITIVE_VALUE_CAST2(x10_byte) +PRIMITIVE_VALUE_CAST2(x10_char) +PRIMITIVE_VALUE_CAST2(x10_short) +PRIMITIVE_VALUE_CAST2(x10_int) +PRIMITIVE_VALUE_CAST2(x10_long) +PRIMITIVE_VALUE_CAST2(x10_float) +PRIMITIVE_VALUE_CAST2(x10_double) +PRIMITIVE_VALUE_CAST2(x10_ubyte) +PRIMITIVE_VALUE_CAST2(x10_ushort) +PRIMITIVE_VALUE_CAST2(x10_uint) +PRIMITIVE_VALUE_CAST2(x10_ulong) + +// vim:tabstop=4:shiftwidth=4:expandtab Modified: trunk/x10.runtime/src-cpp/x10aux/class_cast.h =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/class_cast.h 2009-10-18 23:01:07 UTC (rev 11525) +++ trunk/x10.runtime/src-cpp/x10aux/class_cast.h 2009-10-19 02:33:24 UTC (rev 11526) @@ -70,10 +70,7 @@ // Box primitives on casting to interfaces #define PRIMITIVE_INTERFACE_CAST(T,F) \ template<> struct ClassCastNotBothRef<ref<T>,F> { \ - static GPUSAFE ref<T> _ (F obj, bool checked) { \ - _CAST_(TYPENAME(F) <<" converted to "<<TYPENAME(ref<T>)); \ - return class_cast<ref<T> >(box(obj), checked); \ - } \ + static GPUSAFE ref<T> _ (F obj, bool checked); \ } PRIMITIVE_INTERFACE_CAST(x10::lang::Object, x10_boolean); PRIMITIVE_INTERFACE_CAST(x10::lang::Object, x10_byte); @@ -100,14 +97,12 @@ PRIMITIVE_INTERFACE_CAST(x10::lang::Ref, x10_ulong); PRIMITIVE_INTERFACE_CAST(x10::lang::Ref, x10_float); PRIMITIVE_INTERFACE_CAST(x10::lang::Ref, x10_double); + #undef PRIMITIVE_INTERFACE_CAST // Unbox primitives on down-casting from interfaces #define INTERFACE_PRIMITIVE_CAST(T,F) \ template<> struct ClassCastNotBothRef<T,ref<F> > { \ - static GPUSAFE T _ (ref<F> obj, bool checked) { \ - _CAST_(TYPENAME(ref<F>) <<" converted to "<<TYPENAME(T)); \ - return unbox(class_cast<ref<x10::lang::Box<T> > >(obj, checked)); \ - } \ + static GPUSAFE T _ (ref<F> obj, bool checked); \ } INTERFACE_PRIMITIVE_CAST(x10_boolean, x10::lang::Object); INTERFACE_PRIMITIVE_CAST(x10_byte, x10::lang::Object); @@ -121,6 +116,7 @@ INTERFACE_PRIMITIVE_CAST(x10_ushort, x10::lang::Object); INTERFACE_PRIMITIVE_CAST(x10_uint, x10::lang::Object); INTERFACE_PRIMITIVE_CAST(x10_ulong, x10::lang::Object); + #undef INTERFACE_PRIMITIVE_CAST template<class T, class F> struct ClassCastNotBothRef<ref<T>,F*> { static GPUSAFE ref<T> _(F* obj, bool checked) { @@ -155,17 +151,11 @@ // Primitive -> Value; Value -> Primitive #define PRIMITIVE_VALUE_CAST(P) \ template<> struct ClassCastNotBothRef<ref<x10::lang::Value>,P> { \ - static ref<x10::lang::Value> _(P obj, bool checked) { \ - _CAST_("converted to value: "<<CAST_TRACER<P>(obj)<<" of type "<<TYPENAME(P)); \ - return ref<x10::lang::Value>(new (x10aux::alloc<ValueBox<P> >()) ValueBox<P>(obj)); \ - } \ + static ref<x10::lang::Value> _(P obj, bool checked); \ } #define VALUE_PRIMITIVE_CAST(P) \ template<> struct ClassCastNotBothRef<P,ref<x10::lang::Value> > { \ - static P _(ref<x10::lang::Value> obj, bool checked) { \ - _CAST_("converted from value: "<<CAST_TRACER<ref<x10::lang::Value> >(obj)<<" of type "<<TYPENAME(P)); \ - return ref<ValueBox<P> >(obj)->v; \ - } \ + static P _(ref<x10::lang::Value> obj, bool checked); \ } #define PRIMITIVE_VALUE_CAST2(P) PRIMITIVE_VALUE_CAST(P); VALUE_PRIMITIVE_CAST(P) PRIMITIVE_VALUE_CAST2(x10_boolean); @@ -180,6 +170,9 @@ PRIMITIVE_VALUE_CAST2(x10_ushort); PRIMITIVE_VALUE_CAST2(x10_uint); PRIMITIVE_VALUE_CAST2(x10_ulong); + #undef PRIMITIVE_VALUE_CAST2 + #undef VALUE_PRIMITIVE_CAST + #undef PRIMITIVE_VALUE_CAST template<class T> static GPUSAFE ref<T> real_class_cast(ref<x10::lang::Object> obj, bool checked) { if (obj == x10aux::null) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ipe...@us...> - 2009-10-19 18:35:03
|
Revision: 11529 http://x10.svn.sourceforge.net/x10/?rev=11529&view=rev Author: ipeshansky Date: 2009-10-19 18:34:53 +0000 (Mon, 19 Oct 2009) Log Message: ----------- Re-enable -O3 for xlC Modified Paths: -------------- trunk/x10.compiler/src/x10cpp/postcompiler/CXXCommandBuilder.java trunk/x10.runtime/src-cpp/Makefile trunk/x10.runtime/src-cpp/x10aux/ref.h Modified: trunk/x10.compiler/src/x10cpp/postcompiler/CXXCommandBuilder.java =================================================================== --- trunk/x10.compiler/src/x10cpp/postcompiler/CXXCommandBuilder.java 2009-10-19 15:07:02 UTC (rev 11528) +++ trunk/x10.compiler/src/x10cpp/postcompiler/CXXCommandBuilder.java 2009-10-19 18:34:53 UTC (rev 11529) @@ -109,7 +109,7 @@ } if (x10.Configuration.OPTIMIZE) { - cxxCmd.add("-O2"); + cxxCmd.add(USE_XLC ? "-O3" : "-O2"); cxxCmd.add("-DNDEBUG"); cxxCmd.add(USE_XLC ? "-qinline" : "-finline-functions"); if (USE_XLC) { Modified: trunk/x10.runtime/src-cpp/Makefile =================================================================== --- trunk/x10.runtime/src-cpp/Makefile 2009-10-19 15:07:02 UTC (rev 11528) +++ trunk/x10.runtime/src-cpp/Makefile 2009-10-19 18:34:53 UTC (rev 11529) @@ -68,9 +68,7 @@ override CXXFLAGS += -q32 endif ifdef OPTIMIZE - # override CXXFLAGS += -O3 -qinline -qarch=pwr5 -qtune=pwr5 -qhot - # Work around for XLC bug. Include -O3 when fixed. - override CXXFLAGS += -O2 -qinline -qarch=pwr5 -qtune=pwr5 + override CXXFLAGS += -O3 -qinline -qarch=pwr5 -qtune=pwr5 -qhot endif override CXXFLAGS += -qrtti=all override CXXFLAGS += -qsuppress=1540-0809:1500-029:1540-1101 Modified: trunk/x10.runtime/src-cpp/x10aux/ref.h =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/ref.h 2009-10-19 15:07:02 UTC (rev 11528) +++ trunk/x10.runtime/src-cpp/x10aux/ref.h 2009-10-19 18:34:53 UTC (rev 11529) @@ -63,9 +63,10 @@ template<class T> class ref : public __ref { public: static const x10aux::RuntimeType* getRTT() { return T::getRTT(); } - - GPUSAFE ~ref() { } + # Work around for an xlC ICE + //GPUSAFE ~ref() { } + // Copy between refs of the same type GPUSAFE ref(const ref<T>& _ref) : REF_INIT(_ref._val) { _R_("Copying reference " << &_ref << "(" << _ref._val This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <vj...@us...> - 2009-10-25 02:40:46
|
Revision: 11721 http://x10.svn.sourceforge.net/x10/?rev=11721&view=rev Author: vj0 Date: 2009-10-25 02:40:37 +0000 (Sun, 25 Oct 2009) Log Message: ----------- Fixed type bounds for type parameters. Modified Paths: -------------- trunk/x10.compiler/.classpath trunk/x10.compiler/src/x10/ast/TypeParamNode.java trunk/x10.compiler/src/x10/ast/TypeParamNode_c.java trunk/x10.compiler/src/x10/ast/X10ClassDecl_c.java trunk/x10.compiler/src/x10/types/X10Context.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/visit/X10PrettyPrinterVisitor.java Added Paths: ----------- trunk/x10.tests/examples/Constructs/Generics/Bounds7.x10 Modified: trunk/x10.compiler/.classpath =================================================================== --- trunk/x10.compiler/.classpath 2009-10-25 02:30:33 UTC (rev 11720) +++ trunk/x10.compiler/.classpath 2009-10-25 02:40:37 UTC (rev 11721) @@ -1,8 +1,12 @@ -<?xml version="1.0" encoding="UTF-8"?> -<classpath> - <classpathentry kind="src" path="src"/> - <classpathentry kind="src" path="" including="data/**" excluding="src/"/> - <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> - <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> - <classpathentry kind="output" path="classes"/> -</classpath> +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="src" path="src"/> + <classpathentry excluding="src/" including="data/**" kind="src" path=""/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> + <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> + <classpathentry combineaccessrules="false" kind="src" path="/polyglot3"/> + <classpathentry combineaccessrules="false" kind="src" path="/x10.common"/> + <classpathentry combineaccessrules="false" kind="src" path="/x10.constraints"/> + <classpathentry combineaccessrules="false" kind="src" path="/x10.runtime"/> + <classpathentry kind="output" path="classes"/> +</classpath> Modified: trunk/x10.compiler/src/x10/ast/TypeParamNode.java =================================================================== --- trunk/x10.compiler/src/x10/ast/TypeParamNode.java 2009-10-25 02:30:33 UTC (rev 11720) +++ trunk/x10.compiler/src/x10/ast/TypeParamNode.java 2009-10-25 02:40:37 UTC (rev 11721) @@ -8,6 +8,8 @@ package x10.ast; +import java.util.List; + import polyglot.ast.Id; import polyglot.ast.Term; import polyglot.types.Ref; @@ -22,4 +24,6 @@ TypeParamNode type(ParameterType type); public ParameterType.Variance variance(); public TypeParamNode variance(ParameterType.Variance variance); + + List<Type> upperBounds(); } Modified: trunk/x10.compiler/src/x10/ast/TypeParamNode_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/TypeParamNode_c.java 2009-10-25 02:30:33 UTC (rev 11720) +++ trunk/x10.compiler/src/x10/ast/TypeParamNode_c.java 2009-10-25 02:40:37 UTC (rev 11721) @@ -19,6 +19,7 @@ import polyglot.types.Named; import polyglot.types.SemanticException; import polyglot.types.Types; +import polyglot.types.Type; import polyglot.util.CodeWriter; import polyglot.util.Position; import polyglot.visit.CFGBuilder; @@ -28,6 +29,8 @@ import x10.types.ParameterType; import x10.types.ParameterType_c; import x10.types.X10Context; +import x10.types.X10Context_c; +import x10.types.X10TypeEnv_c; import x10.types.X10TypeSystem; public class TypeParamNode_c extends Term_c implements TypeParamNode { @@ -112,4 +115,11 @@ public void prettyPrint(CodeWriter w, PrettyPrinter pp) { pp.print(this, name, w); } + public List<Type> upperBounds() { + Type type = type(); + X10TypeSystem ts = (X10TypeSystem) type.typeSystem(); + X10Context_c xc = (X10Context_c) ts.emptyContext(); + List<Type> results = new X10TypeEnv_c(xc).upperBounds(type, false); + return results; + } } Modified: trunk/x10.compiler/src/x10/ast/X10ClassDecl_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10ClassDecl_c.java 2009-10-25 02:30:33 UTC (rev 11720) +++ trunk/x10.compiler/src/x10/ast/X10ClassDecl_c.java 2009-10-25 02:40:37 UTC (rev 11721) @@ -374,15 +374,14 @@ for (ParameterType t : type.typeParameters()) { xc.addNamed(t); } - /* vj TODO: This causes a loop. Need to investigate. - * DepParameterExpr v = classInvariant(); + DepParameterExpr v = classInvariant(); if (v != null) { Ref<TypeConstraint> tc = v.typeConstraint(); if (tc != null) { - xc.setCurrentTypeConstraint(tc.get()); + xc.setCurrentTypeConstraint(tc); } } - */ + // Now add this.location == currentLocation /* XConstrainedTerm placeTerm = xc.currentPlaceTerm().copy(); XRoot thisVar = type.thisVar(); @@ -477,41 +476,41 @@ // Add all the constraints on the supertypes into the invariant. c.setResolver(new Runnable() { - public void run() { - XConstraint x = new XConstraint_c(); - try { - if (ci != null) { - XConstraint xi = ci.valueConstraint().get(); - x.addIn(xi); - TypeConstraint ti = ci.typeConstraint().get(); - } - if (nn.superClass != null) { - Type t = nn.superClass.type(); - XConstraint tc = X10TypeMixin.xclause(t); - if (tc != null) - x.addIn(tc); - } - for (TypeNode tn : nn.interfaces) { - Type t = tn.type(); - XConstraint tc = X10TypeMixin.xclause(t); - if (tc != null) - x.addIn(tc); - } + public void run() { + XConstraint x = new XConstraint_c(); + try { + if (ci != null) { + XConstraint xi = ci.valueConstraint().get(); + x.addIn(xi); + TypeConstraint ti = ci.typeConstraint().get(); + } + if (nn.superClass != null) { + Type t = nn.superClass.type(); + XConstraint tc = X10TypeMixin.xclause(t); + if (tc != null) + x.addIn(tc); + } + for (TypeNode tn : nn.interfaces) { + Type t = tn.type(); + XConstraint tc = X10TypeMixin.xclause(t); + if (tc != null) + x.addIn(tc); + } + } + catch (XFailure e) { + x.setInconsistent(); + } + c.update(x); } - catch (XFailure e) { - x.setInconsistent(); - } - c.update(x); - } }); def.setClassInvariant(c); - final Ref<TypeConstraint> tc = new LazyRef_c<TypeConstraint>(new TypeConstraint_c()); + final LazyRef<TypeConstraint> tc = new LazyRef_c<TypeConstraint>(new TypeConstraint_c()); // Set the type bounds for the def. - c.setResolver(new Runnable() { + tc.setResolver(new Runnable() { public void run() { TypeConstraint x = new TypeConstraint_c(); Modified: trunk/x10.compiler/src/x10/types/X10Context.java =================================================================== --- trunk/x10.compiler/src/x10/types/X10Context.java 2009-10-25 02:30:33 UTC (rev 11720) +++ trunk/x10.compiler/src/x10/types/X10Context.java 2009-10-25 02:40:37 UTC (rev 11721) @@ -67,7 +67,7 @@ /** Current constraint on type variables in scope */ TypeConstraint currentTypeConstraint(); - void setCurrentTypeConstraint(TypeConstraint c); + void setCurrentTypeConstraint(Ref<TypeConstraint> c); /** * Looks up a property in the current scope. Modified: trunk/x10.compiler/src/x10/types/X10Context_c.java =================================================================== --- trunk/x10.compiler/src/x10/types/X10Context_c.java 2009-10-25 02:30:33 UTC (rev 11720) +++ trunk/x10.compiler/src/x10/types/X10Context_c.java 2009-10-25 02:40:37 UTC (rev 11721) @@ -296,12 +296,12 @@ return null; } - protected TypeConstraint currentTypeConstraint; + protected Ref<TypeConstraint> currentTypeConstraint; public TypeConstraint currentTypeConstraint() { if (currentTypeConstraint == null) return new TypeConstraint_c(); - return currentTypeConstraint; } - public void setCurrentTypeConstraint(TypeConstraint c) { + return currentTypeConstraint.get(); } + public void setCurrentTypeConstraint(Ref<TypeConstraint> c) { currentTypeConstraint = c; } Modified: trunk/x10.compiler/src/x10/types/X10TypeEnv_c.java =================================================================== --- trunk/x10.compiler/src/x10/types/X10TypeEnv_c.java 2009-10-25 02:30:33 UTC (rev 11720) +++ trunk/x10.compiler/src/x10/types/X10TypeEnv_c.java 2009-10-25 02:40:37 UTC (rev 11721) @@ -775,7 +775,7 @@ for (SubtypeConstraint tt : newEnv) { ec.addTerm(tt); } - xc2.setCurrentTypeConstraint(ec); + xc2.setCurrentTypeConstraint(Types.ref(ec)); X10TypeEnv_c tenv = copy(); tenv.context = xc2; @@ -1008,7 +1008,7 @@ for (SubtypeConstraint tt : newEnv) { ec.addTerm(tt); } - xc2.setCurrentTypeConstraint(ec); + xc2.setCurrentTypeConstraint(Types.ref(ec)); if (term.isEqualityConstraint()) { SubtypeConstraint eq = term; Modified: trunk/x10.compiler/src/x10/types/X10TypeSystem.java =================================================================== --- trunk/x10.compiler/src/x10/types/X10TypeSystem.java 2009-10-25 02:30:33 UTC (rev 11720) +++ trunk/x10.compiler/src/x10/types/X10TypeSystem.java 2009-10-25 02:40:37 UTC (rev 11721) @@ -427,4 +427,6 @@ XConstrainedTerm globalPlace(); boolean isX10Array(Type me); + + Context emptyContext(); } Modified: trunk/x10.compiler/src/x10/types/X10TypeSystem_c.java =================================================================== --- trunk/x10.compiler/src/x10/types/X10TypeSystem_c.java 2009-10-25 02:30:33 UTC (rev 11720) +++ trunk/x10.compiler/src/x10/types/X10TypeSystem_c.java 2009-10-25 02:40:37 UTC (rev 11721) @@ -287,7 +287,7 @@ } X10Context xc = (X10Context) context.pushBlock(); equals.addIn(xc.currentTypeConstraint()); - xc.setCurrentTypeConstraint(equals); + xc.setCurrentTypeConstraint(Types.ref(equals)); if (! consistent(c, xc)) return false; } @@ -2262,8 +2262,9 @@ X10MethodMatcher m = (X10MethodMatcher) matcher; List<MethodInstance> candidates = new ArrayList<MethodInstance>(); - - for (Type t : env(matcher.context()).upperBounds(container, true)) { + + List<Type> types = env(matcher.context()).upperBounds(container, true); + for (Type t : types) { List<MethodInstance> ms = super.findAcceptableMethods(t, matcher); candidates.addAll(ms); } Modified: trunk/x10.compiler/src/x10/visit/X10PrettyPrinterVisitor.java =================================================================== --- trunk/x10.compiler/src/x10/visit/X10PrettyPrinterVisitor.java 2009-10-25 02:30:33 UTC (rev 11720) +++ trunk/x10.compiler/src/x10/visit/X10PrettyPrinterVisitor.java 2009-10-25 02:40:37 UTC (rev 11721) @@ -527,6 +527,12 @@ for (TypeParamNode tp : n.typeParameters()) { w.write(sep); n.print(tp, w, tr); + List<Type> sups = tp.upperBounds(); + if (sups.size() > 0) { + //TODO: Decide what to do with multiple upper bounds. Not sure how Java will handle this. + w.write(" extends "); + er.printType(sups.get(0), PRINT_TYPE_PARAMS | NO_VARIANCE); + } sep = ", "; } w.end(); Added: trunk/x10.tests/examples/Constructs/Generics/Bounds7.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Generics/Bounds7.x10 (rev 0) +++ trunk/x10.tests/examples/Constructs/Generics/Bounds7.x10 2009-10-25 02:40:37 UTC (rev 11721) @@ -0,0 +1,32 @@ +/* + * + * (C) Copyright IBM Corporation 2008 + * + * This file is part of X10 Test. + * + */ +import harness.x10Test; + +/** + * Test type parameter bounds. + * + * @author nystrom 8/2008 + */ +public class Bounds7 extends x10Test { + + interface Sum { + def sum():int; + } + + public class Test[T]{T <: Sum} { + def sum(a:T) = a.sum(); + + } + + public def run() = true; + public static def main( Rail[String]) { + new Bounds7().execute(); + } +} + + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ipe...@us...> - 2009-10-25 09:41:09
|
Revision: 11731 http://x10.svn.sourceforge.net/x10/?rev=11731&view=rev Author: ipeshansky Date: 2009-10-25 09:40:59 +0000 (Sun, 25 Oct 2009) Log Message: ----------- Major change to the deserialization scheme. Factor out common Ref deserialization code and use it everywhere. Invoke the _destructor() method on deallocation. Allows heap-allocated internal state. Modified Paths: -------------- trunk/x10.compiler/src/x10cpp/visit/Emitter.java trunk/x10.runtime/src-cpp/x10/io/FileReader__FileInputStream.cc trunk/x10.runtime/src-cpp/x10/io/FileReader__FileInputStream.h trunk/x10.runtime/src-cpp/x10/io/FileWriter__FileOutputStream.cc trunk/x10.runtime/src-cpp/x10/io/FileWriter__FileOutputStream.h trunk/x10.runtime/src-cpp/x10/lang/Box.h trunk/x10.runtime/src-cpp/x10/lang/Object.h 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/lang/String.h trunk/x10.runtime/src-cpp/x10/lang/Throwable.cc trunk/x10.runtime/src-cpp/x10/lang/ValRail.h trunk/x10.runtime/src-cpp/x10/util/GrowableRail.h Modified: trunk/x10.compiler/src/x10cpp/visit/Emitter.java =================================================================== --- trunk/x10.compiler/src/x10cpp/visit/Emitter.java 2009-10-25 09:35:28 UTC (rev 11730) +++ trunk/x10.compiler/src/x10cpp/visit/Emitter.java 2009-10-25 09:40:59 UTC (rev 11731) @@ -992,6 +992,8 @@ h.write("// Serialization"); h.newline(); String klass = translateType(type); + String template = context.inTemplate() ? "template " : ""; + if (!type.flags().isAbstract()) { // _serialization_id h.write("public: static const x10aux::serialization_id_t "+SERIALIZATION_ID_FIELD+";"); h.newline(); @@ -1000,7 +1002,6 @@ w.write("const x10aux::serialization_id_t "+klass+"::"+SERIALIZATION_ID_FIELD+" = "); w.newline(4); w.write("x10aux::DeserializationDispatcher::addDeserializer("); - String template = context.inTemplate() ? "template " : ""; w.write(klass+"::"+template+DESERIALIZER_METHOD+chevrons(translateType(ts.Object()))+");"); w.newline(); w.forceNewline(); } @@ -1011,13 +1012,19 @@ h.write("static void "+SERIALIZE_METHOD+"("); h.begin(0); h.write(make_ref(klass)+" this_,"); h.newline(); h.write(SERIALIZATION_BUFFER+"& buf,"); h.newline(); - h.write("x10aux::addr_map& m) {"); h.end(); h.newline(4); h.begin(0); - h.write( "_serialize_reference(this_, buf, m);"); h.newline(); - h.write( "if (this_ != x10aux::null) {"); h.newline(4); h.begin(0); - h.write( "this_->_serialize_body(buf, m);"); h.end(); h.newline(); - h.write( "}"); h.end(); h.newline(); - h.write("}"); h.newline(); - h.forceNewline(); + h.write("x10aux::addr_map& m);"); h.end(); + h.newline(); h.forceNewline(); + printTemplateSignature(ct.typeArguments(), w); + w.write("void "+klass+"::"+SERIALIZE_METHOD+"("); w.begin(0); + w.write(make_ref(klass)+" this_,"); w.newline(); + w.write(SERIALIZATION_BUFFER+"& buf,"); w.newline(); + w.write("x10aux::addr_map& m) {"); w.end(); w.newline(4); w.begin(0); + w.write( "_serialize_reference(this_, buf, m);"); w.newline(); + w.write( "if (this_ != x10aux::null) {"); w.newline(4); w.begin(0); + w.write( "this_->_serialize_body(buf, m);"); w.end(); w.newline(); + w.write( "}"); w.end(); w.newline(); + w.write("}"); w.newline(); + w.forceNewline(); } // _serialize_id() @@ -1065,7 +1072,7 @@ w.newline(); w.forceNewline(); if (!type.flags().isAbstract()) { - // _deserialize() + // _deserializer() h.write("public: template<class __T> static "); h.write(make_ref("__T")+" "+DESERIALIZER_METHOD+"("+DESERIALIZATION_BUFFER+"& buf);"); h.newline(); h.forceNewline(); @@ -1075,7 +1082,7 @@ sw.write(make_ref("__T")+" "+klass+"::"+DESERIALIZER_METHOD+"("+DESERIALIZATION_BUFFER+"& buf) {"); sw.newline(4); sw.begin(0); sw.writeln(make_ref(klass)+" this_ = "+ - "new (x10aux::alloc_remote"+chevrons(klass)+"()) "+klass+"();"); + "new (x10aux::alloc_remote"+chevrons(klass)+"()) "+klass+"();"); sw.writeln("this_->"+DESERIALIZE_BODY_METHOD+"(buf);"); sw.write("return this_;"); sw.end(); sw.newline(); @@ -1086,17 +1093,25 @@ if (type.flags().isFinal()) { // _deserialize() h.write("public: template<class __T> static "); - h.write(make_ref("__T")+" "+DESERIALIZE_METHOD+"("+DESERIALIZATION_BUFFER+"& buf) {"); - h.newline(4); h.begin(0); - h.write( make_ref(klass)+" this_ = x10::lang::Ref::_deserialize_reference"+chevrons(klass)+"(buf);"); - h.newline(); - h.write( "if (this_ != x10aux::null && this_->location != x10aux::here) {"); - h.newline(4); h.begin(0); - h.write( "this_->_deserialize_body(buf);"); h.end(); h.newline(); - h.write( "}"); h.newline(); - h.write( "return this_;"); - h.end(); h.newline(); - h.write("}"); h.newline(); h.forceNewline(); + h.write(make_ref("__T")+" "+DESERIALIZE_METHOD+"("+DESERIALIZATION_BUFFER+"& buf);"); + h.newline(); h.forceNewline(); + sw.pushCurrentStream(context.templateFunctions); + printTemplateSignature(ct.typeArguments(), sw); + 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(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.end(); sw.newline(); + sw.writeln("}"); sw.forceNewline(); + sw.popCurrentStream(); } // _deserialize_body() Modified: trunk/x10.runtime/src-cpp/x10/io/FileReader__FileInputStream.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/io/FileReader__FileInputStream.cc 2009-10-25 09:35:28 UTC (rev 11730) +++ trunk/x10.runtime/src-cpp/x10/io/FileReader__FileInputStream.cc 2009-10-25 09:40:59 UTC (rev 11731) @@ -19,34 +19,21 @@ void FileReader__FileInputStream::_serialize_body(x10aux::serialization_buffer& buf, x10aux::addr_map& m) { InputStreamReader__InputStream::_serialize_body(buf, m); + // This class simply has no global state. // TODO: attempting to serialize _inputStream is nonsensical. // The old 1.7 definition of this class simply didn't work either, // it just silently didn't serialize the FILEPtrInputSteam field. - // - assert(false); + // assert(false); // buf.write(this->_inputStream,m); } -template<class __T> x10aux::ref<__T> FileReader__FileInputStream::_deserializer(x10aux::deserialization_buffer& buf) { - // TODO: attempting to serialize _outputStream is nonsensical. - // The old 1.7 definition of this class simply didn't work either, - // it just silently didn't serialize the FILEPtrInputSteam field. - // - assert(false); - // x10aux::ref<FileReader__FileInputStream> this_ = new (x10aux::alloc_remote<FileReader__FileInputStream>()) FileReader__FileInputStream(); - // this_->_deserialize_body(buf); - // return this_; - return NULL; -} - void FileReader__FileInputStream::_deserialize_body(x10aux::deserialization_buffer& buf) { InputStreamReader__InputStream::_deserialize_body(buf); - + // This class simply has no global state. // TODO: attempting to serialize _inputStream is nonsensical. // The old 1.7 definition of this class simply didn't work either, // it just silently didn't serialize the FILEPtrInputSteam field. - // - assert(false); + // assert(false); // _inputStream = buf.read<x10aux::io::FILEPtrInputStream>(); } Modified: trunk/x10.runtime/src-cpp/x10/io/FileReader__FileInputStream.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/io/FileReader__FileInputStream.h 2009-10-25 09:35:28 UTC (rev 11730) +++ trunk/x10.runtime/src-cpp/x10/io/FileReader__FileInputStream.h 2009-10-25 09:40:59 UTC (rev 11731) @@ -47,11 +47,22 @@ static const x10aux::serialization_id_t _serialization_id; virtual x10aux::serialization_id_t _get_serialization_id() { return _serialization_id; - } + } virtual void _serialize_body(x10aux::serialization_buffer& buf, x10aux::addr_map& m); template<class __T> static x10aux::ref<__T> _deserializer(x10aux::deserialization_buffer& buf); void _deserialize_body(x10aux::deserialization_buffer& buf); + // No specialized serialization methods - not optimizing this final class }; + + template<class __T> x10aux::ref<__T> FileReader__FileInputStream::_deserializer(x10aux::deserialization_buffer& buf) { + // TODO: attempting to serialize _outputStream is nonsensical. + // The old 1.7 definition of this class simply didn't work either, + // it just silently didn't serialize the FILEPtrInputSteam field. + // assert(false); + x10aux::ref<FileReader__FileInputStream> this_ = new (x10aux::alloc_remote<FileReader__FileInputStream>()) FileReader__FileInputStream (NULL); + this_->_deserialize_body(buf); + return this_; + } } } Modified: trunk/x10.runtime/src-cpp/x10/io/FileWriter__FileOutputStream.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/io/FileWriter__FileOutputStream.cc 2009-10-25 09:35:28 UTC (rev 11730) +++ trunk/x10.runtime/src-cpp/x10/io/FileWriter__FileOutputStream.cc 2009-10-25 09:40:59 UTC (rev 11731) @@ -22,38 +22,24 @@ void FileWriter__FileOutputStream::_serialize_body(x10aux::serialization_buffer& buf, x10aux::addr_map& m) { OutputStreamWriter__OutputStream::_serialize_body(buf, m); + // This class simply has no global state. // TODO: attempting to serialize _outputStream is nonsensical. // The old 1.7 definition of this class simply didn't work either, // it just silently didn't serialize the FILEPtrInputSteam field. - // - assert(false); - //buf.write(this->_outputStream,m); + // assert(false); + // buf.write(this->_outputStream,m); } -template<class __T> x10aux::ref<__T> FileWriter__FileOutputStream::_deserializer(x10aux::deserialization_buffer& buf) { - // TODO: attempting to serialize _outputStream is nonsensical. - // The old 1.7 definition of this class simply didn't work either, - // it just silently didn't serialize the FILEPtrInputSteam field. - // - assert(false); - // x10aux::ref<FileWriter__FileOutputStream> this_ = new (x10aux::alloc_remote<FileWriter__FileOutputStream>()) FileWriter__FileOutputStream(); - // this_->_deserialize_body(buf); - // return this_; - return NULL; -} - void FileWriter__FileOutputStream::_deserialize_body(x10aux::deserialization_buffer& buf) { OutputStreamWriter__OutputStream::_deserialize_body(buf); + // This class simply has no global state. // TODO: attempting to serialize _outputStream is nonsensical. // The old 1.7 definition of this class simply didn't work either, // it just silently didn't serialize the FILEPtrInputSteam field. - // - assert(false); + // assert(false); // _outputStream = buf.read<x10aux::io::FILEPtrOutputStream>(); } - - RTT_CC_DECLS1(FileWriter__FileOutputStream, "x10.io.FileWriter.FileOutputStream", OutputStreamWriter__OutputStream) // vim:tabstop=4:shiftwidth=4:expandtab Modified: trunk/x10.runtime/src-cpp/x10/io/FileWriter__FileOutputStream.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/io/FileWriter__FileOutputStream.h 2009-10-25 09:35:28 UTC (rev 11730) +++ trunk/x10.runtime/src-cpp/x10/io/FileWriter__FileOutputStream.h 2009-10-25 09:40:59 UTC (rev 11731) @@ -55,7 +55,18 @@ virtual void _serialize_body(x10aux::serialization_buffer& buf, x10aux::addr_map& m); template<class __T> static x10aux::ref<__T> _deserializer(x10aux::deserialization_buffer& buf); void _deserialize_body(x10aux::deserialization_buffer& buf); + // No specialized serialization methods - not optimizing this final class }; + + template<class __T> x10aux::ref<__T> FileWriter__FileOutputStream::_deserializer(x10aux::deserialization_buffer& buf) { + // TODO: attempting to serialize _outputStream is nonsensical. + // The old 1.7 definition of this class simply didn't work either, + // it just silently didn't serialize the FILEPtrInputSteam field. + // assert(false); + x10aux::ref<FileWriter__FileOutputStream> this_ = new (x10aux::alloc_remote<FileWriter__FileOutputStream>()) FileWriter__FileOutputStream(NULL); + this_->_deserialize_body(buf); + return this_; + } } } Modified: trunk/x10.runtime/src-cpp/x10/lang/Box.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Box.h 2009-10-25 09:35:28 UTC (rev 11730) +++ trunk/x10.runtime/src-cpp/x10/lang/Box.h 2009-10-25 09:40:59 UTC (rev 11731) @@ -63,6 +63,7 @@ template<class T> void Box<T>::_serialize_body(x10aux::serialization_buffer &buf, x10aux::addr_map &m) { this->x10::lang::Ref::_serialize_body(buf, m); + buf.write(this->FMGL(value), m); } template<class T> template<class U> x10aux::ref<U> Box<T>::_deserializer(x10aux::deserialization_buffer &buf) { @@ -73,6 +74,7 @@ template<class T> void Box<T>::_deserialize_body(x10aux::deserialization_buffer& buf) { this->x10::lang::Ref::_deserialize_body(buf); + this->FMGL(value) = buf.read<T>(); } template <> class Box<void> : public Ref { Modified: trunk/x10.runtime/src-cpp/x10/lang/Object.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Object.h 2009-10-25 09:35:28 UTC (rev 11730) +++ trunk/x10.runtime/src-cpp/x10/lang/Object.h 2009-10-25 09:40:59 UTC (rev 11731) @@ -40,11 +40,11 @@ // // "All instances of all my subclasses are de/serialised by the same code" // - // Examples of classes that satisfy this property: All final value classes, and Ref. + // Examples of classes that satisfy this property: All final classes, and root classes + // in hierarchies that use double dispatch for deserialization (to save serialization id + // space). // - // These functions should not be overridden in subclasses of classes that override these - // functions, i.e., any strict subclass of Ref. If one is overridden, the other should - // be too. + // If one of these functions is overridden, the other should be too. // // Note these functions are static as we want to dispatch on the static type. Modified: trunk/x10.runtime/src-cpp/x10/lang/Rail.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Rail.h 2009-10-25 09:35:28 UTC (rev 11730) +++ trunk/x10.runtime/src-cpp/x10/lang/Rail.h 2009-10-25 09:40:59 UTC (rev 11731) @@ -92,6 +92,22 @@ x10aux::ref<Fun_0_1<x10_int,T> > init); static x10aux::ref<Rail<T> > make(x10aux::ref<ValRail<T> > other); + static const x10aux::serialization_id_t _serialization_id; + + virtual x10aux::serialization_id_t _get_serialization_id() { return _serialization_id; }; + + static void _serialize(x10aux::ref<Rail<T> > this_, + x10aux::serialization_buffer &buf, + x10aux::addr_map &m); + + void _serialize_body(x10aux::serialization_buffer &buf, x10aux::addr_map &m); + + void _deserialize_body(x10aux::deserialization_buffer &buf); + + template<class S> static x10aux::ref<S> _deserializer(x10aux::deserialization_buffer &buf); + + template<class S> static x10aux::ref<S> _deserialize(x10aux::deserialization_buffer &buf); + static const x10aux::serialization_id_t _copy_to_serialization_id; static void *_copy_to_buffer_finder(x10aux::deserialization_buffer&, x10_int); @@ -534,6 +550,47 @@ // }}} + template<class T> const x10aux::serialization_id_t Rail<T>::_serialization_id = + x10aux::DeserializationDispatcher + ::addDeserializer(Rail<T>::template _deserializer<Object>); + + // Specialized serialization + template <class T> void Rail<T>::_serialize(x10aux::ref<Rail<T> > this_, + x10aux::serialization_buffer &buf, + x10aux::addr_map &m) { + Ref::_serialize_reference(this_, buf, m); + if (this_ != x10aux::null) { + this_->_serialize_body(buf, m); + } + } + + template <class T> void Rail<T>::_serialize_body(x10aux::serialization_buffer &buf, x10aux::addr_map &m) { + x10_int length = this->FMGL(length); + buf.write(length, m); + this->Ref::_serialize_body(buf, m); // 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); + } + + template <class T> template<class S> x10aux::ref<S> Rail<T>::_deserializer(x10aux::deserialization_buffer &buf) { + x10_int length = buf.read<x10_int>(); + x10aux::ref<Rail<T> > this_ = x10aux::alloc_rail_remote<T,Rail<T> >(length); + this_->_deserialize_body(buf); + return this_; + } + + // 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); + x10aux::ref<Rail<T> > this_; + if (rr.ref != 0) { + this_ = Rail<T>::template _deserializer<Rail<T> >(buf); + } + return Ref::_finalize_reference<T>(this_, rr); + } } } Modified: trunk/x10.runtime/src-cpp/x10/lang/Ref.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Ref.cc 2009-10-25 09:35:28 UTC (rev 11730) +++ trunk/x10.runtime/src-cpp/x10/lang/Ref.cc 2009-10-25 09:40:59 UTC (rev 11731) @@ -32,48 +32,27 @@ const serialization_id_t Ref::_serialization_id = DeserializationDispatcher::addDeserializer(Ref::_deserializer<Object>); -// FIXME: optimize refs coming home void Ref::_serialize(ref<Ref> this_, serialization_buffer &buf, addr_map &m) { 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, m); - // FIXME: maybe optimize nulls? - //if (!this_.isNull()) { - // FIXME: factor out common code with _serialize_reference - bool isNull = this_.isNull(); - x10_int loc = isNull ? 0 : this_->location; - buf.write(loc, m); - if (isNull) { - _S_("Serializing a "<<ANSI_SER<<ANSI_BOLD<<"null reference"<<ANSI_RESET<<" to buf: "<<&buf); - buf.write((x10_addr_t)0, m); - return; - } 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->(), m); - } 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, m); + // FIXME: maybe optimize nulls by moving the call below into the conditional? + _serialize_reference(this_, buf, m); + if (!this_.isNull()) { + _S_("Serializing the "<<ANSI_SER<<"class body"<<ANSI_RESET<<" to buf: "<<&buf); + this_->_serialize_body(buf, m); } - _S_("Serializing the "<<ANSI_SER<<"class body"<<ANSI_RESET<<" to buf: "<<&buf); - this_->_serialize_body(buf, m); - //} } -// FIXME: factor out common code with _serialize void Ref::_serialize_reference(ref<Ref> this_, serialization_buffer &buf, addr_map &m) { - _S_("Serializing an untyped "<<ANSI_SER<<ANSI_BOLD<<"reference"<<ANSI_RESET<<" to buf: "<<&buf); bool isNull = this_.isNull(); x10_int loc = isNull ? 0 : this_->location; buf.write(loc, m); if (isNull) { _S_("Serializing a "<<ANSI_SER<<ANSI_BOLD<<"null reference"<<ANSI_RESET<<" to buf: "<<&buf); buf.write((x10_addr_t)0, m); - return; } else if (loc == x10aux::here) { _S_("Serialising a "<<ANSI_SER<<ANSI_BOLD<<"local Ref"<<ANSI_RESET<< " object of type "<<this_->_type()->name()); @@ -86,8 +65,9 @@ } } -void Ref::dealloc_object(const Ref* obj) { +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 Modified: trunk/x10.runtime/src-cpp/x10/lang/Ref.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Ref.h 2009-10-25 09:35:28 UTC (rev 11730) +++ trunk/x10.runtime/src-cpp/x10/lang/Ref.h 2009-10-25 09:40:59 UTC (rev 11731) @@ -31,7 +31,8 @@ x10aux::serialization_buffer &buf, x10aux::addr_map &m); - // A helper method for serializing a final ref with no global state + // 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, x10aux::addr_map &m); @@ -44,9 +45,26 @@ template<class T> static x10aux::ref<T> _deserialize(x10aux::deserialization_buffer &buf); - // A helper method for deserializing a final ref with no global state - template<class R> static x10aux::ref<R> _deserialize_reference(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 Ref::_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 == x10aux::null) + _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<Ref> res, Ref::_reference_state rr); + virtual void _deserialize_body(x10aux::deserialization_buffer &buf) { } template<class T> friend class x10aux::ref; @@ -67,7 +85,11 @@ return false; } - static void dealloc_object(const Ref*); + // 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(Ref*); }; template<class T> x10aux::ref<T> Ref::_deserializer(x10aux::deserialization_buffer &buf) { @@ -77,52 +99,35 @@ } template<class T> x10aux::ref<T> Ref::_deserialize(x10aux::deserialization_buffer &buf) { + // extract the id x10aux::serialization_id_t id = buf.read<x10aux::serialization_id_t>(); - // FIXME: factor out common code with _deserialize_reference - x10_int loc = buf.read<x10_int>(); - x10aux::x10_addr_t ref = buf.read<x10aux::x10_addr_t>(); - if (ref == 0 /*TODO: id == 0*/) { - _S_("Deserializing a "<<ANSI_SER<<ANSI_BOLD<<"null reference"<<ANSI_RESET<<" from buf: "<<&buf); - return x10aux::null; + _reference_state rr = _deserialize_reference_state(buf); + x10aux::ref<Ref> 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); } - _S_("Attempting to deserialize a "<<ANSI_SER<<ANSI_BOLD<<"ref"<<ANSI_RESET<< - " (with id "<<id<<") at "<<loc<<" from buf: "<<&buf); - if (loc == x10aux::here) { // a remote object coming home to roost - _S_("\ta local object come home"); - x10aux::ref<T> obj = x10aux::DeserializationDispatcher::create<T>(buf, id); // consume the buffer - T* ptr = static_cast<T*>((void*)(size_t)ref); - x10aux::dealloc_remote(obj.operator->()); - return ptr; - } - // extract the id and execute a callback to instantiate the right concrete class - _S_("Deserializing a "<<ANSI_SER<<ANSI_BOLD<<"class"<<ANSI_RESET<< - " (with id "<<id<<") from buf: "<<&buf); - x10aux::ref<Ref> obj = x10aux::DeserializationDispatcher::create<T>(buf, id); - obj->location = loc; - x10aux::set_remote_ref(obj.operator->(), ref); - return obj; + // res is uninitialized if rr.ref is null + return _finalize_reference<T>(res, rr); } - // FIXME: factor out common code with _deserialize - template<class R> x10aux::ref<R> Ref::_deserialize_reference(x10aux::deserialization_buffer &buf) { - x10_int loc = buf.read<x10_int>(); - x10aux::x10_addr_t ref = buf.read<x10aux::x10_addr_t>(); - if (ref == 0 /*TODO: id == 0*/) { - _S_("Deserializing a "<<ANSI_SER<<ANSI_BOLD<<"null reference"<<ANSI_RESET<<" from buf: "<<&buf); + // 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> Ref::_finalize_reference(x10aux::ref<Ref> obj, Ref::_reference_state rr) { + if (rr.ref == 0) { return x10aux::null; } - _S_("Attempting to deserialize a "<<ANSI_SER<<ANSI_BOLD<<"ref"<<ANSI_RESET<< - " of type "<<TYPENAME(R)<<" at "<<loc<<" from buf: "<<&buf); - if (loc == x10aux::here) { // a remote object coming home to roost + if (rr.loc == x10aux::here) { // a remote object coming home to roost _S_("\ta local object come home"); - // Nothing left in the buffer (if _serialize_reference was used to serialize the object) - return static_cast<R*>((void*)(size_t)ref); + x10aux::dealloc_remote(obj.operator->()); + return static_cast<R*>((void*)(size_t)rr.ref); } - x10aux::ref<R> obj = new (x10aux::alloc_remote<R>()) R(); - _S_("Deserializing a "<<ANSI_SER<<ANSI_BOLD<<"class"<<ANSI_RESET<< - " "<<obj->_type()->name()<<" from buf: "<<&buf); - obj->location = loc; - x10aux::set_remote_ref(obj.operator->(), 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; } Modified: trunk/x10.runtime/src-cpp/x10/lang/String.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/String.cc 2009-10-25 09:35:28 UTC (rev 11730) +++ trunk/x10.runtime/src-cpp/x10/lang/String.cc 2009-10-25 09:40:59 UTC (rev 11731) @@ -290,29 +290,45 @@ } const serialization_id_t String::_serialization_id = - DeserializationDispatcher::addDeserializer(String::_deserialize<Object>); + DeserializationDispatcher::addDeserializer(String::_deserializer<Object>); -void -String::_serialize(x10aux::ref<String> this_, x10aux::serialization_buffer &buf, x10aux::addr_map &m) { - if (this_==x10aux::null) { - String v; - v._serialize_body(buf,m); - } else { +// Specialized serialization +void String::_serialize(x10aux::ref<String> this_, x10aux::serialization_buffer &buf, x10aux::addr_map &m) { + Ref::_serialize_reference(this_, buf, m); + if (this_ != x10aux::null) { this_->_serialize_body(buf, m); } } -void -String::_serialize_body(x10aux::serialization_buffer& buf, x10aux::addr_map &m) { +void String::_serialize_body(x10aux::serialization_buffer& buf, x10aux::addr_map &m) { this->Ref::_serialize_body(buf, m); // only support strings that are shorter than 4billion chars x10_int sz = FMGL(content_length); - buf.write(sz,m); - for (x10_int i=0 ; i<sz ; ++i) { - buf.write((x10_char)FMGL(content)[i],m); + buf.write(sz, m); + const char* content = FMGL(content); + for (x10_int i = 0; i < sz; ++i) { + buf.write((x10_char)content[i], m); } } +void String::_destructor() { + dealloc(FMGL(content)); +} + +void String::_deserialize_body(x10aux::deserialization_buffer &buf) { + this->Ref::_deserialize_body(buf); + x10_int sz = buf.read<x10_int>(); + char *content = x10aux::alloc<char>(sz+1); + for (x10_int i = 0; i < sz; ++i) { + content[i] = (char)buf.read<x10_char>().v; + } + content[sz] = '\0'; + this->FMGL(content) = content; + this->FMGL(content_length) = strlen(content); + _S_("Deserialized string was: \""<<this<<"\""); +} + + RTT_CC_DECLS1(String, "x10.lang.String", Ref) // vim:tabstop=4:shiftwidth=4:expandtab Modified: trunk/x10.runtime/src-cpp/x10/lang/String.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/String.h 2009-10-25 09:35:28 UTC (rev 11730) +++ trunk/x10.runtime/src-cpp/x10/lang/String.h 2009-10-25 09:40:59 UTC (rev 11731) @@ -99,14 +99,20 @@ x10aux::serialization_buffer &buf, x10aux::addr_map &m); - template<class T> static x10aux::ref<T> _deserialize(x10aux::deserialization_buffer &buf); - static const x10aux::serialization_id_t _serialization_id; virtual x10aux::serialization_id_t _get_serialization_id() { return _serialization_id; }; virtual void _serialize_body(x10aux::serialization_buffer& buf, x10aux::addr_map &m); + template<class T> static x10aux::ref<T> _deserializer(x10aux::deserialization_buffer &buf); + + void _deserialize_body(x10aux::deserialization_buffer &buf); + + template<class T> static x10aux::ref<T> _deserialize(x10aux::deserialization_buffer &buf); + + virtual void _destructor(); + static x10aux::ref<String> format(x10aux::ref<String> format, x10aux::ref<ValRail<x10aux::ref<Object> > > parms); @@ -141,19 +147,22 @@ } #endif - template<class T> x10aux::ref<T> String::_deserialize(x10aux::deserialization_buffer &buf){ - x10_int sz = buf.read<x10_int>(); - char *content = x10aux::alloc<char>(sz+1); - for (x10_int i=0 ; i<sz ; ++i) { - content[i] = (char)buf.read<x10_char>().v; - } - content[sz] = '\0'; - // there are no fields - x10aux::ref<String> this_ = Steal(content); - _S_("Deserialized string was: \""<<this_<<"\""); + template<class T> x10aux::ref<T> String::_deserializer(x10aux::deserialization_buffer& buf) { + x10aux::ref<String> this_ = new (x10aux::alloc_remote<String>()) String(); + this_->_deserialize_body(buf); return this_; } - + + // Specialized deserialization + template<class T> x10aux::ref<T> String::_deserialize(x10aux::deserialization_buffer &buf) { + Ref::_reference_state rr = Ref::_deserialize_reference_state(buf); + x10aux::ref<String> this_; + if (rr.ref != 0) { + this_ = String::_deserializer<String>(buf); + } + return Ref::_finalize_reference<T>(this_, rr); + } + } // namespace x10::lang } // namespace x10 Modified: trunk/x10.runtime/src-cpp/x10/lang/Throwable.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Throwable.cc 2009-10-25 09:35:28 UTC (rev 11730) +++ trunk/x10.runtime/src-cpp/x10/lang/Throwable.cc 2009-10-25 09:40:59 UTC (rev 11731) @@ -37,8 +37,9 @@ void Throwable::_serialize_body(x10aux::serialization_buffer &buf, x10aux::addr_map &m) { this->Ref::_serialize_body(buf, m); - buf.write(FMGL(cause),m); - buf.write(FMGL(message),m); + buf.write(FMGL(cause), m); + buf.write(FMGL(message), m); + // TODO: serialize the trace } void @@ -46,6 +47,7 @@ this->Ref::_deserialize_body(buf); FMGL(cause) = buf.read<x10aux::ref<Throwable> >(); FMGL(message) = buf.read<x10aux::ref<String> >(); + // TODO: deserialize the trace } x10aux::ref<Throwable> Modified: trunk/x10.runtime/src-cpp/x10/lang/ValRail.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/ValRail.h 2009-10-25 09:35:28 UTC (rev 11730) +++ trunk/x10.runtime/src-cpp/x10/lang/ValRail.h 2009-10-25 09:40:59 UTC (rev 11731) @@ -81,17 +81,24 @@ static const x10aux::serialization_id_t _serialization_id; + virtual x10aux::serialization_id_t _get_serialization_id() { return _serialization_id; }; + static void _serialize(x10aux::ref<ValRail<T> > this_, x10aux::serialization_buffer &buf, x10aux::addr_map &m); - virtual x10aux::serialization_id_t _get_serialization_id() { return _serialization_id; }; + void _serialize_body(x10aux::serialization_buffer &buf, x10aux::addr_map &m); + + void _deserialize_body(x10aux::deserialization_buffer &buf); + + template<class S> static x10aux::ref<S> _deserializer(x10aux::deserialization_buffer &buf); + template<class S> static x10aux::ref<S> _deserialize(x10aux::deserialization_buffer &buf); }; template<class T> const x10aux::serialization_id_t ValRail<T>::_serialization_id = x10aux::DeserializationDispatcher - ::addDeserializer(ValRail<T>::template _deserialize<Object>); + ::addDeserializer(ValRail<T>::template _deserializer<Object>); template<class T> void ValRail<T>::_initRTT() { rtt.canonical = &rtt; @@ -108,17 +115,17 @@ static const x10aux::RuntimeType* getRTT() { return &rtt; } }; - template <class T> typename Iterable<T>::template itable<ValRail<T> > ValRail<T>::_itable_iterable(&ValRail<T>::iterator); + template<class T> typename Iterable<T>::template itable<ValRail<T> > ValRail<T>::_itable_iterable(&ValRail<T>::iterator); - template <class T> typename Fun_0_1<x10_int,T>::template itable<ValRail<T> > ValRail<T>::_itable_fun(&ValRail<T>::apply); + template<class T> typename Fun_0_1<x10_int,T>::template itable<ValRail<T> > ValRail<T>::_itable_fun(&ValRail<T>::apply); - template <class T> x10aux::itable_entry ValRail<T>::_itables[3] = { + template<class T> x10aux::itable_entry ValRail<T>::_itables[3] = { x10aux::itable_entry(&Iterable<T>::rtt, &ValRail<T>::_itable_iterable), x10aux::itable_entry(&Fun_0_1<x10_int, T>::rtt, &ValRail<T>::_itable_fun), x10aux::itable_entry(NULL, (void*)x10aux::getRTT<ValRail<T> >()) }; - template <class T> x10aux::ref<ValRail<T> > ValRail<T>::make(x10_int length) { + template<class T> x10aux::ref<ValRail<T> > ValRail<T>::make(x10_int length) { x10aux::ref<ValRail<T> > rail = x10aux::alloc_rail<T,ValRail<T> >(length); rail->x10::lang::Ref::_constructor(); // Memset both for efficiency and to allow T to be a struct. @@ -126,7 +133,7 @@ return rail; } - template <class T> x10aux::ref<ValRail<T> > ValRail<T>::make(x10_int length, + template<class T> x10aux::ref<ValRail<T> > ValRail<T>::make(x10_int length, x10aux::ref<Fun_0_1<x10_int,T> > init ) { x10aux::ref<ValRail<T> > rail = x10aux::alloc_rail<T,ValRail<T> >(length); rail->x10::lang::Ref::_constructor(); @@ -149,32 +156,52 @@ return rail; } + // Specialized serialization template <class T> void ValRail<T>::_serialize(x10aux::ref<ValRail<T> > this_, x10aux::serialization_buffer &buf, x10aux::addr_map &m) { - if (this_ == x10aux::null) { - ValRail<T> v; - v._serialize_body(buf, m); - } else { + Ref::_serialize_reference(this_, buf, m); + if (this_ != x10aux::null) { this_->_serialize_body(buf, m); } } template <class T> void ValRail<T>::_serialize_body(x10aux::serialization_buffer &buf, x10aux::addr_map &m) { - buf.write(this->FMGL(length),m); - for (x10_int i=0 ; i<this->FMGL(length) ; ++i) { - buf.write(this->raw()[i], m); // avoid bounds check + x10_int length = this->FMGL(length); + buf.write(length, m); + this->Ref::_serialize_body(buf, m); // intentional change of order + T* raw = this->raw(); + for (x10_int i=0 ; i<length ; ++i) { + buf.write(raw[i], m); // avoid bounds check } } - template <class T> template<class S> x10aux::ref<S> ValRail<T>::_deserialize(x10aux::deserialization_buffer &buf) { - x10_int length = buf.read<x10_int>(); - x10aux::ref<ValRail> this_ = x10aux::alloc_rail_remote<T,ValRail<T> >(length); + template <class T> void ValRail<T>::_deserialize_body(x10aux::deserialization_buffer &buf) { + // length read out earlier, in _deserializer() + this->Ref::_deserialize_body(buf); + x10_int length = this->FMGL(length); + T* raw = this->raw(); for (x10_int i=0 ; i<length ; ++i) { - this_->raw()[i] = buf.read<T>(); // avoid bounds check + raw[i] = buf.read<T>(); // avoid bounds check } + } + + template <class T> template<class S> x10aux::ref<S> ValRail<T>::_deserializer(x10aux::deserialization_buffer &buf) { + x10_int length = buf.read<x10_int>(); + x10aux::ref<ValRail<T> > this_ = x10aux::alloc_rail_remote<T,ValRail<T> >(length); + this_->_deserialize_body(buf); return this_; } + + // Specialized deserialization + template <class T> template<class S> x10aux::ref<S> ValRail<T>::_deserialize(x10aux::deserialization_buffer &buf) { + Ref::_reference_state rr = Ref::_deserialize_reference_state(buf); + x10aux::ref<ValRail<T> > this_; + if (rr.ref != 0) { + this_ = ValRail<T>::template _deserializer<ValRail<T> >(buf); + } + return Ref::_finalize_reference<T>(this_, rr); + } } } Modified: trunk/x10.runtime/src-cpp/x10/util/GrowableRail.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/util/GrowableRail.h 2009-10-25 09:35:28 UTC (rev 11730) +++ trunk/x10.runtime/src-cpp/x10/util/GrowableRail.h 2009-10-25 09:40:59 UTC (rev 11731) @@ -46,6 +46,8 @@ virtual void _deserialize_body(x10aux::deserialization_buffer& buf); + // No specialized serialization methods - not optimizing this final class + T set(T v, x10_int i); void add(T v); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <vj...@us...> - 2009-10-26 07:07:47
|
Revision: 11757 http://x10.svn.sourceforge.net/x10/?rev=11757&view=rev Author: vj0 Date: 2009-10-26 07:07:24 +0000 (Mon, 26 Oct 2009) Log Message: ----------- X10 2.0 type system, with Values and Ref scrubbed, Object a class, and Any an interface. Note: Jave codegen is now broken and needs to be fixed. Modified Paths: -------------- trunk/x10.compiler/src/x10/ast/ClosureCall_c.java trunk/x10.compiler/src/x10/ast/FunctionTypeNode_c.java trunk/x10.compiler/src/x10/ast/PlacedClosure_c.java trunk/x10.compiler/src/x10/ast/TypeDecl_c.java trunk/x10.compiler/src/x10/ast/X10Binary_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/X10FieldDecl_c.java trunk/x10.compiler/src/x10/ast/X10Field_c.java trunk/x10.compiler/src/x10/ast/X10Formal_c.java trunk/x10.compiler/src/x10/ast/X10New_c.java trunk/x10.compiler/src/x10/emitter/Emitter.java trunk/x10.compiler/src/x10/emitter/RuntimeTypeExpander.java trunk/x10.compiler/src/x10/query/QueryEngine.java trunk/x10.compiler/src/x10/types/ClosureDef.java trunk/x10.compiler/src/x10/types/ClosureDef_c.java trunk/x10.compiler/src/x10/types/ClosureInstance.java trunk/x10.compiler/src/x10/types/ClosureInstance_c.java trunk/x10.compiler/src/x10/types/ClosureType_c.java trunk/x10.compiler/src/x10/types/X10ClassDef.java trunk/x10.compiler/src/x10/types/X10ClassDef_c.java trunk/x10.compiler/src/x10/types/X10FieldInstance_c.java trunk/x10.compiler/src/x10/types/X10MethodInstance_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/types/XTypeTranslator.java trunk/x10.compiler/src/x10/visit/Desugarer.java trunk/x10.compiler/src/x10/visit/X10LocalClassRemover.java trunk/x10.compiler/src/x10/visit/X10PrettyPrinterVisitor.java trunk/x10.compiler/src/x10cpp/visit/Emitter.java trunk/x10.runtime/src-java/x10/core/ValRail.java trunk/x10.runtime/src-x10/Dummy.x10 trunk/x10.runtime/src-x10/x10/array/BaseArray.x10 trunk/x10.runtime/src-x10/x10/array/FastArray.x10 trunk/x10.runtime/src-x10/x10/array/LocalArray.x10 trunk/x10.runtime/src-x10/x10/array/PolyMat.x10 trunk/x10.runtime/src-x10/x10/array/U.x10 trunk/x10.runtime/src-x10/x10/io/Printer.x10 trunk/x10.runtime/src-x10/x10/lang/Box.x10 trunk/x10.runtime/src-x10/x10/lang/Complex.x10 trunk/x10.runtime/src-x10/x10/lang/Equals.x10 trunk/x10.runtime/src-x10/x10/lang/Object.x10 trunk/x10.runtime/src-x10/x10/lang/Place.x10 trunk/x10.runtime/src-x10/x10/lang/RankMismatchException.x10 trunk/x10.runtime/src-x10/x10/lang/System.x10 trunk/x10.runtime/src-x10/x10/runtime/Activity.x10 trunk/x10.runtime/src-x10/x10/runtime/NativeRuntime.x10 trunk/x10.runtime/src-x10/x10/runtime/PlaceLocalHandle.x10 trunk/x10.runtime/src-x10/x10/runtime/PlaceLocalStorage.x10 trunk/x10.runtime/src-x10/x10/runtime/RID.x10 trunk/x10.runtime/src-x10/x10/runtime/Runtime.x10 trunk/x10.runtime/src-x10/x10/util/Pair.x10 trunk/x10.runtime/src-x10/x10/util/StringBuilder.x10 trunk/x10.runtime/src-x10/x10/util/concurrent/atomic/AtomicReference.x10 Added Paths: ----------- trunk/x10.compiler/src/x10/types/FunctionType.java trunk/x10.runtime/src-x10/x10/lang/Struct.x10 trunk/x10.runtime/src-x10/x10/lang/Top.x10 Removed Paths: ------------- trunk/x10.compiler/src/x10/types/ClosureType.java trunk/x10.runtime/src-x10/x10/lang/Ref.x10 trunk/x10.runtime/src-x10/x10/lang/Value.x10 Modified: trunk/x10.compiler/src/x10/ast/ClosureCall_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/ClosureCall_c.java 2009-10-26 06:24:33 UTC (rev 11756) +++ trunk/x10.compiler/src/x10/ast/ClosureCall_c.java 2009-10-26 07:07:24 UTC (rev 11757) @@ -53,7 +53,7 @@ import polyglot.visit.TypeBuilder; import x10.types.ClosureDef; import x10.types.ClosureInstance; -import x10.types.ClosureType; +import x10.types.FunctionType; import x10.types.X10MethodInstance; import x10.types.X10MethodInstance_c; import x10.types.X10TypeSystem; @@ -294,8 +294,8 @@ // Find the most-specific closure type. - if (mi.container() instanceof ClosureType) { - X10MethodInstance ci = ((ClosureType) mi.container()).applyMethod(); + if (mi.container() instanceof FunctionType) { + X10MethodInstance ci = ((FunctionType) mi.container()).applyMethod(); ClosureCall_c n = this; n = (ClosureCall_c) n.arguments(args); return n.closureInstance(ci).type(ci.returnType()); Modified: trunk/x10.compiler/src/x10/ast/FunctionTypeNode_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/FunctionTypeNode_c.java 2009-10-26 06:24:33 UTC (rev 11756) +++ trunk/x10.compiler/src/x10/ast/FunctionTypeNode_c.java 2009-10-26 07:07:24 UTC (rev 11757) @@ -18,6 +18,7 @@ import polyglot.ast.NodeFactory; import polyglot.ast.TypeNode; import polyglot.ast.TypeNode_c; +import polyglot.frontend.SetResolverGoal; import polyglot.types.ClassType; import polyglot.types.CodeDef; import polyglot.types.CodeInstance; @@ -38,6 +39,7 @@ import polyglot.visit.NodeVisitor; import polyglot.visit.PrettyPrinter; import x10.constraint.XConstraint; +import x10.constraint.XConstraint_c; import x10.types.ClosureDef; import x10.types.X10ClassType; import x10.types.X10TypeSystem; @@ -91,7 +93,8 @@ Type result = ts.closureType(position(), returnType.typeRef(), // typeParams, formalTypes, formalNames, - guard != null ? guard.valueConstraint() : null, + guard != null ? guard.valueConstraint() + : Types.<XConstraint>lazyRef(new XConstraint_c()), // guard != null ? guard.typeConstraint() : null, throwTypes); Modified: trunk/x10.compiler/src/x10/ast/PlacedClosure_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/PlacedClosure_c.java 2009-10-26 06:24:33 UTC (rev 11756) +++ trunk/x10.compiler/src/x10/ast/PlacedClosure_c.java 2009-10-26 07:07:24 UTC (rev 11757) @@ -120,7 +120,7 @@ term + " and constraint " + d + "."); } } else { - boolean placeIsRef = ts.isImplicitCastValid(placeType, ts.Ref(), xc); + boolean placeIsRef = ts.isImplicitCastValid(placeType, ts.Object(), xc); if (placeIsRef) { XTerm src = ts.xtypeTranslator().trans(pc, place, xc); if (src == null) { @@ -137,7 +137,7 @@ } else throw new SemanticException( "Place expression |" + place + "| must be of type \"" + - ts.Place() + "\", or " + ts.Ref() + ", not \"" + place.type() + "\".", + ts.Place() + "\", or " + ts.Object() + ", not \"" + place.type() + "\".", place.position()); } Modified: trunk/x10.compiler/src/x10/ast/TypeDecl_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/TypeDecl_c.java 2009-10-26 06:24:33 UTC (rev 11756) +++ trunk/x10.compiler/src/x10/ast/TypeDecl_c.java 2009-10-26 07:07:24 UTC (rev 11757) @@ -199,7 +199,7 @@ if (! local && ct == null && ! ALLOW_TOP_LEVEL_TYPEDEFS) { throw new SemanticException("Type definitions must be static class or interface members. This is a limitation of the current implementation.", position()); } - +/* if (ALLOW_TOP_LEVEL_TYPEDEFS) { // If this is a top-level typedef, add it to a dummy class for the package. // When looking up types, we'll look for the package class then walk through the members. @@ -222,7 +222,7 @@ ts.systemResolver().install(dummyClass, ct.asType()); } } - +*/ TypeDef typeDef; XRoot thisVar = ct != null ? ct.thisVar() : null; Modified: trunk/x10.compiler/src/x10/ast/X10Binary_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10Binary_c.java 2009-10-26 06:24:33 UTC (rev 11756) +++ trunk/x10.compiler/src/x10/ast/X10Binary_c.java 2009-10-26 07:07:24 UTC (rev 11757) @@ -86,7 +86,8 @@ X10TypeSystem xts = (X10TypeSystem) lt.typeSystem(); if (lt == null || rt == null) return false; - if (operator() == Binary.EQ || operator() == Binary.NE) { + /* In X10 2.0, nothing can be of Value type. + * if (operator() == Binary.EQ || operator() == Binary.NE) { X10Context context = (X10Context) xts.emptyContext(); if (xts.isValueType(lt, context) && xts.isReferenceOrInterfaceType(rt, context)) return true; @@ -97,6 +98,7 @@ if (xts.isValueType(rt, context) && lt.isNull()) return true; } + */ return false; } @@ -114,27 +116,29 @@ X10Context context = (X10Context) xts.emptyContext(); // [IP] An optimization: an value and null can never be equal - if (op == EQ) { - if (xts.isValueType(lt, context) && xts.isReferenceOrInterfaceType(rt, context)) + + if (op == EQ) { + if (xts.isStructType(lt) && xts.isReferenceOrInterfaceType(rt, context)) return Boolean.FALSE; - if (xts.isReferenceOrInterfaceType(lt, context) && xts.isValueType(rt, context)) + if (xts.isReferenceOrInterfaceType(lt, context) && xts.isStructType(rt)) return Boolean.FALSE; - if ( xts.isValueType(lt, context) && rt.isNull()) + if ( xts.isStructType(lt) && rt.isNull()) return Boolean.FALSE; - if ( xts.isValueType(rt, context) && lt.isNull()) + if ( xts.isStructType(rt) && lt.isNull()) return Boolean.FALSE; } if (op == NE) { - if (xts.isValueType(lt, context) && xts.isReferenceOrInterfaceType(rt, context)) + if (xts.isStructType(lt) && xts.isReferenceOrInterfaceType(rt, context)) return Boolean.TRUE; - if (xts.isReferenceOrInterfaceType(lt, context) && xts.isValueType(rt, context)) + if (xts.isReferenceOrInterfaceType(lt, context) && xts.isStructType(rt)) return Boolean.TRUE; - if (xts.isValueType(lt, context) && rt.isNull()) + if (xts.isStructType(lt) && rt.isNull()) return Boolean.TRUE; - if (xts.isValueType(rt, context) && lt.isNull()) + if (xts.isStructType(rt) && lt.isNull()) return Boolean.TRUE; return null; } + return null; } @@ -305,6 +309,19 @@ Type lbase = X10TypeMixin.baseType(left.type()); Type rbase = X10TypeMixin.baseType(right.type()); + if (op == EQ || op == NE) { + if (xts.isFunctionType(lbase)) { + throw new SemanticException("The " + op + + " operator cannot be applied to the function " + left, + position()); + } + if (xts.isFunctionType(rbase)) { + throw new SemanticException("The " + op + + " operator cannot be applied to the function " + right, + position()); + } + + } if (op == EQ || op == NE || op == LT || op == GT || op == LE || op == GE) { Object lv = left.isConstant() ? left.constantValue() : null; Object rv = right.isConstant() ? right.constantValue() : null; Modified: trunk/x10.compiler/src/x10/ast/X10Call_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10Call_c.java 2009-10-26 06:24:33 UTC (rev 11756) +++ trunk/x10.compiler/src/x10/ast/X10Call_c.java 2009-10-26 07:07:24 UTC (rev 11757) @@ -490,10 +490,12 @@ && xts.isParameterType(targetType) && xts.isParameterType(argTypes.get(0))) { // Check that both equals(Ref) and equals(Value) are present mi = (X10MethodInstance) xts.findMethod(targetType, - xts.MethodMatcher(targetType, name, typeArgs, Collections.singletonList(xts.Ref()), c)); - mi = null; + xts.MethodMatcher(targetType, name, typeArgs, Collections.singletonList(xts.Object()), c)); + //mi = null; + /* mi = (X10MethodInstance) xts.findMethod(targetType, xts.MethodMatcher(targetType, name, typeArgs, Collections.singletonList(xts.Value()), c)); + */ mi = (X10MethodInstance) mi.formalTypes(Collections.singletonList(X10TypeMixin.baseType(targetType))); LocalInstance d = mi.formalNames().get(0); mi = (X10MethodInstance) mi.formalNames(Collections.singletonList(d.type(X10TypeMixin.baseType(targetType)))); @@ -582,7 +584,7 @@ // Method invocations on structs and values are always permitted - if (! ts.isSubtype(target.type(), ts.Ref(), xc)) + if (! ts.isSubtype(target.type(), ts.Object(), xc)) return; Modified: trunk/x10.compiler/src/x10/ast/X10Cast_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10Cast_c.java 2009-10-26 06:24:33 UTC (rev 11756) +++ trunk/x10.compiler/src/x10/ast/X10Cast_c.java 2009-10-26 07:07:24 UTC (rev 11757) @@ -190,8 +190,8 @@ String c = convert == ConversionType.UNKNOWN_CONVERSION ? "cast" : "implicitly convert"; - throw new SemanticException("Cannot " + c + " expression of type \"" - + fromType + "\" to type \"" + throw new SemanticException("Golden!! Cannot " + c + " expression of type \n\"" + + fromType + "\"\n to type \"" + toType + "\".", position()); } Modified: trunk/x10.compiler/src/x10/ast/X10ClassDecl_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10ClassDecl_c.java 2009-10-26 06:24:33 UTC (rev 11756) +++ trunk/x10.compiler/src/x10/ast/X10ClassDecl_c.java 2009-10-26 07:07:24 UTC (rev 11757) @@ -206,33 +206,27 @@ // during bootstrapping: Object, refers to Int, refers to Object, ... final LazyRef<Type> superRef = Types.lazyRef(null); - if (thisType.fullName().equals(QName.make("x10.lang.Ref"))) { + if (thisType.fullName().equals(QName.make("x10.lang.Object"))) { thisType.superType(null); - } - else if (thisType.fullName().equals(QName.make("x10.lang.Value"))) { + } else if (thisType.fullName().equals(QName.make("x10.lang.Struct"))) { thisType.superType(null); - } - else if (thisType.fullName().equals(QName.make("x10.lang.Object"))) { - thisType.superType(null); } else if (flags().flags().isInterface()) { thisType.superType(null); } - else if (superClass == null && X10Flags.toX10Flags(flags().flags()).isValue()) { - superRef.setResolver(new Runnable() { - public void run() { - superRef.update(xts.Value()); - } - }); - thisType.superType(superRef); - } - else if (superClass == null && X10Flags.toX10Flags(flags().flags()).isStruct()) { - thisType.superType(null); + else if (superClass == null && X10Flags.toX10Flags(flags().flags()).isStruct()) { + final LazyRef<Type> Struct = Types.lazyRef(null); + Struct.setResolver(new Runnable() { + public void run() { + Struct.update(xts.Struct()); + } + }); + thisType.superType(Struct); } else if (superClass == null) { superRef.setResolver(new Runnable() { public void run() { - superRef.update(xts.Ref()); + superRef.update(xts.Object()); } }); thisType.superType(superRef); @@ -244,55 +238,30 @@ @Override protected void setInterfaces(TypeSystem ts, ClassDef thisType) throws SemanticException { - final X10TypeSystem xts = (X10TypeSystem) ts; + final X10TypeSystem xts = (X10TypeSystem) ts; -// if (thisType.fullName().equals(QName.make("x10.lang.Ref"))) { -// // We need to lazily set the superclass, otherwise we go into an infinite loop -// // during bootstrapping: Object, refers to Int, refers to Object, ... -// final LazyRef<Type> superRef = Types.lazyRef(null); -// superRef.setResolver(new Runnable() { -// public void run() { -// superRef.update(xts.Object()); -// } -// }); -// thisType.addInterface(superRef); -// if (! interfaces.isEmpty()) { -// super.setInterfaces(ts, thisType); -// } -// } -// else if (thisType.fullName().equals(QName.make("x10.lang.Value"))) { -// // We need to lazily set the superclass, otherwise we go into an infinite loop -// // during bootstrapping: Object, refers to Int, refers to Object, ... -// final LazyRef<Type> superRef = Types.lazyRef(null); -// superRef.setResolver(new Runnable() { -// public void run() { -// superRef.update(xts.Object()); -// } -// }); -// thisType.addInterface(superRef); -// if (! interfaces.isEmpty()) { -// super.setInterfaces(ts, thisType); -// } -// } -// else - if (thisType.fullName().equals(QName.make("x10.lang.Object"))) { - } - else if (interfaces.isEmpty() && flags().flags().isInterface()) { - // We need to lazily set the superclass, otherwise we go into an infinite loop - // during bootstrapping: Object, refers to Int, refers to Object, ... - final LazyRef<Type> superRef = Types.lazyRef(null); - superRef.setResolver(new Runnable() { - public void run() { - superRef.update(xts.Object()); - } - }); - thisType.addInterface(superRef); - } - else { - super.setInterfaces(ts, thisType); - } + // For every struct and interface, add the implicit Any interface. + X10Flags flags = X10Flags.toX10Flags(flags().flags()); + if (flags.isStruct() + || (flags.isInterface() && ! name.toString().equals("Any")) + || thisType.fullName().equals(QName.make("x10.lang.Object")) + || xts.isParameterType(thisType.asType())) { + + // We need to lazily set the superclass, otherwise we go into an infinite loop + // during bootstrapping: Object, refers to Int, refers to Object, ... + final LazyRef<Type> ANY = Types.lazyRef(null); + ANY.setResolver(new Runnable() { + public void run() { + ANY.update(xts.Any()); + } + }); + thisType.addInterface(ANY); + } + + super.setInterfaces(ts, thisType); } + public Node disambiguate(ContextVisitor ar) throws SemanticException { ClassDecl n = (ClassDecl) super.disambiguate(ar); @@ -806,8 +775,128 @@ return tn; } + public Node superConformanceCheck(ContextVisitor tc) throws SemanticException { + TypeSystem ts = tc.typeSystem(); + + ClassType type = this.type.asType(); + Name name = this.name.id(); + + // The class cannot have the same simple name as any enclosing class. + if (type.isNested()) { + ClassType container = type.outer(); + + while (container != null) { + if (!container.isAnonymous()) { + Name cname = container.name(); + + if (cname.equals(name)) { + throw new SemanticException("Cannot declare member " + + "class \"" + type.fullName() + + "\" inside class with the " + + "same name.", position()); + } + } + if (container.isNested()) { + container = container.outer(); + } + else { + break; + } + } + } + + // A local class name cannot be redeclared within the same + // method, constructor or initializer, and within its scope + if (type.isLocal()) { + Context ctxt = tc.context(); + + if (ctxt.isLocal(name)) { + // Something with the same name was declared locally. + // (but not in an enclosing class) + Named nm = ctxt.find(ts.TypeMatcher(name)); + if (nm instanceof Type) { + Type another = (Type) nm; + if (another.isClass() && another.toClass().isLocal()) { + throw new SemanticException("Cannot declare local " + + "class \"" + this.type + "\" within the same " + + "method, constructor or initializer as another " + + "local class of the same name.", position()); + } + } + } + } + + // check that inner classes do not declare member interfaces + if (type.isMember() && type.flags().isInterface() && + type.outer().isInnerClass()) { + // it's a member interface in an inner class. + throw new SemanticException("Inner classes cannot declare " + + "member interfaces.", this.position()); + } + + // Make sure that static members are not declared inside inner classes + if (type.isMember() && type.flags().isStatic() + && type.outer().isInnerClass()) { + throw new SemanticException("Inner classes cannot declare static " + + "member classes.", position()); + } + + if (type.superClass() != null) { + if (! type.superClass().isClass() || type.superClass().toClass().flags().isInterface()) { + throw new SemanticException("Cannot extend non-class \"" + + type.superClass() + "\".", + position()); + } + + if (type.superClass().toClass().flags().isFinal()) { + throw new SemanticException("Cannot extend final class \"" + + type.superClass() + "\".", + position()); + } + + if (type.typeEquals(ts.Object(), tc.context())) { + throw new SemanticException("Class \"" + this.type + "\" cannot have a superclass.", + superClass.position()); + } + } + + for (Iterator<TypeNode> i = interfaces.iterator(); i.hasNext(); ) { + TypeNode tn = (TypeNode) i.next(); + Type t = tn.type(); + + if (! t.isClass() || ! t.toClass().flags().isInterface()) { + throw new SemanticException("Superinterface " + t + " of " + + type + " is not an interface.", tn.position()); + } + + /* if (type.typeEquals(ts.Object(), tc.context())) { + throw new SemanticException("Class " + this.type + " cannot have a superinterface.", + tn.position()); + }*/ + } + + try { + if (type.isTopLevel()) { + ts.checkTopLevelClassFlags(type.flags()); + } + if (type.isMember()) { + ts.checkMemberClassFlags(type.flags()); + } + if (type.isLocal()) { + ts.checkLocalClassFlags(type.flags()); + } + } + catch (SemanticException e) { + throw new SemanticException(e.getMessage(), position()); + } + + // Check the class implements all abstract methods that it needs to. + ts.checkClassConformance(type, enterChildScope(body, tc.context())); + + return this; + } public Node conformanceCheck(ContextVisitor tc) throws SemanticException { - X10ClassDecl_c result = (X10ClassDecl_c) super.conformanceCheck(tc); + X10ClassDecl_c result = (X10ClassDecl_c) superConformanceCheck(tc); X10Context context = (X10Context) tc.context(); // Check that we're in the right file. @@ -825,25 +914,13 @@ Type superClass = type.asType().superClass(); - if (! flags.flags().isInterface()) { - if (X10Flags.toX10Flags(flags.flags()).isValue()) { - if (superClass != null && ! ts.isValueType(superClass, context)) { - throw new SemanticException("Value class " + type + " cannot extend reference class " + superClass + ".", position()); - } - } - else { - if (superClass != null && ts.isValueType(superClass, context)) { - throw new SemanticException("Reference class " + type + " cannot extend value class " + superClass + ".", position()); - } - } + + if (flags.flags().isInterface() && superClass != null) { + throw new SemanticException("Interface " + this.type + " cannot have a superclass.", + superClass.position()); } - else { - if (superClass != null) { - throw new SemanticException("Interface " + this.type + " cannot have a superclass.", - superClass.position()); - } - } + if (superClass != null) { for (PropertyDecl pd : properties()) { SemanticException ex = null; Modified: trunk/x10.compiler/src/x10/ast/X10FieldDecl_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10FieldDecl_c.java 2009-10-26 06:24:33 UTC (rev 11756) +++ trunk/x10.compiler/src/x10/ast/X10FieldDecl_c.java 2009-10-26 07:07:24 UTC (rev 11757) @@ -98,10 +98,10 @@ X10TypeSystem xts = (X10TypeSystem) ref.typeSystem(); X10Context context = (X10Context) tc.context(); - if (xts.isValueType(ref, context) && !fi.flags().isFinal()) { + /* if (xts.isValueType(ref, context) && !fi.flags().isFinal()) { 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()) { Modified: trunk/x10.compiler/src/x10/ast/X10Field_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10Field_c.java 2009-10-26 06:24:33 UTC (rev 11756) +++ trunk/x10.compiler/src/x10/ast/X10Field_c.java 2009-10-26 07:07:24 UTC (rev 11757) @@ -288,7 +288,7 @@ X10Context xc = (X10Context) tc.context(); Receiver target = target(); - if (! ts.isSubtype(target.type(), ts.Ref(), xc)) + if (! ts.isSubtype(target.type(), ts.Object(), xc)) return; if (ts.isHere(target, xc)) Modified: trunk/x10.compiler/src/x10/ast/X10Formal_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10Formal_c.java 2009-10-26 06:24:33 UTC (rev 11756) +++ trunk/x10.compiler/src/x10/ast/X10Formal_c.java 2009-10-26 07:07:24 UTC (rev 11757) @@ -49,7 +49,7 @@ import polyglot.visit.TypeCheckPreparer; import polyglot.visit.TypeChecker; import x10.extension.X10Del; -import x10.types.ClosureType; +import x10.types.FunctionType; import x10.types.X10Context; import x10.types.X10LocalDef; import x10.types.X10LocalInstance; @@ -173,11 +173,11 @@ Type containerType = ff.type().type(); Type indexType = null; - if (ts.isFunction(containerType, context)) { + if (ts.isFunctionType(containerType)) { List<Type> actualTypes = Collections.singletonList(ts.Int()); try { - // Find the most-specific closure type. + // Find the most-specific function type. X10MethodInstance mi = ts.findMethod(containerType, ts.MethodMatcher(containerType, Name.make("apply"), Collections.EMPTY_LIST, actualTypes, context)); @@ -204,7 +204,7 @@ public Node typeCheck(ContextVisitor tc) throws SemanticException { X10Formal_c n = (X10Formal_c) super.typeCheck(tc); if (n.type() instanceof UnknownTypeNode || n.type().type() instanceof UnknownType) { - throw new SemanticException("Could not infer type for formal parameter.", position()); + throw new SemanticException("Could not infer type for formal parameter " + n + ".", position()); } if (n.type().type().isVoid()) throw new SemanticException("Formal parameter cannot have type " + this.type().type() + ".", position()); Modified: trunk/x10.compiler/src/x10/ast/X10New_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10New_c.java 2009-10-26 06:24:33 UTC (rev 11756) +++ trunk/x10.compiler/src/x10/ast/X10New_c.java 2009-10-26 07:07:24 UTC (rev 11757) @@ -130,12 +130,12 @@ if (!flags.isInterface()) { anonType.superType(ct); } - else if (flags.isValue()) { + else /*if (flags.isValue()) { anonType.superType(Types.<Type> ref(ts.Value())); anonType.setInterfaces(Collections.<Ref<? extends Type>> singletonList(ct)); } - else { - anonType.superType(Types.<Type> ref(ts.Ref())); + else */{ + anonType.superType(Types.<Type> ref(ts.Object())); anonType.setInterfaces(Collections.<Ref<? extends Type>> singletonList(ct)); } Modified: trunk/x10.compiler/src/x10/emitter/Emitter.java =================================================================== --- trunk/x10.compiler/src/x10/emitter/Emitter.java 2009-10-26 06:24:33 UTC (rev 11756) +++ trunk/x10.compiler/src/x10/emitter/Emitter.java 2009-10-26 07:07:24 UTC (rev 11757) @@ -75,7 +75,7 @@ import x10.constraint.XTerms; import x10.extension.X10Ext; import x10.query.QueryEngine; -import x10.types.ClosureType; +import x10.types.FunctionType; import x10.types.MacroType; import x10.types.ParameterType; import x10.types.X10ClassDef; @@ -432,8 +432,8 @@ return; } - if (type instanceof ClosureType) { - ClosureType ct = (ClosureType) type; + if (type instanceof FunctionType) { + FunctionType ct = (FunctionType) type; List<Type> args = ct.argumentTypes(); Type ret = ct.returnType(); if (ret.isVoid()) { Modified: trunk/x10.compiler/src/x10/emitter/RuntimeTypeExpander.java =================================================================== --- trunk/x10.compiler/src/x10/emitter/RuntimeTypeExpander.java 2009-10-26 06:24:33 UTC (rev 11756) +++ trunk/x10.compiler/src/x10/emitter/RuntimeTypeExpander.java 2009-10-26 07:07:24 UTC (rev 11757) @@ -8,7 +8,7 @@ import polyglot.types.Type; import polyglot.visit.Translator; import x10.constraint.XConstraint; -import x10.types.ClosureType; +import x10.types.FunctionType; import x10.types.ConstrainedType; import x10.types.ParameterType; import x10.types.X10ClassDef; @@ -57,8 +57,8 @@ return; } - if (at instanceof ClosureType) { - ClosureType ct = (ClosureType) at; + if (at instanceof FunctionType) { + FunctionType ct = (FunctionType) at; List<Type> args = ct.argumentTypes(); Type ret = ct.returnType(); er.w.write("new "); Modified: trunk/x10.compiler/src/x10/query/QueryEngine.java =================================================================== --- trunk/x10.compiler/src/x10/query/QueryEngine.java 2009-10-26 06:24:33 UTC (rev 11756) +++ trunk/x10.compiler/src/x10/query/QueryEngine.java 2009-10-26 07:07:24 UTC (rev 11757) @@ -67,7 +67,7 @@ if (!Configuration.BAD_PLACE_RUNTIME_CHECK) return false; X10TypeSystem ts = (X10TypeSystem) t.typeSystem(); - if (ts.isValueType(t, context)) return false; + // if (ts.isValueType(t, context)) return false; return true; } Modified: trunk/x10.compiler/src/x10/types/ClosureDef.java =================================================================== --- trunk/x10.compiler/src/x10/types/ClosureDef.java 2009-10-26 06:24:33 UTC (rev 11756) +++ trunk/x10.compiler/src/x10/types/ClosureDef.java 2009-10-26 07:07:24 UTC (rev 11757) @@ -24,7 +24,7 @@ public interface ClosureDef extends FunctionDef, X10Def, X10ProcedureDef { ClosureInstance asInstance(); - public ClosureType asType(); + public FunctionType asType(); /** * Return a copy of this with position reset. * @param pos Modified: trunk/x10.compiler/src/x10/types/ClosureDef_c.java =================================================================== --- trunk/x10.compiler/src/x10/types/ClosureDef_c.java 2009-10-26 06:24:33 UTC (rev 11756) +++ trunk/x10.compiler/src/x10/types/ClosureDef_c.java 2009-10-26 07:07:24 UTC (rev 11757) @@ -75,9 +75,9 @@ return n; } - ClosureType asType; + FunctionType asType; - public ClosureType asType() { + public FunctionType asType() { if (asType == null) { X10TypeSystem ts = (X10TypeSystem) this.ts; asType = ts.closureType(position(), returnType, Modified: trunk/x10.compiler/src/x10/types/ClosureInstance.java =================================================================== --- trunk/x10.compiler/src/x10/types/ClosureInstance.java 2009-10-26 06:24:33 UTC (rev 11756) +++ trunk/x10.compiler/src/x10/types/ClosureInstance.java 2009-10-26 07:07:24 UTC (rev 11757) @@ -34,7 +34,7 @@ public interface ClosureInstance extends FunctionInstance<ClosureDef>, X10ProcedureInstance<ClosureDef> { CodeInstance<?> methodContainer(); ClassType typeContainer(); - ClosureType type(); + FunctionType type(); public ClosureInstance returnTypeRef(Ref<? extends Type> returnType); } Modified: trunk/x10.compiler/src/x10/types/ClosureInstance_c.java =================================================================== --- trunk/x10.compiler/src/x10/types/ClosureInstance_c.java 2009-10-26 06:24:33 UTC (rev 11756) +++ trunk/x10.compiler/src/x10/types/ClosureInstance_c.java 2009-10-26 07:07:24 UTC (rev 11757) @@ -45,9 +45,9 @@ return def(); } - ClosureType type; + FunctionType type; - public ClosureType type() { + public FunctionType type() { X10TypeSystem xts = (X10TypeSystem) ts; assert false; if (type == null) { Deleted: trunk/x10.compiler/src/x10/types/ClosureType.java =================================================================== --- trunk/x10.compiler/src/x10/types/ClosureType.java 2009-10-26 06:24:33 UTC (rev 11756) +++ trunk/x10.compiler/src/x10/types/ClosureType.java 2009-10-26 07:07:24 UTC (rev 11757) @@ -1,81 +0,0 @@ -/* - * Created on Mar 1, 2007 - */ -/* - * - * (C) Copyright IBM Corporation 2006-2008. - * - * This file is part of X10 Language. - * - */ - -package x10.types; - -import java.util.ArrayList; -import java.util.List; - -import polyglot.types.LocalInstance; -import polyglot.types.MethodInstance; -import polyglot.types.Ref; -import polyglot.types.Type; -import x10.constraint.XConstraint; - -/** - * The type of a closure, representing the closure's signature (argument types, - * return type and throwable exception types). - * @author rfuhrer - */ -public interface ClosureType extends X10ParsedClassType { -// ClosureDef closureDef(); - -// ClosureInstance closureInstance(); -// ClosureType closureInstance(ClosureInstance ci); - - X10MethodInstance applyMethod(); - - /** - * @return the type of value returned by an invocation of the closure. cannot be void. - */ - Type returnType(); - - /** - * @return the list of formal type arguments of the closure, in declaration order. may be empty. - * Note: This differs from typeArguments, inherited from X10ClassType. - * For [S](T) => U, - * the class type for the closure is Fun_1_1[T,U]. - * typeParameters is [S] and argumentTypes is (T). typeArguments is [T,U]. - */ - List<Type> typeParameters(); - - /** - * @return the list of formal value argument types of the closure, in declaration order. may be empty. - */ - List<Type> argumentTypes(); - - /** - * @return the list of formal value argument names of the closure, in declaration order. may be empty. - */ - List<LocalInstance> formalNames(); - - /** - * @return the guard for the closure. - */ - XConstraint guard(); - - /** - * @return the list of exception types that this closure may throw from an invocation. may be empty. - */ - List<Type> throwTypes(); - -// public ClosureType returnType(Type l); -// -// public ClosureType guard(XConstraint l); -// -// public ClosureType typeParameters(List<Type> l); -// -// public ClosureType argumentTypes(List<Type> l); -// -// public ClosureType throwTypes(List<Type> l); -// -// public List<Type> typeArguments(); -} Modified: trunk/x10.compiler/src/x10/types/ClosureType_c.java =================================================================== --- trunk/x10.compiler/src/x10/types/ClosureType_c.java 2009-10-26 06:24:33 UTC (rev 11756) +++ trunk/x10.compiler/src/x10/types/ClosureType_c.java 2009-10-26 07:07:24 UTC (rev 11757) @@ -47,7 +47,7 @@ import polyglot.util.TransformingList; import x10.constraint.XConstraint; -public class ClosureType_c extends X10ParsedClassType_c implements ClosureType { +public class ClosureType_c extends X10ParsedClassType_c implements FunctionType { private static final long serialVersionUID = 2768150875334536668L; // protected ClosureInstance ci; Copied: trunk/x10.compiler/src/x10/types/FunctionType.java (from rev 11408, trunk/x10.compiler/src/x10/types/ClosureType.java) =================================================================== --- trunk/x10.compiler/src/x10/types/FunctionType.java (rev 0) +++ trunk/x10.compiler/src/x10/types/FunctionType.java 2009-10-26 07:07:24 UTC (rev 11757) @@ -0,0 +1,81 @@ +/* + * Created on Mar 1, 2007 + */ +/* + * + * (C) Copyright IBM Corporation 2006-2008. + * + * This file is part of X10 Language. + * + */ + +package x10.types; + +import java.util.ArrayList; +import java.util.List; + +import polyglot.types.LocalInstance; +import polyglot.types.MethodInstance; +import polyglot.types.Ref; +import polyglot.types.Type; +import x10.constraint.XConstraint; + +/** + * The type of a closure, representing the closure's signature (argument types, + * return type and throwable exception types). + * @author rfuhrer + */ +public interface FunctionType extends X10ParsedClassType { +// ClosureDef closureDef(); + +// ClosureInstance closureInstance(); +// ClosureType closureInstance(ClosureInstance ci); + + X10MethodInstance applyMethod(); + + /** + * @return the type of value returned by an invocation of the closure. cannot be void. + */ + Type returnType(); + + /** + * @return the list of formal type arguments of the closure, in declaration order. may be empty. + * Note: This differs from typeArguments, inherited from X10ClassType. + * For [S](T) => U, + * the class type for the closure is Fun_1_1[T,U]. + * typeParameters is [S] and argumentTypes is (T). typeArguments is [T,U]. + */ + List<Type> typeParameters(); + + /** + * @return the list of formal value argument types of the closure, in declaration order. may be empty. + */ + List<Type> argumentTypes(); + + /** + * @return the list of formal value argument names of the closure, in declaration order. may be empty. + */ + List<LocalInstance> formalNames(); + + /** + * @return the guard for the closure. + */ + XConstraint guard(); + + /** + * @return the list of exception types that this closure may throw from an invocation. may be empty. + */ + List<Type> throwTypes(); + +// public ClosureType returnType(Type l); +// +// public ClosureType guard(XConstraint l); +// +// public ClosureType typeParameters(List<Type> l); +// +// public ClosureType argumentTypes(List<Type> l); +// +// public ClosureType throwTypes(List<Type> l); +// +// public List<Type> typeArguments(); +} Modified: trunk/x10.compiler/src/x10/types/X10ClassDef.java =================================================================== --- trunk/x10.compiler/src/x10/types/X10ClassDef.java 2009-10-26 06:24:33 UTC (rev 11756) +++ trunk/x10.compiler/src/x10/types/X10ClassDef.java 2009-10-26 07:07:24 UTC (rev 11757) @@ -48,4 +48,8 @@ * @return */ boolean isStruct(); + /** + * Is this the class def for an X10 function? + */ + boolean isFunction(); } Modified: trunk/x10.compiler/src/x10/types/X10ClassDef_c.java =================================================================== --- trunk/x10.compiler/src/x10/types/X10ClassDef_c.java 2009-10-26 06:24:33 UTC (rev 11756) +++ trunk/x10.compiler/src/x10/types/X10ClassDef_c.java 2009-10-26 07:07:24 UTC (rev 11757) @@ -329,4 +329,8 @@ public boolean isStruct() { return X10Flags.toX10Flags(flags()).isStruct(); } + // This is overridden by the synthetic Fun_** classes created in X10TypeSystem_c. + public boolean isFunction() { + return false; + } } Modified: trunk/x10.compiler/src/x10/types/X10FieldInstance_c.java =================================================================== --- trunk/x10.compiler/src/x10/types/X10FieldInstance_c.java 2009-10-26 06:24:33 UTC (rev 11756) +++ trunk/x10.compiler/src/x10/types/X10FieldInstance_c.java 2009-10-26 07:07:24 UTC (rev 11757) @@ -158,7 +158,7 @@ public String containerString() { Type container = container(); container = X10TypeMixin.baseType(container); - if (container instanceof ClosureType) { + if (container instanceof FunctionType) { return "(" + container.toString() + ")"; } if (container instanceof Named) { Modified: trunk/x10.compiler/src/x10/types/X10MethodInstance_c.java =================================================================== --- trunk/x10.compiler/src/x10/types/X10MethodInstance_c.java 2009-10-26 06:24:33 UTC (rev 11756) +++ trunk/x10.compiler/src/x10/types/X10MethodInstance_c.java 2009-10-26 07:07:24 UTC (rev 11757) @@ -398,7 +398,7 @@ public String containerString() { Type container = container(); container = X10TypeMixin.baseType(container); - if (container instanceof ClosureType) { + if (container instanceof FunctionType) { return "(" + container.toString() + ")"; } if (container instanceof Named) { Modified: trunk/x10.compiler/src/x10/types/X10TypeEnv_c.java =================================================================== --- trunk/x10.compiler/src/x10/types/X10TypeEnv_c.java 2009-10-26 06:24:33 UTC (rev 11756) +++ trunk/x10.compiler/src/x10/types/X10TypeEnv_c.java 2009-10-26 07:07:24 UTC (rev 11757) @@ -308,7 +308,7 @@ public Kind kind(Type t) { X10Context c = (X10Context) this.context; t = X10TypeMixin.baseType(t); - if (t instanceof ClosureType) + if (t instanceof FunctionType) return Kind.VALUE; if (t instanceof ClassType) { ClassType ct = (ClassType) t; @@ -638,7 +638,7 @@ @Override public boolean isSubtype(Type t1, Type t2) { - return isSubtype(t1, t2, false); + return isSubtype(t1, t2, true); } public boolean behavesLike(Type t1, Type t2) { @@ -660,7 +660,7 @@ } public boolean isSubtype(Type t1, Type t2, boolean allowValueInterfaces) { - return isSubtype(null, t1, t2, allowValueInterfaces); + return isSubtype(null, t1, t2, true); } /* (non-Javadoc) @@ -725,7 +725,7 @@ } // HACK: treat (S) => T as a subtype of Value. - if (ts.isFunction(t1, xcontext) + /* if (ts.isFunction(t1, xcontext) && ts.typeEquals(t2, ts.Value(), xcontext)) return true; @@ -746,7 +746,7 @@ && ts.isReferenceOrInterfaceType(t1, xcontext)) return false; } - +*/ if (typeEquals(t1, t2)) return true; Modified: trunk/x10.compiler/src/x10/types/X10TypeSystem.java =================================================================== --- trunk/x10.compiler/src/x10/types/X10TypeSystem.java 2009-10-26 06:24:33 UTC (rev 11756) +++ trunk/x10.compiler/src/x10/types/X10TypeSystem.java 2009-10-26 07:07:24 UTC (rev 11757) @@ -119,10 +119,12 @@ Type Runtime(); // used by asyncCodeInstance - Type Value(); + //Type Value(); + + Type Object(); + + Type Any(); - Type Ref(); - XLit FALSE(); XLit TRUE(); @@ -321,15 +323,15 @@ boolean isBox(Type type); - boolean isFunction(Type type, X10Context context); + boolean isFunctionType(Type type); X10ClassDef closureAnonymousClassDef(ClosureDef def); - List<ClosureType> getFunctionSupertypes(Type type, X10Context context); + // List<ClosureType> getFunctionSupertypes(Type type, X10Context context); boolean isInterfaceType(Type toType); - ClosureType closureType(Position position, Ref<? extends Type> typeRef, + FunctionType closureType(Position position, Ref<? extends Type> typeRef, // List<Ref<? extends Type>> typeParams, List<Ref<? extends Type>> formalTypes, List<LocalDef> formalNames, Ref<XConstraint> guard, @@ -429,4 +431,5 @@ boolean isX10Array(Type me); Context emptyContext(); + Type Struct(); } Modified: trunk/x10.compiler/src/x10/types/X10TypeSystem_c.java =================================================================== --- trunk/x10.compiler/src/x10/types/X10TypeSystem_c.java 2009-10-26 06:24:33 UTC (rev 11756) +++ trunk/x10.compiler/src/x10/types/X10TypeSystem_c.java 2009-10-26 07:07:24 UTC (rev 11757) @@ -42,6 +42,7 @@ import polyglot.types.FieldInstance; import polyglot.types.Flags; import polyglot.types.InitializerDef; +import polyglot.types.LazyRef; import polyglot.types.LocalDef; import polyglot.types.LocalInstance; import polyglot.types.Matcher; @@ -365,13 +366,17 @@ } // Instantiate the super type on the new parameters. - X10ClassType sup = (X10ClassType) closureBaseInterfaceDef(numTypeParams, numValueParams, ci.returnType().isVoid(), - def.formalNames(), def.guard()).asType(); + 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.superType(Types.ref(Value())); // Closures are values. cd.addInterface(Types.ref(sup)); return cd; @@ -382,8 +387,20 @@ return closureBaseInterfaceDef(numTypeParams, numValueParams, isVoid, null, null); } - public X10ClassDef closureBaseInterfaceDef(final int numTypeParams, final int numValueParams, - final boolean isVoid, List<LocalDef> formalNames, final Ref<XConstraint> guard) { + /** + * 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; @@ -403,6 +420,10 @@ } X10ClassDef cd = (X10ClassDef) new X10ClassDef_c(this, null) { + @Override + public boolean isFunction() { + return true; + } @Override public ClassType asType() { if (asType == null) { @@ -424,7 +445,9 @@ cd.kind(ClassDef.TOP_LEVEL); cd.superType(null); // interfaces have no superclass - cd.flags(X10Flags.toX10Flags(Flags.PUBLIC.Abstract().Interface()).Value()); + // 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>>(); @@ -453,7 +476,7 @@ // NOTE: don't call cd.asType() until after the type parameters are // added. - ClosureType ct = (ClosureType) cd.asType(); + FunctionType ct = (FunctionType) cd.asType(); xts.systemResolver().install(fullName, ct); String fullNameWithThis = fullName + "#this"; @@ -464,13 +487,324 @@ 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); + 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; } + + X10ClassDef STRUCT_DEF = null; + public X10ClassDef StructDef() { + if (STRUCT_DEF == null) { + STRUCT_DEF = makeStructDef(); + } + return STRUCT_DEF; + } + public X10ClassDef makeStructDef() { + final X10TypeSystem xts = this; + final Position pos = Position.COMPILER_GENERATED; + String name = "Struct"; + X10ClassDef cd = (X10ClassDef) new X10ClassDef_c(this, null) { + + @Override + public ClassType asType() { + if (asType == null) { + X10ClassDef cd = this; + asType = new X10ParsedClassType_c(this); + } + return asType; + } + }; + + 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 + // Functions implement the Any interface. + //cd.setInterfaces(Collections.<Ref<? extends Type>> singletonList(Types.ref(Any()))); + cd.flags(X10Flags.toX10Flags(Flags.PUBLIC.Abstract())); + + + // 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); + + /*public strct Struct { + public native def toString():String; + public native def typeName():String; + property def loc()=here; + property def at(p:Place)=true; + property def at(r:Object)=true; + }*/ + 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()); + } + }); + + X10MethodDef mi = methodDef(pos, Types.ref(ct), + Flags.PUBLIC.Native(), STRING, + Name.make("toString"), + Collections.EMPTY_LIST, + Collections.EMPTY_LIST, + thisVar, + Collections.EMPTY_LIST, + null, + null, + Collections.EMPTY_LIST, + null); + cd.addMethod(mi); + mi = methodDef(pos, Types.ref(ct), + Flags.PUBLIC.Native(), STRING, + Name.make("typeName"), + Collections.EMPTY_LIST, + Collections.EMPTY_LIST, + thisVar, + Collections.EMPTY_LIST, + null, + null, + Collections.EMPTY_LIST, + null); + cd.addMethod(mi); + + mi = methodDef(pos, Types.ref(ct), + Flags.PUBLIC.Abstract(), PLACE, + Name.make("loc"), + Collections.EMPTY_LIST, + Collections.EMPTY_LIST, + thisVar, + Collections.EMPTY_LIST, + null, + null, + Collections.EMPTY_LIST, + null); + cd.addMethod(mi); + final LazyRef<X10ParsedClassType> OBJECT = Types.lazyRef(null); + OBJECT.setResolver(new Runnable() { + public void run() { + OBJECT.update((X10ParsedClassType) xts.Object()); + } + }); + List<LocalDef> parameters = dummyLocalDefs(Collections.<Ref<? extends Type>> singletonList(OBJECT)); + mi = methodDef(pos, Types.ref(ct), + X10Flags.toX10Flags(Flags.PUBLIC.Native()).Property(), BOOLEAN, + Name.make("at"), + Collections.EMPTY_LIST, + Collections.<Ref<? extends Type>> singletonList(OBJECT), + thisVar, + parameters, + null, + null, + Collections.EMPTY_LIST, + null); + cd.addMethod(mi); + parameters = dummyLocalDefs(Collections.<Ref<? extends Type>> singletonList(PLACE)); + mi = methodDef(pos, Types.ref(ct), + X10Flags.toX10Flags(Flags.PUBLIC.Native()).Property(), BOOLEAN, + Name.make("at"), + Collections.EMPTY_LIST, + Collections.<Ref<? extends Type>> singletonList(PLACE), + thisVar, + parameters, + null, + null, + Collections.EMPTY_LIST, + null); + cd.addMethod(mi); + + return cd; + } + X10ClassDef ANY_DEF = null; + public X10ClassDef AnyDef() { + if (ANY_DEF == null) { + ANY_DEF = makeAnyDef(); + } + return ANY_DEF; + } + + + public X10ClassDef makeAnyDef() { + final X10TypeSystem xts = this; + final Position pos = Position.COMPILER_GENERATED; + + String name = "Any"; + X10ClassDef cd = (X10ClassDef) new X10ClassDef_c(this, null) { + + @Override + public ClassType asType() { + if (asType == null) { + X10ClassDef cd = this; + asType = new X10ParsedClassType_c(this); + } + return asType; + } + }; + + 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); // 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())); + + + // 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); + + /*public interface Any { + + def toString():String; + def typeName():String; + property def loc():Place; + property def at(p:Place):boolean; + property def at(r:Object):boolean; +}*/ + 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()); + } + }); + + X10MethodDef mi = methodDef(pos, Types.ref(ct), + Flags.PUBLIC.Abstract(), STRING, + Name.make("toString"), + Collections.EMPTY_LIST, + Collections.EMPTY_LIST, + thisVar, + Collections.EMPTY_LIST, + null, + null, + Collections.EMPTY_LIST, + null); + cd.addMethod(mi); + mi = methodDef(pos, Types.ref(ct), + X10Flags.toX10Flags(Flags.PUBLIC.Abstract()).Global(), STRING, + Name.make("typeName"), + Collections.EMPTY_LIST, + Collections.EMPTY_LIST, + thisVar, + Collections.EMPTY_LIST, + null, + null, + Collections.EMPTY_LIST, + null); + cd.addMethod(mi); + + mi = methodDef(pos, Types.ref(ct), + X10Flags.toX10Flags(Flags.PUBLIC.Abstract()).Property().Global(), PLACE, + Name.make("loc"), + Collections.EMPTY_LIST, + Collections.EMPTY_LIST, + thisVar, + Collections.EMPTY_LIST, + null, + null, + Collections.EMPTY_LIST, + null); + cd.addMethod(mi); + final LazyRef<X10ParsedClassType> OBJECT = Types.lazyRef(null); + OBJECT.setResolver(new Runnable() { + public void run() { + OBJECT.update((X10ParsedClassType) xts.Object()); + } + }); + List<LocalDef> parameters = dummyLocalDefs(Collections.<Ref<? extends Type>> singletonList(OBJECT)); + mi = methodDef(pos, Types.ref(ct), + X10Flags.toX10Flags(Flags.PUBLIC.Abstract()).Property(), BOOLEAN, + Name.make("at"), + Collections.EMPTY_LIST, + Collections.<Ref<? extends Type>> singletonList(OBJECT), + thisVar, + parameters, + null, + null, + Collections.EMPTY_LIST, + null); + cd.addMethod(mi); + + parameters = dummyLocalDefs(Collections.<Ref<? extends Type>> singletonList(PLACE)); + mi = methodDef(pos, Types.ref(ct), + X10Flags.toX10Flags(Flags.PUBLIC.Abstract()).Property(), BOOLEAN, + Name.make("at"), + Collections.EMPTY_LIST, + Collections.<Ref<? extends Type>> singletonList(PLACE), + thisVar, + parameters, + null, + 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... [truncated message content] |
From: <dgr...@us...> - 2009-10-27 11:42:00
|
Revision: 11770 http://x10.svn.sourceforge.net/x10/?rev=11770&view=rev Author: dgrove-oss Date: 2009-10-27 11:41:48 +0000 (Tue, 27 Oct 2009) Log Message: ----------- Include miminal set of x10aux header files in struct.h to enable Place.struct_h to be included in Ref.h. Required to allow the definition of at() on Ref. Modified Paths: -------------- trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java trunk/x10.runtime/src-cpp/x10/lang/Ref.h Modified: trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java =================================================================== --- trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java 2009-10-27 06:28:52 UTC (rev 11769) +++ trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java 2009-10-27 11:41:48 UTC (rev 11770) @@ -681,7 +681,10 @@ sh.write("#ifndef __"+sguard); sh.newline(); sh.write("#define __"+sguard); sh.newline(); sh.forceNewline(0); - sh.write("#include <x10rt17.h>"); sh.newline(); + sh.writeln("#include <x10aux/config.h>"); + sh.writeln("#include <x10aux/ref.h>"); + sh.writeln("#include <x10aux/RTT.h>"); + sh.writeln("#include <x10aux/serialization.h>"); sh.forceNewline(0); } Modified: trunk/x10.runtime/src-cpp/x10/lang/Ref.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Ref.h 2009-10-27 06:28:52 UTC (rev 11769) +++ trunk/x10.runtime/src-cpp/x10/lang/Ref.h 2009-10-27 11:41:48 UTC (rev 11770) @@ -8,6 +8,10 @@ #include <x10/lang/Object.h> +#define X10_LANG_PLASE_H_NODEPS +#include <x10/lang/Place.struct_h> +#undef X10_LANG_PLACE_H_NODEPS + namespace x10 { namespace lang { @@ -74,6 +78,14 @@ 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::Ref> o) { + return location == o->location; + } + // Needed for linking - do not override virtual x10_boolean _struct_equals(x10aux::ref<Object> other) { if (other == x10aux::ref<Ref>(this)) return true; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |