From: <ipe...@us...> - 2009-06-25 04:22:18
|
Revision: 10519 http://x10.svn.sourceforge.net/x10/?rev=10519&view=rev Author: ipeshansky Date: 2009-06-25 04:22:17 +0000 (Thu, 25 Jun 2009) Log Message: ----------- Handle closure types properly in both backends. Modified Paths: -------------- trunk/x10.compiler.p3/src/polyglot/ext/x10/visit/X10PrettyPrinterVisitor.java trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/Emitter.java Modified: trunk/x10.compiler.p3/src/polyglot/ext/x10/visit/X10PrettyPrinterVisitor.java =================================================================== --- trunk/x10.compiler.p3/src/polyglot/ext/x10/visit/X10PrettyPrinterVisitor.java 2009-06-25 04:20:00 UTC (rev 10518) +++ trunk/x10.compiler.p3/src/polyglot/ext/x10/visit/X10PrettyPrinterVisitor.java 2009-06-25 04:22:17 UTC (rev 10519) @@ -2732,7 +2732,7 @@ return; } else if (ct.superClass() != null) { - printType(ct.interfaces().get(0), flags); + printType(ct.superClass(), flags); return; } else { Modified: trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/Emitter.java =================================================================== --- trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/Emitter.java 2009-06-25 04:20:00 UTC (rev 10518) +++ trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/Emitter.java 2009-06-25 04:22:17 UTC (rev 10519) @@ -40,6 +40,7 @@ import polyglot.ext.x10.ast.X10ConstructorDecl_c; import polyglot.ext.x10.ast.X10MethodDecl_c; import polyglot.ext.x10.ast.X10Special_c; +import polyglot.ext.x10.types.ClosureType; import polyglot.ext.x10.types.ParameterType; import polyglot.ext.x10.types.X10ClassDef; import polyglot.ext.x10.types.X10ClassType; @@ -226,19 +227,33 @@ // return translateType(((X10Type) type).toClosure().base(), asRef); type = X10TypeMixin.baseType(type); String name = null; + // TODO +// if (type instanceof ClosureType) { +// ClosureType ct = (ClosureType) type; +// assert (ct.typeArguments().size() != 0); +// name = "x10aux::Fun"; +// String args = ""; +// if (ct.returnType().isVoid()) +// args += translateType(ct.returnType(), true) + ", "; +// int s = ct.typeArguments().size(); +// for (Type t: ct.typeArguments()) { +// args += translateType(t, true); // type arguments are always translated as refs +// if (--s > 0) +// args +=", "; +// } +// name += chevrons(args); +// } else if (type.isClass()) { X10ClassType ct = (X10ClassType) type.toClass(); if (ct.isAnonymous()) { - // assert false : "unexpected anonymous type " + ct; - if (ct.interfaces().size() > 0) { - return translateType(ct.interfaces().get(0), asRef); - } else if (ct.superClass() != null) { - return translateType(ct.interfaces().get(0), asRef); - } else { - assert false; - return translateType(xts.Object(), asRef); - } + if (ct.interfaces().size() == 1 && ct.interfaces().get(0) instanceof ClosureType) { + return translateType(ct.interfaces().get(0), asRef); + } else { + assert false : "unexpected anonymous type " + ct; + assert ct.superClass() != null; + return translateType(ct.superClass(), asRef); + } } else { X10ClassDef cd = ((X10ClassType) type).x10Def(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dgr...@us...> - 2009-06-26 02:53:08
|
Revision: 10552 http://x10.svn.sourceforge.net/x10/?rev=10552&view=rev Author: dgrove-oss Date: 2009-06-26 01:45:12 +0000 (Fri, 26 Jun 2009) Log Message: ----------- Bump x10c and x10cpp version numbers to 1.8 on the trunk. We'll use 1.8.x while we're supporting a hybrid language with a mix of 1.7 and 2.0 features. After we remove 1.7 support, we'll increment version number to 1.9.x and then to 2.0.0. Modified Paths: -------------- trunk/x10.compiler.p3/src/polyglot/ext/x10/Version.java trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/Version.java Modified: trunk/x10.compiler.p3/src/polyglot/ext/x10/Version.java =================================================================== --- trunk/x10.compiler.p3/src/polyglot/ext/x10/Version.java 2009-06-25 18:32:27 UTC (rev 10551) +++ trunk/x10.compiler.p3/src/polyglot/ext/x10/Version.java 2009-06-26 01:45:12 UTC (rev 10552) @@ -14,6 +14,6 @@ public String name() { return "x10"; } public int major() { return 1; } - public int minor() { return 7; } - public int patch_level() { return 4; } + public int minor() { return 8; } + public int patch_level() { return 0; } } Modified: trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/Version.java =================================================================== --- trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/Version.java 2009-06-25 18:32:27 UTC (rev 10551) +++ trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/Version.java 2009-06-26 01:45:12 UTC (rev 10552) @@ -13,6 +13,6 @@ public String name() { return "x10c++"; } public int major() { return 1; } - public int minor() { return 7; } - public int patch_level() { return 4; } + public int minor() { return 8; } + public int patch_level() { return 0; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ipe...@us...> - 2009-06-26 03:23:56
|
Revision: 10553 http://x10.svn.sourceforge.net/x10/?rev=10553&view=rev Author: ipeshansky Date: 2009-06-26 03:23:54 +0000 (Fri, 26 Jun 2009) Log Message: ----------- Fix a bug where inherited methods did not override the ones in an interface. Add a corresponding test case. Modified Paths: -------------- trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/MessagePassingCodeGenerator.java Added Paths: ----------- trunk/x10.tests/examples/Constructs/Inheritance/ trunk/x10.tests/examples/Constructs/Inheritance/InheritedInterfaceMethod.x10 Modified: trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/MessagePassingCodeGenerator.java =================================================================== --- trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/MessagePassingCodeGenerator.java 2009-06-26 01:45:12 UTC (rev 10552) +++ trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/MessagePassingCodeGenerator.java 2009-06-26 03:23:54 UTC (rev 10553) @@ -772,7 +772,7 @@ } X10ClassType superClass = (X10ClassType) X10TypeMixin.baseType(def.asType().superClass()); if (superClass != null) { - for (Name mname : getMethodNames(n.body().members())) { + for (Name mname : getMethodNames(n.body().members(), def.asType().interfaces())) { List<MethodInstance> overriddenOverloads = getOROLMeths(mname, superClass); for (MethodInstance mi : overriddenOverloads) { extractAllClassTypes(mi.returnType(), types, dupes); @@ -974,7 +974,7 @@ return ct; } - private ArrayList<Name> getMethodNames(List<ClassMember> members) { + private ArrayList<Name> getMethodNames(List<ClassMember> members, List<Type> interfaces) { ArrayList<Name> mnames = new ArrayList<Name>(); Set<Name> dupes = new HashSet<Name>(); for (ClassMember member : members) { @@ -988,6 +988,15 @@ dupes.add(mname); mnames.add(mname); } + for (Type iface : interfaces) { + List<MethodInstance> methods = iface.toClass().methods(); + for (MethodInstance mi : methods) { + Name mname = mi.name(); + if (dupes.contains(mname)) continue; + dupes.add(mname); + mnames.add(mname); + } + } return mnames; } @@ -1052,7 +1061,7 @@ // generate proxy methods for an overridden method's superclass overloads if (superClass != null) { // first gather a set of all the method names in the current class - ArrayList<Name> mnames = getMethodNames(members); + ArrayList<Name> mnames = getMethodNames(members, currentClass.interfaces()); // then, for each one for (Name mname : mnames) { Added: trunk/x10.tests/examples/Constructs/Inheritance/InheritedInterfaceMethod.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Inheritance/InheritedInterfaceMethod.x10 (rev 0) +++ trunk/x10.tests/examples/Constructs/Inheritance/InheritedInterfaceMethod.x10 2009-06-26 03:23:54 UTC (rev 10553) @@ -0,0 +1,32 @@ +// (C) Copyright IBM Corporation 2008 +// This file is part of X10 Test. * + +import harness.x10Test; + +/** + * Inherited methods should satisfy interface dependences. + * Adapted from the test case for XTENLANG-22. + * @author igor 06/2009 + */ +class InheritedInterfaceMethod extends x10Test { + + class A { + public def m() = 0; + } + + interface I { + def m(): int; + } + + class B extends A implements I {} + + public def run(): boolean { + val v = new B(); + return v.m() == 0; + } + + public static def main(Rail[String]) { + new InheritedInterfaceMethod().execute(); + } +} + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <njn...@us...> - 2009-06-26 20:49:25
|
Revision: 10559 http://x10.svn.sourceforge.net/x10/?rev=10559&view=rev Author: njnystrom Date: 2009-06-26 20:49:14 +0000 (Fri, 26 Jun 2009) Log Message: ----------- Implemented unsigned integers. - added to runtime: ubyte, ushort, uint, ulong - added unsigned literals to parser - cleaned up operator overloading syntax for implicit coercions - changed $plus etc to use operator overloading syntax - moved implementation of operators into x10 code (using @Native when needed), eliminating some special-case code in the frontend - changed C++ implementation of char to wrap the char in a struct--avoids overloading conflicts between char and ubyte. Modified Paths: -------------- trunk/x10.compiler.p3/src/polyglot/ext/x10/ast/X10Binary_c.java trunk/x10.compiler.p3/src/polyglot/ext/x10/ast/X10Cast_c.java trunk/x10.compiler.p3/src/polyglot/ext/x10/ast/X10Conditional_c.java trunk/x10.compiler.p3/src/polyglot/ext/x10/ast/X10IntLit_c.java trunk/x10.compiler.p3/src/polyglot/ext/x10/ast/X10Local_c.java trunk/x10.compiler.p3/src/polyglot/ext/x10/ast/X10New_c.java trunk/x10.compiler.p3/src/polyglot/ext/x10/ast/X10Unary_c.java trunk/x10.compiler.p3/src/polyglot/ext/x10/types/X10MethodInstance_c.java trunk/x10.compiler.p3/src/polyglot/ext/x10/types/X10TypeEnv.java trunk/x10.compiler.p3/src/polyglot/ext/x10/types/X10TypeEnv_c.java trunk/x10.compiler.p3/src/polyglot/ext/x10/types/X10TypeSystem.java trunk/x10.compiler.p3/src/polyglot/ext/x10/types/X10TypeSystem_c.java trunk/x10.compiler.p3/src/polyglot/ext/x10/visit/Desugarer.java trunk/x10.compiler.p3/src/polyglot/ext/x10/visit/X10PrettyPrinterVisitor.java trunk/x10.compiler.p3/src/x10/parser/X10Lexer.gi trunk/x10.compiler.p3/src/x10/parser/X10Lexer.java trunk/x10.compiler.p3/src/x10/parser/X10Lexerprs.java trunk/x10.compiler.p3/src/x10/parser/X10Lexersym.java trunk/x10.compiler.p3/src/x10/parser/X10Parser.java trunk/x10.compiler.p3/src/x10/parser/X10Parserprs.java trunk/x10.compiler.p3/src/x10/parser/X10Parsersym.java trunk/x10.compiler.p3/src/x10/parser/x10.g trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/Emitter.java trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/MessagePassingCodeGenerator.java trunk/x10.runtime.17/src-cpp/x10/lang/String.cc trunk/x10.runtime.17/src-cpp/x10aux/RTT.h trunk/x10.runtime.17/src-cpp/x10aux/basic_functions.cc trunk/x10.runtime.17/src-cpp/x10aux/basic_functions.h trunk/x10.runtime.17/src-cpp/x10aux/class_cast.h trunk/x10.runtime.17/src-cpp/x10aux/config.h trunk/x10.runtime.17/src-cpp/x10aux/rail_utils.h trunk/x10.runtime.17/src-cpp/x10aux/ref.h trunk/x10.runtime.17/src-cpp/x10aux/string_utils.cc trunk/x10.runtime.17/src-java/x10/core/GrowableRail.java trunk/x10.runtime.17/src-java/x10/types/Types.java trunk/x10.runtime.17/src-x10/x10/array/BaseArray.x10 trunk/x10.runtime.17/src-x10/x10/array/BaseDist.x10 trunk/x10.runtime.17/src-x10/x10/array/PolyMat.x10 trunk/x10.runtime.17/src-x10/x10/array/PolyScanner.x10 trunk/x10.runtime.17/src-x10/x10/array/PolyXform.x10 trunk/x10.runtime.17/src-x10/x10/array/Xform.x10 trunk/x10.runtime.17/src-x10/x10/array/XformMat.x10 trunk/x10.runtime.17/src-x10/x10/compiler/ArithmeticOps.x10 trunk/x10.runtime.17/src-x10/x10/compiler/ComparisonOps.x10 trunk/x10.runtime.17/src-x10/x10/io/Marshal.x10 trunk/x10.runtime.17/src-x10/x10/io/OutputStreamWriter.x10 trunk/x10.runtime.17/src-x10/x10/lang/Array.x10 trunk/x10.runtime.17/src-x10/x10/lang/Boolean.x10 trunk/x10.runtime.17/src-x10/x10/lang/Byte.x10 trunk/x10.runtime.17/src-x10/x10/lang/Char.x10 trunk/x10.runtime.17/src-x10/x10/lang/Dist.x10 trunk/x10.runtime.17/src-x10/x10/lang/Double.x10 trunk/x10.runtime.17/src-x10/x10/lang/Float.x10 trunk/x10.runtime.17/src-x10/x10/lang/Int.x10 trunk/x10.runtime.17/src-x10/x10/lang/Long.x10 trunk/x10.runtime.17/src-x10/x10/lang/Math.x10 trunk/x10.runtime.17/src-x10/x10/lang/Point.x10 trunk/x10.runtime.17/src-x10/x10/lang/Rail.x10 trunk/x10.runtime.17/src-x10/x10/lang/Ref.x10 trunk/x10.runtime.17/src-x10/x10/lang/Region.x10 trunk/x10.runtime.17/src-x10/x10/lang/Short.x10 trunk/x10.runtime.17/src-x10/x10/lang/ValRail.x10 trunk/x10.runtime.17/src-x10/x10/lang/_.x10 Added Paths: ----------- trunk/x10.runtime.17/src-java/x10/core/Unsigned.java trunk/x10.runtime.17/src-java/x10/types/UByteType.java trunk/x10.runtime.17/src-java/x10/types/UIntType.java trunk/x10.runtime.17/src-java/x10/types/ULongType.java trunk/x10.runtime.17/src-java/x10/types/UShortType.java trunk/x10.runtime.17/src-x10/x10/lang/UByte.x10 trunk/x10.runtime.17/src-x10/x10/lang/UInt.x10 trunk/x10.runtime.17/src-x10/x10/lang/ULong.x10 trunk/x10.runtime.17/src-x10/x10/lang/UShort.x10 Modified: trunk/x10.compiler.p3/src/polyglot/ext/x10/ast/X10Binary_c.java =================================================================== --- trunk/x10.compiler.p3/src/polyglot/ext/x10/ast/X10Binary_c.java 2009-06-26 20:39:46 UTC (rev 10558) +++ trunk/x10.compiler.p3/src/polyglot/ext/x10/ast/X10Binary_c.java 2009-06-26 20:49:14 UTC (rev 10559) @@ -20,6 +20,7 @@ import polyglot.ast.Assign; import polyglot.ast.Binary; import polyglot.ast.Binary_c; +import polyglot.ast.Call; import polyglot.ast.Expr; import polyglot.ast.Field; import polyglot.ast.Id; @@ -33,7 +34,6 @@ import polyglot.ast.Stmt; import polyglot.ast.TypeNode; import polyglot.ast.Unary; -import polyglot.ext.x10.types.X10ClassType; import polyglot.ext.x10.types.X10Context; import polyglot.ext.x10.types.X10TypeMixin; import polyglot.ext.x10.types.X10TypeSystem; @@ -203,27 +203,27 @@ public static Name binaryMethodName(Binary.Operator op) { Map<Binary.Operator,String> methodNameMap = new HashMap<Operator, String>(); - methodNameMap.put(ADD, "$plus"); - methodNameMap.put(SUB, "$minus"); - methodNameMap.put(MUL, "$times"); - methodNameMap.put(DIV, "$over"); - methodNameMap.put(MOD, "$percent"); - methodNameMap.put(BIT_AND, "$ampersand"); - methodNameMap.put(BIT_OR, "$bar"); - methodNameMap.put(BIT_XOR, "$caret"); - methodNameMap.put(COND_OR, "$or"); - methodNameMap.put(COND_AND, "$and"); - methodNameMap.put(SHL, "$left"); - methodNameMap.put(SHR, "$right"); - methodNameMap.put(USHR, "$righter"); - methodNameMap.put(LT, "$lt"); - methodNameMap.put(GT, "$gt"); - methodNameMap.put(LE, "$le"); - methodNameMap.put(GE, "$ge"); + methodNameMap.put(ADD, "operator+"); + methodNameMap.put(SUB, "operator-"); + methodNameMap.put(MUL, "operator*"); + methodNameMap.put(DIV, "operator/"); + methodNameMap.put(MOD, "operator%"); + methodNameMap.put(BIT_AND, "operator&"); + methodNameMap.put(BIT_OR, "operator|"); + methodNameMap.put(BIT_XOR, "operator^"); + methodNameMap.put(COND_OR, "operator||"); + methodNameMap.put(COND_AND, "operator&&"); + methodNameMap.put(SHL, "operator<<"); + methodNameMap.put(SHR, "operator>>"); + methodNameMap.put(USHR, "operator>>>"); + methodNameMap.put(LT, "operator<"); + methodNameMap.put(GT, "operator>"); + methodNameMap.put(LE, "operator<="); + methodNameMap.put(GE, "operator>="); // these should not be overridable - methodNameMap.put(EQ, "$eq"); - methodNameMap.put(NE, "$ne"); + methodNameMap.put(EQ, "operator=="); + methodNameMap.put(NE, "operator!="); String methodName = methodNameMap.get(op); if (methodName == null) @@ -235,9 +235,62 @@ Name n = binaryMethodName(op); if (n == null) return null; - return Name.make("inv" + n.toString()); + return Name.make("inverse_" + n.toString()); } + + private static Type promote(X10TypeSystem ts, Type t1, Type t2) { + if (ts.isByte(t1)) { + return t2; + } + if (ts.isShort(t1)) { + if (ts.isByte(t2)) + return t1; + return t2; + } + if (ts.isInt(t1)) { + if (ts.isByte(t2) || ts.isShort(t2)) + return t1; + return t2; + } + if (ts.isLong(t1)) { + if (ts.isByte(t2) || ts.isShort(t2) || ts.isInt(t2)) + return t1; + return t2; + } + if (ts.isUByte(t1)) { + return t2; + } + if (ts.isUShort(t1)) { + if (ts.isUByte(t2)) + return t1; + return t2; + } + if (ts.isUInt(t1)) { + if (ts.isUByte(t2) || ts.isUShort(t2)) + return t1; + return t2; + } + if (ts.isULong(t1)) { + if (ts.isUByte(t2) || ts.isUShort(t2) || ts.isUInt(t2)) + return t1; + return t2; + } + + if (ts.isFloat(t1)) { + if (ts.isByte(t2) || ts.isShort(t2) || ts.isInt(t2) || ts.isLong(t2)) + return t1; + if (ts.isUByte(t2) || ts.isUShort(t2) || ts.isUInt(t2) || ts.isULong(t2)) + return t1; + return t2; + } + if (ts.isDouble(t1)) { + return t1; + } + + return null; + } + /** * Type check a binary expression. Must take care of various cases because * of operators on regions, distributions, points, places and arrays. @@ -246,222 +299,304 @@ */ public Node typeCheck(ContextVisitor tc) throws SemanticException { X10TypeSystem xts = (X10TypeSystem) tc.typeSystem(); - + TypeSystem ts = xts; Context context = tc.context(); - - X10NodeFactory nf = (X10NodeFactory) tc.nodeFactory(); - Name methodName = binaryMethodName(op); - Name invMethodName = invBinaryMethodName(op); - - Type l = left.type(); - Type r = right.type(); - - if (op == EQ || op == NE) { - if (xts.isNumeric(l) && xts.isNumeric(r)) { - return type(xts.Boolean()); + + Type lbase = X10TypeMixin.baseType(left.type()); + Type rbase = X10TypeMixin.baseType(right.type()); + + 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; + + // If comparing signed vs. unsigned, check if one operand is a constant convertible to the other (base) type. + // If so, insert the conversion and check again. + + if (xts.isSigned(lbase) && xts.isUnsigned(rbase) || xts.isSigned(lbase) && xts.isUnsigned(rbase)) { + if (lv != null && xts.numericConversionValid(rbase, lv, context)) { + Expr e = X10New_c.attemptCoercion(tc, left, rbase); + return X10Cast_c.check(left(e), tc); + } + if (rv != null && xts.numericConversionValid(lbase, rv, context)) { + Expr e = X10New_c.attemptCoercion(tc, right, lbase); + return X10Cast_c.check(right(e), tc); + } } + + if (xts.isUnsigned(lbase) && xts.isSigned(rbase)) + throw new SemanticException("Cannot compare unsigned versus signed values.", position()); - if (xts.isCastValid(l, r, context) || xts.isCastValid(r, l, context)) { - return type(xts.Boolean()); + if (xts.isSigned(lbase) && xts.isUnsigned(rbase)) + throw new SemanticException("Cannot compare signed versus unsigned values.", position()); + + Type promoted = promote(xts, lbase, rbase); + + if (promoted != null && + (! xts.typeBaseEquals(lbase, promoted, context) || + ! xts.typeBaseEquals(rbase, promoted, context))) { + Expr el = X10New_c.attemptCoercion(tc, left, promoted); + Expr er = X10New_c.attemptCoercion(tc, right, promoted); + return X10Cast_c.check(left(el).right(er), tc); } - - if (xts.isImplicitCastValid(l, r, context) || xts.isImplicitCastValid(r, l, context)) { + } + + if (op == EQ || op == NE) { + // == and != are allowed if the *unconstrained* types can be cast to each other without coercions. + // Coercions are handled above for numerics. No other coercions are allowed. + // Constraints are ignored so that things like x==k will not cause compile-time errors + // when x is a final variable initialized to a constant != k. + if (xts.isCastValid(lbase, rbase, context) || xts.isCastValid(rbase, lbase, context)) { return type(xts.Boolean()); } +// +// if (xts.isImplicitCastValid(lbase, rbase, context) || xts.isImplicitCastValid(rbase, lbase, context)) { +// assert false : "isCastValid but isImplicitCastValid not for " + lbase + " and " + rbase; +// return type(xts.Boolean()); +// } throw new SemanticException("The " + op + - " operator must have operands of comparable type; the types " + l + " and " + r + " do not share any values.", + " operator must have operands of comparable type; the types " + lbase + " and " + rbase + " do not share any values.", position()); } + Type l = left.type(); + Type r = right.type(); + + Call c = desugarBinaryOp(this, tc); + if (c != null) { + // rebuild the unary using the call's arguments. We'll actually use the call node after desugaring. + if (c.methodInstance().flags().isStatic()) { + return this.left(c.arguments().get(0)).right(c.arguments().get(1)).type(c.type()); + } + else { + return this.left((Expr) c.target()).right(c.arguments().get(0)).type(c.type()); + } + } + + if (op == COND_OR || op == COND_AND) { + if (l.isBoolean() && r.isBoolean()) { + return type(ts.Boolean()); + } + } + + if (op == ADD) { + if (ts.isSubtype(l, ts.String(), context) || ts.isSubtype(r, ts.String(), context)) { + if (!ts.canCoerceToString(l, tc.context())) { + throw new SemanticException("Cannot coerce an expression " + + "of type " + l + " to a String.", + left.position()); + } + if (!ts.canCoerceToString(r, tc.context())) { + throw new SemanticException("Cannot coerce an expression " + + "of type " + r + " to a String.", + right.position()); + } + + Expr newLeft = coerceToString(tc, left); + Expr newRight = coerceToString(tc, right); + + return precedence(Precedence.STRING_ADD).left(newLeft).right(newRight).type(ts.String()); + } + } + + throw new SemanticException("No operation " + op + " found for operands " + l + " and " + r + ".", position()); + } + + public static X10Call_c desugarBinaryOp(Binary n, ContextVisitor tc) throws SemanticException { + Expr left = n.left(); + Expr right = n.right(); + Binary.Operator op = n.operator(); + Position pos = n.position(); + + Type l = left.type(); + Type r = right.type(); + + X10NodeFactory nf = (X10NodeFactory) tc.nodeFactory(); + Name methodName = X10Binary_c.binaryMethodName(op); + Name invMethodName = X10Binary_c.invBinaryMethodName(op); + + // TODO: byte+byte should convert both bytes to int and search int + // For now, we have to define byte+byte in byte.x10. + X10Call_c virtual_left = null; X10Call_c virtual_right = null; X10Call_c static_left = null; X10Call_c static_right = null; - + if (methodName != null) { // Check if there is a method with the appropriate name and type with the left operand as receiver. - X10Call_c n = (X10Call_c) nf.X10Call(position(), left, nf.Id(position(), methodName), Collections.EMPTY_LIST, Collections.singletonList(right)); - + X10Call_c n2 = (X10Call_c) nf.X10Call(pos, left, nf.Id(pos, methodName), Collections.EMPTY_LIST, Collections.singletonList(right)); + try { - n = (X10Call_c) n.del().disambiguate(tc).typeCheck(tc).checkConstants(tc); - virtual_left = n; + n2 = X10Cast_c.check(n2, tc); + if (! n2.methodInstance().def().flags().isStatic()) + virtual_left = n2; } catch (SemanticException e2) { // Cannot find the method. Fall through. } } - + if (methodName != null) { // Check if there is a static method of the left type with the appropriate name and type. - X10Call_c n = (X10Call_c) nf.X10Call(position(), nf.CanonicalTypeNode(position(), Types.ref(l)), nf.Id(position(), methodName), Collections.EMPTY_LIST, CollectionUtil.list(left, right)); - + X10Call_c n4 = (X10Call_c) nf.X10Call(pos, nf.CanonicalTypeNode(pos, Types.ref(l)), nf.Id(pos, methodName), Collections.EMPTY_LIST, CollectionUtil.list(left, right)); + try { - n = (X10Call_c) n.del().disambiguate(tc).typeCheck(tc).checkConstants(tc); - static_left = n; + n4 = X10Cast_c.check(n4, tc); + if (n4.methodInstance().def().flags().isStatic()) + static_left = n4; } catch (SemanticException e2) { // Cannot find the method. Fall through. } } - + if (methodName != null) { // Check if there is a static method of the right type with the appropriate name and type. - X10Call_c n = (X10Call_c) nf.X10Call(position(), nf.CanonicalTypeNode(position(), Types.ref(r)), nf.Id(position(), methodName), Collections.EMPTY_LIST, CollectionUtil.list(left, right)); - + X10Call_c n3 = (X10Call_c) nf.X10Call(pos, nf.CanonicalTypeNode(pos, Types.ref(r)), nf.Id(pos, methodName), Collections.EMPTY_LIST, CollectionUtil.list(left, right)); + try { - n = (X10Call_c) n.del().disambiguate(tc).typeCheck(tc).checkConstants(tc); - static_right = n; + n3 = X10Cast_c.check(n3, tc); + if (n3.methodInstance().def().flags().isStatic()) + static_right = n3; } catch (SemanticException e2) { // Cannot find the method. Fall through. } } - - + if (invMethodName != null) { // Check if there is a method with the appropriate name and type with the left operand as receiver. - X10Call_c n = (X10Call_c) nf.X10Call(position(), right, nf.Id(position(), invMethodName), Collections.EMPTY_LIST, Collections.singletonList(left)); - + X10Call_c n5 = (X10Call_c) nf.X10Call(pos, right, nf.Id(pos, invMethodName), Collections.EMPTY_LIST, Collections.singletonList(left)); + try { - n = (X10Call_c) n.del().disambiguate(tc).typeCheck(tc).checkConstants(tc); - virtual_right = n; + n5 = X10Cast_c.check(n5, tc); + if (! n5.methodInstance().def().flags().isStatic()) + virtual_right = n5; } catch (SemanticException e2) { // Cannot find the method. Fall through. } } - + List<X10Call_c> defs = new ArrayList<X10Call_c>(); if (virtual_left != null) defs.add(virtual_left); if (virtual_right != null) defs.add(virtual_right); if (static_left != null) defs.add(static_left); if (static_right != null) defs.add(static_right); - + if (defs.size() > 1) { - + X10TypeSystem ts = (X10TypeSystem) tc.typeSystem(); + X10Call_c best = null; - + boolean bestNeedsConversion = false; + boolean bestNeedsExplicitConversion = false; + for (int i = 0; i < defs.size(); i++) { - X10Call_c n = defs.get(i); - if (best == null) - best = n; + X10Call_c n1 = defs.get(i); + + // Check if n needs a conversio + boolean needsConversion = false; + boolean needsExplicitConversion = false; + if (n1.arguments().size() == 1 && n1.target() instanceof Expr) { + Expr[] actuals = new Expr[] { (Expr) n1.target(), n1.arguments().get(0) }; + Expr[] original = new Expr[] { left, right }; + needsConversion = needsConversion(actuals, original); + needsExplicitConversion = needsExplicitConversion(actuals, original); + } + else if (n1.arguments().size() == 2) { + Expr[] actuals = new Expr[] { n1.arguments().get(0), n1.arguments().get(1) }; + Expr[] original = new Expr[] { left, right }; + needsConversion = needsConversion(actuals, original); + needsExplicitConversion = needsExplicitConversion(actuals, original); + } + + if (best == null) { + best = n1; + bestNeedsConversion = needsConversion; + bestNeedsExplicitConversion = needsExplicitConversion; + } + else if (needsExplicitConversion && ! bestNeedsExplicitConversion) { + // best is still the best + } + else if (needsConversion && ! bestNeedsConversion) { + // best is still the best + } + else if (! needsExplicitConversion && bestNeedsExplicitConversion) { + best = n1; + bestNeedsConversion = needsConversion; + bestNeedsExplicitConversion = needsExplicitConversion; + } + else if (! needsConversion && bestNeedsConversion) { + best = n1; + bestNeedsConversion = needsConversion; + bestNeedsExplicitConversion = needsExplicitConversion; + } else { MethodDef m0 = best.methodInstance().def(); - MethodDef mi = n.methodInstance().def(); + MethodDef mi = n1.methodInstance().def(); if (m0 == mi) continue; + Type t0 = Types.get(m0.container()); Type ti = Types.get(mi.container()); - t0 = X10TypeMixin.baseType(t0); - ti = X10TypeMixin.baseType(ti); - if (t0 instanceof ClassType && ti instanceof ClassType) { - ClassDef c0 = ((ClassType) t0).def(); - ClassDef ci = ((ClassType) ti).def(); - if (xts.descendsFrom(ci, c0)) { - best = n; + ClassDef d0 = def(t0); + ClassDef di = def(ti); + + if (d0 == null || di == null) { + throw new SemanticException("Ambiguous operator: multiple methods match operator " + op + ": " + m0 + " and " + mi + ".", pos); } - else if (xts.descendsFrom(c0, ci)) { + + if (ts.descendsFrom(d0, di)) { // best is still the best } + else if (ts.descendsFrom(di, d0)) { + best = n1; + bestNeedsConversion = needsConversion; + bestNeedsExplicitConversion = needsExplicitConversion; + } else { - throw new SemanticException("Ambiguous operator: multiple methods match operator " + op + ".", position()); + throw new SemanticException("Ambiguous operator: multiple methods match operator " + op + ": " + m0 + " and " + mi + ".", pos); } - } } } - + assert best != null; return best; } - + if (defs.size() == 1) return defs.get(0); - - X10Binary_c n = (X10Binary_c) superTypeCheck(tc); - - Type resultType = n.type(); - resultType = xts.performBinaryOperation(resultType, l, r, op); - if (resultType != n.type()) { - n = (X10Binary_c) n.type(resultType); - } - - return n; + + return null; } - - // Override to insert explicit coercions. - private Expr superTypeCheck(ContextVisitor tc) throws SemanticException { - Type l = left.type(); - Type r = right.type(); - - TypeSystem ts = tc.typeSystem(); - Context context = tc.context(); - - if (op == GT || op == LT || op == GE || op == LE) { - if (l.isNumeric() && r.isNumeric()) { - return type(ts.Boolean()); - } - } - - if (op == COND_OR || op == COND_AND) { - if (l.isBoolean() && r.isBoolean()) { - return type(ts.Boolean()); - } - } - - if (op == ADD) { - if (ts.isSubtype(l, ts.String(), context) || ts.isSubtype(r, ts.String(), context)) { - if (!ts.canCoerceToString(r, tc.context())) { - throw new SemanticException("Cannot coerce an expression " + - "of type " + r + " to a String.", - right.position()); + + public static ClassDef def(Type t) { + Type base = X10TypeMixin.baseType(t); + if (base instanceof ClassType) + return ((ClassType) base).def(); + return null; + } + + public static boolean needsExplicitConversion(Expr[] actuals, Expr[] original) { + for (int k = 0; k < actuals.length; k++) { + if (actuals[k] != original[k]) + if (actuals[k] instanceof X10Call) { + X10Call c = (X10Call) actuals[k]; + if (c.methodInstance().name() == X10Cast_c.operator_as) + return true; } - if (!ts.canCoerceToString(l, tc.context())) { - throw new SemanticException("Cannot coerce an expression " + - "of type " + l + " to a String.", - left.position()); - } - - Expr newLeft = coerceToString(tc, left); - Expr newRight = coerceToString(tc, right); - - return precedence(Precedence.STRING_ADD).left(newLeft).right(newRight).type(ts.String()); - } } + return false; + } - if (op == ADD || op == SUB || op == MUL || op == DIV || op == MOD) { - if (l.isNumeric() && r.isNumeric()) { - Type t = ts.promote(l, r); - Expr le = X10New_c.attemptCoercion(tc, left, t); - Expr re = X10New_c.attemptCoercion(tc, right, t); - return left(le).right(re).type(t); - } + public static boolean needsConversion(Expr[] actuals, Expr[] original) { + for (int k = 0; k < actuals.length; k++) { + if (actuals[k] != original[k]) + return true; } - - if (op == BIT_AND || op == BIT_OR || op == BIT_XOR) { - if (l.isBoolean() && r.isBoolean()) { - return type(ts.Boolean()); - } - - if (ts.isLongOrLess(l) && ts.isLongOrLess(r)) { - Type t = ts.promote(l, r); - Expr le = X10New_c.attemptCoercion(tc, left, t); - Expr re = X10New_c.attemptCoercion(tc, right, t); - return left(le).right(re).type(t); - } - } - - if (op == SHL || op == SHR || op == USHR) { - if (ts.isLongOrLess(l) && ts.isLongOrLess(r)) { - // For shift, only promote the left operand. - Type t = ts.promote(l); - Expr le = X10New_c.attemptCoercion(tc, left, t); - return left(le).type(t); - } - } - - throw new SemanticException("No operation " + op + " found for operands " + l + " and " + r + ".", position()); + return false; } protected static Expr coerceToString(ContextVisitor tc, Expr e) throws SemanticException { @@ -483,7 +618,7 @@ } public X10Binary_c invert(boolean invert) { - X10Binary_c n = (X10Binary_c) copy(); + X10Binary_c n = (X10Binary_c) copy(); n.invert = invert; return n; } Modified: trunk/x10.compiler.p3/src/polyglot/ext/x10/ast/X10Cast_c.java =================================================================== --- trunk/x10.compiler.p3/src/polyglot/ext/x10/ast/X10Cast_c.java 2009-06-26 20:39:46 UTC (rev 10558) +++ trunk/x10.compiler.p3/src/polyglot/ext/x10/ast/X10Cast_c.java 2009-06-26 20:49:14 UTC (rev 10559) @@ -9,62 +9,33 @@ import java.util.ArrayList; import java.util.Collections; -import java.util.HashMap; import java.util.List; -import java.util.ListIterator; -import polyglot.ast.Block; import polyglot.ast.Call; -import polyglot.ast.Cast; import polyglot.ast.Cast_c; -import polyglot.ast.ClassBody; -import polyglot.ast.ClassMember; -import polyglot.ast.ConstructorCall; -import polyglot.ast.Eval; import polyglot.ast.Expr; -import polyglot.ast.Formal; -import polyglot.ast.Local; -import polyglot.ast.LocalDecl; -import polyglot.ast.MethodDecl; -import polyglot.ast.New; -import polyglot.ast.New_c; import polyglot.ast.Node; import polyglot.ast.Precedence; -import polyglot.ast.Special; -import polyglot.ast.Stmt; import polyglot.ast.TypeNode; import polyglot.ext.x10.types.ParameterType; -import polyglot.ext.x10.types.X10ClassDef; import polyglot.ext.x10.types.X10ClassType; -import polyglot.ext.x10.types.X10ConstructorDef; import polyglot.ext.x10.types.X10Context; -import polyglot.ext.x10.types.X10Def; -import polyglot.ext.x10.types.X10Flags; -import polyglot.ext.x10.types.X10LocalDef; -import polyglot.ext.x10.types.X10MethodInstance; import polyglot.ext.x10.types.X10TypeMixin; import polyglot.ext.x10.types.X10TypeSystem; +import polyglot.types.ClassDef; import polyglot.types.ConstructorDef; import polyglot.types.ConstructorInstance; import polyglot.types.Context; import polyglot.types.ErrorRef_c; -import polyglot.types.Flags; -import polyglot.types.LocalInstance; import polyglot.types.MethodInstance; import polyglot.types.Name; import polyglot.types.ObjectType; -import polyglot.types.Package; -import polyglot.types.Ref; import polyglot.types.SemanticException; import polyglot.types.Type; import polyglot.types.TypeSystem; import polyglot.types.Types; -import polyglot.util.CollectionUtil; import polyglot.util.Position; import polyglot.visit.ContextVisitor; -import polyglot.visit.TypeBuilder; -import polyglot.visit.TypeCheckPreparer; -import polyglot.visit.TypeChecker; import x10.constraint.XConstraint; /** @@ -85,6 +56,9 @@ this.convert = convert; } + public static final Name operator_as = Name.make("operator_as"); + public static final Name implicit_operator_as = Name.make("implicit_operator_as"); + public ConversionType conversionType() { return convert; } @@ -170,11 +144,9 @@ ObjectType o = (ObjectType) t; if (o.superClass() != null) { l.add(o.superClass()); - // addSuperTypes(l, o.superClass()); } for (Type ti : o.interfaces()) { l.add(ti); - // addSuperTypes(l, ti); } } } @@ -262,34 +234,27 @@ n.convert = ConversionType.CHECKED; return n.type(toType); } - - if (ts.isBoolean(fromType) && ts.isBoolean(toType) || - ts.isNumeric(fromType) && ts.isNumeric(toType) || - ts.isChar(fromType) && ts.isChar(toType)) { - if (cFrom == null || cTo == null || ts.clausesConsistent(cFrom, cTo, context)) { - X10Cast_c n = (X10Cast_c) copy(); - n.convert = ConversionType.PRIMITIVE; - return n.type(toType); - } - } } - else { - if (ts.isNumeric(fromType) && ts.isNumeric(toType)) { - if (ts.isImplicitNumericCastValid(fromType, toType, context)) { - X10Cast_c n = (X10Cast_c) copy(); - n.convert = ConversionType.PRIMITIVE; - return n.type(toType); - } - } - } { MethodInstance converter = null; // Can convert if there is a static method toType.$convert(fromType) + if (converter == null && convert != ConversionType.UNKNOWN_IMPLICIT_CONVERSION) { + try { + MethodInstance mi = ts.findMethod(toType, ts.MethodMatcher(toType, operator_as, Collections.singletonList(fromType), context)); + Type baseMiType = X10TypeMixin.baseType(mi.returnType()); + if (mi.flags().isStatic() && baseMiType.isSubtype(baseTo, context)) { + converter = mi; + } + } + catch (SemanticException e) { + } + } + if (converter == null) { try { - MethodInstance mi = ts.findMethod(toType, ts.MethodMatcher(toType, Name.make("$convert"), Collections.singletonList(fromType), context)); + MethodInstance mi = ts.findMethod(toType, ts.MethodMatcher(toType, implicit_operator_as, Collections.singletonList(fromType), context)); Type baseMiType = X10TypeMixin.baseType(mi.returnType()); if (mi.flags().isStatic() && baseMiType.isSubtype(baseTo, context)) { converter = mi; Modified: trunk/x10.compiler.p3/src/polyglot/ext/x10/ast/X10Conditional_c.java =================================================================== --- trunk/x10.compiler.p3/src/polyglot/ext/x10/ast/X10Conditional_c.java 2009-06-26 20:39:46 UTC (rev 10558) +++ trunk/x10.compiler.p3/src/polyglot/ext/x10/ast/X10Conditional_c.java 2009-06-26 20:49:14 UTC (rev 10559) @@ -33,6 +33,7 @@ import polyglot.ext.x10.types.X10TypeSystem; import polyglot.ext.x10.visit.ExprFlattener; import polyglot.ext.x10.visit.ExprFlattener.Flattener; +import polyglot.types.Context; import polyglot.types.Flags; import polyglot.types.LocalDef; import polyglot.types.SemanticException; @@ -49,174 +50,190 @@ */ public class X10Conditional_c extends Conditional_c implements X10Conditional { - /** - * @param pos - * @param cond - * @param consequent - * @param alternative - */ - public X10Conditional_c(Position pos, Expr cond, Expr consequent, - Expr alternative) { - super(pos, cond, consequent, alternative); - - } - public Node typeCheck(ContextVisitor tc) throws SemanticException { - X10TypeSystem ts = (X10TypeSystem) tc.typeSystem(); - - if (! cond.type().isBoolean()) { - throw new SemanticException( - "Condition of ternary expression must be of type boolean.", - cond.position()); - } - - Expr e1 = consequent; - Expr e2 = alternative; - - X10Type t1 = (X10Type) e1.type(); - X10Type t2 = (X10Type) e2.type(); - - // From the JLS, section: - // If the second and third operands have the same type (which may be - // the null type), then that is the type of the conditional expression. - if (ts.typeEquals(t1, t2, tc.context())) - return type(t1); - - if (ts.typeBaseEquals(t1, t2, tc.context())) { - return type(X10TypeMixin.baseType(t1)); - } - - // Otherwise, if the second and third operands have numeric type, then - // there are several cases: - if (t1.isNumeric() && t2.isNumeric()) { - // - If one of the operands is of type byte and the other is of - // type short, then the type of the conditional expression is - // short. - if (t1.isByte() && t2.isShort() || t1.isShort() && t2.isByte()) { - return type(ts.Short()); - } - - // - If one of the operands is of type T where T is byte, short, or - // char, and the other operand is a constant expression of type int - // whose value is representable in type T, then the type of the - // conditional expression is T. - - if (t1.isIntOrLess() && - t2.isInt() && - ts.numericConversionValid(t1, e2.constantValue(), tc.context())) { - return type(t1); - } + /** + * @param pos + * @param cond + * @param consequent + * @param alternative + */ + public X10Conditional_c(Position pos, Expr cond, Expr consequent, + Expr alternative) { + super(pos, cond, consequent, alternative); + + } + public Node typeCheck(ContextVisitor tc) throws SemanticException { + X10TypeSystem ts = (X10TypeSystem) tc.typeSystem(); + Context context = tc.context(); + + if (! cond.type().isBoolean()) { + throw new SemanticException( + "Condition of ternary expression must be of type boolean.", + cond.position()); + } + + Expr e1 = consequent; + Expr e2 = alternative; + + X10Type t1 = (X10Type) e1.type(); + X10Type t2 = (X10Type) e2.type(); + + // From the JLS, section: + // If the second and third operands have the same type (which may be + // the null type), then that is the type of the conditional expression. + if (ts.typeEquals(t1, t2, context)) + return type(t1); + + if (ts.typeBaseEquals(t1, t2, context)) { + return type(X10TypeMixin.baseType(t1)); + } + + // Otherwise, if the second and third operands have numeric type, then + // there are several cases: + if (t1.isNumeric() && t2.isNumeric()) { + // - If one of the operands is of type byte and the other is of + // type short, then the type of the conditional expression is + // short. + if (t1.isByte() && t2.isShort() || t1.isShort() && t2.isByte()) { + return type(ts.Short()); + } + + if (ts.isUByte(t1) && ts.isUShort(t2) || ts.isUByte(t2) && ts.isUShort(t1)) + return type(ts.UShort()); + + // - If one of the operands is of type T where T is byte, short, or + // char, and the other operand is a constant expression of type int + // whose value is representable in type T, then the type of the + // conditional expression is T. + + if ((ts.isByte(t1) || ts.isShort(t1) || ts.isInt(t1) || ts.isUByte(t1) || ts.isUShort(t1) || ts.isUInt(t1)) && + t2.isInt() && + ts.numericConversionValid(t1, e2.constantValue(), context)) { + return type(t1); + } - if (t2.isIntOrLess() && - t1.isInt() && - ts.numericConversionValid(t2, e1.constantValue(), tc.context())) { - return type(t2); - } - - // - Otherwise, binary numeric promotion (Sec. 5.6.2) is applied to the - // operand types, and the type of the conditional expression is the - // promoted type of the second and third operands. Note that binary - // numeric promotion performs value set conversion (Sec. 5.1.8). - return type(ts.promote(t1, t2)); - } - - // If one of the second and third operands is of the null type and the - // type of the other is a reference type, then the type of the - // conditional expression is that reference type. - if (t1.isNull() && t2.isReference()) return type(t2); - if (t2.isNull() && t1.isReference()) return type(t1); - - // If the second and third operands are of different reference types, - // then it must be possible to convert one of the types to the other - // type (call this latter type T) by assignment conversion (Sec. 5.2); the - // type of the conditional expression is T. It is a compile-time error - // if neither type is assignment compatible with the other type. - - if (t1.isReference() && t2.isReference()) { - if (ts.isImplicitCastValid(t1, t2, tc.context())) { - return type(t2); - } - if (ts.isImplicitCastValid(t2, t1, tc.context())) { - return type(t1); - } - } - - try { - Type t = ts.leastCommonAncestor(t1, t2, tc.context()); - Expr n1 = X10New_c.attemptCoercion(tc, e1, t); - Expr n2 = X10New_c.attemptCoercion(tc, e2, t); - return consequent(n1).alternative(n2).type(t); - } - catch (SemanticException e) { - } + if ((ts.isByte(t1) || ts.isShort(t1) || ts.isInt(t1) || ts.isUByte(t1) || ts.isUShort(t1) || ts.isUInt(t1)) && + ts.isUInt(t2) && + ts.numericConversionValid(t1, e2.constantValue(), context)) { + return type(t1); + } - throw new SemanticException("Could not determine type of ternary conditional expression; cannot assign " + t1 + " to " + t2 + " or vice versa.", - position()); - } - + if ((ts.isByte(t2) || ts.isShort(t2) || ts.isInt(t2) || ts.isUByte(t2) || ts.isUShort(t2) || ts.isUInt(t2)) && + t1.isInt() && + ts.numericConversionValid(t2, e2.constantValue(), context)) { + return type(t2); + } - /** Flatten the expressions in place and body, creating stmt if necessary. - * The place field must be visited by the given flattener since those statements must be executed outside - * the future. Howeever, the body must be visited in a new flattener and the statements produced - * captured and stored in stmt. - * Note that this works by side-effecting the current node. This is necessary - * because the method is called from within an enter call for a Visitor. I dont know - * of any way of making the enter call return a copy of the node. - * @param fc - * @return - */ - public Expr flatten(ExprFlattener.Flattener fc) { - //Report.report(1, "X10Binary_c: entering X10Binary " + this); - X10Context xc = (X10Context) fc.context(); - - - final NodeFactory nf = fc.nodeFactory(); - final TypeSystem ts = fc.typeSystem(); - final Position pos = position(); + if ((ts.isByte(t2) || ts.isShort(t2) || ts.isInt(t2) || ts.isUByte(t2) || ts.isUShort(t2) || ts.isUInt(t2)) && + ts.isUInt(t1) && + ts.numericConversionValid(t2, e2.constantValue(), context)) { + return type(t2); + } - final Id condVarName = nf.Id(pos, xc.getNewVarName()); - final Id resultVarName = nf.Id(pos, xc.getNewVarName()); - final TypeNode condTn = nf.CanonicalTypeNode(pos,cond.type()); - final TypeNode resultTn = nf.CanonicalTypeNode(pos,type); - Flags flags = Flags.NONE; - - final LocalDef condLi = ts.localDef(pos, flags, Types.ref(cond.type()), resultVarName.id()); - // Evaluate the condition. - Expr nCond = (Expr) cond.visit(fc); - final LocalDecl condDecl = nf.LocalDecl(pos, nf.FlagsNode(pos, flags), condTn, resultVarName, nCond).localDef(condLi); - fc.add(condDecl); - final Local condRef = (Local) nf.Local(pos,resultVarName).localInstance(condLi.asInstance()).type(cond.type()); + // - Otherwise, binary numeric promotion (Sec. 5.6.2) is applied to the + // operand types, and the type of the conditional expression is the + // promoted type of the second and third operands. Note that binary + // numeric promotion performs value set conversion (Sec. 5.1.8). + return type(ts.promote(t1, t2)); + } + + // If one of the second and third operands is of the null type and the + // type of the other is a reference type, then the type of the + // conditional expression is that reference type. + if (t1.isNull() && t2.isReference()) return type(t2); + if (t2.isNull() && t1.isReference()) return type(t1); + + // If the second and third operands are of different reference types, + // then it must be possible to convert one of the types to the other + // type (call this latter type T) by assignment conversion (Sec. 5.2); the + // type of the conditional expression is T. It is a compile-time error + // if neither type is assignment compatible with the other type. + + if (t1.isReference() && t2.isReference()) { + if (ts.isImplicitCastValid(t1, t2, context)) { + return type(t2); + } + if (ts.isImplicitCastValid(t2, t1, context)) { + return type(t1); + } + } + + try { + Type t = ts.leastCommonAncestor(t1, t2, context); + Expr n1 = X10New_c.attemptCoercion(tc, e1, t); + Expr n2 = X10New_c.attemptCoercion(tc, e2, t); + return consequent(n1).alternative(n2).type(t); + } + catch (SemanticException e) { + } - final LocalDef resultLi = ts.localDef(pos, flags, Types.ref(type), resultVarName.id()); - final Local ldRef = (Local) nf.Local(pos,resultVarName).localInstance(resultLi.asInstance()).type(type); + throw new SemanticException("Could not determine type of ternary conditional expression; cannot assign " + t1 + " to " + t2 + " or vice versa.", + position()); + } + - Block then_, else_; - - { - Flattener newVisitor = (Flattener) new ExprFlattener.Flattener(fc.job(), ts, nf, this).context(xc); - Expr nThen = (Expr) consequent.visit(newVisitor); - List thenBody = newVisitor.stmtList(); - Expr assign = nf.Assign(pos, ldRef, Assign.ASSIGN, nThen ).type(type); - Stmt eval = nf.Eval(pos, assign); - thenBody.add(eval); - then_ = nf.Block(pos, thenBody); - } - - { - Flattener newVisitor = (Flattener) new ExprFlattener.Flattener(fc.job(), ts, nf, this).context(xc); - Expr nElse = (Expr) alternative.visit(newVisitor); - List elseBody = newVisitor.stmtList(); - Expr assign = nf.Assign(pos, ldRef, Assign.ASSIGN, nElse ).type(type); - Stmt eval = nf.Eval(pos, assign); - elseBody.add(eval); - else_ = nf.Block(pos, elseBody); - } + /** Flatten the expressions in place and body, creating stmt if necessary. + * The place field must be visited by the given flattener since those statements must be executed outside + * the future. Howeever, the body must be visited in a new flattener and the statements produced + * captured and stored in stmt. + * Note that this works by side-effecting the current node. This is necessary + * because the method is called from within an enter call for a Visitor. I dont know + * of any way of making the enter call return a copy of the node. + * @param fc + * @return + */ + public Expr flatten(ExprFlattener.Flattener fc) { + //Report.report(1, "X10Binary_c: entering X10Binary " + this); + X10Context xc = (X10Context) fc.context(); + + + final NodeFactory nf = fc.nodeFactory(); + final TypeSystem ts = fc.typeSystem(); + final Position pos = position(); - final Stmt ifStm = nf.If(pos, condRef, then_, else_); - fc.add(ifStm); - - //Report.report(1, "X10Binary_c: returning " + ldRef3); - return ldRef; - - } + final Id condVarName = nf.Id(pos, xc.getNewVarName()); + final Id resultVarName = nf.Id(pos, xc.getNewVarName()); + final TypeNode condTn = nf.CanonicalTypeNode(pos,cond.type()); + final TypeNode resultTn = nf.CanonicalTypeNode(pos,type); + Flags flags = Flags.NONE; + + final LocalDef condLi = ts.localDef(pos, flags, Types.ref(cond.type()), resultVarName.id()); + // Evaluate the condition. + Expr nCond = (Expr) cond.visit(fc); + final LocalDecl condDecl = nf.LocalDecl(pos, nf.FlagsNode(pos, flags), condTn, resultVarName, nCond).localDef(condLi); + fc.add(condDecl); + final Local condRef = (Local) nf.Local(pos,resultVarName).localInstance(condLi.asInstance()).type(cond.type()); + final LocalDef resultLi = ts.localDef(pos, flags, Types.ref(type), resultVarName.id()); + final Local ldRef = (Local) nf.Local(pos,resultVarName).localInstance(resultLi.asInstance()).type(type); + + Block then_, else_; + + { + Flattener newVisitor = (Flattener) new ExprFlattener.Flattener(fc.job(), ts, nf, this).context(xc); + Expr nThen = (Expr) consequent.visit(newVisitor); + List thenBody = newVisitor.stmtList(); + Expr assign = nf.Assign(pos, ldRef, Assign.ASSIGN, nThen ).type(type); + Stmt eval = nf.Eval(pos, assign); + thenBody.add(eval); + then_ = nf.Block(pos, thenBody); + } + + { + Flattener newVisitor = (Flattener) new ExprFlattener.Flattener(fc.job(), ts, nf, this).context(xc); + Expr nElse = (Expr) alternative.visit(newVisitor); + List elseBody = newVisitor.stmtList(); + Expr assign = nf.Assign(pos, ldRef, Assign.ASSIGN, nElse ).type(type); + Stmt eval = nf.Eval(pos, assign); + elseBody.add(eval); + else_ = nf.Block(pos, elseBody); + } + + final Stmt ifStm = nf.If(pos, condRef, then_, else_); + fc.add(ifStm); + + //Report.report(1, "X10Binary_c: returning " + ldRef3); + return ldRef; + + } + } Modified: trunk/x10.compiler.p3/src/polyglot/ext/x10/ast/X10IntLit_c.java =================================================================== --- trunk/x10.compiler.p3/src/polyglot/ext/x10/ast/X10IntLit_c.java 2009-06-26 20:39:46 UTC (rev 10558) +++ trunk/x10.compiler.p3/src/polyglot/ext/x10/ast/X10IntLit_c.java 2009-06-26 20:49:14 UTC (rev 10559) @@ -19,50 +19,106 @@ import polyglot.ext.x10.types.XTypeTranslator; import polyglot.types.SemanticException; import polyglot.types.Type; +import polyglot.util.InternalCompilerError; import polyglot.util.Position; import polyglot.visit.ContextVisitor; import x10.constraint.XConstraint; import x10.constraint.XConstraint_c; import x10.constraint.XFailure; import x10.constraint.XTerm; +import polyglot.ast.IntLit; +import polyglot.ast.IntLit.Kind; /** - * An immutable representation of an int lit, modified from JL - * to support a self-clause in the dep type. + * An immutable representation of an int lit, modified from JL to support a + * self-clause in the dep type. + * * @author vj - * + * */ public class X10IntLit_c extends IntLit_c { - /** - * @param pos - * @param kind - * @param value - */ - public X10IntLit_c(Position pos, Kind kind, long value) { - super(pos, kind,value); - - } - /** Type check the expression. */ - public Node typeCheck(ContextVisitor tc) throws SemanticException { - if (kind==INT) { - if ((value > (long)Integer.MAX_VALUE || value < (long)Integer.MIN_VALUE) && - (value & ~0xFFFFFFFFL) != 0L) - { - throw new SemanticException("Integer literal " + value + " is out of range.",position()); - } - } - X10TypeSystem xts = (X10TypeSystem) tc.typeSystem(); - X10Type Type = (X10Type) (kind==INT ? xts.Int() : xts.Long()); - - XConstraint c = new XConstraint_c(); - XTerm term = xts.xtypeTranslator().trans(c, this.type(Type), (X10Context) tc.context()); - try { - c.addSelfBinding(term); - } - catch (XFailure e) { - } - Type newType = X10TypeMixin.xclause(Type, c); - return type(newType); - } + public static class KindWithUnsigned extends IntLit.Kind { + + public KindWithUnsigned(String name) { + super(name); + } + } + + public static final KindWithUnsigned UINT = new KindWithUnsigned("uint"); + public static final KindWithUnsigned ULONG = new KindWithUnsigned("ulong"); + + /** + * @param pos + * @param kind + * @param value + */ + public X10IntLit_c(Position pos, Kind kind, long value) { + super(pos, kind, value); + } + + /** Type check the expression. */ + public Node typeCheck(ContextVisitor tc) throws SemanticException { + if (kind == INT) { + if ((value > (long) Integer.MAX_VALUE || value < (long) Integer.MIN_VALUE) && (value & ~0xFFFFFFFFL) != 0L) { + throw new SemanticException("Integer literal " + value + " is out of range.", position()); + } + } + if (kind == UINT) { + if (value < 0 && (value & ~0xFFFFFFFFL) != 0L) { + throw new SemanticException("Unsigned integer literal " + value + " is out of range.", position()); + } + } + X10TypeSystem xts = (X10TypeSystem) tc.typeSystem(); + Type Type; + if (kind == INT) { + Type = xts.Int(); + } + else if (kind == UINT) { + Type = xts.UInt(); + } + else if (kind == LONG) { + Type = xts.Long(); + } + else if (kind == ULONG) { + Type = xts.ULong(); + } + else { + throw new InternalCompilerError("bad integer literal kind", position()); + } + XConstraint c = new XConstraint_c(); + XTerm term = xts.xtypeTranslator().trans(c, this.type(Type), (X10Context) tc.context()); + try { + c.addSelfBinding(term); + } + catch (XFailure e) { + } + Type newType = X10TypeMixin.xclause(Type, c); + return type(newType); + } + + @Override + public String toString() { + if (kind() == UINT) { + return Long.toString(value & 0xffffffffL) + "U"; + } + else if (kind() == LONG) { + return Long.toString(value) + "L"; + } + else if (kind() == ULONG) { + StringBuilder sb = new StringBuilder(); + long a = value; + if (a >= 0) + return Long.toString(a); + while (a != 0) { + char ch = (char) ('0' + a % 10); + sb.append(ch); + a /= 10; + } + return sb.reverse().toString() + "UL"; + } + else { + return Long.toString((int) value); + } + } } Modified: trunk/x10.compiler.p3/src/polyglot/ext/x10/ast/X10Local_c.java =================================================================== --- trunk/x10.compiler.p3/src/polyglot/ext/x10/ast/X10Local_c.java 2009-06-26 20:39:46 UTC (rev 10558) +++ trunk/x10.compiler.p3/src/polyglot/ext/x10/ast/X10Local_c.java 2009-06-26 20:49:14 UTC (rev 10559) @@ -78,6 +78,7 @@ result = (X10Local_c) result.type(((X10LocalInstance) li).rightType()); // Fold in the method's guard. + // %%% FIXME: move method guard into context.currentConstraint CodeDef ci = context.currentCode(); if (ci instanceof X10ProcedureDef) { X10ProcedureDef pi = (X10ProcedureDef) ci; Modified: trunk/x10.compiler.p3/src/polyglot/ext/x10/ast/X10New_c.java =================================================================== --- trunk/x10.compiler.p3/src/polyglot/ext/x10/ast/X10New_c.java 2009-06-26 20:39:46 UTC (rev 10558) +++ trunk/x10.compiler.p3/src/polyglot/ext/x10/ast/X10New_c.java 2009-06-26 20:49:14 UTC (rev 10559) @@ -16,7 +16,6 @@ import java.util.Map; import polyglot.ast.AmbTypeNode; -import... [truncated message content] |
From: <ipe...@us...> - 2009-07-07 23:21:28
|
Revision: 10620 http://x10.svn.sourceforge.net/x10/?rev=10620&view=rev Author: ipeshansky Date: 2009-07-07 23:21:26 +0000 (Tue, 07 Jul 2009) Log Message: ----------- Complete the job started by r10617 and move the rest of the distro to pgas2 Modified Paths: -------------- trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/X10CPPTranslator.java trunk/x10.dist/bin/x10c++ Modified: trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/X10CPPTranslator.java =================================================================== --- trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/X10CPPTranslator.java 2009-07-07 13:25:41 UTC (rev 10619) +++ trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/X10CPPTranslator.java 2009-07-07 23:21:26 UTC (rev 10620) @@ -451,7 +451,7 @@ private static class CXXCommandBuilder { public static final String DUMMY = "-U___DUMMY___"; - public static final String X10LIB = System.getenv("X10LIB")==null?"../../../pgas/common/work":System.getenv("X10LIB").replace(File.separatorChar, '/'); + public static final String X10LIB = System.getenv("X10LIB")==null?"../../../pgas2/common/work":System.getenv("X10LIB").replace(File.separatorChar, '/'); public static final String X10GC = System.getenv("X10GC")==null?"../../../x10.dist":System.getenv("X10GC").replace(File.separatorChar, '/'); public static final String TRANSPORT = System.getenv("X10RT_TRANSPORT")==null?DEFAULT_TRANSPORT:System.getenv("X10RT_TRANSPORT"); public static final boolean USE_XLC = PLATFORM.startsWith("aix_") && System.getenv("USE_GCC")==null; Modified: trunk/x10.dist/bin/x10c++ =================================================================== --- trunk/x10.dist/bin/x10c++ 2009-07-07 13:25:41 UTC (rev 10619) +++ trunk/x10.dist/bin/x10c++ 2009-07-07 23:21:26 UTC (rev 10620) @@ -23,7 +23,7 @@ else # Default to developer setup [ -z "$X10REL" ] && export X10REL="../x10.dist" - [ -z "$X10LIB" ] && export X10LIB="$TOP/../pgas/common/work" + [ -z "$X10LIB" ] && export X10LIB="$TOP/../pgas2/common/work" [ -z "$X10LANG" ] && export X10LANG="$TOP/../x10.runtime.17/src-cpp" [ -z "$X10GC" ] && export X10GC="$TOP/../x10.runtime.17/src-cpp/bdwgc/install" X10="$(cd "$TOP/$X10REL" && pwd)" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ipe...@us...> - 2009-07-08 15:04:11
|
Revision: 10630 http://x10.svn.sourceforge.net/x10/?rev=10630&view=rev Author: ipeshansky Date: 2009-07-08 15:04:06 +0000 (Wed, 08 Jul 2009) Log Message: ----------- Fix XTENLANG-423 and add a test case. Modified Paths: -------------- trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/Emitter.java trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/MessagePassingCodeGenerator.java trunk/x10.runtime.17/src-cpp/x10/lang/Ref.h trunk/x10.runtime.17/src-cpp/x10/lang/Throwable.h trunk/x10.runtime.17/src-cpp/x10/lang/Value.h Added Paths: ----------- trunk/x10.tests/examples/Issues/XTENLANG_423.x10 Modified: trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/Emitter.java =================================================================== --- trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/Emitter.java 2009-07-08 11:27:12 UTC (rev 10629) +++ trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/Emitter.java 2009-07-08 15:04:06 UTC (rev 10630) @@ -371,6 +371,8 @@ } public static String voidTemplateInstantiation(int num) { + if (num <= 0) + return ""; StringBuffer b = new StringBuffer(); b.append("<"); for (int i = 0; i < num; i++) { Modified: trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/MessagePassingCodeGenerator.java =================================================================== --- trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/MessagePassingCodeGenerator.java 2009-07-08 11:27:12 UTC (rev 10629) +++ trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/MessagePassingCodeGenerator.java 2009-07-08 15:04:06 UTC (rev 10630) @@ -293,6 +293,7 @@ return ct.typeArguments(args); } + // FIXME: Consolidate with extractInits() private boolean extractGenericStaticDecls(X10ClassDef cd, ClassifiedStream w) { X10CPPContext_c context = (X10CPPContext_c) tr.context(); if (cd.typeParameters().size() == 0) @@ -359,16 +360,15 @@ } w.newline(); w.forceNewline(); } - if (hasInits) { - w.write("static " + VOID + " " + STATIC_INIT + "();"); - w.newline(); w.forceNewline(); - } + w.write("static " + VOID + " " + STATIC_INIT + "();"); + w.newline(); w.forceNewline(); w.end(); w.newline(); w.write("};"); w.newline(); return true; } + // FIXME: Consolidate with extractInits() private void extractGenericStaticInits(X10ClassDef cd) { // Always write non-template static decls into the implementation file ClassifiedStream save_w = sw.currentStream(); @@ -445,27 +445,30 @@ } } - if (inits.size() > 0) { - 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(); - 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.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 + "();"); } + 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.popCurrentStream(); } @@ -475,6 +478,22 @@ { String className = emitter.translateType(currentClass); boolean sawInit = false; + emitter.printTemplateSignature(currentClass.typeArguments(), sw); + 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(); + String superContainer = translate_mangled_FQN(superDef.fullName().toString())+voidTemplateInstantiation(superDef.typeParameters().size()); + sw.write(superContainer + "::" + STATIC_INIT + "();"); + } + } else { + sw.write("_I_(\"Doing initialisation for class: "+className+"\");"); sw.newline(); + } for (Iterator i = members.iterator(); i.hasNext(); ) { ClassMember member = (ClassMember) i.next(); if (!(member instanceof Initializer_c) && !(member instanceof FieldDecl_c)) @@ -497,20 +516,7 @@ continue; } } - if (!sawInit) { - emitter.printTemplateSignature(currentClass.typeArguments(), sw); - 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(); - } else { - sw.write("_I_(\"Doing initialisation for class: "+className+"\");"); sw.newline(); - } - sawInit = true; - } + sawInit = true; if (member instanceof Initializer_c) { Initializer_c init = (Initializer_c) member; init.printBlock(init.body(), sw, tr); @@ -545,16 +551,15 @@ ((X10CPPTranslator)tr).setContext(context); // FIXME } } - if (sawInit) { - if (!retType.equals(VOID)) - sw.write("return ("+retType+")0;"); - sw.end(); sw.newline(); - sw.write("}"); - sw.newline(); sw.forceNewline(0); - } + if (!retType.equals(VOID)) + sw.write("return ("+retType+")0;"); + sw.end(); sw.newline(); + sw.write("}"); + sw.newline(); sw.forceNewline(0); return sawInit; } - boolean hasExternMethods(List members) { + + private boolean hasExternMethods(List members) { for (Iterator i = members.iterator(); i.hasNext(); ) { ClassMember member = (ClassMember) i.next(); if (member instanceof MethodDecl_c) { @@ -1038,9 +1043,9 @@ h.newline(); } + h.write(VOID + " " + INSTANCE_INIT + "();"); + h.newline(); h.forceNewline(); if (extractInits(currentClass, INSTANCE_INIT, VOID, members, false)) { - h.write(VOID + " " + INSTANCE_INIT + "();"); - h.newline(); h.forceNewline(); context.hasInits = true; } @@ -1222,6 +1227,9 @@ sw.write("}"); sw.newline(); } + // declare static init function in header + h.write("public : 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 @@ -1229,15 +1237,11 @@ " __attribute__((__unused__)) = x10aux::InitDispatcher::addInitializer(" + className+"::"+STATIC_INIT + ")" + ";"); sw.newline(); sw.forceNewline(0); - // declare static init function in header - h.write("public : static " + VOID + " " + STATIC_INIT + "();"); - h.newline(); - } + } if (((X10TypeSystem) tr.typeSystem()).isValueType(currentClass, context)) { emitter.generateSerializationMethods(currentClass, sw); } - } h.end(); Modified: trunk/x10.runtime.17/src-cpp/x10/lang/Ref.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/Ref.h 2009-07-08 11:27:12 UTC (rev 10629) +++ trunk/x10.runtime.17/src-cpp/x10/lang/Ref.h 2009-07-08 15:04:06 UTC (rev 10630) @@ -66,6 +66,7 @@ return false; } + static void _static_init() { } }; } Modified: trunk/x10.runtime.17/src-cpp/x10/lang/Throwable.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/Throwable.h 2009-07-08 11:27:12 UTC (rev 10629) +++ trunk/x10.runtime.17/src-cpp/x10/lang/Throwable.h 2009-07-08 15:04:06 UTC (rev 10630) @@ -71,6 +71,8 @@ template<class T> static x10aux::ref<T> _deserializer(x10aux::serialization_buffer &buf); void _deserialize_body(x10aux::serialization_buffer &buf); + + static void _static_init() { } }; template<class T> x10aux::ref<T> Throwable::_deserializer(x10aux::serialization_buffer &buf){ Modified: trunk/x10.runtime.17/src-cpp/x10/lang/Value.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/Value.h 2009-07-08 11:27:12 UTC (rev 10629) +++ trunk/x10.runtime.17/src-cpp/x10/lang/Value.h 2009-07-08 15:04:06 UTC (rev 10630) @@ -51,6 +51,8 @@ } virtual x10_boolean _struct_equals(x10aux::ref<Object> other); + + static void _static_init() { } }; template<class T> x10aux::ref<T> Value::_deserializer(x10aux::serialization_buffer &) { Added: trunk/x10.tests/examples/Issues/XTENLANG_423.x10 =================================================================== --- trunk/x10.tests/examples/Issues/XTENLANG_423.x10 (rev 0) +++ trunk/x10.tests/examples/Issues/XTENLANG_423.x10 2009-07-08 15:04:06 UTC (rev 10630) @@ -0,0 +1,39 @@ +// (C) Copyright IBM Corporation 2009 +// This file is part of X10 Test. * + +import harness.x10Test; + +/** + * @author igor 7/2009 + */ + +public class XTENLANG_423 extends x10Test { + + public static class X { + public const a = foo(); + public static def foo() = 3; + } + + public static class Y extends X { + public const b = bar(); + public static def bar() = X.a; + } + + public static class Z[T] { + public const c = baz(); + public static def baz() = 5; + } + + public static class W[U] extends Z[W[U]] { + public const d = boo(); + public static def boo() = Z.c; + } + + public def run() : boolean { + return Y.b == 3 && W.d == 5; + } + + public static def main(Rail[String]) { + new XTENLANG_423().execute(); + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dgr...@us...> - 2009-07-08 21:26:55
|
Revision: 10637 http://x10.svn.sourceforge.net/x10/?rev=10637&view=rev Author: dgrove-oss Date: 2009-07-08 21:26:52 +0000 (Wed, 08 Jul 2009) Log Message: ----------- WIP in reducing the number of NativeReped classes in XRX. This commit makes several related changes to the handling of NativeRep classes by the code generator. (1) We no longer emit the empty c/h/inc files for a NativeRep class (2) #include directives are generated for NativeRep classes using the same algorithm/rules as normal classes. (3) x10rt17.h no longer includes the header files for NativeRep classes. As a consequence, the handwritten .h and .cc files backing a NativeRep class must follow the name mangling conventions as would have been used by the code generator if it had generated files for the class. This required renaming a number of files in src-cpp/x10/io and also the addition of empty .h files for the various NativeReped primitive classes (Int.h. etc). Modified Paths: -------------- trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/MessagePassingCodeGenerator.java trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/X10CPPTranslator.java trunk/x10.runtime.17/src-cpp/Makefile trunk/x10.runtime.17/src-cpp/x10rt17.h trunk/x10.runtime.17/src-x10/x10/io/Console.x10 trunk/x10.runtime.17/src-x10/x10/io/File.x10 trunk/x10.runtime.17/src-x10/x10/io/FileReader.x10 trunk/x10.runtime.17/src-x10/x10/io/FileWriter.x10 trunk/x10.runtime.17/src-x10/x10/io/InputStreamReader.x10 trunk/x10.runtime.17/src-x10/x10/io/OutputStreamWriter.x10 trunk/x10.runtime.17/src-x10/x10/tuningfork/ScalarType.x10 Added Paths: ----------- trunk/x10.runtime.17/src-cpp/x10/io/FileReader__FileInputStream.cc trunk/x10.runtime.17/src-cpp/x10/io/FileReader__FileInputStream.h trunk/x10.runtime.17/src-cpp/x10/io/FileWriter__FileOutputStream.cc trunk/x10.runtime.17/src-cpp/x10/io/FileWriter__FileOutputStream.h trunk/x10.runtime.17/src-cpp/x10/io/File__NativeFile.cc trunk/x10.runtime.17/src-cpp/x10/io/File__NativeFile.h trunk/x10.runtime.17/src-cpp/x10/io/InputStreamReader__InputStream.cc trunk/x10.runtime.17/src-cpp/x10/io/InputStreamReader__InputStream.h trunk/x10.runtime.17/src-cpp/x10/io/OutputStreamWriter__OutputStream.cc trunk/x10.runtime.17/src-cpp/x10/io/OutputStreamWriter__OutputStream.h trunk/x10.runtime.17/src-cpp/x10/lang/Boolean.h trunk/x10.runtime.17/src-cpp/x10/lang/Byte.h trunk/x10.runtime.17/src-cpp/x10/lang/Char.h trunk/x10.runtime.17/src-cpp/x10/lang/Double.h trunk/x10.runtime.17/src-cpp/x10/lang/Float.h trunk/x10.runtime.17/src-cpp/x10/lang/Int.h trunk/x10.runtime.17/src-cpp/x10/lang/Long.h trunk/x10.runtime.17/src-cpp/x10/lang/Short.h trunk/x10.runtime.17/src-cpp/x10/lang/UByte.h trunk/x10.runtime.17/src-cpp/x10/lang/UInt.h trunk/x10.runtime.17/src-cpp/x10/lang/ULong.h trunk/x10.runtime.17/src-cpp/x10/lang/UShort.h trunk/x10.runtime.17/src-cpp/x10/tuningfork/ trunk/x10.runtime.17/src-cpp/x10/tuningfork/ScalarType.cc trunk/x10.runtime.17/src-cpp/x10/tuningfork/ScalarType.h Removed Paths: ------------- trunk/x10.runtime.17/src-cpp/x10/io/FileInputStream.cc trunk/x10.runtime.17/src-cpp/x10/io/FileInputStream.h trunk/x10.runtime.17/src-cpp/x10/io/FileOutputStream.cc trunk/x10.runtime.17/src-cpp/x10/io/FileOutputStream.h trunk/x10.runtime.17/src-cpp/x10/io/NativeFile.cc trunk/x10.runtime.17/src-cpp/x10/io/NativeFile.h trunk/x10.runtime.17/src-cpp/x10/io/NativeInputStream.cc trunk/x10.runtime.17/src-cpp/x10/io/NativeInputStream.h trunk/x10.runtime.17/src-cpp/x10/io/NativeOutputStream.cc trunk/x10.runtime.17/src-cpp/x10/io/NativeOutputStream.h Modified: trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/MessagePassingCodeGenerator.java =================================================================== --- trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/MessagePassingCodeGenerator.java 2009-07-08 21:26:02 UTC (rev 10636) +++ trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/MessagePassingCodeGenerator.java 2009-07-08 21:26:52 UTC (rev 10637) @@ -693,8 +693,7 @@ if (n.superClass() != null) { ClassType ct = n.superClass().type().toClass(); X10ClassDef scd = (X10ClassDef) ct.def(); - String cpp = getCppRep(scd); - if (scd != def && cpp == null) { + if (scd != def) { String header = getHeader(ct); String guard = getHeaderGuard(header); h.write("#define "+guard+"_NODEPS"); h.newline(); @@ -718,8 +717,7 @@ for (TypeNode i : n.interfaces()) { ClassType ct = i.type().toClass(); X10ClassDef icd = (X10ClassDef) ct.def(); - String cpp = getCppRep(icd); - if (icd != def && cpp == null) { + if (icd != def) { String header = getHeader(ct); String guard = getHeaderGuard(header); h.write("#define "+guard+"_NODEPS"); h.newline(); @@ -794,9 +792,6 @@ X10ClassDef cd = (X10ClassDef) ct.def(); if (cd == def) continue; - String cpp = getCppRep(cd); - if (cpp != null) - continue; if (!allIncludes.contains(ct)) { declareClass(cd, h); allIncludes.add(ct); @@ -841,7 +836,7 @@ emitter.printHeader(n, h, tr, false); h.allowBreak(0, " "); - n.print(n.body(), sw, tr); + n.print(n.body(), sw, tr); ((X10CPPTranslator)tr).setContext(n.enterChildScope(n.body(), context)); // FIXME /* @@ -897,15 +892,13 @@ h.newline(0); } h.forceNewline(0); - + // [IP] Ok to include here, since the class is already defined h.write("#ifndef "+cguard+"_NODEPS"); h.newline(); h.write("#define "+cguard+"_NODEPS"); h.newline(); for (Type t : allIncludes) { ClassType ct = t.toClass(); - String cpp = getCppRep((X10ClassDef) ct.def()); - assert (cpp == null); String header = getHeader(ct); h.write("#include <" + header + ">"); h.newline(); @@ -913,7 +906,7 @@ z.write("#endif // __"+cguard+"_NODEPS"); h.newline(); z.forceNewline(0); - + context.templateFunctions = save_generic; sw.set(save_header, save_body); } @@ -1310,7 +1303,7 @@ // xts.isImplicitCastValid(container, (Type) xts.forName(QName.make("x10.lang.Indexable"))) && // xts.isImplicitCastValid(container, (Type) xts.forName(QName.make("x10.lang.Settable")))) // { -// +// // } // } catch (SemanticException e) { assert (false) : ("Huh? No Indexable or Settable?"); } // we sometimes need to use a more general return type as c++ does not support covariant smartptr return types @@ -1480,7 +1473,7 @@ // FIXME: HACK: skip synthetic serialization fields if (query.isSyntheticField(dec.name().id().toString())) return; - + X10CPPContext_c context = (X10CPPContext_c) tr.context(); if ((((X10ClassDef)((X10ClassType)dec.fieldDef().asInstance().container()).def()).typeParameters().size() != 0) && dec.flags().flags().isStatic()) @@ -3136,7 +3129,7 @@ X10TypeSystem xts = (X10TypeSystem) tr.typeSystem(); NodeFactory nf = tr.nodeFactory(); Unary.Operator op = n.operator(); - + if (op == Unary.POST_DEC || op == Unary.POST_INC || op == Unary.PRE_DEC || op == Unary.PRE_INC) { // TODO visit((Unary_c)n); return; @@ -3154,7 +3147,7 @@ // FIXME: move this to the Desugarer Name methodName = X10Unary_c.unaryMethodName(op); Expr receiver = left; - + if (methodName == null) throw new InternalCompilerError("No method to implement " + n, n.position()); @@ -3240,7 +3233,7 @@ Name methodName = inv ? X10Binary_c.invBinaryMethodName(op) : X10Binary_c.binaryMethodName(op); Expr receiver = inv ? right : left; Expr arg = inv ? left : right; - + if (methodName == null) throw new InternalCompilerError("No method to implement " + n, n.position()); Modified: trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/X10CPPTranslator.java =================================================================== --- trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/X10CPPTranslator.java 2009-07-08 21:26:02 UTC (rev 10636) +++ trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/X10CPPTranslator.java 2009-07-08 21:26:52 UTC (rev 10637) @@ -39,6 +39,7 @@ import polyglot.ext.x10.ast.ForLoop; import polyglot.ext.x10.ast.X10ClassDecl; +import polyglot.ext.x10.types.X10ClassDef; import polyglot.ext.x10cpp.Configuration; import polyglot.ext.x10cpp.X10CPPCompilerOptions; @@ -70,6 +71,7 @@ import x10c.util.ClassifiedStream; import x10c.util.StreamWrapper; import x10c.util.WriterStreams; +import static polyglot.ext.x10cpp.visit.ASTQuery.getCppRep; import static polyglot.ext.x10cpp.visit.SharedVarsMethods.*; public class X10CPPTranslator extends Translator { @@ -330,6 +332,10 @@ if (!(decl instanceof X10ClassDecl)) continue; X10ClassDecl cd = (X10ClassDecl) decl; + // Skip output of all files for a native rep class. + if (getCppRep((X10ClassDef)cd.classDef()) != null) { + continue; + } String className = cd.classDef().name().toString(); wstreams = new WriterStreams(className, pkg, tf, job); sw = new StreamWrapper(wstreams, outputWidth); @@ -381,7 +387,10 @@ } } - wstreams.commitStreams(); + if (wstreams != null) { + // wstreams will be null when the source file contains a NativeRep class + wstreams.commitStreams(); + } return true; } Modified: trunk/x10.runtime.17/src-cpp/Makefile =================================================================== --- trunk/x10.runtime.17/src-cpp/Makefile 2009-07-08 21:26:02 UTC (rev 10636) +++ trunk/x10.runtime.17/src-cpp/Makefile 2009-07-08 21:26:52 UTC (rev 10637) @@ -187,11 +187,11 @@ x10aux/short_utils.o \ x10aux/string_utils.o \ x10aux/system_utils.o \ - x10/io/FileInputStream.o \ - x10/io/FileOutputStream.o \ - x10/io/NativeFile.o \ - x10/io/NativeInputStream.o \ - x10/io/NativeOutputStream.o \ + x10/io/FileReader__FileInputStream.o \ + x10/io/FileWriter__FileOutputStream.o \ + x10/io/File__NativeFile.o \ + x10/io/InputStreamReader__InputStream.o \ + x10/io/OutputStreamWriter__OutputStream.o \ x10/lang/Box.o \ x10/lang/Fun.o \ x10/lang/Iterator.o \ @@ -207,6 +207,7 @@ x10/runtime/Deque.o \ x10/runtime/Lock.o \ x10/runtime/Thread.o \ + x10/tuningfork/ScalarType.o \ x10/util/GrowableRail.o \ x10/util/concurrent/atomic/AtomicBoolean.o \ x10/util/concurrent/atomic/AtomicInteger.o \ Deleted: trunk/x10.runtime.17/src-cpp/x10/io/FileInputStream.cc =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/io/FileInputStream.cc 2009-07-08 21:26:02 UTC (rev 10636) +++ trunk/x10.runtime.17/src-cpp/x10/io/FileInputStream.cc 2009-07-08 21:26:52 UTC (rev 10637) @@ -1,17 +0,0 @@ -#include <x10/io/FileInputStream.h> - -using namespace x10aux; -using namespace x10::lang; -using namespace x10::io; - -x10aux::ref<FileInputStream> FileInputStream::STANDARD_IN - = new (x10aux::alloc<FileInputStream>()) FileInputStream(stdin); - -x10aux::ref<FileInputStream> -FileInputStream::_make(x10aux::ref<x10::lang::String> name) { - return new (x10aux::alloc<FileInputStream>()) FileInputStream (FILEPtrStream::open_file(name, "r")); -} - -RTT_CC_DECLS1(FileInputStream, "x10.io.FileReader.FileInputStream", NativeInputStream) - -// vim:tabstop=4:shiftwidth=4:expandtab Deleted: trunk/x10.runtime.17/src-cpp/x10/io/FileInputStream.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/io/FileInputStream.h 2009-07-08 21:26:02 UTC (rev 10636) +++ trunk/x10.runtime.17/src-cpp/x10/io/FileInputStream.h 2009-07-08 21:26:52 UTC (rev 10637) @@ -1,52 +0,0 @@ -#ifndef X10_IO_FILEINPUTSTREAM_H -#define X10_IO_FILEINPUTSTREAM_H - -#include <x10/io/NativeInputStream.h> -#include <x10aux/io/FILEPtrInputStream.h> - -namespace x10 { - - namespace io { - - class FileInputStream : public x10aux::io::FILEPtrInputStream, - public NativeInputStream { - - public: - RTT_H_DECLS; - - FileInputStream(FILE *f) - : FILEPtrInputStream(f) { } - - static x10aux::ref<FileInputStream> _make(x10aux::ref<x10::lang::String> name); - - virtual char * gets(char *buf, int sz) { - return x10aux::io::FILEPtrInputStream::gets(buf,sz); - } - - virtual x10_int read() { - return x10aux::io::FILEPtrInputStream::read(); - } - - virtual x10_int read(x10aux::ref<x10::lang::Rail<x10_byte> > b) { - return x10::io::NativeInputStream::read(b); - } - - virtual x10_int read(x10aux::ref<x10::lang::Rail<x10_byte> > b, - x10_int off, - x10_int len) { - return x10aux::io::FILEPtrInputStream::read(b, off, len); - } - - virtual void skip(x10_int bytes) { - return x10aux::io::FILEPtrInputStream::skip(bytes); - } - - static x10aux::ref<FileInputStream> STANDARD_IN; - - - }; - } -} - -#endif -// vim:tabstop=4:shiftwidth=4:expandtab Deleted: trunk/x10.runtime.17/src-cpp/x10/io/FileOutputStream.cc =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/io/FileOutputStream.cc 2009-07-08 21:26:02 UTC (rev 10636) +++ trunk/x10.runtime.17/src-cpp/x10/io/FileOutputStream.cc 2009-07-08 21:26:52 UTC (rev 10637) @@ -1,20 +0,0 @@ -#include <x10/io/FileOutputStream.h> - -using namespace x10aux; -using namespace x10::lang; -using namespace x10::io; - -x10aux::ref<FileOutputStream> FileOutputStream::STANDARD_OUT - = new (x10aux::alloc<FileOutputStream>()) FileOutputStream(stdout); - -x10aux::ref<FileOutputStream> FileOutputStream::STANDARD_ERR - = new (x10aux::alloc<FileOutputStream>()) FileOutputStream(stderr); - -x10aux::ref<FileOutputStream> -FileOutputStream::_make(x10aux::ref<x10::lang::String> name) { - return new (x10aux::alloc<FileOutputStream>()) FileOutputStream (FILEPtrStream::open_file(name, "w")); -} - -RTT_CC_DECLS1(FileOutputStream, "x10.io.FileWriter.FileOutputStream", NativeOutputStream) - -// vim:tabstop=4:shiftwidth=4:expandtab Deleted: trunk/x10.runtime.17/src-cpp/x10/io/FileOutputStream.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/io/FileOutputStream.h 2009-07-08 21:26:02 UTC (rev 10636) +++ trunk/x10.runtime.17/src-cpp/x10/io/FileOutputStream.h 2009-07-08 21:26:52 UTC (rev 10637) @@ -1,60 +0,0 @@ -#ifndef X10_IO_FILEOUTPUTSTREAM_H -#define X10_IO_FILEOUTPUTSTREAM_H - -#include <x10/io/NativeOutputStream.h> -#include <x10aux/io/FILEPtrOutputStream.h> - -namespace x10 { - - namespace io { - - class FileOutputStream : public x10aux::io::FILEPtrOutputStream, - public x10::io::NativeOutputStream { - - public: - RTT_H_DECLS; - - FileOutputStream(FILE *f) - : FILEPtrOutputStream(f) { } - - static x10aux::ref<FileOutputStream> _make(x10aux::ref<x10::lang::String> name); - - virtual void write(const char *str) { - x10aux::io::FILEPtrOutputStream::write(str); - } - - virtual void write(x10_int i) { - x10aux::io::FILEPtrOutputStream::write(i); - } - - virtual void write(x10aux::ref<x10::lang::Rail<x10_byte> > b) - { x10::io::NativeOutputStream::write(b); } - virtual void write(x10aux::ref<x10::lang::ValRail<x10_byte> > b) - { x10::io::NativeOutputStream::write(b); } - virtual void write(x10aux::ref<x10::lang::Rail<x10_byte> > b, x10_int off, x10_int len) - { x10aux::io::FILEPtrOutputStream::write(b, off, len); } - virtual void write(x10aux::ref<x10::lang::ValRail<x10_byte> > b,x10_int off,x10_int len) - { x10aux::io::FILEPtrOutputStream::write(b, off, len); } - - virtual void flush() { - x10aux::io::FILEPtrOutputStream::flush(); - } - - /* [DC] Not sure these are needed now - x10aux::ref<FileOutputStream> _constructor(x10aux::ref<x10::lang::String> name) - { return this->FILEPtrOutputStream::_constructor(FILEPtrStream::open_file(name, "w")); } - - x10aux::ref<FileOutputStream> _constructor(FILE *file) - { return this->FILEPtrOutputStream::_constructor(file); } - */ - - static x10aux::ref<FileOutputStream> STANDARD_OUT; - - static x10aux::ref<FileOutputStream> STANDARD_ERR; - - }; - } -} - -#endif -// vim:tabstop=4:shiftwidth=4:expandtab Copied: trunk/x10.runtime.17/src-cpp/x10/io/FileReader__FileInputStream.cc (from rev 10629, trunk/x10.runtime.17/src-cpp/x10/io/FileInputStream.cc) =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/io/FileReader__FileInputStream.cc (rev 0) +++ trunk/x10.runtime.17/src-cpp/x10/io/FileReader__FileInputStream.cc 2009-07-08 21:26:52 UTC (rev 10637) @@ -0,0 +1,17 @@ +#include <x10/io/FileReader__FileInputStream.h> + +using namespace x10aux; +using namespace x10::lang; +using namespace x10::io; + +x10aux::ref<FileReader__FileInputStream> FileReader__FileInputStream::STANDARD_IN + = new (x10aux::alloc<FileReader__FileInputStream>()) FileReader__FileInputStream(stdin); + +x10aux::ref<FileReader__FileInputStream> +FileReader__FileInputStream::_make(x10aux::ref<x10::lang::String> name) { + return new (x10aux::alloc<FileReader__FileInputStream>()) FileReader__FileInputStream (FILEPtrStream::open_file(name, "r")); +} + +RTT_CC_DECLS1(FileReader__FileInputStream, "x10.io.FileReader.FileReader__FileInputStream", InputStreamReader__InputStream) + +// vim:tabstop=4:shiftwidth=4:expandtab Copied: trunk/x10.runtime.17/src-cpp/x10/io/FileReader__FileInputStream.h (from rev 10629, trunk/x10.runtime.17/src-cpp/x10/io/FileInputStream.h) =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/io/FileReader__FileInputStream.h (rev 0) +++ trunk/x10.runtime.17/src-cpp/x10/io/FileReader__FileInputStream.h 2009-07-08 21:26:52 UTC (rev 10637) @@ -0,0 +1,52 @@ +#ifndef X10_IO_FILEINPUTSTREAM_H +#define X10_IO_FILEINPUTSTREAM_H + +#include <x10/io/InputStreamReader__InputStream.h> +#include <x10aux/io/FILEPtrInputStream.h> + +namespace x10 { + + namespace io { + + class FileReader__FileInputStream : public x10aux::io::FILEPtrInputStream, + public InputStreamReader__InputStream { + + public: + RTT_H_DECLS; + + FileReader__FileInputStream(FILE *f) + : FILEPtrInputStream(f) { } + + static x10aux::ref<FileReader__FileInputStream> _make(x10aux::ref<x10::lang::String> name); + + virtual char * gets(char *buf, int sz) { + return x10aux::io::FILEPtrInputStream::gets(buf,sz); + } + + virtual x10_int read() { + return x10aux::io::FILEPtrInputStream::read(); + } + + virtual x10_int read(x10aux::ref<x10::lang::Rail<x10_byte> > b) { + return x10::io::InputStreamReader__InputStream::read(b); + } + + virtual x10_int read(x10aux::ref<x10::lang::Rail<x10_byte> > b, + x10_int off, + x10_int len) { + return x10aux::io::FILEPtrInputStream::read(b, off, len); + } + + virtual void skip(x10_int bytes) { + return x10aux::io::FILEPtrInputStream::skip(bytes); + } + + static x10aux::ref<FileReader__FileInputStream> STANDARD_IN; + + + }; + } +} + +#endif +// vim:tabstop=4:shiftwidth=4:expandtab Copied: trunk/x10.runtime.17/src-cpp/x10/io/FileWriter__FileOutputStream.cc (from rev 10629, trunk/x10.runtime.17/src-cpp/x10/io/FileOutputStream.cc) =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/io/FileWriter__FileOutputStream.cc (rev 0) +++ trunk/x10.runtime.17/src-cpp/x10/io/FileWriter__FileOutputStream.cc 2009-07-08 21:26:52 UTC (rev 10637) @@ -0,0 +1,20 @@ +#include <x10/io/FileWriter__FileOutputStream.h> + +using namespace x10aux; +using namespace x10::lang; +using namespace x10::io; + +x10aux::ref<FileWriter__FileOutputStream> FileWriter__FileOutputStream::STANDARD_OUT + = new (x10aux::alloc<FileWriter__FileOutputStream>()) FileWriter__FileOutputStream(stdout); + +x10aux::ref<FileWriter__FileOutputStream> FileWriter__FileOutputStream::STANDARD_ERR + = new (x10aux::alloc<FileWriter__FileOutputStream>()) FileWriter__FileOutputStream(stderr); + +x10aux::ref<FileWriter__FileOutputStream> +FileWriter__FileOutputStream::_make(x10aux::ref<x10::lang::String> name) { + return new (x10aux::alloc<FileWriter__FileOutputStream>()) FileWriter__FileOutputStream (FILEPtrStream::open_file(name, "w")); +} + +RTT_CC_DECLS1(FileWriter__FileOutputStream, "x10.io.FileWriter.FileOutputStream", OutputStreamWriter__OutputStream) + +// vim:tabstop=4:shiftwidth=4:expandtab Copied: trunk/x10.runtime.17/src-cpp/x10/io/FileWriter__FileOutputStream.h (from rev 10629, trunk/x10.runtime.17/src-cpp/x10/io/FileOutputStream.h) =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/io/FileWriter__FileOutputStream.h (rev 0) +++ trunk/x10.runtime.17/src-cpp/x10/io/FileWriter__FileOutputStream.h 2009-07-08 21:26:52 UTC (rev 10637) @@ -0,0 +1,60 @@ +#ifndef X10_IO_FILEOUTPUTSTREAM_H +#define X10_IO_FILEOUTPUTSTREAM_H + +#include <x10/io/OutputStreamWriter__OutputStream.h> +#include <x10aux/io/FILEPtrOutputStream.h> + +namespace x10 { + + namespace io { + + class FileWriter__FileOutputStream : public x10aux::io::FILEPtrOutputStream, + public x10::io::OutputStreamWriter__OutputStream { + + public: + RTT_H_DECLS; + + FileWriter__FileOutputStream(FILE *f) + : FILEPtrOutputStream(f) { } + + static x10aux::ref<FileWriter__FileOutputStream> _make(x10aux::ref<x10::lang::String> name); + + virtual void write(const char *str) { + x10aux::io::FILEPtrOutputStream::write(str); + } + + virtual void write(x10_int i) { + x10aux::io::FILEPtrOutputStream::write(i); + } + + virtual void write(x10aux::ref<x10::lang::Rail<x10_byte> > b) + { x10::io::OutputStreamWriter__OutputStream::write(b); } + virtual void write(x10aux::ref<x10::lang::ValRail<x10_byte> > b) + { x10::io::OutputStreamWriter__OutputStream::write(b); } + virtual void write(x10aux::ref<x10::lang::Rail<x10_byte> > b, x10_int off, x10_int len) + { x10aux::io::FILEPtrOutputStream::write(b, off, len); } + virtual void write(x10aux::ref<x10::lang::ValRail<x10_byte> > b,x10_int off,x10_int len) + { x10aux::io::FILEPtrOutputStream::write(b, off, len); } + + virtual void flush() { + x10aux::io::FILEPtrOutputStream::flush(); + } + + /* [DC] Not sure these are needed now + x10aux::ref<FileWriter__FileOutputStream> _constructor(x10aux::ref<x10::lang::String> name) + { return this->FILEPtrOutputStream::_constructor(FILEPtrStream::open_file(name, "w")); } + + x10aux::ref<FileWriter__FileOutputStream> _constructor(FILE *file) + { return this->FILEPtrOutputStream::_constructor(file); } + */ + + static x10aux::ref<FileWriter__FileOutputStream> STANDARD_OUT; + + static x10aux::ref<FileWriter__FileOutputStream> STANDARD_ERR; + + }; + } +} + +#endif +// vim:tabstop=4:shiftwidth=4:expandtab Copied: trunk/x10.runtime.17/src-cpp/x10/io/File__NativeFile.cc (from rev 10629, trunk/x10.runtime.17/src-cpp/x10/io/NativeFile.cc) =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/io/File__NativeFile.cc (rev 0) +++ trunk/x10.runtime.17/src-cpp/x10/io/File__NativeFile.cc 2009-07-08 21:26:52 UTC (rev 10637) @@ -0,0 +1,16 @@ +#include <x10aux/config.h> + +#include <x10/io/File__NativeFile.h> + +using namespace x10::lang; +using namespace x10::io; +using namespace x10aux; + +x10aux::ref<File__NativeFile> +File__NativeFile::_make(x10aux::ref<x10::lang::String> s) { + return (new (x10aux::alloc<File__NativeFile>()) File__NativeFile())->_constructor(s); +} + +RTT_CC_DECLS1(File__NativeFile, "x10.io.File.NativeFile", Ref) + +// vim:tabstop=4:shiftwidth=4:expandtab Copied: trunk/x10.runtime.17/src-cpp/x10/io/File__NativeFile.h (from rev 10629, trunk/x10.runtime.17/src-cpp/x10/io/NativeFile.h) =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/io/File__NativeFile.h (rev 0) +++ trunk/x10.runtime.17/src-cpp/x10/io/File__NativeFile.h 2009-07-08 21:26:52 UTC (rev 10637) @@ -0,0 +1,70 @@ +#ifndef X10_IO_NATIVEFILE_H +#define X10_IO_NATIVEFILE_H + +#include <x10aux/config.h> + +#include <stdio.h> + +#include <x10/lang/Ref.h> + +namespace x10 { + + namespace lang { + template<class T> class Rail; + } + + namespace io { + + class File__NativeFile : public x10::lang::Ref { + public: + RTT_H_DECLS; + + private: + + x10aux::ref<x10::lang::String> name; + + public: + + static x10aux::ref<File__NativeFile> _make(x10aux::ref<x10::lang::String> s); + x10aux::ref<File__NativeFile> _constructor(x10aux::ref<x10::lang::String> s) { + name = s; + return this; + } + + virtual x10aux::ref<x10::lang::String> getName() { return name; } + + virtual x10aux::ref<x10::lang::String> getParent() { abort(); return name; } + + virtual x10aux::ref<x10::lang::String> getPath() { abort(); return name; } + + virtual x10_boolean isAbsolute() { abort(); return (x10_boolean)false; } + + virtual x10aux::ref<x10::lang::String> getAbsolutePath() { abort(); return name; } + + virtual x10aux::ref<x10::lang::String> getCanonicalPath() { abort(); return name; } + + virtual x10_boolean canRead() { abort(); return (x10_boolean)false; } + + virtual x10_boolean canWrite() { abort(); return (x10_boolean)false; } + + virtual x10_boolean exists() { abort(); return (x10_boolean)false; } + + virtual x10_boolean isDirectory() { abort(); return (x10_boolean)false; } + + virtual x10_boolean isFile() { abort(); return (x10_boolean)false; } + + virtual x10_boolean isHidden() { abort(); return (x10_boolean)false; } + + virtual x10_long lastModified() { abort(); return (x10_long)0; } + + virtual x10_long length() { abort(); return (x10_long)0; } + + virtual x10_boolean setLastModified(x10_long t) { (void)t; abort(); return (x10_boolean)false; } + + }; + + } +} + +#endif +// vim:tabstop=4:shiftwidth=4:expandtab Added: trunk/x10.runtime.17/src-cpp/x10/io/InputStreamReader__InputStream.cc =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/io/InputStreamReader__InputStream.cc (rev 0) +++ trunk/x10.runtime.17/src-cpp/x10/io/InputStreamReader__InputStream.cc 2009-07-08 21:26:52 UTC (rev 10637) @@ -0,0 +1,38 @@ +#include <x10aux/config.h> + +#include <x10aux/alloc.h> + +#include <x10/io/InputStreamReader__InputStream.h> +#include <x10/lang/Rail.h> + +using namespace x10::lang; +using namespace x10::io; +using namespace x10aux; + +x10_int InputStreamReader__InputStream::read(ref<Rail<x10_byte> > b) { + return this->read(b, 0, b->x10__length); +} + +x10_int InputStreamReader__InputStream::read(ref<Rail<x10_byte> > b, + x10_int off, x10_int len) { + x10_int val; + x10_int i; + for (i = 0; i < len && (val = this->read()) != -1; i++) + b->operator[](off + i) = (x10_byte) (val & 0xFF); + return i; +} + +x10_boolean InputStreamReader__InputStream::_struct_equals(ref<Object> p0) { + if (p0.get() == this) return true; // short-circuit trivial equality + if (!this->Value::_struct_equals(p0)) + return false; +// ref<InputStreamReader__InputStream> that = (ref<InputStreamReader__InputStream>) p0; +// if (!struct_equals(this->FMGL(stream), that->FMGL(stream))) +// return false; + return true; +} + + +RTT_CC_DECLS1(InputStreamReader__InputStream, "x10.io.InputStreamReader.InputStream", Value) + +// vim:tabstop=4:shiftwidth=4:expandtab Property changes on: trunk/x10.runtime.17/src-cpp/x10/io/InputStreamReader__InputStream.cc ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Added: trunk/x10.runtime.17/src-cpp/x10/io/InputStreamReader__InputStream.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/io/InputStreamReader__InputStream.h (rev 0) +++ trunk/x10.runtime.17/src-cpp/x10/io/InputStreamReader__InputStream.h 2009-07-08 21:26:52 UTC (rev 10637) @@ -0,0 +1,54 @@ +#ifndef X10_IO_NATIVEINPUTSTREAM_H +#define X10_IO_NATIVEINPUTSTREAM_H + +#include <x10/lang/Value.h> + +namespace x10 { + + namespace lang { + template<class T> class Rail; + } + + namespace io { + + class InputStreamReader__InputStream : public x10::lang::Value { + public: + RTT_H_DECLS; + + protected: + + + virtual char* gets(char* s, int num) = 0; + + + public: + + virtual void close() { } + + virtual x10_int read() = 0; + + virtual x10_int read(x10aux::ref<x10::lang::Rail<x10_byte> > b); + + virtual x10_int read(x10aux::ref<x10::lang::Rail<x10_byte> > b, + x10_int off, + x10_int len); + + virtual x10_boolean _struct_equals(x10aux::ref<x10::lang::Object> p0); + + + virtual x10_int available() { return 0; } + + virtual void skip(x10_int) = 0; + + virtual void mark(x10_int) { }; + + virtual void reset() { } + + virtual x10_boolean markSupported() { return false; } + + }; + } +} + +#endif +// vim:tabstop=4:shiftwidth=4:expandtab Property changes on: trunk/x10.runtime.17/src-cpp/x10/io/InputStreamReader__InputStream.h ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Deleted: trunk/x10.runtime.17/src-cpp/x10/io/NativeFile.cc =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/io/NativeFile.cc 2009-07-08 21:26:02 UTC (rev 10636) +++ trunk/x10.runtime.17/src-cpp/x10/io/NativeFile.cc 2009-07-08 21:26:52 UTC (rev 10637) @@ -1,16 +0,0 @@ -#include <x10aux/config.h> - -#include <x10/io/NativeFile.h> - -using namespace x10::lang; -using namespace x10::io; -using namespace x10aux; - -x10aux::ref<NativeFile> -NativeFile::_make(x10aux::ref<x10::lang::String> s) { - return (new (x10aux::alloc<NativeFile>()) NativeFile())->_constructor(s); -} - -RTT_CC_DECLS1(NativeFile, "x10.io.File.NativeFile", Ref) - -// vim:tabstop=4:shiftwidth=4:expandtab Deleted: trunk/x10.runtime.17/src-cpp/x10/io/NativeFile.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/io/NativeFile.h 2009-07-08 21:26:02 UTC (rev 10636) +++ trunk/x10.runtime.17/src-cpp/x10/io/NativeFile.h 2009-07-08 21:26:52 UTC (rev 10637) @@ -1,70 +0,0 @@ -#ifndef X10_IO_NATIVEFILE_H -#define X10_IO_NATIVEFILE_H - -#include <x10aux/config.h> - -#include <stdio.h> - -#include <x10/lang/Ref.h> - -namespace x10 { - - namespace lang { - template<class T> class Rail; - } - - namespace io { - - class NativeFile : public x10::lang::Ref { - public: - RTT_H_DECLS; - - private: - - x10aux::ref<x10::lang::String> name; - - public: - - static x10aux::ref<NativeFile> _make(x10aux::ref<x10::lang::String> s); - x10aux::ref<NativeFile> _constructor(x10aux::ref<x10::lang::String> s) { - name = s; - return this; - } - - virtual x10aux::ref<x10::lang::String> getName() { return name; } - - virtual x10aux::ref<x10::lang::String> getParent() { abort(); return name; } - - virtual x10aux::ref<x10::lang::String> getPath() { abort(); return name; } - - virtual x10_boolean isAbsolute() { abort(); return (x10_boolean)false; } - - virtual x10aux::ref<x10::lang::String> getAbsolutePath() { abort(); return name; } - - virtual x10aux::ref<x10::lang::String> getCanonicalPath() { abort(); return name; } - - virtual x10_boolean canRead() { abort(); return (x10_boolean)false; } - - virtual x10_boolean canWrite() { abort(); return (x10_boolean)false; } - - virtual x10_boolean exists() { abort(); return (x10_boolean)false; } - - virtual x10_boolean isDirectory() { abort(); return (x10_boolean)false; } - - virtual x10_boolean isFile() { abort(); return (x10_boolean)false; } - - virtual x10_boolean isHidden() { abort(); return (x10_boolean)false; } - - virtual x10_long lastModified() { abort(); return (x10_long)0; } - - virtual x10_long length() { abort(); return (x10_long)0; } - - virtual x10_boolean setLastModified(x10_long t) { (void)t; abort(); return (x10_boolean)false; } - - }; - - } -} - -#endif -// vim:tabstop=4:shiftwidth=4:expandtab Deleted: trunk/x10.runtime.17/src-cpp/x10/io/NativeInputStream.cc =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/io/NativeInputStream.cc 2009-07-08 21:26:02 UTC (rev 10636) +++ trunk/x10.runtime.17/src-cpp/x10/io/NativeInputStream.cc 2009-07-08 21:26:52 UTC (rev 10637) @@ -1,38 +0,0 @@ -#include <x10aux/config.h> - -#include <x10aux/alloc.h> - -#include <x10/io/NativeInputStream.h> -#include <x10/lang/Rail.h> - -using namespace x10::lang; -using namespace x10::io; -using namespace x10aux; - -x10_int NativeInputStream::read(ref<Rail<x10_byte> > b) { - return this->read(b, 0, b->x10__length); -} - -x10_int NativeInputStream::read(ref<Rail<x10_byte> > b, - x10_int off, x10_int len) { - x10_int val; - x10_int i; - for (i = 0; i < len && (val = this->read()) != -1; i++) - b->operator[](off + i) = (x10_byte) (val & 0xFF); - return i; -} - -x10_boolean NativeInputStream::_struct_equals(ref<Object> p0) { - if (p0.get() == this) return true; // short-circuit trivial equality - if (!this->Value::_struct_equals(p0)) - return false; -// ref<NativeInputStream> that = (ref<NativeInputStream>) p0; -// if (!struct_equals(this->FMGL(stream), that->FMGL(stream))) -// return false; - return true; -} - - -RTT_CC_DECLS1(NativeInputStream, "x10.io.InputStreamReader.InputStream", Value) - -// vim:tabstop=4:shiftwidth=4:expandtab Deleted: trunk/x10.runtime.17/src-cpp/x10/io/NativeInputStream.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/io/NativeInputStream.h 2009-07-08 21:26:02 UTC (rev 10636) +++ trunk/x10.runtime.17/src-cpp/x10/io/NativeInputStream.h 2009-07-08 21:26:52 UTC (rev 10637) @@ -1,54 +0,0 @@ -#ifndef X10_IO_NATIVEINPUTSTREAM_H -#define X10_IO_NATIVEINPUTSTREAM_H - -#include <x10/lang/Value.h> - -namespace x10 { - - namespace lang { - template<class T> class Rail; - } - - namespace io { - - class NativeInputStream : public x10::lang::Value { - public: - RTT_H_DECLS; - - protected: - - - virtual char* gets(char* s, int num) = 0; - - - public: - - virtual void close() { } - - virtual x10_int read() = 0; - - virtual x10_int read(x10aux::ref<x10::lang::Rail<x10_byte> > b); - - virtual x10_int read(x10aux::ref<x10::lang::Rail<x10_byte> > b, - x10_int off, - x10_int len); - - virtual x10_boolean _struct_equals(x10aux::ref<x10::lang::Object> p0); - - - virtual x10_int available() { return 0; } - - virtual void skip(x10_int) = 0; - - virtual void mark(x10_int) { }; - - virtual void reset() { } - - virtual x10_boolean markSupported() { return false; } - - }; - } -} - -#endif -// vim:tabstop=4:shiftwidth=4:expandtab Deleted: trunk/x10.runtime.17/src-cpp/x10/io/NativeOutputStream.cc =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/io/NativeOutputStream.cc 2009-07-08 21:26:02 UTC (rev 10636) +++ trunk/x10.runtime.17/src-cpp/x10/io/NativeOutputStream.cc 2009-07-08 21:26:52 UTC (rev 10637) @@ -1,60 +0,0 @@ -#include <x10aux/config.h> - -#include <x10aux/alloc.h> - -#include <x10/io/NativeOutputStream.h> -#include <x10/lang/ValRail.h> -#include <x10/lang/Rail.h> - -using namespace x10::lang; -using namespace x10::io; -using namespace x10aux; - - -void NativeOutputStream::write(ref<Rail<x10_byte> > b) { - this->write(b, 0, b->x10__length); -} - -void NativeOutputStream::write(ref<Rail<x10_byte> > b, - x10_int off, x10_int len) { - for (x10_int i = 0; i < len; i++) - this->write((x10_int) b->operator[](off + i)); -} - -void NativeOutputStream::write(ref<ValRail<x10_byte> > b) { - this->write(b, 0, b->x10__length); -} - -void NativeOutputStream::write(ref<ValRail<x10_byte> > b, - x10_int off, x10_int len) { - for (x10_int i = 0; i < len; i++) - this->write((x10_int) b->operator[](off + i)); -} - -x10_boolean NativeOutputStream::_struct_equals(ref<Object> p0) { - if (p0.get() == this) return true; // short-circuit trivial equality - if (!this->Value::_struct_equals(p0)) - return false; -// ref<NativeOutputStream> that = (ref<NativeOutputStream>) p0; -// if (!struct_equals(this->FMGL(stream), that->FMGL(stream))) -// return false; - return true; -} - -/* -void NativeOutputStream::_printf(const char* format, ...) { - va_list parms; - va_start(parms, format); - _vprintf(format, parms); - va_end(parms); -} - -void NativeOutputStream::printf(const ref<String>& format) { - this->_printf("%s", ((const string&)(*format)).c_str()); - this->flush(); // FIXME [IP] temp -} -*/ - -RTT_CC_DECLS1(NativeOutputStream, "x10.io.OutputStreamWriter.OutputStream", Value) - -// vim:tabstop=4:shiftwidth=4:expandtab Deleted: trunk/x10.runtime.17/src-cpp/x10/io/NativeOutputStream.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/io/NativeOutputStream.h 2009-07-08 21:26:02 UTC (rev 10636) +++ trunk/x10.runtime.17/src-cpp/x10/io/NativeOutputStream.h 2009-07-08 21:26:52 UTC (rev 10637) @@ -1,36 +0,0 @@ -#ifndef X10_IO_OUTPUTSTREAM_H -#define X10_IO_OUTPUTSTREAM_H - -#include <x10/lang/Value.h> - -namespace x10 { - - namespace lang { - template<class T> class Rail; - template<class T> class ValRail; - } - - namespace io { - - class NativeOutputStream : public x10::lang::Value { - public: - RTT_H_DECLS; - - virtual void write(const char* str) = 0; - - public: - virtual void close() { } - virtual void flush() { } - virtual void write(x10_int b) = 0; - virtual void write(x10aux::ref<x10::lang::Rail<x10_byte> > b); - virtual void write(x10aux::ref<x10::lang::ValRail<x10_byte> > b); - virtual void write(x10aux::ref<x10::lang::Rail<x10_byte> > b, x10_int off, x10_int len); - virtual void write(x10aux::ref<x10::lang::ValRail<x10_byte> > b, x10_int off, x10_int len); - - virtual x10_boolean _struct_equals(x10aux::ref<x10::lang::Object> p0); - }; - } -} - -#endif -// vim:tabstop=4:shiftwidth=4:expandtab Copied: trunk/x10.runtime.17/src-cpp/x10/io/OutputStreamWriter__OutputStream.cc (from rev 10629, trunk/x10.runtime.17/src-cpp/x10/io/NativeOutputStream.cc) =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/io/OutputStreamWriter__OutputStream.cc (rev 0) +++ trunk/x10.runtime.17/src-cpp/x10/io/OutputStreamWriter__OutputStream.cc 2009-07-08 21:26:52 UTC (rev 10637) @@ -0,0 +1,60 @@ +#include <x10aux/config.h> + +#include <x10aux/alloc.h> + +#include <x10/io/OutputStreamWriter__OutputStream.h> +#include <x10/lang/ValRail.h> +#include <x10/lang/Rail.h> + +using namespace x10::lang; +using namespace x10::io; +using namespace x10aux; + + +void OutputStreamWriter__OutputStream::write(ref<Rail<x10_byte> > b) { + this->write(b, 0, b->x10__length); +} + +void OutputStreamWriter__OutputStream::write(ref<Rail<x10_byte> > b, + x10_int off, x10_int len) { + for (x10_int i = 0; i < len; i++) + this->write((x10_int) b->operator[](off + i)); +} + +void OutputStreamWriter__OutputStream::write(ref<ValRail<x10_byte> > b) { + this->write(b, 0, b->x10__length); +} + +void OutputStreamWriter__OutputStream::write(ref<ValRail<x10_byte> > b, + x10_int off, x10_int len) { + for (x10_int i = 0; i < len; i++) + this->write((x10_int) b->operator[](off + i)); +} + +x10_boolean OutputStreamWriter__OutputStream::_struct_equals(ref<Object> p0) { + if (p0.get() == this) return true; // short-circuit trivial equality + if (!this->Value::_struct_equals(p0)) + return false; +// ref<OutputStreamWriter__OutputStream> that = (ref<OutputStreamWriter__OutputStream>) p0; +// if (!struct_equals(this->FMGL(stream), that->FMGL(stream))) +// return false; + return true; +} + +/* +void OutputStreamWriter__OutputStream::_printf(const char* format, ...) { + va_list parms; + va_start(parms, format); + _vprintf(format, parms); + va_end(parms); +} + +void OutputStreamWriter__OutputStream::printf(const ref<String>& format) { + this->_printf("%s", ((const string&)(*format)).c_str()); + this->flush(); // FIXME [IP] temp +} +*/ + +RTT_CC_DECLS1(OutputStreamWriter__OutputStream, "x10.io.OutputStreamWriter.OutputStream", Value) + +// vim:tabstop=4:shiftwidth=4:expandtab Copied: trunk/x10.runtime.17/src-cpp/x10/io/OutputStreamWriter__OutputStream.h (from rev 10629, trunk/x10.runtime.17/src-cpp/x10/io/NativeOutputStream.h) =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/io/OutputStreamWriter__OutputStream.h (rev 0) +++ trunk/x10.runtime.17/src-cpp/x10/io/OutputStreamWriter__OutputStream.h 2009-07-08 21:26:52 UTC (rev 10637) @@ -0,0 +1,36 @@ +#ifndef X10_IO_OUTPUTSTREAM_H +#define X10_IO_OUTPUTSTREAM_H + +#include <x10/lang/Value.h> + +namespace x10 { + + namespace lang { + template<class T> class Rail; + template<class T> class ValRail; + } + + namespace io { + + class OutputStreamWriter__OutputStream : public x10::lang::Value { + public: + RTT_H_DECLS; + + virtual void write(const char* str) = 0; + + public: + virtual void close() { } + virtual void flush() { } + virtual void write(x10_int b) = 0; + virtual void write(x10aux::ref<x10::lang::Rail<x10_byte> > b); + virtual void write(x10aux::ref<x10::lang::ValRail<x10_byte> > b); + virtual void write(x10aux::ref<x10::lang::Rail<x10_byte> > b, x10_int off, x10_int len); + virtual void write(x10aux::ref<x10::lang::ValRail<x10_byte> > b, x10_int off, x10_int len); + + virtual x10_boolean _struct_equals(x10aux::ref<x10::lang::Object> p0); + }; + } +} + +#endif +// vim:tabstop=4:shiftwidth=4:expandtab Added: trunk/x10.runtime.17/src-cpp/x10/lang/Boolean.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/Boolean.h (rev 0) +++ trunk/x10.runtime.17/src-cpp/x10/lang/Boolean.h 2009-07-08 21:26:52 UTC (rev 10637) @@ -0,0 +1,4 @@ +/* + * Empty header file for NativeRep class that doesn't require a + * C++ implementation + */ Property changes on: trunk/x10.runtime.17/src-cpp/x10/lang/Boolean.h ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Added: trunk/x10.runtime.17/src-cpp/x10/lang/Byte.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/Byte.h (rev 0) +++ trunk/x10.runtime.17/src-cpp/x10/lang/Byte.h 2009-07-08 21:26:52 UTC (rev 10637) @@ -0,0 +1,4 @@ +/* + * Empty header file for NativeRep class that doesn't require a + * C++ implementation + */ Property changes on: trunk/x10.runtime.17/src-cpp/x10/lang/Byte.h ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Added: trunk/x10.runtime.17/src-cpp/x10/lang/Char.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/Char.h (rev 0) +++ trunk/x10.runtime.17/src-cpp/x10/lang/Char.h 2009-07-08 21:26:52 UTC (rev 10637) @@ -0,0 +1,4 @@ +/* + * Empty header file for NativeRep class that doesn't require a + * C++ implementation + */ Property changes on: trunk/x10.runtime.17/src-cpp/x10/lang/Char.h ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Added: trunk/x10.runtime.17/src-cpp/x10/lang/Double.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/Double.h (rev 0) +++ trunk/x10.runtime.17/src-cpp/x10/lang/Double.h 2009-07-08 21:26:52 UTC (rev 10637) @@ -0,0 +1,4 @@ +/* + * Empty header file for NativeRep class that doesn't require a + * C++ implementation + */ Property changes on: trunk/x10.runtime.17/src-cpp/x10/lang/Double.h ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Added: trunk/x10.runtime.17/src-cpp/x10/lang/Float.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/Float.h (rev 0) +++ trunk/x10.runtime.17/src-cpp/x10/lang/Float.h 2009-07-08 21:26:52 UTC (rev 10637) @@ -0,0 +1,4 @@ +/* + * Empty header file for NativeRep class that doesn't require a + * C++ implementation + */ Property changes on: trunk/x10.runtime.17/src-cpp/x10/lang/Float.h ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Added: trunk/x10.runtime.17/src-cpp/x10/lang/Int.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/Int.h (rev 0) +++ trunk/x10.runtime.17/src-cpp/x10/lang/Int.h 2009-07-08 21:26:52 UTC (rev 10637) @@ -0,0 +1,4 @@ +/* + * Empty header file for NativeRep class that doesn't require a + * C++ implementation + */ Property changes on: trunk/x10.runtime.17/src-cpp/x10/lang/Int.h ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Added: trunk/x10.runtime.17/src-cpp/x10/lang/Long.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/Long.h (rev 0) +++ trunk/x10.runtime.17/src-cpp/x10/lang/Long.h 2009-07-08 21:26:52 UTC (rev 10637) @@ -0,0 +1,4 @@ +/* + * Empty header file for NativeRep class that doesn't require a + * C++ implementation + */ Property changes on: trunk/x10.runtime.17/src-cpp/x10/lang/Long.h ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Added: trunk/x10.runtime.17/src-cpp/x10/lang/Short.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/Short.h (rev 0) +++ trunk/x10.runtime.17/src-cpp/x10/lang/Short.h 2009-07-08 21:26:52 UTC (rev 10637) @@ -0,0 +1,4 @@ +/* + * Empty header file for NativeRep class that doesn't require a + * C++ implementation + */ Property changes on: trunk/x10.runtime.17/src-cpp/x10/lang/Short.h ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Added: trunk/x10.runtime.17/src-cpp/x10/lang/UByte.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/UByte.h (rev 0) +++ trunk/x10.runtime.17/src-cpp/x10/lang/UByte.h 2009-07-08 21:26:52 UTC (rev 10637) @@ -0,0 +1,4 @@ +/* + * Empty header file for NativeRep class that doesn't require a + * C++ implementation + */ Property changes on: trunk/x10.runtime.17/src-cpp/x10/lang/UByte.h ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Added: trunk/x10.runtime.17/src-cpp/x10/lang/UInt.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/UInt.h (rev 0) +++ trunk/x10.runtime.17/src-cpp/x10/lang/UInt.h 2009-07-08 21:26:52 UTC (rev 10637) @@ -0,0 +1,4 @@ +/* + * Empty header file for NativeRep class that doesn't require a + * C++ implementation + */ Property changes on: trunk/x10.runtime.17/src-cpp/x10/lang/UInt.h ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Added: trunk/x10.runtime.17/src-cpp/x10/lang/ULong.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/ULong.h (rev 0) +++ trunk/x10.runtime.17/src-cpp/x10/lang/ULong.h 2009-07-08 21:26:52 UTC (rev 10637) @@ -0,0 +1,4 @@ +/* + * Empty header file for NativeRep class that doesn't require a + * C++ implementation + */ Property changes on: trunk/x10.runtime.17/src-cpp/x10/lang/ULong.h ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Added: trunk/x10.runtime.17/src-cpp/x10/lang/UShort.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/UShort.h (rev 0) +++ trunk/x10.runtime.17/src-cpp/x10/lang/UShort.h 2009-07-08 21:26:52 UTC (rev 10637) @@ -0,0 +1,4 @@ +/* + * Empty header file for NativeRep class that doesn't require a + * C++ implementation + */ Property changes on: trunk/x10.runtime.17/src-cpp/x10/lang/UShort.h ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Added: trunk/x10.runtime.17/src-cpp/x10/tuningfork/ScalarType.cc =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/tuningfork/ScalarType.cc (rev 0) +++ trunk/x10.runtime.17/src-cpp/x10/tuningfork/ScalarType.cc 2009-07-08 21:26:52 UTC (rev 10637) @@ -0,0 +1,24 @@ +#include <x10/tuningfork/ScalarType.h> + +#include <assert.h> + +using namespace x10::lang; +using namespace x10::tuningfork; + +// TODO: Must initialize these to real values +x10aux::ref<ScalarType> ScalarType::FMGL(INT); +x10aux::ref<ScalarType> ScalarType::FMGL(LONG); +x10aux::ref<ScalarType> ScalarType::FMGL(DOUBLE); +x10aux::ref<ScalarType> ScalarType::FMGL(STRING); + +x10aux::ref<String> ScalarType::getName() { + assert(false); // TODO + return NULL; +} + +x10aux::ref<String> ScalarType::getDescription() { + assert(false); // TODO + return NULL; +} + +RTT_CC_DECLS1(ScalarType, "x10.tuningfork.ScalarValue", Value) Property changes on: trunk/x10.runtime.17/src-cpp/x10/tuningfork/ScalarType.cc ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Added: trunk/x10.runtime.17/src-cpp/x10/tuningfork/ScalarType.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/tuningfork/ScalarType.h (rev 0) +++ trunk/x10.runtime.17/src-cpp/x10/tuningfork/ScalarType.h 2009-07-08 21:26:52 UTC (rev 10637) @@ -0,0 +1,41 @@ +#ifndef X10_TUNINGFORK_SCALARTYPE_H +#define X10_TUNINGFORK_SCALARTYPE_H + +#include <x10aux/config.h> +#include <x10aux/ref.h> + +#include <x10/lang/Value.h> + +namespace x10 { namespace lang { class String; } } + +namespace x10 { + namespace tuningfork { + + // TODO: This is just enough of a skeleton to allow code to compile. + // At some point, this needs to be fleshed out into a true wrapper + // around the TuningFork C/C++ trace generation library. + class ScalarType : public x10::lang::Value { + public: + RTT_H_DECLS; + + static x10aux::ref<ScalarType> FMGL(INT); + static x10aux::ref<ScalarType> FMGL(LONG); + static x10aux::ref<ScalarType> FMGL(DOUBLE); + static x10aux::ref<ScalarType> FMGL(STRING); + + virtual x10aux::ref<x10::lang::String> getName(); + + virtual x10aux::ref<x10::lang::String> getDescription(); + }; + } +} + + + + + + + + +#endif + Property changes on: trunk/x10.runtime.17/src-cpp/x10/tuningfork/ScalarType.h ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Modified: trunk/x10.runtime.17/src-cpp/x10rt17.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10rt17.h 2009-07-08 21:26:02 UTC (rev 10636) +++ trunk/x10.runtime.17/src-cpp/x10rt17.h 2009-07-08 21:26:52 UTC (rev 10637) @@ -43,56 +43,6 @@ #include <x10aux/cuda/bridge_buffer.h> #include <x10aux/cuda/ring_buffer.h> -//#include <x10/io/File.h> -#include <x10/io/FileInputStream.h> -#include <x10/io/FileOutputStream.h> -#include <x10/io/NativeFile.h> -#include <x10/io/NativeInputStream.h> -#include <x10/io/NativeOutputStream.h> - -#include <x10/lang/Box.h> -#include <x10/lang/Fun_0_0.h> -#include <x10/lang/Fun_0_1.h> -#include <x10/lang/Fun_0_2.h> -#include <x10/lang/Fun_0_3.h> -#include <x10/lang/Fun_0_4.h> -#include <x10/lang/Fun_0_5.h> -#include <x10/lang/Fun_0_6.h> -#include <x10/lang/Fun_0_7.h> -#include <x10/lang/Fun_0_8.h> -#include <x10/lang/Fun_0_9.h> -#include <x10/lang/Iterator.h> -#include <x10/lang/Iterable.h> -#include <x10/lang/Object.h> -#include <x10/lang/Rail.h> -#include <x10/lang/Ref.h> -#include <x10/lang/Settable.h> -#include <x10/lang/String.h> -#include <x10/lang/Throwable.h> -#include <x10/lang/ValRail.h> -#include <x10/lang/Value.h> -#include <x10/lang/VoidFun_0_0.h> -#include <x10/lang/VoidFun_0_1.h> -#include <x10/lang/VoidFun_0_2.h> -#include <x10/lang/VoidFun_0_3.h> -#include <x10/lang/VoidFun_0_4.h> -#include <x10/lang/VoidFun_0_5.h> -#include <x10/lang/VoidFun_0_6.h> -#include <x10/lang/VoidFun_0_7.h> -#include <x10/lang/VoidFun_0_8.h> -#include <x10/lang/VoidFun_0_9.h> - -#include <x10/runtime/Deque.h> -#include <x10/runtime/Lock.h> -#include <x10/runtime/Thread.h> - -#include <x10/util/GrowableRail.h> -#include <x10/util/concurrent/atomic/AtomicBoolean.h> -#include <x10/util/concurrent/atomic/AtomicInteger.h> -#include <x10/util/concurrent/atomic/AtomicLong.h> -#include <x10/util/concurrent/atomic/AtomicReference.h> - -// has to be last to ensure the native classes have been included #include <x10aux/bootstrap.h> #endif Modified: trunk/x10.runtime.17/src-x10/x10/io/Console.x10 =================================================================== --- trunk/x10.runtime.17/src-x10/x10/io/Console.x10 2009-07-08 21:26:02 UTC (rev 10636) +++ trunk/x10.runtime.17/src-x10/x10/io/Console.x10 2009-07-08 21:26:52 UTC (rev 10637) @@ -4,16 +4,16 @@ public value Console { @Native("java", "java.lang.System.out") - @Native("c++", "x10::io::FileOutputStream::STANDARD_OUT") - private native static def realOut(): OutputStreamWriter.OutputStream; + @Native("c++", "x10::io::FileWriter__FileOutputStream::STANDARD_OUT") + private native static def realOut(): FileWriter.FileOutputStream; @Native("java", "new java.io.FileOutputStream(java.io.FileDescriptor.err)") - @Native("c++", "x10::io::FileOutputStream::STANDARD_ERR") - private native static def realErr(): OutputStreamWriter.OutputStream; + @Native("c++", "x10::io::FileWriter__FileOutputStream::STANDARD_ERR") + private native static def realErr(): FileWriter.FileOutputStream; @Native("java", "java.lang.System.in") - @Native("c++", "x10::io::FileInputStream::STANDARD_IN") - private native static def realIn(): InputStreamReader.InputStream; + @Native("c++", "x10::io::FileReader__FileInputStream::STANDARD_IN") + private native static def realIn(): FileReader.FileInputStream; public const OUT: Printer = new Printer(new OutputStreamWriter(realOut())); public const ERR: Printer = new Printer(new OutputStreamWriter(realErr())); Modified: trunk/x10.runtime.17/src-x10/x10/io/File.x10 =================================================================== --- trunk/x10.runtime.17/src-x10/x10/io/File.x10 2009-07-08 21:26:02 UTC (rev 10636) +++ trunk/x10.runtime.17/src-x10/x10/io/File.x10 2009-07-08 21:26:52 UTC (rev 10637) @@ -21,7 +21,7 @@ /* model after java.nio.file.Path */ public class File { @NativeRep("java", "java.io.File", null, null) - @NativeRep("c++", "x10aux::ref<x10::io::NativeFile>", "x10::io::NativeFile", null) + @NativeRep("c++", "x10aux::ref<x10::io::File__NativeFile>", "x10::io::File__NativeFile", null) protected final static class NativeFile { native def this(String); Modified: trunk/x10.runtime.17/src-x10/x10/io/FileReader.x10 =================================================================== --- trunk/x10.runtime.17/src-x10/x10/io/FileReader.x10 2009-07-08 21:26:02 UTC (rev 10636) +++ trunk/x10.runtime.17/src-x10/x10/io/FileReader.x10 2009-07-08 21:26:52 UTC (rev 10637) @@ -7,7 +7,7 @@ val file: File; @NativeRep("java", "java.io.FileInputStream", null, null) - @NativeRep("c++", "x10aux::ref<x10::io::FileInputStream>", "x10::io::FileInputStream", null) + @NativeRep("c++", "x10aux::ref<x10::io::FileReader__FileInputStream>", "x10::io::FileReader__FileInputStream", null) protected final static value FileInputStream extends InputStream { public native def this(String); } Modified: trunk/x10.runtime.17/src-x10/x10/io/FileWriter.x10 =================================================================== --- trunk/x10.runtime.17/src-x10/x10/io/FileWriter.x10 2009-07-08 21:26:02 UTC (rev 10636) +++ trunk/x10.runtime.17/src-x10/x10/io/FileWriter.x10 2009-07-08 21:26:52 UTC (rev 10637) @@ -5,7 +5,7 @@ public value FileWriter extends OutputStreamWriter { ... [truncated message content] |
From: <dgr...@us...> - 2009-07-10 18:01:28
|
Revision: 10660 http://x10.svn.sourceforge.net/x10/?rev=10660&view=rev Author: dgrove-oss Date: 2009-07-10 18:01:20 +0000 (Fri, 10 Jul 2009) Log Message: ----------- WIP on reducing header file cyclic dependencies. Remove x10aux/bootstrap.h from x10rt17.h and instead have the compiler generate an including of bootstrap.h in the "implementation" portion of the generated code immediately after it includes the generated "header file." Modified Paths: -------------- trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/MessagePassingCodeGenerator.java trunk/x10.runtime.17/src-cpp/x10rt17.h Modified: trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/MessagePassingCodeGenerator.java =================================================================== --- trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/MessagePassingCodeGenerator.java 2009-07-10 17:58:46 UTC (rev 10659) +++ trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/MessagePassingCodeGenerator.java 2009-07-10 18:01:20 UTC (rev 10660) @@ -673,6 +673,8 @@ } w.write("#include <"+cheader+">"); w.newline(); + w.write("#include <x10aux/bootstrap.h>"); w.newline(); // needed in case the body includes a main method + w.forceNewline(0); w.forceNewline(0); Modified: trunk/x10.runtime.17/src-cpp/x10rt17.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10rt17.h 2009-07-10 17:58:46 UTC (rev 10659) +++ trunk/x10.runtime.17/src-cpp/x10rt17.h 2009-07-10 18:01:20 UTC (rev 10660) @@ -43,7 +43,5 @@ #include <x10aux/cuda/bridge_buffer.h> #include <x10aux/cuda/ring_buffer.h> -#include <x10aux/bootstrap.h> - #endif // vim:tabstop=4:shiftwidth=4:expandtab This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dgr...@us...> - 2009-07-13 13:10:09
|
Revision: 10680 http://x10.svn.sourceforge.net/x10/?rev=10680&view=rev Author: dgrove-oss Date: 2009-07-13 13:10:03 +0000 (Mon, 13 Jul 2009) Log Message: ----------- As a tactical change, instead of including x10aux/iterator_utils in x10rt17.h have the code generator emit an include directive for the file at the top of the implementation stream. This breaks the last header file circularity related to Iterator and allows Iterator to not be a NativeRep class. Modified Paths: -------------- trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/MessagePassingCodeGenerator.java trunk/x10.runtime.17/src-cpp/Makefile trunk/x10.runtime.17/src-cpp/x10rt17.h trunk/x10.runtime.17/src-x10/x10/lang/Iterator.x10 Removed Paths: ------------- trunk/x10.runtime.17/src-cpp/x10/lang/Iterator.cc trunk/x10.runtime.17/src-cpp/x10/lang/Iterator.h Modified: trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/MessagePassingCodeGenerator.java =================================================================== --- trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/MessagePassingCodeGenerator.java 2009-07-13 04:34:37 UTC (rev 10679) +++ trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/MessagePassingCodeGenerator.java 2009-07-13 13:10:03 UTC (rev 10680) @@ -673,6 +673,7 @@ } w.write("#include <"+cheader+">"); w.newline(); + w.write("#include <x10aux/iterator_utils.h>"); w.newline(); w.forceNewline(0); w.forceNewline(0); Modified: trunk/x10.runtime.17/src-cpp/Makefile =================================================================== --- trunk/x10.runtime.17/src-cpp/Makefile 2009-07-13 04:34:37 UTC (rev 10679) +++ trunk/x10.runtime.17/src-cpp/Makefile 2009-07-13 13:10:03 UTC (rev 10680) @@ -194,7 +194,6 @@ x10/io/OutputStreamWriter__OutputStream.o \ x10/lang/Box.o \ x10/lang/Fun.o \ - x10/lang/Iterator.o \ x10/lang/Object.o \ x10/lang/Rail.o \ x10/lang/Ref.o \ Deleted: trunk/x10.runtime.17/src-cpp/x10/lang/Iterator.cc =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/Iterator.cc 2009-07-13 04:34:37 UTC (rev 10679) +++ trunk/x10.runtime.17/src-cpp/x10/lang/Iterator.cc 2009-07-13 13:10:03 UTC (rev 10680) @@ -1,19 +0,0 @@ -#include <x10aux/config.h> -#include <x10aux/alloc.h> -#include <x10aux/RTT.h> - -#include <x10/lang/Object.h> - -using namespace x10aux; - -namespace x10 { - namespace lang { - const RuntimeType* - _initRTTHelper_Iterator(const RuntimeType **location, const RuntimeType *rtt) { - const char *name = alloc_printf("x10.lang.Iterator[%s]",rtt->name()); - const RuntimeType *parent = Object::getRTT(); - const RuntimeType *cand = new (alloc<RuntimeType >()) RuntimeType(name, 1, parent); - return RuntimeType::installRTT(location, cand); - } - } -} Deleted: trunk/x10.runtime.17/src-cpp/x10/lang/Iterator.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/Iterator.h 2009-07-13 04:34:37 UTC (rev 10679) +++ trunk/x10.runtime.17/src-cpp/x10/lang/Iterator.h 2009-07-13 13:10:03 UTC (rev 10680) @@ -1,42 +0,0 @@ -#ifndef X10_LANG_ITERATOR_H -#define X10_LANG_ITERATOR_H - - -#include <x10aux/config.h> -#include <x10aux/RTT.h> -#include <x10aux/alloc.h> - -#include <x10/lang/Object.h> - - - -namespace x10 { - - namespace lang { - - extern const x10aux::RuntimeType* _initRTTHelper_Iterator(const x10aux::RuntimeType **location, const x10aux::RuntimeType *rtt); - - template<class T> class Iterator : public virtual Object { - public: - static const x10aux::RuntimeType* rtt; - static const x10aux::RuntimeType* getRTT() { return NULL == rtt ? _initRTT() : rtt; } - static const x10aux::RuntimeType* _initRTT(); - virtual const x10aux::RuntimeType *_type() const { return getRTT(); } - - virtual x10_boolean hasNext() = 0; - - virtual T next() = 0; - - }; - - template<class T> const x10aux::RuntimeType* Iterator<T>::_initRTT() { - return x10::lang::_initRTTHelper_Iterator(&rtt, x10aux::getRTT<T>()); - } - - template<class T> const x10aux::RuntimeType *Iterator<T>::rtt = NULL; - } -} - - -#endif -// vim:tabstop=4:shiftwidth=4:expandtab Modified: trunk/x10.runtime.17/src-cpp/x10rt17.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10rt17.h 2009-07-13 04:34:37 UTC (rev 10679) +++ trunk/x10.runtime.17/src-cpp/x10rt17.h 2009-07-13 13:10:03 UTC (rev 10680) @@ -37,7 +37,6 @@ #include <x10aux/math_utils.h> #include <x10aux/system_utils.h> -#include <x10aux/iterator_utils.h> #include <x10aux/cuda/cuda_utils.h> #include <x10aux/cuda/bridge_buffer.h> Modified: trunk/x10.runtime.17/src-x10/x10/lang/Iterator.x10 =================================================================== --- trunk/x10.runtime.17/src-x10/x10/lang/Iterator.x10 2009-07-13 04:34:37 UTC (rev 10679) +++ trunk/x10.runtime.17/src-x10/x10/lang/Iterator.x10 2009-07-13 13:10:03 UTC (rev 10680) @@ -12,13 +12,10 @@ import x10.compiler.Native; @NativeRep("java", "x10.core.Iterator<#1>", null, null) -@NativeRep("c++", "x10aux::ref<x10::lang::Iterator<#1 > >", "x10::lang::Iterator<#1 >", null) public interface Iterator[+T] { @Native("java", "#0.hasNext()") - @Native("c++", "(#0)->hasNext()") public def hasNext(): boolean; @Native("java", "#0.next()") - @Native("c++", "(#0)->next()") public def next():T; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <spa...@us...> - 2009-07-13 20:52:27
|
Revision: 10695 http://x10.svn.sourceforge.net/x10/?rev=10695&view=rev Author: sparksparkspark Date: 2009-07-13 20:52:22 +0000 (Mon, 13 Jul 2009) Log Message: ----------- Remove names from asyncs. This naive implementation was serialising strings with every async, causing a 7x bloat in a simple example i just tried. If we want to name asyncs, we should do so in a way which does not cause extra communication. Since names are static, they are available at every place from the get-go. The easiest way to do this is to define toString() on closures. Closures in the c++ backend already have a toString() function which returns file:line information. Modified Paths: -------------- trunk/x10.compiler.p3/src/polyglot/ext/x10/visit/Desugarer.java trunk/x10.runtime.17/src-x10/x10/runtime/Activity.x10 trunk/x10.runtime.17/src-x10/x10/runtime/Future_c.x10 trunk/x10.runtime.17/src-x10/x10/runtime/Runtime.x10 Modified: trunk/x10.compiler.p3/src/polyglot/ext/x10/visit/Desugarer.java =================================================================== --- trunk/x10.compiler.p3/src/polyglot/ext/x10/visit/Desugarer.java 2009-07-13 20:48:45 UTC (rev 10694) +++ trunk/x10.compiler.p3/src/polyglot/ext/x10/visit/Desugarer.java 2009-07-13 20:52:22 UTC (rev 10695) @@ -234,16 +234,15 @@ return closure; } - private Stmt async(Position pos, Stmt body, List clocks, Expr place, String prefix) throws SemanticException { - if (clocks.size() == 0) return async(pos, body, place, prefix); + private Stmt async(Position pos, Stmt body, List clocks, Expr place) throws SemanticException { + if (clocks.size() == 0) return async(pos, body, place); Type clockRailType = xts.ValRail(xts.Clock()); Tuple clockRail = (Tuple) xnf.Tuple(pos, clocks).type(clockRailType); Block block = body instanceof Block ? (Block) body : xnf.Block(body.position(), body); Closure closure = closure(body.position(), xts.Void(), Collections.EMPTY_LIST, block); - StringLit pString = (StringLit) xnf.StringLit(pos, prefix + pos.nameAndLineString()).type(xts.String()); - List<Expr> args = Arrays.asList(new Expr[] { place, clockRail, closure, pString }); + List<Expr> args = Arrays.asList(new Expr[] { place, clockRail, closure }); List<Type> mArgs = Arrays.asList(new Type[] { - xts.Place(), clockRailType, closure.closureDef().asType(), xts.String() + xts.Place(), clockRailType, closure.closureDef().asType() }); // TODO: merge with the call() function MethodInstance implMI = xts.findMethod(xts.Runtime(), @@ -253,13 +252,12 @@ args).methodInstance(implMI).type(xts.Void())); } - private Stmt async(Position pos, Stmt body, Expr place, String prefix) throws SemanticException { + private Stmt async(Position pos, Stmt body, Expr place) throws SemanticException { Block block = body instanceof Block ? (Block) body : xnf.Block(body.position(), body); Closure closure = closure(body.position(), xts.Void(), Collections.EMPTY_LIST, block); - StringLit pString = (StringLit) xnf.StringLit(pos, prefix + pos.nameAndLineString()).type(xts.String()); - List<Expr> args = Arrays.asList(new Expr[] { place, closure, pString }); + List<Expr> args = Arrays.asList(new Expr[] { place, closure }); List<Type> mArgs = Arrays.asList(new Type[] { - xts.Place(), closure.closureDef().asType(), xts.String() + xts.Place(), closure.closureDef().asType() }); // TODO: merge with the call() function MethodInstance implMI = xts.findMethod(xts.Runtime(), @@ -269,16 +267,15 @@ args).methodInstance(implMI).type(xts.Void())); } - private Stmt async(Position pos, Stmt body, List clocks, String prefix) throws SemanticException { - if (clocks.size() == 0) return async(pos, body, prefix); + private Stmt async(Position pos, Stmt body, List clocks) throws SemanticException { + if (clocks.size() == 0) return async(pos, body); Type clockRailType = xts.ValRail(xts.Clock()); Tuple clockRail = (Tuple) xnf.Tuple(pos, clocks).type(clockRailType); Block block = body instanceof Block ? (Block) body : xnf.Block(body.position(), body); Closure closure = closure(body.position(), xts.Void(), Collections.EMPTY_LIST, block); - StringLit pString = (StringLit) xnf.StringLit(pos, prefix + pos.nameAndLineString()).type(xts.String()); - List<Expr> args = Arrays.asList(new Expr[] { clockRail, closure, pString }); + List<Expr> args = Arrays.asList(new Expr[] { clockRail, closure }); List<Type> mArgs = Arrays.asList(new Type[] { - clockRailType, closure.closureDef().asType(), xts.String() + clockRailType, closure.closureDef().asType() }); // TODO: merge with the call() function MethodInstance implMI = xts.findMethod(xts.Runtime(), @@ -288,13 +285,12 @@ args).methodInstance(implMI).type(xts.Void())); } - private Stmt async(Position pos, Stmt body, String prefix) throws SemanticException { + private Stmt async(Position pos, Stmt body) throws SemanticException { Block block = body instanceof Block ? (Block) body : xnf.Block(body.position(), body); Closure closure = closure(body.position(), xts.Void(), Collections.EMPTY_LIST, block); - StringLit pString = (StringLit) xnf.StringLit(pos, prefix + pos.nameAndLineString()).type(xts.String()); - List<Expr> args = Arrays.asList(new Expr[] { closure, pString }); + List<Expr> args = Arrays.asList(new Expr[] { closure }); List<Type> mArgs = Arrays.asList(new Type[] { - closure.closureDef().asType(), xts.String() + closure.closureDef().asType() }); // TODO: merge with the call() function MethodInstance implMI = xts.findMethod(xts.Runtime(), @@ -307,8 +303,8 @@ private Stmt visitAsync(Node old, Async a) throws SemanticException { Position pos = a.position(); if (old instanceof Async && ((Async) old).place() instanceof Here) - return async(pos, a.body(), a.clocks(), "async-"); - return async(pos, a.body(), a.clocks(), a.place(), "async-"); + return async(pos, a.body(), a.clocks()); + return async(pos, a.body(), a.clocks(), a.place()); } private Expr visitHere(Here h) throws SemanticException { @@ -388,7 +384,7 @@ Position pos = f.position(); // Have to desugar some newly-created nodes Expr here = visitHere(xnf.Here(f.body().position())); - Stmt body = async(f.body().position(), f.body(), f.clocks(), here, "foreach-"); + Stmt body = async(f.body().position(), f.body(), f.clocks(), here); X10Formal formal = (X10Formal) f.formal(); return xnf.ForLoop(pos, formal, f.domain(), body).locals(formal.explode(this)); } @@ -434,7 +430,7 @@ xnf.Local(pos, xnf.Id(pos, tmp)).localInstance(lDef.asInstance()).type(dType), xnf.Id(bpos, APPLY), index).methodInstance(mi).type(xts.Place()); - Stmt body = async(bpos, a.body(), a.clocks(), place, "ateach-"); + Stmt body = async(bpos, a.body(), a.clocks(), place); return xnf.Block(pos, local, xnf.ForLoop(pos, formal, Modified: trunk/x10.runtime.17/src-x10/x10/runtime/Activity.x10 =================================================================== --- trunk/x10.runtime.17/src-x10/x10/runtime/Activity.x10 2009-07-13 20:48:45 UTC (rev 10694) +++ trunk/x10.runtime.17/src-x10/x10/runtime/Activity.x10 2009-07-13 20:52:22 UTC (rev 10695) @@ -13,7 +13,7 @@ /** * @author tardieu */ -class Activity(finishState:FinishState, name:String, safe:Boolean) { +class Activity(finishState:FinishState, safe:Boolean) { // the finish state governing the execution of this activity /** @@ -36,16 +36,16 @@ /** * Create activity. */ - def this(body:()=>Void, finishState:FinishState, name:String, safe:Boolean) { - property(finishState, name, safe); + def this(body:()=>Void, finishState:FinishState, safe:Boolean) { + property(finishState, safe); this.body = body; } /** * Create clocked activity. */ - def this(body:()=>Void, finishState:FinishState, clocks:ValRail[Clock], phases:ValRail[Int], name:String) { - this(body, finishState, name, false); + def this(body:()=>Void, finishState:FinishState, clocks:ValRail[Clock], phases:ValRail[Int]) { + this(body, finishState, false); clockPhases = new ClockPhases(); clockPhases.register(clocks, phases); } @@ -95,7 +95,8 @@ if (null != clockPhases) clockPhases.drop(); } - public def toString():String = name; + // [DC] The correct thing to do here is do toString() on the closure + //public def toString():String = name; } // vim:shiftwidth=4:tabstop=4:expandtab Modified: trunk/x10.runtime.17/src-x10/x10/runtime/Future_c.x10 =================================================================== --- trunk/x10.runtime.17/src-x10/x10/runtime/Future_c.x10 2009-07-13 20:48:45 UTC (rev 10694) +++ trunk/x10.runtime.17/src-x10/x10/runtime/Future_c.x10 2009-07-13 20:52:22 UTC (rev 10695) @@ -14,7 +14,7 @@ * The representation of an X10 future expression. * @author tardieu */ -public value Future_c[T](name:String) extends Future[T] { +public value Future_c[T] extends Future[T] { /** * CountDownLatch for signaling and wait -- can be replaced by a boolean latch */ @@ -30,8 +30,7 @@ private val eval:()=>T; - public def this(eval:()=>T, name:String) { - property(name); + public def this(eval:()=>T) { this.eval = eval; result = new GrowableRail[T](); } @@ -65,5 +64,6 @@ } } - public def toString():String = name; + // [DC] The correct thing to do here is pull the name from the closure + //public def toString():String = name; } Modified: trunk/x10.runtime.17/src-x10/x10/runtime/Runtime.x10 =================================================================== --- trunk/x10.runtime.17/src-x10/x10/runtime/Runtime.x10 2009-07-13 20:48:45 UTC (rev 10694) +++ trunk/x10.runtime.17/src-x10/x10/runtime/Runtime.x10 2009-07-13 20:52:22 UTC (rev 10695) @@ -71,7 +71,7 @@ // temporary: printStackTrace call moved to Main template (native code) try { if (master.loc() == 0) { - pool.execute(new Activity(body, rootFinish, "root", true)); + pool.execute(new Activity(body, rootFinish, true)); while (pool.worker().loop(rootFinish, true)); if (!NativeRuntime.local(Place.MAX_PLACES - 1)) { val c = ()=>Runtime.quit(); @@ -104,41 +104,41 @@ /** * Run async */ - public static def runAsync(place:Place, clocks:ValRail[Clock], body:()=>Void, name:String):Void { + public static def runAsync(place:Place, clocks:ValRail[Clock], body:()=>Void):Void { val state = currentState(); val phases = Rail.makeVal[Int](clocks.length, (i:Nat)=>(clocks(i) as Clock_c).register_c()); state.notifySubActivitySpawn(); if (place.id == Thread.currentThread().loc()) { - pool.execute(new Activity(body, state, clocks, phases, name)); + pool.execute(new Activity(body, state, clocks, phases)); } else { - val c = ()=>pool.execute(new Activity(body, state, clocks, phases, name)); + val c = ()=>pool.execute(new Activity(body, state, clocks, phases)); NativeRuntime.runAt(place.id, c); } } - public static def runAsync(place:Place, body:()=>Void, name:String):Void { + public static def runAsync(place:Place, body:()=>Void):Void { val state = currentState(); state.notifySubActivitySpawn(); val ok = safe(); if (place.id == Thread.currentThread().loc()) { - pool.execute(new Activity(body, state, name, ok)); + pool.execute(new Activity(body, state, ok)); } else { - val c = ()=>pool.execute(new Activity(body, state, name, ok)); + val c = ()=>pool.execute(new Activity(body, state, ok)); NativeRuntime.runAt(place.id, c); } } - public static def runAsync(clocks:ValRail[Clock], body:()=>Void, name:String):Void { + public static def runAsync(clocks:ValRail[Clock], body:()=>Void):Void { val state = currentState(); val phases = Rail.makeVal[Int](clocks.length, (i:Nat)=>(clocks(i) as Clock_c).register_c()); state.notifySubActivitySpawn(); - pool.execute(new Activity(body, state, clocks, phases, name)); + pool.execute(new Activity(body, state, clocks, phases)); } - public static def runAsync(body:()=>Void, name:String):Void { + public static def runAsync(body:()=>Void):Void { val state = currentState(); state.notifySubActivitySpawn(); - pool.execute(new Activity(body, state, name, safe())); + pool.execute(new Activity(body, state, safe())); } /** @@ -164,8 +164,8 @@ /** * Eval future expression */ - public static def evalFuture[T](place:Place, eval:()=>T, name:String):Future[T] { - val futur = at (place) new Future_c[T](eval, name); + public static def evalFuture[T](place:Place, eval:()=>T):Future[T] { + val futur = at (place) new Future_c[T](eval); async (place) futur.run(); return futur; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <spa...@us...> - 2009-07-15 02:10:23
|
Revision: 10730 http://x10.svn.sourceforge.net/x10/?rev=10730&view=rev Author: sparksparkspark Date: 2009-07-15 02:10:16 +0000 (Wed, 15 Jul 2009) Log Message: ----------- Fix infinite recursion when initialising cyclic RTTs RTTs are now global variables, they start off blank (parentsc==-1), when first used, they initialise themselves, which consists of the following steps: 1) set parentsc == -2 2) initialise dependent RTTs (superclass, interfaces, type arguments) 3) set parentsc to the correct number (which is 0 for Object and >0 for everything else) The -2 value breaks the cycle since RTTs are only initialised when parentsc == -1 Modified Paths: -------------- trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/Emitter.java trunk/x10.runtime.17/src-cpp/x10/lang/Box.cc trunk/x10.runtime.17/src-cpp/x10/lang/Box.h trunk/x10.runtime.17/src-cpp/x10/lang/Fun.cc trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_0.h trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_1.h trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_2.h trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_3.h trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_4.h trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_5.h trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_6.h trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_7.h trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_8.h trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_9.h trunk/x10.runtime.17/src-cpp/x10/lang/Object.h trunk/x10.runtime.17/src-cpp/x10/lang/Rail.cc trunk/x10.runtime.17/src-cpp/x10/lang/Rail.h trunk/x10.runtime.17/src-cpp/x10/lang/ValRail.cc trunk/x10.runtime.17/src-cpp/x10/lang/ValRail.h trunk/x10.runtime.17/src-cpp/x10/lang/VoidFun_0_1.h trunk/x10.runtime.17/src-cpp/x10/lang/VoidFun_0_2.h trunk/x10.runtime.17/src-cpp/x10/lang/VoidFun_0_3.h trunk/x10.runtime.17/src-cpp/x10/lang/VoidFun_0_4.h trunk/x10.runtime.17/src-cpp/x10/lang/VoidFun_0_5.h trunk/x10.runtime.17/src-cpp/x10/lang/VoidFun_0_6.h trunk/x10.runtime.17/src-cpp/x10/lang/VoidFun_0_7.h trunk/x10.runtime.17/src-cpp/x10/lang/VoidFun_0_8.h trunk/x10.runtime.17/src-cpp/x10/lang/VoidFun_0_9.h trunk/x10.runtime.17/src-cpp/x10/util/GrowableRail.cc trunk/x10.runtime.17/src-cpp/x10/util/GrowableRail.h trunk/x10.runtime.17/src-cpp/x10/util/concurrent/atomic/AtomicReference.cc trunk/x10.runtime.17/src-cpp/x10/util/concurrent/atomic/AtomicReference.h trunk/x10.runtime.17/src-cpp/x10aux/RTT.cc trunk/x10.runtime.17/src-cpp/x10aux/RTT.h trunk/x10.runtime.17/src-cpp/x10aux/bootstrap.h Modified: trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/Emitter.java =================================================================== --- trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/Emitter.java 2009-07-15 01:44:30 UTC (rev 10729) +++ trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/Emitter.java 2009-07-15 02:10:16 UTC (rev 10730) @@ -564,9 +564,9 @@ if (ct.typeArguments().isEmpty()) { h.write("RTT_H_DECLS"); h.newline(); } else { - h.write("static const x10aux::RuntimeType* rtt;"); h.newline(); - h.write("static const x10aux::RuntimeType* getRTT() { return NULL == rtt ? _initRTT() : rtt; }"); h.newline(); - h.write("static const x10aux::RuntimeType* _initRTT();"); h.newline(); + h.write("static x10aux::RuntimeType rtt;"); h.newline(); + h.write("static const x10aux::RuntimeType* getRTT() { if (-1 == rtt.parentsc) _initRTT(); return &rtt; }"); h.newline(); + h.write("static void _initRTT();"); h.newline(); h.write("virtual const x10aux::RuntimeType *_type() const { return getRTT(); }"); h.newline(); h.forceNewline(); } } @@ -576,22 +576,22 @@ String x10name = ct.fullName().toString(); int num_parents = 1 + ct.interfaces().size(); if (ct.typeArguments().isEmpty()) { - h.write("const x10aux::RuntimeType* "+translateType(ct)+"::rtt = NULL;"); h.newline(); - h.write("const x10aux::RuntimeType* "+translateType(ct)+"::_initRTT() {"); h.newline(4); h.begin(0); - h.write("const x10aux::RuntimeType *cand = new (x10aux::alloc<x10aux::RuntimeType >()) x10aux::RuntimeType(\""+ct.fullName()+"\", "+num_parents); + h.write("x10aux::RuntimeType "+translateType(ct)+"::rtt;"); h.newline(); + h.write("void "+translateType(ct)+"::_initRTT() {"); h.newline(4); h.begin(0); + h.write("rtt.parentsc = -2;"); h.newline(); + h.write("rtt.init(\""+ct.fullName()+"\", "+num_parents); h.write(", x10aux::getRTT" + chevrons(ct.superClass()==null ? translateType(xts.Ref()) : translateType(ct.superClass())) + "()"); for (Type iface : ct.interfaces()) { h.write(", x10aux::getRTT"+chevrons(translateType(iface))+"()"); } - h.write(");"); h.newline(); - h.write("return x10aux::RuntimeType::installRTT(&rtt, cand);"); h.end(); h.newline(); + h.write(");"); h.end(); h.newline(); h.write("}"); h.newline(); } else { printTemplateSignature(ct.typeArguments(), h); - h.write("const x10aux::RuntimeType* "+translateType(ct)+"::rtt = NULL;"); h.newline(); + h.write("x10aux::RuntimeType "+translateType(ct)+"::rtt;"); h.newline(); printTemplateSignature(ct.typeArguments(), h); - h.write("const x10aux::RuntimeType* "+translateType(ct)+"::_initRTT() {"); h.newline(4); h.begin(0); + h.write("void "+translateType(ct)+"::_initRTT() {"); h.newline(4); h.begin(0); h.write("const char *name ="); h.newline(4); h.write("x10aux::alloc_printf("); h.begin(0); h.write("\""+x10name+"["); @@ -606,22 +606,12 @@ h.write("x10aux::getRTT"+chevrons(translateType(param))+"()->name()"); } h.write(");") ; h.end(); h.newline(); - if (num_parents <= 5) { - h.write("return x10aux::RuntimeType::allocAndInstallRTT(&rtt, name"); - h.write(", x10aux::getRTT" + chevrons(ct.superClass()==null ? translateType(xts.Ref()) : translateType(ct.superClass())) + "()"); - for (Type iface : ct.interfaces()) { - h.write(", x10aux::getRTT"+chevrons(translateType(iface))+"()"); - } - h.write(");"); h.end(); h.newline(); - } else { - h.write("const x10aux::RuntimeType *cand = new (x10aux::alloc<x10aux::RuntimeType >()) x10aux::RuntimeType(name, "+num_parents); - h.write(", x10aux::getRTT" + chevrons(ct.superClass()==null ? translateType(xts.Ref()) : translateType(ct.superClass())) + "()"); - for (Type iface : ct.interfaces()) { - h.write(", x10aux::getRTT"+chevrons(translateType(iface))+"()"); - } - h.write(");"); h.newline(); - h.write("return x10aux::RuntimeType::installRTT(&rtt, cand);"); h.end(); h.newline(); + h.write("rtt.init(name, "+num_parents); + h.write(", x10aux::getRTT" + chevrons(ct.superClass()==null ? translateType(xts.Ref()) : translateType(ct.superClass())) + "()"); + for (Type iface : ct.interfaces()) { + h.write(", x10aux::getRTT"+chevrons(translateType(iface))+"()"); } + h.write(");"); h.end(); h.newline(); h.write("}"); h.newline(); } h.newline(); Modified: trunk/x10.runtime.17/src-cpp/x10/lang/Box.cc =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/Box.cc 2009-07-15 01:44:30 UTC (rev 10729) +++ trunk/x10.runtime.17/src-cpp/x10/lang/Box.cc 2009-07-15 02:10:16 UTC (rev 10730) @@ -8,12 +8,11 @@ namespace x10 { namespace lang { - const RuntimeType* - _initRTTHelper_Box(const RuntimeType **location, const RuntimeType *rtt) { + void + _initRTTHelper_Box(RuntimeType *location, const RuntimeType *rtt) { const char *name = alloc_printf("x10.lang.Box[%s]",rtt->name()); const RuntimeType *parent = Ref::getRTT(); - const RuntimeType *cand = new (alloc<RuntimeType >()) RuntimeType(name, 1, parent); - return RuntimeType::installRTT(location, cand); + location->init(name, 1, parent); } } } Modified: trunk/x10.runtime.17/src-cpp/x10/lang/Box.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/Box.h 2009-07-15 01:44:30 UTC (rev 10729) +++ trunk/x10.runtime.17/src-cpp/x10/lang/Box.h 2009-07-15 02:10:16 UTC (rev 10730) @@ -16,14 +16,11 @@ class String; - extern const x10aux::RuntimeType* _initRTTHelper_Box(const x10aux::RuntimeType **location, const x10aux::RuntimeType *rtt); + void _initRTTHelper_Box(x10aux::RuntimeType *location, const x10aux::RuntimeType *rtt); template<class T> class Box : public Ref { public: - static const x10aux::RuntimeType* rtt; - static const x10aux::RuntimeType* getRTT() { return NULL == rtt ? _initRTT() : rtt; } - static const x10aux::RuntimeType* _initRTT(); - virtual const x10aux::RuntimeType *_type() const { return getRTT(); } + RTT_H_DECLS static x10aux::ref<Box<T> > _make(T contents_) { return (new (x10aux::alloc<Box<T> >())Box<T>())->_constructor(contents_); @@ -53,11 +50,12 @@ static void _static_init() { } }; - template<class T> const x10aux::RuntimeType* Box<T>::_initRTT() { - return x10::lang::_initRTTHelper_Box(&rtt, x10aux::getRTT<T>()); + template<class T> void Box<T>::_initRTT() { + rtt.parentsc = -2; + x10::lang::_initRTTHelper_Box(&rtt, x10aux::getRTT<T>()); } - template<class T> const x10aux::RuntimeType *Box<T>::rtt = NULL; + template<class T> x10aux::RuntimeType Box<T>::rtt; } } Modified: trunk/x10.runtime.17/src-cpp/x10/lang/Fun.cc =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/Fun.cc 2009-07-15 01:44:30 UTC (rev 10729) +++ trunk/x10.runtime.17/src-cpp/x10/lang/Fun.cc 2009-07-15 02:10:16 UTC (rev 10730) @@ -12,36 +12,33 @@ namespace x10 { namespace lang { - const RuntimeType* - _initRTTHelper_Fun_0_0(const RuntimeType **location, const RuntimeType *rtt0) { + void + _initRTTHelper_Fun_0_0(RuntimeType *location, const RuntimeType *rtt0) { const char *name = alloc_printf("x10.lang.Fun_0_0[%s]",rtt0->name()); const RuntimeType *parent = Object::getRTT(); - const RuntimeType *cand = new (alloc<RuntimeType >()) RuntimeType(name, 1, parent); - return RuntimeType::installRTT(location, cand); + location->init(name, 1, parent); } - const RuntimeType* - _initRTTHelper_Fun_0_1(const RuntimeType **location, const RuntimeType *rtt0, const RuntimeType *rtt1) { + void + _initRTTHelper_Fun_0_1(RuntimeType *location, const RuntimeType *rtt0, const RuntimeType *rtt1) { const char *name = alloc_printf("x10.lang.Fun_0_1[%s,%s]", rtt0->name(), rtt1->name()); const RuntimeType *parent = Object::getRTT(); - const RuntimeType *cand = new (alloc<RuntimeType >()) RuntimeType(name, 1, parent); - return RuntimeType::installRTT(location, cand); + location->init(name, 1, parent); } - const RuntimeType* - _initRTTHelper_Fun_0_2(const RuntimeType **location, + void + _initRTTHelper_Fun_0_2(RuntimeType *location, const RuntimeType *rtt0, const RuntimeType *rtt1, const RuntimeType *rtt2) { const char *name = alloc_printf("x10.lang.Fun_0_2[%s,%s,%s]", rtt0->name(), rtt1->name(), rtt2->name()); const RuntimeType *parent = Object::getRTT(); - const RuntimeType *cand = new (alloc<RuntimeType >()) RuntimeType(name, 1, parent); - return RuntimeType::installRTT(location, cand); + location->init(name, 1, parent); } - const RuntimeType* - _initRTTHelper_Fun_0_3(const RuntimeType **location, + void + _initRTTHelper_Fun_0_3(RuntimeType *location, const RuntimeType *rtt0, const RuntimeType *rtt1, const RuntimeType *rtt2, @@ -49,12 +46,11 @@ const char *name = alloc_printf("x10.lang.Fun_0_3[%s,%s,%s,%s]", rtt0->name(), rtt1->name(), rtt2->name(), rtt3->name()); const RuntimeType *parent = Object::getRTT(); - const RuntimeType *cand = new (alloc<RuntimeType >()) RuntimeType(name, 1, parent); - return RuntimeType::installRTT(location, cand); + location->init(name, 1, parent); } - const RuntimeType* - _initRTTHelper_Fun_0_4(const RuntimeType **location, + void + _initRTTHelper_Fun_0_4(RuntimeType *location, const RuntimeType *rtt0, const RuntimeType *rtt1, const RuntimeType *rtt2, @@ -63,12 +59,11 @@ const char *name = alloc_printf("x10.lang.Fun_0_4[%s,%s,%s,%s,%s]", rtt0->name(), rtt1->name(), rtt2->name(), rtt3->name(), rtt4->name()); const RuntimeType *parent = Object::getRTT(); - const RuntimeType *cand = new (alloc<RuntimeType >()) RuntimeType(name, 1, parent); - return RuntimeType::installRTT(location, cand); + location->init(name, 1, parent); } - const RuntimeType* - _initRTTHelper_Fun_0_5(const RuntimeType **location, + void + _initRTTHelper_Fun_0_5(RuntimeType *location, const RuntimeType *rtt0, const RuntimeType *rtt1, const RuntimeType *rtt2, @@ -79,12 +74,11 @@ rtt0->name(), rtt1->name(), rtt2->name(), rtt3->name(), rtt4->name(), rtt5->name()); const RuntimeType *parent = Object::getRTT(); - const RuntimeType *cand = new (alloc<RuntimeType >()) RuntimeType(name, 1, parent); - return RuntimeType::installRTT(location, cand); + location->init(name, 1, parent); } - const RuntimeType* - _initRTTHelper_Fun_0_6(const RuntimeType **location, + void + _initRTTHelper_Fun_0_6(RuntimeType *location, const RuntimeType *rtt0, const RuntimeType *rtt1, const RuntimeType *rtt2, @@ -96,12 +90,11 @@ rtt0->name(), rtt1->name(), rtt2->name(), rtt3->name(), rtt4->name(), rtt5->name(), rtt6->name()); const RuntimeType *parent = Object::getRTT(); - const RuntimeType *cand = new (alloc<RuntimeType >()) RuntimeType(name, 1, parent); - return RuntimeType::installRTT(location, cand); + location->init(name, 1, parent); } - const RuntimeType* - _initRTTHelper_Fun_0_7(const RuntimeType **location, + void + _initRTTHelper_Fun_0_7(RuntimeType *location, const RuntimeType *rtt0, const RuntimeType *rtt1, const RuntimeType *rtt2, @@ -114,12 +107,11 @@ rtt0->name(), rtt1->name(), rtt2->name(), rtt3->name(), rtt4->name(), rtt5->name(), rtt6->name(), rtt7->name()); const RuntimeType *parent = Object::getRTT(); - const RuntimeType *cand = new (alloc<RuntimeType >()) RuntimeType(name, 1, parent); - return RuntimeType::installRTT(location, cand); + location->init(name, 1, parent); } - const RuntimeType* - _initRTTHelper_Fun_0_8(const RuntimeType **location, + void + _initRTTHelper_Fun_0_8(RuntimeType *location, const RuntimeType *rtt0, const RuntimeType *rtt1, const RuntimeType *rtt2, @@ -133,12 +125,11 @@ rtt0->name(), rtt1->name(), rtt2->name(), rtt3->name(), rtt4->name(), rtt5->name(), rtt6->name(), rtt7->name(), rtt8->name()); const RuntimeType *parent = Object::getRTT(); - const RuntimeType *cand = new (alloc<RuntimeType >()) RuntimeType(name, 1, parent); - return RuntimeType::installRTT(location, cand); + location->init(name, 1, parent); } - const RuntimeType* - _initRTTHelper_Fun_0_9(const RuntimeType **location, + void + _initRTTHelper_Fun_0_9(RuntimeType *location, const RuntimeType *rtt0, const RuntimeType *rtt1, const RuntimeType *rtt2, @@ -153,43 +144,39 @@ rtt0->name(), rtt1->name(), rtt2->name(), rtt3->name(), rtt4->name(), rtt5->name(), rtt6->name(), rtt7->name(), rtt8->name(), rtt9->name()); const RuntimeType *parent = Object::getRTT(); - const RuntimeType *cand = new (alloc<RuntimeType >()) RuntimeType(name, 1, parent); - return RuntimeType::installRTT(location, cand); + location->init(name, 1, parent); } - const RuntimeType* - _initRTTHelper_VoidFun_0_1(const RuntimeType **location, const RuntimeType *rtt1) { + void + _initRTTHelper_VoidFun_0_1(RuntimeType *location, const RuntimeType *rtt1) { const char *name = alloc_printf("x10.lang.VoidFun_0_1[%s]", rtt1->name()); const RuntimeType *parent = Object::getRTT(); - const RuntimeType *cand = new (alloc<RuntimeType >()) RuntimeType(name, 1, parent); - return RuntimeType::installRTT(location, cand); + location->init(name, 1, parent); } - const RuntimeType* - _initRTTHelper_VoidFun_0_2(const RuntimeType **location, + void + _initRTTHelper_VoidFun_0_2(RuntimeType *location, const RuntimeType *rtt1, const RuntimeType *rtt2) { const char *name = alloc_printf("x10.lang.VoidFun_0_2[%s,%s]", rtt1->name(), rtt2->name()); const RuntimeType *parent = Object::getRTT(); - const RuntimeType *cand = new (alloc<RuntimeType >()) RuntimeType(name, 1, parent); - return RuntimeType::installRTT(location, cand); + location->init(name, 1, parent); } - const RuntimeType* - _initRTTHelper_VoidFun_0_3(const RuntimeType **location, + void + _initRTTHelper_VoidFun_0_3(RuntimeType *location, const RuntimeType *rtt1, const RuntimeType *rtt2, const RuntimeType *rtt3) { const char *name = alloc_printf("x10.lang.VoidFun_0_3[%s,%s,%s]", rtt1->name(), rtt2->name(), rtt3->name()); const RuntimeType *parent = Object::getRTT(); - const RuntimeType *cand = new (alloc<RuntimeType >()) RuntimeType(name, 1, parent); - return RuntimeType::installRTT(location, cand); + location->init(name, 1, parent); } - const RuntimeType* - _initRTTHelper_VoidFun_0_4(const RuntimeType **location, + void + _initRTTHelper_VoidFun_0_4(RuntimeType *location, const RuntimeType *rtt1, const RuntimeType *rtt2, const RuntimeType *rtt3, @@ -197,12 +184,11 @@ const char *name = alloc_printf("x10.lang.VoidFun_0_4[%s,%s,%s,%s]", rtt1->name(), rtt2->name(), rtt3->name(), rtt4->name()); const RuntimeType *parent = Object::getRTT(); - const RuntimeType *cand = new (alloc<RuntimeType >()) RuntimeType(name, 1, parent); - return RuntimeType::installRTT(location, cand); + location->init(name, 1, parent); } - const RuntimeType* - _initRTTHelper_VoidFun_0_5(const RuntimeType **location, + void + _initRTTHelper_VoidFun_0_5(RuntimeType *location, const RuntimeType *rtt1, const RuntimeType *rtt2, const RuntimeType *rtt3, @@ -212,12 +198,11 @@ rtt1->name(), rtt2->name(), rtt3->name(), rtt4->name(), rtt5->name()); const RuntimeType *parent = Object::getRTT(); - const RuntimeType *cand = new (alloc<RuntimeType >()) RuntimeType(name, 1, parent); - return RuntimeType::installRTT(location, cand); + location->init(name, 1, parent); } - const RuntimeType* - _initRTTHelper_VoidFun_0_6(const RuntimeType **location, + void + _initRTTHelper_VoidFun_0_6(RuntimeType *location, const RuntimeType *rtt1, const RuntimeType *rtt2, const RuntimeType *rtt3, @@ -228,12 +213,11 @@ rtt1->name(), rtt2->name(), rtt3->name(), rtt4->name(), rtt5->name(), rtt6->name()); const RuntimeType *parent = Object::getRTT(); - const RuntimeType *cand = new (alloc<RuntimeType >()) RuntimeType(name, 1, parent); - return RuntimeType::installRTT(location, cand); + location->init(name, 1, parent); } - const RuntimeType* - _initRTTHelper_VoidFun_0_7(const RuntimeType **location, + void + _initRTTHelper_VoidFun_0_7(RuntimeType *location, const RuntimeType *rtt1, const RuntimeType *rtt2, const RuntimeType *rtt3, @@ -245,12 +229,11 @@ rtt1->name(), rtt2->name(), rtt3->name(), rtt4->name(), rtt5->name(), rtt6->name(), rtt7->name()); const RuntimeType *parent = Object::getRTT(); - const RuntimeType *cand = new (alloc<RuntimeType >()) RuntimeType(name, 1, parent); - return RuntimeType::installRTT(location, cand); + location->init(name, 1, parent); } - const RuntimeType* - _initRTTHelper_VoidFun_0_8(const RuntimeType **location, + void + _initRTTHelper_VoidFun_0_8(RuntimeType *location, const RuntimeType *rtt1, const RuntimeType *rtt2, const RuntimeType *rtt3, @@ -264,12 +247,11 @@ rtt4->name(), rtt5->name(), rtt6->name(), rtt7->name(), rtt8->name()); const RuntimeType *parent = Object::getRTT(); - const RuntimeType *cand = new (alloc<RuntimeType >()) RuntimeType(name, 1, parent); - return RuntimeType::installRTT(location, cand); + location->init(name, 1, parent); } - const RuntimeType* - _initRTTHelper_VoidFun_0_9(const RuntimeType **location, + void + _initRTTHelper_VoidFun_0_9(RuntimeType *location, const RuntimeType *rtt1, const RuntimeType *rtt2, const RuntimeType *rtt3, @@ -284,8 +266,7 @@ rtt4->name(), rtt5->name(), rtt6->name(), rtt7->name(), rtt8->name(), rtt9->name()); const RuntimeType *parent = Object::getRTT(); - const RuntimeType *cand = new (alloc<RuntimeType >()) RuntimeType(name, 1, parent); - return RuntimeType::installRTT(location, cand); + location->init(name, 1, parent); } } } Modified: trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_0.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_0.h 2009-07-15 01:44:30 UTC (rev 10729) +++ trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_0.h 2009-07-15 02:10:16 UTC (rev 10730) @@ -8,24 +8,22 @@ namespace x10 { namespace lang { - extern const x10aux::RuntimeType* _initRTTHelper_Fun_0_0(const x10aux::RuntimeType **location, const x10aux::RuntimeType *rtt0); + void _initRTTHelper_Fun_0_0(x10aux::RuntimeType *location, const x10aux::RuntimeType *rtt0); template<class R> class Fun_0_0 : public virtual Object { public: - static const x10aux::RuntimeType* rtt; - static const x10aux::RuntimeType* getRTT() { return NULL == rtt ? _initRTT() : rtt; } - static const x10aux::RuntimeType* _initRTT(); - virtual const x10aux::RuntimeType *_type() const { return getRTT(); } + RTT_H_DECLS virtual ~Fun_0_0() { } virtual R apply() = 0; }; - template<class R> const x10aux::RuntimeType* Fun_0_0<R>::_initRTT() { - return x10::lang::_initRTTHelper_Fun_0_0(&rtt, x10aux::getRTT<R>()); + template<class R> void Fun_0_0<R>::_initRTT() { + rtt.parentsc = -2; + x10::lang::_initRTTHelper_Fun_0_0(&rtt, x10aux::getRTT<R>()); } - template<class R> const x10aux::RuntimeType* Fun_0_0<R>::rtt = NULL; + template<class R> x10aux::RuntimeType Fun_0_0<R>::rtt; } } #endif Modified: trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_1.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_1.h 2009-07-15 01:44:30 UTC (rev 10729) +++ trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_1.h 2009-07-15 02:10:16 UTC (rev 10730) @@ -8,26 +8,24 @@ namespace x10 { namespace lang { - extern const x10aux::RuntimeType* _initRTTHelper_Fun_0_1(const x10aux::RuntimeType **location, - const x10aux::RuntimeType *rtt0, - const x10aux::RuntimeType *rtt1); + void _initRTTHelper_Fun_0_1(x10aux::RuntimeType *location, + const x10aux::RuntimeType *rtt0, + const x10aux::RuntimeType *rtt1); template<class P1, class R> class Fun_0_1 : public virtual Object { public: - static const x10aux::RuntimeType* rtt; - static const x10aux::RuntimeType* getRTT() { return NULL == rtt ? _initRTT() : rtt; } - static const x10aux::RuntimeType* _initRTT(); - virtual const x10aux::RuntimeType *_type() const { return getRTT(); } + RTT_H_DECLS virtual ~Fun_0_1() { } virtual R apply(P1 p1) = 0; }; - template<class P1, class R> const x10aux::RuntimeType* Fun_0_1<P1,R>::_initRTT() { - return x10::lang::_initRTTHelper_Fun_0_1(&rtt, x10aux::getRTT<P1>(), x10aux::getRTT<R>()); + template<class P1, class R> void Fun_0_1<P1,R>::_initRTT() { + rtt.parentsc = -2; + x10::lang::_initRTTHelper_Fun_0_1(&rtt, x10aux::getRTT<P1>(), x10aux::getRTT<R>()); } - template<class P1, class R> const x10aux::RuntimeType* Fun_0_1<P1,R>::rtt = NULL; + template<class P1, class R> x10aux::RuntimeType Fun_0_1<P1,R>::rtt; } } #endif Modified: trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_2.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_2.h 2009-07-15 01:44:30 UTC (rev 10729) +++ trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_2.h 2009-07-15 02:10:16 UTC (rev 10730) @@ -8,28 +8,26 @@ namespace x10 { namespace lang { - extern const x10aux::RuntimeType* _initRTTHelper_Fun_0_2(const x10aux::RuntimeType **location, - const x10aux::RuntimeType *rtt0, - const x10aux::RuntimeType *rtt1, - const x10aux::RuntimeType *rtt2); + void _initRTTHelper_Fun_0_2(x10aux::RuntimeType *location, + const x10aux::RuntimeType *rtt0, + const x10aux::RuntimeType *rtt1, + const x10aux::RuntimeType *rtt2); template<class P1, class P2, class R> class Fun_0_2 : public virtual Object { public: - static const x10aux::RuntimeType* rtt; - static const x10aux::RuntimeType* getRTT() { return NULL == rtt ? _initRTT() : rtt; } - static const x10aux::RuntimeType* _initRTT(); - virtual const x10aux::RuntimeType *_type() const { return getRTT(); } + RTT_H_DECLS virtual ~Fun_0_2() { }; virtual R apply(P1 p1, P2 p2) = 0; }; - template<class P1, class P2, class R> const x10aux::RuntimeType* Fun_0_2<P1,P2,R>::_initRTT() { - return x10::lang::_initRTTHelper_Fun_0_2(&rtt, x10aux::getRTT<P1>(), x10aux::getRTT<P2>(), - x10aux::getRTT<R>()); + template<class P1, class P2, class R> void Fun_0_2<P1,P2,R>::_initRTT() { + rtt.parentsc = -2; + x10::lang::_initRTTHelper_Fun_0_2(&rtt, x10aux::getRTT<P1>(), x10aux::getRTT<P2>(), + x10aux::getRTT<R>()); } - template<class P1, class P2, class R> const x10aux::RuntimeType* Fun_0_2<P1,P2,R>::rtt = NULL; + template<class P1, class P2, class R> x10aux::RuntimeType Fun_0_2<P1,P2,R>::rtt; } } #endif Modified: trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_3.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_3.h 2009-07-15 01:44:30 UTC (rev 10729) +++ trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_3.h 2009-07-15 02:10:16 UTC (rev 10730) @@ -7,29 +7,28 @@ namespace x10 { namespace lang { - extern const x10aux::RuntimeType* _initRTTHelper_Fun_0_3(const x10aux::RuntimeType **location, - const x10aux::RuntimeType *rtt0, - const x10aux::RuntimeType *rtt1, - const x10aux::RuntimeType *rtt2, - const x10aux::RuntimeType *rtt3); + void _initRTTHelper_Fun_0_3(x10aux::RuntimeType *location, + const x10aux::RuntimeType *rtt0, + const x10aux::RuntimeType *rtt1, + const x10aux::RuntimeType *rtt2, + const x10aux::RuntimeType *rtt3); + template<class P1, class P2, class P3, class R> class Fun_0_3 : public virtual Object { public: - static const x10aux::RuntimeType* rtt; - static const x10aux::RuntimeType* getRTT() { return NULL == rtt ? _initRTT() : rtt; } - static const x10aux::RuntimeType* _initRTT(); - virtual const x10aux::RuntimeType *_type() const { return getRTT(); } + RTT_H_DECLS virtual ~Fun_0_3() { }; virtual R apply(P1 p1, P2 p2, P3 p3) = 0; }; - template<class P1, class P2, class P3, class R> const x10aux::RuntimeType* Fun_0_3<P1,P2,P3,R>::_initRTT() { - return x10::lang::_initRTTHelper_Fun_0_3(&rtt, x10aux::getRTT<P1>(), x10aux::getRTT<P2>(), - x10aux::getRTT<P3>(), x10aux::getRTT<R>()); + template<class P1, class P2, class P3, class R> void Fun_0_3<P1,P2,P3,R>::_initRTT() { + rtt.parentsc = -2; + x10::lang::_initRTTHelper_Fun_0_3(&rtt, x10aux::getRTT<P1>(), x10aux::getRTT<P2>(), + x10aux::getRTT<P3>(), x10aux::getRTT<R>()); } - template<class P1, class P2, class P3, class R> const x10aux::RuntimeType* Fun_0_3<P1,P2,P3,R>::rtt = NULL; + template<class P1, class P2, class P3, class R> x10aux::RuntimeType Fun_0_3<P1,P2,P3,R>::rtt; } } #endif Modified: trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_4.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_4.h 2009-07-15 01:44:30 UTC (rev 10729) +++ trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_4.h 2009-07-15 02:10:16 UTC (rev 10730) @@ -8,33 +8,31 @@ namespace x10 { namespace lang { - extern const x10aux::RuntimeType* _initRTTHelper_Fun_0_4(const x10aux::RuntimeType **location, - const x10aux::RuntimeType *rtt0, - const x10aux::RuntimeType *rtt1, - const x10aux::RuntimeType *rtt2, - const x10aux::RuntimeType *rtt3, - const x10aux::RuntimeType *rtt4); + void _initRTTHelper_Fun_0_4(x10aux::RuntimeType *location, + const x10aux::RuntimeType *rtt0, + const x10aux::RuntimeType *rtt1, + const x10aux::RuntimeType *rtt2, + const x10aux::RuntimeType *rtt3, + const x10aux::RuntimeType *rtt4); template<class P1, class P2, class P3, class P4, class R> class Fun_0_4 : public virtual Object { public: - static const x10aux::RuntimeType* rtt; - static const x10aux::RuntimeType* getRTT() { return NULL == rtt ? _initRTT() : rtt; } - static const x10aux::RuntimeType* _initRTT(); - virtual const x10aux::RuntimeType *_type() const { return getRTT(); } + RTT_H_DECLS virtual ~Fun_0_4() { }; virtual R apply(P1 p1, P2 p2, P3 p3, P4 p4) = 0; }; template<class P1, class P2, class P3, class P4, class R> - const x10aux::RuntimeType* Fun_0_4<P1,P2,P3,P4,R>::_initRTT() { - return x10::lang::_initRTTHelper_Fun_0_4(&rtt, x10aux::getRTT<P1>(), x10aux::getRTT<P2>(), - x10aux::getRTT<P3>(), x10aux::getRTT<P4>(), - x10aux::getRTT<R>()); + void Fun_0_4<P1,P2,P3,P4,R>::_initRTT() { + rtt.parentsc = -2; + x10::lang::_initRTTHelper_Fun_0_4(&rtt, x10aux::getRTT<P1>(), x10aux::getRTT<P2>(), + x10aux::getRTT<P3>(), x10aux::getRTT<P4>(), + x10aux::getRTT<R>()); } template<class P1, class P2, class P3, class P4, class R> - const x10aux::RuntimeType* Fun_0_4<P1,P2,P3,P4,R>::rtt = NULL; + x10aux::RuntimeType Fun_0_4<P1,P2,P3,P4,R>::rtt; } } #endif Modified: trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_5.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_5.h 2009-07-15 01:44:30 UTC (rev 10729) +++ trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_5.h 2009-07-15 02:10:16 UTC (rev 10730) @@ -8,34 +8,32 @@ namespace x10 { namespace lang { - extern const x10aux::RuntimeType* _initRTTHelper_Fun_0_5(const x10aux::RuntimeType **location, - const x10aux::RuntimeType *rtt0, - const x10aux::RuntimeType *rtt1, - const x10aux::RuntimeType *rtt2, - const x10aux::RuntimeType *rtt3, - const x10aux::RuntimeType *rtt4, - const x10aux::RuntimeType *rtt5); + void _initRTTHelper_Fun_0_5(x10aux::RuntimeType *location, + const x10aux::RuntimeType *rtt0, + const x10aux::RuntimeType *rtt1, + const x10aux::RuntimeType *rtt2, + const x10aux::RuntimeType *rtt3, + const x10aux::RuntimeType *rtt4, + const x10aux::RuntimeType *rtt5); template<class P1, class P2, class P3, class P4, class P5, class R> class Fun_0_5 : public virtual Object { public: - static const x10aux::RuntimeType* rtt; - static const x10aux::RuntimeType* getRTT() { return NULL == rtt ? _initRTT() : rtt; } - static const x10aux::RuntimeType* _initRTT(); - virtual const x10aux::RuntimeType *_type() const { return getRTT(); } + RTT_H_DECLS virtual ~Fun_0_5() { }; virtual R apply(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5) = 0; }; template<class P1, class P2, class P3, class P4, class P5, class R> - const x10aux::RuntimeType* Fun_0_5<P1,P2,P3,P4,P5,R>::_initRTT() { - return x10::lang::_initRTTHelper_Fun_0_5(&rtt, x10aux::getRTT<P1>(), x10aux::getRTT<P2>(), - x10aux::getRTT<P3>(), x10aux::getRTT<P4>(), - x10aux::getRTT<P5>(), x10aux::getRTT<R>()); + void Fun_0_5<P1,P2,P3,P4,P5,R>::_initRTT() { + rtt.parentsc = -2; + x10::lang::_initRTTHelper_Fun_0_5(&rtt, x10aux::getRTT<P1>(), x10aux::getRTT<P2>(), + x10aux::getRTT<P3>(), x10aux::getRTT<P4>(), + x10aux::getRTT<P5>(), x10aux::getRTT<R>()); } template<class P1, class P2, class P3, class P4, class P5, class R> - const x10aux::RuntimeType* Fun_0_5<P1,P2,P3,P4,P5,R>::rtt = NULL; + x10aux::RuntimeType Fun_0_5<P1,P2,P3,P4,P5,R>::rtt; } } #endif Modified: trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_6.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_6.h 2009-07-15 01:44:30 UTC (rev 10729) +++ trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_6.h 2009-07-15 02:10:16 UTC (rev 10730) @@ -8,36 +8,34 @@ namespace x10 { namespace lang { - extern const x10aux::RuntimeType* _initRTTHelper_Fun_0_6(const x10aux::RuntimeType **location, - const x10aux::RuntimeType *rtt0, - const x10aux::RuntimeType *rtt1, - const x10aux::RuntimeType *rtt2, - const x10aux::RuntimeType *rtt3, - const x10aux::RuntimeType *rtt4, - const x10aux::RuntimeType *rtt5, - const x10aux::RuntimeType *rtt6); + void _initRTTHelper_Fun_0_6(x10aux::RuntimeType *location, + const x10aux::RuntimeType *rtt0, + const x10aux::RuntimeType *rtt1, + const x10aux::RuntimeType *rtt2, + const x10aux::RuntimeType *rtt3, + const x10aux::RuntimeType *rtt4, + const x10aux::RuntimeType *rtt5, + const x10aux::RuntimeType *rtt6); template<class P1, class P2, class P3, class P4, class P5, class P6, class R> class Fun_0_6 : public virtual Object { public: - static const x10aux::RuntimeType* rtt; - static const x10aux::RuntimeType* getRTT() { return NULL == rtt ? _initRTT() : rtt; } - static const x10aux::RuntimeType* _initRTT(); - virtual const x10aux::RuntimeType *_type() const { return getRTT(); } + RTT_H_DECLS virtual ~Fun_0_6() { }; virtual R apply(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6) = 0; }; template<class P1, class P2, class P3, class P4, class P5, class P6, class R> - const x10aux::RuntimeType* Fun_0_6<P1,P2,P3,P4,P5,P6,R>::_initRTT() { - return x10::lang::_initRTTHelper_Fun_0_6(&rtt, x10aux::getRTT<P1>(), x10aux::getRTT<P2>(), - x10aux::getRTT<P3>(), x10aux::getRTT<P4>(), - x10aux::getRTT<P5>(), x10aux::getRTT<P6>(), - x10aux::getRTT<R>()); + void Fun_0_6<P1,P2,P3,P4,P5,P6,R>::_initRTT() { + rtt.parentsc = -2; + x10::lang::_initRTTHelper_Fun_0_6(&rtt, x10aux::getRTT<P1>(), x10aux::getRTT<P2>(), + x10aux::getRTT<P3>(), x10aux::getRTT<P4>(), + x10aux::getRTT<P5>(), x10aux::getRTT<P6>(), + x10aux::getRTT<R>()); } template<class P1, class P2, class P3, class P4, class P5, class P6, class R> - const x10aux::RuntimeType* Fun_0_6<P1,P2,P3,P4,P5,P6,R>::rtt = NULL; + x10aux::RuntimeType Fun_0_6<P1,P2,P3,P4,P5,P6,R>::rtt; } } #endif Modified: trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_7.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_7.h 2009-07-15 01:44:30 UTC (rev 10729) +++ trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_7.h 2009-07-15 02:10:16 UTC (rev 10730) @@ -7,37 +7,35 @@ namespace x10 { namespace lang { - extern const x10aux::RuntimeType* _initRTTHelper_Fun_0_7(const x10aux::RuntimeType **location, - const x10aux::RuntimeType *rtt0, - const x10aux::RuntimeType *rtt1, - const x10aux::RuntimeType *rtt2, - const x10aux::RuntimeType *rtt3, - const x10aux::RuntimeType *rtt4, - const x10aux::RuntimeType *rtt5, - const x10aux::RuntimeType *rtt6, - const x10aux::RuntimeType *rtt7); + void _initRTTHelper_Fun_0_7(x10aux::RuntimeType *location, + const x10aux::RuntimeType *rtt0, + const x10aux::RuntimeType *rtt1, + const x10aux::RuntimeType *rtt2, + const x10aux::RuntimeType *rtt3, + const x10aux::RuntimeType *rtt4, + const x10aux::RuntimeType *rtt5, + const x10aux::RuntimeType *rtt6, + const x10aux::RuntimeType *rtt7); template<class P1, class P2, class P3, class P4, class P5, class P6, class P7, class R> class Fun_0_7 : public virtual Object { public: - static const x10aux::RuntimeType* rtt; - static const x10aux::RuntimeType* getRTT() { return NULL == rtt ? _initRTT() : rtt; } - static const x10aux::RuntimeType* _initRTT(); - virtual const x10aux::RuntimeType *_type() const { return getRTT(); } + RTT_H_DECLS virtual ~Fun_0_7() { }; virtual R apply(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7) = 0; }; template<class P1, class P2, class P3, class P4, class P5, class P6, class P7, class R> - const x10aux::RuntimeType* Fun_0_7<P1,P2,P3,P4,P5,P6,P7,R>::_initRTT() { - return x10::lang::_initRTTHelper_Fun_0_7(&rtt, x10aux::getRTT<P1>(), x10aux::getRTT<P2>(), - x10aux::getRTT<P3>(), x10aux::getRTT<P4>(), - x10aux::getRTT<P5>(), x10aux::getRTT<P6>(), - x10aux::getRTT<P7>(), x10aux::getRTT<R>()); + void Fun_0_7<P1,P2,P3,P4,P5,P6,P7,R>::_initRTT() { + rtt.parentsc = -2; + x10::lang::_initRTTHelper_Fun_0_7(&rtt, x10aux::getRTT<P1>(), x10aux::getRTT<P2>(), + x10aux::getRTT<P3>(), x10aux::getRTT<P4>(), + x10aux::getRTT<P5>(), x10aux::getRTT<P6>(), + x10aux::getRTT<P7>(), x10aux::getRTT<R>()); } template<class P1, class P2, class P3, class P4, class P5, class P6, class P7, class R> - const x10aux::RuntimeType* Fun_0_7<P1,P2,P3,P4,P5,P6,P7,R>::rtt = NULL; + x10aux::RuntimeType Fun_0_7<P1,P2,P3,P4,P5,P6,P7,R>::rtt; } } #endif Modified: trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_8.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_8.h 2009-07-15 01:44:30 UTC (rev 10729) +++ trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_8.h 2009-07-15 02:10:16 UTC (rev 10730) @@ -7,39 +7,37 @@ namespace x10 { namespace lang { - extern const x10aux::RuntimeType* _initRTTHelper_Fun_0_8(const x10aux::RuntimeType **location, - const x10aux::RuntimeType *rtt0, - const x10aux::RuntimeType *rtt1, - const x10aux::RuntimeType *rtt2, - const x10aux::RuntimeType *rtt3, - const x10aux::RuntimeType *rtt4, - const x10aux::RuntimeType *rtt5, - const x10aux::RuntimeType *rtt6, - const x10aux::RuntimeType *rtt7, - const x10aux::RuntimeType *rtt8); + void _initRTTHelper_Fun_0_8(x10aux::RuntimeType *location, + const x10aux::RuntimeType *rtt0, + const x10aux::RuntimeType *rtt1, + const x10aux::RuntimeType *rtt2, + const x10aux::RuntimeType *rtt3, + const x10aux::RuntimeType *rtt4, + const x10aux::RuntimeType *rtt5, + const x10aux::RuntimeType *rtt6, + const x10aux::RuntimeType *rtt7, + const x10aux::RuntimeType *rtt8); template<class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class R> class Fun_0_8 : public virtual Object { public: - static const x10aux::RuntimeType* rtt; - static const x10aux::RuntimeType* getRTT() { return NULL == rtt ? _initRTT() : rtt; } - static const x10aux::RuntimeType* _initRTT(); - virtual const x10aux::RuntimeType *_type() const { return getRTT(); } + RTT_H_DECLS virtual ~Fun_0_8() { }; virtual R apply(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8) = 0; }; template<class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class R> - const x10aux::RuntimeType* Fun_0_8<P1,P2,P3,P4,P5,P6,P7,P8,R>::_initRTT() { - return x10::lang::_initRTTHelper_Fun_0_8(&rtt, x10aux::getRTT<P1>(), x10aux::getRTT<P2>(), - x10aux::getRTT<P3>(), x10aux::getRTT<P4>(), - x10aux::getRTT<P5>(), x10aux::getRTT<P6>(), - x10aux::getRTT<P7>(), x10aux::getRTT<P8>(), - x10aux::getRTT<R>()); + void Fun_0_8<P1,P2,P3,P4,P5,P6,P7,P8,R>::_initRTT() { + rtt.parentsc = -2; + x10::lang::_initRTTHelper_Fun_0_8(&rtt, x10aux::getRTT<P1>(), x10aux::getRTT<P2>(), + x10aux::getRTT<P3>(), x10aux::getRTT<P4>(), + x10aux::getRTT<P5>(), x10aux::getRTT<P6>(), + x10aux::getRTT<P7>(), x10aux::getRTT<P8>(), + x10aux::getRTT<R>()); } template<class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class R> - const x10aux::RuntimeType* Fun_0_8<P1,P2,P3,P4,P5,P6,P7,P8,R>::rtt = NULL; + x10aux::RuntimeType Fun_0_8<P1,P2,P3,P4,P5,P6,P7,P8,R>::rtt; } } #endif Modified: trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_9.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_9.h 2009-07-15 01:44:30 UTC (rev 10729) +++ trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_9.h 2009-07-15 02:10:16 UTC (rev 10730) @@ -7,40 +7,38 @@ namespace x10 { namespace lang { - extern const x10aux::RuntimeType* _initRTTHelper_Fun_0_9(const x10aux::RuntimeType **location, - const x10aux::RuntimeType *rtt0, - const x10aux::RuntimeType *rtt1, - const x10aux::RuntimeType *rtt2, - const x10aux::RuntimeType *rtt3, - const x10aux::RuntimeType *rtt4, - const x10aux::RuntimeType *rtt5, - const x10aux::RuntimeType *rtt6, - const x10aux::RuntimeType *rtt7, - const x10aux::RuntimeType *rtt8, - const x10aux::RuntimeType *rtt9); + void _initRTTHelper_Fun_0_9(x10aux::RuntimeType *location, + const x10aux::RuntimeType *rtt0, + const x10aux::RuntimeType *rtt1, + const x10aux::RuntimeType *rtt2, + const x10aux::RuntimeType *rtt3, + const x10aux::RuntimeType *rtt4, + const x10aux::RuntimeType *rtt5, + const x10aux::RuntimeType *rtt6, + const x10aux::RuntimeType *rtt7, + const x10aux::RuntimeType *rtt8, + const x10aux::RuntimeType *rtt9); template<class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9, class R> class Fun_0_9 : public virtual Object { public: - static const x10aux::RuntimeType* rtt; - static const x10aux::RuntimeType* getRTT() { return NULL == rtt ? _initRTT() : rtt; } - static const x10aux::RuntimeType* _initRTT(); - virtual const x10aux::RuntimeType *_type() const { return getRTT(); } + RTT_H_DECLS virtual ~Fun_0_9() { }; virtual R apply(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8, P9 p9) = 0; }; template<class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9, class R> - const x10aux::RuntimeType* Fun_0_9<P1,P2,P3,P4,P5,P6,P7,P8,P9,R>::_initRTT() { - return x10::lang::_initRTTHelper_Fun_0_9(&rtt, x10aux::getRTT<P1>(), x10aux::getRTT<P2>(), - x10aux::getRTT<P3>(), x10aux::getRTT<P4>(), - x10aux::getRTT<P5>(), x10aux::getRTT<P6>(), - x10aux::getRTT<P7>(), x10aux::getRTT<P8>(), - x10aux::getRTT<P9>(), x10aux::getRTT<R>()); + void Fun_0_9<P1,P2,P3,P4,P5,P6,P7,P8,P9,R>::_initRTT() { + rtt.parentsc = -2; + x10::lang::_initRTTHelper_Fun_0_9(&rtt, x10aux::getRTT<P1>(), x10aux::getRTT<P2>(), + x10aux::getRTT<P3>(), x10aux::getRTT<P4>(), + x10aux::getRTT<P5>(), x10aux::getRTT<P6>(), + x10aux::getRTT<P7>(), x10aux::getRTT<P8>(), + x10aux::getRTT<P9>(), x10aux::getRTT<R>()); } template<class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9, class R> - const x10aux::RuntimeType* Fun_0_9<P1,P2,P3,P4,P5,P6,P7,P8,P9,R>::rtt = NULL; + x10aux::RuntimeType Fun_0_9<P1,P2,P3,P4,P5,P6,P7,P8,P9,R>::rtt; } } #endif Modified: trunk/x10.runtime.17/src-cpp/x10/lang/Object.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/Object.h 2009-07-15 01:44:30 UTC (rev 10729) +++ trunk/x10.runtime.17/src-cpp/x10/lang/Object.h 2009-07-15 02:10:16 UTC (rev 10730) @@ -24,7 +24,7 @@ public: /* Note special RTT code block because Object is predefined by RuntimeType */ - static const x10aux::RuntimeType* getRTT() { return x10aux::RuntimeType::ObjectType; } + static const x10aux::RuntimeType* getRTT() { return &x10aux::RuntimeType::ObjectType; } virtual const x10aux::RuntimeType *_type() const { return getRTT(); } virtual x10aux::itable_entry* _getITables() { return _itables; } Modified: trunk/x10.runtime.17/src-cpp/x10/lang/Rail.cc =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/Rail.cc 2009-07-15 01:44:30 UTC (rev 10729) +++ trunk/x10.runtime.17/src-cpp/x10/lang/Rail.cc 2009-07-15 02:10:16 UTC (rev 10730) @@ -8,22 +8,20 @@ namespace x10 { namespace lang { - const RuntimeType* - _initRTTHelper_Rail(const RuntimeType **location, const RuntimeType *element, + void + _initRTTHelper_Rail(RuntimeType *location, const RuntimeType *element, const RuntimeType *p1, const RuntimeType *p2) { const char *name = alloc_printf("x10.lang.Rail[%s]", element->name()); const RuntimeType *p0 = Ref::getRTT(); - const RuntimeType *cand = new (alloc<RuntimeType >()) RuntimeType(name, 3, p0, p1, p2); - return RuntimeType::installRTT(location, cand); + location->init(name, 3, p0, p1, p2); } - const RuntimeType* - _initRTTHelper_RailIterator(const RuntimeType **location, const RuntimeType *element, + void + _initRTTHelper_RailIterator(RuntimeType *location, const RuntimeType *element, const RuntimeType *p1) { const char *name = alloc_printf("x10.lang.Rail.Iterator[%s]", element->name()); const RuntimeType *p0 = Ref::getRTT(); - const RuntimeType *cand = new (alloc<RuntimeType >()) RuntimeType(name, 2, p0, p1); - return RuntimeType::installRTT(location, cand); + location->init(name, 2, p0, p1); } } } Modified: trunk/x10.runtime.17/src-cpp/x10/lang/Rail.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/Rail.h 2009-07-15 01:44:30 UTC (rev 10729) +++ trunk/x10.runtime.17/src-cpp/x10/lang/Rail.h 2009-07-15 02:10:16 UTC (rev 10730) @@ -16,10 +16,11 @@ namespace lang { - extern const x10aux::RuntimeType* _initRTTHelper_Rail(const x10aux::RuntimeType **location, const x10aux::RuntimeType *element, - const x10aux::RuntimeType *p1, const x10aux::RuntimeType *p2); - extern const x10aux::RuntimeType* _initRTTHelper_RailIterator(const x10aux::RuntimeType **location, const x10aux::RuntimeType *element, - const x10aux::RuntimeType *p1); + void _initRTTHelper_Rail(x10aux::RuntimeType *location, const x10aux::RuntimeType *element, + const x10aux::RuntimeType *p1, const x10aux::RuntimeType *p2); + void _initRTTHelper_RailIterator(x10aux::RuntimeType *location, + const x10aux::RuntimeType *element, + const x10aux::RuntimeType *p1); template<class P1, class R> class Fun_0_1; @@ -28,10 +29,7 @@ public virtual x10::lang::Iterable<T>, public x10aux::AnyRail<T> { public: - static const x10aux::RuntimeType* rtt; - static const x10aux::RuntimeType* getRTT() { return NULL == rtt ? _initRTT() : rtt; } - static const x10aux::RuntimeType* _initRTT(); - virtual const x10aux::RuntimeType *_type() const { return getRTT(); } + RTT_H_DECLS private: @@ -53,10 +51,7 @@ x... [truncated message content] |
From: <dgr...@us...> - 2009-07-23 02:28:55
|
Revision: 10847 http://x10.svn.sourceforge.net/x10/?rev=10847&view=rev Author: dgrove-oss Date: 2009-07-23 02:28:51 +0000 (Thu, 23 Jul 2009) Log Message: ----------- Merge itable branch to trunk. Modified Paths: -------------- trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/Emitter.java trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/MessagePassingCodeGenerator.java trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/X10CPPTranslator.java trunk/x10.runtime.17/src-cpp/Makefile trunk/x10.runtime.17/src-cpp/x10/io/FileReader__FileInputStream.cc trunk/x10.runtime.17/src-cpp/x10/io/FileReader__FileInputStream.h trunk/x10.runtime.17/src-cpp/x10/io/FileWriter__FileOutputStream.cc trunk/x10.runtime.17/src-cpp/x10/io/FileWriter__FileOutputStream.h trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_0.h trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_1.h trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_2.h trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_3.h trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_4.h trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_5.h trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_6.h trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_7.h trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_8.h trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_9.h trunk/x10.runtime.17/src-cpp/x10/lang/Object.cc trunk/x10.runtime.17/src-cpp/x10/lang/Rail.h trunk/x10.runtime.17/src-cpp/x10/lang/Ref.h trunk/x10.runtime.17/src-cpp/x10/lang/String.cc trunk/x10.runtime.17/src-cpp/x10/lang/Throwable.h trunk/x10.runtime.17/src-cpp/x10/lang/ValRail.cc trunk/x10.runtime.17/src-cpp/x10/lang/ValRail.h trunk/x10.runtime.17/src-cpp/x10/lang/Value.h trunk/x10.runtime.17/src-cpp/x10/lang/VoidFun_0_0.h trunk/x10.runtime.17/src-cpp/x10/lang/VoidFun_0_1.h trunk/x10.runtime.17/src-cpp/x10/lang/VoidFun_0_2.h trunk/x10.runtime.17/src-cpp/x10/lang/VoidFun_0_3.h trunk/x10.runtime.17/src-cpp/x10/lang/VoidFun_0_4.h trunk/x10.runtime.17/src-cpp/x10/lang/VoidFun_0_5.h trunk/x10.runtime.17/src-cpp/x10/lang/VoidFun_0_6.h trunk/x10.runtime.17/src-cpp/x10/lang/VoidFun_0_7.h trunk/x10.runtime.17/src-cpp/x10/lang/VoidFun_0_8.h trunk/x10.runtime.17/src-cpp/x10/lang/VoidFun_0_9.h trunk/x10.runtime.17/src-cpp/x10/runtime/Thread.cc trunk/x10.runtime.17/src-cpp/x10aux/RTT.h trunk/x10.runtime.17/src-cpp/x10aux/basic_functions.h trunk/x10.runtime.17/src-cpp/x10aux/bootstrap.cc trunk/x10.runtime.17/src-cpp/x10aux/bootstrap.h trunk/x10.runtime.17/src-cpp/x10aux/io/FILEPtrInputStream.h trunk/x10.runtime.17/src-cpp/x10aux/io/FILEPtrOutputStream.h trunk/x10.runtime.17/src-cpp/x10aux/io/FILEPtrStream.h trunk/x10.runtime.17/src-cpp/x10aux/itables.h trunk/x10.runtime.17/src-cpp/x10aux/pgas.cc trunk/x10.runtime.17/src-cpp/x10aux/rail_utils.h trunk/x10.runtime.17/src-cpp/x10aux/ref.h trunk/x10.runtime.17/src-cpp/x10rt17.h trunk/x10.runtime.17/src-x10/x10/array/Mat.x10 trunk/x10.runtime.17/src-x10/x10/lang/Array.x10 Added Paths: ----------- trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/ITable.java trunk/x10.runtime.17/src-cpp/x10/lang/RailIterator.cc trunk/x10.runtime.17/src-cpp/x10/lang/RailIterator.h trunk/x10.runtime.17/src-cpp/x10aux/fun_utils.h Removed Paths: ------------- trunk/x10.runtime.17/src-cpp/x10aux/itables.cc trunk/x10.runtime.17/src-cpp/x10aux/iterator_utils.h Property Changed: ---------------- trunk/x10.common.17/ trunk/x10.compiler.p3/ trunk/x10.cppbackend.17/ trunk/x10.dist/ trunk/x10.dist/INSTALL trunk/x10.dist/README trunk/x10.dist/RELEASE.NOTES trunk/x10.dist/bin/runx10 trunk/x10.dist/bin/x10c++ trunk/x10.dist/releng/makeTag.sh trunk/x10.dist/releng/packageCPPRelease.sh trunk/x10.runtime.17/ trunk/x10.runtime.17/src-cpp/x10/lang/ trunk/x10.runtime.17/src-cpp/x10/runtime/Debug.h trunk/x10.runtime.17/src-cpp/x10/runtime/IllegalMonitorStateException.h trunk/x10.runtime.17/src-cpp/x10/runtime/IllegalThreadStateException.h trunk/x10.runtime.17/src-cpp/x10/runtime/Lock.cc trunk/x10.runtime.17/src-cpp/x10/runtime/Lock.h trunk/x10.runtime.17/src-cpp/x10/runtime/Thread.cc trunk/x10.runtime.17/src-cpp/x10/runtime/Thread.h trunk/x10.runtime.17/src-cpp/x10aux/bootstrap.cc trunk/x10.runtime.17/src-cpp/x10aux/bootstrap.h trunk/x10.runtime.17/src-cpp/x10aux/cuda/cuda_utils.cc trunk/x10.runtime.17/src-cpp/x10aux/cuda/cuda_utils.h trunk/x10.runtime.17/src-cpp/x10aux/deserialization_dispatcher.cc trunk/x10.runtime.17/src-cpp/x10aux/deserialization_dispatcher.h trunk/x10.runtime.17/src-cpp/x10aux/pgas.h trunk/x10.runtime.17/src-cpp/x10rt17.h trunk/x10.runtime.17/src-java/ trunk/x10.runtime.17/src-java/x10/runtime/impl/java/ trunk/x10.runtime.17/src-java/x10/runtime/impl/java/Thread.java trunk/x10.runtime.17/src-x10/ trunk/x10.runtime.17/src-x10/x10/array/DistArray.x10 trunk/x10.runtime.17/src-x10/x10/array/LocalArray.x10 trunk/x10.runtime.17/src-x10/x10/array/Mat.x10 trunk/x10.runtime.17/src-x10/x10/array/MatBuilder.x10 trunk/x10.runtime.17/src-x10/x10/array/PolyMat.x10 trunk/x10.runtime.17/src-x10/x10/array/PolyMatBuilder.x10 trunk/x10.runtime.17/src-x10/x10/array/PolyRegionListBuilder.x10 trunk/x10.runtime.17/src-x10/x10/array/PolyRow.x10 trunk/x10.runtime.17/src-x10/x10/array/Row.x10 trunk/x10.runtime.17/src-x10/x10/array/ValRow.x10 trunk/x10.runtime.17/src-x10/x10/array/VarMat.x10 trunk/x10.runtime.17/src-x10/x10/array/VarRow.x10 trunk/x10.runtime.17/src-x10/x10/array/XformMat.x10 trunk/x10.runtime.17/src-x10/x10/runtime/Activity.x10 trunk/x10.runtime.17/src-x10/x10/runtime/ClockPhases.x10 trunk/x10.runtime.17/src-x10/x10/runtime/ClockState.x10 trunk/x10.runtime.17/src-x10/x10/runtime/Clock_c.x10 trunk/x10.runtime.17/src-x10/x10/runtime/FinishState.x10 trunk/x10.runtime.17/src-x10/x10/runtime/Future_c.x10 trunk/x10.runtime.17/src-x10/x10/runtime/InterruptedException.x10 trunk/x10.runtime.17/src-x10/x10/runtime/Lock.x10 trunk/x10.runtime.17/src-x10/x10/runtime/ModCountDownLatch.x10 trunk/x10.runtime.17/src-x10/x10/runtime/NativeRuntime.x10 trunk/x10.runtime.17/src-x10/x10/runtime/Thread.x10 trunk/x10.runtime.17/src-x10/x10/util/HashMap.x10 trunk/x10.runtime.17/src-x10/x10/util/List.x10 trunk/x10.runtime.17/src-x10/x10/util/Map.x10 trunk/x10.runtime.17/src-x10/x10/util/Set.x10 trunk/x10.runtime.17/src-x10/x10/util/Stack.x10 trunk/x10.runtime.17/src-x10/x10/util/concurrent/atomic/AtomicBoolean.x10 trunk/x10.runtime.17/src-x10/x10/util/concurrent/atomic/AtomicInteger.x10 trunk/x10.runtime.17/src-x10/x10/util/concurrent/atomic/AtomicLong.x10 trunk/x10.runtime.17/src-x10/x10/util/concurrent/atomic/AtomicReference.x10 Property changes on: trunk/x10.common.17 ___________________________________________________________________ Added: svn:mergeinfo + /branches/itable/x10.common.17:10541-10846 Property changes on: trunk/x10.compiler.p3 ___________________________________________________________________ Added: svn:mergeinfo + /branches/itable/x10.compiler.p3:10541-10846 Property changes on: trunk/x10.cppbackend.17 ___________________________________________________________________ Added: svn:mergeinfo + /branches/itable/x10.cppbackend.17:10541-10846 Modified: trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/Emitter.java =================================================================== --- trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/Emitter.java 2009-07-22 21:56:53 UTC (rev 10846) +++ trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/Emitter.java 2009-07-23 02:28:51 UTC (rev 10847) @@ -219,7 +219,7 @@ // TODO: handle closures // if (((X10TypeSystem) type.typeSystem()).isClosure(type)) // return translateType(((X10Type) type).toClosure().base(), asRef); - type = X10TypeMixin.baseType(type); + type = X10TypeMixin.baseType(type); String name = null; // TODO // if (type instanceof ClosureType) { @@ -239,7 +239,7 @@ // } else if (type.isClass()) { X10ClassType ct = (X10ClassType) type.toClass(); - + if (ct.isAnonymous()) { if (ct.interfaces().size() == 1 && ct.interfaces().get(0) instanceof ClosureType) { return translateType(ct.interfaces().get(0), asRef); @@ -248,15 +248,14 @@ assert ct.superClass() != null; return translateType(ct.superClass(), asRef); } - } - else { + } else { X10ClassDef cd = ((X10ClassType) type).x10Def(); String pat = null; if (!asRef) pat = getCppBoxRep(cd); else pat = getCppRep(cd); - if (pat != null) { + if (pat != null) { List<Type> typeArguments = ct.typeArguments(); Object[] o = new Object[typeArguments.size()+1]; int i = 0; @@ -293,7 +292,7 @@ return mangled_parameter_type_name(name); // parameter types shouldn't be refs } else if (type.isNull()) { return "x10aux::NullType"; // typedef to something sensible - } else + } else assert false : type; // unhandled type. assert (name != null); name = translateFQN(name); @@ -305,11 +304,11 @@ void printArgumentList(CodeWriter w, X10CPPContext_c c) { printArgumentList(w, c, false, true); } - + void printArgumentList(CodeWriter w, X10CPPContext_c c, boolean omitType) { printArgumentList(w, c, omitType, true); } - + void printArgumentList(CodeWriter w, X10CPPContext_c c, boolean omitType, boolean saved_this_mechanism) { for (int i = 0; i < c.variables.size(); i++) { if (i > 0) { @@ -348,14 +347,14 @@ h.allowBreak(0, " "); } } - + static List<Type> toTypeList(List<Ref<? extends Type>> list) { ArrayList<Type> res = new ArrayList<Type>(); for (Ref<? extends Type> r : list) res.add(r.get()); return res; } - + void printTemplateInstantiation(X10MethodInstance mi, CodeWriter w) { if (mi.typeParameters().size() == 0) return; @@ -455,7 +454,7 @@ //System.out.println(from+" implements "+superMeth); Type newReturnType = findRootMethodReturnType(n, pos, superMeth); - // check -- + // check -- if (returnType != null && !xts.typeDeepBaseEquals(returnType, newReturnType, context)) { String msg = "Two supertypes declare " + from + " with " + "different return types: " + returnType + " != " + newReturnType; @@ -518,9 +517,9 @@ printType(ret, h); h.allowBreak(2, 2, " ", 1); if (qualify) - h.write(translateType(n.methodDef().asInstance().container()) + "::"); + h.write(translateType(n.methodDef().asInstance().container()) + "::"); //n.print(n.id(), h, tr); - h.write(mangled_method_name(name)); + h.write(mangled_method_name(name)); h.write("("); h.allowBreak(2, 2, "", 0); h.begin(0); @@ -560,15 +559,19 @@ } printTemplateSignature(((X10ClassType)cd.asType()).typeArguments(), h); } - + void printRTT(X10ClassType ct, ClassifiedStream h) { + boolean isInterface = ct.flags().isInterface(); if (ct.typeArguments().isEmpty()) { - h.write("RTT_H_DECLS"); h.newline(); + h.write(isInterface ? "RTT_H_DECLS_INTERFACE" : "RTT_H_DECLS_CLASS"); h.newline(); h.forceNewline(); } else { h.write("static x10aux::RuntimeType rtt;"); h.newline(); h.write("static const x10aux::RuntimeType* getRTT() { if (-1 == rtt.parentsc) _initRTT(); return &rtt; }"); h.newline(); h.write("static void _initRTT();"); h.newline(); - h.write("virtual const x10aux::RuntimeType *_type() const { return getRTT(); }"); h.newline(); h.forceNewline(); + if (!isInterface) { + h.write("virtual const x10aux::RuntimeType *_type() const { return getRTT(); }"); h.newline(); + } + h.forceNewline(); } } @@ -590,7 +593,7 @@ } else { printTemplateSignature(ct.typeArguments(), h); h.write("x10aux::RuntimeType "+translateType(ct)+"::rtt;"); h.newline(); - + printTemplateSignature(ct.typeArguments(), h); h.write("void "+translateType(ct)+"::_initRTT() {"); h.newline(4); h.begin(0); h.write("const char *name ="); h.newline(4); @@ -618,49 +621,8 @@ h.newline(); } - void printInheritance(ClassDecl_c n, CodeWriter h, Translator tr) { - X10TypeSystem_c xts = (X10TypeSystem_c) tr.typeSystem(); - String extends_ = n.superClass()==null ? null : translateType(n.superClass().type()); - ArrayList<String> implements_ = new ArrayList<String>(); - for (TypeNode tn : n.interfaces()) { - implements_.add(translateType(tn.type())); - } - - // [DC] FIXME: the following is a hack, probably this should happen in - // the front end but I doubt that will happen any time soon. It ought - // to use type objects instead of strings, too. But I couldn't work - // out how to do that. - - // it seems extends_==null implies that we are dealing with an - // interface, since otherwise extends_ is Ref, Value, or some - // user-defined type. - - String x_l_Object = translateType(xts.Object()); - if (extends_ == null && implements_.isEmpty()) { - //Interfaces must always extend something in c++ - implements_.add(x_l_Object); - } else if (extends_ != null && implements_.contains(x_l_Object)) { - //Cosmetic: No point implementing Object if we're already extending something - implements_.remove(x_l_Object); - } - - String prefix = ":"; - if (extends_ != null) { - h.write(" "+prefix+" public "+extends_); - prefix = ","; - } - - h.allowBreak(2); + void printHeader(ClassDecl_c n, CodeWriter h, Translator tr, boolean qualify) { h.begin(0); - for (String iface : implements_) { - h.write(" "+prefix+" public virtual "+iface); - prefix = ","; - } - h.end(); - } - - void printHeader(ClassDecl_c n, CodeWriter h, Translator tr, boolean qualify) { - h.begin(0); // Handle generics // If it involves Parameter Types then generate C++ // templates. @@ -673,9 +635,12 @@ assert (false) : ("Nested class alert!"); h.write(translateType(n.classDef().outer().get().asType()) + "::"); } - h.write(mangled_non_method_name(n.name().id().toString())); + h.write(mangled_non_method_name(n.name().id().toString())); - printInheritance(n, h, tr); + if (!n.flags().flags().isInterface() && n.superClass() != null) { + String parent = translateType(n.superClass().type()); + h.write(" : public "+parent); + } h.unifiedBreak(0); h.end(); @@ -732,7 +697,7 @@ h.allowBreak(2, 2, " ", 1); if (qualify) h.write(translateType(n.fieldDef().asInstance().container()) + "::"); - h.write(mangled_field_name(n.name().id().toString())); + h.write(mangled_field_name(n.name().id().toString())); h.end(); } @@ -750,10 +715,10 @@ printType(n.type().type(), h); h.write(" "); } - h.write(mangled_non_method_name(n.name().id().toString())); + h.write(mangled_non_method_name(n.name().id().toString())); h.end(); } - + void enterClosure(X10CPPContext_c c) { c.advanceClosureId(); } @@ -779,11 +744,11 @@ return; } - + void printDeclarationList(CodeWriter w, X10CPPContext_c c, ArrayList vars) { printDeclarationList(w, c, vars, true, false); } - + void printDeclarationList(CodeWriter w, X10CPPContext_c c, ArrayList vars, boolean saved_this_mechanism, boolean writable) { for (int i = 0; i < vars.size(); i++) { VarInstance var = (VarInstance)vars.get(i); @@ -804,7 +769,7 @@ } } - + void generateSerializationMethods(ClassType type, StreamWrapper sw) { // FIXME: Has a lot of string constants. Refactor them // into final variables. @@ -862,8 +827,8 @@ h.write("}"); h.newline(); h.forceNewline(); } - + // _serialize_body() h.write("public: "); if (!type.flags().isFinal()) @@ -960,13 +925,13 @@ openNamespaces(h, name.qualifier()); h.write("namespace "+name.name()+" { "); } - + public static void closeNamespaces(CodeWriter h, QName name) { if (name == null) return; h.write("} "); closeNamespaces(h, name.qualifier()); } - + public String makeUnsignedType(Type t) { // FIXME: HACK! if (t.isInt()) Copied: trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/ITable.java (from rev 10846, branches/itable/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/ITable.java) =================================================================== --- trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/ITable.java (rev 0) +++ trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/ITable.java 2009-07-23 02:28:51 UTC (rev 10847) @@ -0,0 +1,273 @@ +package polyglot.ext.x10cpp.visit; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Comparator; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; + +import polyglot.ext.x10.types.X10ClassType; +import polyglot.ext.x10.types.X10TypeMixin; +import polyglot.ext.x10.types.X10TypeSystem_c; +import polyglot.types.Context; +import polyglot.types.MethodInstance; +import polyglot.types.Type; +import polyglot.util.CodeWriter; + +/** + * A class to encapsulate details of how the methods + * of an interface are mapped to itable entries and + * various code-generation details of how itables + * are implemented. + */ +public final class ITable { + private static final HashMap<X10ClassType, ITable> cachedITables = new HashMap<X10ClassType, ITable>(); + + private final X10ClassType interfaceType; + private final MethodInstance[] methods; + private final boolean hasOverloadedMethods; + private final boolean[] overloaded; + + /** + * Construct the ITable instance for the given X10 interface type + * @param interfaceType The interface for which to build the ITable + */ + private ITable(X10ClassType interfaceType) { + assert interfaceType.flags().isInterface() : "Cannot create an ITable for a non-interface type"; + this.interfaceType = interfaceType; + methods = collectMethods(interfaceType); + Arrays.sort(methods, new MethodComparator()); + boolean foundOverload = false; + overloaded = new boolean[methods.length]; + for (int i=1; i<methods.length; i++) { + boolean ol = methods[i-1].name().toString().equals(methods[i].name().toString()); + if (ol) { + overloaded[i-1] = true; + overloaded[i] = true; + foundOverload = true; + } + } + hasOverloadedMethods = foundOverload; + } + + private static MethodInstance[] collectMethods(X10ClassType interfaceType) { + ArrayList<MethodInstance> uniqueMethods = new ArrayList<MethodInstance>(); + uniqueMethods.addAll(interfaceType.methods()); + + for (X10ClassType superInterface : allImplementedInterfaces(interfaceType)) { + for (MethodInstance newMethod : superInterface.methods()) { + boolean duplicate = false; + for (MethodInstance oldMethod : uniqueMethods) { + if (MethodComparator.compareTo(oldMethod, newMethod) == 0) { + duplicate = true; + break; + } + } + if (!duplicate) { + uniqueMethods.add(newMethod); + } + } + } + + return uniqueMethods.toArray(new MethodInstance[uniqueMethods.size()]); + } + + /** + * Find or construct the ITable instance for the argument X10 interface type. + */ + public static ITable getITable(X10ClassType interfaceType) { + ITable ans = cachedITables.get(interfaceType); + if (ans == null) { + ans = new ITable(interfaceType); + cachedITables.put(interfaceType, ans); + } + return ans; + } + + /** + * Return a list of all interfaces directly and indirectly + * implemented by the argument class, excluding x10.lang.Object. + * If c is an interface, this method does not include c in the result! + */ + public static List<X10ClassType> allImplementedInterfaces(X10ClassType c) { + ArrayList<X10ClassType> ans = new ArrayList<X10ClassType>(); + allImplementedInterfaces(c, ans); + return ans; + } + + private static void allImplementedInterfaces(X10ClassType c, ArrayList<X10ClassType> l) { + X10TypeSystem_c xts = (X10TypeSystem_c) c.typeSystem(); + Context context = xts.createContext(); + if (c.typeEquals(xts.Object(), context)) { + return; + } + + for (X10ClassType old : l) { + if (c.typeEquals(old, context)) { + return; /* Already been here */ + } + } + + if (c.flags().isInterface()) { + l.add(c); + } + + if (c.superClass() != null) { + allImplementedInterfaces((X10ClassType)X10TypeMixin.baseType(c.superClass()), l); + } + + for (Type parent : c.interfaces()) { + allImplementedInterfaces((X10ClassType)X10TypeMixin.baseType(parent), l); + } + } + + /** + * @return the canonically ordered array of MethodDecls that + * are included in the itable for this interface. This is + * a set union of the methods directly declared by the interface and + * methods inherited from its superinterfaces. + */ + public MethodInstance[] getMethods() { + return methods; + } + + /** + * @return the interfaceType that this itable is being used to implement. + */ + public X10ClassType getInterface() { + return interfaceType; + } + + /** + * @return true if the ITable contains two methods with the same name + * that are statically overloaded. If true, then when declaring the + * iTable we will need to do additional name mangling to disambiguate + * the C++ names used for the elements of the ITable. + */ + public boolean hasOverloadedMethods() { + return hasOverloadedMethods; + } + + public String mangledName(MethodInstance meth) { + if (hasOverloadedMethods) { + for (int i=0; i<methods.length; i++) { + if (MethodComparator.compareTo(methods[i], meth) == 0) { + if (overloaded[i]) { + return "_m"+i+"__"+Emitter.mangled_method_name(meth.name().toString()); + } else { + return Emitter.mangled_method_name(meth.name().toString()); + } + } + } + assert false : "Method "+meth+" is not a member of interface "+interfaceType; + return Emitter.mangled_method_name(meth.name().toString()); + } else { + return Emitter.mangled_method_name(meth.name().toString()); + } + } + + public void emitFunctionPointerDecl(CodeWriter cw, Emitter emitter, MethodInstance meth, String memberPtr, boolean includeName) { + String returnType = emitter.translateType(meth.returnType(), true); + String name = mangledName(meth); + cw.write(returnType+" ("+memberPtr+"::*"+(includeName ? name : "")+") ("); + boolean first = true; + for (Type f : meth.formalTypes()) { + if (!first) cw.write(", "); + cw.write(emitter.translateType(f, true)); + first = false; + } + cw.write(")"); + } + + public void emitThunks(X10ClassType cls, int itableNum, Emitter emitter, CodeWriter h) { + String clsCTypeRef = emitter.translateType(cls, true); + + // Using thunks to resolve overloaded functions when filling in itable addresses. + // TODO: There really should be some way to avoid needing this. + String thunkRoot = "_itable_thunk_"+itableNum+"_"; + for (int i=0; i<methods.length; i++) { + if (overloaded[i]) { + MethodInstance meth = methods[i]; + h.write(emitter.translateType(meth.returnType(), true)+" "+thunkRoot+i+"("); + List<Type> formals = meth.formalTypes(); + int argNum = 0; + for (Type argType : formals) { + if (argNum > 0) h.write(", "); + h.write(emitter.translateType(argType, true)+" arg"+argNum++); + } + h.write(") {"); h.newline(4); h.begin(0); + h.write((!meth.returnType().isVoid() ? "return this->":"this->")+emitter.mangled_method_name(meth.name().toString())+"("); + for (argNum = 0; argNum<formals.size(); argNum++) { + h.write((argNum>0?", arg":"arg")+argNum); + } + h.write(");"); h.end(); h.newline(); + h.write("}"); h.newline(); + } + } + } + + public void emitITableDecl(X10ClassType cls, int itableNum, Emitter emitter, CodeWriter h) { + if (hasOverloadedMethods) { + emitThunks(cls, itableNum, emitter, h); + } + String interfaceCType = emitter.translateType(interfaceType, false); + boolean doubleTemplate = cls.typeArguments().size() > 0 && interfaceType.typeArguments().size() > 0; + h.write("static "+(doubleTemplate ? "typename ":"")+interfaceCType+ + (doubleTemplate ? "::template itable<":"::itable<")+emitter.translateType(cls, false)+" > _itable_"+itableNum+";"); + h.newline(); + } + + public void emitITableInitialization(X10ClassType cls, int itableNum, Emitter emitter, CodeWriter h, CodeWriter sw) { + String interfaceCType = emitter.translateType(interfaceType, false); + String clsCType = emitter.translateType(cls, false); + boolean doubleTemplate = cls.typeArguments().size() > 0 && interfaceType.typeArguments().size() > 0; + + if (!cls.typeArguments().isEmpty()) { + emitter.printTemplateSignature(cls.typeArguments(), sw); + } + sw.write((doubleTemplate ? "typename " : "")+interfaceCType+(doubleTemplate ? "::template itable<" : "::itable<")+ + emitter.translateType(cls, false)+" > "+" "+clsCType+"::_itable_"+itableNum+"("); + int methodNum = 0; + for (MethodInstance meth : methods) { + if (methodNum > 0) sw.write(", "); + if (overloaded[methodNum]) { + sw.write("&"+clsCType+"::"+"_itable_thunk_"+itableNum+"_"+methodNum); + } else { + sw.write("&"+clsCType+"::"+Emitter.mangled_method_name(meth.name().toString())); + } + methodNum++; + } + sw.write(");"); sw.newline(); + } + + /** + * Helper class to impose a canonical ordering on the methods of an interface. + */ + private static final class MethodComparator implements Comparator<MethodInstance> { + public int compare(MethodInstance m1, MethodInstance m2) { + return compareTo(m1, m2); + } + + public static int compareTo(MethodInstance m1, MethodInstance m2) { + int nameCompare = m1.name().toString().compareTo(m2.name().toString()); + if (nameCompare != 0) return nameCompare; + // Statically overloaded method. Order by comparing function signatures. + List<Type> m1Formals = m1.formalTypes(); + List<Type> m2Formals = m2.formalTypes(); + if (m1Formals.size() < m2Formals.size()) return -1; + if (m1Formals.size() > m2Formals.size()) return 1; + // Have same number of formal parameters; impose arbitrary order via toString of formals + Iterator<Type> i1 = m1Formals.iterator(); + Iterator<Type> i2 = m2Formals.iterator(); + while (i1.hasNext()) { + Type f1 = i1.next(); + Type f2 = i2.next(); + int fcompare = f1.toString().compareTo(f2.toString()); + if (fcompare != 0) return fcompare; + } + // TODO: Does X10 also allow method overloading based on constraints or # of type parameters? + return m1.returnType().toString().compareTo(m2.returnType().toString()); + } + } +} Modified: trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/MessagePassingCodeGenerator.java =================================================================== --- trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/MessagePassingCodeGenerator.java 2009-07-22 21:56:53 UTC (rev 10846) +++ trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/MessagePassingCodeGenerator.java 2009-07-23 02:28:51 UTC (rev 10847) @@ -22,6 +22,8 @@ import static polyglot.ext.x10cpp.visit.Emitter.translate_mangled_FQN; import static polyglot.ext.x10cpp.visit.Emitter.voidTemplateInstantiation; import static polyglot.ext.x10cpp.visit.SharedVarsMethods.CONSTRUCTOR; +import static polyglot.ext.x10cpp.visit.SharedVarsMethods.DESERIALIZER_METHOD; +import static polyglot.ext.x10cpp.visit.SharedVarsMethods.DESERIALIZE_BODY_METHOD; import static polyglot.ext.x10cpp.visit.SharedVarsMethods.DESERIALIZE_METHOD; import static polyglot.ext.x10cpp.visit.SharedVarsMethods.INSTANCE_INIT; import static polyglot.ext.x10cpp.visit.SharedVarsMethods.MAKE; @@ -32,6 +34,7 @@ import static polyglot.ext.x10cpp.visit.SharedVarsMethods.SERIALIZATION_MARKER; import static polyglot.ext.x10cpp.visit.SharedVarsMethods.SERIALIZE_BODY_METHOD; import static polyglot.ext.x10cpp.visit.SharedVarsMethods.SERIALIZE_ID_METHOD; +import static polyglot.ext.x10cpp.visit.SharedVarsMethods.SERIALIZE_METHOD; import static polyglot.ext.x10cpp.visit.SharedVarsMethods.STATIC_INIT; import static polyglot.ext.x10cpp.visit.SharedVarsMethods.STRUCT_EQUALS; import static polyglot.ext.x10cpp.visit.SharedVarsMethods.STRUCT_EQUALS_METHOD; @@ -71,6 +74,7 @@ import polyglot.ast.ClassBody_c; import polyglot.ast.ClassDecl_c; import polyglot.ast.ClassMember; +import polyglot.ast.CodeDecl; import polyglot.ast.Conditional_c; import polyglot.ast.ConstructorCall; import polyglot.ast.ConstructorDecl_c; @@ -97,6 +101,7 @@ import polyglot.ast.LocalDecl_c; import polyglot.ast.Local_c; import polyglot.ast.Loop_c; +import polyglot.ast.MethodDecl; import polyglot.ast.MethodDecl_c; import polyglot.ast.New_c; import polyglot.ast.Node; @@ -182,6 +187,7 @@ import polyglot.ext.x10cpp.types.X10CPPContext_c; import polyglot.ext.x10cpp.visit.X10CPPTranslator.DelegateTargetFactory; import polyglot.types.ClassType; +import polyglot.types.ClassType_c; import polyglot.types.CodeInstance; import polyglot.types.Context; import polyglot.types.FieldInstance; @@ -677,7 +683,6 @@ } w.write("#include <"+cheader+">"); w.newline(); - w.write("#include <x10aux/iterator_utils.h>"); w.newline(); w.forceNewline(0); w.forceNewline(0); @@ -790,7 +795,7 @@ } X10ClassType superClass = (X10ClassType) X10TypeMixin.baseType(def.asType().superClass()); if (superClass != null) { - for (Name mname : getMethodNames(n.body().members(), def.asType().interfaces())) { + for (Name mname : getMethodNames(n.body().members())) { List<MethodInstance> overriddenOverloads = getOROLMeths(mname, superClass); for (MethodInstance mi : overriddenOverloads) { extractAllClassTypes(mi.returnType(), types, dupes); @@ -986,7 +991,7 @@ return ct; } - private ArrayList<Name> getMethodNames(List<ClassMember> members, List<Type> interfaces) { + private ArrayList<Name> getMethodNames(List<ClassMember> members) { ArrayList<Name> mnames = new ArrayList<Name>(); Set<Name> dupes = new HashSet<Name>(); for (ClassMember member : members) { @@ -1000,15 +1005,6 @@ dupes.add(mname); mnames.add(mname); } - for (Type iface : interfaces) { - List<MethodInstance> methods = iface.toClass().methods(); - for (MethodInstance mi : methods) { - Name mname = mi.name(); - if (dupes.contains(mname)) continue; - dupes.add(mname); - mnames.add(mname); - } - } return mnames; } @@ -1016,6 +1012,7 @@ X10CPPContext_c context = (X10CPPContext_c) tr.context(); X10ClassType currentClass = (X10ClassType) context.currentClass(); X10ClassType superClass = (X10ClassType) X10TypeMixin.baseType(currentClass.superClass()); + boolean isInterface = currentClass.flags().isInterface(); ClassifiedStream h = sw.header(); @@ -1030,161 +1027,237 @@ //context.classProperties = new ArrayList(); List<ClassMember> members = n.members(); - if (!members.isEmpty()) { - String className = emitter.translateType(currentClass); + + if (isInterface) { + ITable itable = ITable.getITable(currentClass); - for (ClassMember member : members) { - if (!(member instanceof X10ClassDecl_c)) - continue; - assert (false) : "Nested class alert! "+member+" "+n.position().nameAndLineString(); - ClassDecl_c dec = (ClassDecl_c)member; - X10ClassDef def = (X10ClassDef) dec.classDef(); - if (getCppRep(def) != null) - continue; - if (def.flags().isStatic() && ((X10ClassDef)currentClass.def()).typeParameters().size() != 0) - continue; - emitter.printTemplateSignature(((X10ClassType)dec.classDef().asType()).typeArguments(), h); - h.write("class "); - h.write(mangled_non_method_name(dec.name().id().toString())); + h.write("template <class I> struct itable {"); h.newline(4); h.begin(0); + h.write("itable("); + boolean firstMethod = true; + for (MethodInstance meth : itable.getMethods()) { + if (!firstMethod) { + h.write(", "); + } + firstMethod = false; + itable.emitFunctionPointerDecl(h, emitter, meth, "I", true); + } + h.write(") "); + firstMethod = true; + for (MethodInstance meth : itable.getMethods()) { + if (firstMethod) { + h.write(": "); + firstMethod = false; + } else { + h.write(", "); + } + String name = itable.mangledName(meth); + h.write(name+"("+name+")"); + } + h.write(" {}"); + h.newline(); + + firstMethod = true; + for (MethodInstance meth : itable.getMethods()) { + if (!firstMethod) h.newline(); + firstMethod = false; + itable.emitFunctionPointerDecl(h, emitter, meth, "I", true); h.write(";"); - h.newline(); } + h.end(); h.newline(); + h.write("};"); h.newline(); + h.forceNewline(); + + /* Serialization redirection methods */ + h.write("static void "+SERIALIZE_METHOD+"("); h.begin(0); + h.write(emitter.translateType(currentClass, true)+" 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("x10::lang::Object::"+SERIALIZE_METHOD+"(this_, buf, m);"); h.end(); h.newline(); + h.write("}"); h.newline(); h.forceNewline(); + + h.write("public: template<class __T> static "); + h.write(make_ref("__T")+" "+DESERIALIZE_METHOD+"("+SERIALIZATION_BUFFER+"& buf) {"); h.newline(4) ; h.begin(0); + h.write("return x10::lang::Object::"+DESERIALIZE_METHOD+"<__T>(buf);"); h.end(); h.newline(); + h.write("}"); h.newline(); h.forceNewline(); + } else { + List<X10ClassType> allInterfaces = ITable.allImplementedInterfaces(currentClass); + int numInterfaces = allInterfaces.size(); + if (numInterfaces > 0) { + /* ITables declarations */ + h.write("static x10aux::itable_entry _itables["+(numInterfaces+1)+"];"); h.newline(); h.forceNewline(); + h.write("virtual x10aux::itable_entry* _getITables() { return _itables; }"); h.newline(); h.forceNewline(); + int itableNum = 0; + for (Type interfaceType : allInterfaces) { + ITable itable = ITable.getITable((X10ClassType) X10TypeMixin.baseType(interfaceType)); + itable.emitITableDecl(currentClass, itableNum, emitter, h); + itableNum += 1; + h.forceNewline(); + } + /* ITables initialization */ + itableNum = 0; + for (Type interfaceType : allInterfaces) { + ITable itable = ITable.getITable((X10ClassType) X10TypeMixin.baseType(interfaceType)); + itable.emitITableInitialization(currentClass, itableNum, emitter, h, sw); + itableNum += 1; + } + + if (!currentClass.typeArguments().isEmpty()) { + emitter.printTemplateSignature(currentClass.typeArguments(), sw); + } + sw.write("x10aux::itable_entry "+emitter.translateType(currentClass)+"::_itables["+(numInterfaces+1)+"] = {"); + itableNum = 0; + for (Type interfaceType : allInterfaces) { + sw.write("x10aux::itable_entry(&"+emitter.translateType(interfaceType)+"::rtt, &_itable_"+itableNum+"), "); + itableNum += 1; + } + sw.write("x10aux::itable_entry(NULL, NULL)};"); sw.newline(); + } + } + + if (!members.isEmpty()) { + String className = emitter.translateType(currentClass); + X10TypeSystem xts = (X10TypeSystem) tr.typeSystem(); + h.write(VOID + " " + INSTANCE_INIT + "();"); h.newline(); h.forceNewline(); if (extractInits(currentClass, INSTANCE_INIT, VOID, members, false)) { context.hasInits = true; } - ClassMember prev = null; - for (ClassMember member : members) { - if (member instanceof ClassDecl_c) // Process nested classes separately - continue; - if ((member instanceof polyglot.ast.CodeDecl) || - (prev instanceof polyglot.ast.CodeDecl)) { - h.newline(0); - sw.newline(0); + if (isInterface) { + for (ClassMember member : members) { + if (! (member instanceof polyglot.ast.MethodDecl)){ + n.printBlock(member, sw, tr); + } } - prev = member; - n.printBlock(member, sw, tr); - } + } else { + ClassMember prev = null; + for (ClassMember member : members) { + if ((member instanceof polyglot.ast.CodeDecl) || + (prev instanceof polyglot.ast.CodeDecl)) { + h.newline(0); + sw.newline(0); + } + prev = member; + n.printBlock(member, sw, tr); + } - X10TypeSystem xts = (X10TypeSystem) tr.typeSystem(); - // generate proxy methods for an overridden method's superclass overloads - if (superClass != null) { - // first gather a set of all the method names in the current class - ArrayList<Name> mnames = getMethodNames(members, currentClass.interfaces()); + if (superClass != null) { + // first gather a set of all the method names in the current class + ArrayList<Name> mnames = getMethodNames(members); - // then, for each one - for (Name mname : mnames) { - // get the list of overloads that this class should expose - // (but doesn't because c++ doesn't work that way) - List<MethodInstance> overriddenOverloads = getOROLMeths(mname,superClass); - // for each one... - for (MethodInstance dropzone_ : overriddenOverloads) { - X10MethodInstance dropzone = (X10MethodInstance) dropzone_; - List<Type> formals = dropzone.formalTypes(); - // do we have a matching method? (i.e. one the x10 programmer has written) - if (currentClass.methods(mname, formals, context).size() > 0) continue; - // otherwise we need to add a proxy. - //System.out.println("Not found: "+dropzone); - assert (!dropzone.flags().isStatic()); - //assert(!dropzone.flags().isFinal()); - assert (!dropzone.flags().isPrivate()); - h.write("public: "); - List<Type> typeParameters = dropzone.typeParameters(); - List<Type> newTypeParameters = new ArrayList<Type>(); - HashMap<Type, Type> typeMap = new HashMap<Type, Type>(); - for (Type t : typeParameters) { - assert (t instanceof ParameterType); - Type dummy = new ParameterType_c(xts, t.position(), Name.makeFresh("T"), null); - newTypeParameters.add(dummy); - typeMap.put(t, dummy); - } - emitter.printTemplateSignature(newTypeParameters, h); - if (newTypeParameters.isEmpty()) { - h.write("virtual "); - } - emitter.printType(replaceType(X10TypeMixin.baseType(dropzone.returnType()), typeMap), h); - h.write(" "+mangled_method_name(mname.toString())+"("); - h.begin(0); - int counter = 0; - for (Type formal : formals) { - h.write(counter == 0 ? "" : ", "); - emitter.printType(replaceType(X10TypeMixin.baseType(formal), typeMap), h); - h.write(" p"+counter++); - } - h.end(); - h.write(");"); h.newline(); + // then, for each one + for (Name mname : mnames) { + // get the list of overloads that this class should expose + // (but doesn't because c++ doesn't work that way) + List<MethodInstance> overriddenOverloads = getOROLMeths(mname,superClass); + // for each one... + for (MethodInstance dropzone_ : overriddenOverloads) { + X10MethodInstance dropzone = (X10MethodInstance) dropzone_; + List<Type> formals = dropzone.formalTypes(); + // do we have a matching method? (i.e. one the x10 programmer has written) + if (currentClass.methods(mname, formals, context).size() > 0) continue; + // otherwise we need to add a proxy. + //System.out.println("Not found: "+dropzone); + assert (!dropzone.flags().isStatic()); + //assert(!dropzone.flags().isFinal()); + assert (!dropzone.flags().isPrivate()); + h.write("public: "); + List<Type> typeParameters = dropzone.typeParameters(); + List<Type> newTypeParameters = new ArrayList<Type>(); + HashMap<Type, Type> typeMap = new HashMap<Type, Type>(); + for (Type t : typeParameters) { + assert (t instanceof ParameterType); + Type dummy = new ParameterType_c(xts, t.position(), Name.makeFresh("T"), null); + newTypeParameters.add(dummy); + typeMap.put(t, dummy); + } + emitter.printTemplateSignature(newTypeParameters, h); + if (newTypeParameters.isEmpty()) { + h.write("virtual "); + } + emitter.printType(replaceType(X10TypeMixin.baseType(dropzone.returnType()), typeMap), h); + h.write(" "+mangled_method_name(mname.toString())+"("); + h.begin(0); + int counter = 0; + for (Type formal : formals) { + h.write(counter == 0 ? "" : ", "); + emitter.printType(replaceType(X10TypeMixin.baseType(formal), typeMap), h); + h.write(" p"+counter++); + } + h.end(); + h.write(");"); h.newline(); - if (newTypeParameters.size() != 0) { - sw.pushCurrentStream(context.templateFunctions); - } + if (newTypeParameters.size() != 0) { + sw.pushCurrentStream(context.templateFunctions); + } - emitter.printTemplateSignature(currentClass.typeArguments(), sw); - emitter.printTemplateSignature(newTypeParameters, sw); - emitter.printType(replaceType(X10TypeMixin.baseType(dropzone.returnType()), typeMap), sw); - sw.write(" " + emitter.translateType(currentClass, false) + - "::" + mangled_method_name(mname.toString()) + "("); - sw.begin(0); - counter = 0; - for (Type formal : formals) { - sw.write(counter == 0 ? "" : ", "); - emitter.printType(replaceType(X10TypeMixin.baseType(formal), typeMap), sw); - sw.write(" p"+counter++); - } - sw.end(); - sw.write(") {"); sw.newline(4); sw.begin(0); - if (!dropzone.returnType().isVoid()) - sw.write("return "); - String pat = getCppImplForDef(dropzone.x10Def()); - if (pat != null) { // TODO: merge with emitNativeAnnotation - // FIXME: casts! - Object[] components = new Object[1+3*newTypeParameters.size() + formals.size()]; - components[0] = "this"; - int i = 1; - for (Type at : newTypeParameters) { - components[i++] = at; - components[i++] = "/"+"*"+" UNUSED "+"*"+"/"; - components[i++] = "/"+"*"+" UNUSED "+"*"+"/"; - } - counter = 0; - for (Type formal : formals) { - components[i++] = "p" + (counter++); - } - emitter.dumpRegex("Native", components, tr, pat, sw); - } else { - sw.write(emitter.translateType(superClass, false) + - "::" + mangled_method_name(mname.toString())); - if (newTypeParameters.size() != 0) { - String prefix = "<"; - for (Type t : newTypeParameters) { - sw.write(prefix); - sw.write(emitter.translateType(t)); - prefix = ","; - } - sw.write(">"); - } - sw.write("("); - sw.begin(0); - counter = 0; - for (Type formal : formals) { - sw.write(counter == 0 ? "" : ", "); - sw.write("p" + (counter++)); - } - sw.end(); - sw.write(")"); - } - sw.write(";"); sw.end(); sw.newline(); + emitter.printTemplateSignature(currentClass.typeArguments(), sw); + emitter.printTemplateSignature(newTypeParameters, sw); + emitter.printType(replaceType(X10TypeMixin.baseType(dropzone.returnType()), typeMap), sw); + sw.write(" " + emitter.translateType(currentClass, false) + + "::" + mangled_method_name(mname.toString()) + "("); + sw.begin(0); + counter = 0; + for (Type formal : formals) { + sw.write(counter == 0 ? "" : ", "); + emitter.printType(replaceType(X10TypeMixin.baseType(formal), typeMap), sw); + sw.write(" p"+counter++); + } + sw.end(); + sw.write(") {"); sw.newline(4); sw.begin(0); + if (!dropzone.returnType().isVoid()) + sw.write("return "); + String pat = getCppImplForDef(dropzone.x10Def()); + if (pat != null) { // TODO: merge with emitNativeAnnotation + // FIXME: casts! + Object[] components = new Object[1+3*newTypeParameters.size() + formals.size()]; + components[0] = "this"; + int i = 1; + for (Type at : newTypeParameters) { + components[i++] = at; + components[i++] = "/"+"*"+" UNUSED "+"*"+"/"; + components[i++] = "/"+"*"+" UNUSED "+"*"+"/"; + } + counter = 0; + for (Type formal : formals) { + components[i++] = "p" + (counter++); + } + emitter.dumpRegex("Native", components, tr, pat, sw); + } else { + sw.write(emitter.translateType(superClass, false) + + "::" + mangled_method_name(mname.toString())); + if (newTypeParameters.size() != 0) { + String prefix = "<"; + for (Type t : newTypeParameters) { + sw.write(prefix); + sw.write(emitter.translateType(t)); + prefix = ","; + } + sw.write(">"); + } + sw.write("("); + sw.begin(0); + counter = 0; + for (Type formal : formals) { + sw.write(counter == 0 ? "" : ", "); + sw.write("p" + (counter++)); + } + sw.end(); + sw.write(")"); + } + sw.write(";"); sw.end(); sw.newline(); - sw.write("}"); sw.newline(); + sw.write("}"); sw.newline(); - if (newTypeParameters.size() != 0) { - sw.popCurrentStream(); - } - } - } - } + if (newTypeParameters.size() != 0) { + sw.popCurrentStream(); + } + } + } + } + } // Generate structEquals for values if (xts.isValueType(currentClass, context)) { @@ -1698,13 +1771,13 @@ public void visit(Return_c ret) { Expr e = ret.expr(); - sw.write("return"); - if (e != null) { - sw.write(" "); - ret.print(e, sw, tr); + if (e == null) { + sw.write("return;"); + } else { + sw.write("return "); + ret.print(e, sw, tr); + sw.write(";"); sw.newline(); } - sw.write(";"); - sw.newline(); } @@ -1959,7 +2032,7 @@ X10MethodInstance mi = (X10MethodInstance) n.methodInstance(); Receiver target = n.target(); Type t = target.type(); - + X10MethodDef md = mi.x10Def(); if (mi.flags().isStatic()) { TypeNode tn = @@ -2011,7 +2084,7 @@ { args.set(0, cast(args.get(0), xts.Object())); } - + String pat = getCppImplForDef(md); if (pat != null) { emitNativeAnnotation(pat, mi.typeParameters(), target, args); @@ -2030,6 +2103,8 @@ sw.begin(0); String dangling = ""; boolean already_static = false; + String targetMethodName = mangled_method_name(n.name().id().toString()); + boolean isInterfaceInvoke = false; if (!n.isTargetImplicit()) { // explicit target. @@ -2050,8 +2125,30 @@ already_static = true; } else { boolean assoc = !(target instanceof New_c || target instanceof Binary_c); - n.printSubExpr((Expr) target, assoc, sw, tr); - sw.write("->"); + if (t.isClass()) { + X10ClassType clsType = (X10ClassType)t.toClass(); + if (clsType.flags().isInterface()) { + ITable itable= ITable.getITable(clsType); + targetMethodName = itable.mangledName(mi); + isInterfaceInvoke = true; + if (ret_type.isVoid()) { + sw.write("(__extension__ ({ x10aux::ref<x10::lang::Object> _ = "); + n.printSubExpr((Expr) target, assoc, sw, tr); + sw.write("; (_.get()->*(x10aux::findITable"+chevrons(emitter.translateType(clsType, false))+"(_->_getITables())->"+itable.mangledName(mi)+"))"); + dangling = "; }))"; + } else { + sw.write("(__extension__ ({ x10aux::ref<x10::lang::Object> _ = "); + n.printSubExpr((Expr) target, assoc, sw, tr); + sw.write("; x10aux::GXX_ICE_Workaround"+chevrons(emitter.translateType(ret_type, true))+"::_((_.get()->*(x10aux::findITable"+chevrons(emitter.translateType(clsType, false))+"(_->_getITables())->"+itable.mangledName(mi)+"))"); + dangling = "); }))"; + } + } + } + + if (!isInterfaceInvoke) { + n.printSubExpr((Expr) target, assoc, sw, tr); + sw.write("->"); + } } } else if (target instanceof TypeNode || target instanceof AmbReceiver) { n.print(target, sw, tr); @@ -2059,7 +2156,7 @@ already_static = true; } } - + boolean virtual_dispatch = true; if (t.isClass()) { X10ClassType ct = (X10ClassType)t.toClass(); @@ -2080,8 +2177,10 @@ if (context.inTemplate() && mi.typeParameters().size() != 0 && virtual_dispatch) { sw.write("template "); } - sw.write(mangled_method_name(n.name().id().toString())); - emitter.printTemplateInstantiation(mi, sw); + if (!isInterfaceInvoke) { + sw.write(targetMethodName); + emitter.printTemplateInstantiation(mi, sw); + } sw.write("("); if (args.size() > 0) { sw.allowBreak(2, 2, "", 0); // miser mode @@ -2582,22 +2681,24 @@ sw.newline(4); sw.begin(0); String name = "__i" + form.name(); - sw.write(emitter.translateType(xts.Iterator(form.type().type()))); - sw.write("* " + name + " = &*"); // FIXME - if (!xts.typeDeepBaseEquals(form.type().type(), itType, context)) { - String fType = emitter.translateType(form.type().type(), true); - sw.write("x10aux::convert_iterator"+chevrons(fType+","+emitter.translateType(itType, true))); - } - sw.write("(("); + String itableName = name+"_itable"; + String iteratorType = emitter.translateType(xts.Iterator(form.type().type()), false); + String iterableType = emitter.translateType(xts.Iterable(form.type().type()), false); + String iterableTypeRef = emitter.translateType(xts.Iterable(form.type().type()), true); + String iteratorTypeRef = emitter.translateType(xts.Iterator(form.type().type()), true); + boolean doubleTemplate = ((X10ClassType)context.currentClass()).typeArguments().size() > 0; + + sw.write("x10aux::ref<x10::lang::Object> " + name + " = "+iteratorTypeRef); + sw.write("(__extension__ ({ x10aux::ref<x10::lang::Object> _1 = "); n.print(domain, sw, tr); - sw.write(")->iterator());"); - sw.newline(); - + sw.write("; x10aux::GXX_ICE_Workaround"+chevrons(iteratorTypeRef)+"::_((_1.get()->*(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 ("); sw.begin(0); sw.write(";"); sw.allowBreak(2, " "); - sw.write(name + "->hasNext();"); + sw.write("("+name+".get()->*("+itableName+"->hasNext))();"); sw.allowBreak(2, " "); sw.end(); @@ -2608,7 +2709,7 @@ sw.write(";"); sw.newline(); sw.write(mangled_non_method_name(form.name().id().toString())); - sw.write(" = " + name + "->next();"); + sw.write(" = ("+name+".get()->*("+itableName+"->next))();"); sw.newline(); for (Iterator li = n.locals().iterator(); li.hasNext(); ) { Stmt l = (Stmt) li.next(); @@ -2793,17 +2894,22 @@ if (!retType.isVoid()) supArgs.add(retType); String superType = emitter.translateType(sup.typeArguments(supArgs)); + String superTypeRef = emitter.translateType(sup.typeArguments(supArgs), true); // class header if (!freeTypeParams.isEmpty()) emitter.printTemplateSignature(freeTypeParams, inc); inc.write("class "+cname+" : "); inc.begin(0); - inc.write("public "+emitter.translateType(xts.Value())+", "); inc.newline(); - inc.write("public virtual "+superType); inc.end(); inc.newline(); + inc.write("public "+emitter.translateType(xts.Value())); inc.write("{") ; inc.newline(4); inc.begin(0); inc.write("public:") ; inc.newline(); inc.forceNewline(); + + /* ITables declarations */ + inc.write("static "+(in_template_closure ? "typename " : "")+superType+(in_template_closure ? "::template itable " : "::itable")+chevrons(cnamet)+" _itable;"); inc.newline(); + inc.write("static x10aux::itable_entry _itables[2];"); inc.newline(); inc.forceNewline(); + inc.write("virtual x10aux::itable_entry* _getITables() { return _itables; }"); inc.newline(); inc.forceNewline(); - inc.write("// closure body"); inc.newline(); + inc.write("// closure body"); inc.newline(); inc.write(emitter.translateType(retType, true)+" apply("); prefix = ""; for (Formal formal : n.formals()) { @@ -2905,6 +3011,17 @@ if (in_template_closure) emitter.printTemplateSignature(freeTypeParams, inc); + inc.write((in_template_closure ? "typename ": "")+superType+(in_template_closure ? "::template itable ": "::itable")+chevrons(cnamet)+ + cnamet+"::_itable(&"+cnamet+"::apply);"); + + if (in_template_closure) + emitter.printTemplateSignature(freeTypeParams, inc); + inc.write("x10aux::itable_entry "+cnamet+"::_itables[2] = {"); + inc.write("x10aux::itable_entry(&"+superType+"::rtt, &"+cnamet+"::_itable),"); + inc.write("x10aux::itable_entry(NULL, NULL)};"); inc.newline(); + + if (in_template_closure) + emitter.printTemplateSignature(freeTypeParams, inc); inc.write("x10aux::RuntimeType * "+cnamet+"::rtt = const_cast<x10aux::RuntimeType *>(x10aux::getRTT<"+superType+" >());"); inc.newline(); inc.forceNewline(); @@ -2940,7 +3057,7 @@ if (prefix.equals(",")) sb.append(">"); String templateArgs = sb.toString(); - sw.write(make_ref(superType)); + sw.write(make_ref(superType)+"("+make_ref(cnamet)); sw.write("(new (x10aux::alloc"+chevrons(superType)+"(sizeof("+cname+templateArgs+")))"); sw.write(cname+templateArgs+"("); for (int i = 0; i < c.variables.size(); i++) { @@ -2953,7 +3070,7 @@ name = SAVED_THIS; sw.write(name); } - sw.write("))"); + sw.write(")))"); c.finalizeClosureInstance(); emitter.exitClosure(c); @@ -3134,33 +3251,22 @@ return; } + sw.write("(__extension__ ({ x10aux::ref<x10::lang::Object> _ = "); c.printSubExpr(target, sw, tr); - sw.write("->"); - sw.write("apply"); - sw.write("("); + sw.write("; "+(mi.returnType().isVoid() ? "" : "x10aux::GXX_ICE_Workaround"+chevrons(emitter.translateType(mi.returnType(), true))+"::_")+"((_.get()->*(x10aux::findITable"+chevrons(emitter.translateType(target.type(), false))+"(_->_getITables())->apply))("); sw.begin(0); - /* TODO: TYPE PARAMETERS - for (Iterator<Type> i = mi.typeParameters().iterator(); i.hasNext(); ) { - final Type at = i.next(); - new RuntimeTypeExpander(at).expand(tr); - if (i.hasNext() || c.arguments().size() > 0) { - w.write(","); - w.allowBreak(0, " "); - } - } - */ List l = args; + boolean first = true; for (Iterator i = l.iterator(); i.hasNext(); ) { Expr e = (Expr) i.next(); + if (!first) sw.write(","); + sw.allowBreak(0, " "); c.print(e, sw, tr); - if (i.hasNext()) { - sw.write(","); - sw.allowBreak(0, " "); - } + first = false; } sw.end(); - sw.write(")"); + sw.write("));}))"); } Modified: trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/X10CPPTranslator.java =================================================================== --- trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/X10CPPTranslator.java 2009-07-22 21:56:53 UTC (rev 10846) +++ trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/X10CPPTranslator.java 2009-07-23 02:28:51 UTC (rev 10847) @@ -749,7 +749,7 @@ super.addPreArgs(cxxCmd); for (int i = 0; i < preArgsAIX.length; i++) { cxxCmd.add(preArgsAIX[i]); - } + } } protected void addPostArgs(ArrayList<String> cxxCmd) { Property changes on: trunk/x10.dist ___________________________________________________________________ Added: svn:mergeinfo + /branches/itable/x10.dist:10541-10846 Property changes on: trunk/x10.dist/INSTALL ___________________________________________________________________ Deleted: svn:mergeinfo - Property changes on: trunk/x10.dist/README ___________________________________________________________________ Deleted: svn:mergeinfo - Property changes on: trunk/x10.dist/RELEASE.NOTES ___________________________________________________________________ Deleted: svn:mergeinfo - Property changes on: trunk/x10.dist/bin/runx10 ___________________________________________________________________ Deleted: svn:mergeinfo - Property changes on: trunk/x10.dist/bin/x10c++ ___________________________________________________________________ Deleted: svn:mergeinfo - Property changes on: trunk/x10.dist/releng/makeTag.sh ___________________________________________________________________ Deleted: svn:mergeinfo - Property changes on: trunk/x10.dist/releng/packageCPPRelease.sh ___________________________________________________________________ Deleted: svn:mergeinfo - Property changes on: trunk/x10.runtime.17 ___________________________________________________________________ Added: svn:mergeinfo + /branches/itable/x10.runtime.17:10541-10846 Modified: trunk/x10.runtime.17/src-cpp/Makefile =================================================================== --- trunk/x10.runtim... [truncated message content] |
From: <dgr...@us...> - 2009-07-23 14:05:03
|
Revision: 10850 http://x10.svn.sourceforge.net/x10/?rev=10850&view=rev Author: dgrove-oss Date: 2009-07-23 14:04:58 +0000 (Thu, 23 Jul 2009) Log Message: ----------- finish cleanup work of itable branch reintegration. Property Changed: ---------------- trunk/SafeX10/ trunk/com.ibm.wala.cast.x10/ trunk/com.ibm.wala.cast.x10.tests/ trunk/jsr166-pd/ trunk/jsr166-pd/src/intro.html trunk/jsr166-pd/src/java/ trunk/jsr166-pd/src/readme trunk/x10.constraints/ trunk/x10.effects/ trunk/x10.me/ trunk/x10.sncode/ trunk/x10.tests/ trunk/x10.tests/examples/Benchmarks/SeqArray2a.x10 trunk/x10.tests/examples/Benchmarks/SeqMatMultAdd1a.java trunk/x10.tests/examples/Benchmarks/SeqMatMultAdd1a.x10 trunk/x10.tests/examples/Benchmarks/SeqMethodCall1.java trunk/x10.tests/examples/Benchmarks/SeqMethodCall1.x10 trunk/x10.tests/examples/Benchmarks/SeqPseudoArray1.java trunk/x10.tests/examples/Benchmarks/SeqRail1.x10 trunk/x10.tests/examples/Benchmarks/status.txt trunk/x10.tests/examples/Misc/BasicList.x10 Property changes on: trunk/SafeX10 ___________________________________________________________________ Added: svn:mergeinfo + /branches/itable/SafeX10:10541-10849 Property changes on: trunk/com.ibm.wala.cast.x10 ___________________________________________________________________ Added: svn:mergeinfo + /branches/itable/com.ibm.wala.cast.x10:10541-10849 Property changes on: trunk/com.ibm.wala.cast.x10.tests ___________________________________________________________________ Added: svn:mergeinfo + /branches/itable/com.ibm.wala.cast.x10.tests:10541-10849 Property changes on: trunk/jsr166-pd ___________________________________________________________________ Added: svn:mergeinfo + /branches/itable/jsr166-pd:10541-10849 Property changes on: trunk/jsr166-pd/src/intro.html ___________________________________________________________________ Deleted: svn:mergeinfo - Property changes on: trunk/jsr166-pd/src/java ___________________________________________________________________ Deleted: svn:mergeinfo - Property changes on: trunk/jsr166-pd/src/readme ___________________________________________________________________ Deleted: svn:mergeinfo - Property changes on: trunk/x10.constraints ___________________________________________________________________ Added: svn:mergeinfo + /branches/itable/x10.constraints:10541-10849 Property changes on: trunk/x10.effects ___________________________________________________________________ Added: svn:mergeinfo + /branches/itable/x10.effects:10541-10849 Property changes on: trunk/x10.me ___________________________________________________________________ Added: svn:mergeinfo + /branches/itable/x10.me:10541-10849 Property changes on: trunk/x10.sncode ___________________________________________________________________ Added: svn:mergeinfo + /branches/itable/x10.sncode:10541-10849 Property changes on: trunk/x10.tests ___________________________________________________________________ Added: svn:mergeinfo + /branches/itable/x10.tests:10541-10849 Property changes on: trunk/x10.tests/examples/Benchmarks/SeqArray2a.x10 ___________________________________________________________________ Deleted: svn:mergeinfo - Property changes on: trunk/x10.tests/examples/Benchmarks/SeqMatMultAdd1a.java ___________________________________________________________________ Deleted: svn:mergeinfo - Property changes on: trunk/x10.tests/examples/Benchmarks/SeqMatMultAdd1a.x10 ___________________________________________________________________ Deleted: svn:mergeinfo - Property changes on: trunk/x10.tests/examples/Benchmarks/SeqMethodCall1.java ___________________________________________________________________ Deleted: svn:mergeinfo - Property changes on: trunk/x10.tests/examples/Benchmarks/SeqMethodCall1.x10 ___________________________________________________________________ Deleted: svn:mergeinfo - Property changes on: trunk/x10.tests/examples/Benchmarks/SeqPseudoArray1.java ___________________________________________________________________ Deleted: svn:mergeinfo - Property changes on: trunk/x10.tests/examples/Benchmarks/SeqRail1.x10 ___________________________________________________________________ Deleted: svn:mergeinfo - Property changes on: trunk/x10.tests/examples/Benchmarks/status.txt ___________________________________________________________________ Deleted: svn:mergeinfo - Property changes on: trunk/x10.tests/examples/Misc/BasicList.x10 ___________________________________________________________________ Deleted: svn:mergeinfo - This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dgr...@us...> - 2009-07-23 15:22:01
|
Revision: 10853 http://x10.svn.sourceforge.net/x10/?rev=10853&view=rev Author: dgrove-oss Date: 2009-07-23 15:21:55 +0000 (Thu, 23 Jul 2009) Log Message: ----------- normalize svn properties. Modified Paths: -------------- trunk/SafeX10/src/ArraySum.x10 trunk/SafeX10/src/FRASimpleDist.x10 trunk/SafeX10/src/FSSimpleDist.x10 trunk/SafeX10/src/Hello.x10 trunk/SafeX10/src/HelloWorld.x10 trunk/SafeX10/src/Histogram.x10 trunk/SafeX10/src/Locations.x10 trunk/SafeX10/src/MontyPi.x10 trunk/SafeX10/src/MontyPi2.x10 trunk/SafeX10/src/NQueensPar.x10 trunk/SafeX10/src/Set.x10 trunk/SafeX10/src/Test.x10 trunk/SafeX10/src/Test2.x10 trunk/SafeX10/src/_.x10 trunk/SafeX10/src/fun.x10 trunk/SafeX10/src/parfun.x10 trunk/com.ibm.wala.cast.x10.tests/testSrc/ClockTest10.x10 trunk/com.ibm.wala.cast.x10.tests/testSrc/ClockTest11.x10 trunk/com.ibm.wala.cast.x10.tests/testSrc/ClockTest12.x10 trunk/com.ibm.wala.cast.x10.tests/testSrc/ClockTest13.x10 trunk/com.ibm.wala.cast.x10.tests/testSrc/ClockTest14.x10 trunk/com.ibm.wala.cast.x10.tests/testSrc/ClockTest15.x10 trunk/com.ibm.wala.cast.x10.tests/testSrc/ClockTest16.x10 trunk/com.ibm.wala.cast.x10.tests/testSrc/ClockTest2.x10 trunk/com.ibm.wala.cast.x10.tests/testSrc/ClockTest3.x10 trunk/com.ibm.wala.cast.x10.tests/testSrc/ClockTest4.x10 trunk/com.ibm.wala.cast.x10.tests/testSrc/ClockTest5.x10 trunk/com.ibm.wala.cast.x10.tests/testSrc/ClockTest6.x10 trunk/com.ibm.wala.cast.x10.tests/testSrc/ClockTest7_MustFailTimeout.x10 trunk/com.ibm.wala.cast.x10.tests/testSrc/ClockTest8_MustFailRun.x10 trunk/com.ibm.wala.cast.x10.tests/testSrc/ClockTest9.x10 trunk/x10.constraints/src/x10/constraint/XArray.java trunk/x10.constraints/src/x10/constraint/XArrayElement.java trunk/x10.constraints/src/x10/constraint/XArrayElement_c.java trunk/x10.constraints/src/x10/constraint/XArray_c.java trunk/x10.constraints/src/x10/constraint/XConstraintImp.java trunk/x10.constraints/src/x10/constraint/XDisEquals.java trunk/x10.constraints/src/x10/constraint/XDisEquals_c.java trunk/x10.constraints/src/x10/constraint/XMinus_c.java trunk/x10.constraints/src/x10/constraint/XMod_c.java trunk/x10.constraints/src/x10/constraint/XPlus_c.java trunk/x10.constraints/src/x10/constraint/XTermKind.java trunk/x10.constraints/stuff/x10/constraint/tests/CyclicTest.java trunk/x10.constraints/stuff/x10/constraint/tests/DisEqualsTests.java trunk/x10.constraints/stuff/x10/constraint/tests/EQVEntailmentTests.java trunk/x10.constraints/stuff/x10/constraint/tests/MyTest.java trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/debug/ClosureVariableMap.java trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/debug/StringTable.java trunk/x10.dist/samples/Histogram.x10 trunk/x10.dist/samples/MontyPi.x10 trunk/x10.dist/samples/NQueensDist.x10 trunk/x10.effects/src/x10/effects/constraints/ArrayElementLocs.java trunk/x10.effects/src/x10/effects/constraints/ArrayElementLocs_c.java trunk/x10.effects/src/x10/effects/constraints/ArrayLocs.java trunk/x10.effects/src/x10/effects/constraints/ArrayLocs_c.java trunk/x10.effects/src/x10/effects/constraints/Effect.java trunk/x10.effects/src/x10/effects/constraints/Effect_c.java trunk/x10.effects/src/x10/effects/constraints/Effects.java trunk/x10.effects/src/x10/effects/constraints/FieldLocs.java trunk/x10.effects/src/x10/effects/constraints/FieldLocs_c.java trunk/x10.effects/src/x10/effects/constraints/LocalLocs.java trunk/x10.effects/src/x10/effects/constraints/LocalLocs_c.java trunk/x10.effects/src/x10/effects/constraints/Locs.java trunk/x10.effects/src/x10/effects/constraints/Locs_c.java trunk/x10.effects/src/x10/effects/constraints/ObjLocs.java trunk/x10.effects/src/x10/effects/constraints/ObjLocs_c.java trunk/x10.effects/src/x10/effects/constraints/RigidTerm.java trunk/x10.effects/src/x10/effects/constraints/RigidTerm_c.java trunk/x10.effects/src/x10/effects/constraints/tests/AllTests.java trunk/x10.effects/src/x10/effects/constraints/tests/BaseTests.java trunk/x10.runtime.17/src-x10/x10/array/PlaceLocal.x10 Property Changed: ---------------- trunk/SafeX10/src/ArraySum.x10 trunk/SafeX10/src/Bug.x10 trunk/SafeX10/src/FRASimpleDist.x10 trunk/SafeX10/src/FSSimpleDist.x10 trunk/SafeX10/src/GCSpheres.x10 trunk/SafeX10/src/Hello.x10 trunk/SafeX10/src/HelloWorld.x10 trunk/SafeX10/src/Histogram.x10 trunk/SafeX10/src/KMeans.x10 trunk/SafeX10/src/KMeansDist.x10 trunk/SafeX10/src/Locations.x10 trunk/SafeX10/src/MontyPi.x10 trunk/SafeX10/src/MontyPi2.x10 trunk/SafeX10/src/NQueens.x10 trunk/SafeX10/src/NQueensPar.x10 trunk/SafeX10/src/Set.x10 trunk/SafeX10/src/Test.x10 trunk/SafeX10/src/Test2.x10 trunk/SafeX10/src/_.x10 trunk/SafeX10/src/fun.x10 trunk/SafeX10/src/parfun.x10 trunk/com.ibm.wala.cast.x10/src/com/ibm/wala/cast/x10/X10Plugin.java trunk/com.ibm.wala.cast.x10/src/com/ibm/wala/cast/x10/analysis/AnalysisJobExt.java trunk/com.ibm.wala.cast.x10/src/com/ibm/wala/cast/x10/analysis/AsyncAnalysisGoal.java trunk/com.ibm.wala.cast.x10/src/com/ibm/wala/cast/x10/analysis/AsyncAnalysisPass.java trunk/com.ibm.wala.cast.x10/src/com/ibm/wala/cast/x10/analysis/X10EclipseProjectPath.java trunk/com.ibm.wala.cast.x10/src/com/ibm/wala/cast/x10/analysis/typeInference/AstX10TypeInference.java trunk/com.ibm.wala.cast.x10/src/com/ibm/wala/cast/x10/client/X10EclipseSourceAnalysisEngine.java trunk/com.ibm.wala.cast.x10/src/com/ibm/wala/cast/x10/client/X10SourceAnalysisEngine.java trunk/com.ibm.wala.cast.x10/src/com/ibm/wala/cast/x10/client/X10ZeroXCFACallGraphBuilderFactory.java trunk/com.ibm.wala.cast.x10/src/com/ibm/wala/cast/x10/ipa/callgraph/X10CFABuilder.java trunk/com.ibm.wala.cast.x10/src/com/ibm/wala/cast/x10/ipa/callgraph/X10SSAPropagationCallGraphBuilder.java trunk/com.ibm.wala.cast.x10/src/com/ibm/wala/cast/x10/ipa/callgraph/X10ScopeMappingInstanceKeys.java trunk/com.ibm.wala.cast.x10/src/com/ibm/wala/cast/x10/ipa/callgraph/X10ZeroXCFABuilder.java trunk/com.ibm.wala.cast.x10/src/com/ibm/wala/cast/x10/loader/X10AnalysisScope.java trunk/com.ibm.wala.cast.x10/src/com/ibm/wala/cast/x10/loader/X10Language.java trunk/com.ibm.wala.cast.x10/src/com/ibm/wala/cast/x10/loader/X10PrimordialClassLoader.java trunk/com.ibm.wala.cast.x10/src/com/ibm/wala/cast/x10/ssa/AstX10InstructionVisitor.java trunk/com.ibm.wala.cast.x10/src/com/ibm/wala/cast/x10/ssa/AsyncCallSiteReference.java trunk/com.ibm.wala.cast.x10/src/com/ibm/wala/cast/x10/ssa/AsyncInvokeInstruction.java trunk/com.ibm.wala.cast.x10/src/com/ibm/wala/cast/x10/ssa/SSAAtomicInstruction.java trunk/com.ibm.wala.cast.x10/src/com/ibm/wala/cast/x10/ssa/SSAFinishInstruction.java trunk/com.ibm.wala.cast.x10/src/com/ibm/wala/cast/x10/ssa/SSAForceInstruction.java trunk/com.ibm.wala.cast.x10/src/com/ibm/wala/cast/x10/ssa/SSAHereInstruction.java trunk/com.ibm.wala.cast.x10/src/com/ibm/wala/cast/x10/ssa/SSAPlaceOfPointInstruction.java trunk/com.ibm.wala.cast.x10/src/com/ibm/wala/cast/x10/ssa/SSARegionIterHasNextInstruction.java trunk/com.ibm.wala.cast.x10/src/com/ibm/wala/cast/x10/ssa/SSARegionIterInitInstruction.java trunk/com.ibm.wala.cast.x10/src/com/ibm/wala/cast/x10/ssa/SSARegionIterNextInstruction.java trunk/com.ibm.wala.cast.x10/src/com/ibm/wala/cast/x10/ssa/X10ArrayLoadByIndexInstruction.java trunk/com.ibm.wala.cast.x10/src/com/ibm/wala/cast/x10/ssa/X10ArrayLoadByPointInstruction.java trunk/com.ibm.wala.cast.x10/src/com/ibm/wala/cast/x10/ssa/X10ArrayReferenceByIndexInstruction.java trunk/com.ibm.wala.cast.x10/src/com/ibm/wala/cast/x10/ssa/X10ArrayReferenceByPointInstruction.java trunk/com.ibm.wala.cast.x10/src/com/ibm/wala/cast/x10/ssa/X10ArrayReferenceInstruction.java trunk/com.ibm.wala.cast.x10/src/com/ibm/wala/cast/x10/ssa/X10ArrayStoreByIndexInstruction.java trunk/com.ibm.wala.cast.x10/src/com/ibm/wala/cast/x10/ssa/X10ArrayStoreByPointInstruction.java trunk/com.ibm.wala.cast.x10/src/com/ibm/wala/cast/x10/ssa/X10InstructionFactory.java trunk/com.ibm.wala.cast.x10/src/com/ibm/wala/cast/x10/translator/FilteredPolyglotSourceModuleTranslator.java trunk/com.ibm.wala.cast.x10/src/com/ibm/wala/cast/x10/translator/JavaFilteredSourceLoaderImpl.java trunk/com.ibm.wala.cast.x10/src/com/ibm/wala/cast/x10/translator/X10CAstEntity.java trunk/com.ibm.wala.cast.x10/src/com/ibm/wala/cast/x10/translator/X10CAstPrinter.java trunk/com.ibm.wala.cast.x10/src/com/ibm/wala/cast/x10/translator/X10CAstQualifier.java trunk/com.ibm.wala.cast.x10/src/com/ibm/wala/cast/x10/translator/X10CastNode.java trunk/com.ibm.wala.cast.x10/src/com/ibm/wala/cast/x10/translator/X10ToIRTranslator.java trunk/com.ibm.wala.cast.x10/src/com/ibm/wala/cast/x10/translator/polyglot/CAstDumpedGoal.java trunk/com.ibm.wala.cast.x10/src/com/ibm/wala/cast/x10/translator/polyglot/CAstDumperPass.java trunk/com.ibm.wala.cast.x10/src/com/ibm/wala/cast/x10/translator/polyglot/WALAScheduler.java trunk/com.ibm.wala.cast.x10/src/com/ibm/wala/cast/x10/translator/polyglot/X10ASTTraverser.java trunk/com.ibm.wala.cast.x10/src/com/ibm/wala/cast/x10/translator/polyglot/X10AnalysisExtension.java trunk/com.ibm.wala.cast.x10/src/com/ibm/wala/cast/x10/translator/polyglot/X10AsyncObject.java trunk/com.ibm.wala.cast.x10/src/com/ibm/wala/cast/x10/translator/polyglot/X10CASTGoal.java trunk/com.ibm.wala.cast.x10/src/com/ibm/wala/cast/x10/translator/polyglot/X10CASTPass.java trunk/com.ibm.wala.cast.x10/src/com/ibm/wala/cast/x10/translator/polyglot/X10CAst2IRTranslator.java trunk/com.ibm.wala.cast.x10/src/com/ibm/wala/cast/x10/translator/polyglot/X10ClassLoaderFactory.java trunk/com.ibm.wala.cast.x10/src/com/ibm/wala/cast/x10/translator/polyglot/X10ClosureObject.java trunk/com.ibm.wala.cast.x10/src/com/ibm/wala/cast/x10/translator/polyglot/X10ExtensionInfo.java trunk/com.ibm.wala.cast.x10/src/com/ibm/wala/cast/x10/translator/polyglot/X10IRGoal.java trunk/com.ibm.wala.cast.x10/src/com/ibm/wala/cast/x10/translator/polyglot/X10IRPass.java trunk/com.ibm.wala.cast.x10/src/com/ibm/wala/cast/x10/translator/polyglot/X10IRTranslatorExtension.java trunk/com.ibm.wala.cast.x10/src/com/ibm/wala/cast/x10/translator/polyglot/X10PolyglotIdentityMapper.java trunk/com.ibm.wala.cast.x10/src/com/ibm/wala/cast/x10/translator/polyglot/X10SourceLoaderImpl.java trunk/com.ibm.wala.cast.x10/src/com/ibm/wala/cast/x10/translator/polyglot/X10TranslatorVisitor.java trunk/com.ibm.wala.cast.x10/src/com/ibm/wala/cast/x10/translator/polyglot/X10TypeDictionary.java trunk/com.ibm.wala.cast.x10/src/com/ibm/wala/cast/x10/translator/polyglot/X10WALAScheduler.java trunk/com.ibm.wala.cast.x10/src/com/ibm/wala/cast/x10/translator/polyglot/X10toCAstTranslator.java trunk/com.ibm.wala.cast.x10/src/com/ibm/wala/cast/x10/types/X10TypeReference.java trunk/com.ibm.wala.cast.x10/src/com/ibm/wala/cast/x10/visit/X10CAstVisitor.java trunk/com.ibm.wala.cast.x10.tests/src/com/ibm/wala/cast/x10/tests/AnalysisTests.java trunk/com.ibm.wala.cast.x10.tests/src/com/ibm/wala/cast/x10/tests/X10IRTests.java trunk/com.ibm.wala.cast.x10.tests/src/com/ibm/wala/cast/x10/tests/X10StaAnIRTests.java trunk/com.ibm.wala.cast.x10.tests/src/com/ibm/wala/cast/x10/tests/X10StaAnPrinter.java trunk/com.ibm.wala.cast.x10.tests/src/com/ibm/wala/cast/x10/tests/X10Tests.java trunk/com.ibm.wala.cast.x10.tests/testSrc/ArrayAccess1.x10 trunk/com.ibm.wala.cast.x10.tests/testSrc/ArrayAccess2D.x10 trunk/com.ibm.wala.cast.x10.tests/testSrc/ArrayAccess3D.x10 trunk/com.ibm.wala.cast.x10.tests/testSrc/ArrayCtor1.x10 trunk/com.ibm.wala.cast.x10.tests/testSrc/ArrayUpdate2D.x10 trunk/com.ibm.wala.cast.x10.tests/testSrc/Async1.x10 trunk/com.ibm.wala.cast.x10.tests/testSrc/AsyncInvoke.x10 trunk/com.ibm.wala.cast.x10.tests/testSrc/AtEach1.x10 trunk/com.ibm.wala.cast.x10.tests/testSrc/Clock.x10 trunk/com.ibm.wala.cast.x10.tests/testSrc/ClockAllReductionBarrier.x10 trunk/com.ibm.wala.cast.x10.tests/testSrc/ClockEdmiston.x10 trunk/com.ibm.wala.cast.x10.tests/testSrc/ClockFFTDist.x10 trunk/com.ibm.wala.cast.x10.tests/testSrc/ClockJGFMolDynBenchSizeA.x10 trunk/com.ibm.wala.cast.x10.tests/testSrc/ClockKernel.x10 trunk/com.ibm.wala.cast.x10.tests/testSrc/ClockLUOverlap.x10 trunk/com.ibm.wala.cast.x10.tests/testSrc/ClockLinearSearch.x10 trunk/com.ibm.wala.cast.x10.tests/testSrc/ClockMatrixAdd.x10 trunk/com.ibm.wala.cast.x10.tests/testSrc/ClockPascalTriangle.x10 trunk/com.ibm.wala.cast.x10.tests/testSrc/ClockPipeline.x10 trunk/com.ibm.wala.cast.x10.tests/testSrc/ClockProducerConsumer.x10 trunk/com.ibm.wala.cast.x10.tests/testSrc/ClockQueensList.x10 trunk/com.ibm.wala.cast.x10.tests/testSrc/ClockSieve.x10 trunk/com.ibm.wala.cast.x10.tests/testSrc/ClockSimplePipeline.x10 trunk/com.ibm.wala.cast.x10.tests/testSrc/ClockTest1.x10 trunk/com.ibm.wala.cast.x10.tests/testSrc/ClockTest10.x10 trunk/com.ibm.wala.cast.x10.tests/testSrc/ClockTest11.x10 trunk/com.ibm.wala.cast.x10.tests/testSrc/ClockTest12.x10 trunk/com.ibm.wala.cast.x10.tests/testSrc/ClockTest13.x10 trunk/com.ibm.wala.cast.x10.tests/testSrc/ClockTest14.x10 trunk/com.ibm.wala.cast.x10.tests/testSrc/ClockTest15.x10 trunk/com.ibm.wala.cast.x10.tests/testSrc/ClockTest16.x10 trunk/com.ibm.wala.cast.x10.tests/testSrc/ClockTest2.x10 trunk/com.ibm.wala.cast.x10.tests/testSrc/ClockTest3.x10 trunk/com.ibm.wala.cast.x10.tests/testSrc/ClockTest4.x10 trunk/com.ibm.wala.cast.x10.tests/testSrc/ClockTest5.x10 trunk/com.ibm.wala.cast.x10.tests/testSrc/ClockTest6.x10 trunk/com.ibm.wala.cast.x10.tests/testSrc/ClockTest7_MustFailTimeout.x10 trunk/com.ibm.wala.cast.x10.tests/testSrc/ClockTest8_MustFailRun.x10 trunk/com.ibm.wala.cast.x10.tests/testSrc/ClockTest9.x10 trunk/com.ibm.wala.cast.x10.tests/testSrc/ClockTree.x10 trunk/com.ibm.wala.cast.x10.tests/testSrc/Finish1.x10 trunk/com.ibm.wala.cast.x10.tests/testSrc/Foo.x10 trunk/com.ibm.wala.cast.x10.tests/testSrc/For1.x10 trunk/com.ibm.wala.cast.x10.tests/testSrc/ForEach1.x10 trunk/com.ibm.wala.cast.x10.tests/testSrc/Future1.x10 trunk/com.ibm.wala.cast.x10.tests/testSrc/Places.x10 trunk/com.ibm.wala.cast.x10.tests/testSrc/When1.x10 trunk/com.ibm.wala.cast.x10.tests/testSrc/p/HashTable.x10 trunk/com.ibm.wala.cast.x10.tests/testSrc/x10ForLoopBreakTest.x10 trunk/x10.common.17/contrib/ant/Ejc.java trunk/x10.compiler.p3/src/polyglot/ext/x10/ast/AmbMacroTypeNode.java trunk/x10.compiler.p3/src/polyglot/ext/x10/ast/AmbMacroTypeNode_c.java trunk/x10.compiler.p3/src/polyglot/ext/x10/ast/AtExpr.java trunk/x10.compiler.p3/src/polyglot/ext/x10/ast/AtExpr_c.java trunk/x10.compiler.p3/src/polyglot/ext/x10/ast/AtStmt.java trunk/x10.compiler.p3/src/polyglot/ext/x10/ast/AtStmt_c.java trunk/x10.compiler.p3/src/polyglot/ext/x10/ast/X10Boxed_c.java trunk/x10.compiler.p3/src/polyglot/ext/x10/ast/X10FieldAssign_c.java trunk/x10.compiler.p3/src/polyglot/ext/x10/ast/X10Initializer_c.java trunk/x10.compiler.p3/src/polyglot/ext/x10/ast/X10ProcedureCall.java trunk/x10.compiler.p3/src/polyglot/ext/x10/types/Subst.java trunk/x10.compiler.p3/src/polyglot/ext/x10/types/SubtypeConstraint.java trunk/x10.compiler.p3/src/polyglot/ext/x10/types/SubtypeConstraint_c.java trunk/x10.compiler.p3/src/polyglot/ext/x10/types/TypeConstraint.java trunk/x10.compiler.p3/src/polyglot/ext/x10/types/TypeConstraint_c.java trunk/x10.compiler.p3/src/polyglot/ext/x10/types/X10InitializerDef.java trunk/x10.compiler.p3/src/polyglot/ext/x10/types/X10InitializerDef_c.java trunk/x10.compiler.p3/src/polyglot/ext/x10/types/X10MemberDef.java trunk/x10.compiler.p3/src/polyglot/ext/x10/types/X10TypeEnv.java trunk/x10.compiler.p3/src/polyglot/ext/x10/types/X10TypeEnv_c.java trunk/x10.compiler.p3/src/polyglot/ext/x10/types/X10XLocal_c.java trunk/x10.compiler.p3/src/polyglot/ext/x10/visit/ConstantPropagator.java trunk/x10.compiler.p3/src/polyglot/ext/x10/visit/Desugarer.java trunk/x10.compiler.p3/src/polyglot/ext/x10/visit/FieldInitializerMover.java trunk/x10.compiler.p3/src/polyglot/ext/x10/visit/Inliner.java trunk/x10.compiler.p3/src/polyglot/ext/x10/visit/StaticNestedClassRemover.java trunk/x10.compiler.p3/src/polyglot/ext/x10/visit/X10Caster.java trunk/x10.compiler.p3/stuff/polyglot/ext/x10/dom/DomGenerator.java trunk/x10.compiler.p3/stuff/polyglot/ext/x10/dom/DomParser.java trunk/x10.compiler.p3/stuff/polyglot/ext/x10/dom/DomReader.java trunk/x10.compiler.p3/stuff/polyglot/ext/x10/dom/ExternalizerPlugin.java trunk/x10.compiler.p3/stuff/polyglot/ext/x10/dom/X10Dom.java trunk/x10.compiler.p3/stuff/polyglot/ext/x10/dom/X10MLClassInitializer.java trunk/x10.compiler.p3/stuff/polyglot/ext/x10/dom/XMLReader.java trunk/x10.compiler.p3/stuff/polyglot/ext/x10/dom/XMLWriter.java trunk/x10.compiler.p3/stuff/polyglot/ext/x10/plugin/SimpleOnePassPlugin.java trunk/x10.compiler.p3/stuff/polyglot/ext/x10/plugin/SimplePlugin.java trunk/x10.compiler.p3/stuff/polyglot/ext/x10/plugin/SimpleTypeAnnotationPlugin.java trunk/x10.compiler.p3/stuff/polyglot/ext/x10/plugin/SimpleVisitorPlugin.java trunk/x10.compiler.p3/stuff/polyglot/ext/x10/visit/PropagateAnnotationsVisitor.java trunk/x10.compiler.p3/stuff/polyglot/ext/x10/visit/PropagateDependentAnnotationsVisitor.java trunk/x10.constraints/src/x10/constraint/XArray.java trunk/x10.constraints/src/x10/constraint/XArrayElement.java trunk/x10.constraints/src/x10/constraint/XArrayElement_c.java trunk/x10.constraints/src/x10/constraint/XArray_c.java trunk/x10.constraints/src/x10/constraint/XConstraintImp.java trunk/x10.constraints/src/x10/constraint/XDisEquals.java trunk/x10.constraints/src/x10/constraint/XDisEquals_c.java trunk/x10.constraints/src/x10/constraint/XMinus_c.java trunk/x10.constraints/src/x10/constraint/XMod_c.java trunk/x10.constraints/src/x10/constraint/XPlus_c.java trunk/x10.constraints/src/x10/constraint/XSubst_c.java trunk/x10.constraints/src/x10/constraint/XTermKind.java trunk/x10.constraints/stuff/x10/constraint/tests/AllTests.java trunk/x10.constraints/stuff/x10/constraint/tests/CyclicTest.java trunk/x10.constraints/stuff/x10/constraint/tests/DisEqualsTests.java trunk/x10.constraints/stuff/x10/constraint/tests/EQVEntailmentTests.java trunk/x10.constraints/stuff/x10/constraint/tests/EntailmentTest.java trunk/x10.constraints/stuff/x10/constraint/tests/FormulaTest.java trunk/x10.constraints/stuff/x10/constraint/tests/MyTest.java trunk/x10.constraints/stuff/x10/constraint/tests/Pair.java trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/debug/ClosureVariableMap.java trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/debug/LineNumberMap.java trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/debug/StringTable.java trunk/x10.cppbackend.17/src/polyglot/ext/x10cuda/ExtensionInfo.java trunk/x10.cppbackend.17/src/polyglot/ext/x10cuda/ast/X10CUDADelFactory_c.java trunk/x10.cppbackend.17/src/polyglot/ext/x10cuda/types/X10CUDAContext_c.java trunk/x10.cppbackend.17/src/polyglot/ext/x10cuda/types/X10CUDATypeSystem_c.java trunk/x10.cppbackend.17/src/polyglot/ext/x10cuda/visit/CUDACodeGenerator.java trunk/x10.dist/samples/GCSpheres.x10 trunk/x10.dist/samples/Hello.x10 trunk/x10.dist/samples/Histogram.x10 trunk/x10.dist/samples/KMeans.x10 trunk/x10.dist/samples/KMeansDist.x10 trunk/x10.dist/samples/KMeansSPMD.x10 trunk/x10.dist/samples/MontyPi.x10 trunk/x10.dist/samples/NQueensDist.x10 trunk/x10.effects/src/x10/effects/constraints/ArrayElementLocs.java trunk/x10.effects/src/x10/effects/constraints/ArrayElementLocs_c.java trunk/x10.effects/src/x10/effects/constraints/ArrayLocs.java trunk/x10.effects/src/x10/effects/constraints/ArrayLocs_c.java trunk/x10.effects/src/x10/effects/constraints/Effect.java trunk/x10.effects/src/x10/effects/constraints/Effect_c.java trunk/x10.effects/src/x10/effects/constraints/Effects.java trunk/x10.effects/src/x10/effects/constraints/FieldLocs.java trunk/x10.effects/src/x10/effects/constraints/FieldLocs_c.java trunk/x10.effects/src/x10/effects/constraints/LocalLocs.java trunk/x10.effects/src/x10/effects/constraints/LocalLocs_c.java trunk/x10.effects/src/x10/effects/constraints/Locs.java trunk/x10.effects/src/x10/effects/constraints/Locs_c.java trunk/x10.effects/src/x10/effects/constraints/ObjLocs.java trunk/x10.effects/src/x10/effects/constraints/ObjLocs_c.java trunk/x10.effects/src/x10/effects/constraints/RigidTerm.java trunk/x10.effects/src/x10/effects/constraints/RigidTerm_c.java trunk/x10.effects/src/x10/effects/constraints/tests/AllTests.java trunk/x10.effects/src/x10/effects/constraints/tests/BaseTests.java trunk/x10.runtime.17/src-cpp/x10/io/FileReader__FileInputStream.cc trunk/x10.runtime.17/src-cpp/x10/io/FileReader__FileInputStream.h trunk/x10.runtime.17/src-cpp/x10/io/FileWriter__FileOutputStream.cc trunk/x10.runtime.17/src-cpp/x10/io/FileWriter__FileOutputStream.h trunk/x10.runtime.17/src-cpp/x10/io/File__NativeFile.cc trunk/x10.runtime.17/src-cpp/x10/io/File__NativeFile.h trunk/x10.runtime.17/src-cpp/x10/io/OutputStreamWriter__OutputStream.cc trunk/x10.runtime.17/src-cpp/x10/io/OutputStreamWriter__OutputStream.h trunk/x10.runtime.17/src-cpp/x10/lang/Box.h trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_0.h trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_1.h trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_2.h trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_3.h trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_4.h trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_5.h trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_6.h trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_7.h trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_8.h trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_9.h trunk/x10.runtime.17/src-cpp/x10/lang/Object.cc trunk/x10.runtime.17/src-cpp/x10/lang/Object.h trunk/x10.runtime.17/src-cpp/x10/lang/Rail.h trunk/x10.runtime.17/src-cpp/x10/lang/Ref.cc trunk/x10.runtime.17/src-cpp/x10/lang/Ref.h trunk/x10.runtime.17/src-cpp/x10/lang/String.cc trunk/x10.runtime.17/src-cpp/x10/lang/String.h trunk/x10.runtime.17/src-cpp/x10/lang/Throwable.cc trunk/x10.runtime.17/src-cpp/x10/lang/Throwable.h trunk/x10.runtime.17/src-cpp/x10/lang/ValRail.h trunk/x10.runtime.17/src-cpp/x10/lang/Value.cc trunk/x10.runtime.17/src-cpp/x10/lang/Value.h trunk/x10.runtime.17/src-cpp/x10/lang/VoidFun_0_0.h trunk/x10.runtime.17/src-cpp/x10/lang/VoidFun_0_1.h trunk/x10.runtime.17/src-cpp/x10/lang/VoidFun_0_2.h trunk/x10.runtime.17/src-cpp/x10/lang/VoidFun_0_3.h trunk/x10.runtime.17/src-cpp/x10/lang/VoidFun_0_4.h trunk/x10.runtime.17/src-cpp/x10/lang/VoidFun_0_5.h trunk/x10.runtime.17/src-cpp/x10/lang/VoidFun_0_6.h trunk/x10.runtime.17/src-cpp/x10/lang/VoidFun_0_7.h trunk/x10.runtime.17/src-cpp/x10/lang/VoidFun_0_8.h trunk/x10.runtime.17/src-cpp/x10/lang/VoidFun_0_9.h trunk/x10.runtime.17/src-cpp/x10aux/RTT.cc trunk/x10.runtime.17/src-cpp/x10aux/RTT.h trunk/x10.runtime.17/src-cpp/x10aux/alloc.cc trunk/x10.runtime.17/src-cpp/x10aux/alloc.h trunk/x10.runtime.17/src-cpp/x10aux/assert.cc trunk/x10.runtime.17/src-cpp/x10aux/assert.h trunk/x10.runtime.17/src-cpp/x10aux/basic_functions.cc trunk/x10.runtime.17/src-cpp/x10aux/basic_functions.h trunk/x10.runtime.17/src-cpp/x10aux/bootstrap.cc trunk/x10.runtime.17/src-cpp/x10aux/bootstrap.h trunk/x10.runtime.17/src-cpp/x10aux/class_cast.h trunk/x10.runtime.17/src-cpp/x10aux/config.cc trunk/x10.runtime.17/src-cpp/x10aux/config.h trunk/x10.runtime.17/src-cpp/x10aux/cuda/bridge_buffer.h trunk/x10.runtime.17/src-cpp/x10aux/cuda/cuda_utils.cc trunk/x10.runtime.17/src-cpp/x10aux/cuda/cuda_utils.h trunk/x10.runtime.17/src-cpp/x10aux/cuda/ring_buffer.h trunk/x10.runtime.17/src-cpp/x10aux/deserialization_dispatcher.cc trunk/x10.runtime.17/src-cpp/x10aux/deserialization_dispatcher.h trunk/x10.runtime.17/src-cpp/x10aux/hash.h trunk/x10.runtime.17/src-cpp/x10aux/init_dispatcher.cc trunk/x10.runtime.17/src-cpp/x10aux/init_dispatcher.h trunk/x10.runtime.17/src-cpp/x10aux/io/FILEPtrInputStream.cc trunk/x10.runtime.17/src-cpp/x10aux/io/FILEPtrInputStream.h trunk/x10.runtime.17/src-cpp/x10aux/io/FILEPtrOutputStream.cc trunk/x10.runtime.17/src-cpp/x10aux/io/FILEPtrOutputStream.h trunk/x10.runtime.17/src-cpp/x10aux/io/FILEPtrStream.cc trunk/x10.runtime.17/src-cpp/x10aux/io/FILEPtrStream.h trunk/x10.runtime.17/src-cpp/x10aux/math.h trunk/x10.runtime.17/src-cpp/x10aux/pgas.cc trunk/x10.runtime.17/src-cpp/x10aux/pgas.h trunk/x10.runtime.17/src-cpp/x10aux/rail_utils.cc trunk/x10.runtime.17/src-cpp/x10aux/rail_utils.h trunk/x10.runtime.17/src-cpp/x10aux/ref.h trunk/x10.runtime.17/src-cpp/x10aux/reference_logger.cc trunk/x10.runtime.17/src-cpp/x10aux/reference_logger.h trunk/x10.runtime.17/src-cpp/x10aux/serialization.h trunk/x10.runtime.17/src-cpp/x10aux/string_utils.cc trunk/x10.runtime.17/src-cpp/x10aux/string_utils.h trunk/x10.runtime.17/src-cpp/x10aux/throw.h trunk/x10.runtime.17/src-cpp/x10rt17.h trunk/x10.runtime.17/src-java/x10/core/BoxInt.java trunk/x10.runtime.17/src-java/x10/core/BoxedBoolean.java trunk/x10.runtime.17/src-java/x10/core/BoxedByte.java trunk/x10.runtime.17/src-java/x10/core/BoxedChar.java trunk/x10.runtime.17/src-java/x10/core/BoxedDouble.java trunk/x10.runtime.17/src-java/x10/core/BoxedFloat.java trunk/x10.runtime.17/src-java/x10/core/BoxedInt.java trunk/x10.runtime.17/src-java/x10/core/BoxedLong.java trunk/x10.runtime.17/src-java/x10/core/BoxedShort.java trunk/x10.runtime.17/src-java/x10/core/BoxedString.java trunk/x10.runtime.17/src-java/x10/core/GrowableRail.java trunk/x10.runtime.17/src-java/x10/core/Iterable.java trunk/x10.runtime.17/src-java/x10/core/Iterator.java trunk/x10.runtime.17/src-java/x10/core/RailIterator.java trunk/x10.runtime.17/src-java/x10/core/ThrowableUtilities.java trunk/x10.runtime.17/src-java/x10/core/Unsigned.java trunk/x10.runtime.17/src-java/x10/core/fun/Fun_0_4.java trunk/x10.runtime.17/src-java/x10/core/fun/Fun_0_5.java trunk/x10.runtime.17/src-java/x10/core/fun/Fun_0_6.java trunk/x10.runtime.17/src-java/x10/core/fun/Fun_0_7.java trunk/x10.runtime.17/src-java/x10/core/fun/Fun_0_8.java trunk/x10.runtime.17/src-java/x10/core/fun/Fun_0_9.java trunk/x10.runtime.17/src-java/x10/core/fun/VoidFun_0_4.java trunk/x10.runtime.17/src-java/x10/core/fun/VoidFun_0_5.java trunk/x10.runtime.17/src-java/x10/core/fun/VoidFun_0_6.java trunk/x10.runtime.17/src-java/x10/core/fun/VoidFun_0_7.java trunk/x10.runtime.17/src-java/x10/core/fun/VoidFun_0_8.java trunk/x10.runtime.17/src-java/x10/core/fun/VoidFun_0_9.java trunk/x10.runtime.17/src-java/x10/runtime/impl/java/Configuration.java trunk/x10.runtime.17/src-java/x10/runtime/impl/java/JavaRuntime.java trunk/x10.runtime.17/src-java/x10/runtime/impl/java/PreLoader.java trunk/x10.runtime.17/src-java/x10/runtime/impl/java/Report.java trunk/x10.runtime.17/src-java/x10/runtime/impl/java/Runtime.java trunk/x10.runtime.17/src-java/x10/runtime/impl/java/Thread.java trunk/x10.runtime.17/src-java/x10/runtime/impl/java/Usage.java trunk/x10.runtime.17/src-java/x10/runtime/impl/java/VMInterface.java trunk/x10.runtime.17/src-java/x10/types/UByteType.java trunk/x10.runtime.17/src-java/x10/types/UIntType.java trunk/x10.runtime.17/src-java/x10/types/ULongType.java trunk/x10.runtime.17/src-java/x10/types/UShortType.java trunk/x10.runtime.17/src-x10/Dummy.x10 trunk/x10.runtime.17/src-x10/x10/array/FastArray.x10 trunk/x10.runtime.17/src-x10/x10/array/Mat.x10 trunk/x10.runtime.17/src-x10/x10/array/MatBuilder.x10 trunk/x10.runtime.17/src-x10/x10/array/PlaceLocal.x10 trunk/x10.runtime.17/src-x10/x10/array/PolyMatBuilder.x10 trunk/x10.runtime.17/src-x10/x10/array/PolyXform.x10 trunk/x10.runtime.17/src-x10/x10/array/Row.x10 trunk/x10.runtime.17/src-x10/x10/array/ValRow.x10 trunk/x10.runtime.17/src-x10/x10/array/VarMat.x10 trunk/x10.runtime.17/src-x10/x10/array/VarRow.x10 trunk/x10.runtime.17/src-x10/x10/array/Xform.x10 trunk/x10.runtime.17/src-x10/x10/array/XformMat.x10 trunk/x10.runtime.17/src-x10/x10/compiler/Cuda.x10 trunk/x10.runtime.17/src-x10/x10/compiler/Inline.x10 trunk/x10.runtime.17/src-x10/x10/io/ByteRailWriter.x10 trunk/x10.runtime.17/src-x10/x10/io/ByteValRailWriter.x10 trunk/x10.runtime.17/src-x10/x10/io/ByteWriter.x10 trunk/x10.runtime.17/src-x10/x10/io/Console.x10 trunk/x10.runtime.17/src-x10/x10/io/EOFException.x10 trunk/x10.runtime.17/src-x10/x10/io/File.x10 trunk/x10.runtime.17/src-x10/x10/io/FileNotFoundException.x10 trunk/x10.runtime.17/src-x10/x10/io/FileReader.x10 trunk/x10.runtime.17/src-x10/x10/io/FileSystem.x10 trunk/x10.runtime.17/src-x10/x10/io/FileWriter.x10 trunk/x10.runtime.17/src-x10/x10/io/FilterReader.x10 trunk/x10.runtime.17/src-x10/x10/io/FilterWriter.x10 trunk/x10.runtime.17/src-x10/x10/io/IORuntimeException.x10 trunk/x10.runtime.17/src-x10/x10/io/InputStreamReader.x10 trunk/x10.runtime.17/src-x10/x10/io/Marshal.x10 trunk/x10.runtime.17/src-x10/x10/io/OutputStreamWriter.x10 trunk/x10.runtime.17/src-x10/x10/io/Printer.x10 trunk/x10.runtime.17/src-x10/x10/io/PutbackReader.x10 trunk/x10.runtime.17/src-x10/x10/io/Readable.x10 trunk/x10.runtime.17/src-x10/x10/io/Reader.x10 trunk/x10.runtime.17/src-x10/x10/io/ReaderIterator.x10 trunk/x10.runtime.17/src-x10/x10/io/StringWriter.x10 trunk/x10.runtime.17/src-x10/x10/io/Writable.x10 trunk/x10.runtime.17/src-x10/x10/io/Writer.x10 trunk/x10.runtime.17/src-x10/x10/lang/Box.x10 trunk/x10.runtime.17/src-x10/x10/lang/Equals.x10 trunk/x10.runtime.17/src-x10/x10/lang/OutOfMemoryError.x10 trunk/x10.runtime.17/src-x10/x10/lang/UByte.x10 trunk/x10.runtime.17/src-x10/x10/lang/UInt.x10 trunk/x10.runtime.17/src-x10/x10/lang/ULong.x10 trunk/x10.runtime.17/src-x10/x10/lang/UShort.x10 trunk/x10.runtime.17/src-x10/x10/runtime/Clock_c.x10 trunk/x10.runtime.17/src-x10/x10/runtime/Monitor.x10 trunk/x10.runtime.17/src-x10/x10/runtime/Pool.x10 trunk/x10.runtime.17/src-x10/x10/runtime/Runtime.x10 trunk/x10.runtime.17/src-x10/x10/runtime/Semaphore.x10 trunk/x10.runtime.17/src-x10/x10/runtime/Worker.x10 trunk/x10.runtime.17/src-x10/x10/util/AbstractCollection.x10 trunk/x10.runtime.17/src-x10/x10/util/AbstractContainer.x10 trunk/x10.runtime.17/src-x10/x10/util/Builder.x10 trunk/x10.runtime.17/src-x10/x10/util/Collection.x10 trunk/x10.runtime.17/src-x10/x10/util/CollectionIterator.x10 trunk/x10.runtime.17/src-x10/x10/util/Container.x10 trunk/x10.runtime.17/src-x10/x10/util/GrowableRail.x10 trunk/x10.runtime.17/src-x10/x10/util/HashSet.x10 trunk/x10.runtime.17/src-x10/x10/util/Indexed.x10 trunk/x10.runtime.17/src-x10/x10/util/ListIterator.x10 trunk/x10.runtime.17/src-x10/x10/util/MapIterator.x10 trunk/x10.runtime.17/src-x10/x10/util/MapSet.x10 trunk/x10.runtime.17/src-x10/x10/util/NoSuchElementException.x10 trunk/x10.runtime.17/src-x10/x10/util/RailBuilder.x10 trunk/x10.runtime.17/src-x10/x10/util/StringBuilder.x10 trunk/x10.runtime.17/src-x10/x10/util/Timer.x10 trunk/x10.runtime.17/src-x10/x10/util/ValRailBuilder.x10 trunk/x10.sncode/src/x10/sncode/ByteBuffer.java trunk/x10.sncode/src/x10/sncode/ClassEditor.java trunk/x10.sncode/src/x10/sncode/ConstantPool.java trunk/x10.sncode/src/x10/sncode/ConstantPoolParser.java trunk/x10.sncode/src/x10/sncode/Constraint.java trunk/x10.sncode/src/x10/sncode/ConstraintReader.java trunk/x10.sncode/src/x10/sncode/ConstructorEditor.java trunk/x10.sncode/src/x10/sncode/Container.java trunk/x10.sncode/src/x10/sncode/FieldEditor.java trunk/x10.sncode/src/x10/sncode/InvalidClassFileException.java trunk/x10.sncode/src/x10/sncode/LocalEditor.java trunk/x10.sncode/src/x10/sncode/MemberEditor.java trunk/x10.sncode/src/x10/sncode/MethodEditor.java trunk/x10.sncode/src/x10/sncode/Pair.java trunk/x10.sncode/src/x10/sncode/ProcEditor.java trunk/x10.sncode/src/x10/sncode/SnConstants.java trunk/x10.sncode/src/x10/sncode/SnDump.java trunk/x10.sncode/src/x10/sncode/SnFile.java trunk/x10.sncode/src/x10/sncode/Tree.java trunk/x10.sncode/src/x10/sncode/Type.java trunk/x10.sncode/src/x10/sncode/TypedefEditor.java trunk/x10.sncode/src/x10/sncode/ast/AST.java trunk/x10.sncode/src/x10/sncode/ast/Constant.java trunk/x10.sncode/src/x10/sncode/ast/FieldRef.java trunk/x10.sncode/src/x10/sncode/ast/Formula.java trunk/x10.sncode/src/x10/sncode/ast/MethodRef.java trunk/x10.sncode/src/x10/sncode/ast/Term.java trunk/x10.sncode/src/x10/sncode/ast/Var.java trunk/x10.sncode/src/x10/sncode/test/ClassFileTest.java trunk/x10.sncode/src/x10/sncode/test/TypeTest.java Modified: trunk/SafeX10/src/ArraySum.x10 =================================================================== --- trunk/SafeX10/src/ArraySum.x10 2009-07-23 15:15:34 UTC (rev 10852) +++ trunk/SafeX10/src/ArraySum.x10 2009-07-23 15:21:55 UTC (rev 10853) @@ -1,61 +1,61 @@ -import x10.io.Console; - -public class ArraySum { - - var sum: int; - val size: int; - val data: Rail[int]; - val R:Region{rail}; - - public def this(n: int): ArraySum = { - size=n; - R= 0..n-1 as Region{rail}; - data = Rail.makeVar[int](n, (x:nat)=>0 as int); - for (var i: int = 0; i < n; i++) data(i)=1; - sum=0; - } - - def sum(a: Rail[int], start: int, last: int): int = { - var mySum: int = 0; - for (var i: int = start; i < last; i++) mySum += a(i); - return mySum; - } - - def sum(val numThreads: int): void = { - val mySize: int = size/numThreads; - finish foreach ((p) in 0..numThreads-1) { - var mySum: int = sum(data, p*mySize, (p+1)*mySize); - atomic sum += mySum; - } - } - - public static def main(args: Rail[String]): void = { - - var size: int = 5*1000*1000; - if (args.length >=1) - size = Int.parseInt(args(0)); - - Console.OUT.println("initializing"); - var a: ArraySum = new ArraySum(size); - val numThreads = [1,2,4]; - - //warmup loop - Console.OUT.println("doing warmup"); - for (var i: int = 0; i < numThreads.length; i++) - a.sum(numThreads(i)); - - for (var i: int = 0; i < numThreads.length; i++) { - Console.OUT.println("starting with " + i + " threads"); - a.sum=0; - var time: long = - System.nanoTime(); - a.sum(numThreads(i)); - time += System.nanoTime(); - Console.OUT.println("For p=" + numThreads(i) - + " result: " + a.sum - + ((size==a.sum)? " ok" : " bad") - + " (time=" + (time/(1000*1000)) + " ms)"); - } - - - } -} +import x10.io.Console; + +public class ArraySum { + + var sum: int; + val size: int; + val data: Rail[int]; + val R:Region{rail}; + + public def this(n: int): ArraySum = { + size=n; + R= 0..n-1 as Region{rail}; + data = Rail.makeVar[int](n, (x:nat)=>0 as int); + for (var i: int = 0; i < n; i++) data(i)=1; + sum=0; + } + + def sum(a: Rail[int], start: int, last: int): int = { + var mySum: int = 0; + for (var i: int = start; i < last; i++) mySum += a(i); + return mySum; + } + + def sum(val numThreads: int): void = { + val mySize: int = size/numThreads; + finish foreach ((p) in 0..numThreads-1) { + var mySum: int = sum(data, p*mySize, (p+1)*mySize); + atomic sum += mySum; + } + } + + public static def main(args: Rail[String]): void = { + + var size: int = 5*1000*1000; + if (args.length >=1) + size = Int.parseInt(args(0)); + + Console.OUT.println("initializing"); + var a: ArraySum = new ArraySum(size); + val numThreads = [1,2,4]; + + //warmup loop + Console.OUT.println("doing warmup"); + for (var i: int = 0; i < numThreads.length; i++) + a.sum(numThreads(i)); + + for (var i: int = 0; i < numThreads.length; i++) { + Console.OUT.println("starting with " + i + " threads"); + a.sum=0; + var time: long = - System.nanoTime(); + a.sum(numThreads(i)); + time += System.nanoTime(); + Console.OUT.println("For p=" + numThreads(i) + + " result: " + a.sum + + ((size==a.sum)? " ok" : " bad") + + " (time=" + (time/(1000*1000)) + " ms)"); + } + + + } +} Property changes on: trunk/SafeX10/src/ArraySum.x10 ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Property changes on: trunk/SafeX10/src/Bug.x10 ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Modified: trunk/SafeX10/src/FRASimpleDist.x10 =================================================================== --- trunk/SafeX10/src/FRASimpleDist.x10 2009-07-23 15:15:34 UTC (rev 10852) +++ trunk/SafeX10/src/FRASimpleDist.x10 2009-07-23 15:21:55 UTC (rev 10853) @@ -1,144 +1,144 @@ -import x10.compiler.Native; -import x10.compiler.NativeRep; - -import x10.io.Console; - -import x10.util.Timer; -import x10.runtime.NativeRuntime; - -value LocalTable { - - val a: Rail[long]; - val mask: int; - - def this(size:int) { - mask = size-1; - a = Rail.makeVar[long](size, (i:nat)=>i as long); - } - - public def update(ran:long) { - //a(ran&mask as int) ^= ran; - val index = ran&mask as int; - a(index) = a(index) ^ ran; - } -} - - -class FRASimpleDist { - - const POLY = 0x0000000000000007L; - const PERIOD = 1317624576693539401L; - const NUM_PLACES = NativeRuntime.MAX_PLACES; - const PLACE_ID_MASK = NUM_PLACES-1; - - // Utility routine to start random number generator at Nth step - static def HPCC_starts(var n:long): long { - var i:int, j:int; - val m2 = Rail.makeVar[long](64); - while (n < 0) n += PERIOD; - while (n > PERIOD) n -= PERIOD; - if (n == 0) return 0x1L; - var temp:long = 0x1; - for (i=0; i<64; i++) { - m2(i) = temp; - temp = (temp << 1) ^ (temp < 0 ? POLY : 0L); - temp = (temp << 1) ^ (temp < 0 ? POLY : 0L); - } - for (i=62; i>=0; i--) if (((n >> i) & 1) != 0) break; - var ran:long = 0x2; - while (i > 0) { - temp = 0; - for (j=0; j<64; j++) if (((ran >> j) & 1) != 0) temp ^= m2(j); - ran = temp; - i -= 1; - if (((n >> i) & 1) != 0) - ran = (ran << 1) ^ (ran < 0 ? POLY : 0); - } - return ran; - } - - static def randomAccessUpdate( - NUM_UPDATES: long, - logLocalTableSize: long, - tables: ValRail[LocalTable] - ) { - finish for (var p:int=0; p<Place.MAX_PLACES; p++) { - val valp = p; - async (Place.places(p)) { - var ran:long = HPCC_starts(valp*(NUM_UPDATES/NUM_PLACES)); - for (var i:long=0; i<NUM_UPDATES/NUM_PLACES; i++) { - val placeId = ((ran>>logLocalTableSize) & PLACE_ID_MASK) as int; - val valran = ran; - val table = tables(placeId); - async (Place.places(placeId)) { - table.update(valran); - } - ran = (ran << 1) ^ (ran<0L ? POLY : 0L); - } - } - } - } - - - public static def main(args:Rail[String]) { - - if ((NUM_PLACES & (NUM_PLACES-1)) > 0) { - println("The number of places must be a power of 2."); - return; - } - - // calculate the size of update array (must be a power of 2) - val logLocalTableSize = args.length > 1 && args(0).equals("-m")? - int.parseInt(args(1)) : 12; - val localTableSize = 1<<logLocalTableSize; - val tableSize = localTableSize*NUM_PLACES; - val NUM_UPDATES = 4*tableSize; - - // create local tables - val varTables = Rail.makeVar[LocalTable](Place.MAX_PLACES); - finish for (var p:int=0; p<Place.MAX_PLACES; p++) { - val pp = p; - async (Place.places(p)) { - val t = new LocalTable(localTableSize); - async (Place.places(0)) - varTables(pp) = t; - } - } - val tables = Rail.makeVal[LocalTable](Place.MAX_PLACES, (x:Int) => varTables(x)); - - // print some info - println("Main table size = 2^" +logLocalTableSize + "*" + NUM_PLACES+" = " + tableSize+ " words"); - println("Number of places = " + NUM_PLACES); - println("Number of updates = " + NUM_UPDATES); - - // time it - var cpuTime:double = -now(); - randomAccessUpdate(NUM_UPDATES, logLocalTableSize, tables); - cpuTime += now(); - - // 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); - - // repeat for testing. - randomAccessUpdate(NUM_UPDATES, logLocalTableSize, tables); - for (var i:int=0; i<Place.MAX_PLACES; i++) { - val table = tables(i); - async (Place.places(i)) { - var err:int = 0; - for (var j:int=0; j<table.a.length; j++) - if (table.a(j) != j) err++; - println("Found " + err + " errors."); - } - } - } - - static def now() = Timer.nanoTime() * 1e-9D; - - static def println(s:String) = Console.OUT.println(s); - - @Native("java", "System.out.printf(#1,#2)") - @Native("c++", "printf((#1)->c_str(), #2); fflush(stdout)") - public static native def printf(x:String, o:Object):void; -} +import x10.compiler.Native; +import x10.compiler.NativeRep; + +import x10.io.Console; + +import x10.util.Timer; +import x10.runtime.NativeRuntime; + +value LocalTable { + + val a: Rail[long]; + val mask: int; + + def this(size:int) { + mask = size-1; + a = Rail.makeVar[long](size, (i:nat)=>i as long); + } + + public def update(ran:long) { + //a(ran&mask as int) ^= ran; + val index = ran&mask as int; + a(index) = a(index) ^ ran; + } +} + + +class FRASimpleDist { + + const POLY = 0x0000000000000007L; + const PERIOD = 1317624576693539401L; + const NUM_PLACES = NativeRuntime.MAX_PLACES; + const PLACE_ID_MASK = NUM_PLACES-1; + + // Utility routine to start random number generator at Nth step + static def HPCC_starts(var n:long): long { + var i:int, j:int; + val m2 = Rail.makeVar[long](64); + while (n < 0) n += PERIOD; + while (n > PERIOD) n -= PERIOD; + if (n == 0) return 0x1L; + var temp:long = 0x1; + for (i=0; i<64; i++) { + m2(i) = temp; + temp = (temp << 1) ^ (temp < 0 ? POLY : 0L); + temp = (temp << 1) ^ (temp < 0 ? POLY : 0L); + } + for (i=62; i>=0; i--) if (((n >> i) & 1) != 0) break; + var ran:long = 0x2; + while (i > 0) { + temp = 0; + for (j=0; j<64; j++) if (((ran >> j) & 1) != 0) temp ^= m2(j); + ran = temp; + i -= 1; + if (((n >> i) & 1) != 0) + ran = (ran << 1) ^ (ran < 0 ? POLY : 0); + } + return ran; + } + + static def randomAccessUpdate( + NUM_UPDATES: long, + logLocalTableSize: long, + tables: ValRail[LocalTable] + ) { + finish for (var p:int=0; p<Place.MAX_PLACES; p++) { + val valp = p; + async (Place.places(p)) { + var ran:long = HPCC_starts(valp*(NUM_UPDATES/NUM_PLACES)); + for (var i:long=0; i<NUM_UPDATES/NUM_PLACES; i++) { + val placeId = ((ran>>logLocalTableSize) & PLACE_ID_MASK) as int; + val valran = ran; + val table = tables(placeId); + async (Place.places(placeId)) { + table.update(valran); + } + ran = (ran << 1) ^ (ran<0L ? POLY : 0L); + } + } + } + } + + + public static def main(args:Rail[String]) { + + if ((NUM_PLACES & (NUM_PLACES-1)) > 0) { + println("The number of places must be a power of 2."); + return; + } + + // calculate the size of update array (must be a power of 2) + val logLocalTableSize = args.length > 1 && args(0).equals("-m")? + int.parseInt(args(1)) : 12; + val localTableSize = 1<<logLocalTableSize; + val tableSize = localTableSize*NUM_PLACES; + val NUM_UPDATES = 4*tableSize; + + // create local tables + val varTables = Rail.makeVar[LocalTable](Place.MAX_PLACES); + finish for (var p:int=0; p<Place.MAX_PLACES; p++) { + val pp = p; + async (Place.places(p)) { + val t = new LocalTable(localTableSize); + async (Place.places(0)) + varTables(pp) = t; + } + } + val tables = Rail.makeVal[LocalTable](Place.MAX_PLACES, (x:Int) => varTables(x)); + + // print some info + println("Main table size = 2^" +logLocalTableSize + "*" + NUM_PLACES+" = " + tableSize+ " words"); + println("Number of places = " + NUM_PLACES); + println("Number of updates = " + NUM_UPDATES); + + // time it + var cpuTime:double = -now(); + randomAccessUpdate(NUM_UPDATES, logLocalTableSize, tables); + cpuTime += now(); + + // 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); + + // repeat for testing. + randomAccessUpdate(NUM_UPDATES, logLocalTableSize, tables); + for (var i:int=0; i<Place.MAX_PLACES; i++) { + val table = tables(i); + async (Place.places(i)) { + var err:int = 0; + for (var j:int=0; j<table.a.length; j++) + if (table.a(j) != j) err++; + println("Found " + err + " errors."); + } + } + } + + static def now() = Timer.nanoTime() * 1e-9D; + + static def println(s:String) = Console.OUT.println(s); + + @Native("java", "System.out.printf(#1,#2)") + @Native("c++", "printf((#1)->c_str(), #2); fflush(stdout)") + public static native def printf(x:String, o:Object):void; +} Property changes on: trunk/SafeX10/src/FRASimpleDist.x10 ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Modified: trunk/SafeX10/src/FSSimpleDist.x10 =================================================================== --- trunk/SafeX10/src/FSSimpleDist.x10 2009-07-23 15:15:34 UTC (rev 10852) +++ trunk/SafeX10/src/FSSimpleDist.x10 2009-07-23 15:21:55 UTC (rev 10853) @@ -1,88 +1,88 @@ -/** - * Version of Stream with a collection of local arrays implementing a - * global array. - * - * @seealso Stream - * @author vj - * @author bdlucas - */ - -import x10.runtime.NativeRuntime; -import x10.util.Timer; -import x10.io.Console; - -public class FSSimpleDist { - - const MEG = 1024*1024; - const alpha = 3.0D; - - const NUM_TIMES = 10; - //const NUM_TIMES = 1; - - //const DEFAULT_SIZE = 2*MEG; - const DEFAULT_SIZE = MEG / 8; - - const NUM_PLACES = NativeRuntime.MAX_PLACES; - //const NUM_PLACES = 4; // Place.MAX_PLACES; - - public static def main(args:Rail[String]) { - - val verified: Rail[boolean] = [true]; - val times = Rail.makeVar[double](NUM_TIMES); - val N0 = args.length>0? int.parseInt(args(0)) : DEFAULT_SIZE; - val N = N0 * NUM_PLACES; - val localSize = N0; - - Console.OUT.println("localSize=" + localSize); - - finish { - - for (var pp:int=0; pp<NUM_PLACES; pp++) { - - val p = pp; - - async(Place.places(p)) { - - val a = Rail.makeVar[double](localSize); - val b = Rail.makeVar[double](localSize); - val c = Rail.makeVar[double](localSize); - - for (var i:int=0; i<localSize; i++) { - b(i) = 1.5 * (p*localSize+i); - c(i) = 2.5 * (p*localSize+i); - } - - for (var j:int=0; j<NUM_TIMES; j++) { - if (p==0) times(j) = -now(); - for (var i:int=0; i<localSize; i++) - a(i) = b(i) + alpha*c(i); - if (p==0) times(j) = times(j) + now(); - } - - // verification - for (var i:int=0; i<localSize; i++) - if (a(i) != b(i) + alpha*c(i)) - async(Place.FIRST_PLACE) - verified(0) = false; - } - } - } - - var min:double = 1000000; - for (var j:int=0; j<NUM_TIMES; j++) - if (times(j) < min) - min = times(j); - printStats(N, min, verified(0)); - } - - static def now():double = Timer.nanoTime() * 1e-9; - - static def printStats(N:int, time:double, verified:boolean) { - val size = (3*8*N/MEG); - val rate = (3*8*N) / (1.0E9*time); - Console.OUT.println("Number of places=" + NUM_PLACES); - Console.OUT.println("Size of arrays: " + size +" MB (total)" + size/NUM_PLACES + " MB (per place)"); - Console.OUT.println("Min time: " + time + " rate=" + rate + " GB/s"); - Console.OUT.println("Result is " + (verified ? "verified." : "NOT verified.")); - } -} +/** + * Version of Stream with a collection of local arrays implementing a + * global array. + * + * @seealso Stream + * @author vj + * @author bdlucas + */ + +import x10.runtime.NativeRuntime; +import x10.util.Timer; +import x10.io.Console; + +public class FSSimpleDist { + + const MEG = 1024*1024; + const alpha = 3.0D; + + const NUM_TIMES = 10; + //const NUM_TIMES = 1; + + //const DEFAULT_SIZE = 2*MEG; + const DEFAULT_SIZE = MEG / 8; + + const NUM_PLACES = NativeRuntime.MAX_PLACES; + //const NUM_PLACES = 4; // Place.MAX_PLACES; + + public static def main(args:Rail[String]) { + + val verified: Rail[boolean] = [true]; + val times = Rail.makeVar[double](NUM_TIMES); + val N0 = args.length>0? int.parseInt(args(0)) : DEFAULT_SIZE; + val N = N0 * NUM_PLACES; + val localSize = N0; + + Console.OUT.println("localSize=" + localSize); + + finish { + + for (var pp:int=0; pp<NUM_PLACES; pp++) { + + val p = pp; + + async(Place.places(p)) { + + val a = Rail.makeVar[double](localSize); + val b = Rail.makeVar[double](localSize); + val c = Rail.makeVar[double](localSize); + + for (var i:int=0; i<localSize; i++) { + b(i) = 1.5 * (p*localSize+i); + c(i) = 2.5 * (p*localSize+i); + } + + for (var j:int=0; j<NUM_TIMES; j++) { + if (p==0) times(j) = -now(); + for (var i:int=0; i<localSize; i++) + a(i) = b(i) + alpha*c(i); + if (p==0) times(j) = times(j) + now(); + } + + // verification + for (var i:int=0; i<localSize; i++) + if (a(i) != b(i) + alpha*c(i)) + async(Place.FIRST_PLACE) + verified(0) = false; + } + } + } + + var min:double = 1000000; + for (var j:int=0; j<NUM_TIMES; j++) + if (times(j) < min) + min = times(j); + printStats(N, min, verified(0)); + } + + static def now():double = Timer.nanoTime() * 1e-9; + + static def printStats(N:int, time:double, verified:boolean) { + val size = (3*8*N/MEG); + val rate = (3*8*N) / (1.0E9*time); + Console.OUT.println("Number of places=" + NUM_PLACES); + Console.OUT.println("Size of arrays: " + size +" MB (total)" + size/NUM_PLACES + " MB (per place)"); + Console.OUT.println("Min time: " + time + " rate=" + rate + " GB/s"); + Console.OUT.println("Result is " + (verified ? "verified." : "NOT verified.")); + } +} Property changes on: trunk/SafeX10/src/FSSimpleDist.x10 ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Property changes on: trunk/SafeX10/src/GCSpheres.x10 ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Modified: trunk/SafeX10/src/Hello.x10 =================================================================== --- trunk/SafeX10/src/Hello.x10 2009-07-23 15:15:34 UTC (rev 10852) +++ trunk/SafeX10/src/Hello.x10 2009-07-23 15:21:55 UTC (rev 10853) @@ -1,8 +1,8 @@ -import x10.io.Console; -public class Hello { - public static def main(Rail[String]) { - Console.OUT.println("Hello World"); - } -} - - +import x10.io.Console; +public class Hello { + public static def main(Rail[String]) { + Console.OUT.println("Hello World"); + } +} + + Property changes on: trunk/SafeX10/src/Hello.x10 ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Modified: trunk/SafeX10/src/HelloWorld.x10 =================================================================== --- trunk/SafeX10/src/HelloWorld.x10 2009-07-23 15:15:34 UTC (rev 10852) +++ trunk/SafeX10/src/HelloWorld.x10 2009-07-23 15:21:55 UTC (rev 10853) @@ -1,8 +1,8 @@ -import x10.io.Console; -public class HelloWorld { - public static def main(Rail[String]) { - Console.OUT.println("Hello World"); - } -} - - +import x10.io.Console; +public class HelloWorld { + public static def main(Rail[String]) { + Console.OUT.println("Hello World"); + } +} + + Property changes on: trunk/SafeX10/src/HelloWorld.x10 ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Modified: trunk/SafeX10/src/Histogram.x10 =================================================================== --- trunk/SafeX10/src/Histogram.x10 2009-07-23 15:15:34 UTC (rev 10852) +++ trunk/SafeX10/src/Histogram.x10 2009-07-23 15:21:55 UTC (rev 10853) @@ -1,34 +1,34 @@ -import x10.util.Random; -import x10.io.Console; - -public class Histogram { - public incomplete static def all[T](x:Array[T]):Set[Object]; - public incomplete static def all[T](x:Rail[T]):Set[Object]; - public incomplete static def loc[T](x:T):Set[T]; - public incomplete static def read[T](x:Set[T]):Effects; - public incomplete static def write[T](x:Set[T]):Effects; - public incomplete static def touch[T](x:Set[T]):Effects; - public incomplete static def atomicInc[T](x:Set[T]):Effects ; - public incomplete static def atomicDec[T](x:Set[T]):Effects; - - public static @fun(read(all(a)).and(write(all(b)))) - def run(a:Array[Int], b: Rail[int]) { - finish - for ((i):Point(1) in a) async { - val bin = a(i) % b.length; - atomic b(bin)++; - - } - } - public static @fun def main(args:Rail[String]) { - assert args.length == 2 : "Usage: Histogram N M"; - val N = int.parseInt(args(0)), M=int.parseInt(args(1)); - assert N%M==0 : "Usage: N must be a multiple of M"; - val a = Array.make[int](0..N-1, (q:Point)=> q(0)); - val b = Rail.makeVar[int](M); - run(a, b); - val v = b(0); - for (x in b) assert x==v; - Console.OUT.println("Test ok."); - } -} +import x10.util.Random; +import x10.io.Console; + +public class Histogram { + public incomplete static def all[T](x:Array[T]):Set[Object]; + public incomplete static def all[T](x:Rail[T]):Set[Object]; + public incomplete static def loc[T](x:T):Set[T]; + public incomplete static def read[T](x:Set[T]):Effects; + public incomplete static def write[T](x:Set[T]):Effects; + public incomplete static def touch[T](x:Set[T]):Effects; + public incomplete static def atomicInc[T](x:Set[T]):Effects ; + public incomplete static def atomicDec[T](x:Set[T]):Effects; + + public static @fun(read(all(a)).and(write(all(b)))) + def run(a:Array[Int], b: Rail[int]) { + finish + for ((i):Point(1) in a) async { + val bin = a(i) % b.length; + atomic b(bin)++; + + } + } + public static @fun def main(args:Rail[String]) { + assert args.length == 2 : "Usage: Histogram N M"; + val N = int.parseInt(args(0)), M=int.parseInt(args(1)); + assert N%M==0 : "Usage: N must be a multiple of M"; + val a = Array.make[int](0..N-1, (q:Point)=> q(0)); + val b = Rail.makeVar[int](M); + run(a, b); + val v = b(0); + for (x in b) assert x==v; + Console.OUT.println("Test ok."); + } +} Property changes on: trunk/SafeX10/src/Histogram.x10 ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Property changes on: trunk/SafeX10/src/KMeans.x10 ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Property changes on: trunk/SafeX10/src/KMeansDist.x10 ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Modified: trunk/SafeX10/src/Locations.x10 =================================================================== --- trunk/SafeX10/src/Locations.x10 2009-07-23 15:15:34 UTC (rev 10852) +++ trunk/SafeX10/src/Locations.x10 2009-07-23 15:21:55 UTC (rev 10853) @@ -1,6 +1,6 @@ -public interface Locations[T] { - def read[T](x:Set[T]):Effects; - def write[T](x:Set[T]):Effects; - def touch[T](x:Set[T]):Effects; - def and(x:Effects):Effects; -} +public interface Locations[T] { + def read[T](x:Set[T]):Effects; + def write[T](x:Set[T]):Effects; + def touch[T](x:Set[T]):Effects; + def and(x:Effects):Effects; +} Property changes on: trunk/SafeX10/src/Locations.x10 ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Modified: trunk/SafeX10/src/Mont... [truncated message content] |
From: <ipe...@us...> - 2009-07-23 16:15:18
|
Revision: 10855 http://x10.svn.sourceforge.net/x10/?rev=10855&view=rev Author: ipeshansky Date: 2009-07-23 16:15:16 +0000 (Thu, 23 Jul 2009) Log Message: ----------- Fix XTENLANG-473. Modified Paths: -------------- trunk/x10.compiler.p3/src/polyglot/ext/x10/ast/X10Cast_c.java Added Paths: ----------- trunk/x10.tests/examples/Issues/XTENLANG_473.x10 Modified: trunk/x10.compiler.p3/src/polyglot/ext/x10/ast/X10Cast_c.java =================================================================== --- trunk/x10.compiler.p3/src/polyglot/ext/x10/ast/X10Cast_c.java 2009-07-23 16:01:31 UTC (rev 10854) +++ trunk/x10.compiler.p3/src/polyglot/ext/x10/ast/X10Cast_c.java 2009-07-23 16:15:16 UTC (rev 10855) @@ -229,7 +229,7 @@ XConstraint cTo = X10TypeMixin.xclause(toType); if (convert != ConversionType.UNKNOWN_IMPLICIT_CONVERSION) { - if (! ts.isParameterType(fromType) && ts.isCastValid(fromType, toType, context)) { + if (! ts.isParameterType(fromType) && ! ts.isParameterType(toType) && ts.isCastValid(fromType, toType, context)) { X10Cast_c n = (X10Cast_c) copy(); n.convert = ConversionType.CHECKED; return n.type(toType); @@ -287,14 +287,6 @@ } } - if (convert != ConversionType.UNKNOWN_IMPLICIT_CONVERSION) { - if (ts.isParameterType(fromType) && ts.isCastValid(fromType, toType, context)) { - X10Cast_c n = (X10Cast_c) copy(); - n.convert = ConversionType.CHECKED; - return n.type(toType); - } - } - // if (ts.isValueType(fromType) && ts.isReferenceOrInterfaceType(toType)) { // if (ts.isSubtypeWithValueInterfaces(fromType, toType, Collections.EMPTY_LIST)) { // Expr boxed = wrap(expr, toType, tc); @@ -311,13 +303,13 @@ // (v as Box[Ref]).value as Value if (ts.isReferenceOrInterfaceType(fromType, context) && (ts.isValueType(toType, context) || ts.isParameterType(toType))) { Expr boxed = expr; - if (! ts.typeEquals(fromType, boxOfTo, context)) { + if (! ts.typeEquals(baseFrom, boxOfTo, context)) { boxed = check(nf.X10Cast(position(), nf.CanonicalTypeNode(position(), boxOfTo), expr, convert), tc); return check(nf.X10Cast(position(), nf.CanonicalTypeNode(position(), toType), boxed, convert), tc); } } - if (convert != ConversionType.UNKNOWN_IMPLICIT_CONVERSION && ts.typeEquals(fromType, boxOfTo, context)) { + if (convert != ConversionType.UNKNOWN_IMPLICIT_CONVERSION && ts.typeEquals(baseFrom, boxOfTo, context)) { // System.out.println("UNBOXING " + expr + " from " + fromType + " to " + toType); Expr unboxed = check(nf.Field(position(), expr, nf.Id(position(), Name.make("value"))), tc); return check(nf.X10Cast(position(), nf.CanonicalTypeNode(position(), toType), unboxed, convert), tc); Added: trunk/x10.tests/examples/Issues/XTENLANG_473.x10 =================================================================== --- trunk/x10.tests/examples/Issues/XTENLANG_473.x10 (rev 0) +++ trunk/x10.tests/examples/Issues/XTENLANG_473.x10 2009-07-23 16:15:16 UTC (rev 10855) @@ -0,0 +1,30 @@ +// (C) Copyright IBM Corporation 2009 +// This file is part of X10 Test. * + +import harness.x10Test; + +/** + * @author igor 7/2009 + */ + +public class XTENLANG_473 extends x10Test { + + public static class G[T] { + public def foo(x: Box[T]): T { + val y = x as T; + return y; + } + } + + public def run(): boolean { + val x: Box[String] = "aaa"; + val y = new G[String]().foo(x); + val z = x as String; + return y == z; + } + + public static def main(Rail[String]) { + new XTENLANG_473().execute(); + } +} + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <spa...@us...> - 2009-07-23 22:10:30
|
Revision: 10861 http://x10.svn.sourceforge.net/x10/?rev=10861&view=rev Author: sparksparkspark Date: 2009-07-23 22:10:23 +0000 (Thu, 23 Jul 2009) Log Message: ----------- 1) re-introduce TYPENAME in alloc tracing 2) Remove rtt static member from closures. This was needed only when we were using multiple inheritance 3) Break RTT.h<->alloc.h cycle by commenting out the typeName specialisation for ref<T>. We think this is not needed. Modified Paths: -------------- trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/MessagePassingCodeGenerator.java trunk/x10.runtime.17/src-cpp/x10aux/RTT.h trunk/x10.runtime.17/src-cpp/x10aux/alloc.h Modified: trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/MessagePassingCodeGenerator.java =================================================================== --- trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/MessagePassingCodeGenerator.java 2009-07-23 21:19:17 UTC (rev 10860) +++ trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/MessagePassingCodeGenerator.java 2009-07-23 22:10:23 UTC (rev 10861) @@ -2996,8 +2996,10 @@ inc.write("const x10aux::RuntimeType *_type() const {"+ " return x10aux::getRTT<"+superType+" >(); }"); + /* inc.newline(); inc.write("static x10aux::RuntimeType * rtt;"); + */ inc.newline(); inc.forceNewline(); inc.write(emitter.translateType(xts.String(), true)+" toString() {"); @@ -3020,10 +3022,12 @@ inc.write("x10aux::itable_entry(&"+superType+"::rtt, &"+cnamet+"::_itable),"); inc.write("x10aux::itable_entry(NULL, NULL)};"); inc.newline(); + /* if (in_template_closure) emitter.printTemplateSignature(freeTypeParams, inc); inc.write("x10aux::RuntimeType * "+cnamet+"::rtt = const_cast<x10aux::RuntimeType *>(x10aux::getRTT<"+superType+" >());"); inc.newline(); inc.forceNewline(); + */ if (in_template_closure) emitter.printTemplateSignature(freeTypeParams, inc); Modified: trunk/x10.runtime.17/src-cpp/x10aux/RTT.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10aux/RTT.h 2009-07-23 21:19:17 UTC (rev 10860) +++ trunk/x10.runtime.17/src-cpp/x10aux/RTT.h 2009-07-23 22:10:23 UTC (rev 10861) @@ -2,7 +2,7 @@ #define X10AUX_RTT_H #include <x10aux/config.h> -#include <x10aux/alloc.h> +//#include <x10aux/alloc.h> #include <pthread.h> @@ -121,12 +121,14 @@ return t->name(); } }; +/* template<class T> struct TypeName<ref<T> > { static const char *_() { const RuntimeType *t = getRTT<T>(); if (t == NULL) return "Uninitialized RTT"; static const char *with_star = alloc_printf("%s*",t->name()); return with_star; } }; +*/ template<class T> const char *typeName() { return TypeName<T>::_(); Modified: trunk/x10.runtime.17/src-cpp/x10aux/alloc.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10aux/alloc.h 2009-07-23 21:19:17 UTC (rev 10860) +++ trunk/x10.runtime.17/src-cpp/x10aux/alloc.h 2009-07-23 22:10:23 UTC (rev 10861) @@ -43,7 +43,7 @@ template<class T> T* alloc(size_t size = sizeof(T)) { // broken until we fix closure RTT (see also dealloc) - _M_("Allocating " << size << " bytes of unknown type " /*<< TYPENAME(T)*/); + _M_("Allocating " << size << " bytes of type " << TYPENAME(T)); #ifdef X10_USE_BDWGC T* ret = (T*)GC_MALLOC(size); #else @@ -73,7 +73,7 @@ template<class T> void dealloc(const T* obj_) { T *obj = const_cast<T*>(obj_); // free does not take const void * // broken until we fix closure RTT (see also alloc) - _M_("Freeing chunk " << (void*)obj << " of unknown type " /*<< TYPENAME(T)*/); + _M_("Freeing chunk " << (void*)obj << " of type " << TYPENAME(T)); #ifdef X10_USE_BDWGC GC_FREE(obj); #else This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ipe...@us...> - 2009-07-24 06:54:55
|
Revision: 10864 http://x10.svn.sourceforge.net/x10/?rev=10864&view=rev Author: ipeshansky Date: 2009-07-24 06:54:47 +0000 (Fri, 24 Jul 2009) Log Message: ----------- Fix XTENLANG-472. Tweak whitespace in X10While_c.java. Modified Paths: -------------- trunk/x10.compiler.p3/src/polyglot/ext/x10/ast/X10NodeFactory_c.java trunk/x10.compiler.p3/src/polyglot/ext/x10/ast/X10While_c.java trunk/x10.compiler.p3/src/polyglot/ext/x10/visit/X10DelegatingVisitor.java Added Paths: ----------- trunk/x10.compiler.p3/src/polyglot/ext/x10/ast/X10Do_c.java trunk/x10.tests/examples/Issues/XTENLANG_472.x10 Added: trunk/x10.compiler.p3/src/polyglot/ext/x10/ast/X10Do_c.java =================================================================== --- trunk/x10.compiler.p3/src/polyglot/ext/x10/ast/X10Do_c.java (rev 0) +++ trunk/x10.compiler.p3/src/polyglot/ext/x10/ast/X10Do_c.java 2009-07-24 06:54:47 UTC (rev 10864) @@ -0,0 +1,50 @@ +/* + * + * (C) Copyright IBM Corporation 2006-2008 + * + * This file is part of X10 Language. + * + */ +/** + * + */ +package polyglot.ext.x10.ast; + +import polyglot.ast.Do_c; +import polyglot.ast.Expr; +import polyglot.ast.Node; +import polyglot.ast.Stmt; +import polyglot.types.SemanticException; +import polyglot.types.TypeSystem; +import polyglot.util.Position; +import polyglot.visit.ContextVisitor; + +/** + * @author igor + */ +public class X10Do_c extends Do_c { + + /** + * @param pos + * @param body + * @param cond + */ + public X10Do_c(Position pos, Stmt body, Expr cond) { + super(pos, body, cond); + // TODO Auto-generated constructor stub + } + + /** Type check the statement. */ + public Node typeCheck(ContextVisitor tc) throws SemanticException { + TypeSystem ts = tc.typeSystem(); + + if (! ts.isSubtype(cond.type(), ts.Boolean(), tc.context())) { + throw new SemanticException( + "Condition of do statement must have boolean type, and not " + cond.type() + ".", + cond.position()); + } + + return this; + } + +} Property changes on: trunk/x10.compiler.p3/src/polyglot/ext/x10/ast/X10Do_c.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Modified: trunk/x10.compiler.p3/src/polyglot/ext/x10/ast/X10NodeFactory_c.java =================================================================== --- trunk/x10.compiler.p3/src/polyglot/ext/x10/ast/X10NodeFactory_c.java 2009-07-24 06:35:44 UTC (rev 10863) +++ trunk/x10.compiler.p3/src/polyglot/ext/x10/ast/X10NodeFactory_c.java 2009-07-24 06:54:47 UTC (rev 10864) @@ -31,6 +31,7 @@ import polyglot.ast.ConstructorDecl; import polyglot.ast.DelFactory; import polyglot.ast.Disamb; +import polyglot.ast.Do; import polyglot.ast.Expr; import polyglot.ast.ExtFactory; import polyglot.ast.Field; @@ -714,6 +715,12 @@ n = (Call) n.del(delFactory().delExpr()); return n; } + public Do Do(Position pos, Stmt body, Expr cond) { + Do n = new X10Do_c(pos, body, cond); + n = (Do)n.ext(extFactory().extDo()); + n = (Do)n.del(delFactory().delDo()); + return n; + } public While While(Position pos, Expr cond, Stmt body) { While n = new X10While_c(pos, cond, body); n = (While)n.ext(extFactory().extWhile()); Modified: trunk/x10.compiler.p3/src/polyglot/ext/x10/ast/X10While_c.java =================================================================== --- trunk/x10.compiler.p3/src/polyglot/ext/x10/ast/X10While_c.java 2009-07-24 06:35:44 UTC (rev 10863) +++ trunk/x10.compiler.p3/src/polyglot/ext/x10/ast/X10While_c.java 2009-07-24 06:54:47 UTC (rev 10864) @@ -34,18 +34,18 @@ super(pos, cond, body); // TODO Auto-generated constructor stub } - - /** Type check the statement. */ - public Node typeCheck(ContextVisitor tc) throws SemanticException { - TypeSystem ts = tc.typeSystem(); - - if (! ts.isSubtype(cond.type(), ts.Boolean(), tc.context())) { - throw new SemanticException( - "Condition of while statement must have boolean type, and not " + cond.type() + ".", - cond.position()); + + /** Type check the statement. */ + public Node typeCheck(ContextVisitor tc) throws SemanticException { + TypeSystem ts = tc.typeSystem(); + + if (! ts.isSubtype(cond.type(), ts.Boolean(), tc.context())) { + throw new SemanticException( + "Condition of while statement must have boolean type, and not " + cond.type() + ".", + cond.position()); + } + + return this; } - - return this; - } } Modified: trunk/x10.compiler.p3/src/polyglot/ext/x10/visit/X10DelegatingVisitor.java =================================================================== --- trunk/x10.compiler.p3/src/polyglot/ext/x10/visit/X10DelegatingVisitor.java 2009-07-24 06:35:44 UTC (rev 10863) +++ trunk/x10.compiler.p3/src/polyglot/ext/x10/visit/X10DelegatingVisitor.java 2009-07-24 06:54:47 UTC (rev 10864) @@ -133,6 +133,7 @@ import polyglot.ext.x10.ast.X10Conditional_c; import polyglot.ext.x10.ast.X10ConstructorCall_c; import polyglot.ext.x10.ast.X10ConstructorDecl_c; +import polyglot.ext.x10.ast.X10Do_c; import polyglot.ext.x10.ast.X10FieldDecl_c; import polyglot.ext.x10.ast.X10Field_c; import polyglot.ext.x10.ast.X10FloatLit_c; @@ -188,6 +189,7 @@ if (n instanceof X10While_c) { visit((X10While_c)n); return; } if (n instanceof While_c) { visit((While_c)n); return; } if (n instanceof For_c) { visit((For_c)n); return; } + if (n instanceof X10Do_c) { visit((X10Do_c)n); return; } if (n instanceof Do_c) { visit((Do_c)n); return; } if (n instanceof Loop_c) { visit((Loop_c)n); return; } if (n instanceof LocalTypeDef_c) { visit((LocalTypeDef_c)n); return; } @@ -423,6 +425,7 @@ public void visit(LocalTypeDef_c n) { visit((Stmt_c)n); } public void visit(Loop_c n) { visit((Stmt_c)n); } public void visit(Do_c n) { visit((Loop_c)n); } + public void visit(X10Do_c n) { visit((Do_c)n); } public void visit(For_c n) { visit((Loop_c)n); } public void visit(While_c n) { visit((Loop_c)n); } public void visit(X10While_c n) { visit((While_c)n); } Added: trunk/x10.tests/examples/Issues/XTENLANG_472.x10 =================================================================== --- trunk/x10.tests/examples/Issues/XTENLANG_472.x10 (rev 0) +++ trunk/x10.tests/examples/Issues/XTENLANG_472.x10 2009-07-24 06:54:47 UTC (rev 10864) @@ -0,0 +1,23 @@ +// (C) Copyright IBM Corporation 2009 +// This file is part of X10 Test. * + +import harness.x10Test; + +/** + * @author igor 7/2009 + */ + +public class XTENLANG_472 extends x10Test { + + public def run(): boolean { + var i:Int = 5; + do { + if (--i <= 0) break; + } while(true); + return i == 0; + } + + public static def main(Rail[String]) { + new XTENLANG_472().execute(); + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dgr...@us...> - 2009-07-25 01:16:45
|
Revision: 10874 http://x10.svn.sourceforge.net/x10/?rev=10874&view=rev Author: dgrove-oss Date: 2009-07-25 01:16:39 +0000 (Sat, 25 Jul 2009) Log Message: ----------- Get the RTT of the interface by calling x10aux::getRTT<I> when building the itable to cause initRTT to get called. Partially fixes uninitialized name problem. Store the RTT of the class itself in the itable field of the sentinel itable_entry at the end of the itable to enable better debug message from x10aux::reportITableLookupFailure There are still problems with the names not being fully initialized, which I suspect means that there are still code paths that are not going through getRTT properly, thus causing some RTT objects to be uninitialized. This needs to be fixed..... Modified Paths: -------------- trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/MessagePassingCodeGenerator.java trunk/x10.runtime.17/src-cpp/x10aux/itables.cc Modified: trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/MessagePassingCodeGenerator.java =================================================================== --- trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/MessagePassingCodeGenerator.java 2009-07-24 20:05:56 UTC (rev 10873) +++ trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/MessagePassingCodeGenerator.java 2009-07-25 01:16:39 UTC (rev 10874) @@ -1108,10 +1108,10 @@ sw.write("x10aux::itable_entry "+emitter.translateType(currentClass)+"::_itables["+(numInterfaces+1)+"] = {"); itableNum = 0; for (Type interfaceType : allInterfaces) { - sw.write("x10aux::itable_entry(&"+emitter.translateType(interfaceType)+"::rtt, &_itable_"+itableNum+"), "); + sw.write("x10aux::itable_entry(x10aux::getRTT"+chevrons(emitter.translateType(interfaceType, false))+"(), &_itable_"+itableNum+"), "); itableNum += 1; } - sw.write("x10aux::itable_entry(NULL, NULL)};"); sw.newline(); + sw.write("x10aux::itable_entry(NULL, (void*)x10aux::getRTT"+chevrons(emitter.translateType(currentClass, false))+"())};"); sw.newline(); } } Modified: trunk/x10.runtime.17/src-cpp/x10aux/itables.cc =================================================================== --- trunk/x10.runtime.17/src-cpp/x10aux/itables.cc 2009-07-24 20:05:56 UTC (rev 10873) +++ trunk/x10.runtime.17/src-cpp/x10aux/itables.cc 2009-07-25 01:16:39 UTC (rev 10874) @@ -9,9 +9,11 @@ fprintf(stderr, "\nITable lookup failure!!\n"); fprintf(stderr, "\tTarget interface was %s\n", targetInterface->name()); fprintf(stderr, "\tInterfaces actually implemented by receiver\n"); - for (int i=0; itables[i].id != 0; i++) { + int i = 0; + for (; itables[i].id != 0; i++) { fprintf(stderr, "\t\t%s\n", itables[i].id->name()); } + fprintf(stderr, "\tReceiver object was %s\n", ((RuntimeType*)(itables[i].itable))->name()); fprintf(stderr, "\n"); fflush(stderr); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dgr...@us...> - 2009-07-27 15:16:44
|
Revision: 10885 http://x10.svn.sourceforge.net/x10/?rev=10885&view=rev Author: dgrove-oss Date: 2009-07-27 15:16:37 +0000 (Mon, 27 Jul 2009) Log Message: ----------- Yet another rework of the RTT initialization story to try to avoid problems with partially initialized and multiply initialized RTT objects. The approach now is to completely rely on lazy initialization via calls to getRTT (including Object and primitives in the same protocol). Check against typeName != NULL instead of parentsc != -1 to avoid depending on the order in which C++ static initializers are run. By using a zero (NULL) value as the uninitialized check, we can eliminate the constructor for RuntimeType and instead rely on all static data segments being initially zero. Since many calls to getRTT happen during static inialization (due to itables), we need a sequence that doesn't depend on the constructor for a particular RTT instance being run before getRTT is called for its class. Modified Paths: -------------- trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/Emitter.java trunk/x10.runtime.17/src-cpp/x10/lang/Object.cc trunk/x10.runtime.17/src-cpp/x10/lang/Object.h trunk/x10.runtime.17/src-cpp/x10aux/RTT.cc trunk/x10.runtime.17/src-cpp/x10aux/RTT.h trunk/x10.runtime.17/src-cpp/x10aux/bootstrap.h trunk/x10.runtime.17/src-cpp/x10aux/pgas.cc Modified: trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/Emitter.java =================================================================== --- trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/Emitter.java 2009-07-27 13:15:24 UTC (rev 10884) +++ trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/Emitter.java 2009-07-27 15:16:37 UTC (rev 10885) @@ -393,7 +393,7 @@ if (params == null && sparams == null) return smi; if (params != null && params.equals(sparams)) - return smi; + return smi; } return null; } catch (SemanticException e) { @@ -566,7 +566,7 @@ h.write(isInterface ? "RTT_H_DECLS_INTERFACE" : "RTT_H_DECLS_CLASS"); h.newline(); h.forceNewline(); } else { h.write("static x10aux::RuntimeType rtt;"); h.newline(); - h.write("static const x10aux::RuntimeType* getRTT() { if (-1 == rtt.parentsc) _initRTT(); return &rtt; }"); h.newline(); + h.write("static const x10aux::RuntimeType* getRTT() { if (NULL == rtt.typeName) _initRTT(); return &rtt; }"); h.newline(); h.write("static void _initRTT();"); h.newline(); if (!isInterface) { h.write("virtual const x10aux::RuntimeType *_type() const { return getRTT(); }"); h.newline(); @@ -582,7 +582,7 @@ if (ct.typeArguments().isEmpty()) { h.write("x10aux::RuntimeType "+translateType(ct)+"::rtt;"); h.newline(); h.write("void "+translateType(ct)+"::_initRTT() {"); h.newline(4); h.begin(0); - h.write("rtt.parentsc = -2;"); h.newline(); + h.write("rtt.typeName = \"CYCLIC RTT INIT\";"); h.newline(); h.write("rtt.init(\""+ct.fullName()+"\", "+num_parents); h.write(", x10aux::getRTT" + chevrons(ct.superClass()==null ? translateType(xts.Ref()) : translateType(ct.superClass())) + "()"); for (Type iface : ct.interfaces()) { @@ -596,6 +596,7 @@ printTemplateSignature(ct.typeArguments(), h); h.write("void "+translateType(ct)+"::_initRTT() {"); h.newline(4); h.begin(0); + h.write("rtt.typeName = \"CYCLIC RTT INIT\";"); h.newline(); h.write("const char *name ="); h.newline(4); h.write("x10aux::alloc_printf("); h.begin(0); h.write("\""+x10name+"["); Modified: trunk/x10.runtime.17/src-cpp/x10/lang/Object.cc =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/Object.cc 2009-07-27 13:15:24 UTC (rev 10884) +++ trunk/x10.runtime.17/src-cpp/x10/lang/Object.cc 2009-07-27 15:16:37 UTC (rev 10885) @@ -35,6 +35,13 @@ return false; } +x10aux::RuntimeType x10::lang::Object::rtt; + +void Object::_initRTT() { + rtt.init("x10.lang.Object", 0); +} + + itable_entry Object::_itables[1] = { itable_entry(NULL, NULL) }; Modified: trunk/x10.runtime.17/src-cpp/x10/lang/Object.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/Object.h 2009-07-27 13:15:24 UTC (rev 10884) +++ trunk/x10.runtime.17/src-cpp/x10/lang/Object.h 2009-07-27 15:16:37 UTC (rev 10885) @@ -22,11 +22,8 @@ static x10aux::itable_entry _itables[1]; public: + RTT_H_DECLS - /* Note special RTT code block because Object is predefined by RuntimeType */ - static const x10aux::RuntimeType* getRTT() { return &x10aux::RuntimeType::ObjectType; } - virtual const x10aux::RuntimeType *_type() const { return getRTT(); } - virtual x10aux::itable_entry* _getITables() { return _itables; } Object(){ } Modified: trunk/x10.runtime.17/src-cpp/x10aux/RTT.cc =================================================================== --- trunk/x10.runtime.17/src-cpp/x10aux/RTT.cc 2009-07-27 13:15:24 UTC (rev 10884) +++ trunk/x10.runtime.17/src-cpp/x10aux/RTT.cc 2009-07-27 15:16:37 UTC (rev 10885) @@ -1,6 +1,7 @@ #include <x10aux/config.h> #include <x10aux/RTT.h> #include <x10aux/alloc.h> +#include <x10aux/atomic_ops.h> #include <x10/lang/Object.h> @@ -10,6 +11,12 @@ using namespace x10::lang; bool RuntimeType::subtypeOf(const RuntimeType * const other) const { + // Checks to try to catch partially initialized RTT objects before we use them. + assert(typeName != NULL); + assert(other->typeName != NULL); + assert(parentsc != 0 || this == x10::lang::Object::getRTT()); + assert(other->parentsc != 0 || other == x10::lang::Object::getRTT()); + if (equals(other)) return true; // trivial case for (int i = 0; i < parentsc; ++i) { if (parents[i]->subtypeOf(other)) return true; @@ -38,27 +45,47 @@ for (int i=0 ; i<parentsc ; ++i) parents[i] = va_arg(parentsv,const RuntimeType*); va_end(parentsv); + x10aux::atomic_ops::store_load_barrier(); } -void -RuntimeType::bootstrap() { - /* Initialize RTTs for Object and builtin primitive types */ - ObjectType.init("x10.lang.Object", 0); - BooleanType.init("x10.lang.Boolean", 1, &ObjectType); - ByteType.init("x10.lang.Byte", 1, &ObjectType); - CharType.init("x10.lang.Char", 1, &ObjectType); - ShortType.init("x10.lang.Short", 1, &ObjectType); - IntType.init("x10.lang.Int", 1, &ObjectType); - FloatType.init("x10.lang.Float", 1, &ObjectType); - LongType.init("x10.lang.Long", 1, &ObjectType); - DoubleType.init("x10.lang.Double", 1, &ObjectType); - UByteType.init("x10.lang.UByte", 1, &ObjectType); - UShortType.init("x10.lang.UShort", 1, &ObjectType); - UIntType.init("x10.lang.UInt", 1, &ObjectType); - ULongType.init("x10.lang.ULong", 1, &ObjectType); +void RuntimeType::initBooleanType() { + BooleanType.init("x10.lang.Boolean", 1, x10::lang::Object::getRTT()); } +void RuntimeType::initByteType() { + ByteType.init("x10.lang.Byte", 1, x10::lang::Object::getRTT()); +} +void RuntimeType::initCharType() { + CharType.init("x10.lang.Char", 1, x10::lang::Object::getRTT()); +} +void RuntimeType::initShortType() { + ShortType.init("x10.lang.Short", 1, x10::lang::Object::getRTT()); +} +void RuntimeType::initIntType() { + IntType.init("x10.lang.Int", 1, x10::lang::Object::getRTT()); +} +void RuntimeType::initFloatType() { + FloatType.init("x10.lang.Float", 1, x10::lang::Object::getRTT()); +} +void RuntimeType::initLongType() { + LongType.init("x10.lang.Long", 1, x10::lang::Object::getRTT()); +} +void RuntimeType::initDoubleType() { + DoubleType.init("x10.lang.Double", 1, x10::lang::Object::getRTT()); +} +void RuntimeType::initUByteType() { + UByteType.init("x10.lang.UByte", 1, x10::lang::Object::getRTT()); +} +void RuntimeType::initUShortType() { + UShortType.init("x10.lang.UShort", 1, x10::lang::Object::getRTT()); +} +void RuntimeType::initUIntType() { + UIntType.init("x10.lang.UInt", 1, x10::lang::Object::getRTT()); +} +void RuntimeType::initULongType() { + ULongType.init("x10.lang.ULong", 1, x10::lang::Object::getRTT()); +} -RuntimeType RuntimeType::ObjectType; + RuntimeType RuntimeType::BooleanType; RuntimeType RuntimeType::ByteType; RuntimeType RuntimeType::CharType; Modified: trunk/x10.runtime.17/src-cpp/x10aux/RTT.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10aux/RTT.h 2009-07-27 13:15:24 UTC (rev 10884) +++ trunk/x10.runtime.17/src-cpp/x10aux/RTT.h 2009-07-27 15:16:37 UTC (rev 10885) @@ -9,24 +9,24 @@ /* Macro to use in class declaration for boilerplate RTT junk */ #define RTT_H_DECLS \ static x10aux::RuntimeType rtt; \ - static const x10aux::RuntimeType* getRTT() { if (-1==rtt.parentsc) _initRTT(); return &rtt; } \ + static const x10aux::RuntimeType* getRTT() { if (NULL == rtt.typeName) _initRTT(); return &rtt; } \ static void _initRTT(); \ virtual const x10aux::RuntimeType *_type() const { return getRTT(); } #define RTT_H_DECLS_CLASS \ static x10aux::RuntimeType rtt; \ - static const x10aux::RuntimeType* getRTT() { if (-1==rtt.parentsc) _initRTT(); return &rtt; } \ + static const x10aux::RuntimeType* getRTT() { if (NULL == rtt.typeName) _initRTT(); return &rtt; } \ static void _initRTT(); \ virtual const x10aux::RuntimeType *_type() const { return getRTT(); } #define RTT_H_DECLS_INTERFACE \ static x10aux::RuntimeType rtt; \ - static const x10aux::RuntimeType* getRTT() { if (-1==rtt.parentsc) _initRTT(); return &rtt; } \ + static const x10aux::RuntimeType* getRTT() { if (NULL == rtt.typeName) _initRTT(); return &rtt; } \ static void _initRTT(); \ #define RTT_CC_DECLS1(TYPE,NAME,P1) \ x10aux::RuntimeType TYPE::rtt; \ - void TYPE::_initRTT() { rtt.parentsc = -2; rtt.init(NAME, 1, P1::getRTT()); } + void TYPE::_initRTT() { rtt.typeName = "CYCLIC RTT INIT\n"; rtt.init(NAME, 1, P1::getRTT()); } namespace x10 { namespace lang { @@ -46,7 +46,6 @@ public: /* * RTT objects for all builtin primitive types. - * These are created by the bootstrap method */ static RuntimeType BooleanType; static RuntimeType ByteType; @@ -61,21 +60,11 @@ static RuntimeType UIntType; static RuntimeType ULongType; - - /** - * RTT object for x10::lang::Object - * Created by the bootstrap method because it - * is needed as the parent object for the primitive RTT's - */ - static RuntimeType ObjectType; - public: int parentsc; const RuntimeType **parents; const char* typeName; - RuntimeType () : parentsc(-1) { } - void init(const char* n, int pc, ...); const char *name() const { return typeName; } @@ -92,7 +81,18 @@ return other == this; } - static void bootstrap(); + static void initBooleanType(); + static void initByteType(); + static void initCharType(); + static void initShortType(); + static void initIntType(); + static void initFloatType(); + static void initLongType(); + static void initDoubleType(); + static void initUByteType(); + static void initUShortType(); + static void initUIntType(); + static void initULongType(); }; @@ -101,18 +101,78 @@ return T::getRTT(); } // specializations of getRTT template for primitive types - template<> inline const x10aux::RuntimeType *getRTT<x10_boolean>() { return &x10aux::RuntimeType::BooleanType; } - template<> inline const x10aux::RuntimeType *getRTT<x10_byte>() { return &x10aux::RuntimeType::ByteType; } - template<> inline const x10aux::RuntimeType *getRTT<x10_short>() { return &x10aux::RuntimeType::ShortType; } - template<> inline const x10aux::RuntimeType *getRTT<x10_char>() { return &x10aux::RuntimeType::CharType; } - template<> inline const x10aux::RuntimeType *getRTT<x10_int>() { return &x10aux::RuntimeType::IntType; } - template<> inline const x10aux::RuntimeType *getRTT<x10_float>() { return &x10aux::RuntimeType::FloatType; } - template<> inline const x10aux::RuntimeType *getRTT<x10_long>() { return &x10aux::RuntimeType::LongType; } - template<> inline const x10aux::RuntimeType *getRTT<x10_double>() { return &x10aux::RuntimeType::DoubleType; } - template<> inline const x10aux::RuntimeType *getRTT<x10_ubyte>() { return &x10aux::RuntimeType::UByteType; } - template<> inline const x10aux::RuntimeType *getRTT<x10_ushort>() { return &x10aux::RuntimeType::UShortType; } - template<> inline const x10aux::RuntimeType *getRTT<x10_uint>() { return &x10aux::RuntimeType::UIntType; } - template<> inline const x10aux::RuntimeType *getRTT<x10_ulong>() { return &x10aux::RuntimeType::ULongType; } + template<> inline const x10aux::RuntimeType *getRTT<x10_boolean>() { + if (NULL == x10aux::RuntimeType::BooleanType.typeName) { + x10aux::RuntimeType::initBooleanType(); + } + return &x10aux::RuntimeType::BooleanType; + } + template<> inline const x10aux::RuntimeType *getRTT<x10_byte>() { + if (NULL == x10aux::RuntimeType::ByteType.typeName) { + x10aux::RuntimeType::initByteType(); + } + return &x10aux::RuntimeType::ByteType; + } + template<> inline const x10aux::RuntimeType *getRTT<x10_char>() { + if (NULL == x10aux::RuntimeType::CharType.typeName) { + x10aux::RuntimeType::initCharType(); + } + return &x10aux::RuntimeType::CharType; + } + template<> inline const x10aux::RuntimeType *getRTT<x10_short>() { + if (NULL == x10aux::RuntimeType::ShortType.typeName) { + x10aux::RuntimeType::initShortType(); + } + return &x10aux::RuntimeType::ShortType; + } + template<> inline const x10aux::RuntimeType *getRTT<x10_int>() { + if (NULL == x10aux::RuntimeType::IntType.typeName) { + x10aux::RuntimeType::initIntType(); + } + return &x10aux::RuntimeType::IntType; + } + template<> inline const x10aux::RuntimeType *getRTT<x10_float>() { + if (NULL == x10aux::RuntimeType::FloatType.typeName) { + x10aux::RuntimeType::initFloatType(); + } + return &x10aux::RuntimeType::FloatType; + } + template<> inline const x10aux::RuntimeType *getRTT<x10_long>() { + if (NULL == x10aux::RuntimeType::LongType.typeName) { + x10aux::RuntimeType::initLongType(); + } + return &x10aux::RuntimeType::LongType; + } + template<> inline const x10aux::RuntimeType *getRTT<x10_double>() { + if (NULL == x10aux::RuntimeType::DoubleType.typeName) { + x10aux::RuntimeType::initDoubleType(); + } + return &x10aux::RuntimeType::DoubleType; + } + template<> inline const x10aux::RuntimeType *getRTT<x10_ubyte>() { + if (NULL == x10aux::RuntimeType::UByteType.typeName) { + x10aux::RuntimeType::initUByteType(); + } + return &x10aux::RuntimeType::UByteType; + } + template<> inline const x10aux::RuntimeType *getRTT<x10_ushort>() { + if (NULL == x10aux::RuntimeType::UShortType.typeName) { + x10aux::RuntimeType::initUShortType(); + } + return &x10aux::RuntimeType::UShortType; + } + template<> inline const x10aux::RuntimeType *getRTT<x10_uint>() { + if (NULL == x10aux::RuntimeType::UIntType.typeName) { + x10aux::RuntimeType::initUIntType(); + } + return &x10aux::RuntimeType::UIntType; + } + template<> inline const x10aux::RuntimeType *getRTT<x10_ulong>() { + if (NULL == x10aux::RuntimeType::ULongType.typeName) { + x10aux::RuntimeType::initULongType(); + } + return &x10aux::RuntimeType::ULongType; + } // This is different to getRTT because it distinguishes between T and ref<T> template<class T> struct TypeName { static const char *_() { Modified: trunk/x10.runtime.17/src-cpp/x10aux/bootstrap.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10aux/bootstrap.h 2009-07-27 13:15:24 UTC (rev 10884) +++ trunk/x10.runtime.17/src-cpp/x10aux/bootstrap.h 2009-07-27 15:16:37 UTC (rev 10885) @@ -67,7 +67,6 @@ void initialize_xrx(); template<class Runtime, class T> int template_main(int ac, char **av) { - x10aux::ref<x10::lang::Rail<x10aux::ref<x10::lang::String> > > args = x10aux::convert_args(ac, av); Modified: trunk/x10.runtime.17/src-cpp/x10aux/pgas.cc =================================================================== --- trunk/x10.runtime.17/src-cpp/x10aux/pgas.cc 2009-07-27 13:15:24 UTC (rev 10884) +++ trunk/x10.runtime.17/src-cpp/x10aux/pgas.cc 2009-07-27 15:16:37 UTC (rev 10885) @@ -144,7 +144,6 @@ #ifdef X10_USE_BDWGC GC_INIT(); #endif - RuntimeType::bootstrap(); _X_("PGAS initialization starting"); x10rt_register_async_callback(deserialize_remote_closure); x10rt_init(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <vj...@us...> - 2009-08-03 14:12:38
|
Revision: 10899 http://x10.svn.sourceforge.net/x10/?rev=10899&view=rev Author: vj0 Date: 2009-08-03 13:48:38 +0000 (Mon, 03 Aug 2009) Log Message: ----------- Fixed several type-checking bugs reported by Joel (or discovered when fixing these bugs). For some reason, for loop type-checking was incompletely implemented. Code has been uncommented so that the loop is properly type-checked. This revealed several bugs that have been fixed. For some reason, type bounds on classes were not making it through. A distinction is now made between upperBound(t) and upperTypeBound(t). The former provides all the upper bounds for the type t which are sources for inheritance of members. The latter includes upper bounds on the type t that are inferred upper bounds through variance annotations. These additional upper bounds do not actually supply additional members (methods, fields) -- the fields and methods they identify are already implemented by pre-eisting fields/methods on the class -- but need to be upper bounds because the type system is nominal. Fixed typebounds so that variance is respected. If X <: Y and M takes a type parameter with a + annotation, then M[X] <: M[Y]. Fixed X10TypeEnv_c.isSubType so that it uses upperTypeBound. Had to substantially change the implementation of isSubType. When checking Gamma |- S <: T, the constraints in S need to be added to Gamma. This is necessary because T may be parametrized, and the type parameters may need the constraints for their corresponding type-check to be performed. So now the following typechecks: class ForBug { abstract class A(v: Int) implements Iterable[Int{self==this.v}] { def this(x: Int) { property(x); } } def f(a: A{self.v == 41}) { for (val x: Int{self == 41} in a) ; } } The following also typechecks: public class X { class Row {} abstract class Mat[+T]{T <: Row} implements Iterable[T] { { for (r:Row in this) ; } incomplete def m(x:T):Void; } } Modified Paths: -------------- trunk/x10.compiler.p3/src/polyglot/ext/x10/ast/X10ClassDecl_c.java trunk/x10.compiler.p3/src/polyglot/ext/x10/ast/X10Formal_c.java trunk/x10.compiler.p3/src/polyglot/ext/x10/ast/X10Loop_c.java trunk/x10.compiler.p3/src/polyglot/ext/x10/types/TypeParamSubst.java trunk/x10.compiler.p3/src/polyglot/ext/x10/types/X10ClassDef_c.java trunk/x10.compiler.p3/src/polyglot/ext/x10/types/X10ClassType.java trunk/x10.compiler.p3/src/polyglot/ext/x10/types/X10Context_c.java trunk/x10.compiler.p3/src/polyglot/ext/x10/types/X10Def.java trunk/x10.compiler.p3/src/polyglot/ext/x10/types/X10FieldDef_c.java trunk/x10.compiler.p3/src/polyglot/ext/x10/types/X10InitializerDef_c.java trunk/x10.compiler.p3/src/polyglot/ext/x10/types/X10LocalDef_c.java trunk/x10.compiler.p3/src/polyglot/ext/x10/types/X10ParsedClassType.java trunk/x10.compiler.p3/src/polyglot/ext/x10/types/X10ParsedClassType_c.java trunk/x10.compiler.p3/src/polyglot/ext/x10/types/X10TypeEnv.java trunk/x10.compiler.p3/src/polyglot/ext/x10/types/X10TypeEnv_c.java trunk/x10.constraints/src/x10/constraint/XConstraint.java trunk/x10.constraints/src/x10/constraint/XTerms.java trunk/x10.tests/examples/Constructs/For/ForLoop2.x10 trunk/x10.tests/examples/Constructs/ForEach/Foreach1.x10 trunk/x10.tests/examples/Constructs/ForEach/Foreach2.x10 Added Paths: ----------- trunk/x10.compiler.p3/src/polyglot/ext/x10/types/notes.txt Modified: trunk/x10.compiler.p3/src/polyglot/ext/x10/ast/X10ClassDecl_c.java =================================================================== --- trunk/x10.compiler.p3/src/polyglot/ext/x10/ast/X10ClassDecl_c.java 2009-08-02 17:44:47 UTC (rev 10898) +++ trunk/x10.compiler.p3/src/polyglot/ext/x10/ast/X10ClassDecl_c.java 2009-08-03 13:48:38 UTC (rev 10899) @@ -30,6 +30,8 @@ import polyglot.ext.x10.extension.X10Del_c; import polyglot.ext.x10.types.MacroType; import polyglot.ext.x10.types.ParameterType; +import polyglot.ext.x10.types.TypeConstraint; +import polyglot.ext.x10.types.TypeConstraint_c; import polyglot.ext.x10.types.X10ClassDef; import polyglot.ext.x10.types.X10ClassDef_c; import polyglot.ext.x10.types.X10ClassType; @@ -50,6 +52,7 @@ import polyglot.types.ObjectType; import polyglot.types.QName; import polyglot.types.Ref; +import polyglot.types.Ref_c; import polyglot.types.ReferenceType; import polyglot.types.SemanticException; import polyglot.types.Type; @@ -427,6 +430,7 @@ 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(); @@ -449,7 +453,28 @@ }); def.setClassInvariant(c); + + final Ref<TypeConstraint> tc = new LazyRef_c<TypeConstraint>(new TypeConstraint_c()); + + // Set the type bounds for the def. + c.setResolver(new Runnable() { + public void run() { + TypeConstraint x = new TypeConstraint_c(); + + if (ci != null) { + + TypeConstraint ti = ci.typeConstraint().get(); + x.addIn(ti); + } + + + tc.update(x); + } + }); + + def.setTypeBounds(tc); + return n; } Modified: trunk/x10.compiler.p3/src/polyglot/ext/x10/ast/X10Formal_c.java =================================================================== --- trunk/x10.compiler.p3/src/polyglot/ext/x10/ast/X10Formal_c.java 2009-08-02 17:44:47 UTC (rev 10898) +++ trunk/x10.compiler.p3/src/polyglot/ext/x10/ast/X10Formal_c.java 2009-08-03 13:48:38 UTC (rev 10899) @@ -177,7 +177,9 @@ try { // Find the most-specific closure type. - X10MethodInstance mi = ts.findMethod(containerType, ts.MethodMatcher(containerType, Name.make("apply"), Collections.EMPTY_LIST, actualTypes, context)); + X10MethodInstance mi = ts.findMethod(containerType, + ts.MethodMatcher(containerType, Name.make("apply"), + Collections.EMPTY_LIST, actualTypes, context)); indexType = mi.returnType(); } catch (SemanticException e) { Modified: trunk/x10.compiler.p3/src/polyglot/ext/x10/ast/X10Loop_c.java =================================================================== --- trunk/x10.compiler.p3/src/polyglot/ext/x10/ast/X10Loop_c.java 2009-08-02 17:44:47 UTC (rev 10898) +++ trunk/x10.compiler.p3/src/polyglot/ext/x10/ast/X10Loop_c.java 2009-08-03 13:48:38 UTC (rev 10899) @@ -208,14 +208,14 @@ } } - if (true) - return this; + /*if (true) + return this;*/ try { - throw new SemanticException("Loop domain " + domainType + " is not Iterable[" + formalType + "].", position()); + throw new SemanticException("Loop domain " + domainType + " is not a subtype of Iterable[" + formalType + "].", position()); } catch (SemanticException e) { - tc.errorQueue().enqueue(ErrorInfo.WARNING, "WARNING (should be error, but type-checker is broken): " + e.getMessage(), position()); + tc.errorQueue().enqueue(ErrorInfo.SEMANTIC_ERROR, "ERROR: " + e.getMessage(), position()); return this; } } Modified: trunk/x10.compiler.p3/src/polyglot/ext/x10/types/TypeParamSubst.java =================================================================== --- trunk/x10.compiler.p3/src/polyglot/ext/x10/types/TypeParamSubst.java 2009-08-02 17:44:47 UTC (rev 10898) +++ trunk/x10.compiler.p3/src/polyglot/ext/x10/types/TypeParamSubst.java 2009-08-03 13:48:38 UTC (rev 10899) @@ -29,460 +29,469 @@ import x10.constraint.XTerm; import x10.constraint.XTerms; +/** + * Comments by vj. + * Implements a type substitution [ActualT1,..., ActualTn/FormalX1,..., FormalXn]. + * @author nystrom + * + */ public class TypeParamSubst { - List<Type> typeArguments; - List<ParameterType> typeParameters; - X10TypeSystem ts; + List<Type> typeArguments; + List<ParameterType> typeParameters; + X10TypeSystem ts; - public TypeParamSubst(X10TypeSystem ts, List<Type> typeArguments2, List<ParameterType> typeParameters2) { - typeArguments2 = typeArguments2 == null ? (List) typeParameters2 : (List) typeArguments2; - assert (typeParameters2 == null ? typeArguments2 == null : typeArguments2.size() == typeParameters2.size()); - this.ts = ts; - this.typeArguments = typeArguments2 == null ? Collections.EMPTY_LIST : typeArguments2; - this.typeParameters = typeParameters2 == null ? Collections.EMPTY_LIST : typeParameters2; - } + public TypeParamSubst(X10TypeSystem ts, List<Type> typeArguments2, + List<ParameterType> typeParameters2) { + typeArguments2 = typeArguments2 == null ? (List) typeParameters2 : (List) typeArguments2; + assert (typeParameters2 == null ? typeArguments2 == null + : typeArguments2.size() == typeParameters2.size()); + this.ts = ts; + this.typeArguments = typeArguments2 == null ? Collections.EMPTY_LIST : typeArguments2; + this.typeParameters = typeParameters2 == null ? Collections.EMPTY_LIST : typeParameters2; + } - public static boolean isSameParameter(ParameterType pt1, ParameterType pt2) { - return pt1 == pt2 || (Types.get(pt1.def()) == Types.get(pt2.def()) && pt1.name().equals(pt2.name())); - } + public static boolean isSameParameter(ParameterType pt1, ParameterType pt2) { + return pt1 == pt2 + || (Types.get(pt1.def()) == Types.get(pt2.def()) && pt1.name().equals(pt2.name())); + } - public Type reinstantiateType(Type t) { - if (t instanceof ParameterType) { - ParameterType pt = (ParameterType) t; - for (int i = 0; i < typeParameters.size(); i++) { - ParameterType pt2 = typeParameters.get(i); - if (i < typeArguments.size()) { - if (isSameParameter(pt, pt2)) { - return typeArguments.get(i); - } + public Type reinstantiateType(Type t) { + if (t instanceof ParameterType) { + ParameterType pt = (ParameterType) t; + for (int i = 0; i < typeParameters.size(); i++) { + ParameterType pt2 = typeParameters.get(i); + if (i < typeArguments.size()) { + if (isSameParameter(pt, pt2)) { + return typeArguments.get(i); + } + } + } + return pt; } - } - return pt; + if (t instanceof ConstrainedType) { + ConstrainedType ct = (ConstrainedType) t; + ct = ct.baseType(reinstantiate(ct.baseType())); + ct = ct.constraint(reinstantiate(ct.constraint())); + return ct; + } + if (t instanceof MacroType) { + MacroType mt = (MacroType) t; + final MacroType fi = mt; + return new MacroType_c(ts, mt.position(), Types.ref(mt.def())) { + @Override + public Ref<? extends Type> returnTypeRef() { + if (definedType == null) + return reinstantiate(fi.returnTypeRef()); + return definedType; + } + @Override + public Type returnType() { + if (definedType == null) + return reinstantiate(fi.returnType()); + return definedType.get(); + } + @Override + public Ref<? extends Type> definedTypeRef() { + if (definedType == null) + return reinstantiate(fi.definedTypeRef()); + return definedType; + } + @Override + public Type definedType() { + if (definedType == null) + return reinstantiate(fi.definedType()); + return definedType.get(); + } + @Override + public List<Type> formalTypes() { + if (formalTypes == null) + return reinstantiate(fi.formalTypes()); + return formalTypes; + } + @Override + public XConstraint guard() { + if (guard == null) + return reinstantiate(fi.guard()); + return guard; + } + + }; + } + // if (t instanceof ClosureType) { + // ClosureType ct = (ClosureType) t; + // ct = (ClosureType) ct.copy(); + // ct = ct.closureInstance(reinstantiate(ct.applyMethod())); + // return ct; + // } + if (t instanceof X10ClassType) { + X10ClassType ct = (X10ClassType) t; + if (! hasParams(ct)) + return t; + ct = (X10ClassType) ct.copy(); + ct = ct.typeArguments(reinstantiate(ct.typeArguments())); + if (ct.isMember()) { + ct = (X10ParsedClassType) ct.container(reinstantiate(ct.container())); + } + // This just sucks up memory and slows things down. + // Pair p = new Pair(ct.def(), ct.typeArguments()); + // Map<Object, Type> tcache = ((X10TypeSystem_c) ts).tcache; + // Type o = tcache.get(p); + // if (o != null) + // return o; + // tcache.put(p, ct); + return ct; + } + return t; } - if (t instanceof ConstrainedType) { - ConstrainedType ct = (ConstrainedType) t; - ct = ct.baseType(reinstantiate(ct.baseType())); - ct = ct.constraint(reinstantiate(ct.constraint())); - return ct; + + boolean hasParams(X10ClassType t) { + if (t.typeArguments().size() != 0) { + return true; + } + if (t.isMember()) + return hasParams((X10ClassType) t.outer()); + if (! t.isTopLevel()) + return true; + return false; } - if (t instanceof MacroType) { - MacroType mt = (MacroType) t; - final MacroType fi = mt; - return new MacroType_c(ts, mt.position(), Types.ref(mt.def())) { - @Override - public Ref<? extends Type> returnTypeRef() { - if (definedType == null) - return reinstantiate(fi.returnTypeRef()); - return definedType; - } - @Override - public Type returnType() { - if (definedType == null) - return reinstantiate(fi.returnType()); - return definedType.get(); - } - @Override - public Ref<? extends Type> definedTypeRef() { - if (definedType == null) - return reinstantiate(fi.definedTypeRef()); - return definedType; - } - @Override - public Type definedType() { - if (definedType == null) - return reinstantiate(fi.definedType()); - return definedType.get(); - } - @Override - public List<Type> formalTypes() { - if (formalTypes == null) - return reinstantiate(fi.formalTypes()); - return formalTypes; - } - @Override - public XConstraint guard() { - if (guard == null) - return reinstantiate(fi.guard()); - return guard; - } - }; + public boolean isIdentityInstantiation() { + if (typeArguments == null) return true; + int n = typeParameters.size(); + if (n != typeArguments.size()) return false; + for (int i = 0; i < n; i++) { + ParameterType pt = typeParameters.get(i); + Type at = typeArguments.get(i); + if (at instanceof ParameterType) { + ParameterType apt = (ParameterType) at; + if (! isSameParameter(pt, apt)) + return false; + } + else { + return false; + } + } + return true; } -// if (t instanceof ClosureType) { -// ClosureType ct = (ClosureType) t; -// ct = (ClosureType) ct.copy(); -// ct = ct.closureInstance(reinstantiate(ct.applyMethod())); -// return ct; -// } - if (t instanceof X10ClassType) { - X10ClassType ct = (X10ClassType) t; - if (! hasParams(ct)) + + Map<Object,Object> cache = new HashMap<Object, Object>(); + + public <T> T reinstantiate(T t) { + if (t == null) + return null; + Object o = cache.get(t); + if (o != null && false) + return (T) o; + T x = reinstantiateUncached(t); + cache.put(t, x); + return x; + } + + private <T> T reinstantiateUncached(T t) { + if (isIdentityInstantiation()) { + return t; + } + if (t instanceof Ref) return (T) reinstantiateRef((Ref) t); + if (t instanceof Type) return (T) reinstantiateType((Type) t); + if (t instanceof X10FieldInstance) return (T) reinstantiateFI((X10FieldInstance) t); + if (t instanceof X10MethodInstance) return (T) reinstantiateMI((X10MethodInstance) t); + if (t instanceof X10ConstructorInstance) return (T) reinstantiateCI((X10ConstructorInstance) t); + if (t instanceof ClosureInstance) return (T) reinstantiateClosure((ClosureInstance) t); + if (t instanceof XConstraint) return (T) reinstantiateConstraint((XConstraint) t); + if (t instanceof XTerm) return (T) reinstantiateTerm((XTerm) t); + if (t instanceof TypeConstraint) return (T) reinstantiateTypeConstraint((TypeConstraint) t); return t; - ct = (X10ClassType) ct.copy(); - ct = ct.typeArguments(reinstantiate(ct.typeArguments())); - if (ct.isMember()) { - ct = (X10ParsedClassType) ct.container(reinstantiate(ct.container())); - } -// This just sucks up memory and slows things down. -// Pair p = new Pair(ct.def(), ct.typeArguments()); -// Map<Object, Type> tcache = ((X10TypeSystem_c) ts).tcache; -// Type o = tcache.get(p); -// if (o != null) -// return o; -// tcache.put(p, ct); - return ct; } - return t; - } - - boolean hasParams(X10ClassType t) { - if (t.typeArguments().size() != 0) { - return true; - } - if (t.isMember()) - return hasParams((X10ClassType) t.outer()); - if (! t.isTopLevel()) - return true; - return false; - } - - public boolean isIdentityInstantiation() { - if (typeArguments == null) return true; - int n = typeParameters.size(); - if (n != typeArguments.size()) return false; - for (int i = 0; i < n; i++) { - ParameterType pt = typeParameters.get(i); - Type at = typeArguments.get(i); - if (at instanceof ParameterType) { - ParameterType apt = (ParameterType) at; - if (! isSameParameter(pt, apt)) - return false; - } - else { - return false; - } + + public ClosureInstance reinstantiateClosure(ClosureInstance t) { + final ClosureInstance fi = (ClosureInstance) t.copy(); + return new ClosureInstance_c(fi.typeSystem(), fi.position(), Types.ref(fi.def())) { + @Override + public Ref<? extends Type> returnTypeRef() { + if (returnType == null) + return reinstantiate(fi.returnTypeRef()); + return returnType; + } + @Override + public Type returnType() { + if (returnType == null) + return reinstantiate(fi.returnType()); + return returnType.get(); + } + @Override + public List<Type> formalTypes() { + if (formalTypes == null) + return reinstantiate(fi.formalTypes()); + return formalTypes; + } + @Override + public List<Type> throwTypes() { + if (throwTypes == null) + return reinstantiate(fi.throwTypes()); + return throwTypes; + } + @Override + public XConstraint guard() { + if (guard == null) + return reinstantiate(fi.guard()); + return guard; + } + }; } - return true; - } - - Map<Object,Object> cache = new HashMap<Object, Object>(); - - public <T> T reinstantiate(T t) { - if (t == null) - return null; - Object o = cache.get(t); - if (o != null && false) - return (T) o; - T x = reinstantiateUncached(t); - cache.put(t, x); - return x; - } - private <T> T reinstantiateUncached(T t) { - if (isIdentityInstantiation()) { - return t; - } - if (t instanceof Ref) return (T) reinstantiateRef((Ref) t); - if (t instanceof Type) return (T) reinstantiateType((Type) t); - if (t instanceof X10FieldInstance) return (T) reinstantiateFI((X10FieldInstance) t); - if (t instanceof X10MethodInstance) return (T) reinstantiateMI((X10MethodInstance) t); - if (t instanceof X10ConstructorInstance) return (T) reinstantiateCI((X10ConstructorInstance) t); - if (t instanceof ClosureInstance) return (T) reinstantiateClosure((ClosureInstance) t); - if (t instanceof XConstraint) return (T) reinstantiateConstraint((XConstraint) t); - if (t instanceof XTerm) return (T) reinstantiateTerm((XTerm) t); - if (t instanceof TypeConstraint) return (T) reinstantiateTypeConstraint((TypeConstraint) t); - return t; - } + public Ref reinstantiateRef(final Ref t) { + if (t.known()) { + return Types.ref(reinstantiate(t.get())); + } + final LazyRef r = Types.lazyRef(null); + r.setResolver(new Runnable() { + public void run() { + r.update(reinstantiate(t.get())); + } + }); + return r; + } - public ClosureInstance reinstantiateClosure(ClosureInstance t) { - final ClosureInstance fi = (ClosureInstance) t.copy(); - return new ClosureInstance_c(fi.typeSystem(), fi.position(), Types.ref(fi.def())) { - @Override - public Ref<? extends Type> returnTypeRef() { - if (returnType == null) - return reinstantiate(fi.returnTypeRef()); - return returnType; - } - @Override - public Type returnType() { - if (returnType == null) - return reinstantiate(fi.returnType()); - return returnType.get(); - } - @Override - public List<Type> formalTypes() { - if (formalTypes == null) - return reinstantiate(fi.formalTypes()); - return formalTypes; - } - @Override - public List<Type> throwTypes() { - if (throwTypes == null) - return reinstantiate(fi.throwTypes()); - return throwTypes; - } - @Override - public XConstraint guard() { - if (guard == null) - return reinstantiate(fi.guard()); - return guard; - } - }; - } + public static XConstraint reinstantiateConstraint(X10ClassType ct, XConstraint c) { + if (c == null || c.valid()) + return c; + XConstraint result = c; + if (ct instanceof X10ParsedClassType_c) { + X10ParsedClassType_c t = (X10ParsedClassType_c) ct; + result = t.subst().reinstantiateConstraint(c); + } + return result; + } - public Ref reinstantiateRef(final Ref t) { - if (t.known()) { - return Types.ref(reinstantiate(t.get())); + public static TypeConstraint reinstantiateTypeConstraint(X10ClassType ct, TypeConstraint c) { + if (c == null) + return c; + TypeConstraint result = c; + if (ct instanceof X10ParsedClassType_c) { + X10ParsedClassType_c t = (X10ParsedClassType_c) ct; + result = t.subst().reinstantiateTypeConstraint(c); + } + return result; } - final LazyRef r = Types.lazyRef(null); - r.setResolver(new Runnable() { - public void run() { - r.update(reinstantiate(t.get())); - } - }); - return r; - } - public static XConstraint reinstantiateConstraint(X10ClassType ct, XConstraint c) { - if (c == null || c.valid()) - return c; - XConstraint result = c; - if (ct instanceof X10ParsedClassType_c) { - X10ParsedClassType_c t = (X10ParsedClassType_c) ct; - result = t.subst().reinstantiateConstraint(c); - } - return result; - } - - public static TypeConstraint reinstantiateTypeConstraint(X10ClassType ct, TypeConstraint c) { - if (c == null) - return c; - TypeConstraint result = c; - if (ct instanceof X10ParsedClassType_c) { - X10ParsedClassType_c t = (X10ParsedClassType_c) ct; - result = t.subst().reinstantiateTypeConstraint(c); - } - return result; - } + public XConstraint reinstantiateConstraint(XConstraint c) { + if (isIdentityInstantiation()) { + return c; + } - public XConstraint reinstantiateConstraint(XConstraint c) { - if (isIdentityInstantiation()) { - return c; - } + int n = typeParameters.size(); + assert typeArguments.size() == n; - int n = typeParameters.size(); - assert typeArguments.size() == n; + XTerm[] ys = new XTerm[n]; + XRoot[] xs = new XRoot[n]; - XTerm[] ys = new XTerm[n]; - XRoot[] xs = new XRoot[n]; + for (int i = 0; i < n; i++) { + ParameterType pt = typeParameters.get(i); + Type at = typeArguments.get(i); - for (int i = 0; i < n; i++) { - ParameterType pt = typeParameters.get(i); - Type at = typeArguments.get(i); + XTerm p = ts.xtypeTranslator().trans(pt); + XTerm a = ts.xtypeTranslator().trans(at); - XTerm p = ts.xtypeTranslator().trans(pt); - XTerm a = ts.xtypeTranslator().trans(at); + ys[i] = a; - ys[i] = a; + if (p instanceof XRoot) { + xs[i] = (XRoot) p; + } + else { + xs[i] = XTerms.makeLit(XTerms.makeName("error")); + } + } - if (p instanceof XRoot) { - xs[i] = (XRoot) p; - } - else { - xs[i] = XTerms.makeLit(XTerms.makeName("error")); - } - } - - XConstraint result; + XConstraint result; - try { - result = c.substitute(ys, xs); + try { + result = c.substitute(ys, xs); + } + catch (XFailure e) { + result = new XConstraint_c(); + result.setInconsistent(); + } + + return result; } - catch (XFailure e) { - result = new XConstraint_c(); - result.setInconsistent(); - } + public TypeConstraint reinstantiateTypeConstraint(TypeConstraint c) { + if (isIdentityInstantiation()) { + return c; + } - return result; - } - public TypeConstraint reinstantiateTypeConstraint(TypeConstraint c) { - if (isIdentityInstantiation()) { - return c; - } - - int n = typeParameters.size(); - assert typeArguments.size() == n; + int n = typeParameters.size(); + assert typeArguments.size() == n; - - for (int i = 0; i < n; i++) { - ParameterType pt = typeParameters.get(i); - Type at = typeArguments.get(i); - - List<SubtypeConstraint> terms = new ArrayList<SubtypeConstraint>(c.terms().size()); - for (SubtypeConstraint s : c.terms()) { - Type t1 = s.subtype(); - Type t2 = s.supertype(); - Type t1_ = reinstantiate(t1); - Type t2_ = reinstantiate(t2); - terms.add(new SubtypeConstraint_c(t1_, t2_, s.isEqualityConstraint())); - } - TypeConstraint_c c_ = new TypeConstraint_c(); - c_.addTerms(terms); - c = c_; - } - - return c; - } - public XTerm reinstantiateTerm(XTerm t) { - if (isIdentityInstantiation()) { - return t; + for (int i = 0; i < n; i++) { + ParameterType pt = typeParameters.get(i); + Type at = typeArguments.get(i); + + List<SubtypeConstraint> terms = new ArrayList<SubtypeConstraint>(c.terms().size()); + for (SubtypeConstraint s : c.terms()) { + Type t1 = s.subtype(); + Type t2 = s.supertype(); + Type t1_ = reinstantiate(t1); + Type t2_ = reinstantiate(t2); + terms.add(new SubtypeConstraint_c(t1_, t2_, s.isEqualityConstraint())); + } + TypeConstraint_c c_ = new TypeConstraint_c(); + c_.addTerms(terms); + c = c_; + } + + return c; } - int n = typeParameters.size(); - assert typeArguments.size() == n; + public XTerm reinstantiateTerm(XTerm t) { + if (isIdentityInstantiation()) { + return t; + } - for (int i = 0; i < n; i++) { - ParameterType pt = typeParameters.get(i); - Type at = typeArguments.get(0); + int n = typeParameters.size(); + assert typeArguments.size() == n; - XTerm p = ts.xtypeTranslator().trans(pt); - XTerm a = ts.xtypeTranslator().trans(at); + for (int i = 0; i < n; i++) { + ParameterType pt = typeParameters.get(i); + Type at = typeArguments.get(0); - if (p instanceof XRoot) { - t = t.subst(p, (XRoot) a); - } + XTerm p = ts.xtypeTranslator().trans(pt); + XTerm a = ts.xtypeTranslator().trans(at); + + if (p instanceof XRoot) { + t = t.subst(p, (XRoot) a); + } + } + + return t; } - return t; - } + public X10ConstructorInstance reinstantiateCI(X10ConstructorInstance t) { + final X10ConstructorInstance fi = (X10ConstructorInstance) t.copy(); + return new X10ConstructorInstance_c(fi.typeSystem(), fi.position(), Types.ref(fi.x10Def())) { + @Override + public Ref<? extends Type> returnTypeRef() { + if (returnType == null) + return reinstantiate(fi.returnTypeRef()); + return returnType; + } + @Override + public Type returnType() { + if (returnType == null) + return reinstantiate(fi.returnType()); + return returnType.get(); + } + @Override + public List<Type> formalTypes() { + if (formalTypes == null) + return reinstantiate(fi.formalTypes()); + return formalTypes; + } + @Override + public List<Type> throwTypes() { + if (throwTypes == null) + return reinstantiate(fi.throwTypes()); + return throwTypes; + } + @Override + public XConstraint guard() { + if (guard == null) + return reinstantiate(fi.guard()); + return guard; + } + @Override + public StructType container() { + if (container == null) + return reinstantiate(fi.container()); + return container; + } + }; } - public X10ConstructorInstance reinstantiateCI(X10ConstructorInstance t) { - final X10ConstructorInstance fi = (X10ConstructorInstance) t.copy(); - return new X10ConstructorInstance_c(fi.typeSystem(), fi.position(), Types.ref(fi.x10Def())) { - @Override - public Ref<? extends Type> returnTypeRef() { - if (returnType == null) - return reinstantiate(fi.returnTypeRef()); - return returnType; - } - @Override - public Type returnType() { - if (returnType == null) - return reinstantiate(fi.returnType()); - return returnType.get(); - } - @Override - public List<Type> formalTypes() { - if (formalTypes == null) - return reinstantiate(fi.formalTypes()); - return formalTypes; - } - @Override - public List<Type> throwTypes() { - if (throwTypes == null) - return reinstantiate(fi.throwTypes()); - return throwTypes; - } - @Override - public XConstraint guard() { - if (guard == null) - return reinstantiate(fi.guard()); - return guard; - } - @Override - public StructType container() { - if (container == null) - return reinstantiate(fi.container()); - return container; - } - }; } + public X10MethodInstance reinstantiateMI(X10MethodInstance t) { + final X10MethodInstance fi = (X10MethodInstance) t.copy(); + return new X10MethodInstance_c(fi.typeSystem(), fi.position(), Types.ref(fi.x10Def())) { + @Override + public Ref<? extends Type> returnTypeRef() { + if (returnType == null) + return reinstantiate(fi.returnTypeRef()); + return returnType; + } + @Override + public Type returnType() { + if (returnType == null) + return reinstantiate(fi.returnType()); + return returnType.get(); + } + @Override + public List<Type> formalTypes() { + if (formalTypes == null) + return reinstantiate(fi.formalTypes()); + return formalTypes; + } + @Override + public List<Type> throwTypes() { + if (throwTypes == null) + return reinstantiate(fi.throwTypes()); + return throwTypes; + } + @Override + public XConstraint guard() { + if (guard == null) + return reinstantiate(fi.guard()); + return guard; + } + @Override + public StructType container() { + if (container == null) + return reinstantiate(fi.container()); + return container; + } + }; + } - public X10MethodInstance reinstantiateMI(X10MethodInstance t) { - final X10MethodInstance fi = (X10MethodInstance) t.copy(); - return new X10MethodInstance_c(fi.typeSystem(), fi.position(), Types.ref(fi.x10Def())) { - @Override - public Ref<? extends Type> returnTypeRef() { - if (returnType == null) - return reinstantiate(fi.returnTypeRef()); - return returnType; - } - @Override - public Type returnType() { - if (returnType == null) - return reinstantiate(fi.returnType()); - return returnType.get(); - } - @Override - public List<Type> formalTypes() { - if (formalTypes == null) - return reinstantiate(fi.formalTypes()); - return formalTypes; - } - @Override - public List<Type> throwTypes() { - if (throwTypes == null) - return reinstantiate(fi.throwTypes()); - return throwTypes; - } - @Override - public XConstraint guard() { - if (guard == null) - return reinstantiate(fi.guard()); - return guard; - } - @Override - public StructType container() { - if (container == null) - return reinstantiate(fi.container()); - return container; - } - }; - } + public X10FieldInstance reinstantiateFI(X10FieldInstance t) { + final X10FieldInstance fi = (X10FieldInstance) t.copy(); + return new X10FieldInstance_c(fi.typeSystem(), fi.position(), Types.ref(fi.x10Def())) { + @Override + public Type type() { + if (type == null) + return reinstantiate(fi.type()); + return type; + } + @Override + public XConstraint guard() { + if (guard == null) + return reinstantiate(fi.guard()); + return guard; + } + @Override + public StructType container() { + if (container == null) + return reinstantiate(fi.container()); + return container; + } + }; + } - public X10FieldInstance reinstantiateFI(X10FieldInstance t) { - final X10FieldInstance fi = (X10FieldInstance) t.copy(); - return new X10FieldInstance_c(fi.typeSystem(), fi.position(), Types.ref(fi.x10Def())) { - @Override - public Type type() { - if (type == null) - return reinstantiate(fi.type()); - return type; - } - @Override - public XConstraint guard() { - if (guard == null) - return reinstantiate(fi.guard()); - return guard; - } - @Override - public StructType container() { - if (container == null) - return reinstantiate(fi.container()); - return container; - } - }; - } + public <T> List<T> reinstantiate(List<T> list) { + if (isIdentityInstantiation()) { + return list; + } + return new TransformingList<T, T>(list, new Transformation<T, T>() { + public T transform(T o) { + return reinstantiate(o); + } + }); + } - public <T> List<T> reinstantiate(List<T> list) { - if (isIdentityInstantiation()) { - return list; + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("["); + sb.append(typeArguments); + sb.append("/"); + sb.append(typeParameters); + sb.append("]"); + return sb.toString(); } - return new TransformingList<T, T>(list, new Transformation<T, T>() { - public T transform(T o) { - return reinstantiate(o); - } - }); - } - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("["); - sb.append(typeArguments); - sb.append("/"); - sb.append(typeParameters); - sb.append("]"); - return sb.toString(); - } - } Modified: trunk/x10.compiler.p3/src/polyglot/ext/x10/types/X10ClassDef_c.java =================================================================== --- trunk/x10.compiler.p3/src/polyglot/ext/x10/types/X10ClassDef_c.java 2009-08-02 17:44:47 UTC (rev 10898) +++ trunk/x10.compiler.p3/src/polyglot/ext/x10/types/X10ClassDef_c.java 2009-08-03 13:48:38 UTC (rev 10899) @@ -16,8 +16,10 @@ import polyglot.frontend.Source; import polyglot.types.ClassDef_c; import polyglot.types.FieldDef; +import polyglot.types.LazyRef_c; import polyglot.types.QName; import polyglot.types.Ref; +import polyglot.types.Ref_c; import polyglot.types.SemanticException; import polyglot.types.Type; import polyglot.types.TypeSystem; @@ -317,4 +319,7 @@ public void addMemberType(TypeDef t) { typeMembers.add(t); } + public Ref<TypeConstraint> typeGuard() { + return new LazyRef_c<TypeConstraint>(X10TypeMixin.parameterBounds(asType())); + } } Modified: trunk/x10.compiler.p3/src/polyglot/ext/x10/types/X10ClassType.java =================================================================== --- trunk/x10.compiler.p3/src/polyglot/ext/x10/types/X10ClassType.java 2009-08-02 17:44:47 UTC (rev 10898) +++ trunk/x10.compiler.p3/src/polyglot/ext/x10/types/X10ClassType.java 2009-08-03 13:48:38 UTC (rev 10899) @@ -56,6 +56,7 @@ List<Type> typeArguments(); X10ClassType typeArguments(List<Type> typeArgs); + boolean hasParams(); List<Type> typeMembers(); MacroType typeMemberMatching(Matcher<Named> matcher); Modified: trunk/x10.compiler.p3/src/polyglot/ext/x10/types/X10Context_c.java =================================================================== --- trunk/x10.compiler.p3/src/polyglot/ext/x10/types/X10Context_c.java 2009-08-02 17:44:47 UTC (rev 10898) +++ trunk/x10.compiler.p3/src/polyglot/ext/x10/types/X10Context_c.java 2009-08-03 13:48:38 UTC (rev 10899) @@ -181,6 +181,7 @@ /* sigma(Gamma) restricted to the variables mentioned in c */ private XConstraint constraintProjection(XConstraint c, Map<XTerm,XConstraint> m) throws XFailure { XConstraint r = new XConstraint_c(); + if (c != null) for (XTerm t : c.constraints()) { XConstraint tc = constraintProjection(t, m); if (tc != null) @@ -283,18 +284,33 @@ return null; } - - protected TypeConstraint currentTypeConstraint; - public TypeConstraint currentTypeConstraint() { if (currentTypeConstraint == null) return new TypeConstraint_c(); return currentTypeConstraint; } - public void setCurrentTypeConstraint(TypeConstraint c) { currentTypeConstraint = c; } + public TypeConstraint currentTypeConstraint() { + if (currentTypeConstraint == null) + return new TypeConstraint_c(); + return currentTypeConstraint; } + public void setCurrentTypeConstraint(TypeConstraint c) { + currentTypeConstraint = c; + } protected XConstraint currentPlaceConstraint; - public XConstraint currentPlaceConstraint() { if (currentPlaceConstraint == null) return new XConstraint_c(); return currentPlaceConstraint; } - public void setCurrentPlaceConstraint(XConstraint c) { currentPlaceConstraint = c; } + public XConstraint currentPlaceConstraint() { + if (currentPlaceConstraint == null) + return new XConstraint_c(); + return currentPlaceConstraint; + } + public void setCurrentPlaceConstraint(XConstraint c) { + currentPlaceConstraint = c; + } protected XConstraint currentConstraint; - public XConstraint currentConstraint() { if (currentConstraint == null) return new XConstraint_c(); return currentConstraint; } - public void setCurrentConstraint(XConstraint c) { currentConstraint = c; } + public XConstraint currentConstraint() { + if (currentConstraint == null) + return new XConstraint_c(); + return currentConstraint; + } + public void setCurrentConstraint(XConstraint c) { + currentConstraint = c; + } public CodeDef definingCodeDef(Name name) { if ((isBlock() || isCode()) && @@ -305,7 +321,6 @@ if (outer instanceof X10Context) { return ((X10Context) outer).definingCodeDef(name); } - return null; } @@ -752,7 +767,8 @@ public String toString() { return "(" + (depType != null ? "depType " + depType : kind.toString()) + - " " + mapsToString() + " " + outer + ")"; + (currentConstraint !=null ? " constraint " + currentConstraint : "") + + " "+ mapsToString() + " " + outer + ")"; } static protected int varCount = 0; Modified: trunk/x10.compiler.p3/src/polyglot/ext/x10/types/X10Def.java =================================================================== --- trunk/x10.compiler.p3/src/polyglot/ext/x10/types/X10Def.java 2009-08-02 17:44:47 UTC (rev 10898) +++ trunk/x10.compiler.p3/src/polyglot/ext/x10/types/X10Def.java 2009-08-03 13:48:38 UTC (rev 10899) @@ -14,6 +14,26 @@ import polyglot.types.Ref; import polyglot.types.Type; +/** + * Commentary by vj. + * Interface implemented by all X10 definitions: + * + * TypeDef -- a type definition in X10 (macro-expander) + * X10ProcedureDef + * X10ConstructorDef + * X10MethodDef + * ClosureDef + * X10ClassDef + * X10FieldDef + * X10LocalDef + * X10MemberDef + * X10InitializerDef + * + * + * @author njnystrom + * @author vj + * + */ public interface X10Def extends Def { /** Get the annotations on the definition. */ List<Ref<? extends Type>> defAnnotations(); @@ -23,4 +43,12 @@ List<Type> annotations(); List<Type> annotationsMatching(Type t); + + /** + * Return the type guard, if any, associated with this definition. + * The type guard specifies the type constraints on type parameters + * introduced by this definition. + * @return + */ + Ref<TypeConstraint> typeGuard(); } Modified: trunk/x10.compiler.p3/src/polyglot/ext/x10/types/X10FieldDef_c.java =================================================================== --- trunk/x10.compiler.p3/src/polyglot/ext/x10/types/X10FieldDef_c.java 2009-08-02 17:44:47 UTC (rev 10898) +++ trunk/x10.compiler.p3/src/polyglot/ext/x10/types/X10FieldDef_c.java 2009-08-03 13:48:38 UTC (rev 10899) @@ -87,4 +87,10 @@ public void setProperty() { isProperty = true; } + /** A field declaration cannot have a type guard. + * + */ + public Ref<TypeConstraint> typeGuard() { + return null; + } } Modified: trunk/x10.compiler.p3/src/polyglot/ext/x10/types/X10InitializerDef_c.java =================================================================== --- trunk/x10.compiler.p3/src/polyglot/ext/x10/types/X10InitializerDef_c.java 2009-08-02 17:44:47 UTC (rev 10898) +++ trunk/x10.compiler.p3/src/polyglot/ext/x10/types/X10InitializerDef_c.java 2009-08-03 13:48:38 UTC (rev 10899) @@ -56,4 +56,10 @@ } // END ANNOTATION MIXIN + /** An X10 Initializer cannot have an explicit typeguard. + * + */ + public Ref<TypeConstraint> typeGuard() { + return null; + } } Modified: trunk/x10.compiler.p3/src/polyglot/ext/x10/types/X10LocalDef_c.java =================================================================== --- trunk/x10.compiler.p3/src/polyglot/ext/x10/types/X10LocalDef_c.java 2009-08-02 17:44:47 UTC (rev 10898) +++ trunk/x10.compiler.p3/src/polyglot/ext/x10/types/X10LocalDef_c.java 2009-08-03 13:48:38 UTC (rev 10899) @@ -86,4 +86,10 @@ return X10TypeObjectMixin.annotationsNamed(this, fullName); } // END ANNOTATION MIXIN + /** An X10 Local definition cannot have a type guard. + * + */ + public Ref<TypeConstraint> typeGuard() { + return null; + } } Modified: trunk/x10.compiler.p3/src/polyglot/ext/x10/types/X10ParsedClassType.java =================================================================== --- trunk/x10.compiler.p3/src/polyglot/ext/x10/types/X10ParsedClassType.java 2009-08-02 17:44:47 UTC (rev 10898) +++ trunk/x10.compiler.p3/src/polyglot/ext/x10/types/X10ParsedClassType.java 2009-08-03 13:48:38 UTC (rev 10899) @@ -21,5 +21,7 @@ * */ public interface X10ParsedClassType extends ParsedClassType, X10ClassType, X10NamedType { + + } Modified: trunk/x10.compiler.p3/src/polyglot/ext/x10/types/X10ParsedClassType_c.java =================================================================== --- trunk/x10.compiler.p3/src/polyglot/ext/x10/types/X10ParsedClassType_c.java 2009-08-02 17:44:47 UTC (rev 10898) +++ trunk/x10.compiler.p3/src/polyglot/ext/x10/types/X10ParsedClassType_c.java 2009-08-03 13:48:38 UTC (rev 10899) @@ -128,7 +128,7 @@ return def().fromJavaClassFile(); } - boolean hasParams() { + public boolean hasParams() { return x10Def().typeParameters() != null && x10Def().typeParameters().size() != 0; } Modified: trunk/x10.compiler.p3/src/polyglot/ext/x10/types/X10TypeEnv.java =================================================================== --- trunk/x10.compiler.p3/src/polyglot/ext/x10/types/X10TypeEnv.java 2009-08-02 17:44:47 UTC (rev 10898) +++ trunk/x10.compiler.p3/src/polyglot/ext/x10/types/X10TypeEnv.java 2009-08-03 13:48:38 UTC (rev 10899) @@ -20,6 +20,12 @@ /** Return true if constraints in the type are all consistent. */ boolean consistent(Type t); + /** + * Return a lit of upper bounds for type t. + * @param t + * @param includeObject + * @return + */ List<Type> upperBounds(Type t, boolean includeObject); List<Type> lowerBounds(Type t); @@ -31,7 +37,7 @@ boolean isSubtypeWithValueInterfaces(Type t1, Type t2); boolean isSubtype(Type t1, Type t2, boolean allowValueInterfaces); - + boolean entails(XConstraint c1, XConstraint c2); boolean hasSameClassDef(Type t1, Type t2); Modified: trunk/x10.compiler.p3/src/polyglot/ext/x10/types/X10TypeEnv_c.java =================================================================== --- trunk/x10.compiler.p3/src/polyglot/ext/x10/types/X10TypeEnv_c.java 2009-08-02 17:44:47 UTC (rev 10898) +++ trunk/x10.compiler.p3/src/polyglot/ext/x10/types/X10TypeEnv_c.java 2009-08-03 13:48:38 UTC (rev 10899) @@ -15,6 +15,8 @@ import java.util.List; import java.util.Set; +import polyglot.ext.x10.ast.X10Special; +import polyglot.ext.x10.types.ParameterType.Variance; import polyglot.ext.x10.types.X10TypeSystem_c.Bound; import polyglot.ext.x10.types.X10TypeSystem_c.Kind; import polyglot.main.Report; @@ -229,8 +231,17 @@ * @see polyglot.ext.x10.types.X10TypeEnv#upperBounds(polyglot.types.Type, boolean) */ public List<Type> upperBounds(Type t, boolean includeObject) { - return bounds(t, Bound.UPPER, includeObject); + List<Type> bounds = bounds(t, Bound.UPPER, includeObject); + return bounds; } + public List<Type> upperTypeBounds(Type t, boolean includeObject) { + List<Type> bounds = typeBounds(t, Bound.UPPER, includeObject); + return bounds; + } + public List<Type> lowerTypeBounds(Type t) { + List<Type> bounds = typeBounds(t, Bound.LOWER, false); + return bounds; + } /* (non-Javadoc) * @see polyglot.ext.x10.types.X10TypeEnv#lowerBounds(polyglot.types.Type) */ @@ -334,6 +345,95 @@ return Kind.NEITHER; } + List<Type> typeBounds(Type t, Bound kind, boolean includeObject) { + List<Type> result = new ArrayList<Type>(); + Set<Type> visited = new HashSet<Type>(); + + LinkedList<Type> worklist = new LinkedList<Type>(); + worklist.add(t); + + while (! worklist.isEmpty()) { + Type w = worklist.removeFirst(); + + // Expand macros, remove constraints + Type expanded = X10TypeMixin.baseType(w); + + if (visited.contains(expanded)) { + continue; + } + + visited.add(expanded); + +// // Get constraints from the type's where clause. +// XConstraint wc = X10TypeMixin.xclause(w); +// if (wc != null) { +// List<Type> b = getBoundsFromConstraint(t, wc, kind); +// worklist.addAll(b); +// } + + if (expanded instanceof ParameterType) { + ParameterType pt = (ParameterType) expanded; + X10Def def = (X10Def) Types.get(pt.def()); + Ref<TypeConstraint> ref = def.typeGuard(); + if (ref != null) { + TypeConstraint c = Types.get(def.typeGuard()); + List<Type> b = getBoundsFromConstraint(pt, c, kind); + worklist.addAll(b); + } + continue; + } + // vj: + // If U is an upperbound of Ti, then + // C[T1,..,Ti-1,U,Ti+1,...,Tn] is an upperbound of C[T1,.., Tn] + if (expanded instanceof X10ClassType && kind == Bound.UPPER) { + X10ClassType ct = (X10ClassType) expanded; + + if (ct.hasParams()) { + List<Type> typeArgs = ct.typeArguments(); + X10ClassDef def = ct.x10Def(); + List<Variance> variances = def.variances(); + + for (int i=0; i < typeArgs.size(); i++) { + ParameterType.Variance v = variances.get(i); + switch (v) { + case COVARIANT: + for (Type type : upperBounds(typeArgs.get(i), true)) { + X10ClassType ct1 = (X10ClassType) ct.copy(); + List<Type> typeArgs1 = new ArrayList<Type>(typeArgs); //copy + typeArgs1.set(i,type); + ct1 = ct1.typeArguments(typeArgs1); + result.add(ct1); + } + break; + case CONTRAVARIANT: + for (Type type : lowerBounds(typeArgs.get(i))) { + X10ClassType ct1 = (X10ClassType) ct.copy(); + List<Type> typeArgs1 = new ArrayList<Type>(typeArgs); //copy + typeArgs1.set(i,type); + ct1 = ct1.typeArguments(typeArgs1); + result.add(ct1); + } + break; + + case INVARIANT: + break; + } + + } + } + } + result.add(expanded); + } + + if (kind == Bound.UPPER && result.isEmpty()) + if (includeObject) + return Collections.<Type>singletonList(ts.Object()); + else + return Collections.<Type>emptyList(); + + return new ArrayList<Type>(result); + } + List<Type> bounds(Type t, Bound kind, boolean includeObject) { List<Type> result = new ArrayList<Type>(); Set<Type> visited = new HashSet<Type>(); @@ -362,40 +462,15 @@ if (expanded instanceof ParameterType) { ParameterType pt = (ParameterType) expanded; - Def def = Types.get(pt.def()); - if (def instanceof X10ClassDef) { - X10ClassDef cd = (X10ClassDef) def; - TypeConstraint c = X10TypeMixin.parameterBounds(cd.asType()); - List<Type> b = getBoundsFromConstraint(pt, c, kind); - worklist.addAll(b); + X10Def def = (X10Def) Types.get(pt.def()); + Ref<TypeConstraint> ref = def.typeGuard(); + if (ref != null) { + TypeConstraint c = Types.get(def.typeGuard()); + List<Type> b = getBoundsFromConstraint(pt, c, kind); + worklist.addAll(b); } - if (def instanceof X10MethodDef) { - X10MethodDef md = (X10MethodDef) def; - TypeConstraint c = Types.get(md.typeGuard()); - List<Type> b = getBoundsFromConstraint(pt, c, kind); - worklist.addAll(b); - } - if (def instanceof ClosureDef) { - ClosureDef md = (ClosureDef) def; - TypeConstraint c = Types.get(md.typeGuard()); - List<Type> b = getBoundsFromConstraint(pt, c, kind); - worklist.addAll(b); - } - if (def instanceof TypeDef) { - TypeDef md = (TypeDef) def; - TypeConstraint c = Types.get(md.typeGuard()); - List<Type> b = getBoundsFromConstraint(pt, c, kind); - worklist.addAll(b); - } - if (def instanceof X10ConstructorDef) { - X10ConstructorDef cd = (X10ConstructorDef) def; - TypeConstraint c = Types.get(cd.typeGuard()); - List<Type> b = getBoundsFromConstraint(pt, c, kind); - worklist.addAll(b); - } continue; } - result.add(expanded); } @@ -560,210 +635,263 @@ * @see polyglot.ext.x10.types.X10TypeEnv#isSubtypeWithValueInterfaces(polyglot.types.Type, polyglot.types.Type) */ public boolean isSubtypeWithValueInterfaces(Type t1, Type t2) { - return isSubtype(t1, t2, true); + return isSubtype(null, t1, t2, true); } + + public boolean isSubtype(Type t1, Type t2, boolean allowValueInterfaces) { + return isSubtype(null, t1, t2, allowValueInterfaces); + } /* (non-Javadoc) * @see polyglot.ext.x10.types.X10TypeEnv#isSubtype(polyglot.types.Type, polyglot.types.Type, boolean) */ - public boolean isSubtype(Type t1, Type t2, boolean allowValueInterfaces) { - assert t1 != null; - assert t2 != null; - t1 = ts.expandMacros(t1); - t2 = ts.expandMacros(t2); - - if (t1 == t2) - return true; + public boolean isSubtype(XVar x, Type t1, Type t2, boolean allowValueInterfaces) { + assert t1 != null; + assert t2 != null; + t1 = ts.expandMacros(t1); + t2 = ts.expandMacros(t2); + X10Context xcontext = (X10Context) context; - if (t1.isVoid() || t2.isVoid()) - return false; - if (t1.isNull() && (t2.isNull() || ts.isReferenceOrInterfaceType(t2, (X10Context) context))) { - return true; - } + if (t1 == t2) + return true; - if (t2.isNull()) { - return false; - } - - // HACK: treat (S) => T as a subtype of Value. - if (ts.isFunction(t1, (X10Context) context) && ts.typeEquals(t2, ts.Value(), context)) - return true; + if (t1.isVoid() || t2.isVoid()) + return false; - if (ts.isValueType(t1, (X10Context) context) && ts.isReferenceType(t2, (X10Context) context)) - return false; + if (t1.isNull() && (t2.isNull() + || ts.isReferenceOrInterfaceType(t2, xcontext))) { + return true; + } - if (ts.isValueType(t2, (X10Context) context) && ts.isReferenceType(t1, (X10Context) context)) - return false; + if (t2.isNull()) { + return false; + } - if (! allowValueInterfaces) { - if (ts.isValueType(t1, (X10Context) context) && ts.isReferenceOrInterfaceType(t2, (X10Context) context)) - return false; + // HACK: treat (S) => T as a subtype of Value. + if (ts.isFunction(t1, xcontext) + && ts.typeEquals(t2, ts.Value(), xcontext)) + return true; - if (ts.isValueType(t2, (X10Context) context) && ts.isReferenceOrInterfaceType(t1, (X10Context) context)) - return false; - } + if (ts.isValueType(t1, xcontext) + && ts.isReferenceType(t2, xcontext)) + return false; - if (typeEquals(t1, t2)) - return true; + if (ts.isValueType(t2, xcontext) + && ts.isReferenceType(t1, xcontext)) + return false; - List<SubtypeConstraint> env; - X10Context xc = (X10Context) this.context; - if (xc.currentTypeConstraint() != null) - env = xc.currentTypeConstraint().terms(); - else - env = Collections.EMPTY_LIST; + if (! allowValueInterfaces) { + if (ts.isValueType(t1, xcontext) + && ts.isReferenceOrInterfaceType(t2, xcontext)) + return false; - // DO NOT check if env.entails(t1 <: t2); it would be recursive - // Instead, iterate through the environment. - for (int i = 0; i < env.size(); i++) { - SubtypeConstraint term = env.get(i); - List<SubtypeConstraint> newEnv = new ArrayList<SubtypeConstraint>(); - if (0 <= i-1 && i-1 < env.size()) newEnv.addAll(env.subList(0, i-1)); - if (0 <= i+1 && i+1 < env.size()) newEnv.addAll(env.subList(i+1, env.size())); - // newEnv = env; - // newEnv = Collections.EMPTY_LIST; + if (ts.isValueType(t2, xcontext) + && ts.isReferenceOrInterfaceType(t1, xcontext)) + return false; + } - X10Context xc2 = (X10Context) xc.pushBlock(); - TypeConstraint ec = new TypeConstraint_c(); - for (SubtypeConstraint tt : newEnv) { - ec.addTerm(tt); - } - xc2.setCurrentTypeConstraint(ec); - - X10TypeEnv_c tenv = copy(); - tenv.context = xc2; - - if (term.isEqualityConstraint()) { - SubtypeConstraint eq = term; - Type l = eq.subtype(); - Type r = eq.supertype(); - if (tenv.isSubtype(t1, l, allowValueInterfaces) && tenv.isSubtype(r, t2, allowValueInterfaces)) { - return true; - } - if (tenv.isSubtype(t1, r, allowValueInterfaces) && tenv.isSubtype(l, t2, allowValueInterfaces)) { - return true; - } + if (typeEquals(t1, t2)) + return true; - } - else { - SubtypeConstraint s = term; - Type l = s.subtype(); - Type r = s.supertype(); - if (tenv.isSubtype(t1, l, allowValueInterfaces) && tenv.isSubtype(r, t2, allowValueInterfaces)) { - return true; - } - } - } + TypeConstraint typeConst = xcontext.currentTypeConstraint(); + List<SubtypeConstraint> env; + if (typeConst != null) + env = typeConst.terms(); + else + env = Collections.emptyList(); + + + // DO NOT check if env.entails(t1 <: t2); it would be recursive + // Instead, iterate through the environment. + for (int i = 0; i < env.size(); i++) { + SubtypeConstraint term = env.get(i); + List<SubtypeConstraint> newEnv = new ArrayList<SubtypeConstraint>(); + if (0 <= i-1 && i-1 < env.size()) + newEnv.addAll(env.subList(0, i-1)); + if (0 <= i+1 && i+1 < env.size()) + newEnv.addAll(env.subList(i+1, env.size())); + // newEnv = env; + // newEnv = Collections.EMPTY_LIST; - Type baseType1 = X10TypeMixin.baseType(t1); - Type baseType2 = X10TypeMixin.baseType(t2); - XConstraint c1 = X10TypeMixin.realX(t1); - XConstraint c2 = X10TypeMixin.xclause(t2); // NOTE: xclause, not realX + X10Context xc2 = (X10Context) xcontext.pushBlock(); + TypeConstraint ec = new TypeConstraint_c(); + for (SubtypeConstraint tt : newEnv) { + ec.addTerm(tt); + } + xc2.setCurrentTypeConstraint(ec); - if (c1 != null && c1.valid()) { c1 = null; } - if (c2 != null && c2.valid()) { c2 = null; } + X10TypeEnv_c tenv = copy(); + tenv.context = xc2; - if (! entails(c1, c2)) - return false; + if (term.isEqualityConstraint()) { + SubtypeConstraint eq = term; + Type l = eq.subtype(); + Type r = eq.supertype(); + if (tenv.isSubtype(t1, l, allowValueInterfaces) + && tenv.isSubtype(r, t2, allowValueInterfaces)) { + return true; + } + if (tenv.isSubtype(t1, r, allowValueInterfaces) + && tenv.isSubtype(l, t2, allowValueInterfaces)) { + return true; + } - if (baseType1 != t1 || baseType2 != t2) - if (isSubtype(baseType1, baseType2, allowValueInterfaces)) - return true; + } + else { + SubtypeConstraint s = term; + Type l = s.subtype(); + Type r = s.supertype(); + if (tenv.isSubtype(t1, l, allowValueInterfaces) + && tenv.isSubtype(r, t2, allowValueInterfaces)) { + return true; + } + } + } + Type baseType1 = X10TypeMixin.baseType(t1); + + if (typeEquals(baseType1,t2)) + return true; + + Type baseType2 = X10TypeMixin.baseType(t2); + XConstraint c1 = X10TypeMixin.realX(t1); + XConstraint c2 = X10TypeMixin.xclause(t2); // NOTE: xclause, not realX + if (c2 != null && c2.valid()) { + c2 = null; + } + if (c1 != null && c1.valid()) + c1 = null; + + if (x == null) { + x = X10TypeMixin.selfVar(c1); + if (x == null) { + x = XTerms.makeFreshLocal(); + } + X... [truncated message content] |
From: <dgr...@us...> - 2009-08-04 01:49:20
|
Revision: 10902 http://x10.svn.sourceforge.net/x10/?rev=10902&view=rev Author: dgrove-oss Date: 2009-08-04 01:49:12 +0000 (Tue, 04 Aug 2009) Log Message: ----------- XTENLANG-484 WIP: Interactions of itables and generic types Extend the C++ RuntimeType infrastructure so that it retains information about type parameters and thier variance. This is required to actually do correct subtype testing of generic types (which in turn is required to get itable dispatch of generic interfaces to work in the present of subtyping). This commit just adds most of the supporting declarations to the code generator and the handwritten C++ files. None of this information is actually used at runtime yet (soon...). Modified Paths: -------------- trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/Emitter.java trunk/x10.runtime.17/src-cpp/x10/lang/Box.cc trunk/x10.runtime.17/src-cpp/x10/lang/Box.h trunk/x10.runtime.17/src-cpp/x10/lang/Fun.cc trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_0.h trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_1.h trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_2.h trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_3.h trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_4.h trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_5.h trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_6.h trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_7.h trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_8.h trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_9.h trunk/x10.runtime.17/src-cpp/x10/lang/Object.cc trunk/x10.runtime.17/src-cpp/x10/lang/Rail.cc trunk/x10.runtime.17/src-cpp/x10/lang/Rail.h trunk/x10.runtime.17/src-cpp/x10/lang/RailIterator.cc trunk/x10.runtime.17/src-cpp/x10/lang/RailIterator.h trunk/x10.runtime.17/src-cpp/x10/lang/ValRail.cc trunk/x10.runtime.17/src-cpp/x10/lang/ValRail.h trunk/x10.runtime.17/src-cpp/x10/lang/VoidFun_0_1.h trunk/x10.runtime.17/src-cpp/x10/lang/VoidFun_0_2.h trunk/x10.runtime.17/src-cpp/x10/lang/VoidFun_0_3.h trunk/x10.runtime.17/src-cpp/x10/lang/VoidFun_0_4.h trunk/x10.runtime.17/src-cpp/x10/lang/VoidFun_0_5.h trunk/x10.runtime.17/src-cpp/x10/lang/VoidFun_0_6.h trunk/x10.runtime.17/src-cpp/x10/lang/VoidFun_0_7.h trunk/x10.runtime.17/src-cpp/x10/lang/VoidFun_0_8.h trunk/x10.runtime.17/src-cpp/x10/util/GrowableRail.cc trunk/x10.runtime.17/src-cpp/x10/util/GrowableRail.h trunk/x10.runtime.17/src-cpp/x10/util/concurrent/atomic/AtomicReference.cc trunk/x10.runtime.17/src-cpp/x10/util/concurrent/atomic/AtomicReference.h trunk/x10.runtime.17/src-cpp/x10aux/RTT.cc trunk/x10.runtime.17/src-cpp/x10aux/RTT.h Modified: trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/Emitter.java =================================================================== --- trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/Emitter.java 2009-08-03 18:46:03 UTC (rev 10901) +++ trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/Emitter.java 2009-08-04 01:49:12 UTC (rev 10902) @@ -583,40 +583,64 @@ h.write("x10aux::RuntimeType "+translateType(ct)+"::rtt;"); h.newline(); h.write("void "+translateType(ct)+"::_initRTT() {"); h.newline(4); h.begin(0); h.write("rtt.typeName = \"CYCLIC RTT INIT\";"); h.newline(); - h.write("rtt.init(\""+ct.fullName()+"\", "+num_parents); - h.write(", x10aux::getRTT" + chevrons(ct.superClass()==null ? translateType(xts.Ref()) : translateType(ct.superClass())) + "()"); + h.write("const x10aux::RuntimeType* parents["+num_parents+"] = { "); + h.write("x10aux::getRTT" + chevrons(ct.superClass()==null ? translateType(xts.Ref()) : translateType(ct.superClass())) + "()"); for (Type iface : ct.interfaces()) { h.write(", x10aux::getRTT"+chevrons(translateType(iface))+"()"); } - h.write(");"); h.end(); h.newline(); + h.write("};"); h.newline(); + h.write("rtt.init(\""+ct.fullName()+"\", "+num_parents+ ", parents, 0, NULL, NULL);"); h.end(); h.newline(); h.write("}"); h.newline(); } else { + int numTypeParams = ct.typeArguments().size(); printTemplateSignature(ct.typeArguments(), h); h.write("x10aux::RuntimeType "+translateType(ct)+"::rtt;"); h.newline(); printTemplateSignature(ct.typeArguments(), h); h.write("void "+translateType(ct)+"::_initRTT() {"); h.newline(4); h.begin(0); h.write("rtt.typeName = \"CYCLIC RTT INIT\";"); h.newline(); - h.write("const char *name ="); h.newline(4); + h.write("const x10aux::RuntimeType* parents["+num_parents+"] = { "); + h.write("x10aux::getRTT" + chevrons(ct.superClass()==null ? translateType(xts.Ref()) : translateType(ct.superClass())) + "()"); + for (Type iface : ct.interfaces()) { + h.write(", x10aux::getRTT"+chevrons(translateType(iface))+"()"); + } + h.write("};"); h.newline(); + + h.write("const x10aux::RuntimeType* params["+numTypeParams+"] = { "); + boolean first = true; + for (Type param : ct.typeArguments()) { + if (!first) h.write(", "); + h.write("x10aux::getRTT"+chevrons(translateType(param))+"()"); + first = false; + } + h.write("};"); h.newline(); + + h.write("x10aux::RuntimeType::Variance variances["+numTypeParams+"] = { "); + first = true; + for (ParameterType.Variance v : ct.x10Def().variances()) { + if (!first) h.write(", "); + switch(v) { + case COVARIANT: h.write("x10aux::RuntimeType::covariant"); break; + case CONTRAVARIANT: h.write("x10aux::RuntimeType::contravariant"); break; + case INVARIANT: h.write("x10aux::RuntimeType::invariant"); break; + default: assert false : "Unexpected Variance"; + } + first = false; + } + h.write("};"); h.newline(); + + h.write("const char *name = "); h.newline(4); h.write("x10aux::alloc_printf("); h.begin(0); h.write("\""+x10name+"["); - String comma = ""; - for (Type param : ct.typeArguments()) { - h.write(comma+"%s"); - comma = ","; + for (int i=0; i<numTypeParams; i++) { + h.write(i > 0 ? ",%s" : "%s"); } h.write("]\""); - for (Type param : ct.typeArguments()) { - h.write(","); h.newline(); - h.write("x10aux::getRTT"+chevrons(translateType(param))+"()->name()"); + for (int i=0; i<numTypeParams; i++) { + h.write(", params["+i+"]->name()"); h.newline(); } h.write(");") ; h.end(); h.newline(); - h.write("rtt.init(name, "+num_parents); - h.write(", x10aux::getRTT" + chevrons(ct.superClass()==null ? translateType(xts.Ref()) : translateType(ct.superClass())) + "()"); - for (Type iface : ct.interfaces()) { - h.write(", x10aux::getRTT"+chevrons(translateType(iface))+"()"); - } - h.write(");"); h.end(); h.newline(); + h.write("rtt.init(name, "+num_parents+", parents, "+numTypeParams+", params, variances);"); h.end(); h.newline(); h.write("}"); h.newline(); } h.newline(); Modified: trunk/x10.runtime.17/src-cpp/x10/lang/Box.cc =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/Box.cc 2009-08-03 18:46:03 UTC (rev 10901) +++ trunk/x10.runtime.17/src-cpp/x10/lang/Box.cc 2009-08-04 01:49:12 UTC (rev 10902) @@ -10,9 +10,11 @@ namespace lang { void _initRTTHelper_Box(RuntimeType *location, const RuntimeType *rtt) { - const char *name = alloc_printf("x10.lang.Box[%s]",rtt->name()); - const RuntimeType *parent = Ref::getRTT(); - location->init(name, 1, parent); + const RuntimeType* parents[1] = { Ref::getRTT()}; + const RuntimeType* params[1] = { rtt }; + RuntimeType::Variance variances[1] = { RuntimeType::covariant }; + const char *name = alloc_printf("x10.lang.Box[+%s]",rtt->name()); + location->init(name, 1, parents, 1, params, variances); } } } Modified: trunk/x10.runtime.17/src-cpp/x10/lang/Box.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/Box.h 2009-08-03 18:46:03 UTC (rev 10901) +++ trunk/x10.runtime.17/src-cpp/x10/lang/Box.h 2009-08-04 01:49:12 UTC (rev 10902) @@ -51,7 +51,7 @@ }; template<class T> void Box<T>::_initRTT() { - rtt.parentsc = -2; + rtt.typeName = "CYCLIC RTT INIT\n"; x10::lang::_initRTTHelper_Box(&rtt, x10aux::getRTT<T>()); } Modified: trunk/x10.runtime.17/src-cpp/x10/lang/Fun.cc =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/Fun.cc 2009-08-03 18:46:03 UTC (rev 10901) +++ trunk/x10.runtime.17/src-cpp/x10/lang/Fun.cc 2009-08-04 01:49:12 UTC (rev 10902) @@ -14,16 +14,20 @@ namespace lang { void _initRTTHelper_Fun_0_0(RuntimeType *location, const RuntimeType *rtt0) { + const RuntimeType* parents[1] = { Object::getRTT() }; + const RuntimeType* params[1] = { rtt0 }; + RuntimeType::Variance variances[1] = { RuntimeType::covariant }; const char *name = alloc_printf("x10.lang.Fun_0_0[%s]",rtt0->name()); - const RuntimeType *parent = Object::getRTT(); - location->init(name, 1, parent); + location->init(name, 1, parents, 1, params, variances); } void _initRTTHelper_Fun_0_1(RuntimeType *location, const RuntimeType *rtt0, const RuntimeType *rtt1) { + const RuntimeType* parents[1] = { Object::getRTT() }; + const RuntimeType* params[2] = { rtt0, rtt1 }; + RuntimeType::Variance variances[2] = { RuntimeType::covariant, RuntimeType::contravariant }; const char *name = alloc_printf("x10.lang.Fun_0_1[%s,%s]", rtt0->name(), rtt1->name()); - const RuntimeType *parent = Object::getRTT(); - location->init(name, 1, parent); + location->init(name, 1, parents, 2, params, variances); } void @@ -31,10 +35,12 @@ const RuntimeType *rtt0, const RuntimeType *rtt1, const RuntimeType *rtt2) { + const RuntimeType* parents[1] = { Object::getRTT() }; + const RuntimeType* params[3] = { rtt0, rtt1, rtt2 }; + RuntimeType::Variance variances[] = { RuntimeType::covariant, RuntimeType::contravariant, RuntimeType::contravariant }; const char *name = alloc_printf("x10.lang.Fun_0_2[%s,%s,%s]", rtt0->name(), rtt1->name(), rtt2->name()); - const RuntimeType *parent = Object::getRTT(); - location->init(name, 1, parent); + location->init(name, 1, parents, 3, params, variances); } void @@ -43,10 +49,12 @@ const RuntimeType *rtt1, const RuntimeType *rtt2, const RuntimeType *rtt3) { + const RuntimeType* parents[1] = { Object::getRTT() }; + const RuntimeType* params[4] = { rtt0, rtt1, rtt2, rtt3 }; + RuntimeType::Variance variances[4] = { RuntimeType::covariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant }; const char *name = alloc_printf("x10.lang.Fun_0_3[%s,%s,%s,%s]", rtt0->name(), rtt1->name(), rtt2->name(), rtt3->name()); - const RuntimeType *parent = Object::getRTT(); - location->init(name, 1, parent); + location->init(name, 1, parents, 4, params, variances); } void @@ -56,10 +64,12 @@ const RuntimeType *rtt2, const RuntimeType *rtt3, const RuntimeType *rtt4) { + const RuntimeType* parents[1] = { Object::getRTT() }; + const RuntimeType* params[5] = { rtt0, rtt1, rtt2, rtt3, rtt4 }; + RuntimeType::Variance variances[5] = { RuntimeType::covariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant }; const char *name = alloc_printf("x10.lang.Fun_0_4[%s,%s,%s,%s,%s]", rtt0->name(), rtt1->name(), rtt2->name(), rtt3->name(), rtt4->name()); - const RuntimeType *parent = Object::getRTT(); - location->init(name, 1, parent); + location->init(name, 1, parents, 5, params, variances); } void @@ -70,11 +80,14 @@ const RuntimeType *rtt3, const RuntimeType *rtt4, const RuntimeType *rtt5) { + const RuntimeType* parents[1] = { Object::getRTT() }; + const RuntimeType* params[6] = { rtt0, rtt1, rtt2, rtt3, rtt4, rtt5 }; + RuntimeType::Variance variances[6] = { RuntimeType::covariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, + RuntimeType::contravariant }; const char *name = alloc_printf("x10.lang.Fun_0_5[%s,%s,%s,%s,%s,%s]", rtt0->name(), rtt1->name(), rtt2->name(), rtt3->name(), rtt4->name(), rtt5->name()); - const RuntimeType *parent = Object::getRTT(); - location->init(name, 1, parent); + location->init(name, 1, parents, 6, params, variances); } void @@ -86,11 +99,14 @@ const RuntimeType *rtt4, const RuntimeType *rtt5, const RuntimeType *rtt6) { + const RuntimeType* parents[1] = { Object::getRTT() }; + const RuntimeType* params[7] = { rtt0, rtt1, rtt2, rtt3, rtt4, rtt5, rtt6 }; + RuntimeType::Variance variances[7] = { RuntimeType::covariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, + RuntimeType::contravariant, RuntimeType::contravariant }; const char *name = alloc_printf("x10.lang.Fun_0_6[%s,%s,%s,%s,%s,%s,%s]", rtt0->name(), rtt1->name(), rtt2->name(), rtt3->name(), rtt4->name(), rtt5->name(), rtt6->name()); - const RuntimeType *parent = Object::getRTT(); - location->init(name, 1, parent); + location->init(name, 1, parents, 7, params, variances); } void @@ -103,11 +119,14 @@ const RuntimeType *rtt5, const RuntimeType *rtt6, const RuntimeType *rtt7) { + const RuntimeType* parents[1] = { Object::getRTT() }; + const RuntimeType* params[8] = { rtt0, rtt1, rtt2, rtt3, rtt4, rtt5, rtt6, rtt7 }; + RuntimeType::Variance variances[8] = { RuntimeType::covariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, + RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant }; const char *name = alloc_printf("x10.lang.Fun_0_7[%s,%s,%s,%s,%s,%s,%s,%s]", rtt0->name(), rtt1->name(), rtt2->name(), rtt3->name(), rtt4->name(), rtt5->name(), rtt6->name(), rtt7->name()); - const RuntimeType *parent = Object::getRTT(); - location->init(name, 1, parent); + location->init(name, 1, parents, 8, params, variances); } void @@ -121,11 +140,14 @@ const RuntimeType *rtt6, const RuntimeType *rtt7, const RuntimeType *rtt8) { + const RuntimeType* parents[1] = { Object::getRTT() }; + const RuntimeType* params[9] = { rtt0, rtt1, rtt2, rtt3, rtt4, rtt5, rtt6, rtt7, rtt8 }; + RuntimeType::Variance variances[9] = { RuntimeType::covariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, + RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant }; const char *name = alloc_printf("x10.lang.Fun_0_8[%s,%s,%s,%s,%s,%s,%s,%s,%s]", rtt0->name(), rtt1->name(), rtt2->name(), rtt3->name(), rtt4->name(), rtt5->name(), rtt6->name(), rtt7->name(), rtt8->name()); - const RuntimeType *parent = Object::getRTT(); - location->init(name, 1, parent); + location->init(name, 1, parents, 9, params, variances); } void @@ -140,28 +162,35 @@ const RuntimeType *rtt7, const RuntimeType *rtt8, const RuntimeType *rtt9) { + const RuntimeType* parents[1] = { Object::getRTT() }; + const RuntimeType* params[10] = { rtt0, rtt1, rtt2, rtt3, rtt4, rtt5, rtt6, rtt7, rtt8, rtt9 }; + RuntimeType::Variance variances[10] = { RuntimeType::covariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, + RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant }; const char *name = alloc_printf("x10.lang.Fun_0_9[%s,%s,%s,%s,%s,%s,%s,%s,%s,%s]", rtt0->name(), rtt1->name(), rtt2->name(), rtt3->name(), rtt4->name(), rtt5->name(), rtt6->name(), rtt7->name(), rtt8->name(), rtt9->name()); - const RuntimeType *parent = Object::getRTT(); - location->init(name, 1, parent); + location->init(name, 1, parents, 9, params, variances); } void _initRTTHelper_VoidFun_0_1(RuntimeType *location, const RuntimeType *rtt1) { + const RuntimeType* parents[1] = { Object::getRTT() }; + const RuntimeType* params[1] = { rtt1 }; + RuntimeType::Variance variances[] = { RuntimeType::contravariant }; const char *name = alloc_printf("x10.lang.VoidFun_0_1[%s]", rtt1->name()); - const RuntimeType *parent = Object::getRTT(); - location->init(name, 1, parent); + location->init(name, 1, parents, 1, params, variances); } void _initRTTHelper_VoidFun_0_2(RuntimeType *location, const RuntimeType *rtt1, const RuntimeType *rtt2) { + const RuntimeType* parents[1] = { Object::getRTT() }; + const RuntimeType* params[2] = { rtt1, rtt2 }; + RuntimeType::Variance variances[2] = { RuntimeType::contravariant, RuntimeType::contravariant }; const char *name = alloc_printf("x10.lang.VoidFun_0_2[%s,%s]", rtt1->name(), rtt2->name()); - const RuntimeType *parent = Object::getRTT(); - location->init(name, 1, parent); + location->init(name, 1, parents, 2, params, variances); } void @@ -169,10 +198,12 @@ const RuntimeType *rtt1, const RuntimeType *rtt2, const RuntimeType *rtt3) { + const RuntimeType* parents[1] = { Object::getRTT() }; + const RuntimeType* params[3] = { rtt1, rtt2, rtt3 }; + RuntimeType::Variance variances[3] = { RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant }; const char *name = alloc_printf("x10.lang.VoidFun_0_3[%s,%s,%s]", rtt1->name(), rtt2->name(), rtt3->name()); - const RuntimeType *parent = Object::getRTT(); - location->init(name, 1, parent); + location->init(name, 1, parents, 3, params, variances); } void @@ -181,10 +212,12 @@ const RuntimeType *rtt2, const RuntimeType *rtt3, const RuntimeType *rtt4) { + const RuntimeType* parents[1] = { Object::getRTT() }; + const RuntimeType* params[4] = { rtt1, rtt2, rtt3, rtt4 }; + RuntimeType::Variance variances[4] = { RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant }; const char *name = alloc_printf("x10.lang.VoidFun_0_4[%s,%s,%s,%s]", rtt1->name(), rtt2->name(), rtt3->name(), rtt4->name()); - const RuntimeType *parent = Object::getRTT(); - location->init(name, 1, parent); + location->init(name, 1, parents, 4, params, variances); } void @@ -194,11 +227,13 @@ const RuntimeType *rtt3, const RuntimeType *rtt4, const RuntimeType *rtt5) { + const RuntimeType* parents[1] = { Object::getRTT() }; + const RuntimeType* params[5] = { rtt1, rtt2, rtt3, rtt4, rtt5 }; + RuntimeType::Variance variances[5] = { RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant }; const char *name = alloc_printf("x10.lang.VoidFun_0_5[%s,%s,%s,%s,%s]", rtt1->name(), rtt2->name(), rtt3->name(), rtt4->name(), rtt5->name()); - const RuntimeType *parent = Object::getRTT(); - location->init(name, 1, parent); + location->init(name, 1, parents, 5, params, variances); } void @@ -209,11 +244,14 @@ const RuntimeType *rtt4, const RuntimeType *rtt5, const RuntimeType *rtt6) { + const RuntimeType* parents[1] = { Object::getRTT() }; + const RuntimeType* params[6] = { rtt1, rtt2, rtt3, rtt4, rtt5, rtt6 }; + RuntimeType::Variance variances[6] = { RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, + RuntimeType::contravariant }; const char *name = alloc_printf("x10.lang.VoidFun_0_6[%s,%s,%s,%s,%s,%s]", rtt1->name(), rtt2->name(), rtt3->name(), rtt4->name(), rtt5->name(), rtt6->name()); - const RuntimeType *parent = Object::getRTT(); - location->init(name, 1, parent); + location->init(name, 1, parents, 6, params, variances); } void @@ -225,11 +263,14 @@ const RuntimeType *rtt5, const RuntimeType *rtt6, const RuntimeType *rtt7) { + const RuntimeType* parents[1] = { Object::getRTT() }; + const RuntimeType* params[7] = { rtt1, rtt2, rtt3, rtt4, rtt5, rtt6, rtt7 }; + RuntimeType::Variance variances[7] = { RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, + RuntimeType::contravariant, RuntimeType::contravariant }; const char *name = alloc_printf("x10.lang.VoidFun_0_7[%s,%s,%s,%s,%s,%s,%s]", rtt1->name(), rtt2->name(), rtt3->name(), rtt4->name(), rtt5->name(), rtt6->name(), rtt7->name()); - const RuntimeType *parent = Object::getRTT(); - location->init(name, 1, parent); + location->init(name, 1, parents, 7, params, variances); } void @@ -242,12 +283,15 @@ const RuntimeType *rtt6, const RuntimeType *rtt7, const RuntimeType *rtt8) { + const RuntimeType* parents[1] = { Object::getRTT() }; + const RuntimeType* params[8] = { rtt1, rtt2, rtt3, rtt4, rtt5, rtt6, rtt7, rtt8 }; + RuntimeType::Variance variances[8] = { RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, + RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant }; const char *name = alloc_printf("x10.lang.VoidFun_0_8[%s,%s,%s,%s,%s,%s,%s,%s]", rtt1->name(), rtt2->name(), rtt3->name(), rtt4->name(), rtt5->name(), rtt6->name(), rtt7->name(), rtt8->name()); - const RuntimeType *parent = Object::getRTT(); - location->init(name, 1, parent); + location->init(name, 1, parents, 8, params, variances); } void @@ -261,12 +305,15 @@ const RuntimeType *rtt7, const RuntimeType *rtt8, const RuntimeType *rtt9) { + const RuntimeType* parents[1] = { Object::getRTT() }; + const RuntimeType* params[9] = { rtt1, rtt2, rtt3, rtt4, rtt5, rtt6, rtt7, rtt8, rtt9 }; + RuntimeType::Variance variances[9] = { RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, + RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant }; const char *name = alloc_printf("x10.lang.VoidFun_0_9[%s,%s,%s,%s,%s,%s,%s,%s,%s]", rtt1->name(), rtt2->name(), rtt3->name(), rtt4->name(), rtt5->name(), rtt6->name(), rtt7->name(), rtt8->name(), rtt9->name()); - const RuntimeType *parent = Object::getRTT(); - location->init(name, 1, parent); + location->init(name, 1, parents, 9, params, variances); } } } Modified: trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_0.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_0.h 2009-08-03 18:46:03 UTC (rev 10901) +++ trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_0.h 2009-08-04 01:49:12 UTC (rev 10902) @@ -21,7 +21,7 @@ }; template<class R> void Fun_0_0<R>::_initRTT() { - rtt.parentsc = -2; + rtt.typeName = "CYCLIC RTT INIT\n"; x10::lang::_initRTTHelper_Fun_0_0(&rtt, x10aux::getRTT<R>()); } Modified: trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_1.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_1.h 2009-08-03 18:46:03 UTC (rev 10901) +++ trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_1.h 2009-08-04 01:49:12 UTC (rev 10902) @@ -23,7 +23,7 @@ }; template<class P1, class R> void Fun_0_1<P1,R>::_initRTT() { - rtt.parentsc = -2; + rtt.typeName = "CYCLIC RTT INIT\n"; x10::lang::_initRTTHelper_Fun_0_1(&rtt, x10aux::getRTT<P1>(), x10aux::getRTT<R>()); } Modified: trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_2.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_2.h 2009-08-03 18:46:03 UTC (rev 10901) +++ trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_2.h 2009-08-04 01:49:12 UTC (rev 10902) @@ -24,7 +24,7 @@ }; template<class P1, class P2, class R> void Fun_0_2<P1,P2,R>::_initRTT() { - rtt.parentsc = -2; + rtt.typeName = "CYCLIC RTT INIT\n"; x10::lang::_initRTTHelper_Fun_0_2(&rtt, x10aux::getRTT<P1>(), x10aux::getRTT<P2>(), x10aux::getRTT<R>()); } Modified: trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_3.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_3.h 2009-08-03 18:46:03 UTC (rev 10901) +++ trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_3.h 2009-08-04 01:49:12 UTC (rev 10902) @@ -25,9 +25,9 @@ }; template<class P1, class P2, class P3, class R> void Fun_0_3<P1,P2,P3,R>::_initRTT() { - rtt.parentsc = -2; + rtt.typeName = "CYCLIC RTT INIT\n"; x10::lang::_initRTTHelper_Fun_0_3(&rtt, x10aux::getRTT<P1>(), x10aux::getRTT<P2>(), - x10aux::getRTT<P3>(), x10aux::getRTT<R>()); + x10aux::getRTT<P3>(), x10aux::getRTT<R>()); } template<class P1, class P2, class P3, class R> x10aux::RuntimeType Fun_0_3<P1,P2,P3,R>::rtt; Modified: trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_4.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_4.h 2009-08-03 18:46:03 UTC (rev 10901) +++ trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_4.h 2009-08-04 01:49:12 UTC (rev 10902) @@ -27,7 +27,7 @@ template<class P1, class P2, class P3, class P4, class R> void Fun_0_4<P1,P2,P3,P4,R>::_initRTT() { - rtt.parentsc = -2; + rtt.typeName = "CYCLIC RTT INIT\n"; x10::lang::_initRTTHelper_Fun_0_4(&rtt, x10aux::getRTT<P1>(), x10aux::getRTT<P2>(), x10aux::getRTT<P3>(), x10aux::getRTT<P4>(), x10aux::getRTT<R>()); Modified: trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_5.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_5.h 2009-08-03 18:46:03 UTC (rev 10901) +++ trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_5.h 2009-08-04 01:49:12 UTC (rev 10902) @@ -28,7 +28,7 @@ template<class P1, class P2, class P3, class P4, class P5, class R> void Fun_0_5<P1,P2,P3,P4,P5,R>::_initRTT() { - rtt.parentsc = -2; + rtt.typeName = "CYCLIC RTT INIT\n"; x10::lang::_initRTTHelper_Fun_0_5(&rtt, x10aux::getRTT<P1>(), x10aux::getRTT<P2>(), x10aux::getRTT<P3>(), x10aux::getRTT<P4>(), x10aux::getRTT<P5>(), x10aux::getRTT<R>()); Modified: trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_6.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_6.h 2009-08-03 18:46:03 UTC (rev 10901) +++ trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_6.h 2009-08-04 01:49:12 UTC (rev 10902) @@ -29,7 +29,7 @@ template<class P1, class P2, class P3, class P4, class P5, class P6, class R> void Fun_0_6<P1,P2,P3,P4,P5,P6,R>::_initRTT() { - rtt.parentsc = -2; + rtt.typeName = "CYCLIC RTT INIT\n"; x10::lang::_initRTTHelper_Fun_0_6(&rtt, x10aux::getRTT<P1>(), x10aux::getRTT<P2>(), x10aux::getRTT<P3>(), x10aux::getRTT<P4>(), x10aux::getRTT<P5>(), x10aux::getRTT<P6>(), Modified: trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_7.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_7.h 2009-08-03 18:46:03 UTC (rev 10901) +++ trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_7.h 2009-08-04 01:49:12 UTC (rev 10902) @@ -29,7 +29,7 @@ template<class P1, class P2, class P3, class P4, class P5, class P6, class P7, class R> void Fun_0_7<P1,P2,P3,P4,P5,P6,P7,R>::_initRTT() { - rtt.parentsc = -2; + rtt.typeName = "CYCLIC RTT INIT\n"; x10::lang::_initRTTHelper_Fun_0_7(&rtt, x10aux::getRTT<P1>(), x10aux::getRTT<P2>(), x10aux::getRTT<P3>(), x10aux::getRTT<P4>(), x10aux::getRTT<P5>(), x10aux::getRTT<P6>(), Modified: trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_8.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_8.h 2009-08-03 18:46:03 UTC (rev 10901) +++ trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_8.h 2009-08-04 01:49:12 UTC (rev 10902) @@ -30,7 +30,7 @@ template<class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class R> void Fun_0_8<P1,P2,P3,P4,P5,P6,P7,P8,R>::_initRTT() { - rtt.parentsc = -2; + rtt.typeName = "CYCLIC RTT INIT\n"; x10::lang::_initRTTHelper_Fun_0_8(&rtt, x10aux::getRTT<P1>(), x10aux::getRTT<P2>(), x10aux::getRTT<P3>(), x10aux::getRTT<P4>(), x10aux::getRTT<P5>(), x10aux::getRTT<P6>(), Modified: trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_9.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_9.h 2009-08-03 18:46:03 UTC (rev 10901) +++ trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_9.h 2009-08-04 01:49:12 UTC (rev 10902) @@ -31,7 +31,7 @@ template<class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9, class R> void Fun_0_9<P1,P2,P3,P4,P5,P6,P7,P8,P9,R>::_initRTT() { - rtt.parentsc = -2; + rtt.typeName = "CYCLIC RTT INIT\n"; x10::lang::_initRTTHelper_Fun_0_9(&rtt, x10aux::getRTT<P1>(), x10aux::getRTT<P2>(), x10aux::getRTT<P3>(), x10aux::getRTT<P4>(), x10aux::getRTT<P5>(), x10aux::getRTT<P6>(), Modified: trunk/x10.runtime.17/src-cpp/x10/lang/Object.cc =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/Object.cc 2009-08-03 18:46:03 UTC (rev 10901) +++ trunk/x10.runtime.17/src-cpp/x10/lang/Object.cc 2009-08-04 01:49:12 UTC (rev 10902) @@ -38,7 +38,7 @@ x10aux::RuntimeType x10::lang::Object::rtt; void Object::_initRTT() { - rtt.init("x10.lang.Object", 0); + rtt.init("x10.lang.Object", 0, NULL, 0, NULL, NULL); } Modified: trunk/x10.runtime.17/src-cpp/x10/lang/Rail.cc =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/Rail.cc 2009-08-03 18:46:03 UTC (rev 10901) +++ trunk/x10.runtime.17/src-cpp/x10/lang/Rail.cc 2009-08-04 01:49:12 UTC (rev 10902) @@ -11,17 +11,11 @@ void _initRTTHelper_Rail(RuntimeType *location, const RuntimeType *element, const RuntimeType *p1, const RuntimeType *p2) { + const RuntimeType *parents[3] = { Ref::getRTT(), p1, p2 }; + const RuntimeType *params[1] = { element }; + RuntimeType::Variance variances[1] = { RuntimeType::invariant }; const char *name = alloc_printf("x10.lang.Rail[%s]", element->name()); - const RuntimeType *p0 = Ref::getRTT(); - location->init(name, 3, p0, p1, p2); + location->init(name, 3, parents, 1, params, variances); } - - void - _initRTTHelper_RailIterator(RuntimeType *location, const RuntimeType *element, - const RuntimeType *p1) { - const char *name = alloc_printf("x10.lang.Rail.Iterator[%s]", element->name()); - const RuntimeType *p0 = Ref::getRTT(); - location->init(name, 2, p0, p1); - } } } Modified: trunk/x10.runtime.17/src-cpp/x10/lang/Rail.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/Rail.h 2009-08-03 18:46:03 UTC (rev 10901) +++ trunk/x10.runtime.17/src-cpp/x10/lang/Rail.h 2009-08-04 01:49:12 UTC (rev 10902) @@ -82,8 +82,9 @@ template<class T> x10aux::RuntimeType Rail<T>::rtt; template<class T> void Rail<T>::_initRTT() { - rtt.parentsc = -2; - x10::lang::_initRTTHelper_Rail(&rtt, x10aux::getRTT<T>(), x10aux::getRTT<Settable<x10_int,T> >(), + rtt.typeName = "CYCLIC RTT INIT\n"; + x10::lang::_initRTTHelper_Rail(&rtt, x10aux::getRTT<T>(), + x10aux::getRTT<Settable<x10_int,T> >(), x10aux::getRTT<Iterable<T> >()); } Modified: trunk/x10.runtime.17/src-cpp/x10/lang/RailIterator.cc =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/RailIterator.cc 2009-08-03 18:46:03 UTC (rev 10901) +++ trunk/x10.runtime.17/src-cpp/x10/lang/RailIterator.cc 2009-08-04 01:49:12 UTC (rev 10902) @@ -11,9 +11,11 @@ void _initRTTHelper_RailIterator(RuntimeType *location, const RuntimeType *element, const RuntimeType *p1) { - const char *name = alloc_printf("x10.lang.RailIterator[%s]", element->name()); - const RuntimeType *p0 = Ref::getRTT(); - location->init(name, 2, p0, p1); + const RuntimeType *parents[2] = { Ref::getRTT(), p1 }; + const RuntimeType *params[1] = { element }; + RuntimeType::Variance variances[1] = { RuntimeType::covariant }; + const char *name = alloc_printf("x10.lang.Rail.Iterator[+%s]", element->name()); + location->init(name, 2, parents, 1, params, variances); } } } Modified: trunk/x10.runtime.17/src-cpp/x10/lang/RailIterator.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/RailIterator.h 2009-08-03 18:46:03 UTC (rev 10901) +++ trunk/x10.runtime.17/src-cpp/x10/lang/RailIterator.h 2009-08-04 01:49:12 UTC (rev 10902) @@ -64,7 +64,7 @@ template<class T> x10aux::RuntimeType RailIterator<T>::rtt; template<class T> void RailIterator<T>::_initRTT() { - rtt.parentsc = -2; + rtt.typeName = "CYCLIC RTT INIT\n"; _initRTTHelper_RailIterator(&rtt, x10aux::getRTT<T>(), x10aux::getRTT<Iterator<T> >()); } Modified: trunk/x10.runtime.17/src-cpp/x10/lang/ValRail.cc =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/ValRail.cc 2009-08-03 18:46:03 UTC (rev 10901) +++ trunk/x10.runtime.17/src-cpp/x10/lang/ValRail.cc 2009-08-04 01:49:12 UTC (rev 10902) @@ -13,9 +13,11 @@ void _initRTTHelper_ValRail(RuntimeType *location, const RuntimeType *element, const RuntimeType *p1, const RuntimeType *p2) { - const char *name = alloc_printf("x10.lang.ValRail[%s]", element->name()); - const RuntimeType *p0 = Value::getRTT(); - location->init(name, 3, p0, p1, p2); + const RuntimeType *parents[3] = { Value::getRTT(), p1, p2 }; + const RuntimeType *params[1] = { element }; + RuntimeType::Variance variances[1] = { RuntimeType::covariant }; + const char *name = alloc_printf("x10.lang.ValRail[+%s]", element->name()); + location->init(name, 3, parents, 1, params, variances); } } } Modified: trunk/x10.runtime.17/src-cpp/x10/lang/ValRail.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/ValRail.h 2009-08-03 18:46:03 UTC (rev 10901) +++ trunk/x10.runtime.17/src-cpp/x10/lang/ValRail.h 2009-08-04 01:49:12 UTC (rev 10902) @@ -98,9 +98,10 @@ ::addDeserializer(ValRail<T>::template _deserialize<Object>); template<class T> void ValRail<T>::_initRTT() { - rtt.parentsc = -2; - x10::lang::_initRTTHelper_ValRail(&rtt, x10aux::getRTT<T>(), x10aux::getRTT<Fun_0_1<x10_int,T> >(), - x10aux::getRTT<Iterable<T> >()); + rtt.typeName = "CYCLIC RTT INIT\n"; + x10::lang::_initRTTHelper_ValRail(&rtt, x10aux::getRTT<T>(), + x10aux::getRTT<Fun_0_1<x10_int,T> >(), + x10aux::getRTT<Iterable<T> >()); } template<class T> x10aux::RuntimeType ValRail<T>::rtt; Modified: trunk/x10.runtime.17/src-cpp/x10/lang/VoidFun_0_1.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/VoidFun_0_1.h 2009-08-03 18:46:03 UTC (rev 10901) +++ trunk/x10.runtime.17/src-cpp/x10/lang/VoidFun_0_1.h 2009-08-04 01:49:12 UTC (rev 10902) @@ -22,7 +22,7 @@ }; template<class P1> void VoidFun_0_1<P1>::_initRTT() { - rtt.parentsc = -2; + rtt.typeName = "CYCLIC RTT INIT\n"; x10::lang::_initRTTHelper_VoidFun_0_1(&rtt, x10aux::getRTT<P1>()); } Modified: trunk/x10.runtime.17/src-cpp/x10/lang/VoidFun_0_2.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/VoidFun_0_2.h 2009-08-03 18:46:03 UTC (rev 10901) +++ trunk/x10.runtime.17/src-cpp/x10/lang/VoidFun_0_2.h 2009-08-04 01:49:12 UTC (rev 10902) @@ -23,7 +23,7 @@ }; template<class P1, class P2> void VoidFun_0_2<P1,P2>::_initRTT() { - rtt.parentsc = -2; + rtt.typeName = "CYCLIC RTT INIT\n"; x10::lang::_initRTTHelper_VoidFun_0_2(&rtt, x10aux::getRTT<P1>(), x10aux::getRTT<P2>()); } Modified: trunk/x10.runtime.17/src-cpp/x10/lang/VoidFun_0_3.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/VoidFun_0_3.h 2009-08-03 18:46:03 UTC (rev 10901) +++ trunk/x10.runtime.17/src-cpp/x10/lang/VoidFun_0_3.h 2009-08-04 01:49:12 UTC (rev 10902) @@ -24,7 +24,7 @@ }; template<class P1, class P2, class P3> void VoidFun_0_3<P1,P2,P3>::_initRTT() { - rtt.parentsc = -2; + rtt.typeName = "CYCLIC RTT INIT\n"; x10::lang::_initRTTHelper_VoidFun_0_3(&rtt, x10aux::getRTT<P1>(), x10aux::getRTT<P2>(), x10aux::getRTT<P3>()); } Modified: trunk/x10.runtime.17/src-cpp/x10/lang/VoidFun_0_4.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/VoidFun_0_4.h 2009-08-03 18:46:03 UTC (rev 10901) +++ trunk/x10.runtime.17/src-cpp/x10/lang/VoidFun_0_4.h 2009-08-04 01:49:12 UTC (rev 10902) @@ -26,7 +26,7 @@ template<class P1, class P2, class P3, class P4> void VoidFun_0_4<P1,P2,P3,P4>::_initRTT() { - rtt.parentsc = -2; + rtt.typeName = "CYCLIC RTT INIT\n"; x10::lang::_initRTTHelper_VoidFun_0_4(&rtt, x10aux::getRTT<P1>(), x10aux::getRTT<P2>(), x10aux::getRTT<P3>(), x10aux::getRTT<P4>()); } Modified: trunk/x10.runtime.17/src-cpp/x10/lang/VoidFun_0_5.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/VoidFun_0_5.h 2009-08-03 18:46:03 UTC (rev 10901) +++ trunk/x10.runtime.17/src-cpp/x10/lang/VoidFun_0_5.h 2009-08-04 01:49:12 UTC (rev 10902) @@ -27,7 +27,7 @@ template<class P1, class P2, class P3, class P4, class P5> void VoidFun_0_5<P1,P2,P3,P4,P5>::_initRTT() { - rtt.parentsc = -2; + rtt.typeName = "CYCLIC RTT INIT\n"; x10::lang::_initRTTHelper_VoidFun_0_5(&rtt, x10aux::getRTT<P1>(), x10aux::getRTT<P2>(), x10aux::getRTT<P3>(), x10aux::getRTT<P4>(), x10aux::getRTT<P5>()); Modified: trunk/x10.runtime.17/src-cpp/x10/lang/VoidFun_0_6.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/VoidFun_0_6.h 2009-08-03 18:46:03 UTC (rev 10901) +++ trunk/x10.runtime.17/src-cpp/x10/lang/VoidFun_0_6.h 2009-08-04 01:49:12 UTC (rev 10902) @@ -28,7 +28,7 @@ template<class P1, class P2, class P3, class P4, class P5, class P6> void VoidFun_0_6<P1,P2,P3,P4,P5,P6>::_initRTT() { - rtt.parentsc = -2; + rtt.typeName = "CYCLIC RTT INIT\n"; x10::lang::_initRTTHelper_VoidFun_0_6(&rtt, x10aux::getRTT<P1>(), x10aux::getRTT<P2>(), x10aux::getRTT<P3>(), x10aux::getRTT<P4>(), x10aux::getRTT<P5>(), x10aux::getRTT<P6>()); Modified: trunk/x10.runtime.17/src-cpp/x10/lang/VoidFun_0_7.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/VoidFun_0_7.h 2009-08-03 18:46:03 UTC (rev 10901) +++ trunk/x10.runtime.17/src-cpp/x10/lang/VoidFun_0_7.h 2009-08-04 01:49:12 UTC (rev 10902) @@ -29,7 +29,7 @@ template<class P1, class P2, class P3, class P4, class P5, class P6, class P7> void VoidFun_0_7<P1,P2,P3,P4,P5,P6,P7>::_initRTT() { - rtt.parentsc = -2; + rtt.typeName = "CYCLIC RTT INIT\n"; x10::lang::_initRTTHelper_VoidFun_0_7(&rtt, x10aux::getRTT<P1>(), x10aux::getRTT<P2>(), x10aux::getRTT<P3>(), x10aux::getRTT<P4>(), x10aux::getRTT<P5>(), x10aux::getRTT<P6>(), Modified: trunk/x10.runtime.17/src-cpp/x10/lang/VoidFun_0_8.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/VoidFun_0_8.h 2009-08-03 18:46:03 UTC (rev 10901) +++ trunk/x10.runtime.17/src-cpp/x10/lang/VoidFun_0_8.h 2009-08-04 01:49:12 UTC (rev 10902) @@ -30,7 +30,7 @@ template<class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8> void VoidFun_0_8<P1,P2,P3,P4,P5,P6,P7,P8>::_initRTT() { - rtt.parentsc = -2; + rtt.typeName = "CYCLIC RTT INIT\n"; x10::lang::_initRTTHelper_VoidFun_0_8(&rtt, x10aux::getRTT<P1>(), x10aux::getRTT<P2>(), x10aux::getRTT<P3>(), x10aux::getRTT<P4>(), x10aux::getRTT<P5>(), x10aux::getRTT<P6>(), Modified: trunk/x10.runtime.17/src-cpp/x10/util/GrowableRail.cc =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/util/GrowableRail.cc 2009-08-03 18:46:03 UTC (rev 10901) +++ trunk/x10.runtime.17/src-cpp/x10/util/GrowableRail.cc 2009-08-04 01:49:12 UTC (rev 10902) @@ -11,9 +11,11 @@ namespace util { void _initRTTHelper_GrowableRail(RuntimeType *location, const RuntimeType *element) { + const RuntimeType* parents[1] = { Ref::getRTT() }; + const RuntimeType* params[1] = { element }; + RuntimeType::Variance variances[1] = { RuntimeType::invariant }; const char *name = alloc_printf("x10.lang.GrowableRail[%s]", element->name()); - const RuntimeType *p1 = Ref::getRTT(); - location->init(name, 1, p1); + location->init(name, 1, parents, 1, params, variances); } } } Modified: trunk/x10.runtime.17/src-cpp/x10/util/GrowableRail.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/util/GrowableRail.h 2009-08-03 18:46:03 UTC (rev 10901) +++ trunk/x10.runtime.17/src-cpp/x10/util/GrowableRail.h 2009-08-04 01:49:12 UTC (rev 10902) @@ -134,7 +134,7 @@ }; template<class T> void GrowableRail<T>::_initRTT() { - rtt.parentsc = -2; + rtt.typeName = "CYCLIC RTT INIT\n"; x10::util::_initRTTHelper_GrowableRail(&rtt, x10aux::getRTT<T>()); } Modified: trunk/x10.runtime.17/src-cpp/x10/util/concurrent/atomic/AtomicReference.cc =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/util/concurrent/atomic/AtomicReference.cc 2009-08-03 18:46:03 UTC (rev 10901) +++ trunk/x10.runtime.17/src-cpp/x10/util/concurrent/atomic/AtomicReference.cc 2009-08-04 01:49:12 UTC (rev 10902) @@ -10,9 +10,11 @@ namespace atomic { void _initRTTHelper_AtomicReference(RuntimeType *location, const RuntimeType *rtt) { + const RuntimeType* parents[1] = { Ref::getRTT() }; + const RuntimeType* params[1] = { rtt }; + RuntimeType::Variance variances[1] = { RuntimeType::invariant }; const char *name = alloc_printf("x10.util.concurrent.atomic.AtomicReference[%s]",rtt->name()); - const RuntimeType *parent = Ref::getRTT(); - location->init(name, 1, parent); + location->init(name, 1, parents, 1, params, variances); } } } Modified: trunk/x10.runtime.17/src-cpp/x10/util/concurrent/atomic/AtomicReference.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/util/concurrent/atomic/AtomicReference.h 2009-08-03 18:46:03 UTC (rev 10901) +++ trunk/x10.runtime.17/src-cpp/x10/util/concurrent/atomic/AtomicReference.h 2009-08-04 01:49:12 UTC (rev 10902) @@ -110,7 +110,7 @@ } template<class T> void AtomicReference<T >::_initRTT() { - rtt.parentsc = -2; + rtt.typeName = "CYCLIC RTT INIT\n"; x10::util::concurrent::atomic::_initRTTHelper_AtomicReference(&rtt, x10aux::getRTT<T>()); } Modified: trunk/x10.runtime.17/src-cpp/x10aux/RTT.cc =================================================================== --- trunk/x10.runtime.17/src-cpp/x10aux/RTT.cc 2009-08-03 18:46:03 UTC (rev 10901) +++ trunk/x10.runtime.17/src-cpp/x10aux/RTT.cc 2009-08-04 01:49:12 UTC (rev 10902) @@ -36,53 +36,80 @@ return other->_type()->equals(this); } -void RuntimeType::init(const char* n, int pc, ...) { - parentsc = pc; - typeName = n; - parents = alloc<const RuntimeType*>(parentsc * sizeof(const RuntimeType*)); - va_list parentsv; - va_start(parentsv, pc); - for (int i=0 ; i<parentsc ; ++i) - parents[i] = va_arg(parentsv,const RuntimeType*); - va_end(parentsv); +void RuntimeType::init(const char* typeName_, int parentsc_, const RuntimeType** parents_, + int paramsc_, const RuntimeType** params_, Variance* variances_) { + typeName = typeName_; + parentsc = parentsc_; + paramsc = paramsc_; + if (parentsc > 0) { + parents = alloc<const RuntimeType*>(parentsc * sizeof(const RuntimeType*)); + for (int i=0; i<parentsc; i++) { + parents[i] = parents_[i]; + } + } else { + parents = NULL; + } + if (paramsc > 0) { + params = alloc<const RuntimeType*>(paramsc * sizeof(const RuntimeType*)); + variances = alloc<Variance>(paramsc * sizeof(Variance)); + for (int i=0; i<paramsc; i++) { + params[i] = params_[i]; + variances[i] = variances_[i]; + } + } else { + params = NULL; + variances = NULL; + } x10aux::atomic_ops::store_load_barrier(); } void RuntimeType::initBooleanType() { - BooleanType.init("x10.lang.Boolean", 1, x10::lang::Object::getRTT()); + const RuntimeType* parents[1] = {x10::lang::Object::getRTT()}; + BooleanType.init("x10.lang.Boolean", 1, parents, 0, NULL, NULL); } void RuntimeType::initByteType() { - ByteType.init("x10.lang.Byte", 1, x10::lang::Object::getRTT()); + const RuntimeType* parents[1] = {x10::lang::Object::getRTT()}; + ByteType.init("x10.lang.Byte", 1, parents, 0, NULL, NULL); } void RuntimeType::initCharType() { - CharType.init("x10.lang.Char", 1, x10::lang::Object::getRTT()); + const RuntimeType* parents[1] = {x10::lang::Object::getRTT()}; + CharType.init("x10.lang.Char", 1, parents, 0, NULL, NULL); } void RuntimeType::initShortType() { - ShortType.init("x10.lang.Short", 1, x10::lang::Object::getRTT()); + const RuntimeType* parents[1] = {x10::lang::Object::getRTT()}; + ShortType.init("x10.lang.Short", 1, parents, 0, NULL, NULL); } void RuntimeType::initIntType() { - IntType.init("x10.lang.Int", 1, x10::lang::Object::getRTT()); + const RuntimeType* parents[1] = {x10::lang::Object::getRTT()}; + IntType.init("x10.lang.Int", 1, parents, 0, NULL, NULL); } void RuntimeType::initFloatType() { - FloatType.init("x10.lang.Float", 1, x10::lang::Object::getRTT()); + const RuntimeType* parents[1] = {x10::lang::Object::getRTT()}; + FloatType.init("x10.lang.Float", 1, parents, 0, NULL, NULL); } void RuntimeType::initLongType() { - LongType.init("x10.lang.Long", 1, x10::lang::Object::getRTT()); + const RuntimeType* parents[1] = {x10::lang::Object::getRTT()}; + LongType.init("x10.lang.Long", 1, parents, 0, NULL, NULL); } void RuntimeType::initDoubleType() { - DoubleType.init("x10.lang.Double", 1, x10::lang::Object::getRTT()); + const RuntimeType* parents[1] = {x10::lang::Object::getRTT()}; + DoubleType.init("x10.lang.Double", 1, parents, 0, NULL, NULL); } void RuntimeType::initUByteType() { - UByteType.init("x10.lang.UByte", 1, x10::lang::Object::getRTT()); + const RuntimeType* parents[1] = {x10::lang::Object::getRTT()}; + UByteType.init("x10.lang.UByte", 1, parents, 0, NULL, NULL); } void RuntimeType::initUShortType() { - UShortType.init("x10.lang.UShort", 1, x10::lang::Object::getRTT()); + const RuntimeType* parents[1] = {x10::lang::Object::getRTT()}; + UShortType.init("x10.lang.UShort", 1, parents, 0, NULL, NULL); } void RuntimeType::initUIntType() { - UIntType.init("x10.lang.UInt", 1, x10::lang::Object::getRTT()); + const RuntimeType* parents[1] = {x10::lang::Object::getRTT()}; + UIntType.init("x10.lang.UInt", 1, parents, 0, NULL, NULL); } void RuntimeType::initULongType() { - ULongType.init("x10.lang.ULong", 1, x10::lang::Object::getRTT()); + const RuntimeType* parents[1] = {x10::lang::Object::getRTT()}; + ULongType.init("x10.lang.ULong", 1, parents, 0, NULL, NULL); } Modified: trunk/x10.runtime.17/src-cpp/x10aux/RTT.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10aux/RTT.h 2009-08-03 18:46:03 UTC (rev 10901) +++ trunk/x10.runtime.17/src-cpp/x10aux/RTT.h 2009-08-04 01:49:12 UTC (rev 10902) @@ -22,11 +22,15 @@ #define RTT_H_DECLS_INTERFACE \ static x10aux::RuntimeType rtt; \ static const x10aux::RuntimeType* getRTT() { if (NULL == rtt.typeName) _initRTT(); return &rtt; } \ - static void _initRTT(); \ + static void _initRTT(); -#define RTT_CC_DECLS1(TYPE,NAME,P1) \ - x10aux::RuntimeType TYPE::rtt; \ - void TYPE::_initRTT() { rtt.typeName = "CYCLIC RTT INIT\n"; rtt.init(NAME, 1, P1::getRTT()); } +#define RTT_CC_DECLS1(TYPE,NAME,P1) \ + x10aux::RuntimeType TYPE::rtt; \ + void TYPE::_initRTT() { \ + rtt.typeName = "CYCLIC RTT INIT\n"; \ + const x10aux::RuntimeType* parents[1] = {P1::getRTT()}; \ + rtt.init(NAME, 1, parents, 0, NULL, NULL); \ + } namespace x10 { namespace lang { @@ -60,12 +64,18 @@ static RuntimeType UIntType; static RuntimeType ULongType; + enum Variance { covariant, contravariant, invariant }; + public: int parentsc; + int paramsc; const RuntimeType **parents; + const RuntimeType **params; + Variance *variances; const char* typeName; - void init(const char* n, int pc, ...); + void init(const char* typeName_, int parsentsc_, const RuntimeType** parents_, + int paramsc_, const RuntimeType** params_, Variance* variances_); const char *name() const { return typeName; } @@ -204,6 +214,7 @@ template<> inline const char *typeName<volatile void*>() { return "volatile void *"; } template<> inline const char *typeName<char>() { return "char"; } template<> inline const char *typeName<const RuntimeType*>() { return "const RuntimeType *"; } + template<> inline const char *typeName<RuntimeType::Variance>() { return "Variance"; } template<class T, class S> struct Instanceof { static x10_boolean _(S v) { return false; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <spa...@us...> - 2009-08-04 20:26:33
|
Revision: 10913 http://x10.svn.sourceforge.net/x10/?rev=10913&view=rev Author: sparksparkspark Date: 2009-08-04 20:26:14 +0000 (Tue, 04 Aug 2009) Log Message: ----------- 1) implement realloc properly 2) use plain c malloc calls for non-x10 objects like deserialization_dispatcher, etc 3) split serialization_buffer in two 4) make fewer calls into x10rt 5) adapt to new x10rt interface 6) add accelerator support to x10aux/network.{h,cc} 7) delete dead message receiving code (had rotted anyway) 8) remove references to pgas in debug output, comments etc (talk about x10rt instead) 9) get rid of PGASInitializer class, initialise GC and x10rt from template_main 10) Use network byte order when serialising 11) define _get_serialization_id() instead of _serialize_id(buf) in every value class 12) Remove NativeRuntime.event_probe (busy waiting should be controlled from XRX) 13) Use modern name of pgas library (now we can get rid of the symlink in pgas) 14) Fix bug where closures were indented wrongly Modified Paths: -------------- trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/Emitter.java trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/MessagePassingCodeGenerator.java trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/SharedVarsMethods.java trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/X10CPPTranslator.java trunk/x10.runtime.17/src-cpp/Makefile trunk/x10.runtime.17/src-cpp/x10/lang/Object.cc trunk/x10.runtime.17/src-cpp/x10/lang/Object.h trunk/x10.runtime.17/src-cpp/x10/lang/Ref.cc trunk/x10.runtime.17/src-cpp/x10/lang/Ref.h trunk/x10.runtime.17/src-cpp/x10/lang/String.h trunk/x10.runtime.17/src-cpp/x10/lang/Throwable.cc trunk/x10.runtime.17/src-cpp/x10/lang/Throwable.h trunk/x10.runtime.17/src-cpp/x10/lang/ValRail.h trunk/x10.runtime.17/src-cpp/x10/lang/Value.h trunk/x10.runtime.17/src-cpp/x10aux/alloc.h trunk/x10.runtime.17/src-cpp/x10aux/bootstrap.h trunk/x10.runtime.17/src-cpp/x10aux/config.h trunk/x10.runtime.17/src-cpp/x10aux/deserialization_dispatcher.cc trunk/x10.runtime.17/src-cpp/x10aux/deserialization_dispatcher.h trunk/x10.runtime.17/src-cpp/x10aux/fun_utils.h trunk/x10.runtime.17/src-cpp/x10aux/init_dispatcher.cc trunk/x10.runtime.17/src-cpp/x10aux/init_dispatcher.h trunk/x10.runtime.17/src-cpp/x10aux/network.cc trunk/x10.runtime.17/src-cpp/x10aux/network.h trunk/x10.runtime.17/src-cpp/x10aux/ref.cc trunk/x10.runtime.17/src-cpp/x10aux/serialization.cc trunk/x10.runtime.17/src-cpp/x10aux/serialization.h trunk/x10.runtime.17/src-x10/x10/runtime/NativeRuntime.x10 Modified: trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/Emitter.java =================================================================== --- trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/Emitter.java 2009-08-04 20:16:13 UTC (rev 10912) +++ trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/Emitter.java 2009-08-04 20:26:14 UTC (rev 10913) @@ -5,6 +5,7 @@ import static polyglot.ext.x10cpp.visit.SharedVarsMethods.DESERIALIZER_METHOD; import static polyglot.ext.x10cpp.visit.SharedVarsMethods.DESERIALIZE_BODY_METHOD; import static polyglot.ext.x10cpp.visit.SharedVarsMethods.DESERIALIZE_METHOD; +import static polyglot.ext.x10cpp.visit.SharedVarsMethods.DESERIALIZATION_BUFFER; import static polyglot.ext.x10cpp.visit.SharedVarsMethods.SAVED_THIS; import static polyglot.ext.x10cpp.visit.SharedVarsMethods.SERIALIZATION_BUFFER; import static polyglot.ext.x10cpp.visit.SharedVarsMethods.SERIALIZATION_ID_FIELD; @@ -173,7 +174,6 @@ String dest = ""; int fromIndex = 0; while (true) { - boolean finished=false; int toIndex = src.indexOf('.', fromIndex); if (fromIndex != 0 && toIndex >= 0) dest += "."; @@ -846,9 +846,9 @@ h.write("public: "); if (!type.flags().isFinal()) h.write("virtual "); - h.write("void "+SERIALIZE_ID_METHOD+"("+SERIALIZATION_BUFFER+"& buf, x10aux::addr_map& m) {"); + h.write("x10aux::serialization_id_t "+SERIALIZE_ID_METHOD+"() {"); h.newline(4); h.begin(0); - h.write("buf.write(this->"+SERIALIZATION_ID_FIELD+",m);"); h.end(); h.newline(); + h.write(" return "+SERIALIZATION_ID_FIELD+";"); h.end(); h.newline(); h.write("}"); h.newline(); h.forceNewline(); } @@ -886,7 +886,7 @@ if (!type.flags().isAbstract()) { // _deserialize() h.write("public: template<class __T> static "); - h.write(make_ref("__T")+" "+DESERIALIZER_METHOD+"("+SERIALIZATION_BUFFER+"& buf) {"); + 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(); @@ -900,7 +900,7 @@ if (type.flags().isFinal()) { // _deserialize() h.write("public: template<class __T> static "); - h.write(make_ref("__T")+" "+DESERIALIZE_METHOD+"("+SERIALIZATION_BUFFER+"& buf) {"); + 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(); @@ -910,9 +910,9 @@ // _deserialize_body() h.write("public: "); - h.write("void "+DESERIALIZE_BODY_METHOD+"("+SERIALIZATION_BUFFER+"& buf);"); h.newline(0); + h.write("void "+DESERIALIZE_BODY_METHOD+"("+DESERIALIZATION_BUFFER+"& buf);"); h.newline(0); printTemplateSignature(ct.typeArguments(), w); - w.write("void "+klass+"::"+DESERIALIZE_BODY_METHOD+"("+SERIALIZATION_BUFFER+"& buf) {"); + w.write("void "+klass+"::"+DESERIALIZE_BODY_METHOD+"("+DESERIALIZATION_BUFFER+"& buf) {"); w.newline(4); w.begin(0); if (parent != null && ts.isValueType(parent, context)) { w.write(translateType(parent)+"::"+DESERIALIZE_BODY_METHOD+"(buf);"); Modified: trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/MessagePassingCodeGenerator.java =================================================================== --- trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/MessagePassingCodeGenerator.java 2009-08-04 20:16:13 UTC (rev 10912) +++ trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/MessagePassingCodeGenerator.java 2009-08-04 20:26:14 UTC (rev 10913) @@ -22,8 +22,7 @@ import static polyglot.ext.x10cpp.visit.Emitter.translate_mangled_FQN; import static polyglot.ext.x10cpp.visit.Emitter.voidTemplateInstantiation; import static polyglot.ext.x10cpp.visit.SharedVarsMethods.CONSTRUCTOR; -import static polyglot.ext.x10cpp.visit.SharedVarsMethods.DESERIALIZER_METHOD; -import static polyglot.ext.x10cpp.visit.SharedVarsMethods.DESERIALIZE_BODY_METHOD; +import static polyglot.ext.x10cpp.visit.SharedVarsMethods.DESERIALIZATION_BUFFER; import static polyglot.ext.x10cpp.visit.SharedVarsMethods.DESERIALIZE_METHOD; import static polyglot.ext.x10cpp.visit.SharedVarsMethods.INSTANCE_INIT; import static polyglot.ext.x10cpp.visit.SharedVarsMethods.MAKE; @@ -74,7 +73,6 @@ import polyglot.ast.ClassBody_c; import polyglot.ast.ClassDecl_c; import polyglot.ast.ClassMember; -import polyglot.ast.CodeDecl; import polyglot.ast.Conditional_c; import polyglot.ast.ConstructorCall; import polyglot.ast.ConstructorDecl_c; @@ -101,7 +99,6 @@ import polyglot.ast.LocalDecl_c; import polyglot.ast.Local_c; import polyglot.ast.Loop_c; -import polyglot.ast.MethodDecl; import polyglot.ast.MethodDecl_c; import polyglot.ast.New_c; import polyglot.ast.Node; @@ -187,7 +184,6 @@ import polyglot.ext.x10cpp.types.X10CPPContext_c; import polyglot.ext.x10cpp.visit.X10CPPTranslator.DelegateTargetFactory; import polyglot.types.ClassType; -import polyglot.types.ClassType_c; import polyglot.types.CodeInstance; import polyglot.types.Context; import polyglot.types.FieldInstance; @@ -1089,7 +1085,7 @@ h.write("}"); h.newline(); h.forceNewline(); h.write("public: template<class __T> static "); - h.write(make_ref("__T")+" "+DESERIALIZE_METHOD+"("+SERIALIZATION_BUFFER+"& buf) {"); h.newline(4) ; h.begin(0); + h.write(make_ref("__T")+" "+DESERIALIZE_METHOD+"("+DESERIALIZATION_BUFFER+"& buf) {"); h.newline(4) ; h.begin(0); h.write("return x10::lang::Object::"+DESERIALIZE_METHOD+"<__T>(buf);"); h.end(); h.newline(); h.write("}"); h.newline(); h.forceNewline(); } else { @@ -2917,7 +2913,7 @@ emitter.printTemplateSignature(freeTypeParams, inc); inc.write("class "+cname+" : "); inc.begin(0); inc.write("public "+emitter.translateType(xts.Value())); - inc.write("{") ; inc.newline(4); inc.begin(0); + inc.write("{") ; inc.end() ; inc.newline(4); inc.begin(0); inc.write("public:") ; inc.newline(); inc.forceNewline(); /* ITables declarations */ @@ -2941,9 +2937,9 @@ emitter.printDeclarationList(inc, c, c.variables); inc.forceNewline(); - inc.write("void "+SERIALIZE_ID_METHOD+"("+SERIALIZATION_BUFFER+" &buf, x10aux::addr_map& m) {"); + inc.write("x10aux::serialization_id_t "+SERIALIZE_ID_METHOD+"() {"); inc.newline(4); inc.begin(0); - inc.write("buf.write(_serialization_id, m);"); inc.end(); inc.newline(); + inc.write("return "+SERIALIZATION_ID_FIELD+";"); inc.end(); inc.newline(); inc.write("}"); inc.newline(); inc.forceNewline(); inc.write("void "+SERIALIZE_BODY_METHOD+"("+SERIALIZATION_BUFFER+" &buf, x10aux::addr_map& m) {"); @@ -2961,7 +2957,7 @@ inc.end(); inc.newline(); inc.write("}"); inc.newline(); inc.forceNewline(); - inc.write("template<class __T> static "+make_ref("__T")+" "+DESERIALIZE_METHOD+"("+SERIALIZATION_BUFFER+" &buf) {"); + inc.write("template<class __T> static "+make_ref("__T")+" "+DESERIALIZE_METHOD+"("+DESERIALIZATION_BUFFER+" &buf) {"); inc.newline(4); inc.begin(0); inc.write(make_ref(cnamet)+" this_ = new (x10aux::alloc"+chevrons(cnamet)+"()) "+ cnamet+"("+SERIALIZATION_MARKER+"());"); Modified: trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/SharedVarsMethods.java =================================================================== --- trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/SharedVarsMethods.java 2009-08-04 20:16:13 UTC (rev 10912) +++ trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/SharedVarsMethods.java 2009-08-04 20:26:14 UTC (rev 10913) @@ -71,10 +71,11 @@ 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"; + static final String SERIALIZATION_BUFFER = "x10aux::serialization_buffer"; static final String SERIALIZE_METHOD = "_serialize"; - static final String SERIALIZE_ID_METHOD = "_serialize_id"; + static final String SERIALIZE_ID_METHOD = "_get_serialization_id"; static final String SERIALIZE_BODY_METHOD = "_serialize_body"; + static final String DESERIALIZATION_BUFFER = "x10aux::deserialization_buffer"; static final String DESERIALIZE_METHOD = "_deserialize"; static final String DESERIALIZER_METHOD = "_deserializer"; static final String DESERIALIZE_BODY_METHOD = "_deserialize_body"; Modified: trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/X10CPPTranslator.java =================================================================== --- trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/X10CPPTranslator.java 2009-08-04 20:16:13 UTC (rev 10912) +++ trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/X10CPPTranslator.java 2009-08-04 20:26:14 UTC (rev 10913) @@ -482,7 +482,7 @@ "-L"+X10LANG, "-L"+X10LANG+"/lib", // dist "-lx10", - "-lupcrts_"+TRANSPORT, + "-lxlpgas_"+TRANSPORT, "-ldl", "-lm", "-lpthread", Modified: trunk/x10.runtime.17/src-cpp/Makefile =================================================================== --- trunk/x10.runtime.17/src-cpp/Makefile 2009-08-04 20:16:13 UTC (rev 10912) +++ trunk/x10.runtime.17/src-cpp/Makefile 2009-08-04 20:26:14 UTC (rev 10913) @@ -103,7 +103,7 @@ XRX_MANIFEST = libx10.mft # if this doesn't exist, we need to build pgas first -PGAS_SANITY_CHECK=$(X10LIB)/include/x10/pgasrt_x10.h +PGAS_SANITY_CHECK=$(X10LIB)/include/x10/x10rt_api.h # this builds everything xrx: $(XRX_ARCHIVE) $(PGAS_SANTIY_CHECK) Modified: trunk/x10.runtime.17/src-cpp/x10/lang/Object.cc =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/Object.cc 2009-08-04 20:16:13 UTC (rev 10912) +++ trunk/x10.runtime.17/src-cpp/x10/lang/Object.cc 2009-08-04 20:26:14 UTC (rev 10913) @@ -15,13 +15,13 @@ { if (x10aux::remote_ref::is_remote(this_.get()) || this_.isNull()) { // cannot dispatch for these "addresses", handle here - buf.write(Ref::serialization_id,m); + buf.write(Ref::_serialization_id,m); buf.write(x10aux::remote_ref::make(this_.get()),m); return; } _S_("Serializing an "<<ANSI_SER<<ANSI_BOLD<<"interface"<<ANSI_RESET<< " (i.e. serializing the id) to buf: "<<&buf); - this_->_serialize_id(buf, m); + buf.write(this_->_get_serialization_id(),m); _S_("Serializing the "<<ANSI_SER<<"body"<<ANSI_RESET<<" of the interface to buf: "<<&buf); this_->_serialize_body(buf, m); } Modified: trunk/x10.runtime.17/src-cpp/x10/lang/Object.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/Object.h 2009-08-04 20:16:13 UTC (rev 10912) +++ trunk/x10.runtime.17/src-cpp/x10/lang/Object.h 2009-08-04 20:26:14 UTC (rev 10913) @@ -31,7 +31,7 @@ virtual ~Object() { } - virtual void _serialize_id(x10aux::serialization_buffer &, x10aux::addr_map &) = 0; + virtual x10aux::serialization_id_t _get_serialization_id() = 0; virtual void _serialize_body(x10aux::serialization_buffer &, x10aux::addr_map &) = 0; // This pair of functions should be overridden to not emit/extract the id in subclasses @@ -51,7 +51,7 @@ x10aux::serialization_buffer &buf, x10aux::addr_map &m); - template<class T> static x10aux::ref<T> _deserialize(x10aux::serialization_buffer &buf); + template<class T> static x10aux::ref<T> _deserialize(x10aux::deserialization_buffer &buf); x10_boolean equals(x10aux::ref<Object> other); @@ -68,7 +68,7 @@ }; - template<class T> x10aux::ref<T> Object::_deserialize(x10aux::serialization_buffer &buf){ + template<class T> x10aux::ref<T> Object::_deserialize(x10aux::deserialization_buffer &buf){ // extract the id and execute a callback to instantiate the right concrete class _S_("Deserializing an "<<ANSI_SER<<ANSI_BOLD<<"interface"<<ANSI_RESET<< " (expecting id) from buf: "<<&buf); Modified: trunk/x10.runtime.17/src-cpp/x10/lang/Ref.cc =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/Ref.cc 2009-08-04 20:16:13 UTC (rev 10912) +++ trunk/x10.runtime.17/src-cpp/x10/lang/Ref.cc 2009-08-04 20:26:14 UTC (rev 10913) @@ -29,7 +29,7 @@ return String::Lit(alloc_printf("%s@%x",this->_type()->name(),(std::size_t)this)); } -const serialization_id_t Ref::serialization_id = +const serialization_id_t Ref::_serialization_id = DeserializationDispatcher::addDeserializer(Ref::_deserialize<Object>); RTT_CC_DECLS1(Ref, "x10.lang.Ref", Object) Modified: trunk/x10.runtime.17/src-cpp/x10/lang/Ref.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/Ref.h 2009-08-04 20:16:13 UTC (rev 10912) +++ trunk/x10.runtime.17/src-cpp/x10/lang/Ref.h 2009-08-04 20:26:14 UTC (rev 10913) @@ -4,6 +4,7 @@ #include <x10aux/config.h> #include <x10aux/ref.h> #include <x10aux/RTT.h> +#include <x10aux/serialization.h> #include <x10/lang/Object.h> @@ -21,7 +22,7 @@ x10aux::ref<Ref> _constructor() { return this; } - static const x10aux::serialization_id_t serialization_id; + static const x10aux::serialization_id_t _serialization_id; static void _serialize(x10aux::ref<Ref> this_, x10aux::serialization_buffer &buf, @@ -31,16 +32,14 @@ buf.write(x10aux::remote_ref::make(this_.get()),m); } - virtual void _serialize_id(x10aux::serialization_buffer &buf, x10aux::addr_map &m) { - buf.write(serialization_id,m); - }; + virtual x10aux::serialization_id_t _get_serialization_id() { return _serialization_id; }; virtual void _serialize_body(x10aux::serialization_buffer &buf, x10aux::addr_map &m) { _S_("Serialising a local Ref object of type "<<_type()->name()); buf.write(x10aux::remote_ref::make(this),m); }; - template<class T> static x10aux::ref<T> _deserialize(x10aux::serialization_buffer &buf){ + template<class T> static x10aux::ref<T> _deserialize(x10aux::deserialization_buffer &buf){ return (T*)x10aux::remote_ref::take(buf.read<x10aux::remote_ref>()); } Modified: trunk/x10.runtime.17/src-cpp/x10/lang/String.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/String.h 2009-08-04 20:16:13 UTC (rev 10912) +++ trunk/x10.runtime.17/src-cpp/x10/lang/String.h 2009-08-04 20:26:14 UTC (rev 10913) @@ -86,13 +86,11 @@ x10aux::serialization_buffer &buf, x10aux::addr_map &m); - template<class T> static x10aux::ref<T> _deserialize(x10aux::serialization_buffer &buf); + template<class T> static x10aux::ref<T> _deserialize(x10aux::deserialization_buffer &buf); static const x10aux::serialization_id_t _serialization_id; - virtual void _serialize_id(x10aux::serialization_buffer& buf, x10aux::addr_map &m) { - buf.write(_serialization_id, m); - } + virtual x10aux::serialization_id_t _get_serialization_id() { return _serialization_id; }; virtual void _serialize_body(x10aux::serialization_buffer& buf, x10aux::addr_map &m); @@ -130,7 +128,7 @@ } #endif - template<class T> x10aux::ref<T> String::_deserialize(x10aux::serialization_buffer &buf){ + 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) { Modified: trunk/x10.runtime.17/src-cpp/x10/lang/Throwable.cc =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/Throwable.cc 2009-08-04 20:16:13 UTC (rev 10912) +++ trunk/x10.runtime.17/src-cpp/x10/lang/Throwable.cc 2009-08-04 20:26:14 UTC (rev 10913) @@ -41,7 +41,7 @@ } void -Throwable::_deserialize_body(x10aux::serialization_buffer &buf) { +Throwable::_deserialize_body(x10aux::deserialization_buffer &buf) { FMGL(cause) = buf.read<x10aux::ref<Box<x10aux::ref<Throwable> > > >(); FMGL(message) = buf.read<x10aux::ref<String> >(); } Modified: trunk/x10.runtime.17/src-cpp/x10/lang/Throwable.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/Throwable.h 2009-08-04 20:16:13 UTC (rev 10912) +++ trunk/x10.runtime.17/src-cpp/x10/lang/Throwable.h 2009-08-04 20:26:14 UTC (rev 10913) @@ -62,20 +62,18 @@ static const x10aux::serialization_id_t _serialization_id; - virtual void _serialize_id(x10aux::serialization_buffer &buf, x10aux::addr_map &m) { - buf.write(_serialization_id,m); - } + 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::serialization_buffer &buf); + template<class T> static x10aux::ref<T> _deserializer(x10aux::deserialization_buffer &buf); - void _deserialize_body(x10aux::serialization_buffer &buf); + void _deserialize_body(x10aux::deserialization_buffer &buf); static void _static_init() { } }; - template<class T> x10aux::ref<T> Throwable::_deserializer(x10aux::serialization_buffer &buf){ + template<class T> x10aux::ref<T> Throwable::_deserializer(x10aux::deserialization_buffer &buf){ x10aux::ref<Throwable> this_ = new (x10aux::alloc<Throwable>()) Throwable(); this_->_deserialize_body(buf); return this_; Modified: trunk/x10.runtime.17/src-cpp/x10/lang/ValRail.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/ValRail.h 2009-08-04 20:16:13 UTC (rev 10912) +++ trunk/x10.runtime.17/src-cpp/x10/lang/ValRail.h 2009-08-04 20:26:14 UTC (rev 10913) @@ -86,11 +86,9 @@ static void _serialize(x10aux::ref<ValRail<T> > this_, x10aux::serialization_buffer &buf, x10aux::addr_map &m); - void _serialize_id(x10aux::serialization_buffer &buf, x10aux::addr_map &m) { - buf.write(_serialization_id, m); - } + virtual x10aux::serialization_id_t _get_serialization_id() { return _serialization_id; }; void _serialize_body(x10aux::serialization_buffer &buf, x10aux::addr_map &m); - template<class S> static x10aux::ref<S> _deserialize(x10aux::serialization_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 = @@ -185,7 +183,7 @@ } } - template <class T> template<class S> x10aux::ref<S> ValRail<T>::_deserialize(x10aux::serialization_buffer &buf) { + 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<T,ValRail<T> >(length); for (x10_int i=0 ; i<length ; ++i) { Modified: trunk/x10.runtime.17/src-cpp/x10/lang/Value.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/Value.h 2009-08-04 20:16:13 UTC (rev 10912) +++ trunk/x10.runtime.17/src-cpp/x10/lang/Value.h 2009-08-04 20:26:14 UTC (rev 10913) @@ -23,17 +23,15 @@ static const x10aux::serialization_id_t _serialization_id; - virtual void _serialize_id(x10aux::serialization_buffer &buf, x10aux::addr_map &m) { - buf.write(_serialization_id,m); - } + virtual x10aux::serialization_id_t _get_serialization_id() { return _serialization_id; }; virtual void _serialize_body(x10aux::serialization_buffer &, x10aux::addr_map &) { // there are no fields } - template<class T> static x10aux::ref<T> _deserializer(x10aux::serialization_buffer &); + template<class T> static x10aux::ref<T> _deserializer(x10aux::deserialization_buffer &); - void _deserialize_body(x10aux::serialization_buffer &) { + void _deserialize_body(x10aux::deserialization_buffer &) { // there are no fields } @@ -55,7 +53,7 @@ static void _static_init() { } }; - template<class T> x10aux::ref<T> Value::_deserializer(x10aux::serialization_buffer &) { + template<class T> x10aux::ref<T> Value::_deserializer(x10aux::deserialization_buffer &) { x10aux::ref<Value> this_ = new (x10aux::alloc<Value>())Value(); return this_; } Modified: trunk/x10.runtime.17/src-cpp/x10aux/alloc.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10aux/alloc.h 2009-08-04 20:16:13 UTC (rev 10912) +++ trunk/x10.runtime.17/src-cpp/x10aux/alloc.h 2009-08-04 20:26:14 UTC (rev 10913) @@ -42,7 +42,6 @@ void throwOOME() X10_PRAGMA_NORETURN; template<class T> T* alloc(size_t size = sizeof(T)) { - // broken until we fix closure RTT (see also dealloc) _M_("Allocating " << size << " bytes of type " << TYPENAME(T)); #ifdef X10_USE_BDWGC T* ret = (T*)GC_MALLOC(size); @@ -61,18 +60,26 @@ return ret; } - // FIXME: There is a GC_REALLOC macro, which we could use when this is actually calling realloc.. - template<class T> T* realloc(T* src, size_t ssz = sizeof(T), size_t dsz = sizeof(T)) { - T *dest = alloc<T>(dsz); - if (dest!=NULL && src!=NULL) - memcpy(dest, src, ssz<dsz ? ssz : dsz); - dealloc(src); - return dest; + template<class T> T* realloc(T* src, size_t dsz) { + _M_("Reallocing chunk " << (void*)src << " of type " << TYPENAME(T)); +#ifdef X10_USE_BDWGC + T *ret = (T*)GC_REALLOC(src, dsz); +#else + T *ret = (T*)realloc(src, dsz); +#endif + if (ret==NULL && dsz>0) { + _M_("Out of memory reallocating " << dsz << " bytes"); + #ifndef NO_EXCEPTIONS + throwOOME(); + #else + assert(false && "Out of memory"); + #endif + } + return ret; } template<class T> void dealloc(const T* obj_) { T *obj = const_cast<T*>(obj_); // free does not take const void * - // broken until we fix closure RTT (see also alloc) _M_("Freeing chunk " << (void*)obj << " of type " << TYPENAME(T)); #ifdef X10_USE_BDWGC GC_FREE(obj); Modified: trunk/x10.runtime.17/src-cpp/x10aux/bootstrap.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10aux/bootstrap.h 2009-08-04 20:16:13 UTC (rev 10912) +++ trunk/x10.runtime.17/src-cpp/x10aux/bootstrap.h 2009-08-04 20:26:14 UTC (rev 10913) @@ -1,6 +1,13 @@ #ifndef X10AUX_BOOTSTRAP_H #define X10AUX_BOOTSTRAP_H +#ifdef X10_USE_BDWGC +#ifdef __linux__ +#define GC_LINUX_THREADS +#endif +#include "gc.h" +#endif + #include <x10aux/config.h> #include <x10aux/network.h> #include <x10aux/alloc.h> @@ -67,17 +74,19 @@ void initialize_xrx(); template<class Runtime, class T> int template_main(int ac, char **av) { +#ifdef X10_USE_BDWGC + GC_INIT(); +#endif + x10aux::ref<x10::lang::Rail<x10aux::ref<x10::lang::String> > > args = x10aux::convert_args(ac, av); - x10aux::init_config_bools(); - #ifndef NO_EXCEPTIONS try { #endif setlinebuf(stdout); - x10aux::barrier(); + x10aux::registration_complete(); // Initialise enough state to make this 'main' thread look like a normal x10 thread // (e.g. make Thread::CurrentThread work properly). @@ -106,7 +115,7 @@ x10aux::ref<x10::lang::Throwable> &e_ = static_cast<x10aux::ref<x10::lang::Throwable>&>(e); - fprintf(stderr, "Uncaught exception at place %ld: %s\n", (long)x10aux::here(), + fprintf(stderr, "Uncaught exception at place %ld: %s\n", (long)x10aux::here, e_->toString()->c_str()); e_->printStackTrace(); @@ -115,7 +124,7 @@ } catch(...) { - fprintf(stderr, "Caught unrecognised exception at place %ld\n", (long)x10aux::here()); + fprintf(stderr, "Caught unrecognised exception at place %ld\n", (long)x10aux::here); x10aux::exitCode = 1; } @@ -127,7 +136,7 @@ if (getenv("X10_RXTX")!=NULL) fprintf(stderr, "Place: %ld rx: %lld/%lld tx: %lld/%lld\n", - (long)x10aux::here(), + (long)x10aux::here, (long long)x10aux::deserialized_bytes, (long long)x10aux::asyncs_received, (long long)x10aux::serialized_bytes, (long long)x10aux::asyncs_sent); Modified: trunk/x10.runtime.17/src-cpp/x10aux/config.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10aux/config.h 2009-08-04 20:16:13 UTC (rev 10912) +++ trunk/x10.runtime.17/src-cpp/x10aux/config.h 2009-08-04 20:26:14 UTC (rev 10913) @@ -117,7 +117,7 @@ extern inline bool trace_ser() { if (!init_config_bools_done) init_config_bools() ; return trace_ser_; } - x10_int here (); + extern x10_int here; } #define ANSI_RESET (::x10aux::use_ansi_colors()?"\x1b[0m" :"") @@ -146,7 +146,7 @@ #define _DEBUG_MSG(col,type,msg) do { \ std::stringstream ss; \ - ss << ANSI_BOLD << x10aux::here() << ": " << col << type << ": " << ANSI_RESET << msg; \ + ss << ANSI_BOLD << x10aux::here << ": " << col << type << ": " << ANSI_RESET << msg; \ fprintf(stderr,"%s\n",ss.str().c_str()); \ } while (0) Modified: trunk/x10.runtime.17/src-cpp/x10aux/deserialization_dispatcher.cc =================================================================== --- trunk/x10.runtime.17/src-cpp/x10aux/deserialization_dispatcher.cc 2009-08-04 20:16:13 UTC (rev 10912) +++ trunk/x10.runtime.17/src-cpp/x10aux/deserialization_dispatcher.cc 2009-08-04 20:26:14 UTC (rev 10913) @@ -10,34 +10,43 @@ DeserializationDispatcher *DeserializationDispatcher::it; -serialization_id_t DeserializationDispatcher::addDeserializer (Deserializer init) { +serialization_id_t DeserializationDispatcher::addDeserializer (Deserializer init, bool is_async) { if (NULL == it) { it = new (alloc<DeserializationDispatcher>()) DeserializationDispatcher(); } - return it->addDeserializer_(init); + return it->addDeserializer_(init, is_async); } -serialization_id_t DeserializationDispatcher::addDeserializer_ (Deserializer init) { +serialization_id_t DeserializationDispatcher::addDeserializer_ (Deserializer init, bool is_async) { if (initsz<=(size_t)initc) { // grow slowly as this is init phase and we don't want to take // up RAM unnecessarily size_t newsz = initsz+1; - initv = realloc(initv, initsz*sizeof(Deserializer), newsz*sizeof(Deserializer)); + // do not use GC + initv = (Deserializer*)::realloc(initv, newsz*sizeof(Deserializer)); initsz = newsz; } initv[initc] = init; serialization_id_t r = initc++; _S_("DeserializationDispatcher registered the following handler for id: " <<r<<": "<<std::hex<<(size_t)init<<std::dec); + if (true || is_async) { + // TODO: use a different numbering scheme for the asyncs since there are fewer of them + _S_("(DeserializationDispatcher also registered the above id as an async)"); + x10aux::register_async_handler(r); + } return r; } -ref<Object> DeserializationDispatcher::create_(serialization_buffer &buf) { - serialization_id_t id = buf.read<serialization_id_t>(); +ref<Object> DeserializationDispatcher::create_(deserialization_buffer &buf, serialization_id_t id) { _S_("Dispatching deserialisation using id: "<<id); - return initv[id](buf); } +ref<Object> DeserializationDispatcher::create_(deserialization_buffer &buf) { + serialization_id_t id = buf.read<serialization_id_t>(); + return create_(buf, id); +} + // vim:tabstop=4:shiftwidth=4:expandtab Modified: trunk/x10.runtime.17/src-cpp/x10aux/deserialization_dispatcher.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10aux/deserialization_dispatcher.h 2009-08-04 20:16:13 UTC (rev 10912) +++ trunk/x10.runtime.17/src-cpp/x10aux/deserialization_dispatcher.h 2009-08-04 20:26:14 UTC (rev 10913) @@ -10,9 +10,9 @@ namespace x10aux { - class serialization_buffer; + class deserialization_buffer; - typedef ref<x10::lang::Object> (*Deserializer)(serialization_buffer &buf); + typedef ref<x10::lang::Object> (*Deserializer)(deserialization_buffer &buf); template<> inline const char *typeName<Deserializer>() { return "Deserializer"; } @@ -30,18 +30,26 @@ public: DeserializationDispatcher () : initv(NULL), initc(0), initsz(0) { } - ~DeserializationDispatcher () { dealloc(initv); } + ~DeserializationDispatcher () { ::free(initv); } // do not use GC - template<class T> static ref<T> create(serialization_buffer &buf); + 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); - ref<x10::lang::Object> create_(serialization_buffer &buf); + ref<x10::lang::Object> create_(deserialization_buffer &buf); + ref<x10::lang::Object> create_(deserialization_buffer &buf, x10aux::serialization_id_t id); - static serialization_id_t addDeserializer(Deserializer init); - serialization_id_t addDeserializer_(Deserializer init); + static serialization_id_t addDeserializer(Deserializer init, bool is_async=false); + serialization_id_t addDeserializer_(Deserializer init, bool is_async); }; - template<class T> ref<T> DeserializationDispatcher::create(serialization_buffer &buf) { + template<class T> ref<T> DeserializationDispatcher::create(deserialization_buffer &buf, + x10aux::serialization_id_t id) { // runtime pointer offset magic (for interfaces) happens here + return static_cast<ref<T> >(it->create_(buf,id)); + } + + template<class T> ref<T> DeserializationDispatcher::create(deserialization_buffer &buf) { return static_cast<ref<T> >(it->create_(buf)); } Modified: trunk/x10.runtime.17/src-cpp/x10aux/fun_utils.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10aux/fun_utils.h 2009-08-04 20:16:13 UTC (rev 10912) +++ trunk/x10.runtime.17/src-cpp/x10aux/fun_utils.h 2009-08-04 20:26:14 UTC (rev 10913) @@ -11,13 +11,14 @@ class AnyFun { public: + static void _serialize(ref<AnyFun> this_, x10aux::serialization_buffer &buf, x10aux::addr_map &m) { x10::lang::Object::_serialize(this_, buf, m); } - template<class T> static x10aux::ref<T> _deserialize(x10aux::serialization_buffer &buf) { + template<class T> static x10aux::ref<T> _deserialize(x10aux::deserialization_buffer &buf) { return x10::lang::Object::_deserialize<T>(buf); } }; Modified: trunk/x10.runtime.17/src-cpp/x10aux/init_dispatcher.cc =================================================================== --- trunk/x10.runtime.17/src-cpp/x10aux/init_dispatcher.cc 2009-08-04 20:16:13 UTC (rev 10912) +++ trunk/x10.runtime.17/src-cpp/x10aux/init_dispatcher.cc 2009-08-04 20:26:14 UTC (rev 10913) @@ -40,7 +40,8 @@ // grow slowly as this is init phase and we don't want to take // up RAM unnecessarily size_t newsz = initsz+1; - initv = realloc(initv,initsz*sizeof(Initializer),newsz*sizeof(Initializer)); + // do not use GC + initv = (Initializer*)::realloc(initv, newsz*sizeof(Initializer)); initsz = newsz; } initv[initc++] = init; Modified: trunk/x10.runtime.17/src-cpp/x10aux/init_dispatcher.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10aux/init_dispatcher.h 2009-08-04 20:16:13 UTC (rev 10912) +++ trunk/x10.runtime.17/src-cpp/x10aux/init_dispatcher.h 2009-08-04 20:26:14 UTC (rev 10913) @@ -19,7 +19,7 @@ public: InitDispatcher () : initv(NULL), initc(0), initsz(0) { } - ~InitDispatcher () { dealloc(initv); } + ~InitDispatcher () { ::free(initv); } static void runInitializers(); void runInitializers_(); Modified: trunk/x10.runtime.17/src-cpp/x10aux/network.cc =================================================================== --- trunk/x10.runtime.17/src-cpp/x10aux/network.cc 2009-08-04 20:16:13 UTC (rev 10912) +++ trunk/x10.runtime.17/src-cpp/x10aux/network.cc 2009-08-04 20:26:14 UTC (rev 10913) @@ -1,3 +1,5 @@ +#include <arpa/inet.h> // for htonl + #include <x10aux/config.h> #include <x10aux/network.h> @@ -15,140 +17,65 @@ using namespace x10::lang; using namespace x10aux; +// caches to avoid repeatedly calling into x10rt for trivial things +x10_int x10aux::num_places = -1; +x10_int x10aux::num_hosts = -1; +x10_int x10aux::here = -1; + // keep a counter for the session. volatile x10_long x10aux::asyncs_sent = 0; volatile x10_long x10aux::asyncs_received = 0; volatile x10_long x10aux::serialized_bytes = 0; volatile x10_long x10aux::deserialized_bytes = 0; -volatile int PGASInitializer::count = 0; +void x10aux::run_at(x10_uint place, x10aux::ref<Object> body) { - -void x10aux::run_at(x10_int place, x10aux::ref<VoidFun_0_0> body) { - assert(place!=x10rt_here()); // this case should be handled earlier assert(place<x10rt_nplaces()); // this is ensured by XRX runtime serialization_buffer buf; addr_map m; - _X_(ANSI_BOLD<<ANSI_X10RT<<"Transmitting an async: "<<ANSI_RESET<<ref<Object>(body)->toString()->c_str() - <<" to place: "<<place); - buf.write(body,m); - serialized_bytes += buf.length(); - asyncs_sent++; - _X_(ANSI_BOLD<<ANSI_X10RT<<"async size: "<<ANSI_RESET<<buf.length()); + _X_(ANSI_BOLD<<ANSI_X10RT<<"Transmitting an async: "<<ANSI_RESET + <<ref<Object>(body)->toString()->c_str()<<" to place: "<<place); - void *handle = x10rt_async_spawn(place, buf.get(), buf.length(), QUEUED_ASYNC); - x10rt_async_spawn_wait(handle); + buf.write((x10_uint)body->_get_serialization_id(),m); + buf.write((x10_uint)12345678, m); // this is not the real size, we fill it in properly later + body->_serialize_body(buf, m); + x10_uint sz = buf.length(); + _X_(ANSI_BOLD<<ANSI_X10RT<<"async size: "<<ANSI_RESET<<sz); + serialized_bytes += sz; asyncs_sent++; + char *the_buf = buf.steal(); + + sz = htonl(sz); + ::memcpy(the_buf+4, &sz, 4); // fill bytes [4,8) with the real size + + x10rt_send(place, the_buf, NULL); } x10_int x10aux::num_threads() { - - x10_int num = 2; const char* env = getenv("X10_NTHREADS"); - if (NULL != env) { - num = (x10_int) strtol(env, NULL, 10); - assert (num > 0); - } - + if (env==NULL) return 2; + x10_int num = strtol(env, NULL, 10); + assert (num > 0); return num; } -x10_boolean x10aux::no_steals() { +x10_boolean x10aux::no_steals() { return getenv("X10_NO_STEALS") != NULL; } - return (x10_boolean) (getenv("X10_NO_STEALS") != NULL); - +void x10aux::receive_async (void *the_buf, void *) { + _X_(ANSI_X10RT<<"Receiving an async, deserialising..."<<ANSI_RESET); + x10aux::deserialization_buffer buf(static_cast<char*>(the_buf)); + // note: high bytes thrown away in implicit conversion + x10aux::serialization_id_t id = buf.read<x10_int>(); + x10_int sz = buf.read<x10_int>(); + ref<Object> async(x10aux::DeserializationDispatcher::create<VoidFun_0_0>(buf, id)); + _X_("The deserialised async was: "<<async->toString()); + assert(buf.consumed()==sz); + // FIXME: assert that buf.sofar() == sz + deserialized_bytes += sz; asyncs_received++; + (async.get()->*(findITable<VoidFun_0_0>(async->_getITables())->apply))(); } -#include <pthread.h> -#include <x10/lang/Iterator.h> -#include <x10/lang/String.h> -#include <x10/lang/Throwable.h> -#include <x10/lang/Rail.h> -#include <x10/lang/ValRail.h> -#include <x10/runtime/Thread.h> - -#if 1 -// this one for when pgas does not use an internal thread -static void deserialize_remote_closure(void *cl, int) { - _X_(ANSI_X10RT<<"Receiving an async, deserialising..."<<ANSI_RESET); - x10aux::serialization_buffer buf(reinterpret_cast<const char*>(cl)); - ref<Object> async(x10aux::DeserializationDispatcher::create<VoidFun_0_0>(buf)); - _X_("The deserialised async was: "<<async->toString()->c_str()); - deserialized_bytes += buf.length(); - asyncs_received++; - (async.get()->*(findITable<VoidFun_0_0>(async->_getITables())->apply))(); -} -#endif -#if 0 -// this one otherwise (might have to be rewritten -- contacts are Sreedhar Kodali & Dave C) -static void deserialize_remote_closure(x10_async_closure_t *cl, int) { - -#ifndef NO_EXCEPTIONS - try { -#endif - - //fprintf(stderr,"pthread: %p\n",pthread_self()); - - // init XRX info for this internal pgas thread if it's not already done - if (x10::runtime::Thread::currentThread()==x10aux::null) { - // should happen first time we dispatch on an async or never for lapi - (void) X10NEW(x10::runtime::Thread)(x10aux::null, - String::Lit("async dispatch thread")); - } - - _X_(ANSI_PGAS"Receiving an async, deserialising..."ANSI_RESET); - x10aux::serialization_buffer buf; - buf.set(reinterpret_cast<const char*>(cl)); - ref<Object> async(x10aux::DeserializationDispatcher::create<VoidFun_0_0>(buf)); - _X_("The deserialised async was: "<<async->toString()->c_str()); - (async->*(findITable<VoidFun_0_0>(async->_getITables())->apply))(); - -#ifndef NO_EXCEPTIONS - /* TODO: need some other mechanism for calling exit() from another place - } catch(int exitCode) { - x10aux::exitCode = exitCode; - */ - - } catch(x10aux::__ref& e) { - - using namespace x10::lang; - // Assume that only throwables can be thrown - x10aux::ref<Throwable> &e_ = static_cast<x10aux::ref<Throwable>&>(e); - - fprintf(stderr, "Uncaught exception at place %ld of type: %s\n", - (long)x10aux::here(), e_->_type()->name().c_str()); - fprintf(stderr, "%s\n", e_->toString()->c_str()); - - x10aux::ref<ValRail<x10aux::ref<String> > > trace = e_->getStackTrace(); - - x10aux::ref<Iterator<x10aux::ref<String> > > it = trace->iterator(); - while (it->hasNext()) { - fprintf(stderr, " at %s\n", it->next()->c_str()); - } - - } catch(...) { - - fprintf(stderr, "Caught unrecognised exception at place %ld\n", (long)x10aux::here()); - - } -#endif - -} -#endif - -PGASInitializer::PGASInitializer() { - if (count++ == 0) { -#ifdef X10_USE_BDWGC - GC_INIT(); -#endif - _X_("PGAS initialization starting"); - x10rt_register_async_callback(deserialize_remote_closure); - x10rt_init(); - _X_("PGAS initialization complete"); - } -} - // vim:tabstop=4:shiftwidth=4:expandtab Modified: trunk/x10.runtime.17/src-cpp/x10aux/network.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10aux/network.h 2009-08-04 20:16:13 UTC (rev 10912) +++ trunk/x10.runtime.17/src-cpp/x10aux/network.h 2009-08-04 20:26:14 UTC (rev 10913) @@ -1,60 +1,107 @@ -#ifndef X10AUX_PGAS_H -#define X10AUX_PGAS_H +#ifndef X10AUX_NETWORK_H +#define X10AUX_NETWORK_H #include <x10aux/config.h> +#include <x10aux/ref.h> -#ifdef X10_USE_BDWGC -#ifdef __linux__ -#define GC_LINUX_THREADS -#endif -#include "gc.h" -#endif +#include <x10/x10rt_api.h> //x10rt -#include <x10/pgasrt_x10.h> //pgas +namespace x10 { namespace lang { class VoidFun_0_0; } } - -// Has to be first (aside from config.h which is inert and pgas itself) - namespace x10aux { - class PGASInitializer { - private: - static volatile int count; - public: - PGASInitializer(); - }; -} + void run_at(x10_uint place, x10aux::ref<x10::lang::Object> body); + + // caches to avoid repeatedly calling into x10rt for trivial things + extern x10_int num_places; + extern x10_int num_hosts; + extern x10_int here; -#include <x10aux/ref.h> + inline x10_int num_children(x10_int place) { + #ifdef X10RT_SUPPORTS_ACCELERATORS + return x10rt_nchildren(place); + #else + return 0; + #endif + } + inline x10_boolean is_host(x10_int place) { + #ifdef X10RT_SUPPORTS_ACCELERATORS + return x10rt_is_host(place); + #else + return true; + #endif + } -namespace x10 { namespace lang { class VoidFun_0_0; } } + inline x10_int parent(x10_int place) { + #ifdef X10RT_SUPPORTS_ACCELERATORS + return x10rt_parent(place); + #else + return place; + #endif + } -namespace x10aux { + inline x10_int child(x10_int place, x10_int index) { + #ifdef X10RT_SUPPORTS_ACCELERATORS + return x10rt_child(place, index); + #else + abort(); + #endif + } - void run_at(x10_int place, x10aux::ref<x10::lang::VoidFun_0_0> body); + inline x10_boolean is_spe(x10_int place) { + #ifdef X10RT_SUPPORTS_CELL + return x10rt_is_spe(place); + #else + return false; + #endif + } - // all places must reach the barrier before any may continue - inline void barrier() { - x10rt_barrier(); + inline x10_boolean is_cuda(x10_int place) { + #ifdef X10RT_SUPPORTS_CUDA + return x10rt_is_spe(place); + #else + return false; + #endif } - - inline x10_int num_places() { - return x10rt_nplaces(); + + inline x10_ulong remote_alloc (x10_int place, size_t sz) { + #ifdef X10RT_SUPPORTS_CUDA + return x10rt_remote_alloc(place, sz); + #else + return NULL; + #endif } - inline void event_probe() { - x10rt_probe(); + inline void remote_free (x10_int place, x10_ulong ptr) { + #ifdef X10RT_SUPPORTS_CUDA + x10rt_remote_free(place, ptr); + #endif } - inline x10_int here() { - return (x10_int)x10rt_here(); + void receive_async (void*, void*); + + inline void register_async_handler (unsigned id) { + x10rt_register_receiver(id, receive_async); + // [DC] these belong in registration_complete but currently statics are broken + here = x10rt_here(); + num_places = x10rt_nplaces(); + #ifdef X10RT_SUPPORTS_ACCELERATORS + num_hosts = x10rt_nhosts(); + #else + num_hosts = num_places; + #endif } - inline x10_boolean local(x10_int place) { - return (x10_boolean) (here() == place); + inline void registration_complete (void) { + x10rt_registration_complete(); } + + inline void event_probe() { + x10rt_probe(); + } + extern volatile x10_long asyncs_sent; extern volatile x10_long asyncs_received; extern volatile x10_long serialized_bytes; @@ -65,17 +112,12 @@ x10_boolean no_steals(); inline void shutdown() { - _X_("PGAS shutdown starting"); + _X_("X10RT shutdown starting"); x10rt_finalize(); - _X_("PGAS shutdown complete"); + _X_("X10RT shutdown complete"); } } -namespace { - static x10aux::PGASInitializer pgas_initializer; -} - - #endif // vim:tabstop=4:shiftwidth=4:expandtab Modified: trunk/x10.runtime.17/src-cpp/x10aux/ref.cc =================================================================== --- trunk/x10.runtime.17/src-cpp/x10aux/ref.cc 2009-08-04 20:16:13 UTC (rev 10912) +++ trunk/x10.runtime.17/src-cpp/x10aux/ref.cc 2009-08-04 20:26:14 UTC (rev 10913) @@ -22,19 +22,19 @@ #if defined(X10_USE_BDWGC) || defined(X10_DEBUG_REFERENCE_LOGGER) ReferenceLogger::log(ptr); #endif - remote_ref r = { x10aux::here(), (size_t)ptr }; + remote_ref r = { x10aux::here, (size_t)ptr }; return r; } void *remote_ref::take (remote_ref r) { - if (r.loc==x10aux::here()) return (void*)(size_t)r.addr; + if (r.loc==x10aux::here) return (void*)(size_t)r.addr; if (r.addr==0) return NULL; return mask(new remote_ref(r)); } x10_int x10aux::location (void *ptr) { if (remote_ref::is_remote(ptr)) return remote_ref::strip(ptr)->loc; - return x10aux::here(); + return x10aux::here; } // vim:tabstop=4:shiftwidth=4:expandtab Modified: trunk/x10.runtime.17/src-cpp/x10aux/serialization.cc =================================================================== --- trunk/x10.runtime.17/src-cpp/x10aux/serialization.cc 2009-08-04 20:16:13 UTC (rev 10912) +++ trunk/x10.runtime.17/src-cpp/x10aux/serialization.cc 2009-08-04 20:26:14 UTC (rev 10913) @@ -5,22 +5,21 @@ using namespace x10aux; using namespace x10::lang; -void -addr_map::_grow() { +#if 0 +NOT USED AT PRESENT +void addr_map::_grow() { _ptrs = (const void**) ::memcpy(new (x10aux::alloc<const void*>((_size<<1)*sizeof(const void*))) const void*[_size<<1], _ptrs, _size*sizeof(const void*)); _size <<= 1; } -void -addr_map::_add(const void* ptr) { +void addr_map::_add(const void* ptr) { if (_top == _size) { _grow(); } _ptrs[_top++] = ptr; } -bool -addr_map::_find(const void* ptr) { +bool addr_map::_find(const void* ptr) { for (int i = 0; i < _top; i++) { if (_ptrs[i] == ptr) { return true; @@ -29,29 +28,24 @@ return false; } -bool -addr_map::ensure_unique(const void* p) { +bool addr_map::ensure_unique(const void* p) { if (_find(p)) { return false; } _add(p); return true; } +#endif -char * -serialization_buffer::grow() { - assert (limit != NULL); - char* saved_buf = buffer; - size_t length = cursor - buffer; - size_t allocated = limit - buffer; - float grow_factor = GROW_PERCENT / 100.0; - size_t new_size = (size_t) (allocated * grow_factor); - buffer = alloc(new_size); - ::memcpy(buffer, saved_buf, length); - limit = buffer + new_size; - cursor = buffer + length; - dealloc(saved_buf); - return buffer; -} +void serialization_buffer::grow (void) { + size_t new_length = length(); // no change in used portion of buffer + size_t new_capacity = (size_t) (capacity() * 2.0); // increase capacity by a factor + if (new_capacity<16) new_capacity = 16; // biggest primitive we might serialise -- a SIMD variable + + // do not use GC + buffer = (char*)::realloc(buffer, new_capacity); - + // update pointers to use (potentially) new buffer + limit = buffer + new_capacity; + cursor = buffer + new_length; +} Modified: trunk/x10.runtime.17/src-cpp/x10aux/serialization.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10aux/serialization.h 2009-08-04 20:16:13 UTC (rev 10912) +++ trunk/x10.runtime.17/src-cpp/x10aux/serialization.h 2009-08-04 20:26:14 UTC (rev 10913) @@ -118,10 +118,16 @@ namespace x10aux { + // Used to allow us to define 'do-nothing' constructors for classes that already have default + // constructors. Currently only used in closures. class SERIALIZATION_MARKER { }; - // Allows runtime detection of Value cycles + + // addr_map can be used to detect and properly handle cycles when serialising object graphs + // it can also be used to avoid serialising two copies of an object when serialising a DAG. class addr_map { +#if 0 +NOT USED AT PRESENT int _size; const void** _ptrs; int _top; @@ -129,72 +135,78 @@ 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 }; - // A growable buffer for serialising into and out of + // Endian encoding/decoding support + template<class T> void code_bytes(T *x) { + (void) x; + #if defined(__i386__) || defined(__x86_64__) + unsigned char *buf = (unsigned char*) x; + for (int i=0,j=sizeof(T)-1 ; i<j ; ++i,--j) { + std::swap(buf[i], buf[j]); + } + #endif + } + + + // A growable buffer for serialising into class serialization_buffer { + private: - static const int GROW_PERCENT = 200; // can't use float but don't want extra .cc file - static const size_t INITIAL_SIZE = 16; - char* buffer; - char* limit; - char* cursor; - static char* alloc(size_t size) { return x10aux::alloc<char>(size); } - static void dealloc(char* buf) { x10aux::dealloc<char>(buf); } - char* grow(); + char *buffer; + char *limit; + 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 - serialization_buffer(const char *buffer_) - : buffer(const_cast<char*>(buffer_)), limit(NULL), cursor(buffer) + serialization_buffer (void) + // do not use GC + : buffer(NULL), limit(NULL), cursor(NULL) { } - serialization_buffer() - : buffer(alloc(INITIAL_SIZE)), limit(buffer + INITIAL_SIZE), cursor(buffer) - { } - - ~serialization_buffer() { - if (limit!=NULL) - dealloc(buffer); + ~serialization_buffer (void) { + // do not use GC + ::free(buffer); } - const char *get() const { return buffer; } + void grow (void); - size_t length() { return cursor - buffer; } + size_t length (void) { return cursor - buffer; } + size_t capacity (void) { return limit - buffer; } + char *steal() { char *buf = buffer; buffer = NULL; return buf; } // 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); - // 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(); }; // default case for primitives and other things that never contain pointers template<class T> struct serialization_buffer::Write { - static void _(serialization_buffer &buf, const T &val, addr_map &); + static void _(serialization_buffer &buf, const T &val, addr_map &m); }; - template<class T> void serialization_buffer::Write<T>::_(serialization_buffer &buf, const T &val, addr_map &) { + template<class T> void serialization_buffer::Write<T>::_(serialization_buffer &buf, + const T &val, addr_map &m) { // FIXME: assumes all places are same endian _S_("Serializing a "<<ANSI_SER<<TYPENAME(T)<<ANSI_RESET<<": "<<val<<" into buf: "<<&buf); //*(T*) buf.cursor = val; // Cannot do this because of alignment + if (buf.cursor + sizeof(T) >= buf.limit) buf.grow(); memcpy(buf.cursor, &val, sizeof(T)); + code_bytes((T*)buf.cursor); buf.cursor += sizeof(T); } @@ -204,46 +216,69 @@ }; // case for references e.g. ref<Object>, - template<class T> void serialization_buffer::Write<ref<T> >::_(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) T::_serialize(val,buf,m); } template<typename T> void serialization_buffer::write(const T &val, addr_map &m) { - if (cursor + sizeof(T) >= limit) grow(); Write<T>::_(*this,val,m); } + // A buffer from which we can deserialise x10 objects + class deserialization_buffer { + private: + const char* buffer; + 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 + template<class T> struct Read; + template<class T> struct Read<ref<T> >; + template<typename T> GPUSAFE T read(); + }; + // default case for primitives and other things that never contain pointers - template<class T> struct serialization_buffer::Read { - GPUSAFE static T _(serialization_buffer &buf); + template<class T> struct deserialization_buffer::Read { + GPUSAFE static T _(deserialization_buffer &buf); }; - template<class T> T serialization_buffer::Read<T>::_(serialization_buffer &buf) { + template<class T> T deserialization_buffer::Read<T>::_(deserialization_buffer &buf) { // FIXME: assumes all places are same endian //T &val = *(T*) buf.cursor; // Cannot do this because of alignment T val; memcpy(&val, buf.cursor, sizeof(T)); buf.cursor += sizeof(T); _S_("Deserializing a "<<ANSI_SER<<TYPENAME(T)<<ANSI_RESET<<": "<<val<<" into buf: "<<&buf); + code_bytes(&val); return val; } // case for references e.g. ref<Object>, - template<class T> struct serialization_buffer::Read<ref<T> > { - GPUSAFE static ref<T> _(serialization_buffer &buf); + template<class T> struct deserialization_buffer::Read<ref<T> > { + GPUSAFE static ref<T> _(deserialization_buffer &buf); }; - template<class T> ref<T> serialization_buffer::Read<ref<T> >::_(serialization_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); return T::template _deserialize<T>(buf); } - template<typename T> GPUSAFE T serialization_buffer::read() { + template<typename T> GPUSAFE T deserialization_buffer::read() { return Read<T>::_(*this); } } Modified: trunk/x10.runtime.17/src-x10/x10/runtime/NativeRuntime.x10 =================================================================== --- trunk/x10.runtime.17/src-x10/x10/runtime/NativeRuntime.x10 2009-08-04 20:16:13 UTC (rev 10912) +++ trunk/x10.runtime.17/src-x10/x10/runtime/NativeRuntime.x10 2009-08-04 20:26:14 UTC (rev 10913) @@ -39,7 +39,7 @@ public const NO_STEALS = false; @Native("java", "x10.runtime.impl.java.Runtime.MAX_PLACES") - @Native("c++", "x10aux::num_places()") + @Na... [truncated message content] |
From: <dgr...@us...> - 2009-08-07 14:15:58
|
Revision: 10932 http://x10.svn.sourceforge.net/x10/?rev=10932&view=rev Author: dgrove-oss Date: 2009-08-07 14:15:48 +0000 (Fri, 07 Aug 2009) Log Message: ----------- Add a canonical field to the RuntimeType and machinery to initialize it as part of RTT initialization. For non-generic types, the canonical RTT of an RTT instance is itself. For generic types, the canonical RTT of an RTT instance is the <void,...> instantiation of the generic type. Also some minor cleanups and dead code elimination of RTT infrastructure. This commit puts all the machinery in place to do correct runtime typetests for generic types, but does not actually use it. The next commit will modify RuntimeType::subtypeOf to actually use the new information when determining the subtyping relationship of generic types. Modified Paths: -------------- trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/Emitter.java trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/MessagePassingCodeGenerator.java trunk/x10.runtime.17/src-cpp/x10/io/FileReader__FileInputStream.h trunk/x10.runtime.17/src-cpp/x10/io/FileWriter__FileOutputStream.h trunk/x10.runtime.17/src-cpp/x10/io/File__NativeFile.h trunk/x10.runtime.17/src-cpp/x10/io/InputStreamReader__InputStream.h trunk/x10.runtime.17/src-cpp/x10/io/OutputStreamWriter__OutputStream.h trunk/x10.runtime.17/src-cpp/x10/lang/Box.cc trunk/x10.runtime.17/src-cpp/x10/lang/Box.h trunk/x10.runtime.17/src-cpp/x10/lang/Fun.cc trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_0.h trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_1.h trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_2.h trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_3.h trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_4.h trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_5.h trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_6.h trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_7.h trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_8.h trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_9.h trunk/x10.runtime.17/src-cpp/x10/lang/Object.cc trunk/x10.runtime.17/src-cpp/x10/lang/Object.h trunk/x10.runtime.17/src-cpp/x10/lang/Rail.cc trunk/x10.runtime.17/src-cpp/x10/lang/Rail.h trunk/x10.runtime.17/src-cpp/x10/lang/RailIterator.cc trunk/x10.runtime.17/src-cpp/x10/lang/RailIterator.h trunk/x10.runtime.17/src-cpp/x10/lang/Ref.h trunk/x10.runtime.17/src-cpp/x10/lang/String.h trunk/x10.runtime.17/src-cpp/x10/lang/Throwable.h trunk/x10.runtime.17/src-cpp/x10/lang/ValRail.cc trunk/x10.runtime.17/src-cpp/x10/lang/ValRail.h trunk/x10.runtime.17/src-cpp/x10/lang/Value.h trunk/x10.runtime.17/src-cpp/x10/lang/VoidFun_0_1.h trunk/x10.runtime.17/src-cpp/x10/lang/VoidFun_0_2.h trunk/x10.runtime.17/src-cpp/x10/lang/VoidFun_0_3.h trunk/x10.runtime.17/src-cpp/x10/lang/VoidFun_0_4.h trunk/x10.runtime.17/src-cpp/x10/lang/VoidFun_0_5.h trunk/x10.runtime.17/src-cpp/x10/lang/VoidFun_0_6.h trunk/x10.runtime.17/src-cpp/x10/lang/VoidFun_0_7.h trunk/x10.runtime.17/src-cpp/x10/lang/VoidFun_0_8.h trunk/x10.runtime.17/src-cpp/x10/lang/VoidFun_0_9.h trunk/x10.runtime.17/src-cpp/x10/runtime/Deque.h trunk/x10.runtime.17/src-cpp/x10/runtime/Lock.h trunk/x10.runtime.17/src-cpp/x10/runtime/Thread.h trunk/x10.runtime.17/src-cpp/x10/tuningfork/ScalarType.h trunk/x10.runtime.17/src-cpp/x10/util/GrowableRail.cc trunk/x10.runtime.17/src-cpp/x10/util/GrowableRail.h trunk/x10.runtime.17/src-cpp/x10/util/concurrent/atomic/AtomicBoolean.h trunk/x10.runtime.17/src-cpp/x10/util/concurrent/atomic/AtomicInteger.h trunk/x10.runtime.17/src-cpp/x10/util/concurrent/atomic/AtomicLong.h trunk/x10.runtime.17/src-cpp/x10/util/concurrent/atomic/AtomicReference.cc trunk/x10.runtime.17/src-cpp/x10/util/concurrent/atomic/AtomicReference.h trunk/x10.runtime.17/src-cpp/x10aux/RTT.cc trunk/x10.runtime.17/src-cpp/x10aux/RTT.h Modified: trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/Emitter.java =================================================================== --- trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/Emitter.java 2009-08-06 17:52:41 UTC (rev 10931) +++ trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/Emitter.java 2009-08-07 14:15:48 UTC (rev 10932) @@ -562,17 +562,7 @@ void printRTT(X10ClassType ct, ClassifiedStream h) { boolean isInterface = ct.flags().isInterface(); - if (ct.typeArguments().isEmpty()) { - h.write(isInterface ? "RTT_H_DECLS_INTERFACE" : "RTT_H_DECLS_CLASS"); h.newline(); h.forceNewline(); - } else { - h.write("static x10aux::RuntimeType rtt;"); h.newline(); - h.write("static const x10aux::RuntimeType* getRTT() { if (NULL == rtt.typeName) _initRTT(); return &rtt; }"); h.newline(); - h.write("static void _initRTT();"); h.newline(); - if (!isInterface) { - h.write("virtual const x10aux::RuntimeType *_type() const { return getRTT(); }"); h.newline(); - } - h.forceNewline(); - } + h.write(isInterface ? "RTT_H_DECLS_INTERFACE" : "RTT_H_DECLS_CLASS"); h.newline(); h.forceNewline(); } void printRTTDefn(X10ClassType ct, CodeWriter h) { @@ -582,14 +572,14 @@ if (ct.typeArguments().isEmpty()) { h.write("x10aux::RuntimeType "+translateType(ct)+"::rtt;"); h.newline(); h.write("void "+translateType(ct)+"::_initRTT() {"); h.newline(4); h.begin(0); - h.write("rtt.typeName = \"CYCLIC RTT INIT\";"); h.newline(); + h.write("rtt.canonical = &rtt;"); h.newline(); h.write("const x10aux::RuntimeType* parents["+num_parents+"] = { "); h.write("x10aux::getRTT" + chevrons(ct.superClass()==null ? translateType(xts.Ref()) : translateType(ct.superClass())) + "()"); for (Type iface : ct.interfaces()) { h.write(", x10aux::getRTT"+chevrons(translateType(iface))+"()"); } h.write("};"); h.newline(); - h.write("rtt.init(\""+ct.fullName()+"\", "+num_parents+ ", parents, 0, NULL, NULL);"); h.end(); h.newline(); + h.write("rtt.init(&rtt, \""+ct.fullName()+"\", "+num_parents+ ", parents, 0, NULL, NULL);"); h.end(); h.newline(); h.write("}"); h.newline(); } else { int numTypeParams = ct.typeArguments().size(); @@ -598,7 +588,7 @@ printTemplateSignature(ct.typeArguments(), h); h.write("void "+translateType(ct)+"::_initRTT() {"); h.newline(4); h.begin(0); - h.write("rtt.typeName = \"CYCLIC RTT INIT\";"); h.newline(); + h.write("rtt.canonical = &rtt;"); h.newline(); h.write("const x10aux::RuntimeType* parents["+num_parents+"] = { "); h.write("x10aux::getRTT" + chevrons(ct.superClass()==null ? translateType(xts.Ref()) : translateType(ct.superClass())) + "()"); for (Type iface : ct.interfaces()) { @@ -627,8 +617,11 @@ } first = false; } - h.write("};"); h.newline(); + h.write("};"); h.newline(); + h.write("const x10aux::RuntimeType *canonical = x10aux::getRTT"+chevrons(translateType(MessagePassingCodeGenerator.getStaticMemberContainer(ct),false))+"();"); + h.newline(); + h.write("const char *name = "); h.newline(4); h.write("x10aux::alloc_printf("); h.begin(0); h.write("\""+x10name+"["); @@ -640,7 +633,7 @@ h.write(", params["+i+"]->name()"); h.newline(); } h.write(");") ; h.end(); h.newline(); - h.write("rtt.init(name, "+num_parents+", parents, "+numTypeParams+", params, variances);"); h.end(); h.newline(); + h.write("rtt.init(canonical, name, "+num_parents+", parents, "+numTypeParams+", params, variances);"); h.end(); h.newline(); h.write("}"); h.newline(); } h.newline(); Modified: trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/MessagePassingCodeGenerator.java =================================================================== --- trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/MessagePassingCodeGenerator.java 2009-08-06 17:52:41 UTC (rev 10931) +++ trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/MessagePassingCodeGenerator.java 2009-08-07 14:15:48 UTC (rev 10932) @@ -332,6 +332,8 @@ 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(); // First process all classes for (ClassMember dec : context.pendingStaticDecls()) { if (dec instanceof ClassDecl_c) { @@ -393,6 +395,7 @@ 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;"); for (ClassMember dec : context.pendingStaticDecls()) { if (dec instanceof FieldDecl_c) { FieldDecl_c fd = (FieldDecl_c) dec; Modified: trunk/x10.runtime.17/src-cpp/x10/io/FileReader__FileInputStream.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/io/FileReader__FileInputStream.h 2009-08-06 17:52:41 UTC (rev 10931) +++ trunk/x10.runtime.17/src-cpp/x10/io/FileReader__FileInputStream.h 2009-08-07 14:15:48 UTC (rev 10932) @@ -13,7 +13,7 @@ x10aux::io::FILEPtrInputStream _inputStream; public: - RTT_H_DECLS; + RTT_H_DECLS_CLASS; FileReader__FileInputStream(FILE *f) : _inputStream(f) { } Modified: trunk/x10.runtime.17/src-cpp/x10/io/FileWriter__FileOutputStream.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/io/FileWriter__FileOutputStream.h 2009-08-06 17:52:41 UTC (rev 10931) +++ trunk/x10.runtime.17/src-cpp/x10/io/FileWriter__FileOutputStream.h 2009-08-07 14:15:48 UTC (rev 10932) @@ -13,7 +13,7 @@ x10aux::io::FILEPtrOutputStream _outputStream; public: - RTT_H_DECLS; + RTT_H_DECLS_CLASS; FileWriter__FileOutputStream(FILE *f) : _outputStream(f) { } Modified: trunk/x10.runtime.17/src-cpp/x10/io/File__NativeFile.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/io/File__NativeFile.h 2009-08-06 17:52:41 UTC (rev 10931) +++ trunk/x10.runtime.17/src-cpp/x10/io/File__NativeFile.h 2009-08-07 14:15:48 UTC (rev 10932) @@ -17,7 +17,7 @@ class File__NativeFile : public x10::lang::Ref { public: - RTT_H_DECLS; + RTT_H_DECLS_CLASS; private: Modified: trunk/x10.runtime.17/src-cpp/x10/io/InputStreamReader__InputStream.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/io/InputStreamReader__InputStream.h 2009-08-06 17:52:41 UTC (rev 10931) +++ trunk/x10.runtime.17/src-cpp/x10/io/InputStreamReader__InputStream.h 2009-08-07 14:15:48 UTC (rev 10932) @@ -13,7 +13,7 @@ class InputStreamReader__InputStream : public x10::lang::Value { public: - RTT_H_DECLS; + RTT_H_DECLS_CLASS; protected: Modified: trunk/x10.runtime.17/src-cpp/x10/io/OutputStreamWriter__OutputStream.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/io/OutputStreamWriter__OutputStream.h 2009-08-06 17:52:41 UTC (rev 10931) +++ trunk/x10.runtime.17/src-cpp/x10/io/OutputStreamWriter__OutputStream.h 2009-08-07 14:15:48 UTC (rev 10932) @@ -14,7 +14,7 @@ class OutputStreamWriter__OutputStream : public x10::lang::Value { public: - RTT_H_DECLS; + RTT_H_DECLS_CLASS; virtual void write(const char* str) = 0; Modified: trunk/x10.runtime.17/src-cpp/x10/lang/Box.cc =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/Box.cc 2009-08-06 17:52:41 UTC (rev 10931) +++ trunk/x10.runtime.17/src-cpp/x10/lang/Box.cc 2009-08-07 14:15:48 UTC (rev 10932) @@ -3,6 +3,7 @@ #include <x10aux/RTT.h> #include <x10/lang/Ref.h> +#include <x10/lang/Box.h> using namespace x10aux; @@ -13,8 +14,9 @@ const RuntimeType* parents[1] = { Ref::getRTT()}; const RuntimeType* params[1] = { rtt }; RuntimeType::Variance variances[1] = { RuntimeType::covariant }; + const RuntimeType *canonical = x10aux::getRTT<Box<void> >(); const char *name = alloc_printf("x10.lang.Box[+%s]",rtt->name()); - location->init(name, 1, parents, 1, params, variances); + location->init(canonical, name, 1, parents, 1, params, variances); } } } Modified: trunk/x10.runtime.17/src-cpp/x10/lang/Box.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/Box.h 2009-08-06 17:52:41 UTC (rev 10931) +++ trunk/x10.runtime.17/src-cpp/x10/lang/Box.h 2009-08-07 14:15:48 UTC (rev 10932) @@ -20,7 +20,7 @@ template<class T> class Box : public Ref { public: - RTT_H_DECLS + RTT_H_DECLS_CLASS; static x10aux::ref<Box<T> > _make(T contents_) { return (new (x10aux::alloc<Box<T> >())Box<T>())->_constructor(contents_); @@ -51,7 +51,7 @@ }; template<class T> void Box<T>::_initRTT() { - rtt.typeName = "CYCLIC RTT INIT\n"; + rtt.canonical = &rtt; x10::lang::_initRTTHelper_Box(&rtt, x10aux::getRTT<T>()); } Modified: trunk/x10.runtime.17/src-cpp/x10/lang/Fun.cc =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/Fun.cc 2009-08-06 17:52:41 UTC (rev 10931) +++ trunk/x10.runtime.17/src-cpp/x10/lang/Fun.cc 2009-08-07 14:15:48 UTC (rev 10932) @@ -3,11 +3,51 @@ #include <x10aux/RTT.h> #include <x10/lang/Object.h> +#include <x10/lang/Fun_0_0.h> +#include <x10/lang/Fun_0_1.h> +#include <x10/lang/Fun_0_2.h> +#include <x10/lang/Fun_0_3.h> +#include <x10/lang/Fun_0_4.h> +#include <x10/lang/Fun_0_5.h> +#include <x10/lang/Fun_0_6.h> +#include <x10/lang/Fun_0_7.h> +#include <x10/lang/Fun_0_8.h> +#include <x10/lang/Fun_0_9.h> #include <x10/lang/VoidFun_0_0.h> +#include <x10/lang/VoidFun_0_1.h> +#include <x10/lang/VoidFun_0_2.h> +#include <x10/lang/VoidFun_0_3.h> +#include <x10/lang/VoidFun_0_4.h> +#include <x10/lang/VoidFun_0_5.h> +#include <x10/lang/VoidFun_0_6.h> +#include <x10/lang/VoidFun_0_7.h> +#include <x10/lang/VoidFun_0_8.h> +#include <x10/lang/VoidFun_0_9.h> using namespace x10::lang; using namespace x10aux; +x10aux::RuntimeType Fun_0_0<void>::rtt; +x10aux::RuntimeType Fun_0_1<void,void>::rtt; +x10aux::RuntimeType Fun_0_2<void,void,void>::rtt; +x10aux::RuntimeType Fun_0_3<void,void,void,void>::rtt; +x10aux::RuntimeType Fun_0_4<void,void,void,void,void>::rtt; +x10aux::RuntimeType Fun_0_5<void,void,void,void,void,void>::rtt; +x10aux::RuntimeType Fun_0_6<void,void,void,void,void,void,void>::rtt; +x10aux::RuntimeType Fun_0_7<void,void,void,void,void,void,void,void>::rtt; +x10aux::RuntimeType Fun_0_8<void,void,void,void,void,void,void,void,void>::rtt; +x10aux::RuntimeType Fun_0_9<void,void,void,void,void,void,void,void,void,void>::rtt; + +x10aux::RuntimeType VoidFun_0_1<void>::rtt; +x10aux::RuntimeType VoidFun_0_2<void,void>::rtt; +x10aux::RuntimeType VoidFun_0_3<void,void,void>::rtt; +x10aux::RuntimeType VoidFun_0_4<void,void,void,void>::rtt; +x10aux::RuntimeType VoidFun_0_5<void,void,void,void,void>::rtt; +x10aux::RuntimeType VoidFun_0_6<void,void,void,void,void,void>::rtt; +x10aux::RuntimeType VoidFun_0_7<void,void,void,void,void,void,void>::rtt; +x10aux::RuntimeType VoidFun_0_8<void,void,void,void,void,void,void,void>::rtt; +x10aux::RuntimeType VoidFun_0_9<void,void,void,void,void,void,void,void,void>::rtt; + RTT_CC_DECLS1(VoidFun_0_0, "x10.lang.VoidFun", Object) namespace x10 { @@ -17,8 +57,9 @@ const RuntimeType* parents[1] = { Object::getRTT() }; const RuntimeType* params[1] = { rtt0 }; RuntimeType::Variance variances[1] = { RuntimeType::covariant }; + const RuntimeType* canonical = getRTT<Fun_0_0<void> >(); const char *name = alloc_printf("x10.lang.Fun_0_0[%s]",rtt0->name()); - location->init(name, 1, parents, 1, params, variances); + location->init(canonical, name, 1, parents, 1, params, variances); } void @@ -26,8 +67,9 @@ const RuntimeType* parents[1] = { Object::getRTT() }; const RuntimeType* params[2] = { rtt0, rtt1 }; RuntimeType::Variance variances[2] = { RuntimeType::covariant, RuntimeType::contravariant }; + const RuntimeType* canonical = getRTT<Fun_0_1<void, void> >(); const char *name = alloc_printf("x10.lang.Fun_0_1[%s,%s]", rtt0->name(), rtt1->name()); - location->init(name, 1, parents, 2, params, variances); + location->init(canonical, name, 1, parents, 2, params, variances); } void @@ -40,7 +82,8 @@ RuntimeType::Variance variances[] = { RuntimeType::covariant, RuntimeType::contravariant, RuntimeType::contravariant }; const char *name = alloc_printf("x10.lang.Fun_0_2[%s,%s,%s]", rtt0->name(), rtt1->name(), rtt2->name()); - location->init(name, 1, parents, 3, params, variances); + const RuntimeType* canonical = getRTT<Fun_0_2<void, void, void> >(); + location->init(canonical, name, 1, parents, 3, params, variances); } void @@ -54,7 +97,8 @@ RuntimeType::Variance variances[4] = { RuntimeType::covariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant }; const char *name = alloc_printf("x10.lang.Fun_0_3[%s,%s,%s,%s]", rtt0->name(), rtt1->name(), rtt2->name(), rtt3->name()); - location->init(name, 1, parents, 4, params, variances); + const RuntimeType* canonical = getRTT<Fun_0_3<void, void, void, void> >(); + location->init(canonical, name, 1, parents, 4, params, variances); } void @@ -67,9 +111,10 @@ const RuntimeType* parents[1] = { Object::getRTT() }; const RuntimeType* params[5] = { rtt0, rtt1, rtt2, rtt3, rtt4 }; RuntimeType::Variance variances[5] = { RuntimeType::covariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant }; + const RuntimeType* canonical = getRTT<Fun_0_4<void, void, void, void, void> >(); const char *name = alloc_printf("x10.lang.Fun_0_4[%s,%s,%s,%s,%s]", rtt0->name(), rtt1->name(), rtt2->name(), rtt3->name(), rtt4->name()); - location->init(name, 1, parents, 5, params, variances); + location->init(canonical, name, 1, parents, 5, params, variances); } void @@ -84,10 +129,11 @@ const RuntimeType* params[6] = { rtt0, rtt1, rtt2, rtt3, rtt4, rtt5 }; RuntimeType::Variance variances[6] = { RuntimeType::covariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant }; + const RuntimeType* canonical = getRTT<Fun_0_5<void, void, void, void, void, void> >(); const char *name = alloc_printf("x10.lang.Fun_0_5[%s,%s,%s,%s,%s,%s]", rtt0->name(), rtt1->name(), rtt2->name(), rtt3->name(), rtt4->name(), rtt5->name()); - location->init(name, 1, parents, 6, params, variances); + location->init(canonical, name, 1, parents, 6, params, variances); } void @@ -103,10 +149,11 @@ const RuntimeType* params[7] = { rtt0, rtt1, rtt2, rtt3, rtt4, rtt5, rtt6 }; RuntimeType::Variance variances[7] = { RuntimeType::covariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant }; + const RuntimeType* canonical = getRTT<Fun_0_6<void, void, void, void, void, void, void> >(); const char *name = alloc_printf("x10.lang.Fun_0_6[%s,%s,%s,%s,%s,%s,%s]", rtt0->name(), rtt1->name(), rtt2->name(), rtt3->name(), rtt4->name(), rtt5->name(), rtt6->name()); - location->init(name, 1, parents, 7, params, variances); + location->init(canonical, name, 1, parents, 7, params, variances); } void @@ -123,10 +170,11 @@ const RuntimeType* params[8] = { rtt0, rtt1, rtt2, rtt3, rtt4, rtt5, rtt6, rtt7 }; RuntimeType::Variance variances[8] = { RuntimeType::covariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant }; + const RuntimeType* canonical = getRTT<Fun_0_7<void, void, void, void, void, void, void, void> >(); const char *name = alloc_printf("x10.lang.Fun_0_7[%s,%s,%s,%s,%s,%s,%s,%s]", rtt0->name(), rtt1->name(), rtt2->name(), rtt3->name(), rtt4->name(), rtt5->name(), rtt6->name(), rtt7->name()); - location->init(name, 1, parents, 8, params, variances); + location->init(canonical, name, 1, parents, 8, params, variances); } void @@ -144,10 +192,11 @@ const RuntimeType* params[9] = { rtt0, rtt1, rtt2, rtt3, rtt4, rtt5, rtt6, rtt7, rtt8 }; RuntimeType::Variance variances[9] = { RuntimeType::covariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant }; + const RuntimeType* canonical = getRTT<Fun_0_8<void, void, void, void, void, void, void, void, void> >(); const char *name = alloc_printf("x10.lang.Fun_0_8[%s,%s,%s,%s,%s,%s,%s,%s,%s]", rtt0->name(), rtt1->name(), rtt2->name(), rtt3->name(), rtt4->name(), rtt5->name(), rtt6->name(), rtt7->name(), rtt8->name()); - location->init(name, 1, parents, 9, params, variances); + location->init(canonical, name, 1, parents, 9, params, variances); } void @@ -166,10 +215,11 @@ const RuntimeType* params[10] = { rtt0, rtt1, rtt2, rtt3, rtt4, rtt5, rtt6, rtt7, rtt8, rtt9 }; RuntimeType::Variance variances[10] = { RuntimeType::covariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant }; + const RuntimeType* canonical = getRTT<Fun_0_9<void, void, void, void, void, void, void, void, void, void> >(); const char *name = alloc_printf("x10.lang.Fun_0_9[%s,%s,%s,%s,%s,%s,%s,%s,%s,%s]", rtt0->name(), rtt1->name(), rtt2->name(), rtt3->name(), rtt4->name(), rtt5->name(), rtt6->name(), rtt7->name(), rtt8->name(), rtt9->name()); - location->init(name, 1, parents, 9, params, variances); + location->init(canonical, name, 1, parents, 10, params, variances); } void @@ -177,8 +227,9 @@ const RuntimeType* parents[1] = { Object::getRTT() }; const RuntimeType* params[1] = { rtt1 }; RuntimeType::Variance variances[] = { RuntimeType::contravariant }; + const RuntimeType* canonical = getRTT<VoidFun_0_1<void> >(); const char *name = alloc_printf("x10.lang.VoidFun_0_1[%s]", rtt1->name()); - location->init(name, 1, parents, 1, params, variances); + location->init(canonical, name, 1, parents, 1, params, variances); } void @@ -188,9 +239,10 @@ const RuntimeType* parents[1] = { Object::getRTT() }; const RuntimeType* params[2] = { rtt1, rtt2 }; RuntimeType::Variance variances[2] = { RuntimeType::contravariant, RuntimeType::contravariant }; + const RuntimeType* canonical = getRTT<VoidFun_0_2<void, void> >(); const char *name = alloc_printf("x10.lang.VoidFun_0_2[%s,%s]", rtt1->name(), rtt2->name()); - location->init(name, 1, parents, 2, params, variances); + location->init(canonical, name, 1, parents, 2, params, variances); } void @@ -201,9 +253,10 @@ const RuntimeType* parents[1] = { Object::getRTT() }; const RuntimeType* params[3] = { rtt1, rtt2, rtt3 }; RuntimeType::Variance variances[3] = { RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant }; + const RuntimeType* canonical = getRTT<VoidFun_0_3<void, void, void> >(); const char *name = alloc_printf("x10.lang.VoidFun_0_3[%s,%s,%s]", rtt1->name(), rtt2->name(), rtt3->name()); - location->init(name, 1, parents, 3, params, variances); + location->init(canonical, name, 1, parents, 3, params, variances); } void @@ -215,9 +268,10 @@ const RuntimeType* parents[1] = { Object::getRTT() }; const RuntimeType* params[4] = { rtt1, rtt2, rtt3, rtt4 }; RuntimeType::Variance variances[4] = { RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant }; + const RuntimeType* canonical = getRTT<VoidFun_0_4<void, void, void, void> >(); const char *name = alloc_printf("x10.lang.VoidFun_0_4[%s,%s,%s,%s]", rtt1->name(), rtt2->name(), rtt3->name(), rtt4->name()); - location->init(name, 1, parents, 4, params, variances); + location->init(canonical, name, 1, parents, 4, params, variances); } void @@ -230,10 +284,11 @@ const RuntimeType* parents[1] = { Object::getRTT() }; const RuntimeType* params[5] = { rtt1, rtt2, rtt3, rtt4, rtt5 }; RuntimeType::Variance variances[5] = { RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant }; + const RuntimeType* canonical = getRTT<VoidFun_0_5<void, void, void, void, void> >(); const char *name = alloc_printf("x10.lang.VoidFun_0_5[%s,%s,%s,%s,%s]", rtt1->name(), rtt2->name(), rtt3->name(), rtt4->name(), rtt5->name()); - location->init(name, 1, parents, 5, params, variances); + location->init(canonical, name, 1, parents, 5, params, variances); } void @@ -248,10 +303,11 @@ const RuntimeType* params[6] = { rtt1, rtt2, rtt3, rtt4, rtt5, rtt6 }; RuntimeType::Variance variances[6] = { RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant }; + const RuntimeType* canonical = getRTT<VoidFun_0_6<void, void, void, void, void, void> >(); const char *name = alloc_printf("x10.lang.VoidFun_0_6[%s,%s,%s,%s,%s,%s]", rtt1->name(), rtt2->name(), rtt3->name(), rtt4->name(), rtt5->name(), rtt6->name()); - location->init(name, 1, parents, 6, params, variances); + location->init(canonical, name, 1, parents, 6, params, variances); } void @@ -267,10 +323,11 @@ const RuntimeType* params[7] = { rtt1, rtt2, rtt3, rtt4, rtt5, rtt6, rtt7 }; RuntimeType::Variance variances[7] = { RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant }; + const RuntimeType* canonical = getRTT<VoidFun_0_7<void, void, void, void, void, void, void> >(); const char *name = alloc_printf("x10.lang.VoidFun_0_7[%s,%s,%s,%s,%s,%s,%s]", rtt1->name(), rtt2->name(), rtt3->name(), rtt4->name(), rtt5->name(), rtt6->name(), rtt7->name()); - location->init(name, 1, parents, 7, params, variances); + location->init(canonical, name, 1, parents, 7, params, variances); } void @@ -287,11 +344,12 @@ const RuntimeType* params[8] = { rtt1, rtt2, rtt3, rtt4, rtt5, rtt6, rtt7, rtt8 }; RuntimeType::Variance variances[8] = { RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant }; + const RuntimeType* canonical = getRTT<VoidFun_0_8<void, void, void, void, void, void, void, void> >(); const char *name = alloc_printf("x10.lang.VoidFun_0_8[%s,%s,%s,%s,%s,%s,%s,%s]", rtt1->name(), rtt2->name(), rtt3->name(), rtt4->name(), rtt5->name(), rtt6->name(), rtt7->name(), rtt8->name()); - location->init(name, 1, parents, 8, params, variances); + location->init(canonical, name, 1, parents, 8, params, variances); } void @@ -309,11 +367,12 @@ const RuntimeType* params[9] = { rtt1, rtt2, rtt3, rtt4, rtt5, rtt6, rtt7, rtt8, rtt9 }; RuntimeType::Variance variances[9] = { RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant }; + const RuntimeType* canonical = getRTT<VoidFun_0_9<void, void, void, void, void, void, void, void, void> >(); const char *name = alloc_printf("x10.lang.VoidFun_0_9[%s,%s,%s,%s,%s,%s,%s,%s,%s]", rtt1->name(), rtt2->name(), rtt3->name(), rtt4->name(), rtt5->name(), rtt6->name(), rtt7->name(), rtt8->name(), rtt9->name()); - location->init(name, 1, parents, 9, params, variances); + location->init(canonical, name, 1, parents, 9, params, variances); } } } Modified: trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_0.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_0.h 2009-08-06 17:52:41 UTC (rev 10931) +++ trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_0.h 2009-08-07 14:15:48 UTC (rev 10932) @@ -21,11 +21,17 @@ }; template<class R> void Fun_0_0<R>::_initRTT() { - rtt.typeName = "CYCLIC RTT INIT\n"; + rtt.canonical = &rtt; x10::lang::_initRTTHelper_Fun_0_0(&rtt, x10aux::getRTT<R>()); } template<class R> x10aux::RuntimeType Fun_0_0<R>::rtt; + + template<> class Fun_0_0<void> { + public: + static x10aux::RuntimeType rtt; + static const x10aux::RuntimeType* getRTT() { return &rtt; } + }; } } #endif Modified: trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_1.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_1.h 2009-08-06 17:52:41 UTC (rev 10931) +++ trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_1.h 2009-08-07 14:15:48 UTC (rev 10932) @@ -23,11 +23,17 @@ }; template<class P1, class R> void Fun_0_1<P1,R>::_initRTT() { - rtt.typeName = "CYCLIC RTT INIT\n"; + rtt.canonical = &rtt; x10::lang::_initRTTHelper_Fun_0_1(&rtt, x10aux::getRTT<P1>(), x10aux::getRTT<R>()); } template<class P1, class R> x10aux::RuntimeType Fun_0_1<P1,R>::rtt; + + template<> class Fun_0_1<void, void> { + public: + static x10aux::RuntimeType rtt; + static const x10aux::RuntimeType* getRTT() { return &rtt; } + }; } } #endif Modified: trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_2.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_2.h 2009-08-06 17:52:41 UTC (rev 10931) +++ trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_2.h 2009-08-07 14:15:48 UTC (rev 10932) @@ -24,12 +24,18 @@ }; template<class P1, class P2, class R> void Fun_0_2<P1,P2,R>::_initRTT() { - rtt.typeName = "CYCLIC RTT INIT\n"; + rtt.canonical = &rtt; x10::lang::_initRTTHelper_Fun_0_2(&rtt, x10aux::getRTT<P1>(), x10aux::getRTT<P2>(), x10aux::getRTT<R>()); } template<class P1, class P2, class R> x10aux::RuntimeType Fun_0_2<P1,P2,R>::rtt; + + template<> class Fun_0_2<void, void, void> { + public: + static x10aux::RuntimeType rtt; + static const x10aux::RuntimeType* getRTT() { return &rtt; } + }; } } #endif Modified: trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_3.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_3.h 2009-08-06 17:52:41 UTC (rev 10931) +++ trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_3.h 2009-08-07 14:15:48 UTC (rev 10932) @@ -25,12 +25,18 @@ }; template<class P1, class P2, class P3, class R> void Fun_0_3<P1,P2,P3,R>::_initRTT() { - rtt.typeName = "CYCLIC RTT INIT\n"; + rtt.canonical = &rtt; x10::lang::_initRTTHelper_Fun_0_3(&rtt, x10aux::getRTT<P1>(), x10aux::getRTT<P2>(), x10aux::getRTT<P3>(), x10aux::getRTT<R>()); } template<class P1, class P2, class P3, class R> x10aux::RuntimeType Fun_0_3<P1,P2,P3,R>::rtt; + + template<> class Fun_0_3<void, void, void, void> { + public: + static x10aux::RuntimeType rtt; + static const x10aux::RuntimeType* getRTT() { return &rtt; } + }; } } #endif Modified: trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_4.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_4.h 2009-08-06 17:52:41 UTC (rev 10931) +++ trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_4.h 2009-08-07 14:15:48 UTC (rev 10932) @@ -27,7 +27,7 @@ template<class P1, class P2, class P3, class P4, class R> void Fun_0_4<P1,P2,P3,P4,R>::_initRTT() { - rtt.typeName = "CYCLIC RTT INIT\n"; + rtt.canonical = &rtt; x10::lang::_initRTTHelper_Fun_0_4(&rtt, x10aux::getRTT<P1>(), x10aux::getRTT<P2>(), x10aux::getRTT<P3>(), x10aux::getRTT<P4>(), x10aux::getRTT<R>()); @@ -35,6 +35,12 @@ template<class P1, class P2, class P3, class P4, class R> x10aux::RuntimeType Fun_0_4<P1,P2,P3,P4,R>::rtt; + + template<> class Fun_0_4<void, void, void, void, void> { + public: + static x10aux::RuntimeType rtt; + static const x10aux::RuntimeType* getRTT() { return &rtt; } + }; } } #endif Modified: trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_5.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_5.h 2009-08-06 17:52:41 UTC (rev 10931) +++ trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_5.h 2009-08-07 14:15:48 UTC (rev 10932) @@ -28,7 +28,7 @@ template<class P1, class P2, class P3, class P4, class P5, class R> void Fun_0_5<P1,P2,P3,P4,P5,R>::_initRTT() { - rtt.typeName = "CYCLIC RTT INIT\n"; + rtt.canonical = &rtt; x10::lang::_initRTTHelper_Fun_0_5(&rtt, x10aux::getRTT<P1>(), x10aux::getRTT<P2>(), x10aux::getRTT<P3>(), x10aux::getRTT<P4>(), x10aux::getRTT<P5>(), x10aux::getRTT<R>()); @@ -36,6 +36,12 @@ template<class P1, class P2, class P3, class P4, class P5, class R> x10aux::RuntimeType Fun_0_5<P1,P2,P3,P4,P5,R>::rtt; + + template<> class Fun_0_5<void, void, void, void, void, void> { + public: + static x10aux::RuntimeType rtt; + static const x10aux::RuntimeType* getRTT() { return &rtt; } + }; } } #endif Modified: trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_6.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_6.h 2009-08-06 17:52:41 UTC (rev 10931) +++ trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_6.h 2009-08-07 14:15:48 UTC (rev 10932) @@ -29,7 +29,7 @@ template<class P1, class P2, class P3, class P4, class P5, class P6, class R> void Fun_0_6<P1,P2,P3,P4,P5,P6,R>::_initRTT() { - rtt.typeName = "CYCLIC RTT INIT\n"; + rtt.canonical = &rtt; x10::lang::_initRTTHelper_Fun_0_6(&rtt, x10aux::getRTT<P1>(), x10aux::getRTT<P2>(), x10aux::getRTT<P3>(), x10aux::getRTT<P4>(), x10aux::getRTT<P5>(), x10aux::getRTT<P6>(), @@ -38,6 +38,12 @@ template<class P1, class P2, class P3, class P4, class P5, class P6, class R> x10aux::RuntimeType Fun_0_6<P1,P2,P3,P4,P5,P6,R>::rtt; + + template<> class Fun_0_6<void, void, void, void, void, void, void> { + public: + static x10aux::RuntimeType rtt; + static const x10aux::RuntimeType* getRTT() { return &rtt; } + }; } } #endif Modified: trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_7.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_7.h 2009-08-06 17:52:41 UTC (rev 10931) +++ trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_7.h 2009-08-07 14:15:48 UTC (rev 10932) @@ -29,7 +29,7 @@ template<class P1, class P2, class P3, class P4, class P5, class P6, class P7, class R> void Fun_0_7<P1,P2,P3,P4,P5,P6,P7,R>::_initRTT() { - rtt.typeName = "CYCLIC RTT INIT\n"; + rtt.canonical = &rtt; x10::lang::_initRTTHelper_Fun_0_7(&rtt, x10aux::getRTT<P1>(), x10aux::getRTT<P2>(), x10aux::getRTT<P3>(), x10aux::getRTT<P4>(), x10aux::getRTT<P5>(), x10aux::getRTT<P6>(), @@ -38,6 +38,13 @@ template<class P1, class P2, class P3, class P4, class P5, class P6, class P7, class R> x10aux::RuntimeType Fun_0_7<P1,P2,P3,P4,P5,P6,P7,R>::rtt; + + template<> class Fun_0_7<void, void, void, void, void, void, void, void> { + public: + static x10aux::RuntimeType rtt; + static const x10aux::RuntimeType* getRTT() { return &rtt; } + }; + } } #endif Modified: trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_8.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_8.h 2009-08-06 17:52:41 UTC (rev 10931) +++ trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_8.h 2009-08-07 14:15:48 UTC (rev 10932) @@ -30,7 +30,7 @@ template<class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class R> void Fun_0_8<P1,P2,P3,P4,P5,P6,P7,P8,R>::_initRTT() { - rtt.typeName = "CYCLIC RTT INIT\n"; + rtt.canonical = &rtt; x10::lang::_initRTTHelper_Fun_0_8(&rtt, x10aux::getRTT<P1>(), x10aux::getRTT<P2>(), x10aux::getRTT<P3>(), x10aux::getRTT<P4>(), x10aux::getRTT<P5>(), x10aux::getRTT<P6>(), @@ -40,6 +40,12 @@ template<class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class R> x10aux::RuntimeType Fun_0_8<P1,P2,P3,P4,P5,P6,P7,P8,R>::rtt; + + template<> class Fun_0_8<void, void, void, void, void, void, void, void, void> { + public: + static x10aux::RuntimeType rtt; + static const x10aux::RuntimeType* getRTT() { return &rtt; } + }; } } #endif Modified: trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_9.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_9.h 2009-08-06 17:52:41 UTC (rev 10931) +++ trunk/x10.runtime.17/src-cpp/x10/lang/Fun_0_9.h 2009-08-07 14:15:48 UTC (rev 10932) @@ -31,7 +31,7 @@ template<class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9, class R> void Fun_0_9<P1,P2,P3,P4,P5,P6,P7,P8,P9,R>::_initRTT() { - rtt.typeName = "CYCLIC RTT INIT\n"; + rtt.canonical = &rtt; x10::lang::_initRTTHelper_Fun_0_9(&rtt, x10aux::getRTT<P1>(), x10aux::getRTT<P2>(), x10aux::getRTT<P3>(), x10aux::getRTT<P4>(), x10aux::getRTT<P5>(), x10aux::getRTT<P6>(), @@ -41,6 +41,12 @@ template<class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9, class R> x10aux::RuntimeType Fun_0_9<P1,P2,P3,P4,P5,P6,P7,P8,P9,R>::rtt; + + template<> class Fun_0_9<void, void, void, void, void, void, void, void, void, void> { + public: + static x10aux::RuntimeType rtt; + static const x10aux::RuntimeType* getRTT() { return &rtt; } + }; } } #endif Modified: trunk/x10.runtime.17/src-cpp/x10/lang/Object.cc =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/Object.cc 2009-08-06 17:52:41 UTC (rev 10931) +++ trunk/x10.runtime.17/src-cpp/x10/lang/Object.cc 2009-08-07 14:15:48 UTC (rev 10932) @@ -38,7 +38,7 @@ x10aux::RuntimeType x10::lang::Object::rtt; void Object::_initRTT() { - rtt.init("x10.lang.Object", 0, NULL, 0, NULL, NULL); + rtt.init(&rtt, "x10.lang.Object", 0, NULL, 0, NULL, NULL); } Modified: trunk/x10.runtime.17/src-cpp/x10/lang/Object.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/Object.h 2009-08-06 17:52:41 UTC (rev 10931) +++ trunk/x10.runtime.17/src-cpp/x10/lang/Object.h 2009-08-07 14:15:48 UTC (rev 10932) @@ -22,7 +22,7 @@ static x10aux::itable_entry _itables[1]; public: - RTT_H_DECLS + RTT_H_DECLS_CLASS virtual x10aux::itable_entry* _getITables() { return _itables; } Modified: trunk/x10.runtime.17/src-cpp/x10/lang/Rail.cc =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/Rail.cc 2009-08-06 17:52:41 UTC (rev 10931) +++ trunk/x10.runtime.17/src-cpp/x10/lang/Rail.cc 2009-08-07 14:15:48 UTC (rev 10932) @@ -3,19 +3,24 @@ #include <x10aux/RTT.h> #include <x10/lang/Ref.h> +#include <x10/lang/Rail.h> using namespace x10aux; namespace x10 { namespace lang { + + RuntimeType Rail<void>::rtt; + void _initRTTHelper_Rail(RuntimeType *location, const RuntimeType *element, const RuntimeType *p1, const RuntimeType *p2) { const RuntimeType *parents[3] = { Ref::getRTT(), p1, p2 }; const RuntimeType *params[1] = { element }; RuntimeType::Variance variances[1] = { RuntimeType::invariant }; + const RuntimeType *canonical = x10aux::getRTT<Rail<void> >(); const char *name = alloc_printf("x10.lang.Rail[%s]", element->name()); - location->init(name, 3, parents, 1, params, variances); + location->init(canonical, name, 3, parents, 1, params, variances); } } } Modified: trunk/x10.runtime.17/src-cpp/x10/lang/Rail.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/Rail.h 2009-08-06 17:52:41 UTC (rev 10931) +++ trunk/x10.runtime.17/src-cpp/x10/lang/Rail.h 2009-08-07 14:15:48 UTC (rev 10932) @@ -24,7 +24,7 @@ template<class T> class Rail : public Ref { public: - RTT_H_DECLS + RTT_H_DECLS_CLASS; static typename Iterable<T>::template itable<Rail<T> > _itable_iterable; static typename Settable<x10_int, T>::template itable<Rail<T> > _itable_settable; @@ -81,8 +81,14 @@ template<class T> x10aux::RuntimeType Rail<T>::rtt; + template<> class Rail<void> { + public: + static x10aux::RuntimeType rtt; + static const x10aux::RuntimeType* getRTT() { return &rtt; } + }; + template<class T> void Rail<T>::_initRTT() { - rtt.typeName = "CYCLIC RTT INIT\n"; + rtt.canonical = &rtt; x10::lang::_initRTTHelper_Rail(&rtt, x10aux::getRTT<T>(), x10aux::getRTT<Settable<x10_int,T> >(), x10aux::getRTT<Iterable<T> >()); Modified: trunk/x10.runtime.17/src-cpp/x10/lang/RailIterator.cc =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/RailIterator.cc 2009-08-06 17:52:41 UTC (rev 10931) +++ trunk/x10.runtime.17/src-cpp/x10/lang/RailIterator.cc 2009-08-07 14:15:48 UTC (rev 10932) @@ -3,19 +3,24 @@ #include <x10aux/RTT.h> #include <x10/lang/Ref.h> +#include <x10/lang/RailIterator.h> using namespace x10aux; namespace x10 { namespace lang { + + RuntimeType RailIterator<void>::rtt; + void _initRTTHelper_RailIterator(RuntimeType *location, const RuntimeType *element, const RuntimeType *p1) { const RuntimeType *parents[2] = { Ref::getRTT(), p1 }; const RuntimeType *params[1] = { element }; RuntimeType::Variance variances[1] = { RuntimeType::covariant }; + const RuntimeType *canonical = x10aux::getRTT<RailIterator<void> >(); const char *name = alloc_printf("x10.lang.Rail.Iterator[+%s]", element->name()); - location->init(name, 2, parents, 1, params, variances); + location->init(canonical, name, 2, parents, 1, params, variances); } } } Modified: trunk/x10.runtime.17/src-cpp/x10/lang/RailIterator.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/RailIterator.h 2009-08-06 17:52:41 UTC (rev 10931) +++ trunk/x10.runtime.17/src-cpp/x10/lang/RailIterator.h 2009-08-07 14:15:48 UTC (rev 10932) @@ -23,7 +23,7 @@ T const* data; public: - RTT_H_DECLS + RTT_H_DECLS_CLASS; static typename Iterator<T>::template itable<RailIterator<T> > _itable_iterator; static x10aux::itable_entry _railItITables[2]; @@ -63,8 +63,14 @@ template<class T> x10aux::RuntimeType RailIterator<T>::rtt; + template<> class RailIterator<void> { + public: + static x10aux::RuntimeType rtt; + static const x10aux::RuntimeType* getRTT() { return &rtt; } + }; + template<class T> void RailIterator<T>::_initRTT() { - rtt.typeName = "CYCLIC RTT INIT\n"; + rtt.canonical = &rtt; _initRTTHelper_RailIterator(&rtt, x10aux::getRTT<T>(), x10aux::getRTT<Iterator<T> >()); } Modified: trunk/x10.runtime.17/src-cpp/x10/lang/Ref.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/Ref.h 2009-08-06 17:52:41 UTC (rev 10931) +++ trunk/x10.runtime.17/src-cpp/x10/lang/Ref.h 2009-08-07 14:15:48 UTC (rev 10932) @@ -16,7 +16,7 @@ class Ref : public Object { public: - RTT_H_DECLS; + RTT_H_DECLS_CLASS; static x10aux::ref<Ref> _make(); Modified: trunk/x10.runtime.17/src-cpp/x10/lang/String.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/String.h 2009-08-06 17:52:41 UTC (rev 10931) +++ trunk/x10.runtime.17/src-cpp/x10/lang/String.h 2009-08-07 14:15:48 UTC (rev 10932) @@ -25,7 +25,7 @@ public: const char *c_str() const { return FMGL(content); } - RTT_H_DECLS; + RTT_H_DECLS_CLASS; // Set steal to true if you have just allocated the char * with // alloc_printf or it's otherwise OK if the String frees it. Leave Modified: trunk/x10.runtime.17/src-cpp/x10/lang/Throwable.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/Throwable.h 2009-08-06 17:52:41 UTC (rev 10931) +++ trunk/x10.runtime.17/src-cpp/x10/lang/Throwable.h 2009-08-07 14:15:48 UTC (rev 10932) @@ -19,7 +19,7 @@ class Throwable : public Value { public: - RTT_H_DECLS; + RTT_H_DECLS_CLASS; x10aux::ref<Box<x10aux::ref<Throwable> > > FMGL(cause); x10aux::ref<String> FMGL(message); Modified: trunk/x10.runtime.17/src-cpp/x10/lang/ValRail.cc =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/ValRail.cc 2009-08-06 17:52:41 UTC (rev 10931) +++ trunk/x10.runtime.17/src-cpp/x10/lang/ValRail.cc 2009-08-07 14:15:48 UTC (rev 10932) @@ -4,20 +4,24 @@ #include <x10/lang/Ref.h> #include <x10/lang/Value.h> +#include <x10/lang/ValRail.h> using namespace x10aux; namespace x10 { namespace lang { + RuntimeType ValRail<void>::rtt; + void _initRTTHelper_ValRail(RuntimeType *location, const RuntimeType *element, const RuntimeType *p1, const RuntimeType *p2) { const RuntimeType *parents[3] = { Value::getRTT(), p1, p2 }; const RuntimeType *params[1] = { element }; RuntimeType::Variance variances[1] = { RuntimeType::covariant }; + const RuntimeType *canonical = x10aux::getRTT<ValRail<void> >(); const char *name = alloc_printf("x10.lang.ValRail[+%s]", element->name()); - location->init(name, 3, parents, 1, params, variances); + location->init(canonical, name, 3, parents, 1, params, variances); } } } Modified: trunk/x10.runtime.17/src-cpp/x10/lang/ValRail.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/ValRail.h 2009-08-06 17:52:41 UTC (rev 10931) +++ trunk/x10.runtime.17/src-cpp/x10/lang/ValRail.h 2009-08-07 14:15:48 UTC (rev 10932) @@ -23,7 +23,7 @@ template<class T> class ValRail : public Value { public: - RTT_H_DECLS + RTT_H_DECLS_CLASS; static typename Iterable<T>::template itable<ValRail<T> > _itable_iterable; static typename Fun_0_1<x10_int, T>::template itable<ValRail<T> > _itable_fun; @@ -96,7 +96,7 @@ ::addDeserializer(ValRail<T>::template _deserialize<Object>); template<class T> void ValRail<T>::_initRTT() { - rtt.typeName = "CYCLIC RTT INIT\n"; + rtt.canonical = &rtt; x10::lang::_initRTTHelper_ValRail(&rtt, x10aux::getRTT<T>(), x10aux::getRTT<Fun_0_1<x10_int,T> >(), x10aux::getRTT<Iterable<T> >()); @@ -104,6 +104,12 @@ template<class T> x10aux::RuntimeType ValRail<T>::rtt; + template<> class ValRail<void> { + public: + static x10aux::RuntimeType rtt; + 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 Fun_0_1<x10_int,T>::template itable<ValRail<T> > ValRail<T>::_itable_fun(&ValRail<T>::apply); Modified: trunk/x10.runtime.17/src-cpp/x10/lang/Value.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/Value.h 2009-08-06 17:52:41 UTC (rev 10931) +++ trunk/x10.runtime.17/src-cpp/x10/lang/Value.h 2009-08-07 14:15:48 UTC (rev 10932) @@ -15,7 +15,7 @@ class Value : public Object { public: - RTT_H_DECLS; + RTT_H_DECLS_CLASS static x10aux::ref<Value> _make(); Modified: trunk/x10.runtime.17/src-cpp/x10/lang/VoidFun_0_1.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/VoidFun_0_1.h 2009-08-06 17:52:41 UTC (rev 10931) +++ trunk/x10.runtime.17/src-cpp/x10/lang/VoidFun_0_1.h 2009-08-07 14:15:48 UTC (rev 10932) @@ -22,11 +22,17 @@ }; template<class P1> void VoidFun_0_1<P1>::_initRTT() { - rtt.typeName = "CYCLIC RTT INIT\n"; + rtt.canonical = &rtt; x10::lang::_initRTTHelper_VoidFun_0_1(&rtt, x10aux::getRTT<P1>()); } template<class P1> x10aux::RuntimeType VoidFun_0_1<P1>::rtt; + + template<> class VoidFun_0_1<void> { + public: + static x10aux::RuntimeType rtt; + static const x10aux::RuntimeType* getRTT() { return &rtt; } + }; } } #endif Modified: trunk/x10.runtime.17/src-cpp/x10/lang/VoidFun_0_2.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/VoidFun_0_2.h 2009-08-06 17:52:41 UTC (rev 10931) +++ trunk/x10.runtime.17/src-cpp/x10/lang/VoidFun_0_2.h 2009-08-07 14:15:48 UTC (rev 10932) @@ -23,11 +23,17 @@ }; template<class P1, class P2> void VoidFun_0_2<P1,P2>::_initRTT() { - rtt.typeName = "CYCLIC RTT INIT\n"; + rtt.canonical = &rtt; x10::lang::_initRTTHelper_VoidFun_0_2(&rtt, x10aux::getRTT<P1>(), x10aux::getRTT<P2>()); } template<class P1, class P2> x10aux::RuntimeType VoidFun_0_2<P1,P2>::rtt; + + template<> class VoidFun_0_2<void,void> { + public: + static x10aux::RuntimeType rtt; + static const x10aux::RuntimeType* getRTT() { return &rtt; } + }; } } #endif Modified: trunk/x10.runtime.17/src-cpp/x10/lang/VoidFun_0_3.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/VoidFun_0_3.h 2009-08-06 17:52:41 UTC (rev 10931) +++ trunk/x10.runtime.17/src-cpp/x10/lang/VoidFun_0_3.h 2009-08-07 14:15:48 UTC (rev 10932) @@ -24,12 +24,18 @@ }; template<class P1, class P2, class P3> void VoidFun_0_3<P1,P2,P3>::_initRTT() { - rtt.typeName = "CYCLIC RTT INIT\n"; + rtt.canonical = &rtt; x10::lang::_initRTTHelper_VoidFun_0_3(&rtt, x10aux::getRTT<P1>(), x10aux::getRTT<P2>(), x10aux::getRTT<P3>()); } template<class P1, class P2, class P3> x10aux::RuntimeType VoidFun_0_3<P1,P2,P3>::rtt; + + template<> class VoidFun_0_3<void,void,void> { + public: + static x10aux::RuntimeType rtt; + static const x10aux::RuntimeType* getRTT() { return &rtt; } + }; } } #endif Modified: trunk/x10.runtime.17/src-cpp/x10/lang/VoidFun_0_4.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/VoidFun_0_4.h 2009-08-06 17:52:41 UTC (rev 10931) +++ trunk/x10.runtime.17/src-cpp/x10/lang/VoidFun_0_4.h 2009-08-07 14:15:48 UTC (rev 10932) @@ -26,13 +26,19 @@ template<class P1, class P2, class P3, class P4> void VoidFun_0_4<P1,P2,P3,P4>::_initRTT() { - rtt.typeName = "CYCLIC RTT INIT\n"; + rtt.canonical = &rtt; x10::lang::_initRTTHelper_VoidFun_0_4(&rtt, x10aux::getRTT<P1>(), x10aux::getRTT<P2>(), x10aux::getRTT<P3>(), x10aux::getRTT<P4>()); } template<class P1, class P2, class P3, class P4> x10aux::RuntimeType VoidFun_0_4<P1,P2,P3,P4>::rtt; + + template<> class VoidFun_0_4<void,void,void,void> { + public: + static x10aux::RuntimeType rtt; + static const x10aux::RuntimeType* getRTT() { return &rtt; } + }; } } #endif Modified: trunk/x10.runtime.17/src-cpp/x10/lang/VoidFun_0_5.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/VoidFun_0_5.h 2009-08-06 17:52:41 UTC (rev 10931) +++ trunk/x10.runtime.17/src-cpp/x10/lang/VoidFun_0_5.h 2009-08-07 14:15:48 UTC (rev 10932) @@ -27,7 +27,7 @@ template<class P1, class P2, class P3, class P4, class P5> void VoidFun_0_5<P1,P2,P3,P4,P5>::_initRTT() { - rtt.typeName = "CYCLIC RTT INIT\n"; + rtt.canonical = &rtt; x10::lang::_initRTTHelper_VoidFun_0_5(&rtt, x10aux::getRTT<P1>(), x10aux::getRTT<P2>(), x10aux::getRTT<P3>(), x10aux::getRTT<P4>(), x10aux::getRTT<P5>()); @@ -35,6 +35,12 @@ template<class P1, class P2, class P3, class P4, class P5> x10aux::RuntimeType VoidFun_0_5<P1,P2,P3,P4,P5>::rtt; + + template<> class VoidFun_0_5<void,void,void,void,void> { + public: + static x10aux::RuntimeType rtt; + static const x10aux::RuntimeType* getRTT() { return &rtt; } + }; } } #endif Modified: trunk/x10.runtime.17/src-cpp/x10/lang/VoidFun_0_6.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10/lang/VoidFun_0_6.h 2009-08-06 17:52:41 UTC (rev 10931) +++ trunk/x10.runtime.17/src-cpp/x10/lang/VoidFun_0_6.h 2009-08-07 14:15:48 UTC (rev 10932) @@ -28,7 +28,7 @@ template<class P1, class P2, class P3, class P4, class P5, class P6> void VoidFun_0_6<P1,P2,P3,P4,P5,P6>:... [truncated message content] |
From: <dgr...@us...> - 2009-08-07 21:21:51
|
Revision: 10939 http://x10.svn.sourceforge.net/x10/?rev=10939&view=rev Author: dgrove-oss Date: 2009-08-07 21:21:39 +0000 (Fri, 07 Aug 2009) Log Message: ----------- XTENLANG-481 Codegen fix to ClosureCall so that apply() on Future will find the abstract (Miranda) method in Future instead of attempting to invoke it as an interface method. Codegen for normal invokes was already correct because it is making the interface/non-interface decisions based on the type of the receiver expression, not the type of the method instance's container. Now that the codegen fix is in, we can back out the workaround in Future.x10 applied in r10895 that added an explicit apply method to sidestep the problems with Miranda methods. Modified Paths: -------------- trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/MessagePassingCodeGenerator.java trunk/x10.runtime.17/src-x10/x10/lang/Future.x10 Modified: trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/MessagePassingCodeGenerator.java =================================================================== --- trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/MessagePassingCodeGenerator.java 2009-08-07 19:20:13 UTC (rev 10938) +++ trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/MessagePassingCodeGenerator.java 2009-08-07 21:21:39 UTC (rev 10939) @@ -3253,11 +3253,20 @@ return; } - sw.write("(__extension__ ({ x10aux::ref<x10::lang::Object> _ = "); - c.printSubExpr(target, sw, tr); - sw.write("; "+(mi.returnType().isVoid() ? "" : "x10aux::GXX_ICE_Workaround"+chevrons(emitter.translateType(mi.returnType(), true))+"::_")+"((_.get()->*(x10aux::findITable"+chevrons(emitter.translateType(target.type(), false))+"(_->_getITables())->apply))("); + // Can be a non-interface dispatch for classes like Future, so we have to check. + Type t = target.type(); + String terminate = ""; + if (t.isClass() && t.toClass().flags().isInterface()) { + sw.write("(__extension__ ({ x10aux::ref<x10::lang::Object> _ = "); + c.printSubExpr(target, sw, tr); + sw.write("; "+(mi.returnType().isVoid() ? "" : "x10aux::GXX_ICE_Workaround"+chevrons(emitter.translateType(mi.returnType(), true))+"::_")+"((_.get()->*(x10aux::findITable"+chevrons(emitter.translateType(target.type(), false))+"(_->_getITables())->apply))(");; + terminate = ");}))"; + } else { + c.printSubExpr(target, sw, tr); + sw.write("->apply("); + } + sw.begin(0); - List l = args; boolean first = true; for (Iterator i = l.iterator(); i.hasNext(); ) { @@ -3268,7 +3277,7 @@ first = false; } sw.end(); - sw.write("));}))"); + sw.write(")"+terminate); } Modified: trunk/x10.runtime.17/src-x10/x10/lang/Future.x10 =================================================================== --- trunk/x10.runtime.17/src-x10/x10/lang/Future.x10 2009-08-07 19:20:13 UTC (rev 10938) +++ trunk/x10.runtime.17/src-x10/x10/lang/Future.x10 2009-08-07 21:21:39 UTC (rev 10939) @@ -23,7 +23,4 @@ * Return true if this activity has completed. */ public abstract def forced(): boolean; - - // Workaround XTENLANG-481 - public abstract def apply():T; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dgr...@us...> - 2009-08-12 19:18:31
|
Revision: 10959 http://x10.svn.sourceforge.net/x10/?rev=10959&view=rev Author: dgrove-oss Date: 2009-08-12 19:18:23 +0000 (Wed, 12 Aug 2009) Log Message: ----------- XTENLANG-432 and XTENLANG-434: The c++ codegenerator now inserts explicit calls to x10aux::nullCheck and x10aux::placeCheck. implicit nullCheck and placeCheck operations are removed from ref's -> and * operators. Although the explicit checks are occurring at a subset of the places that the implicit checks in the ref operator were occurring, there are still some obvious and low-hanging places to suppress check generation. In particular, (a) we should never generate the checks on 'this' (b) expressions of value types should not need checks (c) the result of a new does not need check (d) ... However, I also did verify that although at O0, g++ doesn't remove redundant checks, at O2 it does understand that a failed nullCheck/placeCheck won't return and therefore it does successfully eliminate redundant checks. So, that somewhat lessens the pressure to do that optimization ourself in x10c/c++ (although we may eventually want to do that if we ever specify a tighter exception model and the checks are hindering other optimizations). Modified Paths: -------------- trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/MessagePassingCodeGenerator.java trunk/x10.runtime.17/src-cpp/x10aux/ref.h Modified: trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/MessagePassingCodeGenerator.java =================================================================== --- trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/MessagePassingCodeGenerator.java 2009-08-12 19:14:29 UTC (rev 10958) +++ trunk/x10.cppbackend.17/src/polyglot/ext/x10cpp/visit/MessagePassingCodeGenerator.java 2009-08-12 19:18:23 UTC (rev 10959) @@ -2130,22 +2130,23 @@ targetMethodName = itable.mangledName(mi); isInterfaceInvoke = true; if (ret_type.isVoid()) { - sw.write("(__extension__ ({ x10aux::ref<x10::lang::Object> _ = "); + sw.write("(__extension__ ({ x10aux::ref<x10::lang::Object> _ = x10aux::placeCheck(x10aux::nullCheck("); n.printSubExpr((Expr) target, assoc, sw, tr); - sw.write("; (_.get()->*(x10aux::findITable"+chevrons(emitter.translateType(clsType, false))+"(_->_getITables())->"+itable.mangledName(mi)+"))"); + sw.write(")); (_.get()->*(x10aux::findITable"+chevrons(emitter.translateType(clsType, false))+"(_->_getITables())->"+itable.mangledName(mi)+"))"); dangling = "; }))"; } else { - sw.write("(__extension__ ({ x10aux::ref<x10::lang::Object> _ = "); + sw.write("(__extension__ ({ x10aux::ref<x10::lang::Object> _ = x10aux::placeCheck(x10aux::nullCheck("); n.printSubExpr((Expr) target, assoc, sw, tr); - sw.write("; x10aux::GXX_ICE_Workaround"+chevrons(emitter.translateType(ret_type, true))+"::_((_.get()->*(x10aux::findITable"+chevrons(emitter.translateType(clsType, false))+"(_->_getITables())->"+itable.mangledName(mi)+"))"); + sw.write(")); x10aux::GXX_ICE_Workaround"+chevrons(emitter.translateType(ret_type, true))+"::_((_.get()->*(x10aux::findITable"+chevrons(emitter.translateType(clsType, false))+"(_->_getITables())->"+itable.mangledName(mi)+"))"); dangling = "); }))"; } } } if (!isInterfaceInvoke) { + sw.write("x10aux::placeCheck(x10aux::nullCheck("); n.printSubExpr((Expr) target, assoc, sw, tr); - sw.write("->"); + sw.write("))->"); } } } else if (target instanceof TypeNode || target instanceof AmbReceiver) { @@ -2272,7 +2273,9 @@ boolean assoc = !(target instanceof New_c || target instanceof Binary_c); + sw.write("x10aux::placeCheck(x10aux::nullCheck("); n.printSubExpr((Expr) target, assoc, sw, tr); + sw.write("))"); } } else if (target instanceof TypeNode || target instanceof AmbReceiver) { @@ -2481,9 +2484,9 @@ public void visit(Throw_c n) { X10CPPContext_c context = (X10CPPContext_c) tr.context(); - sw.write("x10aux::throwException("); + sw.write("x10aux::throwException(x10aux::nullCheck("); n.print(n.expr(), sw, tr); - sw.write(");"); + sw.write("));"); } public void visit(Try_c n) { @@ -2687,9 +2690,9 @@ boolean doubleTemplate = ((X10ClassType)context.currentClass()).typeArguments().size() > 0; sw.write("x10aux::ref<x10::lang::Object> " + name + " = "+iteratorTypeRef); - sw.write("(__extension__ ({ x10aux::ref<x10::lang::Object> _1 = "); + 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.get()->*(x10aux::findITable"+chevrons(iterableType)+"(_1->_getITables())->iterator))()); }));"); sw.newline(); + sw.write(")); x10aux::GXX_ICE_Workaround"+chevrons(iteratorTypeRef)+"::_((_1.get()->*(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 ("); @@ -2816,7 +2819,6 @@ } public void visit(Closure_c n) { - X10CPPContext_c c = (X10CPPContext_c) tr.context(); emitter.enterClosure(c); @@ -3257,13 +3259,14 @@ Type t = target.type(); String terminate = ""; if (lit != null || (t.isClass() && t.toClass().flags().isInterface())) { - sw.write("(__extension__ ({ x10aux::ref<x10::lang::Object> _ = "); + 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))+"::_")+"((_.get()->*(x10aux::findITable"+chevrons(emitter.translateType(target.type(), false))+"(_->_getITables())->apply))(");; + sw.write(")); "+(mi.returnType().isVoid() ? "" : "x10aux::GXX_ICE_Workaround"+chevrons(emitter.translateType(mi.returnType(), true))+"::_")+"((_.get()->*(x10aux::findITable"+chevrons(emitter.translateType(target.type(), false))+"(_->_getITables())->apply))(");; terminate = ");}))"; } else { + sw.write("x10aux::placeCheck(x10aux::nullCheck("); c.printSubExpr(target, sw, tr); - sw.write("->apply("); + sw.write("))->apply("); } sw.begin(0); Modified: trunk/x10.runtime.17/src-cpp/x10aux/ref.h =================================================================== --- trunk/x10.runtime.17/src-cpp/x10aux/ref.h 2009-08-12 19:14:29 UTC (rev 10958) +++ trunk/x10.runtime.17/src-cpp/x10aux/ref.h 2009-08-12 19:18:23 UTC (rev 10959) @@ -33,10 +33,6 @@ } #endif - void throwNPE() X10_PRAGMA_NORETURN; - - void throwBPE() X10_PRAGMA_NORETURN; - class __ref { protected: #ifndef REF_STRIP_TYPE @@ -112,27 +108,9 @@ return *this; } - inline void assertNonNull() const { - #ifndef NO_EXCEPTIONS - if (isNull()) throwNPE(); - #endif - } - - inline void assertLocal() const { - #ifndef NO_EXCEPTIONS - if (remote_ref::is_remote(_val)) throwBPE(); - #endif - } - T& GPUSAFE operator*() const { _R_("Accessing object (*) via reference " << this << "(" << _val << ") of type " << TYPENAME(T)); - #ifndef NO_NULL_CHECKS - assertNonNull(); - #endif - #ifndef NO_PLACE_CHECKS - assertLocal(); - #endif return *(T*)_val; } @@ -143,12 +121,6 @@ T* GPUSAFE operator->() const { _R_("Accessing object (*) via reference " << this << "(" << _val << ") of type " << TYPENAME(T)); - #ifndef NO_NULL_CHECKS - assertNonNull(); - #endif - #ifndef NO_PLACE_CHECKS - assertLocal(); - #endif return (T*)_val; } @@ -180,6 +152,10 @@ } #endif + void throwNPE() X10_PRAGMA_NORETURN; + + void throwBPE() X10_PRAGMA_NORETURN; + template <class T> inline ref<T> nullCheck(ref<T> obj) { #if !defined(NO_NULL_CHECKS) && !defined(NO_EXCEPTIONS) if (obj.isNull()) throwNPE(); @@ -193,6 +169,18 @@ #endif 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; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |