From: <ta...@us...> - 2010-01-28 21:46:18
|
Revision: 12767 http://x10.svn.sourceforge.net/x10/?rev=12767&view=rev Author: tardieu Date: 2010-01-28 21:46:06 +0000 (Thu, 28 Jan 2010) Log Message: ----------- added mutable annotation for structs Modified Paths: -------------- trunk/x10.compiler/src/x10/ast/X10FieldDecl_c.java trunk/x10.runtime/src-x10/x10/compiler/ByRef.x10 Added Paths: ----------- trunk/x10.runtime/src-x10/x10/compiler/Mutable.x10 Modified: trunk/x10.compiler/src/x10/ast/X10FieldDecl_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10FieldDecl_c.java 2010-01-28 21:43:55 UTC (rev 12766) +++ trunk/x10.compiler/src/x10/ast/X10FieldDecl_c.java 2010-01-28 21:46:06 UTC (rev 12767) @@ -28,6 +28,7 @@ import polyglot.types.InitializerDef; import polyglot.types.LazyRef; import polyglot.types.Name; +import polyglot.types.QName; import polyglot.types.Ref; import polyglot.types.SemanticException; import polyglot.types.StructType; @@ -49,6 +50,7 @@ import x10.types.X10ClassDef; import x10.types.X10ClassType; import x10.types.X10Context; +import x10.types.X10Def; import x10.types.X10FieldDef; import x10.types.X10Flags; import x10.types.X10InitializerDef; @@ -102,8 +104,7 @@ throw new SemanticException("Cannot declare a non-final field in a value class.", position()); } */ - - if (X10TypeMixin.isX10Struct(ref)) { + if (X10TypeMixin.isX10Struct(ref) && !isMutable(xts, ref)) { X10Flags x10flags = X10Flags.toX10Flags(fi.flags()); if (! x10flags.isFinal()) throw new SemanticException("Illegal " + fi @@ -117,6 +118,17 @@ return result; } + protected boolean isMutable(X10TypeSystem xts, Type t) { + if (!(t instanceof X10ClassType)) return false; + X10ClassType ct = (X10ClassType) t; + try { + Type m = (Type) xts.systemResolver().find(QName.make("x10.compiler.Mutable")); + return ct.annotations().contains(m); + } catch (SemanticException e) { + return false; + } + } + protected void checkVariance(ContextVisitor tc) throws SemanticException { X10Context c = (X10Context) tc.context(); X10ClassDef cd; @@ -273,13 +285,15 @@ + this.type().type() + " (a proto type).", position()); } - if (X10TypeMixin.isX10Struct(fieldDef().container().get()) && + X10TypeSystem ts = (X10TypeSystem) tc.typeSystem(); + + if (X10TypeMixin.isX10Struct(fieldDef().container().get()) && + !isMutable(ts, fieldDef().container().get()) && ! X10Flags.toX10Flags(fieldDef().flags()).isFinal()) { throw new SemanticException("A struct may not have var fields.", position()); } - X10TypeSystem ts = (X10TypeSystem) tc.typeSystem(); X10NodeFactory nf = (X10NodeFactory) tc.nodeFactory(); X10Context context = (X10Context) tc.context(); Modified: trunk/x10.runtime/src-x10/x10/compiler/ByRef.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/compiler/ByRef.x10 2010-01-28 21:43:55 UTC (rev 12766) +++ trunk/x10.runtime/src-x10/x10/compiler/ByRef.x10 2010-01-28 21:46:06 UTC (rev 12767) @@ -8,8 +8,10 @@ package x10.compiler; +import x10.lang.annotations.ClassAnnotation; + /** An annotation on a struct that instructs the C++ backend to pass instances * of this struct by reference and not value. * @author Dave Cunningham */ -public interface ByRef { } +public interface ByRef extends ClassAnnotation { } Added: trunk/x10.runtime/src-x10/x10/compiler/Mutable.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/compiler/Mutable.x10 (rev 0) +++ trunk/x10.runtime/src-x10/x10/compiler/Mutable.x10 2010-01-28 21:46:06 UTC (rev 12767) @@ -0,0 +1,17 @@ +/* + * + * (C) Copyright IBM Corporation 2006-2008. + * + * This file is part of X10 Language. + * + */ + +package x10.compiler; + +import x10.lang.annotations.ClassAnnotation; + +/** An annotation on a struct that enables mutable fields + * EXPERIMENTAL + * @author Olivier Tardieu + */ +public interface Mutable extends ClassAnnotation { } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <vj...@us...> - 2010-01-30 08:41:26
|
Revision: 12780 http://x10.svn.sourceforge.net/x10/?rev=12780&view=rev Author: vj0 Date: 2010-01-30 08:41:18 +0000 (Sat, 30 Jan 2010) Log Message: ----------- Refactoring of the constraints implementation. The constraint system in x10.constraint is now made more standard. It exposes publically only those methods that should be used by clients of the constraint solver -- this will make it easier to replace this constraint solver with a more standard congruence-closure solver (necessary for integrating other constraint systems in). The notion of promise is hidden within the constraint solver implementation. Additionally, the special treatment of this and self is removed from this solver. Modified Paths: -------------- trunk/x10.compiler/src/x10/ExtensionInfo.java trunk/x10.compiler/src/x10/ast/AmbDepTypeNode_c.java trunk/x10.compiler/src/x10/ast/AssignPropertyCall_c.java trunk/x10.compiler/src/x10/ast/Async_c.java trunk/x10.compiler/src/x10/ast/AtEach_c.java trunk/x10.compiler/src/x10/ast/AtStmt_c.java trunk/x10.compiler/src/x10/ast/DepParameterExpr.java trunk/x10.compiler/src/x10/ast/DepParameterExpr_c.java trunk/x10.compiler/src/x10/ast/FunctionTypeNode_c.java trunk/x10.compiler/src/x10/ast/Here_c.java trunk/x10.compiler/src/x10/ast/PlacedClosure_c.java trunk/x10.compiler/src/x10/ast/Tuple_c.java trunk/x10.compiler/src/x10/ast/TypeDecl_c.java trunk/x10.compiler/src/x10/ast/X10BooleanLit_c.java trunk/x10.compiler/src/x10/ast/X10CharLit_c.java trunk/x10.compiler/src/x10/ast/X10ClassBody_c.java trunk/x10.compiler/src/x10/ast/X10ClassDecl_c.java trunk/x10.compiler/src/x10/ast/X10ConstructorCall_c.java trunk/x10.compiler/src/x10/ast/X10ConstructorDecl_c.java trunk/x10.compiler/src/x10/ast/X10Field_c.java trunk/x10.compiler/src/x10/ast/X10FloatLit_c.java trunk/x10.compiler/src/x10/ast/X10IntLit_c.java trunk/x10.compiler/src/x10/ast/X10Local_c.java trunk/x10.compiler/src/x10/ast/X10Loop_c.java trunk/x10.compiler/src/x10/ast/X10MethodDecl_c.java trunk/x10.compiler/src/x10/ast/X10New_c.java trunk/x10.compiler/src/x10/ast/X10Return_c.java trunk/x10.compiler/src/x10/ast/X10Special_c.java trunk/x10.compiler/src/x10/ast/X10StringLit_c.java trunk/x10.compiler/src/x10/emitter/Emitter.java trunk/x10.compiler/src/x10/emitter/RuntimeTypeExpander.java trunk/x10.compiler/src/x10/optimizations/LoopUnroller.java trunk/x10.compiler/src/x10/types/ClosureDef.java trunk/x10.compiler/src/x10/types/ClosureDef_c.java trunk/x10.compiler/src/x10/types/ClosureInstance_c.java trunk/x10.compiler/src/x10/types/ClosureType_c.java trunk/x10.compiler/src/x10/types/ConstrainedType.java trunk/x10.compiler/src/x10/types/ConstrainedType_c.java trunk/x10.compiler/src/x10/types/MacroType.java trunk/x10.compiler/src/x10/types/MacroType_c.java trunk/x10.compiler/src/x10/types/ParametrizedType.java trunk/x10.compiler/src/x10/types/Subst.java trunk/x10.compiler/src/x10/types/TypeDef.java trunk/x10.compiler/src/x10/types/TypeDef_c.java trunk/x10.compiler/src/x10/types/TypeParamSubst.java trunk/x10.compiler/src/x10/types/X10ClassDef.java trunk/x10.compiler/src/x10/types/X10ClassDef_c.java trunk/x10.compiler/src/x10/types/X10ConstructorDef.java trunk/x10.compiler/src/x10/types/X10ConstructorDef_c.java trunk/x10.compiler/src/x10/types/X10ConstructorInstance_c.java trunk/x10.compiler/src/x10/types/X10Context.java trunk/x10.compiler/src/x10/types/X10Context_c.java trunk/x10.compiler/src/x10/types/X10FieldInstance.java trunk/x10.compiler/src/x10/types/X10FieldInstance_c.java trunk/x10.compiler/src/x10/types/X10LocalInstance_c.java trunk/x10.compiler/src/x10/types/X10MemberDef.java trunk/x10.compiler/src/x10/types/X10MethodDef_c.java trunk/x10.compiler/src/x10/types/X10MethodInstance_c.java trunk/x10.compiler/src/x10/types/X10ParsedClassType.java trunk/x10.compiler/src/x10/types/X10ParsedClassType_c.java trunk/x10.compiler/src/x10/types/X10ProcedureDef.java trunk/x10.compiler/src/x10/types/X10ProcedureInstance.java trunk/x10.compiler/src/x10/types/X10TypeEnv.java trunk/x10.compiler/src/x10/types/X10TypeEnv_c.java trunk/x10.compiler/src/x10/types/X10TypeMixin.java trunk/x10.compiler/src/x10/types/X10TypeSystem.java trunk/x10.compiler/src/x10/types/X10TypeSystem_c.java trunk/x10.compiler/src/x10/types/XTypeTranslator.java trunk/x10.compiler/src/x10/types/notes.txt trunk/x10.compiler/src/x10/util/ClosureSynthesizer.java trunk/x10.compiler/src/x10/util/Synthesizer.java trunk/x10.compiler/src/x10/visit/ConstantPropagator.java trunk/x10.constraints/src/x10/constraint/XAnd_c.java trunk/x10.constraints/src/x10/constraint/XConstraint.java trunk/x10.constraints/src/x10/constraint/XConstraint_c.java trunk/x10.constraints/src/x10/constraint/XDisEquals_c.java trunk/x10.constraints/src/x10/constraint/XEQV_c.java trunk/x10.constraints/src/x10/constraint/XEquals_c.java trunk/x10.constraints/src/x10/constraint/XFormula_c.java trunk/x10.constraints/src/x10/constraint/XLit_c.java trunk/x10.constraints/src/x10/constraint/XLocal_c.java trunk/x10.constraints/src/x10/constraint/XNot_c.java trunk/x10.constraints/src/x10/constraint/XPromise.java trunk/x10.constraints/src/x10/constraint/XPromise_c.java trunk/x10.constraints/src/x10/constraint/XTerm.java trunk/x10.constraints/src/x10/constraint/XTerms.java trunk/x10.constraints/src/x10/constraint/XVar_c.java trunk/x10.runtime/src-java/x10/rtt/ConstrainedType.java trunk/x10.tests/examples/Constructs/Types/NullableObjectEqualsPrimitive.x10 trunk/x10.tests/examples/Constructs/Types/ObjectEqualsPrimitive.x10 Added Paths: ----------- trunk/x10.compiler/src/x10/types/constraints/ trunk/x10.compiler/src/x10/types/constraints/CConstraint.java trunk/x10.compiler/src/x10/types/constraints/CConstraint_c.java trunk/x10.compiler/src/x10/types/constraints/Constraints.java trunk/x10.compiler/src/x10/types/constraints/XConstrainedTerm.java trunk/x10.tests/examples/Constructs/Cast/ReferenceDependentTypeCast/X10DepTypeSubClassOne.x10 trunk/x10.tests/examples/Constructs/Cast/ReferenceDependentTypeCast/X10InterfaceOne.x10 trunk/x10.tests/examples/Constructs/Types/NullableObjectEqualsPrimitive_MustFailCompile.x10 Removed Paths: ------------- trunk/x10.compiler/src/x10/types/X10ConstructorInstance_c.l trunk/x10.compiler/src/x10/visit/X10Boxer.java trunk/x10.constraints/src/x10/constraint/XConstrainedTerm.java trunk/x10.constraints/src/x10/constraint/XConstraintImp.java Modified: trunk/x10.compiler/src/x10/ExtensionInfo.java =================================================================== --- trunk/x10.compiler/src/x10/ExtensionInfo.java 2010-01-29 22:51:32 UTC (rev 12779) +++ trunk/x10.compiler/src/x10/ExtensionInfo.java 2010-01-30 08:41:18 UTC (rev 12780) @@ -71,7 +71,6 @@ import x10.visit.RewriteAtomicMethodVisitor; import x10.visit.RewriteExternVisitor; import x10.visit.StaticNestedClassRemover; -import x10.visit.X10Boxer; import x10.visit.X10Caster; import x10.visit.X10ImplicitDeclarationExpander; import x10.visit.X10InitChecker; @@ -386,12 +385,7 @@ NodeFactory nf = extInfo.nodeFactory(); return new VisitorGoal("X10MLTypeChecked", job, new X10MLVerifier(job, ts, nf)).intern(this); } - - public Goal X10Boxed(Job job) { - TypeSystem ts = extInfo.typeSystem(); - NodeFactory nf = extInfo.nodeFactory(); - return new VisitorGoal("X10Boxed", job, new X10Boxer(job, ts, nf)).intern(this); - } + public Goal X10Casted(Job job) { TypeSystem ts = extInfo.typeSystem(); Modified: trunk/x10.compiler/src/x10/ast/AmbDepTypeNode_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/AmbDepTypeNode_c.java 2010-01-29 22:51:32 UTC (rev 12779) +++ trunk/x10.compiler/src/x10/ast/AmbDepTypeNode_c.java 2010-01-30 08:41:18 UTC (rev 12780) @@ -32,7 +32,6 @@ import polyglot.visit.NodeVisitor; import polyglot.visit.PrettyPrinter; import polyglot.visit.TypeChecker; -import x10.constraint.XConstraint; import x10.extension.X10Del; import x10.extension.X10Del_c; import x10.types.TypeConstraint; @@ -40,6 +39,7 @@ import x10.types.X10Context; import x10.types.X10TypeMixin; import x10.types.X10TypeSystem; +import x10.types.constraints.CConstraint; public class AmbDepTypeNode_c extends TypeNode_c implements AmbDepTypeNode, AddFlags { @@ -126,7 +126,7 @@ DepParameterExpr dep = (DepParameterExpr) n.visitChild(n.dep, childtc); - XConstraint c = Types.get(dep.valueConstraint()); + CConstraint c = Types.get(dep.valueConstraint()); t = X10TypeMixin.xclause(t, c); if (flags != null) { t = X10TypeMixin.processFlags(flags, t); Modified: trunk/x10.compiler/src/x10/ast/AssignPropertyCall_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/AssignPropertyCall_c.java 2010-01-29 22:51:32 UTC (rev 12779) +++ trunk/x10.compiler/src/x10/ast/AssignPropertyCall_c.java 2010-01-30 08:41:18 UTC (rev 12780) @@ -34,8 +34,7 @@ import polyglot.visit.CFGBuilder; import polyglot.visit.ContextVisitor; import polyglot.visit.NodeVisitor; -import x10.constraint.XConstraint; -import x10.constraint.XConstraint_c; + import x10.constraint.XFailure; import x10.constraint.XRef_c; import x10.constraint.XRoot; @@ -47,6 +46,8 @@ import x10.types.X10TypeMixin; import x10.types.X10TypeSystem; import x10.types.XTypeTranslator; +import x10.types.constraints.CConstraint; +import x10.types.constraints.CConstraint_c; /** * @author vj @@ -187,15 +188,15 @@ Type returnType = Types.get(thisConstructor.returnType()); -// XConstraint result = X10TypeMixin.xclause(returnType); - XConstraint result = X10TypeMixin.realX(returnType); +// CConstraint result = X10TypeMixin.xclause(returnType); + CConstraint result = X10TypeMixin.realX(returnType); if (result.valid()) result = null; if (result != null) { - XConstraint known = Types.get(thisConstructor.supClause()); - known = (known==null ? new XConstraint_c() : known.copy()); + CConstraint known = Types.get(thisConstructor.supClause()); + known = (known==null ? new CConstraint_c() : known.copy()); try { known.addIn(Types.get(thisConstructor.guard())); @@ -210,7 +211,7 @@ XVar prop = (XVar) ts.xtypeTranslator().trans(known, known.self(), fii); // Add in the real clause of the initializer with [self.prop/self] - XConstraint c = X10TypeMixin.realX(initType); + CConstraint c = X10TypeMixin.realX(initType); if (c != null) known.addIn(c.substitute(prop, c.self())); Modified: trunk/x10.compiler/src/x10/ast/Async_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/Async_c.java 2010-01-29 22:51:32 UTC (rev 12779) +++ trunk/x10.compiler/src/x10/ast/Async_c.java 2010-01-30 08:41:18 UTC (rev 12780) @@ -32,7 +32,6 @@ import polyglot.visit.NodeVisitor; import polyglot.visit.PrettyPrinter; import polyglot.visit.PruningVisitor; -import x10.constraint.XConstrainedTerm; import x10.constraint.XConstraint; import x10.constraint.XConstraint_c; import x10.constraint.XFailure; @@ -41,6 +40,7 @@ import x10.types.X10Context; import x10.types.X10MethodDef; import x10.types.X10TypeSystem; +import x10.types.constraints.XConstrainedTerm; /** * Created on Oct 5, 2004 Modified: trunk/x10.compiler/src/x10/ast/AtEach_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/AtEach_c.java 2010-01-29 22:51:32 UTC (rev 12779) +++ trunk/x10.compiler/src/x10/ast/AtEach_c.java 2010-01-30 08:41:18 UTC (rev 12780) @@ -26,12 +26,14 @@ import polyglot.util.Position; import polyglot.visit.PrettyPrinter; import x10.ast.X10Loop.LoopKind; -import x10.constraint.XConstrainedTerm; -import x10.constraint.XConstraint; -import x10.constraint.XConstraint_c; + import x10.constraint.XFailure; import x10.constraint.XTerm; +import x10.constraint.XTerms; import x10.types.X10Context; +import x10.types.constraints.CConstraint; +import x10.types.constraints.CConstraint_c; +import x10.types.constraints.XConstrainedTerm; /** * An immutable representation of the X10 statement: ateach (i : D) S @@ -67,8 +69,8 @@ @Override public Context enterChildScope(Node child, Context c) { X10Context xc = (X10Context) super.enterChildScope(child, c); - XConstraint d = new XConstraint_c(); - XTerm term = XConstraint_c.genUQV(); + CConstraint d = new CConstraint_c(); + XTerm term = XTerms.makeUQV(); try { // FIXME: this creates a new place term; ideally, it should be the place associated with each // point in the ateach distribution Modified: trunk/x10.compiler/src/x10/ast/AtStmt_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/AtStmt_c.java 2010-01-29 22:51:32 UTC (rev 12779) +++ trunk/x10.compiler/src/x10/ast/AtStmt_c.java 2010-01-30 08:41:18 UTC (rev 12780) @@ -37,7 +37,6 @@ import polyglot.visit.NodeVisitor; import polyglot.visit.PrettyPrinter; import polyglot.visit.PruningVisitor; -import x10.constraint.XConstrainedTerm; import x10.constraint.XConstraint; import x10.constraint.XConstraint_c; import x10.constraint.XFailure; @@ -48,6 +47,7 @@ import x10.types.X10MethodDef; import x10.types.X10TypeMixin; import x10.types.X10TypeSystem; +import x10.types.constraints.XConstrainedTerm; /** * Created on Oct 5, 2004 Modified: trunk/x10.compiler/src/x10/ast/DepParameterExpr.java =================================================================== --- trunk/x10.compiler/src/x10/ast/DepParameterExpr.java 2010-01-29 22:51:32 UTC (rev 12779) +++ trunk/x10.compiler/src/x10/ast/DepParameterExpr.java 2010-01-30 08:41:18 UTC (rev 12780) @@ -19,8 +19,8 @@ import polyglot.ast.Formal; import polyglot.ast.TypeNode; import polyglot.types.Ref; -import x10.constraint.XConstraint; import x10.types.TypeConstraint; +import x10.types.constraints.CConstraint; /** * @author vj Jan 9, 2005 @@ -34,8 +34,8 @@ List<Expr> condition(); DepParameterExpr condition(List<Expr> cond); - Ref<XConstraint> valueConstraint(); - DepParameterExpr valueConstraint(Ref<XConstraint> c); + Ref<CConstraint> valueConstraint(); + DepParameterExpr valueConstraint(Ref<CConstraint> c); Ref<TypeConstraint> typeConstraint(); DepParameterExpr typeConstraint(Ref<TypeConstraint> c); Modified: trunk/x10.compiler/src/x10/ast/DepParameterExpr_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/DepParameterExpr_c.java 2010-01-29 22:51:32 UTC (rev 12779) +++ trunk/x10.compiler/src/x10/ast/DepParameterExpr_c.java 2010-01-30 08:41:18 UTC (rev 12780) @@ -39,12 +39,12 @@ import polyglot.visit.TypeBuilder; import polyglot.visit.TypeCheckPreparer; import polyglot.visit.TypeChecker; -import x10.constraint.XConstraint; -import x10.constraint.XConstraint_c; import x10.types.TypeConstraint; import x10.types.TypeConstraint_c; import x10.types.X10Context; import x10.types.X10TypeSystem; +import x10.types.constraints.CConstraint; +import x10.types.constraints.CConstraint_c; /** An immutable representation of a dependent type constraint. * The corresponding syntax is [T](e){x: T; c} @@ -61,7 +61,7 @@ */ protected List<Expr> condition; - private Ref<XConstraint> valueConstraint; + private Ref<CConstraint> valueConstraint; private Ref<TypeConstraint> typeConstraint; /** @@ -102,11 +102,11 @@ return super.enterChildScope(child, c); } - public Ref<XConstraint> valueConstraint() { + public Ref<CConstraint> valueConstraint() { return valueConstraint; } - public DepParameterExpr valueConstraint(Ref<XConstraint> c) { + public DepParameterExpr valueConstraint(Ref<CConstraint> c) { DepParameterExpr_c n = (DepParameterExpr_c) copy(); n.valueConstraint = c; return n; @@ -158,7 +158,7 @@ public Node buildTypes(TypeBuilder tb) throws SemanticException { DepParameterExpr_c n = (DepParameterExpr_c) copy(); - n.valueConstraint = Types.<XConstraint>lazyRef(new XConstraint_c(), new SetResolverGoal(tb.job())); + n.valueConstraint = Types.<CConstraint>lazyRef(new CConstraint_c(), new SetResolverGoal(tb.job())); n.typeConstraint = Types.<TypeConstraint>lazyRef(new TypeConstraint_c(), new SetResolverGoal(tb.job())); return n; } @@ -168,7 +168,7 @@ tc = (TypeChecker) tc.context(v.context().freeze()); { - LazyRef<XConstraint> xr = (LazyRef<XConstraint>) valueConstraint; + LazyRef<CConstraint> xr = (LazyRef<CConstraint>) valueConstraint; assert xr != null : "setResolver pass run before buildTypes for " + this; xr.setResolver(new TypeCheckFragmentGoal(parent, this, tc, xr, false)); } @@ -242,8 +242,8 @@ } } - XConstraint xvc = ts.xtypeTranslator().constraint(formals, values, (X10Context) tc.context()); - ((LazyRef<XConstraint>) valueConstraint).update(xvc); + x10.types.constraints.CConstraint xvc = ts.xtypeTranslator().constraint(formals, values, (X10Context) tc.context()); + ((LazyRef<CConstraint>) valueConstraint).update(xvc); TypeConstraint xtc = ts.xtypeTranslator().typeConstraint(formals, types, (X10Context) tc.context()); ((LazyRef<TypeConstraint>) typeConstraint).update(xtc); Modified: trunk/x10.compiler/src/x10/ast/FunctionTypeNode_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/FunctionTypeNode_c.java 2010-01-29 22:51:32 UTC (rev 12779) +++ trunk/x10.compiler/src/x10/ast/FunctionTypeNode_c.java 2010-01-30 08:41:18 UTC (rev 12780) @@ -38,11 +38,12 @@ import polyglot.visit.ContextVisitor; import polyglot.visit.NodeVisitor; import polyglot.visit.PrettyPrinter; -import x10.constraint.XConstraint; -import x10.constraint.XConstraint_c; + import x10.types.ClosureDef; import x10.types.X10ClassType; import x10.types.X10TypeSystem; +import x10.types.constraints.CConstraint; +import x10.types.constraints.CConstraint_c; public class FunctionTypeNode_c extends TypeNode_c implements FunctionTypeNode { @@ -94,7 +95,7 @@ // typeParams, formalTypes, formalNames, guard != null ? guard.valueConstraint() - : Types.<XConstraint>lazyRef(new XConstraint_c()), + : Types.<CConstraint>lazyRef(new CConstraint_c()), // guard != null ? guard.typeConstraint() : null, throwTypes); Modified: trunk/x10.compiler/src/x10/ast/Here_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/Here_c.java 2010-01-29 22:51:32 UTC (rev 12779) +++ trunk/x10.compiler/src/x10/ast/Here_c.java 2010-01-30 08:41:18 UTC (rev 12780) @@ -23,15 +23,16 @@ import polyglot.visit.CFGBuilder; import polyglot.visit.ContextVisitor; import polyglot.visit.PrettyPrinter; -import x10.constraint.XConstrainedTerm; -import x10.constraint.XConstraint; -import x10.constraint.XConstraint_c; + import x10.constraint.XFailure; import x10.constraint.XTerm; import x10.constraint.XVar; import x10.types.X10Context; import x10.types.X10TypeMixin; import x10.types.X10TypeSystem; +import x10.types.constraints.CConstraint; +import x10.types.constraints.CConstraint_c; +import x10.types.constraints.XConstrainedTerm; /** @@ -76,7 +77,7 @@ X10Context xc = (X10Context) tc.context(); Type tt = ts.Place(); - XConstraint cc = new XConstraint_c(); + CConstraint cc = new CConstraint_c(); try { cc.addSelfBinding(xc.currentPlaceTerm()); } Modified: trunk/x10.compiler/src/x10/ast/PlacedClosure_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/PlacedClosure_c.java 2010-01-29 22:51:32 UTC (rev 12779) +++ trunk/x10.compiler/src/x10/ast/PlacedClosure_c.java 2010-01-30 08:41:18 UTC (rev 12780) @@ -23,15 +23,17 @@ import polyglot.visit.NodeVisitor; import polyglot.visit.PruningVisitor; import polyglot.visit.TypeChecker; -import x10.constraint.XConstrainedTerm; -import x10.constraint.XConstraint; -import x10.constraint.XConstraint_c; + import x10.constraint.XFailure; import x10.constraint.XTerm; +import x10.constraint.XTerms; import x10.types.ClosureDef; import x10.types.X10Context; import x10.types.X10TypeMixin; import x10.types.X10TypeSystem; +import x10.types.constraints.CConstraint; +import x10.types.constraints.CConstraint_c; +import x10.types.constraints.XConstrainedTerm; /** * A common abstraction for a closure that may execute at a given place, @@ -100,16 +102,16 @@ X10TypeSystem ts ) throws SemanticException { Type placeType = place.type(); - XConstraint d = X10TypeMixin.xclause(placeType); - d = (d==null) ? new XConstraint_c() : d.copy(); - XConstraint pc = null; + CConstraint d = X10TypeMixin.xclause(placeType); + d = (d==null) ? new CConstraint_c() : d.copy(); + CConstraint pc = null; XTerm term = null; XConstrainedTerm pt = null; boolean placeIsPlace = ts.isImplicitCastValid(placeType, ts.Place(), xc); if (placeIsPlace) { term = ts.xtypeTranslator().trans(pc, place, xc); if (term == null) { - term = XConstraint_c.genUQV(); + term = XTerms.makeUQV(); } try { pt = XConstrainedTerm.instantiate(d, term); @@ -123,7 +125,7 @@ if (placeIsRef) { XTerm src = ts.xtypeTranslator().trans(pc, place, xc); if (src == null) { - src = XConstraint_c.genUQV(); + src = XTerms.makeUQV(); } try { d= d.substitute(src, d.self()); Modified: trunk/x10.compiler/src/x10/ast/Tuple_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/Tuple_c.java 2010-01-29 22:51:32 UTC (rev 12779) +++ trunk/x10.compiler/src/x10/ast/Tuple_c.java 2010-01-30 08:41:18 UTC (rev 12780) @@ -35,14 +35,14 @@ import polyglot.visit.NodeVisitor; import polyglot.visit.PrettyPrinter; import polyglot.visit.Translator; -import x10.constraint.XConstraint; -import x10.constraint.XConstraint_c; import x10.constraint.XFailure; import x10.constraint.XLit; import x10.constraint.XVar; import x10.types.X10ClassType; import x10.types.X10TypeMixin; import x10.types.X10TypeSystem; +import x10.types.constraints.CConstraint; +import x10.types.constraints.CConstraint_c; /** * An immutable representation of the X10 rail constructor [e1, ..., ek]. @@ -174,7 +174,7 @@ Type r = ts.ValRail(); Type t = (X10ClassType) X10TypeMixin.instantiate(r, type); - XConstraint c = new XConstraint_c(); + CConstraint c = new CConstraint_c(); FieldInstance lengthField = ((X10ClassType) t).fieldNamed(Name.make("length")); if (lengthField == null) throw new InternalCompilerError("Could not find length field of " + t, position()); Modified: trunk/x10.compiler/src/x10/ast/TypeDecl_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/TypeDecl_c.java 2010-01-29 22:51:32 UTC (rev 12779) +++ trunk/x10.compiler/src/x10/ast/TypeDecl_c.java 2010-01-30 08:41:18 UTC (rev 12780) @@ -38,8 +38,7 @@ import polyglot.visit.ContextVisitor; import polyglot.visit.NodeVisitor; import polyglot.visit.TypeBuilder; -import x10.constraint.XConstraint; -import x10.constraint.XConstraint_c; + import x10.constraint.XFailure; import x10.constraint.XRoot; import x10.extension.X10Del_c; @@ -52,6 +51,8 @@ import x10.types.X10ParsedClassType; import x10.types.X10TypeMixin; import x10.types.X10TypeSystem; +import x10.types.constraints.CConstraint; +import x10.types.constraints.CConstraint_c; public class TypeDecl_c extends Term_c implements TypeDecl { private TypeNode type; @@ -262,11 +263,11 @@ List<LocalDef> formalNames = new ArrayList<LocalDef>(); for (Formal f : n.formals()) { final Formal f2 = f; - final LazyRef<XConstraint> cref = Types.<XConstraint>lazyRef(new XConstraint_c()); + final LazyRef<CConstraint> cref = Types.<CConstraint>lazyRef(new CConstraint_c()); Type t = X10TypeMixin.xclause(f.type().typeRef(), cref); cref.setResolver(new Runnable() { public void run() { - XConstraint c = new XConstraint_c(); + CConstraint c = new CConstraint_c(); try { c.addSelfBinding(ts.xtypeTranslator().trans(f2.localDef().asInstance())); } Modified: trunk/x10.compiler/src/x10/ast/X10BooleanLit_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10BooleanLit_c.java 2010-01-29 22:51:32 UTC (rev 12779) +++ trunk/x10.compiler/src/x10/ast/X10BooleanLit_c.java 2010-01-30 08:41:18 UTC (rev 12780) @@ -16,8 +16,6 @@ import polyglot.types.Type; 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 x10.types.X10Context; @@ -25,6 +23,8 @@ import x10.types.X10TypeMixin; import x10.types.X10TypeSystem; import x10.types.XTypeTranslator; +import x10.types.constraints.CConstraint; +import x10.types.constraints.CConstraint_c; /** * @author vj @@ -45,7 +45,7 @@ X10TypeSystem xts = (X10TypeSystem) tc.typeSystem(); Type Boolean = xts.Boolean(); - XConstraint c = new XConstraint_c(); + CConstraint c = new CConstraint_c(); XTerm term = xts.xtypeTranslator().trans(c, this.type(Boolean), (X10Context) tc.context()); try { c.addSelfBinding(term); Modified: trunk/x10.compiler/src/x10/ast/X10CharLit_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10CharLit_c.java 2010-01-29 22:51:32 UTC (rev 12779) +++ trunk/x10.compiler/src/x10/ast/X10CharLit_c.java 2010-01-30 08:41:18 UTC (rev 12780) @@ -16,14 +16,14 @@ import polyglot.types.Type; 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 x10.types.X10Context; import x10.types.X10TypeMixin; import x10.types.X10TypeSystem; import x10.types.XTypeTranslator; +import x10.types.constraints.CConstraint; +import x10.types.constraints.CConstraint_c; /** * An immutable representation of a char lit, modified from JL @@ -44,7 +44,7 @@ X10TypeSystem xts = (X10TypeSystem) tc.typeSystem(); Type charType = xts.Char(); - XConstraint c = new XConstraint_c(); + CConstraint c = new CConstraint_c(); XTerm term = xts.xtypeTranslator().trans(c, this.type(charType), (X10Context) tc.context()); try { c.addSelfBinding(term); Modified: trunk/x10.compiler/src/x10/ast/X10ClassBody_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10ClassBody_c.java 2010-01-29 22:51:32 UTC (rev 12779) +++ trunk/x10.compiler/src/x10/ast/X10ClassBody_c.java 2010-01-30 08:41:18 UTC (rev 12780) @@ -39,7 +39,6 @@ import polyglot.util.TypedList; import polyglot.visit.ContextVisitor; import polyglot.ast.ClassBody_c; -import x10.constraint.XConstrainedTerm; import x10.constraint.XRoot; import x10.types.ClosureDef; import x10.types.MacroType; @@ -57,6 +56,7 @@ import x10.types.X10TypeMixin; import x10.types.X10TypeSystem; import x10.types.X10TypeSystem_c; +import x10.types.constraints.XConstrainedTerm; public class X10ClassBody_c extends ClassBody_c { public X10ClassBody_c(Position pos, java.util.List<ClassMember> members) { Modified: trunk/x10.compiler/src/x10/ast/X10ClassDecl_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10ClassDecl_c.java 2010-01-29 22:51:32 UTC (rev 12779) +++ trunk/x10.compiler/src/x10/ast/X10ClassDecl_c.java 2010-01-30 08:41:18 UTC (rev 12780) @@ -80,9 +80,7 @@ import polyglot.visit.TypeBuilder; import polyglot.visit.TypeCheckPreparer; import polyglot.visit.TypeChecker; -import x10.constraint.XConstrainedTerm; -import x10.constraint.XConstraint; -import x10.constraint.XConstraint_c; + import x10.constraint.XFailure; import x10.constraint.XRoot; import x10.constraint.XTerm; @@ -108,6 +106,9 @@ import x10.types.X10TypeMixin; import x10.types.X10TypeSystem; import x10.types.X10TypeSystem_c; +import x10.types.constraints.CConstraint; +import x10.types.constraints.CConstraint_c; +import x10.types.constraints.XConstrainedTerm; import x10.util.Synthesizer; /** * The same as a Java class, except that it needs to handle properties. @@ -437,29 +438,29 @@ final DepParameterExpr ci = (DepParameterExpr) n.visitChild(n.classInvariant, childTb); n = (X10ClassDecl_c) n.classInvariant(ci); - final LazyRef<XConstraint> c = new LazyRef_c<XConstraint>(new XConstraint_c()); + final LazyRef<CConstraint> c = new LazyRef_c<CConstraint>(new CConstraint_c()); final X10ClassDecl_c nn = n; // Add all the constraints on the supertypes into the invariant. c.setResolver(new Runnable() { public void run() { - XConstraint x = new XConstraint_c(); + CConstraint x = new CConstraint_c(); try { if (ci != null) { - XConstraint xi = ci.valueConstraint().get(); + CConstraint xi = ci.valueConstraint().get(); x.addIn(xi); TypeConstraint ti = ci.typeConstraint().get(); } if (nn.superClass != null) { Type t = nn.superClass.type(); - XConstraint tc = X10TypeMixin.xclause(t); + CConstraint tc = X10TypeMixin.xclause(t); if (tc != null) x.addIn(tc); } for (TypeNode tn : nn.interfaces) { Type t = tn.type(); - XConstraint tc = X10TypeMixin.xclause(t); + CConstraint tc = X10TypeMixin.xclause(t); if (tc != null) x.addIn(tc); } @@ -608,7 +609,8 @@ public Node typeCheckOverride(Node parent, ContextVisitor tc) throws SemanticException { - X10ClassDecl_c n = this; + +X10ClassDecl_c n = this; NodeVisitor v = tc.enter(parent, n); Modified: trunk/x10.compiler/src/x10/ast/X10ConstructorCall_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10ConstructorCall_c.java 2010-01-29 22:51:32 UTC (rev 12779) +++ trunk/x10.compiler/src/x10/ast/X10ConstructorCall_c.java 2010-01-30 08:41:18 UTC (rev 12780) @@ -44,7 +44,6 @@ import polyglot.visit.NodeVisitor; import polyglot.visit.TypeBuilder; import x10.ast.X10New_c.MatcherMaker; -import x10.constraint.XConstraint; import x10.types.X10ConstructorDef; import x10.types.X10ConstructorInstance; import x10.types.X10MethodInstance; @@ -53,6 +52,7 @@ import x10.types.X10TypeSystem; import x10.types.X10TypeSystem_c; import x10.types.X10TypeSystem_c.DumbConstructorMatcher; +import x10.types.constraints.CConstraint; /** * A call to this(...) or super(...) in the body of a constructor. @@ -253,7 +253,7 @@ // The constructor *within which this super call happens*. X10ConstructorDef thisConstructor = (X10ConstructorDef) ctx.currentCode(); - XConstraint c = X10TypeMixin.realX(ci.returnType()); + CConstraint c = X10TypeMixin.realX(ci.returnType()); thisConstructor.setSupClause(Types.ref(c)); } Modified: trunk/x10.compiler/src/x10/ast/X10ConstructorDecl_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10ConstructorDecl_c.java 2010-01-29 22:51:32 UTC (rev 12779) +++ trunk/x10.compiler/src/x10/ast/X10ConstructorDecl_c.java 2010-01-30 08:41:18 UTC (rev 12780) @@ -39,11 +39,9 @@ import polyglot.visit.NodeVisitor; import polyglot.visit.TypeBuilder; import polyglot.visit.TypeChecker; -import x10.constraint.XConstraint; import x10.constraint.XFailure; import x10.constraint.XName; import x10.constraint.XNameWrapper; -import x10.constraint.XPromise; import x10.constraint.XRef_c; import x10.constraint.XRoot; import x10.constraint.XTerms; @@ -60,6 +58,7 @@ import x10.types.X10TypeMixin; import x10.types.X10TypeSystem; +import x10.types.constraints.CConstraint; /** * An X10ConstructorDecl differs from a ConstructorDecl in that it has a returnType. * @@ -253,8 +252,8 @@ // Type newType = ref.get(); // // if (n.localDef().flags().isFinal()) { -// XConstraint c = X10TypeMixin.xclause(newType); -// if (c == null) c = new XConstraint_c(); +// CConstraint c = X10TypeMixin.xclause(newType); +// if (c == null) c = new CConstraint_c(); // try { // c.addSelfBinding(xts.xtypeTranslator().trans(n.localDef().asInstance())); // } @@ -280,7 +279,7 @@ //List newFormals = new ArrayList(formals.size()); X10ProcedureDef pi = (X10ProcedureDef) nn.memberDef(); - XConstraint c = pi.guard().get(); + CConstraint c = pi.guard().get(); try { if (c != null) { c = c.copy(); @@ -291,11 +290,14 @@ // Fold the formal's constraint into the guard. XVar var = xts.xtypeTranslator().trans(n.localDef().asInstance()); - XConstraint dep = X10TypeMixin.xclause(newType); + CConstraint dep = X10TypeMixin.xclause(newType); if (dep != null) { dep = dep.copy(); - XPromise p = dep.intern(var); - dep = dep.substitute(p.term(), c.self()); + dep = dep.substitute(var, c.self()); + /* + XPromise p = dep.intern(var); + dep = dep.substitute(p.term(), c.self()); + */ c.addIn(dep); } @@ -308,7 +310,7 @@ // Fold this's constraint (the class invariant) into the guard. { Type t = tc.context().currentClass(); - XConstraint dep = X10TypeMixin.xclause(t); + CConstraint dep = X10TypeMixin.xclause(t); if (c != null && dep != null) { XRoot thisVar = ((X10MemberDef) constructorDef()).thisVar(); if (thisVar != null) @@ -391,7 +393,7 @@ X10ConstructorDecl_c n = this; for (TypeNode type : n.throwTypes()) { - XConstraint rc = X10TypeMixin.xclause(type.type()); + CConstraint rc = X10TypeMixin.xclause(type.type()); if (rc != null && ! rc.valid()) throw new SemanticException("Cannot throw a dependent type.", type.position()); } @@ -408,7 +410,7 @@ Type retTypeBase = X10TypeMixin.baseOfProto(n.returnType().type()); retTypeBase = X10TypeMixin.baseType(retTypeBase); - XConstraint c = X10TypeMixin.xclause(n.returnType().type()); + CConstraint c = X10TypeMixin.xclause(n.returnType().type()); X10ConstructorDef nnci = (X10ConstructorDef) n.constructorDef(); // Type clazz = ((X10Type) nnci.asInstance().container()).setFlags(X10Flags.ROOTED); Modified: trunk/x10.compiler/src/x10/ast/X10Field_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10Field_c.java 2010-01-29 22:51:32 UTC (rev 12779) +++ trunk/x10.compiler/src/x10/ast/X10Field_c.java 2010-01-30 08:41:18 UTC (rev 12780) @@ -36,11 +36,11 @@ 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.XRoot; import x10.constraint.XTerm; +import x10.constraint.XTerms; import x10.constraint.XVar; import x10.types.ConstrainedType; import x10.types.ParameterType; @@ -54,6 +54,8 @@ import x10.types.X10TypeMixin; import x10.types.X10TypeSystem; +import x10.types.constraints.CConstraint; +import x10.types.constraints.CConstraint_c; /** @@ -159,12 +161,12 @@ // Substitute in the actual target for this. This is done by findField, now. // Type thisType = tType; - // XConstraint rc = X10TypeMixin.realX(retType); + // CConstraint rc = X10TypeMixin.realX(retType); // if (rc != null) { // XVar var= X10TypeMixin.selfVar(thisType); // if (var == null) // var = ts.xtypeTranslator().genEQV(rc, thisType); - // XConstraint newRC = rc.substitute(var, ts.xtypeTranslator().transThis(thisType)); + // CConstraint newRC = rc.substitute(var, ts.xtypeTranslator().transThis(thisType)); // retType = X10TypeMixin.xclause(retType, newRC); // fi = fi.type(retType); // } @@ -172,8 +174,9 @@ result.checkConsistency(c); // Check the guard - XConstraint guard = ((X10FieldInstance) result.fieldInstance()).guard(); - if (guard != null && ! new XConstraint_c().entails(guard, c.constraintProjection(guard))) { + CConstraint guard = ((X10FieldInstance) result.fieldInstance()).guard(); + if (guard != null && ! new CConstraint_c().entails(guard, + c.constraintProjection(guard))) { throw new SemanticException("Cannot access field. Field guard not satisfied.", position()); } @@ -212,20 +215,20 @@ } public static Type rightType(Type t, X10MemberDef fi, Receiver target, Context c) throws SemanticException { - XConstraint x = X10TypeMixin.xclause(t); + CConstraint x = X10TypeMixin.xclause(t); if (x != null && fi.thisVar() != null) { if (target instanceof Expr) { XVar receiver = null; X10TypeSystem ts = (X10TypeSystem) t.typeSystem(); - XTerm r = ts.xtypeTranslator().trans((XConstraint) null, target, (X10Context) c); + XTerm r = ts.xtypeTranslator().trans((CConstraint) null, target, (X10Context) c); if (r instanceof XVar) { receiver = (XVar) r; } if (receiver == null) - receiver = XConstraint_c.genEQV(); + receiver = XTerms.makeEQV(); t = Subst.subst(t, (new XVar[] { receiver }), (new XRoot[] { fi.thisVar() }), new Type[] { }, new ParameterType[] { }); } } @@ -234,13 +237,13 @@ } public static Type fieldRightType(Type t, X10MemberDef fi, Receiver target, Context c) throws SemanticException { - XConstraint x = X10TypeMixin.xclause(t); + CConstraint x = X10TypeMixin.xclause(t); if (x != null && fi.thisVar() != null) { x = x.copy(); // Need to add the target's constraints in here because the target may not // be a variable. hence the type information wont be in the context. if (target instanceof Expr) { - XConstraint xc = X10TypeMixin.xclause(target.type()); + CConstraint xc = X10TypeMixin.xclause(target.type()); if (xc != null && ! xc.valid()) { xc = xc.copy(); try { @@ -248,13 +251,13 @@ assert receiver != null; /*if (receiver == null) { X10TypeSystem ts = (X10TypeSystem) t.typeSystem(); - XTerm r = ts.xtypeTranslator().trans((XConstraint) null, target, (X10Context) c); + XTerm r = ts.xtypeTranslator().trans((CConstraint) null, target, (X10Context) c); if (r instanceof XVar) { receiver = (XVar) r; } if (receiver == null) - receiver = XConstraint_c.genUQV(); + receiver = CConstraint_c.genUQV(); }*/ xc = xc.substitute(receiver, xc.self()); x.addIn(xc); Modified: trunk/x10.compiler/src/x10/ast/X10FloatLit_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10FloatLit_c.java 2010-01-29 22:51:32 UTC (rev 12779) +++ trunk/x10.compiler/src/x10/ast/X10FloatLit_c.java 2010-01-30 08:41:18 UTC (rev 12780) @@ -16,8 +16,6 @@ import polyglot.types.Type; 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 x10.types.X10Context; @@ -25,6 +23,8 @@ import x10.types.X10TypeMixin; import x10.types.X10TypeSystem; import x10.types.XTypeTranslator; +import x10.types.constraints.CConstraint; +import x10.types.constraints.CConstraint_c; /** * An immutable representation of a float lit, modified from JL @@ -47,7 +47,7 @@ X10TypeSystem xts = (X10TypeSystem) tc.typeSystem(); Type Type = (kind==FLOAT ? xts.Float() : xts.Double()); - XConstraint c = new XConstraint_c(); + CConstraint c = new CConstraint_c(); XTerm term = xts.xtypeTranslator().trans(c, this.type(Type), (X10Context) tc.context()); try { c.addSelfBinding(term); Modified: trunk/x10.compiler/src/x10/ast/X10IntLit_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10IntLit_c.java 2010-01-29 22:51:32 UTC (rev 12779) +++ trunk/x10.compiler/src/x10/ast/X10IntLit_c.java 2010-01-30 08:41:18 UTC (rev 12780) @@ -17,8 +17,6 @@ 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 x10.types.X10Context; @@ -26,6 +24,8 @@ import x10.types.X10TypeMixin; import x10.types.X10TypeSystem; import x10.types.XTypeTranslator; +import x10.types.constraints.CConstraint; +import x10.types.constraints.CConstraint_c; import polyglot.ast.IntLit; import polyglot.ast.IntLit.Kind; @@ -86,7 +86,7 @@ else { throw new InternalCompilerError("bad integer literal kind", position()); } - XConstraint c = new XConstraint_c(); + CConstraint c = new CConstraint_c(); XTerm term = xts.xtypeTranslator().trans(c, this.type(Type), (X10Context) tc.context()); try { c.addSelfBinding(term); Modified: trunk/x10.compiler/src/x10/ast/X10Local_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10Local_c.java 2010-01-29 22:51:32 UTC (rev 12779) +++ trunk/x10.compiler/src/x10/ast/X10Local_c.java 2010-01-30 08:41:18 UTC (rev 12780) @@ -27,8 +27,7 @@ import polyglot.types.VarDef; import polyglot.util.Position; import polyglot.visit.ContextVisitor; -import x10.constraint.XConstraint; -import x10.constraint.XConstraint_c; + import x10.constraint.XFailure; import x10.constraint.XLocal; import x10.constraint.XTerm; @@ -39,6 +38,8 @@ import x10.types.X10ProcedureDef; import x10.types.X10TypeMixin; import x10.types.X10TypeSystem; +import x10.types.constraints.CConstraint; +import x10.types.constraints.CConstraint_c; public class X10Local_c extends Local_c { @@ -82,7 +83,7 @@ CodeDef ci = context.currentCode(); if (ci instanceof X10ProcedureDef) { X10ProcedureDef pi = (X10ProcedureDef) ci; - XConstraint c = Types.get(pi.guard()); + CConstraint c = Types.get(pi.guard()); if (c != null) { X10TypeSystem xts = (X10TypeSystem) tc.typeSystem(); @@ -96,8 +97,8 @@ // Add the guard into the constraint for this type. Type t = result.type(); - XConstraint dep = X10TypeMixin.xclause(t); - if (dep == null) dep = new XConstraint_c(); + CConstraint dep = X10TypeMixin.xclause(t); + if (dep == null) dep = new CConstraint_c(); else dep = dep.copy(); // XTerm resultTerm = xts.xtypeTranslator().trans(result); // dep.addSelfBinding((XVar) resultTerm); Modified: trunk/x10.compiler/src/x10/ast/X10Loop_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10Loop_c.java 2010-01-29 22:51:32 UTC (rev 12779) +++ trunk/x10.compiler/src/x10/ast/X10Loop_c.java 2010-01-30 08:41:18 UTC (rev 12780) @@ -44,8 +44,6 @@ import polyglot.visit.TypeBuilder; import polyglot.visit.TypeCheckPreparer; import polyglot.visit.TypeChecker; -import x10.constraint.XConstraint; -import x10.constraint.XConstraint_c; import x10.constraint.XFailure; import x10.constraint.XName; import x10.constraint.XRoot; @@ -63,6 +61,7 @@ import x10.types.X10TypeEnv_c; import x10.types.X10TypeMixin; import x10.types.X10TypeSystem; +import x10.types.constraints.CConstraint; import x10.util.Synthesizer; /** @@ -396,7 +395,7 @@ Type indexType = getIndexType(domainType); Type base = X10TypeMixin.baseType(domainType); - XConstraint c = X10TypeMixin.xclause(domainType); + CConstraint c = X10TypeMixin.xclause(domainType); XVar selfValue = X10TypeMixin.selfVarBinding(domainType); XVar selfVar = c != null ? c.self() : null; @@ -408,7 +407,7 @@ try { // Generate a new local variable if needed - XVar var = selfValue != null ? selfValue : XConstraint_c.genEQV(false); + XVar var = selfValue != null ? selfValue : XTerms.makeUQV(); // And substitute it for this in indexType indexType = Subst.subst(indexType, var, thisVar); if (ts.isSubtype(indexType, ts.Point(),tcp.context())) { Modified: trunk/x10.compiler/src/x10/ast/X10MethodDecl_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10MethodDecl_c.java 2010-01-29 22:51:32 UTC (rev 12779) +++ trunk/x10.compiler/src/x10/ast/X10MethodDecl_c.java 2010-01-30 08:41:18 UTC (rev 12780) @@ -74,11 +74,9 @@ import polyglot.visit.TypeBuilder; import polyglot.visit.TypeCheckPreparer; import polyglot.visit.TypeChecker; -import x10.constraint.XConstraint; import x10.constraint.XFailure; import x10.constraint.XName; import x10.constraint.XNameWrapper; -import x10.constraint.XPromise; import x10.constraint.XRef_c; import x10.constraint.XRoot; import x10.constraint.XTerm; @@ -103,6 +101,7 @@ import x10.types.X10TypeMixin; import x10.types.X10TypeSystem; import x10.types.XTypeTranslator; +import x10.types.constraints.CConstraint; /** A representation of a method declaration. * Includes an extra field to represent the guard @@ -263,7 +262,7 @@ // Add the method guard into the environment. if (guard != null) { - Ref<XConstraint> vc = guard.valueConstraint(); + Ref<CConstraint> vc = guard.valueConstraint(); Ref<TypeConstraint> tc = guard.typeConstraint(); if (vc != null || tc != null) { @@ -363,7 +362,7 @@ } for (TypeNode type : n.throwTypes()) { - XConstraint rc = X10TypeMixin.xclause(type.type()); + CConstraint rc = X10TypeMixin.xclause(type.type()); if (rc != null && ! rc.valid()) throw new SemanticException("Cannot throw a dependent type.", type.position()); } @@ -405,7 +404,7 @@ if (s instanceof Return) { Return r = (Return) s; if (r.expr() != null) { - XTerm v = ts.xtypeTranslator().trans((XConstraint) null, r.expr(), (X10Context) tc.context()); + XTerm v = ts.xtypeTranslator().trans((CConstraint) null, r.expr(), (X10Context) tc.context()); ok = true; X10MethodDef mi = (X10MethodDef) this.mi; if (mi.body() instanceof LazyRef) { @@ -474,7 +473,7 @@ X10TypeSystem xts = (X10TypeSystem) tc.typeSystem(); for (TypeNode type : throwTypes()) { - XConstraint rc = X10TypeMixin.xclause(type.type()); + CConstraint rc = X10TypeMixin.xclause(type.type()); if (rc != null && ! rc.valid()) throw new SemanticException("Cannot throw a dependent type.", type.position()); } @@ -853,7 +852,7 @@ //List newFormals = new ArrayList(formals.size()); X10ProcedureDef pi = (X10ProcedureDef) nn.memberDef(); - XConstraint c = pi.guard().get(); + CConstraint c = pi.guard().get(); try { if (c != null) { c = c.copy(); @@ -864,11 +863,14 @@ // Fold the formal's constraint into the guard. XVar var = xts.xtypeTranslator().trans(n.localDef().asInstance()); - XConstraint dep = X10TypeMixin.xclause(newType); + CConstraint dep = X10TypeMixin.xclause(newType); if (dep != null) { dep = dep.copy(); + dep = dep.substitute(var, c.self()); + /* XPromise p = dep.intern(var); dep = dep.substitute(p.term(), c.self()); + */ c.addIn(dep); } @@ -881,7 +883,7 @@ // Fold this's constraint (the class invariant) into the guard. { Type t = tc.context().currentClass(); - XConstraint dep = X10TypeMixin.xclause(t); + CConstraint dep = X10TypeMixin.xclause(t); if (c != null && dep != null) { XRoot thisVar = ((X10MemberDef) methodDef()).thisVar(); if (thisVar != null) Modified: trunk/x10.compiler/src/x10/ast/X10New_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10New_c.java 2010-01-29 22:51:32 UTC (rev 12779) +++ trunk/x10.compiler/src/x10/ast/X10New_c.java 2010-01-30 08:41:18 UTC (rev 12780) @@ -49,7 +49,6 @@ import polyglot.visit.NodeVisitor; import polyglot.visit.TypeBuilder; import polyglot.visit.TypeChecker; -import x10.constraint.XConstraint; import x10.constraint.XTerm; import x10.constraint.XTerms; import x10.extension.X10Del_c; @@ -61,6 +60,7 @@ import x10.types.X10TypeMixin; import x10.types.X10TypeSystem; import x10.types.X10TypeSystem_c; +import x10.types.constraints.CConstraint; /** @@ -184,7 +184,7 @@ Type t = tn.type(); t = ts.expandMacros(t); - XConstraint xc = X10TypeMixin.xclause(t); + CConstraint xc = X10TypeMixin.xclause(t); t = X10TypeMixin.baseType(t); if (!(t instanceof X10ClassType)) { @@ -229,7 +229,7 @@ Type t = ts.findMemberType(qualifier.type(), name, c); t = ts.expandMacros(t); - XConstraint xc = X10TypeMixin.xclause(t); + CConstraint xc = X10TypeMixin.xclause(t); t = X10TypeMixin.baseType(t); if (!(t instanceof X10ClassType)) { @@ -532,7 +532,7 @@ X10Context c = (X10Context) tc.context(); X10ConstructorInstance ci = (X10ConstructorInstance) constructorInstance(); if (ci != null) { - XConstraint guard = ci.guard(); + CConstraint guard = ci.guard(); if (guard != null && !guard.consistent()) { throw new SemanticException("Constructor guard not satisfied by caller.", position()); } Modified: trunk/x10.compiler/src/x10/ast/X10Return_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10Return_c.java 2010-01-29 22:51:32 UTC (rev 12779) +++ trunk/x10.compiler/src/x10/ast/X10Return_c.java 2010-01-30 08:41:18 UTC (rev 12780) @@ -31,8 +31,6 @@ import polyglot.util.InternalCompilerError; import polyglot.util.Position; import polyglot.visit.ContextVisitor; -import x10.constraint.XConstraint; -import x10.constraint.XConstraint_c; import x10.constraint.XEQV; import x10.constraint.XFailure; import x10.constraint.XLocal; @@ -44,6 +42,7 @@ import x10.types.X10ProcedureDef; import x10.types.X10TypeMixin; import x10.types.X10TypeSystem; +import x10.types.constraints.CConstraint; public class X10Return_c extends Return_c { @@ -58,14 +57,14 @@ Type b = X10TypeMixin.baseType(t); if (b != t) b = removeLocals(ctx, b, thisCode); - XConstraint c = X10TypeMixin.xclause(t); + CConstraint c = X10TypeMixin.xclause(t); if (c == null) return b; c = removeLocals(ctx, c, thisCode); return X10TypeMixin.xclause(b, c); } - public XConstraint removeLocals(X10Context ctx, XConstraint c, CodeDef thisCode) { + public CConstraint removeLocals(X10Context ctx, CConstraint c, CodeDef thisCode) { if (ctx.currentCode() != thisCode) { return c; } @@ -79,7 +78,7 @@ continue LI; } XLocal l = ts.xtypeTranslator().trans(li.asInstance()); - XEQV x = XConstraint_c.genEQV(true); + XEQV x = XTerms.makeEQV(); c = c.substitute(x, l); } catch (SemanticException e) { Modified: trunk/x10.compiler/src/x10/ast/X10Special_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10Special_c.java 2010-01-29 22:51:32 UTC (rev 12779) +++ trunk/x10.compiler/src/x10/ast/X10Special_c.java 2010-01-30 08:41:18 UTC (rev 12780) @@ -18,9 +18,6 @@ import polyglot.types.Types; import polyglot.util.Position; import polyglot.visit.ContextVisitor; -import x10.constraint.XConstrainedTerm; -import x10.constraint.XConstraint; -import x10.constraint.XConstraint_c; import x10.constraint.XFailure; import x10.constraint.XRoot; import x10.constraint.XTerm; @@ -34,6 +31,9 @@ import x10.types.X10TypeMixin; import x10.types.X10TypeSystem; import x10.types.XTypeTranslator; +import x10.types.constraints.CConstraint; +import x10.types.constraints.CConstraint_c; +import x10.types.constraints.XConstrainedTerm; public class X10Special_c extends Special_c implements X10Special { @@ -144,8 +144,8 @@ if (kind == THIS) { Type tt = X10TypeMixin.baseType(t); - XConstraint cc = X10TypeMixin.xclause(t); - cc = cc == null ? new XConstraint_c() : cc.copy(); + CConstraint cc = X10TypeMixin.xclause(t); + cc = cc == null ? new CConstraint_c() : cc.copy(); try { XVar var = (XVar) xts.xtypeTranslator().trans(cc, this, c); cc.addSelfBinding(var); @@ -166,8 +166,8 @@ else if (kind == SUPER) { Type superClass = X10TypeMixin.superClass(t); Type tt = X10TypeMixin.baseType(superClass); - XConstraint cc = X10TypeMixin.xclause(superClass); - cc = cc == null ? new XConstraint_c() : cc.copy(); + CConstraint cc = X10TypeMixin.xclause(superClass); + cc = cc == null ? new CConstraint_c() : cc.copy(); try { cc.addSelfBinding((XVar) xts.xtypeTranslator().trans(cc, this, c)); } @@ -184,10 +184,10 @@ CodeDef ci = c.currentCode(); if (ci instanceof X10ProcedureDef) { X10ProcedureDef pi = (X10ProcedureDef) ci; - XConstraint guard = Types.get(pi.guard()); + CConstraint guard = Types.get(pi.guard()); if (guard != null) { Type newType = result.type(); - XConstraint dep = X10TypeMixin.xclause(newType).copy(); + CConstraint dep = X10TypeMixin.xclause(newType).copy(); try { dep.addIn(guard); } Modified: trunk/x10.compiler/src/x10/ast/X10StringLit_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10StringLit_c.java 2010-01-29 22:51:32 UTC (rev 12779) +++ trunk/x10.compiler/src/x10/ast/X10StringLit_c.java 2010-01-30 08:41:18 UTC (rev 12780) @@ -16,8 +16,7 @@ import polyglot.types.Type; 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 x10.types.X10Context; @@ -25,6 +24,8 @@ import x10.types.X10TypeMixin; import x10.types.X10TypeSystem; import x10.types.XTypeTranslator; +import x10.types.constraints.CConstraint; +import x10.types.constraints.CConstraint_c; /** * @author vj @@ -43,7 +44,7 @@ X10TypeSystem xts= (X10TypeSystem) tc.typeSystem(); Type Type = xts.String(); - XConstraint c = new XConstraint_c(); + CConstraint c = new CConstraint_c(); XTerm term = xts.xtypeTranslator().trans(c, this.type(Type), (X10Context) tc.context()); try { c.addSelfBinding(term); Modified: trunk/x10.compiler/src/x10/emitter/Emitter.java =================================================================== --- trunk/x10.compiler/src/x10/emitter/Emitter.java 2010-01-29 22:51:32 UTC (rev 12779) +++ trunk/x10.compiler/src/x10/emitter/Emitter.java 2010-01-30 08:41:18 UTC (rev 12780) @@ -62,7 +62,6 @@ import x10.ast.X10ClockedLoop; import x10.ast.X10MethodDecl_c; import x10.constraint.XAnd_c; -import x10.constraint.XConstraint; import x10.constraint.XEQV_c; import x10.constraint.XEquals_c; import x10.constraint.XField_c; @@ -88,6 +87,7 @@ import x10.types.X10TypeMixin; import x10.types.X10TypeSystem; import x10.types.XTypeTranslator.XTypeLit_c; +import x10.types.constraints.CConstraint; import x10.visit.X10PrettyPrinterVisitor; import x10.visit.X10Translator; import x10.visit.X10PrettyPrinterVisitor.CircularList; @@ -536,11 +536,11 @@ } } } - public void serializeConstraint(XConstraint constraint) { + public void serializeConstraint(CConstraint constraint) { // String serializedConstraint = serializedForm(constraint); // StringLit lit = tr.nodeFactory().StringLit(Position.COMPILER_GENERATED, serializedConstraint); // tr.print(null, lit, w); - w.write("new x10.constraint.XConstraint_c() {{"); + w.write("new x10.constraint.CConstraint_c() {{"); w.newline(4); w.begin(0); w.write("try {"); @@ -570,7 +570,7 @@ w.write("}}"); } private static final String XTERMS = "x10.constraint.XTerms"; - private void serializeTerm(XTerm term, XConstraint parent) { + private void serializeTerm(XTerm term, CConstraint parent) { if (term.equals(parent.self())) { w.write("self()"); } else @@ -1351,7 +1351,7 @@ // new RuntimeTypeExpander(def.asType()).expand(tr); // Cannot do this, because we are *defining* T.it here w.write(", "); w.write("null, "); // TODO - XConstraint constraint = def.classInvariant().get(); + CConstraint constraint = def.classInvariant().get(); assert (constraint != null); serializeConstraint(constraint); } Modified: trunk/x10.compiler/src/x10/emitter/RuntimeTypeExpander.java =================================================================== --- trunk/x10.compiler/src/x10/emitter/RuntimeTypeExpander.java 2010-01-29 22:51:32 UTC (rev 12779) +++ trunk/x10.compiler/src/x10/emitter/RuntimeTypeExpander.java 2010-01-30 08:41:18 UTC (rev 12780) @@ -13,6 +13,7 @@ import x10.types.ParameterType; import x10.types.X10ClassDef; import x10.types.X10ClassType; +import x10.types.constraints.CConstraint; import x10.visit.X10PrettyPrinterVisitor; final public class RuntimeTypeExpander extends Expander { @@ -143,7 +144,7 @@ ConstrainedType ct = (ConstrainedType) at; Type base = ct.baseType().get(); if (X10PrettyPrinterVisitor.serialize_runtime_constraints) { - XConstraint constraint = ct.constraint().get(); + CConstraint constraint = ct.constraint().get(); ... [truncated message content] |
From: <dgr...@us...> - 2010-02-01 21:09:56
|
Revision: 12783 http://x10.svn.sourceforge.net/x10/?rev=12783&view=rev Author: dgrove-oss Date: 2010-02-01 21:09:38 +0000 (Mon, 01 Feb 2010) Log Message: ----------- Change to use $(LIBTOOL) instead of libtool because on Macs, there is a libtool and it isn't GNU libtool (which is glibtool). Modified Paths: -------------- trunk/x10.compiler/src/x10cpp/postcompiler/MacOSX_CXXCommandBuilder.java trunk/x10.runtime/src-cpp/x10rt/Makefile trunk/x10.runtime/src-cpp/x10rt/mpi/mpi.mk trunk/x10.runtime/src-cpp/x10rt/pgas/pgas.mk trunk/x10.runtime/src-cpp/x10rt/standalone/standalone.mk Modified: trunk/x10.compiler/src/x10cpp/postcompiler/MacOSX_CXXCommandBuilder.java =================================================================== --- trunk/x10.compiler/src/x10cpp/postcompiler/MacOSX_CXXCommandBuilder.java 2010-02-01 19:25:11 UTC (rev 12782) +++ trunk/x10.compiler/src/x10cpp/postcompiler/MacOSX_CXXCommandBuilder.java 2010-02-01 21:09:38 UTC (rev 12783) @@ -15,6 +15,10 @@ assert (CXXCommandBuilder.PLATFORM.startsWith("macosx_")); } + protected String defaultPostCompiler() { + return "glibtool --mode=link --tag=CXX "+x10rtOpts.cxx; + } + protected boolean gcEnabled() { return true; } protected void addPreArgs(ArrayList<String> cxxCmd) { Modified: trunk/x10.runtime/src-cpp/x10rt/Makefile =================================================================== --- trunk/x10.runtime/src-cpp/x10rt/Makefile 2010-02-01 19:25:11 UTC (rev 12782) +++ trunk/x10.runtime/src-cpp/x10rt/Makefile 2010-02-01 21:09:38 UTC (rev 12783) @@ -6,7 +6,15 @@ WGET ?= wget TAR ?= tar GZIP ?= gzip +LIBTOOL ?= libtool +ifeq ($(X10RT_PLATFORM), darwin) +LIBTOOL = glibtool +endif +ifeq ($(X10RT_PLATFORM), darwin64) +LIBTOOL = glibtool +endif + # these are used only for building tests CXXFLAGS += -Iinclude -Icommon LDFLAGS += -Llib -lpthread @@ -39,10 +47,10 @@ include standalone/standalone.mk %.lo: %.cc - libtool --mode=compile $(CXX) $(CXXFLAGS) -c $< -o $@ + $(LIBTOOL) --mode=compile $(CXX) $(CXXFLAGS) -c $< -o $@ install: $(LIBS) $(PROPERTIES) - libtool --mode=install $(CP) $(LIBS) $(X10_HOME)/x10.dist/lib + $(LIBTOOL) --mode=install $(CP) $(LIBS) $(X10_HOME)/x10.dist/lib $(CP) $(PROPERTIES) $(X10_HOME)/x10.dist/etc $(CP) include/*.h $(X10_HOME)/x10.dist/include (test -n "$(EXECUTABLES)" && $(CP) $(EXECUTABLES) $(X10_HOME)/x10.dist/bin) || true @@ -65,7 +73,7 @@ clean: $(RM) -r */*.o bin/* etc/*.properties test/*.mpi */*~ *~ core* vgcore* include/pgasrt*.h include/xlupc*.h - libtool --mode=clean $(RM) */*.lo lib/*.la test/*.standalone test/*.pgas_* test/*.mpi_* + $(LIBTOOL) --mode=clean $(RM) */*.lo lib/*.la test/*.standalone test/*.pgas_* test/*.mpi_* # vim: ts=8:sw=8:noet # DO NOT DELETE Modified: trunk/x10.runtime/src-cpp/x10rt/mpi/mpi.mk =================================================================== --- trunk/x10.runtime/src-cpp/x10rt/mpi/mpi.mk 2010-02-01 19:25:11 UTC (rev 12782) +++ trunk/x10.runtime/src-cpp/x10rt/mpi/mpi.mk 2010-02-01 21:09:38 UTC (rev 12783) @@ -7,13 +7,13 @@ PROPERTIES += etc/x10rt_mpi.properties %.mpi: %.cc lib/libx10rt_mpi.la - libtool --mode=link --tag=CXX $(MPICXX) $(CXXFLAGS) $< -o $@ $(LDFLAGS) -lx10rt_mpi + $(LIBTOOL) --mode=link --tag=CXX $(MPICXX) $(CXXFLAGS) $< -o $@ $(LDFLAGS) -lx10rt_mpi mpi/x10rt_mpi.lo: mpi/x10rt_mpi.cc - libtool --mode=compile --tag=CXX $(MPICXX) $(CXXFLAGS) -c $< -o $@ + $(LIBTOOL) --mode=compile --tag=CXX $(MPICXX) $(CXXFLAGS) -c $< -o $@ lib/libx10rt_mpi.la: mpi/x10rt_mpi.lo $(COMMON_OBJS) - libtool --mode=link --tag=CXX $(MPICXX) -o $@ $^ -rpath ${X10_HOME}/x10.dist/lib + $(LIBTOOL) --mode=link --tag=CXX $(MPICXX) -o $@ $^ -rpath ${X10_HOME}/x10.dist/lib etc/x10rt_mpi.properties: @echo "CXX=$(MPICXX)" > $@ Modified: trunk/x10.runtime/src-cpp/x10rt/pgas/pgas.mk =================================================================== --- trunk/x10.runtime/src-cpp/x10rt/pgas/pgas.mk 2010-02-01 19:25:11 UTC (rev 12782) +++ trunk/x10.runtime/src-cpp/x10rt/pgas/pgas.mk 2010-02-01 21:09:38 UTC (rev 12783) @@ -118,7 +118,7 @@ EXECUTABLES += bin/launcher bin/manager bin/daemon %.pgas_sockets: %.cc lib/libx10rt_pgas_sockets.la - libtool --mode=link $(CXX) $(CXXFLAGS) $< -o $@ $(LDFLAGS) $(SOCKETS_LDFLAGS) $(SOCKETS_LDLIBS) + $(LIBTOOL) --mode=link $(CXX) $(CXXFLAGS) $< -o $@ $(LDFLAGS) $(SOCKETS_LDFLAGS) $(SOCKETS_LDLIBS) ifdef CUSTOM_PGAS lib/libxlpgas_sockets.a: $(COMMON_OBJS) $(CUSTOM_PGAS)/lib/libxlpgas_sockets.a include/pgasrt.h @@ -134,7 +134,7 @@ endif lib/libx10rt_pgas_sockets.la: $(COMMON_OBJS) lib/libxlpgas_sockets.a - libtool --mode=link $(CXX) -o $@ $(COMMON_OBJS) lib/libxlpgas_sockets.a -rpath ${X10_HOME}/x10.dist/lib + $(LIBTOOL) --mode=link $(CXX) -o $@ $(COMMON_OBJS) lib/libxlpgas_sockets.a -rpath ${X10_HOME}/x10.dist/lib etc/x10rt_pgas_sockets.properties: @echo "CXX=$(CXX)" > $@ @@ -160,7 +160,7 @@ PROPERTIES += etc/x10rt_pgas_lapi.properties %.pgas_lapi: %.cc lib/libx10rt_pgas_lapi.la - libtool --mode=link $(CXX) $(CXXFLAGS) $< -o $@ $(LDFLAGS) $(LAPI_LDFLAGS) $(LAPI_LDLIBS) + $(LIBTOOL) --mode=link $(CXX) $(CXXFLAGS) $< -o $@ $(LDFLAGS) $(LAPI_LDFLAGS) $(LAPI_LDLIBS) ifdef CUSTOM_PGAS lib/libxlpgas_lapi.a: $(COMMON_OBJS) $(CUSTOM_PGAS)/lib/libxlpgas_lapi.a include/pgasrt.h @@ -176,7 +176,7 @@ endif lib/libx10rt_pgas_lapi.la: $(COMMON_OBJS) lib/libxlpgas_lapi.a - libtool --mode=link $(CXX) -o $@ $(COMMON_OBJS) lib/libxlpgas_lapi.a -rpath ${X10_HOME}/x10.dist/lib + $(LIBTOOL) --mode=link $(CXX) -o $@ $(COMMON_OBJS) lib/libxlpgas_lapi.a -rpath ${X10_HOME}/x10.dist/lib etc/x10rt_pgas_lapi.properties: echo "CXX=$(CXX)" > $@ @@ -214,7 +214,7 @@ endif lib/libx10rt_pgas_bgp.la: $(COMMON_OBJS) lib/libxlpgas_bgp.a - libtool --mode=link $(CXX) -o $@ $(COMMON_OBJS) lib/libxlpgas_bgp.a -rpath ${X10_HOME}/x10.dist/lib + $(LIBTOOL) --mode=link $(CXX) -o $@ $(COMMON_OBJS) lib/libxlpgas_bgp.a -rpath ${X10_HOME}/x10.dist/lib etc/x10rt_pgas_bgp.properties: @echo "CXX=$(CXX)" > $@ Modified: trunk/x10.runtime/src-cpp/x10rt/standalone/standalone.mk =================================================================== --- trunk/x10.runtime/src-cpp/x10rt/standalone/standalone.mk 2010-02-01 19:25:11 UTC (rev 12782) +++ trunk/x10.runtime/src-cpp/x10rt/standalone/standalone.mk 2010-02-01 21:09:38 UTC (rev 12783) @@ -5,10 +5,10 @@ PROPERTIES += etc/x10rt_standalone.properties %.standalone: %.cc lib/libx10rt_standalone.la - libtool --mode=link $(CXX) $(CXXFLAGS) $< -o $@ $(LDFLAGS) -lx10rt_standalone + $(LIBTOOL) --mode=link $(CXX) $(CXXFLAGS) $< -o $@ $(LDFLAGS) -lx10rt_standalone lib/libx10rt_standalone.la: standalone/x10rt_standalone.lo $(COMMON_OBJS) - libtool --mode=link $(CXX) -o $@ $^ -rpath ${X10_HOME}/x10.dist/lib + $(LIBTOOL) --mode=link $(CXX) -o $@ $^ -rpath ${X10_HOME}/x10.dist/lib etc/x10rt_standalone.properties: @echo "CXX=$(CXX)" > $@ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dgr...@us...> - 2010-02-01 22:03:06
|
Revision: 12784 http://x10.svn.sourceforge.net/x10/?rev=12784&view=rev Author: dgrove-oss Date: 2010-02-01 22:02:53 +0000 (Mon, 01 Feb 2010) Log Message: ----------- backout libtool changes (12782 and 12783) until they can be made to work on more platforms than just linux-x86. Modified Paths: -------------- trunk/x10.compiler/src/x10cpp/postcompiler/CXXCommandBuilder.java trunk/x10.compiler/src/x10cpp/postcompiler/MacOSX_CXXCommandBuilder.java trunk/x10.runtime/src-cpp/x10rt/Makefile trunk/x10.runtime/src-cpp/x10rt/mpi/mpi.mk trunk/x10.runtime/src-cpp/x10rt/pgas/pgas.mk trunk/x10.runtime/src-cpp/x10rt/standalone/standalone.mk Property Changed: ---------------- trunk/x10.runtime/src-cpp/x10rt/pgas/pgas.mk Modified: trunk/x10.compiler/src/x10cpp/postcompiler/CXXCommandBuilder.java =================================================================== --- trunk/x10.compiler/src/x10cpp/postcompiler/CXXCommandBuilder.java 2010-02-01 21:09:38 UTC (rev 12783) +++ trunk/x10.compiler/src/x10cpp/postcompiler/CXXCommandBuilder.java 2010-02-01 22:02:53 UTC (rev 12784) @@ -92,7 +92,7 @@ protected boolean gcEnabled() { return false; } protected String defaultPostCompiler() { - return "libtool --mode=link --tag=CXX "+x10rtOpts.cxx; + return x10rtOpts.cxx; } /** Add the arguments that go before the output files */ Modified: trunk/x10.compiler/src/x10cpp/postcompiler/MacOSX_CXXCommandBuilder.java =================================================================== --- trunk/x10.compiler/src/x10cpp/postcompiler/MacOSX_CXXCommandBuilder.java 2010-02-01 21:09:38 UTC (rev 12783) +++ trunk/x10.compiler/src/x10cpp/postcompiler/MacOSX_CXXCommandBuilder.java 2010-02-01 22:02:53 UTC (rev 12784) @@ -15,10 +15,6 @@ assert (CXXCommandBuilder.PLATFORM.startsWith("macosx_")); } - protected String defaultPostCompiler() { - return "glibtool --mode=link --tag=CXX "+x10rtOpts.cxx; - } - protected boolean gcEnabled() { return true; } protected void addPreArgs(ArrayList<String> cxxCmd) { Modified: trunk/x10.runtime/src-cpp/x10rt/Makefile =================================================================== --- trunk/x10.runtime/src-cpp/x10rt/Makefile 2010-02-01 21:09:38 UTC (rev 12783) +++ trunk/x10.runtime/src-cpp/x10rt/Makefile 2010-02-01 22:02:53 UTC (rev 12784) @@ -6,15 +6,7 @@ WGET ?= wget TAR ?= tar GZIP ?= gzip -LIBTOOL ?= libtool -ifeq ($(X10RT_PLATFORM), darwin) -LIBTOOL = glibtool -endif -ifeq ($(X10RT_PLATFORM), darwin64) -LIBTOOL = glibtool -endif - # these are used only for building tests CXXFLAGS += -Iinclude -Icommon LDFLAGS += -Llib -lpthread @@ -23,9 +15,9 @@ EXECUTABLES = -X10_HOME = ${CURDIR}/../../.. +X10_HOME = ../../.. -COMMON_OBJS = common/x10rt_front.lo common/x10rt_logical.lo common/x10rt_cuda.lo +COMMON_OBJS = common/x10rt_front.o common/x10rt_logical.o common/x10rt_cuda.o ifdef ENABLE_X10RT_CUDA CXXFLAGS += -DENABLE_CUDA -isystem/usr/local/cuda/include @@ -46,11 +38,8 @@ include standalone/standalone.mk -%.lo: %.cc - $(LIBTOOL) --mode=compile $(CXX) $(CXXFLAGS) -c $< -o $@ - install: $(LIBS) $(PROPERTIES) - $(LIBTOOL) --mode=install $(CP) $(LIBS) $(X10_HOME)/x10.dist/lib + $(CP) $(LIBS) $(X10_HOME)/x10.dist/lib $(CP) $(PROPERTIES) $(X10_HOME)/x10.dist/etc $(CP) include/*.h $(X10_HOME)/x10.dist/include (test -n "$(EXECUTABLES)" && $(CP) $(EXECUTABLES) $(X10_HOME)/x10.dist/bin) || true @@ -72,21 +61,20 @@ @echo TESTS = $(TESTS) clean: - $(RM) -r */*.o bin/* etc/*.properties test/*.mpi */*~ *~ core* vgcore* include/pgasrt*.h include/xlupc*.h - $(LIBTOOL) --mode=clean $(RM) */*.lo lib/*.la test/*.standalone test/*.pgas_* test/*.mpi_* + $(RM) -r */*.o lib/*.a bin/* etc/*.properties test/*.mpi test/*.standalone test/*.pgas_* */*~ *~ core* vgcore* include/pgasrt*.h include/xlupc*.h # vim: ts=8:sw=8:noet # DO NOT DELETE -common/x10rt_cuda.lo: include/x10rt_types.h common/x10rt_internal.h -common/x10rt_cuda.lo: include/x10rt_cuda.h -common/x10rt_front.lo: include/x10rt_front.h include/x10rt_types.h -common/x10rt_front.lo: include/x10rt_logical.h -common/x10rt_logical.lo: include/x10rt_logical.h include/x10rt_types.h -common/x10rt_logical.lo: include/x10rt_net.h include/x10rt_cuda.h -common/x10rt_logical.lo: common/x10rt_internal.h -mpi/x10rt_mpi.lo: include/x10rt_net.h include/x10rt_types.h -standalone/x10rt_standalone.lo: include/x10rt_net.h include/x10rt_types.h -test/x10rt_basic.lo: include/x10rt_front.h include/x10rt_types.h -test/x10rt_gups.lo: include/x10rt_front.h include/x10rt_types.h -test/x10rt_topology.lo: include/x10rt_front.h include/x10rt_types.h +common/x10rt_cuda.o: include/x10rt_types.h common/x10rt_internal.h +common/x10rt_cuda.o: include/x10rt_cuda.h +common/x10rt_front.o: include/x10rt_front.h include/x10rt_types.h +common/x10rt_front.o: include/x10rt_logical.h +common/x10rt_logical.o: include/x10rt_logical.h include/x10rt_types.h +common/x10rt_logical.o: include/x10rt_net.h include/x10rt_cuda.h +common/x10rt_logical.o: common/x10rt_internal.h +mpi/x10rt_mpi.o: include/x10rt_net.h include/x10rt_types.h +standalone/x10rt_standalone.o: include/x10rt_net.h include/x10rt_types.h +test/x10rt_basic.o: include/x10rt_front.h include/x10rt_types.h +test/x10rt_gups.o: include/x10rt_front.h include/x10rt_types.h +test/x10rt_topology.o: include/x10rt_front.h include/x10rt_types.h Modified: trunk/x10.runtime/src-cpp/x10rt/mpi/mpi.mk =================================================================== --- trunk/x10.runtime/src-cpp/x10rt/mpi/mpi.mk 2010-02-01 21:09:38 UTC (rev 12783) +++ trunk/x10.runtime/src-cpp/x10rt/mpi/mpi.mk 2010-02-01 22:02:53 UTC (rev 12784) @@ -2,18 +2,18 @@ AR ?= ar -LIBS += lib/libx10rt_mpi.la +LIBS += lib/libx10rt_mpi.a PROPERTIES += etc/x10rt_mpi.properties -%.mpi: %.cc lib/libx10rt_mpi.la - $(LIBTOOL) --mode=link --tag=CXX $(MPICXX) $(CXXFLAGS) $< -o $@ $(LDFLAGS) -lx10rt_mpi +%.mpi: %.cc lib/libx10rt_mpi.a + $(MPICXX) $(CXXFLAGS) $< -o $@ $(LDFLAGS) -lx10rt_mpi -mpi/x10rt_mpi.lo: mpi/x10rt_mpi.cc - $(LIBTOOL) --mode=compile --tag=CXX $(MPICXX) $(CXXFLAGS) -c $< -o $@ +mpi/x10rt_mpi.o: mpi/x10rt_mpi.cc + $(MPICXX) $(CXXFLAGS) -c $< -o $@ -lib/libx10rt_mpi.la: mpi/x10rt_mpi.lo $(COMMON_OBJS) - $(LIBTOOL) --mode=link --tag=CXX $(MPICXX) -o $@ $^ -rpath ${X10_HOME}/x10.dist/lib +lib/libx10rt_mpi.a: mpi/x10rt_mpi.o $(COMMON_OBJS) + $(AR) $(ARFLAGS) $@ $^ etc/x10rt_mpi.properties: @echo "CXX=$(MPICXX)" > $@ Modified: trunk/x10.runtime/src-cpp/x10rt/pgas/pgas.mk =================================================================== --- trunk/x10.runtime/src-cpp/x10rt/pgas/pgas.mk 2010-02-01 21:09:38 UTC (rev 12783) +++ trunk/x10.runtime/src-cpp/x10rt/pgas/pgas.mk 2010-02-01 22:02:53 UTC (rev 12784) @@ -113,12 +113,12 @@ ifeq ($(PLATFORM_SUPPORTS_SOCKETS), yes) TESTS += $(patsubst test/%,test/%.pgas_sockets,$(BASE_TESTS)) -LIBS += lib/libx10rt_pgas_sockets.la +LIBS += lib/libx10rt_pgas_sockets.a PROPERTIES += etc/x10rt_pgas_sockets.properties EXECUTABLES += bin/launcher bin/manager bin/daemon -%.pgas_sockets: %.cc lib/libx10rt_pgas_sockets.la - $(LIBTOOL) --mode=link $(CXX) $(CXXFLAGS) $< -o $@ $(LDFLAGS) $(SOCKETS_LDFLAGS) $(SOCKETS_LDLIBS) +%.pgas_sockets: %.cc lib/libx10rt_pgas_sockets.a + $(CXX) $(CXXFLAGS) $< -o $@ $(LDFLAGS) $(SOCKETS_LDFLAGS) $(SOCKETS_LDLIBS) ifdef CUSTOM_PGAS lib/libxlpgas_sockets.a: $(COMMON_OBJS) $(CUSTOM_PGAS)/lib/libxlpgas_sockets.a include/pgasrt.h @@ -133,8 +133,9 @@ $(GZIP) -cd $(SOCKETS_TGZ) | $(TAR) -xf - endif -lib/libx10rt_pgas_sockets.la: $(COMMON_OBJS) lib/libxlpgas_sockets.a - $(LIBTOOL) --mode=link $(CXX) -o $@ $(COMMON_OBJS) lib/libxlpgas_sockets.a -rpath ${X10_HOME}/x10.dist/lib +lib/libx10rt_pgas_sockets.a: $(COMMON_OBJS) lib/libxlpgas_sockets.a + $(CP) lib/libxlpgas_sockets.a lib/libx10rt_pgas_sockets.a + $(AR) $(ARFLAGS) $@ $(COMMON_OBJS) etc/x10rt_pgas_sockets.properties: @echo "CXX=$(CXX)" > $@ @@ -156,11 +157,11 @@ HACK=$(shell echo "Your platform supports LAPI but we could not find the poe executable so not building LAPI tests">2) endif -LIBS += lib/libx10rt_pgas_lapi.la +LIBS += lib/libx10rt_pgas_lapi.a PROPERTIES += etc/x10rt_pgas_lapi.properties -%.pgas_lapi: %.cc lib/libx10rt_pgas_lapi.la - $(LIBTOOL) --mode=link $(CXX) $(CXXFLAGS) $< -o $@ $(LDFLAGS) $(LAPI_LDFLAGS) $(LAPI_LDLIBS) +%.pgas_lapi: %.cc lib/libx10rt_pgas_lapi.a + $(CXX) $(CXXFLAGS) $< -o $@ $(LDFLAGS) $(LAPI_LDFLAGS) $(LAPI_LDLIBS) ifdef CUSTOM_PGAS lib/libxlpgas_lapi.a: $(COMMON_OBJS) $(CUSTOM_PGAS)/lib/libxlpgas_lapi.a include/pgasrt.h @@ -175,8 +176,9 @@ $(GZIP) -cd $(LAPI_TGZ) | $(TAR) -xf - endif -lib/libx10rt_pgas_lapi.la: $(COMMON_OBJS) lib/libxlpgas_lapi.a - $(LIBTOOL) --mode=link $(CXX) -o $@ $(COMMON_OBJS) lib/libxlpgas_lapi.a -rpath ${X10_HOME}/x10.dist/lib +lib/libx10rt_pgas_lapi.a: $(COMMON_OBJS) lib/libxlpgas_lapi.a + $(CP) lib/libxlpgas_lapi.a lib/libx10rt_pgas_lapi.a + $(AR) $(ARFLAGS) $@ $(COMMON_OBJS) etc/x10rt_pgas_lapi.properties: echo "CXX=$(CXX)" > $@ @@ -194,10 +196,10 @@ ifeq ($(PLATFORM_SUPPORTS_BGP),yes) TESTS += $(patsubst test/%,test/%.pgas_bgp,$(BASE_TESTS)) -LIBS += lib/libx10rt_pgas_bgp.la +LIBS += lib/libx10rt_pgas_bgp.a PROPERTIES += etc/x10rt_pgas_bgp.properties -%.pgas_bgp: %.cc lib/libx10rt_pgas_bgp.la +%.pgas_bgp: %.cc lib/libx10rt_pgas_bgp.a $(CXX) $(CXXFLAGS) $< -o $@ $(LDFLAGS) $(BGP_LDFLAGS) $(BGP_LDLIBS) ifdef CUSTOM_PGAS @@ -213,8 +215,9 @@ $(GZIP) -cd $(BGP_TGZ) | $(TAR) -xf - endif -lib/libx10rt_pgas_bgp.la: $(COMMON_OBJS) lib/libxlpgas_bgp.a - $(LIBTOOL) --mode=link $(CXX) -o $@ $(COMMON_OBJS) lib/libxlpgas_bgp.a -rpath ${X10_HOME}/x10.dist/lib +lib/libx10rt_pgas_bgp.a: $(COMMON_OBJS) lib/libxlpgas_bgp.a + $(CP) lib/libxlpgas_bgp.a lib/libx10rt_pgas_bgp.a + $(AR) $(ARFLAGS) $@ $(COMMON_OBJS) etc/x10rt_pgas_bgp.properties: @echo "CXX=$(CXX)" > $@ Property changes on: trunk/x10.runtime/src-cpp/x10rt/pgas/pgas.mk ___________________________________________________________________ Deleted: svn:mergeinfo - Modified: trunk/x10.runtime/src-cpp/x10rt/standalone/standalone.mk =================================================================== --- trunk/x10.runtime/src-cpp/x10rt/standalone/standalone.mk 2010-02-01 21:09:38 UTC (rev 12783) +++ trunk/x10.runtime/src-cpp/x10rt/standalone/standalone.mk 2010-02-01 22:02:53 UTC (rev 12784) @@ -1,14 +1,14 @@ TESTS += $(patsubst test/%,test/%.standalone,$(BASE_TESTS)) -LIBS += lib/libx10rt_standalone.la +LIBS += lib/libx10rt_standalone.a PROPERTIES += etc/x10rt_standalone.properties -%.standalone: %.cc lib/libx10rt_standalone.la - $(LIBTOOL) --mode=link $(CXX) $(CXXFLAGS) $< -o $@ $(LDFLAGS) -lx10rt_standalone +%.standalone: %.cc lib/libx10rt_standalone.a + $(CXX) $(CXXFLAGS) $< -o $@ $(LDFLAGS) -lx10rt_standalone -lib/libx10rt_standalone.la: standalone/x10rt_standalone.lo $(COMMON_OBJS) - $(LIBTOOL) --mode=link $(CXX) -o $@ $^ -rpath ${X10_HOME}/x10.dist/lib +lib/libx10rt_standalone.a: standalone/x10rt_standalone.o $(COMMON_OBJS) + $(AR) $(ARFLAGS) $@ $^ etc/x10rt_standalone.properties: @echo "CXX=$(CXX)" > $@ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dgr...@us...> - 2010-02-03 16:47:05
|
Revision: 12791 http://x10.svn.sourceforge.net/x10/?rev=12791&view=rev Author: dgrove-oss Date: 2010-02-03 16:46:59 +0000 (Wed, 03 Feb 2010) Log Message: ----------- A less ambituous version of r12782 that only attempts to make the MPI-based variant of x10rt into a shared library. This is sufficient to enable the development of Java bindings for X10RT to proceed without requiring that PGAS always be built in a way that supports shared libraries and/or libtool. We will eventually need to revisit this and change how we build/package PGAS for X10 so that shared library versions of PGAS are built & included in the PGAS binary tarballs that are input into the X10RT build. Modified Paths: -------------- trunk/x10.compiler/src/x10cpp/postcompiler/CXXCommandBuilder.java trunk/x10.runtime/src-cpp/x10rt/Makefile trunk/x10.runtime/src-cpp/x10rt/mpi/mpi.mk Modified: trunk/x10.compiler/src/x10cpp/postcompiler/CXXCommandBuilder.java =================================================================== --- trunk/x10.compiler/src/x10cpp/postcompiler/CXXCommandBuilder.java 2010-02-02 22:07:07 UTC (rev 12790) +++ trunk/x10.compiler/src/x10cpp/postcompiler/CXXCommandBuilder.java 2010-02-03 16:46:59 UTC (rev 12791) @@ -132,6 +132,12 @@ // prebuilt XRX cxxCmd.add("-L"+X10_DIST+"/lib"); cxxCmd.add("-lx10"); + if (USE_XLC) { + // TODO: Linker magic to tell it to encode where to load X10's shared libraries from in the generated executable. + } else { + cxxCmd.add("-Wl,--rpath"); + cxxCmd.add("-Wl,"+X10_DIST+"/lib"); + } if (!Configuration.DISABLE_GC && gcEnabled()) { cxxCmd.add("-L"+X10GC+"/lib"); Modified: trunk/x10.runtime/src-cpp/x10rt/Makefile =================================================================== --- trunk/x10.runtime/src-cpp/x10rt/Makefile 2010-02-02 22:07:07 UTC (rev 12790) +++ trunk/x10.runtime/src-cpp/x10rt/Makefile 2010-02-03 16:46:59 UTC (rev 12791) @@ -6,6 +6,7 @@ WGET ?= wget TAR ?= tar GZIP ?= gzip +LIBTOOL ?= libtool # these are used only for building tests CXXFLAGS += -Iinclude -Icommon @@ -15,9 +16,10 @@ EXECUTABLES = -X10_HOME = ../../.. +X10_HOME = ${CURDIR}/../../.. COMMON_OBJS = common/x10rt_front.o common/x10rt_logical.o common/x10rt_cuda.o +COMMON_LT_OBJS = $(COMMON_OBJS:.o=.lo) ifdef ENABLE_X10RT_CUDA CXXFLAGS += -DENABLE_CUDA -isystem/usr/local/cuda/include @@ -28,6 +30,9 @@ default: all +%.lo: %.cc + $(LIBTOOL) --mode=compile --tag=CXX $(CXX) $(CXXFLAGS) -c $< -o $@ + ifdef ENABLE_X10RT_MPI include mpi/mpi.mk endif @@ -38,8 +43,9 @@ include standalone/standalone.mk -install: $(LIBS) $(PROPERTIES) - $(CP) $(LIBS) $(X10_HOME)/x10.dist/lib +install: $(LIBS) $(LT_LIBS) $(PROPERTIES) + (test -n "$(LIBS)" && $(CP) $(LIBS) $(X10_HOME)/x10.dist/lib) || true + (test -n "$(LT_LIBS)" && $(LIBTOOL) --mode=install $(CP) $(LT_LIBS) $(X10_HOME)/x10.dist/lib) || true $(CP) $(PROPERTIES) $(X10_HOME)/x10.dist/etc $(CP) include/*.h $(X10_HOME)/x10.dist/include (test -n "$(EXECUTABLES)" && $(CP) $(EXECUTABLES) $(X10_HOME)/x10.dist/bin) || true @@ -61,20 +67,33 @@ @echo TESTS = $(TESTS) clean: + $(LIBTOOL) --mode=clean $(RM) */*.lo lib/*.la $(RM) -r */*.o lib/*.a bin/* etc/*.properties test/*.mpi test/*.standalone test/*.pgas_* */*~ *~ core* vgcore* include/pgasrt*.h include/xlupc*.h # vim: ts=8:sw=8:noet # DO NOT DELETE common/x10rt_cuda.o: include/x10rt_types.h common/x10rt_internal.h +common/x10rt_cuda.lo: include/x10rt_types.h common/x10rt_internal.h common/x10rt_cuda.o: include/x10rt_cuda.h +common/x10rt_cuda.lo: include/x10rt_cuda.h common/x10rt_front.o: include/x10rt_front.h include/x10rt_types.h common/x10rt_front.o: include/x10rt_logical.h +common/x10rt_front.lo: include/x10rt_front.h include/x10rt_types.h +common/x10rt_front.lo: include/x10rt_logical.h common/x10rt_logical.o: include/x10rt_logical.h include/x10rt_types.h common/x10rt_logical.o: include/x10rt_net.h include/x10rt_cuda.h common/x10rt_logical.o: common/x10rt_internal.h +common/x10rt_logical.lo: include/x10rt_logical.h include/x10rt_types.h +common/x10rt_logical.lo: include/x10rt_net.h include/x10rt_cuda.h +common/x10rt_logical.lo: common/x10rt_internal.h mpi/x10rt_mpi.o: include/x10rt_net.h include/x10rt_types.h +mpi/x10rt_mpi.lo: include/x10rt_net.h include/x10rt_types.h standalone/x10rt_standalone.o: include/x10rt_net.h include/x10rt_types.h +standalone/x10rt_standalone.lo: include/x10rt_net.h include/x10rt_types.h test/x10rt_basic.o: include/x10rt_front.h include/x10rt_types.h +test/x10rt_basic.lo: include/x10rt_front.h include/x10rt_types.h test/x10rt_gups.o: include/x10rt_front.h include/x10rt_types.h +test/x10rt_gups.lo: include/x10rt_front.h include/x10rt_types.h test/x10rt_topology.o: include/x10rt_front.h include/x10rt_types.h +test/x10rt_topology.lo: include/x10rt_front.h include/x10rt_types.h Modified: trunk/x10.runtime/src-cpp/x10rt/mpi/mpi.mk =================================================================== --- trunk/x10.runtime/src-cpp/x10rt/mpi/mpi.mk 2010-02-02 22:07:07 UTC (rev 12790) +++ trunk/x10.runtime/src-cpp/x10rt/mpi/mpi.mk 2010-02-03 16:46:59 UTC (rev 12791) @@ -1,19 +1,17 @@ TESTS += $(patsubst test/%,test/%.mpi,$(BASE_TESTS)) -AR ?= ar +LT_LIBS += lib/libx10rt_mpi.la -LIBS += lib/libx10rt_mpi.a - PROPERTIES += etc/x10rt_mpi.properties -%.mpi: %.cc lib/libx10rt_mpi.a - $(MPICXX) $(CXXFLAGS) $< -o $@ $(LDFLAGS) -lx10rt_mpi +%.mpi: %.cc lib/libx10rt_mpi.la + $(LIBTOOL) --mode=link --tag=CXX $(MPICXX) $(CXXFLAGS) $< -o $@ $(LDFLAGS) -lx10rt_mpi -mpi/x10rt_mpi.o: mpi/x10rt_mpi.cc - $(MPICXX) $(CXXFLAGS) -c $< -o $@ +mpi/x10rt_mpi.lo: mpi/x10rt_mpi.cc + $(LIBTOOL) --mode=compile --tag=CXX $(MPICXX) $(CXXFLAGS) -c $< -o $@ -lib/libx10rt_mpi.a: mpi/x10rt_mpi.o $(COMMON_OBJS) - $(AR) $(ARFLAGS) $@ $^ +lib/libx10rt_mpi.la: mpi/x10rt_mpi.lo $(COMMON_LT_OBJS) + $(LIBTOOL) --mode=link --tag=CXX $(MPICXX) -o $@ $^ -rpath $(X10_HOME)/x10.dist/lib etc/x10rt_mpi.properties: @echo "CXX=$(MPICXX)" > $@ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dgr...@us...> - 2010-02-03 20:25:32
|
Revision: 12792 http://x10.svn.sourceforge.net/x10/?rev=12792&view=rev Author: dgrove-oss Date: 2010-02-03 20:25:09 +0000 (Wed, 03 Feb 2010) Log Message: ----------- WIP on X10RT Java bindings. Initial import of Java-side of implementation. Code will not actually be usable until backing natives are checked in and ported to x10rt API, but since the code is currently unreachable the lack of backing natives doesn't matter. Modified Paths: -------------- trunk/x10.dist/bin/x10.in Added Paths: ----------- trunk/x10.runtime/src-java/x10/x10rt/ trunk/x10.runtime/src-java/x10/x10rt/ActiveMessage.java trunk/x10.runtime/src-java/x10/x10rt/MessageRegistry.java trunk/x10.runtime/src-java/x10/x10rt/Node.java trunk/x10.runtime/src-java/x10/x10rt/UnknownMessageException.java trunk/x10.runtime/src-java/x10/x10rt/X10RT.java Modified: trunk/x10.dist/bin/x10.in =================================================================== --- trunk/x10.dist/bin/x10.in 2010-02-03 16:46:59 UTC (rev 12791) +++ trunk/x10.dist/bin/x10.in 2010-02-03 20:25:09 UTC (rev 12792) @@ -67,7 +67,7 @@ classpath="$extra_cp${PATH_SEP}$classpath" fi -externpath="${TOP}${FILE_SEP}lib${FILE_SEP}${X10_PLATFORM}" +externpath="${classpath}${PATH_SEP}${LIB_DIR}${PATH_SEP}${TOP}${FILE_SEP}lib${FILE_SEP}${X10_PLATFORM}" if [ -n "$extra_lib" ]; then externpath="$extra_lib${PATH_SEP}$externpath" fi Added: trunk/x10.runtime/src-java/x10/x10rt/ActiveMessage.java =================================================================== --- trunk/x10.runtime/src-java/x10/x10rt/ActiveMessage.java (rev 0) +++ trunk/x10.runtime/src-java/x10/x10rt/ActiveMessage.java 2010-02-03 20:25:09 UTC (rev 12792) @@ -0,0 +1,1612 @@ +package x10.x10rt; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.ObjectOutputStream; +import java.io.ObjectInputStream; +import java.io.IOException; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; + +/** + * <p>A class whose instances represent active messages that have been registered + * with the X10RT runtime. The primary operation that is available, is to invoke + * send on the message object, which will send an active message to the target node + * composed of a message id and the data payload. The target node will respond to this + * message by invoking the java method associated with the active message with the data + * payload of the message as its arguments.</p> + * <p>It is important to note that this implements a mostly asynchronous messaging system. + * If a node sends a message to itself, then send will be synchronous (the send is implemented + * by directly invoking the target method with the given arguments). If the node sends a message + * to a different node, then send will return as soon as the data has been transfered to the network + * layer and the send is locally complete. Local completion does not imply that the target method + * has been invoked/completed on the remote node.</p> + */ +public class ActiveMessage { + + private static final int MAX_MESSAGE_ID = 100; + + /** + * A simple lookup from message ids to messages. + * Used to implement {@link #receiveGeneral(int, byte[])}. + */ + private static final ActiveMessage[] messages = new ActiveMessage[MAX_MESSAGE_ID+1]; + + /** + * The method that will be invoked when the active message is sent. + */ + private final Method method; + + /** + * The numeric id assigned to this message by the {@link MessageRegistry} and + * used to communicate message identity between nodes. + */ + private final int messageId; + + private ActiveMessage(Method method, int id) throws UnsupportedOperationException { + this.method = method; + this.messageId = id; + } + + static ActiveMessage registerMessage(Method method, int id) throws IllegalArgumentException { + assert X10RT.isBooted() : "must boot X10RT before registering active messages"; + + if (method.getReturnType() != Void.TYPE) { + throw new IllegalArgumentException("Cannot register a method with a non-void return type as an active message"); + } + + assert id < MAX_MESSAGE_ID : "Implement resizing of native registeredMethods array"; + + ActiveMessage msg = new ActiveMessage(method, id); + messages[id] = msg; + registerMethodImpl(msg.method, msg.method.getDeclaringClass(), msg.messageId); + + return msg; + } + + /** + * Send the message represented by <code>this</code> to <code>Node</code>. + * If <code>node</code> is equal to {@link X10RT#here()}, then the + * send is implemented as a direct invocation of the target method and will + * not return until the method invocation completes. + * If <code>node</code> is not equal to {@link X10RT#here()}, then the + * send is implemented by sending an active message to the remote node, + * transmitting the {@link #messageId} and any arguments as data payload. In the remote + * case, the invocation of send will return as soon as the local network send has + * completed. IE, in the remote case, the completion of send does not imply that the + * method has completed (or even been invoked) on the remote node. + * + * @param node the Node to which the message should be sent. + */ + public void send(Node node) { + if (X10RT.here() == node) { + // local send; simply invoked via reflection. + try { + method.invoke(null); + } catch (Exception e) { + if (X10RT.REPORT_UNCAUGHT_USER_EXCEPTIONS) { + e.printStackTrace(); + } + } + } else { + // remote send: pass down to x10rtrt + sendRemote(node.getId(), messageId); + } + } + + /** + * Send the message represented by <code>this</code> to <code>Node</code>. + * If <code>node</code> is equal to {@link X10RT#here()}, then the + * send is implemented as a direct invocation of the target method and will + * not return until the method invocation completes. + * If <code>node</code> is not equal to {@link X10RT#here()}, then the + * send is implemented by sending an active message to the remote node, + * transmitting the {@link #messageId} and any arguments as data payload. In the remote + * case, the invocation of send will return as soon as the local network send has + * completed. IE, in the remote case, the completion of send does not imply that the + * method has completed (or even been invoked) on the remote node. + * + * @param node the Node to which the message should be sent. + * @param arg first argument to the target method + */ + public void send(Node node, int arg) { + if (X10RT.here() == node) { + // local send; simply invoked via reflection. + try { + // Reflection is picky about narrowing conversions, while jni is not. + // So for the local case, we need to undo any widening conversion + // that was done before doing the invoke. + Class<?> argType = method.getParameterTypes()[0]; + if (argType.equals(Integer.TYPE)) { + method.invoke(null, arg); + } else if (argType.equals(Byte.TYPE)) { + method.invoke(null, (byte)arg); + } else if (argType.equals(Short.TYPE)) { + method.invoke(null, (short)arg); + } else { + assert argType.equals(Character.TYPE); + method.invoke(null, (char)arg); + } + } catch (Exception e) { + if (X10RT.REPORT_UNCAUGHT_USER_EXCEPTIONS) { + e.printStackTrace(); + } + } + } else { + // remote send: pass down to x10rt + sendRemote(node.getId(), messageId, arg); + } + } + + /** + * Send the message represented by <code>this</code> to <code>Node</code>. + * If <code>node</code> is equal to {@link X10RT#here()}, then the + * send is implemented as a direct invocation of the target method and will + * not return until the method invocation completes. + * If <code>node</code> is not equal to {@link X10RT#here()}, then the + * send is implemented by sending an active message to the remote node, + * transmitting the {@link #messageId} and any arguments as data payload. In the remote + * case, the invocation of send will return as soon as the local network send has + * completed. IE, in the remote case, the completion of send does not imply that the + * method has completed (or even been invoked) on the remote node. + * + * @param node the Node to which the message should be sent. + * @param arg1 first argument to the target method + * @param arg2 second argument to the target method + */ + public void send(Node node, int arg1, int arg2) { + if (X10RT.here() == node) { + // local send; simply invoked via reflection. + try { + // Reflection is picky about narrowing conversions, while jni is not. + // So for the local case, we need to undo any widening conversion + // that was done before doing the invoke. + Class<?>[] argTypes = method.getParameterTypes(); + if (argTypes[0].equals(Integer.TYPE) && argTypes[1].equals(Integer.TYPE)) { + method.invoke(null, arg1, arg2); + } else { + int[] args = new int[] { arg1, arg2 }; + Object[] boxedArgs = new Object[argTypes.length]; + for (int i=0; i<argTypes.length; i++) { + Class<?> argType = argTypes[i]; + int arg = args[i]; + if (argType.equals(Byte.TYPE)) { + boxedArgs[i] = Byte.valueOf((byte)arg); + } else if (argType.equals(Short.TYPE)) { + boxedArgs[i] = Short.valueOf((short)arg); + } else if (argType.equals(Character.TYPE)){ + boxedArgs[i] = Character.valueOf((char)arg); + } else { + assert argType.equals(Integer.TYPE); + boxedArgs[i] = Integer.valueOf(arg); + } + } + method.invoke(null, boxedArgs); + } + } catch (Exception e) { + if (X10RT.REPORT_UNCAUGHT_USER_EXCEPTIONS) { + e.printStackTrace(); + } + } + } else { + // remote send: pass down to x10rt + sendRemote(node.getId(), messageId, arg1, arg2); + } + } + + /** + * Send the message represented by <code>this</code> to <code>Node</code>. + * If <code>node</code> is equal to {@link X10RT#here()}, then the + * send is implemented as a direct invocation of the target method and will + * not return until the method invocation completes. + * If <code>node</code> is not equal to {@link X10RT#here()}, then the + * send is implemented by sending an active message to the remote node, + * transmitting the {@link #messageId} and any arguments as data payload. In the remote + * case, the invocation of send will return as soon as the local network send has + * completed. IE, in the remote case, the completion of send does not imply that the + * method has completed (or even been invoked) on the remote node. + * + * @param node the Node to which the message should be sent. + * @param arg1 first argument to the target method + * @param arg2 second argument to the target method + * @param arg3 third argument to the target method + */ + public void send(Node node, int arg1, int arg2, int arg3) { + if (X10RT.here() == node) { + // local send; simply invoked via reflection. + try { + // Reflection is picky about narrowing conversions, while jni is not. + // So for the local case, we need to undo any widening conversion + // that was done before doing the invoke. + Class<?>[] argTypes = method.getParameterTypes(); + if (argTypes[0].equals(Integer.TYPE) && argTypes[1].equals(Integer.TYPE) && argTypes[2].equals(Integer.TYPE)) { + method.invoke(null, arg1, arg2, arg3); + } else { + int[] args = new int[] { arg1, arg2, arg3 }; + Object[] boxedArgs = new Object[argTypes.length]; + for (int i=0; i<argTypes.length; i++) { + Class<?> argType = argTypes[i]; + int arg = args[i]; + if (argType.equals(Byte.TYPE)) { + boxedArgs[i] = Byte.valueOf((byte)arg); + } else if (argType.equals(Short.TYPE)) { + boxedArgs[i] = Short.valueOf((short)arg); + } else if (argType.equals(Character.TYPE)){ + boxedArgs[i] = Character.valueOf((char)arg); + } else { + assert argType.equals(Integer.TYPE); + boxedArgs[i] = Integer.valueOf(arg); + } + } + method.invoke(null, boxedArgs); + } + } catch (Exception e) { + if (X10RT.REPORT_UNCAUGHT_USER_EXCEPTIONS) { + e.printStackTrace(); + } + } + } else { + // remote send: pass down to x10rt + sendRemote(node.getId(), messageId, arg1, arg2, arg3); + } + } + + /** + * Send the message represented by <code>this</code> to <code>Node</code>. + * If <code>node</code> is equal to {@link X10RT#here()}, then the + * send is implemented as a direct invocation of the target method and will + * not return until the method invocation completes. + * If <code>node</code> is not equal to {@link X10RT#here()}, then the + * send is implemented by sending an active message to the remote node, + * transmitting the {@link #messageId} and any arguments as data payload. In the remote + * case, the invocation of send will return as soon as the local network send has + * completed. IE, in the remote case, the completion of send does not imply that the + * method has completed (or even been invoked) on the remote node. + * + * @param node the Node to which the message should be sent. + * @param arg1 first argument to the target method + * @param arg2 second argument to the target method + * @param arg3 third argument to the target method + * @param arg4 fourth argument to the target method + */ + public void send(Node node, int arg1, int arg2, int arg3, int arg4) { + if (X10RT.here() == node) { + // local send; simply invoked via reflection. + try { + // Reflection is picky about narrowing conversions, while jni is not. + // So for the local case, we need to undo any widening conversion + // that was done before doing the invoke. + Class<?>[] argTypes = method.getParameterTypes(); + if (argTypes[0].equals(Integer.TYPE) && argTypes[1].equals(Integer.TYPE) && + argTypes[2].equals(Integer.TYPE) && argTypes[4].equals(Integer.TYPE)) { + method.invoke(null, arg1, arg2, arg3, arg4); + } else { + int[] args = new int[] { arg1, arg2, arg3, arg4}; + Object[] boxedArgs = new Object[argTypes.length]; + for (int i=0; i<argTypes.length; i++) { + Class<?> argType = argTypes[i]; + int arg = args[i]; + if (argType.equals(Byte.TYPE)) { + boxedArgs[i] = Byte.valueOf((byte)arg); + } else if (argType.equals(Short.TYPE)) { + boxedArgs[i] = Short.valueOf((short)arg); + } else if (argType.equals(Character.TYPE)){ + boxedArgs[i] = Character.valueOf((char)arg); + } else { + assert argType.equals(Integer.TYPE); + boxedArgs[i] = Integer.valueOf(arg); + } + } + method.invoke(null, boxedArgs); + } + } catch (Exception e) { + if (X10RT.REPORT_UNCAUGHT_USER_EXCEPTIONS) { + e.printStackTrace(); + } + } + } else { + // remote send: pass down to x10rt + sendRemote(node.getId(), messageId, arg1, arg2, arg3, arg4); + } + } + + /** + * Send the message represented by <code>this</code> to <code>Node</code>. + * If <code>node</code> is equal to {@link X10RT#here()}, then the + * send is implemented as a direct invocation of the target method and will + * not return until the method invocation completes. + * If <code>node</code> is not equal to {@link X10RT#here()}, then the + * send is implemented by sending an active message to the remote node, + * transmitting the {@link #messageId} and any arguments as data payload. In the remote + * case, the invocation of send will return as soon as the local network send has + * completed. IE, in the remote case, the completion of send does not imply that the + * method has completed (or even been invoked) on the remote node. + * + * @param node the Node to which the message should be sent. + * @param arg first argument to the target method + */ + public void send(Node node, long arg) { + // Because there is a send(I)V, we can't get here via a widening conversion. + assert method.getParameterTypes()[0].equals(Long.TYPE); + + if (X10RT.here() == node) { + // local send; simply invoked via reflection. + try { + method.invoke(null, arg); + } catch (Exception e) { + if (X10RT.REPORT_UNCAUGHT_USER_EXCEPTIONS) { + e.printStackTrace(); + } + } + } else { + // remote send: pass down to x10rt + sendRemote(node.getId(), messageId, arg); + } + } + + /** + * Send the message represented by <code>this</code> to <code>Node</code>. + * If <code>node</code> is equal to {@link X10RT#here()}, then the + * send is implemented as a direct invocation of the target method and will + * not return until the method invocation completes. + * If <code>node</code> is not equal to {@link X10RT#here()}, then the + * send is implemented by sending an active message to the remote node, + * transmitting the {@link #messageId} and any arguments as data payload. In the remote + * case, the invocation of send will return as soon as the local network send has + * completed. IE, in the remote case, the completion of send does not imply that the + * method has completed (or even been invoked) on the remote node. + * + * @param node the Node to which the message should be sent. + * @param arg1 first argument to the target method + * @param arg2 second argument to the target method + */ + public void send(Node node, long arg1, long arg2) { + // We've covered all the combinations explicitly, so we can't get here via widening conversion. + assert method.getParameterTypes()[0].equals(Long.TYPE) && method.getParameterTypes()[1].equals(Long.TYPE); + + if (X10RT.here() == node) { + // local send; simply invoked via reflection. + try { + method.invoke(null, arg1, arg2); + } catch (Exception e) { + if (X10RT.REPORT_UNCAUGHT_USER_EXCEPTIONS) { + e.printStackTrace(); + } + } + } else { + // remote send: pass down to x10rt + sendRemote(node.getId(), messageId, arg1, arg2); + } + } + + /** + * Send the message represented by <code>this</code> to <code>Node</code>. + * If <code>node</code> is equal to {@link X10RT#here()}, then the + * send is implemented as a direct invocation of the target method and will + * not return until the method invocation completes. + * If <code>node</code> is not equal to {@link X10RT#here()}, then the + * send is implemented by sending an active message to the remote node, + * transmitting the {@link #messageId} and any arguments as data payload. In the remote + * case, the invocation of send will return as soon as the local network send has + * completed. IE, in the remote case, the completion of send does not imply that the + * method has completed (or even been invoked) on the remote node. + * + * @param node the Node to which the message should be sent. + * @param arg1 first argument to the target method + * @param arg2 second argument to the target method + */ + public void send(Node node, int arg1, long arg2) { + // We've covered all the possibilities for arg2 explicitly, so we can't get here via widening conversion. + assert method.getParameterTypes()[0].equals(Long.TYPE); + + if (X10RT.here() == node) { + // local send; simply invoked via reflection. + try { + // Arg1 may have had a widening conversion applied which we need to undo before calling invoke. + Class<?> argType = method.getParameterTypes()[0]; + if (argType.equals(Integer.TYPE)) { + method.invoke(null, arg1, arg2); + } else if (argType.equals(Byte.TYPE)) { + method.invoke(null, (byte)arg1, arg2); + } else if (argType.equals(Short.TYPE)) { + method.invoke(null, (short)arg1, arg2); + } else { + assert argType.equals(Character.TYPE); + method.invoke(null, (char)arg1, arg2); + } + } catch (Exception e) { + if (X10RT.REPORT_UNCAUGHT_USER_EXCEPTIONS) { + e.printStackTrace(); + } + } + } else { + // remote send: pass down to x10rt + sendRemote(node.getId(), messageId, arg1, arg2); + } + } + + /** + * Send the message represented by <code>this</code> to <code>Node</code>. + * If <code>node</code> is equal to {@link X10RT#here()}, then the + * send is implemented as a direct invocation of the target method and will + * not return until the method invocation completes. + * If <code>node</code> is not equal to {@link X10RT#here()}, then the + * send is implemented by sending an active message to the remote node, + * transmitting the {@link #messageId} and any arguments as data payload. In the remote + * case, the invocation of send will return as soon as the local network send has + * completed. IE, in the remote case, the completion of send does not imply that the + * method has completed (or even been invoked) on the remote node. + * + * @param node the Node to which the message should be sent. + * @param arg1 first argument to the target method + * @param arg2 second argument to the target method + */ + public void send(Node node, long arg1, int arg2) { + // We've covered all the possibilities for arg1 explicitly, so we can't get here via widening conversion. + assert method.getParameterTypes()[0].equals(Long.TYPE); + + if (X10RT.here() == node) { + // local send; simply invoked via reflection. + try { + // Arg2 may have had a widening conversion applied which we need to undo before calling invoke. + Class<?> argType = method.getParameterTypes()[1]; + if (argType.equals(Integer.TYPE)) { + method.invoke(null, arg1, arg2); + } else if (argType.equals(Byte.TYPE)) { + method.invoke(null, arg1, (byte)arg2); + } else if (argType.equals(Short.TYPE)) { + method.invoke(null, arg1, (short)arg2); + } else { + assert argType.equals(Character.TYPE); + method.invoke(null, arg1, (char)arg2); + } + } catch (Exception e) { + if (X10RT.REPORT_UNCAUGHT_USER_EXCEPTIONS) { + e.printStackTrace(); + } + } + } else { + // remote send: pass down to x10rt + sendRemote(node.getId(), messageId, arg1, arg2); + } + } + + /** + * Send the message represented by <code>this</code> to <code>Node</code>. + * If <code>node</code> is equal to {@link X10RT#here()}, then the + * send is implemented as a direct invocation of the target method and will + * not return until the method invocation completes. + * If <code>node</code> is not equal to {@link X10RT#here()}, then the + * send is implemented by sending an active message to the remote node, + * transmitting the {@link #messageId} and any arguments as data payload. In the remote + * case, the invocation of send will return as soon as the local network send has + * completed. IE, in the remote case, the completion of send does not imply that the + * method has completed (or even been invoked) on the remote node. + * + * @param node the Node to which the message should be sent. + * @param arg first argument to the target method + */ + public void send(Node node, float arg) { + // Because there is a 1 argument send defined for both int and long, + // it should be impossible to get here via a widening conversion. + assert method.getParameterTypes()[0].equals(Float.TYPE); + + if (X10RT.here() == node) { + // local send; simply invoked via reflection. + try { + method.invoke(null, arg); + } catch (Exception e) { + if (X10RT.REPORT_UNCAUGHT_USER_EXCEPTIONS) { + e.printStackTrace(); + } + } + } else { + // remote send: pass down to x10rt + sendRemote(node.getId(), messageId, arg); + } + } + + /** + * Send the message represented by <code>this</code> to <code>Node</code>. + * If <code>node</code> is equal to {@link X10RT#here()}, then the + * send is implemented as a direct invocation of the target method and will + * not return until the method invocation completes. + * If <code>node</code> is not equal to {@link X10RT#here()}, then the + * send is implemented by sending an active message to the remote node, + * transmitting the {@link #messageId} and any arguments as data payload. In the remote + * case, the invocation of send will return as soon as the local network send has + * completed. IE, in the remote case, the completion of send does not imply that the + * method has completed (or even been invoked) on the remote node. + * + * @param node the Node to which the message should be sent. + * @param arg1 first argument to the target method + * @param arg2 second argument to the target method + */ + public void send(Node node, float arg1, float arg2) { + // We've covered all the combinations explicitly, so we can't get here via widening conversion. + assert method.getParameterTypes()[0].equals(Float.TYPE) && method.getParameterTypes()[1].equals(Float.TYPE); + + if (X10RT.here() == node) { + // local send; simply invoked via reflection. + try { + method.invoke(null, arg1, arg2); + } catch (Exception e) { + if (X10RT.REPORT_UNCAUGHT_USER_EXCEPTIONS) { + e.printStackTrace(); + } + } + } else { + // remote send: pass down to x10rt + sendRemote(node.getId(), messageId, arg1, arg2); + } + } + + /** + * Send the message represented by <code>this</code> to <code>Node</code>. + * If <code>node</code> is equal to {@link X10RT#here()}, then the + * send is implemented as a direct invocation of the target method and will + * not return until the method invocation completes. + * If <code>node</code> is not equal to {@link X10RT#here()}, then the + * send is implemented by sending an active message to the remote node, + * transmitting the {@link #messageId} and any arguments as data payload. In the remote + * case, the invocation of send will return as soon as the local network send has + * completed. IE, in the remote case, the completion of send does not imply that the + * method has completed (or even been invoked) on the remote node. + * + * @param node the Node to which the message should be sent. + * @param arg1 first argument to the target method + * @param arg2 second argument to the target method + */ + public void send(Node node, int arg1, float arg2) { + // We've covered all the possibilities for arg2 explicitly, so we can't get here via widening conversion. + assert method.getParameterTypes()[1].equals(Float.TYPE); + + if (X10RT.here() == node) { + // local send; simply invoked via reflection. + try { + // Arg1 may have had a widening conversion applied which we need to undo before calling invoke. + Class<?> argType = method.getParameterTypes()[0]; + if (argType.equals(Integer.TYPE)) { + method.invoke(null, arg1, arg2); + } else if (argType.equals(Byte.TYPE)) { + method.invoke(null, (byte)arg1, arg2); + } else if (argType.equals(Short.TYPE)) { + method.invoke(null, (short)arg1, arg2); + } else { + assert argType.equals(Character.TYPE); + method.invoke(null, (char)arg1, arg2); + } + } catch (Exception e) { + if (X10RT.REPORT_UNCAUGHT_USER_EXCEPTIONS) { + e.printStackTrace(); + } + } + } else { + // remote send: pass down to x10rt + sendRemote(node.getId(), messageId, arg1, arg2); + } + } + + /** + * Send the message represented by <code>this</code> to <code>Node</code>. + * If <code>node</code> is equal to {@link X10RT#here()}, then the + * send is implemented as a direct invocation of the target method and will + * not return until the method invocation completes. + * If <code>node</code> is not equal to {@link X10RT#here()}, then the + * send is implemented by sending an active message to the remote node, + * transmitting the {@link #messageId} and any arguments as data payload. In the remote + * case, the invocation of send will return as soon as the local network send has + * completed. IE, in the remote case, the completion of send does not imply that the + * method has completed (or even been invoked) on the remote node. + * + * @param node the Node to which the message should be sent. + * @param arg1 first argument to the target method + * @param arg2 second argument to the target method + */ + public void send(Node node, long arg1, float arg2) { + // We've covered all the combinations explicitly, so we can't get here via widening conversion. + assert method.getParameterTypes()[0].equals(Long.TYPE) && method.getParameterTypes()[1].equals(Float.TYPE); + + if (X10RT.here() == node) { + // local send; simply invoked via reflection. + try { + method.invoke(null, arg1, arg2); + } catch (Exception e) { + if (X10RT.REPORT_UNCAUGHT_USER_EXCEPTIONS) { + e.printStackTrace(); + } + } + } else { + // remote send: pass down to x10rt + sendRemote(node.getId(), messageId, arg1, arg2); + } + } + + /** + * Send the message represented by <code>this</code> to <code>Node</code>. + * If <code>node</code> is equal to {@link X10RT#here()}, then the + * send is implemented as a direct invocation of the target method and will + * not return until the method invocation completes. + * If <code>node</code> is not equal to {@link X10RT#here()}, then the + * send is implemented by sending an active message to the remote node, + * transmitting the {@link #messageId} and any arguments as data payload. In the remote + * case, the invocation of send will return as soon as the local network send has + * completed. IE, in the remote case, the completion of send does not imply that the + * method has completed (or even been invoked) on the remote node. + * + * @param node the Node to which the message should be sent. + * @param arg1 first argument to the target method + * @param arg2 second argument to the target method + */ + public void send(Node node, float arg1, int arg2) { + // We've covered all the possibilities for arg1 explicitly, so we can't get here via widening conversion. + assert method.getParameterTypes()[0].equals(Float.TYPE); + + if (X10RT.here() == node) { + // local send; simply invoked via reflection. + try { + // Arg2 may have had a widening conversion applied which we need to undo before calling invoke. + Class<?> argType = method.getParameterTypes()[1]; + if (argType.equals(Integer.TYPE)) { + method.invoke(null, arg1, arg2); + } else if (argType.equals(Byte.TYPE)) { + method.invoke(null, arg1, (byte)arg2); + } else if (argType.equals(Short.TYPE)) { + method.invoke(null, arg1, (short)arg2); + } else { + assert argType.equals(Character.TYPE); + method.invoke(null, arg1, (char)arg2); + } + } catch (Exception e) { + if (X10RT.REPORT_UNCAUGHT_USER_EXCEPTIONS) { + e.printStackTrace(); + } + } + } else { + // remote send: pass down to x10rt + sendRemote(node.getId(), messageId, arg1, arg2); + } + } + + /** + * Send the message represented by <code>this</code> to <code>Node</code>. + * If <code>node</code> is equal to {@link X10RT#here()}, then the + * send is implemented as a direct invocation of the target method and will + * not return until the method invocation completes. + * If <code>node</code> is not equal to {@link X10RT#here()}, then the + * send is implemented by sending an active message to the remote node, + * transmitting the {@link #messageId} and any arguments as data payload. In the remote + * case, the invocation of send will return as soon as the local network send has + * completed. IE, in the remote case, the completion of send does not imply that the + * method has completed (or even been invoked) on the remote node. + * + * @param node the Node to which the message should be sent. + * @param arg1 first argument to the target method + * @param arg2 second argument to the target method + */ + public void send(Node node, float arg1, long arg2) { + // We've covered all the combinations explicitly, so we can't get here via widening conversion. + assert method.getParameterTypes()[0].equals(Float.TYPE) && method.getParameterTypes()[1].equals(Long.TYPE); + + if (X10RT.here() == node) { + // local send; simply invoked via reflection. + try { + method.invoke(null, arg1, arg2); + } catch (Exception e) { + if (X10RT.REPORT_UNCAUGHT_USER_EXCEPTIONS) { + e.printStackTrace(); + } + } + } else { + // remote send: pass down to x10rt + sendRemote(node.getId(), messageId, arg1, arg2); + } + } + + /** + * Send the message represented by <code>this</code> to <code>Node</code>. + * If <code>node</code> is equal to {@link X10RT#here()}, then the + * send is implemented as a direct invocation of the target method and will + * not return until the method invocation completes. + * If <code>node</code> is not equal to {@link X10RT#here()}, then the + * send is implemented by sending an active message to the remote node, + * transmitting the {@link #messageId} and any arguments as data payload. In the remote + * case, the invocation of send will return as soon as the local network send has + * completed. IE, in the remote case, the completion of send does not imply that the + * method has completed (or even been invoked) on the remote node. + * + * @param node the Node to which the message should be sent. + * @param arg first argument to the target method + */ + public void send(Node node, double arg) { + // Because there is a 1 argument send defined for int, float, and long + // it should be impossible to get here via a widening conversion. + assert method.getParameterTypes()[0].equals(Double.TYPE); + + if (X10RT.here() == node) { + // local send; simply invoked via reflection. + try { + method.invoke(null, arg); + } catch (Exception e) { + if (X10RT.REPORT_UNCAUGHT_USER_EXCEPTIONS) { + e.printStackTrace(); + } + } + } else { + // remote send: pass down to x10rt + sendRemote(node.getId(), messageId, arg); + } + } + + /** + * Send the message represented by <code>this</code> to <code>Node</code>. + * If <code>node</code> is equal to {@link X10RT#here()}, then the + * send is implemented as a direct invocation of the target method and will + * not return until the method invocation completes. + * If <code>node</code> is not equal to {@link X10RT#here()}, then the + * send is implemented by sending an active message to the remote node, + * transmitting the {@link #messageId} and any arguments as data payload. In the remote + * case, the invocation of send will return as soon as the local network send has + * completed. IE, in the remote case, the completion of send does not imply that the + * method has completed (or even been invoked) on the remote node. + * + * @param node the Node to which the message should be sent. + * @param arg1 first argument to the target method + * @param arg2 second argument to the target method + */ + public void send(Node node, double arg1, double arg2) { + // We've covered all the combinations explicitly, so we can't get here via widening conversion. + assert method.getParameterTypes()[0].equals(Double.TYPE) && method.getParameterTypes()[1].equals(Double.TYPE); + + if (X10RT.here() == node) { + // local send; simply invoked via reflection. + try { + method.invoke(null, arg1, arg2); + } catch (Exception e) { + if (X10RT.REPORT_UNCAUGHT_USER_EXCEPTIONS) { + e.printStackTrace(); + } + } + } else { + // remote send: pass down to x10rt + sendRemote(node.getId(), messageId, arg1, arg2); + } + } + + /** + * Send the message represented by <code>this</code> to <code>Node</code>. + * If <code>node</code> is equal to {@link X10RT#here()}, then the + * send is implemented as a direct invocation of the target method and will + * not return until the method invocation completes. + * If <code>node</code> is not equal to {@link X10RT#here()}, then the + * send is implemented by sending an active message to the remote node, + * transmitting the {@link #messageId} and any arguments as data payload. In the remote + * case, the invocation of send will return as soon as the local network send has + * completed. IE, in the remote case, the completion of send does not imply that the + * method has completed (or even been invoked) on the remote node. + * + * @param node the Node to which the message should be sent. + * @param arg1 first argument to the target method + * @param arg2 second argument to the target method + */ + public void send(Node node, int arg1, double arg2) { + // We've covered all the possibilities for arg2 explicitly, so we can't get here via widening conversion. + assert method.getParameterTypes()[1].equals(Double.TYPE); + + if (X10RT.here() == node) { + // local send; simply invoked via reflection. + try { + // Arg1 may have had a widening conversion applied which we need to undo before calling invoke. + Class<?> argType = method.getParameterTypes()[0]; + if (argType.equals(Integer.TYPE)) { + method.invoke(null, arg1, arg2); + } else if (argType.equals(Byte.TYPE)) { + method.invoke(null, (byte)arg1, arg2); + } else if (argType.equals(Short.TYPE)) { + method.invoke(null, (short)arg1, arg2); + } else { + assert argType.equals(Character.TYPE); + method.invoke(null, (char)arg1, arg2); + } + } catch (Exception e) { + if (X10RT.REPORT_UNCAUGHT_USER_EXCEPTIONS) { + e.printStackTrace(); + } + } + } else { + // remote send: pass down to x10rt + sendRemote(node.getId(), messageId, arg1, arg2); + } + } + + /** + * Send the message represented by <code>this</code> to <code>Node</code>. + * If <code>node</code> is equal to {@link X10RT#here()}, then the + * send is implemented as a direct invocation of the target method and will + * not return until the method invocation completes. + * If <code>node</code> is not equal to {@link X10RT#here()}, then the + * send is implemented by sending an active message to the remote node, + * transmitting the {@link #messageId} and any arguments as data payload. In the remote + * case, the invocation of send will return as soon as the local network send has + * completed. IE, in the remote case, the completion of send does not imply that the + * method has completed (or even been invoked) on the remote node. + * + * @param node the Node to which the message should be sent. + * @param arg1 first argument to the target method + * @param arg2 second argument to the target method + */ + public void send(Node node, float arg1, double arg2) { + // We've covered all the combinations explicitly, so we can't get here via widening conversion. + assert method.getParameterTypes()[0].equals(Float.TYPE) && method.getParameterTypes()[1].equals(Double.TYPE); + + if (X10RT.here() == node) { + // local send; simply invoked via reflection. + try { + method.invoke(null, arg1, arg2); + } catch (Exception e) { + if (X10RT.REPORT_UNCAUGHT_USER_EXCEPTIONS) { + e.printStackTrace(); + } + } + } else { + // remote send: pass down to x10rt + sendRemote(node.getId(), messageId, arg1, arg2); + } + } + + /** + * Send the message represented by <code>this</code> to <code>Node</code>. + * If <code>node</code> is equal to {@link X10RT#here()}, then the + * send is implemented as a direct invocation of the target method and will + * not return until the method invocation completes. + * If <code>node</code> is not equal to {@link X10RT#here()}, then the + * send is implemented by sending an active message to the remote node, + * transmitting the {@link #messageId} and any arguments as data payload. In the remote + * case, the invocation of send will return as soon as the local network send has + * completed. IE, in the remote case, the completion of send does not imply that the + * method has completed (or even been invoked) on the remote node. + * + * @param node the Node to which the message should be sent. + * @param arg1 first argument to the target method + * @param arg2 second argument to the target method + */ + public void send(Node node, long arg1, double arg2) { + // We've covered all the combinations explicitly, so we can't get here via widening conversion. + assert method.getParameterTypes()[0].equals(Long.TYPE) && method.getParameterTypes()[1].equals(Double.TYPE); + + if (X10RT.here() == node) { + // local send; simply invoked via reflection. + try { + method.invoke(null, arg1, arg2); + } catch (Exception e) { + if (X10RT.REPORT_UNCAUGHT_USER_EXCEPTIONS) { + e.printStackTrace(); + } + } + } else { + // remote send: pass down to x10rt + sendRemote(node.getId(), messageId, arg1, arg2); + } + } + + /** + * Send the message represented by <code>this</code> to <code>Node</code>. + * If <code>node</code> is equal to {@link X10RT#here()}, then the + * send is implemented as a direct invocation of the target method and will + * not return until the method invocation completes. + * If <code>node</code> is not equal to {@link X10RT#here()}, then the + * send is implemented by sending an active message to the remote node, + * transmitting the {@link #messageId} and any arguments as data payload. In the remote + * case, the invocation of send will return as soon as the local network send has + * completed. IE, in the remote case, the completion of send does not imply that the + * method has completed (or even been invoked) on the remote node. + * + * @param node the Node to which the message should be sent. + * @param arg1 first argument to the target method + * @param arg2 second argument to the target method + */ + public void send(Node node, double arg1, int arg2) { + // We've covered all the possibilities for arg1 explicitly, so we can't get here via widening conversion. + assert method.getParameterTypes()[0].equals(Double.TYPE); + + if (X10RT.here() == node) { + // local send; simply invoked via reflection. + try { + // Arg2 may have had a widening conversion applied which we need to undo before calling invoke. + Class<?> argType = method.getParameterTypes()[1]; + if (argType.equals(Integer.TYPE)) { + method.invoke(null, arg1, arg2); + } else if (argType.equals(Byte.TYPE)) { + method.invoke(null, arg1, (byte)arg2); + } else if (argType.equals(Short.TYPE)) { + method.invoke(null, arg1, (short)arg2); + } else { + assert argType.equals(Character.TYPE); + method.invoke(null, arg1, (char)arg2); + } + } catch (Exception e) { + if (X10RT.REPORT_UNCAUGHT_USER_EXCEPTIONS) { + e.printStackTrace(); + } + } + } else { + // remote send: pass down to x10rt + sendRemote(node.getId(), messageId, arg1, arg2); + } + } + + /** + * Send the message represented by <code>this</code> to <code>Node</code>. + * If <code>node</code> is equal to {@link X10RT#here()}, then the + * send is implemented as a direct invocation of the target method and will + * not return until the method invocation completes. + * If <code>node</code> is not equal to {@link X10RT#here()}, then the + * send is implemented by sending an active message to the remote node, + * transmitting the {@link #messageId} and any arguments as data payload. In the remote + * case, the invocation of send will return as soon as the local network send has + * completed. IE, in the remote case, the completion of send does not imply that the + * method has completed (or even been invoked) on the remote node. + * + * @param node the Node to which the message should be sent. + * @param arg1 first argument to the target method + * @param arg2 second argument to the target method + */ + public void send(Node node, double arg1, float arg2) { + // We've covered all the combinations explicitly, so we can't get here via widening conversion. + assert method.getParameterTypes()[0].equals(Double.TYPE) && method.getParameterTypes()[1].equals(Float.TYPE); + + if (X10RT.here() == node) { + // local send; simply invoked via reflection. + try { + method.invoke(null, arg1, arg2); + } catch (Exception e) { + if (X10RT.REPORT_UNCAUGHT_USER_EXCEPTIONS) { + e.printStackTrace(); + } + } + } else { + // remote send: pass down to x10rt + sendRemote(node.getId(), messageId, arg1, arg2); + } + } + + /** + * Send the message represented by <code>this</code> to <code>Node</code>. + * If <code>node</code> is equal to {@link X10RT#here()}, then the + * send is implemented as a direct invocation of the target method and will + * not return until the method invocation completes. + * If <code>node</code> is not equal to {@link X10RT#here()}, then the + * send is implemented by sending an active message to the remote node, + * transmitting the {@link #messageId} and any arguments as data payload. In the remote + * case, the invocation of send will return as soon as the local network send has + * completed. IE, in the remote case, the completion of send does not imply that the + * method has completed (or even been invoked) on the remote node. + * + * @param node the Node to which the message should be sent. + * @param arg1 first argument to the target method + * @param arg2 second argument to the target method + */ + public void send(Node node, double arg1, long arg2) { + // We've covered all the combinations explicitly, so we can't get here via widening conversion. + assert method.getParameterTypes()[0].equals(Double.TYPE) && method.getParameterTypes()[1].equals(Long.TYPE); + + if (X10RT.here() == node) { + // local send; simply invoked via reflection. + try { + method.invoke(null, arg1, arg2); + } catch (Exception e) { + if (X10RT.REPORT_UNCAUGHT_USER_EXCEPTIONS) { + e.printStackTrace(); + } + } + } else { + // remote send: pass down to x10rt + sendRemote(node.getId(), messageId, arg1, arg2); + } + } + + /** + * Send the message represented by <code>this</code> to <code>Node</code>. + * If <code>node</code> is equal to {@link X10RT#here()}, then the + * send is implemented as a direct invocation of the target method and will + * not return until the method invocation completes. + * If <code>node</code> is not equal to {@link X10RT#here()}, then the + * send is implemented by sending an active message to the remote node, + * transmitting the {@link #messageId} and any arguments as data payload. In the remote + * case, the invocation of send will return as soon as the local network send has + * completed. IE, in the remote case, the completion of send does not imply that the + * method has completed (or even been invoked) on the remote node. + * + * @param arg first argument to the target method + * @param node the Node to which the message should be sent. + */ + public void send(Node node, boolean[] arg) { + if (X10RT.here() == node) { + // local send; simply invoked via reflection. + try { + method.invoke(null, arg); + } catch (Exception e) { + if (X10RT.REPORT_UNCAUGHT_USER_EXCEPTIONS) { + e.printStackTrace(); + } + } + } else { + // remote send: pass down to x10rt + sendArrayRemote(node.getId(), messageId, arg.length, arg); + } + } + + /** + * Send the message represented by <code>this</code> to <code>Node</code>. + * If <code>node</code> is equal to {@link X10RT#here()}, then the + * send is implemented as a direct invocation of the target method and will + * not return until the method invocation completes. + * If <code>node</code> is not equal to {@link X10RT#here()}, then the + * send is implemented by sending an active message to the remote node, + * transmitting the {@link #messageId} and any arguments as data payload. In the remote + * case, the invocation of send will return as soon as the local network send has + * completed. IE, in the remote case, the completion of send does not imply that the + * method has completed (or even been invoked) on the remote node. + * + * @param arg first argument to the target method + * @param node the Node to which the message should be sent. + */ + public void send(Node node, byte[] arg) { + if (X10RT.here() == node) { + // local send; simply invoked via reflection. + try { + method.invoke(null, arg); + } catch (Exception e) { + if (X10RT.REPORT_UNCAUGHT_USER_EXCEPTIONS) { + e.printStackTrace(); + } + } + } else { + // remote send: pass down to x10rt + sendArrayRemote(node.getId(), messageId, arg.length, arg); + } + } + + /** + * Send the message represented by <code>this</code> to <code>Node</code>. + * If <code>node</code> is equal to {@link X10RT#here()}, then the + * send is implemented as a direct invocation of the target method and will + * not return until the method invocation completes. + * If <code>node</code> is not equal to {@link X10RT#here()}, then the + * send is implemented by sending an active message to the remote node, + * transmitting the {@link #messageId} and any arguments as data payload. In the remote + * case, the invocation of send will return as soon as the local network send has + * completed. IE, in the remote case, the completion of send does not imply that the + * method has completed (or even been invoked) on the remote node. + * + * @param arg first argument to the target method + * @param node the Node to which the message should be sent. + */ + public void send(Node node, short[] arg) { + if (X10RT.here() == node) { + // local send; simply invoked via reflection. + try { + method.invoke(null, arg); + } catch (Exception e) { + if (X10RT.REPORT_UNCAUGHT_USER_EXCEPTIONS) { + e.printStackTrace(); + } + } + } else { + // remote send: pass down to x10rt + sendArrayRemote(node.getId(), messageId, arg.length, arg); + } + } + + /** + * Send the message represented by <code>this</code> to <code>Node</code>. + * If <code>node</code> is equal to {@link X10RT#here()}, then the + * send is implemented as a direct invocation of the target method and will + * not return until the method invocation completes. + * If <code>node</code> is not equal to {@link X10RT#here()}, then the + * send is implemented by sending an active message to the remote node, + * transmitting the {@link #messageId} and any arguments as data payload. In the remote + * case, the invocation of send will return as soon as the local network send has + * completed. IE, in the remote case, the completion of send does not imply that the + * method has completed (or even been invoked) on the remote node. + * + * @param arg first argument to the target method + * @param node the Node to which the message should be sent. + */ + public void send(Node node, char[] arg) { + if (X10RT.here() == node) { + // local send; simply invoked via reflection. + try { + method.invoke(null, arg); + } catch (Exception e) { + if (X10RT.REPORT_UNCAUGHT_USER_EXCEPTIONS) { + e.printStackTrace(); + } + } + } else { + // remote send: pass down to x10rt + sendArrayRemote(node.getId(), messageId, arg.length, arg); + } + } + /** + * Send the message represented by <code>this</code> to <code>Node</code>. + * If <code>node</code> is equal to {@link X10RT#here()}, then the + * send is implemented as a direct invocation of the target method and will + * not return until the method invocation completes. + * If <code>node</code> is not equal to {@link X10RT#here()}, then the + * send is implemented by sending an active message to the remote node, + * transmitting the {@link #messageId} and any arguments as data payload. In the remote + * case, the invocation of send will return as soon as the local network send has + * completed. IE, in the remote case, the completion of send does not imply that the + * method has completed (or even been invoked) on the remote node. + * + * @param arg first argument to the target method + * @param node the Node to which the message should be sent. + */ + + public void send(Node node, int[] arg) { + if (X10RT.here() == node) { + // local send; simply invoked via reflection. + try { + method.invoke(null, arg); + } catch (Exception e) { + if (X10RT.REPORT_UNCAUGHT_USER_EXCEPTIONS) { + e.printStackTrace(); + } + } + } else { + // remote send: pass down to x10rt + sendArrayRemote(node.getId(), messageId, arg.length, arg); + } + } + + /** + * Send the message represented by <code>this</code> to <code>Node</code>. + * If <code>node</code> is equal to {@link X10RT#here()}, then the + * send is implemented as a direct invocation of the target method and will + * not return until the method invocation completes. + * If <code>node</code> is not equal to {@link X10RT#here()}, then the + * send is implemented by sending an active message to the remote node, + * transmitting the {@link #messageId} and any arguments as data payload. In the remote + * case, the invocation of send will return as soon as the local network send has + * completed. IE, in the remote case, the completion of send does not imply that the + * method has completed (or even been invoked) on the remote node. + * + * @param arg first argument to the target method + * @param node the Node to which the message should be sent. + */ + public void send(Node node, float[] arg) { + if (X10RT.here() == node) { + // local send; ... [truncated message content] |
From: <spa...@us...> - 2010-02-03 20:29:43
|
Revision: 12793 http://x10.svn.sourceforge.net/x10/?rev=12793&view=rev Author: sparksparkspark Date: 2010-02-03 20:28:53 +0000 (Wed, 03 Feb 2010) Log Message: ----------- Handle passing null pointers to CUDA Modified Paths: -------------- trunk/x10.compiler/src/x10cuda/visit/CUDACodeGenerator.java trunk/x10.runtime/src-cpp/x10/lang/Object.h trunk/x10.runtime/src-cpp/x10aux/ref.h Modified: trunk/x10.compiler/src/x10cuda/visit/CUDACodeGenerator.java =================================================================== --- trunk/x10.compiler/src/x10cuda/visit/CUDACodeGenerator.java 2010-02-03 20:25:09 UTC (rev 12792) +++ trunk/x10.compiler/src/x10cuda/visit/CUDACodeGenerator.java 2010-02-03 20:28:53 UTC (rev 12793) @@ -619,14 +619,14 @@ if (isIntRail(t)) { if (xts().isRail(t)) { - inc.write("(x10_int*)(size_t)x10aux::get_remote_ref("+name+".operator->())"); + inc.write("(x10_int*)(size_t)x10aux::get_remote_ref_maybe_null("+name+".operator->())"); } else { inc.write("(x10_int*)(size_t)x10aux::remote_alloc(__gpu, sizeof(x10_int)*"+name+"->FMGL(length));"); inc.newline(); inc.write("x10aux::cuda_put(__gpu, (x10_ulong) __env."+name+", &(*"+name+")[0], sizeof(x10_int)*"+name+"->FMGL(length))"); } } else if (isFloatRail(t)) { if (xts().isRail(t)) { - inc.write("(x10_float*)(size_t)x10aux::get_remote_ref("+name+".operator->())"); + inc.write("(x10_float*)(size_t)x10aux::get_remote_ref_maybe_null("+name+".operator->())"); } else { inc.write("(x10_float*)(size_t)x10aux::remote_alloc(__gpu, sizeof(x10_float)*"+name+"->FMGL(length));"); inc.newline(); inc.write("x10aux::cuda_put(__gpu, (x10_ulong) __env."+name+", &(*"+name+")[0], sizeof(x10_float)*"+name+"->FMGL(length))"); Modified: trunk/x10.runtime/src-cpp/x10/lang/Object.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Object.h 2010-02-03 20:25:09 UTC (rev 12792) +++ trunk/x10.runtime/src-cpp/x10/lang/Object.h 2010-02-03 20:28:53 UTC (rev 12793) @@ -93,6 +93,7 @@ // Needed for linking - do not override virtual x10_boolean _struct_equals(x10aux::ref<Object> other) { + assert(other!=x10aux::null); // checked in basic_functions.h x10aux::struct_equals if (other == x10aux::ref<Object>(this)) return true; if (this->location == x10aux::here) return false; // already tested above if (other->location == this->location && Modified: trunk/x10.runtime/src-cpp/x10aux/ref.h =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/ref.h 2010-02-03 20:25:09 UTC (rev 12792) +++ trunk/x10.runtime/src-cpp/x10aux/ref.h 2010-02-03 20:28:53 UTC (rev 12793) @@ -16,6 +16,9 @@ inline x10_addr_t get_remote_ref(void *obj) { return *(x10_addr_t*)(((char*)obj)-sizeof(x10_addr_t)); } + inline x10_addr_t get_remote_ref_maybe_null(void *obj) { + return obj==NULL ? NULL : get_remote_ref(obj); + } inline void set_remote_ref(void *obj, x10_addr_t ref) { *(x10_addr_t*)(((char*)obj)-sizeof(x10_addr_t)) = ref; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mer...@us...> - 2010-01-28 08:54:29
|
Revision: 12758 http://x10.svn.sourceforge.net/x10/?rev=12758&view=rev Author: mergen-oss Date: 2010-01-28 08:54:12 +0000 (Thu, 28 Jan 2010) Log Message: ----------- First commit of bytecode backend, to establish structure. Very little works. Modified Paths: -------------- trunk/x10.compiler/META-INF/MANIFEST.MF trunk/x10.compiler/build.xml trunk/x10.dist/bin/x10c.in trunk/x10.dist/build.xml Added Paths: ----------- trunk/x10.compiler/src/x10bc/ trunk/x10.compiler/src/x10bc/ExtensionInfo.java trunk/x10.compiler/src/x10bc/X10BytecodeTranslator.java trunk/x10.dist/bin/x10bc Modified: trunk/x10.compiler/META-INF/MANIFEST.MF =================================================================== --- trunk/x10.compiler/META-INF/MANIFEST.MF 2010-01-27 21:57:21 UTC (rev 12757) +++ trunk/x10.compiler/META-INF/MANIFEST.MF 2010-01-28 08:54:12 UTC (rev 12758) @@ -7,7 +7,8 @@ Require-Bundle: x10.common, x10.constraints, polyglot3, - lpg.runtime;bundle-version="2.0.17" + lpg.runtime;bundle-version="2.0.17", + polyglot.bytecode;bundle-version="1.0.0" Export-Package: x10, x10.ast, x10.emitter, @@ -18,6 +19,7 @@ x10.types, x10.util, x10.visit, + x10bc, x10cpp, x10cpp.ast, x10cpp.debug, Modified: trunk/x10.compiler/build.xml =================================================================== --- trunk/x10.compiler/build.xml 2010-01-27 21:57:21 UTC (rev 12757) +++ trunk/x10.compiler/build.xml 2010-01-28 08:54:12 UTC (rev 12758) @@ -18,11 +18,15 @@ <property name="config" value="*.cfg"/> <property name="lpg.jar" value="lpg.jar"/> <property name="polyglot.jar" value="polyglot3.jar"/> + <property name="polyglot.bytecode.jar" value="polyglot-bytecode.jar"/> + <property name="asm.jar" value="asm-all-3.2.jar"/> <property name="runtime.jar" value="x10.jar"/> <path id="project.classpath"> <path refid="mainproject.classpath"/> <path refid="lpg.classpath"/> <path refid="polyglot.classpath"/> + <path refid="polyglot.bytecode.classpath"/> + <path refid="asm.classpath"/> <path refid="x10.runtime.classpath"/> <path refid="x10.constraints.classpath"/> <path refid="x10.common.classpath"/> @@ -36,6 +40,12 @@ <path id="polyglot.classpath"> <pathelement location="${lib}/${polyglot.jar}"/> </path> + <path id="polyglot.bytecode.classpath"> + <pathelement location="${lib}/${polyglot.bytecode.jar}"/> + </path> + <path id="asm.classpath"> + <pathelement location="${lib}/${asm.jar}"/> + </path> <path id="x10.runtime.classpath"> <pathelement location="${lib}/${runtime.jar}"/> </path> @@ -65,7 +75,7 @@ </copy> </target> <target name="check-jar" depends="init"> - <fileset id="compiler.classes" dir="${build}" includes="org/**,x10/**,x10cpp/**,x10c/**,x10cuda/**,data/**" excludes="${jar}"/> + <fileset id="compiler.classes" dir="${build}" includes="org/**,x10/**,x10bc/**,x10cpp/**,x10c/**,x10cuda/**,data/**" excludes="${jar}"/> <fileset id="constraints.classes" dir="${x10.constraints.location}/classes" includes="x10/constraint/**" excludes="x10/constraint/test/**"/> <fileset id="common.classes" dir="${x10.common.location}/classes" includes="x10/**"/> <uptodate property="compiler.uptodate" targetfile="${build}/${jar}"> @@ -80,7 +90,7 @@ <fileset refid="compiler.classes"/> <fileset refid="constraints.classes"/> <fileset refid="common.classes"/> - <!--<fileset dir="${build}" includes="org/**,x10/**,x10cpp/**,x10c/**,x10cuda/**,data/**" excludes="${jar}"/>--> + <!--<fileset dir="${build}" includes="org/**,x10/**,x10bc/**,x10cpp/**,x10c/**,x10cuda/**,data/**" excludes="${jar}"/>--> <!--<fileset dir="${x10.constraints.location}/classes" includes="x10/constraint/**" excludes="x10/constraint/test/**"/>--> <!--<fileset dir="${x10.common.location}/classes" includes="x10/**"/>--> </jar> @@ -97,7 +107,7 @@ </target> <target name="build" depends="init,prereq-jars"> <echo message="${ant.project.name}: ${ant.file}"/> - <javac destdir="${build}" source="1.5" target="1.5" debug="on" includes="x10/**,x10c/**,x10cpp/**,x10cuda/**" excludes="polyglot/ext/x10/dom/**,polyglot/ext/x10/plugin/**,polyglot/ext/x10/visit/Propagate*AnnotationsVisitor.java"> + <javac destdir="${build}" source="1.5" target="1.5" debug="on" includes="x10/**,x10bc/**,x10c/**,x10cpp/**,x10cuda/**" excludes="polyglot/ext/x10/dom/**,polyglot/ext/x10/plugin/**,polyglot/ext/x10/visit/Propagate*AnnotationsVisitor.java"> <src path="${src}"/> <classpath refid="project.classpath"/> </javac> Added: trunk/x10.compiler/src/x10bc/ExtensionInfo.java =================================================================== --- trunk/x10.compiler/src/x10bc/ExtensionInfo.java (rev 0) +++ trunk/x10.compiler/src/x10bc/ExtensionInfo.java 2010-01-28 08:54:12 UTC (rev 12758) @@ -0,0 +1,64 @@ +package x10bc; + +import polyglot.ast.NodeFactory; +import polyglot.ast.SourceFile; +import polyglot.frontend.AbstractGoal_c; +import polyglot.frontend.Compiler; +import polyglot.frontend.Goal; +import polyglot.frontend.JLScheduler; +import polyglot.frontend.Job; +import polyglot.frontend.Scheduler; +import polyglot.types.TypeSystem; + +/** + * Extension information for ibex extension. + */ +public class ExtensionInfo extends x10.ExtensionInfo { + @Override + protected Scheduler createScheduler() { + return new X10BCScheduler(this); + } + + @Override + public void initCompiler(Compiler compiler) { + getOptions().output_ext = "class"; + super.initCompiler(compiler); + } + + public String compilerName() { + return "x10bc"; + } + + static class X10BCScheduler extends X10Scheduler { + public X10BCScheduler(ExtensionInfo extInfo) { + super(extInfo); + } + + @Override + protected Goal PostCompiled() { + return new AbstractGoal_c("PostCompiled") { + public boolean runTask() { + return true; + } + }.intern(this); + } + + @Override + public Goal CodeGenerated(final Job job) { + final TypeSystem ts = extInfo.typeSystem(); + final NodeFactory nf = extInfo.nodeFactory(); + return new AbstractGoal_c("BCCodeGenerated") { + @Override + public boolean runTask() { + try { + new X10BytecodeTranslator(job, ts, nf).visit((SourceFile) job.ast()); + } + catch (Exception e) { + return false; + } + return true; + } + }.intern(this); + } + } +} Added: trunk/x10.compiler/src/x10bc/X10BytecodeTranslator.java =================================================================== --- trunk/x10.compiler/src/x10bc/X10BytecodeTranslator.java (rev 0) +++ trunk/x10.compiler/src/x10bc/X10BytecodeTranslator.java 2010-01-28 08:54:12 UTC (rev 12758) @@ -0,0 +1,379 @@ +package x10bc; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import polyglot.ast.Call; +import polyglot.ast.ClassBody; +import polyglot.ast.ClassDecl; +import polyglot.ast.ConstructorCall; +import polyglot.ast.Expr; +import polyglot.ast.Expr_c; +import polyglot.ast.Node; +import polyglot.ast.NodeFactory; +import polyglot.ast.SourceFile; +import polyglot.ast.Special; +import polyglot.ast.TopLevelDecl; +import polyglot.ast.TypeNode; +import polyglot.bytecode.rep.IClassGen; +import polyglot.bytecode.rep.ILabel; +import polyglot.bytecode.types.Type; +import polyglot.bytecode.AbstractTranslator; +import polyglot.bytecode.BranchTranslator; +import polyglot.bytecode.BytecodeTranslator; +import polyglot.bytecode.ClassTranslator; +import polyglot.bytecode.ExprTranslator; +import polyglot.bytecode.MethodContext; +import polyglot.bytecode.StmtTranslator; +import polyglot.dispatch.Dispatch; +import polyglot.frontend.Job; +import polyglot.types.ClassDef; +import polyglot.types.ClassType; +import polyglot.types.MethodInstance; +import polyglot.types.Name; +import polyglot.types.QName; +import polyglot.types.SemanticException; +import polyglot.types.TypeSystem; +import polyglot.types.Types; +import polyglot.util.ErrorInfo; +import polyglot.util.InternalCompilerError; +import polyglot.util.Position; + +import x10.ast.ParExpr_c; +import x10.types.X10ClassDef; +import x10.types.X10ClassType; +import x10.types.X10TypeMixin; +import x10.types.X10TypeSystem; +import x10.visit.X10InnerClassRemover; +import x10.visit.X10LocalClassRemover; + +public class X10BytecodeTranslator extends BytecodeTranslator { + + static public class X10ClassTranslator extends ClassTranslator { + public X10ClassTranslator(Job job, TypeSystem ts, NodeFactory nf, BytecodeTranslator bc, ClassDef cd) { + super(job, ts, nf, bc, cd); + } + + public X10ClassTranslator(Job job, TypeSystem ts, NodeFactory nf, BytecodeTranslator bc, ClassDef cd, MethodContext context) { + super(job, ts, nf, bc, cd, context); + } + + public void visitChild(Node s, AbstractTranslator t) { + System.out.println("visit " + s); + new Dispatch.Dispatcher("visit").invoke(t, s); + } + + protected Type typeFromPolyglotTypeV(polyglot.types.Type t) { + return typeFromPolyglotType(t); + } + + protected Type getSuperklass(final ClassDef sym) { + System.out.println(sym.superType()); + if (sym.superType().toString().equals("x10.lang.Object")) { + System.out.println("true"); + System.out.println(Type.typeFromClassName("x10.core.Ref")); + return Type.typeFromClassName("x10.core.Ref"); + } else { + System.out.println("false"); + polyglot.types.ClassType t = (ClassType) Types.get(sym.superType()); + assert ! t.flags().isInterface(); + System.out.println(typeFromPolyglotTypeV(t)); + return typeFromPolyglotTypeV(t); + } + } + + public ClassTranslator newClassTranslator(BytecodeTranslator bc, ClassDef cd) { + return new X10ClassTranslator(job, ts, nf, bc, cd); + } + + public ExprTranslator newExprTranslator(BytecodeTranslator bc, MethodContext context) { + return new X10ExprTranslator(job, ts, nf, bc, context); + } + + public StmtTranslator newStmtTranslator(BytecodeTranslator bc, MethodContext context) { + return new X10StmtTranslator(job, ts, nf, bc, context); + } + } + + static public class X10StmtTranslator extends StmtTranslator { + public X10StmtTranslator(Job job, TypeSystem ts, NodeFactory nf, BytecodeTranslator bc, MethodContext context) { + super(job, ts, nf, bc, context); + } + + public void visitChild(Node s, AbstractTranslator t) { + System.out.println("visit " + s); + new Dispatch.Dispatcher("visit").invoke(t, s); + } + + protected Type typeFromPolyglotTypeV(polyglot.types.Type t) { + return typeFromPolyglotType(t); + } + + public void visit(final ConstructorCall n) { + final int thisIndex = context.getThisIndex(); + + // Call superclass constructors. + il.ALOAD(thisIndex, context.localType(thisIndex), n.position()); + + pushArguments(n.constructorInstance().formalTypes(), n.arguments()); + + Type t; + if (n.kind() == ConstructorCall.THIS) { + System.out.println("THIS"); + t = typeFromPolyglotTypeV(context.currentClass.asType()); + } else if (context.currentClass.superType().toString().equals("x10.lang.Object")) { + System.out.println("true"); + t = Type.typeFromClassName("x10.core.Ref"); + } else { + System.out.println("false"); + t = typeFromPolyglotTypeV(Types.get(context.currentClass.superType())); + } + System.out.println(t); + il.INVOKESPECIAL(t, "<init>", typeof(n.arguments()), Type.VOID, n.position()); + + if (n.kind() == ConstructorCall.SUPER) { + context.fieldInits.appendInstructions(il, context); + } + } + + public ClassTranslator newClassTranslator(BytecodeTranslator bc, ClassDef cd, MethodContext context) { + return new X10ClassTranslator(job, ts, nf, bc, cd, context); + } + + public StmtTranslator newStmtTranslator(BytecodeTranslator bc, MethodContext context) { + return new X10StmtTranslator(job, ts, nf, bc, context); + } + + public ExprTranslator newExprTranslator(BytecodeTranslator bc, MethodContext context) { + return new X10ExprTranslator(job, ts, nf, bc, context); + } + + public BranchTranslator newBranchTranslator(BytecodeTranslator bc, MethodContext context, ILabel branchTarget_, boolean branchOnTrue_) { + return new X10BranchTranslator(job, ts, nf, bc, context, branchTarget_, branchOnTrue_); + } + } + + static public class X10ExprTranslator extends ExprTranslator { + public X10ExprTranslator(Job job, TypeSystem ts, NodeFactory nf, BytecodeTranslator bc, MethodContext context) { + super(job, ts, nf, bc, context); + } + + public void visitChild(Node s, AbstractTranslator t) { + System.out.println("visit " + s); + new Dispatch.Dispatcher("visit").invoke(t, s); + } + + protected Type typeFromPolyglotTypeV(polyglot.types.Type t) { + return typeFromPolyglotType(t); + } + + public void visit(ParExpr_c n) { visitExpr(n.expr()); } + + public void visit(final Call n) { + System.out.println("visit Call " + n); + if (n.target() instanceof Expr) { + visitChild(n.target()); + } + + MethodInstance mi = n.methodInstance(); + System.out.println(mi.name().toString()); + + pushArguments(mi.formalTypes(), n.arguments()); + + if (n.target() instanceof Special && ((Special) n.target()).kind() == Special.SUPER) { + il.INVOKESPECIAL(typeof(mi.container()), mi.name().toString(), typeofTypes(mi.formalTypes()), typeof(mi.returnType()), n.position()); + } + else if (n.target() instanceof TypeNode) { + Type[] args = typeofTypes(mi.formalTypes()); + System.out.println(typeof(mi.container()) + " " + mi.name().toString() + " " + args[0] + (args.length>1?args[1]:"")); + if (typeof(mi.container()).equals(Type.STRING)) { + System.out.println("true1"); + if (mi.name().toString().equals("valueOf")) { + System.out.println("true2"); + if (args[0].isObject()) { + System.out.println("true3"); + args[0] = Type.OBJECT; + } + } + } + il.INVOKESTATIC(typeof(mi.container()), mi.name().toString(), args, typeof(mi.returnType()), n.position()); + } + else if (mi.container().isClass() && mi.container().toClass().flags().isInterface()) { + il.INVOKEINTERFACE(typeof(mi.container()), mi.name().toString(), typeofTypes(mi.formalTypes()), typeof(mi.returnType()), n.position()); + } + else { + il.INVOKEVIRTUAL(typeof(mi.container()), mi.name().toString(), typeofTypes(mi.formalTypes()), typeof(mi.returnType()), n.position()); + } + } + + public void stringify(final Expr n) { + visitChild(n); + try { + TypeSystem ts = n.type().typeSystem(); + MethodInstance mi = ts.findMethod(ts.String(), ts.MethodMatcher(ts.String(), Name.make("valueOf"), Collections.singletonList(n.type()), ts.emptyContext())); + coerce(typeof(n.type()), typeof(mi.formalTypes().get(0)), n.position()); + Type[] args = typeofTypes(mi.formalTypes()); + System.out.println(typeof(mi.container()) + " " + mi.name().toString() + " " + args[0] + (args.length>1?args[1]:"")); + if (typeof(mi.container()).equals(Type.STRING)) { + System.out.println("true1"); + if (mi.name().toString().equals("valueOf")) { + System.out.println("true2"); + if (args[0].isObject()) { + System.out.println("true3"); + args[0] = Type.OBJECT; + } + } + } + il.INVOKESTATIC(typeof(mi.container()), mi.name().toString(), args, typeof(mi.returnType()), n.position()); + } + catch (SemanticException e) { + throw new InternalCompilerError(e); + } + } + + protected void coerce(final Type currentTop, final Type newTop, final Position pos) { + coerce(il, currentTop, newTop, pos); + } + + public ClassTranslator newClassTranslator(BytecodeTranslator bc, ClassDef cd, MethodContext context) { + return new X10ClassTranslator(job, ts, nf, bc, cd, context); + } + + public ExprTranslator newExprTranslator(BytecodeTranslator bc, MethodContext context) { + return new X10ExprTranslator(job, ts, nf, bc, context); + } + + public BranchTranslator newBranchTranslator(BytecodeTranslator bc, MethodContext context, ILabel branchTarget_, boolean branchOnTrue_) { + return new X10BranchTranslator(job, ts, nf, bc, context, branchTarget_, branchOnTrue_); + } + } + + static public class X10BranchTranslator extends BranchTranslator { + public X10BranchTranslator(Job job, TypeSystem ts, NodeFactory nf, BytecodeTranslator bc, MethodContext context, ILabel branchTarget_, boolean branchOnTrue_) { + super(job, ts, nf, bc, context, branchTarget_, branchOnTrue_); + } + + public void visitChild(Node s, AbstractTranslator t) { + System.out.println("visit " + s); + new Dispatch.Dispatcher("visit").invoke(t, s); + } + + public ExprTranslator newExprTranslator(BytecodeTranslator bc, MethodContext context) { + return new X10ExprTranslator(job, ts, nf, bc, context); + } + + public BranchTranslator newBranchTranslator(BytecodeTranslator bc, MethodContext context, ILabel branchTarget_, boolean branchOnTrue_) { + return new X10BranchTranslator(job, ts, nf, bc, context, branchTarget_, branchOnTrue_); + } + } + + public X10BytecodeTranslator(Job job, TypeSystem ts, NodeFactory nf) { + super(job, ts, nf); + } + + private static Type typeFromPolyglotType(polyglot.types.Type t) { + boolean boxPrimitives = true; + if (t.isArray()) + return Type.array(typeFromPolyglotType(t.toArray().base())); + t = X10TypeMixin.baseType(t); + if (t instanceof X10ClassType) { + System.out.println("X10ClassType"); + X10ClassDef cd = ((X10ClassType) t).x10Def(); + String pat = getJavaRep(cd); + if (pat != null) { + if (boxPrimitives) { + String[] s = new String[] { "boolean", "byte", "char", "short", "int", "long", "float", "double" }; + String[] w = new String[] { "java.lang.Boolean", "java.lang.Byte", "java.lang.Character", "java.lang.Short", "java.lang.Integer", "java.lang.Long", "java.lang.Float", "java.lang.Double" }; + for (int i = 0; i < s.length; i++) { + if (pat.equals(s[i])) { + System.out.println("primitive " + s[i]); + pat = w[i]; + break; + } + } + } + System.out.println(cd + " -> " + Type.typeFromClassName(pat)); + return Type.typeFromClassName(pat); + } + System.out.println("no @NativeRep"); + } + System.out.println(t + " => " + Type.typeFromPolyglotType(t)); + return Type.typeFromPolyglotType(t); + } + + private static String getJavaRep(X10ClassDef def) { + return getJavaRepParam(def, 1); + } + + private static String getJavaRTTRep(X10ClassDef def) { + return getJavaRepParam(def, 3); + } + + private static String getJavaRepParam(X10ClassDef def, int i) { + try { + X10TypeSystem xts = (X10TypeSystem) def.typeSystem(); + polyglot.types.Type rep = (polyglot.types.Type) xts.systemResolver().find(QName.make("x10.compiler.NativeRep")); + List<polyglot.types.Type> as = def.annotationsMatching(rep); + for (polyglot.types.Type at : as) { + assertNumberOfInitializers(at, 4); + String lang = getPropertyInit(at, 0); + if (lang != null && lang.equals("java")) { + return getPropertyInit(at, i); + } + } + } + catch (SemanticException e) {} + return null; + } + + private static String getPropertyInit(polyglot.types.Type at, int index) { + at = X10TypeMixin.baseType(at); + if (at instanceof X10ClassType) { + X10ClassType act = (X10ClassType) at; + if (index < act.propertyInitializers().size()) { + Expr e = act.propertyInitializer(index); + if (e.isConstant()) { + Object v = e.constantValue(); + if (v instanceof String) { + return (String) v; + } + } + } + } + return null; + } + + private static void assertNumberOfInitializers(polyglot.types.Type at, int len) { + at = X10TypeMixin.baseType(at); + if (at instanceof X10ClassType) { + X10ClassType act = (X10ClassType) at; + assert len == act.propertyInitializers().size(); + } + } + + public void visit(SourceFile n) { + n = (SourceFile) n.visit(new X10LocalClassRemover(job, ts, nf).context(ts.emptyContext())); + n = (SourceFile) n.visit(new X10InnerClassRemover(job, ts, nf).context(ts.emptyContext())); + + for (TopLevelDecl d : n.decls()) { + if (d instanceof ClassDecl) { + ClassDecl cd = (ClassDecl) d; + ClassDef def = cd.classDef(); + ClassBody body = cd.body(); + IClassGen cg = newClassTranslator(this, def).translateClass(cd, body); + genClass(n, Types.get(def.package_()), cg); + } + } + } + + public ClassTranslator newClassTranslator(BytecodeTranslator bc, ClassDef cd) { + return new X10ClassTranslator(job, ts, nf, bc, cd); + } +} Added: trunk/x10.dist/bin/x10bc =================================================================== --- trunk/x10.dist/bin/x10bc (rev 0) +++ trunk/x10.dist/bin/x10bc 2010-01-28 08:54:12 UTC (rev 12758) @@ -0,0 +1,25 @@ +#!/bin/bash + +# If X10_FROM_SRC is set in your environment, then +# this script will default to using paths that assume +# the standard X10 developer setup and a desire to build from source. +# If it is not set, then the script will use paths that are +# appropriate for a pre-built distribution of x10. + +UNAME=`uname -s` +FILE_SEP='/'; if [[ "$UNAME" = CYGWIN* ]]; then FILE_SEP='\\'; fi +PATH_SEP=':'; if [[ "$UNAME" = CYGWIN* ]]; then PATH_SEP=';'; fi + +prog=$(readlink $0 2>&1) +[ $? -eq 127 -o "$prog" = "" ] && prog="$0" +export X10_DIST="$(cd "$(dirname "$prog")/.." && pwd)" +if [[ "$UNAME" = CYGWIN* ]]; then X10_DIST="$(cygpath -aw "$X10_DIST")"; fi + +[ -z "$X10GC" ] && export X10GC="$X10_DIST" +[ -z "$X10SOURCES" ] && export X10SOURCES="${X10_DIST}/lib/x10.jar" + +export CP_OVERRIDE="${X10_DIST}${FILE_SEP}lib${FILE_SEP}x10c.jar${PATH_SEP}${X10_DIST}${FILE_SEP}classes${PATH_SEP}" +export DEXT="x10bc.ExtensionInfo" + +exec "${X10_DIST}/bin/x10c" "$@" + Property changes on: trunk/x10.dist/bin/x10bc ___________________________________________________________________ Added: svn:executable + * Modified: trunk/x10.dist/bin/x10c.in =================================================================== --- trunk/x10.dist/bin/x10c.in 2010-01-27 21:57:21 UTC (rev 12757) +++ trunk/x10.dist/bin/x10c.in 2010-01-28 08:54:12 UTC (rev 12758) @@ -82,7 +82,7 @@ classpath="${CP_OVERRIDE}" [ -n "$dev" ] && classpath="${classpath}${TOP}${FILE_SEP}..${FILE_SEP}x10.compiler${FILE_SEP}classes${PATH_SEP}${TOP}${FILE_SEP}..${FILE_SEP}x10.runtime${FILE_SEP}classes${PATH_SEP}${TOP}${FILE_SEP}..${FILE_SEP}polyglot3-dev${FILE_SEP}bin${PATH_SEP}${TOP}${FILE_SEP}classes${PATH_SEP}" -classpath="${classpath}${LIB_DIR}${FILE_SEP}x10c.jar${PATH_SEP}${LIB_DIR}${FILE_SEP}x10.jar${PATH_SEP}${LIB_DIR}${FILE_SEP}${POLYGLOT_JAR}${PATH_SEP}${LIB_DIR}${FILE_SEP}${LPG_JAR}${ext_cp}${extra_cp}" +classpath="${classpath}${LIB_DIR}${FILE_SEP}x10c.jar${PATH_SEP}${LIB_DIR}${FILE_SEP}x10.jar${PATH_SEP}${LIB_DIR}${FILE_SEP}${POLYGLOT_JAR}${PATH_SEP}${LIB_DIR}${FILE_SEP}${POLYGLOT_BYTECODE_JAR}${PATH_SEP}${LIB_DIR}${FILE_SEP}${ASM_JAR}${PATH_SEP}${LIB_DIR}${FILE_SEP}${LPG_JAR}${ext_cp}${extra_cp}" # include x10.jar in sourcepath [ -z "$X10SOURCES" ] && export X10SOURCES="${LIB_DIR}${FILE_SEP}x10.jar" Modified: trunk/x10.dist/build.xml =================================================================== --- trunk/x10.dist/build.xml 2010-01-27 21:57:21 UTC (rev 12757) +++ trunk/x10.dist/build.xml 2010-01-28 08:54:12 UTC (rev 12758) @@ -18,6 +18,12 @@ <property name="polyglot.jar" value="polyglot3.jar"/> <property name="polyglot.url" value="http://polyglot-compiler.googlecode.com/svn/trunk/updates/plugins"/> <property name="polyglot.jar.url" value="${polyglot.url}/polyglot3_3.1.1.jar"/> + <property name="polyglot.bytecode.jar" value="polyglot-bytecode.jar"/> + <property name="polyglot.bytecode.url" value="http://polyglot-compiler.googlecode.com/svn/trunk/polyglot.bytecode/lib"/> + <property name="polyglot.bytecode.jar.url" value="${polyglot.bytecode.url}/polyglot-bytecode.jar"/> + <property name="asm.jar" value="asm.jar"/> + <property name="asm.url" value="http://polyglot-compiler.googlecode.com/svn/trunk/polyglot.bytecode/lib"/> + <property name="asm.jar.url" value="${asm.url}/asm-all-3.2.jar"/> <property name="x10.constraints.location" location="${x10.home}/x10.constraints"/> <property name="constraints.jar" value="x10constraints.jar"/> <property name="x10.common.location" location="${x10.home}/x10.common"/> @@ -40,6 +46,12 @@ <condition property="local.polyglot.jar" value="${env.LOCAL_POLYGLOT_JAR}"> <isset property="env.LOCAL_POLYGLOT_JAR"/> </condition> + <condition property="local.polyglot.bytecode.jar" value="${env.LOCAL_POLYGLOT_BYTECODE_JAR}"> + <isset property="env.LOCAL_POLYGLOT_BYTECODE_JAR"/> + </condition> + <condition property="local.asm.jar" value="${env.LOCAL_ASM_JAR}"> + <isset property="env.LOCAL_ASM_JAR"/> + </condition> <condition property="local.lpg.jar" value="${env.LOCAL_LPG_JAR}"> <isset property="env.LOCAL_LPG_JAR"/> </condition> @@ -130,7 +142,33 @@ <fail message="Unable to find ${polyglot.jar}" unless="polyglot.jar.present"/> </target> - <target name="build" depends="init,bin,etc,lpg-jar,ecj-jar,polyglot-jar"> + <target name="polyglot-bytecode-jar" depends="init,polyglot-bytecode-local-jar" unless="local.polyglot.bytecode.jar"> + <mkdir dir="${lib}"/> + <get usetimestamp="true" ignoreerrors="true" src="${polyglot.bytecode.jar.url}" dest="${lib}/${polyglot.bytecode.jar}"/> + <available property="polyglot.bytecode.jar.present" file="${lib}/${polyglot.bytecode.jar}"/> + <fail message="Unable to get ${polyglot.bytecode.jar}" unless="polyglot.bytecode.jar.present"/> + </target> + <target name="polyglot-bytecode-local-jar" depends="init" if="local.polyglot.bytecode.jar"> + <mkdir dir="${lib}"/> + <copy file="${local.polyglot.bytecode.jar}" tofile="${lib}/${polyglot.bytecode.jar}"/> + <available property="polyglot.bytecode.jar.present" file="${lib}/${polyglot.bytecode.jar}"/> + <fail message="Unable to find ${polyglot.bytecode.jar}" unless="polyglot.bytecode.jar.present"/> + </target> + + <target name="asm-jar" depends="init,asm-local-jar" unless="local.asm.jar"> + <mkdir dir="${lib}"/> + <get usetimestamp="true" ignoreerrors="true" src="${asm.jar.url}" dest="${lib}/${asm.jar}"/> + <available property="asm.jar.present" file="${lib}/${asm.jar}"/> + <fail message="Unable to get ${asm.jar}" unless="asm.jar.present"/> + </target> + <target name="asm-local-jar" depends="init" if="local.asm.jar"> + <mkdir dir="${lib}"/> + <copy file="${local.asm.jar}" tofile="${lib}/${asm.jar}"/> + <available property="asm.jar.present" file="${lib}/${asm.jar}"/> + <fail message="Unable to find ${asm.jar}" unless="asm.jar.present"/> + </target> + + <target name="build" depends="init,bin,etc,lpg-jar,ecj-jar,polyglot-jar,polyglot-bytecode-jar,asm-jar"> <echo message="${ant.project.name}: ${ant.file}"/> </target> @@ -281,9 +319,13 @@ #PATH_SEP='${path.separator}' #CONFIG_FILE='${config}' POLYGLOT_JAR='${polyglot.jar}' +POLYGLOT_BYTECODE_JAR='${polyglot.bytecode.jar}' +ASM_JAR='${asm.jar}' LPG_JAR='${lpg.jar}' ECJ_JAR='${ecj.jar}' POLYGLOT_URL='${polyglot.jar.url}' +POLYGLOT_BYTECODE_URL='${polyglot.bytecode.jar.url}' +ASM_URL='${asm.jar.url}' LPG_URL='${lpg.jar.url}' ECJ_URL='${ecj.jar.url}' @@ -423,7 +465,7 @@ <zip destfile="${src.zip.location}/x10-${src.zip.version}.zip"> <zipfileset prefix="" dir="${basedir}" includes="epl-v10.html,RELEASE.NOTES,BUILD"/> <zipfileset prefix="" dir="${x10.tests.location}" includes="TESTING"/> - <zipfileset prefix="x10.dist" dir="${basedir}" excludes="releng/**,**/.*.swp,lib/**,etc/**" includes=".launchConfigs/*,.classpath,.project,README,INSTALL,build*,exportPlugin.xml,bin/*.in,bin/x10c++,lib/${polyglot.jar},lib/${lpg.jar},lib/${ecj.jar},samples/**"/> + <zipfileset prefix="x10.dist" dir="${basedir}" excludes="releng/**,**/.*.swp,lib/**,etc/**" includes=".launchConfigs/*,.classpath,.project,README,INSTALL,build*,exportPlugin.xml,bin/*.in,bin/x10c++,lib/${polyglot.jar},lib/${polyglot.bytecode.jar},lib/${asm.jar},lib/${lpg.jar},lib/${ecj.jar},samples/**"/> <zipfileset prefix="x10.compiler" dir="${x10.compiler.location}" excludes="releng/**,**/.*.swp,classes/**"/> <zipfileset prefix="x10.runtime" dir="${x10.runtime.location}" excludes="releng/**,**/.*.swp,classes/**,src-cpp/gen/**"/> <zipfileset prefix="x10.constraints" dir="${x10.constraints.location}" excludes="releng/**,**/.*.swp,classes/**"/> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ta...@us...> - 2010-02-08 16:03:13
|
Revision: 12824 http://x10.svn.sourceforge.net/x10/?rev=12824&view=rev Author: tardieu Date: 2010-02-08 16:02:44 +0000 (Mon, 08 Feb 2010) Log Message: ----------- miror r12817 for java backend: permit native instance methods to refer to type parameters of enclosing class removed dummy type parameter of copyTo/From methods Modified Paths: -------------- trunk/x10.compiler/src/x10/emitter/Emitter.java trunk/x10.compiler/src/x10/visit/X10PrettyPrinterVisitor.java trunk/x10.runtime/src-x10/x10/lang/Rail.x10 trunk/x10.runtime/src-x10/x10/lang/System.x10 trunk/x10.runtime/src-x10/x10/util/DistributedRail.x10 Modified: trunk/x10.compiler/src/x10/emitter/Emitter.java =================================================================== --- trunk/x10.compiler/src/x10/emitter/Emitter.java 2010-02-08 11:57:05 UTC (rev 12823) +++ trunk/x10.compiler/src/x10/emitter/Emitter.java 2010-02-08 16:02:44 UTC (rev 12824) @@ -4,6 +4,7 @@ import java.io.InputStream; import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; @@ -988,7 +989,7 @@ String pat = getJavaImplForDef(md.x10Def()); if (pat != null) { String target = "this"; - emitNativeAnnotation(pat, target, md.typeParameters(), dispatchArgs); + emitNativeAnnotation(pat, target, md.typeParameters(), dispatchArgs, Collections.<Type>emptyList()); w.write("; }"); return; } @@ -1124,8 +1125,8 @@ * object for B #7 = a #8 = b */ public void emitNativeAnnotation(String pat, Object target, - List<Type> types, List<? extends Object> args) { - Object[] components = new Object[1 + types.size() * 3 + args.size()]; + List<Type> types, List<? extends Object> args, List<Type> typeArguments) { + Object[] components = new Object[1 + types.size() * 3 + args.size() + typeArguments.size() * 3]; int i = 0; components[i++] = target; for (Type at : types) { @@ -1136,6 +1137,11 @@ for (Object e : args) { components[i++] = e; } + for (Type at : typeArguments) { + components[i++] = new TypeExpander(this, at, true, false, false); + components[i++] = new TypeExpander(this, at, true, true, false); + components[i++] = new RuntimeTypeExpander(this, at); + } this.dumpRegex("Native", components, tr, pat); } Modified: trunk/x10.compiler/src/x10/visit/X10PrettyPrinterVisitor.java =================================================================== --- trunk/x10.compiler/src/x10/visit/X10PrettyPrinterVisitor.java 2010-02-08 11:57:05 UTC (rev 12823) +++ trunk/x10.compiler/src/x10/visit/X10PrettyPrinterVisitor.java 2010-02-08 16:02:44 UTC (rev 12824) @@ -931,7 +931,12 @@ if (needsHereCheck && ! (target instanceof TypeNode || target instanceof New)) { tmp = new Template(er, "place-check", new TypeExpander(er, target.type(), true, false, false), target); } - er.emitNativeAnnotation(pat, null == tmp ? target : tmp, mi.typeParameters(), c.arguments()); + List<Type> typeArguments = Collections.<Type>emptyList(); + if (mi.container().isClass() && !mi.flags().isStatic()) { + X10ClassType ct = (X10ClassType) mi.container().toClass(); + typeArguments = ct.typeArguments(); + } + er.emitNativeAnnotation(pat, null == tmp ? target : tmp, mi.typeParameters(), c.arguments(), typeArguments); return; } @@ -1403,7 +1408,7 @@ String pat = er.getJavaImplForDef(mi.x10Def()); if (pat != null) { - er.emitNativeAnnotation(pat, null == tmp ? array : tmp, mi.typeParameters(), args); + er.emitNativeAnnotation(pat, null == tmp ? array : tmp, mi.typeParameters(), args, Collections.<Type>emptyList()); return; } else { // otherwise emit the hardwired code. Modified: trunk/x10.runtime/src-x10/x10/lang/Rail.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Rail.x10 2010-02-08 11:57:05 UTC (rev 12823) +++ trunk/x10.runtime/src-x10/x10/lang/Rail.x10 2010-02-08 16:02:44 UTC (rev 12824) @@ -100,70 +100,60 @@ // Transfer functions - @Native("java", "x10.lang.System.copyTo(#3, #0,#4,#5,#6,#7)") - @Native("c++", "(#0)->copyTo(#4,#5,#6,#7)") - // U must be T. hack to get the type info. - public native def copyTo[U] (src_off:Int, dst:Rail[U], dst_off:Int, len:Int) : Void; + @Native("java", "x10.lang.System.copyTo(#7, #0,#1,#2,#3,#4)") + @Native("c++", "(#0)->copyTo(#1,#2,#3,#4)") + public native def copyTo (src_off:Int, dst:Rail[T], dst_off:Int, len:Int) : Void; - @Native("java", "x10.lang.System.copyTo(#3, #0,#4,#5,#6,#7)") - @Native("c++", "(#0)->copyTo(#4,#5,#6,#7)") - // U must be T. hack to get the type info. - public native def copyTo[U] (src_off:Int, - dst_place:Place, dst_finder:()=>Pair[Rail[U],Int], - len:Int) : Void; + @Native("java", "x10.lang.System.copyTo(#7, #0,#1,#2,#3,#4)") + @Native("c++", "(#0)->copyTo(#1,#2,#3,#4)") + public native def copyTo (src_off:Int, + dst_place:Place, dst_finder:()=>Pair[Rail[T],Int], + len:Int) : Void; - @Native("java", "x10.lang.System.copyTo(#3, #0,#4,#5,#6,#7,#8)") - @Native("c++", "(#0)->copyTo(#4,#5,#6,#7,#8)") - // U must be T. hack to get the type info. - public native def copyTo[U] (src_off:Int, - dst_place:Place, dst_finder:()=>Pair[Rail[U],Int], - len:Int, notifier:()=>Void) : Void; + @Native("java", "x10.lang.System.copyTo(#8, #0,#1,#2,#3,#4,#5)") + @Native("c++", "(#0)->copyTo(#1,#2,#3,#4,#5)") + public native def copyTo (src_off:Int, + dst_place:Place, dst_finder:()=>Pair[Rail[T],Int], + len:Int, notifier:()=>Void) : Void; - @Native("java", "x10.lang.System.copyTo(#3, #0,#4,#5,#6,#7,#8)") - @Native("c++", "x10::lang::System::copyTo(#0,#4,#5,#6,#7,#8)") - // U must be T. hack to get the type info. - public native def copyTo[U] (src_off:Int, - dst_place:Place, dst_handle:PlaceLocalHandle[Rail[U]], dst_off:Int, - len:Int) : Void; + @Native("java", "x10.lang.System.copyTo(#8, #0,#1,#2,#3,#4,#5)") + @Native("c++", "x10::lang::System::copyTo(#0,#1,#2,#3,#4,#5)") + public native def copyTo (src_off:Int, + dst_place:Place, dst_handle:PlaceLocalHandle[Rail[T]], dst_off:Int, + len:Int) : Void; - @Native("java", "x10.lang.System.copyTo(#3, #0,#4,#5,#6,#7,#8,#9)") - @Native("c++", "x10::lang::System::copyTo(#0,#4,#5,#6,#7,#8,#9)") - // U must be T. hack to get the type info. - public native def copyTo[U] (src_off:Int, - dst_place:Place, dst_handle:PlaceLocalHandle[Rail[U]], dst_off:Int, - len:Int, notifier:()=>Void) : Void; + @Native("java", "x10.lang.System.copyTo(#9, #0,#1,#2,#3,#4,#5,#6)") + @Native("c++", "x10::lang::System::copyTo(#0,#1,#2,#3,#4,#5,#6)") + public native def copyTo (src_off:Int, + dst_place:Place, dst_handle:PlaceLocalHandle[Rail[T]], dst_off:Int, + len:Int, notifier:()=>Void) : Void; - @Native("java", "x10.lang.System.copyTo(#3 #0,#4,#5,#6,#7,#8)") - @Native("c++", "x10::lang::System::copyTo(#0,#4,#5,#6,#7,#8)") - // U must be T. hack to get the type info. - public native def copyTo[U] (src_off:Int, dst:Rail[U], dst_off:Int, - len:Int, notifier:()=>Void) : Void; + @Native("java", "x10.lang.System.copyTo(#8 #0,#1,#2,#3,#4,#5)") + @Native("c++", "x10::lang::System::copyTo(#0,#1,#2,#3,#4,#5)") + public native def copyTo (src_off:Int, dst:Rail[T], dst_off:Int, + len:Int, notifier:()=>Void) : Void; - @Native("java", "x10.lang.System.copyFrom(#3, #0,#4,#5,#6,#7)") - @Native("c++", "(#0)->copyFrom(#4,#5,#6,#7)") - // U must be T. hack to get the type info. - public native def copyFrom[U] (dst_off:Int, src:Rail[U], src_off:Int, len:Int) : Void; + @Native("java", "x10.lang.System.copyFrom(#7, #0,#1,#2,#3,#4)") + @Native("c++", "(#0)->copyFrom(#1,#2,#3,#4)") + public native def copyFrom (dst_off:Int, src:Rail[T], src_off:Int, len:Int) : Void; - @Native("java", "x10.lang.System.copyFrom(#3, #0,#4,#5,#6,#7)") - @Native("c++", "(#0)->copyFrom(#4,#5,#6,#7)") - // U must be T. hack to get the type info. - public native def copyFrom[U] (dst_off:Int, - src_place:Place, src_finder:()=>Pair[Rail[U],Int], - len:Int) : Void; + @Native("java", "x10.lang.System.copyFrom(#7, #0,#1,#2,#3,#4)") + @Native("c++", "(#0)->copyFrom(#1,#2,#3,#4)") + public native def copyFrom (dst_off:Int, + src_place:Place, src_finder:()=>Pair[Rail[T],Int], + len:Int) : Void; - @Native("java", "x10.lang.System.copyFrom(#3, #0,#4,#5,#6,#7)") - @Native("c++", "(#0)->copyFrom(#4,#5,#6,#7)") - // U must be T. hack to get the type info. - public native def copyFrom[U] (dst_off:Int, src:ValRail[U], src_off:Int, len:Int):Void; + @Native("java", "x10.lang.System.copyFrom(#7, #0,#1,#2,#3,#4)") + @Native("c++", "(#0)->copyFrom(#1,#2,#3,#4)") + public native def copyFrom (dst_off:Int, src:ValRail[T], src_off:Int, len:Int):Void; - @Native("java", "x10.lang.System.copyFrom(#3, #0,#4,#5,#6,#7)") - @Native("c++", "(#0)->copyFrom(#4,#5,#6,#7)") - // U must be T. hack to get the type info. - public native def copyFrom[U] (dst_off:Int, - src_place:Place, src_finder:()=>Pair[ValRail[U],Int], - len:Int) : Void; + @Native("java", "x10.lang.System.copyFrom(#7, #0,#1,#2,#3,#4)") + @Native("c++", "(#0)->copyFrom(#1,#2,#3,#4)") + public native def copyFrom (dst_off:Int, + src_place:Place, src_finder:()=>Pair[ValRail[T],Int], + len:Int) : Void; - @Native("java", "#0.view()") + @Native("java", "#0.view()") @Native("c++", "#0->view()") public native def view(): ValRail[T]{self.length==this.length}; Modified: trunk/x10.runtime/src-x10/x10/lang/System.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/System.x10 2010-02-08 11:57:05 UTC (rev 12823) +++ trunk/x10.runtime/src-x10/x10/lang/System.x10 2010-02-08 16:02:44 UTC (rev 12824) @@ -245,7 +245,7 @@ dst_place:Place, dst_handle:PlaceLocalHandle[Rail[T]]!, dst_off:Int, len:Int) { val finder = ()=> Pair[Rail[T],Int](dst_handle(), dst_off); - src.copyTo[T](src_off, dst_place, finder, len); + src.copyTo(src_off, dst_place, finder, len); Runtime.dealloc(finder); } @@ -267,7 +267,7 @@ dst:Place, dst_handle:PlaceLocalHandle[Rail[T]]!, dst_off:Int, len:Int, notifier:()=>Void) { val finder = ()=> Pair[Rail[T],Int](dst_handle(), dst_off); - src.copyTo[T](src_off, dst, finder, len, notifier); + src.copyTo(src_off, dst, finder, len, notifier); Runtime.dealloc(finder); Runtime.dealloc(notifier); } @@ -287,7 +287,7 @@ public static def copyTo[T](handle:PlaceLocalHandle[Rail[T]]!, dst_place:Place, len:Int, notifier:()=>Void) { val finder = ()=>Pair[Rail[T],Int](handle(), 0); - handle().copyTo[T](0, dst_place, finder, len, notifier); + handle().copyTo(0, dst_place, finder, len, notifier); Runtime.dealloc(finder); Runtime.dealloc(notifier); } @@ -306,7 +306,7 @@ public static def copyTo[T](src:Rail[T]!, src_off:Int, dst:Rail[T], dst_off:Int, len:Int, notifier:()=>Void) { val finder = ()=>Pair[Rail[T],Int](dst,dst_off); - src.copyTo[T](src_off, dst.home, finder, len, notifier); + src.copyTo(src_off, dst.home, finder, len, notifier); Runtime.dealloc(finder); Runtime.dealloc(notifier); } Modified: trunk/x10.runtime/src-x10/x10/util/DistributedRail.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/util/DistributedRail.x10 2010-02-08 11:57:05 UTC (rev 12823) +++ trunk/x10.runtime/src-x10/x10/util/DistributedRail.x10 2010-02-08 16:02:44 UTC (rev 12824) @@ -86,7 +86,7 @@ } next; // every place has transmitted contents to master val handle = data; // avoid 'this' being serialised - finish local_.copyFrom[T](0, firstPlace, ()=>Pair[Rail[T],Int](handle(),0), local_.length); + finish local_.copyFrom(0, firstPlace, ()=>Pair[Rail[T],Int](handle(),0), local_.length); } else { next; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ta...@us...> - 2010-02-08 17:09:13
|
Revision: 12826 http://x10.svn.sourceforge.net/x10/?rev=12826&view=rev Author: tardieu Date: 2010-02-08 17:08:57 +0000 (Mon, 08 Feb 2010) Log Message: ----------- added experimental annotation to request an object to be stack allocated (actual stack allocation is not implemented yet) Modified Paths: -------------- trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java Added Paths: ----------- trunk/x10.runtime/src-x10/x10/compiler/StackAllocate.x10 Modified: trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java =================================================================== --- trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java 2010-02-08 16:28:01 UTC (rev 12825) +++ trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java 2010-02-08 17:08:57 UTC (rev 12826) @@ -3206,6 +3206,14 @@ X10TypeSystem xts = (X10TypeSystem)context.typeSystem(); ConstructorInstance constructor = n.constructorInstance(); + // TODO: implement @StackAllocate + try { + Type annotation = (Type) xts.systemResolver().find(QName.make("x10.compiler.StackAllocate")); + if (!((X10Ext) n.ext()).annotationMatching(annotation).isEmpty()) { + System.err.println("@StackAllocate " + n); + } + } catch (SemanticException e) {} + if (n.qualifier() != null) throw new InternalCompilerError("Qualified new not supported"); if (n.body() != null) Added: trunk/x10.runtime/src-x10/x10/compiler/StackAllocate.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/compiler/StackAllocate.x10 (rev 0) +++ trunk/x10.runtime/src-x10/x10/compiler/StackAllocate.x10 2010-02-08 17:08:57 UTC (rev 12826) @@ -0,0 +1,17 @@ +/* + * + * (C) Copyright IBM Corporation 2006-2008. + * + * This file is part of X10 Language. + * + */ + +package x10.compiler; + +import x10.lang.annotations.ExpressionAnnotation; + +/** An annotation on "new" that requests the compiler to stack allocate the object + * EXPERIMENTAL + * @author Olivier Tardieu + */ +public interface StackAllocate extends ExpressionAnnotation { } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ipe...@us...> - 2010-02-10 20:58:08
|
Revision: 12851 http://x10.svn.sourceforge.net/x10/?rev=12851&view=rev Author: ipeshansky Date: 2010-02-10 20:58:02 +0000 (Wed, 10 Feb 2010) Log Message: ----------- WIP: More Cygwin dynamic library build fixes. The dynamic libraries for libx10 and libx10rt are built, but not the proper import libraries, so the post-compiler picks up the static ones. Modified Paths: -------------- trunk/x10.dist/bin/runx10 trunk/x10.runtime/Make.rules trunk/x10.runtime/src-cpp/Makefile trunk/x10.runtime/x10rt/include/x10rt_front.h trunk/x10.runtime/x10rt/include/x10rt_types.h Property Changed: ---------------- trunk/x10.runtime/src-cpp/ Modified: trunk/x10.dist/bin/runx10 =================================================================== --- trunk/x10.dist/bin/runx10 2010-02-10 19:22:29 UTC (rev 12850) +++ trunk/x10.dist/bin/runx10 2010-02-10 20:58:02 UTC (rev 12851) @@ -3,6 +3,10 @@ # Can also be used to invoke valgrind, gdb, etc # Should work on Cygwin, Linux, Darwin, AIX +prog="$(readlink $0 2>&1)" +[ $? -eq 127 -o "$prog" = "" ] && prog="$0" +TOP="$(cd "$(dirname $prog)/.." && pwd)" + PATH="$PATH:." if [ "`uname -s`" = "AIX" ] ; then @@ -28,5 +32,11 @@ else export MP_CHILD=0 MP_PROCS=1 fi + + # Cygwin: add x10.dist/lib to PATH to pick up the shared libs + if [[ "`uname -s`" = CYGWIN* ]] ; then + export PATH="$PATH:$TOP/lib" + fi + exec "$@" fi Modified: trunk/x10.runtime/Make.rules =================================================================== --- trunk/x10.runtime/Make.rules 2010-02-10 19:22:29 UTC (rev 12850) +++ trunk/x10.runtime/Make.rules 2010-02-10 20:58:02 UTC (rev 12851) @@ -128,7 +128,7 @@ else ifeq ($(firstword $(subst _, ,$(shell uname -s))),CYGWIN) export X10RT_PLATFORM=cygwin - override CXXFLAGS_SHARED += -shared + override CXXFLAGS_SHARED += -shared -Wl,--export-all-symbols -Wl,--enable-auto-import LIBPREFIX := LIBSUFFIX := .dll else Property changes on: trunk/x10.runtime/src-cpp ___________________________________________________________________ Modified: svn:ignore - bdwgc gen depend.mk libx10rt17.a libx10lib17.a libx10lib17.mft libx10.a libx10.mft + bdwgc gen depend.mk libx10.a libx10.mft x10.dll Modified: trunk/x10.runtime/src-cpp/Makefile =================================================================== --- trunk/x10.runtime/src-cpp/Makefile 2010-02-10 19:22:29 UTC (rev 12850) +++ trunk/x10.runtime/src-cpp/Makefile 2010-02-10 20:58:02 UTC (rev 12851) @@ -21,7 +21,11 @@ # Targets # ########### -XRX_ARCHIVE = libx10.so +XRX_ARCHIVE = $(LIBPREFIX)x10$(LIBSUFFIX) +ifeq ($(X10RT_PLATFORM),cygwin) + +XRX_DEP_LIBS = -L../x10rt/lib -lx10rt_pgas_sockets +endif XRX_MANIFEST = libx10.mft # this builds everything @@ -150,7 +154,8 @@ $(XRX_ARCHIVE): gen/all-o-generated $(XRX_MANIFEST) $(ALL_MANUAL_OBJECTS) $(CXX) $(CXXFLAGS) $(CXXFLAGS_SHARED) -o $@ \ $(shell sed -e 's@^\(.*\)\.cc$$@gen/\1.o@' -e '/\.x10$$/d' -e '/\.jar$$/d' $(XRX_MANIFEST)) \ - $(ALL_MANUAL_OBJECTS) + $(ALL_MANUAL_OBJECTS) \ + $(XRX_DEP_LIBS) # The dummy files are needed to avoid rebuilds so must not be removed as # intermediate files usually are. Modified: trunk/x10.runtime/x10rt/include/x10rt_front.h =================================================================== --- trunk/x10.runtime/x10rt/include/x10rt_front.h 2010-02-10 19:22:29 UTC (rev 12850) +++ trunk/x10.runtime/x10rt/include/x10rt_front.h 2010-02-10 20:58:02 UTC (rev 12851) @@ -2,51 +2,51 @@ #include <x10rt_types.h> -EXPORT void x10rt_init (int &argc, char **&argv); +void x10rt_init (int &argc, char **&argv); -EXPORT x10rt_msg_type x10rt_register_msg_receiver (x10rt_handler *cb, - x10rt_cuda_pre *pre, x10rt_cuda_post *post, - const char *cubin, const char *kernel_name); +x10rt_msg_type x10rt_register_msg_receiver (x10rt_handler *cb, + x10rt_cuda_pre *pre, x10rt_cuda_post *post, + const char *cubin, const char *kernel_name); -EXPORT x10rt_msg_type x10rt_register_get_receiver (x10rt_finder *cb1, x10rt_notifier *cb2, - x10rt_finder *cuda_cb1, x10rt_notifier *cuda_cb2); +x10rt_msg_type x10rt_register_get_receiver (x10rt_finder *cb1, x10rt_notifier *cb2, + x10rt_finder *cuda_cb1, x10rt_notifier *cuda_cb2); -EXPORT x10rt_msg_type x10rt_register_put_receiver (x10rt_finder *cb1, x10rt_notifier *cb2, - x10rt_finder *cuda_cb1, x10rt_notifier *cuda_cb2); +x10rt_msg_type x10rt_register_put_receiver (x10rt_finder *cb1, x10rt_notifier *cb2, + x10rt_finder *cuda_cb1, x10rt_notifier *cuda_cb2); -EXPORT void x10rt_registration_complete (void); +void x10rt_registration_complete (void); -EXPORT x10rt_place x10rt_nplaces (void); -EXPORT x10rt_place x10rt_nhosts (void); -EXPORT x10rt_place x10rt_here (void); -EXPORT bool x10rt_is_host (x10rt_place place); -EXPORT bool x10rt_is_cuda (x10rt_place place); -EXPORT bool x10rt_is_spe (x10rt_place place); -EXPORT x10rt_place x10rt_parent (x10rt_place place); -EXPORT x10rt_place x10rt_nchildren (x10rt_place place); -EXPORT x10rt_place x10rt_child (x10rt_place host, x10rt_place index); -EXPORT x10rt_place x10rt_child_index (x10rt_place child); +x10rt_place x10rt_nplaces (void); +x10rt_place x10rt_nhosts (void); +x10rt_place x10rt_here (void); +bool x10rt_is_host (x10rt_place place); +bool x10rt_is_cuda (x10rt_place place); +bool x10rt_is_spe (x10rt_place place); +x10rt_place x10rt_parent (x10rt_place place); +x10rt_place x10rt_nchildren (x10rt_place place); +x10rt_place x10rt_child (x10rt_place host, x10rt_place index); +x10rt_place x10rt_child_index (x10rt_place child); -EXPORT void *x10rt_msg_realloc (void *old, size_t old_sz, size_t new_sz); -EXPORT void x10rt_send_msg (x10rt_msg_params &); +void *x10rt_msg_realloc (void *old, size_t old_sz, size_t new_sz); +void x10rt_send_msg (x10rt_msg_params &); -EXPORT void *x10rt_get_realloc (void *old, size_t old_sz, size_t new_sz); -EXPORT void x10rt_send_get (x10rt_msg_params &, void *buf, x10rt_copy_sz len); +void *x10rt_get_realloc (void *old, size_t old_sz, size_t new_sz); +void x10rt_send_get (x10rt_msg_params &, void *buf, x10rt_copy_sz len); -EXPORT void *x10rt_put_realloc (void *old, size_t old_sz, size_t new_sz); -EXPORT void x10rt_send_put (x10rt_msg_params &, void *buf, x10rt_copy_sz len); +void *x10rt_put_realloc (void *old, size_t old_sz, size_t new_sz); +void x10rt_send_put (x10rt_msg_params &, void *buf, x10rt_copy_sz len); -EXPORT x10rt_remote_ptr x10rt_remote_alloc (x10rt_place place, x10rt_remote_ptr sz); -EXPORT void x10rt_remote_free (x10rt_place place, x10rt_remote_ptr ptr); +x10rt_remote_ptr x10rt_remote_alloc (x10rt_place place, x10rt_remote_ptr sz); +void x10rt_remote_free (x10rt_place place, x10rt_remote_ptr ptr); -EXPORT void x10rt_remote_xor (x10rt_place place, x10rt_remote_ptr addr, long long update); +void x10rt_remote_xor (x10rt_place place, x10rt_remote_ptr addr, long long update); -EXPORT void x10rt_remote_op_fence (void); +void x10rt_remote_op_fence (void); -EXPORT void x10rt_blocks_threads (x10rt_place d, x10rt_msg_type type, int dyn_shm, - int &blocks, int &threads, const int *cfg); +void x10rt_blocks_threads (x10rt_place d, x10rt_msg_type type, int dyn_shm, + int &blocks, int &threads, const int *cfg); -EXPORT void x10rt_probe (void); +void x10rt_probe (void); -EXPORT void x10rt_finalize (void); +void x10rt_finalize (void); Modified: trunk/x10.runtime/x10rt/include/x10rt_types.h =================================================================== --- trunk/x10.runtime/x10rt/include/x10rt_types.h 2010-02-10 19:22:29 UTC (rev 12850) +++ trunk/x10.runtime/x10rt/include/x10rt_types.h 2010-02-10 20:58:02 UTC (rev 12851) @@ -30,10 +30,4 @@ typedef void x10rt_notifier(const x10rt_msg_params &, x10rt_copy_sz); -#ifdef __CYGWIN__ -#define EXPORT __declspec(dllexport) -#else -#define EXPORT #endif - -#endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dgr...@us...> - 2010-02-11 15:20:16
|
Revision: 12860 http://x10.svn.sourceforge.net/x10/?rev=12860&view=rev Author: dgrove-oss Date: 2010-02-11 15:20:10 +0000 (Thu, 11 Feb 2010) Log Message: ----------- Bug fix for struct constructors that pass this to proto methods. Change signatures for struct constructor so it takes a T& instead of a T*. Allows uniform codegen for passing this from both constructors and other instance methods. Modified Paths: -------------- trunk/x10.compiler/src/x10cpp/visit/Emitter.java trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java trunk/x10.runtime/src-cpp/x10/lang/Struct.cc trunk/x10.runtime/src-cpp/x10/lang/Struct.h Modified: trunk/x10.compiler/src/x10cpp/visit/Emitter.java =================================================================== --- trunk/x10.compiler/src/x10cpp/visit/Emitter.java 2010-02-11 13:21:41 UTC (rev 12859) +++ trunk/x10.compiler/src/x10cpp/visit/Emitter.java 2010-02-11 15:20:10 UTC (rev 12860) @@ -788,7 +788,7 @@ h.allowBreak(2, 2, "", 0); h.begin(0); if (container.isX10Struct() && !isMakeMethod) { - h.write(typeName + " *this_"); + h.write(typeName + "& this_"); if (!n.formals().isEmpty()) h.write(", "); } for (Iterator i = n.formals().iterator(); i.hasNext(); ) { Modified: trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java =================================================================== --- trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java 2010-02-11 13:21:41 UTC (rev 12859) +++ trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java 2010-02-11 15:20:10 UTC (rev 12860) @@ -494,7 +494,7 @@ boolean sawInit = false; emitter.printTemplateSignature(currentClass.typeArguments(), sw); if (currentClass.isX10Struct()) { - sw.write(retType + " " + Emitter.structMethodClass(currentClass, true, true) + "::" + methodName + "("+className+" *this_) {"); + sw.write(retType + " " + Emitter.structMethodClass(currentClass, true, true) + "::" + methodName + "("+className+"& this_) {"); } else { sw.write(retType + " " + className + "::" + methodName + "() {"); } @@ -1280,7 +1280,7 @@ if (!members.isEmpty()) { String className = Emitter.translateType(currentClass); - h.write("static "+VOID + " " + INSTANCE_INIT + "("+className+" *this_);"); + h.write("static "+VOID + " " + INSTANCE_INIT + "("+className+"& this_);"); h.newline(); h.forceNewline(); @@ -1973,7 +1973,7 @@ b.allowBreak(0, " "); b.write("{"); b.newline(4); b.begin(0); if (container.isX10Struct()) { b.write(typeName+" this_; "); b.newline(); - b.write(CONSTRUCTOR+"(&this_"); + b.write(CONSTRUCTOR+"(this_"); if (!dec.formals().isEmpty()) b.write(", "); } else { b.write(make_ref(typeName)+" this_ = "+ Modified: trunk/x10.runtime/src-cpp/x10/lang/Struct.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Struct.cc 2010-02-11 13:21:41 UTC (rev 12859) +++ trunk/x10.runtime/src-cpp/x10/lang/Struct.cc 2010-02-11 15:20:10 UTC (rev 12860) @@ -3,11 +3,11 @@ using namespace x10aux; using namespace x10::lang; -void Struct_methods::_instance_init(Struct *this_) { +void Struct_methods::_instance_init(Struct& this_) { _I_("Doing initialisation for class: x10::lang::Struct"); } -void Struct_methods::_constructor(Struct *this_) { +void Struct_methods::_constructor(Struct& this_) { } x10_boolean Struct::_struct_equals(Struct that) { Modified: trunk/x10.runtime/src-cpp/x10/lang/Struct.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Struct.h 2010-02-11 13:21:41 UTC (rev 12859) +++ trunk/x10.runtime/src-cpp/x10/lang/Struct.h 2010-02-11 15:20:10 UTC (rev 12860) @@ -10,8 +10,8 @@ class Struct_methods { public: - static void _instance_init(x10::lang::Struct *this_); - static void _constructor(x10::lang::Struct *this_); + static void _instance_init(x10::lang::Struct& this_); + static void _constructor(x10::lang::Struct& this_); template<class T> static x10::lang::Place home(T v); template<class T> static x10_boolean at(T v, x10aux::ref<x10::lang::Object> p); template<class T> static x10_boolean at(T v, x10::lang::Place p); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ipe...@us...> - 2010-02-12 23:56:20
|
Revision: 12878 http://x10.svn.sourceforge.net/x10/?rev=12878&view=rev Author: ipeshansky Date: 2010-02-12 23:56:14 +0000 (Fri, 12 Feb 2010) Log Message: ----------- Fix XTENLANG-983. Turns out we had stale static libraries that weren't cleaned out. Once the 'clean' rule was updated to get rid of them, the executables are linked against the shared libs. Also updated the BDWGC install rule to copy shared/import libs if present. Modified Paths: -------------- trunk/x10.dist/build.xml trunk/x10.runtime/build.xml trunk/x10.runtime/src-cpp/Makefile Modified: trunk/x10.dist/build.xml =================================================================== --- trunk/x10.dist/build.xml 2010-02-12 23:02:16 UTC (rev 12877) +++ trunk/x10.dist/build.xml 2010-02-12 23:56:14 UTC (rev 12878) @@ -73,6 +73,15 @@ <mkdir dir="${etc}" /> <delete dir="${incdir}" /> <mkdir dir="${incdir}" /> + <delete> <!-- TODO: download jars elsewhere and copy --> + <fileset dir="${lib}"> + <include name="*.a"/> + <include name="*.la"/> + <include name="*.so"/> + <include name="*.dll"/> + <include name="*.mft"/> + </fileset> + </delete> <!-- TODO: remove generated libs, but not downloaded ones <delete dir="${lib}" /> <mkdir dir="${lib}" /> Modified: trunk/x10.runtime/build.xml =================================================================== --- trunk/x10.runtime/build.xml 2010-02-12 23:02:16 UTC (rev 12877) +++ trunk/x10.runtime/build.xml 2010-02-12 23:56:14 UTC (rev 12878) @@ -365,7 +365,9 @@ <sequential> <mkdir dir="${lib}"/> <copy todir="${lib}" preservelastmodified="true" > - <fileset dir="${bdwgc.dir}/install/lib" includes="libgc.a"/> + <!--<fileset dir="${bdwgc.dir}/install/lib" includes="libgc.a"/>--> + <fileset dir="${bdwgc.dir}/install/lib" includes="*.a,*.so,*.la"/> + <fileset dir="${bdwgc.dir}/install/bin" includes="*.dll"/> <!-- Cygwin --> </copy> <copy todir="${inc}"> <fileset dir="${bdwgc.dir}/install/include" includes="**/*.h"/> Modified: trunk/x10.runtime/src-cpp/Makefile =================================================================== --- trunk/x10.runtime/src-cpp/Makefile 2010-02-12 23:02:16 UTC (rev 12877) +++ trunk/x10.runtime/src-cpp/Makefile 2010-02-12 23:56:14 UTC (rev 12878) @@ -23,7 +23,7 @@ XRX_ARCHIVE = $(LIBPREFIX)x10$(LIBSUFFIX) ifeq ($(X10RT_PLATFORM),cygwin) - XRX_DEP_LIBS = -L$(INSTDIR)/lib -lx10rt_pgas_sockets + XRX_DEP_LIBS = -L$(INSTDIR)/lib -lx10rt_pgas_sockets -lgc endif XRX_MANIFEST = libx10.mft This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ipe...@us...> - 2010-02-13 00:07:20
|
Revision: 12879 http://x10.svn.sourceforge.net/x10/?rev=12879&view=rev Author: ipeshansky Date: 2010-02-13 00:07:13 +0000 (Sat, 13 Feb 2010) Log Message: ----------- XTENLANG-369 WIP: Change LineNumberMap to store a full file:line->file:line mapping. Add debug header with debugger data structure declarations. Add code generation of maps in the Toronto Parallel Debugger format. Generate one map per set of C++ files (.cc, .inc, .h). Turn off DEBUG info generation by default. Can be turned back on by using -DEBUG=true. Modified Paths: -------------- trunk/x10.compiler/src/x10/Configuration.java trunk/x10.compiler/src/x10cpp/debug/LineNumberMap.java trunk/x10.compiler/src/x10cpp/debug/StringTable.java trunk/x10.compiler/src/x10cpp/visit/X10CPPTranslator.java trunk/x10.runtime/src-cpp/x10aux/config.h Added Paths: ----------- trunk/x10.runtime/src-cpp/x10aux/debug.cc trunk/x10.runtime/src-cpp/x10aux/debug.h Modified: trunk/x10.compiler/src/x10/Configuration.java =================================================================== --- trunk/x10.compiler/src/x10/Configuration.java 2010-02-12 23:56:14 UTC (rev 12878) +++ trunk/x10.compiler/src/x10/Configuration.java 2010-02-13 00:07:13 UTC (rev 12879) @@ -40,7 +40,7 @@ public static boolean OPTIMIZE = false; private static final String OPTIMIZE_desc = "Generate optimized code"; - public static boolean DEBUG = true; + public static boolean DEBUG = false; private static final String DEBUG_desc = "Generate debug information"; public static boolean NO_CHECKS = false; Modified: trunk/x10.compiler/src/x10cpp/debug/LineNumberMap.java =================================================================== --- trunk/x10.compiler/src/x10cpp/debug/LineNumberMap.java 2010-02-12 23:56:14 UTC (rev 12878) +++ trunk/x10.compiler/src/x10cpp/debug/LineNumberMap.java 2010-02-13 00:07:13 UTC (rev 12879) @@ -1,21 +1,28 @@ package x10cpp.debug; import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.Comparator; import java.util.HashMap; import java.util.List; import java.util.StringTokenizer; +import java.util.TreeSet; import polyglot.types.ConstructorDef; import polyglot.types.MethodDef; import polyglot.types.Ref; import polyglot.types.Type; +import polyglot.util.Pair; import polyglot.util.QuotedStringTokenizer; +import polyglot.util.StringUtil; +import x10.util.ClassifiedStream; import x10cpp.visit.Emitter; /** - * Map from generated line to source line and filename. - * Also stores the C++ filename (String). - * C++ line number (Integer) -> (X10 filename (String), X10 line number (Integer)). + * Map from generated filename and line to source filename and line. + * (C++ filename (String), C++ line number (Integer)) -> + * (X10 filename (String), X10 line number (Integer)). * Also stores the method mapping. * * @author igor @@ -32,8 +39,7 @@ return fileId + ":" + line; } } - private final String filename; - private final HashMap<Integer, Entry> map; + private final HashMap<Pair<Integer, Integer>, Entry> map; private static class MethodDescriptor { public final int returnType; public final int container; @@ -137,50 +143,46 @@ private final HashMap<MethodDescriptor, MethodDescriptor> methods; /** - * @param filename C++ filename */ - public LineNumberMap(String filename) { - this(filename, new ArrayList<String>()); + public LineNumberMap() { + this(new ArrayList<String>()); } - private LineNumberMap(String filename, ArrayList<String> strings) { + private LineNumberMap(ArrayList<String> strings) { super(strings); - this.filename = filename; - this.map = new HashMap<Integer, Entry>(); + this.map = new HashMap<Pair<Integer, Integer>, Entry>(); this.methods = new HashMap<MethodDescriptor, MethodDescriptor>(); } /** - * @return C++ filename - */ - public String file() { return filename; } - - /** + * @param cppFile C++ filename * @param lineNumber C++ line number * @param sourceFile X10 filename * @param sourceLine X10 line number */ - public void put(int lineNumber, String sourceFile, int sourceLine) { - map.put(lineNumber, new Entry(stringId(sourceFile), sourceLine)); + public void put(String cppFile, int lineNumber, String sourceFile, int sourceLine) { + map.put(new Pair<Integer, Integer>(stringId(cppFile), lineNumber), new Entry(stringId(sourceFile), sourceLine)); } /** + * @param cppFile C++ filename * @param lineNumber C++ line number * @return X10 filename */ - public String getSourceFile(int lineNumber) { - Entry entry = map.get(lineNumber); + public String getSourceFile(String cppFile, int lineNumber) { + Entry entry = map.get(new Pair<Integer, Integer>(stringId(cppFile), lineNumber)); if (entry == null) return null; return lookupString(entry.fileId); } /** + * @param cppFile C++ filename * @param lineNumber C++ line number * @return X10 line number */ - public int getSourceLine(int lineNumber) { - Entry entry = map.get(lineNumber); + public int getSourceLine(String cppFile, int lineNumber) { + Entry entry = map.get(new Pair<Integer, Integer>(stringId(cppFile), lineNumber)); if (entry == null) return -1; return entry.line; @@ -250,36 +252,40 @@ public String toString() { final StringBuilder sb = new StringBuilder(); - sb.append(filename).append(":\n"); - for (Integer line : map.keySet()) { - Entry entry = map.get(line); - sb.append(" ").append(line).append("->"); + for (Pair<Integer, Integer> pos : map.keySet()) { + Entry entry = map.get(pos); + sb.append(lookupString(pos.fst())).append(":").append(pos.snd()).append("->"); sb.append(lookupString(entry.fileId)).append(":").append(entry.line).append("\n"); } sb.append("\n"); for (MethodDescriptor md : methods.keySet()) { MethodDescriptor sm = methods.get(md); - sb.append(" ").append(md.toPrettyString(this, true)).append("->"); + sb.append(md.toPrettyString(this, true)).append("->"); sb.append(sm.toPrettyString(this, true)).append("\n"); } return sb.toString(); } + /** + * Is the map empty? + * @return true if the map is empty. + */ public boolean isEmpty() { return map.isEmpty(); } /** * Produces a string suitable for initializing a field in the generated file. + * The resulting string can be parsed by {@link #importMap(String)}. */ public String exportMap() { final StringBuilder sb = new StringBuilder(); - sb.append("N{\"").append(filename).append("\"} F"); + sb.append("F"); exportStringMap(sb); sb.append(" L{"); - for (Integer line : map.keySet()) { - Entry entry = map.get(line); - sb.append(line).append("->"); + for (Pair<Integer, Integer> pos : map.keySet()) { + Entry entry = map.get(pos); + sb.append(pos.fst()).append(":").append(pos.snd()).append("->"); sb.append(entry.fileId).append(":").append(entry.line).append(","); } sb.append("} M{"); @@ -293,21 +299,15 @@ /** * Parses a string into a {@link LineNumberMap}. + * The string is produced by {@link #exportMap()}. * @param input the input string */ public static LineNumberMap importMap(String input) { StringTokenizer st = new QuotedStringTokenizer(input, " ", "\"\'", '\\', true); String s = st.nextToken("{}"); - assert (s.equals("N")); - s = st.nextToken(); - assert (s.equals("{")); - String file = st.nextToken(); - s = st.nextToken(); - assert (s.equals("}")); - s = st.nextToken("{}"); - assert (s.equals(" F")); + assert (s.equals("F")); ArrayList<String> strings = importStringMap(st); - LineNumberMap res = new LineNumberMap(file, strings); + LineNumberMap res = new LineNumberMap(strings); if (!st.hasMoreTokens()) return res; s = st.nextToken("{}"); @@ -315,9 +315,13 @@ s = st.nextToken(); assert (s.equals("{")); while (st.hasMoreTokens()) { - String t = st.nextToken("-}"); + String t = st.nextToken(":}"); if (t.equals("}")) break; + int n = Integer.parseInt(t); + t = st.nextToken(); + assert (t.equals(":")); + t = st.nextToken("-"); int i = Integer.parseInt(t); t = st.nextToken(">"); assert (t.equals("-")); @@ -327,7 +331,7 @@ t = st.nextToken(); assert (t.equals(":")); int l = Integer.parseInt(st.nextToken(",")); - res.map.put(i, new Entry(f, l)); + res.map.put(new Pair<Integer, Integer>(n, i), new Entry(f, l)); t = st.nextToken(); assert (t.equals(",")); } @@ -359,66 +363,278 @@ * Inverts the current map. Creates a full (file,line)->(file,line) map. * @return the resulting inverted map */ - public HashMap<String, LineNumberMap> invert() { - HashMap<String, LineNumberMap> res = new HashMap<String, LineNumberMap>(); - for (Integer line : map.keySet()) { - Entry e = map.get(line); + public LineNumberMap invert() { + LineNumberMap m = new LineNumberMap(); + for (Pair<Integer, Integer> pos : map.keySet()) { + Entry e = map.get(pos); String f = lookupString(e.fileId); int l = e.line; - LineNumberMap m = res.get(f); - if (m == null) - res.put(f, m = new LineNumberMap(f)); - m.put(l, filename, line.intValue()); - } - for (MethodDescriptor md : methods.keySet()) { + m.put(f, l, lookupString(pos.fst()), pos.snd()); + } + for (MethodDescriptor md : methods.keySet()) { MethodDescriptor sm = methods.get(md); - String f = lookupString(0); // FIXME: hack - LineNumberMap m = res.get(f); - if (m == null) - res.put(f, m = new LineNumberMap(f)); MethodDescriptor tmd = m.createMethodDescriptor(lookupString(md.container), lookupString(md.name), lookupString(md.returnType), lookupStrings(md.args)); MethodDescriptor tsm = m.createMethodDescriptor(lookupString(sm.container), lookupString(sm.name), lookupString(sm.returnType), lookupStrings(sm.args)); m.methods.put(tsm, tmd); - } - return res; + } + return m; } /** - * Creates a new map. - * @return new map - */ - public static HashMap<String, LineNumberMap> initMap() { - return new HashMap<String, LineNumberMap>(); - } - - /** * Merges a set of new entries into a given map. Changes the map in place! * @param map the target map (changed in place!) * @param newEntries the set of new entries */ - public static void mergeMap(HashMap<String, LineNumberMap> map, HashMap<String, LineNumberMap> newEntries) { + private static void mergeMap(LineNumberMap map, LineNumberMap newEntries) { assert (map != null); - for (String f : newEntries.keySet()) { - LineNumberMap n = newEntries.get(f); - LineNumberMap m = map.get(f); - if (m == null) - map.put(f, m = new LineNumberMap(f)); - for (int l : n.map.keySet()) { -// assert (!m.map.containsKey(l)); - Entry e = n.map.get(l); - m.put(l, n.lookupString(e.fileId), e.line); - } - for (MethodDescriptor d : n.methods.keySet()) { - assert (!m.methods.containsKey(d)); - MethodDescriptor e = n.methods.get(d); - MethodDescriptor dp = m.createMethodDescriptor(n.lookupString(d.container), - n.lookupString(d.name), n.lookupString(d.returnType), n.lookupStrings(d.args)); - MethodDescriptor ep = m.createMethodDescriptor(n.lookupString(e.container), - n.lookupString(e.name), n.lookupString(e.returnType), n.lookupStrings(e.args)); - m.methods.put(dp, ep); - } + final LineNumberMap m = map; + final LineNumberMap n = newEntries; + for (Pair<Integer, Integer> p : n.map.keySet()) { +// assert (!m.map.containsKey(p)); + Entry e = n.map.get(p); + m.put(n.lookupString(p.fst()), p.snd(), n.lookupString(e.fileId), e.line); } + for (MethodDescriptor d : n.methods.keySet()) { +// if (m.methods.containsKey(d)) +// assert (false) : d.toPrettyString(n)+" already present"; + assert (!m.methods.containsKey(d)) : d.toPrettyString(n)+" already present"; + MethodDescriptor e = n.methods.get(d); + MethodDescriptor dp = m.createMethodDescriptor(n.lookupString(d.container), + n.lookupString(d.name), n.lookupString(d.returnType), n.lookupStrings(d.args)); + MethodDescriptor ep = m.createMethodDescriptor(n.lookupString(e.container), + n.lookupString(e.name), n.lookupString(e.returnType), n.lookupStrings(e.args)); + m.methods.put(dp, ep); + } } + + /** + * Merges a set of maps into a new map. Returns the new map. + * @param maps the set of maps to merge + * @return the newly-created map containing merged entries from maps + */ + public static LineNumberMap mergeMaps(LineNumberMap[] maps) { + LineNumberMap map = new LineNumberMap(); + for (int i = 0; i < maps.length; i++) { + mergeMap(map, maps[i]); + } + return map; + } + + private String[] allFiles() { + TreeSet<String> files = new TreeSet<String>(); + for (Entry e : map.values()) { + files.add(lookupString(e.fileId)); + } + return files.toArray(new String[files.size()]); + } + + private static int findFile(String name, String[] files) { + // files is assumed sorted alphanumerically + return Arrays.binarySearch(files, name); + } + + private static class CPPLineInfo { + public final int x10index; + public final int x10method; + public final int cppindex; + public final int x10line; + public final int cppfromline; + public final int cpptoline; + public CPPLineInfo(int x10index, int x10method, int cppindex, int x10line, int cppfromline) { + this(x10index, x10method, cppindex, x10line, cppfromline, -1); + } + public CPPLineInfo(int x10index, int x10method, int cppindex, int x10line, int cppfromline, int cpptoline) { + this.x10index = x10index; + this.x10method = x10method; + this.cppindex = cppindex; + this.x10line = x10line; + this.cppfromline = cppfromline; + this.cpptoline = cpptoline; + } + public static Comparator<CPPLineInfo> byX10info() { + return new Comparator<CPPLineInfo>() { + public int compare(CPPLineInfo o1, CPPLineInfo o2) { + int index_d = o1.x10index - o2.x10index; + if (index_d != 0) return index_d; + return o1.x10line - o2.x10line; + } + }; + } + public static Comparator<CPPLineInfo> byCPPinfo() { + return new Comparator<CPPLineInfo>() { + public int compare(CPPLineInfo o1, CPPLineInfo o2) { + int index_d = o1.cppindex - o2.cppindex; + if (index_d != 0) return index_d; + return o1.cppfromline - o2.cppfromline; + } + }; + } + } + + private class CPPMethodInfo implements Comparable<CPPMethodInfo> { + public final int x10class; + public final int x10method; + public final int x10rettype; + public final int[] x10args; + public final int cppclass; + public final int cpplineindex; + public CPPMethodInfo(int x10class, int x10method, int x10rettype, int[] x10args, int cppclass, int cpplineindex) { + this.x10class = x10class; + this.x10method = x10method; + this.x10rettype = x10rettype; + this.x10args = x10args; + this.cppclass = cppclass; + this.cpplineindex = cpplineindex; + } + private String concatArgs() { + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < x10args.length; i++) { + sb.append(lookupString(x10args[i])); + } + return sb.toString(); + } + public int compareTo(CPPMethodInfo o) { + int class_d = lookupString(x10class).compareTo(lookupString(o.x10class)); + if (class_d != 0) return class_d; + int name_d = lookupString(x10method).compareTo(lookupString(o.x10method)); + if (name_d != 0) return name_d; + return concatArgs().compareTo(o.concatArgs()); + } + } + + /** + * Generates code for the line number map as required by the Toronto C++ + * Debugger backend into the specified stream. + * @param w the output stream + * @param m the map to export + */ + public static void exportForCPPDebugger(ClassifiedStream w, LineNumberMap m) { + int size = m.size(); + int offset = 0; + int[] offsets = new int[size]; + // All strings, concatenated, with intervening nulls. + w.writeln("static const char _X10strings[] ="); + for (int i = 0; i < size; i++) { + offsets[i] = offset; + String s = m.lookupString(i); + w.writeln(" \""+StringUtil.escape(s)+"\\0\" //"+offsets[i]); + offset += s.length()+1; + } + w.writeln(" \"\";"); + w.forceNewline(); + + if (!m.isEmpty()) { + String[] files = m.allFiles(); + // A list of X10 source files that contributed to the generation of the current C++ file. + w.writeln("static const struct _X10sourceFile _X10sourceList[] = {"); + for (int i = 0; i < files.length; i++) { + w.write(" { "); + w.write(""+0+", "); // FIXME: _numLines + w.write(""+offsets[m.stringId(files[i])]); // _stringIndex + w.writeln(" },"); + } + w.writeln("};"); + w.forceNewline(); + + // A cross reference of X10 statements to the first C++ statement. + // Sorted by X10 file index and X10 source file line. + ArrayList<CPPLineInfo> x10toCPPlist = new ArrayList<CPPLineInfo>(m.map.size()); + for (Pair<Integer, Integer> p : m.map.keySet()) { + Entry e = m.map.get(p); + x10toCPPlist.add( + new CPPLineInfo(findFile(m.lookupString(e.fileId), files), // _X10index + 0, // FIXME: _X10method + offsets[p.fst()], // _CPPindex + e.line, // _X10line + p.snd())); // _CPPline + } + Collections.sort(x10toCPPlist, CPPLineInfo.byX10info()); + w.writeln("static const struct _X10toCPPxref _X10toCPPlist[] = {"); + for (CPPLineInfo cppDebugInfo : x10toCPPlist) { + w.write(" { "); + w.write(""+cppDebugInfo.x10index+", "); // _X10index + w.write(""+cppDebugInfo.x10method+", "); // _X10method + w.write(""+cppDebugInfo.cppindex+", "); // _CPPindex + w.write(""+cppDebugInfo.x10line+", "); // _X10line + w.write(""+cppDebugInfo.cppfromline); // _CPPline + w.writeln(" },"); + } + w.writeln("};"); + w.forceNewline(); + + // A cross reference of C++ statements to X10 statements. + // Sorted by C++ file index and C++ source file line. + // A line range is used to minimize the storage required. + ArrayList<CPPLineInfo> cpptoX10xrefList = new ArrayList<CPPLineInfo>(m.map.size()); + for (Pair<Integer, Integer> p : m.map.keySet()) { + Entry e = m.map.get(p); + cpptoX10xrefList.add( + new CPPLineInfo(findFile(m.lookupString(e.fileId), files), // _X10index + 0, // FIXME: _X10method + offsets[p.fst()], // _CPPindex + e.line, // _X10line + p.snd(), // _CPPfromline + p.snd())); // FIXME: _CPPtoline + } + Collections.sort(cpptoX10xrefList, CPPLineInfo.byCPPinfo()); + w.writeln("static const struct _CPPtoX10xref _CPPtoX10xrefList[] = {"); + for (CPPLineInfo cppDebugInfo : cpptoX10xrefList) { + w.write(" { "); + w.write(""+cppDebugInfo.x10index+", "); // _X10index + w.write(""+cppDebugInfo.x10method+", "); // _X10method + w.write(""+cppDebugInfo.cppindex+", "); // _CPPindex + w.write(""+cppDebugInfo.x10line+", "); // _X10line + w.write(""+cppDebugInfo.cppfromline+", "); // _CPPfromline + w.write(""+cppDebugInfo.cpptoline); // _CPPtoline + w.writeln(" },"); + } + w.writeln("};"); + w.forceNewline(); + } + + if (!m.methods.isEmpty()) { + // A list of the X10 method names. + // Sorted by X10 method name. + ArrayList<CPPMethodInfo> x10MethodList = new ArrayList<CPPMethodInfo>(m.methods.size()); + for (MethodDescriptor md : m.methods.keySet()) { + MethodDescriptor sm = m.methods.get(md); + x10MethodList.add( + m.new CPPMethodInfo(sm.container, // _x10class + sm.name, // _x10method + sm.returnType, // _x10returnType + sm.args, // _x10args + md.container, // _cppClass + 0)); // FIXME: _lineIndex + } + Collections.sort(x10MethodList); + w.writeln("static const struct _X10methodName _X10methodNameList[] = {"); + for (CPPMethodInfo cppMethodInfo : x10MethodList) { + w.write(" { "); + w.write(""+offsets[cppMethodInfo.x10class]+", "); // _x10class + w.write(""+offsets[cppMethodInfo.x10method]+", "); // _x10method + w.write(""+offsets[cppMethodInfo.x10rettype]+", "); // _x10returnType + w.write("(uint64_t) "); + for (int i = 0; i < cppMethodInfo.x10args.length; i++) { + int a = cppMethodInfo.x10args[i]; + w.write("\""+encodeIntAsChars(offsets[a])+"\" "); // _x10args + } + w.write("\"\", "); + w.write(""+offsets[cppMethodInfo.cppclass]+", "); // _cppClass + w.write(""+cppMethodInfo.x10args.length+", "); // _x10argCount + w.write(""+cppMethodInfo.cpplineindex); // _lineIndex + w.writeln(" },"); + } + w.writeln("};"); + } + } + + private static String encodeIntAsChars(int i) { + String b1 = "\\"+Integer.toOctalString((i >> 24) & 0xFF); + String b2 = "\\"+Integer.toOctalString((i >> 16) & 0xFF); + String b3 = "\\"+Integer.toOctalString((i >> 8) & 0xFF); + String b4 = "\\"+Integer.toOctalString((i >> 0) & 0xFF); + return b1+b2+b3+b4; + } } Modified: trunk/x10.compiler/src/x10cpp/debug/StringTable.java =================================================================== --- trunk/x10.compiler/src/x10cpp/debug/StringTable.java 2010-02-12 23:56:14 UTC (rev 12878) +++ trunk/x10.compiler/src/x10cpp/debug/StringTable.java 2010-02-13 00:07:13 UTC (rev 12879) @@ -13,7 +13,7 @@ this.strings = strings; } - protected int stringId(String str) { + public int stringId(String str) { String f = str.intern(); int n = strings.size(); for (int i = 0; i < n; i++) @@ -23,11 +23,11 @@ return n; } - protected String lookupString(int i) { + public String lookupString(int i) { return strings.get(i); } - protected String[] lookupStrings(int[] indices) { + public String[] lookupStrings(int[] indices) { String[] res = new String[indices.length]; for (int i = 0; i < indices.length; i++) { res[i] = lookupString(indices[i]); @@ -35,14 +35,18 @@ return res; } - protected void exportStringMap(final StringBuilder sb) { - sb.append("{"); + public int size() { + return strings.size(); + } + + public void exportStringMap(final StringBuilder sb) { + sb.append("{"); for (int i = 0; i < strings.size(); i++) sb.append(i).append(":\"").append(StringUtil.escape(lookupString(i))).append("\","); // FIXME: might need to escape sb.append("}"); } - protected static ArrayList<String> importStringMap(StringTokenizer st) { + public static ArrayList<String> importStringMap(StringTokenizer st) { ArrayList<String> strings = new ArrayList<String>(); String s = st.nextToken(); assert (s.equals("{")); Modified: trunk/x10.compiler/src/x10cpp/visit/X10CPPTranslator.java =================================================================== --- trunk/x10.compiler/src/x10cpp/visit/X10CPPTranslator.java 2010-02-12 23:56:14 UTC (rev 12878) +++ trunk/x10.compiler/src/x10cpp/visit/X10CPPTranslator.java 2010-02-13 00:07:13 UTC (rev 12879) @@ -262,9 +262,11 @@ HashMap<String, LineNumberMap> fileToLineNumberMap = (HashMap<String, LineNumberMap>) c.findData(FILE_TO_LINE_NUMBER_MAP); if (fileToLineNumberMap!=null) { - final LineNumberMap lineNumberMap = fileToLineNumberMap.get(w.getStreamName(w.currentStream().ext)); + String key = w.getStreamName(StreamWrapper.CC); + final LineNumberMap lineNumberMap = fileToLineNumberMap.get(key); // [DC] avoid NPE when writing to .cu files if (lineNumberMap!=null) { + final String cppFile = w.getStreamName(w.currentStream().ext); if (n instanceof MethodDecl) { lineNumberMap.addMethodMapping(((MethodDecl) n).methodDef()); } @@ -276,7 +278,7 @@ public void run(ClassifiedStream s) { int cppLine = s.getStartLineOffset()+outputLine; // System.out.println("Adding line number entry: "+lineNumberMap.file()+":"+cppLine+"->"+file+":"+line); - lineNumberMap.put(cppLine, file, line); + lineNumberMap.put(cppFile, cppLine, file, line); } }); } @@ -294,9 +296,11 @@ HashMap<String, LineNumberMap> fileToLineNumberMap = (HashMap<String, LineNumberMap>) c.findData(FILE_TO_LINE_NUMBER_MAP); if (fileToLineNumberMap!=null) { - final LineNumberMap lineNumberMap = fileToLineNumberMap.get(w.getStreamName(w.currentStream().ext)); + final String key = w.getStreamName(StreamWrapper.CC); + final LineNumberMap lineNumberMap = fileToLineNumberMap.get(key); // [DC] avoid NPE when writing to .cu files if (lineNumberMap!=null) { + final String cppFile = w.getStreamName(w.currentStream().ext); final int line = n.position().endLine(); final String file = n.position().file(); final int outputLine = w.currentStream().getStreamLineNumber(); @@ -304,7 +308,7 @@ public void run(ClassifiedStream s) { int cppLine = s.getStartLineOffset()+outputLine; // System.out.println("Adding block line number entry: "+lineNumberMap.file()+":"+cppLine+"->"+file+":"+line); - lineNumberMap.put(cppLine, file, line); + lineNumberMap.put(cppFile, cppLine, file, line); } }); } @@ -369,24 +373,27 @@ if (x10.Configuration.DEBUG) { HashMap<String, LineNumberMap> fileToLineNumberMap = (HashMap<String, LineNumberMap>)c.getData(FILE_TO_LINE_NUMBER_MAP); String closures = wstreams.getStreamName(StreamWrapper.Closures); - fileToLineNumberMap.put(closures, new LineNumberMap(closures)); + fileToLineNumberMap.put(closures, new LineNumberMap()); String cc = wstreams.getStreamName(StreamWrapper.CC); - fileToLineNumberMap.put(cc, new LineNumberMap(cc)); + fileToLineNumberMap.put(cc, new LineNumberMap()); String header = wstreams.getStreamName(StreamWrapper.Header); - fileToLineNumberMap.put(header, new LineNumberMap(header)); + fileToLineNumberMap.put(header, new LineNumberMap()); } translateTopLevelDecl(sw, sfn, decl); if (x10.Configuration.DEBUG) { HashMap<String, LineNumberMap> fileToLineNumberMap = (HashMap<String, LineNumberMap>)c.getData(FILE_TO_LINE_NUMBER_MAP); - sw.pushCurrentStream(sw.getNewStream(StreamWrapper.Closures, false)); - printLineNumberMap(sw, pkg, className, StreamWrapper.Closures, fileToLineNumberMap); - sw.popCurrentStream(); +// sw.pushCurrentStream(sw.getNewStream(StreamWrapper.Closures, false)); +// printLineNumberMap(sw, pkg, className, StreamWrapper.Closures, fileToLineNumberMap); +// sw.popCurrentStream(); +// sw.pushCurrentStream(sw.getNewStream(StreamWrapper.CC, false)); +// printLineNumberMap(sw, pkg, className, StreamWrapper.CC, fileToLineNumberMap); +// sw.popCurrentStream(); +// sw.pushCurrentStream(sw.getNewStream(StreamWrapper.CC, false)); +// printLineNumberMap(sw, pkg, className, StreamWrapper.Header, fileToLineNumberMap); +// sw.popCurrentStream(); sw.pushCurrentStream(sw.getNewStream(StreamWrapper.CC, false)); - printLineNumberMap(sw, pkg, className, StreamWrapper.CC, fileToLineNumberMap); + printLineNumberMapForCPPDebugger(sw, fileToLineNumberMap); sw.popCurrentStream(); - sw.pushCurrentStream(sw.getNewStream(StreamWrapper.CC, false)); - printLineNumberMap(sw, pkg, className, StreamWrapper.Header, fileToLineNumberMap); - sw.popCurrentStream(); } if (i.hasNext()) { wstreams.commitStreams(); @@ -421,6 +428,18 @@ } } + private void printLineNumberMapForCPPDebugger(StreamWrapper sw, HashMap<String, LineNumberMap> fileToLineNumberMap) { + final LineNumberMap map = fileToLineNumberMap.get(sw.getStreamName(StreamWrapper.CC)); + sw.currentStream().registerCommitListener(new ClassifiedStream.CommitListener() { + public void run(ClassifiedStream s) { +// if (map.isEmpty()) +// return; + s.forceNewline(); + LineNumberMap.exportForCPPDebugger(s, map); + } + }); + } + private void printLineNumberMap(StreamWrapper sw, String pkg, String className, final String ext, HashMap<String, LineNumberMap> fileToLineNumberMap) { String fName = sw.getStreamName(ext); final LineNumberMap map = fileToLineNumberMap.get(fName); Modified: trunk/x10.runtime/src-cpp/x10aux/config.h =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/config.h 2010-02-12 23:56:14 UTC (rev 12878) +++ trunk/x10.runtime/src-cpp/x10aux/config.h 2010-02-13 00:07:13 UTC (rev 12879) @@ -245,5 +245,8 @@ //combine __FILE__ and __LINE__ without using sprintf or other junk #define __FILELINE__ __FILE__ ":" __TOKEN_STRING_DEREF(__LINE__) +// Debug support +#include <x10aux/debug.h> + #endif // vim:tabstop=4:shiftwidth=4:expandtab Added: trunk/x10.runtime/src-cpp/x10aux/debug.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/debug.cc (rev 0) +++ trunk/x10.runtime/src-cpp/x10aux/debug.cc 2010-02-13 00:07:13 UTC (rev 12879) @@ -0,0 +1,13 @@ +#include <x10aux/debug.h> + +// A hook at the start of every X10 method. +void _X10_Entry_Hook() { } + +// A hook at the end of every X10 method. +void _X10_Exit_Hook() { } + +// A hook at the start of every X10 executable statement. +// Follows any method start hook, and precedes any method end hook. +void _X10_Statement_Hook() { } + +// vim:tabstop=4:shiftwidth=4:expandtab Added: trunk/x10.runtime/src-cpp/x10aux/debug.h =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/debug.h (rev 0) +++ trunk/x10.runtime/src-cpp/x10aux/debug.h 2010-02-13 00:07:13 UTC (rev 12879) @@ -0,0 +1,79 @@ +// +// A list of interfaces agreed upon with the Toronto Parallel Debugger +// team for passing source program information to the C++ debugger +// back-end. +// +// Based on X10LineNumberDebug Design Document Version 2, Jan 25, 2010 +// Updated as agreed with Roger Pett on Feb 11, 2010 +// + +#ifndef X10AUX_DEBUG_H +#define X10AUX_DEBUG_H + +// Each generated C++ file is expected to have the following information: +// +// static const char _X10strings[] = {}; +// // All strings, concatenated, with intervening nulls. +// // e.g., for the strings "aa", "bb", and "cc" , this variable would contain "aa\0bb\0ccc". +// static const struct _X10sourceFile _X10sourceList[]; +// // A list of X10 source files that contributed to the generation of the current C++ file. +// static const struct _X10toCPPxref _X10toCPPlist[] = {}; +// // A cross reference of X10 statements to the first C++ statement. +// // Sorted by X10 file index and X10 source file line. +// static const struct _CPPtoX10xref _CPPtoX10xrefList[] = {}; +// // A cross reference of C++ statements to X10 statements. +// // Sorted by C++ file index and C++ source file line. +// // A line range is used to minimize the storage required. +// static const struct _X10methodName _X10methodNameList[] = {}; +// // A list of the X10 method names. +// // Sorted by X10 method name. + +struct _X10sourceFile +{ + uint32_t _numLines; // The number of lines in the X10 source file + uint32_t _stringIndex; // Index in _X10strings of the name of the X10 source file. +}; + +struct _X10toCPPxref +{ + uint16_t _X10index; // Index of X10 file name in _X10sourceList + uint16_t _X10method; // Index into _X10methodNameList of the X10 method (see Method Mapping) + uint32_t _CPPindex; // Index of C++ file name in _X10strings + uint32_t _X10line; // Line number of X10 source file line + uint32_t _CPPline; // Line number of C++ source file line +}; + +struct _CPPtoX10xref +{ + uint16_t _X10index; // Index of X10 file name in _X10sourceList + uint16_t _X10method; // Index into _X10methodNameList of the X10 method (see Method Mapping) + uint32_t _CPPindex; // Index of C++ file name in _X10strings + uint32_t _X10line; // Line number of X10 line + uint32_t _CPPfromLine; // First line number of C++ line range + uint32_t _CPPtoLine; // Last line number of C++ line range +}; + +struct _MethodSignature +{ +}; + +struct _X10methodName +{ + uint32_t _x10class; // Index of the X10 containing class name in _X10strings + uint32_t _x10method; // Index of the X10 method name in _X10strings + uint32_t _x10returnType; // Index of the X10 return type in _X10strings + uint64_t _x10args; // A pointer to a string that contains binary encodings of the + // argument indices. Each group of 4 bytes represents the index + // of the corresponding argument in _X10strings + uint32_t _cppClass; // Index of the C++ class name in _X10strings + uint16_t _x10argCount; // The number of X10 arguments + uint16_t _lineIndex; // Index into _X10toCPPlist of the first line of the method +}; + +extern void _X10_Entry_Hook(); // A hook at the start of every X10 method. +extern void _X10_Exit_Hook(); // A hook at the end of every X10 method. +extern void _X10_Statement_Hook(); // A hook at the start of every X10 executable statement. + // Follows any method start hook, and precedes any method end hook. + +#endif //X10AUX_DEBUG_H +// 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: <ta...@us...> - 2010-02-16 20:43:59
|
Revision: 12897 http://x10.svn.sourceforge.net/x10/?rev=12897&view=rev Author: tardieu Date: 2010-02-16 20:43:49 +0000 (Tue, 16 Feb 2010) Log Message: ----------- added @NativeString annotations to avoid wrapping string litterals in x10::lang::String objects. To be used only when calling native methods that expect native strings. added toNativeString method on closures in the C++ backend. Modified Paths: -------------- trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java Added Paths: ----------- trunk/x10.runtime/src-x10/x10/compiler/NativeString.x10 Modified: trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java =================================================================== --- trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java 2010-02-16 17:01:17 UTC (rev 12896) +++ trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java 2010-02-16 20:43:49 UTC (rev 12897) @@ -3362,10 +3362,28 @@ } public void visit(StringLit_c n) { - X10TypeSystem_c xts = (X10TypeSystem_c) tr.typeSystem(); - sw.write(Emitter.translateType(xts.String())+"::Lit(\""); - sw.write(StringUtil.escape(n.stringValue())); - sw.write("\")"); + X10TypeSystem_c xts = (X10TypeSystem_c) tr.typeSystem(); + + boolean nativeString = false; + try { + Type annotation = (Type) xts.systemResolver().find(QName.make("x10.compiler.NativeString")); + if (!((X10Ext) n.ext()).annotationMatching(annotation).isEmpty()) { + nativeString = true; + System.err.println("@NativeString " + n); + } + } catch (SemanticException e) { + /* Ignore exception when looking for annotation */ + } + + if (nativeString) { + sw.write("\""); + sw.write(StringUtil.escape(n.stringValue())); + sw.write("\""); + } else { + sw.write(Emitter.translateType(xts.String())+"::Lit(\""); + sw.write(StringUtil.escape(n.stringValue())); + sw.write("\")"); + } } public void visit(CharLit_c lit) { @@ -4091,9 +4109,16 @@ inc.write(Emitter.translateType(xts.String(), true)+" toString() {"); inc.newline(4); inc.begin(0); - inc.write("return "+Emitter.translateType(xts.String())+"::Lit(\""+StringUtil.escape(n.position().nameAndLineString())+"\");"); + inc.write("return "+Emitter.translateType(xts.String())+"::Lit(this->toNativeString());"); inc.end(); inc.newline(); inc.write("}"); + inc.newline(); inc.forceNewline(); + + inc.write("const char* toNativeString() {"); + inc.newline(4); inc.begin(0); + inc.write("return \""+StringUtil.escape(n.position().nameAndLineString())+"\";"); + inc.end(); inc.newline(); + inc.write("}"); inc.end(); inc.newline(); inc.forceNewline(); inc.write("};"); inc.newline(); inc.forceNewline(); Added: trunk/x10.runtime/src-x10/x10/compiler/NativeString.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/compiler/NativeString.x10 (rev 0) +++ trunk/x10.runtime/src-x10/x10/compiler/NativeString.x10 2010-02-16 20:43:49 UTC (rev 12897) @@ -0,0 +1,17 @@ +/* + * + * (C) Copyright IBM Corporation 2006-2008. + * + * This file is part of X10 Language. + * + */ + +package x10.compiler; + +import x10.lang.annotations.ExpressionAnnotation; + +/** An annotation that requests the compiler to... + * EXPERIMENTAL + * @author Olivier Tardieu + */ +public interface NativeString extends ExpressionAnnotation { } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ipe...@us...> - 2010-02-18 05:23:13
|
Revision: 12933 http://x10.svn.sourceforge.net/x10/?rev=12933&view=rev Author: ipeshansky Date: 2010-02-18 05:23:06 +0000 (Thu, 18 Feb 2010) Log Message: ----------- Fix XTENLANG-984. Shared libraries are now built and found using rpath. Remaining cleanup: - Extra relative path in the install_name for x10rt_*.so - hence the need for an extra -rpath in MacOSX_CXXCommandBuilder and X10RT_TEST_LDFLAGS - Repeated code for shared library dependencies in the Makefile Modified Paths: -------------- trunk/x10.compiler/src/x10cpp/postcompiler/MacOSX_CXXCommandBuilder.java trunk/x10.runtime/Make.rules trunk/x10.runtime/src-cpp/Makefile Property Changed: ---------------- trunk/x10.runtime/src-cpp/ trunk/x10.runtime/x10rt/lib/ Modified: trunk/x10.compiler/src/x10cpp/postcompiler/MacOSX_CXXCommandBuilder.java =================================================================== --- trunk/x10.compiler/src/x10cpp/postcompiler/MacOSX_CXXCommandBuilder.java 2010-02-18 02:51:10 UTC (rev 12932) +++ trunk/x10.compiler/src/x10cpp/postcompiler/MacOSX_CXXCommandBuilder.java 2010-02-18 05:23:06 UTC (rev 12933) @@ -31,5 +31,11 @@ protected void addPostArgs(ArrayList<String> cxxCmd) { super.addPostArgs(cxxCmd); + + // Support for loading shared libraries from x10.dist/lib + cxxCmd.add("-Wl,-rpath"); + cxxCmd.add("-Wl,"+X10_DIST+"/lib"); + cxxCmd.add("-Wl,-rpath"); + cxxCmd.add("-Wl,"+X10_DIST+""); // some libs end up with a "lib/" relative path } } Modified: trunk/x10.runtime/Make.rules =================================================================== --- trunk/x10.runtime/Make.rules 2010-02-18 02:51:10 UTC (rev 12932) +++ trunk/x10.runtime/Make.rules 2010-02-18 05:23:06 UTC (rev 12933) @@ -144,8 +144,8 @@ else ifeq ($(shell uname -s),Darwin) export X10RT_PLATFORM=$(shell echo | gcc -E -dM - | grep -q x86_64 && echo darwin64 || echo darwin) - export X10_STATIC_LIB=1 - LIBSUFFIX := .a + override CXXFLAGS_SHARED += -shared -fPIC -install_name '@rpath/$@' + export X10RT_TEST_LDFLAGS = -Wl,-rpath -Wl,$(X10_HOME)/x10.runtime/x10rt/lib -Wl,-rpath -Wl,$(X10_HOME)/x10.runtime/x10rt else ifeq ($(shell uname -s),SunOS) export X10RT_PLATFORM=sunos Property changes on: trunk/x10.runtime/src-cpp ___________________________________________________________________ Modified: svn:ignore - bdwgc gen depend.mk libx10.a libx10.mft x10.dll + bdwgc gen depend.mk libx10.a libx10.so libx10.mft x10.dll Modified: trunk/x10.runtime/src-cpp/Makefile =================================================================== --- trunk/x10.runtime/src-cpp/Makefile 2010-02-18 02:51:10 UTC (rev 12932) +++ trunk/x10.runtime/src-cpp/Makefile 2010-02-18 05:23:06 UTC (rev 12933) @@ -25,6 +25,12 @@ ifeq ($(X10RT_PLATFORM),cygwin) XRX_DEP_LIBS = -L$(INSTDIR)/lib -lx10rt_pgas_sockets -lgc endif +ifeq ($(X10RT_PLATFORM),darwin) + XRX_DEP_LIBS = -L$(INSTDIR)/lib -lx10rt_pgas_sockets -lgc +endif +ifeq ($(X10RT_PLATFORM),darwin64) + XRX_DEP_LIBS = -L$(INSTDIR)/lib -lx10rt_pgas_sockets -lgc +endif XRX_MANIFEST = libx10.mft # this builds everything Property changes on: trunk/x10.runtime/x10rt/lib ___________________________________________________________________ Modified: svn:ignore - libx10rt_mpi.a libx10rt_standalone.a libx10rt_pgas_sockets.a libx10rt_pgas_lapi.a libxlpgas_*.a x10rt_mpi.dll x10rt_standalone.dll x10rt_pgas_sockets.dll x10rt_pgas_lapi.dll + libx10rt_mpi.a libx10rt_standalone.a libx10rt_pgas_sockets.a libx10rt_pgas_lapi.a libx10rt_mpi.so libx10rt_standalone.so libx10rt_pgas_sockets.so libx10rt_pgas_lapi.so libxlpgas_*.a x10rt_mpi.dll x10rt_standalone.dll x10rt_pgas_sockets.dll x10rt_pgas_lapi.dll This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ma...@us...> - 2010-02-18 08:46:04
|
Revision: 12935 http://x10.svn.sourceforge.net/x10/?rev=12935&view=rev Author: makinoy Date: 2010-02-18 08:45:55 +0000 (Thu, 18 Feb 2010) Log Message: ----------- Fix XTENLANG-27. Add conversion function for cast primitive to a type parameter and a type parameter to a type parameter. Modified Paths: -------------- trunk/x10.compiler/src/x10/visit/X10PrettyPrinterVisitor.java trunk/x10.runtime/src-java/x10/rtt/Types.java Added Paths: ----------- trunk/x10.compiler/data/cast_deptype_primitive_param.xcd Added: trunk/x10.compiler/data/cast_deptype_primitive_param.xcd =================================================================== --- trunk/x10.compiler/data/cast_deptype_primitive_param.xcd (rev 0) +++ trunk/x10.compiler/data/cast_deptype_primitive_param.xcd 2010-02-18 08:45:55 UTC (rev 12935) @@ -0,0 +1,12 @@ +// SYNOPSIS: (#0) #1 #0=param type #1=primitive or Parameter type #2=runtime type #3=depclause +(new java.lang.Object() { + final #0 cast(Object self) { + x10.rtt.Type rtt = #2; + #0 dep = (#0) x10.rtt.Types.conversion(rtt,self); + if (self==null) return null; + if (rtt != null && ! rtt.instanceof$(dep)) throw new java.lang.ClassCastException(); + boolean sat = #3; + if (! sat) throw new java.lang.ClassCastException(); + return dep; + } +}.cast(#1)) Modified: trunk/x10.compiler/src/x10/visit/X10PrettyPrinterVisitor.java =================================================================== --- trunk/x10.compiler/src/x10/visit/X10PrettyPrinterVisitor.java 2010-02-18 05:53:13 UTC (rev 12934) +++ trunk/x10.compiler/src/x10/visit/X10PrettyPrinterVisitor.java 2010-02-18 08:45:55 UTC (rev 12935) @@ -695,6 +695,9 @@ w.write(")"); w.write(")"); w.end(); + } else if (t instanceof ParameterType + && (X10TypeMixin.baseType(type) instanceof ParameterType || type.isNumeric() || type.isChar())) { + new Template(er, "cast_deptype_primitive_param", ex, expr, rt, "true").expand(); } else { new Template(er, template, ex, expr, rt, "true").expand(); } Modified: trunk/x10.runtime/src-java/x10/rtt/Types.java =================================================================== --- trunk/x10.runtime/src-java/x10/rtt/Types.java 2010-02-18 05:53:13 UTC (rev 12934) +++ trunk/x10.runtime/src-java/x10/rtt/Types.java 2010-02-18 08:45:55 UTC (rev 12935) @@ -44,4 +44,84 @@ public static Type<Long> ULONG = new ULongType(); public static Type<Float> FLOAT = new FloatType(); public static Type<Double> DOUBLE = new DoubleType(); + + public static Object conversion(Type rtt, Object primOrTypeParam) { + if (rtt == x10.rtt.Types.BYTE) { + if (primOrTypeParam instanceof java.lang.Byte) return primOrTypeParam; + if (primOrTypeParam instanceof java.lang.Short) return ((java.lang.Short) primOrTypeParam).byteValue(); + if (primOrTypeParam instanceof java.lang.Character) return (byte)((java.lang.Character) primOrTypeParam).charValue(); + if (primOrTypeParam instanceof java.lang.Integer) return ((java.lang.Integer) primOrTypeParam).byteValue(); + if (primOrTypeParam instanceof java.lang.Long) return ((java.lang.Long) primOrTypeParam).byteValue(); + if (primOrTypeParam instanceof java.lang.Float) return ((java.lang.Float) primOrTypeParam).byteValue(); + if (primOrTypeParam instanceof java.lang.Double) return ((java.lang.Double) primOrTypeParam).byteValue(); + return primOrTypeParam; + } + if (rtt == x10.rtt.Types.SHORT) { + if (primOrTypeParam instanceof java.lang.Byte) return ((java.lang.Byte) primOrTypeParam).shortValue(); + if (primOrTypeParam instanceof java.lang.Short) return primOrTypeParam; + if (primOrTypeParam instanceof java.lang.Character) return (short)((java.lang.Character) primOrTypeParam).charValue(); + if (primOrTypeParam instanceof java.lang.Integer) return ((java.lang.Integer) primOrTypeParam).shortValue(); + if (primOrTypeParam instanceof java.lang.Long) return ((java.lang.Long) primOrTypeParam).shortValue(); + if (primOrTypeParam instanceof java.lang.Float) return ((java.lang.Float) primOrTypeParam).shortValue(); + if (primOrTypeParam instanceof java.lang.Double) return ((java.lang.Double) primOrTypeParam).shortValue(); + return primOrTypeParam; + } + if (rtt == x10.rtt.Types.CHAR) { + if (primOrTypeParam instanceof java.lang.Byte) return (char)(byte)((java.lang.Byte) primOrTypeParam); + if (primOrTypeParam instanceof java.lang.Short) return (char)(short)((java.lang.Short) primOrTypeParam); + if (primOrTypeParam instanceof java.lang.Character) return primOrTypeParam; + if (primOrTypeParam instanceof java.lang.Integer) return (char)(int)((java.lang.Integer) primOrTypeParam); + if (primOrTypeParam instanceof java.lang.Long) return (char)(long)((java.lang.Long) primOrTypeParam); + if (primOrTypeParam instanceof java.lang.Float) return (char)(float)((java.lang.Float) primOrTypeParam); + if (primOrTypeParam instanceof java.lang.Double) return (char)(double)((java.lang.Double) primOrTypeParam); + return primOrTypeParam; + } + if (rtt == x10.rtt.Types.INT) { + if (primOrTypeParam instanceof java.lang.Byte) return ((java.lang.Byte) primOrTypeParam).intValue(); + if (primOrTypeParam instanceof java.lang.Short) return ((java.lang.Short) primOrTypeParam).intValue(); + if (primOrTypeParam instanceof java.lang.Character) return (int)((java.lang.Character) primOrTypeParam).charValue(); + if (primOrTypeParam instanceof java.lang.Integer) return primOrTypeParam; + if (primOrTypeParam instanceof java.lang.Long) return ((java.lang.Long) primOrTypeParam).intValue(); + if (primOrTypeParam instanceof java.lang.Float) return ((java.lang.Float) primOrTypeParam).intValue(); + if (primOrTypeParam instanceof java.lang.Double) return ((java.lang.Double) primOrTypeParam).intValue(); + return primOrTypeParam; + } + if (rtt == x10.rtt.Types.LONG) { + if (primOrTypeParam instanceof java.lang.Byte) return ((java.lang.Byte) primOrTypeParam).longValue(); + if (primOrTypeParam instanceof java.lang.Short) return ((java.lang.Short) primOrTypeParam).longValue(); + if (primOrTypeParam instanceof java.lang.Character) return (long)((java.lang.Character) primOrTypeParam).charValue(); + if (primOrTypeParam instanceof java.lang.Integer) return ((java.lang.Integer) primOrTypeParam).longValue(); + if (primOrTypeParam instanceof java.lang.Long) return primOrTypeParam; + if (primOrTypeParam instanceof java.lang.Float) return ((java.lang.Float) primOrTypeParam).longValue(); + if (primOrTypeParam instanceof java.lang.Double) return ((java.lang.Double) primOrTypeParam).longValue(); + return primOrTypeParam; + } + if (rtt == x10.rtt.Types.FLOAT) { + if (primOrTypeParam instanceof java.lang.Byte) return ((java.lang.Byte) primOrTypeParam).floatValue(); + if (primOrTypeParam instanceof java.lang.Short) return ((java.lang.Short) primOrTypeParam).floatValue(); + if (primOrTypeParam instanceof java.lang.Character) return (float)((java.lang.Character) primOrTypeParam).charValue(); + if (primOrTypeParam instanceof java.lang.Integer) return ((java.lang.Integer) primOrTypeParam).floatValue(); + if (primOrTypeParam instanceof java.lang.Long) return ((java.lang.Long) primOrTypeParam).floatValue(); + if (primOrTypeParam instanceof java.lang.Float) return primOrTypeParam; + if (primOrTypeParam instanceof java.lang.Double) return ((java.lang.Double) primOrTypeParam).floatValue(); + return primOrTypeParam; + } + if (rtt == x10.rtt.Types.DOUBLE) { + if (primOrTypeParam instanceof java.lang.Byte) return ((java.lang.Byte) primOrTypeParam).doubleValue(); + if (primOrTypeParam instanceof java.lang.Short) return ((java.lang.Short) primOrTypeParam).doubleValue(); + if (primOrTypeParam instanceof java.lang.Character) return (double)((java.lang.Character) primOrTypeParam).charValue(); + if (primOrTypeParam instanceof java.lang.Integer) return ((java.lang.Integer) primOrTypeParam).doubleValue(); + if (primOrTypeParam instanceof java.lang.Long) return ((java.lang.Long) primOrTypeParam).doubleValue(); + if (primOrTypeParam instanceof java.lang.Float) return ((java.lang.Float) primOrTypeParam).doubleValue(); + if (primOrTypeParam instanceof java.lang.Double) return primOrTypeParam; + return primOrTypeParam; + } + + // unimplemented + if (rtt == x10.rtt.Types.UBYTE) {return primOrTypeParam;} + if (rtt == x10.rtt.Types.USHORT) {return primOrTypeParam;} + if (rtt == x10.rtt.Types.UINT) {return primOrTypeParam;} + if (rtt == x10.rtt.Types.ULONG) {return primOrTypeParam;} + return primOrTypeParam; + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ma...@us...> - 2010-02-19 07:23:30
|
Revision: 12950 http://x10.svn.sourceforge.net/x10/?rev=12950&view=rev Author: makinoy Date: 2010-02-19 07:23:23 +0000 (Fri, 19 Feb 2010) Log Message: ----------- Fix XTENLANG-999. Add conversion function for cast a type parameter type to primitive. Modified Paths: -------------- trunk/x10.runtime/src-java/x10/rtt/Types.java Added Paths: ----------- trunk/x10.compiler/src/x10/visit/TestCodeWriter.java Added: trunk/x10.compiler/src/x10/visit/TestCodeWriter.java =================================================================== --- trunk/x10.compiler/src/x10/visit/TestCodeWriter.java (rev 0) +++ trunk/x10.compiler/src/x10/visit/TestCodeWriter.java 2010-02-19 07:23:23 UTC (rev 12950) @@ -0,0 +1,97 @@ +package x10.visit; + +import java.io.IOException; + +import polyglot.util.CodeWriter; + +public class TestCodeWriter extends CodeWriter { + + private final CodeWriter w; + private final String name; + + public TestCodeWriter(CodeWriter w) { + name = w.getClass().getName(); + this.w = w; + } + + public void allowBreak(int n, int level, String alt, int altlen) { + w.allowBreak(n, level, alt, altlen); + } + + public void allowBreak(int n, String alt) { + w.allowBreak(n, alt); + } + + public void allowBreak(int n) { + w.allowBreak(n); + } + + public void begin(int n) { + w.begin(n); + } + + public void close() throws IOException { + w.close(); + } + + public void end() { + w.end(); + } + + public boolean equals(Object arg0) { + return w.equals(arg0); + } + + public boolean flush() throws IOException { + return w.flush(); + } + + public boolean flush(boolean format) throws IOException { + return w.flush(format); + } + + public int hashCode() { + return w.hashCode(); + } + + public void newline() { + w.newline(); + } + + public void newline(int n, int level) { + w.newline(n, level); + } + + public void newline(int n) { + w.newline(n); + } + + public String toString() { + return w.toString(); + } + + public void unifiedBreak(int n, int level, String alt, int altlen) { + w.unifiedBreak(n, level, alt, altlen); + } + + public void unifiedBreak(int n) { + w.unifiedBreak(n); + } + + public void write(String s, int length) { +// System.out.println(s); + w.write(s, length); + } + + public void write(String s) { + if (name.equals("polyglot.util.OptimalCodeWriter")) { + StackTraceElement[] stackTrace = new Exception().getStackTrace(); + System.out.print(stackTrace[4]); + System.out.print(" " + stackTrace[3]); + System.out.print(" " + stackTrace[2]); + System.out.println(" " + stackTrace[1]); + System.out.println("write(s):" + s); + } + w.write(s); + } +} Property changes on: trunk/x10.compiler/src/x10/visit/TestCodeWriter.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Modified: trunk/x10.runtime/src-java/x10/rtt/Types.java =================================================================== --- trunk/x10.runtime/src-java/x10/rtt/Types.java 2010-02-19 04:58:35 UTC (rev 12949) +++ trunk/x10.runtime/src-java/x10/rtt/Types.java 2010-02-19 07:23:23 UTC (rev 12950) @@ -45,6 +45,17 @@ public static Type<Float> FLOAT = new FloatType(); public static Type<Double> DOUBLE = new DoubleType(); + public static Object conversion(Class dep, Object typeParam) { + if(dep == java.lang.Byte.class) return conversion(BYTE, typeParam); + if(dep == java.lang.Short.class) return conversion(SHORT, typeParam); + if(dep == java.lang.Character.class) return conversion(CHAR, typeParam); + if(dep == java.lang.Integer.class) return conversion(INT, typeParam); + if(dep == java.lang.Long.class) return conversion(LONG, typeParam); + if(dep == java.lang.Float.class) return conversion(FLOAT, typeParam); + if(dep == java.lang.Double.class) return conversion(DOUBLE, typeParam); + return typeParam; + } + public static Object conversion(Type rtt, Object primOrTypeParam) { if (rtt == x10.rtt.Types.BYTE) { if (primOrTypeParam instanceof java.lang.Byte) return primOrTypeParam; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ma...@us...> - 2010-02-19 18:12:45
|
Revision: 12954 http://x10.svn.sourceforge.net/x10/?rev=12954&view=rev Author: makinoy Date: 2010-02-19 18:12:39 +0000 (Fri, 19 Feb 2010) Log Message: ----------- Refactor x10.rtt.Types.conversion() Modified Paths: -------------- trunk/x10.compiler/src/x10/visit/X10PrettyPrinterVisitor.java trunk/x10.runtime/src-java/x10/rtt/Types.java Modified: trunk/x10.compiler/src/x10/visit/X10PrettyPrinterVisitor.java =================================================================== --- trunk/x10.compiler/src/x10/visit/X10PrettyPrinterVisitor.java 2010-02-19 15:20:25 UTC (rev 12953) +++ trunk/x10.compiler/src/x10/visit/X10PrettyPrinterVisitor.java 2010-02-19 18:12:39 UTC (rev 12954) @@ -694,10 +694,6 @@ // does if (X10TypeMixin.baseType(type) instanceof ParameterType && (t.isNumeric() || t.isChar())) { TypeExpander te = new TypeExpander(er, t, BOX_PRIMITIVES); - w.write("("); - te.expand(tr); - w.write(")"); - w.write(" "); w.write("x10.rtt.Types.conversion("); te.expand(tr); w.write(".class"); Modified: trunk/x10.runtime/src-java/x10/rtt/Types.java =================================================================== --- trunk/x10.runtime/src-java/x10/rtt/Types.java 2010-02-19 15:20:25 UTC (rev 12953) +++ trunk/x10.runtime/src-java/x10/rtt/Types.java 2010-02-19 18:12:39 UTC (rev 12954) @@ -45,36 +45,28 @@ public static Type<Float> FLOAT = new FloatType(); public static Type<Double> DOUBLE = new DoubleType(); - public static Object conversion(Class dep, Object typeParam) { - if(dep == java.lang.Byte.class) return conversion(BYTE, typeParam); - if(dep == java.lang.Short.class) return conversion(SHORT, typeParam); - if(dep == java.lang.Character.class) return conversion(CHAR, typeParam); - if(dep == java.lang.Integer.class) return conversion(INT, typeParam); - if(dep == java.lang.Long.class) return conversion(LONG, typeParam); - if(dep == java.lang.Float.class) return conversion(FLOAT, typeParam); - if(dep == java.lang.Double.class) return conversion(DOUBLE, typeParam); - return typeParam; + public static <T> T conversion(Class<T> dep, Object typeParam) { + if(dep == java.lang.Byte.class) return (T)conversion(BYTE, typeParam); + if(dep == java.lang.Short.class) return (T)conversion(SHORT, typeParam); + if(dep == java.lang.Character.class) return (T)conversion(CHAR, typeParam); + if(dep == java.lang.Integer.class) return (T)conversion(INT, typeParam); + if(dep == java.lang.Long.class) return (T)conversion(LONG, typeParam); + if(dep == java.lang.Float.class) return (T)conversion(FLOAT, typeParam); + if(dep == java.lang.Double.class) return (T)conversion(DOUBLE, typeParam); + return (T)typeParam; } public static Object conversion(Type rtt, Object primOrTypeParam) { if (rtt == x10.rtt.Types.BYTE) { + if (primOrTypeParam instanceof java.lang.Number) return ((java.lang.Number) primOrTypeParam).byteValue(); if (primOrTypeParam instanceof java.lang.Byte) return primOrTypeParam; - if (primOrTypeParam instanceof java.lang.Short) return ((java.lang.Short) primOrTypeParam).byteValue(); if (primOrTypeParam instanceof java.lang.Character) return (byte)((java.lang.Character) primOrTypeParam).charValue(); - if (primOrTypeParam instanceof java.lang.Integer) return ((java.lang.Integer) primOrTypeParam).byteValue(); - if (primOrTypeParam instanceof java.lang.Long) return ((java.lang.Long) primOrTypeParam).byteValue(); - if (primOrTypeParam instanceof java.lang.Float) return ((java.lang.Float) primOrTypeParam).byteValue(); - if (primOrTypeParam instanceof java.lang.Double) return ((java.lang.Double) primOrTypeParam).byteValue(); return primOrTypeParam; } if (rtt == x10.rtt.Types.SHORT) { - if (primOrTypeParam instanceof java.lang.Byte) return ((java.lang.Byte) primOrTypeParam).shortValue(); + if (primOrTypeParam instanceof java.lang.Number) return ((java.lang.Number) primOrTypeParam).shortValue(); if (primOrTypeParam instanceof java.lang.Short) return primOrTypeParam; if (primOrTypeParam instanceof java.lang.Character) return (short)((java.lang.Character) primOrTypeParam).charValue(); - if (primOrTypeParam instanceof java.lang.Integer) return ((java.lang.Integer) primOrTypeParam).shortValue(); - if (primOrTypeParam instanceof java.lang.Long) return ((java.lang.Long) primOrTypeParam).shortValue(); - if (primOrTypeParam instanceof java.lang.Float) return ((java.lang.Float) primOrTypeParam).shortValue(); - if (primOrTypeParam instanceof java.lang.Double) return ((java.lang.Double) primOrTypeParam).shortValue(); return primOrTypeParam; } if (rtt == x10.rtt.Types.CHAR) { @@ -88,42 +80,26 @@ return primOrTypeParam; } if (rtt == x10.rtt.Types.INT) { - if (primOrTypeParam instanceof java.lang.Byte) return ((java.lang.Byte) primOrTypeParam).intValue(); - if (primOrTypeParam instanceof java.lang.Short) return ((java.lang.Short) primOrTypeParam).intValue(); + if (primOrTypeParam instanceof java.lang.Number) return ((java.lang.Number) primOrTypeParam).intValue(); if (primOrTypeParam instanceof java.lang.Character) return (int)((java.lang.Character) primOrTypeParam).charValue(); if (primOrTypeParam instanceof java.lang.Integer) return primOrTypeParam; - if (primOrTypeParam instanceof java.lang.Long) return ((java.lang.Long) primOrTypeParam).intValue(); - if (primOrTypeParam instanceof java.lang.Float) return ((java.lang.Float) primOrTypeParam).intValue(); - if (primOrTypeParam instanceof java.lang.Double) return ((java.lang.Double) primOrTypeParam).intValue(); return primOrTypeParam; } if (rtt == x10.rtt.Types.LONG) { - if (primOrTypeParam instanceof java.lang.Byte) return ((java.lang.Byte) primOrTypeParam).longValue(); - if (primOrTypeParam instanceof java.lang.Short) return ((java.lang.Short) primOrTypeParam).longValue(); + if (primOrTypeParam instanceof java.lang.Number) return ((java.lang.Number) primOrTypeParam).longValue(); if (primOrTypeParam instanceof java.lang.Character) return (long)((java.lang.Character) primOrTypeParam).charValue(); - if (primOrTypeParam instanceof java.lang.Integer) return ((java.lang.Integer) primOrTypeParam).longValue(); if (primOrTypeParam instanceof java.lang.Long) return primOrTypeParam; - if (primOrTypeParam instanceof java.lang.Float) return ((java.lang.Float) primOrTypeParam).longValue(); - if (primOrTypeParam instanceof java.lang.Double) return ((java.lang.Double) primOrTypeParam).longValue(); return primOrTypeParam; } if (rtt == x10.rtt.Types.FLOAT) { - if (primOrTypeParam instanceof java.lang.Byte) return ((java.lang.Byte) primOrTypeParam).floatValue(); - if (primOrTypeParam instanceof java.lang.Short) return ((java.lang.Short) primOrTypeParam).floatValue(); + if (primOrTypeParam instanceof java.lang.Number) return ((java.lang.Number) primOrTypeParam).floatValue(); if (primOrTypeParam instanceof java.lang.Character) return (float)((java.lang.Character) primOrTypeParam).charValue(); - if (primOrTypeParam instanceof java.lang.Integer) return ((java.lang.Integer) primOrTypeParam).floatValue(); - if (primOrTypeParam instanceof java.lang.Long) return ((java.lang.Long) primOrTypeParam).floatValue(); if (primOrTypeParam instanceof java.lang.Float) return primOrTypeParam; - if (primOrTypeParam instanceof java.lang.Double) return ((java.lang.Double) primOrTypeParam).floatValue(); return primOrTypeParam; } if (rtt == x10.rtt.Types.DOUBLE) { - if (primOrTypeParam instanceof java.lang.Byte) return ((java.lang.Byte) primOrTypeParam).doubleValue(); - if (primOrTypeParam instanceof java.lang.Short) return ((java.lang.Short) primOrTypeParam).doubleValue(); + if (primOrTypeParam instanceof java.lang.Number) return ((java.lang.Number) primOrTypeParam).doubleValue(); if (primOrTypeParam instanceof java.lang.Character) return (double)((java.lang.Character) primOrTypeParam).charValue(); - if (primOrTypeParam instanceof java.lang.Integer) return ((java.lang.Integer) primOrTypeParam).doubleValue(); - if (primOrTypeParam instanceof java.lang.Long) return ((java.lang.Long) primOrTypeParam).doubleValue(); - if (primOrTypeParam instanceof java.lang.Float) return ((java.lang.Float) primOrTypeParam).doubleValue(); if (primOrTypeParam instanceof java.lang.Double) return primOrTypeParam; return primOrTypeParam; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <vj...@us...> - 2010-02-20 20:21:37
|
Revision: 12961 http://x10.svn.sourceforge.net/x10/?rev=12961&view=rev Author: vj0 Date: 2010-02-20 20:21:24 +0000 (Sat, 20 Feb 2010) Log Message: ----------- Major refactoring of the type checker (1) Correct handling of EQV and UQV. Constraints and Types now provide a way to project out (existentially quantify) a variable. (2) Fixed a deep bug in type-checking (constraint clauses on parameteric types were not getting checked properly). (3) Fixed XTENLANG-899 (4) Started moving compiler errors into their own separate package (see Errors.java). Centralization helps when debugging the compiler. Further, we now have uniqueids for each error type (serialization ids for the class). Subsequent work will look to consolidate and rationalize some type-checking idioms that are still implemented in multiple places. Modified Paths: -------------- trunk/x10.compiler/src/x10/ast/AmbDepTypeNode_c.java trunk/x10.compiler/src/x10/ast/Async_c.java trunk/x10.compiler/src/x10/ast/ClosureCall_c.java trunk/x10.compiler/src/x10/ast/DepParameterExpr.java trunk/x10.compiler/src/x10/ast/DepParameterExpr_c.java trunk/x10.compiler/src/x10/ast/Here_c.java trunk/x10.compiler/src/x10/ast/PlaceCast_c.java trunk/x10.compiler/src/x10/ast/SettableAssign_c.java trunk/x10.compiler/src/x10/ast/X10AmbAssign_c.java trunk/x10.compiler/src/x10/ast/X10Binary_c.java trunk/x10.compiler/src/x10/ast/X10Call_c.java trunk/x10.compiler/src/x10/ast/X10CanonicalTypeNode_c.java trunk/x10.compiler/src/x10/ast/X10Cast.java trunk/x10.compiler/src/x10/ast/X10Cast_c.java trunk/x10.compiler/src/x10/ast/X10ClassBody_c.java trunk/x10.compiler/src/x10/ast/X10ClassDecl_c.java trunk/x10.compiler/src/x10/ast/X10Conditional_c.java trunk/x10.compiler/src/x10/ast/X10ConstructorCall_c.java trunk/x10.compiler/src/x10/ast/X10ConstructorDecl_c.java trunk/x10.compiler/src/x10/ast/X10FieldAssign_c.java trunk/x10.compiler/src/x10/ast/X10FieldDecl_c.java trunk/x10.compiler/src/x10/ast/X10Field_c.java trunk/x10.compiler/src/x10/ast/X10LocalAssign_c.java trunk/x10.compiler/src/x10/ast/X10LocalDecl_c.java trunk/x10.compiler/src/x10/ast/X10Local_c.java trunk/x10.compiler/src/x10/ast/X10Loop_c.java trunk/x10.compiler/src/x10/ast/X10MethodDecl_c.java trunk/x10.compiler/src/x10/ast/X10New_c.java trunk/x10.compiler/src/x10/ast/X10NodeFactory.java trunk/x10.compiler/src/x10/ast/X10NodeFactory_c.java trunk/x10.compiler/src/x10/ast/X10Return_c.java trunk/x10.compiler/src/x10/ast/X10Special_c.java trunk/x10.compiler/src/x10/ast/X10Unary_c.java trunk/x10.compiler/src/x10/emitter/Emitter.java trunk/x10.compiler/src/x10/optimizations/ForLoopOptimizer.java trunk/x10.compiler/src/x10/parser/X10Parser.java trunk/x10.compiler/src/x10/types/ClosureDef_c.java trunk/x10.compiler/src/x10/types/ClosureInstance_c.java trunk/x10.compiler/src/x10/types/ConstrainedType.java trunk/x10.compiler/src/x10/types/ConstrainedType_c.java trunk/x10.compiler/src/x10/types/MacroType_c.java trunk/x10.compiler/src/x10/types/TypeDef_c.java trunk/x10.compiler/src/x10/types/TypeParamSubst.java trunk/x10.compiler/src/x10/types/X10ClassDef.java trunk/x10.compiler/src/x10/types/X10ClassDef_c.java trunk/x10.compiler/src/x10/types/X10ConstructorDef_c.java trunk/x10.compiler/src/x10/types/X10ConstructorInstance_c.java trunk/x10.compiler/src/x10/types/X10Context.java trunk/x10.compiler/src/x10/types/X10Context_c.java trunk/x10.compiler/src/x10/types/X10Def.java trunk/x10.compiler/src/x10/types/X10FieldDef_c.java trunk/x10.compiler/src/x10/types/X10FieldInstance_c.java trunk/x10.compiler/src/x10/types/X10Flags.java trunk/x10.compiler/src/x10/types/X10InitializerDef_c.java trunk/x10.compiler/src/x10/types/X10LocalDef_c.java trunk/x10.compiler/src/x10/types/X10LocalInstance_c.java trunk/x10.compiler/src/x10/types/X10MethodDef.java trunk/x10.compiler/src/x10/types/X10MethodDef_c.java trunk/x10.compiler/src/x10/types/X10MethodInstance_c.java trunk/x10.compiler/src/x10/types/X10ParsedClassType_c.java trunk/x10.compiler/src/x10/types/X10ProcedureDef.java trunk/x10.compiler/src/x10/types/X10ProcedureInstance.java trunk/x10.compiler/src/x10/types/X10TypeEnv.java trunk/x10.compiler/src/x10/types/X10TypeEnv_c.java trunk/x10.compiler/src/x10/types/X10TypeMixin.java trunk/x10.compiler/src/x10/types/X10TypeSystem.java trunk/x10.compiler/src/x10/types/X10TypeSystem_c.java trunk/x10.compiler/src/x10/types/XTypeTranslator.java trunk/x10.compiler/src/x10/types/constraints/CConstraint.java trunk/x10.compiler/src/x10/types/constraints/CConstraint_c.java trunk/x10.compiler/src/x10/visit/ConstantPropagator.java trunk/x10.compiler/src/x10/visit/Desugarer.java trunk/x10.compiler/src/x10/visit/Inliner.java trunk/x10.compiler/src/x10/visit/X10Caster.java trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java trunk/x10.constraints/src/x10/constraint/XPromise_c.java trunk/x10.constraints/src/x10/constraint/XTerms.java trunk/x10.runtime/src-x10/x10/array/BaseArray.x10 trunk/x10.runtime/src-x10/x10/array/BaseDist.x10 trunk/x10.runtime/src-x10/x10/array/BaseRegion.x10 trunk/x10.runtime/src-x10/x10/array/DistArray.x10 trunk/x10.runtime/src-x10/x10/array/FastArray.x10 trunk/x10.runtime/src-x10/x10/array/LocalArray.x10 trunk/x10.runtime/src-x10/x10/array/PolyMat.x10 trunk/x10.runtime/src-x10/x10/array/PolyRegion.x10 trunk/x10.runtime/src-x10/x10/array/PolyScanner.x10 trunk/x10.runtime/src-x10/x10/array/RectRegion.x10 trunk/x10.runtime/src-x10/x10/array/UnionRegion.x10 trunk/x10.runtime/src-x10/x10/io/Reader.x10 trunk/x10.runtime/src-x10/x10/io/ReaderIterator.x10 trunk/x10.runtime/src-x10/x10/lang/Array.x10 trunk/x10.runtime/src-x10/x10/lang/Clock.x10 trunk/x10.runtime/src-x10/x10/lang/Dist.x10 trunk/x10.runtime/src-x10/x10/lang/Region.x10 trunk/x10.runtime/src-x10/x10/lang/Runtime.x10 trunk/x10.runtime/src-x10/x10/lang/System.x10 trunk/x10.runtime/src-x10/x10/lang/_.x10 trunk/x10.runtime/src-x10/x10/util/ArrayList.x10 trunk/x10.runtime/src-x10/x10/util/HashMap.x10 trunk/x10.runtime/src-x10/x10/util/HashSet.x10 trunk/x10.runtime/src-x10/x10/util/Map.x10 trunk/x10.runtime/src-x10/x10/util/MapIterator.x10 trunk/x10.tests/examples/Constructs/Cast/MacroConstraint.x10 trunk/x10.tests/examples/Constructs/Distribution/TestDist.x10 trunk/x10.tests/examples/x10lib/harness/x10Test.x10 Added Paths: ----------- trunk/x10.compiler/src/x10/errors/ trunk/x10.compiler/src/x10/errors/Errors.java trunk/x10.compiler/src/x10/types/TypeDefMatcher.java trunk/x10.compiler/src/x10/types/checker/ trunk/x10.compiler/src/x10/types/checker/Checker.java trunk/x10.compiler/src/x10/types/checker/Converter.java trunk/x10.compiler/src/x10/types/constraints/SubtypeConstraint.java trunk/x10.compiler/src/x10/types/constraints/SubtypeConstraint_c.java trunk/x10.compiler/src/x10/types/constraints/TypeConstraint.java trunk/x10.compiler/src/x10/types/constraints/TypeConstraint_c.java trunk/x10.compiler/src/x10/types/matcher/ trunk/x10.compiler/src/x10/types/matcher/DumbConstructorMatcher.java trunk/x10.compiler/src/x10/types/matcher/DumbMethodMatcher.java trunk/x10.compiler/src/x10/types/matcher/Matcher.java trunk/x10.compiler/src/x10/types/matcher/Subst.java trunk/x10.compiler/src/x10/types/matcher/X10ConstructorMatcher.java trunk/x10.compiler/src/x10/types/matcher/X10FieldMatcher.java trunk/x10.compiler/src/x10/types/matcher/X10MemberTypeMatcher.java trunk/x10.compiler/src/x10/types/matcher/X10MethodMatcher.java trunk/x10.compiler/src/x10/types/matcher/X10TypeMatcher.java Removed Paths: ------------- trunk/x10.compiler/src/x10/types/SubtypeConstraint.java Modified: trunk/x10.compiler/src/x10/ast/AmbDepTypeNode_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/AmbDepTypeNode_c.java 2010-02-20 16:42:35 UTC (rev 12960) +++ trunk/x10.compiler/src/x10/ast/AmbDepTypeNode_c.java 2010-02-20 20:21:24 UTC (rev 12961) @@ -38,12 +38,12 @@ import polyglot.visit.TypeChecker; import x10.extension.X10Del; import x10.extension.X10Del_c; -import x10.types.TypeConstraint; import x10.types.X10ClassType; import x10.types.X10Context; import x10.types.X10TypeMixin; import x10.types.X10TypeSystem; import x10.types.constraints.CConstraint; +import x10.types.constraints.TypeConstraint; public class AmbDepTypeNode_c extends TypeNode_c implements AmbDepTypeNode, AddFlags { Modified: trunk/x10.compiler/src/x10/ast/Async_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/Async_c.java 2010-02-20 16:42:35 UTC (rev 12960) +++ trunk/x10.compiler/src/x10/ast/Async_c.java 2010-02-20 20:21:24 UTC (rev 12961) @@ -180,38 +180,6 @@ if (placeTerm != null) xc = (X10Context) xc.pushPlace(placeTerm); - - /* - - // Change the place constraint to here==p - if (xc == c) - xc = (X10Context) xc.pushBlock(); - - XConstraint_c pc = new XConstraint_c(); - XTerm here = ts.xtypeTranslator().transHere(); - XTerm there = null; - try { - if (place != null) - there = ts.xtypeTranslator().trans(pc, place, xc); - else - there = ts.xtypeTranslator().transHere(); - } - catch (SemanticException e) { - // The place cannot be represented as a constraint term. - } - - if (there == null) - there = pc.genEQV(XTerms.makeFreshName("place"), false); - - try { - pc.addBinding(here, there); - } - catch (XFailure e) { - } - - xc.setCurrentPlaceConstraint(pc); - - */ } return xc; } Modified: trunk/x10.compiler/src/x10/ast/ClosureCall_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/ClosureCall_c.java 2010-02-20 16:42:35 UTC (rev 12960) +++ trunk/x10.compiler/src/x10/ast/ClosureCall_c.java 2010-02-20 20:21:24 UTC (rev 12961) @@ -57,8 +57,8 @@ import x10.types.X10MethodInstance; import x10.types.X10MethodInstance_c; import x10.types.X10TypeSystem; -import x10.types.X10TypeSystem_c; -import x10.types.X10TypeSystem_c.DumbMethodMatcher; +import x10.types.checker.Converter; +import x10.types.matcher.DumbMethodMatcher; public class ClosureCall_c extends Expr_c implements ClosureCall { protected Expr target; @@ -234,9 +234,9 @@ final Context context = tc.context(); ClassDef currentClassDef = context.currentClassDef(); - List<MethodInstance> methods = ts.findAcceptableMethods(targetType, new X10TypeSystem_c.DumbMethodMatcher(targetType, Name.make("apply"), typeArgs, argTypes, context)); + List<MethodInstance> methods = ts.findAcceptableMethods(targetType, new DumbMethodMatcher(targetType, Name.make("apply"), typeArgs, argTypes, context)); - Pair<MethodInstance,List<Expr>> p = X10New_c.<MethodDef,MethodInstance>tryImplicitConversions(n, tc, targetType, methods, new X10New_c.MatcherMaker<MethodInstance>() { + Pair<MethodInstance,List<Expr>> p = Converter.<MethodDef,MethodInstance>tryImplicitConversions(n, tc, targetType, methods, new X10New_c.MatcherMaker<MethodInstance>() { public Matcher<MethodInstance> matcher(Type ct, List<Type> typeArgs, List<Type> argTypes) { return ts.MethodMatcher(ct, Name.make("apply"), typeArgs, argTypes, context); } Modified: trunk/x10.compiler/src/x10/ast/DepParameterExpr.java =================================================================== --- trunk/x10.compiler/src/x10/ast/DepParameterExpr.java 2010-02-20 16:42:35 UTC (rev 12960) +++ trunk/x10.compiler/src/x10/ast/DepParameterExpr.java 2010-02-20 20:21:24 UTC (rev 12961) @@ -18,8 +18,8 @@ import polyglot.ast.Formal; import polyglot.ast.TypeNode; import polyglot.types.Ref; -import x10.types.TypeConstraint; import x10.types.constraints.CConstraint; +import x10.types.constraints.TypeConstraint; /** * @author vj Jan 9, 2005 Modified: trunk/x10.compiler/src/x10/ast/DepParameterExpr_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/DepParameterExpr_c.java 2010-02-20 16:42:35 UTC (rev 12960) +++ trunk/x10.compiler/src/x10/ast/DepParameterExpr_c.java 2010-02-20 20:21:24 UTC (rev 12961) @@ -38,12 +38,12 @@ import polyglot.visit.TypeBuilder; import polyglot.visit.TypeCheckPreparer; import polyglot.visit.TypeChecker; -import x10.types.TypeConstraint; -import x10.types.TypeConstraint_c; import x10.types.X10Context; import x10.types.X10TypeSystem; import x10.types.constraints.CConstraint; import x10.types.constraints.CConstraint_c; +import x10.types.constraints.TypeConstraint; +import x10.types.constraints.TypeConstraint_c; /** An immutable representation of a dependent type constraint. * The corresponding syntax is [T](e){x: T; c} Modified: trunk/x10.compiler/src/x10/ast/Here_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/Here_c.java 2010-02-20 16:42:35 UTC (rev 12960) +++ trunk/x10.compiler/src/x10/ast/Here_c.java 2010-02-20 20:21:24 UTC (rev 12961) @@ -78,14 +78,18 @@ X10Context xc = (X10Context) tc.context(); Type tt = ts.Place(); - CConstraint cc = new CConstraint_c(); - try { - cc.addSelfBinding(xc.currentPlaceTerm()); + XConstrainedTerm h = xc.currentPlaceTerm(); + if (h != null) { + CConstraint cc = new CConstraint_c(); + try { + cc.addSelfBinding(xc.currentPlaceTerm()); + } + catch (XFailure e) { + throw new SemanticException("Constraint on here is inconsistent; " + e.getMessage(), position()); + } + tt = X10TypeMixin.xclause(X10TypeMixin.baseType(tt), cc); } - catch (XFailure e) { - throw new SemanticException("Constraint on here is inconsistent; " + e.getMessage(), position()); - } - tt = X10TypeMixin.xclause(X10TypeMixin.baseType(tt), cc); + return type(tt); } public String translate(Resolver c) { Modified: trunk/x10.compiler/src/x10/ast/PlaceCast_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/PlaceCast_c.java 2010-02-20 16:42:35 UTC (rev 12960) +++ trunk/x10.compiler/src/x10/ast/PlaceCast_c.java 2010-02-20 20:21:24 UTC (rev 12961) @@ -62,7 +62,7 @@ Expr expr = (Expr) visitChild(this.expr, v); Node result = reconstruct(place, expr); if (v instanceof ExprFlattener.Flattener ) { - Report.report(1, "PlaceCast_c flattened to |" + result + "|"); + //Report.report(1, "PlaceCast_c flattened to |" + result + "|"); } return result; } Modified: trunk/x10.compiler/src/x10/ast/SettableAssign_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/SettableAssign_c.java 2010-02-20 16:42:35 UTC (rev 12960) +++ trunk/x10.compiler/src/x10/ast/SettableAssign_c.java 2010-02-20 20:21:24 UTC (rev 12961) @@ -83,6 +83,7 @@ */ public SettableAssign_c(Position pos, Expr array, List<Expr> index, Operator op, Expr right) { super(pos, op, right); + if (index.size() < 1) assert index.size() >= 1; this.array = array; this.index = index; @@ -253,7 +254,7 @@ @Override public Node typeCheck(ContextVisitor tc) throws SemanticException { - SettableAssign_c a = (SettableAssign_c) X10LocalAssign_c.typeCheckAssign(this, tc); + SettableAssign_c a = (SettableAssign_c) x10.types.checker.Checker.typeCheckAssign(this, tc); return a.type(a.mi.returnType()); } Modified: trunk/x10.compiler/src/x10/ast/X10AmbAssign_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10AmbAssign_c.java 2010-02-20 16:42:35 UTC (rev 12960) +++ trunk/x10.compiler/src/x10/ast/X10AmbAssign_c.java 2010-02-20 20:21:24 UTC (rev 12961) @@ -35,7 +35,11 @@ if (v instanceof ContextVisitor) { ContextVisitor cv = (ContextVisitor) v; - v = cv.context(((X10Context) cv.context()).pushAssignment()); + // Do not update context if within a deptype. + // This is an illegal user program -- assignments are not allowed in dep types -- + // and the error will be reported separately to the user. + if (! ((X10Context) cv.context()).inDepType()) + v = cv.context(((X10Context) cv.context()).pushAssignment()); } return super.visitLeft(v); } Modified: trunk/x10.compiler/src/x10/ast/X10Binary_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10Binary_c.java 2010-02-20 16:42:35 UTC (rev 12960) +++ trunk/x10.compiler/src/x10/ast/X10Binary_c.java 2010-02-20 20:21:24 UTC (rev 12961) @@ -52,6 +52,7 @@ import x10.types.X10Context; import x10.types.X10TypeMixin; import x10.types.X10TypeSystem; +import x10.types.checker.Converter; import x10.visit.ExprFlattener; import x10.visit.ExprFlattener.Flattener; @@ -332,12 +333,12 @@ 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); + Expr e = Converter.attemptCoercion(tc, left, rbase); + return Converter.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); + Expr e = Converter.attemptCoercion(tc, right, lbase); + return Converter.check(right(e), tc); } } @@ -352,9 +353,9 @@ 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); + Expr el = Converter.attemptCoercion(tc, left, promoted); + Expr er = Converter.attemptCoercion(tc, right, promoted); + return Converter.check(left(el).right(er), tc); } } @@ -449,7 +450,7 @@ n2 = n2.constantValue(n.constantValue()); try { - n2 = X10Cast_c.check(n2, tc); + n2 = Converter.check(n2, tc); if (! n2.methodInstance().def().flags().isStatic()) virtual_left = n2; } @@ -465,7 +466,7 @@ n4 = n4.constantValue(n.constantValue()); try { - n4 = X10Cast_c.check(n4, tc); + n4 = Converter.check(n4, tc); if (n4.methodInstance().def().flags().isStatic()) static_left = n4; } @@ -481,7 +482,7 @@ n3 = n3.constantValue(n.constantValue()); try { - n3 = X10Cast_c.check(n3, tc); + n3 = Converter.check(n3, tc); if (n3.methodInstance().def().flags().isStatic()) static_right = n3; } @@ -497,7 +498,7 @@ n5 = n5.constantValue(n.constantValue()); try { - n5 = X10Cast_c.check(n5, tc); + n5 = Converter.check(n5, tc); if (! n5.methodInstance().def().flags().isStatic()) virtual_right = n5; } @@ -611,7 +612,7 @@ if (actuals[k] != original[k]) if (actuals[k] instanceof X10Call) { X10Call c = (X10Call) actuals[k]; - if (c.methodInstance().name() == X10Cast_c.operator_as) + if (c.methodInstance().name() == Converter.operator_as) return true; } } @@ -626,7 +627,7 @@ return false; } - protected static Expr coerceToString(ContextVisitor tc, Expr e) throws SemanticException { + public static Expr coerceToString(ContextVisitor tc, Expr e) throws SemanticException { TypeSystem ts = tc.typeSystem(); if (!e.type().isSubtype(ts.String(), tc.context())) { Modified: trunk/x10.compiler/src/x10/ast/X10Call_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10Call_c.java 2010-02-20 16:42:35 UTC (rev 12960) +++ trunk/x10.compiler/src/x10/ast/X10Call_c.java 2010-02-20 20:21:24 UTC (rev 12961) @@ -64,6 +64,7 @@ import x10.constraint.XConstraint; import x10.constraint.XLocal; import x10.constraint.XRoot; +import x10.errors.Errors; import x10.parser.X10ParsedName; import x10.types.ParameterType; import x10.types.X10ClassType; @@ -75,13 +76,16 @@ import x10.types.X10TypeMixin; import x10.types.X10TypeSystem; -import x10.types.X10TypeSystem_c; import x10.types.XTypeTranslator; +import x10.types.checker.Converter; +import x10.types.constraints.XConstrainedTerm; +import x10.types.matcher.DumbMethodMatcher; /** * Representation of an X10 method call. * @author Igor + * @author vj */ public class X10Call_c extends Call_c implements X10Call, X10ProcedureCall { public X10Call_c(Position pos, Receiver target, Id name, @@ -97,7 +101,13 @@ n.typeArguments = new ArrayList<TypeNode>(args); return n; } + public X10Call arguments(List<Expr> args) { + X10Call_c n = (X10Call_c) copy(); + n.arguments = new ArrayList<Expr>(args); + return n; + } + @Override public Node visitChildren(NodeVisitor v) { Receiver target = (Receiver) visitChild(this.target, v); @@ -579,21 +589,17 @@ // Method invocations on structs are always permitted if (ts.isStructType(target.type())) - //if (! (ts.isSubtype(target.type(), ts.Object(), xc) || ts.isInterfaceType(target.type()))) return; if (ts.isHere(target, xc)) return; - if (xc.currentPlaceTerm().equals(((X10TypeSystem) tc.typeSystem()).globalPlace())) { - throw new SemanticError("Place type error: " + - " method " + name() + " called in the body of a global method; should be global.", - position()); + XConstrainedTerm h = xc.currentPlaceTerm(); + if (h != null && h.equals(((X10TypeSystem) tc.typeSystem()).globalPlace())) { + throw new Errors.PlaceTypeErrorMethodShouldBeGlobal(this, position()); } - throw new SemanticError("Place type error: method target " - + target + " cannot be determined to be at " + xc.currentPlaceTerm(), - position()); + throw new Errors.PlaceTypeErrorMethodShouldBeLocalOrGlobal (this, xc.currentPlaceTerm(), position()); } static Pair<MethodInstance,List<Expr>> tryImplicitConversions(final X10Call_c n, ContextVisitor tc, Type targetType, List<Type> typeArgs, List<Type> argTypes) throws SemanticException { @@ -601,9 +607,9 @@ final Context context = tc.context(); ClassDef currentClassDef = context.currentClassDef(); - List<MethodInstance> methods = ts.findAcceptableMethods(targetType, new X10TypeSystem_c.DumbMethodMatcher(targetType, n.name().id(), typeArgs, argTypes, context)); + List<MethodInstance> methods = ts.findAcceptableMethods(targetType, new DumbMethodMatcher(targetType, n.name().id(), typeArgs, argTypes, context)); - Pair<MethodInstance,List<Expr>> p = X10New_c.<MethodDef,MethodInstance>tryImplicitConversions(n, tc, targetType, methods, new X10New_c.MatcherMaker<MethodInstance>() { + Pair<MethodInstance,List<Expr>> p = Converter.<MethodDef,MethodInstance>tryImplicitConversions(n, tc, targetType, methods, new X10New_c.MatcherMaker<MethodInstance>() { public Matcher<MethodInstance> matcher(Type ct, List<Type> typeArgs, List<Type> argTypes) { return ts.MethodMatcher(ct, n.name().id(), typeArgs, argTypes, context); } Modified: trunk/x10.compiler/src/x10/ast/X10CanonicalTypeNode_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10CanonicalTypeNode_c.java 2010-02-20 16:42:35 UTC (rev 12960) +++ trunk/x10.compiler/src/x10/ast/X10CanonicalTypeNode_c.java 2010-02-20 20:21:24 UTC (rev 12961) @@ -54,6 +54,10 @@ public X10CanonicalTypeNode_c(Position pos, Ref<? extends Type> type) { super(pos, type); } + public X10CanonicalTypeNode_c(Position pos, Ref<? extends Type> type, DepParameterExpr d) { + super(pos, type); + this.expr = d; + } DepParameterExpr expr; Modified: trunk/x10.compiler/src/x10/ast/X10Cast.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10Cast.java 2010-02-20 16:42:35 UTC (rev 12960) +++ trunk/x10.compiler/src/x10/ast/X10Cast.java 2010-02-20 20:21:24 UTC (rev 12961) @@ -8,23 +8,15 @@ * * (C) Copyright IBM Corporation 2006-2010. */ - package x10.ast; import polyglot.ast.Cast; +import polyglot.ast.Expr; +import polyglot.visit.ContextVisitor; +import x10.types.checker.Converter; public interface X10Cast extends Cast { - public static enum ConversionType { - UNKNOWN_CONVERSION, - UNKNOWN_IMPLICIT_CONVERSION, - PRIMITIVE, - CHECKED, - SUBTYPE, - UNBOXING, - BOXING, - UNCHECKED - } - - public ConversionType conversionType(); - public X10Cast conversionType(ConversionType convert); + public Converter.ConversionType conversionType(); + public X10Cast conversionType(Converter.ConversionType convert); + } Modified: trunk/x10.compiler/src/x10/ast/X10Cast_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10Cast_c.java 2010-02-20 16:42:35 UTC (rev 12960) +++ trunk/x10.compiler/src/x10/ast/X10Cast_c.java 2010-02-20 20:21:24 UTC (rev 12961) @@ -12,10 +12,9 @@ package x10.ast; import java.util.ArrayList; -import java.util.Collections; import java.util.List; -import polyglot.ast.Call; +import polyglot.ast.Cast; import polyglot.ast.Cast_c; import polyglot.ast.Expr; import polyglot.ast.Node; @@ -26,8 +25,6 @@ import polyglot.types.ConstructorInstance; import polyglot.types.Context; import polyglot.types.ErrorRef_c; -import polyglot.types.MethodInstance; -import polyglot.types.Name; import polyglot.types.ObjectType; import polyglot.types.SemanticException; import polyglot.types.Type; @@ -35,12 +32,11 @@ import polyglot.types.Types; import polyglot.util.Position; import polyglot.visit.ContextVisitor; -import x10.constraint.XConstraint; import x10.types.ParameterType; import x10.types.X10ClassType; -import x10.types.X10Context; -import x10.types.X10TypeMixin; import x10.types.X10TypeSystem; +import x10.types.checker.Converter; +import x10.types.checker.Converter.ConversionType; /** * Represent java cast operation. @@ -53,17 +49,15 @@ * */ public class X10Cast_c extends Cast_c implements X10Cast, X10CastInfo { - protected ConversionType convert; + protected Converter.ConversionType convert; - public X10Cast_c(Position pos, TypeNode castType, Expr expr, ConversionType convert) { + + public X10Cast_c(Position pos, TypeNode castType, Expr expr, Converter.ConversionType convert) { super(pos, castType, expr); 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() { + public Converter.ConversionType conversionType() { return convert; } @@ -72,6 +66,12 @@ n.convert = convert; return n; } + public X10Cast conversionType(Expr expr, ConversionType convert) { + X10Cast_c n = (X10Cast_c) copy(); + n.convert = convert; + n.expr = expr; + return n; + } @Override public Precedence precedence() { @@ -84,322 +84,14 @@ } } - public static <T extends Node> T check(T n, ContextVisitor tc) throws SemanticException { - return (T) n.del().disambiguate(tc).del().typeCheck(tc).del().checkConstants(tc); - } - - /** Return list of conversion functions needed to convert from fromType to toType */ - public Expr converterChain(final ContextVisitor tc) throws SemanticException { - try { - return checkCast(tc); - } - catch (SemanticException e) { - } - - X10TypeSystem ts = (X10TypeSystem) tc.typeSystem(); - final X10NodeFactory nf = (X10NodeFactory) tc.nodeFactory(); - final Context context = tc.context(); - - class Helper { - Expr attempt(X10ClassType ct, int i, List<Type>[] alternatives, Type fromType, List<Type> accum, Type toType, boolean changed) throws SemanticException { - assert alternatives.length == accum.size(); - - if (i < alternatives.length) { - try { - accum.set(i, ct.typeArguments().get(i)); - return attempt(ct, i+1, alternatives, fromType, accum, toType, changed); - } - catch (SemanticException e) { - } - for (Type ti : alternatives[i]) { - try { - accum.set(i, ti); - return attempt(ct, i+1, alternatives, fromType, accum, toType, true); - } - catch (SemanticException e) { - } - } - } - else if (changed) { - X10ClassType ct2 = ct.typeArguments(accum); - Type newFrom = X10TypeMixin.xclause(X10TypeMixin.baseType(ct2), X10TypeMixin.xclause(fromType)); - if (fromType.typeEquals(newFrom, context)) { - assert false; - } - if (newFrom.isSubtype(toType, context)) - return X10Cast_c.this.expr(); - X10Cast_c newCast = (X10Cast_c) nf.X10Cast(position(), nf.CanonicalTypeNode(position(), newFrom), X10Cast_c.this.expr(), ConversionType.UNKNOWN_IMPLICIT_CONVERSION); - Expr newE = newCast.converterChain(tc); - assert newE.type() != null; - X10Cast_c newC = (X10Cast_c) X10Cast_c.this.expr(newE); - return newC.checkCast(tc); - } - - throw new SemanticException("Cannot convert from " + fromType + " to " + toType + ".", position()); - } - - void addSuperTypes(List<Type> l, Type t) { - Type b = X10TypeMixin.baseType(t); - if (! b.typeSystem().typeEquals(b, t, context)) { - l.add(b); - } - else - if (t instanceof ObjectType) { - ObjectType o = (ObjectType) t; - if (o.superClass() != null) { - l.add(o.superClass()); - } - for (Type ti : o.interfaces()) { - l.add(ti); - } - } - } - } - - Type fromType = expr.type(); - Type toType = castType.type(); - - // If the fromType has a covariant parameter, - // try supertypes of the corresponding argument type. - Type baseFrom = X10TypeMixin.baseType(fromType); - - if (baseFrom instanceof X10ClassType) { - X10ClassType ct = (X10ClassType) baseFrom; - if (ct.typeArguments().size() > 0) { - List<Type>[] alternatives = new List[ct.typeArguments().size()]; - List<Type> newArgs = new ArrayList<Type>(ct.typeArguments().size()); - for (int i = 0; i < ct.typeArguments().size(); i++) { - ParameterType.Variance v = ct.x10Def().variances().get(i); - Type ti = ct.typeArguments().get(i); - switch (v) { - case COVARIANT: - alternatives[i] = new ArrayList<Type>(); - new Helper().addSuperTypes(alternatives[i], ti); - break; - default: - alternatives[i] = Collections.EMPTY_LIST; - break; - } - } - - // Now, try all possible combinations of the alternative type arguments. - try { - return new Helper().attempt(ct, 0, alternatives, fromType, new ArrayList<Type>(ct.typeArguments()), toType, false); - } - catch (SemanticException e) { - // Fall through. - } - } - } - - String c = convert == ConversionType.UNKNOWN_CONVERSION ? "cast" : "implicitly convert"; - - throw new SemanticException("Cannot " + c + " expression of type \n\"" - + fromType + "\"\n to type \"" - + toType + "\".", - position()); - } - public Node typeCheck(ContextVisitor tc) throws SemanticException { - X10TypeSystem ts = (X10TypeSystem) tc.typeSystem(); - // if (ts.isBox(castType.type()) && expr.type() instanceof ParameterType) - // System.out.println(this); - Expr e = converterChain(tc); + Expr e = Converter.converterChain(this, tc); assert e.type() != null; - assert ! (e instanceof X10Cast_c) || ((X10Cast_c) e).convert != ConversionType.UNKNOWN_CONVERSION; - assert ! (e instanceof X10Cast_c) || ((X10Cast_c) e).convert != ConversionType.UNKNOWN_IMPLICIT_CONVERSION; + assert ! (e instanceof X10Cast_c) || ((X10Cast_c) e).convert != Converter.ConversionType.UNKNOWN_CONVERSION; + assert ! (e instanceof X10Cast_c) || ((X10Cast_c) e).convert != Converter.ConversionType.UNKNOWN_IMPLICIT_CONVERSION; return e; } - public Expr checkCast(ContextVisitor tc) throws SemanticException { - Type toType = castType.type(); - Type fromType = expr.type(); - X10TypeSystem ts = (X10TypeSystem) tc.typeSystem(); - X10NodeFactory nf = (X10NodeFactory) tc.nodeFactory(); - X10Context context = (X10Context) tc.context(); - - if (ts.isVoid(toType) || ts.isVoid(fromType)) - throw new SemanticException("Cannot cast from " + toType + " to " + fromType + ".", position()); - - if (ts.isSubtype(fromType, toType, context)) { - X10Cast_c n = (X10Cast_c) copy(); - n.convert = ConversionType.SUBTYPE; - return n.type(toType); - } - - Type baseFrom = X10TypeMixin.baseType(fromType); - Type baseTo = X10TypeMixin.baseType(toType); - XConstraint cFrom = X10TypeMixin.xclause(fromType); - XConstraint cTo = X10TypeMixin.xclause(toType); - - if (convert != ConversionType.UNKNOWN_IMPLICIT_CONVERSION) { - 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); - } - } - - { - MethodInstance converter = null; - Call c = null; - MethodInstance mi = converter; - Position p = position(); - Expr e = expr; - - // Can convert if there is a static method toType.$convert(fromType) - if (converter == null && convert != ConversionType.UNKNOWN_IMPLICIT_CONVERSION) { - try { - 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; - // Do the conversion. - c = nf.Call(p, nf.CanonicalTypeNode(p, toType), nf.Id(p, mi.name()), e); - c = c.methodInstance(mi); - c = (Call) c.type(mi.returnType()); - } - } - catch (SemanticException z1) { - } - } - // or can convert if there is a static method fromType.$convert(ToType) - - if (converter == null) { - try { - 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; - // Do the conversion. - c = nf.Call(p, nf.CanonicalTypeNode(p, toType), nf.Id(p, mi.name()), e); - c = c.methodInstance(mi); - c = (Call) c.type(mi.returnType()); - } - } - catch (SemanticException z2) { - try { - mi = ts.findMethod(fromType, 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; - c = nf.Call(p, nf.CanonicalTypeNode(p, fromType), nf.Id(p, mi.name()), e); - c = c.methodInstance(mi); - c = (Call) c.type(mi.returnType()); - } - } catch (SemanticException z) { - } - } - } - - if (converter != null) { - - // Now, do a coercion if needed to check any additional constraints on the type. - if (! ts.isParameterType(fromType) && ! mi.returnType().isSubtype(toType, context)) { - X10Cast_c n = (X10Cast_c) copy(); - n.expr = c; - n.convert = ConversionType.CHECKED; - return n.type(toType); - } - else { - return c; - } - } - } - - // if (ts.isValueType(fromType) && ts.isReferenceOrInterfaceType(toType)) { - // if (ts.isSubtypeWithValueInterfaces(fromType, toType, Collections.EMPTY_LIST)) { - // Expr boxed = wrap(expr, toType, tc); - // return boxed; - // } - // } - - // Type boxOfTo = ts.boxOf(Types.ref(toType)); - // Type boxOfFrom = ts.boxOf(Types.ref(fromType)); - - // v: Ref - // v as Value - // -> - // (v as Box[Ref]).value as Value - /* if (ts.isReferenceOrInterfaceType(fromType, context) && (ts.isParameterType(toType))) { - Expr boxed = expr; - if (! ts.typeEquals(baseFrom, boxOfTo, context)) { - boxed = check(nf.X10Cast(position(), nf.CanonicalTypeNode(position(), boxOfTo), expr, convert), tc); - return check(nf.X10Cast(position(), nf.CanonicalTypeNode(position(), toType), boxed, convert), tc); - } - }*/ - - /* if (convert != ConversionType.UNKNOWN_IMPLICIT_CONVERSION && ts.typeEquals(baseFrom, boxOfTo, context)) { - // System.out.println("UNBOXING " + expr + " from " + fromType + " to " + toType); - Expr unboxed = check(nf.Field(position(), expr, nf.Id(position(), Name.make("value"))), tc); - return check(nf.X10Cast(position(), nf.CanonicalTypeNode(position(), toType), unboxed, convert), tc); - }*/ - - // v to I, where I is not a value interface (i.e., a function type) - /* if (ts.isParameterType(fromType) && ts.typeBaseEquals(toType, ts.Object(), context)) { - if (ts.isSubtypeWithValueInterfaces(fromType, toType, context)) { - // TypeBuilder tb = new TypeBuilder(tc.job(), ts, nf); - // tb = tb.pushPackage(tc.context().package_()); - // tb = tb.pushClass(tc.context().currentClassDef()); - // tb = tb.pushCode(tc.context().currentCode()); - // - // TypeCheckPreparer sr = new TypeCheckPreparer(tc.job(), ts, nf, tc instanceof TypeChecker ? ((TypeChecker) tc).memo() : new HashMap<Node, Node>()); - // sr = (TypeCheckPreparer) sr.context(tc.context()); - - X10New_c boxed = (X10New_c) nf.X10New(position(), nf.CanonicalTypeNode(position(), Types.ref(boxOfFrom)), Collections.EMPTY_LIST, Collections.singletonList(expr)); - - ConstructorInstance ci = ts.createConstructorInstance(position(), new ErrorRef_c<ConstructorDef>(ts, position(), "Cannot get ConstructorDef before type-checking new expression.")); - boxed = (X10New_c) boxed.constructorInstance(ci); - - return check(boxed, tc); - } - } -*/ - // v to I, where I is not a value interface (i.e., a function type) - if (( ts.isParameterType(fromType)) && ts.isInterfaceType(toType)) { - if (ts.isSubtypeWithValueInterfaces(fromType, toType, context)) { - return new X10Boxed_c(position(), castType, expr, ConversionType.BOXING).type(toType); - } - } - - l: if (convert != ConversionType.UNKNOWN_IMPLICIT_CONVERSION) { - if (ts.isParameterType(toType)) { - // Now get the upper bound. - List<Type> upper = ts.env(context).upperBounds(toType, false); - if (upper.isEmpty()) { - // No upper bound. Now a hecked conversion is permitted only - // if fromType is not Null. - if (! fromType.isNull()) - return checkedConversionForTypeParameter(fromType, toType); - } else { - for (Type t : upper) - if (ts.isSubtype(fromType, t)) - return checkedConversionForTypeParameter(fromType, toType); - } - } else if (ts.isParameterType(fromType)) { - // Now get the upper bound. - List<Type> upper = ts.env(context).upperBounds(fromType, false); - for (Type t : upper) - if (! ts.isSubtype(t, toType)) - break l; - return checkedConversionForTypeParameter(fromType, toType); - } - } - - throw new SemanticException("Cannot convert expression of type \"" - + fromType + "\" to type \"" - + toType + "\".", - position()); - } - - Expr checkedConversionForTypeParameter(Type fromType, Type toType) { - X10Cast_c n = (X10Cast_c) copy(); - n.convert = ConversionType.CHECKED; - return n.type(toType); - } - public TypeNode getTypeNode() { return (TypeNode) this.castType().copy(); } Modified: trunk/x10.compiler/src/x10/ast/X10ClassBody_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10ClassBody_c.java 2010-02-20 16:42:35 UTC (rev 12960) +++ trunk/x10.compiler/src/x10/ast/X10ClassBody_c.java 2010-02-20 20:21:24 UTC (rev 12961) @@ -47,7 +47,6 @@ import x10.types.ClosureDef; import x10.types.MacroType; import x10.types.ParameterType; -import x10.types.TypeConstraint; import x10.types.TypeDef; import x10.types.X10ClassDef; import x10.types.X10ClassType; @@ -60,6 +59,7 @@ import x10.types.X10TypeMixin; import x10.types.X10TypeSystem; import x10.types.X10TypeSystem_c; +import x10.types.constraints.TypeConstraint; import x10.types.constraints.XConstrainedTerm; public class X10ClassBody_c extends ClassBody_c { Modified: trunk/x10.compiler/src/x10/ast/X10ClassDecl_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10ClassDecl_c.java 2010-02-20 16:42:35 UTC (rev 12960) +++ trunk/x10.compiler/src/x10/ast/X10ClassDecl_c.java 2010-02-20 20:21:24 UTC (rev 12961) @@ -93,8 +93,6 @@ import x10.extension.X10Ext; import x10.types.MacroType; import x10.types.ParameterType; -import x10.types.TypeConstraint; -import x10.types.TypeConstraint_c; import x10.types.TypeDef; import x10.types.X10ClassDef; import x10.types.X10ClassDef_c; @@ -112,6 +110,8 @@ import x10.types.X10TypeSystem_c; import x10.types.constraints.CConstraint; import x10.types.constraints.CConstraint_c; +import x10.types.constraints.TypeConstraint; +import x10.types.constraints.TypeConstraint_c; import x10.types.constraints.XConstrainedTerm; import x10.util.Synthesizer; /** Modified: trunk/x10.compiler/src/x10/ast/X10Conditional_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10Conditional_c.java 2010-02-20 16:42:35 UTC (rev 12960) +++ trunk/x10.compiler/src/x10/ast/X10Conditional_c.java 2010-02-20 20:21:24 UTC (rev 12961) @@ -42,6 +42,7 @@ import x10.types.X10TypeMixin; import x10.types.X10TypeSystem; +import x10.types.checker.Converter; import x10.visit.ExprFlattener; import x10.visit.ExprFlattener.Flattener; @@ -140,8 +141,8 @@ // 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 (t1.isNull() && X10TypeMixin.permitsNull(t2)) return type(t2); + if (t2.isNull() && X10TypeMixin.permitsNull(t1)) 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 @@ -160,8 +161,8 @@ try { Type t = ts.leastCommonAncestor(t1, t2, context); - Expr n1 = X10New_c.attemptCoercion(tc, e1, t); - Expr n2 = X10New_c.attemptCoercion(tc, e2, t); + Expr n1 = Converter.attemptCoercion(tc, e1, t); + Expr n2 = Converter.attemptCoercion(tc, e2, t); return consequent(n1).alternative(n2).type(t); } catch (SemanticException e) { Modified: trunk/x10.compiler/src/x10/ast/X10ConstructorCall_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10ConstructorCall_c.java 2010-02-20 16:42:35 UTC (rev 12960) +++ trunk/x10.compiler/src/x10/ast/X10ConstructorCall_c.java 2010-02-20 20:21:24 UTC (rev 12961) @@ -50,9 +50,9 @@ import x10.types.X10TypeMixin; import x10.types.X10TypeSystem; -import x10.types.X10TypeSystem_c; -import x10.types.X10TypeSystem_c.DumbConstructorMatcher; +import x10.types.checker.Converter; import x10.types.constraints.CConstraint; +import x10.types.matcher.DumbConstructorMatcher; /** * A call to this(...) or super(...) in the body of a constructor. @@ -268,8 +268,8 @@ List<ConstructorInstance> methods = ts.findAcceptableConstructors(targetType, - new X10TypeSystem_c.DumbConstructorMatcher(targetType, typeArgs, argTypes, context)); - return X10New_c.tryImplicitConversions(n, tc, targetType, methods, + new DumbConstructorMatcher(targetType, typeArgs, argTypes, context)); + return Converter.tryImplicitConversions(n, tc, targetType, methods, new MatcherMaker<ConstructorInstance>() { public Matcher<ConstructorInstance> matcher(Type ct, List<Type> typeArgs, List<Type> argTypes) { return ts.ConstructorMatcher(ct, typeArgs, argTypes, context); Modified: trunk/x10.compiler/src/x10/ast/X10ConstructorDecl_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10ConstructorDecl_c.java 2010-02-20 16:42:35 UTC (rev 12960) +++ trunk/x10.compiler/src/x10/ast/X10ConstructorDecl_c.java 2010-02-20 20:21:24 UTC (rev 12961) @@ -37,6 +37,7 @@ import polyglot.types.TypeSystem; import polyglot.types.Types; import polyglot.util.CollectionUtil; +import polyglot.util.InternalCompilerError; import polyglot.util.Position; import polyglot.util.TypedList; import polyglot.visit.ContextVisitor; @@ -48,6 +49,7 @@ import x10.constraint.XNameWrapper; import x10.constraint.XRef_c; import x10.constraint.XRoot; +import x10.constraint.XTerm; import x10.constraint.XTerms; import x10.constraint.XVar; import x10.extension.X10Del; @@ -63,6 +65,8 @@ import x10.types.X10TypeMixin; import x10.types.X10TypeSystem; import x10.types.constraints.CConstraint; +import x10.types.constraints.TypeConstraint; +import x10.types.constraints.XConstrainedTerm; /** * An X10ConstructorDecl differs from a ConstructorDecl in that it has a returnType. * @@ -179,6 +183,9 @@ return n; } + public Context enterScope(Context c) { + return c.pushCode(ci); + } public Context enterChildScope(Node child, Context c) { // We should have entered the constructor scope already. assert c.currentCode() == this.constructorDef(); @@ -212,8 +219,43 @@ f.addDecls(c); } } + // Ensure that the place constraint is set appropriately when + // entering the body of the method. + + c = super.enterChildScope(child, c); + X10Context xc = (X10Context) c; + + X10TypeSystem xts = (X10TypeSystem) c.typeSystem(); + if (child == body) { + if (! X10TypeMixin.isX10Struct(c.currentClassDef().asType())) { + XTerm h = xts.homeVar(xc.thisVar(),xc); + if (h != null) // null for structs. + c = ((X10Context) c).pushPlace(XConstrainedTerm.make(h)); + } + } + - return super.enterChildScope(child, c); + // Add the constructor guard into the environment. + if (guard != null) { + Ref<CConstraint> vc = guard.valueConstraint(); + Ref<TypeConstraint> tc = guard.typeConstraint(); + + if (vc != null || tc != null) { + c = c.pushBlock(); + try { + if (vc.known()) + c= ((X10Context) c).pushAdditionalConstraint(vc.get()); + } catch (SemanticException z) { + throw + new InternalCompilerError("Unexpected inconsistent guard" + z); + } + // ((X10Context) c).setCurrentConstraint(vc.get()); + // ((X10Context) c).setCurrentTypeConstraint(tc.get()); + } + } + + + return c; } /** Visit the children of the method. */ Modified: trunk/x10.compiler/src/x10/ast/X10FieldAssign_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10FieldAssign_c.java 2010-02-20 16:42:35 UTC (rev 12960) +++ trunk/x10.compiler/src/x10/ast/X10FieldAssign_c.java 2010-02-20 20:21:24 UTC (rev 12961) @@ -31,6 +31,8 @@ import x10.types.X10Flags; import x10.types.X10TypeMixin; +import x10.types.checker.Checker; +import x10.errors.Errors; public class X10FieldAssign_c extends FieldAssign_c { @@ -40,6 +42,10 @@ @Override public Assign typeCheckLeft(ContextVisitor tc) throws SemanticException { + X10Context cxt = (X10Context) tc.context(); + if (cxt.inDepType()) + throw new Errors.NoAssignmentInDepType(this, this.position()); + tc = tc.context(((X10Context) tc.context()).pushAssignment()); return super.typeCheckLeft(tc); } @@ -63,31 +69,21 @@ // Check the proto condition. if (X10TypeMixin.isProto(s)) { - if (! X10TypeMixin.isProto(targetType)) { - throw new SemanticException("The receiver " + this.target() + - " does not have a proto type; hence " + - this.right() + - " cannot be assigned to it's field " + this.name(), - this.position()); - } - if (op != ASSIGN) { - throw new SemanticException("Only the assignment operator = can be used to " - + " assign the proto value " + this.right() + - " to a field.", position()); - } + if (! X10TypeMixin.isProto(targetType)) + throw new Errors.ProtoValuesAssignableOnlyToProtoReceivers(this.right(), this, position()); + if (op != ASSIGN) + throw new Errors.ProtoValuesAssignableOnlyUsingEquals(right(), position()); s = X10TypeMixin.baseOfProto(s); - if (! (ts.isSubtype(s, t, tc.context()))) { - throw new SemanticException("Cannot assign " + s + " to " + t + ".", - n.position()); - - } + if (! (ts.isSubtype(s, t, tc.context()))) + throw new Errors.CannotAssign(n.right(), n.target().type(), n.position); + n.checkFieldPlaceType(tc); n= (X10FieldAssign_c) n.type(t); return n; } - return X10LocalAssign_c.typeCheckAssign(n, tc); + return Checker.typeCheckAssign(n, tc); } public void checkFieldPlaceType(ContextVisitor tc) throws SemanticException { Modified: trunk/x10.compiler/src/x10/ast/X10FieldDecl_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10FieldDecl_c.java 2010-02-20 16:42:35 UTC (rev 12960) +++ trunk/x10.compiler/src/x10/ast/X10FieldDecl_c.java 2010-02-20 20:21:24 UTC (rev 12961) @@ -47,6 +47,7 @@ import polyglot.visit.TypeBuilder; import polyglot.visit.TypeCheckPreparer; import polyglot.visit.TypeChecker; +import x10.constraint.XTerm; import x10.extension.X10Del; import x10.extension.X10Del_c; import x10.extension.X10Ext; @@ -61,6 +62,9 @@ import x10.types.X10TypeMixin; import x10.types.X10TypeSystem; +import x10.types.checker.Checker; +import x10.types.checker.Converter; +import x10.types.constraints.XConstrainedTerm; public class X10FieldDecl_c extends FieldDecl_c implements X10FieldDecl { @@ -85,6 +89,18 @@ xc.setVarWhoseTypeIsBeingElaborated(fi); c = xc; } + if (child == this.type || child == this.init) { + X10TypeSystem xts = (X10TypeSystem) c.typeSystem(); + X10Context xc = (X10Context) c; + ClassDef cd = c.currentClassDef(); + if (cd != null) + if ( ! X10TypeMixin.isX10Struct(cd.asType())) { + XTerm h = xts.homeVar(xc.thisVar(),xc); + if (h != null) // null for structs. + c = ((X10Context) c).pushPlace(XConstrainedTerm.make(h)); + } + + } Context cc = super.enterChildScope(child, c); return cc; } @@ -147,10 +163,10 @@ vars.put(pt.name(), v); } if (flags().flags().isFinal()) { - X10MethodDecl_c.checkVariancesOfType(type.position(), type.type(), ParameterType.Variance.COVARIANT, "as the type of a final field", vars, tc); + Checker.checkVariancesOfType(type.position(), type.type(), ParameterType.Variance.COVARIANT, "as the type of a final field", vars, tc); } else { - X10MethodDecl_c.checkVariancesOfType(type.position(), type.type(), ParameterType.Variance.INVARIANT, "as the type of a non-final field", vars, tc); + Checker.checkVariancesOfType(type.position(), type.type(), ParameterType.Variance.INVARIANT, "as the type of a non-final field", vars, tc); } } @@ -336,7 +352,7 @@ if (init != null) { try { - Expr newInit = X10New_c.attemptCoercion(tc, init, this.type().type()); + Expr newInit = Converter.attemptCoercion(tc, init, this.type().type()); return this.init(newInit); } catch (SemanticException e) { Modified: trunk/x10.compiler/src/x10/ast/X10Field_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10Field_c.java 2010-02-20 16:42:35 UTC (rev 12960) +++ trunk/x10.compiler/src/x10/ast/X10Field_c.java 2010-02-20 20:21:24 UTC (rev 12961) @@ -15,6 +15,7 @@ import polyglot.ast.Call; import polyglot.ast.Expr; +import polyglot.ast.Field; import polyglot.ast.Field_c; import polyglot.ast.Id; import polyglot.ast.Node; @@ -43,7 +44,6 @@ import x10.constraint.XVar; import x10.types.ConstrainedType; import x10.types.ParameterType; -import x10.types.Subst; import x10.types.X10ClassType; import x10.types.X10Context; import x10.types.X10FieldInstance; @@ -55,6 +55,9 @@ import x10.types.X10TypeSystem; import x10.types.constraints.CConstraint; import x10.types.constraints.CConstraint_c; +import x10.types.constraints.XConstrainedTerm; +import x10.types.matcher.Subst; +import x10.errors.Errors; /** @@ -73,36 +76,27 @@ super(pos, target, name); } - public static class ProtoFieldAccessException extends SemanticException{ - public ProtoFieldAccessException(String s) { - super(s); - } - } public Node typeCheck(ContextVisitor tc) throws SemanticException { Node n = typeCheck1(tc); // Keep this at the very end. This is caught by // handle proto. if (! ((X10Context) tc.context()).inAssignment()) { if (n instanceof X10Field_c) { - - Type xtType = ((X10Field_c) n).target().type(); - if (X10TypeMixin.isProto(xtType)) { - throw new SemanticException("Not permitted to read field " + - n + " of proto value " + target() +"." - - + ((X10Field_c) n).target()); + Field nf = (Field) n; + Type xtType = nf.target().type(); + if (X10TypeMixin.isProto(xtType)) { + throw new Errors.CannotReadFieldOfProtoValue(nf, + nf.position()); + + } } - } } return n; } public Node typeCheck1(ContextVisitor tc) throws SemanticException { final X10TypeSystem ts = (X10TypeSystem) tc.typeSystem(); final X10NodeFactory nf = (X10NodeFactory) tc.nodeFactory(); - final X10Context c = (X10Context) tc.context(); - //System.err.println("X10Field_c: Examining " + this + " at " + - // position() + " in depTypeMode=" + c.inDepType()); - + final X10Context c = (X10Context) tc.context(); Type tType = target.type(); @@ -110,7 +104,8 @@ Type t = ((TypeNode) target).type(); t = X10TypeMixin.baseType(t); if (t instanceof ParameterType) { - throw new SemanticException("Cannot access a static field of a type parameter.", position()); + throw new Errors.CannotAccessStaticFieldOfTypeParameter(t, + position()); } } @@ -128,14 +123,15 @@ // Found! X10Field_c result = this; Type t = c.inDepType()? rightType(fi.rightType(), fi.x10Def(), target, c) - : fieldRightType(fi.rightType(), fi.x10Def(), target, c); + : fi.rightType(); // fieldRightType(fi.rightType(), fi.x10Def(), target, c); result = (X10Field_c) result.fieldInstance(fi).type(... [truncated message content] |
From: <bti...@us...> - 2010-02-22 15:09:59
|
Revision: 12971 http://x10.svn.sourceforge.net/x10/?rev=12971&view=rev Author: btibbitts Date: 2010-02-22 15:09:50 +0000 (Mon, 22 Feb 2010) Log Message: ----------- update versions to 2.0.2 Modified Paths: -------------- trunk/x10.common/META-INF/MANIFEST.MF trunk/x10.compiler/META-INF/MANIFEST.MF trunk/x10.constraints/META-INF/MANIFEST.MF trunk/x10.effects/META-INF/MANIFEST.MF trunk/x10.runtime/META-INF/MANIFEST.MF Modified: trunk/x10.common/META-INF/MANIFEST.MF =================================================================== --- trunk/x10.common/META-INF/MANIFEST.MF 2010-02-22 15:03:00 UTC (rev 12970) +++ trunk/x10.common/META-INF/MANIFEST.MF 2010-02-22 15:09:50 UTC (rev 12971) @@ -2,5 +2,5 @@ Bundle-ManifestVersion: 2 Bundle-Name: X10 Common components Bundle-SymbolicName: x10.common -Bundle-Version: 2.0.1.qualifier +Bundle-Version: 2.0.2.qualifier Export-Package: x10.config Modified: trunk/x10.compiler/META-INF/MANIFEST.MF =================================================================== --- trunk/x10.compiler/META-INF/MANIFEST.MF 2010-02-22 15:03:00 UTC (rev 12970) +++ trunk/x10.compiler/META-INF/MANIFEST.MF 2010-02-22 15:09:50 UTC (rev 12971) @@ -2,7 +2,7 @@ Bundle-ManifestVersion: 2 Bundle-Name: X10 compiler Bundle-SymbolicName: x10.compiler -Bundle-Version: 2.0.1.qualifier +Bundle-Version: 2.0.2.qualifier Bundle-Localization: plugin Require-Bundle: x10.common, x10.constraints, Modified: trunk/x10.constraints/META-INF/MANIFEST.MF =================================================================== --- trunk/x10.constraints/META-INF/MANIFEST.MF 2010-02-22 15:03:00 UTC (rev 12970) +++ trunk/x10.constraints/META-INF/MANIFEST.MF 2010-02-22 15:09:50 UTC (rev 12971) @@ -2,5 +2,5 @@ Bundle-ManifestVersion: 2 Bundle-Name: X10 Constraints Bundle-SymbolicName: x10.constraints -Bundle-Version: 2.0.1.qualifier +Bundle-Version: 2.0.2.qualifier Export-Package: x10.constraint Modified: trunk/x10.effects/META-INF/MANIFEST.MF =================================================================== --- trunk/x10.effects/META-INF/MANIFEST.MF 2010-02-22 15:03:00 UTC (rev 12970) +++ trunk/x10.effects/META-INF/MANIFEST.MF 2010-02-22 15:09:50 UTC (rev 12971) @@ -2,6 +2,6 @@ Bundle-ManifestVersion: 2 Bundle-Name: Effects Bundle-SymbolicName: x10.effects -Bundle-Version: 2.0.1.qualifier +Bundle-Version: 2.0.2.qualifier Export-Package: x10.effects.constraints Require-Bundle: x10.constraints;bundle-version="1.7.3" Modified: trunk/x10.runtime/META-INF/MANIFEST.MF =================================================================== --- trunk/x10.runtime/META-INF/MANIFEST.MF 2010-02-22 15:03:00 UTC (rev 12970) +++ trunk/x10.runtime/META-INF/MANIFEST.MF 2010-02-22 15:09:50 UTC (rev 12971) @@ -2,7 +2,7 @@ Bundle-ManifestVersion: 2 Bundle-Name: X10 runtime Bundle-SymbolicName: x10.runtime -Bundle-Version: 2.0.1.qualifier +Bundle-Version: 2.0.2.qualifier Eclipse-AutoStart: true Bundle-Vendor: rf...@wa... Require-Bundle: x10.common, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dgr...@us...> - 2010-02-22 21:07:09
|
Revision: 13005 http://x10.svn.sourceforge.net/x10/?rev=13005&view=rev Author: dgrove-oss Date: 2010-02-22 21:07:02 +0000 (Mon, 22 Feb 2010) Log Message: ----------- Run standardizeAllHeaders.sh to fixup header comments. Modified Paths: -------------- trunk/x10.compiler/src/x10/errors/Errors.java trunk/x10.compiler/src/x10/types/TypeDefMatcher.java trunk/x10.compiler/src/x10/types/X10ConstructorDef_c.java trunk/x10.compiler/src/x10/types/X10Context.java trunk/x10.compiler/src/x10/types/X10LocalDef_c.java trunk/x10.compiler/src/x10/types/checker/Checker.java trunk/x10.compiler/src/x10/types/checker/Converter.java trunk/x10.compiler/src/x10/types/constraints/SubtypeConstraint_c.java trunk/x10.compiler/src/x10/types/constraints/TypeConstraint.java trunk/x10.compiler/src/x10/types/constraints/TypeConstraint_c.java trunk/x10.compiler/src/x10/types/matcher/DumbConstructorMatcher.java trunk/x10.compiler/src/x10/types/matcher/DumbMethodMatcher.java trunk/x10.compiler/src/x10/types/matcher/Matcher.java trunk/x10.compiler/src/x10/types/matcher/Subst.java trunk/x10.compiler/src/x10/types/matcher/X10ConstructorMatcher.java trunk/x10.compiler/src/x10/types/matcher/X10FieldMatcher.java trunk/x10.compiler/src/x10/types/matcher/X10MemberTypeMatcher.java trunk/x10.compiler/src/x10/types/matcher/X10MethodMatcher.java trunk/x10.compiler/src/x10/types/matcher/X10TypeMatcher.java trunk/x10.runtime/x10rt/test-jni/CountPlaces.java trunk/x10.runtime/x10rt/test-jni/Latency.java trunk/x10.runtime/x10rt/test-jni/SerializationTest.java trunk/x10.runtime/x10rt/test-jni/SimpleMessageTest.java Modified: trunk/x10.compiler/src/x10/errors/Errors.java =================================================================== --- trunk/x10.compiler/src/x10/errors/Errors.java 2010-02-22 21:00:12 UTC (rev 13004) +++ trunk/x10.compiler/src/x10/errors/Errors.java 2010-02-22 21:07:02 UTC (rev 13005) @@ -1,3 +1,14 @@ +/* + * This file is part of the X10 project (http://x10-lang.org). + * + * This file is licensed to You under the Eclipse Public License (EPL); + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.opensource.org/licenses/eclipse-1.0.php + * + * (C) Copyright IBM Corporation 2006-2010. + */ + package x10.errors; import polyglot.ast.Call; Modified: trunk/x10.compiler/src/x10/types/TypeDefMatcher.java =================================================================== --- trunk/x10.compiler/src/x10/types/TypeDefMatcher.java 2010-02-22 21:00:12 UTC (rev 13004) +++ trunk/x10.compiler/src/x10/types/TypeDefMatcher.java 2010-02-22 21:07:02 UTC (rev 13005) @@ -1,6 +1,14 @@ -/** - * - */ +/* + * This file is part of the X10 project (http://x10-lang.org). + * + * This file is licensed to You under the Eclipse Public License (EPL); + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.opensource.org/licenses/eclipse-1.0.php + * + * (C) Copyright IBM Corporation 2006-2010. + */ + package x10.types; import java.util.List; Modified: trunk/x10.compiler/src/x10/types/X10ConstructorDef_c.java =================================================================== --- trunk/x10.compiler/src/x10/types/X10ConstructorDef_c.java 2010-02-22 21:00:12 UTC (rev 13004) +++ trunk/x10.compiler/src/x10/types/X10ConstructorDef_c.java 2010-02-22 21:07:02 UTC (rev 13005) @@ -1,4 +1,5 @@ /* + * This file is part of the X10 project (http://x10-lang.org). * * This file is licensed to You under the Eclipse Public License (EPL); * You may not use this file except in compliance with the License. Modified: trunk/x10.compiler/src/x10/types/X10Context.java =================================================================== --- trunk/x10.compiler/src/x10/types/X10Context.java 2010-02-22 21:00:12 UTC (rev 13004) +++ trunk/x10.compiler/src/x10/types/X10Context.java 2010-02-22 21:07:02 UTC (rev 13005) @@ -6,8 +6,7 @@ * You may obtain a copy of the License at * http://www.opensource.org/licenses/eclipse-1.0.php * - * This file is part of X10 Language. - * + * (C) Copyright IBM Corporation 2006-2010. */ package x10.types; Modified: trunk/x10.compiler/src/x10/types/X10LocalDef_c.java =================================================================== --- trunk/x10.compiler/src/x10/types/X10LocalDef_c.java 2010-02-22 21:00:12 UTC (rev 13004) +++ trunk/x10.compiler/src/x10/types/X10LocalDef_c.java 2010-02-22 21:07:02 UTC (rev 13005) @@ -1,4 +1,5 @@ /* + * This file is part of the X10 project (http://x10-lang.org). * * This file is licensed to You under the Eclipse Public License (EPL); * You may not use this file except in compliance with the License. Modified: trunk/x10.compiler/src/x10/types/checker/Checker.java =================================================================== --- trunk/x10.compiler/src/x10/types/checker/Checker.java 2010-02-22 21:00:12 UTC (rev 13004) +++ trunk/x10.compiler/src/x10/types/checker/Checker.java 2010-02-22 21:07:02 UTC (rev 13005) @@ -1,3 +1,14 @@ +/* + * This file is part of the X10 project (http://x10-lang.org). + * + * This file is licensed to You under the Eclipse Public License (EPL); + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.opensource.org/licenses/eclipse-1.0.php + * + * (C) Copyright IBM Corporation 2006-2010. + */ + package x10.types.checker; import java.util.Map; Modified: trunk/x10.compiler/src/x10/types/checker/Converter.java =================================================================== --- trunk/x10.compiler/src/x10/types/checker/Converter.java 2010-02-22 21:00:12 UTC (rev 13004) +++ trunk/x10.compiler/src/x10/types/checker/Converter.java 2010-02-22 21:07:02 UTC (rev 13005) @@ -1,3 +1,14 @@ +/* + * This file is part of the X10 project (http://x10-lang.org). + * + * This file is licensed to You under the Eclipse Public License (EPL); + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.opensource.org/licenses/eclipse-1.0.php + * + * (C) Copyright IBM Corporation 2006-2010. + */ + package x10.types.checker; import java.util.ArrayList; Modified: trunk/x10.compiler/src/x10/types/constraints/SubtypeConstraint_c.java =================================================================== --- trunk/x10.compiler/src/x10/types/constraints/SubtypeConstraint_c.java 2010-02-22 21:00:12 UTC (rev 13004) +++ trunk/x10.compiler/src/x10/types/constraints/SubtypeConstraint_c.java 2010-02-22 21:07:02 UTC (rev 13005) @@ -1,3 +1,14 @@ +/* + * This file is part of the X10 project (http://x10-lang.org). + * + * This file is licensed to You under the Eclipse Public License (EPL); + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.opensource.org/licenses/eclipse-1.0.php + * + * (C) Copyright IBM Corporation 2006-2010. + */ + package x10.types.constraints; import java.util.ArrayList; Modified: trunk/x10.compiler/src/x10/types/constraints/TypeConstraint.java =================================================================== --- trunk/x10.compiler/src/x10/types/constraints/TypeConstraint.java 2010-02-22 21:00:12 UTC (rev 13004) +++ trunk/x10.compiler/src/x10/types/constraints/TypeConstraint.java 2010-02-22 21:07:02 UTC (rev 13005) @@ -1,3 +1,14 @@ +/* + * This file is part of the X10 project (http://x10-lang.org). + * + * This file is licensed to You under the Eclipse Public License (EPL); + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.opensource.org/licenses/eclipse-1.0.php + * + * (C) Copyright IBM Corporation 2006-2010. + */ + package x10.types.constraints; import java.io.Serializable; Modified: trunk/x10.compiler/src/x10/types/constraints/TypeConstraint_c.java =================================================================== --- trunk/x10.compiler/src/x10/types/constraints/TypeConstraint_c.java 2010-02-22 21:00:12 UTC (rev 13004) +++ trunk/x10.compiler/src/x10/types/constraints/TypeConstraint_c.java 2010-02-22 21:07:02 UTC (rev 13005) @@ -1,3 +1,14 @@ +/* + * This file is part of the X10 project (http://x10-lang.org). + * + * This file is licensed to You under the Eclipse Public License (EPL); + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.opensource.org/licenses/eclipse-1.0.php + * + * (C) Copyright IBM Corporation 2006-2010. + */ + package x10.types.constraints; import java.util.ArrayList; Modified: trunk/x10.compiler/src/x10/types/matcher/DumbConstructorMatcher.java =================================================================== --- trunk/x10.compiler/src/x10/types/matcher/DumbConstructorMatcher.java 2010-02-22 21:00:12 UTC (rev 13004) +++ trunk/x10.compiler/src/x10/types/matcher/DumbConstructorMatcher.java 2010-02-22 21:07:02 UTC (rev 13005) @@ -1,3 +1,14 @@ +/* + * This file is part of the X10 project (http://x10-lang.org). + * + * This file is licensed to You under the Eclipse Public License (EPL); + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.opensource.org/licenses/eclipse-1.0.php + * + * (C) Copyright IBM Corporation 2006-2010. + */ + package x10.types.matcher; import java.util.List; Modified: trunk/x10.compiler/src/x10/types/matcher/DumbMethodMatcher.java =================================================================== --- trunk/x10.compiler/src/x10/types/matcher/DumbMethodMatcher.java 2010-02-22 21:00:12 UTC (rev 13004) +++ trunk/x10.compiler/src/x10/types/matcher/DumbMethodMatcher.java 2010-02-22 21:07:02 UTC (rev 13005) @@ -1,3 +1,14 @@ +/* + * This file is part of the X10 project (http://x10-lang.org). + * + * This file is licensed to You under the Eclipse Public License (EPL); + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.opensource.org/licenses/eclipse-1.0.php + * + * (C) Copyright IBM Corporation 2006-2010. + */ + package x10.types.matcher; import java.util.List; Modified: trunk/x10.compiler/src/x10/types/matcher/Matcher.java =================================================================== --- trunk/x10.compiler/src/x10/types/matcher/Matcher.java 2010-02-22 21:00:12 UTC (rev 13004) +++ trunk/x10.compiler/src/x10/types/matcher/Matcher.java 2010-02-22 21:07:02 UTC (rev 13005) @@ -1,3 +1,14 @@ +/* + * This file is part of the X10 project (http://x10-lang.org). + * + * This file is licensed to You under the Eclipse Public License (EPL); + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.opensource.org/licenses/eclipse-1.0.php + * + * (C) Copyright IBM Corporation 2006-2010. + */ + package x10.types.matcher; import java.util.ArrayList; Modified: trunk/x10.compiler/src/x10/types/matcher/Subst.java =================================================================== --- trunk/x10.compiler/src/x10/types/matcher/Subst.java 2010-02-22 21:00:12 UTC (rev 13004) +++ trunk/x10.compiler/src/x10/types/matcher/Subst.java 2010-02-22 21:07:02 UTC (rev 13005) @@ -1,6 +1,14 @@ -/** - * +/* + * This file is part of the X10 project (http://x10-lang.org). + * + * This file is licensed to You under the Eclipse Public License (EPL); + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.opensource.org/licenses/eclipse-1.0.php + * + * (C) Copyright IBM Corporation 2006-2010. */ + package x10.types.matcher; import java.util.ArrayList; Modified: trunk/x10.compiler/src/x10/types/matcher/X10ConstructorMatcher.java =================================================================== --- trunk/x10.compiler/src/x10/types/matcher/X10ConstructorMatcher.java 2010-02-22 21:00:12 UTC (rev 13004) +++ trunk/x10.compiler/src/x10/types/matcher/X10ConstructorMatcher.java 2010-02-22 21:07:02 UTC (rev 13005) @@ -1,6 +1,14 @@ -/** - * - */ +/* + * This file is part of the X10 project (http://x10-lang.org). + * + * This file is licensed to You under the Eclipse Public License (EPL); + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.opensource.org/licenses/eclipse-1.0.php + * + * (C) Copyright IBM Corporation 2006-2010. + */ + package x10.types.matcher; import java.util.Collections; Modified: trunk/x10.compiler/src/x10/types/matcher/X10FieldMatcher.java =================================================================== --- trunk/x10.compiler/src/x10/types/matcher/X10FieldMatcher.java 2010-02-22 21:00:12 UTC (rev 13004) +++ trunk/x10.compiler/src/x10/types/matcher/X10FieldMatcher.java 2010-02-22 21:07:02 UTC (rev 13005) @@ -1,6 +1,14 @@ -/** - * - */ +/* + * This file is part of the X10 project (http://x10-lang.org). + * + * This file is licensed to You under the Eclipse Public License (EPL); + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.opensource.org/licenses/eclipse-1.0.php + * + * (C) Copyright IBM Corporation 2006-2010. + */ + package x10.types.matcher; import polyglot.types.Context; Modified: trunk/x10.compiler/src/x10/types/matcher/X10MemberTypeMatcher.java =================================================================== --- trunk/x10.compiler/src/x10/types/matcher/X10MemberTypeMatcher.java 2010-02-22 21:00:12 UTC (rev 13004) +++ trunk/x10.compiler/src/x10/types/matcher/X10MemberTypeMatcher.java 2010-02-22 21:07:02 UTC (rev 13005) @@ -1,6 +1,14 @@ -/** - * - */ +/* + * This file is part of the X10 project (http://x10-lang.org). + * + * This file is licensed to You under the Eclipse Public License (EPL); + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.opensource.org/licenses/eclipse-1.0.php + * + * (C) Copyright IBM Corporation 2006-2010. + */ + package x10.types.matcher; import polyglot.types.Context; Modified: trunk/x10.compiler/src/x10/types/matcher/X10MethodMatcher.java =================================================================== --- trunk/x10.compiler/src/x10/types/matcher/X10MethodMatcher.java 2010-02-22 21:00:12 UTC (rev 13004) +++ trunk/x10.compiler/src/x10/types/matcher/X10MethodMatcher.java 2010-02-22 21:07:02 UTC (rev 13005) @@ -1,6 +1,14 @@ -/** - * - */ +/* + * This file is part of the X10 project (http://x10-lang.org). + * + * This file is licensed to You under the Eclipse Public License (EPL); + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.opensource.org/licenses/eclipse-1.0.php + * + * (C) Copyright IBM Corporation 2006-2010. + */ + package x10.types.matcher; import java.util.Collections; Modified: trunk/x10.compiler/src/x10/types/matcher/X10TypeMatcher.java =================================================================== --- trunk/x10.compiler/src/x10/types/matcher/X10TypeMatcher.java 2010-02-22 21:00:12 UTC (rev 13004) +++ trunk/x10.compiler/src/x10/types/matcher/X10TypeMatcher.java 2010-02-22 21:07:02 UTC (rev 13005) @@ -1,6 +1,14 @@ -/** - * - */ +/* + * This file is part of the X10 project (http://x10-lang.org). + * + * This file is licensed to You under the Eclipse Public License (EPL); + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.opensource.org/licenses/eclipse-1.0.php + * + * (C) Copyright IBM Corporation 2006-2010. + */ + package x10.types.matcher; import polyglot.types.Name; Modified: trunk/x10.runtime/x10rt/test-jni/CountPlaces.java =================================================================== --- trunk/x10.runtime/x10rt/test-jni/CountPlaces.java 2010-02-22 21:00:12 UTC (rev 13004) +++ trunk/x10.runtime/x10rt/test-jni/CountPlaces.java 2010-02-22 21:07:02 UTC (rev 13005) @@ -1,3 +1,14 @@ +/* + * This file is part of the X10 project (http://x10-lang.org). + * + * This file is licensed to You under the Eclipse Public License (EPL); + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.opensource.org/licenses/eclipse-1.0.php + * + * (C) Copyright IBM Corporation 2006-2010. + */ + import x10.x10rt.X10RT; public class CountPlaces { Modified: trunk/x10.runtime/x10rt/test-jni/Latency.java =================================================================== --- trunk/x10.runtime/x10rt/test-jni/Latency.java 2010-02-22 21:00:12 UTC (rev 13004) +++ trunk/x10.runtime/x10rt/test-jni/Latency.java 2010-02-22 21:07:02 UTC (rev 13005) @@ -1,5 +1,12 @@ -/** - * Bidirectional Simulataneous Latency test +/* + * This file is part of the X10 project (http://x10-lang.org). + * + * This file is licensed to You under the Eclipse Public License (EPL); + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.opensource.org/licenses/eclipse-1.0.php + * + * (C) Copyright IBM Corporation 2006-2010. */ import x10.x10rt.ActiveMessage; Modified: trunk/x10.runtime/x10rt/test-jni/SerializationTest.java =================================================================== --- trunk/x10.runtime/x10rt/test-jni/SerializationTest.java 2010-02-22 21:00:12 UTC (rev 13004) +++ trunk/x10.runtime/x10rt/test-jni/SerializationTest.java 2010-02-22 21:07:02 UTC (rev 13005) @@ -1,3 +1,14 @@ +/* + * This file is part of the X10 project (http://x10-lang.org). + * + * This file is licensed to You under the Eclipse Public License (EPL); + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.opensource.org/licenses/eclipse-1.0.php + * + * (C) Copyright IBM Corporation 2006-2010. + */ + import java.io.Serializable; import x10.x10rt.ActiveMessage; Modified: trunk/x10.runtime/x10rt/test-jni/SimpleMessageTest.java =================================================================== --- trunk/x10.runtime/x10rt/test-jni/SimpleMessageTest.java 2010-02-22 21:00:12 UTC (rev 13004) +++ trunk/x10.runtime/x10rt/test-jni/SimpleMessageTest.java 2010-02-22 21:07:02 UTC (rev 13005) @@ -1,3 +1,14 @@ +/* + * This file is part of the X10 project (http://x10-lang.org). + * + * This file is licensed to You under the Eclipse Public License (EPL); + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.opensource.org/licenses/eclipse-1.0.php + * + * (C) Copyright IBM Corporation 2006-2010. + */ + import x10.x10rt.ActiveMessage; import x10.x10rt.MessageRegistry; import x10.x10rt.Node; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dgr...@us...> - 2010-02-23 16:23:33
|
Revision: 13020 http://x10.svn.sourceforge.net/x10/?rev=13020&view=rev Author: dgrove-oss Date: 2010-02-23 16:23:26 +0000 (Tue, 23 Feb 2010) Log Message: ----------- Fix performance problem noticed by Olivier. Since placeChecks are supposed to be redundant with the static place checking, the intent was that when compiling with optimization, we should disable place checking (ie, they are only a form of assertion checking for unoptimized code just like assert). Modified Paths: -------------- trunk/x10.compiler/src/x10cpp/postcompiler/CXXCommandBuilder.java trunk/x10.runtime/Make.rules Modified: trunk/x10.compiler/src/x10cpp/postcompiler/CXXCommandBuilder.java =================================================================== --- trunk/x10.compiler/src/x10cpp/postcompiler/CXXCommandBuilder.java 2010-02-23 15:14:39 UTC (rev 13019) +++ trunk/x10.compiler/src/x10cpp/postcompiler/CXXCommandBuilder.java 2010-02-23 16:23:26 UTC (rev 13020) @@ -121,6 +121,7 @@ if (x10.Configuration.OPTIMIZE) { cxxCmd.add(USE_XLC ? "-O3" : "-O2"); cxxCmd.add("-DNDEBUG"); + cxxCmd.add("-DNO_PLACE_CHECKS"); // All place checking is done statically, so this should be completely safe to do. cxxCmd.add(USE_XLC ? "-qinline" : "-finline-functions"); if (USE_XLC) { cxxCmd.add("-qhot"); Modified: trunk/x10.runtime/Make.rules =================================================================== --- trunk/x10.runtime/Make.rules 2010-02-23 15:14:39 UTC (rev 13019) +++ trunk/x10.runtime/Make.rules 2010-02-23 16:23:26 UTC (rev 13020) @@ -30,7 +30,7 @@ #avoid specifying -NDEBUG twice ifdef OPTIMIZE - USE_NDEBUG := -DNDEBUG + USE_NDEBUG := -DNDEBUG -DNO_PLACE_CHECKS X10CPPFLAGS += -optimize endif ifdef NO_CHECKS This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dgr...@us...> - 2010-02-24 19:32:36
|
Revision: 13029 http://x10.svn.sourceforge.net/x10/?rev=13029&view=rev Author: dgrove-oss Date: 2010-02-24 19:32:29 +0000 (Wed, 24 Feb 2010) Log Message: ----------- XTENLANG-848 : Complex Math functions and associated test cases. Contributed by Josh Milthrope of ANU under terms of ARC Linkage Grant PAO. Modified Paths: -------------- trunk/x10.runtime/src-cpp/x10aux/math_utils.h trunk/x10.runtime/src-x10/x10/lang/Math.x10 Added Paths: ----------- trunk/x10.tests/examples/Constructs/Math/ trunk/x10.tests/examples/Constructs/Math/TestComplex.x10 trunk/x10.tests/examples/Constructs/Math/TestComplexMath.x10 Removed Paths: ------------- trunk/x10.tests/examples/Constructs/Structs/TestComplex.x10 Modified: trunk/x10.runtime/src-cpp/x10aux/math_utils.h =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/math_utils.h 2010-02-24 15:43:38 UTC (rev 13028) +++ trunk/x10.runtime/src-cpp/x10aux/math_utils.h 2010-02-24 19:32:29 UTC (rev 13029) @@ -41,6 +41,7 @@ static inline x10_double ceil(x10_double x) { return ::ceil(x); } static inline x10_double floor(x10_double x) { return ::floor(x); } static inline x10_double round(x10_double x) { return ::round(x); } + static inline x10_double copysign(x10_double x, x10_double y) { return ::copysign(x, y); } }; } Modified: trunk/x10.runtime/src-x10/x10/lang/Math.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Math.x10 2010-02-24 15:43:38 UTC (rev 13028) +++ trunk/x10.runtime/src-x10/x10/lang/Math.x10 2010-02-24 19:32:29 UTC (rev 13029) @@ -7,6 +7,7 @@ * http://www.opensource.org/licenses/eclipse-1.0.php * * (C) Copyright IBM Corporation 2006-2010. + * (C) Copyright Australian National University 2009-2010. */ package x10.lang; @@ -41,6 +42,15 @@ @Native("c++", "x10aux::math_utils::pow(#1,#2)") public static native def pow(a:Double, b:Double):Double; + /** + * Returns the principal value of the complex power <code>a^b</code>. + * The branch cuts are on the real line at (-inf, 0) for real(b) <= 0, + * and (-inf, 0] for real(b) > 0. pow(0,0) is not defined. + * @return a raised to the power <code>b</code> + * @see http://mathworld.wolfram.com/Power.html + */ + public static safe def pow(a:Complex, b:Complex) = Math.exp(Math.log(a) * b); + @Native("java", "java.lang.Math.exp(#1)") @Native("c++", "x10aux::math_utils::exp(#1)") public static native def exp(a:Double):Double; @@ -51,6 +61,18 @@ @Native("cuda", "__expf(#1)") public static native def exp(a:Float):Float; + /** + * @return the exponential function <code>e^a</code> + * @see http://mathworld.wolfram.com/ExponentialFunction.html + */ + public static safe def exp(a:Complex):Complex { + if (a.isNaN()) { + return Complex.NaN; + } + val expRe = Math.exp(a.re); + return Complex(expRe * Math.cos(a.im), expRe * Math.sin(a.im)); + } + @Native("java", "java.lang.Math.expm1(#1)") @Native("c++", "x10aux::math_utils::expm1(#1)") public static native def expm1(a:Double):Double; @@ -59,26 +81,116 @@ @Native("c++", "x10aux::math_utils::cos(#1)") public static native def cos(a:Double):Double; + /** + * @return the cosine of <code>z</code> + * @see http://mathworld.wolfram.com/Cosine.html + */ + public static safe def cos(z:Complex):Complex { + if (z.im == 0.0) { + return Complex(Math.cos(z.re), 0.0); + } else { + return Complex(Math.cos(z.re) * Math.cosh(z.im), Math.sin(z.re) * Math.sinh(-(z.im))); + } + } + @Native("java", "java.lang.Math.sin(#1)") @Native("c++", "x10aux::math_utils::sin(#1)") public static native def sin(a:Double):Double; + /** + * @return the sine of <code>z</code> + * @see http://mathworld.wolfram.com/Sine.html + */ + public static safe def sin(z:Complex):Complex { + if (z.im == 0.0) { + return Complex(Math.sin(z.re), 0.0); + } else { + return Complex(Math.sin(z.re) * Math.cosh(z.im), Math.cos(z.re) * Math.sinh(z.im)); + } + } + @Native("java", "java.lang.Math.tan(#1)") @Native("c++", "x10aux::math_utils::tan(#1)") public static native def tan(a:Double):Double; + /** + * @return the tangent of <code>z</code> + * @see http://mathworld.wolfram.com/Tangent.html + */ + public static safe def tan(z:Complex):Complex { + if (z.im == 0.0) { + return Complex(Math.tan(z.re), 0.0); + } else { + // tan(z) = e^2iz - 1 / i (e^21z + 1) + val e2IZ = Math.exp(2.0 * Complex.I * z); + return (e2IZ - 1.0) / (Complex.I * (e2IZ + 1.0)); + } + } + @Native("java", "java.lang.Math.acos(#1)") @Native("c++", "x10aux::math_utils::acos(#1)") public static native def acos(a:Double):Double; + /** + * Returns the principal value of the inverse cosine of <code>z</code>. + * The branch cuts are on the real line at (-inf, -1) and (1, +inf) + * The real part of the inverse cosine ranges from 0 to PI. + * @return the inverse cosine of <code>z</code> + * @see http://mathworld.wolfram.com/InverseCosine.html + */ + public static safe def acos(z:Complex):Complex { + if (z.im == 0.0 && Math.abs(z.re) <= 1.0) { + return Complex(Math.acos(z.re), 0.0); + } else { + // acos(z) = pi / 2.0 + i log(iz + sqrt(1 - z^2)) + return Math.PI / 2.0 + Complex.I * Math.log(Complex.I * z + Math.sqrt(1.0 - z * z)); + } + } + @Native("java", "java.lang.Math.asin(#1)") @Native("c++", "x10aux::math_utils::asin(#1)") public static native def asin(a:Double):Double; + /** + * Returns the principal value of the inverse sine of <code>z</code>. + * The branch cuts are on the real line at (-inf, -1) and (1, +inf) + * The real part of the inverse sine ranges from -PI/2 to +PI/2. + * @return the inverse sine of <code>z</code> + * @see http://mathworld.wolfram.com/InverseSine.html + */ + public static safe def asin(z:Complex):Complex { + if (z.im == 0.0 && Math.abs(z.re) <= 1.0) { + return Complex(Math.asin(z.re), 0.0); + } else { + // asin(z) = -i * log(iz + sqrt(1 - z^2)) + return -Complex.I * Math.log(Complex.I * z + Math.sqrt(1.0 - z * z)); + } + } + @Native("java", "java.lang.Math.atan(#1)") @Native("c++", "x10aux::math_utils::atan(#1)") public static native def atan(a:Double):Double; + /** + * Returns the principal value of the inverse tangent of <code>z</code>. + * The branch cuts are on the imaginary line at (-i*inf, -i] and [i, i*inf) + * The real part of the inverse tangent ranges from -PI/2 to +PI/2. + * @return the principal value of the inverse tangent of <code>z</code> + * @see http://mathworld.wolfram.com/InverseTangent.html + */ + public static safe def atan(z:Complex):Complex { + if (z.im == 0.0) { + return Complex(Math.atan(z.re), 0.0); + } else if (z == Complex.I) { + return Complex(0.0, Double.POSITIVE_INFINITY); + } else if (z == -Complex.I) { + return Complex(0.0, Double.NEGATIVE_INFINITY); + } else { + // atan(z) = i/2 * log(1 - iz) - log(1 + iz)) + return Complex.I / 2.0 * (Math.log(1.0 - Complex.I * z) - Math.log(1.0 + Complex.I * z)); + } + } + @Native("java", "java.lang.Math.atan2(#1,#2)") @Native("c++", "x10aux::math_utils::atan2(#1,#2)") public static native def atan2(a:Double, b:Double):Double; @@ -87,18 +199,79 @@ @Native("c++", "x10aux::math_utils::cosh(#1)") public static native def cosh(a:Double):Double; + /** + * @return the hyperbolic cosine of <code>z</code> + * @see http://mathworld.wolfram.com/HyperbolicCosine.html + */ + public static safe def cosh(z:Complex):Complex { + if (z.isNaN()) { + return Complex.NaN; + } else if (z.im == 0.0) { + return Complex(Math.cosh(z.re), 0.0); + } else { + return Complex(Math.cosh(z.re) * Math.cos(z.im), Math.sinh(z.re) * Math.sin(z.im)); + } + } + @Native("java", "java.lang.Math.sinh(#1)") @Native("c++", "x10aux::math_utils::sinh(#1)") public static native def sinh(a:Double):Double; + /** + * @return the hyperbolic sine of <code>z</code> + * @see http://mathworld.wolfram.com/HyperbolicSine.html + */ + public static safe def sinh(z:Complex):Complex { + if (z.isNaN()) { + return Complex.NaN; + } else if (z.im == 0.0) { + return Complex(Math.sinh(z.re), 0.0); + } else { + return Complex(Math.sinh(z.re) * Math.cos(z.im), Math.cosh(z.re) * Math.sin(z.im)); + } + } + @Native("java", "java.lang.Math.tanh(#1)") @Native("c++", "x10aux::math_utils::tanh(#1)") public static native def tanh(a:Double):Double; + /** + * @return the hyperbolic tangent of <code>z</code> + * @see http://mathworld.wolfram.com/HyperbolicTangent.html + */ + public static safe def tanh(z:Complex):Complex { + if (z.isNaN()) { + return Complex.NaN; + } + val d = Math.cosh(2.0 * z.re) + Math.cos(2.0 * z.im); + return Complex(Math.sinh(2.0 * z.re)/d, Math.sin(2.0 * z.im)/d); + } + @Native("java", "java.lang.Math.sqrt(#1)") @Native("c++", "x10aux::math_utils::sqrt(#1)") public static native def sqrt(a:Double):Double; + /** + * Returns the principal value of the square root of <code>z</code>. + * The branch cut is on the real line at (-inf, 0) + * @return the principal square root of <code>z</code> + * @see http://mathworld.wolfram.com/SquareRoot.html + */ + public static safe def sqrt(z:Complex):Complex { + if (z.isNaN()) { + return Complex.NaN; + } else if (z == Complex.ZERO) { + return Complex.ZERO; + } else { + val t = Math.sqrt((Math.abs(z.re) + z.abs()) / 2.0); + if (z.re >= 0.0) { + return Complex(t, z.im / (2.0 * t)); + } else { + return Complex(Math.abs(z.im) / (2.0 * t), Math.copySign(t, z.im)); + } + } + } + // GPUs don't like doubles @Native("java", "(float)java.lang.Math.sqrt(#1)") @Native("c++", "(x10_float)x10aux::math_utils::sqrt(#1)") @@ -123,6 +296,19 @@ @Native("cuda", "__logf(#1)") public static native def log(a:Float):Float; + /** + * Returns the principal value of the natural logarithm of <code>z</code>. + * The branch cut is on the real line at (-inf, 0] + * @return the natural logarithm of <code>a</code> + * @see http://mathworld.wolfram.com/NaturalLogarithm.html + */ + public static safe def log(a:Complex):Complex { + if (a.isNaN()) { + return Complex.NaN; + } + return Complex(Math.log(a.abs()), Math.atan2(a.im, a.re)); + } + @Native("java", "java.lang.Math.log10(#1)") @Native("c++", "x10aux::math_utils::log10(#1)") public static native def log10(a:Double):Double; @@ -145,6 +331,13 @@ public static safe def max(a:Double, b:Double)= a<b?b:a; public static safe def min(a:Double, b:Double)= a<b?a:b; + /** + * @return the value of a with the sign of b + */ + @Native("java", "java.lang.Math.signum(#1) == java.lang.Math.signum(#2) ? #1 : -1 * #1") + @Native("c++", "x10aux::math_utils::copysign(#1,#2)") + public static native def copySign(a:Double, b:Double):Double; + public static safe def nextPowerOf2(val p: int): int { if (p==0) return 0; var pow2: int = 1; Added: trunk/x10.tests/examples/Constructs/Math/TestComplex.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Math/TestComplex.x10 (rev 0) +++ trunk/x10.tests/examples/Constructs/Math/TestComplex.x10 2010-02-24 19:32:29 UTC (rev 13029) @@ -0,0 +1,53 @@ +/* + * This file is part of the X10 project (http://x10-lang.org). + * + * This file is licensed to You under the Eclipse Public License (EPL); + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.opensource.org/licenses/eclipse-1.0.php + * + * (C) Copyright IBM Corporation 2006-2010. + * (C) Copyright Australian National University 2009-2010. + */ + +import harness.x10Test; + +/** + * Test operations on complex numbers. + * @author milthorpe + */ +class TestComplex extends x10Test { + public def run(): boolean { + val a = Complex(2.0, 2.0); + chk ((-(-a)) == a); + chk (a.abs() == Math.sqrt(8.0)); + + val b = a.conjugate(); + chk (b.conjugate() == a); + + val c = Complex(1.0, 4.0); + chk (a + c - c == a, "a + c - c = a"); + /* Note: this identity does not always hold, given peculiarities of Smith's algorithm for division */ + chk ((a * c) / c == a, "a * c / c = a"); + + + val d = Complex(4.0, -1.0); + chk (a + d - d == a, "a + d - d = a"); + + chk ((a * d) / d == a, "a * d / d = a"); + + val e = a / Complex(0.0, 0.0); + chk (e.isNaN()); + + val f = Complex(3.0, 4.0); + val fAbs = f.abs(); + chk (fAbs == 5.0); // abs(3 + 4i) = 5 by Pythagoras' theorem + + return true; + } + + public static def main(Rail[String]) { + new TestComplex().execute(); + } + +} Property changes on: trunk/x10.tests/examples/Constructs/Math/TestComplex.x10 ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Added: trunk/x10.tests/examples/Constructs/Math/TestComplexMath.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Math/TestComplexMath.x10 (rev 0) +++ trunk/x10.tests/examples/Constructs/Math/TestComplexMath.x10 2010-02-24 19:32:29 UTC (rev 13029) @@ -0,0 +1,79 @@ +/* + * This file is part of the X10 project (http://x10-lang.org). + * + * This file is licensed to You under the Eclipse Public License (EPL); + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.opensource.org/licenses/eclipse-1.0.php + * + * (C) Copyright IBM Corporation 2006-2010. + * (C) Copyright Australian National University 2009-2010. + */ + +import harness.x10Test; + +/** + * Test x10.lang.Math methods for complex operands. + * @author milthorpe + */ +class TestComplexMath extends x10Test { + public def run(): boolean { + val a = Complex(1.0, -3.1); + val z = Complex(0.5, 2.0); + + // a^z = e^(z ln a) + chk(Math.pow(a, z) == Math.exp(z * Math.log(a))); + + val sinZ = Math.sin(z); + val cosZ = Math.cos(z); + + // sin(z1 + z2) = sin(z1)cos(z2) + cos(z1)sin(z2) + chk(nearEnough(Math.sin(a + z), Math.sin(a) * cosZ + Math.cos(a) * sinZ)); + + val tanZ = Math.tan(z); + // tan(z) = sin(z) / cos(z) + chk(nearEnough(tanZ, sinZ / cosZ)); + + val secZ = 1.0 / cosZ; + // tan2(z) + 1 = sec2(z) + chk(nearEnough(secZ * secZ, tanZ * tanZ + 1.0)); + + val cotZ = 1.0 / tanZ; + val cosecZ = 1.0 / sinZ; + // cot2(z) + 1 = csc2(z) + chk(nearEnough(cosecZ * cosecZ, cotZ * cotZ + 1.0)); + + // inverse trigonometric identities + // note these won't always hold as inverse trig are all multi-valued + chk(nearEnough(Math.asin(sinZ), z)); + chk(nearEnough(Math.acos(cosZ), z)); + chk(nearEnough(Math.atan(tanZ), z)); + + val sinhZ = Math.sinh(z); + val coshZ = Math.cosh(z); + val tanhZ = Math.tanh(z); + // tanh(z) = sinh(z) / cosh(z) + chk(nearEnough(tanhZ, sinhZ / coshZ)); + + // sinh(z1 + z2) = sinh(z1)cosh(z2) + cosh(z1)sinh(z2) + chk(nearEnough(Math.sinh(a + z), Math.sinh(a) * Math.cosh(z) + Math.cosh(a) * Math.sinh(z))); + + return true; + } + + /** + * Returns true if a and b are near-enough equal. + * This sort of check is necessary because complex identities + * implemented in cartesian form in double precision are usually + * inaccurate in the last digit. + */ + private static def nearEnough(a : Complex, b : Complex) { + return ((a.re as Float) == (b.re as Float) + && (a.im as Float) == (b.im as Float)); + } + + public static def main(Rail[String]) { + new TestComplexMath().execute(); + } + +} Property changes on: trunk/x10.tests/examples/Constructs/Math/TestComplexMath.x10 ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Deleted: trunk/x10.tests/examples/Constructs/Structs/TestComplex.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Structs/TestComplex.x10 2010-02-24 15:43:38 UTC (rev 13028) +++ trunk/x10.tests/examples/Constructs/Structs/TestComplex.x10 2010-02-24 19:32:29 UTC (rev 13029) @@ -1,47 +0,0 @@ -/* - * This file is part of the X10 project (http://x10-lang.org). - * - * This file is licensed to You under the Eclipse Public License (EPL); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.opensource.org/licenses/eclipse-1.0.php - * - * (C) Copyright IBM Corporation 2006-2010. - */ - -import harness.x10Test; - -/** - * @author milthorpe - */ -class TestComplex extends x10Test { - public def run(): boolean { - val a = Complex(2.0, 2.0); - chk ((-(-a)) == a); - chk (a.abs() == Math.sqrt(8.0)); - - val b = a.conjugate(); - chk (b.conjugate() == a); - - val c = Complex(1.0, 4.0); - chk (a + c - c == a, "a + c - c = a"); - /* Note: this identity does not always hold, given peculiarities of Smith's algorithm for division */ - chk ((a * c) / c == a, "a * c / c = a"); - - - val d = Complex(4.0, -1.0); - chk (a + d - d == a, "a + d - d = a"); - - chk ((a * d) / d == a, "a * d / d = a"); - - val e = a / Complex(0.0, 0.0); - chk (e.isNaN()); - - return true; - } - - public static def main(Rail[String]) { - new TestComplex().execute(); - } - -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dgr...@us...> - 2010-02-24 20:02:17
|
Revision: 13030 http://x10.svn.sourceforge.net/x10/?rev=13030&view=rev Author: dgrove-oss Date: 2010-02-24 20:02:10 +0000 (Wed, 24 Feb 2010) Log Message: ----------- XTENLANG-910 WIP : Math.erf and Math.erfc functions for C++ runtime. Will leave 910 open until we have picked up Gamma for both backends and erf/erfc for Java backend from Apache Commons. However erf/erfc are blocking issues for ANU, so want to get at least the C++ implementation into 2.0.2. Patch contributed by Josh Milthrope from ANU under ARC Linkage Grant PAO. Modified Paths: -------------- trunk/x10.runtime/src-cpp/x10aux/math_utils.h trunk/x10.runtime/src-x10/x10/lang/Math.x10 Added Paths: ----------- trunk/x10.tests/examples/Constructs/Math/TestDoubleMath.x10 Modified: trunk/x10.runtime/src-cpp/x10aux/math_utils.h =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/math_utils.h 2010-02-24 19:32:29 UTC (rev 13029) +++ trunk/x10.runtime/src-cpp/x10aux/math_utils.h 2010-02-24 20:02:10 UTC (rev 13030) @@ -37,6 +37,8 @@ static inline x10_double log1p(x10_double x) { return ::log1p(x); } static inline x10_double sqrt(x10_double x) { return ::sqrt(x); } static inline x10_double cbrt(x10_double x) { return ::cbrt(x); } + static inline x10_double erf(x10_double x) { return ::erf(x); } + static inline x10_double erfc(x10_double x) { return ::erfc(x); } static inline x10_double hypot(x10_double x, x10_double y) { return ::hypot(x, y); } static inline x10_double ceil(x10_double x) { return ::ceil(x); } static inline x10_double floor(x10_double x) { return ::floor(x); } Modified: trunk/x10.runtime/src-x10/x10/lang/Math.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Math.x10 2010-02-24 19:32:29 UTC (rev 13029) +++ trunk/x10.runtime/src-x10/x10/lang/Math.x10 2010-02-24 20:02:10 UTC (rev 13030) @@ -282,6 +282,16 @@ @Native("c++", "x10aux::math_utils::cbrt(#1)") public static native def cbrt(a:Double):Double; + // See XTENLANG-910 + @Native("java", "Double.NaN") + @Native("c++", "x10aux::math_utils::erf(#1)") + public static native def erf(a:Double):Double; + + // See XTENLANG-910 + @Native("java", "Double.NaN") + @Native("c++", "x10aux::math_utils::erfc(#1)") + public static native def erfc(a:Double):Double; + @Native("java", "java.lang.Math.hypot(#1,#2)") @Native("c++", "x10aux::math_utils::hypot(#1,#2)") public static native def hypot(a:Double, b:Double):Double; Added: trunk/x10.tests/examples/Constructs/Math/TestDoubleMath.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Math/TestDoubleMath.x10 (rev 0) +++ trunk/x10.tests/examples/Constructs/Math/TestDoubleMath.x10 2010-02-24 20:02:10 UTC (rev 13030) @@ -0,0 +1,39 @@ +/* + * This file is part of the X10 project (http://x10-lang.org). + * + * This file is licensed to You under the Eclipse Public License (EPL); + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.opensource.org/licenses/eclipse-1.0.php + * + * (C) Copyright IBM Corporation 2006-2010. + * (C) Copyright Australian National University 2009-2010. + */ + +import harness.x10Test; + +/** + * Test x10.lang.Math operations for Double operands. + * @author milthorpe + */ +class TestDoubleMath extends x10Test { + public def run(): boolean { + // error function + val a = 0.6; + // note in general this relationship does not hold to machine precision + // if this is problematic on too many platforms, consider changing to + chk (Math.erf(a) == 1.0 - Math.erfc(a)); + + chk (Math.erf(0) == 0.0); + chk (Math.erfc(0) == 1.0); + chk (Math.erf(Double.POSITIVE_INFINITY) == 1.0); + chk (Math.erfc(Double.POSITIVE_INFINITY) == 0.0); + + return true; + } + + public static def main(Rail[String]) { + new TestDoubleMath().execute(); + } + +} Property changes on: trunk/x10.tests/examples/Constructs/Math/TestDoubleMath.x10 ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |