From: <dgr...@us...> - 2010-02-25 20:41:05
|
Revision: 13040 http://x10.svn.sourceforge.net/x10/?rev=13040&view=rev Author: dgrove-oss Date: 2010-02-25 20:40:58 +0000 (Thu, 25 Feb 2010) Log Message: ----------- Add rule to generate x10doc for XRX into x10.dist/x10doc. Add x10doc to svn:ignore of x10.dist Modified Paths: -------------- trunk/x10.doc/build.xml Property Changed: ---------------- trunk/x10.dist/ Property changes on: trunk/x10.dist ___________________________________________________________________ Modified: svn:ignore - etc gen include lib + x10doc etc gen include lib Modified: trunk/x10.doc/build.xml =================================================================== --- trunk/x10.doc/build.xml 2010-02-25 20:05:23 UTC (rev 13039) +++ trunk/x10.doc/build.xml 2010-02-25 20:40:58 UTC (rev 13040) @@ -7,12 +7,15 @@ <property name="build" location="${basedir}/classes"/> <property name="src" location="${basedir}/src"/> <property name="lib" location="${x10.dist.location}/lib"/> + <property name="xrx.src.dir" location="${x10.home}/x10.runtime/src-x10" /> + <property name="xrx.xdoc.output.dir" location="${x10.dist.location}/x10doc"/> <property name="jar" value="x10doc.jar"/> <property name="lpg.jar" value="lpg.jar"/> <property name="polyglot.jar" value="polyglot3.jar"/> <property name="compiler.jar" value="x10c.jar"/> <property name="runtime.jar" value="x10.jar"/> <property name="tools.jar" value="tools.jar"/> + <property name="bash.exe" value="bash"/> <!-- get the environment variables --> <property environment="env"/> <property name="tools.jar.location" value="${env.JAVA_HOME}/lib/${tools.jar}"/> @@ -94,4 +97,15 @@ <classpath refid="project.classpath"/> </javac> </target> + <target name="xrx-xdoc" depends="build"> + <mkdir dir="${xrx.xdoc.output.dir}"/> + <fileset id="xrx.files" dir="${xrx.src.dir}" includes="**/*.x10"/> + <pathconvert property="xrx.list" refid="xrx.files" dirsep="/" pathsep=" "/> + <echo message="x10doc -d ${xrx.xdoc.output.dir} ${xrx.list}"/> + <exec executable="${bash.exe}" failonerror="true" dir="${basedir}/bin"> + <env key="X10_ROOT" value="${x10.home}" /> + <arg value="-c" /> + <arg value="'${basedir}/bin/x10doc' -d '${xrx.xdoc.output.dir}' ${xrx.list}" /> + </exec> + </target> </project> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <vj...@us...> - 2010-02-26 02:54:15
|
Revision: 13055 http://x10.svn.sourceforge.net/x10/?rev=13055&view=rev Author: vj0 Date: 2010-02-26 02:54:04 +0000 (Fri, 26 Feb 2010) Log Message: ----------- Complete refactoring of place types -- see x10.types.PlaceChecker in the compiler. Many bugs in the place checker now fixed. Also started an effort to suppress duplicate error messages. Now the typechecker will not throw duplicate errors -- if it does please let me know. Modified Paths: -------------- trunk/x10.compiler/src/x10/ExtensionInfo.java trunk/x10.compiler/src/x10/ast/AmbDepTypeNode_c.java trunk/x10.compiler/src/x10/ast/AmbHereThis_c.java trunk/x10.compiler/src/x10/ast/AmbMacroTypeNode_c.java trunk/x10.compiler/src/x10/ast/Async_c.java trunk/x10.compiler/src/x10/ast/AtStmt_c.java trunk/x10.compiler/src/x10/ast/Closure_c.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/PlacedClosure_c.java trunk/x10.compiler/src/x10/ast/UnknownTypeNode_c.java trunk/x10.compiler/src/x10/ast/X10AmbQualifierNode_c.java trunk/x10.compiler/src/x10/ast/X10AmbTypeNode_c.java trunk/x10.compiler/src/x10/ast/X10Call_c.java trunk/x10.compiler/src/x10/ast/X10CanonicalTypeNode_c.java trunk/x10.compiler/src/x10/ast/X10ClassDecl_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/X10Formal_c.java trunk/x10.compiler/src/x10/ast/X10Initializer_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/X10Special_c.java trunk/x10.compiler/src/x10/errors/Errors.java trunk/x10.compiler/src/x10/types/ConstrainedType_c.java trunk/x10.compiler/src/x10/types/X10Context_c.java trunk/x10.compiler/src/x10/types/X10LocalDef.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/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/checker/Converter.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/types/matcher/Matcher.java trunk/x10.compiler/src/x10/types/matcher/Subst.java trunk/x10.compiler/src/x10/visit/Desugarer.java trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java trunk/x10.constraints/src/x10/constraint/XTerms.java trunk/x10.runtime/src-x10/x10/array/BaseDist.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/io/Reader.x10 trunk/x10.runtime/src-x10/x10/io/ReaderIterator.x10 trunk/x10.runtime/src-x10/x10/lang/Any.x10 trunk/x10.runtime/src-x10/x10/lang/Runtime.x10 trunk/x10.runtime/src-x10/x10/util/DistributedRail.x10 trunk/x10.tests/examples/Constructs/Place/FutureFieldAccessStruct.x10 trunk/x10.tests/examples/Constructs/Place/FutureGlobalMethodInvokeStruct.x10 Added Paths: ----------- trunk/x10.compiler/src/x10/types/checker/PlaceChecker.java trunk/x10.compiler/src/x10/types/checker/package.html trunk/x10.compiler/src/x10/visit/X10TypeChecker.java trunk/x10.tests/examples/Constructs/Place/BangACrossPlaces_MustFailCompile2.x10 trunk/x10.tests/examples/Constructs/Place/BangAcrossPlaces_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Place/ClosureBang.x10 trunk/x10.tests/examples/Constructs/Place/PlaceCheckInRail_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Place/PlaceCheckinRail_MustFailCompile2.x10 Removed Paths: ------------- trunk/x10.tests/examples/Constructs/Place/PlaceCheckInRail.x10 trunk/x10.tests/examples/Constructs/Place/PlaceCheckRail.x10 Modified: trunk/x10.compiler/src/x10/ExtensionInfo.java =================================================================== --- trunk/x10.compiler/src/x10/ExtensionInfo.java 2010-02-26 02:39:50 UTC (rev 13054) +++ trunk/x10.compiler/src/x10/ExtensionInfo.java 2010-02-26 02:54:04 UTC (rev 13055) @@ -19,11 +19,14 @@ import java.io.Reader; import java.util.ArrayList; import java.util.Collections; +import java.util.Comparator; import java.util.Enumeration; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; +import java.util.TreeSet; import java.util.jar.JarEntry; import java.util.jar.JarFile; @@ -54,7 +57,9 @@ import polyglot.types.TypeSystem; import polyglot.util.ErrorQueue; import polyglot.util.InternalCompilerError; +import polyglot.util.Position; import polyglot.visit.PruningVisitor; +import polyglot.visit.TypeChecker; import x10.ast.X10NodeFactory_c; import x10.optimizations.Optimizer; import x10.parser.X10Lexer; @@ -84,6 +89,7 @@ import x10.visit.X10InnerClassRemover; import x10.visit.X10MLVerifier; import x10.visit.X10Translator; +import x10.visit.X10TypeChecker; /** * Extension information for x10 extension. @@ -186,7 +192,32 @@ return true; return false; } - + + static class ExceptionComparator implements Comparator<SemanticException> { + public int compare(SemanticException a, SemanticException b) { + Position pa = a.position(); + if (pa == null) + return -1; + Position pb = b.position(); + if (pb==null) + return 1; + if (pa.line() < pb.line()) + return -1; + if (pb.line() < pa.line()) + return 1; + if (pa.column() < pb.column()) + return -1; + if (pb.line() < pa.line()) + return 1; + return 0; + } + } + Set<SemanticException> errors = new TreeSet<SemanticException>(new ExceptionComparator()); + + public Set<SemanticException> errorSet() { + return errors; + } + protected void initTypeSystem() { try { TopLevelResolver r = new X10SourceClassResolver(compiler, this, getOptions().constructFullClasspath(), @@ -408,6 +439,12 @@ return new VisitorGoal("X10MLTypeChecked", job, new X10MLVerifier(job, ts, nf)).intern(this); } + @Override + public Goal TypeChecked(Job job) { + TypeSystem ts = job.extensionInfo().typeSystem(); + NodeFactory nf = job.extensionInfo().nodeFactory(); + return new VisitorGoal("TypeChecked", job, new X10TypeChecker(job, ts, nf, job.nodeMemo())).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-02-26 02:39:50 UTC (rev 13054) +++ trunk/x10.compiler/src/x10/ast/AmbDepTypeNode_c.java 2010-02-26 02:54:04 UTC (rev 13055) @@ -18,6 +18,7 @@ import polyglot.ast.CanonicalTypeNode; import polyglot.ast.Expr; import polyglot.ast.Node; +import polyglot.ast.TypeCheckTypeGoal; import polyglot.ast.TypeNode; import polyglot.ast.TypeNode_c; import polyglot.types.Context; @@ -35,6 +36,7 @@ import polyglot.visit.ExceptionChecker; import polyglot.visit.NodeVisitor; import polyglot.visit.PrettyPrinter; +import polyglot.visit.TypeCheckPreparer; import polyglot.visit.TypeChecker; import x10.extension.X10Del; import x10.extension.X10Del_c; @@ -44,6 +46,7 @@ import x10.types.X10TypeSystem; import x10.types.constraints.CConstraint; import x10.types.constraints.TypeConstraint; +import x10.visit.X10TypeChecker; public class AmbDepTypeNode_c extends TypeNode_c implements AmbDepTypeNode, AddFlags { @@ -108,6 +111,14 @@ return (base != null ? base.toString() : "") + (dep != null ? dep.toString() : ""); } + public void setResolver(Node parent, final TypeCheckPreparer v) { + if (typeRef() instanceof LazyRef) { + LazyRef<Type> r = (LazyRef<Type>) typeRef(); + TypeChecker tc = new X10TypeChecker(v.job(), v.typeSystem(), v.nodeFactory(), v.getMemo()); + tc = (TypeChecker) tc.context(v.context().freeze()); + r.setResolver(new TypeCheckTypeGoal(parent, this, tc, r, false)); + } + } public Node typeCheckOverride(Node parent, ContextVisitor tc) throws SemanticException { X10TypeSystem ts = (X10TypeSystem) tc.typeSystem(); X10NodeFactory nf = (X10NodeFactory) tc.nodeFactory(); Modified: trunk/x10.compiler/src/x10/ast/AmbHereThis_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/AmbHereThis_c.java 2010-02-26 02:39:50 UTC (rev 13054) +++ trunk/x10.compiler/src/x10/ast/AmbHereThis_c.java 2010-02-26 02:54:04 UTC (rev 13055) @@ -43,6 +43,7 @@ /** Disambiguate the receiver. */ public Node disambiguate(ContextVisitor ar) throws SemanticException { X10NodeFactory nf = ((X10NodeFactory) ar.nodeFactory()); + return (ar.context().inCode()) ? nf.Here(position()) : nf.This(position()); Modified: trunk/x10.compiler/src/x10/ast/AmbMacroTypeNode_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/AmbMacroTypeNode_c.java 2010-02-26 02:39:50 UTC (rev 13054) +++ trunk/x10.compiler/src/x10/ast/AmbMacroTypeNode_c.java 2010-02-26 02:54:04 UTC (rev 13055) @@ -23,6 +23,7 @@ import polyglot.ast.Local; import polyglot.ast.Node; import polyglot.ast.Prefix; +import polyglot.ast.TypeCheckTypeGoal; import polyglot.ast.TypeNode; import polyglot.ast.TypeNode_c; import polyglot.frontend.Globals; @@ -46,6 +47,7 @@ import polyglot.visit.ExceptionChecker; import polyglot.visit.NodeVisitor; import polyglot.visit.PrettyPrinter; +import polyglot.visit.TypeCheckPreparer; import polyglot.visit.TypeChecker; import x10.constraint.XRoot; import x10.constraint.XTerms; @@ -60,6 +62,7 @@ import x10.types.X10ParsedClassType; import x10.types.X10TypeMixin; import x10.types.X10TypeSystem; +import x10.visit.X10TypeChecker; public class AmbMacroTypeNode_c extends TypeNode_c implements AmbMacroTypeNode, AddFlags { @@ -130,6 +133,15 @@ return n; } + @Override + public void setResolver(Node parent, final TypeCheckPreparer v) { + if (typeRef() instanceof LazyRef) { + LazyRef<Type> r = (LazyRef<Type>) typeRef(); + TypeChecker tc = new X10TypeChecker(v.job(), v.typeSystem(), v.nodeFactory(), v.getMemo()); + tc = (TypeChecker) tc.context(v.context().freeze()); + r.setResolver(new TypeCheckTypeGoal(parent, this, tc, r, false)); + } + } public Node visitChildren(NodeVisitor v) { Prefix prefix = (Prefix) visitChild(this.prefix, v); Id name = (Id) visitChild(this.name, v); Modified: trunk/x10.compiler/src/x10/ast/Async_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/Async_c.java 2010-02-26 02:39:50 UTC (rev 13054) +++ trunk/x10.compiler/src/x10/ast/Async_c.java 2010-02-26 02:54:04 UTC (rev 13055) @@ -44,6 +44,7 @@ import x10.types.X10Context; import x10.types.X10MethodDef; import x10.types.X10TypeSystem; +import x10.types.checker.PlaceChecker; import x10.types.constraints.XConstrainedTerm; /** @@ -148,7 +149,7 @@ } if (placeTerm == null) { - placeTerm = PlacedClosure_c.computePlaceTerm((Expr) visitChild(this.place, v), + placeTerm = PlaceChecker.computePlaceTerm((Expr) visitChild(this.place, v), (X10Context) tc.context(),ts); } Modified: trunk/x10.compiler/src/x10/ast/AtStmt_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/AtStmt_c.java 2010-02-26 02:39:50 UTC (rev 13054) +++ trunk/x10.compiler/src/x10/ast/AtStmt_c.java 2010-02-26 02:54:04 UTC (rev 13055) @@ -51,6 +51,7 @@ import x10.types.X10MethodDef; import x10.types.X10TypeMixin; import x10.types.X10TypeSystem; +import x10.types.checker.PlaceChecker; import x10.types.constraints.XConstrainedTerm; /** @@ -132,7 +133,7 @@ } if (placeTerm == null) { - placeTerm = PlacedClosure_c.computePlaceTerm((Expr) visitChild(this.place, v), + placeTerm = PlaceChecker.computePlaceTerm((Expr) visitChild(this.place, v), (X10Context) tc.context(),ts); } Modified: trunk/x10.compiler/src/x10/ast/Closure_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/Closure_c.java 2010-02-26 02:39:50 UTC (rev 13054) +++ trunk/x10.compiler/src/x10/ast/Closure_c.java 2010-02-26 02:54:04 UTC (rev 13055) @@ -65,6 +65,7 @@ import x10.types.X10TypeSystem; import x10.types.X10TypeSystem_c; import x10.util.ClosureSynthesizer; +import x10.visit.X10TypeChecker; /** * An implementation of a closure literal in the source text. @@ -365,7 +366,7 @@ if (childv instanceof TypeCheckPreparer) { TypeCheckPreparer tcp = (TypeCheckPreparer) childv; final LazyRef<Type> r = (LazyRef<Type>) tn.typeRef(); - TypeChecker tc = new TypeChecker(v.job(), v.typeSystem(), v.nodeFactory(), v.getMemo()); + TypeChecker tc = new X10TypeChecker(v.job(), v.typeSystem(), v.nodeFactory(), v.getMemo()); tc = (TypeChecker) tc.context(tcp.context().freeze()); r.setResolver(new TypeCheckReturnTypeGoal(this, body, tc, r, true)); } Modified: trunk/x10.compiler/src/x10/ast/DepParameterExpr_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/DepParameterExpr_c.java 2010-02-26 02:39:50 UTC (rev 13054) +++ trunk/x10.compiler/src/x10/ast/DepParameterExpr_c.java 2010-02-26 02:54:04 UTC (rev 13055) @@ -44,6 +44,7 @@ import x10.types.constraints.CConstraint_c; import x10.types.constraints.TypeConstraint; import x10.types.constraints.TypeConstraint_c; +import x10.visit.X10TypeChecker; /** An immutable representation of a dependent type constraint. * The corresponding syntax is [T](e){x: T; c} @@ -163,7 +164,7 @@ } public void setResolver(Node parent, final TypeCheckPreparer v) { - TypeChecker tc = new TypeChecker(v.job(), v.typeSystem(), v.nodeFactory(), v.getMemo()); + TypeChecker tc = new X10TypeChecker(v.job(), v.typeSystem(), v.nodeFactory(), v.getMemo()); tc = (TypeChecker) tc.context(v.context().freeze()); { Modified: trunk/x10.compiler/src/x10/ast/FunctionTypeNode_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/FunctionTypeNode_c.java 2010-02-26 02:39:50 UTC (rev 13054) +++ trunk/x10.compiler/src/x10/ast/FunctionTypeNode_c.java 2010-02-26 02:54:04 UTC (rev 13055) @@ -19,6 +19,7 @@ import polyglot.ast.Formal; import polyglot.ast.Node; import polyglot.ast.NodeFactory; +import polyglot.ast.TypeCheckTypeGoal; import polyglot.ast.TypeNode; import polyglot.ast.TypeNode_c; import polyglot.frontend.SetResolverGoal; @@ -41,12 +42,15 @@ import polyglot.visit.ContextVisitor; import polyglot.visit.NodeVisitor; import polyglot.visit.PrettyPrinter; +import polyglot.visit.TypeCheckPreparer; +import polyglot.visit.TypeChecker; import x10.types.ClosureDef; import x10.types.X10ClassType; import x10.types.X10TypeSystem; import x10.types.constraints.CConstraint; import x10.types.constraints.CConstraint_c; +import x10.visit.X10TypeChecker; public class FunctionTypeNode_c extends TypeNode_c implements FunctionTypeNode { @@ -138,6 +142,15 @@ return n; } + @Override + public void setResolver(Node parent, final TypeCheckPreparer v) { + if (typeRef() instanceof LazyRef) { + LazyRef<Type> r = (LazyRef<Type>) typeRef(); + TypeChecker tc = new X10TypeChecker(v.job(), v.typeSystem(), v.nodeFactory(), v.getMemo()); + tc = (TypeChecker) tc.context(v.context().freeze()); + r.setResolver(new TypeCheckTypeGoal(parent, this, tc, r, false)); + } + } /* (non-Javadoc) * @see x10.ast.FunctionTypeNode#typeParameters() */ Modified: trunk/x10.compiler/src/x10/ast/PlacedClosure_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/PlacedClosure_c.java 2010-02-26 02:39:50 UTC (rev 13054) +++ trunk/x10.compiler/src/x10/ast/PlacedClosure_c.java 2010-02-26 02:54:04 UTC (rev 13055) @@ -23,7 +23,6 @@ import polyglot.types.Context; import polyglot.types.SemanticException; import polyglot.types.Type; -import polyglot.util.InternalCompilerError; import polyglot.util.Position; import polyglot.visit.AscriptionVisitor; import polyglot.visit.CFGBuilder; @@ -32,15 +31,10 @@ import polyglot.visit.PruningVisitor; import polyglot.visit.TypeChecker; -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.checker.PlaceChecker; import x10.types.constraints.XConstrainedTerm; /** @@ -89,70 +83,7 @@ return n; } - /* @Override - public NodeVisitor typeCheckEnter(TypeChecker v) throws SemanticException { - if (placeTerm != null) { - v = (TypeChecker) v.context(pushPlaceTerm((X10Context) v.context())); - } - return v; - -} -*/ - //XTerm placeTerm; - /** - * The type of the place term. May be Ref or Place. May contain a newly generated - * var, equated to self. The associated constraint must be considered to be in scope - * when examining the body of this PlacedClosure. - */ - // Type placeType; - - public static XConstrainedTerm computePlaceTerm( Expr place, X10Context xc, - X10TypeSystem ts - ) throws SemanticException { - Type placeType = place.type(); - 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 = XTerms.makeUQV(); - } - try { - pt = XConstrainedTerm.instantiate(d, term); - } catch (XFailure z) { - - throw new InternalCompilerError("Cannot construct placeTerm from " + - term + " and constraint " + d + "."); - } - } else { - boolean placeIsRef = true; // ts.isImplicitCastValid(placeType, ts.Object(), xc); - if (placeIsRef) { - XTerm src = ts.xtypeTranslator().trans(pc, place, xc); - if (src == null) { - src = XTerms.makeUQV(); - } - try { - d= d.substitute(src, d.self()); - pt = XConstrainedTerm.make(ts.homeVar(src,xc), d); - } catch (XFailure z) { - assert false; - throw new InternalCompilerError("Cannot construct placeTerm from " + - place + " and constraint " + d + "."); - } - } else - throw new SemanticException( - "Place expression |" + place + "| must be of type \"" + - ts.Place() + "\", or " + ts.Object() + ", not \"" + place.type() + "\".", - place.position()); - } - - return pt; - } - @Override + @Override public Node typeCheckOverride(Node parent, ContextVisitor tc) throws SemanticException { X10TypeSystem ts = (X10TypeSystem) tc.typeSystem(); @@ -164,7 +95,7 @@ ClosureDef def = (ClosureDef) this.codeDef(); if (def.placeTerm() == null) { Expr e = (Expr) visitChild(place, v); - def.setPlaceTerm(computePlaceTerm(e, (X10Context) tc.context(), ts)); + def.setPlaceTerm(PlaceChecker.computePlaceTerm(e, (X10Context) tc.context(), ts)); } // now that placeTerm is set in this node, continue visiting children // enterScope will ensure that placeTerm is installed in the context. Modified: trunk/x10.compiler/src/x10/ast/UnknownTypeNode_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/UnknownTypeNode_c.java 2010-02-26 02:39:50 UTC (rev 13054) +++ trunk/x10.compiler/src/x10/ast/UnknownTypeNode_c.java 2010-02-26 02:54:04 UTC (rev 13055) @@ -15,6 +15,7 @@ import polyglot.ast.Node; import polyglot.ast.NodeFactory; import polyglot.ast.QualifierNode; +import polyglot.ast.TypeCheckTypeGoal; import polyglot.ast.TypeNode; import polyglot.ast.TypeNode_c; import polyglot.frontend.AbstractGoal_c; @@ -31,6 +32,8 @@ import polyglot.visit.NodeVisitor; import polyglot.visit.PrettyPrinter; import polyglot.visit.TypeCheckPreparer; +import polyglot.visit.TypeChecker; +import x10.visit.X10TypeChecker; public class UnknownTypeNode_c extends TypeNode_c implements UnknownTypeNode { public UnknownTypeNode_c(Position pos) { @@ -63,6 +66,7 @@ return nf.CanonicalTypeNode(position(), typeRef()); } + public void setResolver(Node parent, final TypeCheckPreparer v) { if (typeRef() instanceof LazyRef) { final LazyRef<Type> r = (LazyRef<Type>) typeRef(); Modified: trunk/x10.compiler/src/x10/ast/X10AmbQualifierNode_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10AmbQualifierNode_c.java 2010-02-26 02:39:50 UTC (rev 13054) +++ trunk/x10.compiler/src/x10/ast/X10AmbQualifierNode_c.java 2010-02-26 02:54:04 UTC (rev 13055) @@ -35,6 +35,7 @@ import polyglot.visit.TypeBuilder; import polyglot.visit.TypeCheckPreparer; import polyglot.visit.TypeChecker; +import x10.visit.X10TypeChecker; /** * An <code>X10AmbQualifierNode</code> is an ambiguous AST node composed of @@ -96,7 +97,7 @@ public void setResolver(Node parent, final TypeCheckPreparer v) { final LazyRef<Qualifier> r = (LazyRef<Qualifier>) qualifierRef(); - TypeChecker tc = new TypeChecker(v.job(), v.typeSystem(), v.nodeFactory(), v.getMemo()); + TypeChecker tc = new X10TypeChecker(v.job(), v.typeSystem(), v.nodeFactory(), v.getMemo()); tc = (TypeChecker) tc.context(v.context().freeze()); r.setResolver(new TypeCheckTypeGoal(parent, this, tc, r, false)); } Modified: trunk/x10.compiler/src/x10/ast/X10AmbTypeNode_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10AmbTypeNode_c.java 2010-02-26 02:39:50 UTC (rev 13054) +++ trunk/x10.compiler/src/x10/ast/X10AmbTypeNode_c.java 2010-02-26 02:54:04 UTC (rev 13055) @@ -21,6 +21,7 @@ import polyglot.ast.Node; import polyglot.ast.PackageNode; import polyglot.ast.Prefix; +import polyglot.ast.TypeCheckTypeGoal; import polyglot.ast.TypeNode; import polyglot.frontend.Globals; import polyglot.frontend.Goal; @@ -36,6 +37,8 @@ import polyglot.util.Position; import polyglot.visit.ContextVisitor; import polyglot.visit.PrettyPrinter; +import polyglot.visit.TypeCheckPreparer; +import polyglot.visit.TypeChecker; import x10.extension.X10Del; import x10.extension.X10Del_c; import x10.types.MacroType; @@ -44,6 +47,7 @@ import x10.types.X10ParsedClassType; import x10.types.X10TypeMixin; import x10.types.X10TypeSystem; +import x10.visit.X10TypeChecker; /** * An <code>AmbTypeNode</code> is an ambiguous AST node composed of @@ -201,6 +205,15 @@ throw ex; } + @Override + public void setResolver(Node parent, final TypeCheckPreparer v) { + if (typeRef() instanceof LazyRef) { + LazyRef<Type> r = (LazyRef<Type>) typeRef(); + TypeChecker tc = new X10TypeChecker(v.job(), v.typeSystem(), v.nodeFactory(), v.getMemo()); + tc = (TypeChecker) tc.context(v.context().freeze()); + r.setResolver(new TypeCheckTypeGoal(parent, this, tc, r, false)); + } + } static TypeNode postprocess(CanonicalTypeNode result, TypeNode n, ContextVisitor childtc) throws SemanticException { Flags f = ((X10AmbTypeNode_c) n).flags; Modified: trunk/x10.compiler/src/x10/ast/X10Call_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10Call_c.java 2010-02-26 02:39:50 UTC (rev 13054) +++ trunk/x10.compiler/src/x10/ast/X10Call_c.java 2010-02-26 02:54:04 UTC (rev 13055) @@ -78,6 +78,7 @@ import x10.types.X10TypeSystem; import x10.types.XTypeTranslator; import x10.types.checker.Converter; +import x10.types.checker.PlaceChecker; import x10.types.constraints.XConstrainedTerm; import x10.types.matcher.DumbMethodMatcher; @@ -465,7 +466,7 @@ } if (n instanceof X10Call_c) - ((X10Call_c) n).checkLocalReceiver(tc); + PlaceChecker.checkLocalReceiver((Call) n, tc); // We have both! @@ -559,7 +560,7 @@ ///////////////////////////////////////////////////////////////////// result.checkProtoMethod(); - result.checkLocalReceiver(tc); + PlaceChecker.checkLocalReceiver(result, tc); // the arguments here. result.checkConsistency(c); // result = result.adjustMI(tc); @@ -570,38 +571,7 @@ } - public void checkLocalReceiver( ContextVisitor tc) - throws SemanticException { - X10Flags xFlags = X10Flags.toX10Flags(methodInstance().flags()); - // A global method can be invoked from anywhere. - if (xFlags.isGlobal()) - return; - - // A static method can be invoked from anywhere. - if (xFlags.isStatic()) - return; - - X10TypeSystem ts = (X10TypeSystem) tc.typeSystem(); - X10Context xc = (X10Context) tc.context(); - - Receiver target = target(); - - - // Method invocations on structs are always permitted - if (ts.isStructType(target.type())) - return; - - - if (ts.isHere(target, xc)) - return; - - XConstrainedTerm h = xc.currentPlaceTerm(); - if (h != null && h.equals(((X10TypeSystem) tc.typeSystem()).globalPlace())) { - throw new Errors.PlaceTypeErrorMethodShouldBeGlobal(this, 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 { final X10TypeSystem ts = (X10TypeSystem) tc.typeSystem(); final Context context = tc.context(); Modified: trunk/x10.compiler/src/x10/ast/X10CanonicalTypeNode_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10CanonicalTypeNode_c.java 2010-02-26 02:39:50 UTC (rev 13054) +++ trunk/x10.compiler/src/x10/ast/X10CanonicalTypeNode_c.java 2010-02-26 02:54:04 UTC (rev 13055) @@ -18,6 +18,7 @@ import polyglot.ast.CanonicalTypeNode_c; import polyglot.ast.Expr; import polyglot.ast.Node; +import polyglot.ast.TypeCheckTypeGoal; import polyglot.frontend.SetResolverGoal; import polyglot.types.ClassDef; import polyglot.types.CodeDef; @@ -34,6 +35,7 @@ import polyglot.util.InternalCompilerError; import polyglot.util.Position; import polyglot.visit.TypeBuilder; +import polyglot.visit.TypeCheckPreparer; import polyglot.visit.TypeChecker; import polyglot.visit.ContextVisitor; import polyglot.visit.NodeVisitor; @@ -48,6 +50,7 @@ import x10.types.X10TypeMixin; import x10.types.X10TypeSystem; +import x10.visit.X10TypeChecker; public class X10CanonicalTypeNode_c extends CanonicalTypeNode_c implements X10CanonicalTypeNode, AddFlags { @@ -165,6 +168,15 @@ } @Override + public void setResolver(Node parent, final TypeCheckPreparer v) { + if (typeRef() instanceof LazyRef) { + LazyRef<Type> r = (LazyRef<Type>) typeRef(); + TypeChecker tc = new X10TypeChecker(v.job(), v.typeSystem(), v.nodeFactory(), v.getMemo()); + tc = (TypeChecker) tc.context(v.context().freeze()); + r.setResolver(new TypeCheckTypeGoal(parent, this, tc, r, false)); + } + } + @Override public Node conformanceCheck(ContextVisitor tc) throws SemanticException { Type t = type(); Modified: trunk/x10.compiler/src/x10/ast/X10ClassDecl_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10ClassDecl_c.java 2010-02-26 02:39:50 UTC (rev 13054) +++ trunk/x10.compiler/src/x10/ast/X10ClassDecl_c.java 2010-02-26 02:54:04 UTC (rev 13055) @@ -293,7 +293,7 @@ } public Context enterChildScope(Node child, Context c) { X10Context xc = (X10Context) c; - if (child != this.body) { + if (child != this.body ) { X10ClassDef_c type = (X10ClassDef_c) this.type; xc = xc.pushSuperTypeDeclaration(type); @@ -339,7 +339,7 @@ // return child.del().enterScope(xc); // } - if (child == this.body) { + if (child == this.body || child == this.properties || (this.properties != null && this.properties.contains(child))) { X10ClassDef_c type = (X10ClassDef_c) this.type; xc = (X10Context) xc.pushClass(type, type.asType()); // Add type parameters Modified: trunk/x10.compiler/src/x10/ast/X10ConstructorDecl_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10ConstructorDecl_c.java 2010-02-26 02:39:50 UTC (rev 13054) +++ trunk/x10.compiler/src/x10/ast/X10ConstructorDecl_c.java 2010-02-26 02:54:04 UTC (rev 13055) @@ -64,6 +64,7 @@ import x10.types.X10TypeMixin; import x10.types.X10TypeSystem; +import x10.types.checker.PlaceChecker; import x10.types.constraints.CConstraint; import x10.types.constraints.TypeConstraint; import x10.types.constraints.XConstrainedTerm; @@ -227,11 +228,7 @@ 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)); - } + c = PlaceChecker.pushHereIsThisHome(xc); } Modified: trunk/x10.compiler/src/x10/ast/X10FieldAssign_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10FieldAssign_c.java 2010-02-26 02:39:50 UTC (rev 13054) +++ trunk/x10.compiler/src/x10/ast/X10FieldAssign_c.java 2010-02-26 02:54:04 UTC (rev 13055) @@ -32,6 +32,7 @@ import x10.types.X10TypeMixin; import x10.types.checker.Checker; +import x10.types.checker.PlaceChecker; import x10.errors.Errors; public class X10FieldAssign_c extends FieldAssign_c { @@ -77,7 +78,7 @@ if (! (ts.isSubtype(s, t, tc.context()))) throw new Errors.CannotAssign(n.right(), n.target().type(), n.position); - n.checkFieldPlaceType(tc); + PlaceChecker.checkFieldPlaceType((Field) left(tc.nodeFactory()), (X10Context) tc.context()); n= (X10FieldAssign_c) n.type(t); return n; @@ -86,7 +87,4 @@ return Checker.typeCheckAssign(n, tc); } - public void checkFieldPlaceType(ContextVisitor tc) throws SemanticException { - ((X10Field_c) left(tc.nodeFactory())).checkFieldPlaceType(tc); - } } \ No newline at end of file Modified: trunk/x10.compiler/src/x10/ast/X10FieldDecl_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10FieldDecl_c.java 2010-02-26 02:39:50 UTC (rev 13054) +++ trunk/x10.compiler/src/x10/ast/X10FieldDecl_c.java 2010-02-26 02:54:04 UTC (rev 13055) @@ -25,6 +25,8 @@ import polyglot.ast.Node; import polyglot.ast.StringLit; import polyglot.ast.TypeNode; +import polyglot.frontend.AbstractGoal_c; +import polyglot.frontend.Goal; import polyglot.types.ClassDef; import polyglot.types.Context; import polyglot.types.FieldDef; @@ -39,6 +41,7 @@ import polyglot.types.Type; import polyglot.types.TypeSystem; import polyglot.types.Types; +import polyglot.types.VarDef_c.ConstantValue; import polyglot.util.CollectionUtil; import polyglot.util.Position; import polyglot.visit.AscriptionVisitor; @@ -48,6 +51,7 @@ import polyglot.visit.TypeCheckPreparer; import polyglot.visit.TypeChecker; import x10.constraint.XTerm; +import x10.errors.Errors; import x10.extension.X10Del; import x10.extension.X10Del_c; import x10.extension.X10Ext; @@ -64,7 +68,9 @@ import x10.types.X10TypeSystem; import x10.types.checker.Checker; import x10.types.checker.Converter; +import x10.types.checker.PlaceChecker; import x10.types.constraints.XConstrainedTerm; +import x10.visit.X10TypeChecker; public class X10FieldDecl_c extends FieldDecl_c implements X10FieldDecl { @@ -89,22 +95,49 @@ 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)); - } - + + if (child == this.type || child == this.init) { + c = PlaceChecker.pushHereTerm(fieldDef(), (X10Context) c); } Context cc = super.enterChildScope(child, c); return cc; } + + @Override + public void setResolver(final Node parent, TypeCheckPreparer v) { + final FieldDef def = fieldDef(); + Ref<ConstantValue> rx = def.constantValueRef(); + if (rx instanceof LazyRef) { + LazyRef<ConstantValue> r = (LazyRef<ConstantValue>) rx; + TypeChecker tc0 = new X10TypeChecker(v.job(), v.typeSystem(), v.nodeFactory(), v.getMemo()); + final TypeChecker tc = (TypeChecker) tc0.context(v.context().freeze()); + final Node n = this; + r.setResolver(new AbstractGoal_c("ConstantValue") { + public boolean runTask() { + if (state() == Goal.Status.RUNNING_RECURSIVE || state() == Goal.Status.RUNNING_WILL_FAIL) { + // The field is not constant if the initializer is recursive. + // + // But, we could be checking if the field is constant for another + // reference in the same file: + // + // m() { use x; } + // final int x = 1; + // + // So this is incorrect. The goal below needs to be refined to only visit the initializer. + def.setNotConstant(); + } + else { + Node m = parent.visitChild(n, tc); + tc.job().nodeMemo().put(n, m); + tc.job().nodeMemo().put(m, m); + } + return true; + } + }); + } + } + public Node conformanceCheck(ContextVisitor tc) throws SemanticException { Node result = super.conformanceCheck(tc); @@ -246,7 +279,7 @@ if (childv instanceof TypeCheckPreparer) { TypeCheckPreparer tcp = (TypeCheckPreparer) childv; final LazyRef<Type> r = (LazyRef<Type>) tn.typeRef(); - TypeChecker tc = new TypeChecker(v.job(), v.typeSystem(), v.nodeFactory(), v.getMemo()); + TypeChecker tc = new X10TypeChecker(v.job(), v.typeSystem(), v.nodeFactory(), v.getMemo()); tc = (TypeChecker) tc.context(tcp.context().freeze()); r.setResolver(new TypeCheckExprGoal(this, init, tc, r)); } @@ -256,8 +289,9 @@ @Override public Node typeCheckOverride(Node parent, ContextVisitor tc) throws SemanticException { + if (type() instanceof UnknownTypeNode) { - NodeVisitor childtc = tc.enter(parent, this); + NodeVisitor childtc = tc.enter(parent, this); Expr init = (Expr) this.visitChild(init(), childtc); if (init != null) { @@ -271,6 +305,8 @@ t = ct.superClass(); } } + X10Context xc = (X10Context) enterChildScope(type(), tc.context()); + t = PlaceChecker.ReplaceHereByPlaceTerm(t, xc); LazyRef<Type> r = (LazyRef<Type>) type().typeRef(); r.update(t); @@ -292,82 +328,88 @@ } return super.typeCheckOverride(parent, tc); } - + @Override - public Node typeCheck(ContextVisitor tc) throws SemanticException { + public Node typeCheck(ContextVisitor tc) throws SemanticException { Type type = this.type().type(); + Type oldType = (Type)type.copy(); + X10Context xc = (X10Context) enterChildScope(type(), tc.context()); - if (type.isVoid()) - throw new SemanticException("Field cannot have type " + this.type().type() + ".", position()); + + // Need to replace here by current placeTerm in type, + // since the field of this type can be referenced across + // a place shift. So here must be bound to the current placeTerm. + + type = PlaceChecker.ReplaceHereByPlaceTerm(type, xc); - if (X10TypeMixin.isProto(type)) { - throw new SemanticException("Field cannot have type " - + this.type().type() + " (a proto type).", position()); - - } - X10TypeSystem ts = (X10TypeSystem) tc.typeSystem(); + if (type.isVoid()) + throw new SemanticException("Field cannot have type " + this.type().type() + ".", position()); - 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()); - } - - X10NodeFactory nf = (X10NodeFactory) tc.nodeFactory(); - X10Context context = (X10Context) tc.context(); - - X10FieldDecl_c n = this; + if (X10TypeMixin.isProto(type)) { + throw new SemanticException("Field cannot have type " + + type + " (a proto type).", position()); - // Add an initializer to uninitialized var fields. - if (! n.flags().flags().isFinal() && n.init() == null) { - Type t = n.type().type(); - Expr e = null; - if (t.isBoolean()) { - e = (Expr) nf.BooleanLit(position(), false).del().typeCheck(tc).checkConstants(tc); - } - if (t.isIntOrLess()) { - e = (Expr) nf.IntLit(position(), IntLit.INT, 0L).del().typeCheck(tc).checkConstants(tc); - } - if (t.isLong()) { - e = (Expr) nf.IntLit(position(), IntLit.LONG, 0L).del().typeCheck(tc).checkConstants(tc); - } - if (t.isFloat()) { - e = (Expr) nf.FloatLit(position(), FloatLit.FLOAT, 0.0).del().typeCheck(tc).checkConstants(tc); - } - if (t.isDouble()) { - e = (Expr) nf.FloatLit(position(), FloatLit.DOUBLE, 0.0).del().typeCheck(tc).checkConstants(tc); - } - if (ts.isSubtype(t, ts.String(), tc.context())) { - e = (Expr) nf.StringLit(position(), "").del().typeCheck(tc).checkConstants(tc); - } - if (ts.isReferenceType(t, context)) { - e = (Expr) nf.NullLit(position()).del().typeCheck(tc).checkConstants(tc); - } - - if (e != null) { - n = (X10FieldDecl_c) n.init(e); - } - } - - if (init != null) { - try { - Expr newInit = Converter.attemptCoercion(tc, init, this.type().type()); - return this.init(newInit); - } - catch (SemanticException e) { - throw new SemanticException("The type of the variable " + - "initializer \"" + init.type() + - "\" does not match that of " + - "the declaration \"" + - type + "\".", - init.position()); - } - } + } + X10TypeSystem ts = (X10TypeSystem) tc.typeSystem(); - return this; - } + 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()); + } + X10NodeFactory nf = (X10NodeFactory) tc.nodeFactory(); + X10Context context = (X10Context) tc.context(); + + X10FieldDecl_c n = (X10FieldDecl_c) this.type(nf.CanonicalTypeNode(type().position(), type)); + + // Add an initializer to uninitialized var fields. + if (! n.flags().flags().isFinal() && n.init() == null) { + Type t = n.type().type(); + Expr e = null; + if (t.isBoolean()) { + e = (Expr) nf.BooleanLit(position(), false).del().typeCheck(tc).checkConstants(tc); + } + if (t.isIntOrLess()) { + e = (Expr) nf.IntLit(position(), IntLit.INT, 0L).del().typeCheck(tc).checkConstants(tc); + } + if (t.isLong()) { + e = (Expr) nf.IntLit(position(), IntLit.LONG, 0L).del().typeCheck(tc).checkConstants(tc); + } + if (t.isFloat()) { + e = (Expr) nf.FloatLit(position(), FloatLit.FLOAT, 0.0).del().typeCheck(tc).checkConstants(tc); + } + if (t.isDouble()) { + e = (Expr) nf.FloatLit(position(), FloatLit.DOUBLE, 0.0).del().typeCheck(tc).checkConstants(tc); + } + if (ts.isSubtype(t, ts.String(), tc.context())) { + e = (Expr) nf.StringLit(position(), "").del().typeCheck(tc).checkConstants(tc); + } + if (ts.isReferenceType(t, context)) { + e = (Expr) nf.NullLit(position()).del().typeCheck(tc).checkConstants(tc); + } + + if (e != null) { + n = (X10FieldDecl_c) n.init(e); + } + } + + if (n.init != null) { + try { + xc = (X10Context) n.enterChildScope(n.init, tc.context()); + ContextVisitor childtc = tc.context(xc); + Expr newInit = Converter.attemptCoercion(childtc, n.init, oldType); // use the oldType. The type of n.init may have "here". + return n.init(newInit); + } + catch (SemanticException e) { + throw new Errors.FieldInitTypeWrong(init, type, init.position()); + } + } + + return n; + } + public Type childExpectedType(Expr child, AscriptionVisitor av) { if (child == init) { TypeSystem ts = av.typeSystem(); Modified: trunk/x10.compiler/src/x10/ast/X10Field_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10Field_c.java 2010-02-26 02:39:50 UTC (rev 13054) +++ trunk/x10.compiler/src/x10/ast/X10Field_c.java 2010-02-26 02:54:04 UTC (rev 13055) @@ -53,9 +53,9 @@ import x10.types.X10TypeMixin; import x10.types.X10TypeSystem; +import x10.types.checker.PlaceChecker; 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; @@ -176,9 +176,8 @@ } checkFieldAccessesInDepClausesAreFinal(result, tc); + PlaceChecker.checkFieldPlaceType(result, c); - result.checkFieldPlaceType(tc); - //System.err.println("X10Field_c: typeCheck " + result+ " has type " + result.type()); return result; } catch (NoMemberException e) { @@ -267,40 +266,6 @@ private static final boolean ENABLE_PLACE_TYPES = true; - public void checkFieldPlaceType( ContextVisitor tc) - throws SemanticException { - X10Flags xFlags = X10Flags.toX10Flags(fieldInstance().flags()); - // A global field can be accessed from anywhere. - if (xFlags.isGlobal()) - return; - - // A static field can be accessed from anywhere. - if (xFlags.isStatic()) - return; - - X10TypeSystem ts = (X10TypeSystem) tc.typeSystem(); - X10Context xc = (X10Context) tc.context(); - - Receiver target = target(); - if (! ts.isSubtype(target.type(), ts.Object(), xc)) - return; - - if (ts.isHere(target, xc)) - return; - - XConstrainedTerm h = xc.currentPlaceTerm(); - if (h != null && h.equals(((X10TypeSystem) tc.typeSystem()).globalPlace())) { - throw new Errors.PlaceTypeErrorFieldShouldBeGlobal(this, - position()); - } - XTerm placeTerm=null; - if (h!= null) - placeTerm = h.term(); - throw new Errors.PlaceTypeErrorFieldShouldBeLocalOrGlobal(this, - placeTerm, - position()); - } - protected void checkFieldAccessesInDepClausesAreFinal(X10Field_c result, ContextVisitor tc) throws SemanticException { // Check that field accesses in dep clauses refer to final fields. Modified: trunk/x10.compiler/src/x10/ast/X10Formal_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10Formal_c.java 2010-02-26 02:39:50 UTC (rev 13054) +++ trunk/x10.compiler/src/x10/ast/X10Formal_c.java 2010-02-26 02:54:04 UTC (rev 13055) @@ -58,6 +58,8 @@ import x10.types.X10TypeMixin; import x10.types.X10TypeSystem; +import x10.types.checker.PlaceChecker; +import x10.types.constraints.XConstrainedTerm; import x10.visit.X10PrettyPrinterVisitor; import x10.visit.X10Translator; @@ -122,7 +124,7 @@ * @see polyglot.ext.jl.ast.Formal#addDecls() */ public void addDecls(Context c) { - super.addDecls(c); + c.addVariable(li.asInstance()); for (Iterator<Formal> j = this.vars().iterator(); j.hasNext(); ) { Formal fj = (Formal) j.next(); fj.addDecls(c); @@ -162,10 +164,13 @@ final X10TypeSystem ts = (X10TypeSystem) v.typeSystem(); final X10Context context = (X10Context) v.context(); final ClassDef currClassDef = context.currentClassDef(); + Formal f = (Formal) this; X10LocalDef li = (X10LocalDef) f.localDef(); + if (f.type() instanceof UnknownTypeNode && parent instanceof Formal) { + // We infer the types of exploded formals final UnknownTypeNode tn = (UnknownTypeNode) f.type(); final LazyRef<Type> r = (LazyRef<Type>) tn.typeRef(); r.setResolver(new Runnable() { @@ -197,11 +202,27 @@ r.update(ts.unknownType(tn.position())); } }); - } + } return null; } + @Override + public Type declType() { + return type.type(); + } + + @Override + public Node typeCheckOverride(Node parent, ContextVisitor tc) throws SemanticException { + NodeVisitor childtc = tc.enter(parent, this); + + XConstrainedTerm pt = ((X10Context) ((ContextVisitor) childtc).context()).currentPlaceTerm(); + + if (pt != null) + ((X10LocalDef) localDef()).setPlaceTerm(pt.term()); + return null; + } + @Override public Node typeCheck(ContextVisitor tc) throws SemanticException { X10Formal_c n = (X10Formal_c) super.typeCheck(tc); if (n.type() instanceof UnknownTypeNode || n.type().type() instanceof UnknownType) { Modified: trunk/x10.compiler/src/x10/ast/X10Initializer_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10Initializer_c.java 2010-02-26 02:39:50 UTC (rev 13054) +++ trunk/x10.compiler/src/x10/ast/X10Initializer_c.java 2010-02-26 02:54:04 UTC (rev 13055) @@ -14,14 +14,18 @@ import polyglot.ast.Block; import polyglot.ast.FlagsNode; import polyglot.ast.Initializer_c; +import polyglot.ast.Node; import polyglot.types.ClassDef; +import polyglot.types.Context; import polyglot.types.Flags; import polyglot.types.InitializerDef; import polyglot.types.TypeSystem; import polyglot.types.Types; import polyglot.util.Position; import x10.types.X10ClassDef; +import x10.types.X10Context; import x10.types.X10InitializerDef; +import x10.types.checker.PlaceChecker; public class X10Initializer_c extends Initializer_c { @@ -32,8 +36,16 @@ public InitializerDef createInitializerDef(TypeSystem ts, ClassDef ct, Flags flags) { X10InitializerDef ii; ii = (X10InitializerDef) super.createInitializerDef(ts, ct , flags); - ii.setThisVar(((X10ClassDef) ct).thisVar()); + if (! ii.flags().isStatic()) + ii.setThisVar(((X10ClassDef) ct).thisVar()); return ii; } + @Override + public Context enterChildScope(Node child, Context c) { + if (child == body ) { + c = PlaceChecker.pushHereTerm(initializerDef(), (X10Context) c); + } + return c; + } } Modified: trunk/x10.compiler/src/x10/ast/X10LocalDecl_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10LocalDecl_c.java 2010-02-26 02:39:50 UTC (rev 13054) +++ trunk/x10.compiler/src/x10/ast/X10LocalDecl_c.java 2010-02-26 02:54:04 UTC (rev 13055) @@ -49,8 +49,12 @@ import x10.types.X10Context; import x10.types.X10FieldDef; import x10.types.X10LocalDef; +import x10.types.X10TypeSystem; import x10.types.checker.Converter; +import x10.types.checker.PlaceChecker; +import x10.types.constraints.XConstrainedTerm; import x10.visit.X10PrettyPrinterVisitor; +import x10.visit.X10TypeChecker; public class X10LocalDecl_c extends LocalDecl_c implements X10VarDecl { @@ -70,7 +74,7 @@ super.addDecls(c); } - + @Override public Node buildTypes(TypeBuilder tb) throws SemanticException { if (type instanceof UnknownTypeNode) { @@ -86,7 +90,6 @@ // This installs a LocalDef X10LocalDecl_c n = (X10LocalDecl_c) super.buildTypes(tb); - X10LocalDef fi = (X10LocalDef) n.localDef(); List<AnnotationNode> as = ((X10Del) n.del()).annotations(); @@ -108,8 +111,13 @@ */ @Override public Node typeCheckOverride(Node parent, ContextVisitor tc) throws SemanticException { + NodeVisitor childtc = tc.enter(parent, this); + + XConstrainedTerm pt = ((X10Context) tc.context()).currentPlaceTerm(); + assert pt.term()!= null; + ((X10LocalDef) localDef()).setPlaceTerm(pt.term()); if (type() instanceof UnknownTypeNode) { - NodeVisitor childtc = tc.enter(parent, this); + Expr init = (Expr) this.visitChild(init(), childtc); if (init != null) { @@ -151,7 +159,13 @@ */ @Override public Node typeCheck(ContextVisitor tc) throws SemanticException { - if (this.type().type().isVoid()) + Type type = type().type(); + + type = PlaceChecker.ReplaceHereByPlaceTerm(type, (X10Context) tc.context()); + Ref<Type> r = (Ref<Type>) type().typeRef(); + r.update(type); + + if (type.isVoid()) throw new SemanticException("Local variable cannot have type " + this.type().type() + ".", position()); TypeSystem ts = tc.typeSystem(); @@ -163,15 +177,17 @@ throw new SemanticException(e.getMessage(), position()); } + X10LocalDecl_c n = (X10LocalDecl_c) this.type(tc.nodeFactory().CanonicalTypeNode(type().position(), type)); + // Need to check that the initializer is a subtype of the (declared or inferred) type of the variable, // or can be implicitly coerced to the type. - if (init != null) { + if (n.init != null) { try { - Expr newInit = Converter.attemptCoercion(tc, init, this.type().type()); - return this.init(newInit); + Expr newInit = Converter.attemptCoercion(tc, n.init, type); + return n.init(newInit); } catch (SemanticException e) { - throw new Errors.CannotAssign(init, this.type().type(), init.position()); + throw new Errors.CannotAssign(n.init, type, n.init.position()); } } @@ -189,7 +205,7 @@ if (childv instanceof TypeCheckPreparer) { TypeCheckPreparer tcp = (TypeCheckPreparer) childv; final LazyRef<Type> r = (LazyRef<Type>) tn.typeRef(); - TypeChecker tc = new TypeChecker(v.job(), v.typeSystem(), v.nodeFactory(), v.getMemo()); + TypeChecker tc = new X10TypeChecker(v.job(), v.typeSystem(), v.nodeFactory(), v.getMemo()); tc = (TypeChecker) tc.context(tcp.context().freeze()); r.setResolver(new TypeCheckExprGoal(this, init, tc, r)); } Modified: trunk/x10.compiler/src/x10/ast/X10Local_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10Local_c.java 2010-02-26 02:39:50 UTC (rev 13054) +++ trunk/x10.compiler/src/x10/ast/X10Local_c.java 2010-02-26 02:54:04 UTC (rev 13055) @@ -42,6 +42,7 @@ import x10.types.X10ProcedureDef; import x10.types.X10TypeMixin; import x10.types.X10TypeSystem; +import x10.types.checker.PlaceChecker; import x10.types.constraints.CConstraint; import x10.types.constraints.CConstraint_c; @@ -81,7 +82,8 @@ // Add in self==x to local variable x. - result = (X10Local_c) result.type(((X10LocalInstance) li).rightType()); + Type type = ((X10LocalInstance) li).rightType(); + result = (X10Local_c) result.type(type); // Fold in the method's guard. // %%% FIXME: move method guard into context.currentConstraint Modified: trunk/x10.compiler/src/x10/ast/X10Loop_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10Loop_c.java 2010-02-26 02:39:50 UTC (rev 13054) +++ trunk/x10.compiler/src/x10/ast/X10Loop_c.java 2010-02-26 02:54:04 UTC (rev 13055) @@ -63,6 +63,7 @@ import x10.types.constraints.CConstraint; import x10.types.matcher.Subst; import x10.util.Synthesizer; +import x10.visit.X10TypeChecker; /** * Captures the commonality of for, foreach and ateach loops in X10. @@ -352,7 +353,7 @@ if (childv instanceof TypeCheckPreparer) { final TypeCheckPreparer tcp = (TypeCheckPreparer) childv; final LazyRef<Type> r = (LazyRef<Type>) tn.typeRef(); - TypeChecker tc = new TypeChecker(v.job(), v.typeSystem(), v.nodeFactory(), + TypeChecker tc = new X10TypeChecker(v.job(), v.typeSystem(), v.nodeFactory(), v.getMemo()); tc = (TypeChecker) tc.context(tcp.context().freeze()); Modified: trunk/x10.compiler/src/x10/ast/X10MethodDecl_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10MethodDecl_c.java 2010-02-26 02:39:50 UTC (rev 13054) +++ trunk/x10.compiler/src/x10/ast/X10MethodDecl_c.java 2010-02-26 02:54:04 UTC (rev 13055) @@ -105,9 +105,11 @@ import x10.types.X10TypeSystem; import x10.types.XTypeTranslator; import x10.types.checker.Checker; +import x10.types.checker.PlaceChecker; import x10.types.constraints.CConstraint; import x10.types.constraints.TypeConstraint; import x10.types.constraints.XConstrainedTerm; +import x10.visit.X10TypeChecker; /** A representation of a method declaration. * Includes an extra field to represent the guard @@ -120,6 +122,9 @@ // The representation of the guard on the method definition DepParameterExpr guard; List<TypeParamNode> typeParameters; + + // set by createMethodDef. + XTerm placeTerm; public X10MethodDecl_c(Position pos, FlagsNode flags, TypeNode returnType, Id name, @@ -127,6 +132,7 @@ super(pos, flags, returnType, name, formals, throwTypes, body); this.guard = guard; this.typeParameters = TypedList.copyAndCheck(typeParams, TypeParamNode.class, true); + } @@ -134,6 +140,7 @@ protected MethodDef createMethodDef(TypeSystem ts, ClassDef ct, Flags flags) { X10MethodDef mi = (X10MethodDef) super.createMethodDef(ts, ct, flags); mi.setThisVar(((X10ClassDef) ct).thisVar()); + this.placeTerm = PlaceChecker.methodPT(flags, ct); return mi; } @@ -210,7 +217,7 @@ X10MethodDef mi = (X10MethodDef) this.mi; if (mi.body() instanceof LazyRef) { LazyRef<XTerm> r = (LazyRef<XTerm>) mi.body(); - TypeChecker tc = new TypeChecker(v.job(), v.typeSystem(), v.nodeFactory(), v.getMemo()); + TypeChecker tc = new X10TypeChecker(v.job(), v.typeSystem(), v.nodeFactory(), v.getMemo()); tc = (TypeChecker) tc.context(v.context().freeze()); r.setResolver(new TypeCheckFragmentGoal(parent, this, tc, r, false)); } @@ -266,22 +273,13 @@ // Ensure that the place constraint is set appropriately when // entering the body of the method, the return type and the throw type. - X10Context xc = (X10Context) c; - if (child == body || child == returnType || child == throwTypes) { - X10TypeSystem xts = (X10TypeSystem) c.typeSystem(); - X10Flags flags = X10Flags.toX10Flags(methodDef().flags()); - boolean isGlobal = flags.isGlobal() || X10Flags.toX10Flags(xc.currentClass().flags()).isStruct(); - if (! isGlobal) { - 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)); - } - } + + if (child == body || child == returnType || child == throwTypes || (formals != null && formals.contains(child))) { + if (placeTerm != null) + c = ((X10Context) c).pushPlace( XConstrainedTerm.make(placeTerm)); + // PlaceChecker.pushHereTerm(methodDef(), (X10Context) c); } - - - + // Add the method guard into the environment. if (guard != null) { Ref<CConstraint> vc = guard.valueConstraint(); @@ -339,7 +337,7 @@ if (childv instanceof TypeCheckPreparer) { TypeCheckPreparer tcp = (TypeCheckPreparer) childv; final LazyRef<Type> r = (LazyRef<Type>) tn.typeRef(); - TypeChecker tc = new TypeChecker(v.job(), v.typeSystem(), v.nodeFactory(), v.getMemo()); + TypeChecker tc = new X10TypeChecker(v.job(), v.typeSystem(), v.nodeFactory(), v.getMemo()); tc = (TypeChecker) tc.context(tcp.context().freeze()); r.setResolver(new TypeCheckReturnTypeGoal(this, body, tc, r, true)); } @@ -873,10 +871,13 @@ nn.visitList(nn.typeParameters(),childtc1); nn.visitList(nn.formals(),childtc1); (( X10Context ) childtc1.context()).setVarWhoseTypeIsBeingElaborated(null); - final TypeNode r = (TypeNode) nn.visitChild(nn.returnType(), childtc1); - if (childtc1.hasErrors()) throw new SemanticException(); - nn = (X10MethodDecl) nn.returnType(r); - ((Ref<Type>) nn.methodDef().returnType()).update(r.type()); + { + final TypeNode r = (TypeNode) nn.visitChild(nn.returnType(), childtc1); + if (childtc1.hasErrors()) throw new SemanticException(); + nn = (X10MethodDecl) nn.returnType(r); + Type type = PlaceChecker.ReplaceHereByPlaceTerm(r.type(), ( X10Context ) childtc1.... [truncated message content] |
From: <ipe...@us...> - 2010-02-26 19:36:49
|
Revision: 13072 http://x10.svn.sourceforge.net/x10/?rev=13072&view=rev Author: ipeshansky Date: 2010-02-26 19:36:42 +0000 (Fri, 26 Feb 2010) Log Message: ----------- d2u and normalize properties Modified Paths: -------------- trunk/x10.compiler/src/x10/errors/Errors.java trunk/x10.tests/examples/Constructs/Cast/ReferenceDependentTypeCast/X10DepTypeSubClassOne.x10 trunk/x10.tests/examples/Constructs/Inference/LCA1.x10 trunk/x10.tests/examples/Constructs/Types/NullableObjectEqualsPrimitive_MustFailCompile.x10 Property Changed: ---------------- trunk/x10.compiler/src/x10/errors/Errors.java trunk/x10.tests/examples/Constructs/Cast/ReferenceDependentTypeCast/X10DepTypeSubClassOne.x10 trunk/x10.tests/examples/Constructs/Inference/LCA1.x10 trunk/x10.tests/examples/Constructs/Types/NullableObjectEqualsPrimitive_MustFailCompile.x10 Modified: trunk/x10.compiler/src/x10/errors/Errors.java =================================================================== --- trunk/x10.compiler/src/x10/errors/Errors.java 2010-02-26 19:31:50 UTC (rev 13071) +++ trunk/x10.compiler/src/x10/errors/Errors.java 2010-02-26 19:36:42 UTC (rev 13072) @@ -9,303 +9,303 @@ * (C) Copyright IBM Corporation 2006-2010. */ -package x10.errors; - -import polyglot.ast.Call; -import polyglot.ast.Expr; -import polyglot.ast.Field; -import polyglot.ast.FieldAssign; -import polyglot.ast.Receiver; -import polyglot.types.FieldInstance; -import polyglot.types.MethodInstance; -import polyglot.types.SemanticException; -import polyglot.types.Type; -import polyglot.util.Position; -import x10.ast.SemanticError; -import x10.ast.X10Call; -import x10.ast.X10FieldAssign_c; -import x10.constraint.XTerm; -import x10.types.X10ProcedureInstance; -import x10.types.checker.Converter; -import x10.types.checker.PlaceChecker; -import x10.types.checker.Converter.ConversionType; -import x10.types.constraints.XConstrainedTerm; - -/** - * Start at centralizing Error messages. Goal is to support standardization of error messages for - * internationalization, to make unit tests more accurate, and to support better error-handling - * inside compiler. - * - * @author vj 2010/02/06 - * - */ -public class Errors { - - public static interface DepTypeException {} - public static interface PlaceTypeException {} - public static interface ProtoTypeException {} - public static interface ConversionException {} - - public static class CannotAssign extends SemanticException { - private static final long serialVersionUID = -4243637083971033996L; - public CannotAssign(Expr expr, Type targetType, Position pos) { - super("Cannot assign expression to target." - + "\n\t Expression: " + expr - + "\n\t Type: " + expr.type() - + "\n\t Expected type: " + targetType, pos); - } - public boolean equals(Object o) { - if (o==null || ! (o instanceof CannotAssign) ) - return false; - return((CannotAssign)o).position().equals(position()); - } - } - public static class FieldInitTypeWrong extends SemanticException { - private static final long serialVersionUID = 4778277210134359519L; - - public FieldInitTypeWrong(Expr expr, Type targetType, Position pos) { - super("The type of the field initializer is not a subtype of the field type." - + "\n\t Expression: " + expr - + "\n\t Type: " + expr.type() - + "\n\t Expected type: " + targetType, pos); - } - public boolean equals(Object o) { - if (o==null || ! (o instanceof FieldInitTypeWrong) ) - return false; - return((FieldInitTypeWrong)o).position().equals(position()); - } - } - public static class IncompatibleReturnType extends SemanticException { - private static final long serialVersionUID = -6220163900080278288L; - - public IncompatibleReturnType(MethodInstance mi, MethodInstance mj) { - super("Attempting to use incompatible return type." - + "\n\t Method: " + mi - + "\n\t Expected Type: " + mj.returnType() - + "\n\t Found Type: " + mi.returnType(), mi.position()); - } - public boolean equals(Object o) { - if (o==null || ! (o instanceof IncompatibleReturnType) ) - return false; - return((IncompatibleReturnType)o).position().equals(position()); - } - } - - public static class InvalidParameter extends SemanticException { - private static final long serialVersionUID = -1351185257724314440L; - public InvalidParameter(Type from, Type to, Position pos) { - super("Invalid Parameter.\n\t expected type: " + to + "\n\t found: " + from, pos); - } - public boolean equals(Object o) { - if (o==null || ! (o instanceof InvalidParameter) ) - return false; - return((InvalidParameter)o).position().equals(position()); - } - } - - - public static class NoAssignmentInDepType extends SemanticException implements DepTypeException { - private static final long serialVersionUID = 8343234065357158485L; - public NoAssignmentInDepType(FieldAssign f, Position pos) { - super("Assignment may not appear in a dependent type: \n\t Error: " + f, pos); - } - public boolean equals(Object o) { - if (o==null || ! (o instanceof NoAssignmentInDepType) ) - return false; - return((NoAssignmentInDepType)o).position().equals(position()); - } - } - - - public static class PlaceTypeErrorFieldShouldBeGlobal extends SemanticException implements PlaceTypeException { - private static final long serialVersionUID = -7491337042919050786L; - public PlaceTypeErrorFieldShouldBeGlobal(Field f, Position pos) { - super("Place type error: Field should be global. \n\t Field: " + f, pos); - } - public boolean equals(Object o) { - if (o==null || ! (o instanceof PlaceTypeErrorFieldShouldBeGlobal) ) - return false; - return((PlaceTypeErrorFieldShouldBeGlobal)o).position().equals(position()); - } - } - public static class PlaceTypeErrorFieldShouldBeLocalOrGlobal extends SemanticException implements PlaceTypeException { - private static final long serialVersionUID = 8839433155480902083L; - public PlaceTypeErrorFieldShouldBeLocalOrGlobal(Field f, XTerm place, XTerm targetPlace, Position pos) { - super("Place type error: either field target should be local or field should be global." - + "\n\t Field: " + f.name() - + "\n\t Field target: " + f.target() - + (targetPlace != null ? "\n\t Field target place: "+ targetPlace : "" ) - + "\n\t Current place: " + place, - pos); - } - public boolean equals(Object o) { - if (o==null || ! (o instanceof PlaceTypeErrorFieldShouldBeLocalOrGlobal) ) - return false; - return posEquals(this.position(), ((SemanticError) o).position()); - } - } - - public static class PlaceTypeErrorMethodShouldBeGlobal extends SemanticException implements PlaceTypeException { - private static final long serialVersionUID = -657551989521522263L; - - public PlaceTypeErrorMethodShouldBeGlobal(Call c, Position pos) { - super("Place type error: Method should be global. (Called within a global method.) \n\t Method: " + c.name(), pos); - } - public boolean equals(Object o) { - if (o==null || ! (o instanceof PlaceTypeErrorMethodShouldBeGlobal) ) - return false; - return posEquals(this.position(), ((SemanticError) o).position()); - } - } - public static class PlaceTypeErrorMethodShouldBeLocalOrGlobal extends SemanticException implements PlaceTypeException { - private static final long serialVersionUID = 5212483087766572622L; - - public PlaceTypeErrorMethodShouldBeLocalOrGlobal(Call c, XTerm place, XTerm targetPlace, Position pos) { - super("Place type error: either method target should be local or method should be global." - + "\n\t Method target: " + c.target() - + "\n\t Method target place: " + targetPlace - + "\n\t Current place: " + place - + "\n\t Method: " + c.name(), pos); - } - public boolean equals(Object o) { - if (o==null || ! (o instanceof PlaceTypeErrorMethodShouldBeLocalOrGlobal) ) - return false; - - return posEquals(this.position(), ((SemanticError) o).position()); - } - } - static boolean posEquals(Position a, Position b) { - return a.line()==b.line() && a.column()==b.column(); - } - public static class DependentClauseErrorFieldMustBeFinal extends SemanticException implements DepTypeException { - private static final long serialVersionUID = 8737323529719693415L; - public DependentClauseErrorFieldMustBeFinal(Field f,Position pos) { - super("Only final fields are permitted in dependent clauses." - + "\n\t Field: " + f, pos); - } - public boolean equals(Object o) { - if (o==null || ! (o instanceof DependentClauseErrorFieldMustBeFinal) ) - return false; - return((DependentClauseErrorFieldMustBeFinal)o).position().equals(position()); - } - } - - public static class DependentClauseErrorSelfMayAccessOnlyProperties extends SemanticException implements DepTypeException { - private static final long serialVersionUID = 8019315512496243771L; - public DependentClauseErrorSelfMayAccessOnlyProperties(FieldInstance fi,Position pos) { - super("Only properties may be prefixed with self in a dependent clause." - + "\n\t Field: " + fi.name() - + "\n\t Container: " + fi.container(), pos); - } - public boolean equals(Object o) { - if (o==null || ! (o instanceof DependentClauseErrorSelfMayAccessOnlyProperties) ) - return false; - return((DependentClauseErrorSelfMayAccessOnlyProperties)o).position().equals(position()); - } - } - - public static class CannotAccessStaticFieldOfTypeParameter extends SemanticException { - private static final long serialVersionUID = -8016592273145691613L; - public CannotAccessStaticFieldOfTypeParameter(Type t,Position pos) { - super("Cannot access static field of a type parameter" - + "\n\t Type Parameter: " + t, pos); - } - public boolean equals(Object o) { - if (o==null || ! (o instanceof CannotAccessStaticFieldOfTypeParameter) ) - return false; - return((CannotAccessStaticFieldOfTypeParameter)o).position().equals(position()); - } - } - - public static class CannotReadFieldOfProtoValue extends SemanticException implements ProtoTypeException { - private static final long serialVersionUID = -512760271069318563L; - public CannotReadFieldOfProtoValue(Field f,Position pos) { - super("Cannot read field of a proto value." - + "\n\t Field: " + f - + "\n\t Proto value:" + f.target(), pos); - } - public boolean equals(Object o) { - if (o==null || ! (o instanceof CannotReadFieldOfProtoValue) ) - return false; - return((CannotReadFieldOfProtoValue)o).position().equals(position()); - } - } - public static class ProtoValuesAssignableOnlyToProtoReceivers extends SemanticException implements ProtoTypeException { - private static final long serialVersionUID = -6741587508354666830L; - public ProtoValuesAssignableOnlyToProtoReceivers(Expr e, FieldAssign f, Position pos) { - super("A proto value can be assigned to a field only if receiver type is proto." - + "\n\t Value: " + e - + "\n\t Field: " + f.name() - + "\n\t Target: " + f.target() - + "\n\t Target type: " + f.target().type(), - pos); - } - public boolean equals(Object o) { - if (o==null || ! (o instanceof ProtoValuesAssignableOnlyToProtoReceivers) ) - return false; - return((ProtoValuesAssignableOnlyToProtoReceivers)o).position().equals(position()); - } - } - public static class ProtoValuesAssignableOnlyUsingEquals extends SemanticException implements ProtoTypeException { - private static final long serialVersionUID = -7997300104807372345L; - public ProtoValuesAssignableOnlyUsingEquals(Expr e, Position pos) { - super("A proto value assignment to a field must use \"=\" assignment operator." - + "\n\t Value: " + e, - pos); - } - public boolean equals(Object o) { - if (o==null || ! (o instanceof ProtoValuesAssignableOnlyUsingEquals) ) - return false; - return((ProtoValuesAssignableOnlyUsingEquals)o).position().equals(position()); - } - } - public static class CannotConvertToType extends SemanticException implements ConversionException { - private static final long serialVersionUID = 5580836853775144578L; - - public CannotConvertToType(Type fromType, Type toType, Position pos) { - super("Cannot perform type conversion." - + "\n\t From type: " + fromType - + "\n\t To type: " + toType, - pos); - } - public boolean equals(Object o) { - if (o==null || ! (o instanceof CannotConvertToType) ) - return false; - return((CannotConvertToType)o).position().equals(position()); - } - } - - public static class CannotConvertExprToType extends SemanticException implements ConversionException { - private static final long serialVersionUID = -3353656656440601443L; - public CannotConvertExprToType(Expr expr, Converter.ConversionType conversion, Type toType, Position pos) { - super("Cannot " - + (conversion == ConversionType.UNKNOWN_CONVERSION ? "cast" : "implicitly convert") - + " expression to type." - + "\n\t Expression: " + expr - + "\n\t Expression type: " + expr.type() - + "\n\t To type: " + toType, - pos); - } - public boolean equals(Object o) { - if (o==null || ! (o instanceof CannotConvertExprToType) ) - return false; - return((CannotConvertExprToType)o).position().equals(position()); - } - } - public static class InconsistentReturnType extends SemanticException { - private static final long serialVersionUID = 5928425853367539997L; - - public <PI extends X10ProcedureInstance<?>> InconsistentReturnType(Type t, PI me) { - super("Inconsistent return type." - + "\n\t ReturnType: " + t - + "\n\t Invocation: " + me - + "\n\t Position: " + me.position()); - } - public boolean equals(Object o) { - if (o==null || ! (o instanceof InconsistentReturnType) ) - return false; - return((InconsistentReturnType)o).position().equals(position()); - } - } - -} +package x10.errors; + +import polyglot.ast.Call; +import polyglot.ast.Expr; +import polyglot.ast.Field; +import polyglot.ast.FieldAssign; +import polyglot.ast.Receiver; +import polyglot.types.FieldInstance; +import polyglot.types.MethodInstance; +import polyglot.types.SemanticException; +import polyglot.types.Type; +import polyglot.util.Position; +import x10.ast.SemanticError; +import x10.ast.X10Call; +import x10.ast.X10FieldAssign_c; +import x10.constraint.XTerm; +import x10.types.X10ProcedureInstance; +import x10.types.checker.Converter; +import x10.types.checker.PlaceChecker; +import x10.types.checker.Converter.ConversionType; +import x10.types.constraints.XConstrainedTerm; + +/** + * Start at centralizing Error messages. Goal is to support standardization of error messages for + * internationalization, to make unit tests more accurate, and to support better error-handling + * inside compiler. + * + * @author vj 2010/02/06 + * + */ +public class Errors { + + public static interface DepTypeException {} + public static interface PlaceTypeException {} + public static interface ProtoTypeException {} + public static interface ConversionException {} + + public static class CannotAssign extends SemanticException { + private static final long serialVersionUID = -4243637083971033996L; + public CannotAssign(Expr expr, Type targetType, Position pos) { + super("Cannot assign expression to target." + + "\n\t Expression: " + expr + + "\n\t Type: " + expr.type() + + "\n\t Expected type: " + targetType, pos); + } + public boolean equals(Object o) { + if (o==null || ! (o instanceof CannotAssign) ) + return false; + return((CannotAssign)o).position().equals(position()); + } + } + public static class FieldInitTypeWrong extends SemanticException { + private static final long serialVersionUID = 4778277210134359519L; + + public FieldInitTypeWrong(Expr expr, Type targetType, Position pos) { + super("The type of the field initializer is not a subtype of the field type." + + "\n\t Expression: " + expr + + "\n\t Type: " + expr.type() + + "\n\t Expected type: " + targetType, pos); + } + public boolean equals(Object o) { + if (o==null || ! (o instanceof FieldInitTypeWrong) ) + return false; + return((FieldInitTypeWrong)o).position().equals(position()); + } + } + public static class IncompatibleReturnType extends SemanticException { + private static final long serialVersionUID = -6220163900080278288L; + + public IncompatibleReturnType(MethodInstance mi, MethodInstance mj) { + super("Attempting to use incompatible return type." + + "\n\t Method: " + mi + + "\n\t Expected Type: " + mj.returnType() + + "\n\t Found Type: " + mi.returnType(), mi.position()); + } + public boolean equals(Object o) { + if (o==null || ! (o instanceof IncompatibleReturnType) ) + return false; + return((IncompatibleReturnType)o).position().equals(position()); + } + } + + public static class InvalidParameter extends SemanticException { + private static final long serialVersionUID = -1351185257724314440L; + public InvalidParameter(Type from, Type to, Position pos) { + super("Invalid Parameter.\n\t expected type: " + to + "\n\t found: " + from, pos); + } + public boolean equals(Object o) { + if (o==null || ! (o instanceof InvalidParameter) ) + return false; + return((InvalidParameter)o).position().equals(position()); + } + } + + + public static class NoAssignmentInDepType extends SemanticException implements DepTypeException { + private static final long serialVersionUID = 8343234065357158485L; + public NoAssignmentInDepType(FieldAssign f, Position pos) { + super("Assignment may not appear in a dependent type: \n\t Error: " + f, pos); + } + public boolean equals(Object o) { + if (o==null || ! (o instanceof NoAssignmentInDepType) ) + return false; + return((NoAssignmentInDepType)o).position().equals(position()); + } + } + + + public static class PlaceTypeErrorFieldShouldBeGlobal extends SemanticException implements PlaceTypeException { + private static final long serialVersionUID = -7491337042919050786L; + public PlaceTypeErrorFieldShouldBeGlobal(Field f, Position pos) { + super("Place type error: Field should be global. \n\t Field: " + f, pos); + } + public boolean equals(Object o) { + if (o==null || ! (o instanceof PlaceTypeErrorFieldShouldBeGlobal) ) + return false; + return((PlaceTypeErrorFieldShouldBeGlobal)o).position().equals(position()); + } + } + public static class PlaceTypeErrorFieldShouldBeLocalOrGlobal extends SemanticException implements PlaceTypeException { + private static final long serialVersionUID = 8839433155480902083L; + public PlaceTypeErrorFieldShouldBeLocalOrGlobal(Field f, XTerm place, XTerm targetPlace, Position pos) { + super("Place type error: either field target should be local or field should be global." + + "\n\t Field: " + f.name() + + "\n\t Field target: " + f.target() + + (targetPlace != null ? "\n\t Field target place: "+ targetPlace : "" ) + + "\n\t Current place: " + place, + pos); + } + public boolean equals(Object o) { + if (o==null || ! (o instanceof PlaceTypeErrorFieldShouldBeLocalOrGlobal) ) + return false; + return posEquals(this.position(), ((SemanticError) o).position()); + } + } + + public static class PlaceTypeErrorMethodShouldBeGlobal extends SemanticException implements PlaceTypeException { + private static final long serialVersionUID = -657551989521522263L; + + public PlaceTypeErrorMethodShouldBeGlobal(Call c, Position pos) { + super("Place type error: Method should be global. (Called within a global method.) \n\t Method: " + c.name(), pos); + } + public boolean equals(Object o) { + if (o==null || ! (o instanceof PlaceTypeErrorMethodShouldBeGlobal) ) + return false; + return posEquals(this.position(), ((SemanticError) o).position()); + } + } + public static class PlaceTypeErrorMethodShouldBeLocalOrGlobal extends SemanticException implements PlaceTypeException { + private static final long serialVersionUID = 5212483087766572622L; + + public PlaceTypeErrorMethodShouldBeLocalOrGlobal(Call c, XTerm place, XTerm targetPlace, Position pos) { + super("Place type error: either method target should be local or method should be global." + + "\n\t Method target: " + c.target() + + "\n\t Method target place: " + targetPlace + + "\n\t Current place: " + place + + "\n\t Method: " + c.name(), pos); + } + public boolean equals(Object o) { + if (o==null || ! (o instanceof PlaceTypeErrorMethodShouldBeLocalOrGlobal) ) + return false; + + return posEquals(this.position(), ((SemanticError) o).position()); + } + } + static boolean posEquals(Position a, Position b) { + return a.line()==b.line() && a.column()==b.column(); + } + public static class DependentClauseErrorFieldMustBeFinal extends SemanticException implements DepTypeException { + private static final long serialVersionUID = 8737323529719693415L; + public DependentClauseErrorFieldMustBeFinal(Field f,Position pos) { + super("Only final fields are permitted in dependent clauses." + + "\n\t Field: " + f, pos); + } + public boolean equals(Object o) { + if (o==null || ! (o instanceof DependentClauseErrorFieldMustBeFinal) ) + return false; + return((DependentClauseErrorFieldMustBeFinal)o).position().equals(position()); + } + } + + public static class DependentClauseErrorSelfMayAccessOnlyProperties extends SemanticException implements DepTypeException { + private static final long serialVersionUID = 8019315512496243771L; + public DependentClauseErrorSelfMayAccessOnlyProperties(FieldInstance fi,Position pos) { + super("Only properties may be prefixed with self in a dependent clause." + + "\n\t Field: " + fi.name() + + "\n\t Container: " + fi.container(), pos); + } + public boolean equals(Object o) { + if (o==null || ! (o instanceof DependentClauseErrorSelfMayAccessOnlyProperties) ) + return false; + return((DependentClauseErrorSelfMayAccessOnlyProperties)o).position().equals(position()); + } + } + + public static class CannotAccessStaticFieldOfTypeParameter extends SemanticException { + private static final long serialVersionUID = -8016592273145691613L; + public CannotAccessStaticFieldOfTypeParameter(Type t,Position pos) { + super("Cannot access static field of a type parameter" + + "\n\t Type Parameter: " + t, pos); + } + public boolean equals(Object o) { + if (o==null || ! (o instanceof CannotAccessStaticFieldOfTypeParameter) ) + return false; + return((CannotAccessStaticFieldOfTypeParameter)o).position().equals(position()); + } + } + + public static class CannotReadFieldOfProtoValue extends SemanticException implements ProtoTypeException { + private static final long serialVersionUID = -512760271069318563L; + public CannotReadFieldOfProtoValue(Field f,Position pos) { + super("Cannot read field of a proto value." + + "\n\t Field: " + f + + "\n\t Proto value:" + f.target(), pos); + } + public boolean equals(Object o) { + if (o==null || ! (o instanceof CannotReadFieldOfProtoValue) ) + return false; + return((CannotReadFieldOfProtoValue)o).position().equals(position()); + } + } + public static class ProtoValuesAssignableOnlyToProtoReceivers extends SemanticException implements ProtoTypeException { + private static final long serialVersionUID = -6741587508354666830L; + public ProtoValuesAssignableOnlyToProtoReceivers(Expr e, FieldAssign f, Position pos) { + super("A proto value can be assigned to a field only if receiver type is proto." + + "\n\t Value: " + e + + "\n\t Field: " + f.name() + + "\n\t Target: " + f.target() + + "\n\t Target type: " + f.target().type(), + pos); + } + public boolean equals(Object o) { + if (o==null || ! (o instanceof ProtoValuesAssignableOnlyToProtoReceivers) ) + return false; + return((ProtoValuesAssignableOnlyToProtoReceivers)o).position().equals(position()); + } + } + public static class ProtoValuesAssignableOnlyUsingEquals extends SemanticException implements ProtoTypeException { + private static final long serialVersionUID = -7997300104807372345L; + public ProtoValuesAssignableOnlyUsingEquals(Expr e, Position pos) { + super("A proto value assignment to a field must use \"=\" assignment operator." + + "\n\t Value: " + e, + pos); + } + public boolean equals(Object o) { + if (o==null || ! (o instanceof ProtoValuesAssignableOnlyUsingEquals) ) + return false; + return((ProtoValuesAssignableOnlyUsingEquals)o).position().equals(position()); + } + } + public static class CannotConvertToType extends SemanticException implements ConversionException { + private static final long serialVersionUID = 5580836853775144578L; + + public CannotConvertToType(Type fromType, Type toType, Position pos) { + super("Cannot perform type conversion." + + "\n\t From type: " + fromType + + "\n\t To type: " + toType, + pos); + } + public boolean equals(Object o) { + if (o==null || ! (o instanceof CannotConvertToType) ) + return false; + return((CannotConvertToType)o).position().equals(position()); + } + } + + public static class CannotConvertExprToType extends SemanticException implements ConversionException { + private static final long serialVersionUID = -3353656656440601443L; + public CannotConvertExprToType(Expr expr, Converter.ConversionType conversion, Type toType, Position pos) { + super("Cannot " + + (conversion == ConversionType.UNKNOWN_CONVERSION ? "cast" : "implicitly convert") + + " expression to type." + + "\n\t Expression: " + expr + + "\n\t Expression type: " + expr.type() + + "\n\t To type: " + toType, + pos); + } + public boolean equals(Object o) { + if (o==null || ! (o instanceof CannotConvertExprToType) ) + return false; + return((CannotConvertExprToType)o).position().equals(position()); + } + } + public static class InconsistentReturnType extends SemanticException { + private static final long serialVersionUID = 5928425853367539997L; + + public <PI extends X10ProcedureInstance<?>> InconsistentReturnType(Type t, PI me) { + super("Inconsistent return type." + + "\n\t ReturnType: " + t + + "\n\t Invocation: " + me + + "\n\t Position: " + me.position()); + } + public boolean equals(Object o) { + if (o==null || ! (o instanceof InconsistentReturnType) ) + return false; + return((InconsistentReturnType)o).position().equals(position()); + } + } + +} Property changes on: trunk/x10.compiler/src/x10/errors/Errors.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Modified: trunk/x10.tests/examples/Constructs/Cast/ReferenceDependentTypeCast/X10DepTypeSubClassOne.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Cast/ReferenceDependentTypeCast/X10DepTypeSubClassOne.x10 2010-02-26 19:31:50 UTC (rev 13071) +++ trunk/x10.tests/examples/Constructs/Cast/ReferenceDependentTypeCast/X10DepTypeSubClassOne.x10 2010-02-26 19:36:42 UTC (rev 13072) @@ -9,12 +9,12 @@ * (C) Copyright IBM Corporation 2006-2010. */ -import harness.x10Test; - -public class X10DepTypeSubClassOne(int k) extends X10DepTypeClassOne { - - public X10DepTypeSubClassOne(:self.p==a&& self.k==q)(final int a, final int q) { - super(a); - property(q); - } -} +import harness.x10Test; + +public class X10DepTypeSubClassOne(int k) extends X10DepTypeClassOne { + + public X10DepTypeSubClassOne(:self.p==a&& self.k==q)(final int a, final int q) { + super(a); + property(q); + } +} Property changes on: trunk/x10.tests/examples/Constructs/Cast/ReferenceDependentTypeCast/X10DepTypeSubClassOne.x10 ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Modified: trunk/x10.tests/examples/Constructs/Inference/LCA1.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Inference/LCA1.x10 2010-02-26 19:31:50 UTC (rev 13071) +++ trunk/x10.tests/examples/Constructs/Inference/LCA1.x10 2010-02-26 19:36:42 UTC (rev 13072) @@ -9,24 +9,24 @@ * (C) Copyright IBM Corporation 2006-2010. */ -import harness.x10Test; - -/** - * Inference of least common ancestor type. - * - * @author vj 2/29/2010 - */ -public class LCA1 extends x10Test { - public def run() { - val x:double = 1.2345678; - val y:int = 2; - // should succeed. LCA of double and int is Any. - val z:ValRail[Any] = [x,y]; - return true; - } - - public static def main(Rail[String]) { - new LCA1().execute(); - } -} - +import harness.x10Test; + +/** + * Inference of least common ancestor type. + * + * @author vj 2/29/2010 + */ +public class LCA1 extends x10Test { + public def run() { + val x:double = 1.2345678; + val y:int = 2; + // should succeed. LCA of double and int is Any. + val z:ValRail[Any] = [x,y]; + return true; + } + + public static def main(Rail[String]) { + new LCA1().execute(); + } +} + Property changes on: trunk/x10.tests/examples/Constructs/Inference/LCA1.x10 ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Modified: trunk/x10.tests/examples/Constructs/Types/NullableObjectEqualsPrimitive_MustFailCompile.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Types/NullableObjectEqualsPrimitive_MustFailCompile.x10 2010-02-26 19:31:50 UTC (rev 13071) +++ trunk/x10.tests/examples/Constructs/Types/NullableObjectEqualsPrimitive_MustFailCompile.x10 2010-02-26 19:36:42 UTC (rev 13072) @@ -9,24 +9,24 @@ * (C) Copyright IBM Corporation 2006-2010. */ -import harness.x10Test; -import x10.util.Box; -/** - * Checks 3 is an object which can be compared to a nullable - * - * @author vcave - */ -public class NullableObjectEqualsPrimitive_MustFailCompile extends x10Test { - - public def run(): boolean = { - var x: Box[Any] = null; - // This use of == must generate a compiler error - var res1: boolean = 3==x; - var res2: boolean = x==3; // should be false - return !res1 && !res2; - } - - public static def main(Rail[String]) { - new NullableObjectEqualsPrimitive_MustFailCompile().execute(); - } -} +import harness.x10Test; +import x10.util.Box; +/** + * Checks 3 is an object which can be compared to a nullable + * + * @author vcave + */ +public class NullableObjectEqualsPrimitive_MustFailCompile extends x10Test { + + public def run(): boolean = { + var x: Box[Any] = null; + // This use of == must generate a compiler error + var res1: boolean = 3==x; + var res2: boolean = x==3; // should be false + return !res1 && !res2; + } + + public static def main(Rail[String]) { + new NullableObjectEqualsPrimitive_MustFailCompile().execute(); + } +} Property changes on: trunk/x10.tests/examples/Constructs/Types/NullableObjectEqualsPrimitive_MustFailCompile.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. |
From: <ipe...@us...> - 2010-02-27 07:10:59
|
Revision: 13078 http://x10.svn.sourceforge.net/x10/?rev=13078&view=rev Author: ipeshansky Date: 2010-02-27 07:10:50 +0000 (Sat, 27 Feb 2010) Log Message: ----------- d2u and normalize SVN properties. Modified Paths: -------------- trunk/x10.compiler/src/x10/types/Proto.java trunk/x10.compiler/src/x10/types/TypeDefMatcher.java trunk/x10.compiler/src/x10/types/X10Struct.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/checker/PlaceChecker.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/types/constraints/Constraints.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/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.compiler/src/x10/util/ClosureSynthesizer.java trunk/x10.compiler/src/x10/visit/X10TypeChecker.java trunk/x10.tests/examples/Constructs/Cast/ReferenceDependentTypeCast/X10InterfaceOne.x10 trunk/x10.tests/examples/Constructs/Inference/LCAClassAClassB.x10 trunk/x10.tests/examples/Constructs/Inference/LCAClassAStructB.x10 trunk/x10.tests/examples/Constructs/Inference/LCAClassAStructB_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Inference/LCAClassASubclassB.x10 trunk/x10.tests/examples/Constructs/Place/BangACrossPlaces_MustFailCompile2.x10 trunk/x10.tests/examples/Constructs/Place/BangAcrossPlaces_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Place/ClosureBang.x10 trunk/x10.tests/examples/Constructs/Place/PlaceCheckInRail_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Place/PlaceCheckinRail_MustFailCompile2.x10 trunk/x10.tests/examples/Issues/XTENLANG_825.x10 trunk/x10.tests/examples/Issues/XTENLANG_994.x10 Property Changed: ---------------- trunk/x10.compiler/src/x10/types/Proto.java trunk/x10.compiler/src/x10/types/TypeDefMatcher.java trunk/x10.compiler/src/x10/types/X10Struct.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/checker/PlaceChecker.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/types/constraints/Constraints.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/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.compiler/src/x10/util/ClosureSynthesizer.java trunk/x10.compiler/src/x10/visit/NativeClassVisitor.java trunk/x10.compiler/src/x10/visit/X10TypeChecker.java trunk/x10.compiler/src/x10bc/ExtensionInfo.java trunk/x10.compiler/src/x10bc/X10BytecodeTranslator.java trunk/x10.runtime/src-cpp/x10aux/debug.cc trunk/x10.runtime/src-cpp/x10aux/debug.h trunk/x10.runtime/src-x10/x10/compiler/ByRef.x10 trunk/x10.runtime/src-x10/x10/compiler/Mutable.x10 trunk/x10.runtime/src-x10/x10/compiler/NativeClass.x10 trunk/x10.runtime/src-x10/x10/compiler/NativeDef.x10 trunk/x10.runtime/src-x10/x10/compiler/NativeString.x10 trunk/x10.runtime/src-x10/x10/compiler/StackAllocate.x10 trunk/x10.runtime/src-x10/x10/lang/Activity.x10 trunk/x10.runtime/src-x10/x10/lang/Rail__NativeRep.x10 trunk/x10.runtime/src-x10/x10/lang/ValRail__NativeRep.x10 trunk/x10.tests/examples/Constructs/Cast/ReferenceDependentTypeCast/X10InterfaceOne.x10 trunk/x10.tests/examples/Constructs/Inference/LCAClassAClassB.x10 trunk/x10.tests/examples/Constructs/Inference/LCAClassAStructB.x10 trunk/x10.tests/examples/Constructs/Inference/LCAClassAStructB_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Inference/LCAClassASubclassB.x10 trunk/x10.tests/examples/Constructs/Place/BangACrossPlaces_MustFailCompile2.x10 trunk/x10.tests/examples/Constructs/Place/BangAcrossPlaces_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Place/ClosureBang.x10 trunk/x10.tests/examples/Constructs/Place/PlaceCheckInRail_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Place/PlaceCheckinRail_MustFailCompile2.x10 trunk/x10.tests/examples/Constructs/Rail/RailCopy.x10 trunk/x10.tests/examples/Issues/XTENLANG_231.x10 trunk/x10.tests/examples/Issues/XTENLANG_655.x10 trunk/x10.tests/examples/Issues/XTENLANG_825.x10 trunk/x10.tests/examples/Issues/XTENLANG_994.x10 Modified: trunk/x10.compiler/src/x10/types/Proto.java =================================================================== --- trunk/x10.compiler/src/x10/types/Proto.java 2010-02-26 23:36:04 UTC (rev 13077) +++ trunk/x10.compiler/src/x10/types/Proto.java 2010-02-27 07:10:50 UTC (rev 13078) @@ -9,29 +9,29 @@ * (C) Copyright IBM Corporation 2006-2010. */ -package x10.types; - -import polyglot.types.Type; - - -/** - * Interface implemented by types that may be proto types, viz ConstrainedType or X10ClassType. - * - * @author vj - * - */ -public interface Proto extends Type { - - boolean isProto(); - - /** - * Return T if this is proto T; else return this. - * @return - */ - Proto baseOfProto(); - - /** - * @return this if this is proto T; else proto this - */ - Proto makeProto(); -} +package x10.types; + +import polyglot.types.Type; + + +/** + * Interface implemented by types that may be proto types, viz ConstrainedType or X10ClassType. + * + * @author vj + * + */ +public interface Proto extends Type { + + boolean isProto(); + + /** + * Return T if this is proto T; else return this. + * @return + */ + Proto baseOfProto(); + + /** + * @return this if this is proto T; else proto this + */ + Proto makeProto(); +} Property changes on: trunk/x10.compiler/src/x10/types/Proto.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Modified: trunk/x10.compiler/src/x10/types/TypeDefMatcher.java =================================================================== --- trunk/x10.compiler/src/x10/types/TypeDefMatcher.java 2010-02-26 23:36:04 UTC (rev 13077) +++ trunk/x10.compiler/src/x10/types/TypeDefMatcher.java 2010-02-27 07:10:50 UTC (rev 13078) @@ -9,72 +9,72 @@ * (C) Copyright IBM Corporation 2006-2010. */ -package x10.types; - -import java.util.List; - -import polyglot.types.Context; -import polyglot.types.Matcher; -import polyglot.types.Name; -import polyglot.types.Named; -import polyglot.types.SemanticException; -import polyglot.types.Type; -import polyglot.util.CollectionUtil; - -class TypeDefMatcher implements Matcher<Named> { - Type container; - Name name; - List<Type> typeArgs; - List<Type> argTypes; - Context context; - - public TypeDefMatcher(Type container, Name name, List<Type> typeArgs, List<Type> argTypes, Context context) { - this.container = container; - this.name = name; - this.typeArgs = typeArgs; - this.argTypes = argTypes; - this.context = context; - } - - public Name name() { - return name; - } - - public String argumentString() { - return (typeArgs.isEmpty() ? "" : "[" + CollectionUtil.listToString(typeArgs) + "]") - + (argTypes.isEmpty() ? "" : "(" + CollectionUtil.listToString(argTypes) + ")"); - } - - public String signature() { - return name + argumentString(); - } - - public String toString() { - return signature(); - } - - public MacroType instantiate(Named n) throws SemanticException { - if (n instanceof MacroType) { - MacroType mi = (MacroType) n; - if (!mi.name().equals(name)) - return null; - if (mi.formalTypes().size() != argTypes.size()) - return null; - if (mi instanceof MacroType) { - MacroType xmi = (MacroType) mi; - Type c = container != null ? container : xmi.container(); - if (typeArgs.isEmpty() || typeArgs.size() == xmi.typeParameters().size()) { - // no implicit coercions! - MacroType result = x10.types.matcher.Matcher.inferAndCheckAndInstantiate((X10Context) context, - xmi, c, typeArgs, argTypes, n.position()); - return result; - } - } - } - return null; - } - - public Object key() { - return null; - } +package x10.types; + +import java.util.List; + +import polyglot.types.Context; +import polyglot.types.Matcher; +import polyglot.types.Name; +import polyglot.types.Named; +import polyglot.types.SemanticException; +import polyglot.types.Type; +import polyglot.util.CollectionUtil; + +class TypeDefMatcher implements Matcher<Named> { + Type container; + Name name; + List<Type> typeArgs; + List<Type> argTypes; + Context context; + + public TypeDefMatcher(Type container, Name name, List<Type> typeArgs, List<Type> argTypes, Context context) { + this.container = container; + this.name = name; + this.typeArgs = typeArgs; + this.argTypes = argTypes; + this.context = context; + } + + public Name name() { + return name; + } + + public String argumentString() { + return (typeArgs.isEmpty() ? "" : "[" + CollectionUtil.listToString(typeArgs) + "]") + + (argTypes.isEmpty() ? "" : "(" + CollectionUtil.listToString(argTypes) + ")"); + } + + public String signature() { + return name + argumentString(); + } + + public String toString() { + return signature(); + } + + public MacroType instantiate(Named n) throws SemanticException { + if (n instanceof MacroType) { + MacroType mi = (MacroType) n; + if (!mi.name().equals(name)) + return null; + if (mi.formalTypes().size() != argTypes.size()) + return null; + if (mi instanceof MacroType) { + MacroType xmi = (MacroType) mi; + Type c = container != null ? container : xmi.container(); + if (typeArgs.isEmpty() || typeArgs.size() == xmi.typeParameters().size()) { + // no implicit coercions! + MacroType result = x10.types.matcher.Matcher.inferAndCheckAndInstantiate((X10Context) context, + xmi, c, typeArgs, argTypes, n.position()); + return result; + } + } + } + return null; + } + + public Object key() { + return null; + } } \ No newline at end of file Property changes on: trunk/x10.compiler/src/x10/types/TypeDefMatcher.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Modified: trunk/x10.compiler/src/x10/types/X10Struct.java =================================================================== --- trunk/x10.compiler/src/x10/types/X10Struct.java 2010-02-26 23:36:04 UTC (rev 13077) +++ trunk/x10.compiler/src/x10/types/X10Struct.java 2010-02-27 07:10:50 UTC (rev 13078) @@ -9,24 +9,24 @@ * (C) Copyright IBM Corporation 2006-2010. */ -package x10.types; - -import polyglot.types.Type; - - - -/** - * Interface implemented by types that may represent an X10 struct, viz subtypes of ConstrainedType or X10ClassType. - * - * @author vj - * - */ -public interface X10Struct extends Type { - /** - * Is this type an X10 struct type? - */ - boolean isX10Struct(); - X10Struct makeX10Struct(); - - -} +package x10.types; + +import polyglot.types.Type; + + + +/** + * Interface implemented by types that may represent an X10 struct, viz subtypes of ConstrainedType or X10ClassType. + * + * @author vj + * + */ +public interface X10Struct extends Type { + /** + * Is this type an X10 struct type? + */ + boolean isX10Struct(); + X10Struct makeX10Struct(); + + +} Property changes on: trunk/x10.compiler/src/x10/types/X10Struct.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Modified: trunk/x10.compiler/src/x10/types/checker/Checker.java =================================================================== --- trunk/x10.compiler/src/x10/types/checker/Checker.java 2010-02-26 23:36:04 UTC (rev 13077) +++ trunk/x10.compiler/src/x10/types/checker/Checker.java 2010-02-27 07:10:50 UTC (rev 13078) @@ -9,201 +9,201 @@ * (C) Copyright IBM Corporation 2006-2010. */ -package x10.types.checker; - -import java.util.Map; - -import polyglot.ast.Assign; -import polyglot.ast.Assign_c; -import polyglot.ast.Expr; -import polyglot.ast.Node; -import polyglot.ast.Assign.Operator; -import polyglot.types.Name; -import polyglot.types.SemanticException; -import polyglot.types.Type; -import polyglot.types.TypeSystem; -import polyglot.types.Types; -import polyglot.util.InternalCompilerError; -import polyglot.util.Position; -import polyglot.visit.ContextVisitor; -import x10.ast.X10Binary_c; -import x10.ast.X10New_c; -import x10.errors.Errors; -import x10.errors.Errors.CannotAssign; -import x10.types.ConstrainedType; -import x10.types.MacroType; -import x10.types.ParameterType; -import x10.types.X10ClassDef; -import x10.types.X10ClassType; -import static polyglot.ast.Assign.*; - -/** - * A set of static methods used by AST nodes to check types. - * @author vj - * - */ -public class Checker { - - public static Node typeCheckAssign(Assign_c a, ContextVisitor tc) throws SemanticException { - Assign_c n = (Assign_c) a.typeCheckLeft(tc); - - TypeSystem ts = tc.typeSystem(); - Type t = n.leftType(); - - if (t == null) - t = ts.unknownType(n.position()); - - Expr right = n.right(); - Assign.Operator op = n.operator(); - - Type s = right.type(); - - if (op == ASSIGN) { - try { - Expr e = Converter.attemptCoercion(tc, right, t); - return n.right(e).type(t); - } - catch (SemanticException e) { - // Dont try to extract the LHS expression, this is called by X10FieldAssign_c as well. - throw new Errors.CannotAssign(right, t, n.position()); - } - } - - if (op == ADD_ASSIGN) { - // t += s - if (ts.typeEquals(t, ts.String(), tc.context()) && ts.canCoerceToString(s, tc.context())) { - Expr newRight = X10Binary_c.coerceToString(tc, right); - return n.right(newRight).type(ts.String()); - } - - if (t.isNumeric() && s.isNumeric()) { - return n.type(ts.promote(t, s)); - } - - throw new SemanticException("The " + op + " operator must have " - + "numeric or String operands.", - n.position()); - } - - if (op == Assign.SUB_ASSIGN || op == Assign.MUL_ASSIGN || - op == DIV_ASSIGN || op == MOD_ASSIGN) { - if (t.isNumeric() && s.isNumeric()) { - return n.type(ts.promote(t, s)); - } - - throw new SemanticException("The " + op + " operator must have " - + "numeric operands.", - n.position()); - } - - if (op == BIT_AND_ASSIGN || op == BIT_OR_ASSIGN || op == BIT_XOR_ASSIGN) { - if (t.isBoolean() && s.isBoolean()) { - return n.type(ts.Boolean()); - } - - if (ts.isLongOrLess(t) && - ts.isLongOrLess(s)) { - return n.type(ts.promote(t, s)); - } - - throw new SemanticException("The " + op + " operator must have " - + "integral or boolean operands.", - n.position()); - } - - if (op == SHL_ASSIGN || op == SHR_ASSIGN || op == USHR_ASSIGN) { - if (ts.isLongOrLess(t) && - ts.isLongOrLess(s)) { - // Only promote the left of a shift. - return n.type(ts.promote(t)); - } - - throw new SemanticException("The " + op + " operator must have " - + "integral operands.", - n.position()); - } - - throw new InternalCompilerError("Unrecognized assignment operator " + - op + "."); - } - - public static void checkVariancesOfType(Position pos, Type t, ParameterType.Variance requiredVariance, - String desc, Map<Name,ParameterType.Variance> vars, ContextVisitor tc) throws SemanticException { - if (t instanceof ParameterType) { - ParameterType pt = (ParameterType) t; - X10ClassDef cd = (X10ClassDef) tc.context().currentClassDef(); - if (pt.def() != cd) - return; - ParameterType.Variance actualVariance = vars.get(pt.name()); - if (actualVariance == null) - return; - switch (actualVariance) { - case INVARIANT: - break; - case COVARIANT: - switch (requiredVariance) { - case INVARIANT: - throw new SemanticException("Cannot use covariant parameter " + pt + " " + desc + "; must be invariant.", pos); - case COVARIANT: - break; - case CONTRAVARIANT: - throw new SemanticException("Cannot use covariant parameter " + pt + " " + desc + "; must be contravariant or invariant.", pos); - } - break; - case CONTRAVARIANT: - switch (requiredVariance) { - case INVARIANT: - throw new SemanticException("Cannot use contravariant parameter " + pt + " " + desc + "; must be invariant.", pos); - case COVARIANT: - throw new SemanticException("Cannot use contravariant parameter " + pt + " " + desc + "; must be covariant or invariant.", pos); - case CONTRAVARIANT: - break; - } - break; - } - } - if (t instanceof MacroType) { - MacroType mt = (MacroType) t; - checkVariancesOfType(pos, mt.definedType(), requiredVariance, desc, vars, tc); - } - if (t instanceof X10ClassType) { - X10ClassType ct = (X10ClassType) t; - X10ClassDef def = ct.x10Def(); - for (int i = 0; i < ct.typeArguments().size(); i++) { - Type at = ct.typeArguments().get(i); - ParameterType pt = def.typeParameters().get(i); - ParameterType.Variance v = def.variances().get(i); - ParameterType.Variance newVariance; - - switch (v) { - case INVARIANT: - checkVariancesOfType(pos, at, requiredVariance, desc, vars, tc); - break; - case COVARIANT: - checkVariancesOfType(pos, at, requiredVariance, desc, vars, tc); - break; - case CONTRAVARIANT: - switch (requiredVariance) { - case INVARIANT: - checkVariancesOfType(pos, at, requiredVariance, desc, vars, tc); - break; - case COVARIANT: - checkVariancesOfType(pos, at, ParameterType.Variance.CONTRAVARIANT, desc, vars, tc); - break; - case CONTRAVARIANT: - checkVariancesOfType(pos, at, ParameterType.Variance.COVARIANT, desc, vars, tc); - break; - } - break; - } - } - } - if (t instanceof ConstrainedType) { - ConstrainedType ct = (ConstrainedType) t; - Type at = Types.get(ct.baseType()); - checkVariancesOfType(pos, at, requiredVariance, desc, vars, tc); - } - } - - -} +package x10.types.checker; + +import java.util.Map; + +import polyglot.ast.Assign; +import polyglot.ast.Assign_c; +import polyglot.ast.Expr; +import polyglot.ast.Node; +import polyglot.ast.Assign.Operator; +import polyglot.types.Name; +import polyglot.types.SemanticException; +import polyglot.types.Type; +import polyglot.types.TypeSystem; +import polyglot.types.Types; +import polyglot.util.InternalCompilerError; +import polyglot.util.Position; +import polyglot.visit.ContextVisitor; +import x10.ast.X10Binary_c; +import x10.ast.X10New_c; +import x10.errors.Errors; +import x10.errors.Errors.CannotAssign; +import x10.types.ConstrainedType; +import x10.types.MacroType; +import x10.types.ParameterType; +import x10.types.X10ClassDef; +import x10.types.X10ClassType; +import static polyglot.ast.Assign.*; + +/** + * A set of static methods used by AST nodes to check types. + * @author vj + * + */ +public class Checker { + + public static Node typeCheckAssign(Assign_c a, ContextVisitor tc) throws SemanticException { + Assign_c n = (Assign_c) a.typeCheckLeft(tc); + + TypeSystem ts = tc.typeSystem(); + Type t = n.leftType(); + + if (t == null) + t = ts.unknownType(n.position()); + + Expr right = n.right(); + Assign.Operator op = n.operator(); + + Type s = right.type(); + + if (op == ASSIGN) { + try { + Expr e = Converter.attemptCoercion(tc, right, t); + return n.right(e).type(t); + } + catch (SemanticException e) { + // Dont try to extract the LHS expression, this is called by X10FieldAssign_c as well. + throw new Errors.CannotAssign(right, t, n.position()); + } + } + + if (op == ADD_ASSIGN) { + // t += s + if (ts.typeEquals(t, ts.String(), tc.context()) && ts.canCoerceToString(s, tc.context())) { + Expr newRight = X10Binary_c.coerceToString(tc, right); + return n.right(newRight).type(ts.String()); + } + + if (t.isNumeric() && s.isNumeric()) { + return n.type(ts.promote(t, s)); + } + + throw new SemanticException("The " + op + " operator must have " + + "numeric or String operands.", + n.position()); + } + + if (op == Assign.SUB_ASSIGN || op == Assign.MUL_ASSIGN || + op == DIV_ASSIGN || op == MOD_ASSIGN) { + if (t.isNumeric() && s.isNumeric()) { + return n.type(ts.promote(t, s)); + } + + throw new SemanticException("The " + op + " operator must have " + + "numeric operands.", + n.position()); + } + + if (op == BIT_AND_ASSIGN || op == BIT_OR_ASSIGN || op == BIT_XOR_ASSIGN) { + if (t.isBoolean() && s.isBoolean()) { + return n.type(ts.Boolean()); + } + + if (ts.isLongOrLess(t) && + ts.isLongOrLess(s)) { + return n.type(ts.promote(t, s)); + } + + throw new SemanticException("The " + op + " operator must have " + + "integral or boolean operands.", + n.position()); + } + + if (op == SHL_ASSIGN || op == SHR_ASSIGN || op == USHR_ASSIGN) { + if (ts.isLongOrLess(t) && + ts.isLongOrLess(s)) { + // Only promote the left of a shift. + return n.type(ts.promote(t)); + } + + throw new SemanticException("The " + op + " operator must have " + + "integral operands.", + n.position()); + } + + throw new InternalCompilerError("Unrecognized assignment operator " + + op + "."); + } + + public static void checkVariancesOfType(Position pos, Type t, ParameterType.Variance requiredVariance, + String desc, Map<Name,ParameterType.Variance> vars, ContextVisitor tc) throws SemanticException { + if (t instanceof ParameterType) { + ParameterType pt = (ParameterType) t; + X10ClassDef cd = (X10ClassDef) tc.context().currentClassDef(); + if (pt.def() != cd) + return; + ParameterType.Variance actualVariance = vars.get(pt.name()); + if (actualVariance == null) + return; + switch (actualVariance) { + case INVARIANT: + break; + case COVARIANT: + switch (requiredVariance) { + case INVARIANT: + throw new SemanticException("Cannot use covariant parameter " + pt + " " + desc + "; must be invariant.", pos); + case COVARIANT: + break; + case CONTRAVARIANT: + throw new SemanticException("Cannot use covariant parameter " + pt + " " + desc + "; must be contravariant or invariant.", pos); + } + break; + case CONTRAVARIANT: + switch (requiredVariance) { + case INVARIANT: + throw new SemanticException("Cannot use contravariant parameter " + pt + " " + desc + "; must be invariant.", pos); + case COVARIANT: + throw new SemanticException("Cannot use contravariant parameter " + pt + " " + desc + "; must be covariant or invariant.", pos); + case CONTRAVARIANT: + break; + } + break; + } + } + if (t instanceof MacroType) { + MacroType mt = (MacroType) t; + checkVariancesOfType(pos, mt.definedType(), requiredVariance, desc, vars, tc); + } + if (t instanceof X10ClassType) { + X10ClassType ct = (X10ClassType) t; + X10ClassDef def = ct.x10Def(); + for (int i = 0; i < ct.typeArguments().size(); i++) { + Type at = ct.typeArguments().get(i); + ParameterType pt = def.typeParameters().get(i); + ParameterType.Variance v = def.variances().get(i); + ParameterType.Variance newVariance; + + switch (v) { + case INVARIANT: + checkVariancesOfType(pos, at, requiredVariance, desc, vars, tc); + break; + case COVARIANT: + checkVariancesOfType(pos, at, requiredVariance, desc, vars, tc); + break; + case CONTRAVARIANT: + switch (requiredVariance) { + case INVARIANT: + checkVariancesOfType(pos, at, requiredVariance, desc, vars, tc); + break; + case COVARIANT: + checkVariancesOfType(pos, at, ParameterType.Variance.CONTRAVARIANT, desc, vars, tc); + break; + case CONTRAVARIANT: + checkVariancesOfType(pos, at, ParameterType.Variance.COVARIANT, desc, vars, tc); + break; + } + break; + } + } + } + if (t instanceof ConstrainedType) { + ConstrainedType ct = (ConstrainedType) t; + Type at = Types.get(ct.baseType()); + checkVariancesOfType(pos, at, requiredVariance, desc, vars, tc); + } + } + + +} Property changes on: trunk/x10.compiler/src/x10/types/checker/Checker.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Modified: trunk/x10.compiler/src/x10/types/checker/Converter.java =================================================================== --- trunk/x10.compiler/src/x10/types/checker/Converter.java 2010-02-26 23:36:04 UTC (rev 13077) +++ trunk/x10.compiler/src/x10/types/checker/Converter.java 2010-02-27 07:10:50 UTC (rev 13078) @@ -9,477 +9,477 @@ * (C) Copyright IBM Corporation 2006-2010. */ -package x10.types.checker; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import polyglot.ast.Call; -import polyglot.ast.ConstructorCall; -import polyglot.ast.Expr; -import polyglot.ast.New; -import polyglot.ast.Node; -import polyglot.ast.TypeNode; -import polyglot.main.Report; -import polyglot.types.ClassDef; -import polyglot.types.Context; -import polyglot.types.Def; -import polyglot.types.Matcher; -import polyglot.types.MemberInstance; -import polyglot.types.MethodInstance; -import polyglot.types.Name; -import polyglot.types.NoMemberException; -import polyglot.types.ObjectType; -import polyglot.types.ProcedureDef; -import polyglot.types.ProcedureInstance; -import polyglot.types.SemanticException; -import polyglot.types.Type; -import polyglot.util.Pair; -import polyglot.util.Position; -import polyglot.visit.ContextVisitor; -import x10.ast.X10Cast; -import x10.ast.X10Cast_c; -import x10.ast.X10New_c; -import x10.ast.X10NodeFactory; -import x10.ast.X10ProcedureCall; -import x10.ast.X10New_c.MatcherMaker; -import x10.constraint.XConstraint; -import x10.errors.Errors; -import x10.types.ParameterType; -import x10.types.X10ClassType; -import x10.types.X10Context; -import x10.types.X10ParsedClassType_c; -import x10.types.X10TypeMixin; -import x10.types.X10TypeSystem; -import x10.types.X10TypeSystem_c; - -/** - * A set of static methods used to convert an AST representing an X10 expressions of a given type - * into an AST representing an expressions of another type. - * - * @author vj 2/6/2010 - * - */ -public class Converter { - - public static enum ConversionType { - UNKNOWN_CONVERSION, - UNKNOWN_IMPLICIT_CONVERSION, - PRIMITIVE, - CHECKED, - SUBTYPE, - UNBOXING, - BOXING, - UNCHECKED - } - - /** - * Return the expression, obtained from e through a sequence of operations, that is of type toType - * @param tc -- Visitor to use during construction - * @param e -- the subject expression - * @param toType -- the target type - * @return -- the expression constructed from e of type toType - * @throws SemanticException If this is not possible - */ - public static Expr attemptCoercion(ContextVisitor tc, Expr e, Type toType) throws SemanticException { - X10TypeSystem ts = (X10TypeSystem) tc.typeSystem(); - Type t1 = e.type(); - t1 = PlaceChecker.ReplaceHereByPlaceTerm(t1, (X10Context) tc.context()); - if (ts.isSubtype(t1, toType, tc.context())) - return e; - - ConversionType ct = ts.numericConversionValid(toType, e.type(), e.constantValue(), tc.context()) - ? ConversionType.UNKNOWN_CONVERSION - : ConversionType.UNKNOWN_IMPLICIT_CONVERSION; - - X10NodeFactory nf = (X10NodeFactory) tc.nodeFactory(); - - Expr result = check(nf.X10Cast(e.position(), nf.CanonicalTypeNode(e.position(), toType), e, ct),tc); - return result; - } - - /** - * - * @param <PD> - * @param <PI> - * @param n - * @param tc - * @param targetType - * @param methods - * Unsubstituted, uninstantiated methods. Need to go through - * MethodMatcher.instantiate to use. - * @param maker - * @return - * @throws SemanticException - */ - public static <PD extends ProcedureDef, PI extends ProcedureInstance<PD>> Pair<PI, List<Expr>> - tryImplicitConversions(X10ProcedureCall n, - ContextVisitor tc, Type targetType, List<PI> methods, X10New_c.MatcherMaker<PI> maker) throws SemanticException { - X10NodeFactory nf = (X10NodeFactory) tc.nodeFactory(); - X10TypeSystem ts = (X10TypeSystem) tc.typeSystem(); - X10Context xc = (X10Context) tc.context(); - ClassDef currentClassDef = xc.currentClassDef(); - - List<PI> acceptable = new ArrayList<PI>(); - Map<Def, List<Expr>> newArgs = new HashMap<Def, List<Expr>>(); - - List<Type> typeArgs = new ArrayList<Type>(n.typeArguments().size()); - - for (TypeNode tn : n.typeArguments()) { - typeArgs.add(tn.type()); - } - - METHOD: for (Iterator<PI> i = methods.iterator(); i.hasNext();) { - PI smi = (PI) i.next(); - - if (Report.should_report(Report.types, 3)) - Report.report(3, "Trying " + smi); - - List<Expr> transformedArgs = new ArrayList<Expr>(); - List<Type> transformedArgTypes = new ArrayList<Type>(); - - List<Type> formals = smi.formalTypes(); - - for (int j = 0; j < n.arguments().size(); j++) { - Expr e = n.arguments().get(j); - Type toType = formals.get(j); - - try { - Expr e2 = attemptCoercion(tc, e, toType); - transformedArgs.add(e2); - transformedArgTypes.add(e2.type()); - } - catch (SemanticException ex) { - // Implicit cast not allowed here. - continue METHOD; - } - } - - try { - Matcher<PI> matcher = maker.matcher(targetType, typeArgs, transformedArgTypes); - // ((X10ProcedureInstance) smi).returnType(); - // X10MethodInstance_c.checkCall(xc, (X10ProcedureInstance) smi, - // targetType, typeArgs, transformedArgTypes); - // // smi = (PI) matcher.instantiate(smi); - - // Reinstantiate using the new argument types. - // Be careful to re-subst in the type arguments of the container type. - // This should be cleaner! - PI raw = (PI) smi.def().asInstance(); - if (smi instanceof MemberInstance) { - Type container = ((MemberInstance) smi).container(); - Type base = X10TypeMixin.baseType(container); - if (base instanceof X10ClassType) { - X10ParsedClassType_c ct = (X10ParsedClassType_c) base; - raw = ct.subst().reinstantiate(raw); - } - } - PI smi2 = (PI) matcher.instantiate(raw); - // ((X10ProcedureInstance) smi2).returnType(); - acceptable.add(smi2); - newArgs.put(smi2.def(), transformedArgs); - } - catch (SemanticException e) { - System.out.print(""); - } - } - - if (acceptable.size() == 0) { - if (n instanceof New || n instanceof ConstructorCall) - throw new NoMemberException(NoMemberException.CONSTRUCTOR, "Could not find matching constructor in " + targetType + ".", n.position()); - else - throw new NoMemberException(NoMemberException.METHOD, "Could not find matching method in " + targetType + ".", n.position()); - } - - Collection<PI> maximal = ts.<PD, PI> findMostSpecificProcedures(acceptable, (Matcher<PI>) null, xc); - - if (maximal.size() > 1) { - StringBuffer sb = new StringBuffer(); - for (Iterator<PI> i = maximal.iterator(); i.hasNext();) { - PI ma = (PI) i.next(); - if (ma instanceof MemberInstance) { - sb.append(((MemberInstance) ma).container()); - sb.append("."); - } - sb.append(ma.signature()); - if (i.hasNext()) { - if (maximal.size() == 2) { - sb.append(" and "); - } - else { - sb.append(", "); - } - } - } - - if (n instanceof New || n instanceof ConstructorCall) - throw new NoMemberException(NoMemberException.CONSTRUCTOR, "Reference to " + targetType + " is ambiguous, multiple " + "constructors match: " - + sb.toString(), n.position()); - else - throw new NoMemberException(NoMemberException.METHOD, "Reference to " + targetType + " is ambiguous, multiple " + "methods match: " - + sb.toString(), n.position()); - } - - PI mi; - mi = (PI) maximal.iterator().next(); - - List<Expr> args = newArgs.get(mi.def()); - assert args != null; - - return new Pair<PI, List<Expr>>(mi, args); - } - - - - /** Return list of conversion functions needed to convert from fromType to toType */ - public static Expr converterChain(final X10Cast_c cast, final ContextVisitor tc) throws SemanticException { - try { - return Converter.checkCast(cast, 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 cast.expr(); - X10Cast_c newCast = (X10Cast_c) nf.X10Cast(cast.position(), - nf.CanonicalTypeNode(cast.position(), newFrom), cast.expr(), - Converter.ConversionType.UNKNOWN_IMPLICIT_CONVERSION); - Expr newE = converterChain(newCast, tc); - assert newE.type() != null; - X10Cast_c newC = (X10Cast_c) cast.expr(newE); - return Converter.checkCast(newC, tc); - } - - throw new Errors.CannotConvertToType(fromType, toType, cast.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 = cast.expr().type(); - Type toType = cast.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. - } - } - } - - throw new Errors.CannotConvertExprToType(cast.expr(), cast.conversionType(), toType, cast.position()); - } - - public static Expr checkCast(X10Cast_c cast, ContextVisitor tc) throws SemanticException { - Type toType = cast.castType().type(); - Type fromType = cast.expr().type(); - X10TypeSystem_c ts = (X10TypeSystem_c) tc.typeSystem(); - X10NodeFactory nf = (X10NodeFactory) tc.nodeFactory(); - X10Context context = (X10Context) tc.context(); - - if (ts.isVoid(toType) || ts.isVoid(fromType)) - throw new Errors.CannotConvertToType(fromType, toType, cast.position()); - - if (ts.isSubtype(fromType, toType, context)) { - X10Cast n = cast.conversionType(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 (cast.conversionType() != ConversionType.UNKNOWN_IMPLICIT_CONVERSION) { - if (! ts.isParameterType(fromType) - && ! ts.isParameterType(toType) - && ts.isCastValid(fromType, toType, context)) { - X10Cast n = cast.conversionType(ConversionType.CHECKED); - return n.type(toType); - } - } - - { - MethodInstance converter = null; - Call c = null; - MethodInstance mi = converter; - Position p = cast.position(); - Expr e = cast.expr(); - - // Can convert if there is a static method toType.$convert(fromType) - if (converter == null && cast.conversionType() != ConversionType.UNKNOWN_IMPLICIT_CONVERSION) { - try { - mi = ts.findMethod(toType, ts.MethodMatcher(toType, Converter.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, Converter.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, Converter.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 n = cast.conversionType(c, ConversionType.CHECKED); - return n.type(toType); - } - else { - return c; - } - } - } - - l: if (cast.conversionType() != 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(cast, fromType, toType); - } else { - for (Type t : upper) - if (ts.isSubtype(fromType, t)) - return checkedConversionForTypeParameter(cast, 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(cast, fromType, toType); - } - } - - throw new Errors.CannotConvertExprToType(cast.expr(), cast.conversionType(), toType, cast.position()); - } - - - static Expr checkedConversionForTypeParameter(X10Cast_c cast, Type fromType, Type toType) { - return cast.conversionType(ConversionType.CHECKED).type(toType); - } - 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); - } - public static final Name operator_as = Name.make("operator_as"); - public static final Name implicit_operator_as = Name.make("implicit_operator_as"); - -} +package x10.types.checker; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import polyglot.ast.Call; +import polyglot.ast.ConstructorCall; +import polyglot.ast.Expr; +import polyglot.ast.New; +import polyglot.ast.Node; +import polyglot.ast.TypeNode; +import polyglot.main.Report; +import polyglot.types.ClassDef; +import polyglot.types.Context; +import polyglot.types.Def; +import polyglot.types.Matcher; +import polyglot.types.MemberInstance; +import polyglot.types.MethodInstance; +import polyglot.types.Name; +import polyglot.types.NoMemberException; +import polyglot.types.ObjectType; +import polyglot.types.ProcedureDef; +import polyglot.types.ProcedureInstance; +import polyglot.types.SemanticException; +import polyglot.types.Type; +import polyglot.util.Pair; +import polyglot.util.Position; +import polyglot.visit.ContextVisitor; +import x10.ast.X10Cast; +import x10.ast.X10Cast_c; +import x10.ast.X10New_c; +import x10.ast.X10NodeFactory; +import x10.ast.X10ProcedureCall; +import x10.ast.X10New_c.MatcherMaker; +import x10.constraint.XConstraint; +import x10.errors.Errors; +import x10.types.ParameterType; +import x10.types.X10ClassType; +import x10.types.X10Context; +import x10.types.X10ParsedClassType_c; +import x10.types.X10TypeMixin; +import x10.types.X10TypeSystem; +import x10.types.X10TypeSystem_c; + +/** + * A set of static methods used to convert an AST representing an X10 expressions of a given type + * into an AST representing an expressions of another type. + * + * @author vj 2/6/2010 + * + */ +public class Converter { + + public static enum ConversionType { + UNKNOWN_CONVERSION, + UNKNOWN_IMPLICIT_CONVERSION, + PRIMITIVE, + CHECKED, + SUBTYPE, + UNBOXING, + BOXING, + UNCHECKED + } + + /** + * Return the expression, obtained from e through a sequence of operations, that is of type toType + * @param tc -- Visitor to use during construction + * @param e -- the subject expression + * @param toType -- the target type + * @return -- the expression constructed from e of type toType + * @throws SemanticException If this is not possible + */ + public static Expr attemptCoercion(ContextVisitor tc, Expr e, Type toType) throws SemanticException { + X10TypeSystem ts = (X10TypeSystem) tc.typeSystem(); + Type t1 = e.type(); + t1 = PlaceChecker.ReplaceHereByPlaceTerm(t1, (X10Context) tc.context()); + if (ts.isSubtype(t1, toType, tc.context())) + return e; + + ConversionType ct = ts.numericConversionValid(toType, e.type(), e.constantValue(), tc.context()) + ? ConversionType.UNKNOWN_CONVERSION + : ConversionType.UNKNOWN_IMPLICIT_CONVERSION; + + X10NodeFactory nf = (X10NodeFactory) tc.nodeFactory(); + + Expr result = check(nf.X10Cast(e.position(), nf.CanonicalTypeNode(e.position(), toType), e, ct),tc); + return result; + } + + /** + * + * @param <PD> + * @param <PI> + * @param n + * @param tc + * @param targetType + * @param methods + * Unsubstituted, uninstantiated methods. Need to go through + * MethodMatcher.instantiate to use. + * @param maker + * @return + * @throws SemanticException + */ + public static <PD extends ProcedureDef, PI extends ProcedureInstance<PD>> Pair<PI, List<Expr>> + tryImplicitConversions(X10ProcedureCall n, + ContextVisitor tc, Type targetType, List<PI> methods, X10New_c.MatcherMaker<PI> maker) throws SemanticException { + X10NodeFactory nf = (X10NodeFactory) tc.nodeFactory(); + X10TypeSystem ts = (X10TypeSystem) tc.typeSystem(); + X10Context xc = (X10Context) tc.context(); + ClassDef currentClassDef = xc.currentClassDef(); + + List<PI> acceptable = new ArrayList<PI>(); + Map<Def, List<Expr>> newArgs = new HashMap<Def, List<Expr>>(); + + List<Type> typeArgs = new ArrayList<Type>(n.typeArguments().size()); + + for (TypeNode tn : n.typeArguments()) { + typeArgs.add(tn.type()); + } + + METHOD: for (Iterator<PI> i = methods.iterator(); i.hasNext();) { + PI smi = (PI) i.next(); + + if (Report.should_report(Report.types, 3)) + Report.report(3, "Trying " + smi); + + List<Expr> transformedArgs = new ArrayList<Expr>(); + List<Type> transformedArgTypes = new ArrayList<Type>(); + + List<Type> formals = smi.formalTypes(); + + for (int j = 0; j < n.arguments().size(); j++) { + Expr e = n.arguments().get(j); + Type toType = formals.get(j); + + try { + Expr e2 = attemptCoercion(tc, e, toType); + transformedArgs.add(e2); + transformedArgTypes.add(e2.type()); + } + catch (SemanticException ex) { + // Implicit cast not allowed here. + continue METHOD; + } + } + + try { + Matcher<PI> matcher = maker.matcher(targetType, typeArgs, transformedArgTypes); + // ((X10ProcedureInstance) smi).returnType(); + // X10MethodInstance_c.checkCall(xc, (X10ProcedureInstance) smi, + // targetType, typeArgs, transformedArgTypes); + // // smi = (PI) matcher.instantiate(smi); + + // Reinstantiate using the new argument types. + // Be careful to re-subst in the type arguments of the container type. + // This should be cleaner! + PI raw = (PI) smi.def().asInstance(); + if (smi instanceof MemberInstance) { + Type container = ((MemberInstance) smi).container(); + Type base = X10TypeMixin.baseType(container); + if (base instanceof X10ClassType) { + X10ParsedClassType_c ct = (X10ParsedClassType_c) base; + raw = ct.subst().reinstantiate(raw); + } + } + PI smi2 = (PI) matcher.instantiate(raw); + // ((X10ProcedureInstance) smi2).returnType(); + acceptable.add(smi2); + newArgs.put(smi2.def(), transformedArgs); + } + catch (SemanticException e) { + System.out.print(""); + } + } + + if (acceptable.size() == 0) { + if (n instanceof New || n instanceof ConstructorCall) + throw new NoMemberException(NoMemberException.CONSTRUCTOR, "Could not find matching constructor in " + targetType + ".", n.position()); + else + throw new NoMemberException(NoMemberException.METHOD, "Could not find matching method in " + targetType + ".", n.position()); + } + + Collection<PI> maximal = ts.<PD, PI> findMostSpecificProcedures(acceptable, (Matcher<PI>) null, xc); + + if (maximal.size() > 1) { + StringBuffer sb = new StringBuffer(); + for (Iterator<PI> i = maximal.iterator(); i.hasNext();) { + PI ma = (PI) i.next(); + if (ma instanceof MemberInstance) { + sb.append(((MemberInstance) ma).container()); + sb.append("."); + } + sb.append(ma.signature()); + if (i.hasNext()) { + if (maximal.size() == 2) { + sb.append(" and "); + } + else { + sb.append(", "); + } + } + } + + if (n instanceof New || n instanceof ConstructorCall) + throw new NoMemberException(NoMemberException.CONSTRUCTOR, "Reference to " + targetType + " is ambiguous, multiple " + "constructors match: " + + sb.toString(), n.position()); + else + throw new NoMemberException(NoMemberException.METHOD, "Reference to " + targetType + " is ambiguous, multiple " + "methods match: " + + sb.toString(), n.position()); + } + + PI mi; + mi = (PI) maximal.iterator().next(); + + List<Expr> args = newArgs.get(mi.def()); + assert args != null; + + return new Pair<PI, List<Expr>>(mi, args); + } + + + + /** Return list of conversion functions needed to convert from fromType to toType */ + public static Expr converterChain(final X10Cast_c cast, final ContextVisitor tc) throws SemanticException { + try { + return Converter.checkCast(cast, 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 cast.expr(); + X10Cast_c newCast = (X10Cast_c) nf.X10Cast(cast.position(), + nf.CanonicalTypeNode(cast.position(), newFrom), cast.expr(), + Converter.ConversionType.UNKNOWN_IMPLICIT_CONVERSION); + Expr newE = converterChain(newCast, tc); + assert newE.type() != null; + X10Cast_c newC = (X10Cast_c) cast.expr(newE); + return Converter.checkCast(newC, tc); + } + + throw new Errors.CannotConvertToType(fromType, toType, cast.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 = cast.expr().type(); + Type toType = cast.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. + } + } + } + + throw new Errors.CannotConvertExprToType(cast.expr(), cast.conversionType(), toType, cast.position()); + } + + public static Expr checkCast(X10Cast_c cast, ContextVisitor tc) throws SemanticException { + Type toType = cast.castType().type(); + Type fromType = cast.expr().type(); + X10TypeSystem_c ts = (X10TypeSystem_c) tc.typeSystem(); + X10NodeFactory nf = (X10NodeFactory) tc.nodeFactory(); + X10Context context = (X10Context) tc.context(); + + if (ts.isVoid(toType) || ts.isVoid(fromType)) + throw new Errors.CannotConvertToType(fromType, toType, cast.position()); + + if (ts.isSubtype(fromType, toType, context)) { + X10Cast n = cast.conversionType(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 (cast.conversionType() != ConversionType.UNKNOWN_IMPLICIT_CONVERSION) { + if (! ts.isParameterType(fromType) + && ! ts.isParameterType(toType) + && ts.isCastValid(fromType, toType, context)) { + X10Cast n = cast.conversionType(ConversionType.CHECKED); + return n.type(toType); + } + } + + { + MethodInstance converter = null; + Call c = null; + MethodInstance mi = converter; + Position p = cast.position(); + Expr e = cast.expr(); + + // Can convert if there is a static method toType.$convert(fromType) + if (converter == null && cast.conversionType() != ConversionType.UNKNOWN_IMPLICIT_CONVERSION) { + try { + mi = ts.findMethod(toType, ts.MethodMatcher(toType, Converter.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, Converter.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, Converter.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 n = cast.conversionType(c, ConversionType.CHECKED); + return n.type(toType); + } + else { + return c; + } + } + } + + l: if (cast.conversionType() != ConversionType.UNKNOWN_IMPLICIT_CONVERSION) { + if (ts.isPa... [truncated message content] |
From: <vj...@us...> - 2010-02-28 23:47:22
|
Revision: 13089 http://x10.svn.sourceforge.net/x10/?rev=13089&view=rev Author: vj0 Date: 2010-02-28 23:47:16 +0000 (Sun, 28 Feb 2010) Log Message: ----------- Type-checker now ensures that field assignment cannot be used to write into a property. The property(...) call must be used instead. Fixes XTENLANG-973. Modified Paths: -------------- trunk/x10.compiler/src/x10/ast/X10FieldAssign_c.java trunk/x10.compiler/src/x10/errors/Errors.java trunk/x10.runtime/src-x10/x10/array/PolyMatBuilder.x10 trunk/x10.runtime/src-x10/x10/array/RectLayout.x10 trunk/x10.tests/examples/Constructs/DepType/PropertyNotInvoked_MustFailCompile.x10 Modified: trunk/x10.compiler/src/x10/ast/X10FieldAssign_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10FieldAssign_c.java 2010-02-28 21:57:28 UTC (rev 13088) +++ trunk/x10.compiler/src/x10/ast/X10FieldAssign_c.java 2010-02-28 23:47:16 UTC (rev 13089) @@ -20,6 +20,7 @@ import polyglot.ast.Node; import polyglot.ast.Receiver; import polyglot.ast.Assign.Operator; +import polyglot.types.FieldInstance; import polyglot.types.SemanticException; import polyglot.types.Type; import polyglot.types.TypeSystem; @@ -28,6 +29,7 @@ import polyglot.visit.ContextVisitor; import x10.types.X10ClassType; import x10.types.X10Context; +import x10.types.X10FieldInstance; import x10.types.X10Flags; import x10.types.X10TypeMixin; @@ -57,6 +59,11 @@ TypeSystem ts = tc.typeSystem(); X10FieldAssign_c n = (X10FieldAssign_c) typeCheckLeft(tc); Type t = n.leftType(); + // Check that the field being assigned to is not a property. Such fields + X10FieldInstance fd = (X10FieldInstance) n.fieldInstance(); + if (fd.isProperty()) { + throw new Errors.CannotAssignToProperty(fd, n.position()); + } Type targetType = n.target().type(); if (t == null) @@ -83,6 +90,8 @@ n= (X10FieldAssign_c) n.type(t); return n; } + + return Checker.typeCheckAssign(n, tc); } Modified: trunk/x10.compiler/src/x10/errors/Errors.java =================================================================== --- trunk/x10.compiler/src/x10/errors/Errors.java 2010-02-28 21:57:28 UTC (rev 13088) +++ trunk/x10.compiler/src/x10/errors/Errors.java 2010-02-28 23:47:16 UTC (rev 13089) @@ -26,6 +26,7 @@ import x10.ast.X10FieldAssign_c; import x10.ast.X10FieldDecl; import x10.constraint.XTerm; +import x10.types.X10FieldInstance; import x10.types.X10ProcedureInstance; import x10.types.checker.Converter; import x10.types.checker.PlaceChecker; @@ -322,5 +323,18 @@ return((GlobalFieldIsVar)o).position().equals(position()); } } + public static class CannotAssignToProperty extends SemanticException { + private static final long serialVersionUID = 3461823901187721248L; + public CannotAssignToProperty(X10FieldInstance f, Position p) { + super("Must use property(...) to assign to a property." + + "\n\t Property: " + f.name(), + p); + } + public boolean equals(Object o) { + if (o==null || ! (o instanceof CannotAssignToProperty) ) + return false; + return((CannotAssignToProperty)o).position().equals(position()); + } + } } Modified: trunk/x10.runtime/src-x10/x10/array/PolyMatBuilder.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/array/PolyMatBuilder.x10 2010-02-28 21:57:28 UTC (rev 13088) +++ trunk/x10.runtime/src-x10/x10/array/PolyMatBuilder.x10 2010-02-28 23:47:16 UTC (rev 13089) @@ -33,9 +33,9 @@ * Create a new empty builder. */ - public def this(val rank: int): PolyMatBuilder{self.rank==rank} { + public def this(rank: int): PolyMatBuilder{self.rank==rank} { super(rank+1); - this.rank = rank; + property(rank); } Modified: trunk/x10.runtime/src-x10/x10/array/RectLayout.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/array/RectLayout.x10 2010-02-28 21:57:28 UTC (rev 13088) +++ trunk/x10.runtime/src-x10/x10/array/RectLayout.x10 2010-02-28 23:47:16 UTC (rev 13089) @@ -44,7 +44,7 @@ throw U.illegal("min and max must have same length"); val r = min.length; - this.rank = r; + property(r); this.min = min; val d0 = ValRail.make[int](r, (i:Int) => max(i) - min(i) + 1); Modified: trunk/x10.tests/examples/Constructs/DepType/PropertyNotInvoked_MustFailCompile.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/DepType/PropertyNotInvoked_MustFailCompile.x10 2010-02-28 21:57:28 UTC (rev 13088) +++ trunk/x10.tests/examples/Constructs/DepType/PropertyNotInvoked_MustFailCompile.x10 2010-02-28 23:47:16 UTC (rev 13089) @@ -34,7 +34,7 @@ class Tester(i: int(2) ) { public def this(arg:int):Tester{self.i==2} { - i=2; + if (i==2) property(arg as int{self==2}); else { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <vj...@us...> - 2010-03-01 15:51:57
|
Revision: 13096 http://x10.svn.sourceforge.net/x10/?rev=13096&view=rev Author: vj0 Date: 2010-03-01 12:17:50 +0000 (Mon, 01 Mar 2010) Log Message: ----------- Fix for place type errors in TestArray.x10 -- caused many regressions in 2/26 commit. Also fixed scanners() to return a local object. Modified Paths: -------------- trunk/x10.runtime/src-x10/x10/array/BaseRegion.x10 trunk/x10.runtime/src-x10/x10/array/PolyRegion.x10 trunk/x10.runtime/src-x10/x10/array/UnionRegion.x10 trunk/x10.runtime/src-x10/x10/lang/Region.x10 trunk/x10.tests/examples/Constructs/Array/TestArray.x10 Modified: trunk/x10.runtime/src-x10/x10/array/BaseRegion.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/array/BaseRegion.x10 2010-03-01 11:50:12 UTC (rev 13095) +++ trunk/x10.runtime/src-x10/x10/array/BaseRegion.x10 2010-03-01 12:17:50 UTC (rev 13096) @@ -220,7 +220,7 @@ // PolyRegion.Iterator gives us a BaseRegion.Iterator // - public global def scanners(): Iterator[Scanner] { + public global def scanners(): Iterator[Scanner]! { throw U.unsupported(this, "scanners()"); } Modified: trunk/x10.runtime/src-x10/x10/array/PolyRegion.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/array/PolyRegion.x10 2010-03-01 11:50:12 UTC (rev 13095) +++ trunk/x10.runtime/src-x10/x10/array/PolyRegion.x10 2010-03-01 12:17:50 UTC (rev 13096) @@ -77,9 +77,7 @@ } }; - public global def scanners(): Iterator[Scanner] { - return new Scanners(); - } + public global def scanners()=new Scanners(); protected global def scanner(): Region.Scanner { val scanner = PolyScanner.make(mat); Modified: trunk/x10.runtime/src-x10/x10/array/UnionRegion.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/array/UnionRegion.x10 2010-03-01 11:50:12 UTC (rev 13095) +++ trunk/x10.runtime/src-x10/x10/array/UnionRegion.x10 2010-03-01 12:17:50 UTC (rev 13096) @@ -131,9 +131,7 @@ } - public global def scanners(): Iterator[Scanner] { - return new Scanners(); - } + public global def scanners()=new Scanners(); // Modified: trunk/x10.runtime/src-x10/x10/lang/Region.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Region.x10 2010-03-01 11:50:12 UTC (rev 13095) +++ trunk/x10.runtime/src-x10/x10/lang/Region.x10 2010-03-01 12:17:50 UTC (rev 13096) @@ -367,7 +367,7 @@ def max(axis: int): int; } - public abstract global def scanners(): Iterator[Scanner]; + public abstract global def scanners(): Iterator[Scanner]!; public global def scan() = new x10.array.PolyScanner(this); Modified: trunk/x10.tests/examples/Constructs/Array/TestArray.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Array/TestArray.x10 2010-03-01 11:50:12 UTC (rev 13095) +++ trunk/x10.tests/examples/Constructs/Array/TestArray.x10 2010-03-01 12:17:50 UTC (rev 13096) @@ -21,8 +21,8 @@ abstract public class TestArray extends x10Test { - var os: StringWriter; - var out: Printer; + global val os: StringWriter; + global val out: Printer; val testName = typeName(); def this() { @@ -34,6 +34,7 @@ } catch (e:Exception) { //e.printStackTrace(); x10.io.Console.OUT.println(e.toString()); + throw e; } } @@ -73,7 +74,7 @@ class Grid { - var os: Rail[Object] = Rail.make[Object](10); + var os: Rail[Object]! = Rail.make[Object](10); def set(i0: int, vue: double): void = { os(i0) = vue as Box[Double]; @@ -118,7 +119,7 @@ out.print("-"); out.print(" " + i + "\n"); } - (o as Grid).pr(rank-1); + (o as Grid!).pr(rank-1); } else { val d = (o as Box[double]).value; out.print((d as int)+""); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ipe...@us...> - 2010-03-01 17:34:08
|
Revision: 13098 http://x10.svn.sourceforge.net/x10/?rev=13098&view=rev Author: ipeshansky Date: 2010-03-01 17:33:56 +0000 (Mon, 01 Mar 2010) Log Message: ----------- Fix XTENLANG-791 and XTENLANG-801. Major change: all numerics are now closed under arithmetic (and bitwise) operations. The shift count operand of operator >> in all integral types is now Int. Synchronize the APIs of all built-in numeric types. All numeric types have signum() and reverse(). Add X10doc comments to all built-in numeric types. Fix a few API bugs (rotateLeft and rotateRight were just broken). Fix @Native bugs (unary operators and constants, Char conversions). Deprecate operator >>> in built-in numeric types. Rename all T.parseT(...) methods in built-in numeric types to T.parse(...). Deprecate T.parseT(...). Make all toXString() methods in built-in numeric types global and safe. Add Double.MIN_NORMAL and Float.MIN_NORMAL constants. Make second argument of all @NativeRep annotations in built-in numerics null (used to be boxed form). Add interfaces for arithmetic operators (Arithmetic, renamed from ArithmeticOps and cleaned up), comparison operators (Ordered, renamed from ComparisonOps and cleaned up), and bitwise operators (Bitwise). The interfaces are currently not used because there are issues with implicit coercions and non-static operators. Modified Paths: -------------- trunk/x10.dist/samples/ArraySum.x10 trunk/x10.dist/samples/CUDAKernelTest.x10 trunk/x10.dist/samples/FRASimpleDist.x10 trunk/x10.dist/samples/FSSimpleDist.x10 trunk/x10.dist/samples/Histogram.x10 trunk/x10.dist/samples/MontyPi.x10 trunk/x10.dist/samples/NQueensDist.x10 trunk/x10.dist/samples/NQueensPar.x10 trunk/x10.runtime/src-x10/x10/io/Marshal.x10 trunk/x10.runtime/src-x10/x10/lang/Array.x10 trunk/x10.runtime/src-x10/x10/lang/Boolean.x10 trunk/x10.runtime/src-x10/x10/lang/Byte.x10 trunk/x10.runtime/src-x10/x10/lang/Char.x10 trunk/x10.runtime/src-x10/x10/lang/Complex.x10 trunk/x10.runtime/src-x10/x10/lang/Double.x10 trunk/x10.runtime/src-x10/x10/lang/Float.x10 trunk/x10.runtime/src-x10/x10/lang/Int.x10 trunk/x10.runtime/src-x10/x10/lang/Long.x10 trunk/x10.runtime/src-x10/x10/lang/Point.x10 trunk/x10.runtime/src-x10/x10/lang/Short.x10 trunk/x10.runtime/src-x10/x10/lang/String.x10 trunk/x10.runtime/src-x10/x10/lang/UByte.x10 trunk/x10.runtime/src-x10/x10/lang/UInt.x10 trunk/x10.runtime/src-x10/x10/lang/ULong.x10 trunk/x10.runtime/src-x10/x10/lang/UShort.x10 trunk/x10.runtime/src-x10/x10/util/Random.x10 trunk/x10.tests/examples/Benchmarks/UTSRand.x10 trunk/x10.tests/examples/Issues/XTENLANG_477.x10 trunk/x10.tests/examples/Misc/ExpressionParentheses.x10 trunk/x10.tests/examples/Misc/FS.x10 trunk/x10.tests/examples/Misc/Stencil1D.x10 trunk/x10.tests/examples/Tutorial/Fib.x10 trunk/x10.tests/examples/Tutorial/Integrate.x10 Added Paths: ----------- trunk/x10.runtime/src-x10/x10/lang/Arithmetic.x10 trunk/x10.runtime/src-x10/x10/lang/Bitwise.x10 trunk/x10.runtime/src-x10/x10/util/Ordered.x10 Removed Paths: ------------- trunk/x10.runtime/src-x10/x10/compiler/ArithmeticOps.x10 trunk/x10.runtime/src-x10/x10/compiler/ComparisonOps.x10 Modified: trunk/x10.dist/samples/ArraySum.x10 =================================================================== --- trunk/x10.dist/samples/ArraySum.x10 2010-03-01 15:15:20 UTC (rev 13097) +++ trunk/x10.dist/samples/ArraySum.x10 2010-03-01 17:33:56 UTC (rev 13098) @@ -58,7 +58,7 @@ var size:Int = 5*1000*1000; if (args.length >=1) - size = Int.parseInt(args(0)); + size = Int.parse(args(0)); Console.OUT.println("Initializing."); val a = new ArraySum(size); Modified: trunk/x10.dist/samples/CUDAKernelTest.x10 =================================================================== --- trunk/x10.dist/samples/CUDAKernelTest.x10 2010-03-01 15:15:20 UTC (rev 13097) +++ trunk/x10.dist/samples/CUDAKernelTest.x10 2010-03-01 17:33:56 UTC (rev 13098) @@ -47,7 +47,7 @@ } public static def main (args : Rail[String]!) { - val len = args.length==1 ? Int.parseInt(args(0)) : 1000; + val len = args.length==1 ? Int.parse(args(0)) : 1000; for (host in Place.places) at (host) { Modified: trunk/x10.dist/samples/FRASimpleDist.x10 =================================================================== --- trunk/x10.dist/samples/FRASimpleDist.x10 2010-03-01 15:15:20 UTC (rev 13097) +++ trunk/x10.dist/samples/FRASimpleDist.x10 2010-03-01 17:33:56 UTC (rev 13098) @@ -64,7 +64,7 @@ static def randomAccessUpdate( num_updates: long, - logLocalTableSize: long, + logLocalTableSize: int, tables: PlaceLocalHandle[LocalTable] ) { finish for (var p:int=0; p<Place.MAX_PLACES; p++) { @@ -91,7 +91,7 @@ } // calculate the size of update array (must be a power of 2) - val logLocalTableSize = args.length > 1 && args(0).equals("-m")?int.parseInt(args(1)) : 12; + val logLocalTableSize = args.length > 1 && args(0).equals("-m") ? int.parse(args(1)) : 12; val localTableSize = 1<<logLocalTableSize; val tableSize = localTableSize*Place.MAX_PLACES; val num_updates = 4*tableSize; Modified: trunk/x10.dist/samples/FSSimpleDist.x10 =================================================================== --- trunk/x10.dist/samples/FSSimpleDist.x10 2010-03-01 15:15:20 UTC (rev 13097) +++ trunk/x10.dist/samples/FSSimpleDist.x10 2010-03-01 17:33:56 UTC (rev 13098) @@ -30,7 +30,7 @@ public static def main(args:Rail[String]!){here == Place.FIRST_PLACE} { val verified: Rail[boolean]! = [true]; val times = Rail.make[double](NUM_TIMES); - val N0 = args.length>0? int.parseInt(args(0)) : DEFAULT_SIZE; + val N0 = args.length > 0 ? int.parse(args(0)) : DEFAULT_SIZE; val N = N0 * NUM_PLACES; val localSize = N0; Modified: trunk/x10.dist/samples/Histogram.x10 =================================================================== --- trunk/x10.dist/samples/Histogram.x10 2010-03-01 15:15:20 UTC (rev 13097) +++ trunk/x10.dist/samples/Histogram.x10 2010-03-01 17:33:56 UTC (rev 13098) @@ -30,8 +30,8 @@ System.setExitCode(-1); return; } - val N = int.parseInt(args(0)); - val S=int.parseInt(args(1)); + val N = int.parse(args(0)); + val S = int.parse(args(1)); val a = Array.make[int](0..N-1, ((i):Point)=> i); val b = Rail.make[int](S); run(a, b); Modified: trunk/x10.dist/samples/MontyPi.x10 =================================================================== --- trunk/x10.dist/samples/MontyPi.x10 2010-03-01 15:15:20 UTC (rev 13097) +++ trunk/x10.dist/samples/MontyPi.x10 2010-03-01 17:33:56 UTC (rev 13098) @@ -19,7 +19,7 @@ System.setExitCode(-1); return; } - val N = int.parseInt(s(0)); + val N = int.parse(s(0)); val initializer = (i:Point) => { val r = new Random(); var result:double=0.0D; Modified: trunk/x10.dist/samples/NQueensDist.x10 =================================================================== --- trunk/x10.dist/samples/NQueensDist.x10 2010-03-01 15:15:20 UTC (rev 13097) +++ trunk/x10.dist/samples/NQueensDist.x10 2010-03-01 17:33:56 UTC (rev 13098) @@ -92,7 +92,7 @@ } public static def main(args: Rail[String]!) { - val n = args.length > 0 ? Int.parseInt(args(0)) : 8; + val n = args.length > 0 ? Int.parse(args(0)) : 8; println("N=" + n); //warmup //finish new NQueensPar(12, 1).start(); Modified: trunk/x10.dist/samples/NQueensPar.x10 =================================================================== --- trunk/x10.dist/samples/NQueensPar.x10 2010-03-01 15:15:20 UTC (rev 13097) +++ trunk/x10.dist/samples/NQueensPar.x10 2010-03-01 17:33:56 UTC (rev 13098) @@ -84,7 +84,7 @@ } public static def main(args: Rail[String]!) { - val n = args.length > 0 ? Int.parseInt(args(0)) : 8; + val n = args.length > 0 ? Int.parse(args(0)) : 8; println("N=" + n); //warmup //finish new NQueensPar(12, 1).start(); Deleted: trunk/x10.runtime/src-x10/x10/compiler/ArithmeticOps.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/compiler/ArithmeticOps.x10 2010-03-01 15:15:20 UTC (rev 13097) +++ trunk/x10.runtime/src-x10/x10/compiler/ArithmeticOps.x10 2010-03-01 17:33:56 UTC (rev 13098) @@ -1,24 +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. - */ - -package x10.compiler; - -public interface ArithmeticOps[T] { - operator + this: T; - operator - this: T; - - operator this + (that: T): T; - operator this - (that: T): T; - operator this * (that: T): T; - operator this / (that: T): T; - operator this % (that: T): T; -} - Deleted: trunk/x10.runtime/src-x10/x10/compiler/ComparisonOps.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/compiler/ComparisonOps.x10 2010-03-01 15:15:20 UTC (rev 13097) +++ trunk/x10.runtime/src-x10/x10/compiler/ComparisonOps.x10 2010-03-01 17:33:56 UTC (rev 13098) @@ -1,21 +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. - */ - -package x10.compiler; - -public interface ComparisonOps[T] { - operator this == (that: T): boolean; - operator this < (that: T): boolean; - operator this > (that: T): boolean; - operator this <= (that: T): boolean; - operator this >= (that: T): boolean; - operator this != (that: T): boolean; -} Modified: trunk/x10.runtime/src-x10/x10/io/Marshal.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/io/Marshal.x10 2010-03-01 15:15:20 UTC (rev 13097) +++ trunk/x10.runtime/src-x10/x10/io/Marshal.x10 2010-03-01 17:33:56 UTC (rev 13098) @@ -105,20 +105,20 @@ return; } if ((i & 0xfffff800) == 0) { - w.write(((i >>> 6) & 0x0000001f) | 0x000000c0 as Byte); + w.write(((i >> 6) & 0x0000001f) | 0x000000c0 as Byte); w.write((i & 0x0000003f) | 0x00000080 as Byte); return; } if ((i & 0xffff0000) == 0) { - w.write(((i >>> 12) & 0x0000000f) | 0x000000e0 as Byte); - w.write(((i >>> 6) & 0x0000003f) | 0x00000080 as Byte); + w.write(((i >> 12) & 0x0000000f) | 0x000000e0 as Byte); + w.write(((i >> 6) & 0x0000003f) | 0x00000080 as Byte); w.write((i & 0x0000003f) | 0x00000080 as Byte); return; } if ((i & 0xffe00000) == 0) { - w.write(((i >>> 18) & 0x00000007) | 0x000000f0 as Byte); - w.write(((i >>> 12) & 0x0000003f) | 0x00000080 as Byte); - w.write(((i >>> 6) & 0x0000003f) | 0x00000080 as Byte); + w.write(((i >> 18) & 0x00000007) | 0x000000f0 as Byte); + w.write(((i >> 12) & 0x0000003f) | 0x00000080 as Byte); + w.write(((i >> 6) & 0x0000003f) | 0x00000080 as Byte); w.write((i & 0x0000003f) | 0x00000080 as Byte); return; } @@ -134,7 +134,7 @@ public global def write(w: Writer, s: Short): Void throws IOException { val i = s as Int; - val b1 = ((i >>> 8) & 0xff) as Byte; + val b1 = ((i >> 8) & 0xff) as Byte; val b2 = (i & 0xff) as Byte; w.write(b1); w.write(b2); @@ -151,9 +151,9 @@ } public global def write(w: Writer, i: Int): Void throws IOException { - val b1 = ((i >>> 24) & 0xff) as Byte; - val b2 = ((i >>> 16) & 0xff) as Byte; - val b3 = ((i >>> 8) & 0xff) as Byte; + val b1 = ((i >> 24) & 0xff) as Byte; + val b2 = ((i >> 16) & 0xff) as Byte; + val b3 = ((i >> 8) & 0xff) as Byte; val b4 = (i & 0xff) as Byte; w.write(b1); w.write(b2); @@ -176,7 +176,7 @@ var shift: int = 64; while (shift > 0) { shift -= 8; - val b = ((l >>> shift) & 0xffL) as Byte; + val b = ((l >> shift) & 0xffL) as Byte; w.write(b); } } Copied: trunk/x10.runtime/src-x10/x10/lang/Arithmetic.x10 (from rev 12966, trunk/x10.runtime/src-x10/x10/compiler/ArithmeticOps.x10) =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Arithmetic.x10 (rev 0) +++ trunk/x10.runtime/src-x10/x10/lang/Arithmetic.x10 2010-03-01 17:33:56 UTC (rev 13098) @@ -0,0 +1,60 @@ +/* + * 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.lang; + +/** + * A set of common arithmetic operations. + */ +public interface Arithmetic[T] { + /** + * A unary plus operator. + * A no-op. + * @return the value of the current entity. + */ + operator + this: T; + /** + * A unary minus operator. + * Negates the operand. + * @return the negated value of the current entity. + */ + operator - this: T; + + /** + * A binary plus operator. + * Computes the result of the addition of the two operands. + * @param that the other entity + * @return the sum of the current entity and the other entity. + */ + operator this + (that: T): T; + /** + * A binary minus operator. + * Computes the result of the subtraction of the two operands. + * @param that the other entity + * @return the difference of the current entity and the other entity. + */ + operator this - (that: T): T; + /** + * A binary multiply operator. + * Computes the result of the multiplication of the two operands. + * @param that the other entity + * @return the product of the current entity and the other entity. + */ + operator this * (that: T): T; + /** + * A binary divide operator. + * Computes the result of the division of the two operands. + * @param that the other entity + * @return the quotient of the current entity and the other entity. + */ + operator this / (that: T): T; +} + Modified: trunk/x10.runtime/src-x10/x10/lang/Array.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Array.x10 2010-03-01 15:15:20 UTC (rev 13097) +++ trunk/x10.runtime/src-x10/x10/lang/Array.x10 2010-03-01 17:33:56 UTC (rev 13098) @@ -11,7 +11,6 @@ package x10.lang; -import x10.compiler.ArithmeticOps; import x10.array.BaseArray; import x10.array.FastArray; Added: trunk/x10.runtime/src-x10/x10/lang/Bitwise.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Bitwise.x10 (rev 0) +++ trunk/x10.runtime/src-x10/x10/lang/Bitwise.x10 2010-03-01 17:33:56 UTC (rev 13098) @@ -0,0 +1,75 @@ +/* + * 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.lang; + +/** + * A set of common bitwise operations. + */ +public interface Bitwise[T] { + /** + * A bitwise complement operator. + * Computes a bitwise complement (NOT) of the operand. + * @return the bitwise complement of the current entity. + */ + operator ~ this: T; + + /** + * A bitwise and operator. + * Computes a bitwise AND of the two operands. + * @param that the other entity + * @return the bitwise AND of the current entity and the other entity. + */ + operator this & (that: T): T; + /** + * A bitwise or operator. + * Computes a bitwise OR of the two operands. + * @param that the other entity + * @return the bitwise OR of the current entity and the other entity. + */ + operator this | (that: T): T; + /** + * A bitwise xor operator. + * Computes a bitwise XOR of the two operands. + * @param that the other entity + * @return the bitwise XOR of the current entity and the other entity. + */ + operator this ^ (that: T): T; + + /** + * A bitwise left shift operator. + * Computes the value of the left-hand operand shifted left by the value of the right-hand operand. + * If the right-hand operand is negative, the results are undefined. + * @param count the shift count + * @return the current entity shifted left by count. + */ + operator this << (count: Int): T; + /** + * A bitwise right shift operator. + * Computes the value of the left-hand operand shifted right by the value of the right-hand operand. + * If the right-hand operand is negative, the results are undefined. + * @param count the shift count + * @return the current entity shifted right by count. + */ + operator this >> (count: Int): T; + + /** + * A bitwise logical right shift operator (zero-fill). + * Computes the value of the left-hand operand shifted right by the value of the right-hand operand, + * filling the high bits with zeros. + * If the right-hand operand is negative, the results are undefined. + * @deprecated use the right-shift operator and unsigned conversions instead. + * @param count the shift count + * @return the current entity shifted right by count with high bits zero-filled. + */ + operator this >>> (count: Int): T; +} + Property changes on: trunk/x10.runtime/src-x10/x10/lang/Bitwise.x10 ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Modified: trunk/x10.runtime/src-x10/x10/lang/Boolean.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Boolean.x10 2010-03-01 15:15:20 UTC (rev 13097) +++ trunk/x10.runtime/src-x10/x10/lang/Boolean.x10 2010-03-01 17:33:56 UTC (rev 13098) @@ -14,47 +14,120 @@ import x10.compiler.Native; import x10.compiler.NativeRep; -@NativeRep("java", "boolean", "x10.core.BoxedBoolean", "x10.rtt.Type.BOOLEAN") +/** + * Boolean is a logical data type, with two values: 'true' and 'false'. + * All of the normal logical operations are defined on Boolean. + * There are also static methods that define conversions to and from String, + * as well as some Boolean constants. + */ +@NativeRep("java", "boolean", null, "x10.rtt.Type.BOOLEAN") @NativeRep("c++", "x10_boolean", "x10_boolean", null) public final struct Boolean { - @Native("java", "!(#1)") - @Native("c++", "!(#1)") + /** + * A logical complement operator. + * Computes a logical complement of the given Boolean. + * @param x the given Boolean + * @return the logical complement of the given Boolean. + */ + @Native("java", "(!(#1))") + @Native("c++", "(!(#1))") public native static safe operator ! (x:Boolean): Boolean; - + + /** + * A logical and operator (not short-circuiting). + * Computes a logical AND of the given Boolean and the other Boolean. + * Evaluates both arguments. + * @param x the given Boolean + * @param y the other Boolean + * @return the logical AND of the given Boolean and the other Boolean. + */ @Native("java", "((#1) & (#2))") @Native("c++", "((x10_boolean) (((#1) ? 1 : 0) & ((#2) ? 1 : 0)))") public native static safe operator (x:Boolean) & (y:Boolean): Boolean; - + + /** + * A logical or operator (not short-circuiting). + * Computes a logical OR of the given Boolean and the other Boolean. + * Evaluates both arguments. + * @param x the given Boolean + * @param y the other Boolean + * @return the logical OR of the given Boolean and the other Boolean. + */ + @Native("java", "((#1) | (#2))") + @Native("c++", "((x10_boolean) (((#1) ? 1 : 0) | ((#2) ? 1 : 0)))") + public native static safe operator (x:Boolean) | (y:Boolean): Boolean; + + /** + * A logical xor operator. + * Computes a logical XOR of the given Boolean and the other Boolean. + * @param x the given Boolean + * @param y the other Boolean + * @return the logical XOR of the given Boolean and the other Boolean. + */ @Native("java", "((#1) ^ (#2))") @Native("c++", "((x10_boolean) (((#1) ? 1 : 0) ^ ((#2) ? 1 : 0)))") public native static safe operator (x:Boolean) ^ (y:Boolean): Boolean; - - @Native("java", "((#1) | (#2))") - @Native("c++", "((x10_boolean) (((#1) ? 1 : 0) | ((#2) ? 1 : 0)))") - public native static safe operator (x:Boolean) | (y:Boolean): Boolean; - - + + + /** + * A constant holding the Boolean value 'true'. + */ @Native("java", "true") @Native("c++", "true") public const TRUE = true; + /** + * A constant holding the Boolean value 'false'. + */ @Native("java", "false") @Native("c++", "false") public const FALSE = false; + + /** + * Returns a String representation of this Boolean. + * @return a string representation of this Boolean. + */ @Native("java", "java.lang.Boolean.toString(#0)") @Native("c++", "x10aux::to_string(#0)") public global safe native def toString(): String; - + + /** + * @deprecated use {@link #parse(String)} instead + */ @Native("java", "java.lang.Boolean.parseBoolean(#1)") @Native("c++", "x10aux::boolean_utils::parseBoolean(#1)") public native static def parseBoolean(String): Boolean; + /** + * Parses the String argument as a Boolean. + * The Boolean returned represents the value 'true' if the String argument + * is not null and is equal, ignoring case, to the string "true". + * @param s the String containing the Boolean representation to be parsed + * @return the Boolean represented by the String argument. + */ + @Native("java", "java.lang.Boolean.parseBoolean(#1)") + @Native("c++", "x10aux::boolean_utils::parseBoolean(#1)") + public native static def parse(s:String): Boolean; + + + /** + * Return true if the given entity is a Boolean, and this Boolean is equal + * to the given entity. + * @param x the given entity + * @return true if this Boolean is equal to the given entity. + */ + //FIXME Java: use equalsequals()? @Native("java", "((((#2) instanceof boolean) && #1 == ((boolean)#2)) || (((#2) instanceof Boolean) && #1 == ((Boolean) #2).booleanValue()))") @Native("c++", "x10aux::equals(#0,#1)") public global safe native def equals(x:Any):Boolean; + /** + * Returns true if this Boolean is equal to the given Boolean. + * @param x the given Boolean + * @return true if this Boolean is equal to the given Boolean. + */ @Native("java", "x10.rtt.Equality.equalsequals(#0, #1)") @Native("c++", "x10aux::equals(#0,#1)") public global safe native def equals(x:Boolean):Boolean; Modified: trunk/x10.runtime/src-x10/x10/lang/Byte.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Byte.x10 2010-03-01 15:15:20 UTC (rev 13097) +++ trunk/x10.runtime/src-x10/x10/lang/Byte.x10 2010-03-01 17:33:56 UTC (rev 13098) @@ -13,158 +13,413 @@ import x10.compiler.Native; import x10.compiler.NativeRep; +import x10.util.Ordered; -@NativeRep("java", "byte", "x10.core.BoxedByte", "x10.rtt.Type.BYTE") +/** + * Byte is an 8-bit signed two's complement integral data type, with + * values ranging from -128 to 127, inclusive. All of the normal + * arithmetic and bitwise operations are defined on Byte, and Byte + * is closed under those operations. There are also static methods + * that define conversions from other data types, including String, + * as well as some Byte constants. + */ +@NativeRep("java", "byte", null, "x10.rtt.Type.BYTE") @NativeRep("c++", "x10_byte", "x10_byte", null) -public final struct Byte { +public final struct Byte /*TODO implements Arithmetic[Byte], Bitwise[Byte], Ordered[Byte]*/ { + /** + * A less-than operator. + * Compares the given Byte with another Byte and returns true if the given Byte is + * strictly less than the other Byte. + * @param x the given Byte + * @param y the other Byte + * @return true if the given Byte is strictly less than the other Byte. + */ @Native("java", "((#1) < (#2))") @Native("c++", "((#1) < (#2))") public native static safe operator (x:Byte) < (y:Byte): Boolean; + /** + * A greater-than operator. + * Compares the given Byte with another Byte and returns true if the given Byte is + * strictly greater than the other Byte. + * @param x the given Byte + * @param y the other Byte + * @return true if the given Byte is strictly greater than the other Byte. + */ @Native("java", "((#1) > (#2))") @Native("c++", "((#1) > (#2))") public native static safe operator (x:Byte) > (y:Byte): Boolean; + /** + * A less-than-or-equal-to operator. + * Compares the given Byte with another Byte and returns true if the given Byte is + * less than or equal to the other Byte. + * @param x the given Byte + * @param y the other Byte + * @return true if the given Byte is less than or equal to the other Byte. + */ @Native("java", "((#1) <= (#2))") @Native("c++", "((#1) <= (#2))") public native static safe operator (x:Byte) <= (y:Byte): Boolean; + /** + * A greater-than-or-equal-to operator. + * Compares the given Byte with another Byte and returns true if the given Byte is + * greater than or equal to the other Byte. + * @param x the given Byte + * @param y the other Byte + * @return true if the given Byte is greater than or equal to the other Byte. + */ @Native("java", "((#1) >= (#2))") @Native("c++", "((#1) >= (#2))") public native static safe operator (x:Byte) >= (y:Byte): Boolean; - @Native("java", "((#1) + (#2))") - @Native("c++", "((x10_int) ((#1) + (#2)))") - public native static safe operator (x:Byte) + (y:Byte): Int; - @Native("java", "((#1) - (#2))") - @Native("c++", "((x10_int) ((#1) - (#2)))") - public native static safe operator (x:Byte) - (y:Byte): Int; + /** + * A binary plus operator. + * Computes the result of the addition of the two operands. + * Overflows result in truncating the high bits. + * @param x the given Byte + * @param y the other Byte + * @return the sum of the given Byte and the other Byte. + */ + @Native("java", "((byte) ((#1) + (#2)))") + @Native("c++", "((x10_byte) ((#1) + (#2)))") + public native static safe operator (x:Byte) + (y:Byte): Byte; - @Native("java", "((#1) * (#2))") - @Native("c++", "((x10_int) ((#1) * (#2)))") - public native static safe operator (x:Byte) * (y:Byte): Int; + /** + * A binary minus operator. + * Computes the result of the subtraction of the two operands. + * Overflows result in truncating the high bits. + * @param x the given Byte + * @param y the other Byte + * @return the difference of the given Byte and the other Byte. + */ + @Native("java", "((byte) ((#1) - (#2)))") + @Native("c++", "((x10_byte) ((#1) - (#2)))") + public native static safe operator (x:Byte) - (y:Byte): Byte; - @Native("java", "((#1) / (#2))") - @Native("c++", "((x10_int) ((#1) / (#2)))") - public native static safe operator (x:Byte) / (y:Byte): Int; + /** + * A binary multiply operator. + * Computes the result of the multiplication of the two operands. + * Overflows result in truncating the high bits. + * @param x the given Byte + * @param y the other Byte + * @return the product of the given Byte and the other Byte. + */ + @Native("java", "((byte) ((#1) * (#2)))") + @Native("c++", "((x10_byte) ((#1) * (#2)))") + public native static safe operator (x:Byte) * (y:Byte): Byte; - @Native("java", "((#1) % (#2))") - @Native("c++", "((x10_int) ((#1) % (#2)))") - public native static safe operator (x:Byte) % (y:Byte): Int; - - @Native("java", "((#1) & (#2))") - @Native("c++", "((x10_int) ((#1) & (#2)))") - public native static safe operator (x:Byte) & (y:Byte): Int; - - @Native("java", "((#1) ^ (#2))") - @Native("c++", "((x10_int) ((#1) ^ (#2)))") - public native static safe operator (x:Byte) ^ (y:Byte): Int; - - @Native("java", "((#1) | (#2))") - @Native("c++", "((x10_int) ((#1) | (#2)))") - public native static safe operator (x:Byte) | (y:Byte): Int; - - @Native("java", "((#1) << (#2))") - @Native("c++", "((x10_int) ((#1) << (#2)))") - public native static safe operator (x:Byte) << (y:Int): Int; - - @Native("java", "((#1) >> (#2))") - @Native("c++", "((x10_int) ((#1) >> (#2)))") - public native static safe operator (x:Byte) >> (y:Int): Int; - - @Native("java", "((#1) >>> (#2))") - @Native("c++", "((x10_int) ((x10_uint) (#1) >> (#2)))") - public native static safe operator (x:Byte) >>> (y:Int): Int; - - // FIXME: why is this here? - @Native("java", "((#1) << (#2))") - @Native("c++", "((x10_int) ((#1) << (#2)))") - public native static safe operator (x:Byte) << (y:Long): Int; - - // FIXME: why is this here? - @Native("java", "((#1) >> (#2))") - @Native("c++", "((x10_int) ((#1) >> (#2)))") - public native static safe operator (x:Byte) >> (y:Long): Int; - - // FIXME: why is this here? - @Native("java", "((#1) >>> (#2))") - @Native("c++", "((x10_int) ((x10_uint) (#1) >> (#2)))") - public native static safe operator (x:Byte) >>> (y:Long): Int; - - @Native("java", "+(#1)") - @Native("c++", "((x10_int) +(#1))") - public native static safe operator + (x:Byte): Int; - - @Native("java", "-(#1)") - @Native("c++", "((x10_int) -(#1))") - public native static safe operator - (x:Byte): Int; - - @Native("java", "~(#1)") - @Native("c++", "((x10_int) ~(#1))") - public native static safe operator ~ (x:Byte): Int; - + /** + * A binary divide operator. + * Computes the result of the division of the two operands. + * @param x the given Byte + * @param y the other Byte + * @return the quotient of the given Byte and the other Byte. + */ + @Native("java", "((byte) ((#1) / (#2)))") + @Native("c++", "((x10_byte) ((#1) / (#2)))") + public native static safe operator (x:Byte) / (y:Byte): Byte; + + /** + * A binary remainder operator. + * Computes a remainder from the division of the two operands. + * @param x the given Byte + * @param y the other Byte + * @return the remainder from dividing the given Byte by the other Byte. + */ + @Native("java", "((byte) ((#1) % (#2)))") + @Native("c++", "((x10_byte) ((#1) % (#2)))") + public native static safe operator (x:Byte) % (y:Byte): Byte; + + /** + * A unary plus operator. + * A no-op. + * @param x the given Byte + * @return the value of the given Byte. + */ + @Native("java", "((byte) +(#1))") + @Native("c++", "((x10_byte) +(#1))") + public native static safe operator + (x:Byte): Byte; + + /** + * A unary minus operator. + * Negates the operand. + * Overflows result in truncating the high bits. + * @param x the given Byte + * @return the negated value of the given Byte. + */ + @Native("java", "((byte) -(#1))") + @Native("c++", "((x10_byte) -(#1))") + public native static safe operator - (x:Byte): Byte; + + + /** + * A bitwise and operator. + * Computes a bitwise AND of the two operands. + * @param x the given Byte + * @param y the other Byte + * @return the bitwise AND of the given Byte and the other Byte. + */ + @Native("java", "((byte) ((#1) & (#2)))") + @Native("c++", "((x10_byte) ((#1) & (#2)))") + public native static safe operator (x:Byte) & (y:Byte): Byte; + + /** + * A bitwise or operator. + * Computes a bitwise OR of the two operands. + * @param x the given Byte + * @param y the other Byte + * @return the bitwise OR of the given Byte and the other Byte. + */ + @Native("java", "((byte) ((#1) | (#2)))") + @Native("c++", "((x10_byte) ((#1) | (#2)))") + public native static safe operator (x:Byte) | (y:Byte): Byte; + + /** + * A bitwise xor operator. + * Computes a bitwise XOR of the two operands. + * @param x the given Byte + * @param y the other Byte + * @return the bitwise XOR of the given Byte and the other Byte. + */ + @Native("java", "((byte) ((#1) ^ (#2)))") + @Native("c++", "((x10_byte) ((#1) ^ (#2)))") + public native static safe operator (x:Byte) ^ (y:Byte): Byte; + + /** + * A bitwise left shift operator. + * Computes the value of the left-hand operand shifted left by the value of the right-hand operand. + * If the right-hand operand is negative, the results are undefined. + * @param x the given Byte + * @param count the shift count + * @return the given Byte shifted left by count. + */ + @Native("java", "((byte) ((#1) << (#2)))") + @Native("c++", "((x10_byte) ((#1) << (#2)))") + public native static safe operator (x:Byte) << (count:Int): Byte; + + /** + * A bitwise right shift operator. + * Computes the value of the left-hand operand shifted right by the value of the right-hand operand, + * replicating the sign bit into the high bits. + * If the right-hand operand is negative, the results are undefined. + * @param x the given Byte + * @param count the shift count + * @return the given Byte shifted right by count. + */ + @Native("java", "((byte) ((#1) >> (#2)))") + @Native("c++", "((x10_byte) ((#1) >> (#2)))") + public native static safe operator (x:Byte) >> (count:Int): Byte; + + /** + * A bitwise logical right shift operator (zero-fill). + * Computes the value of the left-hand operand shifted right by the value of the right-hand operand, + * filling the high bits with zeros. + * If the right-hand operand is negative, the results are undefined. + * @deprecated use the right-shift operator and unsigned conversions instead. + * @param x the given Byte + * @param count the shift count + * @return the given Byte shifted right by count with high bits zero-filled. + */ + @Native("java", "((byte) ((#1) >>> (#2)))") + @Native("c++", "((x10_byte) ((x10_uint) (#1) >> (#2)))") + public native static safe operator (x:Byte) >>> (count:Int): Byte; + + /** + * A bitwise complement operator. + * Computes a bitwise complement (NOT) of the operand. + * @param x the given Byte + * @return the bitwise complement of the given Byte. + */ + @Native("java", "((byte) ~(#1))") + @Native("c++", "((x10_byte) ~(#1))") + public native static safe operator ~ (x:Byte): Byte; + + + /** + * Convert a given Short to a Byte. + * @param x the given Short + * @return the given Short converted to a Byte. + */ @Native("java", "((byte)(short)(#1))") @Native("c++", "((x10_byte) (#1))") public native static safe operator (x:Short) as Byte; - + + /** + * Convert a given Int to a Byte. + * @param x the given Int + * @return the given Int converted to a Byte. + */ @Native("java", "((byte)(int)(#1))") @Native("c++", "((x10_byte) (#1))") public native static safe operator (x:Int) as Byte; + /** + * Convert a given Long to a Byte. + * @param x the given Long + * @return the given Long converted to a Byte. + */ @Native("java", "((byte)(long)(#1))") @Native("c++", "((x10_byte) (#1))") public native static safe operator (x:Long) as Byte; + /** + * Convert a given Float to a Byte. + * @param x the given Float + * @return the given Float converted to a Byte. + */ @Native("java", "((byte)(float)(#1))") @Native("c++", "((x10_byte) (#1))") public native static safe operator (x:Float) as Byte; - + + /** + * Convert a given Double to a Byte. + * @param x the given Double + * @return the given Double converted to a Byte. + */ @Native("java", "((byte)(double)(#1))") @Native("c++", "((x10_byte) (#1))") public native static safe operator (x:Double) as Byte; - + /** + * Convert a given UByte to a Byte. + * @param x the given UByte + * @return the given UByte converted to a Byte. + */ + @Native("java", "((byte)(#1))") + @Native("c++", "((x10_byte) (#1))") + public native static safe operator (x:UByte) as Byte; + + + /** + * A constant holding the minimum value a Byte can have, -2<sup>7</sup>. + */ @Native("java", "java.lang.Byte.MIN_VALUE") - @Native("c++", "(x10_byte)0x80") + @Native("c++", "((x10_byte)0x80)") public const MIN_VALUE = 0x80 as Byte; - + + /** + * A constant holding the maximum value a Byte can have, 2<sup>7</sup>-1. + */ @Native("java", "java.lang.Byte.MAX_VALUE") - @Native("c++", "(x10_byte)0x7f") + @Native("c++", "((x10_byte)0x7f)") public const MAX_VALUE = 0x7f as Byte; + + /** + * Returns a String representation of this Byte in the specified radix. + * @param radix the radix to use in the String representation + * @return a String representation of this Byte in the specified radix. + */ @Native("java", "java.lang.Integer.toString(#0, #1)") @Native("c++", "x10aux::byte_utils::toString(#0, #1)") - public global safe native def toString(radix: Int): String; - + public global safe native def toString(radix:Int): String; + + /** + * Returns a String representation of this Byte as a hexadecimal number. + * @return a String representation of this Byte as a hexadecimal number. + */ @Native("java", "java.lang.Integer.toHexString(#0)") @Native("c++", "x10aux::byte_utils::toHexString(#0)") - public native def toHexString(): String; - + public global safe native def toHexString(): String; + + /** + * Returns a String representation of this Byte as an octal number. + * @return a String representation of this Byte as an octal number. + */ @Native("java", "java.lang.Integer.toOctalString(#0)") @Native("c++", "x10aux::byte_utils::toOctalString(#0)") - public native def toOctalString(): String; - + public global safe native def toOctalString(): String; + + /** + * Returns a String representation of this Byte as a binary number. + * @return a String representation of this Byte as a binary number. + */ @Native("java", "java.lang.Integer.toBinaryString(#0)") @Native("c++", "x10aux::byte_utils::toBinaryString(#0)") - public native def toBinaryString(): String; - + public global safe native def toBinaryString(): String; + + /** + * Returns a String representation of this Byte as a decimal number. + * @return a String representation of this Byte as a decimal number. + */ @Native("java", "java.lang.Byte.toString(#0)") @Native("c++", "x10aux::to_string(#0)") public global safe native def toString(): String; - + + /** + * @deprecated use {@link #parse(String,Int)} instead + */ @Native("java", "java.lang.Byte.parseByte(#1, #2)") @Native("c++", "x10aux::byte_utils::parseByte(#1, #2)") - public native static def parseByte(String, radix: Int): Byte throws NumberFormatException; - + public native static def parseByte(String, radix:Int): Byte throws NumberFormatException; + + /** + * @deprecated use {@link #parse(String)} instead + */ @Native("java", "java.lang.Byte.parseByte(#1)") @Native("c++", "x10aux::byte_utils::parseByte(#1)") public native static def parseByte(String): Byte throws NumberFormatException; + /** + * Parses the String argument as a Byte in the radix specified by the second argument. + * @param s the String containing the Byte representation to be parsed + * @param radix the radix to be used while parsing s + * @return the Byte represented by the String argument in the specified radix. + * @throws NumberFormatException if the String does not contain a parsable Byte. + */ + @Native("java", "java.lang.Byte.parseByte(#1, #2)") + @Native("c++", "x10aux::byte_utils::parseByte(#1, #2)") + public native static def parse(s:String, radix:Int): Byte throws NumberFormatException; + + /** + * Parses the String argument as a decimal Byte. + * @param s the String containing the Byte representation to be parsed + * @return the Byte represented by the String argument. + * @throws NumberFormatException if the String does not contain a parsable Byte. + */ + @Native("java", "java.lang.Byte.parseByte(#1)") + @Native("c++", "x10aux::byte_utils::parseByte(#1)") + public native static def parse(s:String): Byte throws NumberFormatException; + + + /** + * Returns the value obtained by reversing the order of the bits in the + * two's complement binary representation of this Byte. + * @return the value obtained by reversing order of the bits in this Byte. + */ + @Native("java", "((byte)(java.lang.Integer.reverse(#0)>>>24))") + @Native("c++", "((x10_byte)(x10aux::int_utils::reverse(#0)>>24))") + public native def reverse(): Byte; + + /** + * Returns the signum function of this Byte. The return value is -1 if + * this Byte is negative; 0 if this Byte is zero; and 1 if this Byte is + * positive. + * @return the signum function of this Byte. + */ + @Native("java", "java.lang.Integer.signum(#0)") + @Native("c++", "x10aux::int_utils::signum((x10_int)#0)") + public native def signum(): Int; + + + /** + * Return true if the given entity is a Byte, and this Byte is equal + * to the given entity. + * @param x the given entity + * @return true if this Byte is equal to the given entity. + */ @Native("java", "x10.rtt.Equality.equalsequals(#0, #1)") @Native("c++", "x10aux::equals(#0,#1)") public global safe native def equals(x:Any):Boolean; + /** + * Returns true if this Byte is equal to the given Byte. + * @param x the given Byte + * @return true if this Byte is equal to the given Byte. + */ @Native("java", "x10.rtt.Equality.equalsequals(#0, #1)") @Native("c++", "x10aux::equals(#0,#1)") public global safe native def equals(x:Byte):Boolean; Modified: trunk/x10.runtime/src-x10/x10/lang/Char.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Char.x10 2010-03-01 15:15:20 UTC (rev 13097) +++ trunk/x10.runtime/src-x10/x10/lang/Char.x10 2010-03-01 17:33:56 UTC (rev 13098) @@ -13,130 +13,307 @@ import x10.compiler.Native; import x10.compiler.NativeRep; +import x10.util.Ordered; -@NativeRep("java", "char", "x10.core.BoxedChar", "x10.rtt.Type.CHAR") +/** + * Char is a data type representing a Unicode character. It is not + * an integral data type. The "arithmetic" operations defined on + * Char are in fact character manipulation operations. There are + * also static methods that define conversions from other data types, + * including String, as well as some Char constants. + */ +@NativeRep("java", "char", null, "x10.rtt.Type.CHAR") @NativeRep("c++", "x10_char", "x10_char", null) -public final struct Char { +public final struct Char /*TODO implements Ordered[Char]*/ { + /** + * Convert a given Byte to a Char with that ordinal value. + * @param x the given Byte + * @return the Char with the same ordinal value as the given Byte. + */ @Native("java", "((char) (#1))") @Native("c++", "((x10_char) (char) (#1))") public native static safe operator (x:Byte) as Char; - + + /** + * Convert a given Short to a Char with that ordinal value. + * @param x the given Short + * @return the Char with the same ordinal value as the given Short. + */ @Native("java", "((char) (#1))") - @Native("c++", "((x10_char) (char) (#1))") + @Native("c++", "((x10_char) (int) (#1))") public native static safe operator (x:Short) as Char; - + + /** + * Convert a given Int to a Char with that ordinal value. + * @param x the given Int + * @return the Char with the same ordinal value as the given Int. + */ @Native("java", "((char) (#1))") - @Native("c++", "((x10_char) (char) (#1))") + @Native("c++", "((x10_char) (int) (#1))") public native static safe operator (x:Int) as Char; - + + /** + * Convert a given Long to a Char with that ordinal value. + * @param x the given Long + * @return the Char with the same ordinal value as the given Long. + */ @Native("java", "((char) (#1))") - @Native("c++", "((x10_char) (char) (#1))") + @Native("c++", "((x10_char) (int) (#1))") public native static safe operator (x:Long) as Char; - + + + /** + * Translate a given Char's ordinal value forward by the specified distance. + * @param x the given Char + * @param y the specified distance + * @return the Char whose ordinal value is the sum of the given Char's ordinal value and the given distance. + */ @Native("java", "((char) ((#1) + (#2)))") - @Native("c++", "((x10_char) (char) ((#1) + (#2)))") + @Native("c++", "((x10_char) (int) ((#1) + (#2)))") public native static safe operator (x:Char) + (y:Int): Char; + /** + * Translate a given Char's ordinal value forward by the specified distance. + * @param x the specified distance + * @param y the given Char + * @return the Char whose ordinal value is the sum of the given Char's ordinal value and the given distance. + */ @Native("java", "((char) ((#1) + (#2)))") - @Native("c++", "((x10_char) (char) ((#1) + (#2)))") + @Native("c++", "((x10_char) (int) ((#1) + (#2)))") public native static safe operator (x:Int) + (y:Char): Char; + /** + * Translate a given Char's ordinal value backward by the specified distance. + * @param x the given Char + * @param y the specified distance + * @return the Char whose ordinal value is the difference of the given Char's ordinal value and the given distance. + */ @Native("java", "((char) ((#1) - (#2)))") - @Native("c++", "((x10_char) (char) ((#1) - (#2)))") + @Native("c++", "((x10_char) (int) ((#1) - (#2)))") public native static safe operator (x:Char) - (y:Int): Char; + /** + * Compute the distance between two Chars. + * @param x the target Char + * @param y the source Char + * @return the distance between the source Char and the target Char. + */ @Native("java", "((#1) - (#2))") @Native("c++", "((#1) - (#2))") public native static safe operator (x:Char) - (y:Char): Int; - @Native("java", "((#1) < (#2))") - @Native("c++", "((#1) < (#2))") - public native static safe operator (x:Char) < (y:Char): Boolean; - @Native("java", "((#1) > (#2))") - @Native("c++", "((#1) > (#2))") - public native static safe operator (x:Char) > (y:Char): Boolean; - @Native("java", "((#1) <= (#2))") - @Native("c++", "((#1) <= (#2))") - public native static safe operator (x:Char) <= (y:Char): Boolean; - @Native("java", "((#1) >= (#2))") - @Native("c++", "((#1) >= (#2))") - public native static safe operator (x:Char) >= (y:Char): Boolean; - + + // FIXME: Locale sensitivity + /** + * A less-than operator. + * Compares this Char with another Char and returns true if this Char is + * strictly before the other Char in dictionary order. + * @param x the other Char + * @return true if this Char is strictly before the other Char. + */ + @Native("java", "((#0) < (#1))") + @Native("c++", "((#0) < (#1))") + public native safe operator this < (x:Char): Boolean; + + // FIXME: Locale sensitivity + /** + * A greater-than operator. + * Compares this Char with another Char and returns true if this Char is + * strictly after the other Char in dictionary order. + * @param x the other Char + * @return true if this Char is strictly after the other Char. + */ + @Native("java", "((#0) > (#1))") + @Native("c++", "((#0) > (#1))") + public native safe operator this > (x:Char): Boolean; + + // FIXME: Locale sensitivity + /** + * A less-than-or-equal-to operator. + * Compares this Char with another Char and returns true if this Char is + * equal to the other Char or is before it in dictionary order. + * @param x the other Char + * @return true if this Char is before or equal to the other Char. + */ + @Native("java", "((#0) <= (#1))") + @Native("c++", "((#0) <= (#1))") + public native safe operator this <= (x:Char): Boolean; + + // FIXME: Locale sensitivity + /** + * A greater-than-or-equal-to operator. + * Compares this Char with another Char and returns true if this Char is + * equal to the other Char or is after it in dictionary order. + * @param x the other Char + * @return true if this Char is after or equal to the other Char. + */ + @Native("java", "((#0) >= (#1))") + @Native("c++", "((#0) >= (#1))") + public native safe operator this >= (x:Char): Boolean; + + + /** + * Returns a String representation of this Char. + * @return a String representation of this Char. + */ @Native("java", "java.lang.Character.toString(#0)") @Native("c++", "x10aux::to_string(#0)") public global safe native def toString(): String; - + + // Duplicate the methods from java.lang.Character, changing static methods to non-static. // We'll ignore the code point methods for now and just include the isXXX ones. - + + /** + * Determines if this Char is a lowercase character. + * @return true if this Char is lowercase; false otherwise. + */ @Native("java", "java.lang.Character.isLowerCase(#0)") @Native("c++", "x10aux::char_utils::isLowerCase(#0)") public native def isLowerCase(): boolean; + /** + * Determines if this Char is an uppercase character. + * @return true if this Char is uppercase; false otherwise. + */ @Native("java", "java.lang.Character.isUpperCase(#0)") @Native("c++", "x10aux::char_utils::isUpperCase(#0)") public native def isUpperCase(): boolean; + /** + * Determines if this Char is a titlecase character. + * @return true if this Char is titlecase; false otherwise. + */ @Native("java", "java.lang.Character.isTitleCase(#0)") @Native("c++", "x10aux::char_utils::isTitleCase(#0)") public native def isTitleCase(): boolean; + /** + * Determines if this Char is a digit. + * @return true if this Char is a digit; false otherwise. + */ @Native("java", "java.lang.Character.isDigit(#0)") @Native("c++", "x10aux::char_utils::isDigit(#0)") public native def isDigit(): boolean; + /** + * Determines if this Char is a letter. + * @return true if this Char is a letter; false otherwise. + */ @Native("java", "java.lang.Character.isLetter(#0)") @Native("c++", "x10aux::char_utils::isLetter(#0)") public native def isLetter(): boolean; + /** + * Determines if this Char is a letter or digit. + * @return true if this Char is a letter or digit; false otherwise. + */ @Native("java", "java.lang.Character.isLetterOrDigit(#0)") @Native("c++", "x10aux::char_utils::isLetterOrDigit(#0)") public native def isLetterOrDigit(): boolean; + /** + * Determines if this Char is a Unicode space character. + * A Char is considered to be a space character if and only if it + * is specified to be a space character by the Unicode standard. + * @return true if this Char is a space character; false otherwise. + */ @Native("java", "java.lang.Character.isSpaceChar(#0)") @Native("c++", "x10aux::char_utils::isSpaceChar(#0)") public native def isSpaceChar(): boolean; + /** + * Determines if this Char is whitespace according to X10. + * A Char is an X10 whitespace character if and only if it serves + * as a whitespace separator in an X10 program. + * @return true if this Char is an X10 whitespace character; false otherwise. + */ @Native("java", "java.lang.Character.isWhitespace(#0)") @Native("c++", "x10aux::char_utils::isWhitespace(#0)") public native def isWhitespace(): boolean; + /** + * Determines if this Char is an ISO control character. + * @return true if this Char is an ISO control character; false otherwise. + */ @Native("java", "java.lang.Character.isISOControl(#0)") @Native("c++", "x10aux::char_utils::isISOControl(#0)") public native def isISOControl(): boolean; - + + /** + * Converts this Char to lowercase using case mapping information from + * the UnicodeData file. + * @return the lowercase equivalent of this Char, if any; otherwise, the Char itself. + */ @Native("java", "java.lang.Character.toLowerCase(#0)") @Native("c++", "x10aux::char_utils::toLowerCase(#0)") public native def toLowerCase(): Char; + /** + * Converts this Char to uppercase using case mapping information from + * the UnicodeData file. + * @return the lowercase equivalent of this Char, if any; otherwise, the Char itself. + */ @Native("java", "java.lang.Character.toUpperCase(#0)") @Native("c++", "x10aux::char_utils::toUpperCase(#0)") public native def toUpperCase(): Char; + /** + * Converts this Char to titlecase using case mapping information from + * the UnicodeData file. + * If a Char has no explicit titlecase mapping and is not itself a + * titlecase Char according to UnicodeData, then the uppercase mapping + * is returned as an equivalent titlecase mapping. If this Char is + * already a titlecase Char, the same Char value will be returned. + * @return the titlecase equivalent of this Char, if any; otherwise, the Char itself. + */ @Native("java", "java.lang.Character.toTitleCase(#0)") @Native("c++", "x10aux::char_utils::toTitleCase(#0)") public native def toTitleCase(): Char; - + + + /** + * Returns the ordinal value of this Char. + * @return the ordinal value of this Char. + */ @Native("java", "((int) (#0))") @Native("c++", "((x10_int) (#0).v)") public native def ord(): Int; + /** + * Returns the ordinal value of the given Char. + * @param c the given Char + * @return the ordinal value of the given Char. + */ @Native("java", "((int) (#1))") @Native("c++", "((x10_int) (#1).v)") - public native static def ord(Char): Int; + public native static def ord(c:Char): Int; + /** + * Return the Char with the same ordinal value as the given Int. + * @param x the given Int + * @return the Char with the same ordinal value as the given Int. + */ @Native("java", "((char) (#1))") @Native("c++", "((x10_char) (int) (#1))") - public native static def chr(Int): Char; - - @Native("java", "java.lang.Character.reverseBytes(#0)") - @Native("c++", "x10aux::char_utils::reverseBytes(#0)") - public native def reverseBytes(): Char; + public native static def chr(x:Int): Char; + + /** + * Return true if the given entity is a Byte, and this Byte is equal + * to the given entity. + * @param x the given entity + * @return true if this Byte is equal to the given entity. + */ @Native("java", "x10.rtt.Equality.equalsequals(#0, #1)") @Native("c++", "x10aux::equals(#0,#1)") public global safe native def equals(x:Any):Boolean; + /** + * Returns true if this Byte is equal to the given Byte. + * @param x the given Byte + * @return true if this Byte is equal to the given Byte. + */ @Native("java", "x10.rtt.Equality.equalsequals(#0, #1)") @Native("c++", "x10aux::equals(#0,#1)") public global safe native def equals(x:Char):Boolean; Modified: trunk/x10.runtime/src-x10/x10/lang/Complex.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Complex.x10 2010-03-01 15:15:20 UTC (rev 13097) +++ trunk/x10.runtime/src-x10/x10/lang/Complex.x10 2010-03-01 17:33:56 UTC (rev 13098) @@ -13,9 +13,10 @@ package x10.lang; /** - * This struct represents a complex number (a + b*i). + * Complex is a struct representing a complex number (a + b*i). + * The real and imaginary components are represented as Doubles. */ -public struct Complex { +public struct Complex /*TODO implements Arithmetic[Complex]*//*, Arithmetic[Double]*/ { /** The real component of this complex number. */ public val re:Double; /** The imaginary component of this complex number. */ @@ -165,6 +166,11 @@ } /** + * @return this complex number. + */ + public safe operator + this:Complex = this; + + /** * @return the negation of this complex number. */ public safe operator - this:Complex = isNaN() ? Complex.NaN : Complex(-re, -im); Modified: trunk/x10.runtime/src-x10/x10/lang/Double.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Double.x10 2010-03-01 15:15:20 UTC (rev 13097) +++ trunk/x10.runtime/src-x10/x10/lang/Double.x10 2010-03-01 17:33:56 UTC (rev 13098) @@ -13,132 +13,364 @@ import x10.compiler.Native; import x10.compiler.NativeRep; +import x10.util.Ordered; -@NativeRep("java", "double", "x10.core.BoxedDouble", "x10.rtt.Types.DOUBLE") +/** + * Double is a 64-bit double-precision IEEE 754 floating point data type. + * Unlike Java, X10 does not restrict the precision of floating + * point values, so they may be represented by an extended-exponent + * variant at runtime. All of the normal + * arithmetic and bitwise operations are defined on Double, and Double + * is closed under those operations. There are also static methods + * that define conversions from other data types, including String, + * as well as some Double constants. + */ +@NativeRep("java", "double", null, "x10.rtt.Types.DOUBLE") @NativeRep("c++", "x10_double", "x10_double", null) -public final struct Double { +public final struct Double /*TODO implements Arithmetic[Double], Ordered[Double]*/ { + /** + * A less-than operator. + * Compares the given Double with another Double and returns true if the given Double is + * strictly less than the other Double. + * Note that NaN values are unordered. + * @param x the given Double + * @param y the other Double + * @return true if the given Double is strictly less than the other Double. + */ @Native("java", "((#1) < (#2))") @Native("c++", "((#1) < (#2))") public native static safe operator (x:Double) < (y:Double): Bo... [truncated message content] |
From: <vj...@us...> - 2010-03-02 17:31:30
|
Revision: 13128 http://x10.svn.sourceforge.net/x10/?rev=13128&view=rev Author: vj0 Date: 2010-03-02 17:31:22 +0000 (Tue, 02 Mar 2010) Log Message: ----------- Added check for args of type def invocations--- if they are local variables, they must be final variables. Modified Paths: -------------- trunk/x10.compiler/src/x10/ast/AmbMacroTypeNode_c.java trunk/x10.tests/examples/Constructs/DepType/DepTypeInMethodRet1_MustFailCompile.x10 Modified: trunk/x10.compiler/src/x10/ast/AmbMacroTypeNode_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/AmbMacroTypeNode_c.java 2010-03-02 16:58:28 UTC (rev 13127) +++ trunk/x10.compiler/src/x10/ast/AmbMacroTypeNode_c.java 2010-03-02 17:31:22 UTC (rev 13128) @@ -28,6 +28,7 @@ import polyglot.ast.TypeNode_c; import polyglot.frontend.Globals; import polyglot.frontend.Goal; +import polyglot.types.Context; import polyglot.types.Flags; import polyglot.types.LazyRef; import polyglot.types.LocalDef; @@ -36,6 +37,7 @@ import polyglot.types.Ref; import polyglot.types.SemanticException; import polyglot.types.Type; +import polyglot.types.TypeSystem; import polyglot.types.Types; import polyglot.types.UnknownType; import polyglot.util.CodeWriter; @@ -296,6 +298,8 @@ throw ex; } + + public Node typeCheckOverride(Node parent, ContextVisitor tc) throws SemanticException { X10TypeSystem ts = (X10TypeSystem) tc.typeSystem(); X10NodeFactory nf = (X10NodeFactory) tc.nodeFactory(); @@ -313,6 +317,7 @@ n = (AmbMacroTypeNode_c) n.prefix(prefix); n = (AmbMacroTypeNode_c) n.name(name); + List<TypeNode> typeArgs = visitList(n.typeArgs, childtc); List<Expr> args = visitList(n.args, childtc); n = (AmbMacroTypeNode_c) n.typeArgs(typeArgs); @@ -435,8 +440,31 @@ result = (CanonicalTypeNode) ((X10Del) result.del()).annotations(((X10Del) n.del()).annotations()); result = (CanonicalTypeNode) ((X10Del) result.del()).setComment(((X10Del) n.del()).comment()); result = (CanonicalTypeNode) result.del().typeCheck(childtc); - - + { + class VarChecker extends NodeVisitor { + SemanticError error = null; + public Node override(Node n) { + if (n instanceof Local) { + Local e = (Local) n; + if (! e.flags().isFinal()) + error = new SemanticError("Local variable " + e.name() + + " must be final in type def.", + e.position()); + return n; + + } + return null; + } + } + + VarChecker ac = new VarChecker(); + result.visit(ac); + + if (ac.error != null) { + throw ac.error; + } + + } return result; } Modified: trunk/x10.tests/examples/Constructs/DepType/DepTypeInMethodRet1_MustFailCompile.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/DepType/DepTypeInMethodRet1_MustFailCompile.x10 2010-03-02 16:58:28 UTC (rev 13127) +++ trunk/x10.tests/examples/Constructs/DepType/DepTypeInMethodRet1_MustFailCompile.x10 2010-03-02 17:31:22 UTC (rev 13128) @@ -22,7 +22,7 @@ public def m(var t: boolean): boolean(t)= t; public def run() = m(true); - public static def main(var args: Rail[String]): void = { + public static def main(Rail[String]) { new DepTypeInMethodRet1_MustFailCompile().execute(); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <vj...@us...> - 2010-03-03 10:56:24
|
Revision: 13135 http://x10.svn.sourceforge.net/x10/?rev=13135&view=rev Author: vj0 Date: 2010-03-03 10:56:17 +0000 (Wed, 03 Mar 2010) Log Message: ----------- Clears the TestArray regression. Change to Matcher clears the RegionAlgebra.x10 regression. Modified Paths: -------------- trunk/x10.compiler/src/x10/types/matcher/DumbMethodMatcher.java trunk/x10.compiler/src/x10/types/matcher/Matcher.java trunk/x10.tests/examples/Constructs/Array/TestArray.x10 Modified: trunk/x10.compiler/src/x10/types/matcher/DumbMethodMatcher.java =================================================================== --- trunk/x10.compiler/src/x10/types/matcher/DumbMethodMatcher.java 2010-03-03 03:01:56 UTC (rev 13134) +++ trunk/x10.compiler/src/x10/types/matcher/DumbMethodMatcher.java 2010-03-03 10:56:17 UTC (rev 13135) @@ -23,10 +23,6 @@ /** A method matcher that only checks name and arity. */ public class DumbMethodMatcher extends X10MethodMatcher { - public DumbMethodMatcher(Type container, Name name, List<Type> argTypes, Context context) { - super(container, name, argTypes, context); - } - public DumbMethodMatcher(Type container, Name name, List<Type> typeArgs, List<Type> argTypes, Context context) { super(container, name, typeArgs, argTypes, context); } Modified: trunk/x10.compiler/src/x10/types/matcher/Matcher.java =================================================================== --- trunk/x10.compiler/src/x10/types/matcher/Matcher.java 2010-03-03 03:01:56 UTC (rev 13134) +++ trunk/x10.compiler/src/x10/types/matcher/Matcher.java 2010-03-03 10:56:17 UTC (rev 13135) @@ -70,10 +70,8 @@ } // Instantiate the proposed PI. - XVar[] ys = new XVar[actuals.size()+1]; - boolean[] hasSymbol = new boolean[actuals.size()+1]; Type[] thisTypeArray = new Type[] { thisType}; - PI newMe = instantiate2(context, me, thisTypeArray, typeActuals, actuals, ys, hasSymbol, true); + PI newMe = instantiate2(context, me, thisTypeArray, typeActuals, actuals, true); return newMe; } @@ -82,7 +80,9 @@ Type thisType, List<Type> typeActuals, final List<Type> actuals) throws SemanticException { - return instantiate2(context, me, new Type[] {thisType}, typeActuals, actuals, new XVar[actuals.size()+1], new boolean[actuals.size()+1], false); + + PI me2 = instantiate2(context, me, new Type[] {thisType}, typeActuals, actuals, false); + return me2; } /** @@ -95,18 +95,17 @@ * @param actuals -- The types of the actual parameters for the call. * @param ys -- An inout parameter, on completion contains a symbolic name for the target and each parameter * @param hasSymbol -- An inout parameter of the same size as ys. On completion, the ith entry is true iff a symbolic name was generated for ys[i]. - * @return -- An instantiated version of me, with actuals substituted for formals in actual types and return types. Needs to be type-checked by checkCall. + * @return -- An instantiated version of me, with actuals substituted for formals in actual types and return types. * @throws SemanticException */ public static <PI extends X10ProcedureInstance<?>> PI instantiate2(final X10Context context, final PI me, /*inout*/ Type[] thisTypeArray, List<Type> typeActuals, List<Type> actuals, - /*inout*/ final XVar[] ys, - /*inout*/ final boolean [] hasSymbol, boolean checkActuals ) throws SemanticException { - + final XVar[] ys = new XVar[actuals.size()+1]; + final boolean[] hasSymbol = new boolean[actuals.size()+1]; final X10TypeSystem xts = (X10TypeSystem) me.typeSystem(); final List<Type> formals = new ArrayList<Type>(); @@ -249,14 +248,45 @@ // by replacing x's by y's and this by the yeqv, and substituting in type parameters. // with this normalization, checkCall will simply have to check that the types of the actuals // are a subtype of the formals. - List<Type> newFormals = new ArrayList<Type>(); - for (Type t : formals) { - Type newT = Subst.subst(t, y2eqv, x2, Y, X); - newFormals.add(newT); - } - newMe = (PI) newMe.formalTypes(newFormals); - } + // substitute in the information about this. + if (! checkActuals) { + List<Type> newFormals = new ArrayList<Type>(); + CConstraint env = null; + if (! isStatic) { + env = X10TypeMixin.xclause(thisType); + if (env != null && ythiseqv != null && ! ((env == null) || env.valid())) { + env = env.copy().instantiateSelf(ythiseqv); + } + } + for (Type t : formals) { + t = Subst.subst(t, y2eqv, x2, Y, X); + if (! (env == null || env.valid())) { + try { + t = Subst.subst(t, y2eqv, x2, Y, X); + if (! isStatic) + t = Subst.addIn(t, env); + } catch (XFailure z) { + t = xts.unknownType(me.position()); + } + } + if (! isStatic && ! hasSymbol[0]) { + t = Subst.project(t, (XRoot) ys[0]); + } + newFormals.add(t); + } + newMe = (PI) newMe.formalTypes(newFormals); + + } else { + List<Type> newFormals = new ArrayList<Type>(); + for (Type t : formals) { + t = Subst.subst(t, y2eqv, x2, Y, X); + newFormals.add(t); + } + newMe = (PI) newMe.formalTypes(newFormals); + } + } + { // set up the guard. CConstraint newWhere = Subst.subst(me.guard(), y2eqv, x2, Y, X); newMe = (PI) newMe.guard(newWhere); @@ -314,7 +344,8 @@ final List<Type> myFormals = new ArrayList<Type>(newMe.formalTypes()); // copy for (int i = 0; i < formals.size(); i++) { Type ytype = actuals.get(i); - Type xtype = myFormals.get(i); + Type xtype = Subst.subst(formals.get(i), y2eqv, x2, Y, X); + if (! xts.consistent(xtype, context2)) { throw new SemanticException("Parameter type " + xtype + " of call is inconsistent in calling context."); } @@ -391,7 +422,8 @@ private static XVar getSymbol(Type type, String prefix) { XVar symbol = X10TypeMixin.selfVarBinding(type); if (symbol == null) { - symbol = XTerms.makeUQV(XTerms.makeFreshName(prefix)); + symbol = XTerms.makeLocal(XTerms.makeFreshName("arg")); + // symbol = XTerms.makeUQV(XTerms.makeFreshName(prefix)); } return symbol; } Modified: trunk/x10.tests/examples/Constructs/Array/TestArray.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Array/TestArray.x10 2010-03-03 03:01:56 UTC (rev 13134) +++ trunk/x10.tests/examples/Constructs/Array/TestArray.x10 2010-03-03 10:56:17 UTC (rev 13135) @@ -297,7 +297,7 @@ var ps: Rail[Place]! = d.places(); for (var i: int = 0; i<ps.length; i++) { - var r: Region = d.get(ps(i)); + val r: Region = d.get(ps(i)); for (p:Point(r.rank) in r) { val q = p as Point(a.dist.region.rank); a(q) = a(q) + ps(i).id + 1; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ipe...@us...> - 2010-03-04 03:15:32
|
Revision: 13169 http://x10.svn.sourceforge.net/x10/?rev=13169&view=rev Author: ipeshansky Date: 2010-03-04 03:15:25 +0000 (Thu, 04 Mar 2010) Log Message: ----------- Fix XTENLANG-900, which was caused by 2 problems: (1) @Native methods of Object were not using virtual dispatch, and (2) we were generating override proxies for @Native methods incorrectly. Factor out some string constants (REFERENCE_TYPE and CLOSURE_TYPE). Minor tweaks to X10doc in x10.lang.Any. Add X10doc to methods of x10.lang.Object. Modified Paths: -------------- trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java trunk/x10.compiler/src/x10cpp/visit/SharedVarsMethods.java trunk/x10.runtime/src-x10/x10/lang/Any.x10 trunk/x10.runtime/src-x10/x10/lang/Object.x10 Modified: trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java =================================================================== --- trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java 2010-03-04 02:51:14 UTC (rev 13168) +++ trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java 2010-03-04 03:15:25 UTC (rev 13169) @@ -40,6 +40,8 @@ import static x10cpp.visit.SharedVarsMethods.THIS; import static x10cpp.visit.SharedVarsMethods.VOID; import static x10cpp.visit.SharedVarsMethods.VOID_PTR; +import static x10cpp.visit.SharedVarsMethods.REFERENCE_TYPE; +import static x10cpp.visit.SharedVarsMethods.CLOSURE_TYPE; import static x10cpp.visit.SharedVarsMethods.chevrons; import static x10cpp.visit.SharedVarsMethods.getId; import static x10cpp.visit.SharedVarsMethods.getUniqueId_; @@ -1175,12 +1177,12 @@ h.write("static void "+SERIALIZE_METHOD+"("); h.begin(0); h.write(Emitter.translateType(currentClass, true)+" this_,"); h.newline(); h.write(SERIALIZATION_BUFFER+"& buf) {"); h.end(); h.newline(4); h.begin(0); - h.write("x10::lang::Reference::"+SERIALIZE_METHOD+"(this_, buf);"); h.end(); h.newline(); + h.write(REFERENCE_TYPE+"::"+SERIALIZE_METHOD+"(this_, buf);"); h.end(); h.newline(); h.write("}"); h.newline(); h.forceNewline(); h.write("public: template<class __T> static "); h.write(make_ref("__T")+" "+DESERIALIZE_METHOD+"("+DESERIALIZATION_BUFFER+"& buf) {"); h.newline(4) ; h.begin(0); - h.write("return x10::lang::Reference::"+DESERIALIZE_METHOD+"<__T>(buf);"); h.end(); h.newline(); + h.write("return "+REFERENCE_TYPE+"::"+DESERIALIZE_METHOD+"<__T>(buf);"); h.end(); h.newline(); h.write("}"); h.newline(); h.forceNewline(); if (!members.isEmpty()) { @@ -1419,7 +1421,7 @@ emitter.printTemplateSignature(currentClass.typeArguments(), sw); sw.write("x10_boolean "+StructCType+ "::equals(x10aux::ref<x10::lang::Any> that) {"); sw.newline(4); sw.begin(0); - sw.writeln("x10aux::ref<x10::lang::Reference> thatAsRef(that);"); + sw.writeln(make_ref(REFERENCE_TYPE)+" thatAsRef(that);"); sw.write("if (thatAsRef->_type()->equals(x10aux::getRTT<"+StructCType+" >())) {"); sw.newline(4); sw.begin(0); sw.writeln("x10aux::ref<x10::lang::IBox<"+StructCType+" > > thatAsIBox(that);"); @@ -1616,9 +1618,9 @@ } private void generateProxiesForOverriddenMethods(X10CPPContext_c context, - X10ClassType currentClass, X10ClassType superClass, - X10TypeSystem xts, String maybeVirtual, ClassifiedStream h, - List<ClassMember> members) { + X10ClassType currentClass, X10ClassType superClass, + X10TypeSystem xts, String maybeVirtual, ClassifiedStream h, + List<ClassMember> members) { // first gather a set of all the method names in the current class ArrayList<Name> mnames = getMethodNames(members); @@ -1685,21 +1687,17 @@ if (!dropzone.returnType().isVoid()) sw.write("return "); String pat = getCppImplForDef(dropzone.x10Def()); - if (pat != null) { // TODO: merge with emitNativeAnnotation + if (pat != null) { + X10ClassType ct = (X10ClassType) dropzone.container().toClass(); + List<Type> typeArguments = ct.typeArguments(); + Expr target = tr.nodeFactory().Super(Position.COMPILER_GENERATED).type(ct); // FIXME: casts! - Object[] components = new Object[1+3*newTypeParameters.size() + formals.size()]; - components[0] = "this"; - int i = 1; - for (Type at : newTypeParameters) { - components[i++] = at; - components[i++] = "/"+"*"+" UNUSED "+"*"+"/"; - components[i++] = "/"+"*"+" UNUSED "+"*"+"/"; - } + ArrayList<String> args = new ArrayList<String>(); counter = 0; for (Type formal : formals) { - components[i++] = "p" + (counter++); + args.add("p" + (counter++)); } - emitter.dumpRegex("Native", components, tr, pat, sw); + emitNativeAnnotation(pat, newTypeParameters, target, args, typeArguments); } else { sw.write(Emitter.translateType(superClass, false) + "::" + mangled_method_name(mname.toString())); @@ -1733,7 +1731,7 @@ } } - String defaultValue(Type type) { + String defaultValue(Type type) { return type.isPrimitive() ? "0" : "x10aux::null"; } @@ -2938,7 +2936,7 @@ if (t.isClass()) { X10ClassType clsType = (X10ClassType)t.toClass(); if (clsType.flags().isInterface()) { - invokeInterface(n, (Expr) target, args, make_ref("x10::lang::Reference"), clsType, mi, needsPlaceCheck, needsNullCheck); + invokeInterface(n, (Expr) target, args, make_ref(REFERENCE_TYPE), clsType, mi, needsPlaceCheck, needsNullCheck); sw.end(); return; } @@ -3081,7 +3079,7 @@ sw.allowBreak(0, " "); } boolean needsCast = true; - sw.write("(((x10::lang::Reference*)("); + sw.write("((("+REFERENCE_TYPE+"*)("); if (!replicate) { sw.write("_"); } else { @@ -3804,11 +3802,11 @@ boolean needsPlaceCheck = !xf.isGlobal() && PlaceChecker.needsPlaceCheck(domain, context); boolean needsNullCheck = needsNullCheck(domain); if (mi.container().toClass().flags().isInterface()) { - sw.write(make_ref("x10::lang::Reference") + " " + name + " = "+iteratorTypeRef+"("); - invokeInterface(n, domain, Collections.EMPTY_LIST, make_ref("x10::lang::Reference"), xts.Iterable(form.type().type()), mi, needsPlaceCheck, needsNullCheck); + sw.write(make_ref(REFERENCE_TYPE) + " " + name + " = "+iteratorTypeRef+"("); + invokeInterface(n, domain, Collections.EMPTY_LIST, make_ref(REFERENCE_TYPE), xts.Iterable(form.type().type()), mi, needsPlaceCheck, needsNullCheck); sw.write(");"); sw.newline(); } else { - sw.write(make_ref("x10::lang::Reference") + " " + name + " = ("); + sw.write(make_ref(REFERENCE_TYPE) + " " + name + " = ("); if (needsPlaceCheck) sw.write("x10aux::placeCheck("); if (needsNullCheck) sw.write("x10aux::nullCheck("); n.print(domain, sw, tr); @@ -3816,13 +3814,13 @@ if (needsNullCheck) sw.write(")"); sw.writeln(")->iterator();"); } - sw.write((doubleTemplate ? "typename " : "")+iteratorType+"::"+(doubleTemplate ? "template ":"")+"itable<x10::lang::Reference> *"+itableName+" = x10aux::findITable"+chevrons(iteratorType)+"("+name+"->_getITables());"); sw.newline(); + sw.write((doubleTemplate ? "typename " : "")+iteratorType+"::"+(doubleTemplate ? "template ":"")+"itable<"+REFERENCE_TYPE+"> *"+itableName+" = x10aux::findITable"+chevrons(iteratorType)+"("+name+"->_getITables());"); sw.newline(); sw.write("for ("); sw.begin(0); sw.write(";"); sw.allowBreak(2, " "); - sw.write("(((x10::lang::Reference*)("+name+".operator->()))->*("+itableName+"->hasNext))();"); + sw.write("((("+REFERENCE_TYPE+"*)("+name+".operator->()))->*("+itableName+"->hasNext))();"); sw.allowBreak(2, " "); sw.end(); @@ -3833,7 +3831,7 @@ sw.write(";"); sw.newline(); sw.write(mangled_non_method_name(form.name().id().toString())); - sw.write(" = (((x10::lang::Reference*)("+name+".operator->()))->*("+itableName+"->next))();"); + sw.write(" = ((("+REFERENCE_TYPE+"*)("+name+".operator->()))->*("+itableName+"->next))();"); sw.newline(); for (Iterator li = n.locals().iterator(); li.hasNext(); ) { Stmt l = (Stmt) li.next(); @@ -4038,7 +4036,7 @@ // class header if (!freeTypeParams.isEmpty()) emitter.printTemplateSignature(freeTypeParams, inc); - inc.write("class "+cname+" : public x10::lang::Closure {"); + inc.write("class "+cname+" : public "+CLOSURE_TYPE+" {"); inc.newline(4); inc.begin(0); inc.write("public:") ; inc.newline(); inc.forceNewline(); @@ -4131,8 +4129,9 @@ // (an overridden member function will not be called from the itable, which is very non-intuitive). // As soon as XTENLANG-467 is fixed, take out the explicit qualifications and let C++ member lookup do its job... inc.write((in_template_closure ? "typename ": "")+superType+(in_template_closure ? "::template itable ": "::itable")+chevrons(cnamet)+ - cnamet+"::_itable(&"+cnamet+"::apply, &Reference::at, &Reference::at, &Reference::equals, &Closure::hashCode, &Reference::home, &" - +cnamet+"::toString, &Closure::typeName);"); + cnamet+"::_itable(&"+cnamet+"::apply, &"+REFERENCE_TYPE+"::at, &"+REFERENCE_TYPE+"::at, "+ + "&"+REFERENCE_TYPE+"::equals, &"+CLOSURE_TYPE+"::hashCode, &"+REFERENCE_TYPE+"::home, &" + +cnamet+"::toString, &"+CLOSURE_TYPE+"::typeName);"); if (in_template_closure) emitter.printTemplateSignature(freeTypeParams, inc); @@ -4470,7 +4469,7 @@ e.printStackTrace(); assert (false); } - invokeInterface(c, target, args, make_ref("x10::lang::Reference"), t.toClass(), ami, needsPlaceCheck, needsNullCheck); + invokeInterface(c, target, args, make_ref(REFERENCE_TYPE), t.toClass(), ami, needsPlaceCheck, needsNullCheck); return; } else { if (needsPlaceCheck) sw.write("x10aux::placeCheck("); @@ -4734,31 +4733,31 @@ return null; } - // FIXME: generic native methods will break - private void emitNativeAnnotation(String pat, List<Type> types, Receiver receiver, List<Expr> args, List<Type> typeArguments) { - Object[] components = new Object[1+3*types.size() + args.size() + 3*typeArguments.size()]; - assert (receiver != null); - components[0] = receiver; - if (receiver instanceof X10Special_c && ((X10Special_c)receiver).kind() == X10Special_c.SUPER) { - pat = pat.replaceAll("\\(#0\\)->", "#0::"); // FIXME: HACK - pat = pat.replaceAll("\\(#0\\)", "("+Emitter.translateType(receiver.type(), true)+"((#0*)this))"); // FIXME: An even bigger HACK (remove when @Native migrates to the body) - } + // FIXME: generic native methods will break + private void emitNativeAnnotation(String pat, List<Type> types, Receiver receiver, List<? extends Object> args, List<Type> typeArguments) { + Object[] components = new Object[1+3*types.size() + args.size() + 3*typeArguments.size()]; + assert (receiver != null); + components[0] = receiver; + if (receiver instanceof X10Special_c && ((X10Special_c)receiver).kind() == X10Special_c.SUPER) { + pat = pat.replaceAll("\\(#0\\)->", "#0::"); // FIXME: HACK + pat = pat.replaceAll("\\(#0\\)", "("+Emitter.translateType(receiver.type(), true)+"((#0*)this))"); // FIXME: An even bigger HACK (remove when @Native migrates to the body) + } - int i = 1; - for (Type at : types) { - components[i++] = at; - components[i++] = "/"+"*"+" UNUSED "+"*"+"/"; - components[i++] = "/"+"*"+" UNUSED "+"*"+"/"; - } - for (Expr e : args) { - components[i++] = e; - } - for (Type at : typeArguments) { - components[i++] = at; - components[i++] = "/"+"*"+" UNUSED "+"*"+"/"; - components[i++] = "/"+"*"+" UNUSED "+"*"+"/"; - } - emitter.dumpRegex("Native", components, tr, pat, sw); + int i = 1; + for (Type at : types) { + components[i++] = at; + components[i++] = "/"+"*"+" UNUSED "+"*"+"/"; + components[i++] = "/"+"*"+" UNUSED "+"*"+"/"; + } + for (Object e : args) { + components[i++] = e; + } + for (Type at : typeArguments) { + components[i++] = at; + components[i++] = "/"+"*"+" UNUSED "+"*"+"/"; + components[i++] = "/"+"*"+" UNUSED "+"*"+"/"; + } + emitter.dumpRegex("Native", components, tr, pat, sw); } public void visit(Tuple_c c) { Modified: trunk/x10.compiler/src/x10cpp/visit/SharedVarsMethods.java =================================================================== --- trunk/x10.compiler/src/x10cpp/visit/SharedVarsMethods.java 2010-03-04 02:51:14 UTC (rev 13168) +++ trunk/x10.compiler/src/x10cpp/visit/SharedVarsMethods.java 2010-03-04 03:15:25 UTC (rev 13169) @@ -93,6 +93,8 @@ public static final String DESERIALIZE_CUDA_METHOD = "_deserialize_cuda"; static final String STRUCT_EQUALS = "x10aux::struct_equals"; static final String STRUCT_EQUALS_METHOD = "_struct_equals"; + public static final String REFERENCE_TYPE = "x10::lang::Reference"; + public static final String CLOSURE_TYPE = "x10::lang::Closure"; static final String VIM_MODELINE = "vim:tabstop=4:shiftwidth=4:expandtab"; Modified: trunk/x10.runtime/src-x10/x10/lang/Any.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Any.x10 2010-03-04 02:51:14 UTC (rev 13168) +++ trunk/x10.runtime/src-x10/x10/lang/Any.x10 2010-03-04 03:15:25 UTC (rev 13169) @@ -43,12 +43,12 @@ /** * Return true if this entity is in the same home location as the given object. * - * @param p The given object - * @return true if the home location of this entity is the same as the home location of p. + * @param r The given object + * @return true if the home location of this entity is the same as the home location of r. */ @Native("java", "x10.core.Ref.at(#0, #1)") @Native("c++", "(x10aux::get_location(#0) == (#1)->location)") - property def at(p:Object):Boolean; + property def at(r:Object):Boolean; /** * Return true if the home location of this entity is the given place. @@ -115,7 +115,7 @@ * Note that the method is global and safe, so the implementations cannot * spawn activities at other places. So, either the equality comparison * has to be based on only global information, or the implementation has - * to ensure that the home location of the entities is 'here', and + * to ensure that the home location of this entity is 'here', and * possibly throw an exception if not. * * @return the hash code of this entity. Modified: trunk/x10.runtime/src-x10/x10/lang/Object.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Object.x10 2010-03-04 02:51:14 UTC (rev 13168) +++ trunk/x10.runtime/src-x10/x10/lang/Object.x10 2010-03-04 03:15:25 UTC (rev 13169) @@ -25,34 +25,90 @@ home: Place) implements Any { - -// @Native("java", "new x10.lang.Box<#2>(#3, #4)") -// @Native("c++", "new (x10aux::alloc<x10::lang::Box>()) x10::lang::Box<#2>(#3, #4)") -// @Native("c++", "x10::lang::Box<#1 >::_make(#4)") -// public static operator [T](x: T): Box[T] /* {T <: Value} */ = new Box[T](x); - + /** + * Default constructor. + */ public native def this(); + /** + * Return true if the given entity is an Object, and this object is equal + * to the given entity in an implementation-dependent way. + * The usual properties of symmetry, commutativity, and purity should + * apply, i.e., x.equals(x) should always be true; if x.equals(y) is true, + * then so should y.equals(x) be; and x.equals(y) should return the same + * value on subsequent invocations. + * + * Note that the method is global and safe, so the implementations cannot + * spawn activities at other places. So, either the equality comparison + * has to be based on only global information, or the implementation has + * to ensure that the home location of this object and the given entity is + * 'here', and possibly throw an exception if not. + * + * @param that the given entity + * @return true if this object is equal to the given entity. + */ @Native("java", "((Object)#0).equals(#1)") - @Native("c++", "x10aux::equals(#0,#1)") - public global safe native def equals(Any): boolean; + @Native("c++", "(#0)->equals(#1)") + public global safe native def equals(that:Any): boolean; + /** + * Return the implementation-defined hash code of this object. + * The implementation should be pure, i.e., x.hashCode() should return the + * same value on subsequent invocations, with an additional invariant that + * if x.equals(y) is true, then x.hashCode() should equal y.hashCode(). + * + * Note that the method is global and safe, so the implementations cannot + * spawn activities at other places. So, either the equality comparison + * has to be based on only global information, or the implementation has + * to ensure that the home location of this object is 'here', and + * possibly throw an exception if not. + * + * @return the hash code of this object. + */ @Native("java", "((Object)#0).hashCode()") - @Native("c++", "x10aux::hash_code(#0)") + @Native("c++", "(#0)->hashCode()") public global safe native def hashCode() : Int; + /** + * Return the string representation of this object. + * + * Note that the method is global and safe, so the implementations cannot + * spawn activities at other places. So, either the string representation + * has to include only global information, or the implementation has to + * ensure that the home location of the object is 'here', and possibly + * throw an exception if not. + * + * @return a string representation of this object. + */ @Native("java", "((Object)#0).toString()") - @Native("c++", "x10aux::to_string(#0)") + @Native("c++", "(#0)->toString()") public global safe native def toString() : String; + /** + * Return true if the home location of this object is the given place. + * + * @param p The given place + * @return true if the home location of this object is p. + */ @Native("java", "x10.core.Ref.at(#0, #1.id)") - @Native("c++", "((#0)->location == (#1)->FMGL(id))") + @Native("c++", "(#0)->at(#1)") public property safe def at(p:Place) = home==p; + /** + * Return true if this object is in the same home location as the given Object. + * + * @param r The given Object + * @return true if the home location of this object is the same as the home location of r. + */ @Native("java", "x10.core.Ref.at(#0, #1)") - @Native("c++", "((#0)->location == (#1)->location)") + @Native("c++", "(#0)->at(#1)") public property safe def at(r:Object) = home==r.home; + /** + * Return a string representation of the run-time type of this object. + * + * @return a string representation of the run-time type of this object. + */ @Native("java", "x10.core.Ref.typeName(#0)") @Native("c++", "x10aux::type_name(#0)") public global safe native final def typeName():String; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ma...@us...> - 2010-03-05 01:26:19
|
Revision: 13197 http://x10.svn.sourceforge.net/x10/?rev=13197&view=rev Author: makinoy Date: 2010-03-05 01:26:07 +0000 (Fri, 05 Mar 2010) Log Message: ----------- Add java specific scheduler for sparating java specific passes from common scheduler, and add a goal to box shared variable for locating shared variable in heap to the sheduler. But x10c command in the mainstream doesn't uses the scheduler yet. I'm going to change to use the scheduler after local test. Added Paths: ----------- trunk/x10.compiler/src/x10/visit/SharedBoxer.java trunk/x10.compiler/src/x10c/ trunk/x10.compiler/src/x10c/ExtensionInfo.java trunk/x10.runtime/src-x10/x10/compiler/Shared.x10 Added: trunk/x10.compiler/src/x10/visit/SharedBoxer.java =================================================================== --- trunk/x10.compiler/src/x10/visit/SharedBoxer.java (rev 0) +++ trunk/x10.compiler/src/x10/visit/SharedBoxer.java 2010-03-05 01:26:07 UTC (rev 13197) @@ -0,0 +1,151 @@ +/* + * 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.visit; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; + +import polyglot.ast.Call; +import polyglot.ast.Expr; +import polyglot.ast.Local; +import polyglot.ast.LocalDecl; +import polyglot.ast.Node; +import polyglot.ast.NodeFactory; +import polyglot.ast.Binary.Operator; +import polyglot.frontend.Job; +import polyglot.types.Flags; +import polyglot.types.Name; +import polyglot.types.QName; +import polyglot.types.SemanticException; +import polyglot.types.Type; +import polyglot.types.TypeSystem; +import polyglot.types.Types; +import polyglot.util.InternalCompilerError; +import polyglot.util.Position; +import polyglot.visit.ContextVisitor; +import polyglot.visit.NodeVisitor; +import x10.ast.X10Binary_c; +import x10.ast.X10Call_c; +import x10.ast.X10Conditional_c; +import x10.ast.X10If_c; +import x10.ast.X10LocalAssign_c; +import x10.ast.X10LocalDecl_c; +import x10.ast.X10Local_c; +import x10.ast.X10New_c; +import x10.ast.X10NodeFactory; +import x10.ast.X10Return_c; +import x10.types.X10ClassType; +import x10.types.X10Flags; +import x10.types.X10MethodInstance; +import x10.types.X10TypeSystem; +import x10.util.Synthesizer; + +public class SharedBoxer extends ContextVisitor { + private static final QName SHARED = QName.make("x10.compiler.Shared"); + + private final X10TypeSystem xts; + private final X10NodeFactory xnf; + + public SharedBoxer(Job job, TypeSystem ts, NodeFactory nf) { + super(job, ts, nf); + xts = (X10TypeSystem) ts; + xnf = (X10NodeFactory) nf; + } + + protected Node leaveCall(Node parent, Node old, Node n, NodeVisitor v) throws SemanticException { + + // shared var *** = +++ -> val Share[typeof***] *** = new Shared[typeof***](+++) + if (n instanceof X10LocalDecl_c) + return visitLocalDecl((X10LocalDecl_c) n); + + // *** = +++ -> ***.set(+++) + if (n instanceof X10LocalAssign_c) + return visitLocalAssign((X10LocalAssign_c) n); + + // *** not above case && (*** = ) -> ***.get() + if (!(parent instanceof X10LocalAssign_c) && n instanceof X10Local_c) { + X10Local_c local = (X10Local_c) n; + if(X10Flags.toX10Flags(local.flags()).isShared()) { + return createWrappingCall(local); + } + } + + return n; + } + + private Node visitLocalDecl(X10LocalDecl_c n) { + if (X10Flags.toX10Flags(n.flags().flags()).isShared()) { + Flags f = n.flags().flags(); + try { + Position position = n.position(); + Type type = xts.typeForName(SHARED); + X10ClassType type2 = ((X10ClassType) type).typeArguments(Collections.singletonList(n.type().type())); + Expr construct = xnf.New(position,xnf.CanonicalTypeNode(position, type2),Collections.singletonList(n.init())) + .constructorInstance(xts.findConstructor(type2, xts.ConstructorMatcher(n.type().type(), Collections.singletonList(n.type().type()), context))) + .type(type2); + // clear shared flag and set final flag + LocalDecl localDecl = xnf.LocalDecl(position,xnf.FlagsNode(position,X10Flags.toX10Flags(f).clearShared().Final()), xnf.CanonicalTypeNode(position, type2), n.name(), construct) + .localDef(xts.localDef(n.position(), n.flags().flags().Final(), Types.ref(type2), n.name().id())); + return localDecl; + } catch (SemanticException e) { + throw new InternalCompilerError("Something is terribly wrong", e); + } + } + return n; + } + + private Node visitLocalAssign(X10LocalAssign_c n) { + if (X10Flags.toX10Flags(n.local().flags()).isShared()) { + Local local = n.local(); + Position position = n.position(); + Operator bo = n.operator().binaryOperator(); + Expr right = n.right(); + + // if b is also shared, a += b -> a += b.get() + if (right instanceof X10Local_c) { + X10Local_c local2 = (X10Local_c) right; + if (X10Flags.toX10Flags(local2.flags()).isShared()) + right = createWrappingCall(local2); + } + + X10MethodInstance mi; + try { + Type type = xts.typeForName(SHARED); + List<Type> typeArguments = ((X10ClassType) type).typeArguments(); + mi = (X10MethodInstance) xts.findMethod(type, xts.MethodMatcher(right.type(), Name.make("set"), typeArguments, context)); + } catch (SemanticException e) { + throw new InternalCompilerError("Something is terribly wrong", e); + } + if (bo == null) { // i.e. = a = b -> a.set(b) + return (Call) xnf.Call(position, local, xnf.Id(position, "set"), right).methodInstance(mi).type(right.type()); + } else { // i.e. += *= ... a += b -> a.set(a.get() + b) + return (Call) xnf.Call(position, local, xnf.Id(position, "set"), xnf.Binary(position, createWrappingCall(local), bo, right)) + .methodInstance(mi).type(right.type()); + } + } + return n; + } + + private Call createWrappingCall(Local local) { + X10MethodInstance mi; + try { + Type type = xts.typeForName(SHARED); + mi = (X10MethodInstance) xts.findMethod(type, xts.MethodMatcher(local.type(), Name.make("get"), Collections.EMPTY_LIST, context)); + } catch (SemanticException e) { + throw new InternalCompilerError("Something is terribly wrong", e); + } + Call call = xnf.Call(local.position(), local, xnf.Id(local.position(), "get")); + call = (Call) call.methodInstance(mi).type(local.type()); + return call; + } +} Property changes on: trunk/x10.compiler/src/x10/visit/SharedBoxer.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Added: trunk/x10.compiler/src/x10c/ExtensionInfo.java =================================================================== --- trunk/x10.compiler/src/x10c/ExtensionInfo.java (rev 0) +++ trunk/x10.compiler/src/x10c/ExtensionInfo.java 2010-03-05 01:26:07 UTC (rev 13197) @@ -0,0 +1,57 @@ +/* + * 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 x10c; + +import java.util.ArrayList; +import java.util.List; + +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.frontend.VisitorGoal; +import polyglot.types.TypeSystem; +import x10.optimizations.Optimizer; +import x10.visit.SharedBoxer; +import x10.visit.TestNodeVisitor; +import x10.visit.TestVisitor; + +public class ExtensionInfo extends x10.ExtensionInfo { + @Override + protected Scheduler createScheduler() { + return new X10CScheduler(this); + } + + static class X10CScheduler extends X10Scheduler { + public X10CScheduler(ExtensionInfo extInfo) { + super(extInfo); + } + + @Override + public List<Goal> goals(Job job) { + List<Goal> goals = super.goals(job); + CodeGenerated(job).addPrereq(Desugarer(job)); + CodeGenerated(job).addPrereq(SharedBoxed(job)); + return goals; + } + + private Goal SharedBoxed(Job job) { + TypeSystem ts = extInfo.typeSystem(); + NodeFactory nf = extInfo.nodeFactory(); + return new VisitorGoal("sharedBoxer", job, new SharedBoxer(job, ts, nf)).intern(this); + } + } +} Property changes on: trunk/x10.compiler/src/x10c/ExtensionInfo.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Added: trunk/x10.runtime/src-x10/x10/compiler/Shared.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/compiler/Shared.x10 (rev 0) +++ trunk/x10.runtime/src-x10/x10/compiler/Shared.x10 2010-03-05 01:26:07 UTC (rev 13197) @@ -0,0 +1,19 @@ +/* + * 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.compiler; + +public class Shared[T] { + var x:T; + public def this(x:T){this.x=x;} + public def get():T = x; + public def set(x:T){this.x=x;} +} \ No newline at end of file Property changes on: trunk/x10.runtime/src-x10/x10/compiler/Shared.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. |
From: <ma...@us...> - 2010-03-05 04:56:06
|
Revision: 13205 http://x10.svn.sourceforge.net/x10/?rev=13205&view=rev Author: makinoy Date: 2010-03-05 04:55:58 +0000 (Fri, 05 Mar 2010) Log Message: ----------- Refactor code gen for cast node and conversion function. Fix XTENLANG-1117. 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-03-05 04:08:24 UTC (rev 13204) +++ trunk/x10.compiler/src/x10/visit/X10PrettyPrinterVisitor.java 2010-03-05 04:55:58 UTC (rev 13205) @@ -155,6 +155,8 @@ final public Translator tr; final public Emitter er; + private static final String X10_RTT_TYPES = "x10.rtt.Types"; + private static int nextId_; /* to provide a unique name for local variables introduce in the templates */ public static Integer getUniqueId_() { @@ -171,14 +173,14 @@ this.er = new Emitter(w,tr); } - public void visit(Block_c n) { - String s = er.getJavaImplForStmt(n, (X10TypeSystem) tr.typeSystem()); - if (s != null) { - w.write(s); - } else { + public void visit(Block_c n) { + String s = er.getJavaImplForStmt(n, (X10TypeSystem) tr.typeSystem()); + if (s != null) { + w.write(s); + } else { super.visit(n); - } - } + } + } public void visit(Node n) { // Don't call through del; that would be recursive. @@ -642,45 +644,35 @@ xct.setAnonObjectScope(); new Template(er, template, ex, expr, rt, new Join(er, " && ", conds)).expand(); xct.restoreAnonObjectScope(inAnonObjectScope); - } else if (((X10TypeSystem) type.typeSystem()).isAny(X10TypeMixin.baseType(type)) - && (t.isBoolean() || t.isNumeric())) { /* special path for "Any as Numeric" */ - /* XTENLANG-964: if expr==null, explicitly throw ClassCastException. otherwise, NullPointerException is thrown */ - er.dumpCodeString("((#0)==null) ? " + - "(new java.lang.Object(){ final #1 nullIsCasted(){throw new java.lang.ClassCastException();} }).nullIsCasted() : ", - expr, new TypeExpander(er, t, 0)); - if (t.isBoolean()) { - er.dumpCodeString("((Boolean) #0).booleanValue()", expr); - } else if (t.isInt()) { - er.dumpCodeString("((Number) #0).intValue()", expr); - } else if (t.isShort()) { - er.dumpCodeString("((Number) #0).shortValue()", expr); - } else if (t.isByte()) { - er.dumpCodeString("((Number) #0).byteValue()", expr); - } else if (t.isLong()) { - er.dumpCodeString("((Number) #0).longValue()", expr); - } else if (t.isFloat()) { - er.dumpCodeString("((Number) #0).floatValue()", expr); - } else if (t.isDouble()) { - er.dumpCodeString("((Number) #0).doubleValue()", expr); - } else if (t.isChar()) { - er.dumpCodeString("((Char) #0).charValue()", expr); - } - } else if (t.isBoolean() || t.isNumeric() || t.isChar() || type.isSubtype(t, tr.context())) { + } + else if ( + (X10TypeMixin.baseType(type) instanceof ParameterType || ((X10TypeSystem) type.typeSystem()).isAny(X10TypeMixin.baseType(type))) + && (t.isBoolean() || t.isNumeric() || t.isChar()) + ) { // e.g. any as Int (any:Any), t as Int (t:T) + w.write(X10_RTT_TYPES + ".as"); + new TypeExpander(er, t, 0).expand(tr); + w.write("("); + c.printSubExpr(expr, w, tr); + w.write(")"); + } + else if (t.isBoolean() || t.isNumeric() || t.isChar() || type.isSubtype(t, tr.context())) { w.begin(0); w.write("("); // put "(Type) expr" in parentheses. w.write("("); ex.expand(tr); w.write(")"); + // e.g. d as Int (d:Double) -> (int)(double)(Double)d if (type.isBoolean() || type.isNumeric() || type.isChar()) { w.write(" "); w.write("("); - new TypeExpander(er, type, BOX_PRIMITIVES).expand(tr); + new TypeExpander(er, type, 0).expand(tr); w.write(")"); w.write(" "); w.write("("); - new TypeExpander(er, type, 0).expand(tr); + new TypeExpander(er, type, BOX_PRIMITIVES).expand(tr); w.write(")"); // Fix XTENLANG-804 + // e.g. b as Int (b:Byte) -> (int)(byte)(Byte)(byte)b (in case b is int literal in jvava (e.g. 0)) if (type.isByte() || type.isShort()) { w.write("("); new TypeExpander(er, type, 0).expand(tr); @@ -692,23 +684,14 @@ // doesn't parse correctly, but // (java.lang.Integer) (-1) // does - if (X10TypeMixin.baseType(type) instanceof ParameterType && (t.isNumeric() || t.isChar())) { - TypeExpander te = new TypeExpander(er, t, BOX_PRIMITIVES); - w.write("x10.rtt.Types.conversion("); - te.expand(tr); - w.write(".class"); - w.write(","); - } if (expr instanceof Unary || expr instanceof Lit) w.write("("); c.printSubExpr(expr, w, tr); if (expr instanceof Unary || expr instanceof Lit) w.write(")"); - if (X10TypeMixin.baseType(type) instanceof ParameterType && (t.isNumeric() || t.isChar())) - w.write(")"); w.write(")"); w.end(); - } else if (t instanceof ParameterType) { + } else if (t instanceof ParameterType) { // e.g. i as T (T is parameterType) 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-03-05 04:08:24 UTC (rev 13204) +++ trunk/x10.runtime/src-java/x10/rtt/Types.java 2010-03-05 04:55:58 UTC (rev 13205) @@ -45,92 +45,108 @@ public static Type<Float> FLOAT = new FloatType(); public static Type<Double> DOUBLE = new DoubleType(); - 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; + private static boolean isStruct(Type<?> rtt) { + if ( + rtt == BOOLEAN + || rtt == BYTE || rtt == SHORT || rtt == CHAR || rtt == INT || rtt == LONG + || rtt == UBYTE || rtt == USHORT || rtt == UINT || rtt == ULONG + || rtt == FLOAT || rtt == DOUBLE + ) { + return true; + } + return false; } + + public static boolean asboolean(Object typeParamOrAny) { + if (typeParamOrAny == null) {nullIsCastedToStruct();} + if (typeParamOrAny instanceof java.lang.Boolean) {return (java.lang.Boolean) typeParamOrAny;} + throw new ClassCastException(); + } - public static Object conversion(Type rtt, Object primOrTypeParam) { - if (rtt == BOOLEAN) { - if (primOrTypeParam == null) {throw new ClassCastException();} - } + public static byte asbyte(Object typeParamOrAny){ + if (typeParamOrAny == null) {nullIsCastedToStruct();} + if (typeParamOrAny instanceof java.lang.Number) {return((java.lang.Number) typeParamOrAny).byteValue();} + throw new ClassCastException(); + } + + public static short asshort(Object typeParamOrAny){ + if (typeParamOrAny == null) {nullIsCastedToStruct();} + if (typeParamOrAny instanceof java.lang.Number) {return((java.lang.Number) typeParamOrAny).shortValue();} + throw new ClassCastException(); + } + + public static int asint(Object typeParamOrAny){ + if (typeParamOrAny == null) {nullIsCastedToStruct();} + if (typeParamOrAny instanceof java.lang.Number) {return((java.lang.Number) typeParamOrAny).intValue();} + throw new ClassCastException(); + } + + public static long aslong(Object typeParamOrAny){ + if (typeParamOrAny == null) {nullIsCastedToStruct();} + if (typeParamOrAny instanceof java.lang.Number) {return((java.lang.Number) typeParamOrAny).longValue();} + throw new ClassCastException(); + } + + public static float asfloat(Object typeParamOrAny){ + if (typeParamOrAny == null) {nullIsCastedToStruct();} + if (typeParamOrAny instanceof java.lang.Number) {return((java.lang.Number) typeParamOrAny).floatValue();} + throw new ClassCastException(); + } + + public static double asdouble(Object typeParamOrAny){ + if (typeParamOrAny == null) {nullIsCastedToStruct();} + if (typeParamOrAny instanceof java.lang.Number) {return((java.lang.Number) typeParamOrAny).doubleValue();} + throw new ClassCastException(); + } + + public static char aschar(Object typeParamOrAny) { + if (typeParamOrAny == null) {nullIsCastedToStruct();} + if (typeParamOrAny instanceof java.lang.Character) {return (java.lang.Character) typeParamOrAny;} + throw new ClassCastException(); + } + + + public static Object conversion(Type<?> rtt, Object primOrTypeParam) { + if (primOrTypeParam == null && isStruct(rtt)) {nullIsCastedToStruct();} + if (rtt == BYTE) { - if (primOrTypeParam == null) {throw new ClassCastException();} 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.Character) return (byte)((java.lang.Character) primOrTypeParam).charValue(); return primOrTypeParam; } if (rtt == SHORT) { - if (primOrTypeParam == null) {throw new ClassCastException();} 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(); return primOrTypeParam; } - if (rtt == CHAR) { - if (primOrTypeParam == null) {throw new ClassCastException();} - 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 == INT) { - if (primOrTypeParam == null) {throw new ClassCastException();} 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; return primOrTypeParam; } if (rtt == LONG) { - if (primOrTypeParam == null) {throw new ClassCastException();} 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.Long) return primOrTypeParam; return primOrTypeParam; } if (rtt == FLOAT) { - if (primOrTypeParam == null) {throw new ClassCastException();} 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.Float) return primOrTypeParam; return primOrTypeParam; } if (rtt == DOUBLE) { - if (primOrTypeParam == null) {throw new ClassCastException();} 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.Double) return primOrTypeParam; return primOrTypeParam; } // unimplemented - if (rtt == UBYTE) { - if (primOrTypeParam == null) {throw new ClassCastException();} - return primOrTypeParam; - } - if (rtt == USHORT) { - if (primOrTypeParam == null) {throw new ClassCastException();} - return primOrTypeParam; - } - if (rtt == UINT) { - if (primOrTypeParam == null) {throw new ClassCastException();} - return primOrTypeParam; - } - if (rtt == ULONG) { - if (primOrTypeParam == null) {throw new ClassCastException();} - return primOrTypeParam; - } + if (rtt == UBYTE) {return primOrTypeParam;} + if (rtt == USHORT) {return primOrTypeParam;} + if (rtt == UINT) {return primOrTypeParam;} + if (rtt == ULONG) {return primOrTypeParam;} return primOrTypeParam; } + + public static void nullIsCastedToStruct(){throw new java.lang.ClassCastException();} } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dgr...@us...> - 2010-03-07 21:55:01
|
Revision: 13238 http://x10.svn.sourceforge.net/x10/?rev=13238&view=rev Author: dgrove-oss Date: 2010-03-07 21:54:51 +0000 (Sun, 07 Mar 2010) Log Message: ----------- XTENLANG-1106 : StackOverflow (SegFault) due to infinite regress during initialization of cyclic RTT's. Rework RTT initialization protocol in the C++ backend to correctly handle cycles in the RTT graph (can be introduced by generic type where a type parameter is also a descendant). The code was already trying to handle this, but the check for recursive initialization came "too late." The fix is to break x10aux::RuntimeType::init into two methods initStageOne and initStageTwo. initStageOne is responsible for detecting cyclic initialization. It is called before _initRTT attempts to get any of the RTT objects for ancestor/parameter types. If initStageOne returns false (not recursive), then the other input RTT types for the initialization are acquired by calling x10aux::getRTT<TYPE> for them and they are passed as arguments to RuntimeType::initStageTwo which finishes the job of initializing the RuntimeType object. Modified Paths: -------------- trunk/x10.compiler/src/x10cpp/visit/Emitter.java trunk/x10.runtime/src-cpp/x10/lang/Any.cc trunk/x10.runtime/src-cpp/x10/lang/Fun.cc trunk/x10.runtime/src-cpp/x10/lang/Fun_0_0.h trunk/x10.runtime/src-cpp/x10/lang/Fun_0_1.h trunk/x10.runtime/src-cpp/x10/lang/Fun_0_2.h trunk/x10.runtime/src-cpp/x10/lang/Fun_0_3.h trunk/x10.runtime/src-cpp/x10/lang/Fun_0_4.h trunk/x10.runtime/src-cpp/x10/lang/Fun_0_5.h trunk/x10.runtime/src-cpp/x10/lang/Fun_0_6.h trunk/x10.runtime/src-cpp/x10/lang/Fun_0_7.h trunk/x10.runtime/src-cpp/x10/lang/Fun_0_8.h trunk/x10.runtime/src-cpp/x10/lang/Fun_0_9.h trunk/x10.runtime/src-cpp/x10/lang/Object.cc trunk/x10.runtime/src-cpp/x10/lang/PlaceLocalHandle_Impl.cc trunk/x10.runtime/src-cpp/x10/lang/PlaceLocalHandle_Impl.struct_h trunk/x10.runtime/src-cpp/x10/lang/Rail.cc trunk/x10.runtime/src-cpp/x10/lang/Rail.h trunk/x10.runtime/src-cpp/x10/lang/Reference.cc trunk/x10.runtime/src-cpp/x10/lang/Struct.cc trunk/x10.runtime/src-cpp/x10/lang/ValRail.cc trunk/x10.runtime/src-cpp/x10/lang/ValRail.h trunk/x10.runtime/src-cpp/x10/lang/VoidFun_0_1.h trunk/x10.runtime/src-cpp/x10/lang/VoidFun_0_2.h trunk/x10.runtime/src-cpp/x10/lang/VoidFun_0_3.h trunk/x10.runtime/src-cpp/x10/lang/VoidFun_0_4.h trunk/x10.runtime/src-cpp/x10/lang/VoidFun_0_5.h trunk/x10.runtime/src-cpp/x10/lang/VoidFun_0_6.h trunk/x10.runtime/src-cpp/x10/lang/VoidFun_0_7.h trunk/x10.runtime/src-cpp/x10/lang/VoidFun_0_8.h trunk/x10.runtime/src-cpp/x10/lang/VoidFun_0_9.h trunk/x10.runtime/src-cpp/x10/util/GrowableRail.cc trunk/x10.runtime/src-cpp/x10/util/GrowableRail.h trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicReference.cc trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicReference.h trunk/x10.runtime/src-cpp/x10aux/RTT.cc trunk/x10.runtime/src-cpp/x10aux/RTT.h Modified: trunk/x10.compiler/src/x10cpp/visit/Emitter.java =================================================================== --- trunk/x10.compiler/src/x10cpp/visit/Emitter.java 2010-03-07 21:27:04 UTC (rev 13237) +++ trunk/x10.compiler/src/x10cpp/visit/Emitter.java 2010-03-07 21:54:51 UTC (rev 13238) @@ -623,94 +623,96 @@ printTemplateSignature(((X10ClassType)cd.asType()).typeArguments(), h); } - void printRTTDefn(X10ClassType ct, CodeWriter h) { - X10TypeSystem_c xts = (X10TypeSystem_c) ct.typeSystem(); - String x10name = ct.fullName().toString(); - int numParents = 0; - if (ct.superClass() != null) { - numParents++; - } - numParents += ct.interfaces().size(); - - if (ct.typeArguments().isEmpty()) { - boolean first = true; - h.write("x10aux::RuntimeType "+translateType(ct)+"::rtt;"); h.newline(); - h.write("void "+translateType(ct)+"::_initRTT() {"); h.newline(4); h.begin(0); - if (numParents > 0) { - h.write("const x10aux::RuntimeType* parents["+numParents+"] = { "); - if (ct.superClass() != null) { - h.write("x10aux::getRTT" + chevrons(translateType(ct.superClass())) + "()"); - first = false; - } - for (Type iface : ct.interfaces()) { - if (!first) h.write(", "); - h.write("x10aux::getRTT"+chevrons(translateType(iface))+"()"); - first = false; - } - h.write("};"); h.newline(); - } else { - h.write("const x10aux::RuntimeType** parents = NULL; "); h.newline(); - } - h.write("rtt.init(&rtt, \""+ct.fullName()+"\", "+numParents+ ", parents, 0, NULL, NULL);"); - if (ct.isX10Struct() && isPointerless(ct)) { - h.newline(); h.write("rtt.containsPtrs = false;"); - } - h.end(); h.newline(); - h.write("}"); h.newline(); - } else { - boolean first = true; - int numTypeParams = ct.typeArguments().size(); - printTemplateSignature(ct.typeArguments(), h); - h.write("x10aux::RuntimeType "+translateType(ct)+"::rtt;"); h.newline(); + void printRTTDefn(X10ClassType ct, CodeWriter h) { + X10TypeSystem_c xts = (X10TypeSystem_c) ct.typeSystem(); + String x10name = ct.fullName().toString(); + int numParents = 0; + if (ct.superClass() != null) { + numParents++; + } + numParents += ct.interfaces().size(); - printTemplateSignature(ct.typeArguments(), h); - h.write("void "+translateType(ct)+"::_initRTT() {"); h.newline(4); h.begin(0); - if (numParents > 0) { - h.write("const x10aux::RuntimeType* parents["+numParents+"] = { "); - if (ct.superClass() != null) { - h.write("x10aux::getRTT" + chevrons(translateType(ct.superClass())) + "()"); - first = false; - } - for (Type iface : ct.interfaces()) { - if (!first) h.write(", "); - h.write("x10aux::getRTT"+chevrons(translateType(iface))+"()"); - first = false; - } - h.write("};"); h.newline(); - } else { - h.write("const x10aux::RuntimeType** parents = NULL; "); h.newline(); - } - h.write("const x10aux::RuntimeType* params["+numTypeParams+"] = { "); - first = true; - for (Type param : ct.typeArguments()) { - if (!first) h.write(", "); - h.write("x10aux::getRTT"+chevrons(translateType(param))+"()"); - first = false; - } - h.write("};"); h.newline(); - - h.write("x10aux::RuntimeType::Variance variances["+numTypeParams+"] = { "); - first = true; - for (ParameterType.Variance v : ct.x10Def().variances()) { - if (!first) h.write(", "); - switch(v) { - case COVARIANT: h.write("x10aux::RuntimeType::covariant"); break; - case CONTRAVARIANT: h.write("x10aux::RuntimeType::contravariant"); break; - case INVARIANT: h.write("x10aux::RuntimeType::invariant"); break; - default: assert false : "Unexpected Variance"; - } - first = false; - } - h.write("};"); h.newline(); - - h.write("const x10aux::RuntimeType *canonical = x10aux::getRTT"+chevrons(translateType(MessagePassingCodeGenerator.getStaticMemberContainer(ct),false))+"();"); - h.newline(); - - h.write("const char *baseName = \""+x10name+"\";"); h.newline(); - h.write("rtt.init(canonical, baseName, "+numParents+", parents, "+numTypeParams+", params, variances);"); h.end(); h.newline(); - h.write("}"); h.newline(); - } - h.newline(); + if (ct.typeArguments().isEmpty()) { + boolean first = true; + h.write("x10aux::RuntimeType "+translateType(ct)+"::rtt;"); h.newline(); + h.write("void "+translateType(ct)+"::_initRTT() {"); h.newline(4); h.begin(0); + h.write("if (rtt.initStageOne(&rtt)) return;"); h.newline(); + if (numParents > 0) { + h.write("const x10aux::RuntimeType* parents["+numParents+"] = { "); + if (ct.superClass() != null) { + h.write("x10aux::getRTT" + chevrons(translateType(ct.superClass())) + "()"); + first = false; + } + for (Type iface : ct.interfaces()) { + if (!first) h.write(", "); + h.write("x10aux::getRTT"+chevrons(translateType(iface))+"()"); + first = false; + } + h.write("};"); h.newline(); + } else { + h.write("const x10aux::RuntimeType** parents = NULL; "); h.newline(); + } + h.write("rtt.initStageTwo(\""+ct.fullName()+"\", "+numParents+ ", parents, 0, NULL, NULL);"); + if (ct.isX10Struct() && isPointerless(ct)) { + h.newline(); h.write("rtt.containsPtrs = false;"); + } + h.end(); h.newline(); + h.write("}"); h.newline(); + } else { + boolean first = true; + int numTypeParams = ct.typeArguments().size(); + printTemplateSignature(ct.typeArguments(), h); + h.write("x10aux::RuntimeType "+translateType(ct)+"::rtt;"); h.newline(); + + printTemplateSignature(ct.typeArguments(), h); + h.write("void "+translateType(ct)+"::_initRTT() {"); h.newline(4); h.begin(0); + h.write("const x10aux::RuntimeType *canonical = x10aux::getRTT"+chevrons(translateType(MessagePassingCodeGenerator.getStaticMemberContainer(ct),false))+"();"); + h.newline(); + h.write("if (rtt.initStageOne(canonical)) return;"); h.newline(); + + if (numParents > 0) { + h.write("const x10aux::RuntimeType* parents["+numParents+"] = { "); + if (ct.superClass() != null) { + h.write("x10aux::getRTT" + chevrons(translateType(ct.superClass())) + "()"); + first = false; + } + for (Type iface : ct.interfaces()) { + if (!first) h.write(", "); + h.write("x10aux::getRTT"+chevrons(translateType(iface))+"()"); + first = false; + } + h.write("};"); h.newline(); + } else { + h.write("const x10aux::RuntimeType** parents = NULL; "); h.newline(); + } + h.write("const x10aux::RuntimeType* params["+numTypeParams+"] = { "); + first = true; + for (Type param : ct.typeArguments()) { + if (!first) h.write(", "); + h.write("x10aux::getRTT"+chevrons(translateType(param))+"()"); + first = false; + } + h.write("};"); h.newline(); + + h.write("x10aux::RuntimeType::Variance variances["+numTypeParams+"] = { "); + first = true; + for (ParameterType.Variance v : ct.x10Def().variances()) { + if (!first) h.write(", "); + switch(v) { + case COVARIANT: h.write("x10aux::RuntimeType::covariant"); break; + case CONTRAVARIANT: h.write("x10aux::RuntimeType::contravariant"); break; + case INVARIANT: h.write("x10aux::RuntimeType::invariant"); break; + default: assert false : "Unexpected Variance"; + } + first = false; + } + h.write("};"); h.newline(); + + h.write("const char *baseName = \""+x10name+"\";"); h.newline(); + h.write("rtt.initStageTwo(baseName, "+numParents+", parents, "+numTypeParams+", params, variances);"); h.end(); h.newline(); + h.write("}"); h.newline(); + } + h.newline(); } // Helper method to recursively examine the fields of a struct and determine if they Modified: trunk/x10.runtime/src-cpp/x10/lang/Any.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Any.cc 2010-03-07 21:27:04 UTC (rev 13237) +++ trunk/x10.runtime/src-cpp/x10/lang/Any.cc 2010-03-07 21:54:51 UTC (rev 13238) @@ -17,7 +17,8 @@ x10aux::RuntimeType x10::lang::Any::rtt; void x10::lang::Any::_initRTT() { - rtt.init(&rtt, "x10.lang.Any", 0, NULL, 0, NULL, NULL); + if (rtt.initStageOne(&rtt)) return; + rtt.initStageTwo("x10.lang.Any", 0, NULL, 0, NULL, NULL); } // vim:tabstop=4:shiftwidth=4:expandtab Modified: trunk/x10.runtime/src-cpp/x10/lang/Fun.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Fun.cc 2010-03-07 21:27:04 UTC (rev 13237) +++ trunk/x10.runtime/src-cpp/x10/lang/Fun.cc 2010-03-07 21:54:51 UTC (rev 13238) @@ -64,23 +64,22 @@ void VoidFun_0_0::_initRTT() { - rtt.init(&rtt, "x10::lang::VoidFun_0_0", 0, NULL, 0, NULL, NULL); + if (rtt.initStageOne(&rtt)) return; + rtt.initStageTwo("x10::lang::VoidFun_0_0", 0, NULL, 0, NULL, NULL); } void _initRTTHelper_Fun_0_0(RuntimeType *location, const RuntimeType *rtt0) { const RuntimeType* params[1] = { rtt0 }; RuntimeType::Variance variances[1] = { RuntimeType::covariant }; - const RuntimeType* canonical = getRTT<Fun_0_0<void> >(); - location->init(canonical, "x10.lang.Fun_0_0", 0, NULL, 1, params, variances); + location->initStageTwo("x10.lang.Fun_0_0", 0, NULL, 1, params, variances); } void _initRTTHelper_Fun_0_1(RuntimeType *location, const RuntimeType *rtt0, const RuntimeType *rtt1) { const RuntimeType* params[2] = { rtt0, rtt1 }; RuntimeType::Variance variances[2] = { RuntimeType::contravariant, RuntimeType::covariant }; - const RuntimeType* canonical = getRTT<Fun_0_1<void, void> >(); - location->init(canonical, "x10.lang.Fun_0_1", 0, NULL, 2, params, variances); + location->initStageTwo("x10.lang.Fun_0_1", 0, NULL, 2, params, variances); } void @@ -90,8 +89,7 @@ const RuntimeType *rtt2) { const RuntimeType* params[3] = { rtt0, rtt1, rtt2 }; RuntimeType::Variance variances[] = { RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::covariant }; - const RuntimeType* canonical = getRTT<Fun_0_2<void, void, void> >(); - location->init(canonical, "x10.lang.Fun_0_2", 0, NULL, 3, params, variances); + location->initStageTwo("x10.lang.Fun_0_2", 0, NULL, 3, params, variances); } void @@ -102,8 +100,7 @@ const RuntimeType *rtt3) { const RuntimeType* params[4] = { rtt0, rtt1, rtt2, rtt3 }; RuntimeType::Variance variances[4] = { RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::covariant }; - const RuntimeType* canonical = getRTT<Fun_0_3<void, void, void, void> >(); - location->init(canonical, "x10.lang.Fun_0_3", 0, NULL, 4, params, variances); + location->initStageTwo("x10.lang.Fun_0_3", 0, NULL, 4, params, variances); } void @@ -115,8 +112,7 @@ const RuntimeType *rtt4) { const RuntimeType* params[5] = { rtt0, rtt1, rtt2, rtt3, rtt4 }; RuntimeType::Variance variances[5] = { RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::covariant }; - const RuntimeType* canonical = getRTT<Fun_0_4<void, void, void, void, void> >(); - location->init(canonical, "x10.lang.Fun_0_4", 0, NULL, 5, params, variances); + location->initStageTwo("x10.lang.Fun_0_4", 0, NULL, 5, params, variances); } void @@ -130,8 +126,7 @@ const RuntimeType* params[6] = { rtt0, rtt1, rtt2, rtt3, rtt4, rtt5 }; RuntimeType::Variance variances[6] = { RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::covariant }; - const RuntimeType* canonical = getRTT<Fun_0_5<void, void, void, void, void, void> >(); - location->init(canonical, "x10.lang.Fun_0_5", 0, NULL, 6, params, variances); + location->initStageTwo("x10.lang.Fun_0_5", 0, NULL, 6, params, variances); } void @@ -147,8 +142,7 @@ RuntimeType::Variance variances[7] = { RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::covariant }; - const RuntimeType* canonical = getRTT<Fun_0_6<void, void, void, void, void, void, void> >(); - location->init(canonical, "x10.lang.Fun_0_6", 0, NULL, 7, params, variances); + location->initStageTwo("x10.lang.Fun_0_6", 0, NULL, 7, params, variances); } void @@ -165,8 +159,7 @@ RuntimeType::Variance variances[8] = { RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::covariant }; - const RuntimeType* canonical = getRTT<Fun_0_7<void, void, void, void, void, void, void, void> >(); - location->init(canonical, "x10.lang.Fun_0_7", 0, NULL, 8, params, variances); + location->initStageTwo("x10.lang.Fun_0_7", 0, NULL, 8, params, variances); } void @@ -184,8 +177,7 @@ RuntimeType::Variance variances[9] = { RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::covariant }; - const RuntimeType* canonical = getRTT<Fun_0_8<void, void, void, void, void, void, void, void, void> >(); - location->init(canonical, "x10.lang.Fun_0_8", 0, NULL, 9, params, variances); + location->initStageTwo("x10.lang.Fun_0_8", 0, NULL, 9, params, variances); } void @@ -205,16 +197,14 @@ RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::covariant }; - const RuntimeType* canonical = getRTT<Fun_0_9<void, void, void, void, void, void, void, void, void, void> >(); - location->init(canonical, "x10.lang.Fun_0_9", 0, NULL, 10, params, variances); + location->initStageTwo("x10.lang.Fun_0_9", 0, NULL, 10, params, variances); } void _initRTTHelper_VoidFun_0_1(RuntimeType *location, const RuntimeType *rtt1) { const RuntimeType* params[1] = { rtt1 }; RuntimeType::Variance variances[] = { RuntimeType::contravariant }; - const RuntimeType* canonical = getRTT<VoidFun_0_1<void> >(); - location->init(canonical, "x10.lang.VoidFun_0_1", 0, NULL, 1, params, variances); + location->initStageTwo("x10.lang.VoidFun_0_1", 0, NULL, 1, params, variances); } void @@ -223,8 +213,7 @@ const RuntimeType *rtt2) { const RuntimeType* params[2] = { rtt1, rtt2 }; RuntimeType::Variance variances[2] = { RuntimeType::contravariant, RuntimeType::contravariant }; - const RuntimeType* canonical = getRTT<VoidFun_0_2<void, void> >(); - location->init(canonical, "x10.lang.VoidFun_0_2", 0, NULL, 2, params, variances); + location->initStageTwo("x10.lang.VoidFun_0_2", 0, NULL, 2, params, variances); } void @@ -234,8 +223,7 @@ const RuntimeType *rtt3) { const RuntimeType* params[3] = { rtt1, rtt2, rtt3 }; RuntimeType::Variance variances[3] = { RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant }; - const RuntimeType* canonical = getRTT<VoidFun_0_3<void, void, void> >(); - location->init(canonical, "x10.lang.VoidFun_0_3", 0, NULL, 3, params, variances); + location->initStageTwo("x10.lang.VoidFun_0_3", 0, NULL, 3, params, variances); } void @@ -246,8 +234,7 @@ const RuntimeType *rtt4) { const RuntimeType* params[4] = { rtt1, rtt2, rtt3, rtt4 }; RuntimeType::Variance variances[4] = { RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant }; - const RuntimeType* canonical = getRTT<VoidFun_0_4<void, void, void, void> >(); - location->init(canonical, "x10.lang.VoidFun_0_4", 0, NULL, 4, params, variances); + location->initStageTwo("x10.lang.VoidFun_0_4", 0, NULL, 4, params, variances); } void @@ -259,8 +246,7 @@ const RuntimeType *rtt5) { const RuntimeType* params[5] = { rtt1, rtt2, rtt3, rtt4, rtt5 }; RuntimeType::Variance variances[5] = { RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant }; - const RuntimeType* canonical = getRTT<VoidFun_0_5<void, void, void, void, void> >(); - location->init(canonical, "x10.lang.VoidFun_0_5", 0, NULL, 5, params, variances); + location->initStageTwo("x10.lang.VoidFun_0_5", 0, NULL, 5, params, variances); } void @@ -274,8 +260,7 @@ const RuntimeType* params[6] = { rtt1, rtt2, rtt3, rtt4, rtt5, rtt6 }; RuntimeType::Variance variances[6] = { RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant }; - const RuntimeType* canonical = getRTT<VoidFun_0_6<void, void, void, void, void, void> >(); - location->init(canonical, "x10.lang.VoidFun_0_6", 0, NULL, 6, params, variances); + location->initStageTwo("x10.lang.VoidFun_0_6", 0, NULL, 6, params, variances); } void @@ -290,8 +275,7 @@ const RuntimeType* params[7] = { rtt1, rtt2, rtt3, rtt4, rtt5, rtt6, rtt7 }; RuntimeType::Variance variances[7] = { RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant }; - const RuntimeType* canonical = getRTT<VoidFun_0_7<void, void, void, void, void, void, void> >(); - location->init(canonical, "x10.lang.VoidFun_0_7", 0, NULL, 7, params, variances); + location->initStageTwo("x10.lang.VoidFun_0_7", 0, NULL, 7, params, variances); } void @@ -307,8 +291,7 @@ const RuntimeType* params[8] = { rtt1, rtt2, rtt3, rtt4, rtt5, rtt6, rtt7, rtt8 }; RuntimeType::Variance variances[8] = { RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant }; - const RuntimeType* canonical = getRTT<VoidFun_0_8<void, void, void, void, void, void, void, void> >(); - location->init(canonical, "x10.lang.VoidFun_0_8", 0, NULL, 8, params, variances); + location->initStageTwo("x10.lang.VoidFun_0_8", 0, NULL, 8, params, variances); } void @@ -325,8 +308,7 @@ const RuntimeType* params[9] = { rtt1, rtt2, rtt3, rtt4, rtt5, rtt6, rtt7, rtt8, rtt9 }; RuntimeType::Variance variances[9] = { RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant }; - const RuntimeType* canonical = getRTT<VoidFun_0_9<void, void, void, void, void, void, void, void, void> >(); - location->init(canonical, "x10.lang.VoidFun_0_9", 0, NULL, 9, params, variances); + location->initStageTwo("x10.lang.VoidFun_0_9", 0, NULL, 9, params, variances); } } } Modified: trunk/x10.runtime/src-cpp/x10/lang/Fun_0_0.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Fun_0_0.h 2010-03-07 21:27:04 UTC (rev 13237) +++ trunk/x10.runtime/src-cpp/x10/lang/Fun_0_0.h 2010-03-07 21:54:51 UTC (rev 13238) @@ -49,6 +49,7 @@ }; template<class R> void Fun_0_0<R>::_initRTT() { + if (rtt.initStageOne(x10aux::getRTT<Fun_0_0<void> >())) return; x10::lang::_initRTTHelper_Fun_0_0(&rtt, x10aux::getRTT<R>()); } Modified: trunk/x10.runtime/src-cpp/x10/lang/Fun_0_1.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Fun_0_1.h 2010-03-07 21:27:04 UTC (rev 13237) +++ trunk/x10.runtime/src-cpp/x10/lang/Fun_0_1.h 2010-03-07 21:54:51 UTC (rev 13238) @@ -51,6 +51,7 @@ }; template<class P1, class R> void Fun_0_1<P1,R>::_initRTT() { + if (rtt.initStageOne(x10aux::getRTT<Fun_0_1<void,void> >())) return; x10::lang::_initRTTHelper_Fun_0_1(&rtt, x10aux::getRTT<P1>(), x10aux::getRTT<R>()); } Modified: trunk/x10.runtime/src-cpp/x10/lang/Fun_0_2.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Fun_0_2.h 2010-03-07 21:27:04 UTC (rev 13237) +++ trunk/x10.runtime/src-cpp/x10/lang/Fun_0_2.h 2010-03-07 21:54:51 UTC (rev 13238) @@ -52,6 +52,7 @@ }; template<class P1, class P2, class R> void Fun_0_2<P1,P2,R>::_initRTT() { + if (rtt.initStageOne(x10aux::getRTT<Fun_0_2<void,void,void> >())) return; x10::lang::_initRTTHelper_Fun_0_2(&rtt, x10aux::getRTT<P1>(), x10aux::getRTT<P2>(), x10aux::getRTT<R>()); } Modified: trunk/x10.runtime/src-cpp/x10/lang/Fun_0_3.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Fun_0_3.h 2010-03-07 21:27:04 UTC (rev 13237) +++ trunk/x10.runtime/src-cpp/x10/lang/Fun_0_3.h 2010-03-07 21:54:51 UTC (rev 13238) @@ -53,6 +53,7 @@ }; template<class P1, class P2, class P3, class R> void Fun_0_3<P1,P2,P3,R>::_initRTT() { + if (rtt.initStageOne(x10aux::getRTT<Fun_0_3<void,void,void,void> >())) return; x10::lang::_initRTTHelper_Fun_0_3(&rtt, x10aux::getRTT<P1>(), x10aux::getRTT<P2>(), x10aux::getRTT<P3>(), x10aux::getRTT<R>()); } Modified: trunk/x10.runtime/src-cpp/x10/lang/Fun_0_4.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Fun_0_4.h 2010-03-07 21:27:04 UTC (rev 13237) +++ trunk/x10.runtime/src-cpp/x10/lang/Fun_0_4.h 2010-03-07 21:54:51 UTC (rev 13238) @@ -55,6 +55,7 @@ template<class P1, class P2, class P3, class P4, class R> void Fun_0_4<P1,P2,P3,P4,R>::_initRTT() { + if (rtt.initStageOne(x10aux::getRTT<Fun_0_4<void,void,void,void,void> >())) return; x10::lang::_initRTTHelper_Fun_0_4(&rtt, x10aux::getRTT<P1>(), x10aux::getRTT<P2>(), x10aux::getRTT<P3>(), x10aux::getRTT<P4>(), x10aux::getRTT<R>()); Modified: trunk/x10.runtime/src-cpp/x10/lang/Fun_0_5.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Fun_0_5.h 2010-03-07 21:27:04 UTC (rev 13237) +++ trunk/x10.runtime/src-cpp/x10/lang/Fun_0_5.h 2010-03-07 21:54:51 UTC (rev 13238) @@ -56,6 +56,7 @@ template<class P1, class P2, class P3, class P4, class P5, class R> void Fun_0_5<P1,P2,P3,P4,P5,R>::_initRTT() { + if (rtt.initStageOne(x10aux::getRTT<Fun_0_5<void,void,void,void,void,void> >())) return; x10::lang::_initRTTHelper_Fun_0_5(&rtt, x10aux::getRTT<P1>(), x10aux::getRTT<P2>(), x10aux::getRTT<P3>(), x10aux::getRTT<P4>(), x10aux::getRTT<P5>(), x10aux::getRTT<R>()); Modified: trunk/x10.runtime/src-cpp/x10/lang/Fun_0_6.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Fun_0_6.h 2010-03-07 21:27:04 UTC (rev 13237) +++ trunk/x10.runtime/src-cpp/x10/lang/Fun_0_6.h 2010-03-07 21:54:51 UTC (rev 13238) @@ -57,6 +57,7 @@ template<class P1, class P2, class P3, class P4, class P5, class P6, class R> void Fun_0_6<P1,P2,P3,P4,P5,P6,R>::_initRTT() { + if (rtt.initStageOne(x10aux::getRTT<Fun_0_6<void,void,void,void,void,void,void> >())) return; x10::lang::_initRTTHelper_Fun_0_6(&rtt, x10aux::getRTT<P1>(), x10aux::getRTT<P2>(), x10aux::getRTT<P3>(), x10aux::getRTT<P4>(), x10aux::getRTT<P5>(), x10aux::getRTT<P6>(), Modified: trunk/x10.runtime/src-cpp/x10/lang/Fun_0_7.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Fun_0_7.h 2010-03-07 21:27:04 UTC (rev 13237) +++ trunk/x10.runtime/src-cpp/x10/lang/Fun_0_7.h 2010-03-07 21:54:51 UTC (rev 13238) @@ -57,6 +57,7 @@ template<class P1, class P2, class P3, class P4, class P5, class P6, class P7, class R> void Fun_0_7<P1,P2,P3,P4,P5,P6,P7,R>::_initRTT() { + if (rtt.initStageOne(x10aux::getRTT<Fun_0_7<void,void,void,void,void,void,void,void> >())) return; x10::lang::_initRTTHelper_Fun_0_7(&rtt, x10aux::getRTT<P1>(), x10aux::getRTT<P2>(), x10aux::getRTT<P3>(), x10aux::getRTT<P4>(), x10aux::getRTT<P5>(), x10aux::getRTT<P6>(), Modified: trunk/x10.runtime/src-cpp/x10/lang/Fun_0_8.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Fun_0_8.h 2010-03-07 21:27:04 UTC (rev 13237) +++ trunk/x10.runtime/src-cpp/x10/lang/Fun_0_8.h 2010-03-07 21:54:51 UTC (rev 13238) @@ -58,6 +58,7 @@ template<class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class R> void Fun_0_8<P1,P2,P3,P4,P5,P6,P7,P8,R>::_initRTT() { + if (rtt.initStageOne(x10aux::getRTT<Fun_0_8<void,void,void,void,void,void,void,void,void> >())) return; x10::lang::_initRTTHelper_Fun_0_8(&rtt, x10aux::getRTT<P1>(), x10aux::getRTT<P2>(), x10aux::getRTT<P3>(), x10aux::getRTT<P4>(), x10aux::getRTT<P5>(), x10aux::getRTT<P6>(), @@ -65,7 +66,7 @@ x10aux::getRTT<R>()); } - template<class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class R> + template<class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class R> x10aux::RuntimeType Fun_0_8<P1,P2,P3,P4,P5,P6,P7,P8,R>::rtt; template<> class Fun_0_8<void, void, void, void, void, void, void, void, void> { Modified: trunk/x10.runtime/src-cpp/x10/lang/Fun_0_9.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Fun_0_9.h 2010-03-07 21:27:04 UTC (rev 13237) +++ trunk/x10.runtime/src-cpp/x10/lang/Fun_0_9.h 2010-03-07 21:54:51 UTC (rev 13238) @@ -59,6 +59,7 @@ template<class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9, class R> void Fun_0_9<P1,P2,P3,P4,P5,P6,P7,P8,P9,R>::_initRTT() { + if (rtt.initStageOne(x10aux::getRTT<Fun_0_9<void,void,void,void,void,void,void,void,void,void> >())) return; x10::lang::_initRTTHelper_Fun_0_9(&rtt, x10aux::getRTT<P1>(), x10aux::getRTT<P2>(), x10aux::getRTT<P3>(), x10aux::getRTT<P4>(), x10aux::getRTT<P5>(), x10aux::getRTT<P6>(), Modified: trunk/x10.runtime/src-cpp/x10/lang/Object.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Object.cc 2010-03-07 21:27:04 UTC (rev 13237) +++ trunk/x10.runtime/src-cpp/x10/lang/Object.cc 2010-03-07 21:54:51 UTC (rev 13238) @@ -106,7 +106,8 @@ x10aux::RuntimeType x10::lang::Object::rtt; void x10::lang::Object::_initRTT() { - rtt.init(&rtt, "x10.lang.Object", 0, NULL, 0, NULL, NULL); + if (rtt.initStageOne(&rtt)) return; + rtt.initStageTwo("x10.lang.Object", 0, NULL, 0, NULL, NULL); } itable_entry Object::_itables[1] = { itable_entry(NULL, (void*)x10aux::getRTT<Object>()) }; Modified: trunk/x10.runtime/src-cpp/x10/lang/PlaceLocalHandle_Impl.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/PlaceLocalHandle_Impl.cc 2010-03-07 21:27:04 UTC (rev 13237) +++ trunk/x10.runtime/src-cpp/x10/lang/PlaceLocalHandle_Impl.cc 2010-03-07 21:54:51 UTC (rev 13238) @@ -27,8 +27,7 @@ _initRTTHelper_PlaceLocalHandle_Impl(RuntimeType *location, const RuntimeType *rtt) { const RuntimeType* params[1] = { rtt }; RuntimeType::Variance variances[1] = { RuntimeType::invariant }; - const RuntimeType *canonical = x10aux::getRTT<PlaceLocalHandle_Impl<void> >(); - location->init(canonical, "x10.lang.PlaceLocalHandle_Impl", 0, NULL, 1, params, variances); + location->initStageTwo("x10.lang.PlaceLocalHandle_Impl", 0, NULL, 1, params, variances); } } } Modified: trunk/x10.runtime/src-cpp/x10/lang/PlaceLocalHandle_Impl.struct_h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/PlaceLocalHandle_Impl.struct_h 2010-03-07 21:27:04 UTC (rev 13237) +++ trunk/x10.runtime/src-cpp/x10/lang/PlaceLocalHandle_Impl.struct_h 2010-03-07 21:54:51 UTC (rev 13238) @@ -78,6 +78,7 @@ }; template<class T> void PlaceLocalHandle_Impl<T>::_initRTT() { + if (rtt.initStageOne(x10aux::getRTT<PlaceLocalHandle_Impl<void> >())) return; x10::lang::_initRTTHelper_PlaceLocalHandle_Impl(&rtt, x10aux::getRTT<T>()); } Modified: trunk/x10.runtime/src-cpp/x10/lang/Rail.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Rail.cc 2010-03-07 21:27:04 UTC (rev 13237) +++ trunk/x10.runtime/src-cpp/x10/lang/Rail.cc 2010-03-07 21:54:51 UTC (rev 13238) @@ -31,8 +31,7 @@ const RuntimeType *parents[3] = { Object::getRTT(), p1, p2 }; const RuntimeType *params[1] = { element }; RuntimeType::Variance variances[1] = { RuntimeType::invariant }; - const RuntimeType *canonical = x10aux::getRTT<Rail<void> >(); - location->init(canonical, "x10.lang.Rail", 3, parents, 1, params, variances); + location->initStageTwo("x10.lang.Rail", 3, parents, 1, params, variances); } } } Modified: trunk/x10.runtime/src-cpp/x10/lang/Rail.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Rail.h 2010-03-07 21:27:04 UTC (rev 13237) +++ trunk/x10.runtime/src-cpp/x10/lang/Rail.h 2010-03-07 21:54:51 UTC (rev 13238) @@ -220,6 +220,7 @@ namespace lang { template<class T> void Rail<T>::_initRTT() { + if (rtt.initStageOne(x10aux::getRTT<Rail<void> >())) return; x10::lang::_initRTTHelper_Rail(&rtt, x10aux::getRTT<T>(), x10aux::getRTT<Settable<x10_int,T> >(), x10aux::getRTT<Iterable<T> >()); Modified: trunk/x10.runtime/src-cpp/x10/lang/Reference.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Reference.cc 2010-03-07 21:27:04 UTC (rev 13237) +++ trunk/x10.runtime/src-cpp/x10/lang/Reference.cc 2010-03-07 21:54:51 UTC (rev 13238) @@ -54,7 +54,8 @@ x10aux::RuntimeType x10::lang::NullType::rtt; void x10::lang::NullType::_initRTT() { - rtt.init(&rtt, "Null", 0, NULL, 0, NULL, NULL); + if (rtt.initStageOne(&rtt)) return; + rtt.initStageTwo("Null", 0, NULL, 0, NULL, NULL); } // vim:tabstop=4:shiftwidth=4:expandtab Modified: trunk/x10.runtime/src-cpp/x10/lang/Struct.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Struct.cc 2010-03-07 21:27:04 UTC (rev 13237) +++ trunk/x10.runtime/src-cpp/x10/lang/Struct.cc 2010-03-07 21:54:51 UTC (rev 13238) @@ -37,7 +37,8 @@ RuntimeType Struct::rtt; void Struct::_initRTT() { - rtt.init(&rtt, "x10.lang.Struct", 0, NULL, 0, NULL, NULL); + if (rtt.initStageOne(&rtt)) return; + rtt.initStageTwo("x10.lang.Struct", 0, NULL, 0, NULL, NULL); } // vim:tabstop=4:shiftwidth=4:expandtab:textwidth=100 Modified: trunk/x10.runtime/src-cpp/x10/lang/ValRail.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/ValRail.cc 2010-03-07 21:27:04 UTC (rev 13237) +++ trunk/x10.runtime/src-cpp/x10/lang/ValRail.cc 2010-03-07 21:54:51 UTC (rev 13238) @@ -29,8 +29,7 @@ const RuntimeType *parents[3] = { Object::getRTT(), p1, p2 }; const RuntimeType *params[1] = { element }; RuntimeType::Variance variances[1] = { RuntimeType::covariant }; - const RuntimeType *canonical = x10aux::getRTT<ValRail<void> >(); - location->init(canonical, "x10.lang.ValRail", 3, parents, 1, params, variances); + location->initStageTwo("x10.lang.ValRail", 3, parents, 1, params, variances); } } } Modified: trunk/x10.runtime/src-cpp/x10/lang/ValRail.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/ValRail.h 2010-03-07 21:27:04 UTC (rev 13237) +++ trunk/x10.runtime/src-cpp/x10/lang/ValRail.h 2010-03-07 21:54:51 UTC (rev 13238) @@ -126,6 +126,7 @@ ::addDeserializer(ValRail<T>::template _deserializer<Object>); template<class T> void ValRail<T>::_initRTT() { + if (rtt.initStageOne(x10aux::getRTT<ValRail<void> >())) return; x10::lang::_initRTTHelper_ValRail(&rtt, x10aux::getRTT<T>(), x10aux::getRTT<Fun_0_1<x10_int,T> >(), x10aux::getRTT<Iterable<T> >()); Modified: trunk/x10.runtime/src-cpp/x10/lang/VoidFun_0_1.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/VoidFun_0_1.h 2010-03-07 21:27:04 UTC (rev 13237) +++ trunk/x10.runtime/src-cpp/x10/lang/VoidFun_0_1.h 2010-03-07 21:54:51 UTC (rev 13238) @@ -50,6 +50,7 @@ }; template<class P1> void VoidFun_0_1<P1>::_initRTT() { + if (rtt.initStageOne(x10aux::getRTT<VoidFun_0_1<void> >())) return; x10::lang::_initRTTHelper_VoidFun_0_1(&rtt, x10aux::getRTT<P1>()); } Modified: trunk/x10.runtime/src-cpp/x10/lang/VoidFun_0_2.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/VoidFun_0_2.h 2010-03-07 21:27:04 UTC (rev 13237) +++ trunk/x10.runtime/src-cpp/x10/lang/VoidFun_0_2.h 2010-03-07 21:54:51 UTC (rev 13238) @@ -51,6 +51,7 @@ }; template<class P1, class P2> void VoidFun_0_2<P1,P2>::_initRTT() { + if (rtt.initStageOne(x10aux::getRTT<VoidFun_0_2<void,void> >())) return; x10::lang::_initRTTHelper_VoidFun_0_2(&rtt, x10aux::getRTT<P1>(), x10aux::getRTT<P2>()); } Modified: trunk/x10.runtime/src-cpp/x10/lang/VoidFun_0_3.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/VoidFun_0_3.h 2010-03-07 21:27:04 UTC (rev 13237) +++ trunk/x10.runtime/src-cpp/x10/lang/VoidFun_0_3.h 2010-03-07 21:54:51 UTC (rev 13238) @@ -52,6 +52,7 @@ }; template<class P1, class P2, class P3> void VoidFun_0_3<P1,P2,P3>::_initRTT() { + if (rtt.initStageOne(x10aux::getRTT<VoidFun_0_3<void,void,void> >())) return; x10::lang::_initRTTHelper_VoidFun_0_3(&rtt, x10aux::getRTT<P1>(), x10aux::getRTT<P2>(), x10aux::getRTT<P3>()); } Modified: trunk/x10.runtime/src-cpp/x10/lang/VoidFun_0_4.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/VoidFun_0_4.h 2010-03-07 21:27:04 UTC (rev 13237) +++ trunk/x10.runtime/src-cpp/x10/lang/VoidFun_0_4.h 2010-03-07 21:54:51 UTC (rev 13238) @@ -54,6 +54,7 @@ template<class P1, class P2, class P3, class P4> void VoidFun_0_4<P1,P2,P3,P4>::_initRTT() { + if (rtt.initStageOne(x10aux::getRTT<VoidFun_0_4<void,void,void,void> >())) return; x10::lang::_initRTTHelper_VoidFun_0_4(&rtt, x10aux::getRTT<P1>(), x10aux::getRTT<P2>(), x10aux::getRTT<P3>(), x10aux::getRTT<P4>()); } Modified: trunk/x10.runtime/src-cpp/x10/lang/VoidFun_0_5.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/VoidFun_0_5.h 2010-03-07 21:27:04 UTC (rev 13237) +++ trunk/x10.runtime/src-cpp/x10/lang/VoidFun_0_5.h 2010-03-07 21:54:51 UTC (rev 13238) @@ -55,6 +55,7 @@ template<class P1, class P2, class P3, class P4, class P5> void VoidFun_0_5<P1,P2,P3,P4,P5>::_initRTT() { + if (rtt.initStageOne(x10aux::getRTT<VoidFun_0_5<void,void,void,void,void> >())) return; x10::lang::_initRTTHelper_VoidFun_0_5(&rtt, x10aux::getRTT<P1>(), x10aux::getRTT<P2>(), x10aux::getRTT<P3>(), x10aux::getRTT<P4>(), x10aux::getRTT<P5>()); Modified: trunk/x10.runtime/src-cpp/x10/lang/VoidFun_0_6.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/VoidFun_0_6.h 2010-03-07 21:27:04 UTC (rev 13237) +++ trunk/x10.runtime/src-cpp/x10/lang/VoidFun_0_6.h 2010-03-07 21:54:51 UTC (rev 13238) @@ -56,6 +56,7 @@ template<class P1, class P2, class P3, class P4, class P5, class P6> void VoidFun_0_6<P1,P2,P3,P4,P5,P6>::_initRTT() { + if (rtt.initStageOne(x10aux::getRTT<VoidFun_0_6<void,void,void,void,void,void> >())) return; x10::lang::_initRTTHelper_VoidFun_0_6(&rtt, x10aux::getRTT<P1>(), x10aux::getRTT<P2>(), x10aux::getRTT<P3>(), x10aux::getRTT<P4>(), x10aux::getRTT<P5>(), x10aux::getRTT<P6>()); Modified: trunk/x10.runtime/src-cpp/x10/lang/VoidFun_0_7.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/VoidFun_0_7.h 2010-03-07 21:27:04 UTC (rev 13237) +++ trunk/x10.runtime/src-cpp/x10/lang/VoidFun_0_7.h 2010-03-07 21:54:51 UTC (rev 13238) @@ -57,6 +57,7 @@ template<class P1, class P2, class P3, class P4, class P5, class P6, class P7> void VoidFun_0_7<P1,P2,P3,P4,P5,P6,P7>::_initRTT() { + if (rtt.initStageOne(x10aux::getRTT<VoidFun_0_7<void,void,void,void,void,void,void> >())) return; x10::lang::_initRTTHelper_VoidFun_0_7(&rtt, x10aux::getRTT<P1>(), x10aux::getRTT<P2>(), x10aux::getRTT<P3>(), x10aux::getRTT<P4>(), x10aux::getRTT<P5>(), x10aux::getRTT<P6>(), Modified: trunk/x10.runtime/src-cpp/x10/lang/VoidFun_0_8.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/VoidFun_0_8.h 2010-03-07 21:27:04 UTC (rev 13237) +++ trunk/x10.runtime/src-cpp/x10/lang/VoidFun_0_8.h 2010-03-07 21:54:51 UTC (rev 13238) @@ -58,6 +58,7 @@ template<class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8> void VoidFun_0_8<P1,P2,P3,P4,P5,P6,P7,P8>::_initRTT() { + if (rtt.initStageOne(x10aux::getRTT<VoidFun_0_8<void,void,void,void,void,void,void,void> >())) return; x10::lang::_initRTTHelper_VoidFun_0_8(&rtt, x10aux::getRTT<P1>(), x10aux::getRTT<P2>(), x10aux::getRTT<P3>(), x10aux::getRTT<P4>(), x10aux::getRTT<P5>(), x10aux::getRTT<P6>(), Modified: trunk/x10.runtime/src-cpp/x10/lang/VoidFun_0_9.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/VoidFun_0_9.h 2010-03-07 21:27:04 UTC (rev 13237) +++ trunk/x10.runtime/src-cpp/x10/lang/VoidFun_0_9.h 2010-03-07 21:54:51 UTC (rev 13238) @@ -59,6 +59,7 @@ template<class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9> void VoidFun_0_9<P1,P2,P3,P4,P5,P6,P7,P8,P9>::_initRTT() { + if (rtt.initStageOne(x10aux::getRTT<VoidFun_0_9<void,void,void,void,void,void,void,void,void> >())) return; x10::lang::_initRTTHelper_VoidFun_0_9(&rtt, x10aux::getRTT<P1>(), x10aux::getRTT<P2>(), x10aux::getRTT<P3>(), x10aux::getRTT<P4>(), x10aux::getRTT<P5>(), x10aux::getRTT<P6>(), Modified: trunk/x10.runtime/src-cpp/x10/util/GrowableRail.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/util/GrowableRail.cc 2010-03-07 21:27:04 UTC (rev 13237) +++ trunk/x10.runtime/src-cpp/x10/util/GrowableRail.cc 2010-03-07 21:54:51 UTC (rev 13238) @@ -29,8 +29,7 @@ const RuntimeType* parents[1] = { Object::getRTT() }; const RuntimeType* params[1] = { element }; RuntimeType::Variance variances[1] = { RuntimeType::invariant }; - const RuntimeType *canonical = x10aux::getRTT<GrowableRail<void> >(); - location->init(canonical, "x10.lang.GrowableRail", 1, parents, 1, params, variances); + location->initStageTwo("x10.lang.GrowableRail", 1, parents, 1, params, variances); } } } Modified: trunk/x10.runtime/src-cpp/x10/util/GrowableRail.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/util/GrowableRail.h 2010-03-07 21:27:04 UTC (rev 13237) +++ trunk/x10.runtime/src-cpp/x10/util/GrowableRail.h 2010-03-07 21:54:51 UTC (rev 13238) @@ -187,6 +187,7 @@ template<class T> x10_int GrowableRail<T>::size() { return _array->FMGL(length); } template<class T> void GrowableRail<T>::_initRTT() { + if (rtt.initStageOne(x10aux::getRTT<GrowableRail<void> >())) return; x10::util::_initRTTHelper_GrowableRail(&rtt, x10aux::getRTT<T>()); } Modified: trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicReference.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicReference.cc 2010-03-07 21:27:04 UTC (rev 13237) +++ trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicReference.cc 2010-03-07 21:54:51 UTC (rev 13238) @@ -25,8 +25,7 @@ const RuntimeType* parents[1] = { Object::getRTT() }; const RuntimeType* params[1] = { rtt }; RuntimeType::Variance variances[1] = { RuntimeType::invariant }; - const RuntimeType *canonical = x10aux::getRTT<AtomicReference<void> >(); - location->init(canonical, "x10.util.concurrent.atomic.AtomicReference", 1, parents, 1, params, variances); + location->initStageTwo("x10.util.concurrent.atomic.AtomicReference", 1, parents, 1, params, variances); } } } Modified: trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicReference.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicReference.h 2010-03-07 21:27:04 UTC (rev 13237) +++ trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicReference.h 2010-03-07 21:54:51 UTC (rev 13238) @@ -134,6 +134,7 @@ } template<class T> void AtomicReference<T>::_initRTT() { + if (rtt.initStageOne(x10aux::getRTT<AtomicReference<void> >())) return; x10::util::concurrent::atomic::_initRTTHelper_AtomicReference(&rtt, x10aux::getRTT<T>()); } Modified: trunk/x10.runtime/src-cpp/x10aux/RTT.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/RTT.cc 2010-03-07 21:27:04 UTC (rev 13237) +++ trunk/x10.runtime/src-cpp/x10aux/RTT.cc 2010-03-07 21:54:51 UTC (rev 13238) @@ -97,10 +97,10 @@ return other->_type()->equals(this); } -void RuntimeType::init(const RuntimeType *canonical_, const char* baseName_, - int parentsc_, const RuntimeType** parents_, - int paramsc_, const RuntimeType** params_, - Variance* variances_) { + + +bool RuntimeType::initStageOne(const RuntimeType *canonical_) { + // Ensure that at most one thread is doing any RTT initialization at a time. // This is overkill, since many RTT's have nothing to do with each other and // RTT initialization is idempotent. However, we want to make sure that if @@ -117,16 +117,31 @@ if (canonical != NULL) { if (isInitialized) { const_cast<x10::lang::Lock__ReentrantLock *>(initRTTLock)->unlock(); - return; // another thread finished the job while this thread was blocked on initRTTLock. + return true; // another thread finished the job while this thread was blocked on initRTTLock. } // We should only get here if there is a cyclic intialization in progress. // We don't have a 100% foolproof way to be sure that is what is happening, so // just hope that is what is happening and return. const_cast<x10::lang::Lock__ReentrantLock *>(initRTTLock)->unlock(); - return; + return true; } canonical = canonical_; + + // NOTE: Intentionally did not call unlock before returning. + // the unlock will happen at the end of initStageTwo + // Return false to indicate that the thread should continue with initStageTwo. + return false; +} + + +void RuntimeType::initStageTwo(const char* baseName_, + int parentsc_, const RuntimeType** parents_, + int paramsc_, const RuntimeType** params_, + Variance* variances_) { + // NOTE: Lock still held because it was not released before returning + // false from the end of initStageOne + baseName = baseName_; parentsc = parentsc_; paramsc = paramsc_; @@ -154,55 +169,69 @@ x10aux::atomic_ops::store_load_barrier(); isInitialized = true; // must come after the store_load_barrier + + // Unlock paired with lock operation at entry to initStageOne. const_cast<x10::lang::Lock__ReentrantLock *>(initRTTLock)->unlock(); } void RuntimeType::initBooleanType() { - BooleanType.init(&BooleanType, "x10.lang.Boolean", 0, NULL, 0, NULL, NULL); + if (BooleanType.initStageOne(&BooleanType)) return; + BooleanType.initStageTwo("x10.lang.Boolean", 0, NULL, 0, NULL, NULL); BooleanType.containsPtrs = false; } void RuntimeType::initByteType() { - ByteType.init(&ByteType, "x10.lang.Byte", 0, NULL, 0, NULL, NULL); + if (ByteType.initStageOne(&ByteType)) return; + ByteType.initStageTwo("x10.lang.Byte", 0, NULL, 0, NULL, NULL); ByteType.containsPtrs = false; } void RuntimeType::initCharType() { - CharType.init(&CharType, "x10.lang.Char", 0, NULL, 0, NULL, NULL); + if (CharType.initStageOne(&CharType)) return; + CharType.initStageTwo("x10.lang.Char", 0, NULL, 0, NULL, NULL); CharType.containsPtrs = false; } void RuntimeType::initShortType() { - ShortType.init(&ShortType, "x10.lang.Short", 0, NULL, 0, NULL, NULL); + if (ShortType.initStageOne(&ShortType)) return; + ShortType.initStageTwo("x10.lang.Short", 0, NULL, 0, NULL, NULL); ShortType.containsPtrs = false; } void RuntimeType::initIntType() { - IntType.init(&IntType, "x10.lang.Int", 0, NULL, 0, NULL, NULL); + if (IntType.initStageOne(&IntType)) return; + IntType.initStageTwo("x10.lang.Int", 0, NULL, 0, NULL, NULL); IntType.containsPtrs = false; } void RuntimeType::initFloatType() { - FloatType.init(&FloatType, "x10.lang.Float", 0, NULL, 0, NULL, NULL); + if (FloatType.initStageOne(&FloatType)) return; + FloatType.initStageTwo("x10.lang.Float", 0, NULL, 0, NULL, NULL); FloatType.containsPtrs = false; } void RuntimeType::initLongType() { - LongType.init(&LongType, "x10.lang.Long", 0, NULL, 0, NULL, NULL); + if (LongType.initStageOne(&LongType)) return; + LongType.initStageTwo("x10.lang.Long", 0, NULL, 0, NULL, NULL); LongType.containsPtrs = false; } void RuntimeType::initDoubleType() { - DoubleType.init(&DoubleType, "x10.lang.Double", 0, NULL, 0, NULL, NULL); + if (DoubleType.initStageOne(&DoubleType)) return; + DoubleType.initStageTwo("x10.lang.Double", 0, NULL, 0, NULL, NULL); DoubleType.containsPtrs = false; } void RuntimeType::initUByteType() { - UByteType.init(&UByteType, "x10.lang.UByte", 0, NULL, 0, NULL, NULL); + if (UByteType.initStageOne(&UByteType)) return; + UByteType.initStageTwo("x10.lang.UByte", 0, NULL, 0, NULL, NULL); UByteType.containsPtrs = false; } void RuntimeType::initUShortType() { - UShortType.init(&UShortType, "x10.lang.UShort", 0, NULL, 0, NULL, NULL); + if (UShortType.initStageOne(&UShortType)) return; + UShortType.initStageTwo("x10.lang.UShort", 0, NULL, 0, NULL, NULL); UShortType.containsPtrs = false; } void RuntimeType::initUIntType() { - UIntType.init(&UIntType, "x10.lang.UInt", 0, NULL, 0, NULL, NULL); + if (UIntType.initStageOne(&UIntType)) return; + UIntType.initStageTwo("x10.lang.UInt", 0, NULL, 0, NULL, NULL); UIntType.containsPtrs = false; } void RuntimeType::initULongType() { - ULongType.init(&ULongType, "x10.lang.ULong", 0, NULL, 0, NULL, NULL); + if (ULongType.initStageOne(&ULongType)) return; + ULongType.initStageTwo("x10.lang.ULong", 0, NULL, 0, NULL, NULL); ULongType.containsPtrs = false; } Modified: trunk/x10.runtime/src-cpp/x10aux/RTT.h =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/RTT.h 2010-03-07 21:27:04 UTC (rev 13237) +++ trunk/x10.runtime/src-cpp/x10aux/RTT.h 2010-03-07 21:54:51 UTC (rev 13238) @@ -36,8 +36,9 @@ #define RTT_CC_DECLS1(TYPE,NAME,P1) \ x10aux::RuntimeType TYPE::rtt; \ void TYPE::_initRTT() { \ + if (rtt.initStageOne(&rtt)) return; \ const x10aux::RuntimeType* parents[1] = {P1::getRTT()}; \ - rtt.init(&rtt, NAME, 1, parents, 0, NULL, NULL); \ + rtt.initStageTwo(NAME, 1, parents, 0, NULL, NULL); \ } namespace x10 { @@ -85,10 +86,25 @@ Variance *variances; const char* fullTypeName; const char* baseName; + + // Initialization protocol. + // (a) Call initStageOne before attempting to acquire the RTT + // if any of the types parents or parameters. + // (b) if initStageOne returns true, then the type is either + // (a) being recursively initialized by the same thread + // (b) has already been initialied by another thread + // In either case, return from initRTT because by the time + // we unwind all the way back to the "user" code, the recursive + // RTT cycle will have been fully initialized. + // (c) call getRTT on any input RTTs + // (d) call initStageTwo + - void init(const RuntimeType* canonical_, const char* baseName_, - int parsentsc_, const RuntimeType** parents_, - int paramsc_, const RuntimeType** params_, Variance* variances_); + bool initStageOne(const RuntimeType* canonical_); + + void initStageTwo(const char* baseName_, + int parsentsc_, const RuntimeType** parents_, + int paramsc_, const RuntimeType** params_, Variance* variances_); const char *name() const; @@ -212,15 +228,6 @@ return t->name(); } }; -/* - template<class T> struct TypeName<ref<T> > { static const char *_() { - const RuntimeType *t = getRTT<T>(); - if (t == NULL) return "Uninitialized RTT"; - static const char *with_star = alloc_printf("%s*",t->name()); - return with_star; - } }; -*/ - template<class T> const char *typeName() { return TypeName<T>::_(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <spa...@us...> - 2010-03-08 14:39:31
|
Revision: 13260 http://x10.svn.sourceforge.net/x10/?rev=13260&view=rev Author: sparksparkspark Date: 2010-03-08 14:39:20 +0000 (Mon, 08 Mar 2010) Log Message: ----------- Migrate to new x10rt C API Also add doxyfile and doxygen comments (also some small changes to CUDA mixed in with the x10rt changes, and appropriate matching change in the compiler) Modified Paths: -------------- trunk/x10.compiler/src/x10cuda/types/X10CUDAContext_c.java trunk/x10.runtime/src-cpp/x10/lang/Rail.h trunk/x10.runtime/src-cpp/x10aux/network.cc trunk/x10.runtime/src-cpp/x10aux/static_init.cc trunk/x10.runtime/x10rt/common/x10rt_cuda.cc trunk/x10.runtime/x10rt/common/x10rt_front.cc trunk/x10.runtime/x10rt/common/x10rt_logical.cc trunk/x10.runtime/x10rt/include/x10rt_cuda.h trunk/x10.runtime/x10rt/include/x10rt_front.h trunk/x10.runtime/x10rt/include/x10rt_logical.h trunk/x10.runtime/x10rt/include/x10rt_net.h trunk/x10.runtime/x10rt/include/x10rt_types.h trunk/x10.runtime/x10rt/jni/jni_x10rt.cc trunk/x10.runtime/x10rt/mpi/x10rt_mpi.cc trunk/x10.runtime/x10rt/standalone/x10rt_standalone.cc trunk/x10.runtime/x10rt/test/x10rt_basic.cc trunk/x10.runtime/x10rt/test/x10rt_gups.cc trunk/x10.runtime/x10rt/test/x10rt_topology.cc Added Paths: ----------- trunk/x10.runtime/x10rt/Doxyfile Modified: trunk/x10.compiler/src/x10cuda/types/X10CUDAContext_c.java =================================================================== --- trunk/x10.compiler/src/x10cuda/types/X10CUDAContext_c.java 2010-03-08 14:22:31 UTC (rev 13259) +++ trunk/x10.compiler/src/x10cuda/types/X10CUDAContext_c.java 2010-03-08 14:39:20 UTC (rev 13260) @@ -86,6 +86,7 @@ cudaStream.write("#include <cfloat>"); cudaStream.newline(); cudaStream.forceNewline(); cudaStream.write("extern __shared__ char __shm[];"); cudaStream.newline(); + cudaStream.write("extern __constant__ char __cmem[64*1024];"); cudaStream.newline(); cudaStream.forceNewline(); } return cudaStream; Modified: trunk/x10.runtime/src-cpp/x10/lang/Rail.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Rail.h 2010-03-08 14:22:31 UTC (rev 13259) +++ trunk/x10.runtime/src-cpp/x10/lang/Rail.h 2010-03-08 14:39:20 UTC (rev 13260) @@ -502,13 +502,11 @@ { typedef x10::util::Pair<R,x10_int> P; R this_ = this; - x10aux::place dst_place = dst_place_.FMGL(id); - // check beginning and end of range x10aux::checkRailBounds(src_off, FMGL(length)); x10aux::checkRailBounds(src_off+len-1, FMGL(length)); x10aux::ref<Reference> df = dst_finder; - assert(dst_place != x10aux::here); // handle in X10 code wrapper + assert(dst_place_.FMGL(id) != x10aux::here); // handle in X10 code wrapper Rail_serializeAndSendPut(dst_place_, df, 1, _copy_to_serialization_id, &_data[src_off], len * sizeof(T)); } // }}} @@ -691,13 +689,11 @@ { typedef x10::util::Pair<R,x10_int> P; R this_ = this; - x10aux::place src_place = src_place_.FMGL(id); - assert(src_place != x10aux::here); + assert(src_place_.FMGL(id) != x10aux::here); // check beginning and end of range x10aux::checkRailBounds(dst_off, FMGL(length)); x10aux::checkRailBounds(dst_off+len-1, FMGL(length)); x10aux::ref<Reference> df = dst_finder; - assert(src_place!=x10aux::here); Rail_serializeAndSendGet(src_place_, df, 1, _copy_from_serialization_id, &_data[dst_off], len * sizeof(T)); } // }}} Modified: trunk/x10.runtime/src-cpp/x10aux/network.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/network.cc 2010-03-08 14:22:31 UTC (rev 13259) +++ trunk/x10.runtime/src-cpp/x10aux/network.cc 2010-03-08 14:39:20 UTC (rev 13260) @@ -97,23 +97,23 @@ }; void x10aux::blocks_threads (place p, msg_type t, int shm, int &bs, int &ts, const int *cfgs) -{ x10rt_blocks_threads(p,t,shm,bs,ts,cfgs); } +{ x10rt_blocks_threads(p,t,shm,&bs,&ts,cfgs); } -void *kernel_put_finder (const x10rt_msg_params &p, x10rt_copy_sz) +void *kernel_put_finder (const x10rt_msg_params *p, x10rt_copy_sz) { - x10aux::deserialization_buffer buf(static_cast<char*>(p.msg)); + x10aux::deserialization_buffer buf(static_cast<char*>(p->msg)); buf.read<x10_ulong>(); x10_ulong remote_addr = buf.read<x10_ulong>(); - assert(buf.consumed() <= p.len); + assert(buf.consumed() <= p->len); _X_(ANSI_X10RT<<"CUDA kernel populating: "<<remote_addr<<ANSI_RESET); return (void*)(size_t)remote_addr; } -void kernel_put_notifier (const x10rt_msg_params &p, x10rt_copy_sz) +void kernel_put_notifier (const x10rt_msg_params *p, x10rt_copy_sz) { - x10aux::deserialization_buffer buf(static_cast<char*>(p.msg)); + x10aux::deserialization_buffer buf(static_cast<char*>(p->msg)); bool *finished = (bool*)(size_t)buf.read<x10_ulong>(); *finished = true; } @@ -129,7 +129,7 @@ } void x10aux::network_init (int ac, char **av) { - x10rt_init(ac, av); + x10rt_init(&ac, &av); x10aux::here = x10rt_here(); x10aux::num_places = x10rt_nplaces(); x10aux::num_hosts = x10rt_nhosts(); @@ -188,7 +188,7 @@ _X_(ANSI_BOLD<<ANSI_X10RT<<"async size: "<<ANSI_RESET<<sz); x10rt_msg_params params = {p, id, buf.steal(), sz}; - x10rt_send_msg(params); + x10rt_send_msg(¶ms); } else { @@ -232,7 +232,7 @@ _X_(ANSI_BOLD<<ANSI_X10RT<<"async size: "<<ANSI_RESET<<sz); x10rt_msg_params params = {p, real_id, buf.steal(), sz}; - x10rt_send_msg(params); + x10rt_send_msg(¶ms); } } @@ -245,7 +245,7 @@ x10rt_msg_params p = { place, id, buf.steal(), buf_length }; _X_(ANSI_BOLD<<ANSI_X10RT<<"Transmitting a get: "<<ANSI_RESET <<data<<" sid "<<id_<<" id "<<id<<" size "<<len<<" header "<<buf_length<<" to place: "<<place); - x10rt_send_get(p, data, len); + x10rt_send_get(&p, data, len); } void x10aux::send_put (x10aux::place place, x10aux::serialization_id_t id_, @@ -256,7 +256,7 @@ x10rt_msg_params p = { place, id, buf.steal(), buf_length }; _X_(ANSI_BOLD<<ANSI_X10RT<<"Transmitting a put: "<<ANSI_RESET <<data<<" sid "<<id_<<" id "<<id<<" size "<<len<<" header "<<buf_length<<" to place: "<<place); - x10rt_send_put(p, data, len); + x10rt_send_put(&p, data, len); } x10_int x10aux::num_threads() { @@ -271,13 +271,13 @@ x10_boolean x10aux::static_threads() { return (getenv("X10_STATIC_THREADS") != NULL); } -static void receive_async (const x10rt_msg_params &p) { +static void receive_async (const x10rt_msg_params *p) { _X_(ANSI_X10RT<<"Receiving an async, deserialising..."<<ANSI_RESET); - x10aux::deserialization_buffer buf(static_cast<char*>(p.msg)); + x10aux::deserialization_buffer buf(static_cast<char*>(p->msg)); // note: high bytes thrown away in implicit conversion - serialization_id_t sid = x10aux::DeserializationDispatcher::getSerializationId(p.type); + serialization_id_t sid = x10aux::DeserializationDispatcher::getSerializationId(p->type); ref<Reference> async(x10aux::DeserializationDispatcher::create<VoidFun_0_0>(buf, sid)); - assert(buf.consumed() <= p.len); + assert(buf.consumed() <= p->len); _X_("The deserialised async was: "<<x10aux::safe_to_string(async)); deserialized_bytes += buf.consumed() ; asyncs_received++; if (async.isNull()) return; @@ -285,24 +285,26 @@ x10aux::dealloc(async.operator->()); } -static void *cuda_pre (const x10rt_msg_params &p, size_t &blocks, size_t &threads, size_t &shm) +static void cuda_pre (const x10rt_msg_params *p, size_t *blocks, size_t *threads, size_t *shm, + size_t *argc, const char **argv, size_t *cmemc, const char **cmemv) { _X_(ANSI_X10RT<<"Receiving a kernel pre callback, deserialising..."<<ANSI_RESET); - x10aux::deserialization_buffer buf(static_cast<char*>(p.msg)); + x10aux::deserialization_buffer buf(static_cast<char*>(p->msg)); buf.read<x10aux::ref<x10::lang::Reference> >(); // note: high bytes thrown away in implicit conversion - serialization_id_t sid = x10aux::DeserializationDispatcher::getSerializationId(p.type); + serialization_id_t sid = x10aux::DeserializationDispatcher::getSerializationId(p->type); x10aux::CUDAPre pre = x10aux::DeserializationDispatcher::getCUDAPre(sid); - x10_ulong env = pre(buf, p.dest_place, blocks, threads, shm); - assert(buf.consumed() <= p.len); - return (void*)(size_t)env; + x10_ulong env = pre(buf, p->dest_place, *blocks, *threads, *shm); + assert(buf.consumed() <= p->len); + *argv = (char*)(size_t)env; + *argc = sizeof(void*); } -static void cuda_post (const x10rt_msg_params &p, void *env) +static void cuda_post (const x10rt_msg_params *p, void *env) { _X_(ANSI_X10RT<<"Receiving a kernel post callback, deserialising..."<<ANSI_RESET); - remote_free(p.dest_place, (x10_ulong)(size_t)env); - x10aux::deserialization_buffer buf(static_cast<char*>(p.msg)); + remote_free(p->dest_place, (x10_ulong)(size_t)env); + x10aux::deserialization_buffer buf(static_cast<char*>(p->msg)); x10aux::ref<x10::lang::Reference> fs = buf.read<x10aux::ref<x10::lang::Reference> >(); x10aux::ref<x10::lang::Runtime> rt = x10::lang::PlaceLocalHandle_methods<x10aux::ref<x10::lang::Runtime> >::apply(x10::lang::Runtime::FMGL(runtime)); (fs.operator->()->*(x10aux::findITable<x10::lang::Runtime__FinishState>(fs->_getITables())->notifyActivityCreation))(); @@ -318,47 +320,47 @@ } } -static void *receive_put (const x10rt_msg_params &p, x10aux::copy_sz len) { +static void *receive_put (const x10rt_msg_params *p, x10aux::copy_sz len) { _X_(ANSI_X10RT<<"Receiving a put, deserialising for buffer finder..."<<ANSI_RESET); - x10aux::deserialization_buffer buf(static_cast<char*>(p.msg)); + x10aux::deserialization_buffer buf(static_cast<char*>(p->msg)); // note: high bytes thrown away in implicit conversion - serialization_id_t sid = x10aux::DeserializationDispatcher::getSerializationId(p.type); + serialization_id_t sid = x10aux::DeserializationDispatcher::getSerializationId(p->type); x10aux::BufferFinder bf = x10aux::DeserializationDispatcher::getPutBufferFinder(sid); void *dropzone = bf(buf,len); - assert(buf.consumed() <= p.len); + assert(buf.consumed() <= p->len); return dropzone; } -static void *cuda_receive_put (const x10rt_msg_params &p, x10aux::copy_sz len) { +static void *cuda_receive_put (const x10rt_msg_params *p, x10aux::copy_sz len) { _X_(ANSI_X10RT<<"Receiving a put, deserialising for cuda buffer finder..."<<ANSI_RESET); - x10aux::deserialization_buffer buf(static_cast<char*>(p.msg)); + x10aux::deserialization_buffer buf(static_cast<char*>(p->msg)); // note: high bytes thrown away in implicit conversion - serialization_id_t sid = x10aux::DeserializationDispatcher::getSerializationId(p.type); + serialization_id_t sid = x10aux::DeserializationDispatcher::getSerializationId(p->type); x10aux::BufferFinder bf = x10aux::DeserializationDispatcher::getCUDAPutBufferFinder(sid); void *dropzone = bf(buf,len); - assert(buf.consumed() <= p.len); + assert(buf.consumed() <= p->len); return dropzone; } -static void finished_put (const x10rt_msg_params &p, x10aux::copy_sz len) { +static void finished_put (const x10rt_msg_params *p, x10aux::copy_sz len) { _X_(ANSI_X10RT<<"Receiving a put, deserialising for notifier..."<<ANSI_RESET); - x10aux::deserialization_buffer buf(static_cast<char*>(p.msg)); + x10aux::deserialization_buffer buf(static_cast<char*>(p->msg)); // note: high bytes thrown away in implicit conversion - serialization_id_t sid = x10aux::DeserializationDispatcher::getSerializationId(p.type); + serialization_id_t sid = x10aux::DeserializationDispatcher::getSerializationId(p->type); x10aux::Notifier n = x10aux::DeserializationDispatcher::getPutNotifier(sid); n(buf,len); - assert(buf.consumed() <= p.len); + assert(buf.consumed() <= p->len); deserialized_bytes += buf.consumed() ; asyncs_received++; } -static void cuda_finished_put (const x10rt_msg_params &p, x10aux::copy_sz len) { +static void cuda_finished_put (const x10rt_msg_params *p, x10aux::copy_sz len) { _X_(ANSI_X10RT<<"Receiving a put, deserialising for cuda notifier..."<<ANSI_RESET); - x10aux::deserialization_buffer buf(static_cast<char*>(p.msg)); + x10aux::deserialization_buffer buf(static_cast<char*>(p->msg)); // note: high bytes thrown away in implicit conversion - serialization_id_t sid = x10aux::DeserializationDispatcher::getSerializationId(p.type); + serialization_id_t sid = x10aux::DeserializationDispatcher::getSerializationId(p->type); x10aux::Notifier n = x10aux::DeserializationDispatcher::getCUDAPutNotifier(sid); n(buf,len); - assert(buf.consumed() <= p.len); + assert(buf.consumed() <= p->len); deserialized_bytes += buf.consumed() ; asyncs_received++; } @@ -367,49 +369,49 @@ cuda_receive_put, cuda_finished_put); } -static void *receive_get (const x10rt_msg_params &p, x10aux::copy_sz len) { +static void *receive_get (const x10rt_msg_params *p, x10aux::copy_sz len) { _X_(ANSI_X10RT<<"Receiving a get, deserialising for buffer finder..."<<ANSI_RESET); - x10aux::deserialization_buffer buf(static_cast<char*>(p.msg)); + x10aux::deserialization_buffer buf(static_cast<char*>(p->msg)); // note: high bytes thrown away in implicit conversion - serialization_id_t sid = x10aux::DeserializationDispatcher::getSerializationId(p.type); + serialization_id_t sid = x10aux::DeserializationDispatcher::getSerializationId(p->type); x10aux::BufferFinder bf = x10aux::DeserializationDispatcher::getGetBufferFinder(sid); void *dropzone = bf(buf,len); - assert(buf.consumed() <= p.len); + assert(buf.consumed() <= p->len); deserialized_bytes += buf.consumed() ; asyncs_received++; return dropzone; } -static void *cuda_receive_get (const x10rt_msg_params &p, x10aux::copy_sz len) { +static void *cuda_receive_get (const x10rt_msg_params *p, x10aux::copy_sz len) { _X_(ANSI_X10RT<<"Receiving a get, deserialising for cuda buffer finder..."<<ANSI_RESET); - x10aux::deserialization_buffer buf(static_cast<char*>(p.msg)); + x10aux::deserialization_buffer buf(static_cast<char*>(p->msg)); // note: high bytes thrown away in implicit conversion - serialization_id_t sid = x10aux::DeserializationDispatcher::getSerializationId(p.type); + serialization_id_t sid = x10aux::DeserializationDispatcher::getSerializationId(p->type); x10aux::BufferFinder bf = x10aux::DeserializationDispatcher::getCUDAGetBufferFinder(sid); void *dropzone = bf(buf,len); - assert(buf.consumed() <= p.len); + assert(buf.consumed() <= p->len); deserialized_bytes += buf.consumed() ; asyncs_received++; return dropzone; } -static void finished_get (const x10rt_msg_params &p, x10aux::copy_sz len) { +static void finished_get (const x10rt_msg_params *p, x10aux::copy_sz len) { _X_(ANSI_X10RT<<"Receiving a get, deserialising for notifier..."<<ANSI_RESET); - x10aux::deserialization_buffer buf(static_cast<char*>(p.msg)); + x10aux::deserialization_buffer buf(static_cast<char*>(p->msg)); // note: high bytes thrown away in implicit conversion - serialization_id_t sid = x10aux::DeserializationDispatcher::getSerializationId(p.type); + serialization_id_t sid = x10aux::DeserializationDispatcher::getSerializationId(p->type); x10aux::Notifier n = x10aux::DeserializationDispatcher::getGetNotifier(sid); n(buf,len); - assert(buf.consumed() <= p.len); + assert(buf.consumed() <= p->len); deserialized_bytes += buf.consumed() ; asyncs_received++; } -static void cuda_finished_get (const x10rt_msg_params &p, x10aux::copy_sz len) { +static void cuda_finished_get (const x10rt_msg_params *p, x10aux::copy_sz len) { _X_(ANSI_X10RT<<"Receiving a get, deserialising for cuda notifier..."<<ANSI_RESET); - x10aux::deserialization_buffer buf(static_cast<char*>(p.msg)); + x10aux::deserialization_buffer buf(static_cast<char*>(p->msg)); // note: high bytes thrown away in implicit conversion - serialization_id_t sid = x10aux::DeserializationDispatcher::getSerializationId(p.type); + serialization_id_t sid = x10aux::DeserializationDispatcher::getSerializationId(p->type); x10aux::Notifier n = x10aux::DeserializationDispatcher::getCUDAGetNotifier(sid); n(buf,len); - assert(buf.consumed() <= p.len); + assert(buf.consumed() <= p->len); deserialized_bytes += buf.consumed() ; asyncs_received++; } @@ -427,7 +429,7 @@ buf.write(addr); size_t len = buf.length(); x10rt_msg_params p = {gpu, kernel_put, buf.steal(), len}; - x10rt_send_put(p, var, sz); + x10rt_send_put(&p, var, sz); while (!finished) x10rt_probe(); } Modified: trunk/x10.runtime/src-cpp/x10aux/static_init.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/static_init.cc 2010-03-08 14:22:31 UTC (rev 13259) +++ trunk/x10.runtime/src-cpp/x10aux/static_init.cc 2010-03-08 14:39:20 UTC (rev 13260) @@ -47,7 +47,7 @@ // Save the buffer for the rest of the broadcast the_buf = (char*)x10rt_msg_realloc(NULL, 0, sz); ::memmove(the_buf, p.msg, sz); - x10rt_send_msg(p); + x10rt_send_msg(&p); } // Free the buffer x10rt_msg_realloc(the_buf, sz, 0); Added: trunk/x10.runtime/x10rt/Doxyfile =================================================================== --- trunk/x10.runtime/x10rt/Doxyfile (rev 0) +++ trunk/x10.runtime/x10rt/Doxyfile 2010-03-08 14:39:20 UTC (rev 13260) @@ -0,0 +1,1514 @@ +# Doxyfile 1.6.1 + +# This file describes the settings to be used by the documentation system +# doxygen (www.doxygen.org) for a project +# +# All text after a hash (#) is considered a comment and will be ignored +# The format is: +# TAG = value [value, ...] +# For lists items can also be appended using: +# TAG += value [value, ...] +# Values that contain spaces should be placed between quotes (" ") + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- + +# This tag specifies the encoding used for all characters in the config file +# that follow. The default is UTF-8 which is also the encoding used for all +# text before the first occurrence of this tag. Doxygen uses libiconv (or the +# iconv built into libc) for the transcoding. See +# http://www.gnu.org/software/libiconv for the list of possible encodings. + +DOXYFILE_ENCODING = UTF-8 + +# The PROJECT_NAME tag is a single word (or a sequence of words surrounded +# by quotes) that should identify the project. + +PROJECT_NAME = X10RT + +# The PROJECT_NUMBER tag can be used to enter a project or revision number. +# This could be handy for archiving the generated documentation or +# if some version control system is used. + +PROJECT_NUMBER = + +# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) +# base path where the generated documentation will be put. +# If a relative path is entered, it will be relative to the location +# where doxygen was started. If left blank the current directory will be used. + +OUTPUT_DIRECTORY = doxygen_output + +# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create +# 4096 sub-directories (in 2 levels) under the output directory of each output +# format and will distribute the generated files over these directories. +# Enabling this option can be useful when feeding doxygen a huge amount of +# source files, where putting all generated files in the same directory would +# otherwise cause performance problems for the file system. + +CREATE_SUBDIRS = NO + +# The OUTPUT_LANGUAGE tag is used to specify the language in which all +# documentation generated by doxygen is written. Doxygen will use this +# information to generate all constant output in the proper language. +# The default language is English, other supported languages are: +# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, +# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German, +# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English +# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, +# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrilic, Slovak, +# Slovene, Spanish, Swedish, Ukrainian, and Vietnamese. + +OUTPUT_LANGUAGE = English + +# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will +# include brief member descriptions after the members that are listed in +# the file and class documentation (similar to JavaDoc). +# Set to NO to disable this. + +BRIEF_MEMBER_DESC = YES + +# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend +# the brief description of a member or function before the detailed description. +# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the +# brief descriptions will be completely suppressed. + +REPEAT_BRIEF = YES + +# This tag implements a quasi-intelligent brief description abbreviator +# that is used to form the text in various listings. Each string +# in this list, if found as the leading text of the brief description, will be +# stripped from the text and the result after processing the whole list, is +# used as the annotated text. Otherwise, the brief description is used as-is. +# If left blank, the following values are used ("$name" is automatically +# replaced with the name of the entity): "The $name class" "The $name widget" +# "The $name file" "is" "provides" "specifies" "contains" +# "represents" "a" "an" "the" + +ABBREVIATE_BRIEF = + +# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then +# Doxygen will generate a detailed section even if there is only a brief +# description. + +ALWAYS_DETAILED_SEC = NO + +# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all +# inherited members of a class in the documentation of that class as if those +# members were ordinary class members. Constructors, destructors and assignment +# operators of the base classes will not be shown. + +INLINE_INHERITED_MEMB = NO + +# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full +# path before files name in the file list and in the header files. If set +# to NO the shortest path that makes the file name unique will be used. + +FULL_PATH_NAMES = YES + +# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag +# can be used to strip a user-defined part of the path. Stripping is +# only done if one of the specified strings matches the left-hand part of +# the path. The tag can be used to show relative paths in the file list. +# If left blank the directory from which doxygen is run is used as the +# path to strip. + +STRIP_FROM_PATH = + +# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of +# the path mentioned in the documentation of a class, which tells +# the reader which header file to include in order to use a class. +# If left blank only the name of the header file containing the class +# definition is used. Otherwise one should specify the include paths that +# are normally passed to the compiler using the -I flag. + +STRIP_FROM_INC_PATH = + +# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter +# (but less readable) file names. This can be useful is your file systems +# doesn't support long names like on DOS, Mac, or CD-ROM. + +SHORT_NAMES = NO + +# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen +# will interpret the first line (until the first dot) of a JavaDoc-style +# comment as the brief description. If set to NO, the JavaDoc +# comments will behave just like regular Qt-style comments +# (thus requiring an explicit @brief command for a brief description.) + +JAVADOC_AUTOBRIEF = YES + +# If the QT_AUTOBRIEF tag is set to YES then Doxygen will +# interpret the first line (until the first dot) of a Qt-style +# comment as the brief description. If set to NO, the comments +# will behave just like regular Qt-style comments (thus requiring +# an explicit \brief command for a brief description.) + +QT_AUTOBRIEF = YES + +# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen +# treat a multi-line C++ special comment block (i.e. a block of //! or /// +# comments) as a brief description. This used to be the default behaviour. +# The new default is to treat a multi-line C++ comment block as a detailed +# description. Set this tag to YES if you prefer the old behaviour instead. + +MULTILINE_CPP_IS_BRIEF = NO + +# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented +# member inherits the documentation from any documented member that it +# re-implements. + +INHERIT_DOCS = YES + +# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce +# a new page for each member. If set to NO, the documentation of a member will +# be part of the file/class/namespace that contains it. + +SEPARATE_MEMBER_PAGES = NO + +# The TAB_SIZE tag can be used to set the number of spaces in a tab. +# Doxygen uses this value to replace tabs by spaces in code fragments. + +TAB_SIZE = 4 + +# This tag can be used to specify a number of aliases that acts +# as commands in the documentation. An alias has the form "name=value". +# For example adding "sideeffect=\par Side Effects:\n" will allow you to +# put the command \sideeffect (or @sideeffect) in the documentation, which +# will result in a user-defined paragraph with heading "Side Effects:". +# You can put \n's in the value part of an alias to insert newlines. + +ALIASES = + +# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C +# sources only. Doxygen will then generate output that is more tailored for C. +# For instance, some of the names that are used will be different. The list +# of all members will be omitted, etc. + +OPTIMIZE_OUTPUT_FOR_C = YES + +# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java +# sources only. Doxygen will then generate output that is more tailored for +# Java. For instance, namespaces will be presented as packages, qualified +# scopes will look different, etc. + +OPTIMIZE_OUTPUT_JAVA = NO + +# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran +# sources only. Doxygen will then generate output that is more tailored for +# Fortran. + +OPTIMIZE_FOR_FORTRAN = NO + +# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL +# sources. Doxygen will then generate output that is tailored for +# VHDL. + +OPTIMIZE_OUTPUT_VHDL = NO + +# Doxygen selects the parser to use depending on the extension of the files it parses. +# With this tag you can assign which parser to use for a given extension. +# Doxygen has a built-in mapping, but you can override or extend it using this tag. +# The format is ext=language, where ext is a file extension, and language is one of +# the parsers supported by doxygen: IDL, Java, Javascript, C#, C, C++, D, PHP, +# Objective-C, Python, Fortran, VHDL, C, C++. For instance to make doxygen treat +# .inc files as Fortran files (default is PHP), and .f files as C (default is Fortran), +# use: inc=Fortran f=C. Note that for custom extensions you also need to set FILE_PATTERNS otherwise the files are not read by doxygen. + +EXTENSION_MAPPING = + +# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want +# to include (a tag file for) the STL sources as input, then you should +# set this tag to YES in order to let doxygen match functions declarations and +# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. +# func(std::string) {}). This also make the inheritance and collaboration +# diagrams that involve STL classes more complete and accurate. + +BUILTIN_STL_SUPPORT = NO + +# If you use Microsoft's C++/CLI language, you should set this option to YES to +# enable parsing support. + +CPP_CLI_SUPPORT = NO + +# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. +# Doxygen will parse them like normal C++ but will assume all classes use public +# instead of private inheritance when no explicit protection keyword is present. + +SIP_SUPPORT = NO + +# For Microsoft's IDL there are propget and propput attributes to indicate getter +# and setter methods for a property. Setting this option to YES (the default) +# will make doxygen to replace the get and set methods by a property in the +# documentation. This will only work if the methods are indeed getting or +# setting a simple type. If this is not the case, or you want to show the +# methods anyway, you should set this option to NO. + +IDL_PROPERTY_SUPPORT = YES + +# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC +# tag is set to YES, then doxygen will reuse the documentation of the first +# member in the group (if any) for the other members of the group. By default +# all members of a group must be documented explicitly. + +DISTRIBUTE_GROUP_DOC = NO + +# Set the SUBGROUPING tag to YES (the default) to allow class member groups of +# the same type (for instance a group of public functions) to be put as a +# subgroup of that type (e.g. under the Public Functions section). Set it to +# NO to prevent subgrouping. Alternatively, this can be done per class using +# the \nosubgrouping command. + +SUBGROUPING = YES + +# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum +# is documented as struct, union, or enum with the name of the typedef. So +# typedef struct TypeS {} TypeT, will appear in the documentation as a struct +# with name TypeT. When disabled the typedef will appear as a member of a file, +# namespace, or class. And the struct will be named TypeS. This can typically +# be useful for C code in case the coding convention dictates that all compound +# types are typedef'ed and only the typedef is referenced, never the tag name. + +TYPEDEF_HIDES_STRUCT = NO + +# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to +# determine which symbols to keep in memory and which to flush to disk. +# When the cache is full, less often used symbols will be written to disk. +# For small to medium size projects (<1000 input files) the default value is +# probably good enough. For larger projects a too small cache size can cause +# doxygen to be busy swapping symbols to and from disk most of the time +# causing a significant performance penality. +# If the system has enough physical memory increasing the cache will improve the +# performance by keeping more symbols in memory. Note that the value works on +# a logarithmic scale so increasing the size by one will rougly double the +# memory usage. The cache size is given by this formula: +# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, +# corresponding to a cache size of 2^16 = 65536 symbols + +SYMBOL_CACHE_SIZE = 0 + +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- + +# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in +# documentation are documented, even if no documentation was available. +# Private class members and static file members will be hidden unless +# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES + +EXTRACT_ALL = NO + +# If the EXTRACT_PRIVATE tag is set to YES all private members of a class +# will be included in the documentation. + +EXTRACT_PRIVATE = YES + +# If the EXTRACT_STATIC tag is set to YES all static members of a file +# will be included in the documentation. + +EXTRACT_STATIC = YES + +# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) +# defined locally in source files will be included in the documentation. +# If set to NO only classes defined in header files are included. + +EXTRACT_LOCAL_CLASSES = YES + +# This flag is only useful for Objective-C code. When set to YES local +# methods, which are defined in the implementation section but not in +# the interface are included in the documentation. +# If set to NO (the default) only methods in the interface are included. + +EXTRACT_LOCAL_METHODS = NO + +# If this flag is set to YES, the members of anonymous namespaces will be +# extracted and appear in the documentation as a namespace called +# 'anonymous_namespace{file}', where file will be replaced with the base +# name of the file that contains the anonymous namespace. By default +# anonymous namespace are hidden. + +EXTRACT_ANON_NSPACES = NO + +# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all +# undocumented members of documented classes, files or namespaces. +# If set to NO (the default) these members will be included in the +# various overviews, but no documentation section is generated. +# This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_MEMBERS = NO + +# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all +# undocumented classes that are normally visible in the class hierarchy. +# If set to NO (the default) these classes will be included in the various +# overviews. This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_CLASSES = NO + +# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all +# friend (class|struct|union) declarations. +# If set to NO (the default) these declarations will be included in the +# documentation. + +HIDE_FRIEND_COMPOUNDS = NO + +# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any +# documentation blocks found inside the body of a function. +# If set to NO (the default) these blocks will be appended to the +# function's detailed documentation block. + +HIDE_IN_BODY_DOCS = NO + +# The INTERNAL_DOCS tag determines if documentation +# that is typed after a \internal command is included. If the tag is set +# to NO (the default) then the documentation will be excluded. +# Set it to YES to include the internal documentation. + +INTERNAL_DOCS = NO + +# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate +# file names in lower-case letters. If set to YES upper-case letters are also +# allowed. This is useful if you have classes or files whose names only differ +# in case and if your file system supports case sensitive file names. Windows +# and Mac users are advised to set this option to NO. + +CASE_SENSE_NAMES = YES + +# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen +# will show members with their full class and namespace scopes in the +# documentation. If set to YES the scope will be hidden. + +HIDE_SCOPE_NAMES = NO + +# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen +# will put a list of the files that are included by a file in the documentation +# of that file. + +SHOW_INCLUDE_FILES = YES + +# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] +# is inserted in the documentation for inline members. + +INLINE_INFO = YES + +# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen +# will sort the (detailed) documentation of file and class members +# alphabetically by member name. If set to NO the members will appear in +# declaration order. + +SORT_MEMBER_DOCS = NO + +# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the +# brief documentation of file, namespace and class members alphabetically +# by member name. If set to NO (the default) the members will appear in +# declaration order. + +SORT_BRIEF_DOCS = NO + +# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen will sort the (brief and detailed) documentation of class members so that constructors and destructors are listed first. If set to NO (the default) the constructors will appear in the respective orders defined by SORT_MEMBER_DOCS and SORT_BRIEF_DOCS. This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO. + +SORT_MEMBERS_CTORS_1ST = NO + +# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the +# hierarchy of group names into alphabetical order. If set to NO (the default) +# the group names will appear in their defined order. + +SORT_GROUP_NAMES = NO + +# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be +# sorted by fully-qualified names, including namespaces. If set to +# NO (the default), the class list will be sorted only by class name, +# not including the namespace part. +# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. +# Note: This option applies only to the class list, not to the +# alphabetical list. + +SORT_BY_SCOPE_NAME = NO + +# The GENERATE_TODOLIST tag can be used to enable (YES) or +# disable (NO) the todo list. This list is created by putting \todo +# commands in the documentation. + +GENERATE_TODOLIST = YES + +# The GENERATE_TESTLIST tag can be used to enable (YES) or +# disable (NO) the test list. This list is created by putting \test +# commands in the documentation. + +GENERATE_TESTLIST = YES + +# The GENERATE_BUGLIST tag can be used to enable (YES) or +# disable (NO) the bug list. This list is created by putting \bug +# commands in the documentation. + +GENERATE_BUGLIST = YES + +# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or +# disable (NO) the deprecated list. This list is created by putting +# \deprecated commands in the documentation. + +GENERATE_DEPRECATEDLIST= YES + +# The ENABLED_SECTIONS tag can be used to enable conditional +# documentation sections, marked by \if sectionname ... \endif. + +ENABLED_SECTIONS = + +# The MAX_INITIALIZER_LINES tag determines the maximum number of lines +# the initial value of a variable or define consists of for it to appear in +# the documentation. If the initializer consists of more lines than specified +# here it will be hidden. Use a value of 0 to hide initializers completely. +# The appearance of the initializer of individual variables and defines in the +# documentation can be controlled using \showinitializer or \hideinitializer +# command in the documentation regardless of this setting. + +MAX_INITIALIZER_LINES = 30 + +# Set the SHOW_USED_FILES tag to NO to disable the list of files generated +# at the bottom of the documentation of classes and structs. If set to YES the +# list will mention the files that were used to generate the documentation. + +SHOW_USED_FILES = YES + +# If the sources in your project are distributed over multiple directories +# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy +# in the documentation. The default is NO. + +SHOW_DIRECTORIES = NO + +# Set the SHOW_FILES tag to NO to disable the generation of the Files page. +# This will remove the Files entry from the Quick Index and from the +# Folder Tree View (if specified). The default is YES. + +SHOW_FILES = YES + +# Set the SHOW_NAMESPACES tag to NO to disable the generation of the +# Namespaces page. +# This will remove the Namespaces entry from the Quick Index +# and from the Folder Tree View (if specified). The default is YES. + +SHOW_NAMESPACES = YES + +# The FILE_VERSION_FILTER tag can be used to specify a program or script that +# doxygen should invoke to get the current version for each file (typically from +# the version control system). Doxygen will invoke the program by executing (via +# popen()) the command <command> <input-file>, where <command> is the value of +# the FILE_VERSION_FILTER tag, and <input-file> is the name of an input file +# provided by doxygen. Whatever the program writes to standard output +# is used as the file version. See the manual for examples. + +FILE_VERSION_FILTER = + +# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed by +# doxygen. The layout file controls the global structure of the generated output files +# in an output format independent way. The create the layout file that represents +# doxygen's defaults, run doxygen with the -l option. You can optionally specify a +# file name after the option, if omitted DoxygenLayout.xml will be used as the name +# of the layout file. + +LAYOUT_FILE = + +#--------------------------------------------------------------------------- +# configuration options related to warning and progress messages +#--------------------------------------------------------------------------- + +# The QUIET tag can be used to turn on/off the messages that are generated +# by doxygen. Possible values are YES and NO. If left blank NO is used. + +QUIET = NO + +# The WARNINGS tag can be used to turn on/off the warning messages that are +# generated by doxygen. Possible values are YES and NO. If left blank +# NO is used. + +WARNINGS = YES + +# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings +# for undocumented members. If EXTRACT_ALL is set to YES then this flag will +# automatically be disabled. + +WARN_IF_UNDOCUMENTED = YES + +# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for +# potential errors in the documentation, such as not documenting some +# parameters in a documented function, or documenting parameters that +# don't exist or using markup commands wrongly. + +WARN_IF_DOC_ERROR = YES + +# This WARN_NO_PARAMDOC option can be abled to get warnings for +# functions that are documented, but have no documentation for their parameters +# or return value. If set to NO (the default) doxygen will only warn about +# wrong or incomplete parameter documentation, but not about the absence of +# documentation. + +WARN_NO_PARAMDOC = YES + +# The WARN_FORMAT tag determines the format of the warning messages that +# doxygen can produce. The string should contain the $file, $line, and $text +# tags, which will be replaced by the file and line number from which the +# warning originated and the warning text. Optionally the format may contain +# $version, which will be replaced by the version of the file (if it could +# be obtained via FILE_VERSION_FILTER) + +WARN_FORMAT = "$file:$line: $text" + +# The WARN_LOGFILE tag can be used to specify a file to which warning +# and error messages should be written. If left blank the output is written +# to stderr. + +WARN_LOGFILE = + +#--------------------------------------------------------------------------- +# configuration options related to the input files +#--------------------------------------------------------------------------- + +# The INPUT tag can be used to specify the files and/or directories that contain +# documented source files. You may enter file names like "myfile.cpp" or +# directories like "/usr/src/myproject". Separate the files or directories +# with spaces. + +INPUT = include/ + +# This tag can be used to specify the character encoding of the source files +# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is +# also the default input encoding. Doxygen uses libiconv (or the iconv built +# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for +# the list of possible encodings. + +INPUT_ENCODING = UTF-8 + +# If the value of the INPUT tag contains directories, you can use the +# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank the following patterns are tested: +# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx +# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py *.f90 + +FILE_PATTERNS = x10rt_*.h + +# The RECURSIVE tag can be used to turn specify whether or not subdirectories +# should be searched for input files as well. Possible values are YES and NO. +# If left blank NO is used. + +RECURSIVE = NO + +# The EXCLUDE tag can be used to specify files and/or directories that should +# excluded from the INPUT source files. This way you can easily exclude a +# subdirectory from a directory tree whose root is specified with the INPUT tag. + +EXCLUDE = + +# The EXCLUDE_SYMLINKS tag can be used select whether or not files or +# directories that are symbolic links (a Unix filesystem feature) are excluded +# from the input. + +EXCLUDE_SYMLINKS = NO + +# If the value of the INPUT tag contains directories, you can use the +# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude +# certain files from those directories. Note that the wildcards are matched +# against the file with absolute path, so to exclude all test directories +# for example use the pattern */test/* + +EXCLUDE_PATTERNS = + +# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names +# (namespaces, classes, functions, etc.) that should be excluded from the +# output. The symbol name can be a fully qualified name, a word, or if the +# wildcard * is used, a substring. Examples: ANamespace, AClass, +# AClass::ANamespace, ANamespace::*Test + +EXCLUDE_SYMBOLS = + +# The EXAMPLE_PATH tag can be used to specify one or more files or +# directories that contain example code fragments that are included (see +# the \include command). + +EXAMPLE_PATH = + +# If the value of the EXAMPLE_PATH tag contains directories, you can use the +# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank all files are included. + +EXAMPLE_PATTERNS = + +# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be +# searched for input files to be used with the \include or \dontinclude +# commands irrespective of the value of the RECURSIVE tag. +# Possible values are YES and NO. If left blank NO is used. + +EXAMPLE_RECURSIVE = NO + +# The IMAGE_PATH tag can be used to specify one or more files or +# directories that contain image that are included in the documentation (see +# the \image command). + +IMAGE_PATH = + +# The INPUT_FILTER tag can be used to specify a program that doxygen should +# invoke to filter for each input file. Doxygen will invoke the filter program +# by executing (via popen()) the command <filter> <input-file>, where <filter> +# is the value of the INPUT_FILTER tag, and <input-file> is the name of an +# input file. Doxygen will then use the output that the filter program writes +# to standard output. +# If FILTER_PATTERNS is specified, this tag will be +# ignored. + +INPUT_FILTER = + +# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern +# basis. +# Doxygen will compare the file name with each pattern and apply the +# filter if there is a match. +# The filters are a list of the form: +# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further +# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER +# is applied to all files. + +FILTER_PATTERNS = + +# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using +# INPUT_FILTER) will be used to filter the input files when producing source +# files to browse (i.e. when SOURCE_BROWSER is set to YES). + +FILTER_SOURCE_FILES = NO + +#--------------------------------------------------------------------------- +# configuration options related to source browsing +#--------------------------------------------------------------------------- + +# If the SOURCE_BROWSER tag is set to YES then a list of source files will +# be generated. Documented entities will be cross-referenced with these sources. +# Note: To get rid of all source code in the generated output, make sure also +# VERBATIM_HEADERS is set to NO. + +SOURCE_BROWSER = NO + +# Setting the INLINE_SOURCES tag to YES will include the body +# of functions and classes directly in the documentation. + +INLINE_SOURCES = NO + +# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct +# doxygen to hide any special comment blocks from generated source code +# fragments. Normal C and C++ comments will always remain visible. + +STRIP_CODE_COMMENTS = YES + +# If the REFERENCED_BY_RELATION tag is set to YES +# then for each documented function all documented +# functions referencing it will be listed. + +REFERENCED_BY_RELATION = NO + +# If the REFERENCES_RELATION tag is set to YES +# then for each documented function all documented entities +# called/used by that function will be listed. + +REFERENCES_RELATION = NO + +# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) +# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from +# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will +# link to the source code. +# Otherwise they will link to the documentation. + +REFERENCES_LINK_SOURCE = YES + +# If the USE_HTAGS tag is set to YES then the references to source code +# will point to the HTML generated by the htags(1) tool instead of doxygen +# built-in source browser. The htags tool is part of GNU's global source +# tagging system (see http://www.gnu.org/software/global/global.html). You +# will need version 4.8.6 or higher. + +USE_HTAGS = NO + +# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen +# will generate a verbatim copy of the header file for each class for +# which an include is specified. Set to NO to disable this. + +VERBATIM_HEADERS = YES + +#--------------------------------------------------------------------------- +# configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- + +# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index +# of all compounds will be generated. Enable this if the project +# contains a lot of classes, structs, unions or interfaces. + +ALPHABETICAL_INDEX = NO + +# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then +# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns +# in which this list will be split (can be a number in the range [1..20]) + +COLS_IN_ALPHA_INDEX = 5 + +# In case all classes in a project start with a common prefix, all +# classes will be put under the same header in the alphabetical index. +# The IGNORE_PREFIX tag can be used to specify one or more prefixes that +# should be ignored while generating the index headers. + +IGNORE_PREFIX = + +#--------------------------------------------------------------------------- +# configuration options related to the HTML output +#--------------------------------------------------------------------------- + +# If the GENERATE_HTML tag is set to YES (the default) Doxygen will +# generate HTML output. + +GENERATE_HTML = YES + +# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `html' will be used as the default path. + +HTML_OUTPUT = html + +# The HTML_FILE_EXTENSION tag can be used to specify the file extension for +# each generated HTML page (for example: .htm,.php,.asp). If it is left blank +# doxygen will generate files with .html extension. + +HTML_FILE_EXTENSION = .html + +# The HTML_HEADER tag can be used to specify a personal HTML header for +# each generated HTML page. If it is left blank doxygen will generate a +# standard header. + +HTML_HEADER = + +# The HTML_FOOTER tag can be used to specify a personal HTML footer for +# each generated HTML page. If it is left blank doxygen will generate a +# standard footer. + +HTML_FOOTER = + +# The HTML_STYLESHEET tag can be used to specify a user-defined cascading +# style sheet that is used by each HTML page. It can be used to +# fine-tune the look of the HTML output. If the tag is left blank doxygen +# will generate a default style sheet. Note that doxygen will try to copy +# the style sheet file to the HTML output directory, so don't put your own +# stylesheet in the HTML output directory as well, or it will be erased! + +HTML_STYLESHEET = + +# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, +# files or namespaces will be aligned in HTML using tables. If set to +# NO a bullet list will be used. + +HTML_ALIGN_MEMBERS = YES + +# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML +# documentation will contain sections that can be hidden and shown after the +# page has loaded. For this to work a browser that supports +# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox +# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari). + +HTML_DYNAMIC_SECTIONS = YES + +# If the GENERATE_DOCSET tag is set to YES, additional index files +# will be generated that can be used as input for Apple's Xcode 3 +# integrated development environment, introduced with OSX 10.5 (Leopard). +# To create a documentation set, doxygen will generate a Makefile in the +# HTML output directory. Running make will produce the docset in that +# directory and running "make install" will install the docset in +# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find +# it at startup. +# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html for more information. + +GENERATE_DOCSET = NO + +# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the +# feed. A documentation feed provides an umbrella under which multiple +# documentation sets from a single provider (such as a company or product suite) +# can be grouped. + +DOCSET_FEEDNAME = "Doxygen generated docs" + +# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that +# should uniquely identify the documentation set bundle. This should be a +# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen +# will append .docset to the name. + +DOCSET_BUNDLE_ID = org.doxygen.Project + +# If the GENERATE_HTMLHELP tag is set to YES, additional index files +# will be generated that can be used as input for tools like the +# Microsoft HTML help workshop to generate a compiled HTML help file (.chm) +# of the generated HTML documentation. + +GENERATE_HTMLHELP = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can +# be used to specify the file name of the resulting .chm file. You +# can add a path in front of the file if the result should not be +# written to the html output directory. + +CHM_FILE = + +# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can +# be used to specify the location (absolute path including file name) of +# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run +# the HTML help compiler on the generated index.hhp. + +HHC_LOCATION = + +# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag +# controls if a separate .chi index file is generated (YES) or that +# it should be included in the master .chm file (NO). + +GENERATE_CHI = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING +# is used to encode HtmlHelp index (hhk), content (hhc) and project file +# content. + +CHM_INDEX_ENCODING = + +# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag +# controls whether a binary table of contents is generated (YES) or a +# normal table of contents (NO) in the .chm file. + +BINARY_TOC = NO + +# The TOC_EXPAND flag can be set to YES to add extra items for group members +# to the contents of the HTML help documentation and to the tree view. + +TOC_EXPAND = NO + +# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and QHP_VIRTUAL_FOLDER +# are set, an additional index file will be generated that can be used as input for +# Qt's qhelpgenerator to generate a Qt Compressed Help (.qch) of the generated +# HTML documentation. + +GENERATE_QHP = NO + +# If the QHG_LOCATION tag is specified, the QCH_FILE tag can +# be used to specify the file name of the resulting .qch file. +# The path specified is relative to the HTML output folder. + +QCH_FILE = + +# The QHP_NAMESPACE tag specifies the namespace to use when generating +# Qt Help Project output. For more information please see +# http://doc.trolltech.com/qthelpproject.html#namespace + +QHP_NAMESPACE = + +# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating +# Qt Help Project output. For more information please see +# http://doc.trolltech.com/qthelpproject.html#virtual-folders + +QHP_VIRTUAL_FOLDER = doc + +# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to add. +# For more information please see +# http://doc.trolltech.com/qthelpproject.html#custom-filters + +QHP_CUST_FILTER_NAME = + +# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the custom filter to add.For more information please see +# <a href="http://doc.trolltech.com/qthelpproject.html#custom-filters">Qt Help Project / Custom Filters</a>. + +QHP_CUST_FILTER_ATTRS = + +# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this project's +# filter section matches. +# <a href="http://doc.trolltech.com/qthelpproject.html#filter-attributes">Qt Help Project / Filter Attributes</a>. + +QHP_SECT_FILTER_ATTRS = + +# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can +# be used to specify the location of Qt's qhelpgenerator. +# If non-empty doxygen will try to run qhelpgenerator on the generated +# .qhp file. + +QHG_LOCATION = + +# The DISABLE_INDEX tag can be used to turn on/off the condensed index at +# top of each HTML page. The value NO (the default) enables the index and +# the value YES disables it. + +DISABLE_INDEX = NO + +# This tag can be used to set the number of enum values (range [1..20]) +# that doxygen will group on one line in the generated HTML documentation. + +ENUM_VALUES_PER_LINE = 4 + +# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index +# structure should be generated to display hierarchical information. +# If the tag value is set to YES, a side panel will be generated +# containing a tree-like index structure (just like the one that +# is generated for HTML Help). For this to work a browser that supports +# JavaScript, DHTML, CSS and frames is required (i.e. any modern browser). +# Windows users are probably better off using the HTML help feature. + +GENERATE_TREEVIEW = NO + +# By enabling USE_INLINE_TREES, doxygen will generate the Groups, Directories, +# and Class Hierarchy pages using a tree view instead of an ordered list. + +USE_INLINE_TREES = NO + +# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be +# used to set the initial width (in pixels) of the frame in which the tree +# is shown. + +TREEVIEW_WIDTH = 250 + +# Use this tag to change the font size of Latex formulas included +# as images in the HTML documentation. The default is 10. Note that +# when you change the font size after a successful doxygen run you need +# to manually remove any form_*.png images from the HTML output directory +# to force them to be regenerated. + +FORMULA_FONTSIZE = 10 + +# When the SEARCHENGINE tag is enable doxygen will generate a search box for the HTML output. The underlying search engine uses javascript +# and DHTML and should work on any modern browser. Note that w... [truncated message content] |
From: <ipe...@us...> - 2010-03-08 20:25:40
|
Revision: 13272 http://x10.svn.sourceforge.net/x10/?rev=13272&view=rev Author: ipeshansky Date: 2010-03-08 20:25:34 +0000 (Mon, 08 Mar 2010) Log Message: ----------- Fix XTENLANG-1126. Add a test case for comparing remote references for equality. Modified Paths: -------------- trunk/x10.runtime/src-cpp/x10/lang/Object.h Added Paths: ----------- trunk/x10.tests/examples/Constructs/References/ trunk/x10.tests/examples/Constructs/References/RemoteRefEquality.x10 Modified: trunk/x10.runtime/src-cpp/x10/lang/Object.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Object.h 2010-03-08 20:23:07 UTC (rev 13271) +++ trunk/x10.runtime/src-cpp/x10/lang/Object.h 2010-03-08 20:25:34 UTC (rev 13272) @@ -103,9 +103,9 @@ virtual x10aux::ref<x10::lang::String> typeName(); // Needed for linking - do not override - virtual x10_boolean _struct_equals(x10aux::ref<Object> other) { + virtual x10_boolean _struct_equals(x10aux::ref<Reference> other) { assert(other!=x10aux::null); // checked in basic_functions.h x10aux::struct_equals - if (other == x10aux::ref<Object>(this)) return true; + if (other == x10aux::ref<Reference>(this)) return true; if (this->location == x10aux::here) return false; // already tested above if (other->location == this->location && x10aux::get_remote_ref(other.operator->()) == x10aux::get_remote_ref(this)) Added: trunk/x10.tests/examples/Constructs/References/RemoteRefEquality.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/References/RemoteRefEquality.x10 (rev 0) +++ trunk/x10.tests/examples/Constructs/References/RemoteRefEquality.x10 2010-03-08 20:25:34 UTC (rev 13272) @@ -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. + */ + +import harness.x10Test; + +/** + * Two remote references to the same object must be equal. + * @author igor 06/2009 + */ +class RemoteRefEquality extends x10Test { + + val rr:RemoteRefEquality; + + public def this(v:RemoteRefEquality) { rr = v; } + + public def this() { this(null); } + + public def run(): boolean { + chk(Place.places.length > 1, "This test must be run with multiple places"); + val local = new RemoteRefEquality(); + val remote = at (here.next()) new RemoteRefEquality(local); + Console.OUT.println(local == (at (remote) remote.rr)); // workaround XTENLANG-1124 + Console.OUT.println(at (remote) remote.rr == local); + return at (remote) remote.rr == local; + } + + public static def main(Rail[String]) { + new RemoteRefEquality().execute(); + } +} + Property changes on: trunk/x10.tests/examples/Constructs/References/RemoteRefEquality.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. |
From: <spa...@us...> - 2010-03-09 23:56:36
|
Revision: 13303 http://x10.svn.sourceforge.net/x10/?rev=13303&view=rev Author: sparksparkspark Date: 2010-03-09 23:56:29 +0000 (Tue, 09 Mar 2010) Log Message: ----------- RailCopy test now runs to completion, reports 26 errors, which are to do with copyFrom (buffer finder version) not copying the data properly, to be investigated... Modified Paths: -------------- trunk/x10.runtime/src-cpp/x10/lang/Rail.h trunk/x10.runtime/src-x10/x10/lang/Rail__NativeRep.x10 trunk/x10.tests/examples/Constructs/Rail/RailCopy.x10 Modified: trunk/x10.runtime/src-cpp/x10/lang/Rail.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Rail.h 2010-03-09 23:51:06 UTC (rev 13302) +++ trunk/x10.runtime/src-cpp/x10/lang/Rail.h 2010-03-09 23:56:29 UTC (rev 13303) @@ -51,6 +51,7 @@ RTT_H_DECLS_CLASS; typedef x10aux::ref<Rail<T> > R; + typedef x10aux::ref<ValRail<T> > V; static typename Iterable<T>::template itable<Rail<T> > _itable_iterable; static typename Settable<x10_int, T>::template itable<Rail<T> > _itable_settable; @@ -180,6 +181,10 @@ x10aux::ref<Fun_0_0<x10::util::Pair<R, x10_int> > > src_finder, x10_int len); + virtual void copyFrom (x10_int dst_off, x10::lang::Place src_place, + x10aux::ref<Fun_0_0<x10::util::Pair<V, x10_int> > > src_finder, + x10_int len); + virtual x10aux::ref<String> toString(); }; @@ -531,7 +536,7 @@ x10aux::ref<VoidFun_0_0> notifier) { typedef x10::util::Pair<R,x10_int> P; - R this_ = this; + x10aux::ref<Reference> n = notifier; x10aux::place dst_place = x10aux::location(dst); // check beginning and end of range @@ -544,6 +549,7 @@ buf.write(code); buf.write(dst); buf.write(dst_off); + buf.write(n); x10aux::send_put(dst_place, _copy_to_serialization_id, buf, &_data[src_off], len * sizeof(T)); @@ -557,9 +563,7 @@ x10aux::ref<VoidFun_0_0> notifier) { typedef x10::util::Pair<R,x10_int> P; - R this_ = this; x10aux::place dst_place = dst_place_.FMGL(id); - (void) dst_place; // check beginning and end of range x10aux::checkRailBounds(src_off, FMGL(length)); @@ -589,36 +593,52 @@ x10aux::deserialization_buffer &buf, x10_int len) { - typedef x10::util::Pair<R,x10_int> P; + typedef x10::util::Pair<R,x10_int> PR; + typedef x10::util::Pair<V,x10_int> PV; assert(len%sizeof(T) == 0); // we can only transmit whole array elements len /= sizeof(T); x10_ubyte code = buf.read<x10_ubyte>(); - R this_; x10_int src_off; + x10_int length; + void *ptr; _X_("Finding a rail for copyFrom ("<<(int)code<<")"); switch (code) { case 0: { // get rail+offset explicitly - this_ = buf.read<R>(); + R this_ = buf.read<R>(); src_off = buf.read<x10_int>(); + length = this_->FMGL(length); + ptr = &this_->_data[src_off]; break; } case 1: { // get rail+offset from closure - x10aux::ref<Reference> bf = buf.read<x10aux::ref<Fun_0_0<P> > >(); - P pair = (bf.operator->()->*(x10aux::findITable<Fun_0_0<P> >(bf->_getITables())->apply))(); - this_ = pair.FMGL(first); + x10aux::ref<Reference> bf = buf.read<x10aux::ref<Fun_0_0<PR> > >(); + PR pair = (bf.operator->()->*(x10aux::findITable<Fun_0_0<PR> >(bf->_getITables())->apply))(); + R this_ = pair.FMGL(first); src_off = pair.FMGL(second); x10aux::dealloc(bf.operator->()); + length = this_->FMGL(length); + ptr = &this_->_data[src_off]; break; } + case 2: { // get valrail+offset from closure + x10aux::ref<Reference> bf = buf.read<x10aux::ref<Fun_0_0<PV> > >(); + PV pair = (bf.operator->()->*(x10aux::findITable<Fun_0_0<PV> >(bf->_getITables())->apply))(); + V this_ = pair.FMGL(first); + src_off = pair.FMGL(second); + x10aux::dealloc(bf.operator->()); + length = this_->FMGL(length); + ptr = &this_->_data[src_off]; + break; + } default: abort(); } // FIXME: should catch exception here, add to finish state, return NULL - x10aux::checkRailBounds(src_off, this_->FMGL(length)); - x10aux::checkRailBounds(src_off+len-1, this_->FMGL(length)); + x10aux::checkRailBounds(src_off, length); + x10aux::checkRailBounds(src_off+len-1, length); - return &this_->_data[src_off]; + return ptr; } // }}} // nf {{{ @@ -626,7 +646,8 @@ x10aux::deserialization_buffer &buf, x10_int len) { - typedef x10::util::Pair<R,x10_int> P; + typedef x10::util::Pair<R,x10_int> PR; + typedef x10::util::Pair<V,x10_int> PV; x10_ubyte code = buf.read<x10_ubyte>(); _X_("Completing a rail copyFrom ("<<(int)code<<")"); switch (code) { @@ -636,11 +657,17 @@ Rail_notifyEnclosingFinish(buf); } break; case 1: { - x10aux::ref<Reference> bf = buf.read<x10aux::ref<Fun_0_0<P> > >(); + x10aux::ref<Reference> bf = buf.read<x10aux::ref<Fun_0_0<PR> > >(); x10aux::dealloc(bf.operator->()); Rail_notifyEnclosingFinish(buf); break; } + case 2: { + x10aux::ref<Reference> bf = buf.read<x10aux::ref<Fun_0_0<PV> > >(); + x10aux::dealloc(bf.operator->()); + Rail_notifyEnclosingFinish(buf); + break; + } default: abort(); } } // }}} @@ -724,7 +751,7 @@ template <class T> void Rail<T>::copyFrom (x10_int dst_off, x10::lang::Place src_place_, x10aux::ref<Fun_0_0<x10::util::Pair<x10aux::ref<Rail<T> >, - x10_int> > > dst_finder, + x10_int> > > src_finder, x10_int len) { typedef x10::util::Pair<R,x10_int> P; @@ -733,11 +760,30 @@ // check beginning and end of range x10aux::checkRailBounds(dst_off, FMGL(length)); x10aux::checkRailBounds(dst_off+len-1, FMGL(length)); - x10aux::ref<Reference> df = dst_finder; + x10aux::ref<Reference> df = src_finder; Rail_serializeAndSendGet(src_place_, df, 1, _copy_from_serialization_id, &_data[dst_off], len * sizeof(T)); } // }}} + // CLOSURE FINISH VALRAIL (4) {{{ + template <class T> + void Rail<T>::copyFrom (x10_int dst_off, + x10::lang::Place src_place_, + x10aux::ref<Fun_0_0<x10::util::Pair<x10aux::ref<ValRail<T> >, + x10_int> > > src_finder, + x10_int len) + { + typedef x10::util::Pair<V,x10_int> P; + R this_ = this; + // check beginning and end of range + x10aux::checkRailBounds(dst_off, FMGL(length)); + x10aux::checkRailBounds(dst_off+len-1, FMGL(length)); + x10aux::ref<Reference> df = src_finder; + assert(src_place_.FMGL(id) != x10aux::here); // handle in X10 code wrapper + Rail_serializeAndSendGet(src_place_, df, 2, _copy_from_serialization_id, + &_data[dst_off], len * sizeof(T)); + } // }}} + // }}} Modified: trunk/x10.runtime/src-x10/x10/lang/Rail__NativeRep.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Rail__NativeRep.x10 2010-03-09 23:51:06 UTC (rev 13302) +++ trunk/x10.runtime/src-x10/x10/lang/Rail__NativeRep.x10 2010-03-09 23:56:29 UTC (rev 13303) @@ -105,7 +105,7 @@ dst_place:Place, dst_finder:()=>Pair[Rail[T]!,Int], len:Int) : Void; - @Native("c++", "(#4)->copyTo(#5,#6,#7,#8)") + @Native("c++", "(#4)->copyFrom(#5,#6,#7,#8)") @Native("java", "java.lang.System.out.println(\"Should never occur, see Rail.x10\")") public static native def copyFrom1_[T] (dst: Rail[T]!, dst_off:Int, src_place:Place, src_finder:()=>Pair[ValRail[T]!,Int], Modified: trunk/x10.tests/examples/Constructs/Rail/RailCopy.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Rail/RailCopy.x10 2010-03-09 23:51:06 UTC (rev 13302) +++ trunk/x10.tests/examples/Constructs/Rail/RailCopy.x10 2010-03-09 23:56:29 UTC (rev 13303) @@ -6,26 +6,30 @@ public class RailCopy extends x10Test { + // If the two rails are not the same, return 1 and print an error public static def verify[T] (r : ValRail[T], master : ValRail[T], where : String) { if (r.length != master.length) { Console.ERR.println("Failed verification at "+where+": "+"length mismatch"); - return false; + return 1; } for ((i) in 0..r.length-1) { if (r(i) != master(i)) { - Console.ERR.println("Failed verification at "+where+": "+"test_subject("+i+") == " + r(i) + " (should be "+master(i)+")"); - return false; + Console.ERR.println("\033[0;31m----------\033[0m"); + Console.ERR.println("Failed verification at "+where+": " + + "test_subject("+i+") == " + r(i) + + " (should be "+master(i)+")"); + return 1; } } Console.ERR.println("Success at "+where); - return true; + return 0; } @Native("c++", "fprintf(stderr,\"addr: %p\\n\",(#1)._val)") public static def printPtr(o:Object) { } - @Native("c++", "fprintf(stderr,\"addr remote: %p\\n\",x10aux::get_remote_ref((#1)._val))") + @Native("c++", "fprintf(stderr,\"addr remote: %p\\n\",(void*)(size_t)x10aux::get_remote_ref((#1)._val))") public static def printRemotePtr(o:Object) { } @Native("c++", "fprintf(stderr,\"name: \\\"%s\\\"\\n\",(#1)->_type()->name())") @@ -36,148 +40,147 @@ // for verification val master1 = ValRail.make(sz, init1); val master2 = ValRail.make(sz, init2); - var success:Boolean = true; + var failures:Int = 0; val local = Rail.make(sz, init1); val localv = local as ValRail[T]; val remote = at (there) Rail.make(sz, init2); val handle = PlaceLocalHandle.make[Rail[T]](Dist.makeUnique(here==there ? [here] : [here,there]), ()=>Rail.make(sz, init2)); - success &= verify(at (here) local as ValRail[T], master1, prefix+": Local rail initialization"); - success &= verify(at (here) localv, master1, prefix+": Local valrail initialization"); - success &= verify(at (there) remote as ValRail[T], master2, prefix+": Remote rail initialization"); + failures += verify(at (here) local as ValRail[T], master1, prefix+": Local rail initialization"); + failures += verify(at (here) localv, master1, prefix+": Local valrail initialization"); + failures += verify(at (there) remote as ValRail[T], master2, prefix+": Remote rail initialization"); val c = new Cell[Boolean](false); // for notifiers printPtr(c); printName(c); - val update = (c2:Cell[Boolean]!) => { atomic { c2.value = true; } ; printPtr(c2); printPtr(c); printName(c) }; + val update = (c2:Cell[Boolean]!) => { atomic { c2.value = true; c.value = true; } ; printPtr(c2); printPtr(c); printName(c) }; val notifier = () => { printRemotePtr(c); if (here==c.home) update(c); else Runtime.runAtNative(c.home.id, ()=>update(c)); }; -/* temporarily commented out +///* temporarily commented out finish local.copyTo(0,remote,0,sz); - success &= verify(at (there) remote as ValRail[T], master1, prefix+": test 1"); + failures += verify(at (there) remote as ValRail[T], master1, prefix+": test 1"); at (remote) remote.reset(init2); - success &= verify(at (there) remote as ValRail[T], master2, prefix+": test 1 (reset)"); + failures += verify(at (there) remote as ValRail[T], master2, prefix+": test 1 (reset)"); finish local.copyTo(0,there,()=>Pair[Rail[T],Int](remote,0),sz); - success &= verify(at (there) remote as ValRail[T], master1, prefix+": test 2"); + failures += verify(at (there) remote as ValRail[T], master1, prefix+": test 2"); at (remote) remote.reset(init2); - success &= verify(at (there) remote as ValRail[T], master2, prefix+": test 2 (reset)"); -*/ + failures += verify(at (there) remote as ValRail[T], master2, prefix+": test 2 (reset)"); +//*/ -/* not implemented c(false); local.copyTo(0,remote,0,sz,notifier); await c.value; - success &= verify(at (there) remote as ValRail[T], master1, prefix+": test 3"); + failures += verify(at (there) remote as ValRail[T], master1, prefix+": test 3"); at (there) remote.reset(init2); - success &= verify(at (there) remote as ValRail[T], master2, prefix+": test 3 (reset)"); -*/ + failures += verify(at (there) remote as ValRail[T], master2, prefix+": test 3 (reset)"); - c(false); local.copyTo(0,there,()=>Pair[Rail[T],Int](remote,0),sz,notifier); await c.value; - success &= verify(at (there) remote as ValRail[T], master1, prefix+": test 4"); + failures += verify(at (there) remote as ValRail[T], master1, prefix+": test 4"); at (remote) remote.reset(init2); - success &= verify(at (there) remote as ValRail[T], master2, prefix+": test 4 (reset)"); + failures += verify(at (there) remote as ValRail[T], master2, prefix+": test 4 (reset)"); -/* temporarily commented out +///* temporarily commented out finish local.copyTo(0,there,handle,0,sz); - success &= verify(at (there) handle() as ValRail[T], master1, prefix+": test 5"); + failures += verify(at (there) handle() as ValRail[T], master1, prefix+": test 5"); at (there) handle().reset(init2); - success &= verify(at (there) handle() as ValRail[T], master2, prefix+": test 5 (reset)"); + failures += verify(at (there) handle() as ValRail[T], master2, prefix+": test 5 (reset)"); c(false); local.copyTo(0,there,handle,0,sz,notifier); await c.value; - success &= verify(at (there) handle() as ValRail[T], master1, prefix+": test 6"); + failures += verify(at (there) handle() as ValRail[T], master1, prefix+": test 6"); at (there) handle().reset(init2); - success &= verify(at (there) handle() as ValRail[T], master2, prefix+": test 6 (reset)"); + failures += verify(at (there) handle() as ValRail[T], master2, prefix+": test 6 (reset)"); finish localv.copyTo(0,remote,0,sz); - success &= verify(at (there) remote as ValRail[T], master1, prefix+": test 1v"); + failures += verify(at (there) remote as ValRail[T], master1, prefix+": test 1v"); at (remote) remote.reset(init2); - success &= verify(at (there) remote as ValRail[T], master2, prefix+": test 1v (reset)"); + failures += verify(at (there) remote as ValRail[T], master2, prefix+": test 1v (reset)"); finish localv.copyTo(0,there,()=>Pair[Rail[T],Int](remote,0),sz); - success &= verify(at (there) remote as ValRail[T], master1, prefix+": test 2v"); + failures += verify(at (there) remote as ValRail[T], master1, prefix+": test 2v"); at (remote) remote.reset(init2); - success &= verify(at (there) remote as ValRail[T], master2, prefix+": test 2v (reset)"); -*/ + failures += verify(at (there) remote as ValRail[T], master2, prefix+": test 2v (reset)"); +//*/ /* not implemented c(false); localv.copyTo(0,remote,0,sz,notifier); await c.value; - success &= verify(at (there) remote as ValRail[T], master1, prefix+": test 3v"); + failures += verify(at (there) remote as ValRail[T], master1, prefix+": test 3v"); at (there) remote.reset(init2); - success &= verify(at (there) remote as ValRail[T], master2, prefix+": test 3v (reset)"); + failures += verify(at (there) remote as ValRail[T], master2, prefix+": test 3v (reset)"); */ /* not implemented c(false); localv.copyTo(0,there,()=>Pair[Rail[T],Int](remote,0),sz,notifier); await c.value; - success &= verify(at (there) remote as ValRail[T], master1, prefix+": test 4v"); + failures += verify(at (there) remote as ValRail[T], master1, prefix+": test 4v"); at (there) remote.reset(init2); - success &= verify(at (there) remote as ValRail[T], master2, prefix+": test 4v (reset)"); + failures += verify(at (there) remote as ValRail[T], master2, prefix+": test 4v (reset)"); */ /* not implemented finish localv.copyTo(0,there,handle,0,sz); - success &= verify(at (there) handle() as ValRail[T], master1, prefix+": test 5v"); + failures += verify(at (there) handle() as ValRail[T], master1, prefix+": test 5v"); at (there) handle().reset(init2); - success &= verify(at (there) handle() as ValRail[T], master2, prefix+": test 5v (reset)"); + failures += verify(at (there) handle() as ValRail[T], master2, prefix+": test 5v (reset)"); */ /* not implemented c(false); localv.copyTo(0,there,handle,0,sz,notifier); await c.value; - success &= verify(at (there) handle() as ValRail[T], master1, prefix+": test 6v"); + failures += verify(at (there) handle() as ValRail[T], master1, prefix+": test 6v"); at (there) handle().reset(init2); - success &= verify(at (there) handle() as ValRail[T], master2, prefix+": test 6v (reset)"); + failures += verify(at (there) handle() as ValRail[T], master2, prefix+": test 6v (reset)"); */ -/* temporarily commented out +///* temporarily commented out local.reset(init2); at (remote) remote.reset(init1); - success &= verify(at (here) local as ValRail[T], master2, prefix+": Local rail initialization (swapped)"); - success &= verify(at (there) remote as ValRail[T], master1, prefix+": Remote rail initialization (swapped)"); + failures += verify(at (here) local as ValRail[T], master2, prefix+": Local rail initialization (swapped)"); + failures += verify(at (there) remote as ValRail[T], master1, prefix+": Remote rail initialization (swapped)"); finish local.copyFrom(0,remote,0,sz); - success &= verify(local as ValRail[T], master1, prefix+": test 1f"); + failures += verify(local as ValRail[T], master1, prefix+": test 1f"); local.reset(init2); - success &= verify(local as ValRail[T], master2, prefix+": test 1f (reset)"); + failures += verify(local as ValRail[T], master2, prefix+": test 1f (reset)"); finish local.copyFrom(0,there,()=>Pair[Rail[T],Int](remote,0),sz); - success &= verify(local as ValRail[T], master1, prefix+": test 2f"); + failures += verify(local as ValRail[T], master1, prefix+": test 2f"); local.reset(init2); - success &= verify(local as ValRail[T], master2, prefix+": test 2f (reset)"); + failures += verify(local as ValRail[T], master2, prefix+": test 2f (reset)"); finish local.copyFrom(0,localv,0,sz); - success &= verify(local as ValRail[T], master1, prefix+": test 1fv"); + failures += verify(local as ValRail[T], master1, prefix+": test 1fv"); local.reset(init2); - success &= verify(local as ValRail[T], master2, prefix+": test 1fv (reset)"); + failures += verify(local as ValRail[T], master2, prefix+": test 1fv (reset)"); finish local.copyFrom(0,there,()=>Pair[ValRail[T],Int](remote as ValRail[T],0),sz); - success &= verify(local as ValRail[T], master1, prefix+": test 2fv"); + failures += verify(local as ValRail[T], master1, prefix+": test 2fv"); local.reset(init2); - success &= verify(local as ValRail[T], master2, prefix+": test 2fv (reset)"); -*/ + failures += verify(local as ValRail[T], master2, prefix+": test 2fv (reset)"); +//*/ - return success; + return failures; } public def run () : Boolean { - var b:Boolean = true; + var failures:Int = 0; val places = here.next() == here ? [here] : [here.next(), here]; for (p in places) { Console.ERR.println("========================="); Console.ERR.println("| "+(here==p?" Local copy test ":" Remote copy test ")+" |"); Console.ERR.println("========================="); - for (i in [1]) { //, 4200, 500000]) { - b &= test(i, p, (i:Int)=>i+1000 as Char, (i:Int)=>0 as Char, "Char"+i); - //b &= test(i, p, (i:Int)=>i-1000 as Int, (i:Int)=>0 as Int, "Int"+i); - //b &= test(i, p, (i:Int)=>i/1000.0 as Float, (i:Int)=>0 as Float, "Float"+i); - //b &= test(i, p, (i:Int)=>Math.pow(-i,3) as Double, (i:Int)=>0 as Double, "Double"+i); + for (i in [1, 4200, 500000]) { + failures += test(i, p, (i:Int)=>(65+(i%26)) as Char, (i:Int)=>'x', "Char"+i); + failures += test(i, p, (i:Int)=>i+1000 as Byte, (i:Int)=>0 as Byte, "Byte"+i); + failures += test(i, p, (i:Int)=>i-1000 as Int, (i:Int)=>0 as Int, "Int"+i); + failures += test(i, p, (i:Int)=>i/1000.0 as Float, (i:Int)=>0 as Float, "Float"+i); + failures += test(i, p, (i:Int)=>Math.pow(-i,3) as Double, (i:Int)=>0 as Double, "Double"+i); } } - return b; + Console.ERR.println("Number of failures: "+failures); + return failures == 0; } public static def main(Rail[String]) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ipe...@us...> - 2010-03-10 17:55:56
|
Revision: 13327 http://x10.svn.sourceforge.net/x10/?rev=13327&view=rev Author: ipeshansky Date: 2010-03-10 17:55:49 +0000 (Wed, 10 Mar 2010) Log Message: ----------- Cleanup of x10.lang.String. Make String concatenation a proper overloaded operator. Disable special compiler support for string concatenation. String now implements Comparable[String]. Implement String.hashCode() correctly. Implement String.equalsIgnoreCase(), String.toLowerCase(), String.toUpperCase(). Implement String.compareTo(), String.compareToIgnoreCase(). Remove String.format(String,Rail[Any]). Add X10doc comments to String. Add X10doc comment for Any.home. Make Comparable.compareTo() and the operators in Ordered global. Better behavior of isTitleCase() and toTitleCase() on Char. Remove some dead code from char_utils. Point now implements Ordered[Point(rank)]. Modified Paths: -------------- trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java trunk/x10.runtime/src-cpp/x10/lang/String.cc trunk/x10.runtime/src-cpp/x10/lang/String.h trunk/x10.runtime/src-cpp/x10aux/char_utils.cc trunk/x10.runtime/src-x10/x10/lang/Any.x10 trunk/x10.runtime/src-x10/x10/lang/Comparable.x10 trunk/x10.runtime/src-x10/x10/lang/Point.x10 trunk/x10.runtime/src-x10/x10/lang/String.x10 trunk/x10.runtime/src-x10/x10/util/Ordered.x10 Modified: trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java =================================================================== --- trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java 2010-03-10 17:07:38 UTC (rev 13326) +++ trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java 2010-03-10 17:55:49 UTC (rev 13327) @@ -2404,12 +2404,8 @@ // TODO // // Boolean short-circuiting operators are ok -// // FIXME: [IP] string concatenation are ok for now // Assign_c n = asgn; -// assert (opString.equals("&&") || opString.equals("||") || -// (opString.equals("+") && -// (n.left(nf).type().isSubtype(xts.String(), context)) || -// n.right().type().isSubtype(xts.String(), context))) +// assert (opString.equals("&&") || opString.equals("||")) // : "visiting "+n.getClass()+" at "+n.position()+": "+n; if (opString.equals(">>>=")) { @@ -4647,12 +4643,8 @@ String opString = n.operator().toString(); // Boolean short-circuiting operators are ok - // FIXME: [IP] string concatenation are ok for now X10TypeSystem_c xts = (X10TypeSystem_c) tr.typeSystem(); - assert (opString.equals("&&") || opString.equals("||") || - (opString.equals("+") && - (n.left().type().isSubtype(xts.String(), tr.context())) || - n.right().type().isSubtype(xts.String(), tr.context()))) + assert (opString.equals("&&") || opString.equals("||")) : "visiting "+n.getClass()+" at "+n.position()+": "+n; n.printSubExpr(n.left(), true, sw, tr); Modified: trunk/x10.runtime/src-cpp/x10/lang/String.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/String.cc 2010-03-10 17:07:38 UTC (rev 13326) +++ trunk/x10.runtime/src-cpp/x10/lang/String.cc 2010-03-10 17:55:49 UTC (rev 13327) @@ -17,6 +17,7 @@ #include <x10aux/basic_functions.h> #include <x10aux/throw.h> #include <x10aux/hash.h> +#include <x10aux/char_utils.h> #include <x10/lang/String.h> #include <x10/lang/Rail.h> @@ -44,7 +45,15 @@ } x10_int String::hashCode() { - return x10aux::hash(reinterpret_cast<const unsigned char*>(FMGL(content)), length()); + //return x10aux::hash(reinterpret_cast<const unsigned char*>(FMGL(content)), length()); + x10_int hc = 0; + x10_int l = length(); + const unsigned char* k = reinterpret_cast<const unsigned char*>(FMGL(content)); + for (; l > 0; k++, l--) { + hc *= 31; + hc += (x10_int) *k; + } + return hc; } x10_int String::indexOf(ref<String> str, x10_int i) { @@ -268,11 +277,83 @@ if (ref<String>(p0).operator->() == this) return true; // short-circuit trivial equality if (!x10aux::instanceof<ref<x10::lang::String> >(p0)) return false; ref<String> that = (ref<String>) p0; + if (this->FMGL(content_length) != that->FMGL(content_length)) return false; // short-circuit trivial dis-equality if (strcmp(this->FMGL(content), that->FMGL(content))) return false; return true; } +#ifdef __CYGWIN__ +extern "C" int strcasecmp(const char *, const char *); +#endif + +/* FIXME: Unicode support */ +x10_boolean String::equalsIgnoreCase(ref<String> s) { + nullCheck(s); + if (ref<String>(s).operator->() == this) return true; // short-circuit trivial equality + if (this->FMGL(content_length) != s->FMGL(content_length)) return false; // short-circuit trivial dis-equality + if (strcasecmp(this->FMGL(content), s->FMGL(content))) + return false; + return true; +} + +/* FIXME: Unicode support */ +ref<String> String::toLowerCase() { + char *str = x10aux::alloc<char>(FMGL(content_length)+1); + bool all_lower = true; + for (std::size_t i=0 ; i<FMGL(content_length) ; ++i) { + x10_char c = FMGL(content)[i]; + if (!x10aux::char_utils::isLowerCase(c)) + all_lower = false; + x10_char l = x10aux::char_utils::toLowerCase(c); + str[i] = (char)l.v; + } + if (all_lower) { + x10aux::dealloc(str); + return this; + } + str[FMGL(content_length)] = '\0'; + return String::Steal(str); +} + +/* FIXME: Unicode support */ +ref<String> String::toUpperCase() { + char *str = x10aux::alloc<char>(FMGL(content_length)+1); + bool all_upper = true; + for (std::size_t i=0 ; i<FMGL(content_length) ; ++i) { + x10_char c = FMGL(content)[i]; + if (!x10aux::char_utils::isUpperCase(c)) + all_upper = false; + x10_char u = x10aux::char_utils::toUpperCase(c); + str[i] = (char)u.v; + } + if (all_upper) { + x10aux::dealloc(str); + return this; + } + str[FMGL(content_length)] = '\0'; + return String::Steal(str); +} + +x10_int String::compareTo(ref<String> s) { + nullCheck(s); + if (ref<String>(s).operator->() == this) return 0; // short-circuit trivial equality + int length_diff = this->FMGL(content_length) - s->FMGL(content_length); + if (length_diff != 0) + return length_diff; + return (x10_int) strcmp(this->FMGL(content), s->FMGL(content)); +} + +/* FIXME: Unicode support */ +x10_int String::compareToIgnoreCase(ref<String> s) { + nullCheck(s); + if (ref<String>(s).operator->() == this) return 0; // short-circuit trivial equality + int length_diff = this->FMGL(content_length) - s->FMGL(content_length); + if (length_diff != 0) + return length_diff; + return (x10_int) strcasecmp(this->FMGL(content), s->FMGL(content)); +} + const serialization_id_t String::_serialization_id = DeserializationDispatcher::addDeserializer(String::_deserializer<Object>); @@ -315,9 +396,13 @@ Fun_0_1<x10_int, x10_char>::itable<String> String::_itable_Fun_0_1(&String::apply, &String::at, &String::at, &String::equals, &String::hashCode, &String::home, &String::toString, &String::typeName); - -x10aux::itable_entry String::_itables[2] = { +Comparable<ref<String> >::itable<String> String::_itable_Comparable(&String::at, &String::at, &String::compareTo, + &String::equals, &String::hashCode, + &String::home, &String::toString, &String::typeName); + +x10aux::itable_entry String::_itables[3] = { x10aux::itable_entry(&Fun_0_1<x10_int, x10_char>::rtt, &String::_itable_Fun_0_1), + x10aux::itable_entry(&Comparable<ref<String> >::rtt, &String::_itable_Comparable), x10aux::itable_entry(NULL, (void*)x10aux::getRTT<String>()) }; Modified: trunk/x10.runtime/src-cpp/x10/lang/String.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/String.h 2010-03-10 17:07:38 UTC (rev 13326) +++ trunk/x10.runtime/src-cpp/x10/lang/String.h 2010-03-10 17:55:49 UTC (rev 13327) @@ -19,6 +19,7 @@ #include <x10/lang/Object.h> #include <x10/lang/Fun_0_1.h> +#include <x10/lang/Comparable.h> #ifdef __CYGWIN__ extern "C" char *strdup (const char *); @@ -42,8 +43,9 @@ RTT_H_DECLS_CLASS; - static Fun_0_1<x10_int/*nat*/, x10_char>::itable<String> _itable_Fun_0_1; - static x10aux::itable_entry _itables[2]; + static Fun_0_1<x10_int, x10_char>::itable<String> _itable_Fun_0_1; + static Comparable<x10aux::ref<String> >::itable<String> _itable_Comparable; + static x10aux::itable_entry _itables[3]; virtual x10aux::itable_entry* _getITables() { return _itables; } // Set steal to true if you have just allocated the char * with @@ -142,6 +144,16 @@ virtual x10_boolean equals(x10aux::ref<x10::lang::Any> p0); + x10_boolean equalsIgnoreCase(x10aux::ref<x10::lang::String> s); + + x10aux::ref<String> toLowerCase(); + + x10aux::ref<String> toUpperCase(); + + x10_int compareTo(x10aux::ref<x10::lang::String> s); + + x10_int compareToIgnoreCase(x10aux::ref<x10::lang::String> s); + String () : FMGL(content)(NULL) { } virtual ~String () { x10aux::dealloc(FMGL(content)); Modified: trunk/x10.runtime/src-cpp/x10aux/char_utils.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/char_utils.cc 2010-03-10 17:07:38 UTC (rev 13326) +++ trunk/x10.runtime/src-cpp/x10aux/char_utils.cc 2010-03-10 17:55:49 UTC (rev 13327) @@ -31,8 +31,7 @@ } x10_boolean x10aux::char_utils::isTitleCase(x10_char x) { - (void) x; - assert(false); /* FIXME: STUBBED NATIVE */ + /* FIXME: Proper title case support */ return false; } @@ -96,12 +95,7 @@ } x10_char x10aux::char_utils::toTitleCase(x10_char x) { - (void) x; - assert(false); /* FIXME: STUBBED NATIVE */ - return x; + /* FIXME: Proper title case support */ + return toUpperCase(x); } - -x10_char x10aux::char_utils::reverseBytes(x10_char x) { - return ((x.v&0x00FF)<<8)|((x.v&0xFF00)>>8); -} // vim:tabstop=4:shiftwidth=4:expandtab Modified: trunk/x10.runtime/src-x10/x10/lang/Any.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Any.x10 2010-03-10 17:07:38 UTC (rev 13326) +++ trunk/x10.runtime/src-x10/x10/lang/Any.x10 2010-03-10 17:55:49 UTC (rev 13327) @@ -26,10 +26,15 @@ */ @NativeRep("java", "java.lang.Object", null, null) @NativeRep("c++", "x10aux::ref<x10::lang::Any>", "x10::lang::Any", null) -public interface Any( @Native("java", "x10.lang.Place.place(x10.core.Ref.home(#0))") - @Native("c++", - "x10::lang::Place_methods::place(x10aux::get_location(#0))") - home: Place) { +public interface Any( + /** + * The home location of this entity. + * This will be 'here' for non-object entities. + */ + @Native("java", "x10.lang.Place.place(x10.core.Ref.home(#0))") + @Native("c++", "x10::lang::Place_methods::place(x10aux::get_location(#0))") + home: Place +) { /** * Return the home location of this entity. Modified: trunk/x10.runtime/src-x10/x10/lang/Comparable.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Comparable.x10 2010-03-10 17:07:38 UTC (rev 13326) +++ trunk/x10.runtime/src-x10/x10/lang/Comparable.x10 2010-03-10 17:55:49 UTC (rev 13327) @@ -11,6 +11,7 @@ package x10.lang; +// FIXME: fold into Ordered[T] /** * This interface imposes a total ordering on the entities of each type that implements it. * @@ -35,7 +36,7 @@ * @return a negative integer, zero, or a positive integer if this entity is less than, equal * to, or greater than the given entity. */ - def compareTo(that:T):Int; + global def compareTo(that:T):Int; } // vim:shiftwidth=4:tabstop=4:expandtab Modified: trunk/x10.runtime/src-x10/x10/lang/Point.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Point.x10 2010-03-10 17:07:38 UTC (rev 13326) +++ trunk/x10.runtime/src-x10/x10/lang/Point.x10 2010-03-10 17:55:49 UTC (rev 13327) @@ -11,6 +11,8 @@ package x10.lang; +import x10.util.Ordered; + /** * The type <code>Point(rank)</code> represents a point in a * rank-dimensional space. The coordiIntes of a point <code>p</code> @@ -22,7 +24,7 @@ * @author bdlucas * @author vj */ -final public class Point(rank: Int) implements (Int) => Int { +final public class Point(rank: Int) implements (Int) => Int, Ordered[Point(rank)] { /** * Returns the value of the ith coordiInte. Modified: trunk/x10.runtime/src-x10/x10/lang/String.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/String.x10 2010-03-10 17:07:38 UTC (rev 13326) +++ trunk/x10.runtime/src-x10/x10/lang/String.x10 2010-03-10 17:55:49 UTC (rev 13327) @@ -13,80 +13,379 @@ import x10.compiler.Native; import x10.compiler.NativeRep; +import x10.util.Ordered; -// TODO: comparison operators +/** + * The String class represents character strings. + * All string literals in X10 programs, such as "Hello", are instances of String. + * Strings are immutable and cannot be changed after they are created. + * + * String provides a concatenation operator '+', methods for converting + * instances of other types to strings (which invoke the + * {@link x10.lang.Any#toString()} method), methods for examining individual + * characters of the sequence, for searching strings, for comparing + * strings, for extracting substrings, and for creating a copy of a string + * with all characters translated to uppercase or to lowercase. Case mapping + * is defined in {@link x10.lang.Char}. + */ @NativeRep("java", "java.lang.String", "x10.core.BoxedString", null) @NativeRep("c++", "x10aux::ref<x10::lang::String>", "x10::lang::String", null) -public final class String implements (Int) => Char { - // TODO: constructors +public final class String implements (Int) => Char/*TODO, (Range) => String*//*TODO, Ordered[String]*/, Comparable[String] { + /** + * Default constructor. + */ public native def this(): String; + + /** + * Copy constructor. + */ public native def this(String): String; - + + + /** + * Return true if the given entity is a String, and this String is equal + * to the given entity. + * @param x the given entity + * @return true if this String is equal to the given entity. + */ @Native("java", "(#0).equals(#1)") @Native("c++", "x10aux::equals(#0,#1)") public native global safe def equals(Any): boolean; - + + // FIXME: Locale sensitivity + /** + * Returns true if this String is equal to the given String, ignoring case considerations. + * @param x the given String + * @return true if this String is equal to the given String ignoring case. + */ + @Native("java", "(#0).equalsIgnoreCase(#1)") + @Native("c++", "(#0)->equalsIgnoreCase(#1)") + public native global def equalsIgnoreCase(String): boolean; + + /** + * Returns a hash code for this String. + * The hash code for a String object is computed as + * <pre> + * s(0).ord()*31^(n-1) + s(1).ord()*31^(n-2) + ... + s(n-1).ord() + * </pre> + * using integer arithmetic, where s(i) is the ith character of the string, + * n is the length of the string, and ^ indicates exponentiation. + * (The hash value of the empty string is zero.) + * @return a hash code value for this String. + */ @Native("java", "(#0).hashCode()") @Native("c++", "x10aux::hash_code(#0)") public native global safe def hashCode(): int; - + + + /** + * Returns this String. + * @return the String itself. + */ @Native("java", "(#0).toString()") @Native("c++", "x10aux::to_string(#0)") public native global safe def toString(): String; - - @Native("java", "#0.length()") - @Native("c++", "#0->length()") + + + /** + * Returns the length of this String. + * @return the length of this String. + */ + @Native("java", "(#0).length()") + @Native("c++", "(#0)->length()") public native global def length(): Int; - + + /** + * Returns the Char at the specified index in this String. + * An index ranges from 0 to length()-1. + * @param index the index of the Char + * @return the Char at the specified (0-based) index of this String. + * @see #charAt(Int) + */ @Native("java", "(#0).charAt(#1)") @Native("c++", "(#0)->charAt(#1)") public native global def apply(index: Int): Char; + /** + * Returns the Char at the specified index in this String. + * An index ranges from 0 to length()-1. + * @param index the index of the Char + * @return the Char at the specified (0-based) index of this String. + * @see #apply(Int) + */ @Native("java", "(#0).charAt(#1)") @Native("c++", "(#0)->charAt(#1)") public native global def charAt(index: Int): Char; - - @Native("java", "x10.core.RailFactory.<java.lang.Character>makeValRailFromJavaArray(#0.toCharArray())") + + /** + * Converts this String to a ValRail of Chars. + * @return a ValRail of Chars whose length is the length of this String and + * whose contents are initialized to contain the Chars in this String. + * @see #bytes() + */ + @Native("java", "x10.core.RailFactory.<java.lang.Character>makeValRailFromJavaArray((#0).toCharArray())") @Native("c++", "(#0)->chars()") public native global def chars(): ValRail[Char]; - - @Native("java", "x10.core.RailFactory.<java.lang.Byte>makeValRailFromJavaArray(#0.getBytes())") + + /** + * Encodes this String into a sequence of Bytes using the platform's default charset. + * @return the ValRail of Bytes representing this String in the default charset. + * @see #chars() + */ + @Native("java", "x10.core.RailFactory.<java.lang.Byte>makeValRailFromJavaArray((#0).getBytes())") @Native("c++", "(#0)->bytes()") public native global def bytes(): ValRail[Byte]; - - @Native("java", "#0.substring(#1, #2)") + + /** + * Returns a new String that is a substring of this String. + * The substring begins at the specified fromIndex and extends to the Char at index toIndex-1. + * Thus the length of the substring is toIndex-fromIndex. + * @param fromIndex the starting index, inclusive + * @param toIndex the ending index, exclusive + * @return the specified substring. + */ + @Native("java", "(#0).substring(#1, #2)") @Native("c++", "(#0)->substring(#1, #2)") public native global def substring(fromIndex: Int, toIndex: Int): String; - - @Native("java", "#0.indexOf(#1)") + + + /** + * Returns the index within this String of the first occurrence of the specified Char ch. + * If the Char ch occurs in this String, then the index of the first such occurrence is returned. + * This index is the smallest value k such that: + * <pre> + * this(k) == ch + * </pre> + * is true. + * If no such Char occurs in this String, then -1 is returned. + * @param ch the given Char + * @return the index of the first occurrence of the Char in this String, or -1 if the Char does not occur. + * @see #indexOf(String) + * @see #lastIndexOf(Char) + */ + @Native("java", "(#0).indexOf(#1)") @Native("c++", "(#0)->indexOf(#1)") - public native global def indexOf(Char): Int; - - @Native("java", "#0.indexOf(#1)") + public native global def indexOf(ch: Char): Int; + + /** + * Returns the index within this String of the first occurrence of the specified substring. + * The Int returned is the smallest value k such that + * <pre> + * this.substring(k, k+str.length()).equals(str) + * </pre> + * is true. + * @param str the substring to search for + * @return if the String argument occurs as a substring within this object, + * then the index of the first character of the first such substring + * is returned. If it does not occur as a substring, -1 is returned. + * @see #indexOf(Char) + * @see #lastIndexOf(String) + */ + @Native("java", "(#0).indexOf(#1)") @Native("c++", "(#0)->indexOf(#1)") - public native global def indexOf(String): Int; - - @Native("java", "#0.lastIndexOf(#1)") + public native global def indexOf(str: String): Int; + + /** + * Returns the index within this String of the last occurrence of the specified Char ch. + * If the Char ch occurs in this String, then the index of the last such occurrence is returned. + * This index is the largest value k such that: + * <pre> + * this(k) == ch + * </pre> + * is true. + * If no such Char occurs in this String, then -1 is returned. + * The String is searched backwards starting at the last Char. + * @param ch the given Char + * @return the index of the last occurrence of the Char in this String, or -1 if the Char does not occur. + * @see #lastIndexOf(String) + * @see #indexOf(Char) + */ + @Native("java", "(#0).lastIndexOf(#1)") @Native("c++", "(#0)->lastIndexOf(#1)") - public native global def lastIndexOf(Char): Int; + public native global def lastIndexOf(ch: Char): Int; - @Native("java", "#0.lastIndexOf(#1)") + /** + * Returns the index within this String of the rightmost occurrence of the specified substring. + * The rightmost empty string "" is considered to occur at the index value this.length(). + * The returned index is the largest value k such that + * <pre> + * this.substring(k, k+str.length()).equals(str) + * </pre> + * is true. + * @param str the substring to search for + * @return if the String argument occurs one or more times as a substring + * within this object, then the index of the first character of the + * last such substring is returned. If it does not occur as a + * substring, -1 is returned. + * @see #lastIndexOf(Char) + * @see #indexOf(String) + */ + @Native("java", "(#0).lastIndexOf(#1)") @Native("c++", "(#0)->lastIndexOf(#1)") - public native global def lastIndexOf(String): Int; + public native global def lastIndexOf(str: String): Int; - @Native("java", "x10.core.RailFactory.makeValRailFromJavaArray(#0.split(#1))") + + /** + * Splits this String around matches of the given regular expression. + * Trailing empty strings are not included in the resulting ValRail. + * @param regex the delimiting regular expression. + * @return the ValRail of Strings computed by splitting this String around matches of the given regular expression. + */ + @Native("java", "x10.core.RailFactory.makeValRailFromJavaArray((#0).split(#1))") @Native("c++", "(#0)->split(#1)") - public native global def split(String): ValRail[String]; + public native global def split(regex: String): ValRail[String]; + + /** + * Returns the String representation of the given entity. + * The representation is exactly the one returned by the toString() method of the entity. + * @param v the given entity + * @return a String representation of the given entity. + */ @Native("java", "java.lang.String.valueOf(#4)") @Native("c++", "x10aux::safe_to_string(#4)") - public native static def valueOf[T](T):String; - - @Native("java", "java.lang.String.format(#1, #2.getBoxedArray())") + public native static def valueOf[T](v: T): String; + + + /** + * Returns a formatted String using the specified format String and arguments. + * The only format specifiers supported at the moment are those common to Java's String.format() and C++'s printf. + * If there are more arguments than format specifiers, the extra arguments are ignored. + * The number of arguments is variable and may be zero. + * The behaviour on a null argument depends on the conversion. + * @param fmt the format String + * @param args the arguments referenced by the format specifiers in the format string. + * @return a formatted string. + */ + @Native("java", "java.lang.String.format(#1,(#2).getBoxedArray())") @Native("c++", "x10::lang::String::format(#1,#2)") - public native static def format(fmt: String, Rail[Any]): String; - - @Native("java", "java.lang.String.format(#1, #2.getBoxedArray())") - @Native("c++", "x10::lang::String::format(#1,#2)") - public native static def format(fmt: String, ValRail[Any]): String; + public native static def format(fmt: String, args: ValRail[Any]): String; + + + // FIXME: Locale sensitivity + /** + * Converts all of the Chars in this String to lower case. + * @return this String, converted to lowercase. + */ + @Native("java", "(#0).toLowerCase()") + @Native("c++", "(#0)->toLowerCase()") + public native global def toLowerCase(): String; + + // FIXME: Locale sensitivity + /** + * Converts all of the Chars in this String to upper case. + * @return this String, converted to uppercase. + */ + @Native("java", "(#0).toUpperCase()") + @Native("c++", "(#0)->toUpperCase()") + public native global def toUpperCase(): String; + + + /** + * Compares this String with another String lexicographically. + * The result is a negative integer if this String lexicographically precedes the argument String. + * The result is a positive integer if this String lexicographically follows the argument String. + * The result is zero if the Strings are equal; compareTo returns 0 exactly when the equals(Any) method would return true. + * <p/> + * This method compares the Chars in this String and the argument String at all indexes from 0 to the length of the shorter of the two strings. + * If the Chars at some index k are not equal, the method returns the difference in ordinal values of those Chars: + * <pre> + * this(k).ord() - arg(k).ord() + * </pre> + * If there is no index position at which the Chars differ, then the method returns the difference of the lengths of the two strings: + * <pre> + * this.length() - arg.length() + * </pre> + * @param arg the argument String + * @return 0 if the argument String is equal to this String; a negative Int if this String is lexicographically less than the argument String; and a positive Int if this String is lexicographically greater than the argument String. + */ + @Native("java", "(#0).compareTo(#1)") + @Native("c++", "(#0)->compareTo(#1)") + public native global def compareTo(arg: String): Int; + + // FIXME: Locale sensitivity + /** + * Compares this String with another String lexicographically, ignoring case differences. + * This method returns an integer whose sign is that of calling {@link #compareTo(String)} + * with normalized versions of the Strings where case differences have been eliminated, + * e.g., by calling s.toLowerCase().toUpperCase() on each String. + * @param arg the argument String + * @return a negative Int, zero, or a positive Int as the argument String is greater than, equal to, or less than this String, ignoring case considerations. + */ + @Native("java", "(#0).compareToIgnoreCase(#1)") + @Native("c++", "(#0)->compareToIgnoreCase(#1)") + public native global def compareToIgnoreCase(arg: String): Int; + + + // FIXME: Locale sensitivity + /** + * A less-than operator. + * Compares this String with another String and returns true if this String is + * strictly before the other String in dictionary order. + * @param x the other String + * @return true if this String is strictly before the other String. + */ + @Native("java", "((#0).compareTo(#1) < 0)") + @Native("c++", "((#0)->compareTo(#1) < 0)") + public native global safe operator this < (x:String): Boolean; + + // FIXME: Locale sensitivity + /** + * A greater-than operator. + * Compares this String with another String and returns true if this String is + * strictly after the other String in dictionary order. + * @param x the other String + * @return true if this String is strictly after the other String. + */ + @Native("java", "((#0).compareTo(#1) > 0)") + @Native("c++", "((#0)->compareTo(#1) > 0)") + public native global safe operator this > (x:String): Boolean; + + // FIXME: Locale sensitivity + /** + * A less-than-or-equal-to operator. + * Compares this String with another String and returns true if this String is + * equal to the other String or is before it in dictionary order. + * @param x the other String + * @return true if this String is before or equal to the other String. + */ + @Native("java", "((#0).compareTo(#1) <= 0)") + @Native("c++", "((#0)->compareTo(#1) <= 0)") + public native global safe operator this <= (x:String): Boolean; + + // FIXME: Locale sensitivity + /** + * A greater-than-or-equal-to operator. + * Compares this String with another String and returns true if this String is + * equal to the other String or is after it in dictionary order. + * @param x the other String + * @return true if this String is after or equal to the other String. + */ + @Native("java", "((#0).compareTo(#1) >= 0)") + @Native("c++", "((#0)->compareTo(#1) >= 0)") + public native global safe operator this >= (x:String): Boolean; + + /** + * A string concatenation operator. + * Appends the given entity to the given String by calling the entity's + * {@link x10.lang.Any#toString()} method. + * @param x the given String + * @param y the given entity + * @return the resulting String + */ + @Native("java", "((#4) + (#5))") + @Native("c++", "((#4) + (#5))") + public native static safe operator[T] (x:String) + (y:T): String; + + /** + * A string concatenation operator. + * Prepends the given entity to the given String by calling the entity's + * {@link x10.lang.Any#toString()} method. + * @param x the given entity + * @param y the given String + * @return the resulting String + */ + @Native("java", "((#4) + (#5))") + @Native("c++", "((#4) + (#5))") + public native static safe operator[T] (x:T) + (y:String): String; } Modified: trunk/x10.runtime/src-x10/x10/util/Ordered.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/util/Ordered.x10 2010-03-10 17:07:38 UTC (rev 13326) +++ trunk/x10.runtime/src-x10/x10/util/Ordered.x10 2010-03-10 17:55:49 UTC (rev 13327) @@ -24,7 +24,7 @@ * @param that the other entity * @return true if the current entity is strictly less than the other entity. */ - operator this < (that: T): Boolean; + global operator this < (that: T): Boolean; /** * A binary greater-than operator. * Compares the two operands and returns true if the left-hand operand @@ -33,7 +33,7 @@ * @param that the other entity * @return true if the current entity is strictly greater than the other entity. */ - operator this > (that: T): Boolean; + global operator this > (that: T): Boolean; /** * A binary less-than-or-equal-to operator. * Compares the two operands and returns true if the left-hand operand @@ -42,7 +42,7 @@ * @param that the other entity * @return true if the current entity is less than or equal to the other entity. */ - operator this <= (that: T): Boolean; + global operator this <= (that: T): Boolean; /** * A binary greater-than-or-equal-to operator. * Compares the two operands and returns true if the left-hand operand @@ -51,5 +51,5 @@ * @param that the other entity * @return true if the current entity is greater than or equal to the other entity. */ - operator this >= (that: T): Boolean; + global operator this >= (that: T): Boolean; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ipe...@us...> - 2010-03-11 00:28:31
|
Revision: 13336 http://x10.svn.sourceforge.net/x10/?rev=13336&view=rev Author: ipeshansky Date: 2010-03-11 00:28:23 +0000 (Thu, 11 Mar 2010) Log Message: ----------- Fix XTENLANG-1141. Add test case for sending remote references home. Modified Paths: -------------- trunk/x10.compiler/src/x10cpp/visit/Emitter.java trunk/x10.runtime/src-cpp/x10/lang/Object.h trunk/x10.runtime/src-cpp/x10/lang/Rail.h trunk/x10.runtime/src-cpp/x10/lang/String.h trunk/x10.runtime/src-cpp/x10/lang/ValRail.h trunk/x10.runtime/src-cpp/x10aux/serialization.cc trunk/x10.runtime/src-cpp/x10aux/serialization.h trunk/x10.tests/examples/Constructs/References/RemoteRefEquality.x10 Added Paths: ----------- trunk/x10.tests/examples/Constructs/References/MultiRefRoundtrip.x10 Modified: trunk/x10.compiler/src/x10cpp/visit/Emitter.java =================================================================== --- trunk/x10.compiler/src/x10cpp/visit/Emitter.java 2010-03-10 23:52:21 UTC (rev 13335) +++ trunk/x10.compiler/src/x10cpp/visit/Emitter.java 2010-03-11 00:28:23 UTC (rev 13336) @@ -1034,7 +1034,7 @@ sw.write("this_ = "+klass+"::"+template+DESERIALIZER_METHOD+chevrons(klass)+"(buf);"); sw.end(); sw.newline(); sw.writeln("}"); - sw.write("return x10::lang::Object::_finalize_reference"+chevrons("__T")+"(this_, rr);"); + sw.write("return x10::lang::Object::_finalize_reference"+chevrons("__T")+"(this_, rr, buf);"); sw.end(); sw.newline(); sw.writeln("}"); sw.forceNewline(); sw.popCurrentStream(); Modified: trunk/x10.runtime/src-cpp/x10/lang/Object.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Object.h 2010-03-10 23:52:21 UTC (rev 13335) +++ trunk/x10.runtime/src-cpp/x10/lang/Object.h 2010-03-11 00:28:23 UTC (rev 13336) @@ -90,7 +90,7 @@ // A helper method for computing the final deserialized reference // res is ignored if rr.ref is null, and could even be uninitialized // res is freed if rr.loc is here - template<class R> static x10aux::ref<R> _finalize_reference(x10aux::ref<Object> res, Object::_reference_state rr); + template<class R> static x10aux::ref<R> _finalize_reference(x10aux::ref<Object> res, Object::_reference_state rr, x10aux::deserialization_buffer &buf); virtual void _deserialize_body(x10aux::deserialization_buffer &buf) { } @@ -141,19 +141,21 @@ res = x10aux::DeserializationDispatcher::create<T>(buf, id); } // res is uninitialized if rr.ref is null - return _finalize_reference<T>(res, rr); + return _finalize_reference<T>(res, rr, buf); } // Given a deserialized object pointer (allocated with alloc_remote) and // remote reference info, return the reference to the right object - template<class R> x10aux::ref<R> Object::_finalize_reference(x10aux::ref<Object> obj, Object::_reference_state rr) { + template<class R> x10aux::ref<R> Object::_finalize_reference(x10aux::ref<Object> obj, Object::_reference_state rr, x10aux::deserialization_buffer &buf) { if (rr.ref == 0) { return x10aux::null; } if (rr.loc == x10aux::here) { // a remote object coming home to roost _S_("\ta local object come home"); + x10aux::ref<R> ret = static_cast<R*>((void*)(size_t)rr.ref); + buf.update_reference(x10aux::ref<R>(obj), ret); x10aux::dealloc_remote(obj.operator->()); - return static_cast<R*>((void*)(size_t)rr.ref); + return ret; } _S_("Deserialized a "<<ANSI_SER<<ANSI_BOLD<<"class"<<ANSI_RESET<< " "<<obj->_type()->name()); Modified: trunk/x10.runtime/src-cpp/x10/lang/Rail.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Rail.h 2010-03-10 23:52:21 UTC (rev 13335) +++ trunk/x10.runtime/src-cpp/x10/lang/Rail.h 2010-03-11 00:28:23 UTC (rev 13336) @@ -830,7 +830,7 @@ if (rr.ref != 0) { this_ = Rail<T>::template _deserializer<Rail<T> >(buf); } - return Object::_finalize_reference<T>(this_, rr); + return Object::_finalize_reference<S>(this_, rr, buf); } } } Modified: trunk/x10.runtime/src-cpp/x10/lang/String.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/String.h 2010-03-10 23:52:21 UTC (rev 13335) +++ trunk/x10.runtime/src-cpp/x10/lang/String.h 2010-03-11 00:28:23 UTC (rev 13336) @@ -194,7 +194,7 @@ if (rr.ref != 0) { this_ = String::_deserializer<String>(buf); } - return Object::_finalize_reference<T>(this_, rr); + return Object::_finalize_reference<T>(this_, rr, buf); } } // namespace x10::lang Modified: trunk/x10.runtime/src-cpp/x10/lang/ValRail.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/ValRail.h 2010-03-10 23:52:21 UTC (rev 13335) +++ trunk/x10.runtime/src-cpp/x10/lang/ValRail.h 2010-03-11 00:28:23 UTC (rev 13336) @@ -255,7 +255,7 @@ if (rr.ref != 0) { this_ = ValRail<T>::template _deserializer<ValRail<T> >(buf); } - return Object::_finalize_reference<T>(this_, rr); + return Object::_finalize_reference<S>(this_, rr, buf); } } } Modified: trunk/x10.runtime/src-cpp/x10aux/serialization.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/serialization.cc 2010-03-10 23:52:21 UTC (rev 13335) +++ trunk/x10.runtime/src-cpp/x10aux/serialization.cc 2010-03-11 00:28:23 UTC (rev 13336) @@ -44,6 +44,14 @@ return _ptrs[_top+pos]; } +const void* addr_map::_set(int pos, const void* ptr) { + if (pos < -_top || pos >= 0) + return NULL; + const void* old = _ptrs[_top+pos]; + _ptrs[_top+pos] = ptr; + return old; +} + int addr_map::_position(const void* p) { int pos = _find(p); if (pos != 0) { Modified: trunk/x10.runtime/src-cpp/x10aux/serialization.h =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/serialization.h 2010-03-10 23:52:21 UTC (rev 13335) +++ trunk/x10.runtime/src-cpp/x10aux/serialization.h 2010-03-11 00:28:23 UTC (rev 13336) @@ -148,6 +148,7 @@ void _add(const void* ptr); int _find(const void* ptr); const void* _get(int pos); + const void* _set(int pos, const void* ptr); int _position(const void* p); public: addr_map(int init_size = 4) : @@ -171,6 +172,11 @@ _S_("\t\tRetrieving repeated reference "<<((void*) val)<<" of type "<<ANSI_SER<<ANSI_BOLD<<TYPENAME(T)<<ANSI_RESET<<" at "<<(_top+pos)<<" (absolute) in map: "<<this); return ref<T>(val); } + template<class T> ref<T> set_at_position(int pos, ref<T> newval) { + T* val = (T*)_set(pos, newval.operator->()); + _S_("\t\tReplacing repeated reference "<<((void*) val)<<" of type "<<ANSI_SER<<ANSI_BOLD<<TYPENAME(T)<<ANSI_RESET<<" at "<<(_top+pos)<<" (absolute) in map: "<<this<<" by "<<((void*) newval.operator->())); + return ref<T>(val); + } void reset() { _top = 0; assert (false); } ~addr_map() { x10aux::dealloc(_ptrs); } }; @@ -334,6 +340,8 @@ // before the rest of the object is deserialized! template<typename T> bool record_reference(ref<T> ref); + template<typename T> void update_reference(ref<T> ref, ref<T> newref); + // So it can access the addr_map template<class T> friend struct Read; }; @@ -345,6 +353,14 @@ } return !pos; } + + template<typename T> void deserialization_buffer::update_reference(ref<T> ref, ref<T> newref) { + int pos = map.previous_position(ref); + if (pos == 0) { + _S_("\t"<<ANSI_SER<<ANSI_BOLD<<"OOPS!"<<ANSI_RESET<<" Attempting to update a nonexistent reference "<<((void*)ref.operator->())<<" in buf: "<<this); + } + map.set_at_position(pos, newref); + } // Case for non-refs (includes simple primitives like x10_int and all structs) template<class T> struct deserialization_buffer::Read { Added: trunk/x10.tests/examples/Constructs/References/MultiRefRoundtrip.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/References/MultiRefRoundtrip.x10 (rev 0) +++ trunk/x10.tests/examples/Constructs/References/MultiRefRoundtrip.x10 2010-03-11 00:28:23 UTC (rev 13336) @@ -0,0 +1,35 @@ +/* + * 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; + +/** + * Sending two remote references back to their home place should work. + * @author igor 03/2010 + */ +class MultiRefRoundtrip extends x10Test { + + public def run(): boolean { + chk(Place.places.length > 1, "This test must be run with multiple places"); + val local = new MultiRefRoundtrip(); + val second = local; + at (here.next()) { + at (local) { + Console.OUT.println(local == second); + } + } + return at (here.next()) at (local) second == local; + } + + public static def main(Rail[String]) { + new MultiRefRoundtrip().execute(); + } +} Property changes on: trunk/x10.tests/examples/Constructs/References/MultiRefRoundtrip.x10 ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Modified: trunk/x10.tests/examples/Constructs/References/RemoteRefEquality.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/References/RemoteRefEquality.x10 2010-03-10 23:52:21 UTC (rev 13335) +++ trunk/x10.tests/examples/Constructs/References/RemoteRefEquality.x10 2010-03-11 00:28:23 UTC (rev 13336) @@ -13,7 +13,7 @@ /** * Two remote references to the same object must be equal. - * @author igor 06/2009 + * @author igor 03/2010 */ class RemoteRefEquality extends x10Test { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dgr...@us...> - 2010-03-11 13:56:27
|
Revision: 13349 http://x10.svn.sourceforge.net/x10/?rev=13349&view=rev Author: dgrove-oss Date: 2010-03-11 13:56:21 +0000 (Thu, 11 Mar 2010) Log Message: ----------- svn housekeeping: the SafeX10 work is being done on a branch; the code in trunk is obsolete. Removed Paths: ------------- trunk/SafeX10/ trunk/x10.effects/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dgr...@us...> - 2010-03-12 15:41:27
|
Revision: 13365 http://x10.svn.sourceforge.net/x10/?rev=13365&view=rev Author: dgrove-oss Date: 2010-03-12 15:41:21 +0000 (Fri, 12 Mar 2010) Log Message: ----------- Move tutorial samples out of x10.test and into x10.dist/samples/tutorial. Will add x10Test wrappers into examples/Tutorial to actually run the tests in a subsequent test. Added Paths: ----------- trunk/x10.dist/samples/tutorial/ trunk/x10.dist/samples/tutorial/Fib.x10 trunk/x10.dist/samples/tutorial/HeatTransfer_v1.x10 trunk/x10.dist/samples/tutorial/HeatTransfer_v2.x10 trunk/x10.dist/samples/tutorial/HeatTransfer_v3.x10 trunk/x10.dist/samples/tutorial/HeatTransfer_v4.x10 trunk/x10.dist/samples/tutorial/HeatTransfer_v5.x10 trunk/x10.dist/samples/tutorial/HelloWorldPar.x10 trunk/x10.dist/samples/tutorial/Integrate.x10 Removed Paths: ------------- trunk/x10.tests/examples/Tutorial/Fib.x10 trunk/x10.tests/examples/Tutorial/HeatTransfer_v1.x10 trunk/x10.tests/examples/Tutorial/HeatTransfer_v2.x10 trunk/x10.tests/examples/Tutorial/HeatTransfer_v3.x10 trunk/x10.tests/examples/Tutorial/HeatTransfer_v4.x10 trunk/x10.tests/examples/Tutorial/HeatTransfer_v5.x10 trunk/x10.tests/examples/Tutorial/HelloWorldPar.x10 trunk/x10.tests/examples/Tutorial/Integrate.x10 Copied: trunk/x10.dist/samples/tutorial/Fib.x10 (from rev 13362, trunk/x10.tests/examples/Tutorial/Fib.x10) =================================================================== --- trunk/x10.dist/samples/tutorial/Fib.x10 (rev 0) +++ trunk/x10.dist/samples/tutorial/Fib.x10 2010-03-12 15:41:21 UTC (rev 13365) @@ -0,0 +1,63 @@ +/* + * 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.io.Console; + +/** + * This is a small program to illustrate the use of + * <code>async</code> and <code>finish</code> in a + * prototypical recursive divide-and-conquer algorithm. + * It is obviously not intended to show a efficient way to + * compute Fibonacci numbers in X10.<p> + * + * The heart of the example is the <code>run</code> method, + * which directly embodies the recursive definition of + * <pre> + * Fib(n) = Fib(n-1)+Fib(n- + * </pre> + * by using an <code>async</code> to compute <code>Fib(n-1)</code> while + * the current activity computes <code>Fib(n-2)</code>. A <code>finish</code> + * is used to ensure that both computations are complete before + * their results are added together to compute <code>Fib(n)</code> + */ +public class Fib { + /** + * Used as an in-out parameter to the computation. + * When the Fib object is created, r indicates the number to compute. + * After the computation has completed, r holds the result (Fib(r)). + */ + var r:int; + + public def this(x:int) { + r = x; + } + + public def run() { + if (r<2) return; // r already contains Fib(r) + + val f1 = new Fib(r-1); + val f2 = new Fib(r-2); + finish { + async f1.run(); + f2.run(); + } + r = f1.r + f2.r; + } + + public static def main(args:Rail[String]!) { + val n = (args.length > 0) ? int.parse(args(0)) : 10; + Console.OUT.println("Computing Fib("+n+")"); + val f = new Fib(n); + f.run(); + Console.OUT.println("Fib("+n+") = "+f.r); + } +} + Copied: trunk/x10.dist/samples/tutorial/HeatTransfer_v1.x10 (from rev 13362, trunk/x10.tests/examples/Tutorial/HeatTransfer_v1.x10) =================================================================== --- trunk/x10.dist/samples/tutorial/HeatTransfer_v1.x10 (rev 0) +++ trunk/x10.dist/samples/tutorial/HeatTransfer_v1.x10 2010-03-12 15:41:21 UTC (rev 13365) @@ -0,0 +1,75 @@ +/* + * 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. + */ + +/** + * This is one of a series of programs showing how to express + * different forms of parallelism in X10.</p> + * + * All of the example programs in the series are computing + * the same thing: solving a set of 2D partial differential + * equations that can be expressed as an iterative 4-point + * stencil operation. See the X10 2.0 tutorial for + * for more details and some pictures.</p> + * + * This program is illustrating a high-level "ZPL style", where + * the computation is expressed directly in terms of + * fine-grained computation on global arrays.<p> + */ +public class HeatTransfer_v1 { + static type Real=Double; + const n = 3, epsilon = 1.0e-5; + + const BigD = Dist.makeBlock([0..n+1, 0..n+1], 0); + const D = BigD | ([1..n, 1..n] as Region); + const LastRow = [0..0, 1..n] as Region; + const A = Array.make[Real](BigD,(p:Point)=>{ LastRow.contains(p) ? 1.0 : 0.0 }); + const Temp = Array.make[Real](BigD); + + static def stencil_1((x,y):Point(2)) = (([x-1..x+1,y..y] as Region(2)) || [x..x,y-1..y+1]) - [x..x,y..y]; + + static def subtract(a:Array[Real],b:Array[Real]) = Array.make[Real](a.dist, (p:Point)=>a(p as Point(a.rank))-b(p as Point(b.rank))); + + def run() { + var delta:Real = 1.0; + do { + finish ateach (p in D) + Temp(p) = (A | stencil_1(p)).reduce(Double.+, 0.0)/4; + + delta = subtract(A|D.region,Temp|D.region).lift(Math.abs.(Double)).reduce(Math.max.(Double,Double), 0.0); + finish ateach (p in D) A(p) = Temp(p); + } while (delta > epsilon); + } + + def prettyPrintResult() { + for ((i) in A.region.projection(0)) { + for ((j) in A.region.projection(1)) { + val pt = Point.make(i,j); + at (BigD(pt)) { + val tmp = A(pt); + at (Place.FIRST_PLACE) Console.OUT.printf("%1.4f ",tmp); + } + } + Console.OUT.println(); + } + } + + public static def main(Rail[String]) { + Console.OUT.println("HeatTransfer Tutorial example with n="+n+" and epsilon="+epsilon); + Console.OUT.println("Initializing data structures"); + val s = new HeatTransfer_v1(); + Console.OUT.print("Beginning computation..."); + val start = System.nanoTime(); + s.run(); + val stop = System.nanoTime(); + Console.OUT.printf("...completed in %1.3f seconds.\n", (stop-start as double)/1e9); + s.prettyPrintResult(); + } +} Copied: trunk/x10.dist/samples/tutorial/HeatTransfer_v2.x10 (from rev 13362, trunk/x10.tests/examples/Tutorial/HeatTransfer_v2.x10) =================================================================== --- trunk/x10.dist/samples/tutorial/HeatTransfer_v2.x10 (rev 0) +++ trunk/x10.dist/samples/tutorial/HeatTransfer_v2.x10 2010-03-12 15:41:21 UTC (rev 13365) @@ -0,0 +1,77 @@ +/* + * 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. + */ + +/** + * This is one of a series of programs showing how to express + * different forms of parallelism in X10.</p> + * + * All of the example programs in the series are computing + * the same thing: solving a set of 2D partial differential + * equations that can be expressed as an iterative 4-point + * stencil operation. See the X10 2.0 tutorial for + * for more details and some pictures.</p> + * + * This program is illustrating explicit loop chunking to + * coarsen the parallelism at each place (vs HeatTransfer_v1) + * to gain efficiency.<p> + */ +public class HeatTransfer_v2 { + static type Real=Double; + const n = 3, epsilon = 1.0e-5; + + const BigD = Dist.makeBlock([0..n+1, 0..n+1], 0); + const D = BigD | ([1..n, 1..n] as Region); + const LastRow = [0..0, 1..n] as Region; + const A = Array.make[Real](BigD,(p:Point)=>{ LastRow.contains(p) ? 1.0 : 0.0 }); + const Temp = Array.make[Real](BigD); + + static def stencil_1((x,y):Point(2)) = (([x-1..x+1,y..y] as Region(2)) || [x..x,y-1..y+1]) - [x..x,y..y]; + + static def subtract(a:Array[Real],b:Array[Real]) = Array.make[Real](a.dist, (p:Point)=>a(p as Point(a.rank))-b(p as Point(b.rank))); + + def run() { + val D_Base = Dist.makeUnique(D.places()); + var delta:Real = 1.0; + do { + finish ateach (z in D_Base) + for (p:Point(2) in D | here) + Temp(p) = (A | stencil_1(p)).reduce(Double.+, 0.0)/4; + + delta = subtract(A|D.region,Temp|D.region).lift(Math.abs.(Double)).reduce(Math.max.(Double,Double), 0.0); + finish ateach (p in D) A(p) = Temp(p); + } while (delta > epsilon); + } + + def prettyPrintResult() { + for ((i) in A.region.projection(0)) { + for ((j) in A.region.projection(1)) { + val pt = Point.make(i,j); + at (BigD(pt)) { + val tmp = A(pt); + at (Place.FIRST_PLACE) Console.OUT.printf("%1.4f ", tmp); + } + } + Console.OUT.println(); + } + } + + public static def main(Rail[String]) { + Console.OUT.println("HeatTransfer Tutorial example with n="+n+" and epsilon="+epsilon); + Console.OUT.println("Initializing data structures"); + val s = new HeatTransfer_v2(); + Console.OUT.print("Beginning computation..."); + val start = System.nanoTime(); + s.run(); + val stop = System.nanoTime(); + Console.OUT.printf("...completed in %1.3f seconds.\n", (stop-start as double)/1e9); + s.prettyPrintResult(); + } +} Copied: trunk/x10.dist/samples/tutorial/HeatTransfer_v3.x10 (from rev 13362, trunk/x10.tests/examples/Tutorial/HeatTransfer_v3.x10) =================================================================== --- trunk/x10.dist/samples/tutorial/HeatTransfer_v3.x10 (rev 0) +++ trunk/x10.dist/samples/tutorial/HeatTransfer_v3.x10 2010-03-12 15:41:21 UTC (rev 13365) @@ -0,0 +1,106 @@ +/* + * 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. + */ + +/** + * This is one of a series of programs showing how to express + * different forms of parallelism in X10.</p> + * + * All of the example programs in the series are computing + * the same thing: solving a set of 2D partial differential + * equations that can be expressed as an iterative 4-point + * stencil operation. See the X10 2.0 tutorial for + * for more details and some pictures.</p> + * + * This program is illustrating explicit loop chunking + * with hierarchical parallelism. It diverges from the + * presentation in the X10 2.0 tutorial slides because + * the current X10 2.0 array/distribution library doesn't + * provide a built-in function to take a (already block-cyclic) + * distribution and split the points into P sub-regions at each + * place. In this sample, this is done fairly inefficiently + * by the blockIt method, which is actually being invoked in each + * outer iteration of the main do/while loop. For better performance, + * (a) the creation of sub-regions should probably consider locality + * and (b) the sub-region creation should only be done once at each + * place instead of being redone on every loop iteration.<p> + */ +public class HeatTransfer_v3 { + static type Real=Double; + const n = 3; + const epsilon = 1.0e-5; + const P = 2; + + const BigD = Dist.makeBlock([0..n+1, 0..n+1], 0); + const D = BigD | ([1..n, 1..n] as Region); + const LastRow = [0..0, 1..n] as Region; + const A = Array.make[Real](BigD,(p:Point)=>{ LastRow.contains(p) ? 1.0 : 0.0 }); + const Temp = Array.make[Real](BigD); + + static def stencil_1((x,y):Point(2)) = (([x-1..x+1,y..y] as Region(2)) || [x..x,y-1..y+1]) - [x..x,y..y]; + + static def subtract(a:Array[Real],b:Array[Real]) = Array.make[Real](a.dist, (p:Point)=>a(p as Point(a.rank))-b(p as Point(b.rank))); + + // TODO: This is a really inefficient implementation of this abstraction. + // Needs to be done properly and integrated into the Dist/Region/Array + // class library in x10.array. + static def blockIt(d:Dist(2), numProcs:int):ValRail[Iterable[Point(2)]] { + val ans = ValRail.make(numProcs, (int) => new x10.util.ArrayList[Point{self.rank==d.rank}]()); + var modulo:int = 0; + for (p in d) { + ans(modulo).add(p); + modulo = (modulo + 1) % numProcs; + } + return ans; + } + + def run() { + val D_Base = Dist.makeUnique(D.places()); + var delta:Real = 1.0; + do { + finish ateach (z in D_Base) { + val blocks:ValRail[Iterable[Point(2)]] = blockIt(D | here, P); + foreach ((q) in 0..P-1) { + for (p in blocks(q)) { + Temp(p) = (A | stencil_1(p)).reduce(Double.+, 0.0)/4; + } + } + } + + delta = subtract(A|D.region,Temp|D.region).lift(Math.abs.(Double)).reduce(Math.max.(Double,Double), 0.0); + finish ateach (p in D) A(p) = Temp(p); + } while (delta > epsilon); + } + + def prettyPrintResult() { + for ((i) in A.region.projection(0)) { + for ((j) in A.region.projection(1)) { + val pt = Point.make(i,j); + at (BigD(pt)) { + val tmp = A(pt); + at (Place.FIRST_PLACE) Console.OUT.printf("%1.4f ", tmp); + } + } + Console.OUT.println(); + } + } + + public static def main(Rail[String]) { + Console.OUT.println("HeatTransfer Tutorial example with n="+n+" and epsilon="+epsilon); + Console.OUT.println("Initializing data structures"); + val s = new HeatTransfer_v3(); + Console.OUT.print("Beginning computation..."); + val start = System.nanoTime(); + s.run(); + val stop = System.nanoTime(); + Console.OUT.printf("...completed in %1.3f seconds.\n", (stop-start as double)/1e9); + s.prettyPrintResult(); + } +} Copied: trunk/x10.dist/samples/tutorial/HeatTransfer_v4.x10 (from rev 13362, trunk/x10.tests/examples/Tutorial/HeatTransfer_v4.x10) =================================================================== --- trunk/x10.dist/samples/tutorial/HeatTransfer_v4.x10 (rev 0) +++ trunk/x10.dist/samples/tutorial/HeatTransfer_v4.x10 2010-03-12 15:41:21 UTC (rev 13365) @@ -0,0 +1,95 @@ +/* + * 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. + */ + +/** + * This is one of a series of programs showing how to express + * different forms of parallelism in X10.</p> + * + * All of the example programs in the series are computing + * the same thing: solving a set of 2D partial differential + * equations that can be expressed as an iterative 4-point + * stencil operation. See the X10 2.0 tutorial for + * for more details and some pictures.</p> + * + * This program is illustrating an SPMD with all-to-all reduction + * ("MPI-style").</p> + */ +public class HeatTransfer_v4 { + static type Real=Double; + const n = 3, epsilon = 1.0e-5; + + const BigD = Dist.makeBlock([0..n+1, 0..n+1], 0); + const D = BigD | ([1..n, 1..n] as Region); + const LastRow = [0..0, 1..n] as Region; + const A = Array.make[Real](BigD,(p:Point)=>{ LastRow.contains(p) ? 1.0 : 0.0 }); + const Temp = Array.make[Real](BigD); + + static def stencil_1((x,y):Point(2)) = (([x-1..x+1,y..y] as Region(2)) || [x..x,y-1..y+1]) - [x..x,y..y]; + + static def subtract(a:Array[Real],b:Array[Real]) = Array.make[Real](a.dist, (p:Point)=>a(p as Point(a.rank))-b(p as Point(b.rank))); + + // TODO: The array library really should provide an efficient + // all-to-all collective reduction. + // This is a quick and sloppy implementation, which does way too much work. + static def reduceMax(z:Point{self.rank==diff.rank}, diff:Array[Real], scratch:Array[Real]) { + val max = diff.reduce(Math.max.(Double,Double), 0.0); + diff(z) = max; + next; + } + + def run() { + finish async { + val c = Clock.make(); + val D_Base = Dist.makeUnique(D.places()); + val diff = Array.make[Real](D_Base); + val scratch = Array.make[Real](D_Base); + ateach (z in D_Base) clocked(c) { + do { + diff(z) = 0; + for (p:Point(2) in D | here) { + Temp(p) = (A | stencil_1(p)).reduce(Double.+, 0.0)/4; + diff(z) = Math.max(diff(z), Math.abs(A(p) - Temp(p))); + } + next; + for (p:Point(2) in D | here) { + A(p) = Temp(p); + } + reduceMax(z, diff, scratch); + } while (diff(z) > epsilon); + } + } + } + + def prettyPrintResult() { + for ((i) in A.region.projection(0)) { + for ((j) in A.region.projection(1)) { + val pt = Point.make(i,j); + at (BigD(pt)) { + val tmp = A(pt); + at (Place.FIRST_PLACE) Console.OUT.printf("%1.4f ", tmp); + } + } + Console.OUT.println(); + } + } + + public static def main(Rail[String]) { + Console.OUT.println("HeatTransfer Tutorial example with n="+n+" and epsilon="+epsilon); + Console.OUT.println("Initializing data structures"); + val s = new HeatTransfer_v4(); + Console.OUT.print("Beginning computation..."); + val start = System.nanoTime(); + s.run(); + val stop = System.nanoTime(); + Console.OUT.printf("...completed in %1.3f seconds.\n", (stop-start as double)/1e9); + s.prettyPrintResult(); + } +} Copied: trunk/x10.dist/samples/tutorial/HeatTransfer_v5.x10 (from rev 13362, trunk/x10.tests/examples/Tutorial/HeatTransfer_v5.x10) =================================================================== --- trunk/x10.dist/samples/tutorial/HeatTransfer_v5.x10 (rev 0) +++ trunk/x10.dist/samples/tutorial/HeatTransfer_v5.x10 2010-03-12 15:41:21 UTC (rev 13365) @@ -0,0 +1,117 @@ +/* + * 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. + */ + +/** + * This is one of a series of programs showing how to express + * different forms of parallelism in X10.</p> + * + * All of the example programs in the series are computing + * the same thing: solving a set of 2D partial differential + * equations that can be expressed as an iterative 4-point + * stencil operation. See the X10 2.0 tutorial for + * for more details and some pictures.</p> + * + * This program is illustrating an SPMD with all-to-all reduction + * and multiple activities per node ("OpenMP within MPI-style").</p> + */ +public class HeatTransfer_v5 { + static type Real=Double; + const n = 3, epsilon = 1.0e-5; + const P = 1; + + const BigD = Dist.makeBlock([0..n+1, 0..n+1], 0); + const D = BigD | ([1..n, 1..n] as Region); + const LastRow = [0..0, 1..n] as Region; + const A = Array.make[Real](BigD,(p:Point)=>{ LastRow.contains(p) ? 1.0 : 0.0 }); + const Temp = Array.make[Real](BigD); + + static def stencil_1((x,y):Point(2)) = (([x-1..x+1,y..y] as Region(2)) || [x..x,y-1..y+1]) - [x..x,y..y]; + + static def subtract(a:Array[Real],b:Array[Real]) = Array.make[Real](a.dist, (p:Point)=>a(p as Point(a.rank))-b(p as Point(b.rank))); + + // TODO: The array library really should provide an efficient + // all-to-all collective reduction. + // This is a quick and sloppy implementation, which does way too much work. + static def reduceMax(z:Point{self.rank==diff.rank}, diff:Array[Real], scratch:Array[Real]) { + val max = diff.reduce(Math.max.(Double,Double), 0.0); + diff(z) = max; + next; + } + + // TODO: This is a really inefficient implementation of this abstraction. + // Needs to be done properly and integrated into the Dist/Region/Array + // class library in x10.array. + static def blockIt(d:Dist(2), numProcs:int):ValRail[Iterable[Point(2)]] { + val ans = ValRail.make(numProcs, (int) => new x10.util.ArrayList[Point{self.rank==d.rank}]()); + var modulo:int = 0; + for (p in d) { + ans(modulo).add(p); + modulo = (modulo + 1) % numProcs; + } + return ans; + } + + def run() { + finish async { + val c = Clock.make(); + val D_Base = Dist.makeUnique(D.places()); + val diff = Array.make[Real](D_Base); + val scratch = Array.make[Real](D_Base); + ateach (z in D_Base) clocked(c) { + val blocks:ValRail[Iterable[Point(2)]] = blockIt(D | here, P); + foreach ((q) in 0..P-1) clocked(c) { + var myDiff:Real; + do { + if (q == 0) diff(z) = 0; + myDiff = 0; + for (p:Point(2) in blocks(q)) { + Temp(p) = (A | stencil_1(p)).reduce(Double.+, 0.0)/4; + myDiff = Math.max(myDiff, Math.abs(A(p) - Temp(p))); + } + atomic diff(z) = Math.max(myDiff, diff(z)); + next; + for (p:Point(2) in blocks(q)) { + A(p) = Temp(p); + } + if (q == 0) reduceMax(z, diff, scratch); + myDiff = diff(z); + next; + } while (myDiff > epsilon); + } + } + } + } + + def prettyPrintResult() { + for ((i) in A.region.projection(0)) { + for ((j) in A.region.projection(1)) { + val pt = Point.make(i,j); + at (BigD(pt)) { + val tmp = A(pt); + at (Place.FIRST_PLACE) Console.OUT.printf("%1.4f ", tmp); + } + } + Console.OUT.println(); + } + } + + public static def main(Rail[String]) { + Console.OUT.println("HeatTransfer Tutorial example with n="+n+" and epsilon="+epsilon); + Console.OUT.println("Initializing data structures"); + val s = new HeatTransfer_v5(); + Console.OUT.print("Beginning computation..."); + val start = System.nanoTime(); + s.run(); + val stop = System.nanoTime(); + Console.OUT.printf("...completed in %1.3f seconds.\n", (stop-start as double)/1e9); + s.prettyPrintResult(); + } +} Copied: trunk/x10.dist/samples/tutorial/HelloWorldPar.x10 (from rev 13362, trunk/x10.tests/examples/Tutorial/HelloWorldPar.x10) =================================================================== --- trunk/x10.dist/samples/tutorial/HelloWorldPar.x10 (rev 0) +++ trunk/x10.dist/samples/tutorial/HelloWorldPar.x10 2010-03-12 15:41:21 UTC (rev 13365) @@ -0,0 +1,22 @@ +/* + * 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.io.Console; + +class HelloWorldPar { + public static def main(args:Rail[String]):void { + finish ateach (p in Dist.makeUnique()) { + Console.OUT.println("Hello World from Place" +p); + } + } +} + + Copied: trunk/x10.dist/samples/tutorial/Integrate.x10 (from rev 13362, trunk/x10.tests/examples/Tutorial/Integrate.x10) =================================================================== --- trunk/x10.dist/samples/tutorial/Integrate.x10 (rev 0) +++ trunk/x10.dist/samples/tutorial/Integrate.x10 2010-03-12 15:41:21 UTC (rev 13365) @@ -0,0 +1,57 @@ +/* + * 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. + */ + +/** + * This is a slightly more realistic example of the + * basic computational pattern of using async/finish + * to express recursive divide-and-conquer algorithms. + * The program does integration via Guassian Quadrature. + * <p> + * It also can serve as an example of using a closure. + */ +public class Integrate { + const epsilon = 1.0e-12; + + val fun:(double)=>double; + + static final class resHolder { var value:double; } + + public def this(f:(double)=>double) { fun = f; } + + public def computeArea(left:double, right:double) { + return recEval(left, fun(left), right, fun(right), 0); + } + + private def recEval(l:double, fl:double, r:double, fr:double, a:double) { + val h = (r - l) / 2; + val hh = h / 2; + val c = l + h; + val fc = fun(c); + val al = (fl + fc) * hh; + val ar = (fr + fc) * hh; + val alr = al + ar; + if (Math.abs(alr - a) < epsilon) return alr; + val resHolder = new resHolder(); + var expr2:double = 0; + finish { + async { resHolder.value = recEval(c, fc, r, fr, ar); }; + expr2 = recEval(l, fl, c, fc, al); + } + return resHolder.value + expr2; + } + + public static def main(args:Rail[String]!) { + val obj = new Integrate((x:double)=>(x*x + 1.0) * x); + val xMax = args.length > 0 ? Int.parse(args(0)) : 10; + val area = obj.computeArea(0, xMax); + Console.OUT.println("The area of (x*x +1) * x from 0 to "+xMax+" is "+area); + } +} Deleted: trunk/x10.tests/examples/Tutorial/Fib.x10 =================================================================== --- trunk/x10.tests/examples/Tutorial/Fib.x10 2010-03-12 15:11:28 UTC (rev 13364) +++ trunk/x10.tests/examples/Tutorial/Fib.x10 2010-03-12 15:41:21 UTC (rev 13365) @@ -1,63 +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 x10.io.Console; - -/** - * This is a small program to illustrate the use of - * <code>async</code> and <code>finish</code> in a - * prototypical recursive divide-and-conquer algorithm. - * It is obviously not intended to show a efficient way to - * compute Fibonacci numbers in X10.<p> - * - * The heart of the example is the <code>run</code> method, - * which directly embodies the recursive definition of - * <pre> - * Fib(n) = Fib(n-1)+Fib(n- - * </pre> - * by using an <code>async</code> to compute <code>Fib(n-1)</code> while - * the current activity computes <code>Fib(n-2)</code>. A <code>finish</code> - * is used to ensure that both computations are complete before - * their results are added together to compute <code>Fib(n)</code> - */ -public class Fib { - /** - * Used as an in-out parameter to the computation. - * When the Fib object is created, r indicates the number to compute. - * After the computation has completed, r holds the result (Fib(r)). - */ - var r:int; - - public def this(x:int) { - r = x; - } - - public def run() { - if (r<2) return; // r already contains Fib(r) - - val f1 = new Fib(r-1); - val f2 = new Fib(r-2); - finish { - async f1.run(); - f2.run(); - } - r = f1.r + f2.r; - } - - public static def main(args:Rail[String]!) { - val n = (args.length > 0) ? int.parse(args(0)) : 10; - Console.OUT.println("Computing Fib("+n+")"); - val f = new Fib(n); - f.run(); - Console.OUT.println("Fib("+n+") = "+f.r); - } -} - Deleted: trunk/x10.tests/examples/Tutorial/HeatTransfer_v1.x10 =================================================================== --- trunk/x10.tests/examples/Tutorial/HeatTransfer_v1.x10 2010-03-12 15:11:28 UTC (rev 13364) +++ trunk/x10.tests/examples/Tutorial/HeatTransfer_v1.x10 2010-03-12 15:41:21 UTC (rev 13365) @@ -1,75 +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. - */ - -/** - * This is one of a series of programs showing how to express - * different forms of parallelism in X10.</p> - * - * All of the example programs in the series are computing - * the same thing: solving a set of 2D partial differential - * equations that can be expressed as an iterative 4-point - * stencil operation. See the X10 2.0 tutorial for - * for more details and some pictures.</p> - * - * This program is illustrating a high-level "ZPL style", where - * the computation is expressed directly in terms of - * fine-grained computation on global arrays.<p> - */ -public class HeatTransfer_v1 { - static type Real=Double; - const n = 3, epsilon = 1.0e-5; - - const BigD = Dist.makeBlock([0..n+1, 0..n+1], 0); - const D = BigD | ([1..n, 1..n] as Region); - const LastRow = [0..0, 1..n] as Region; - const A = Array.make[Real](BigD,(p:Point)=>{ LastRow.contains(p) ? 1.0 : 0.0 }); - const Temp = Array.make[Real](BigD); - - static def stencil_1((x,y):Point(2)) = (([x-1..x+1,y..y] as Region(2)) || [x..x,y-1..y+1]) - [x..x,y..y]; - - static def subtract(a:Array[Real],b:Array[Real]) = Array.make[Real](a.dist, (p:Point)=>a(p as Point(a.rank))-b(p as Point(b.rank))); - - def run() { - var delta:Real = 1.0; - do { - finish ateach (p in D) - Temp(p) = (A | stencil_1(p)).reduce(Double.+, 0.0)/4; - - delta = subtract(A|D.region,Temp|D.region).lift(Math.abs.(Double)).reduce(Math.max.(Double,Double), 0.0); - finish ateach (p in D) A(p) = Temp(p); - } while (delta > epsilon); - } - - def prettyPrintResult() { - for ((i) in A.region.projection(0)) { - for ((j) in A.region.projection(1)) { - val pt = Point.make(i,j); - at (BigD(pt)) { - val tmp = A(pt); - at (Place.FIRST_PLACE) Console.OUT.printf("%1.4f ",tmp); - } - } - Console.OUT.println(); - } - } - - public static def main(Rail[String]) { - Console.OUT.println("HeatTransfer Tutorial example with n="+n+" and epsilon="+epsilon); - Console.OUT.println("Initializing data structures"); - val s = new HeatTransfer_v1(); - Console.OUT.print("Beginning computation..."); - val start = System.nanoTime(); - s.run(); - val stop = System.nanoTime(); - Console.OUT.printf("...completed in %1.3f seconds.\n", (stop-start as double)/1e9); - s.prettyPrintResult(); - } -} Deleted: trunk/x10.tests/examples/Tutorial/HeatTransfer_v2.x10 =================================================================== --- trunk/x10.tests/examples/Tutorial/HeatTransfer_v2.x10 2010-03-12 15:11:28 UTC (rev 13364) +++ trunk/x10.tests/examples/Tutorial/HeatTransfer_v2.x10 2010-03-12 15:41:21 UTC (rev 13365) @@ -1,77 +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. - */ - -/** - * This is one of a series of programs showing how to express - * different forms of parallelism in X10.</p> - * - * All of the example programs in the series are computing - * the same thing: solving a set of 2D partial differential - * equations that can be expressed as an iterative 4-point - * stencil operation. See the X10 2.0 tutorial for - * for more details and some pictures.</p> - * - * This program is illustrating explicit loop chunking to - * coarsen the parallelism at each place (vs HeatTransfer_v1) - * to gain efficiency.<p> - */ -public class HeatTransfer_v2 { - static type Real=Double; - const n = 3, epsilon = 1.0e-5; - - const BigD = Dist.makeBlock([0..n+1, 0..n+1], 0); - const D = BigD | ([1..n, 1..n] as Region); - const LastRow = [0..0, 1..n] as Region; - const A = Array.make[Real](BigD,(p:Point)=>{ LastRow.contains(p) ? 1.0 : 0.0 }); - const Temp = Array.make[Real](BigD); - - static def stencil_1((x,y):Point(2)) = (([x-1..x+1,y..y] as Region(2)) || [x..x,y-1..y+1]) - [x..x,y..y]; - - static def subtract(a:Array[Real],b:Array[Real]) = Array.make[Real](a.dist, (p:Point)=>a(p as Point(a.rank))-b(p as Point(b.rank))); - - def run() { - val D_Base = Dist.makeUnique(D.places()); - var delta:Real = 1.0; - do { - finish ateach (z in D_Base) - for (p:Point(2) in D | here) - Temp(p) = (A | stencil_1(p)).reduce(Double.+, 0.0)/4; - - delta = subtract(A|D.region,Temp|D.region).lift(Math.abs.(Double)).reduce(Math.max.(Double,Double), 0.0); - finish ateach (p in D) A(p) = Temp(p); - } while (delta > epsilon); - } - - def prettyPrintResult() { - for ((i) in A.region.projection(0)) { - for ((j) in A.region.projection(1)) { - val pt = Point.make(i,j); - at (BigD(pt)) { - val tmp = A(pt); - at (Place.FIRST_PLACE) Console.OUT.printf("%1.4f ", tmp); - } - } - Console.OUT.println(); - } - } - - public static def main(Rail[String]) { - Console.OUT.println("HeatTransfer Tutorial example with n="+n+" and epsilon="+epsilon); - Console.OUT.println("Initializing data structures"); - val s = new HeatTransfer_v2(); - Console.OUT.print("Beginning computation..."); - val start = System.nanoTime(); - s.run(); - val stop = System.nanoTime(); - Console.OUT.printf("...completed in %1.3f seconds.\n", (stop-start as double)/1e9); - s.prettyPrintResult(); - } -} Deleted: trunk/x10.tests/examples/Tutorial/HeatTransfer_v3.x10 =================================================================== --- trunk/x10.tests/examples/Tutorial/HeatTransfer_v3.x10 2010-03-12 15:11:28 UTC (rev 13364) +++ trunk/x10.tests/examples/Tutorial/HeatTransfer_v3.x10 2010-03-12 15:41:21 UTC (rev 13365) @@ -1,106 +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. - */ - -/** - * This is one of a series of programs showing how to express - * different forms of parallelism in X10.</p> - * - * All of the example programs in the series are computing - * the same thing: solving a set of 2D partial differential - * equations that can be expressed as an iterative 4-point - * stencil operation. See the X10 2.0 tutorial for - * for more details and some pictures.</p> - * - * This program is illustrating explicit loop chunking - * with hierarchical parallelism. It diverges from the - * presentation in the X10 2.0 tutorial slides because - * the current X10 2.0 array/distribution library doesn't - * provide a built-in function to take a (already block-cyclic) - * distribution and split the points into P sub-regions at each - * place. In this sample, this is done fairly inefficiently - * by the blockIt method, which is actually being invoked in each - * outer iteration of the main do/while loop. For better performance, - * (a) the creation of sub-regions should probably consider locality - * and (b) the sub-region creation should only be done once at each - * place instead of being redone on every loop iteration.<p> - */ -public class HeatTransfer_v3 { - static type Real=Double; - const n = 3; - const epsilon = 1.0e-5; - const P = 2; - - const BigD = Dist.makeBlock([0..n+1, 0..n+1], 0); - const D = BigD | ([1..n, 1..n] as Region); - const LastRow = [0..0, 1..n] as Region; - const A = Array.make[Real](BigD,(p:Point)=>{ LastRow.contains(p) ? 1.0 : 0.0 }); - const Temp = Array.make[Real](BigD); - - static def stencil_1((x,y):Point(2)) = (([x-1..x+1,y..y] as Region(2)) || [x..x,y-1..y+1]) - [x..x,y..y]; - - static def subtract(a:Array[Real],b:Array[Real]) = Array.make[Real](a.dist, (p:Point)=>a(p as Point(a.rank))-b(p as Point(b.rank))); - - // TODO: This is a really inefficient implementation of this abstraction. - // Needs to be done properly and integrated into the Dist/Region/Array - // class library in x10.array. - static def blockIt(d:Dist(2), numProcs:int):ValRail[Iterable[Point(2)]] { - val ans = ValRail.make(numProcs, (int) => new x10.util.ArrayList[Point{self.rank==d.rank}]()); - var modulo:int = 0; - for (p in d) { - ans(modulo).add(p); - modulo = (modulo + 1) % numProcs; - } - return ans; - } - - def run() { - val D_Base = Dist.makeUnique(D.places()); - var delta:Real = 1.0; - do { - finish ateach (z in D_Base) { - val blocks:ValRail[Iterable[Point(2)]] = blockIt(D | here, P); - foreach ((q) in 0..P-1) { - for (p in blocks(q)) { - Temp(p) = (A | stencil_1(p)).reduce(Double.+, 0.0)/4; - } - } - } - - delta = subtract(A|D.region,Temp|D.region).lift(Math.abs.(Double)).reduce(Math.max.(Double,Double), 0.0); - finish ateach (p in D) A(p) = Temp(p); - } while (delta > epsilon); - } - - def prettyPrintResult() { - for ((i) in A.region.projection(0)) { - for ((j) in A.region.projection(1)) { - val pt = Point.make(i,j); - at (BigD(pt)) { - val tmp = A(pt); - at (Place.FIRST_PLACE) Console.OUT.printf("%1.4f ", tmp); - } - } - Console.OUT.println(); - } - } - - public static def main(Rail[String]) { - Console.OUT.println("HeatTransfer Tutorial example with n="+n+" and epsilon="+epsilon); - Console.OUT.println("Initializing data structures"); - val s = new HeatTransfer_v3(); - Console.OUT.print("Beginning computation..."); - val start = System.nanoTime(); - s.run(); - val stop = System.nanoTime(); - Console.OUT.printf("...completed in %1.3f seconds.\n", (stop-start as double)/1e9); - s.prettyPrintResult(); - } -} Deleted: trunk/x10.tests/examples/Tutorial/HeatTransfer_v4.x10 =================================================================== --- trunk/x10.tests/examples/Tutorial/HeatTransfer_v4.x10 2010-03-12 15:11:28 UTC (rev 13364) +++ trunk/x10.tests/examples/Tutorial/HeatTransfer_v4.x10 2010-03-12 15:41:21 UTC (rev 13365) @@ -1,95 +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. - */ - -/** - * This is one of a series of programs showing how to express - * different forms of parallelism in X10.</p> - * - * All of the example programs in the series are computing - * the same thing: solving a set of 2D partial differential - * equations that can be expressed as an iterative 4-point - * stencil operation. See the X10 2.0 tutorial for - * for more details and some pictures.</p> - * - * This program is illustrating an SPMD with all-to-all reduction - * ("MPI-style").</p> - */ -public class HeatTransfer_v4 { - static type Real=Double; - const n = 3, epsilon = 1.0e-5; - - const BigD = Dist.makeBlock([0..n+1, 0..n+1], 0); - const D = BigD | ([1..n, 1..n] as Region); - const LastRow = [0..0, 1..n] as Region; - const A = Array.make[Real](BigD,(p:Point)=>{ LastRow.contains(p) ? 1.0 : 0.0 }); - const Temp = Array.make[Real](BigD); - - static def stencil_1((x,y):Point(2)) = (([x-1..x+1,y..y] as Region(2)) || [x..x,y-1..y+1]) - [x..x,y..y]; - - static def subtract(a:Array[Real],b:Array[Real]) = Array.make[Real](a.dist, (p:Point)=>a(p as Point(a.rank))-b(p as Point(b.rank))); - - // TODO: The array library really should provide an efficient - // all-to-all collective reduction. - // This is a quick and sloppy implementation, which does way too much work. - static def reduceMax(z:Point{self.rank==diff.rank}, diff:Array[Real], scratch:Array[Real]) { - val max = diff.reduce(Math.max.(Double,Double), 0.0); - diff(z) = max; - next; - } - - def run() { - finish async { - val c = Clock.make(); - val D_Base = Dist.makeUnique(D.places()); - val diff = Array.make[Real](D_Base); - val scratch = Array.make[Real](D_Base); - ateach (z in D_Base) clocked(c) { - do { - diff(z) = 0; - for (p:Point(2) in D | here) { - Temp(p) = (A | stencil_1(p)).reduce(Double.+, 0.0)/4; - diff(z) = Math.max(diff(z), Math.abs(A(p) - Temp(p))); - } - next; - for (p:Point(2) in D | here) { - A(p) = Temp(p); - } - reduceMax(z, diff, scratch); - } while (diff(z) > epsilon); - } - } - } - - def prettyPrintResult() { - for ((i) in A.region.projection(0)) { - for ((j) in A.region.projection(1)) { - val pt = Point.make(i,j); - at (BigD(pt)) { - val tmp = A(pt); - at (Place.FIRST_PLACE) Console.OUT.printf("%1.4f ", tmp); - } - } - Console.OUT.println(); - } - } - - public static def main(Rail[String]) { - Console.OUT.println("HeatTransfer Tutorial example with n="+n+" and epsilon="+epsilon); - Console.OUT.println("Initializing data structures"); - val s = new HeatTransfer_v4(); - Console.OUT.print("Beginning computation..."); - val start = System.nanoTime(); - s.run(); - val stop = System.nanoTime(); - Console.OUT.printf("...completed in %1.3f seconds.\n", (stop-start as double)/1e9); - s.prettyPrintResult(); - } -} Deleted: trunk/x10.tests/examples/Tutorial/HeatTransfer_v5.x10 =================================================================== --- trunk/x10.tests/examples/Tutorial/HeatTransfer_v5.x10 2010-03-12 15:11:28 UTC (rev 13364) +++ trunk/x10.tests/examples/Tutorial/HeatTransfer_v5.x10 2010-03-12 15:41:21 UTC (rev 13365) @@ -1,117 +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. - */ - -/** - * This is one of a series of programs showing how to express - * different forms of parallelism in X10.</p> - * - * All of the example programs in the series are computing - * the same thing: solving a set of 2D partial differential - * equations that can be expressed as an iterative 4-point - * stencil operation. See the X10 2.0 tutorial for - * for more details and some pictures.</p> - * - * This program is illustrating an SPMD with all-to-all reduction - * and multiple activities per node ("OpenMP within MPI-style").</p> - */ -public class HeatTransfer_v5 { - static type Real=Double; - const n = 3, epsilon = 1.0e-5; - const P = 1; - - const BigD = Dist.makeBlock([0..n+1, 0..n+1], 0); - const D = BigD | ([1..n, 1..n] as Region); - const LastRow = [0..0, 1..n] as Region; - const A = Array.make[Real](BigD,(p:Point)=>{ LastRow.contains(p) ? 1.0 : 0.0 }); - const Temp = Array.make[Real](BigD); - - static def stencil_1((x,y):Point(2)) = (([x-1..x+1,y..y] as Region(2)) || [x..x,y-1..y+1]) - [x..x,y..y]; - - static def subtract(a:Array[Real],b:Array[Real]) = Array.make[Real](a.dist, (p:Point)=>a(p as Point(a.rank))-b(p as Point(b.rank))); - - // TODO: The array library really should provide an efficient - // all-to-all collective reduction. - // This is a quick and sloppy implementation, which does way too much work. - static def reduceMax(z:Point{self.rank==diff.rank}, diff:Array[Real], scratch:Array[Real]) { - val max = diff.reduce(Math.max.(Double,Double), 0.0); - diff(z) = max; - next; - } - - // TODO: This is a really inefficient implementation of this abstraction. - // Needs to be done properly and integrated into the Dist/Region/Array - // class library in x10.array. - static def blockIt(d:Dist(2), numProcs:int):ValRail[Iterable[Point(2)]] { - val ans = ValRail.make(numProcs, (int) => new x10.util.ArrayList[Point{self.rank==d.rank}]()); - var modulo:int = 0; - for (p in d) { - ans(modulo).add(p); - modulo = (modulo + 1) % numProcs; - } - return ans; - } - - def run() { - finish async { - val c = Clock.make(); - val D_Base = Dist.makeUnique(D.places()); - val diff = Array.make[Real](D_Base); - val scratch = Array.make[Real](D_Base); - ateach (z in D_Base) clocked(c) { - val blocks:ValRail[Iterable[Point(2)]] = blockIt(D | here, P); - foreach ((q) in 0..P-1) clocked(c) { - var myDiff:Real; - do { - if (q == 0) diff(z) = 0; - myDiff = 0; - for (p:Point(2) in blocks(q)) { - Temp(p) = (A | stencil_1(p)).reduce(Double.+, 0.0)/4; - myDiff = Math.max(myDiff, Math.abs(A(p) - Temp(p))); - } - atomic diff(z) = Math.max(myDiff, diff(z)); - next; - for (p:Point(2) in blocks(q)) { - A(p) = Temp(p); - } - if (q == 0) reduceMax(z, diff, scratch); - myDiff = diff(z); - next; - } while (myDiff > epsilon); - } - } - } - } - - def prettyPrintResult() { - for ((i) in A.region.projection(0)) { - for ((j) in A.region.projection(1)) { - val pt = Point.make(i,j); - at (BigD(pt)) { - val tmp = A(pt); - at (Place.FIRST_PLACE) Console.OUT.printf("%1.4f ", tmp); - } - } - Console.OUT.println(); - } - } - - public static def main(Rail[String]) { - Console.OUT.println("HeatTransfer Tutorial example with n="+n+" and epsilon="+epsilon); - Console.OUT.println("Initializing data structures"); - val s = new HeatTransfer_v5(); - Console.OUT.print("Beginning computation..."); - val start = System.nanoTime(); - s.run(); - val stop = System.nanoTime(); - Console.OUT.printf("...completed in %1.3f seconds.\n", (stop-start as double)/1e9); - s.prettyPrintResult(); - } -} Deleted: trunk/x10.tests/examples/Tutorial/HelloWorldPar.x10 =================================================================== --- trunk/x10.tests/examples/Tutorial/HelloWorldPar.x10 2010-03-12 15:11:28 UTC (rev 13364) +++ trunk/x10.tests/examples/Tutorial/HelloWorldPar.x10 2010-03-12 15:41:21 UTC (rev 13365) @@ -1,22 +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 x10.io.Console; - -class HelloWorldPar { - public static def main(args:Rail[String]):void { - finish ateach (p in Dist.makeUnique()) { - Console.OUT.println("Hello World from Place" +p); - } - } -} - - Deleted: trunk/x10.tests/examples/Tutorial/Integrate.x10 =================================================================== --- trunk/x10.tests/examples/Tutorial/Integrate.x10 2010-03-12 15:11:28 UTC (rev 13364) +++ trunk/x10.tests/examples/Tutorial/Integrate.x10 2010-03-12 15:41:21 UTC (rev 13365) @@ -1,57 +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. - */ - -/** - * This is a slightly more realistic example of the - * basic computational pattern of using async/finish - * to express recursive divide-and-conquer algorithms. - * The program does integration via Guassian Quadrature. - * <p> - * It also can serve as an example of using a closure. - */ -public class Integrate { - const epsilon = 1.0e-12; - - val fun:(double)=>double; - - static final class resHolder { var value:double; } - - public def this(f:(double)=>double) { fun = f; } - - public def computeArea(left:double, right:double) { - return recEval(left, fun(left), right, fun(right), 0); - } - - private def recEval(l:double, fl:double, r:double, fr:double, a:double) { - val h = (r - l) / 2; - val hh = h / 2; - val c = l + h; - val fc = fun(c); - val al = (fl + fc) * hh; - val ar = (fr + fc) * hh; - val alr = al + ar; - if (Math.abs(alr - a) < epsilon) return alr; - val resHolder = new resHolder(); - var expr2:double = 0; - finish { - async { resHolder.value = recEval(c, fc, r, fr, ar); }; - expr2 = recEval(l, fl, c, fc, al); - } - return resHolder.value + expr2; - } - - public static def main(args:Rail[String]!) { - val obj = new Integrate((x:double)=>(x*x + 1.0) * x); - val xMax = args.length > 0 ? Int.parse(args(0)) : 10; - val area = obj.computeArea(0, xMax); - Console.OUT.println("The area of (x*x +1) * x from 0 to "+xMax+" is "+area); - } -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dgr...@us...> - 2010-03-12 20:33:06
|
Revision: 13377 http://x10.svn.sourceforge.net/x10/?rev=13377&view=rev Author: dgrove-oss Date: 2010-03-12 20:32:59 +0000 (Fri, 12 Mar 2010) Log Message: ----------- Generate x10Test wrappers for all the programs in x10.dist/samples. TODO: Currently not validating the actual computation. Need to go through and do that for each test where possible Remove redundant copy of HelloWholeWorld. Added Paths: ----------- trunk/x10.tests/examples/Samples/ArraySumTest.x10 trunk/x10.tests/examples/Samples/CUDABlackScholesTest.x10 trunk/x10.tests/examples/Samples/CUDAKernelTestTest.x10 trunk/x10.tests/examples/Samples/CUDATopologyTest.x10 trunk/x10.tests/examples/Samples/FRASimpleDistTest.x10 trunk/x10.tests/examples/Samples/FSSimpleDistTest.x10 trunk/x10.tests/examples/Samples/GCSpheresTest.x10 trunk/x10.tests/examples/Samples/HelloTest.x10 trunk/x10.tests/examples/Samples/HelloWholeWorldTest.x10 trunk/x10.tests/examples/Samples/HelloWorldTest.x10 trunk/x10.tests/examples/Samples/HistogramTest.x10 trunk/x10.tests/examples/Samples/KMeansCUDATest.x10 trunk/x10.tests/examples/Samples/KMeansDistTest.x10 trunk/x10.tests/examples/Samples/KMeansSPMDTest.x10 trunk/x10.tests/examples/Samples/KMeansTest.x10 trunk/x10.tests/examples/Samples/MontyPiTest.x10 trunk/x10.tests/examples/Samples/NQueensDistTest.x10 trunk/x10.tests/examples/Samples/NQueensParTest.x10 trunk/x10.tests/examples/Samples/StructSpheresTest.x10 Removed Paths: ------------- trunk/x10.dist/samples/tutorial/HelloWorldPar.x10 trunk/x10.tests/examples/Misc/ArraySum.x10 trunk/x10.tests/examples/Misc/FRA.x10 trunk/x10.tests/examples/Misc/FRASimpleDist.x10 trunk/x10.tests/examples/Misc/FRASimpleDistTest.x10 trunk/x10.tests/examples/Misc/FRATest.x10 trunk/x10.tests/examples/Misc/FS.x10 trunk/x10.tests/examples/Misc/FSSimple.x10 trunk/x10.tests/examples/Misc/FSSimpleDist.x10 trunk/x10.tests/examples/Misc/FSSimpleDistTest.x10 trunk/x10.tests/examples/Misc/FSSimpleTest.x10 trunk/x10.tests/examples/Misc/NQueensPar.x10 trunk/x10.tests/examples/Misc/NQueensParTest.x10 trunk/x10.tests/examples/Samples/HelloWorldParTest.x10 Deleted: trunk/x10.dist/samples/tutorial/HelloWorldPar.x10 =================================================================== --- trunk/x10.dist/samples/tutorial/HelloWorldPar.x10 2010-03-12 20:11:39 UTC (rev 13376) +++ trunk/x10.dist/samples/tutorial/HelloWorldPar.x10 2010-03-12 20:32:59 UTC (rev 13377) @@ -1,22 +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 x10.io.Console; - -class HelloWorldPar { - public static def main(args:Rail[String]):void { - finish ateach (p in Dist.makeUnique()) { - Console.OUT.println("Hello World from Place" +p); - } - } -} - - Deleted: trunk/x10.tests/examples/Misc/ArraySum.x10 =================================================================== --- trunk/x10.tests/examples/Misc/ArraySum.x10 2010-03-12 20:11:39 UTC (rev 13376) +++ trunk/x10.tests/examples/Misc/ArraySum.x10 2010-03-12 20:32:59 UTC (rev 13377) @@ -1,70 +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 x10.io.Console; -import harness.x10Test; - -public class ArraySum extends x10Test { - - var sum: Int; - val size: Int; - val data: Rail[Int]!; - val R:Region{rail}; - - public def this(n: Int) { - size=n; - R= 0..n-1 as Region{rail}; - data = Rail.make[Int](n, (x:int)=>1); - // for ((i) in R) S executes S for each point in R. - // R must be a 1-d region. (i) decomposes the 1-d point - // to retrieve the index in the 0th dimension. - // Thus for iteration over a 2d point, you would use - // the idiom for ((i,j) in R) S - // The syntax for (p in R) S will also work, but p - // will be bound to the points in R. - sum=0; - } - - def sum(a: Rail[Int]!, start: Int, last: Int): Int = { - var mySum: Int = 0; - for ((i) in start..last-1) mySum += a(i); - return mySum; - } - - def sum(numThreads: Int) { - val mySize = size/numThreads; - finish foreach ((p) in 0..numThreads-1) { - val mySum = sum(data, p*mySize, (p+1)*mySize); - // Multiple activities will simultaneously update - // this location -- so use an atomic operation. - atomic sum += mySum; - } - } - - public def run(): boolean { - var size: int = 5*1000; - var a:ArraySum! = new ArraySum(size); - val numThreads = [1,2,4]; - var good:boolean=true; - for (var i: int = 0; i < numThreads.length && good; i++) { - a.sum=0; - var time: long = - System.nanoTime(); - a.sum(numThreads(i)); - time += System.nanoTime(); - good &= size==a.sum; - } - return good; - } - - public static def main(var args: Rail[String]){ - new ArraySum(1).execute(); - } -} Deleted: trunk/x10.tests/examples/Misc/FRA.x10 =================================================================== --- trunk/x10.tests/examples/Misc/FRA.x10 2010-03-12 20:11:39 UTC (rev 13376) +++ trunk/x10.tests/examples/Misc/FRA.x10 2010-03-12 20:32:59 UTC (rev 13377) @@ -1,113 +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. - */ - -class LocalTable { - val a:Array[long](1)!; - val mask: int; - - def this(size:int) { - mask = size-1; - a = Array.make[long](0..size-1, ((i):Point) => i as long); - } - - public def update(ran:long) { - a(ran&mask as int) ^= ran; - } -} - -/** - * Random Access, using Array[Array[long]] as the backing data - * structure for the data. This is much less efficient than - * the approach taken in FRASimpleDist, which uses - * PlaceLocalHandle[Rail[long]] to access the data. - */ -public class FRA { - - const POLY = 0x0000000000000007L; - const PERIOD = 1317624576693539401L; - const NUM_PLACES = Place.MAX_PLACES; - const PLACE_ID_MASK = NUM_PLACES-1; - - // Utility routine to start random number generator at Nth step - static def HPCC_starts(var n:long): long { - var i:int, j:int; - val m2 = Rail.make[long](64); - while (n < 0) n += PERIOD; - while (n > PERIOD) n -= PERIOD; - if (n == 0) return 0x1L; - var temp:long = 0x1; - for (i=0; i<64; i++) { - m2(i) = temp; - temp = (temp << 1) ^ (temp < 0 ? POLY : 0L); - temp = (temp << 1) ^ (temp < 0 ? POLY : 0L); - } - for (i=62; i>=0; i--) if (((n >> i) & 1) != 0) break; - var ran:long = 0x2; - while (i > 0) { - temp = 0; - for (j=0; j<64; j++) if (((ran >> j) & 1) != 0) temp ^= m2(j); - ran = temp; - i -= 1; - if (((n >> i) & 1) != 0) - ran = (ran << 1) ^ (ran < 0 ? POLY : 0); - } - return ran; - } - - static def randomAccessUpdate( - NUM_UPDATES: long, - logLocalTableSize: long, - tables: Array[LocalTable](1) - ) { - finish ateach((p):Point in Dist.makeUnique()) { - var ran:long = HPCC_starts(p*(NUM_UPDATES/NUM_PLACES)); - for (var i:long=0; i<NUM_UPDATES/NUM_PLACES; i++) { - val placeId = ((ran>>logLocalTableSize) & PLACE_ID_MASK) as int; - val temp = ran; - async (Place.places(placeId)) - tables(here.id).update(temp); - ran = (ran << 1) ^ (ran<0L ? POLY : 0L); - } - } - } - - - public def run():boolean { - - // calculate the size of update array (must be a power of 2) - val logLocalTableSize = 10; - val localTableSize = 1<<logLocalTableSize; - val tableSize = localTableSize*NUM_PLACES; - val NUM_UPDATES = 4*tableSize; - - // create local tables - val init = (p:Point) => new LocalTable(localTableSize); - val tables = Array.make[LocalTable](Dist.makeUnique(), - (p:Point) => new LocalTable(localTableSize)); - - // time it - var cpuTime:double = -now(); - randomAccessUpdate(NUM_UPDATES, logLocalTableSize, tables); - cpuTime += now(); - - // repeat for testing. - randomAccessUpdate(NUM_UPDATES, logLocalTableSize, tables); - val result = Array.make[Int](Dist.makeUnique(), (Point)=>0); - for (p:Place in Place.places) async(p) { - val l = tables(p.id) as LocalTable!; - for ((q):Point in l.a) if (l.a(q) != q) result(p.id)++; - } - return result.reduce(Int.+,0) < (localTableSize/100); - } - - static def now() = System.nanoTime() * 1e-9D; - -} Deleted: trunk/x10.tests/examples/Misc/FRASimpleDist.x10 =================================================================== --- trunk/x10.tests/examples/Misc/FRASimpleDist.x10 2010-03-12 20:11:39 UTC (rev 13376) +++ trunk/x10.tests/examples/Misc/FRASimpleDist.x10 2010-03-12 20:32:59 UTC (rev 13377) @@ -1,137 +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 x10.io.Console; - -import x10.util.Timer; - -class LocalTable { - - val a: Rail[long]{self.at(this)}; - val mask: int; - - def this(size:int) { - mask = size-1; - a = Rail.make[long](size, (i:int)=>i as long); - } - - public def update(ran:long) { - //a(ran&mask as int) ^= ran; - val index = ran&mask as int; - a(index) = a(index) ^ ran; - } -} - - -class FRASimpleDist { - - const POLY = 0x0000000000000007L; - const PERIOD = 1317624576693539401L; - - // Utility routine to start random number generator at Nth step - static def HPCC_starts(var n:long): long { - var i:int, j:int; - val m2 = Rail.make[long](64); - while (n < 0) n += PERIOD; - while (n > PERIOD) n -= PERIOD; - if (n == 0) return 0x1L; - var temp:long = 0x1; - for (i=0; i<64; i++) { - m2(i) = temp; - temp = (temp << 1) ^ (temp < 0 ? POLY : 0L); - temp = (temp << 1) ^ (temp < 0 ? POLY : 0L); - } - for (i=62; i>=0; i--) if (((n >> i) & 1) != 0) break; - var ran:long = 0x2; - while (i > 0) { - temp = 0; - for (j=0; j<64; j++) if (((ran >> j) & 1) != 0) temp ^= m2(j); - ran = temp; - i -= 1; - if (((n >> i) & 1) != 0) - ran = (ran << 1) ^ (ran < 0 ? POLY : 0); - } - return ran; - } - - static def randomAccessUpdate( - num_updates: long, - logLocalTableSize:int, - tables: PlaceLocalHandle[LocalTable] - ) { - finish for (var p:int=0; p<Place.MAX_PLACES; p++) { - val valp = p; - async (Place.places(p)) { - var ran:long = HPCC_starts(valp*(num_updates/Place.MAX_PLACES)); - for (var i:long=0; i<num_updates/Place.MAX_PLACES; i++) { - val placeId = ((ran>>logLocalTableSize) & (Place.MAX_PLACES-1)) as int; - val valran = ran; - async (Place.places(placeId)) { - tables().update(valran); - } - ran = (ran << 1) ^ (ran<0L ? POLY : 0L); - } - } - } - } - - public def run() { - if ((Place.MAX_PLACES & (Place.MAX_PLACES-1)) > 0) { - println("The number of places must be a power of 2."); - return false; - } - - // calculate the size of update array (must be a power of 2) - val logLocalTableSize = 12; - val localTableSize = 1<<logLocalTableSize; - val tableSize = localTableSize*Place.MAX_PLACES; - val num_updates = 4*tableSize; - - // create local tables - val tables = PlaceLocalHandle.make[LocalTable](Dist.makeUnique(), () => new LocalTable(localTableSize)); - - // print some info - println("Main table size = 2^" +logLocalTableSize + "*" + Place.MAX_PLACES+" = " + tableSize+ " words"); - println("Number of places = " + Place.MAX_PLACES); - println("Number of updates = " + num_updates); - - // time it - var cpuTime:double = -now(); - randomAccessUpdate(num_updates, logLocalTableSize, tables); - cpuTime += now(); - - // print statistics - val GUPs = (cpuTime > 0.0 ? 1.0 / cpuTime : -1.0) * num_updates / 1e9; - Console.OUT.println("CPU time used = "+cpuTime+" seconds"); - Console.OUT.println(GUPs+" Billion(10^9) Updates per second (GUP/s)"); - - // repeat for testing. - randomAccessUpdate(num_updates, logLocalTableSize, tables); - val result = Array.make[Int](Dist.makeUnique(), (Point)=>0); - for (var i:int=0; i<Place.MAX_PLACES; i++) { - async (Place.places(i)) { - val table = tables(); - var err:int = 0; - for (var j:int=0; j<table.a.length; j++) { - if (table.a(j) != j) { - result(here.id)++; - println("Found error at j=" + j + " " + table.a(j)); - } - } - } - } - return result.reduce(Int.+,0) < (localTableSize/100); - } - - static def now() = Timer.nanoTime() * 1e-9D; - - static def println(s:String) = Console.OUT.println(s); -} Deleted: trunk/x10.tests/examples/Misc/FRASimpleDistTest.x10 =================================================================== --- trunk/x10.tests/examples/Misc/FRASimpleDistTest.x10 2010-03-12 20:11:39 UTC (rev 13376) +++ trunk/x10.tests/examples/Misc/FRASimpleDistTest.x10 2010-03-12 20:32:59 UTC (rev 13377) @@ -1,22 +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; -public class FRASimpleDistTest extends x10Test { - public def run():boolean { - return new FRASimpleDist().run(); - } - public static def main(args:Rail[String]) { - new FRASimpleDistTest().execute(); - } - - -} Deleted: trunk/x10.tests/examples/Misc/FRATest.x10 =================================================================== --- trunk/x10.tests/examples/Misc/FRATest.x10 2010-03-12 20:11:39 UTC (rev 13376) +++ trunk/x10.tests/examples/Misc/FRATest.x10 2010-03-12 20:32:59 UTC (rev 13377) @@ -1,22 +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; -public class FRATest extends x10Test { - public def run():boolean { - return new FRA().run(); - } - public static def main(args:Rail[String]) { - new FRATest().execute(); - } - - -} Deleted: trunk/x10.tests/examples/Misc/FS.x10 =================================================================== --- trunk/x10.tests/examples/Misc/FS.x10 2010-03-12 20:11:39 UTC (rev 13376) +++ trunk/x10.tests/examples/Misc/FS.x10 2010-03-12 20:32:59 UTC (rev 13377) @@ -1,91 +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. - */ - -/** - * Version of Stream with a collection of local arrays implementing a - * global array. - * - * @seealso Stream - * @author vj - * @author bdlucas - */ - -public class FS { - - const MEG = 1024*1024; - const alpha = 3.0D; - - //const NUM_TIMES = 10; - const NUM_TIMES = 1; - - //const DEFAULT_SIZE = 2*MEG; - const DEFAULT_SIZE = MEG / 8; - - public static def main(args:Rail[String]!) { - - val verified: Rail[boolean]! = [true]; - val times = Rail.make[double](NUM_TIMES); - val N0 = args.length > 0 ? int.parse(args(0)) : DEFAULT_SIZE; - val N = N0 * Place.MAX_PLACES; - val localSize = N0; - val localRegion = 0..localSize-1; - - x10.io.Console.OUT.println("localSize=" + localSize); - - finish async { - - val clock = Clock.make(); - - ateach ((p):Point in Dist.makeUnique()) clocked (clock) { - - val a = Rail.make[double](localSize); - val b = Rail.make[double](localSize); - val c = Rail.make[double](localSize); - - for ((i):Point in localRegion) { - b(i) = 1.5 * (p*localSize+i); - c(i) = 2.5 * (p*localSize+i); - } - - for (var j:int=0; j<NUM_TIMES; j++) { - if (p==0) times(j) = -now(); - for ((i):Point in localRegion) - a(i) = b(i) + alpha*c(i); - next; - if (p==0) times(j) += now(); - } - - // verification - for ((i):Point in localRegion) - if (a(i) != b(i) + alpha*c(i)) - async(Place.FIRST_PLACE) clocked (clock) - verified(0) = false; - } - } - - var min:double = 1000000; - for (var j:int=0; j<NUM_TIMES; j++) - if (times(j) < min) - min = times(j); - printStats(N, min, verified(0)); - } - - static def now():double = System.nanoTime() * 1e-9; - - static def printStats(N:int, time:double, verified:boolean) { - val size = (3*8*N/MEG); - val rate = (3*8*N) / (1.0E9*time); - x10.io.Console.OUT.println("Number of places=" + Place.MAX_PLACES); - x10.io.Console.OUT.println("Size of arrays: " + size +" MB (total)" + size/Place.MAX_PLACES + " MB (per place)"); - x10.io.Console.OUT.println("Min time: " + time + " rate=" + rate + " GB/s"); - x10.io.Console.OUT.println("Result is " + (verified ? "verified." : "NOT verified.")); - } -} Deleted: trunk/x10.tests/examples/Misc/FSSimple.x10 =================================================================== --- trunk/x10.tests/examples/Misc/FSSimple.x10 2010-03-12 20:11:39 UTC (rev 13376) +++ trunk/x10.tests/examples/Misc/FSSimple.x10 2010-03-12 20:32:59 UTC (rev 13377) @@ -1,93 +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. - */ - -/** - * Version of Stream with a collection of local arrays implementing a - * global array. - * - * @seealso Stream - * @author vj - * @author bdlucas - */ - -import x10.util.Timer; - -public class FSSimple { - - const MEG = 1024*1024; - const alpha = 3.0D; - - //const NUM_TIMES = 10; - const NUM_TIMES = 1; - - //const DEFAULT_SIZE = 2*MEG; - const DEFAULT_SIZE = MEG / 8; - - // const NUM_PLACES = NUM_PLACES; - const NUM_PLACES = 4; - - public def run():Boolean { - - val verified: Rail[boolean]! = [true]; - val times = Rail.make[double](NUM_TIMES); - val N0 = DEFAULT_SIZE; - val N = N0 * NUM_PLACES; - val localSize = N0; - - println("localSize=" + localSize); - - for (var pp:int=0; pp<NUM_PLACES; pp++) { - - val p = pp; - - val a = Rail.make[double](localSize); - val b = Rail.make[double](localSize); - val c = Rail.make[double](localSize); - - for (var i:int=0; i<localSize; i++) { - b(i) = 1.5 * (p*localSize+i); - c(i) = 2.5 * (p*localSize+i); - } - - for (var j:int=0; j<NUM_TIMES; j++) { - if (p==0) times(j) = -now(); - for (var i:int=0; i<localSize; i++) - a(i) = b(i) + alpha*c(i); - if (p==0) times(j) = times(j) + now(); - } - - // verification - for (var i:int=0; i<localSize; i++) - if (a(i) != b(i) + alpha*c(i)) - verified(0) = false; - } - - var min:double = 1000000; - for (var j:int=0; j<NUM_TIMES; j++) - if (times(j) < min) - min = times(j); - printStats(N, min, verified(0)); - return verified(0); - } - - static def now():double = Timer.nanoTime() * 1e-9; - - static def println(s:String) = Console.OUT.println(s); - - static def printStats(N:int, time:double, verified:boolean) { - val size = (3*8*N/MEG); - val rate = (3*8*N) / (1.0E9*time); - println("Number of places=" + NUM_PLACES); - println("Size of arrays: " + size +" MB (total)" + size/NUM_PLACES + " MB (per place)"); - println("Min time: " + time + " rate=" + rate + " GB/s"); - println("Result is " + (verified ? "verified." : "NOT verified.")); - } -} Deleted: trunk/x10.tests/examples/Misc/FSSimpleDist.x10 =================================================================== --- trunk/x10.tests/examples/Misc/FSSimpleDist.x10 2010-03-12 20:11:39 UTC (rev 13376) +++ trunk/x10.tests/examples/Misc/FSSimpleDist.x10 2010-03-12 20:32:59 UTC (rev 13377) @@ -1,97 +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. - */ - -/** - * Version of Stream with a collection of local arrays implementing a - * global array. - * - * @seealso Stream - * @author vj - * @author bdlucas - */ - -import x10.util.Timer; -import x10.io.Console; - -public class FSSimpleDist { - - const MEG = 1024*1024; - const alpha = 3.0D; - - const NUM_TIMES = 10; - //const NUM_TIMES = 1; - - //const DEFAULT_SIZE = 2*MEG; - const DEFAULT_SIZE = MEG / 8; - - const NUM_PLACES = Place.MAX_PLACES; - - public static def run():Boolean { - val verified:Rail[boolean]! = [true]; - val times = Rail.make[double](NUM_TIMES); - val N0 = DEFAULT_SIZE; - val N = N0 * NUM_PLACES; - val localSize = N0; - - x10.io.Console.OUT.println("localSize=" + localSize); - - finish { - - for (var pp:int=0; pp<NUM_PLACES; pp++) { - - val p = pp; - - async(Place.places(p)) { - - val a = Rail.make[double](localSize); - val b = Rail.make[double](localSize); - val c = Rail.make[double](localSize); - - for (var i:int=0; i<localSize; i++) { - b(i) = 1.5 * (p*localSize+i); - c(i) = 2.5 * (p*localSize+i); - } - - for (var j:int=0; j<NUM_TIMES; j++) { - if (p==0) (times as Rail[double]!)(j) = -now(); - for (var i:int=0; i<localSize; i++) - a(i) = b(i) + alpha*c(i); - if (p==0) (times as Rail[double]!)(j) = (times as Rail[double]!)(j) + now(); - } - - // verification - for (var i:int=0; i<localSize; i++) - if (a(i) != b(i) + alpha*c(i)) - async(verified) - verified(0) = false; - } - } - } - - var min:double = 1000000; - for (var j:int=0; j<NUM_TIMES; j++) - if (times(j) < min) - min = times(j); - printStats(N, min, verified(0)); - return verified(0); - } - - static def now():double = Timer.nanoTime() * 1e-9; - - static def printStats(N:int, time:double, verified:boolean) { - val size = (3*8*N/MEG); - val rate = (3*8*N) / (1.0E9*time); - x10.io.Console.OUT.println("Number of places=" + NUM_PLACES); - x10.io.Console.OUT.println("Size of arrays: " + size +" MB (total)" + size/NUM_PLACES + " MB (per place)"); - x10.io.Console.OUT.println("Min time: " + time + " rate=" + rate + " GB/s"); - x10.io.Console.OUT.println("Result is " + (verified ? "verified." : "NOT verified.")); - } -} Deleted: trunk/x10.tests/examples/Misc/FSSimpleDistTest.x10 =================================================================== --- trunk/x10.tests/examples/Misc/FSSimpleDistTest.x10 2010-03-12 20:11:39 UTC (rev 13376) +++ trunk/x10.tests/examples/Misc/FSSimpleDistTest.x10 2010-03-12 20:32:59 UTC (rev 13377) @@ -1,22 +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; -public class FSSimpleDistTest extends x10Test { - public def run():boolean { - return new FSSimpleDist().run(); - } - public static def main(Rail[String]) { - new FSSimpleDistTest().execute(); - } - - -} Deleted: trunk/x10.tests/examples/Misc/FSSimpleTest.x10 =================================================================== --- trunk/x10.tests/examples/Misc/FSSimpleTest.x10 2010-03-12 20:11:39 UTC (rev 13376) +++ trunk/x10.tests/examples/Misc/FSSimpleTest.x10 2010-03-12 20:32:59 UTC (rev 13377) @@ -1,22 +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; -public class FSSimpleTest extends x10Test { - public def run():boolean { - return new FSSimple().run(); - } - public static def main(Rail[String]) { - new FSSimpleTest().execute(); - } - - -} Deleted: trunk/x10.tests/examples/Misc/NQueensPar.x10 =================================================================== --- trunk/x10.tests/examples/Misc/NQueensPar.x10 2010-03-12 20:11:39 UTC (rev 13376) +++ trunk/x10.tests/examples/Misc/NQueensPar.x10 2010-03-12 20:32:59 UTC (rev 13377) @@ -1,110 +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 x10.io.Console; - -public class NQueensPar { - - var nSolutions:int = 0; - - public static val expectedSolutions = - [0, 1, 0, 0, 2, 10, 4, 40, 92, 352, 724, 2680, 14200, 73712, 365596, 2279184, 14772512]; - - global val N:Int; - global val P:Int; - - def this(N:Int, P:Int) { this.N=N; this.P=P;} - - def start() { - new Board().search(); - } - - /** - * Return an array of P regions, which together block divide the 1-D region R. - */ - public static def block(R: Region(1), P: Int): ValRail[Region(1)](P) = { - assert P >= 0; - val low = R.min()(0), high = R.max()(0), count = high-low+1; - val baseSize = count/P, extra = count - baseSize*P; - ValRail.make[Region(1)](P, (i:int):Region(1) => { - val start = low+i*baseSize+ (i < extra? i:extra); - start..start+baseSize+(i < extra?0:-1) - }) - } - - class Board { - - val q: Rail[Int]{self.at(this)}; - - def this() { - q = Rail.make[Int](0, (int)=>0); - } - - def this(old: Rail[Int]!, newItem:Int) { - val n = old.length; - q = Rail.make[Int](n+1, (i:int)=> (i < n? old(i) : newItem)); - } - - def safe(j: int) { - val n = q.length; - for ((k) in 0..n-1) { - if (j == q(k) || Math.abs(n-k) == Math.abs(j-q(k))) - return false; - } - return true; - } - - /** Search for all solutions in parallel, on finding - * a solution update nSolutions. - */ - def search(R: Region(1)) { - for ((k) in R) - if (safe(k)) - new Board(q, k).search(); - } - - def search() { - if (q.length == N) { - at (NQueensPar.this) atomic nSolutions++; - return; - } - if (q.length == 0) { - val R = block(0..N-1, P); - foreach ((q) in 0..P-1) - search(R(q)); - } else search(0..N-1); - } - } - - public static def run() { - val n = 8; - var result:boolean = true; - println("N=" + n); - //warmup - //finish new NQueensPar(12, 1).start(); - val ps = [1,2,4]; - for (var i:Int = 0; i < ps.length; i++) { - println("starting " + ps(i) + " threads"); - val nq = new NQueensPar(n,ps(i)); - var start:Long = -System.nanoTime(); - finish nq.start(); - result &= nq.nSolutions==expectedSolutions(nq.N); - start += System.nanoTime(); - start /= 1000000; - println("NQueensPar " + nq.N + "(P=" + ps(i) + - ") has " + nq.nSolutions + " solutions" + - (result? " (ok)." : " (wrong).") + "time=" + start + "ms"); - } - return result; - } - - static def println(s:String) = Console.OUT.println(s); -} Deleted: trunk/x10.tests/examples/Misc/NQueensParTest.x10 =================================================================== --- trunk/x10.tests/examples/Misc/NQueensParTest.x10 2010-03-12 20:11:39 UTC (rev 13376) +++ trunk/x10.tests/examples/Misc/NQueensParTest.x10 2010-03-12 20:32:59 UTC (rev 13377) @@ -1,22 +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; -public class NQueensParTest extends x10Test { - public def run():boolean { - return NQueensPar.run(); - } - public static def main(Rail[String]) { - new NQueensParTest().execute(); - } - - -} Added: trunk/x10.tests/examples/Samples/ArraySumTest.x10 =================================================================== --- trunk/x10.tests/examples/Samples/ArraySumTest.x10 (rev 0) +++ trunk/x10.tests/examples/Samples/ArraySumTest.x10 2010-03-12 20:32:59 UTC (rev 13377) @@ -0,0 +1,24 @@ +/* + * 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; + +public class ArraySumTest extends x10Test { + public def run():boolean { + val args = Rail.make[String](0); + ArraySum.main(args); + return true; + } + + public static def main(args:Rail[String]) { + new ArraySumTest().execute(); + } +} Property changes on: trunk/x10.tests/examples/Samples/ArraySumTest.x10 ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Added: trunk/x10.tests/examples/Samples/CUDABlackScholesTest.x10 =================================================================== --- trunk/x10.tests/examples/Samples/CUDABlackScholesTest.x10 (rev 0) +++ trunk/x10.tests/examples/Samples/CUDABlackScholesTest.x10 2010-03-12 20:32:59 UTC (rev 13377) @@ -0,0 +1,24 @@ +/* + * 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; + +public class CUDABlackScholesTest extends x10Test { + public def run():boolean { + val args = Rail.make[String](0); + CUDABlackScholes.main(args); + return true; + } + + public static def main(args:Rail[String]) { + new CUDABlackScholesTest().execute(); + } +} Property changes on: trunk/x10.tests/examples/Samples/CUDABlackScholesTest.x10 ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Added: trunk/x10.tests/examples/Samples/CUDAKernelTestTest.x10 =================================================================== --- trunk/x10.tests/examples/Samples/CUDAKernelTestTest.x10 (rev 0) +++ trunk/x10.tests/examples/Samples/CUDAKernelTestTest.x10 2010-03-12 20:32:59 UTC (rev 13377) @@ -0,0 +1,24 @@ +/* + * 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; + +public class CUDAKernelTestTest extends x10Test { + public def run():boolean { + val args = Rail.make[String](0); + CUDAKernelTest.main(args); + return true; + } + + public static def main(args:Rail[String]) { + new CUDAKernelTestTest().execute(); + } +} Property changes on: trunk/x10.tests/examples/Samples/CUDAKernelTestTest.x10 ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Added: trunk/x10.tests/examples/Samples/CUDATopologyTest.x10 =================================================================== --- trunk/x10.tests/examples/Samples/CUDATopologyTest.x10 (rev 0) +++ trunk/x10.tests/examples/Samples/CUDATopologyTest.x10 2010-03-12 20:32:59 UTC (rev 13377) @@ -0,0 +1,24 @@ +/* + * 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; + +public class CUDATopologyTestTest extends x10Test { + public def run():boolean { + val args = Rail.make[String](0); + CUDATopologyTest.main(args); + return true; + } + + public static def main(args:Rail[String]) { + new CUDATopologyTestTest().execute(); + } +} Property changes on: trunk/x10.tests/examples/Samples/CUDATopologyTest.x10 ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Added: trunk/x10.tests/examples/Samples/FRASimpleDistTest.x10 =================================================================== --- trunk/x10.tests/examples/Samples/FRASimpleDistTest.x10 (rev 0) +++ trunk/x10.tests/examples/Samples/FRASimpleDistTest.x10 2010-03-12 20:32:59 UTC (rev 13377) @@ -0,0 +1,24 @@ +/* + * 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; + +public class FRASimpleDistTest extends x10Test { + public def run():boolean { + val args = Rail.make[String](0); + FRASimpleDist.main(args); + return true; + } + + public static def main(args:Rail[String]) { + new FRASimpleDistTest().execute(); + } +} Property changes on: trunk/x10.tests/examples/Samples/FRASimpleDistTest.x10 ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Added: trunk/x10.tests/examples/Samples/FSSimpleDistTest.x10 =================================================================== --- trunk/x10.tests/examples/Samples/FSSimpleDistTest.x10 (rev 0) +++ trunk/x10.tests/examples/Samples/FSSimpleDistTest.x10 2010-03-12 20:32:59 UTC (rev 13377) @@ -0,0 +1,24 @@ +/* + * 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; + +public class FSSimpleDistTest extends x10Test { + public def run():boolean { + val args = Rail.make[String](0); + FSSimpleDist.main(args); + return true; + } + + public static def main(args:Rail[String]) { + new FSSimpleDistTest().execute(); + } +} Property changes on: trunk/x10.tests/examples/Samples/FSSimpleDistTest.x10 ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Added: trunk/x10.tests/examples/Samples/GCSpheresTest.x10 =================================================================== --- trunk/x10.tests/examples/Samples/GCSpheresTest.x10 (rev 0) +++ trunk/x10.tests/examples/Samples/GCSpheresTest.x10 2010-03-12 20:32:59 UTC (rev 13377) @@ -0,0 +1,24 @@ +/* + * 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; + +public class GCSpheresTest extends x10Test { + public def run():boolean { + val args = Rail.make[String](0); + GCSpheres.main(args); + return true; + } + + public static def main(args:Rail[String]) { + new GCSpheresTest().execute(); + } +} Property changes on: trunk/x10.tests/examples/Samples/GCSpheresTest.x10 ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Added: trunk/x10.tests/examples/Samples/HelloTest.x10 =================================================================== --- trunk/x10.tests/examples/Samples/HelloTest.x10 (rev 0) +++ trunk/x10.tests/examples/Samples/HelloTest.x10 2010-03-12 20:32:59 UTC (rev 13377) @@ -0,0 +1,24 @@ +/* + * 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; + +public class HelloTest extends x10Test { + public def run():boolean { + val args = Rail.make[String](0); + Hello.main(args); + return true; + } + + public static def main(args:Rail[String]) { + new HelloTest().execute(); + } +} Property changes on: trunk/x10.tests/examples/Samples/HelloTest.x10 ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Added: trunk/x10.tests/examples/Samples/HelloWholeWorldTest.x10 =================================================================== --- trunk/x10.tests/examples/Samples/HelloWholeWorldTest.x10 (rev 0) +++ trunk/x10.tests/examples/Samples/HelloWholeWorldTest.x10 2010-03-12 20:32:59 UTC (rev 13377) @@ -0,0 +1,24 @@ +/* + * 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; + +public class HelloWholeWorldTest extends x10Test { + public def run():boolean { + val args = Rail.make[String](0); + HelloWholeWorld.main(args); + return true; + } + + public static def main(args:Rail[String]) { + new HelloWholeWorldTest().execute(); + } +} Property changes on: trunk/x10.tests/examples/Samples/HelloWholeWorldTest.x10 ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Deleted: trunk/x10.tests/examples/Samples/HelloWorldParTest.x10 =================================================================== --- trunk/x10.tests/examples/Samples/HelloWorldParTest.x10 2010-03-12 20:11:39 UTC (rev 13376) +++ trunk/x10.tests/examples/Samples/HelloWorldParTest.x10 2010-03-12 20:32:59 UTC (rev 13377) @@ -1,24 +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; - -public class HelloWorldParTest extends x10Test { - public def run():boolean { - val args = Rail.make[String](0); - HelloWorldPar.main(args); - return true; - } - - public static def main(args:Rail[String]) { - new HelloWorldParTest().execute(); - } -} Added: trunk/x10.tests/examples/Samples/HelloWorldTest.x10 =================================================================== --- trunk/x10.tests/examples/Samples/HelloWorldTest.x10 (rev 0) +++ trunk/x10.tests/examples/Samples/HelloWorldTest.x10 2010-03-12 20:32:59 UTC (rev 13377) @@ -0,0 +1,24 @@ +/* + * 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; + +public class HelloWorldTest extends x10Test { + public def run():boolean { + val args = Rail.make[String](0); + HelloWorld.main(args); + return true; + } + + public static def main(args:Rail[String]) { + new HelloWorldTest().execute(); + } +} Property changes on: trunk/x10.tests/examples/Samples/HelloWorldTest.x10 ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Added: trunk/x10.tests/examples/Samples/HistogramTest.x10 =================================================================== --- trunk/x10.tests/examples/Samples/HistogramTest.x10 (rev 0) +++ trunk/x10.tests/examples/Samples/HistogramTest.x10 2010-03-12 20:32:59 UTC (rev 13377) @@ -0,0 +1,24 @@ +/* + * 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; + +public class HistogramTest extends x10Test { + public def run():boolean { + val args = Rail.make[String](0); + Histogram.main(args); + return true; + } + + public static def main(args:Rail[String]) { + new HistogramTest().execute(); + } +} Property changes on: trunk/x10.tests/examples/Samples/HistogramTest.x10 ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Added: trunk/x10.tests/examples/Samples/KMeansCUDATest.x10 =================================================================== --- trunk/x10.tests/examples/Samples/KMeansCUDATest.x10 (rev 0) +++ trunk/x10.tests/examples/Samples/KMeansCUDATest.x10 2010-03-12 20:32:59 UTC (rev 13377) @@ -0,0 +1,24 @@ +/* + * 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; + +public class KMeansCUDATest extends x10Test { + public def run():boolean { + val args = Rail.make[String](0); + KMeansCUDA.main(args); + return true; + } + + public static def main(args:Rail[String]) { + new KMeansCUDATest().execute(); + } +} Property changes on: trunk/x10.tests/examples/Samples/KMeansCUDATest.x10 ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Added: trunk/x10.tests/examples/Samples/KMeansDistTest.x10 =================================================================== --- trunk/x10.tests/examples/Samples/KMeansDistTest.x10 (rev 0) +++ trunk/x10.tests/examples/Samples/KMeansDistTest.x10 2010-03-12 20:32:59 UTC (rev 13377) @@ -0,0 +1,24 @@ +/* + * 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; + +public class KMeansDistTest extends x10Test { + public def run():boolean { + val args = Rail.make[String](0); + KMeansDist.main(args); + return true; + } + + public static def main(args:Rail[String]) { + new KMeansDistTest().execute(); + } +} Property changes on: trunk/x10.tests/examples/Samples/KMeansDistTest.x10 ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Added: trunk/x10.tests/examples/Samples/KMeansSPMDTest.x10 =================================================================== --- trunk/x10.tests/examples/Samples/KMeansSPMDTest.x10 (rev 0) +++ trunk/x10.tests/examples/Samples/KMeansSPMDTest.x10 2010-03-12 20:32:59 UTC (rev 13377) @@ -0,0 +1,24 @@ +/* + * 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; + +public class KMeansSPMDTest extends x10Test { + public def run():boolean { + val args = Rail.make[String](0); + KMeansSPMD.main(args); + return true; + } + + public static def main(args:Rail[String]) { + new KMeansSPMDTest().execute(); + } +} Property changes on: trunk/x10.tests/examples/Samples/KMeansSPMDTest.x10 ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Added: trunk/x10.tests/examples/Samples/KMeansTest.x10 =================================================================== --- trunk/x10.tests/examples/Samples/KMeansTest.x10 (rev 0) +++ trunk/x10.tests/examples/Samples/KMeansTest.x10 2010-03-12 20:32:59 UTC (rev 13377) @@ -0,0 +1,24 @@ +/* + * 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; + +public class KMeansTest extends x10Test { + public def run():boolean { + val args = Rail.make[String](0); + KMeans.main(args); + return true; + } + + public static def main(args:Rail[String]) { + new KMeansTest().execute(); + } +} Property changes on: trunk/x10.tests/examples/Samples/KMeansTest.x10 ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Added: trunk/x10.tests/examples/Samples/MontyPiTest.x10 =================================================================== --- trunk/x10.tests/examples/Samples/MontyPiTest.x10 (rev 0) +++ trunk/x10.tests/examples/Samples/MontyPiTest.x10 2010-03-12 20:32:59 UTC (rev 13377) @@ -0,0 +1,24 @@ +/* + * 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; + +public class MontyPiTest extends x10Test { + public def run():boolean { + val args = ["10000"] as Rail[String]; + MontyPi.main(args); + return true; + } + + public static def main(args:Rail[String]) { + new MontyPiTest().execute(); + } +} Property changes on: trunk/x10.tests/examples/Samples/MontyPiTest.x10 ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Added: trunk/x10.tests/examples/Samples/NQueensDistTest.x10 =================================================================== --- trunk/x10.tests/examples/Samples/NQueensDistTest.x10 (rev 0) +++ trunk/x10.tests/examples/Samples/NQueensDistTest.x10 2010-03-12 20:32:59 UTC (rev 13377) @@ -0,0 +1,24 @@ +/* + * 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; + +public class NQueensDistTest extends x10Test { + public def run():boolean { + val args = Rail.make[String](0); + NQueensDist.main(args); + return true; + } + + public static def main(args:Rail[String]) { + new NQueensDistTest().execute(); + } +} Property changes on: trunk/x10.tests/examples/Samples/NQueensDistTest.x10 ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Added: trunk/x10.tests/examples/Samples/NQueensParTest.x10 =================================================================== --- trunk/x10.tests/examples/Samples/NQueensParTest.x10 (rev 0) +++ trunk/x10.tests/examples/Samples/NQueensParTest.x10 2010-03-12 20:32:59 UTC (rev 13377) @@ -0,0 +1,24 @@ +/* + * 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; + +public class NQueensParTest extends x10Test { + public def run():boolean { + val args = Rail.make[String](0); + NQueensPar.main(args); + return true; + } + + public static def main(args:Rail[String]) { + new NQueensParTest().execute(); + } +} Property changes on: trunk/x10.tests/examples/Samples/NQueensParTest.x10 ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Added: trunk/x10.tests/examples/Samples/StructSpheresTest.x10 =================================================================== --- trunk/x10.tests/examples/Samples/StructSpheresTest.x10 (rev 0) +++ trunk/x10.tests/examples/Samples/StructSpheresTest.x10 2010-03-12 20:32:59 UTC (rev 13377) @@ -0,0 +1,24 @@ +/* + * 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; + +public class StructSpheresTest extends x10Test { + public def run():boolean { + val args = Rail.make[String](0); + StructSpheres.main(args); + return true; + } + + public static def main(args:Rail[String]) { + new StructSpheresTest().execute(); + } +} Property changes on: trunk/x10.tests/examples/Samples/StructSpheresTest.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. |
From: <dgr...@us...> - 2010-03-12 21:00:24
|
Revision: 13381 http://x10.svn.sourceforge.net/x10/?rev=13381&view=rev Author: dgrove-oss Date: 2010-03-12 21:00:18 +0000 (Fri, 12 Mar 2010) Log Message: ----------- svn housecleaning. Remove obsolete version of wala-bridge code. The current "real" version of this code is on the polyglot3 branch. at some point it will be merged back into trunk, but the code in the trunk copy of the projects is no longer relevant. Removed Paths: ------------- trunk/com.ibm.wala.cast.x10/ trunk/com.ibm.wala.cast.x10.tests/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dgr...@us...> - 2010-03-15 19:27:56
|
Revision: 13413 http://x10.svn.sourceforge.net/x10/?rev=13413&view=rev Author: dgrove-oss Date: 2010-03-15 19:27:49 +0000 (Mon, 15 Mar 2010) Log Message: ----------- Add rules to create a java_x10rt wrapper script based on x10 wrapper script. Update x10rt/test-jni for changes to new Java X10RT API; CountPlaces test is working again. Modified Paths: -------------- trunk/x10.dist/build.xml trunk/x10.runtime/x10rt/test-jni/CountPlaces.java trunk/x10.runtime/x10rt/test-jni/Latency.java trunk/x10.runtime/x10rt/test-jni/Makefile trunk/x10.runtime/x10rt/test-jni/SerializationTest.java trunk/x10.runtime/x10rt/test-jni/SimpleMessageTest.java Added Paths: ----------- trunk/x10.dist/bin/java_x10rt.in Property Changed: ---------------- trunk/x10.dist/bin/ Property changes on: trunk/x10.dist/bin ___________________________________________________________________ Modified: svn:ignore - x10 x10c setupX10 daemon launcher manager daemon.exe launcher.exe manager.exe + x10 x10c setupX10 daemon launcher manager daemon.exe launcher.exe manager.exe java_x10rt Copied: trunk/x10.dist/bin/java_x10rt.in (from rev 13407, trunk/x10.dist/bin/x10.in) =================================================================== --- trunk/x10.dist/bin/java_x10rt.in (rev 0) +++ trunk/x10.dist/bin/java_x10rt.in 2010-03-15 19:27:49 UTC (rev 13413) @@ -0,0 +1,78 @@ +help="" +time="" +verbose="" +extra_cp="" +extra_lib="" +mx="" +defs="" +dev="" +java_args="" +args="" + +while [ -n "$1" ]; do + case "$1" in + -h|-help|--help) help="1"; break;; + -mx) shift; mx="$1";; + -D*) if [[ "${1##-D}" = java.library.path=* ]]; then + echo >&2 "Error: Cannot reset java.library.path, use -libpath instead" + exit 1 + fi + # TODO: add tests for more system properties above + defs="${defs} $1";; + -classpath|-cp) shift; extra_cp="$1";; + -libpath) shift; extra_lib="$1";; + -config) shift; config="$1.cfg";; + -dev) dev="true";; + -J*) java_args="${java_args} '${1##-J}'";; + -*=*) java_args="${java_args} -Dx10.${1##-}";; + -*) java_args="${java_args} -Dx10.${1##-}=true";; + *) args="$args $1"; shift; args="$args $*"; break;; + esac + shift +done + +if [ -n "$help" -o -z "$args" ]; then + cat << EOF +Usage: java_x10rt [options] <main-class> [arg0 arg1 ...] +where [options] includes: + -h -help --help print this message + -mx <size> set max heap size, e.g., -mx 200M + -D<name>=<value> set system property <name> to <value> + -classpath <path> search path for class files + -libpath <path> search path for native libraries + -J<arg> [USE WITH CAUTION] pass <arg> directly to java. + e.g., use -J-verbose to make java execution verbose. +EOF + exit 1 +fi + + +LIB_DIR="${TOP}${FILE_SEP}lib" + +classpath="" +[ -n "$dev" ] && classpath="${TOP}${FILE_SEP}..${FILE_SEP}x10.runtime${FILE_SEP}classes${PATH_SEP}" +classpath=".${PATH_SEP}${classpath}${LIB_DIR}${FILE_SEP}x10.jar" + +if [ -n "$extra_cp" ]; then + classpath="$extra_cp${PATH_SEP}$classpath" +fi + +externpath="${classpath}${PATH_SEP}${LIB_DIR}" +if [ -n "$extra_lib" ]; then + externpath="$extra_lib${PATH_SEP}$externpath" +fi + +java_args="-Djava.library.path=\"$externpath\" -ea -classpath \"$classpath\" ${java_args}" + +if [ -n "$mx" ]; then + java_args="-Xmx$mx $java_args" +fi +java_args="${java_args} ${defs}" + +command="\"$JAVA\" $java_args $config $args" + +[ -n "$verbose" ] && echo "$command" + +eval "$command" +exit $? + Modified: trunk/x10.dist/build.xml =================================================================== --- trunk/x10.dist/build.xml 2010-03-15 19:08:26 UTC (rev 13412) +++ trunk/x10.dist/build.xml 2010-03-15 19:27:49 UTC (rev 13413) @@ -62,6 +62,7 @@ <fileset dir="${bin}"> <include name="defs"/> <include name="setupX10"/> + <include name="java_x10rt"/> <include name="x10"/> <include name="x10c"/> </fileset> @@ -222,6 +223,7 @@ <antcall target="setupX10"/> <antcall target="x10"/> <antcall target="x10c"/> + <antcall target="java_x10rt"/> </target> <target name="etc" @@ -251,11 +253,16 @@ <srcfiles file="${ant.file}"/> <srcfiles file="${bin}/x10c.in"/> </uptodate> + <uptodate property="java_x10rt.up-to-date" targetfile="${bin}/java_x10rt"> + <srcfiles file="${ant.file}"/> + <srcfiles file="${bin}/java_x10rt.in"/> + </uptodate> <condition property="bin.up-to-date"> <and> <isset property="setupX10.up-to-date"/> <isset property="x10.up-to-date"/> <isset property="x10c.up-to-date"/> + <isset property="java_x10rt.up-to-date"/> </and> </condition> </target> @@ -413,6 +420,22 @@ <delete file="${bin}/defs"/> </target> + <target name="java_x10rt" unless="java_x10rt.up-to-date" + depends="executable-defs" + description="creates the executable script x10"> + <echo message="Creating ${bin}/java_x10rt"/> + <concat destfile="${bin}/java_x10rt" append="no"> + <filelist dir="${bin}" files="defs"/> + </concat> + <concat destfile="${bin}/java_x10rt" append="yes"> + <filelist dir="${bin}" files="java_x10rt.in"/> + </concat> + + <chmod perm="+x" file="${bin}/java_x10rt"/> + + <delete file="${bin}/defs"/> + </target> + <!-- the following lines have only ever been tested on AIX --> <!-- they build the LAPI support library --> <target name="buildLAPISupportTask"> Modified: trunk/x10.runtime/x10rt/test-jni/CountPlaces.java =================================================================== --- trunk/x10.runtime/x10rt/test-jni/CountPlaces.java 2010-03-15 19:08:26 UTC (rev 13412) +++ trunk/x10.runtime/x10rt/test-jni/CountPlaces.java 2010-03-15 19:27:49 UTC (rev 13413) @@ -16,12 +16,12 @@ X10RT.barrier(); - if (X10RT.here() == X10RT.getNode(X10RT.numNodes()-1)) { + if (X10RT.here() == X10RT.getPlace(X10RT.numPlaces()-1)) { System.out.println(X10RT.here()+" is about to sleep for 1 second..."); Thread.sleep(1000); System.out.println("Hello world: I am the tardy node "+X10RT.here()); } else { - System.out.println("Hello world: There are " +X10RT.numNodes()+" Nodes and I am "+X10RT.here()); + System.out.println("Hello world: There are " +X10RT.numPlaces()+" Places and I am "+X10RT.here()); } X10RT.barrier(); Modified: trunk/x10.runtime/x10rt/test-jni/Latency.java =================================================================== --- trunk/x10.runtime/x10rt/test-jni/Latency.java 2010-03-15 19:08:26 UTC (rev 13412) +++ trunk/x10.runtime/x10rt/test-jni/Latency.java 2010-03-15 19:27:49 UTC (rev 13413) @@ -11,7 +11,7 @@ import x10.x10rt.ActiveMessage; import x10.x10rt.MessageRegistry; -import x10.x10rt.Node; +import x10.x10rt.Place; import x10.x10rt.X10RT; import x10.x10rt.UnknownMessageException; @@ -26,9 +26,9 @@ int [] sbuf = new int[MAXBUFSIZE]; int rank = X10RT.here().getId(); - Node otherNode = X10RT.getNode(rank^1); + Place otherPlace = X10RT.getPlace(rank^1); - if(2 != X10RT.numNodes()) { + if(2 != X10RT.numPlaces()) { System.err.println("This test requires exactly 2 processes"); System.exit(1); } @@ -51,15 +51,15 @@ for(int buflen=1; buflen <= MAXBUFSIZE; buflen <<= 1) { X10RT.barrier(); ++ _g_flagcntr; - ping.send(otherNode, 0, buflen-1, sbuf); - while(_g_flag < _g_flagcntr) X10RT.poll(); + ping.send(otherPlace, 0, buflen-1, sbuf); + while(_g_flag < _g_flagcntr) X10RT.probe(); int niters = (buflen > 10000) ? 10 : 100; X10RT.barrier(); long t0 = System.nanoTime(); for(int i=0; i < niters; ++i) { ++ _g_flagcntr; - ping.send(otherNode, 0, buflen-1, sbuf); - while (_g_flag < _g_flagcntr) X10RT.poll(); + ping.send(otherPlace, 0, buflen-1, sbuf); + while (_g_flag < _g_flagcntr) X10RT.probe(); } long t1 = System.nanoTime(); if (rank == 0) { Modified: trunk/x10.runtime/x10rt/test-jni/Makefile =================================================================== --- trunk/x10.runtime/x10rt/test-jni/Makefile 2010-03-15 19:08:26 UTC (rev 13412) +++ trunk/x10.runtime/x10rt/test-jni/Makefile 2010-03-15 19:27:49 UTC (rev 13413) @@ -13,22 +13,22 @@ CLASSES = ${SRCS:.java=.class} -default: compile tests +default: compile test compile: $(CLASSES) test: serializationtest countplaces simplemessagetest latency serializationtest: SerializationTest.class - mpirun -n 2 java -cp $(X10RT_JAR):. -Djava.library.path=$(X10RT_LIBS) SerializationTest + mpirun -n 2 $(X10_DIST)/bin/java_x10rt SerializationTest countplaces: CountPlaces.class - mpirun -n 4 java -cp $(X10RT_JAR):. -Djava.library.path=$(X10RT_LIBS) CountPlaces + mpirun -n 4 $(X10_DIST)/bin/java_x10rt CountPlaces simplemessagetest: SimpleMessageTest.class - mpirun -n 4 java -cp $(X10RT_JAR):. -Djava.library.path=$(X10RT_LIBS) SimpleMessageTest + mpirun -n 4 $(X10_DIST)/bin/java_x10rt SimpleMessageTest latency: Latency.class - mpirun -n 2 java -cp $(X10RT_JAR):. -Djava.library.path=$(X10RT_LIBS) Latency + mpirun -n 2 $(X10_DIST)/bin/java_x10rt Latency .PHONY: compile test Modified: trunk/x10.runtime/x10rt/test-jni/SerializationTest.java =================================================================== --- trunk/x10.runtime/x10rt/test-jni/SerializationTest.java 2010-03-15 19:08:26 UTC (rev 13412) +++ trunk/x10.runtime/x10rt/test-jni/SerializationTest.java 2010-03-15 19:27:49 UTC (rev 13413) @@ -70,9 +70,9 @@ X10RT.barrier(); if(0 == X10RT.here().getId()) { - msg.send(X10RT.getNode(0), obj); + msg.send(X10RT.getPlace(0), obj); - msg2.send(X10RT.getNode(0), obj); + msg2.send(X10RT.getPlace(0), obj); } X10RT.barrier(); Modified: trunk/x10.runtime/x10rt/test-jni/SimpleMessageTest.java =================================================================== --- trunk/x10.runtime/x10rt/test-jni/SimpleMessageTest.java 2010-03-15 19:08:26 UTC (rev 13412) +++ trunk/x10.runtime/x10rt/test-jni/SimpleMessageTest.java 2010-03-15 19:27:49 UTC (rev 13413) @@ -11,7 +11,7 @@ import x10.x10rt.ActiveMessage; import x10.x10rt.MessageRegistry; -import x10.x10rt.Node; +import x10.x10rt.Place; import x10.x10rt.X10RT; import x10.x10rt.UnknownMessageException; @@ -36,9 +36,9 @@ X10RT.barrier(); - if (X10RT.here() == X10RT.getNode(0)) { - for (int i=0; i<X10RT.numNodes(); i++) { - Node where = X10RT.getNode(i); + if (X10RT.here() == X10RT.getPlace(0)) { + for (int i=0; i<X10RT.numPlaces(); i++) { + Place where = X10RT.getPlace(i); ping.send(where); add.send(where, 10+i, 20+i); addScaled.send(where, new int[] { 1, 2, 3, 4, 5 }, 10); @@ -85,7 +85,7 @@ public static void ping() throws UnknownMessageException, IllegalArgumentException { System.out.println(X10RT.here()+ ": PING"); - MessageRegistry.lookup(SimpleMessageTest.class, "pong", Integer.TYPE).send(X10RT.getNode(0), X10RT.here().getId()); + MessageRegistry.lookup(SimpleMessageTest.class, "pong", Integer.TYPE).send(X10RT.getPlace(0), X10RT.here().getId()); } public static void pong(int where) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ipe...@us...> - 2010-03-15 20:04:18
|
Revision: 13415 http://x10.svn.sourceforge.net/x10/?rev=13415&view=rev Author: ipeshansky Date: 2010-03-15 20:04:11 +0000 (Mon, 15 Mar 2010) Log Message: ----------- Update to latest debug info spec. Modified Paths: -------------- trunk/x10.compiler/src/x10cpp/debug/LineNumberMap.java trunk/x10.runtime/src-cpp/x10aux/debug.h Modified: trunk/x10.compiler/src/x10cpp/debug/LineNumberMap.java =================================================================== --- trunk/x10.compiler/src/x10cpp/debug/LineNumberMap.java 2010-03-15 19:58:42 UTC (rev 13414) +++ trunk/x10.compiler/src/x10cpp/debug/LineNumberMap.java 2010-03-15 20:04:11 UTC (rev 13415) @@ -639,6 +639,45 @@ } w.writeln("};"); } + + // A meta-structure that refers to all of the above + w.write("static const struct _MetaDebugInfo_t _MetaDebugInfo __attribute__((used)) = {"); + w.newline(4); w.begin(0); + w.writeln("sizeof(struct _MetaDebugInfo_t),"); + w.writeln("X10_META_LANG,"); + w.writeln("0,"); + w.writeln("sizeof(_X10strings),"); + if (!m.isEmpty()) { + w.writeln("sizeof(_X10sourceList),"); + w.writeln("sizeof(_X10toCPPlist),"); + w.writeln("sizeof(_CPPtoX10xrefList),"); + } else { + w.writeln("0,"); + w.writeln("0,"); + w.writeln("0,"); + } + if (!m.methods.isEmpty()) { + w.writeln("sizeof(_X10methodNameList),"); + } else { + w.writeln("0,"); + } + w.writeln("_X10strings,"); + if (!m.isEmpty()) { + w.writeln("_X10sourceList,"); + w.writeln("_X10toCPPlist,"); + w.writeln("_CPPtoX10xrefList,"); + } else { + w.writeln("NULL,"); + w.writeln("NULL,"); + w.writeln("NULL,"); + } + if (!m.methods.isEmpty()) { + w.write("_X10methodNameList,"); + } else { + w.write("NULL,"); + } + w.end(); w.newline(); + w.writeln("};"); } private static String encodeIntAsChars(int i) { Modified: trunk/x10.runtime/src-cpp/x10aux/debug.h =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/debug.h 2010-03-15 19:58:42 UTC (rev 13414) +++ trunk/x10.runtime/src-cpp/x10aux/debug.h 2010-03-15 20:04:11 UTC (rev 13415) @@ -38,6 +38,21 @@ // static const struct _X10methodName _X10methodNameList[] = {}; // // A list of the X10 method names. // // Sorted by X10 method name. +// static const struct _MetaDebugInfo _MetaDebugInfo __attribute__((used)) = { +// sizeof(struct _MetaDebugInfo), +// X10_META_LANG, +// sizeof(_X10strings), +// sizeof(_X10sourceList), +// sizeof(_X10toCPPlist), +// sizeof(_CPPtoX10xrefList), +// sizeof(_X10methodNameList), +// _X10strings, +// _X10sourceList, +// _X10toCPPlist, +// _CPPtoX10xrefList, +// _X10methodNameList +// }; +// // A meta-structure that refers to all of the above struct _X10sourceFile { @@ -64,10 +79,6 @@ 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 @@ -81,6 +92,33 @@ uint16_t _lineIndex; // Index into _X10toCPPlist of the first line of the method }; +enum _MetaLanguage { + X10_META_LANG = 0 // Metalanguage 0 is X10 +}; + +#ifndef NULL +#define NULL ((void*)0) +#endif + +struct _MetaDebugInfo_t { + unsigned short structSize; // size of this structure + unsigned char metalanguage; // language (allows the use of this technique for other languages) + unsigned char debugVersion; // version of this structure (so we can change it in future) + + // The remainder of this structure is language/version specific + unsigned x10stringSize; // the size in bytes of the string table (including the trailing NUL) + unsigned x10sourceListSize; // the size in bytes of the X10 source list + unsigned x10toCPPlistSize; // the size in bytes of the X10->C++ cross reference + unsigned cPPtoX10xrefListSize; // the size in bytes of the C++->X10 cross reference + unsigned x10methodNameListSize; // the size in bytes of the X10 method name mapping list + + const char* x10strings; // The string table + const struct _X10sourceFile* x10sourceList; // The list of X10 source files + const struct _X10toCPPxref* x10toCPPlist; // The X10->C++ cross reference + const struct _CPPtoX10xref* cPPtoX10xrefList; // The C++->X10 cross reference + const struct _X10methodName* x10methodNameList; // The method name mapping list +}; + 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. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <spa...@us...> - 2010-03-20 07:20:06
|
Revision: 13478 http://x10.svn.sourceforge.net/x10/?rev=13478&view=rev Author: sparksparkspark Date: 2010-03-20 07:19:59 +0000 (Sat, 20 Mar 2010) Log Message: ----------- WIP on outstanding CUDA issues Modified Paths: -------------- trunk/x10.compiler/src/x10cuda/visit/CUDACodeGenerator.java trunk/x10.runtime/src-cpp/x10aux/deserialization_dispatcher.h trunk/x10.runtime/src-cpp/x10aux/network.cc trunk/x10.runtime/x10rt/common/x10rt_cuda.cc Modified: trunk/x10.compiler/src/x10cuda/visit/CUDACodeGenerator.java =================================================================== --- trunk/x10.compiler/src/x10cuda/visit/CUDACodeGenerator.java 2010-03-20 05:45:37 UTC (rev 13477) +++ trunk/x10.compiler/src/x10cuda/visit/CUDACodeGenerator.java 2010-03-20 07:19:59 UTC (rev 13478) @@ -579,7 +579,7 @@ if (nodeHasCUDAAnnotation(block)) { - inc.write("static x10_ulong "+SharedVarsMethods.DESERIALIZE_CUDA_METHOD+"("+DESERIALIZATION_BUFFER+" &__buf, x10aux::place __gpu, size_t &__blocks, size_t &__threads, size_t &__shm) {"); + inc.write("static void "+SharedVarsMethods.DESERIALIZE_CUDA_METHOD+"("+DESERIALIZATION_BUFFER+" &__buf, x10aux::place __gpu, size_t &__blocks, size_t &__threads, size_t &__shm, size_t &argc, char *&argv, size_t &cmemc, char *&cmemv) {"); inc.newline(4); inc.begin(0); inc.write(make_ref(cnamet)+" __this = "+cnamet+"::"+DESERIALIZE_METHOD+"<"+cnamet+">(__buf);"); @@ -647,10 +647,16 @@ inc.write(";"); inc.newline(); } - inc.write("x10_ulong __remote_env = x10aux::remote_alloc(__gpu, sizeof(__env));"); inc.newline(); - inc.write("x10aux::cuda_put(__gpu, __remote_env, &__env, sizeof(__env));"); inc.newline(); - inc.write("return __remote_env;"); inc.end(); inc.newline(); - inc.write("}"); inc.newline(); inc.forceNewline(); + if (true) { + inc.write("x10_ulong __remote_env = x10aux::remote_alloc(__gpu, sizeof(__env));"); inc.newline(); + inc.write("x10aux::cuda_put(__gpu, __remote_env, &__env, sizeof(__env));"); inc.newline(); + inc.write("::memcpy(argv, &__remote_env, sizeof (void*));"); inc.newline(); + inc.write("argc = sizeof(void*);"); inc.end(); inc.newline(); + } else { + inc.write("memcpy(argv, __env, sizeof(__env));"); inc.newline(); + inc.write("argc = sizeof(__env);"); inc.end(); inc.newline(); + } + inc.write("}"); inc.newline(); inc.forceNewline(); } } @@ -660,14 +666,8 @@ } @Override - public void visit(ArrayInit_c n) { - // TODO Auto-generated method stub - super.visit(n); - } - - @Override public void visit(Assert_c n) { - // TODO Auto-generated method stub + assert !generatingKernel() : "Throwing exceptions not allowed in @CUDA code."; super.visit(n); } @@ -685,7 +685,7 @@ @Override public void visit(Await_c n) { - // TODO Auto-generated method stub + assert !generatingKernel() : "Await not allowed in @CUDA code."; super.visit(n); } @@ -715,7 +715,7 @@ @Override public void visit(Catch_c n) { - // TODO Auto-generated method stub + assert !generatingKernel() : "Catching exceptions not allowed in @CUDA code."; super.visit(n); } @@ -726,14 +726,8 @@ } @Override - public void visit(ClassBody_c n) { - // TODO Auto-generated method stub - super.visit(n); - } - - @Override public void visit(ClosureCall_c c) { - // TODO Auto-generated method stub + assert !generatingKernel() : "Closure calls not allowed in @CUDA code."; super.visit(c); } @@ -744,18 +738,6 @@ } @Override - public void visit(ConstantDistMaker_c n) { - // TODO Auto-generated method stub - super.visit(n); - } - - @Override - public void visit(ConstructorDecl_c dec) { - // TODO Auto-generated method stub - super.visit(dec); - } - - @Override public void visit(Do_c n) { // TODO Auto-generated method stub super.visit(n); @@ -780,12 +762,6 @@ } @Override - public void visit(FieldDecl_c dec) { - // TODO Auto-generated method stub - super.visit(dec); - } - - @Override public void visit(FloatLit_c n) { // TODO Auto-generated method stub super.visit(n); @@ -822,12 +798,6 @@ } @Override - public void visit(Import_c n) { - // TODO Auto-generated method stub - super.visit(n); - } - - @Override public void visit(Initializer_c n) { // TODO Auto-generated method stub super.visit(n); @@ -877,60 +847,12 @@ } @Override - public void visit(LocalClassDecl_c n) { - // TODO Auto-generated method stub - super.visit(n); - } - - @Override - public void visit(LocalDecl_c dec) { - // TODO Auto-generated method stub - super.visit(dec); - } - - @Override - public void visit(MethodDecl_c dec) { - // TODO Auto-generated method stub - super.visit(dec); - } - - @Override - public void visit(Node n) { - // TODO Auto-generated method stub - super.visit(n); - } - - @Override public void visit(NullLit_c n) { // TODO Auto-generated method stub super.visit(n); } @Override - public void visit(PackageNode_c n) { - // TODO Auto-generated method stub - super.visit(n); - } - - @Override - public void visit(ParExpr_c n) { - // TODO Auto-generated method stub - super.visit(n); - } - - @Override - public void visit(PropertyDecl_c n) { - // TODO Auto-generated method stub - super.visit(n); - } - - @Override - public void visit(RegionMaker_c n) { - // TODO Auto-generated method stub - super.visit(n); - } - - @Override public void visit(Return_c ret) { // TODO Auto-generated method stub super.visit(ret); @@ -962,13 +884,13 @@ @Override public void visit(Throw_c n) { - // TODO Auto-generated method stub + assert !generatingKernel() : "Throwing exceptions not allowed in @CUDA code."; super.visit(n); } @Override public void visit(Try_c n) { - // TODO Auto-generated method stub + assert !generatingKernel() : "Catching exceptions not allowed in @CUDA code."; super.visit(n); } @@ -1004,7 +926,8 @@ @Override public void visit(X10Call_c n) { - // TODO Auto-generated method stub + // In fact they are allowed, as long as they are implemented with @Native + //assert !generatingKernel() : "Calling functions not allowed in @CUDA code."; super.visit(n); } @@ -1028,7 +951,7 @@ @Override public void visit(X10Instanceof_c n) { - // TODO Auto-generated method stub + assert !generatingKernel() : "Runtime types not available in @CUDA code."; super.visit(n); } Modified: trunk/x10.runtime/src-cpp/x10aux/deserialization_dispatcher.h =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/deserialization_dispatcher.h 2010-03-20 05:45:37 UTC (rev 13477) +++ trunk/x10.runtime/src-cpp/x10aux/deserialization_dispatcher.h 2010-03-20 07:19:59 UTC (rev 13478) @@ -26,8 +26,8 @@ typedef ref<x10::lang::Object> (*Deserializer)(deserialization_buffer &buf); template<> inline const char *typeName<Deserializer>() { return "Deserializer"; } - typedef x10_ulong (*CUDAPre)(deserialization_buffer &buf, place p, - size_t &blocks, size_t &threads, size_t &shm); + typedef void (*CUDAPre)(deserialization_buffer &buf, place p, + size_t &blocks, size_t &threads, size_t &shm, size_t &argc, char *&argv, size_t &cmemc, char *&cmemv); template<> inline const char *typeName<CUDAPre>() { return "CUDAPre"; } typedef void *(*BufferFinder)(deserialization_buffer &buf, x10_int len); Modified: trunk/x10.runtime/src-cpp/x10aux/network.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/network.cc 2010-03-20 05:45:37 UTC (rev 13477) +++ trunk/x10.runtime/src-cpp/x10aux/network.cc 2010-03-20 07:19:59 UTC (rev 13478) @@ -294,16 +294,14 @@ // note: high bytes thrown away in implicit conversion serialization_id_t sid = x10aux::DeserializationDispatcher::getSerializationId(p->type); x10aux::CUDAPre pre = x10aux::DeserializationDispatcher::getCUDAPre(sid); - x10_ulong env = pre(buf, p->dest_place, *blocks, *threads, *shm); + pre(buf, p->dest_place, *blocks, *threads, *shm, *argc, *argv, *cmemc, *cmemv); assert(buf.consumed() <= p->len); - *argv = (char*)(size_t)env; - *argc = sizeof(void*); } static void cuda_post (const x10rt_msg_params *p, void *env) { _X_(ANSI_X10RT<<"Receiving a kernel post callback, deserialising..."<<ANSI_RESET); - remote_free(p->dest_place, (x10_ulong)(size_t)env); + //remote_free(p->dest_place, (x10_ulong)(size_t)env); x10aux::deserialization_buffer buf(static_cast<char*>(p->msg)); x10aux::ref<x10::lang::Reference> fs = buf.read<x10aux::ref<x10::lang::Reference> >(); x10aux::ref<x10::lang::Runtime> rt = x10::lang::PlaceLocalHandle_methods<x10aux::ref<x10::lang::Runtime> >::apply(x10::lang::Runtime::FMGL(runtime)); Modified: trunk/x10.runtime/x10rt/common/x10rt_cuda.cc =================================================================== --- trunk/x10.runtime/x10rt/common/x10rt_cuda.cc 2010-03-20 05:45:37 UTC (rev 13477) +++ trunk/x10.runtime/x10rt/common/x10rt_cuda.cc 2010-03-20 07:19:59 UTC (rev 13478) @@ -22,7 +22,7 @@ // TODO: fine grained synchronisation, lock free datastructures pthread_mutex_t big_lock_of_doom; - static inline void DEBUG(const char *fmt, ...) { + inline void DEBUG(const char *fmt, ...) { (void) fmt; va_list ap; va_start(ap, fmt); @@ -108,7 +108,7 @@ /* }}} */ - static size_t dma_slice_sz (void) { + size_t dma_slice_sz (void) { static size_t sz = 0; if (sz == 0) { const char *env_var = "X10RT_CUDA_DMA_SLICE"; @@ -275,6 +275,7 @@ void *pinned_mem2; void *front; void *back; + size_t commit; op_queue<x10rt_cuda_kernel> kernel_q; op_queue<x10rt_cuda_copy> dma_q; Table<x10rt_functions> cbs; @@ -433,7 +434,6 @@ #endif } - void *x10rt_cuda_device_alloc (x10rt_cuda_ctx *ctx, size_t len) { @@ -441,6 +441,8 @@ pthread_mutex_lock(&big_lock_of_doom); CU_SAFE(cuCtxPushCurrent(ctx->ctx)); CUdeviceptr ptr; + ctx->commit += len; + //fprintf(stderr,"CUDA committed memory: %llu bytes\n", (unsigned long long)ctx->commit); CU_SAFE(cuMemAlloc(&ptr, len)); CU_SAFE(cuCtxPopCurrent(NULL)); pthread_mutex_unlock(&big_lock_of_doom); @@ -684,7 +686,8 @@ CUfunction k = ctx->cbs[type].kernel_cbs.kernel; // y and z params we leave as 1, as threads can vary from 1 to 512 CU_SAFE(cuFuncSetBlockShape(k, kop->threads, 1, 1)); - CU_SAFE(cuParamSetv(k, 0, &kop->argv, kop->argc)); + //fprintf(stderr,"%p<<<%d,%d,%d>>> argc: %d argv: %p\n", (void*)k, kop->blocks, kop->threads, kop->shm, kop->argc, *(void**)kop->argv); + CU_SAFE(cuParamSetv(k, 0, &kop->argv[0], kop->argc)); CU_SAFE(cuParamSetSize(k, kop->argc)); CU_SAFE(cuFuncSetSharedSize(k, kop->shm)); CU_SAFE(cuLaunchGridAsync(k, kop->blocks, 1, ctx->kernel_q.stream)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |