From: <spa...@us...> - 2009-11-18 18:25:41
|
Revision: 12125 http://x10.svn.sourceforge.net/x10/?rev=12125&view=rev Author: sparksparkspark Date: 2009-11-18 18:25:26 +0000 (Wed, 18 Nov 2009) Log Message: ----------- Add autoconfiguration utility for CUDA and use it in KMeansCUDA Modified Paths: -------------- trunk/x10.compiler/src/x10cuda/types/X10CUDAContext_c.java trunk/x10.compiler/src/x10cuda/visit/CUDACodeGenerator.java trunk/x10.dist/samples/KMeansCUDA.x10 Added Paths: ----------- trunk/x10.runtime/src-x10/x10/compiler/CUDAUtilities.x10 Modified: trunk/x10.compiler/src/x10cuda/types/X10CUDAContext_c.java =================================================================== --- trunk/x10.compiler/src/x10cuda/types/X10CUDAContext_c.java 2009-11-18 18:13:39 UTC (rev 12124) +++ trunk/x10.compiler/src/x10cuda/types/X10CUDAContext_c.java 2009-11-18 18:25:26 UTC (rev 12125) @@ -18,6 +18,7 @@ import polyglot.ast.Expr; import polyglot.ast.Formal; +import polyglot.ast.LocalDecl; import polyglot.frontend.Job; import x10.ast.Closure_c; import x10cpp.types.X10CPPContext_c; @@ -58,6 +59,10 @@ this.threadsVar = threadsVar; this.shm = shm; this.kernelParams = variables(); + if (autoBlocks!=null) + this.kernelParams.add(autoBlocks.localDef().asInstance()); + if (autoThreads!=null) + this.kernelParams.add(autoThreads.localDef().asInstance()); } public boolean isKernelParam(Name n) { for (VarInstance i : kernelParams) { @@ -85,7 +90,15 @@ X10CUDAContext_c established; public void establishClosure() { established = this; } public X10CUDAContext_c established() { return established; } - + + LocalDecl autoBlocks; + public void autoBlocks(LocalDecl v) { this.autoBlocks = v; } + public LocalDecl autoBlocks() { return this.autoBlocks; } + + LocalDecl autoThreads; + public void autoThreads(LocalDecl v) { this.autoThreads = v; } + public LocalDecl autoThreads() { return this.autoThreads; } + } //vim:tabstop=4:shiftwidth=4:expandtab Modified: trunk/x10.compiler/src/x10cuda/visit/CUDACodeGenerator.java =================================================================== --- trunk/x10.compiler/src/x10cuda/visit/CUDACodeGenerator.java 2009-11-18 18:13:39 UTC (rev 12124) +++ trunk/x10.compiler/src/x10cuda/visit/CUDACodeGenerator.java 2009-11-18 18:25:26 UTC (rev 12125) @@ -405,6 +405,30 @@ r.var = real_var.name().id(); return r; } + + public void checkAutoVar(Stmt s) { + assert s instanceof LocalDecl : s.getClass(); // FIXME: proper error + LocalDecl s_ = (LocalDecl)s; + Expr init_expr = s_.init(); + assert init_expr instanceof X10Call_c : init_expr.getClass(); // FIXME: proper error + X10Call_c init_call = (X10Call_c) init_expr; + Receiver init_call_target = init_call.target(); + assert init_call_target instanceof CanonicalTypeNode : init_call_target.getClass(); // FIXME: proper error + CanonicalTypeNode init_call_target_node = (CanonicalTypeNode) init_call_target; + assert init_call_target_node.nameString().equals("CUDAUtilities") : init_call_target_node.nameString(); + assert init_call.typeArguments().size() == 0 : init_call.typeArguments(); + if (init_call.name().toString().equals("autoBlocks")) { + assert context().autoBlocks()==null : "Already have autoBlocks: "+context().autoBlocks(); + context().autoBlocks(s_); + context().established().autoBlocks(s_); + } else if (init_call.name().toString().equals("autoThreads")) { + assert context().autoThreads()==null : "Already have autoThreads: "+context().autoThreads(); + context().autoThreads(s_); + context().established().autoThreads(s_); + } else { + assert false : init_call.name(); + } + } public void visit(Block_c b) { super.visit(b); @@ -412,8 +436,12 @@ assert !generatingKernel() : "Nesting of cuda annotation makes no sense."; // TODO: assert the block is the body of an async - assert b.statements().size() == 1; // FIXME: proper error - Stmt loop_ = b.statements().get(0); + assert b.statements().size()==1 || b.statements().size()==3 : b.statements(); + if (b.statements().size()==3) { + checkAutoVar(b.statements().get(0)); + checkAutoVar(b.statements().get(1)); + } + Stmt loop_ = b.statements().get(b.statements().size()-1); // test that it is of the form for (blah in region) assert loop_ instanceof For : loop_.getClass(); // FIXME: proper // error @@ -546,31 +574,45 @@ inc.write(make_ref(cnamet)+" __this = "+cnamet+"::"+DESERIALIZE_METHOD+"<"+cnamet+">(__buf);"); inc.newline(); + + ArrayList<VarInstance> env = context().kernelParams(); - for (int i = 0; i < c.variables.size(); i++) { - VarInstance var = (VarInstance) c.variables.get(i); + for (VarInstance var : env) { Type t = var.type(); String name = var.name().toString(); - inc.write(Emitter.translateType(t, true)+" "+name+" = __this->"+name+";"); inc.newline(); + inc.write(Emitter.translateType(t, true)+" "+name); + if (var == context().autoBlocks().localDef().asInstance()) { + inc.write(";"); + } else if (var == context().autoThreads().localDef().asInstance()) { + inc.write(";"); + } else { + inc.write(" = __this->"+name+";"); + } + inc.newline(); } - inc.write("__blocks = ("); inc.begin(0); - tr.print(null, context().blocks(), inc); - inc.write(")+1;"); inc.end(); inc.newline(); - - inc.write("__threads = ("); inc.begin(0); - tr.print(null, context().threads(), inc); - inc.write(")+1;"); inc.end(); inc.newline(); - inc.write("__shm = "); inc.begin(0); context().shm().generateSize(inc, tr); inc.write(";"); inc.end(); inc.newline(); - - generateStruct("__", inc, c.variables); + + if (context().autoBlocks()!=null && context().autoThreads()!=null) { + String bname = context().autoBlocks().name().id().toString(); + String tname = context().autoThreads().name().id().toString();; + inc.write("x10aux::blocks_threads(__gpu, x10aux::DeserializationDispatcher::getMsgType(_serialization_id), __shm, "+bname+", "+tname+");"); inc.newline(); + }// else { + inc.write("__blocks = ("); inc.begin(0); + tr.print(null, context().blocks(), inc); + inc.write(")+1;"); inc.end(); inc.newline(); + + inc.write("__threads = ("); inc.begin(0); + tr.print(null, context().threads(), inc); + inc.write(")+1;"); inc.end(); inc.newline(); + //} + + generateStruct("__", inc, context().kernelParams()); inc.write("___env __env;"); inc.newline(); - for (int i = 0; i < c.variables.size(); i++) { - VarInstance var = (VarInstance) c.variables.get(i); + for (VarInstance var : env) { Type t = var.type(); String name = var.name().toString(); inc.write("__env."+name+" = "); @@ -812,7 +854,15 @@ super.visit(n); } } else { - super.visit(n); + // we end up here in the _deserialize_cuda function because generatingKernel() is false + Name ln = n.name().id(); + if (context().autoBlocks()!=null && ln == context().autoBlocks().name().id()) { + sw.write(context().autoBlocks().name().id().toString()); + } else if (context().autoThreads()!=null && ln == context().autoThreads().name().id()) { + sw.write(context().autoThreads().name().id().toString()); + } else { + super.visit(n); + } } } Modified: trunk/x10.dist/samples/KMeansCUDA.x10 =================================================================== --- trunk/x10.dist/samples/KMeansCUDA.x10 2009-11-18 18:13:39 UTC (rev 12124) +++ trunk/x10.dist/samples/KMeansCUDA.x10 2009-11-18 18:25:26 UTC (rev 12125) @@ -10,6 +10,7 @@ import x10.util.Option; import x10.compiler.CUDA; +import x10.compiler.CUDAUtilities; public class KMeansCUDA { @@ -78,10 +79,10 @@ val clusters_copy = clusters as ValRail[Float]; - val kernel_start_time = System.currentTimeMillis(); // classify kernel - val blocks = 4, threads = 256; at (gpu) @CUDA { + val blocks = CUDAUtilities.autoBlocks(), + threads = CUDAUtilities.autoThreads(); for ((block) in 0..blocks-1) { val clustercache = Rail.make[Float](num_clusters*4, clusters_copy); for ((thread) in 0..threads-1) async { Added: trunk/x10.runtime/src-x10/x10/compiler/CUDAUtilities.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/compiler/CUDAUtilities.x10 (rev 0) +++ trunk/x10.runtime/src-x10/x10/compiler/CUDAUtilities.x10 2009-11-18 18:25:26 UTC (rev 12125) @@ -0,0 +1,9 @@ +package x10.compiler; + +public class CUDAUtilities { + public static def autoBlocks() = 8; + public static def autoThreads() = 1; +} + +// vim: shiftwidth=8:tabstop=8:expandtab + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ipe...@us...> - 2009-11-19 22:43:22
|
Revision: 12146 http://x10.svn.sourceforge.net/x10/?rev=12146&view=rev Author: ipeshansky Date: 2009-11-19 22:43:11 +0000 (Thu, 19 Nov 2009) Log Message: ----------- Add a collective Optimizer pass for single-source optimizations. Includes the LoopUnroller pass, the Inliner pass, and the ForLoopOptimizer pass. Move Optimizer to x10.optimizations and rename it to ForLoopOptimizer. Add a LoopUnroller pass to unroll loops annotated with @Unroll. Add an @Unroll annotation. Change the ASTQuery API for property initializers to access non-String properties. Add header comment and d2u Immediate.x10. Fix comment in Native.x10. Modified Paths: -------------- trunk/x10.compiler/src/x10/ExtensionInfo.java trunk/x10.compiler/src/x10cpp/visit/ASTQuery.java trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java trunk/x10.runtime/src-x10/x10/compiler/Immediate.x10 trunk/x10.runtime/src-x10/x10/compiler/Native.x10 Added Paths: ----------- trunk/x10.compiler/src/x10/optimizations/ trunk/x10.compiler/src/x10/optimizations/ForLoopOptimizer.java trunk/x10.compiler/src/x10/optimizations/LoopUnroller.java trunk/x10.compiler/src/x10/optimizations/Optimizer.java trunk/x10.runtime/src-x10/x10/compiler/Unroll.x10 Removed Paths: ------------- trunk/x10.compiler/src/x10/visit/Optimizer.java Modified: trunk/x10.compiler/src/x10/ExtensionInfo.java =================================================================== --- trunk/x10.compiler/src/x10/ExtensionInfo.java 2009-11-19 22:08:04 UTC (rev 12145) +++ trunk/x10.compiler/src/x10/ExtensionInfo.java 2009-11-19 22:43:11 UTC (rev 12146) @@ -49,6 +49,7 @@ import polyglot.util.InternalCompilerError; import polyglot.visit.PruningVisitor; import x10.ast.X10NodeFactory_c; +import x10.optimizations.Optimizer; import x10.parser.X10Lexer; import x10.parser.X10Parser; import x10.plugin.CompilerPlugin; @@ -66,7 +67,6 @@ import x10.visit.ExprFlattener; import x10.visit.FieldInitializerMover; import x10.visit.Inliner; -import x10.visit.Optimizer; import x10.visit.RewriteAtomicMethodVisitor; import x10.visit.RewriteExternVisitor; import x10.visit.StaticNestedClassRemover; @@ -284,7 +284,6 @@ goals.add(InnerClassRemover(job)); goals.add(Desugarer(job)); goals.add(Optimizer(job)); - goals.add(Inlined(job)); goals.add(CodeGenerated(job)); goals.add(End(job)); @@ -440,22 +439,6 @@ return new VisitorGoal("X10Expanded", job, new X10ImplicitDeclarationExpander(job, ts, nf)).intern(this); } - public Goal Inlined(Job job) { - TypeSystem ts = extInfo.typeSystem(); - NodeFactory nf = extInfo.nodeFactory(); - if (x10.Configuration.INLINE_OPTIMIZATIONS) { - return new VisitorGoal("Inlined", job, new Inliner(job, ts, nf)).intern(this); - } - else { - return new SourceGoal_c("Inlined", job) { - @Override - public boolean runTask() { - return true; - } - }.intern(this); - } - } - public Goal CheckNativeAnnotations(Job job) { TypeSystem ts = extInfo.typeSystem(); NodeFactory nf = extInfo.nodeFactory(); @@ -469,9 +452,9 @@ } public Goal Optimizer(Job job) { - TypeSystem ts = extInfo.typeSystem(); - NodeFactory nf = extInfo.nodeFactory(); - return new VisitorGoal("Optimizer", job, new Optimizer(job, ts, nf)).intern(this); + TypeSystem ts = extInfo.typeSystem(); + NodeFactory nf = extInfo.nodeFactory(); + return new Optimizer(job).intern(this); } public Goal InnerClassRemover(Job job) { Copied: trunk/x10.compiler/src/x10/optimizations/ForLoopOptimizer.java (from rev 12124, trunk/x10.compiler/src/x10/visit/Optimizer.java) =================================================================== --- trunk/x10.compiler/src/x10/optimizations/ForLoopOptimizer.java (rev 0) +++ trunk/x10.compiler/src/x10/optimizations/ForLoopOptimizer.java 2009-11-19 22:43:11 UTC (rev 12146) @@ -0,0 +1,100 @@ +/** + * + */ +package x10.optimizations; + + +import java.util.List; + +import polyglot.ast.Eval; +import polyglot.ast.Expr; +import polyglot.ast.Node; +import polyglot.ast.NodeFactory; +import polyglot.frontend.Job; +import polyglot.types.SemanticException; +import polyglot.types.Type; +import polyglot.types.TypeSystem; +import polyglot.visit.ContextVisitor; +import polyglot.visit.NodeVisitor; +import x10.ast.Async; +import x10.ast.AtEach; +import x10.ast.AtExpr; +import x10.ast.AtStmt; +import x10.ast.Atomic; +import x10.ast.Await; +import x10.ast.Finish; +import x10.ast.ForEach; +import x10.ast.ForLoop; +import x10.ast.ForLoop_c; +import x10.ast.Future; +import x10.ast.Here; +import x10.ast.Next; +import x10.ast.RegionMaker; +import x10.ast.SettableAssign_c; +import x10.ast.When; +import x10.ast.X10Binary_c; +import x10.ast.X10Formal; +import x10.ast.X10NodeFactory; +import x10.ast.X10Unary_c; +import x10.constraint.XTerms; +import x10.constraint.XVar; +import x10.types.X10Context; +import x10.types.X10Type; +import x10.types.X10TypeMixin; +import x10.types.X10TypeSystem; +import x10.util.Synthesizer; + +/** + * @author vj + * + */ +public class ForLoopOptimizer extends ContextVisitor { + + private final X10TypeSystem xts; + private final X10NodeFactory xnf; + + public ForLoopOptimizer(Job job, TypeSystem ts, NodeFactory nf) { + super(job, ts, nf); + xts = (X10TypeSystem) ts; + xnf = (X10NodeFactory) nf; + } + + public Node leaveCall(Node old, Node n, NodeVisitor v) throws SemanticException { + if (n instanceof ForLoop) + return visitForLoop((ForLoop_c) n); + return n; + } + + public Node visitForLoop(ForLoop_c loop) throws SemanticException { + Synthesizer syn = new Synthesizer(xnf, xts); + X10Type domainType = loop.domainType(); + XVar var = XTerms.makeEQV("self"); + Type regionType = syn.addRankConstraint(xts.Region(), var, 1, xts); + regionType = syn.addRectConstraint(regionType, var); + X10TypeMixin.setSelfVar(regionType, var); + + + if (xts.isSubtypeWithValueInterfaces(domainType, regionType, context())) { + // Now check if domain is actually a RegionMaker, i.e. a parsing of e1..e2 + if (loop.domain() instanceof RegionMaker) { + List<Expr> args = ((RegionMaker) loop.domain()).arguments(); + if (args.size() == 2) { + Expr low = args.get(0); + Expr high = args.get(1); + X10Formal xf = (X10Formal) loop.formal(); + // Only handle the case |for ((i) in e1..e2) S| for now + if (xf.isUnnamed()) { + X10Formal index = (X10Formal) xf.vars().get(0); + Node n = syn.makeForLoop(loop.position(), index, low, high, + loop.body(), + (X10Context) context()); + return n; + } + + } + + } + } + return loop; + } +} Added: trunk/x10.compiler/src/x10/optimizations/LoopUnroller.java =================================================================== --- trunk/x10.compiler/src/x10/optimizations/LoopUnroller.java (rev 0) +++ trunk/x10.compiler/src/x10/optimizations/LoopUnroller.java 2009-11-19 22:43:11 UTC (rev 12146) @@ -0,0 +1,774 @@ +/******************************************************************************* +* Copyright (c) 2009 IBM Corporation. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the Eclipse Public License v1.0 +* which accompanies this distribution, and is available at +* http://www.eclipse.org/legal/epl-v10.html +* +* Contributors: +* Robert Fuhrer (rf...@wa...) - initial API and implementation +*******************************************************************************/ + +package x10.optimizations; + +import static x10cpp.visit.ASTQuery.annotationNamed; +import static x10cpp.visit.ASTQuery.assertNumberOfInitializers; +import static x10cpp.visit.ASTQuery.getPropertyInit; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import polyglot.ast.Assign; +import polyglot.ast.Binary; +import polyglot.ast.Block; +import polyglot.ast.Call; +import polyglot.ast.CanonicalTypeNode; +import polyglot.ast.Expr; +import polyglot.ast.Field; +import polyglot.ast.FlagsNode; +import polyglot.ast.For; +import polyglot.ast.ForInit; +import polyglot.ast.ForUpdate; +import polyglot.ast.Formal; +import polyglot.ast.Id; +import polyglot.ast.IntLit; +import polyglot.ast.Local; +import polyglot.ast.LocalDecl; +import polyglot.ast.Node; +import polyglot.ast.NodeFactory; +import polyglot.ast.Receiver; +import polyglot.ast.Stmt; +import polyglot.ast.Unary; +import polyglot.ast.VarDecl; +import polyglot.frontend.Globals; +import polyglot.frontend.Job; +import polyglot.types.ClassType; +import polyglot.types.Context; +import polyglot.types.Context_c; +import polyglot.types.Flags; +import polyglot.types.LocalDef; +import polyglot.types.LocalInstance; +import polyglot.types.MethodInstance; +import polyglot.types.Name; +import polyglot.types.SemanticException; +import polyglot.types.Type; +import polyglot.types.TypeSystem; +import polyglot.types.Types; +import polyglot.types.VarDef; +import polyglot.types.VarInstance; +import polyglot.util.Position; +import polyglot.visit.ContextVisitor; +import polyglot.visit.NodeVisitor; +import x10.ast.ForLoop; +import x10.ast.RegionMaker; +import x10.ast.Tuple; +import x10.ast.X10Formal; +import x10.ast.X10NodeFactory; +import x10.constraint.XConstraint; +import x10.constraint.XEquals; +import x10.constraint.XField; +import x10.constraint.XLit; +import x10.constraint.XLocal; +import x10.constraint.XName; +import x10.constraint.XTerm; +import x10.constraint.XVar; +import x10.types.ConstrainedType; +import x10.types.X10Flags; +import x10.types.X10TypeSystem; +import x10.visit.Desugarer; + +/** + * Unrolls loops annotated with @Unroll(n). + * Adapted from the X10DT refactoring engine. + * + * @author rmfuhrer + * @author igor + */ +public class LoopUnroller extends ContextVisitor { + private static final String LOOP_UNROLL_TRANSFORMATION_NAME= "Loop Unroll"; + private static final String UNROLL_ANNOTATION_NAME= "x10.compiler.Unroll"; + + private enum LoopLeftoverHandling { + GENERATE_ASSERT, + GENERATE_TAIL_LOOP + } + + private class LoopParams { + final VarDecl fLoopVar; + final Expr fLoopDomain; + Set<Expr> fLoopDomainValues= new HashSet<Expr>(); + boolean fExtentUnknown; + int fMin; + Expr fMinSymbolic; + int fMax; + Expr fMaxSymbolic; + int fStride; + + public LoopParams(VarDecl vd, Expr domain) { + fLoopVar= vd; + fLoopDomain= domain; + fExtentUnknown= true; + } + + public LoopParams(VarDecl vd, Expr domain, int min, int max, int stride) { + this(vd, domain); + fMin= min; + fMax= max; + fStride= stride; + fExtentUnknown= false; + } + + protected void addDomainValue(Expr e) { + fLoopDomainValues.add(e); + } + + protected int getMin() { + return fMin; + } + + protected Expr getMinSymbolic() { + return fMinSymbolic; + } + + protected void setMin(int min, Expr minSymbolic) { + fMin= min; + fMinSymbolic= minSymbolic; + fExtentUnknown= false; + } + + protected int getMax() { + return fMax; + } + + protected Expr getMaxSymbolic() { + return fMaxSymbolic; + } + + protected void setMax(int max, Expr maxSymbolic) { + fMax= max; + fMaxSymbolic= maxSymbolic; + fExtentUnknown= false; + } + + protected int getStride() { + return fStride; + } + + protected void setStride(int stride) { + fStride= stride; + } + } + + /** + * The user-selected ForLoop (often the same as fNode, if the latter is a ForLoop) + */ + private ForLoop fLoop; + + /** + * the user-supplied number of times to unroll the loop + */ + private int fUnrollFactor; + + /** + * records symbolic and constant information about the loop iteration domain + */ + private LoopParams fLoopParams; + + /** + * determines how to handle trailing iterations that are left over by the unrolled loop + */ + private LoopLeftoverHandling fHandleLoopLeftovers; + + private final X10TypeSystem xts; + + private final X10NodeFactory xnf; + + public LoopUnroller(Job job, TypeSystem ts, NodeFactory nf) { + super(job, ts, nf); + xts = (X10TypeSystem) ts; + xnf = (X10NodeFactory) nf; + } + + protected Node leaveCall(Node old, Node n, NodeVisitor v) throws SemanticException { + if (n instanceof ForLoop) + return unrollLoop((ForLoop) n); + return super.leaveCall(old, n, v); + } + + public String getName() { + return LOOP_UNROLL_TRANSFORMATION_NAME; + } + + public void warn(String message) { + System.err.println(getName()+": "+message); + // TODO: put a WARNING on the compiler's error queue + } + + public boolean fatalStatus(String message) { + warn(message); + return false; + } + + public boolean okStatus() { + return true; + } + + private Type getAnnotation(Node o, String name) { + try { + return annotationNamed(xts, o, name); + } + catch (SemanticException e) {} + return null; + } + + private boolean extractUnrollFactor() { + Type at = getAnnotation(fLoop, UNROLL_ANNOTATION_NAME); + if (at == null) + return false; + assertNumberOfInitializers(at, 1); + Object val = getPropertyInit(at, 0); + assert (val instanceof Integer); + fUnrollFactor = ((Integer) val).intValue(); + return okStatus(); + } + + public boolean checkPreconditions(ForLoop fLoop) { + this.fLoop = fLoop; + return checkInitialConditions() && checkFinalConditions(); + } + + public boolean checkInitialConditions() { + boolean status= extractUnrollFactor(); + if (!status) + return false; + fHandleLoopLeftovers = LoopLeftoverHandling.GENERATE_TAIL_LOOP; + return true; + } + + public boolean checkFinalConditions() { + try { + if (Globals.Compiler() == null) { + Globals.initialize(xts.extensionInfo().compiler()); + } + boolean status= findLoopParams(); + if (status) { + status= checkForInductionVarRefs(); + } + return status; + } catch (Exception e) { + return fatalStatus(e.getMessage()); + } + } + + private boolean checkForInductionVarRefs() { + final boolean hasRefs[] = { false }; + fLoop.visit(new NodeVisitor() { + @Override + public NodeVisitor enter(Node n) { + if (n instanceof Local) { + Local local = (Local) n; + if (local.localInstance().equals(fLoop.formal().localDef().asInstance())) { + hasRefs[0] = true; + } + } + return super.enter(n); + } + }); + return hasRefs[0] ? fatalStatus("Loop body has references to the Point loop induction variable") : okStatus(); + } + + private boolean findLoopParams() { + fLoopParams= new LoopParams(fLoop.formal(), fLoop.domain()); + + X10Formal loopVar = (X10Formal) fLoop.formal(); + List<Formal> explodedVars= loopVar.vars(); + + if (explodedVars.size() > 1) { + return fatalStatus("Exploded variable syntax is not yet supported for multi-dimensional loop iteration domains"); + } + + // use type of domain to check its rank + if (!checkDomainIs1D(fLoop.domain())) { + return fatalStatus("Cannot statically confirm that loop iteration domain is 1-dimensional"); + } + + // now find the values that flow into the domain expr + boolean status= findDomainValues(); + + if (!status) { + return status; + } + + // now examine the domain values to determine the loop bounds + return extractDomainBounds(); + } + + private boolean extractDomainBounds() { + if (fLoopParams.fLoopDomainValues.size() != 1) { + return fatalStatus("Can only analyze loop with 1 possible iteration domain value"); + } + Expr v= fLoopParams.fLoopDomainValues.iterator().next(); + + if (v instanceof Call) { + Call call= (Call) v; + MethodInstance mi= call.methodInstance(); + List<Expr> args= call.arguments(); + + if (isRegionConvertCall(mi)) { + int dimen= args.size(); + if (dimen > 1) { + return fatalStatus("Cannot unroll loops over multi-dimensional iteration domains."); + } + Expr regionTuple= args.get(0); + List<Expr> dimensionArgs= ((Tuple) regionTuple).arguments(); + Expr low, hi; + if (dimensionArgs.get(0) instanceof RegionMaker) { + RegionMaker regionMaker= (RegionMaker) dimensionArgs.get(0); + + low= regionMaker.arguments().get(0); + hi= regionMaker.arguments().get(1); + } else { + low= null; + hi= null; + } + if (low != null && hi != null) { + fLoopParams.fMin= getConstantValueOf(low); + fLoopParams.fMinSymbolic= low; + fLoopParams.fMax= getConstantValueOf(hi); + fLoopParams.fMaxSymbolic= hi; + fLoopParams.fStride= 1; + } + } else if (mi.container() instanceof ClassType && ((ClassType) mi.container()).fullName().toString().equals("x10.lang.Region") && + mi.name().toString().equals("makeRectangular")) { + Expr low, hi; + low= args.get(0); + hi= args.get(1); + fLoopParams.fMin= getConstantValueOf(low); + fLoopParams.fMinSymbolic= low; + fLoopParams.fMax= getConstantValueOf(hi); + fLoopParams.fMaxSymbolic= hi; + fLoopParams.fStride= 1; + } else if (mi.container() instanceof ClassType && ((ClassType) mi.container()).fullName().toString().equals("x10.lang.Rail") && + mi.name().toString().equals("makeVar")) { + Expr size= args.get(0); + fLoopParams.fMin= 1; + fLoopParams.fMinSymbolic= intLit(1); + fLoopParams.fMax= getConstantValueOf(size); + fLoopParams.fMaxSymbolic= size; + fLoopParams.fStride= 1; + } else { + return fatalStatus("Don't understand iteration domain: " + call); + } + } else { + if (!checkDomainIs1D(v)) { + return fatalStatus("Cannot determine that iteration domain is 1-dimensional: " + fLoopParams.fLoopDomain); + } + fLoopParams.fExtentUnknown= true; + } + return okStatus(); + } + + private boolean isRegionConvertCall(MethodInstance mi) { + return mi.container() instanceof ClassType && ((ClassType) mi.container()).fullName().toString().equals("x10.lang.Region") && + mi.name().toString().equals("$convert"); + } + + private int getConstantValueOf(Expr e) { + // TODO Need to produce the literal value here, but elsewhere need the symbolic value (e.g. when rewriting the region bounds) + if (e.constantValue() != null && e.constantValue() instanceof Integer) { + return ((Integer) e.constantValue()).intValue(); + } + return -1; // TOTALLY BOGUS - probably need to return a RefactoringStatus to abort the refactoring + } + + private boolean findDomainValues() { + Local domainLocal; + Expr domain= fLoop.domain(); + + if (domain instanceof Field || domain instanceof Local) { + if (domain instanceof Field) { + Field f= (Field) domain; + if (f.name().toString().equals("dist")) { + Receiver rcvr= f.target(); + if (rcvr instanceof Local) { + domainLocal= ((Local) rcvr); + } else { + return fatalStatus("for-loop domain is a '.dist' pseudo-field access via something other than a local variable"); + } + } else { + return fatalStatus("for-loop domain is a field access to something other than '.dist'"); + } + } else if (domain instanceof Local) { + domainLocal= (Local) domain; + } else { + return fatalStatus("for-loop domain is neither a local var nor a 'dist' field access"); + } +// VarDef localDef= domainLocal.localInstance().def(); +// Set<Term> domainTerms= fValueMap.getValues(localDef); +// +// for(Term t: domainTerms) { +// if (t instanceof Expr) { +// fLoopParams.addDomainValue((Expr) t); +// } else { +// warn("Don't know what to do with domain term: " + t); +// } +// } + } else if (domain instanceof Call) { + fLoopParams.addDomainValue(domain); + } + return okStatus(); + } + + private boolean checkDomainIs1D(Expr domain) { + ConstrainedType type= (ConstrainedType) domain.type(); + + if (xts.isRail(type)) { + return true; + } + + XConstraint typeCons= type.constraint().get(); + List<XTerm> consTerms= typeCons.constraints(); + + XTerm rankConstraint= findRankConstraint(consTerms); + if (rankConstraint != null) { + if (constraintEq1(rankConstraint)) { + return true; + } + } + return false; + } + + private boolean constraintEq1(XTerm term) { + XEquals eq= (XEquals) term; + List<XTerm> args= eq.arguments(); + XTerm left= args.get(0); + XTerm right= args.get(1); + + if (right instanceof XLit) { + XLit lit= (XLit) right; + Object litVal= lit.val(); + return litVal.equals(new Integer(1)); + } else if (right instanceof XLocal) { + // Might we need to know what values flow into this RHS operand? + } else if (right instanceof XField) { + // Might we need to know what values flow into this RHS operand? + XField rightField= (XField) right; + XVar rightRcvr= rightField.receiver(); + XName rightName= rightField.field(); + + if (rightRcvr instanceof XLocal) { + XLocal rightRcvrLocal= (XLocal) rightRcvr; + warn("Hey!"); + } + } + return false; + } + + private XTerm findRankConstraint(List<XTerm> terms) { + for(XTerm term: terms) { + if (term instanceof XEquals) { + XEquals eq= (XEquals) term; + List<XTerm> args= eq.arguments(); + XTerm left= args.get(0); + XTerm right= args.get(1); + + if (left instanceof XField) { + XField leftField= (XField) left; + XVar leftRcvr= leftField.receiver(); + XName leftName= leftField.field(); + + // HACK Would like to know whether leftRcvr is on "self", but the only indication seems to be + // that its name looks like "_selfNNNN" + boolean isSelf= leftRcvr instanceof XLocal && ((XLocal) leftRcvr).name().toString().contains("self"); + if (leftName.toString().equals("x10.lang.Region#rank")) { + return term; + } + } + } + } + return null; + } + + private static Position PCG= Position.COMPILER_GENERATED; + + private IntLit intLit(int i) { + return (IntLit) xnf.IntLit(PCG, IntLit.INT, i).type(xts.Int()); + } + + private Id id(String name) { + return xnf.Id(PCG, name); + } + + private CanonicalTypeNode intTypeNode() { + return xnf.CanonicalTypeNode(PCG, xts.Int()); + } + + private FlagsNode finalFlag() { + return xnf.FlagsNode(PCG, Flags.FINAL); + } + + private FlagsNode valueFlag() { + return xnf.FlagsNode(PCG, X10Flags.VALUE); + } + + private FlagsNode noFlags() { + return xnf.FlagsNode(PCG, Flags.NONE); + } + + private Id id(Name name) { + return xnf.Id(PCG, name); + } + + private Local local(LocalDef def) { + LocalInstance li = def.asInstance(); + return (Local) xnf.Local(PCG, id(li.name())).localInstance(li).type(li.type()); + } + + private LocalDecl localDecl(Name name, CanonicalTypeNode intTypeNode, Expr init) { + LocalDef def= xts.localDef(PCG, Flags.NONE, Types.ref(xts.Int()), name); + return xnf.LocalDecl(PCG, noFlags(), intTypeNode, id(name), init).localDef(def); + } + + private LocalDecl finalLocalDecl(Name name, CanonicalTypeNode intTypeNode, Expr init) { + LocalDef def= xts.localDef(PCG, Flags.FINAL, Types.ref(intTypeNode.type()), name); + return xnf.LocalDecl(PCG, finalFlag(), intTypeNode, id(name), init).localDef(def); + } + + /** + * Creates a name with the given prefix that is unique within the given context. + * The name will be just the prefix if that does not cause unintended name capture. + * @param prefix + * @param context + * @return + */ + private Name makeFreshInContext(String prefix) { + Context ctx= context(); + Name name= Name.make(prefix); + if (ctx.findVariableSilent(name) != null) + return Name.makeFresh(prefix); + return name; + } + + private Expr div(Expr left, Expr right) { + return xnf.Binary(PCG, left, Binary.DIV, right).type(xts.Int()); + } + + private Expr mod(Expr left, Expr right) { + return xnf.Binary(PCG, left, Binary.MOD, right).type(xts.Int()); + } + + private Expr mul(Expr left, Expr right) { + return xnf.Binary(PCG, left, Binary.MUL, right).type(xts.Int()); + } + + private Expr plus(Expr left, Expr right) { + return xnf.Binary(PCG, left, Binary.ADD, right).type(xts.Int()); + } + + private Expr sub(Expr left, Expr right) { + return xnf.Binary(PCG, left, Binary.SUB, right).type(xts.Int()); + } + + private Expr lt(Expr left, Expr right) { + return xnf.Binary(PCG, left, Binary.LT, right).type(xts.Boolean()); + } + + private Expr le(Expr left, Expr right) { + return xnf.Binary(PCG, left, Binary.LE, right).type(xts.Boolean()); + } + + private Expr eq(Expr left, Expr right) { + return xnf.Binary(PCG, left, Binary.EQ, right).type(xts.Boolean()); + } + + private Expr neq(Expr left, Expr right) { + return xnf.Binary(PCG, left, Binary.NE, right).type(xts.Boolean()); + } + + private Expr ge(Expr left, Expr right) { + return xnf.Binary(PCG, left, Binary.GE, right).type(xts.Boolean()); + } + + private Expr gt(Expr left, Expr right) { + return xnf.Binary(PCG, left, Binary.GT, right).type(xts.Boolean()); + } + + private Expr addAssign(Expr target, Expr source) { + return xnf.Assign(PCG, target, Assign.ADD_ASSIGN, source).type(target.type()); + } + + private Expr subAssign(Expr target, Expr source) { + return xnf.Assign(PCG, target, Assign.SUB_ASSIGN, source).type(target.type()); + } + + private Expr mulAssign(Expr target, Expr source) { + return xnf.Assign(PCG, target, Assign.MUL_ASSIGN, source).type(target.type()); + } + + private Expr divAssign(Expr target, Expr source) { + return xnf.Assign(PCG, target, Assign.DIV_ASSIGN, source).type(target.type()); + } + + private Expr modAssign(Expr target, Expr source) { + return xnf.Assign(PCG, target, Assign.MOD_ASSIGN, source).type(target.type()); + } + + private Expr postInc(Expr target) { + return xnf.Unary(PCG, target, Unary.POST_INC).type(xts.Int()); + } + + private Expr postDec(Expr target) { + return xnf.Unary(PCG, target, Unary.POST_DEC).type(xts.Int()); + } + + private Expr preInc(Expr target) { + return xnf.Unary(PCG, target, Unary.PRE_INC).type(xts.Int()); + } + + private Expr preDec(Expr target) { + return xnf.Unary(PCG, target, Unary.PRE_DEC).type(xts.Int()); + } + + private Expr not(Expr expr) { + return xnf.Unary(PCG, expr, Unary.NOT).type(xts.Boolean()); + } + + private Expr neg(Expr expr) { + return xnf.Unary(PCG, expr, Unary.NEG).type(expr.type()); + } + + private Expr bitNot(Expr expr) { + return xnf.Unary(PCG, expr, Unary.BIT_NOT).type(xts.Int()); + } + + private Stmt eval(Expr expr) { + return xnf.Eval(PCG, expr); + } + + private Stmt unrollLoop(ForLoop fLoop) { + if (!checkPreconditions(fLoop)) + return fLoop; + assert (fLoopParams.fExtentUnknown); + // Have to do this the hard way: Generate code to ask the loop domain for its min and max, + // and use those bounds to drive an ordinary for-loop. Also have to re-generate the loop + // to take care of the tail end of the iteration domain (if the unroll factor doesn't + // evenly divide the iteration bounds). + // The code will look like this: + // + // { + // int min = r.min(0); + // int max = r.max(0); + // int loopMax = (max - min + 1) / `fUnrollFactor` * `fUnrollFactor` + min; + // for(int loopVar = min; loopVar < loopMax; loopVar += `fUnrollFactor`) { // [(min..max) : `fUnrollFactor`] + // loopBody + // loopBody[loopVar+1/loopVar] + // ... + // loopBody[loopVar+`fUnrollFactor`-1/loopVar] + // } + // + // for(int loopVar = loopMax; loopVar < max; loopVar++) { + // loopBody + // } + // } + Expr domain= fLoopParams.fLoopDomain; + Expr domainMin= (fLoopParams.fMinSymbolic != null) ? fLoopParams.fMinSymbolic : xnf.Call(PCG, domain, id("min"), intLit(0)); + Expr domainMax= (fLoopParams.fMaxSymbolic != null) ? fLoopParams.fMaxSymbolic : xnf.Call(PCG, domain, id("max"), intLit(0)); + LocalDecl minDecl= finalLocalDecl(makeFreshInContext("min"), intTypeNode(), domainMin); + LocalDecl maxDecl= finalLocalDecl(makeFreshInContext("max"), intTypeNode(), domainMax); + Expr loopMax= plus(mul(div(plus(sub(local(maxDecl.localDef()), local(minDecl.localDef())), intLit(1)), intLit(fUnrollFactor)), intLit(fUnrollFactor)), local(minDecl.localDef())); + LocalDecl loopMaxDecl= finalLocalDecl(makeFreshInContext("loopMax"), intTypeNode(), loopMax); + + Formal firstDimVar= ((X10Formal) fLoopParams.fLoopVar).vars().get(0); + Name loopVarName= makeFreshInContext(firstDimVar.name().toString()); + LocalDecl newLoopVarInit= localDecl(loopVarName, intTypeNode(), local(minDecl.localDef())); + Expr loopCond= lt(local(newLoopVarInit.localDef()), local(loopMaxDecl.localDef())); + ForUpdate loopUpdate= (ForUpdate) eval(addAssign(local(newLoopVarInit.localDef()), intLit(fUnrollFactor))); + List<ForInit> newLoopInits= Arrays.<ForInit>asList(newLoopVarInit); + List<ForUpdate> newLoopUpdates= Arrays.asList(loopUpdate); + List<Stmt> newLoopBodyStmts= new ArrayList<Stmt>(fUnrollFactor); + X10Formal loopVar= (X10Formal) fLoopParams.fLoopVar; + + for(int i= 0; i < fUnrollFactor; i++) { + if (loopVar.vars().size() > 0) { + final Map<VarInstance<VarDef>, Expr> subs= new HashMap<VarInstance<VarDef>, Expr>(1); + Expr varValue= intLit(i); + subs.put((VarInstance) firstDimVar.localDef().asInstance(), plus(local(newLoopVarInit.localDef()), varValue)); + final Context outer = context(); + Desugarer.Substitution<Expr> subPerformer= new Desugarer.Substitution<Expr>(Expr.class, null) { + protected Expr subst(Expr n) { + if (n instanceof Local) { + Local l = (Local) n; + Context_c ctx = (Context_c) context(); + while (ctx != outer) { + if (ctx.findVariableInThisScope(l.name().id()) != null) { + // TODO Do something more sensible than just throwing an exception + // This info needs to get back to the user in consumable form + throw new IllegalStateException("Inlining failed: unintended name capture for " + l.name().id()); + } + } + VarInstance li = l.localInstance(); + if (subs.containsKey(li)) { + return subs.get(li); + } + } + return n; + } + }; + Stmt subbedBody = (Stmt) fLoop.body().visit(subPerformer); + + newLoopBodyStmts.add(subbedBody); + } else { + newLoopBodyStmts.add((Stmt) fLoop.body().copy()); + } + } + Block newLoopBody= xnf.Block(PCG, newLoopBodyStmts); + For newForStmt= xnf.For(PCG, newLoopInits, loopCond, newLoopUpdates, newLoopBody); + List<Stmt> unrollBlockStmts; + + if (fHandleLoopLeftovers == LoopLeftoverHandling.GENERATE_ASSERT) { + Stmt assertStmt= xnf.Assert(PCG, eq(mod(plus(sub(local(maxDecl.localDef()), local(minDecl.localDef())), intLit(1)), intLit(fUnrollFactor)), intLit(0))); + + unrollBlockStmts= Arrays.asList(minDecl, maxDecl, loopMaxDecl, assertStmt, newForStmt); + } else { + // Now for the "remainder loop": + // for(int loopVar = (max / `fUnrollFactor`) * `fUnrollFactor`; loopVar < max; loopVar++) { + // loopBody + // } + Expr remainderLoopMinIdx= local(loopMaxDecl.localDef()); + LocalDecl remainderLoopInit= localDecl(loopVarName, intTypeNode(), remainderLoopMinIdx); + Expr remainderCond= le(local(remainderLoopInit.localDef()), local(maxDecl.localDef())); + ForUpdate remainderUpdate= (ForUpdate) eval(postInc(local(newLoopVarInit.localDef()))); + Stmt remainderLoop= xnf.For(PCG, Arrays.<ForInit>asList(remainderLoopInit), remainderCond, Arrays.asList(remainderUpdate), (Stmt) fLoop.body().copy()); + + unrollBlockStmts= Arrays.asList(minDecl, maxDecl, loopMaxDecl, newForStmt, remainderLoop); + } + + return xnf.Block(PCG, unrollBlockStmts); + } + + protected int findIndexInParent(Stmt s, Block parent) { + for(int stmtIdx= 0; stmtIdx < parent.statements().size(); stmtIdx++) { + if (parent.statements().get(stmtIdx) == s) { + return stmtIdx; + } + } + return -1; + } + + public void setUnrollFactor(int factor) { + fUnrollFactor= factor; + } + + public void setAddAssertion() { + fHandleLoopLeftovers= LoopLeftoverHandling.GENERATE_ASSERT; + } + + public void setGenerateTailLoop() { + fHandleLoopLeftovers= LoopLeftoverHandling.GENERATE_TAIL_LOOP; + } +} Added: trunk/x10.compiler/src/x10/optimizations/Optimizer.java =================================================================== --- trunk/x10.compiler/src/x10/optimizations/Optimizer.java (rev 0) +++ trunk/x10.compiler/src/x10/optimizations/Optimizer.java 2009-11-19 22:43:11 UTC (rev 12146) @@ -0,0 +1,299 @@ +package x10.optimizations; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.LinkedHashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Set; + +import polyglot.ast.NodeFactory; +import polyglot.frontend.AbstractGoal_c; +import polyglot.frontend.CyclicDependencyException; +import polyglot.frontend.ExtensionInfo; +import polyglot.frontend.Globals; +import polyglot.frontend.Goal; +import polyglot.frontend.JLScheduler; +import polyglot.frontend.Job; +import polyglot.frontend.Scheduler; +import polyglot.frontend.VisitorGoal; +import polyglot.frontend.Goal.Status; +import polyglot.main.Report; +import polyglot.types.ClassDef; +import polyglot.types.Flags; +import polyglot.types.LazyRef; +import polyglot.types.QName; +import polyglot.types.Type; +import polyglot.types.TypeSystem; +import x10.visit.Inliner; + +public class Optimizer extends JLScheduler implements Goal { + + private final Job job; + private Goal.Status status; + private boolean known; + private List<Goal> prereqs; + + public Optimizer(Job job) { + super(job.extensionInfo()); + this.job = job; + this.status = Goal.Status.NEW; + this.known = false; + } + + public Goal intern(Scheduler scheduler) { + return scheduler.intern(this); + } + + public List<Goal> goals(Job job) { + List<Goal> goals = new ArrayList<Goal>(); + + if (x10.Configuration.INLINE_OPTIMIZATIONS) + goals.add(Inliner(job)); + goals.add(LoopUnrolling(job)); + goals.add(ForLoopOptimizations(job)); + + return goals; + } + + public Goal ForLoopOptimizations(Job job) { + TypeSystem ts = extInfo.typeSystem(); + NodeFactory nf = extInfo.nodeFactory(); + return new VisitorGoal("For Loop Optimizations", job, new ForLoopOptimizer(job, ts, nf)).intern(this); + } + + public Goal LoopUnrolling(Job job) { + TypeSystem ts = extInfo.typeSystem(); + NodeFactory nf = extInfo.nodeFactory(); + return new VisitorGoal("Loop Unrolling", job, new LoopUnroller(job, ts, nf)).intern(this); + } + + public Goal Inliner(Job job) { + TypeSystem ts = extInfo.typeSystem(); + NodeFactory nf = extInfo.nodeFactory(); + return new VisitorGoal("Inlined", job, new Inliner(job, ts, nf)).intern(this); + } + + public boolean runTask() { + List<Goal> goals = goals(job); + for (Goal goal : goals) { + if (!goal.runTask()) + return false; + } + return true; + } + + // FIXME: code copied from AbstractGoal_c + public void run() { + Goal goal = this; + if (Report.should_report(Report.frontend, 2)) + Report.report(2, "Running to goal " + goal); + + LinkedList<Goal> worklist = new LinkedList<Goal>(prereqs()); + + Set<Goal> prereqs = new LinkedHashSet<Goal>(); + prereqs.addAll(worklist); + + while (! worklist.isEmpty()) { + Goal g = worklist.removeFirst(); + + if (g.getCached() == Goal.Status.SUCCESS) + continue; + + if (Report.should_report(Report.frontend, 4)) + Report.report(4, "running prereq: " + g + "->" + goal); + + Status s = g.get(); + + // Make sure any new prereqs added during the recursion are in the queue. + for (Goal g2 : prereqs()) { + if (! prereqs.contains(g2)) { + prereqs.add(g2); + worklist.add(g2); + } + } + + switch (s) { + case NEW: + case FAIL: + case RUNNING: + case RUNNING_RECURSIVE: + case RUNNING_WILL_FAIL: + case UNREACHABLE: + update(Status.UNREACHABLE); + continue; + case SUCCESS: + break; + } + } + + Status oldStatus = getCached(); + + switch (oldStatus) { + case RUNNING: + case RUNNING_RECURSIVE: + status = Status.RUNNING_RECURSIVE; + break; + case NEW: + status = Status.RUNNING; + break; + case RUNNING_WILL_FAIL: + default: + return; + } + + boolean recursive = oldStatus == Status.RUNNING_RECURSIVE; + + if (Report.should_report(Report.frontend, 4)) + Report.report(4, "running goal " + goal); + + if (Report.should_report(Report.frontend, 5)) { + if (Globals.Scheduler().currentGoal() != null) { + Report.report(5, "CURRENT = " + Globals.Scheduler().currentGoal()); + Report.report(5, "SPAWN = " + goal); + } + } + + boolean result = false; + try { + result = runPass(this); + if (state() == Goal.Status.RUNNING_WILL_FAIL) + result = false; + } + catch (CyclicDependencyException e) { + } + + if (result) { + switch (oldStatus) { + case RUNNING: + case RUNNING_RECURSIVE: + update(oldStatus); + break; + case NEW: + update(Status.SUCCESS); + break; + default: + break; + } + } + else { + switch (oldStatus) { + case RUNNING: + case RUNNING_RECURSIVE: + update(Status.RUNNING_WILL_FAIL); + break; + case NEW: + update(Status.FAIL); + break; + default: + break; + } + } + } + + // FIXME: code copied from AbstractGoal_c + public List<Goal> prereqs() { + if (prereqs == null) { + return Collections.emptyList(); + } + else { + return Collections.unmodifiableList(prereqs); + } + } + + // FIXME: code copied from AbstractGoal_c + public void addPrereq(final Goal goal) { + if (prereqs == null) { + prereqs = new ArrayList<Goal>(); + } + + prereqs.add(goal); + } + + // FIXME: code copied from AbstractGoal_c + public boolean hasBeenReached() { + return getCached() == Status.SUCCESS; + } + + // FIXME: code copied from AbstractGoal_c + public boolean isReachable() { + Status state = getCached(); + switch (state) { + case NEW: + case RUNNING: + case RUNNING_RECURSIVE: + case SUCCESS: + return true; + case RUNNING_WILL_FAIL: + case FAIL: + case UNREACHABLE: + return false; + default: + return false; + } + } + + public String name() { + return "Optimizer"; + } + + // FIXME: code copied from AbstractGoal_c + public Status state() { + return getCached(); + } + + public int hashCode() { + return name().hashCode(); + } + + public boolean equals(Object o) { + if (o instanceof Goal) { + Goal g = (Goal) o; + return name().equals(g.name()); + } + return false; + } + + // FIXME: code copied from AbstractGoal_c + public void fail() { + switch (state()) { + case SUCCESS: + assert false; + break; + case RUNNING: + case RUNNING_RECURSIVE: + update(Goal.Status.RUNNING_WILL_FAIL); + break; + case NEW: + update(Goal.Status.UNREACHABLE); + break; + case RUNNING_WILL_FAIL: + case FAIL: + case UNREACHABLE: + break; + } + } + + public Status get() { + if (! known()) { + run(); + if (! known()) { + // Should have already reported an error. + } + known = true; + } + return getCached(); + } + + public Status getCached() { + return status; + } + + public boolean known() { + return known; + } + + public void update(Status v) { + status = v; + } +} Deleted: trunk/x10.compiler/src/x10/visit/Optimizer.java =================================================================== --- trunk/x10.compiler/src/x10/visit/Optimizer.java 2009-11-19 22:08:04 UTC (rev 12145) +++ trunk/x10.compiler/src/x10/visit/Optimizer.java 2009-11-19 22:43:11 UTC (rev 12146) @@ -1,100 +0,0 @@ -/** - * - */ -package x10.visit; - - -import java.util.List; - -import polyglot.ast.Eval; -import polyglot.ast.Expr; -import polyglot.ast.Node; -import polyglot.ast.NodeFactory; -import polyglot.frontend.Job; -import polyglot.types.SemanticException; -import polyglot.types.Type; -import polyglot.types.TypeSystem; -import polyglot.visit.ContextVisitor; -import polyglot.visit.NodeVisitor; -import x10.ast.Async; -import x10.ast.AtEach; -import x10.ast.AtExpr; -import x10.ast.AtStmt; -import x10.ast.Atomic; -import x10.ast.Await; -import x10.ast.Finish; -import x10.ast.ForEach; -import x10.ast.ForLoop; -import x10.ast.ForLoop_c; -import x10.ast.Future; -import x10.ast.Here; -import x10.ast.Next; -import x10.ast.RegionMaker; -import x10.ast.SettableAssign_c; -import x10.ast.When; -import x10.ast.X10Binary_c; -import x10.ast.X10Formal; -import x10.ast.X10NodeFactory; -import x10.ast.X10Unary_c; -import x10.constraint.XTerms; -import x10.constraint.XVar; -import x10.types.X10Context; -import x10.types.X10Type; -import x10.types.X10TypeMixin; -import x10.types.X10TypeSystem; -import x10.util.Synthesizer; - -/** - * @author vj - * - */ -public class Optimizer extends ContextVisitor { - - private final X10TypeSystem xts; - private final X10NodeFactory xnf; - - public Optimizer(Job job, TypeSystem ts, NodeFactory nf) { - super(job, ts, nf); - xts = (X10TypeSystem) ts; - xnf = (X10NodeFactory) nf; - } - - public Node leaveCall(Node old, Node n, NodeVisitor v) throws SemanticException { - if (n instanceof ForLoop) - return visitForLoop((ForLoop_c) n); - return n; - } - - public Node visitForLoop(ForLoop_c loop) throws SemanticException { - Synthesizer syn = new Synthesizer(xnf, xts); - X10Type domainType = loop.domainType(); - XVar var = XTerms.makeEQV("self"); - Type regionType = syn.addRankConstraint(xts.Region(), var, 1, xts); - regionType = syn.addRectConstraint(regionType, var); - X10TypeMixin.setSelfVar(regionType, var); - - - if (xts.isSubtypeWithValueInterfaces(domainType, regionType, context())) { - // Now check if domain is actually a RegionMaker, i.e. a parsing of e1..e2 - if (loop.domain() instanceof RegionMaker) { - List<Expr> args = ((RegionMaker) loop.domain()).arguments(); - if (args.size() == 2) { - Expr low = args.get(0); - Expr high = args.get(1); - X10Formal xf = (X10Formal) loop.formal(); - // Only handle the case |for ((i) in e1..e2) S| for now - if (xf.isUnnamed()) { - X10Formal index = (X10Formal) xf.vars().get(0); - Node n = syn.makeForLoop(loop.position(), index, low, high, - loop.body(), - (X10Context) context()); - return n; - } - - } - - } - } - return loop; - } -} Modified: trunk/x10.compiler/src/x10cpp/visit/ASTQuery.java =================================================================== --- trunk/x10.compiler/src/x10cpp/visit/ASTQuery.java 2009-11-19 22:08:04 UTC (rev 12145) +++ trunk/x10.compiler/src/x10cpp/visit/ASTQuery.java 2009-11-19 22:43:11 UTC (rev 12146) @@ -115,8 +115,11 @@ } boolean hasAnnotation(Node dec, String name) { + return hasAnnotation((X10TypeSystem) tr.typeSystem(), dec, name); + } + + public static boolean hasAnnotation(X10TypeSystem ts, Node dec, String name) { try { - X10TypeSystem ts = (X10TypeSystem) tr.typeSystem(); if (annotationNamed(ts, dec, name) != null) return true; } catch (NoClassException e) { @@ -127,7 +130,8 @@ } return false; } - X10ClassType annotationNamed(TypeSystem ts, Node o, String name) throws SemanticException { + + public static X10ClassType annotationNamed(TypeSystem ts, Node o, String name) throws SemanticException { // Nate's code. This one. if (o.ext() instanceof X10Ext) { X10Ext ext = (X10Ext) o.ext(); @@ -309,9 +313,9 @@ List<Type> as = def.annotationsMatching(rep); for (Type at : as) { assertNumberOfInitializers(at, 4); - String lang = getPropertyInit(at, 0); + String lang = getStringPropertyInit(at, 0); if (lang != null && lang.equals(CPP_NATIVE_STRING)) { - return getPropertyInit(at, i); + return getStringPropertyInit(at, i); } } } @@ -327,17 +331,23 @@ } } - public static String getPropertyInit(Type at, int index) { + public static String getStringPropertyInit(Type at, int index) { + Object v = getPropertyInit(at, index); + if (v instanceof String) + return (String) v; + else if (v != null) + return v.toString(); + return null; + } + + public static Object getPropertyInit(Type at, int index) { at = X10TypeMixin.baseType(at); if (at instanceof X10ClassType) { X10ClassType act = (X10ClassType) at; if (index < act.propertyInitializers().size()) { Expr e = act.propertyInitializer(index); if (e.isConstant()) { - Object v = e.constantValue(); - if (v instanceof String) { - return (String) v; - } + return e.constantValue(); } } } Modified: trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java =================================================================== --- trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java 2009-11-19 22:08:04 UTC (rev 12145) +++ trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java 2009-11-19 22:43:11 UTC (rev 12146) @@ -13,7 +13,7 @@ import static x10cpp.visit.ASTQuery.assertNumberOfInitializers; import static x10cpp.visit.ASTQuery.getConstructorId; import static x10cpp.visit.ASTQuery.getCppRep; -import static x10cpp.visit.ASTQuery.getPropertyInit; +import static x10cpp.visit.ASTQuery.getStringPropertyInit; import static x10cpp.visit.Emitter.mangled_field_name; import static x10cpp.visit.Emitter.mangled_method_name; import static x10cpp.visit.Emitter.mangled_non_method_name; @@ -4611,9 +4611,9 @@ List<Type> as = o.annotationsMatching(annotation); for (Type at : as) { assertNumberOfInitializers(at, 2); - String lang = getPropertyInit(at, 0); + String lang = getStringPropertyInit(at, 0); if (lang != null && lang.equals(our_lang)) { - String lit = getPropertyInit(at, 1); + String lit = getStringPropertyInit(at, 1); return lit; } } Modified: trunk/x10.runtime/src-x10/x10/compiler/Immediate.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/compiler/Immediate.x10 2009-11-19 22:08:04 UTC (rev 12145) +++ trunk/x10.runtime/src-x10/x10/compiler/Immediate.x10 2009-11-19 22:43:11 UTC (rev 12146) @@ -1,31 +1,40 @@ -package x10.compiler; -import x10.lang.annotations.MethodAnnotation; -import x10.lang.annotations.FieldAnnotation; -import x10.lang.annotations.ExpressionAnnotation; -import x10.lang.annotations.StatementAnnotation; - -/** - * <tt>@Immediate</tt> may be used to annotate <tt>async</tt> and <tt>finish</tt>. - * The body of an <tt>@Immediate async</tt> satisfies significant restrictions. (1) It must execute only a short piece of sequential code - * (i.e. the code cannot use <tt>at</tt>, <tt>async</tt>, </tt>finish</tt>, <tt>when</tt> constructs). - * (2) It accesses a very small amount of memory, (3) The <tt>finish</tt> it is governed by must be marked <tt>@immediate</tt>. - * <p> - * The body <tt>S</tt> of an <tt>@Immediate finish S</tt> must satisfy the restriction that the only asyncs it generates - * are <tt>@Immediate asyncs</tt>. - * <p> - <p> The point of marking a <tt>finish</tt> and its enclosed <tt>asyncs</tt> with <tt>@Immediate</tt> is that - significant performance gains may be realized on certain transport networks, such as LAPI, that must acknowledge - receipt of network packets to the sender, and are able to execute a small piece of user code on the destination - (in the "header handler"), before sending the acknowledgment). - - <p> On such systems, the compiler can translate an <tt>@Immediate async</tt> as follows: - if the target place is local, execute the code in-line. If it is remote, - execute it in the header handler. Correspondingly, an <tt>@Immediate finish</tt> can be - translated into the invocation of a "local fence". This fence is a blocking - operation that succeeds only when acknowledgments for all messages sent out from the source - (since the last "local fence" call) have been received. (While it blocks, it services incoming messages.) - - */ -public interface Immediate - extends ExpressionAnnotation, StatementAnnotation, MethodAnnotation { -} +/* + * + * (C) Copyright IBM Corporation 2006-2008. + * + * This file is part of X10 Language. + * + */ + +package x10.compiler; + +import x10.lang.annotations.MethodAnnotation; +import x10.lang.annotations.FieldAnnotation; +import x10.lang.annotations.ExpressionAnnotation; +import x10.lang.annotations.StatementAnnotation; + +/** + * <tt>@Immediate</tt> may be used to annotate <tt>async</tt> and <tt>finish</tt>. + * The body of an <tt>@Immediate async</tt> satisfies significant restrictions. (1) It must execute only a short piece of sequential code + * (i.e. the code cannot use <tt>at</tt>, <tt>async</tt>, </tt>finish</tt>, <tt>when</tt> constructs). + * (2) It accesses a very small amount of memory, (3) The <tt>finish</tt> it is governed by must be marked <tt>@immediate</tt>. + * <p> + * The body <tt>S</tt> of an <tt>@Immediate finish S</tt> must satisfy the restriction that the only asyncs it generates + * are <tt>@Immediate asyncs</tt>. + * <p> + <p> The point of marking a <tt>finish</tt> and its enclosed <tt>asyncs</tt> with <tt>@Immediate</tt> is that + significant performance gains may be realized on certain transport networks, such as LAPI, that must acknowledge + receipt of network packets to the sender, and are able to execute a small piece of user code on the destination + (in the "header handler"), before sending the acknowledgment). + + <p> On such systems, the compiler can translate an <tt>@Immediate async</tt> as follows: + if the target place is local, execute the code in-line. If it is remote, + execute it in the header handler. Correspondingly, an <tt>@Immediate finish</tt> can be + translated into the invocation of a "local fence". This fence is a blocking + operation that succeeds only when acknowledgments for all messages sent out from the source + (since the last "local fence" call) have been received. (While it blocks, it services incoming messages.) + + */ +public interface Immediate + extends ExpressionAnnotation, StatementAnnotation, MethodAnnotation { +} Modified: trunk/x10.runtime/src-x10/x10/compiler/Native.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/compiler/Native.x10 2009-11-19 22:08:04 UTC (rev 12145) +++ trunk/x10.runtime/src-x10/x10/compiler/Native.x10 2009-11-19 22:43:11 UTC (rev 12146) @@ -13,7 +13,7 @@ /** * Annotation to mark methods and fields as having a particular native implementation. - * lang is the name of the language, typically "java" or "c". + * lang is the name of the language, typically "java" or "c++". * code is the code to insert for a call to the method or an access to the field. * * For "java" annotations: Added: trunk/x10.runtime/src-x10/x10/compiler/Unroll.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/compiler/Unroll.x10 (rev 0) +++ trunk/x10.runtime/src-x10/x10/compiler/Unroll.x10 2009-11-19 22:43:11 UTC (rev 12146) @@ -0,0 +1,17 @@ +/* + * + * (C) Copyright IBM Corporation 2006-2008. + * + * This file is part of X10 Language. + * + */ + +package x10.compiler; + +import x10.lang.annotations.StatementAnnotation; + +/** + * <tt>@Unroll</tt> may be used to annotate a loop. + * The body of the loop will be unrolled the specified number of times. + */ +public interface Unroll(factor: Int) extends StatementAnnotation { } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <spa...@us...> - 2009-11-19 23:57:46
|
Revision: 12152 http://x10.svn.sourceforge.net/x10/?rev=12152&view=rev Author: sparksparkspark Date: 2009-11-19 23:57:36 +0000 (Thu, 19 Nov 2009) Log Message: ----------- Disable debug output Modified Paths: -------------- trunk/x10.dist/samples/KMeansCUDA.x10 trunk/x10.runtime/src-cpp/x10rt/common/x10rt_cuda.cc Modified: trunk/x10.dist/samples/KMeansCUDA.x10 =================================================================== --- trunk/x10.dist/samples/KMeansCUDA.x10 2009-11-19 23:20:56 UTC (rev 12151) +++ trunk/x10.dist/samples/KMeansCUDA.x10 2009-11-19 23:57:36 UTC (rev 12152) @@ -17,6 +17,7 @@ +import x10.compiler.Unroll; import x10.compiler.CUDA; import x10.compiler.CUDAUtilities; @@ -221,8 +222,7 @@ for (var p:Int=tid ; p<num_local_points ; p+=tids) { var closest:Int = -1; var closest_dist:Float = Float.MAX_VALUE; - //@unroll(20) - for ((k) in 0..num_clusters-1) { + @Unroll(10) for ((k) in 0..num_clusters-1) { // Pythagoras (in d dimensions) var dist : Float = 0; for ((d) in 0..3) { @@ -277,7 +277,7 @@ for (var d:Int=0 ; d<4 ; ++d) clusters(k*4+d) /= cluster_counts(k); } - printClusters(clusters(),4); + //printClusters(clusters(),4); // TEST FOR CONVERGENCE for (var j:Int=0 ; j<num_clusters*4 ; ++j) { Modified: trunk/x10.runtime/src-cpp/x10rt/common/x10rt_cuda.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10rt/common/x10rt_cuda.cc 2009-11-19 23:20:56 UTC (rev 12151) +++ trunk/x10.runtime/src-cpp/x10rt/common/x10rt_cuda.cc 2009-11-19 23:57:36 UTC (rev 12152) @@ -15,7 +15,7 @@ #include <cuda.h> // Proprietory nvidia header -#define TRACE 0 +//#define TRACE 1 namespace { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <spa...@us...> - 2009-11-20 22:34:17
|
Revision: 12160 http://x10.svn.sourceforge.net/x10/?rev=12160&view=rev Author: sparksparkspark Date: 2009-11-20 22:34:09 +0000 (Fri, 20 Nov 2009) Log Message: ----------- Some usability improvements to KMeansCUDA put the new DistributedRail back into XRX Modified Paths: -------------- trunk/x10.dist/samples/KMeansCUDA.x10 trunk/x10.runtime/src-x10/x10/util/DistributedRail.x10 Modified: trunk/x10.dist/samples/KMeansCUDA.x10 =================================================================== --- trunk/x10.dist/samples/KMeansCUDA.x10 2009-11-20 17:05:26 UTC (rev 12159) +++ trunk/x10.dist/samples/KMeansCUDA.x10 2009-11-20 22:34:09 UTC (rev 12160) @@ -4,13 +4,7 @@ import x10.io.Marshal; import x10.io.IOException; -//import x10.util.DistributedRail; -import x10.runtime.PlaceLocalStorage; -import x10.runtime.PlaceLocalHandle; -import x10.runtime.Runtime; -import x10.runtime.Activity; -import x10.util.Pair; -import x10.util.HashMap; +import x10.util.DistributedRail; import x10.util.OptionsParser; import x10.util.Option; @@ -22,125 +16,6 @@ import x10.compiler.CUDAUtilities; -final class DistributedRail[T] implements Settable[Int,T], Iterable[T] { - global val data : PlaceLocalHandle[Rail[T]]; - global val firstPlace : Place; - global val localRails = PlaceLocalStorage.createDistributedObject[HashMap[Activity, Rail[T]!]](Dist.makeUnique(), ()=>new HashMap[Activity, Rail[T]!]()); - global val original : ValRail[T]; - global val original_len : Int; - - global val done = PlaceLocalStorage.createDistributedObject[Cell[Boolean]](Dist.makeUnique(), ()=>new Cell[Boolean](false)); - - public def this (len:Int, vr:ValRail[T]) { - data = PlaceLocalStorage.createDistributedObject[Rail[T]](Dist.makeUnique(), ()=>Rail.make(len,vr)); - firstPlace = here; - original = vr; - original_len = len; - } - - public def this (len:Int, init:(Int)=>T) { - val vr = ValRail.make(len, init); - data = PlaceLocalStorage.createDistributedObject[Rail[T]](Dist.makeUnique(), ()=>Rail.make(len,vr)); - firstPlace = here; - original = vr; - original_len = len; - } - - public static safe operator[S] (x:DistributedRail[S]) = x() as ValRail[S]; - - public global safe def apply () { - val a = Runtime.activity(); - val r = localRails.get().getOrElse(a, null); - if (r==null) { - val r_ = Rail.make(original_len, original); - localRails.get().put(a, r_); - return r_; - } - return r; - } - - public global safe def get() = data.get(); - - public global safe def drop() { localRails.get().remove(Runtime.activity()); } - - public global safe def apply (i:Int) = this()(i); - - public global safe def set (v:T, i:Int) = this()(i) = v; - - public global safe def iterator () = this().iterator(); - - private global def reduceLocal (op:(T,T)=>T) { - val master = data.get(); - var first:Boolean = true; - for (e in localRails.get().entries()) { - val r = e.getValue(); - if (first) { - finish r.copyTo(0, master, 0, r.length); - first = false; - } else { - for (var i:Int=0 ; i<master.length ; ++i) { - master(i) = op(master(i), r(i)); - } - } - } - } - - private global def reduceGlobal (op:(T,T)=>T) { - if (firstPlace!=here) { - val local_ = data.get(); - { - val local = local_ as ValRail[T]; - at (firstPlace) { - val master = data.get(); - atomic for (var i:Int=0 ; i<master.length ; ++i) { - master(i) = op(master(i), local(i)); - } - } - } - next; // every place has transmitted contents to master - val handle = data; // avoid 'this' being serialised - finish local_.copyFrom[T](0, firstPlace, ()=>Pair[Rail[T],Int](handle.get(),0), local_.length); - } else { - next; - } - } - - private global def bcastLocal (op:(T,T)=>T) { - val master = data.get(); - for (e in localRails.get().entries()) { - val r = e.getValue(); - finish r.copyFrom(0, master, 0, r.length); - } - } - - // op must be commutative - public global def collectiveReduce (op:(T,T)=>T) { - var i_won:Boolean = false; - atomic { - if (!done.get().value) { - i_won = true; - done.get().value = true; - } - } - next; // activity rails populated at this place - if (i_won) { - // single thread per place mode - reduceLocal(op); - next; // every place has local rail populated - reduceGlobal(op); // there's one 'next' in here too - bcastLocal(op); - done.get().value = false; - } else { - next; - next; - } - next; // every place has finished reading from place 0 - } - -} - - - public class KMeansCUDA { public static def printClusters (clusters:Rail[Float]!, dims:Int) { @@ -157,26 +32,31 @@ public static def main (args : Rail[String]!) { try { - val opts = new OptionsParser(args, null, [ + val opts = new OptionsParser(args, [ + Option("q","quiet","just print time taken"), + Option("v","verbose","print out each iteration") + ], [ Option("p","points","location of data file"), Option("i","iterations","quit after this many iterations"), Option("c","clusters","number of clusters to find"), Option("n","num","quantity of points")]); val fname = opts("-p", "points.dat"), num_clusters=opts("-c",8), num_global_points=opts("-n", 100000), iterations=opts("-i",500); + val verbose = opts("-v"), quiet = opts("-q"); val MEM_ALIGN = 32; // FOR CUDA Console.OUT.println("points: "+num_global_points+" clusters: "+num_clusters+" dim: "+4); // file is dimension-major - val fr = (new File(fname)).openRead(); + val file = new File(fname), fr = file.openRead(); val init_points = (Int) => Float.fromIntBits(Marshal.INT.read(fr).reverseBytes()); - val global_points = ValRail.make(num_global_points*4, init_points); + val num_file_points = file.size() / 4 / 4 as Int; + val file_points = ValRail.make(num_file_points*4, init_points); var results : Rail[Float]!; // clusters are dimension-major - val clusters = new DistributedRail[Float](num_clusters*4, global_points); + val clusters = new DistributedRail[Float](num_clusters*4, file_points); val cluster_counts = new DistributedRail[Int](num_clusters, (Int)=>0); finish async { @@ -193,7 +73,7 @@ val num_local_points_stride = round_up(num_local_points,MEM_ALIGN); val init = (i:Int) => { val d=i/num_local_points_stride, p=i%num_local_points_stride; - return p<num_local_points ? global_points(((p+offset)%750000)*4 + d) : 0; + return p<num_local_points ? file_points(((p+offset)%num_file_points)*4 + d) : 0; }; // these are pretty big so allocate up front @@ -206,8 +86,6 @@ main_loop: for (var iter:Int=0 ; iter<iterations ; iter++) { - //if (offset==0) Console.OUT.println("Iteration: "+iter); - val clusters_copy = clusters as ValRail[Float]; // classify kernel @@ -222,7 +100,7 @@ for (var p:Int=tid ; p<num_local_points ; p+=tids) { var closest:Int = -1; var closest_dist:Float = Float.MAX_VALUE; - @Unroll(10) for ((k) in 0..num_clusters-1) { + @Unroll(20) for ((k) in 0..num_clusters-1) { // Pythagoras (in d dimensions) var dist : Float = 0; for ((d) in 0..3) { @@ -277,7 +155,10 @@ for (var d:Int=0 ; d<4 ; ++d) host_clusters(k*4+d) /= host_cluster_counts(k); } - //printClusters(clusters(),4); + if (offset==0 && verbose) { + Console.OUT.println("Iteration: "+iter); + printClusters(clusters(),4); + } // TEST FOR CONVERGENCE for (var j:Int=0 ; j<num_clusters*4 ; ++j) { @@ -298,11 +179,13 @@ } // finish - for (var k:Int=0 ; k<num_clusters ; ++k) { - for (var d:Int=0 ; d<4 ; ++d) clusters.get()(k*4+d) /= cluster_counts.get()(k); + if (!quiet) { + for (var k:Int=0 ; k<num_clusters ; ++k) { + for (var d:Int=0 ; d<4 ; ++d) clusters.get()(k*4+d) /= cluster_counts.get()(k); + } + printClusters(clusters.get(),4); } - printClusters(clusters.get(),4); } catch (e : Throwable) { e.printStackTrace(Console.ERR); Modified: trunk/x10.runtime/src-x10/x10/util/DistributedRail.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/util/DistributedRail.x10 2009-11-20 17:05:26 UTC (rev 12159) +++ trunk/x10.runtime/src-x10/x10/util/DistributedRail.x10 2009-11-20 22:34:09 UTC (rev 12160) @@ -2,61 +2,129 @@ import x10.runtime.PlaceLocalStorage; import x10.runtime.PlaceLocalHandle; - +import x10.runtime.Runtime; +import x10.runtime.Activity; import x10.util.Pair; +import x10.util.HashMap; /** * @author Dave Cunningham */ public final class DistributedRail[T] implements Settable[Int,T], Iterable[T] { - global val handle : PlaceLocalHandle[Rail[T]]; + global val data : PlaceLocalHandle[Rail[T]]; global val firstPlace : Place; - global val clock : Clock; + global val localRails = PlaceLocalStorage.createDistributedObject[HashMap[Activity, Rail[T]!]](Dist.makeUnique(), ()=>new HashMap[Activity, Rail[T]!]()); + global val original : ValRail[T]; + global val original_len : Int; - public def this (c:Clock, dist:Dist, len:Int, vr:ValRail[T]) { - handle = PlaceLocalStorage.createDistributedObject[Rail[T]](dist, ()=>Rail.make(len,vr)); - firstPlace = dist(0); - clock = c; + global val done = PlaceLocalStorage.createDistributedObject[Cell[Boolean]](Dist.makeUnique(), ()=>new Cell[Boolean](false)); + + public def this (len:Int, vr:ValRail[T]) { + data = PlaceLocalStorage.createDistributedObject[Rail[T]](Dist.makeUnique(), ()=>Rail.make(len,vr)); + firstPlace = here; + original = vr; + original_len = len; } - public def this (c:Clock, dist:Dist, len:Int, init:(Int)=>T) { + public def this (len:Int, init:(Int)=>T) { val vr = ValRail.make(len, init); - handle = PlaceLocalStorage.createDistributedObject[Rail[T]](dist, ()=>Rail.make(len,vr)); - firstPlace = dist(0); - clock = c; + data = PlaceLocalStorage.createDistributedObject[Rail[T]](Dist.makeUnique(), ()=>Rail.make(len,vr)); + firstPlace = here; + original = vr; + original_len = len; } - public static operator[S] (x:DistributedRail[S]) = x.handle.get() as ValRail[S]; + public static safe operator[S] (x:DistributedRail[S]) = x() as ValRail[S]; - public global def apply () = handle.get(); + public global safe def apply () { + val a = Runtime.activity(); + val r = localRails.get().getOrElse(a, null); + if (r==null) { + val r_ = Rail.make(original_len, original); + localRails.get().put(a, r_); + return r_; + } + return r; + } - public global def apply (i:Int) = handle.get()(i); + public global safe def get() = data.get(); - public global def set (v:T, i:Int) = handle.get()(i) = v; + public global safe def drop() { localRails.get().remove(Runtime.activity()); } - public global def iterator () = handle.get().iterator(); + public global safe def apply (i:Int) = this()(i); - // op must be commutative - public global def collectiveReduce (op:(T,T)=>T) { - // naive implementation - clock.next(); - val home = here; - val local_ = handle.get(); - { - val local = local_ as ValRail[T]; - at (firstPlace) { - val master = handle.get(); - atomic for (var i:Int=0 ; i<master.length ; ++i) { - master(i) = op(master(i), local(i)); + public global safe def set (v:T, i:Int) = this()(i) = v; + + public global safe def iterator () = this().iterator(); + + private global def reduceLocal (op:(T,T)=>T) { + val master = data.get(); + var first:Boolean = true; + for (e in localRails.get().entries()) { + val r = e.getValue(); + if (first) { + finish r.copyTo(0, master, 0, r.length); + first = false; + } else { + for (var i:Int=0 ; i<master.length ; ++i) { + master(i) = op(master(i), r(i)); } } } - clock.next(); - if (firstPlace!=here) + } + + private global def reduceGlobal (op:(T,T)=>T) { + if (firstPlace!=here) { + val local_ = data.get(); + { + val local = local_ as ValRail[T]; + at (firstPlace) { + val master = data.get(); + atomic for (var i:Int=0 ; i<master.length ; ++i) { + master(i) = op(master(i), local(i)); + } + } + } + next; // every place has transmitted contents to master + val handle = data; // avoid 'this' being serialised finish local_.copyFrom[T](0, firstPlace, ()=>Pair[Rail[T],Int](handle.get(),0), local_.length); - clock.next(); + } else { + next; + } } + private global def bcastLocal (op:(T,T)=>T) { + val master = data.get(); + for (e in localRails.get().entries()) { + val r = e.getValue(); + finish r.copyFrom(0, master, 0, r.length); + } + } + + // op must be commutative + public global def collectiveReduce (op:(T,T)=>T) { + var i_won:Boolean = false; + atomic { + if (!done.get().value) { + i_won = true; + done.get().value = true; + } + } + next; // activity rails populated at this place + if (i_won) { + // single thread per place mode + reduceLocal(op); + next; // every place has local rail populated + reduceGlobal(op); // there's one 'next' in here too + bcastLocal(op); + done.get().value = false; + } else { + next; + next; + } + next; // every place has finished reading from place 0 + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dgr...@us...> - 2009-11-23 17:35:22
|
Revision: 12174 http://x10.svn.sourceforge.net/x10/?rev=12174&view=rev Author: dgrove-oss Date: 2009-11-23 17:35:07 +0000 (Mon, 23 Nov 2009) Log Message: ----------- XTENLANG-586: Rename x10rt17.h to x10rt.h Modified Paths: -------------- trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java trunk/x10.runtime/build.xml trunk/x10.runtime/src-cpp/Makefile trunk/x10.runtime/src-cpp/x10/lang/Struct.h trunk/x10.runtime/src-cpp/x10/runtime/Deque.h trunk/x10.runtime/src-cpp/x10/runtime/PlaceLocalHandle.h trunk/x10.runtime/src-cpp/x10/runtime/PlaceLocalHandle.struct_h trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicBoolean.h trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicInteger.h trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicLong.h trunk/x10.runtime/src-cpp/x10aux/itables.cc trunk/x10.tests/bin/samplesTestScriptCT++ trunk/x10.tests/bin/xtestScript++ trunk/x10.tests/bin/xtestScriptCT++ Added Paths: ----------- trunk/x10.runtime/src-cpp/x10rt.h Removed Paths: ------------- trunk/x10.runtime/src-cpp/x10rt17.h Modified: trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java =================================================================== --- trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java 2009-11-23 17:29:26 UTC (rev 12173) +++ trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java 2009-11-23 17:35:07 UTC (rev 12174) @@ -681,7 +681,7 @@ h.write("#ifndef __"+cguard); h.newline(); h.write("#define __"+cguard); h.newline(); h.forceNewline(0); - h.write("#include <x10rt17.h>"); h.newline(); + h.write("#include <x10rt.h>"); h.newline(); h.forceNewline(0); g.write("#ifndef "+cguard+"_GENERICS"); g.newline(); Modified: trunk/x10.runtime/build.xml =================================================================== --- trunk/x10.runtime/build.xml 2009-11-23 17:29:26 UTC (rev 12173) +++ trunk/x10.runtime/build.xml 2009-11-23 17:35:07 UTC (rev 12174) @@ -117,6 +117,10 @@ <exec executable="${make.exe}" failonerror="true" dir="${basedir}/src-cpp"> <arg value="-j1" /> <arg value="clean"/> + <arg value="${cppmake.x10rt_mpi}" /> + <arg value="${cppmake.x10rt_pgas}" /> + <arg value="${cppmake.x10rt_cuda}" /> + <arg value="${cppmake.cross_compile_bgp}" /> </exec> </target> <target name="prepare-clean-bdwgc" if="bdwgc.enabled"> Modified: trunk/x10.runtime/src-cpp/Makefile =================================================================== --- trunk/x10.runtime/src-cpp/Makefile 2009-11-23 17:29:26 UTC (rev 12173) +++ trunk/x10.runtime/src-cpp/Makefile 2009-11-23 17:35:07 UTC (rev 12174) @@ -295,7 +295,7 @@ find x10 -name \*.h | tar cf - $(INC_FLAG) | (cd $(INSTDIR)/include && tar xvf -) find x10 -name \*.struct_h | tar cf - $(INC_FLAG) | (cd $(INSTDIR)/include && tar xvf -) find x10aux -name \*.h | tar cf - $(INC_FLAG) | (cd $(INSTDIR)/include && tar xvf -) - cp -p x10rt17.h $(INSTDIR)/include + cp -p x10rt.h $(INSTDIR)/include cp -p $(XRX_ARCHIVE) $(INSTDIR)/lib cp -p $(XRX_MANIFEST) $(INSTDIR)/lib cd x10rt && $(MAKE) -j1 debug all install X10RT_PLATFORM=$(X10RT_PLATFORM) Modified: trunk/x10.runtime/src-cpp/x10/lang/Struct.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Struct.h 2009-11-23 17:29:26 UTC (rev 12173) +++ trunk/x10.runtime/src-cpp/x10/lang/Struct.h 2009-11-23 17:35:07 UTC (rev 12174) @@ -1,7 +1,7 @@ #ifndef __X10_LANG_STRUCT_H #define __X10_LANG_STRUCT_H -#include <x10rt17.h> +#include <x10rt.h> namespace x10 { namespace lang { Modified: trunk/x10.runtime/src-cpp/x10/runtime/Deque.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/runtime/Deque.h 2009-11-23 17:29:26 UTC (rev 12173) +++ trunk/x10.runtime/src-cpp/x10/runtime/Deque.h 2009-11-23 17:35:07 UTC (rev 12174) @@ -7,7 +7,7 @@ #ifndef X10_RUNTIME_DEQUE_H #define X10_RUNTIME_DEQUE_H -#include <x10rt17.h> +#include <x10rt.h> #include <x10/lang/Ref.h> #include <x10aux/serialization.h> Modified: trunk/x10.runtime/src-cpp/x10/runtime/PlaceLocalHandle.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/runtime/PlaceLocalHandle.h 2009-11-23 17:29:26 UTC (rev 12173) +++ trunk/x10.runtime/src-cpp/x10/runtime/PlaceLocalHandle.h 2009-11-23 17:35:07 UTC (rev 12174) @@ -1,7 +1,7 @@ #ifndef X10_RUNTIME_PLACELOCALHANDLE_H #define X10_RUNTIME_PLACELOCALHANDLE_H -#include <x10rt17.h> +#include <x10rt.h> #include <x10/runtime/PlaceLocalHandle.struct_h> Modified: trunk/x10.runtime/src-cpp/x10/runtime/PlaceLocalHandle.struct_h =================================================================== --- trunk/x10.runtime/src-cpp/x10/runtime/PlaceLocalHandle.struct_h 2009-11-23 17:29:26 UTC (rev 12173) +++ trunk/x10.runtime/src-cpp/x10/runtime/PlaceLocalHandle.struct_h 2009-11-23 17:35:07 UTC (rev 12174) @@ -1,7 +1,7 @@ #ifndef X10_RUNTIME_PLACELOCALHANDLE_STRUCT_H #define X10_RUNTIME_PLACELOCALHANDLE_STRUCT_H -#include <x10rt17.h> +#include <x10rt.h> #include <x10/lang/String.h> Modified: trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicBoolean.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicBoolean.h 2009-11-23 17:29:26 UTC (rev 12173) +++ trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicBoolean.h 2009-11-23 17:35:07 UTC (rev 12174) @@ -7,7 +7,7 @@ #ifndef X10_UTIL_CONCURRENT_ATOMIC_ATOMICBOOLEAN_H #define X10_UTIL_CONCURRENT_ATOMIC_ATOMICBOOLEAN_H -#include <x10rt17.h> +#include <x10rt.h> #include <x10/lang/Ref.h> #include <x10aux/serialization.h> Modified: trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicInteger.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicInteger.h 2009-11-23 17:29:26 UTC (rev 12173) +++ trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicInteger.h 2009-11-23 17:35:07 UTC (rev 12174) @@ -7,7 +7,7 @@ #ifndef X10_UTIL_CONCURRENT_ATOMIC_ATOMICINTEGER_H #define X10_UTIL_CONCURRENT_ATOMIC_ATOMICINTEGER_H -#include <x10rt17.h> +#include <x10rt.h> #include <x10/lang/Ref.h> #include <x10aux/serialization.h> Modified: trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicLong.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicLong.h 2009-11-23 17:29:26 UTC (rev 12173) +++ trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicLong.h 2009-11-23 17:35:07 UTC (rev 12174) @@ -7,7 +7,7 @@ #ifndef X10_UTIL_CONCURRENT_ATOMIC_ATOMICLONG_H #define X10_UTIL_CONCURRENT_ATOMIC_ATOMICLONG_H -#include <x10rt17.h> +#include <x10rt.h> #include <x10/lang/Ref.h> #include <x10aux/serialization.h> Modified: trunk/x10.runtime/src-cpp/x10aux/itables.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/itables.cc 2009-11-23 17:29:26 UTC (rev 12173) +++ trunk/x10.runtime/src-cpp/x10aux/itables.cc 2009-11-23 17:35:07 UTC (rev 12174) @@ -1,6 +1,6 @@ #include <stdio.h> -#include<x10rt17.h> +#include<x10rt.h> using namespace x10aux; using namespace x10::lang; Copied: trunk/x10.runtime/src-cpp/x10rt.h (from rev 12171, trunk/x10.runtime/src-cpp/x10rt17.h) =================================================================== --- trunk/x10.runtime/src-cpp/x10rt.h (rev 0) +++ trunk/x10.runtime/src-cpp/x10rt.h 2009-11-23 17:35:07 UTC (rev 12174) @@ -0,0 +1,50 @@ +#ifndef X10RT_H +#define X10RT_H + +// include everything from this file + +#include <x10aux/config.h> + +// has to be first to ensure initialisation of pgas occurs before uses of x10aux::alloc +#include <x10aux/network.h> + +#include <x10aux/class_cast.h> +#include <x10aux/ref.h> +#include <x10aux/reference_logger.h> +#include <x10aux/alloc.h> +#include <x10aux/serialization.h> +#include <x10aux/deserialization_dispatcher.h> +#include <x10aux/throw.h> +#include <x10aux/RTT.h> +#include <x10aux/assert.h> +#include <x10aux/init_dispatcher.h> +#include <x10aux/static_init.h> +#include <x10aux/hash.h> +#include <x10aux/basic_functions.h> +#include <x10aux/atomic_ops.h> + +#include <x10aux/itables.h> + +#include <x10aux/boolean_utils.h> +#include <x10aux/byte_utils.h> +#include <x10aux/char_utils.h> +#include <x10aux/double_utils.h> +#include <x10aux/int_utils.h> +#include <x10aux/float_utils.h> +#include <x10aux/long_utils.h> +#include <x10aux/short_utils.h> +#include <x10aux/string_utils.h> +#include <x10aux/rail_utils.h> +#include <x10aux/fun_utils.h> + +#include <x10aux/math_utils.h> +#include <x10aux/system_utils.h> + +#include <x10aux/place_local.h> + +#include <x10aux/cuda/cuda_utils.h> +#include <x10aux/cuda/bridge_buffer.h> +#include <x10aux/cuda/ring_buffer.h> + +#endif +// vim:tabstop=4:shiftwidth=4:expandtab Deleted: trunk/x10.runtime/src-cpp/x10rt17.h =================================================================== --- trunk/x10.runtime/src-cpp/x10rt17.h 2009-11-23 17:29:26 UTC (rev 12173) +++ trunk/x10.runtime/src-cpp/x10rt17.h 2009-11-23 17:35:07 UTC (rev 12174) @@ -1,50 +0,0 @@ -#ifndef X10RT17_H -#define X10RT17_H - -// include everything from this file - -#include <x10aux/config.h> - -// has to be first to ensure initialisation of pgas occurs before uses of x10aux::alloc -#include <x10aux/network.h> - -#include <x10aux/class_cast.h> -#include <x10aux/ref.h> -#include <x10aux/reference_logger.h> -#include <x10aux/alloc.h> -#include <x10aux/serialization.h> -#include <x10aux/deserialization_dispatcher.h> -#include <x10aux/throw.h> -#include <x10aux/RTT.h> -#include <x10aux/assert.h> -#include <x10aux/init_dispatcher.h> -#include <x10aux/static_init.h> -#include <x10aux/hash.h> -#include <x10aux/basic_functions.h> -#include <x10aux/atomic_ops.h> - -#include <x10aux/itables.h> - -#include <x10aux/boolean_utils.h> -#include <x10aux/byte_utils.h> -#include <x10aux/char_utils.h> -#include <x10aux/double_utils.h> -#include <x10aux/int_utils.h> -#include <x10aux/float_utils.h> -#include <x10aux/long_utils.h> -#include <x10aux/short_utils.h> -#include <x10aux/string_utils.h> -#include <x10aux/rail_utils.h> -#include <x10aux/fun_utils.h> - -#include <x10aux/math_utils.h> -#include <x10aux/system_utils.h> - -#include <x10aux/place_local.h> - -#include <x10aux/cuda/cuda_utils.h> -#include <x10aux/cuda/bridge_buffer.h> -#include <x10aux/cuda/ring_buffer.h> - -#endif -// vim:tabstop=4:shiftwidth=4:expandtab Modified: trunk/x10.tests/bin/samplesTestScriptCT++ =================================================================== --- trunk/x10.tests/bin/samplesTestScriptCT++ 2009-11-23 17:29:26 UTC (rev 12173) +++ trunk/x10.tests/bin/samplesTestScriptCT++ 2009-11-23 17:35:07 UTC (rev 12174) @@ -603,7 +603,7 @@ X10CPP="$X10CPP -DISABLE_GC -NO_CHECKS -x10rt pgas_lapi" fi - if [[ ! -f $X10_HOME/x10.dist/include/x10rt17.h ]]; then + if [[ ! -f $X10_HOME/x10.dist/include/x10rt.h ]]; then printf "\n[$prog: err]: unable to locate x10rt header files!\n" cleanUpExitHarness 2 fi Modified: trunk/x10.tests/bin/xtestScript++ =================================================================== --- trunk/x10.tests/bin/xtestScript++ 2009-11-23 17:29:26 UTC (rev 12173) +++ trunk/x10.tests/bin/xtestScript++ 2009-11-23 17:35:07 UTC (rev 12174) @@ -510,7 +510,7 @@ if [[ -z "$X10LANG" ]]; then X10LANG=$X10_HOME/x10.runtime/src-cpp fi - if [[ ! (-f $X10LANG/x10rt17.h || -f $X10LANG/include/x10rt17.h) ]]; then + if [[ ! (-f $X10LANG/x10rt.h || -f $X10LANG/include/x10rt.h) ]]; then printf "\n[$prog: err]: unable to locate x10rt header files!\n" cleanUpExit 2 fi Modified: trunk/x10.tests/bin/xtestScriptCT++ =================================================================== --- trunk/x10.tests/bin/xtestScriptCT++ 2009-11-23 17:29:26 UTC (rev 12173) +++ trunk/x10.tests/bin/xtestScriptCT++ 2009-11-23 17:35:07 UTC (rev 12174) @@ -607,7 +607,7 @@ X10CPP="$X10CPP -DISABLE_GC -NO_CHECKS -x10rt pgas_sockets" fi - if [[ ! -f $X10_HOME/x10.dist/include/x10rt17.h ]]; then + if [[ ! -f $X10_HOME/x10.dist/include/x10rt.h ]]; then printf "\n[$prog: err]: unable to locate x10rt header files!\n" cleanUpExitHarness 2 fi This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ipe...@us...> - 2009-11-24 05:42:27
|
Revision: 12180 http://x10.svn.sourceforge.net/x10/?rev=12180&view=rev Author: ipeshansky Date: 2009-11-24 05:42:16 +0000 (Tue, 24 Nov 2009) Log Message: ----------- Numerous fixes to the persistent failures in the testsuite: - Proto, place type and other constrained type errors - Old operator overloading syntax - Old or nonexistent APIs - Missing casts and inheritance clauses - Ambiguous property references - Last vestiges of value types - Remove some defintitely invalid tests Fixes for some compiler errors: - Flags to X10Flags conversions Fixes to the X10 library classes: - Add constraints to some return types - Add iterator() to MapSet Modified Paths: -------------- trunk/x10.compiler/src/x10/types/MacroType_c.java trunk/x10.compiler/src/x10/types/X10ParsedClassType_c.java trunk/x10.runtime/src-x10/x10/lang/Array.x10 trunk/x10.runtime/src-x10/x10/lang/Place.x10 trunk/x10.runtime/src-x10/x10/util/HashSet.x10 trunk/x10.runtime/src-x10/x10/util/MapSet.x10 trunk/x10.tests/examples/Benchmarks/DistStream1.x10 trunk/x10.tests/examples/Benchmarks/ParRandomAccess1.x10 trunk/x10.tests/examples/Benchmarks/SeqRandomAccess1.x10 trunk/x10.tests/examples/Constructs/Array/ArrayCopy3.x10 trunk/x10.tests/examples/Constructs/Array/ArrayStaticPlusEqual.x10 trunk/x10.tests/examples/Constructs/Array/MiscTest1.x10 trunk/x10.tests/examples/Constructs/Array/PolyRestriction1.x10 trunk/x10.tests/examples/Constructs/Clock/ClockPascal.x10 trunk/x10.tests/examples/Constructs/Clock/ClockPascal2.x10 trunk/x10.tests/examples/Constructs/Clock/ClockTest17_MustFailTimeout.x10 trunk/x10.tests/examples/Constructs/Closures/ClosureExample1.x10 trunk/x10.tests/examples/Constructs/DepType/MethodArgDepTypes2.x10 trunk/x10.tests/examples/Constructs/Distribution/BlockCyclicDistWithPlaceSet.x10 trunk/x10.tests/examples/Constructs/Distribution/BlockDistWithPlaceSet.x10 trunk/x10.tests/examples/Constructs/Distribution/CyclicDistWithPlaceSet.x10 trunk/x10.tests/examples/Constructs/Generics/Bounds1.x10 trunk/x10.tests/examples/Constructs/Generics/GenericInference2.x10 trunk/x10.tests/examples/Constructs/Instanceof/ObjectToPrimitive2.x10 trunk/x10.tests/examples/Constructs/Place/PlaceCheckRail.x10 trunk/x10.tests/examples/Constructs/Region/PolyAlgebra2.x10 trunk/x10.tests/examples/Constructs/Region/PolyBox1.x10 trunk/x10.tests/examples/Constructs/Region/RegionAlgebra.x10 trunk/x10.tests/examples/Constructs/Region/RegionBoundingBox.x10 trunk/x10.tests/examples/Constructs/Region/RegionDifference.x10 trunk/x10.tests/examples/Constructs/Region/RegionEquality.x10 trunk/x10.tests/examples/Constructs/Typedefs/TypedefBasic2.x10 trunk/x10.tests/examples/Constructs/Typedefs/TypedefConstraint1a.x10 trunk/x10.tests/examples/Constructs/Typedefs/TypedefConstraint1b.x10 trunk/x10.tests/examples/Constructs/Typedefs/TypedefConstraint1c.x10 trunk/x10.tests/examples/Issues/XTENLANG_109.x10 trunk/x10.tests/examples/Issues/XTENLANG_110.x10 trunk/x10.tests/examples/Issues/XTENLANG_111.x10 trunk/x10.tests/examples/Issues/XTENLANG_118.x10 trunk/x10.tests/examples/Issues/XTENLANG_208.x10 trunk/x10.tests/examples/Issues/XTENLANG_209.x10 trunk/x10.tests/examples/Issues/XTENLANG_240.x10 trunk/x10.tests/examples/Issues/XTENLANG_241.x10 trunk/x10.tests/examples/Issues/XTENLANG_258.x10 trunk/x10.tests/examples/Issues/XTENLANG_305.x10 trunk/x10.tests/examples/Issues/XTENLANG_32.x10 trunk/x10.tests/examples/Issues/XTENLANG_4.x10 trunk/x10.tests/examples/Issues/XTENLANG_50.x10 trunk/x10.tests/examples/Issues/XTENLANG_51.x10 trunk/x10.tests/examples/Issues/XTENLANG_62.x10 trunk/x10.tests/examples/Misc/TypeElaborationAcrossCompilationUnits.x10 trunk/x10.tests/examples/Timings/ArrayIndexing.x10 trunk/x10.tests/examples/Timings/IntArrayIndexing.x10 Removed Paths: ------------- trunk/x10.tests/examples/Issues/XTENLANG_91.x10 trunk/x10.tests/examples/Misc/Unreachable.x10 Modified: trunk/x10.compiler/src/x10/types/MacroType_c.java =================================================================== --- trunk/x10.compiler/src/x10/types/MacroType_c.java 2009-11-24 03:15:20 UTC (rev 12179) +++ trunk/x10.compiler/src/x10/types/MacroType_c.java 2009-11-24 05:42:16 UTC (rev 12180) @@ -80,23 +80,23 @@ } public boolean isGlobal() { - return flags() == null ? false : ((X10Flags) flags()).isGlobal(); + return flags() == null ? false : X10Flags.toX10Flags(flags()).isGlobal(); } public boolean isProto() { - return flags() == null ? false : ((X10Flags) flags()).isProto(); + return flags() == null ? false : X10Flags.toX10Flags(flags()).isProto(); } public boolean isX10Struct() { return ((X10TypeSystem) typeSystem()).isStructType(this); } public X10Type setFlags(Flags f) { - X10Flags xf = (X10Flags) f; + X10Flags xf = X10Flags.toX10Flags(f); MacroType_c c = (MacroType_c) this.copy(); if (c.flags == null) c.flags = X10Flags.toX10Flags(Flags.NONE); c.flags = xf.isGlobal() - ? (xf.isStruct() ? ((X10Flags) c.flags).Global().Struct() : ((X10Flags) c.flags).Global()) - : ((xf.isStruct()) ? ((X10Flags) c.flags).Struct() : c.flags); + ? (xf.isStruct() ? X10Flags.toX10Flags(c.flags).Global().Struct() : X10Flags.toX10Flags(c.flags).Global()) + : ((xf.isStruct()) ? X10Flags.toX10Flags(c.flags).Struct() : c.flags); return c; } public X10Type clearFlags(Flags f) { Modified: trunk/x10.compiler/src/x10/types/X10ParsedClassType_c.java =================================================================== --- trunk/x10.compiler/src/x10/types/X10ParsedClassType_c.java 2009-11-24 03:15:20 UTC (rev 12179) +++ trunk/x10.compiler/src/x10/types/X10ParsedClassType_c.java 2009-11-24 05:42:16 UTC (rev 12180) @@ -111,7 +111,7 @@ } public X10Type setFlags(Flags f) { - X10Flags xf = (X10Flags) f; + X10Flags xf = X10Flags.toX10Flags(f); X10ParsedClassType_c c = (X10ParsedClassType_c) this.copy(); c.flags = flags().set(f); /*if (xf.isRooted() || xf.isStruct()) { @@ -122,9 +122,9 @@ c.flags = X10Flags.toX10Flags(Flags.NONE); f.s c.flags = xf.isRooted() - ? (xf.isStruct() ? ((X10Flags) c.flags).Rooted().Struct() - : ((X10Flags) c.flags).Rooted()) - : ((xf.isStruct()) ? ((X10Flags) c.flags).Struct() : c.flags); + ? (xf.isStruct() ? X10Flags.toX10Flags(c.flags).Rooted().Struct() + : X10Flags.toX10Flags(c.flags).Rooted()) + : ((xf.isStruct()) ? X10Flags.toX10Flags(c.flags).Struct() : c.flags); return c; }*/ return c; Modified: trunk/x10.runtime/src-x10/x10/lang/Array.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Array.x10 2009-11-24 03:15:20 UTC (rev 12179) +++ trunk/x10.runtime/src-x10/x10/lang/Array.x10 2009-11-24 05:42:16 UTC (rev 12180) @@ -113,8 +113,8 @@ public abstract safe global def set(v:T, i0: int, i1: int, i2: int) {rank==3}: T; public abstract safe global def set(v:T, i0: int, i1: int, i2: int, i3:int) {rank==4}: T; - public abstract safe global def restriction(r: Region(rank)): Array[T]; - public abstract safe global def restriction(p: Place): Array[T]; + public abstract safe global def restriction(r: Region(rank)): Array[T](rank); + public abstract safe global def restriction(p: Place): Array[T](rank); public abstract safe global operator + this: Array[T]; public abstract safe global operator - this: Array[T]; Modified: trunk/x10.runtime/src-x10/x10/lang/Place.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Place.x10 2009-11-24 03:15:20 UTC (rev 12179) +++ trunk/x10.runtime/src-x10/x10/lang/Place.x10 2009-11-24 05:42:16 UTC (rev 12180) @@ -29,7 +29,7 @@ public def this(id: Int):Place{self.id==id} { property(id); } - public static def place(id: Int) = places(id); + public static def place(id: Int): Place(id) = places(id) as Place(id); public def next(): Place = next(1); public def prev(): Place = next(-1); public def prev(i: Int): Place = next(-i); Modified: trunk/x10.runtime/src-x10/x10/util/HashSet.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/util/HashSet.x10 2009-11-24 03:15:20 UTC (rev 12179) +++ trunk/x10.runtime/src-x10/x10/util/HashSet.x10 2009-11-24 05:42:16 UTC (rev 12180) @@ -1,8 +1,8 @@ package x10.util; -public abstract class HashSet[T] extends MapSet[T] { +public class HashSet[T] extends MapSet[T] { public def this() { super(new HashMap[T,boolean]()); } public def this(sz: int) { super(new HashMap[T,boolean](sz)); } public incomplete def clone(): HashSet[T]; -} \ No newline at end of file +} Modified: trunk/x10.runtime/src-x10/x10/util/MapSet.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/util/MapSet.x10 2009-11-24 03:15:20 UTC (rev 12179) +++ trunk/x10.runtime/src-x10/x10/util/MapSet.x10 2009-11-24 05:42:16 UTC (rev 12180) @@ -11,4 +11,5 @@ public def add(v: T): Boolean = map.put(v, true) == null; public def remove(v: T): Boolean = map.remove(v) != null; public def clear(): Void = map.clear(); + public def iterator(): Iterator[T] = map.keySet().iterator(); } Modified: trunk/x10.tests/examples/Benchmarks/DistStream1.x10 =================================================================== --- trunk/x10.tests/examples/Benchmarks/DistStream1.x10 2009-11-24 03:15:20 UTC (rev 12179) +++ trunk/x10.tests/examples/Benchmarks/DistStream1.x10 2009-11-24 05:42:16 UTC (rev 12180) @@ -34,17 +34,19 @@ public def once() { finish for (var p:int=0; p<PARALLELISM; p++) { - val a = as(p); - val b = bs(p); - val c = cs(p); - async (Place.place(p)) { + val pl = Place.place(p); + val a = as(p) as Rail[double]!pl; + val b = bs(p) as Rail[double]!pl; + val c = cs(p) as Rail[double]!pl; + async (pl) { for (var tt:int=0; tt<NUM_TIMES; tt++) // XTENLANG-311 for (var i:int=0; i<localSize; i++) a(i) = b(i) + gamma*c(i); } } - val a = as(1); - return at (Place.place(1)) a(1); + val p1 = Place.place(1); + val a = as(1) as Rail[double]!p1; + return at (p1) a(1); } // Modified: trunk/x10.tests/examples/Benchmarks/ParRandomAccess1.x10 =================================================================== --- trunk/x10.tests/examples/Benchmarks/ParRandomAccess1.x10 2009-11-24 03:15:20 UTC (rev 12179) +++ trunk/x10.tests/examples/Benchmarks/ParRandomAccess1.x10 2009-11-24 05:42:16 UTC (rev 12180) @@ -75,7 +75,7 @@ for (var i:long=0; i<numUpdates/PARALLELISM; i++) { val placeId = ((ran>>logLocalTableSize) & placeMask) as int; val valran = ran; - val table = tables(placeId); + val table = tables(placeId) as LocalTable!; table.update(valran); ran = (ran << 1) ^ (ran<0L ? POLY : 0L); } @@ -96,7 +96,7 @@ randomAccessUpdate(tables); var errors:int = 0; for (var p:int=0; p<PARALLELISM; p++) { - val table = tables(p); + val table = tables(p) as LocalTable!; for (var j:int=0; j<table.a.length; j++) if (table.a(j) != j) errors++; Modified: trunk/x10.tests/examples/Benchmarks/SeqRandomAccess1.x10 =================================================================== --- trunk/x10.tests/examples/Benchmarks/SeqRandomAccess1.x10 2009-11-24 03:15:20 UTC (rev 12179) +++ trunk/x10.tests/examples/Benchmarks/SeqRandomAccess1.x10 2009-11-24 05:42:16 UTC (rev 12180) @@ -93,7 +93,7 @@ randomAccessUpdate(tables); var errors:int = 0; for (var p:int=0; p<PARALLELISM; p++) { - val table = tables(p); + val table = tables(p) as LocalTable!; for (var j:int=0; j<table.a.length; j++) if (table.a(j) != j) errors++; Modified: trunk/x10.tests/examples/Constructs/Array/ArrayCopy3.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Array/ArrayCopy3.x10 2009-11-24 03:15:20 UTC (rev 12179) +++ trunk/x10.tests/examples/Constructs/Array/ArrayCopy3.x10 2009-11-24 05:42:16 UTC (rev 12180) @@ -76,7 +76,7 @@ val Common: Region(A.rank) = LocalD && RemoteE; val D_common: Dist(A.rank) = D | Common; // the future's can be aggregated - for (val i: Point in D_common) { + for (val i: Point(A.rank) in D_common) { async(py) atomic accessed_b(i) += 1; val temp = (future(py){B(i)}).force(); // the following may need to be bracketed in @@ -111,10 +111,10 @@ } // ensure each A[i] was accessed exactly once - finish ateach (val i: Point in D) chk(accessed_a(i) == 1); + finish ateach (val i: Point(A.rank) in D) chk(accessed_a(i) == 1); // ensure each B[i] was accessed exactly once - finish ateach (val i: Point in E) chk(accessed_b(i) == 1); + finish ateach (val i: Point(A.rank) in E) chk(accessed_b(i) == 1); } public const N: int = 3; @@ -126,7 +126,7 @@ public def run(): boolean = { val R: Region{rank==4} = [0..N-1, 0..N-1, 0..N-1, 0..N-1]; - val TestDists: Region = [0..dist2.N_DIST_TYPES-1, 0..dist2.N_DIST_TYPES-1]; + val TestDists: Region(2) = [0..dist2.N_DIST_TYPES-1, 0..dist2.N_DIST_TYPES-1]; for (val distP(dX,dY): Point(2) in TestDists) { val D: Dist{rank==4} = dist2.getDist(dX, R); @@ -155,9 +155,7 @@ const CYCLIC: int = 1; const BLOCKCYCLIC: int = 2; const CONSTANT: int = 3; - const RANDOM: int = 4; - const ARBITRARY: int = 5; - const N_DIST_TYPES: int = 6; + const N_DIST_TYPES: int = 4; /** * Return a dist with region r, of type disttype @@ -166,10 +164,8 @@ switch(distType) { case BLOCK: return Dist.makeBlock(r); case CYCLIC: return Dist.makeCyclic(r); - case BLOCKCYCLIC: return Dist.makeBlockCyclic(r, 3); + case BLOCKCYCLIC: return Dist.makeBlockCyclic(r, 0, 3); case CONSTANT: return r->here; - case RANDOM: return Dist.makeRandom(r); - case ARBITRARY:return Dist.makeArbitrary(r); default: throw new Error(); } } Modified: trunk/x10.tests/examples/Constructs/Array/ArrayStaticPlusEqual.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Array/ArrayStaticPlusEqual.x10 2009-11-24 03:15:20 UTC (rev 12179) +++ trunk/x10.tests/examples/Constructs/Array/ArrayStaticPlusEqual.x10 2009-11-24 05:42:16 UTC (rev 12180) @@ -4,7 +4,7 @@ static val v: Rail[int]{self.at(Place.FIRST_PLACE)} = Rail.make[int](2, (x:nat)=>0); - public def run(){here == Place.FIRST_PLACE} { + public def run() { for ((i):Point(1) in 0..1) v(i) += 5; for ((i):Point(1) in 0..1) chk(v(i) == 5); return true; Modified: trunk/x10.tests/examples/Constructs/Array/MiscTest1.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Array/MiscTest1.x10 2009-11-24 03:15:20 UTC (rev 12179) +++ trunk/x10.tests/examples/Constructs/Array/MiscTest1.x10 2009-11-24 05:42:16 UTC (rev 12180) @@ -75,25 +75,25 @@ } // test scan - val y: Array[int]{dist==D} = x.scan(intArray.add, 0); + val y: Array[int]{dist==D} = x.scan(Int.+, 0); // y[i] == x[i]+y[i-1], for i>0 finish { ateach (pi(i) in D) { - val pi1: Point = [i-1]; + val pi1: Point(1) = [i-1]; chk(y(pi) == x(pi) + (i == 0 ? 0 : (future(D(pi1)) y(pi1)).force())); chk(y(i) == x(i) + (i == 0 ? 0 : (future(D(i-1)) y(i-1)).force())); } } // y[NP-1] == SUM(x[0..NP-1]) - val pNP_1: Point = [NP-1]; + val pNP_1: Point(1) = [NP-1]; chk(sum == (future(D(pNP_1)) y(pNP_1)).force()); chk(sum == (future(D(NP-1)) y(NP-1)).force()); // test lift - val z: Array[int]{dist==D} = x.lift(intArray.add, y) as Array[int]{dist==D}; + val z: Array[int]{dist==D} = x.lift(Int.+, y) as Array[int]{dist==D}; finish ateach (val pi in D) chk(z(pi) == x(pi) + y(pi)); Modified: trunk/x10.tests/examples/Constructs/Array/PolyRestriction1.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Array/PolyRestriction1.x10 2009-11-24 03:15:20 UTC (rev 12179) +++ trunk/x10.tests/examples/Constructs/Array/PolyRestriction1.x10 2009-11-24 05:42:16 UTC (rev 12180) @@ -14,7 +14,7 @@ val a2 = a1.restriction(r2); prArray("restricted array", a2); - for (x:Point in a2.region) + for (x:Point(2) in a2.region) a2(x(0), x(1)) = 7.0; prArray("whole array modified", a1); Modified: trunk/x10.tests/examples/Constructs/Clock/ClockPascal.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Clock/ClockPascal.x10 2009-11-24 03:15:20 UTC (rev 12179) +++ trunk/x10.tests/examples/Constructs/Clock/ClockPascal.x10 2009-11-24 05:42:16 UTC (rev 12180) @@ -77,13 +77,13 @@ val D = Dist.makeConstant([0..N-1, 0..N-1], here); val Dinner = D|([1..N-1, 1..N-1] as Region); val Dboundary = D-Dinner; - val A: Array[int] = Array.make[int](D, ((i,j):Point)=>Dboundary.contains([i, j]) ? 1 : 0); + val A: Array[int](2) = Array.make[int](D, ((i,j):Point)=>Dboundary.contains([i, j]) ? 1 : 0); finish async { // (nullable Clock)[.] N = does not work // clock[.] N = new clock[D]; should not work but does. // This is a workaround for this bug. - var N: Array[Clock] = Array.make[Clock](D, (Point)=>Clock.make()); - var W: Array[Clock] = Array.make[Clock](D, (Point)=>Clock.make()); + var N: Array[Clock](2) = Array.make[Clock](D, (Point)=>Clock.make()); + var W: Array[Clock](2) = Array.make[Clock](D, (Point)=>Clock.make()); // foreach (Point [i,j]: Dinner) // clocked(N[i-1,j], W[i,j-1], N[i,j], W[i,j]) { ... } Modified: trunk/x10.tests/examples/Constructs/Clock/ClockPascal2.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Clock/ClockPascal2.x10 2009-11-24 03:15:20 UTC (rev 12179) +++ trunk/x10.tests/examples/Constructs/Clock/ClockPascal2.x10 2009-11-24 05:42:16 UTC (rev 12180) @@ -77,7 +77,7 @@ val D = Dist.makeConstant([0..N-1, 0..N-1], here); val Dinner = D|([1..N-1, 1..N-1] as Region); val Dboundary = D-Dinner; - val A: Array[int] = Array.make[int](D, ((i,j):Point)=>Dboundary.contains([i, j]) ? 1 : 0); + val A: Array[int](2) = Array.make[int](D, ((i,j):Point)=>Dboundary.contains([i, j]) ? 1 : 0); finish async { val N = Array.make[Clock](D, (Point)=>Clock.make()); for ((i,j) in D.region) { N(i, j) = Clock.make(); } Modified: trunk/x10.tests/examples/Constructs/Clock/ClockTest17_MustFailTimeout.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Clock/ClockTest17_MustFailTimeout.x10 2009-11-24 03:15:20 UTC (rev 12179) +++ trunk/x10.tests/examples/Constructs/Clock/ClockTest17_MustFailTimeout.x10 2009-11-24 05:42:16 UTC (rev 12180) @@ -44,7 +44,7 @@ public def run(): boolean = { /*A0*/ val c0: Clock = Clock.make(); - var x: X = new X(); + var x: X! = new X(); // f0 does not transmit clocks to subactivity var f0: foo = new foo() { public def apply(): void = { @@ -65,7 +65,7 @@ } }; - var fooArray: Rail[foo] = [f0,f1]; + var fooArray: Rail[foo]! = [f0,f1]; // This is invoking Y.test(f0) but not clear to a compiler Y.test(fooArray(x.zero())); @@ -122,7 +122,7 @@ * for a typical compiler */ static class X { - public val z:Rail[Int] = [1,0]; + public val z:Rail[Int]! = [1,0]; def zero(): int = { return z(z(z(1))); } def one(): int = { return z(z(z(0))); } def modify(): void = { z(0) += 1; } Modified: trunk/x10.tests/examples/Constructs/Closures/ClosureExample1.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Closures/ClosureExample1.x10 2009-11-24 03:15:20 UTC (rev 12179) +++ trunk/x10.tests/examples/Constructs/Closures/ClosureExample1.x10 2009-11-24 05:42:16 UTC (rev 12180) @@ -3,6 +3,7 @@ import harness.x10Test; +import x10.util.List; /** * Example from spec. If changes need to be made to this code to make @@ -13,7 +14,7 @@ public class ClosureExample1 extends x10Test { - def find[T](f:T=>Boolean, xs: List[T]):T { + def find[T](f:(T)=>Boolean, xs: List[T]):T { for (x in xs) if (f(x)) return x; return null; Modified: trunk/x10.tests/examples/Constructs/DepType/MethodArgDepTypes2.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/DepType/MethodArgDepTypes2.x10 2009-11-24 03:15:20 UTC (rev 12179) +++ trunk/x10.tests/examples/Constructs/DepType/MethodArgDepTypes2.x10 2009-11-24 05:42:16 UTC (rev 12180) @@ -15,8 +15,8 @@ public class MethodArgDepTypes2 extends x10Test { public static def arraycopy(val a_dest: Array[double], val a_src: Array[double]{rank==a_dest.rank}): void = { - val R: Region = a_src.region&& a_dest.region; - finish foreach (val p: Point in R) { + val R: Region{rank==a_dest.rank} = a_src.region&& a_dest.region; + finish foreach (val p: Point{rank==a_dest.rank} in R) { //finish for( point p : R){ a_dest(p)= (future(a_src.dist(p)) {a_src(p)}).force(); } Modified: trunk/x10.tests/examples/Constructs/Distribution/BlockCyclicDistWithPlaceSet.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Distribution/BlockCyclicDistWithPlaceSet.x10 2009-11-24 03:15:20 UTC (rev 12179) +++ trunk/x10.tests/examples/Constructs/Distribution/BlockCyclicDistWithPlaceSet.x10 2009-11-24 05:42:16 UTC (rev 12180) @@ -5,9 +5,10 @@ * This file is part of X10 Test. * */ +import harness.x10Test; + import x10.util.Set; import x10.util.HashSet; -import harness.x10Test; /** * Testing block-cyclic dist. @@ -24,10 +25,10 @@ */ public class BlockCyclicDistWithPlaceSet extends x10Test { - const P = Dist.makeUnique(); - const COUNT = 200; - const L = 5; - const K = 1; + public const P = Dist.makeUnique(); + public const COUNT = 200; + public const L = 5; + public const K = 1; public def run(): boolean = { for (val (tries): Point in 1..COUNT) { @@ -36,15 +37,15 @@ val ub1: int = ranInt(lb1, L); val ub2: int = ranInt(lb2, L); val R = [lb1..ub1, lb2..ub2] as Region; - val totalPoints: int = (ub1-lb1+1)*(ub2-lb2+1); + val totalPoints = (ub1-lb1+1)*(ub2-lb2+1); val bSize: int = ranInt(1, totalPoints+1); val r = createRandPlaceSet(); val np = r.np; val placeNums = r.placeNums; val placeSet = r.placeSet; - val DBlockCyclic = Dist.makeBlockCyclic(R, bSize, placeSet); - val offsWithinPlace = Array.makeUnique[int](np); + val DBlockCyclic = Dist.makeBlockCyclic(R, 0, bSize, placeSet); + val offsWithinPlace = Rail.make[int](np); var pn: int = 0; var offsWithinBlock: int = 0; //x10.io.Console.OUT.println("lb1 = "+lb1+" ub1 = "+ub1+" lb2 = "+lb2+" ub2 = "+ub2+" totalPoints = "+totalPoints+" bSize = "+bSize); @@ -72,56 +73,34 @@ */ static class randPlaceSet { val np: int; - val placeSet: ValRail[Place]; - val placeNums: Array[Int](1); - def this(n: int, a: Array[Int](1), s: ValRail[Place]): randPlaceSet = { + val placeSet: Set[Place]!; + val placeNums: Rail[Int]!; + def this(n: int, a: Rail[Int]!, s: Set[Place]): randPlaceSet = { np = n; placeNums = a; placeSet = s; } } - static class Cell { - val p:Place; - var next:Cell; - var length:Int; - def this(p:Place) = this(p, null); - - def this(p:Place, n:Cell):Cell { - this.p=p; - this.next=n; - this.length=(n==null? 0: n.length+1); - } - var temp:Cell; - def add(p:Place) = new Cell(p, this); - def toValRail():ValRail[Place] = { - temp = this; - new ValRail[Place](length, (Nat)=> - { val pp = this.temp.p; - this.temp = this.temp.next; - pp}) - } - } - + /** * Create a random, non-empty subset of the places */ - def createRandPlaceSet(): randPlaceSet = { - var placeSet: Cell = null; + def createRandPlaceSet(): randPlaceSet! = { + val placeSet: Set[Place] = new HashSet[Place](); var np: int; - val placeNums = Array.makeUnique[int](Place.MAX_PLACES); + val placeNums = Rail.make[int](Place.MAX_PLACES); do { np = 0; - val THRESH: int = ranInt(10, 90); for (val (i): Point(1) in P) { val x: int = ranInt(0, 99); if (x >= THRESH) { - placeSet = new Cell(P(i), placeSet); + placeSet.add(P(i)); placeNums(np++) = i; } } } while (np == 0); - return new randPlaceSet(np, placeNums, placeSet.toValRail()); + return new randPlaceSet(np, placeNums, placeSet); } public static def main(var args: Rail[String]): void = { Modified: trunk/x10.tests/examples/Constructs/Distribution/BlockDistWithPlaceSet.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Distribution/BlockDistWithPlaceSet.x10 2009-11-24 03:15:20 UTC (rev 12179) +++ trunk/x10.tests/examples/Constructs/Distribution/BlockDistWithPlaceSet.x10 2009-11-24 05:42:16 UTC (rev 12180) @@ -5,10 +5,11 @@ * This file is part of X10 Test. * */ -import x10.util.HashSet; -import x10.util.Set; import harness.x10Test; +import x10.util.Set; +import x10.util.HashSet; + /** * Testing block dist. * @@ -28,32 +29,31 @@ */ public class BlockDistWithPlaceSet extends x10Test { - public const P: Dist = Dist.makeUnique(); - public const COUNT: int = 200; - public const L: int = 5; + public const P = Dist.makeUnique(); + public const COUNT = 200; + public const L = 5; public def run(): boolean = { - for (val (tries): Point in [1..COUNT]) { + for (val (tries): Point in 1..COUNT) { val lb1: int = ranInt(-L, L); val lb2: int = ranInt(-L, L); val ub1: int = ranInt(lb1, L); val ub2: int = ranInt(lb2, L); - val R: Region = [lb1..ub1, lb2..ub2]; + val R = [lb1..ub1, lb2..ub2] as Region; + val totalPoints = (ub1-lb1+1)*(ub2-lb2+1); + val r = createRandPlaceSet(); + val np = r.np; + val placeNums = r.placeNums; + val placeSet = r.placeSet; - val r: randPlaceSet = createRandPlaceSet(); - val np: int = r.np; - val placeNums: Array[int] = r.placeNums; - val placeSet: Set = r.placeSet; - - val DBlock: Dist = Dist.makeBlock(R, 0, placeSet); - val totalPoints: int = (ub1-lb1+1)*(ub2-lb2+1); + val DBlock = Dist.makeBlock(R, 0, placeSet); val p: int = totalPoints/np; val q: int = totalPoints%np; var offsWithinPlace: int = 0; var pn: int = 0; //x10.io.Console.OUT.println("np = " + np + " lb1 = "+lb1+" ub1 = "+ub1+" lb2 = "+lb2+" ub2 = "+ub2+" totalPoints = "+totalPoints+" p = "+p+" q = "+q); - for (val (i,j): Point in R) { + for (val (i,j): Point(2) in R) { //x10.io.Console.OUT.println("placeNum = "+placeNums[pn]+" offsWithinPlace = "+offsWithinPlace+" i = "+i+" j = "+j+" DBlock[i,j] = "+DBlock[i,j].id); chk(DBlock(i, j) == P(placeNums(pn))); chk(P(placeNums(pn)).id == placeNums(pn)); @@ -73,9 +73,9 @@ */ static class randPlaceSet { val np: int; - val placeSet: Set; - val placeNums: Array[int]; - def this(var n: int, var a: Array[int], var s: Set): randPlaceSet = { + val placeSet: Set[Place]!; + val placeNums: Rail[Int]!; + def this(n: int, a: Rail[Int]!, s: Set[Place]): randPlaceSet = { np = n; placeNums = a; placeSet = s; @@ -85,15 +85,14 @@ /** * Create a random, non-empty subset of the places */ - def createRandPlaceSet(): randPlaceSet = { - var placeSet: Set; + def createRandPlaceSet(): randPlaceSet! = { + val placeSet: Set[Place] = new HashSet[Place](); var np: int; - var placeNums: Array[int] = Array.make[int](Place.MAX_PLACES); + val placeNums = Rail.make[int](Place.MAX_PLACES); do { np = 0; - placeSet = new HashSet(); val THRESH: int = ranInt(10, 90); - for (val (i): Point in P) { + for (val (i): Point(1) in P) { val x: int = ranInt(0, 99); if (x >= THRESH) { placeSet.add(P(i)); Modified: trunk/x10.tests/examples/Constructs/Distribution/CyclicDistWithPlaceSet.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Distribution/CyclicDistWithPlaceSet.x10 2009-11-24 03:15:20 UTC (rev 12179) +++ trunk/x10.tests/examples/Constructs/Distribution/CyclicDistWithPlaceSet.x10 2009-11-24 05:42:16 UTC (rev 12180) @@ -5,9 +5,10 @@ * This file is part of X10 Test. * */ +import harness.x10Test; + import x10.util.Set; import x10.util.HashSet; -import harness.x10Test; /** * Testing cyclic dist. @@ -24,32 +25,32 @@ */ public class CyclicDistWithPlaceSet extends x10Test { - public const P = Dist.makeUnique(); - public const COUNT: int = 200; - public const L: int = 5; + public const P = Dist.makeUnique(); + public const COUNT = 200; + public const L = 5; public def run(): boolean = { - for (val (tries): Point in [1..COUNT]) { + for (val (tries): Point in 1..COUNT) { val lb1: int = ranInt(-L, L); val lb2: int = ranInt(-L, L); val ub1: int = ranInt(lb1, L); val ub2: int = ranInt(lb2, L); + val R = [lb1..ub1, lb2..ub2] as Region; + val totalPoints = (ub1-lb1+1)*(ub2-lb2+1); + val r = createRandPlaceSet(); + val np = r.np; + val placeNums = r.placeNums; + val placeSet = r.placeSet; - val R: Region = [lb1..ub1, lb2..ub2]; - val r: randPlaceSet = createRandPlaceSet(); - val np: int = r.np; - val placeNums: Array[int] = r.placeNums; - val placeSet = r.placeSet; - val DCyclic = Dist.cyclic(R, placeSet); - val totalPoints: int = (ub1-lb1+1)*(ub2-lb2+1); + val DCyclic = Dist.makeCyclic(R, 0, placeSet); var offsWithinPlace: int = 0; var pn: int = 0; //x10.io.Console.OUT.println("lb1 = "+lb1+" ub1 = "+ub1+" lb2 = "+lb2+" ub2 = "+ub2+" totalPoints = "+totalPoints); - for (val (i,j): Point in R) { - x10.io.Console.OUT.println("placeNum = "+Place.place(pn)+" offsWithinPlace = "+offsWithinPlace+" i = "+i+" j = "+j+" DCyclic[i,j] = "+DCyclic(i, j).id); - chk(P(placeNums(pn)).id == Place.place(pn)); - chk(DCyclic(i, j) == P(Place.place(pn))); + for (val (i,j): Point(2) in R) { + //x10.io.Console.OUT.println("placeNum = "+Place.place(pn)+" offsWithinPlace = "+offsWithinPlace+" i = "+i+" j = "+j+" DCyclic[i,j] = "+DCyclic(i, j).id); + chk(DCyclic(i, j) == P(placeNums(pn))); + chk(P(placeNums(pn)).id == placeNums(pn)); pn++; if (pn == np) { //time to go to next offset @@ -66,9 +67,9 @@ */ static class randPlaceSet { val np: int; - val placeSet: Set[Place]; - val placeNums: Array[int]; - def this(var n: int, var a: Array[int], var s: Set[Place]): randPlaceSet = { + val placeSet: Set[Place]!; + val placeNums: Rail[Int]!; + def this(n: int, a: Rail[Int]!, s: Set[Place]): randPlaceSet = { np = n; placeNums = a; placeSet = s; @@ -78,15 +79,14 @@ /** * Create a random, non-empty subset of the places */ - def createRandPlaceSet(): randPlaceSet = { - var placeSet: Set; + def createRandPlaceSet(): randPlaceSet! = { + val placeSet: Set[Place] = new HashSet[Place](); var np: int; - var placeNums: Array[int] = Array.make[int](Place.MAX_PLACES); + val placeNums = Rail.make[int](Place.MAX_PLACES); do { np = 0; - placeSet = new HashSet(); val THRESH: int = ranInt(10, 90); - for (val (i): Point in P) { + for (val (i): Point(1) in P) { val x: int = ranInt(0, 99); if (x >= THRESH) { placeSet.add(P(i)); Modified: trunk/x10.tests/examples/Constructs/Generics/Bounds1.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Generics/Bounds1.x10 2009-11-24 03:15:20 UTC (rev 12179) +++ trunk/x10.tests/examples/Constructs/Generics/Bounds1.x10 2009-11-24 05:42:16 UTC (rev 12180) @@ -18,7 +18,7 @@ } public def run(): boolean = { - return new C[String]().x == ""; + return new C[String]().x.equals(""); } public static def main(var args: Rail[String]): void = { Modified: trunk/x10.tests/examples/Constructs/Generics/GenericInference2.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Generics/GenericInference2.x10 2009-11-24 03:15:20 UTC (rev 12179) +++ trunk/x10.tests/examples/Constructs/Generics/GenericInference2.x10 2009-11-24 05:42:16 UTC (rev 12180) @@ -15,11 +15,11 @@ public class GenericInference2 extends GenericTest { - class V {const name = "V"; def name(): String = name; }; - class W extends V {const name = "W"; def name(): String = name; }; - class X extends V {const name = "X"; def name(): String = name; }; - class Y extends X {const name = "Y"; def name(): String = name; }; - class Z extends X {const name = "Z"; def name(): String = name; }; + class V {const name = "V"; global def name(): String = name; }; + class W extends V {const name = "W"; global def name(): String = name; }; + class X extends V {const name = "X"; global def name(): String = name; }; + class Y extends X {const name = "Y"; global def name(): String = name; }; + class Z extends X {const name = "Z"; global def name(): String = name; }; def m[T](t:T){T<:X} = t.name(); Modified: trunk/x10.tests/examples/Constructs/Instanceof/ObjectToPrimitive2.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Instanceof/ObjectToPrimitive2.x10 2009-11-24 03:15:20 UTC (rev 12179) +++ trunk/x10.tests/examples/Constructs/Instanceof/ObjectToPrimitive2.x10 2009-11-24 05:42:16 UTC (rev 12180) @@ -14,7 +14,7 @@ public class ObjectToPrimitive2 extends x10Test { public def run(): boolean = { - var array: Rail[X10DepTypeClassOne] + var array: Rail[X10DepTypeClassOne]! = Rail.make[X10DepTypeClassOne](1, (nat):X10DepTypeClassOne=>null); var var: x10.lang.Object = array(0); return !(var instanceof Int); Modified: trunk/x10.tests/examples/Constructs/Place/PlaceCheckRail.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Place/PlaceCheckRail.x10 2009-11-24 03:15:20 UTC (rev 12179) +++ trunk/x10.tests/examples/Constructs/Place/PlaceCheckRail.x10 2009-11-24 05:42:16 UTC (rev 12180) @@ -38,7 +38,7 @@ public def run03(): boolean { - val r = ValRail.make[int](3); + val r = ValRail.make[int](3, (Int)=>0); try { (future (Place.places(1)) r(0)).force(); @@ -51,7 +51,7 @@ public def run04(): boolean { - val r = (future (Place.places(1)) ValRail.make[int](3)).force(); + val r = (future (Place.places(1)) ValRail.make[int](3, (Int)=>0)).force(); try { r(0); Modified: trunk/x10.tests/examples/Constructs/Region/PolyAlgebra2.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Region/PolyAlgebra2.x10 2009-11-24 03:15:20 UTC (rev 12179) +++ trunk/x10.tests/examples/Constructs/Region/PolyAlgebra2.x10 2009-11-24 05:42:16 UTC (rev 12180) @@ -17,30 +17,30 @@ val r3 = r(0,7,4,5); prArray("r3", r3, true); - val r4 = (r1.$or(r2)).$and(r3); + val r4 = (r1 || r2) && r3; prArray("r4=(r1||r2)&&r3", r4, true); - val r4x = r(0,1,4,5).$or(r(4,5,4,5)); + val r4x = r(0,1,4,5) || r(4,5,4,5); prArray("r4x", r4x, true); pr("r4.equals(r4x) checks " + r4.equals(r4x)); - pr("(r1.$or(r2)).contains(r4) checks " + (r1.$or(r2)).contains(r4)); + pr("(r1 || r2).contains(r4) checks " + (r1 || r2).contains(r4)); pr("r3.contains(r4) checks " + r3.contains(r4)); - val r5 = r1.$or(r2).$or(r3); + val r5 = r1 || r2 || r3; prArray("r5=r1||r2||r3", r5, true); - val r5x = r(0,1,0,7).$or(r(4,5,0,7)).$or(r(2,3,4,5)).$or(r(6,7,4,5)); + val r5x = r(0,1,0,7) || r(4,5,0,7) || r(2,3,4,5) || r(6,7,4,5); prArray("r5x", r5x, true); pr("r5.equals(r5x) checks " + r5.equals(r5x)); pr("r5.contains(r1) checks " + r5.contains(r1)); pr("r5.contains(r2) checks " + r5.contains(r2)); pr("r5.contains(r3) checks " + r5.contains(r3)); - val r6 = (r1.$or(r2)).$minus(r3); + val r6 = (r1 || r2) - r3; prArray("r6=(r1||r2)-r3", r6); - val r6x = r(0,1,0,3).$or(r(0,1,6,7)).$or(r(4,5,0,3)).$or(r(4,5,6,7)); + val r6x = r(0,1,0,3) || r(0,1,6,7) || r(4,5,0,3) || r(4,5,6,7); prArray("r6x", r6x, true); pr("r6.equals(r6x) checks " + r6.equals(r6x)); - pr("(r1.$or(r2)).contains(r6) checks " + (r1.$or(r2)).contains(r6)); + pr("(r1 || r2).contains(r6) checks " + (r1 || r2).contains(r6)); pr("r6.disjoint(r3) checks " + r6.disjoint(r3)); return status(); @@ -148,7 +148,7 @@ " 4 . . . . 1 1 . . . . \n"+ " 5 . . . . 1 1 . . . . \n"+ "r4.equals(r4x) checks true\n"+ - "(r1.$or(r2)).contains(r4) checks true\n"+ + "(r1 || r2).contains(r4) checks true\n"+ "r3.contains(r4) checks true\n"+ "--- PolyAlgebra2: r5=r1||r2||r3\n"+ "rank 2\n"+ @@ -263,7 +263,7 @@ " 4 1 1 1 1 . . 1 1 . . \n"+ " 5 1 1 1 1 . . 1 1 . . \n"+ "r6.equals(r6x) checks true\n"+ - "(r1.$or(r2)).contains(r6) checks true\n"+ + "(r1 || r2).contains(r6) checks true\n"+ "r6.disjoint(r3) checks true\n"; public static def main(Rail[String]) { Modified: trunk/x10.tests/examples/Constructs/Region/PolyBox1.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Region/PolyBox1.x10 2009-11-24 03:15:20 UTC (rev 12179) +++ trunk/x10.tests/examples/Constructs/Region/PolyBox1.x10 2009-11-24 05:42:16 UTC (rev 12180) @@ -19,16 +19,16 @@ prArray("r3", r3, true); pr("r3.boundingBox().equals(r3) checks " + r3.boundingBox().equals(r3)); - val r12 = r1.$or(r2); + val r12 = r1 || r2; prArray("r12", r12, true); val r12b = r12.boundingBox(); prArray("r12b", r12b, true); pr("r12b.equals(r(0,5,0,7)) checks " + r12b.equals(r(0,5,0,7))); - val r12a3 = r12.$and(r3); + val r12a3 = r12 && r3; prArray("r12a3", r12a3, true); - val r12a3x = r(0,1,4,5).$or(r(4,5,4,5)); + val r12a3x = r(0,1,4,5) || r(4,5,4,5); prArray("r12a3x", r12a3x, true); pr("r12a3.equals(r12a3x) checks " + r12a3.equals(r12a3x)); pr("r12.contains(r12a3) checks " + r12.contains(r12a3)); @@ -38,9 +38,9 @@ prArray("r12a3b", r12a3b, true); pr("r12a3b.equals(r(0,5,4,5)) checks " + r12a3b.equals(r(0,5,4,5))); - val r123 = r1.$or(r2).$or(r3); + val r123 = r1 || r2 || r3; prArray("r123", r123, true); - val r123x = r(0,1,0,7).$or(r(4,5,0,7)).$or(r(2,3,4,5)).$or(r(6,7,4,5)); + val r123x = r(0,1,0,7) || r(4,5,0,7) || r(2,3,4,5) || r(6,7,4,5); prArray("r123x", r123x, true); pr("r123.equals(r123x) checks " + r123.equals(r123x)); pr("r123.contains(r1) checks " + r123.contains(r1)); @@ -51,9 +51,9 @@ prArray("r123b", r123b, true); pr("r123b.equals(r(0,7,0,7)) checks " + r123b.equals(r(0,7,0,7))); - val r12m3 = r12.$minus(r3); + val r12m3 = r12 - r3; prArray("r12m3", r12m3, true); - val r12m3x = r(0,1,0,3).$or(r(0,1,6,7)).$or(r(4,5,0,3)).$or(r(4,5,6,7)); + val r12m3x = r(0,1,0,3) || r(0,1,6,7) || r(4,5,0,3) || r(4,5,6,7); pr("r12m3.equals(r12m3x) checks " + r12m3.equals(r12m3x)); pr("r12.contains(r12m3) checks " + r12.contains(r12m3)); pr("r12m3.disjoint(r3) checks " + r12m3.disjoint(r3)); @@ -62,14 +62,14 @@ prArray("r12m3b", r12m3b, true); pr("r12m3b.equals(r(0,5,0,7)) checks " + r12m3b.equals(r(0,5,0,7))); - val r4 = r(0,0,4,4).$or(r(1,1,3,3)).$or(r(5,5,2,2)).$or(r(3,3,6,6)); + val r4 = r(0,0,4,4) || r(1,1,3,3) || r(5,5,2,2) || r(3,3,6,6); prArray("r4", r4, true); val r4b = r4.boundingBox(); prArray("r4b", r4b, true); pr("r4b.equals(r(0,5,2,6)) checks " + r4b.equals(r(0,5,2,6))); - val r1a2 = r1.$and(r2); + val r1a2 = r1 && r2; prArray("r1a2", r1a2, true); pr("r1a2.isEmpty() checks " + r1a2.isEmpty()); Modified: trunk/x10.tests/examples/Constructs/Region/RegionAlgebra.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Region/RegionAlgebra.x10 2009-11-24 03:15:20 UTC (rev 12179) +++ trunk/x10.tests/examples/Constructs/Region/RegionAlgebra.x10 2009-11-24 05:42:16 UTC (rev 12180) @@ -22,13 +22,13 @@ val R2: Region{rank==2} = [4..5, 0..7]; val R3: Region{rank==2} = [0..7, 4..5]; val T1: Region{rank==2} = (R1 || R2) && R3; - chk(T1.equals([0..1, 4..5] || [4..5, 4..5])); + chk(T1.equals(([0..1, 4..5] as Region{rank==2}) || [4..5, 4..5])); chk((R1 || R2).contains(T1) && R3.contains(T1)); val T2: Region{rank==2} = R1 || R2 || R3; - chk(T2.equals([0..1, 0..7] || [4..5, 0..7] || [2..3, 4..5] || [6..7, 4..5])); + chk(T2.equals(([0..1, 0..7] as Region{rank==2}) || [4..5, 0..7] || [2..3, 4..5] || [6..7, 4..5])); chk(T2.contains(R1) && T2.contains(R2) && T2.contains(R3)); val T3: Region{rank==2} = (R1 || R2) - R3; - chk(T3.equals([0..1, 0..3] || [0..1, 6..7] || [4..5, 0..3] || [4..5, 6..7])); + chk(T3.equals(([0..1, 0..3] as Region{rank==2}) || [0..1, 6..7] || [4..5, 0..3] || [4..5, 6..7])); chk((R1 || R2).contains(T3) && T3.disjoint(R3)); return true; } Modified: trunk/x10.tests/examples/Constructs/Region/RegionBoundingBox.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Region/RegionBoundingBox.x10 2009-11-24 03:15:20 UTC (rev 12179) +++ trunk/x10.tests/examples/Constructs/Region/RegionBoundingBox.x10 2009-11-24 05:42:16 UTC (rev 12180) @@ -41,7 +41,7 @@ chk(R1orR2BoundingBox.equals([0..5, 0..7])); val R1orR2andR3: Region{rank==2} = R1orR2 && R3; pr("R1orR2andR3", R1orR2andR3); - chk(R1orR2andR3.equals([0..1, 4..5] || [4..5, 4..5])); + chk(R1orR2andR3.equals(([0..1, 4..5] as Region{rank==2}) || [4..5, 4..5])); chk(R1orR2.contains(R1orR2andR3) && R3.contains(R1orR2andR3)); chk(!R1orR2andR3.isConvex()); val R1orR2andR3BoundingBox: Region{rank==2} = R1orR2andR3.boundingBox() as Region{rank==2}; @@ -50,7 +50,7 @@ chk(R1orR2andR3BoundingBox.equals([0..5, 4..5])); val R1orR2orR3: Region{rank==2} = R1 || R2 || R3; pr("R1orR2orR3", R1orR2orR3); - chk(R1orR2orR3.equals([0..1, 0..7] || [4..5, 0..7] || [2..3, 4..5] || [6..7, 4..5])); + chk(R1orR2orR3.equals(([0..1, 0..7] as Region{rank==2}) || [4..5, 0..7] || [2..3, 4..5] || [6..7, 4..5])); chk(R1orR2orR3.contains(R1) && R1orR2orR3.contains(R2) && R1orR2orR3.contains(R3)); chk(!R1orR2orR3.isConvex()); val R1orR2orR3BoundingBox: Region = R1orR2orR3.boundingBox(); @@ -60,14 +60,14 @@ chk(R1orR2orR3BoundingBox.equals([0..7, 0..7])); val R1orR2minusR3: Region{rank==2} = R1orR2 - R3; pr("R1orR2minusR3", R1orR2minusR3); - chk(R1orR2minusR3.equals([0..1, 0..3] || [0..1, 6..7] || [4..5, 0..3] || [4..5, 6..7])); + chk(R1orR2minusR3.equals(([0..1, 0..3] as Region{rank==2}) || [0..1, 6..7] || [4..5, 0..3] || [4..5, 6..7])); chk(R1orR2.contains(R1orR2minusR3) && R1orR2minusR3.disjoint(R3)); chk(!R1orR2minusR3.isConvex()); val R1orR2minusR3BoundingBox: Region{rank==2} = R1orR2minusR3.boundingBox() as Region{rank==2}; pr("R1orR2minusR3BoundingBox", R1orR2minusR3BoundingBox); chk(R1orR2minusR3BoundingBox.isConvex()); chk(R1orR2minusR3BoundingBox.equals([0..5, 0..7])); - val R4: Region{rank==2} = ([0..0, 4..4] || [1..1, 3..3] || [5..5, 2..2] || [3..3, 6..6]); + val R4: Region{rank==2} = (([0..0, 4..4] as Region{rank==2}) || [1..1, 3..3] || [5..5, 2..2] || [3..3, 6..6]); pr("R4", R4); val R4boundingBox: Region{rank==2} = R4.boundingBox() as Region{rank==2}; pr("R4boundingBox", R4boundingBox); Modified: trunk/x10.tests/examples/Constructs/Region/RegionDifference.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Region/RegionDifference.x10 2009-11-24 03:15:20 UTC (rev 12179) +++ trunk/x10.tests/examples/Constructs/Region/RegionDifference.x10 2009-11-24 05:42:16 UTC (rev 12180) @@ -25,7 +25,7 @@ val factor: int = 8; val r: Region{rank==2} = [k..size-1, k..k]; //x10.io.Console.OUT.println(([k:k+factor-1,k:k]-r).toString()); - val d: Dist = Dist.makeCyclic([k..k+factor-1, k..k]-r, 0); + val d: Dist = Dist.makeCyclic(([k..k+factor-1, k..k] as Region{rank==2})-r, 0); return true; } Modified: trunk/x10.tests/examples/Constructs/Region/RegionEquality.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Region/RegionEquality.x10 2009-11-24 03:15:20 UTC (rev 12179) +++ trunk/x10.tests/examples/Constructs/Region/RegionEquality.x10 2009-11-24 05:42:16 UTC (rev 12180) @@ -13,8 +13,9 @@ public def run(): boolean = { val size: int = 10; - val R = [0..size-1, 0..size-1], S = [0..size-1, 0..size-1]; - return R==S; + val R: Region{rank==2} = [0..size-1, 0..size-1]; + val S: Region{rank==2} = [0..size-1, 0..size-1]; + return R.equals(S); } public static def main(var args: Rail[String]): void = { Modified: trunk/x10.tests/examples/Constructs/Typedefs/TypedefBasic2.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Typedefs/TypedefBasic2.x10 2009-11-24 03:15:20 UTC (rev 12179) +++ trunk/x10.tests/examples/Constructs/Typedefs/TypedefBasic2.x10 2009-11-24 05:42:16 UTC (rev 12180) @@ -25,9 +25,9 @@ type T1 = A[String]; type T2 = A[String]; - var t0:A[String] = new A[String]("0"); - var t1:T1 = new T1("1"); - var t2:T2 = new T2("2"); + var t0:A[String]! = new A[String]("0"); + var t1:T1! = new T1("1"); + var t2:T2! = new T2("2"); t0 = t1; t1 = t2; Modified: trunk/x10.tests/examples/Constructs/Typedefs/TypedefConstraint1a.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Typedefs/TypedefConstraint1a.x10 2009-11-24 03:15:20 UTC (rev 12179) +++ trunk/x10.tests/examples/Constructs/Typedefs/TypedefConstraint1a.x10 2009-11-24 05:42:16 UTC (rev 12180) @@ -17,7 +17,7 @@ public def run(): boolean = { type A[T]{T==Y} = T; - a:A[Y] = new Y(); + a:A[Y]! = new Y(); check("a.name()", a.name(), "Y"); return result; Modified: trunk/x10.tests/examples/Constructs/Typedefs/TypedefConstraint1b.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Typedefs/TypedefConstraint1b.x10 2009-11-24 03:15:20 UTC (rev 12179) +++ trunk/x10.tests/examples/Constructs/Typedefs/TypedefConstraint1b.x10 2009-11-24 05:42:16 UTC (rev 12180) @@ -16,7 +16,7 @@ public def run(): boolean = { type B[T]{T<:Y} = T; - b:B[Y] = new Y(); + b:B[Y]! = new Y(); check("b.name()", b.name(), "Y"); return result; Modified: trunk/x10.tests/examples/Constructs/Typedefs/TypedefConstraint1c.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Typedefs/TypedefConstraint1c.x10 2009-11-24 03:15:20 UTC (rev 12179) +++ trunk/x10.tests/examples/Constructs/Typedefs/TypedefConstraint1c.x10 2009-11-24 05:42:16 UTC (rev 12180) @@ -17,7 +17,7 @@ public def run(): boolean = { type C[T]{Y<:T} = T; - c:C[X] = new X(); + c:C[X]! = new X(); check("c.name()", c.name(), "X"); return result; Modified: trunk/x10.tests/examples/Issues/XTENLANG_109.x10 =================================================================== --- trunk/x10.tests/examples/Issues/XTENLANG_109.x10 2009-11-24 03:15:20 UTC (rev 12179) +++ trunk/x10.tests/examples/Issues/XTENLANG_109.x10 2009-11-24 05:42:16 UTC (rev 12180) @@ -9,13 +9,13 @@ class XTENLANG_109 extends x10Test { - class R(zb:boolean) { + static class R(zb:boolean) { def this(zb:boolean) = property(zb); - incomplete static def m(min:int, max:int): R{zb==(min==0)}; + incomplete static def m(min:int, max:int): R{self.zb==(min==0)}; - static def make(min:int, max:int): R{zb==(min==0)} { + static def make(min:int, max:int): R{self.zb==(min==0)} { return m(min, max); //return m(min, max) as R{zb==(min==0)}; // this doesn't work either } Modified: trunk/x10.tests/examples/Issues/XTENLANG_110.x10 =================================================================== --- trunk/x10.tests/examples/Issues/XTENLANG_110.x10 2009-11-24 03:15:20 UTC (rev 12179) +++ trunk/x10.tests/examples/Issues/XTENLANG_110.x10 2009-11-24 05:42:16 UTC (rev 12180) @@ -13,11 +13,11 @@ class D extends C {} - class CS { + class CS implements Iterable[C] { incomplete public def iterator(): Iterator[C]; } - class DS { + class DS implements Iterable[D] { incomplete public def iterator(): Iterator[D]; } Modified: trunk/x10.tests/examples/Issues/XTENLANG_111.x10 =================================================================== --- trunk/x10.tests/examples/Issues/XTENLANG_111.x10 2009-11-24 03:15:20 UTC (rev 12179) +++ trunk/x10.tests/examples/Issues/XTENLANG_111.x10 2009-11-24 05:42:16 UTC (rev 12180) @@ -10,7 +10,7 @@ class XTENLANG_111 extends x10Test { static class P { - incomplete public static def $convert(r: ValRail[int]): P; + incomplete public static operator (r: ValRail[int]): P; } static class A { Modified: trunk/x10.tests/examples/Issues/XTENLANG_118.x10 =================================================================== --- trunk/x10.tests/examples/Issues/XTENLANG_118.x10 2009-11-24 03:15:20 UTC (rev 12179) +++ trunk/x10.tests/examples/Issues/XTENLANG_118.x10 2009-11-24 05:42:16 UTC (rev 12180) @@ -22,7 +22,7 @@ } class UR extends R { - def this(rs: PRL) { super(rs.rank); val regions: Rail[R(rank)] = rs.toArray(); } + def this(rs: PRL!) { super(rs.rank); val regions: Rail[R(rs.rank)] = rs.toArray(); } } } Modified: trunk/x10.tests/examples/Issues/XTENLANG_208.x10 =================================================================== --- trunk/x10.tests/examples/Issues/XTENLANG_208.x10 2009-11-24 03:15:20 UTC (rev 12179) +++ trunk/x10.tests/examples/Issues/XTENLANG_208.x10 2009-11-24 05:42:16 UTC (rev 12180) @@ -9,7 +9,7 @@ public class XTENLANG_208 extends x10Test { - public def $plus(that: XTENLANG_208) = this; + public operator this + (that: XTENLANG_208) = this; def foo() { val sum = this + this; Modified: trunk/x10.tests/examples/Issues/XTENLANG_209.x10 =================================================================== --- trunk/x10.tests/examples/Issues/XTENLANG_209.x10 2009-11-24 03:15:20 UTC (rev 12179) +++ trunk/x10.tests/examples/Issues/XTENLANG_209.x10 2009-11-24 05:42:16 UTC (rev 12180) @@ -9,7 +9,7 @@ public class XTENLANG_209 extends x10Test { - public def $plus(c: int) = this; + public operator this + (c: int) = this; public def run():boolean { val i = 0; Modified: trunk/x10.tests/examples/Issues/XTENLANG_240.x10 =================================================================== --- trunk/x10.tests/examples/Issues/XTENLANG_240.x10 2009-11-24 03:15:20 UTC (rev 12179) +++ trunk/x10.tests/examples/Issues/XTENLANG_240.x10 2009-11-24 05:42:16 UTC (rev 12180) @@ -15,7 +15,7 @@ final public def apply(i0:int) = 0; } - def foo(a:A) { + def foo(a:A!) { for (var i:int=0; i<0; i++) a(i) = 0.0; } Modified: trunk/x10.tests/examples/Issues/XTENLANG_241.x10 =================================================================== --- trunk/x10.tests/examples/Issues/XTENLANG_241.x10 2009-11-24 03:15:20 UTC (rev 12179) +++ trunk/x10.tests/examples/Issues/XTENLANG_241.x10 2009-11-24 05:42:16 UTC (rev 12180) @@ -9,9 +9,9 @@ public class XTENLANG_241 extends x10Test { - public def $minus(): XTENLANG_241 = this; + public operator - this: XTENLANG_241! = this; - public def bar(p: XTENLANG_241) { + public def bar(p: XTENLANG_241!) { val q = -p; } Modified: trunk/x10.tests/examples/Issues/XTENLANG_258.x10 =================================================================== --- trunk/x10.tests/examples/Issues/XTENLANG_258.x10 2009-11-24 03:15:20 UTC (rev 12179) +++ trunk/x10.tests/examples/Issues/XTENLANG_258.x10 2009-11-24 05:42:16 UTC (rev 12180) @@ -10,7 +10,7 @@ class XTENLANG_258 extends x10Test { public def run():boolean { - val v: Rail[int] = Rail.make[int](1); + val v: Rail[int]! = Rail.make[int](1); v(0) += 1; return true; } Modified: trunk/x10.tests/examples/Issues/XTENLANG_305.x10 =================================================================== --- trunk/x10.tests/examples/Issues/XTENLANG_305.x10 2009-11-24 03:15:20 UTC (rev 12179) +++ trunk/x10.tests/examples/Issues/XTENLANG_305.x10 2009-11-24 05:42:16 UTC (rev 12180) @@ -14,7 +14,7 @@ public def apply(i:int, j:int, k:int): T = 0 as T; } - def foo(a:A[double]) { + def foo(a:A[double]!) { a(0,0,0)++; } Modified: trunk/x10.tests/examples/Issues/XTENLANG_32.x10 =================================================================== --- trunk/x10.tests/examples/Issues/XTENLANG_32.x10 2009-11-24 03:15:20 UTC (rev 12179) +++ trunk/x10.tests/examples/Issues/XTENLANG_32.x10 2009-11-24 05:42:16 UTC (rev 12180) @@ -12,7 +12,7 @@ def foo(x: (nat)=>int) = x(0); public def run():boolean { - val r = ValRail.make[int](2); // same problem with literal [1.2] + val r = [1,2]; foo(r); return true; } Modified: trunk/x10.tests/examples/Issues/XTENLANG_4.x10 =================================================================== --- trunk/x10.tests/examples/Issues/XTENLANG_4.x10 2009-11-24 03:15:20 UTC (rev 12179) +++ trunk/x10.tests/examples/Issues/XTENLANG_4.x10 2009-11-24 05:42:16 UTC (rev 12180) @@ -10,10 +10,12 @@ class XTENLANG_4 extends x10Test { class R(rank:int) { + def this(r:int) { property(r); } incomplete def m(val r: int): R{self.rank==r}; } class B extends R { + def this(r:int) { super(r); } incomplete def m(val r: int): R{self.rank==r}; } Modified: trunk/x10.tests/examples/Issues/XTENLANG_50.x10 =================================================================== --- trunk/x10.tests/examples/Issues/XTENLANG_50.x10 2009-11-24 03:15:20 UTC (rev 12179) +++ trunk/x10.tests/examples/Issues/XTENLANG_50.x10 2009-11-24 05:42:16 UTC (rev 12180) @@ -11,14 +11,14 @@ static class R(rank:nat) { - public static def make(val rs: ValRail[R]): R{rank==rs.length} { - return new R(rs.length) as R{rank==rs.length}; + public static def make(val rs: ValRail[R]): R{self.rank==rs.length} { + return new R(rs.length) as R{self.rank==rs.length}; } - public static def $convert(rs: ValRail[R]) = make(rs); + public static operator (rs: ValRail[R]) = make(rs); // workaround: declare return type explicitly - //public static def $convert(rs: ValRail[R]): R{rank==rs.length} = make(rs); + //public static operator (rs: ValRail[R]): R{self.rank==rs.length} = make(rs); def this(rank:nat) = property(rank); } @@ -26,6 +26,7 @@ val x: R{rank==2} = [new R(1), new R(1)]; // this doesn't work either, i.e. problem isn't with automatic conversion + // FIXME: this is old syntax //val x: R{rank==2} = R.$convert([new R(1), new R(1)]); public def run(): boolean { Modified: trunk/x10.tests/examples/Issues/XTENLANG_51.x10 =================================================================== --- trunk/x10.tests/examples/Issues/XTENLANG_51.x10 2009-11-24 03:15:20 UTC (rev 12179) +++ trunk/x10.tests/examples/Issues/XTENLANG_51.x10 2009-11-24 05:42:16 UTC (rev 12180) @@ -11,12 +11,12 @@ // standin for Region static public class R { - incomplete public static def $convert(rs: ValRail[R]): R; - incomplete public def $or(r:R):R; + incomplete public static operator (rs: ValRail[R!]): R!; + incomplete public operator this || (r:R!):R!; } // standin for val r:Region = [a..b, c..d] - val r:R = [new R(), new R()]; + val r:R! = [new R(), new R()]; // this works as expected val w = r || r; Modified: trunk/x10.tests/examples/Issues/XTENLANG_62.x10 =================================================================== --- trunk/x10.tests/examples/Issues/XTENLANG_62.x10 2009-11-24 03:15:20 UTC (rev 12179) +++ trunk/x10.tests/examples/Issues/XTENLANG_62.x10 2009-11-24 05:42:16 UTC (rev 12180) @@ -13,7 +13,7 @@ public def set(v:T, i0: int) {} } - def foo(a:A[double]) { + def foo(a:A[double]!) { //a.set(0.0, 0); // this works a(0) = 0.0; // this doesn't } Deleted: trunk/x10.tests/examples/Issues/XTENLANG_91.x10 =================================================================== --- trunk/x10.tests/examples/Issues/XTENLANG_91.x10 2009-11-24 03:15:20 UTC (rev 12179) +++ trunk/x10.tests/examples/Issues/XTENLANG_91.x10 2009-11-24 05:42:16 UTC (rev 12180) @@ -1,22 +0,0 @@ -// (C) Copyright IBM Corporation 2008 -// This file is part of X10 Test. * - -import harness.x10Test; - -/** - * @author bdlucas 10/2008 - */ - -class XTENLANG_91 extends x10Test { - - val y:Box[int] = 3; - val z = y + 1; - - public def run(): boolean { - return true; - } - - public static def main(Rail[String]) { - new XTENLANG_91().execute(); - } -} Modified: trunk/x10.tests/examples/Misc/TypeElaborationAcrossCompilationUnits.x10 =================================================================== --- trunk/x10.tests/examples/Misc/TypeElaborationAcrossCompilationUnits.x10 2009-11-24 03:15:20 UTC (rev 12179) +++ trunk/x10.tests/examples/Misc/TypeElaborationAcrossCompilationUnits.x10 2009-11-24 05:42:16 UTC (rev 12180) @@ -19,8 +19,8 @@ public def run(): boolean = { - var t: Temp = new Temp(); - var b: Region{rank==3} = t.m([1..10, 1..10, 1..10]); + var t: Temp! = new Temp(); + var b... [truncated message content] |
From: <vj...@us...> - 2009-11-27 16:51:58
|
Revision: 12200 http://x10.svn.sourceforge.net/x10/?rev=12200&view=rev Author: vj0 Date: 2009-11-27 16:51:51 +0000 (Fri, 27 Nov 2009) Log Message: ----------- Fixed Array.make's so that the arg initializer is of the form (Point(dist.rank))=>T. Existing X10 code (which expects (Point)=>T) will continue to work since the new type is a tighter type. Also reduced the detail in the string representation of a constraint. Fixes XTENLANG-659. Modified Paths: -------------- trunk/x10.compiler/src/x10/optimizations/LoopUnroller.java trunk/x10.compiler/src/x10/types/X10MethodInstance_c.java trunk/x10.compiler/src/x10/types/X10TypeEnv_c.java trunk/x10.compiler/src/x10/types/XTypeTranslator.java trunk/x10.runtime/src-x10/x10/array/BaseArray.x10 trunk/x10.runtime/src-x10/x10/array/DistArray.x10 trunk/x10.runtime/src-x10/x10/array/FastArray.x10 trunk/x10.runtime/src-x10/x10/array/LocalArray.x10 trunk/x10.runtime/src-x10/x10/lang/Array.x10 Modified: trunk/x10.compiler/src/x10/optimizations/LoopUnroller.java =================================================================== --- trunk/x10.compiler/src/x10/optimizations/LoopUnroller.java 2009-11-27 11:34:28 UTC (rev 12199) +++ trunk/x10.compiler/src/x10/optimizations/LoopUnroller.java 2009-11-27 16:51:51 UTC (rev 12200) @@ -294,7 +294,7 @@ // use type of domain to check its rank if (!checkDomainIs1D(fLoop.domain())) { - return fatalStatus("Cannot statically confirm that loop iteration domain is 1-dimensional"); + return fatalStatus("(at " + fLoopParams.fLoopVar.position() + ": cannot statically confirm that loop iteration domain is 1-dimensional"); } // now find the values that flow into the domain expr Modified: trunk/x10.compiler/src/x10/types/X10MethodInstance_c.java =================================================================== --- trunk/x10.compiler/src/x10/types/X10MethodInstance_c.java 2009-11-27 11:34:28 UTC (rev 12199) +++ trunk/x10.compiler/src/x10/types/X10MethodInstance_c.java 2009-11-27 16:51:51 UTC (rev 12200) @@ -829,7 +829,7 @@ return x; } /** - * thisType has had ys[0] substitued in for its self, and for this. + * thisType has had ys[0] substituted in for its self, and for this. * * @param <PI> * @param context Modified: trunk/x10.compiler/src/x10/types/X10TypeEnv_c.java =================================================================== --- trunk/x10.compiler/src/x10/types/X10TypeEnv_c.java 2009-11-27 11:34:28 UTC (rev 12199) +++ trunk/x10.compiler/src/x10/types/X10TypeEnv_c.java 2009-11-27 16:51:51 UTC (rev 12200) @@ -17,6 +17,7 @@ import polyglot.main.Report; import polyglot.types.ClassType; +import polyglot.types.ConstructorInstance; import polyglot.types.Context; import polyglot.types.Def; import polyglot.types.DerefTransform; @@ -38,6 +39,7 @@ import polyglot.types.TypeEnv_c; import polyglot.types.TypeSystem_c; import polyglot.types.Types; +import polyglot.types.TypeSystem_c.ConstructorMatcher; import polyglot.types.TypeSystem_c.TypeEquals; import polyglot.util.CollectionUtil; import polyglot.util.InternalCompilerError; @@ -1904,5 +1906,74 @@ return X10MethodInstance_c.callValidImpl((X10ProcedureInstance<?>) prototype, thisType, argTypes, context); } + /** + * Populates the list acceptable with those MethodInstances which are + * Applicable and Accessible as defined by JLS 15.11.2.1 + * + * @param container + * TODO + * @param matcher + * TODO + */ + @Override + public List<ConstructorInstance> findAcceptableConstructors(Type container, ConstructorMatcher matcher) throws SemanticException { + SemanticException error = null; + + List<ConstructorInstance> acceptable = new ArrayList<ConstructorInstance>(); + + if (Report.should_report(Report.types, 2)) + Report.report(2, "Searching type " + container + " for constructor " + matcher.signature()); + + if (!(container instanceof ClassType)) { + return Collections.EMPTY_LIST; + } + + for (ConstructorInstance ci : ((ClassType) container).constructors()) { + if (Report.should_report(Report.types, 3)) + Report.report(3, "Trying " + ci); + + try { + ci = matcher.instantiate(ci); + + if (ci == null) { + continue; + } + + if (isAccessible(ci)) { + if (Report.should_report(Report.types, 3)) + Report.report(3, "->acceptable: " + ci); + acceptable.add(ci); + } + else { + if (error == null) { + error = new NoMemberException(NoMemberException.CONSTRUCTOR, "Constructor " + ci.signature() + "\n is inaccessible."); + } + } + + continue; + } + catch (SemanticException e) { + // Treat any instantiation errors as call invalid errors. + } + + if (error == null) { + error = new NoMemberException(NoMemberException.CONSTRUCTOR, "Constructor " + ci.signature() + + "\n cannot be invoked with arguments \n" + + matcher.argumentString() + "."); + + } + } + + if (acceptable.size() == 0) { + if (error == null) { + error = new NoMemberException(NoMemberException.CONSTRUCTOR, "No valid constructor found for " + container + matcher.signature() + "."); + } + + throw error; + } + + return acceptable; + } + } Modified: trunk/x10.compiler/src/x10/types/XTypeTranslator.java =================================================================== --- trunk/x10.compiler/src/x10/types/XTypeTranslator.java 2009-11-27 11:34:28 UTC (rev 12199) +++ trunk/x10.compiler/src/x10/types/XTypeTranslator.java 2009-11-27 16:51:51 UTC (rev 12200) @@ -167,7 +167,8 @@ public XTerm trans(XConstraint c, XTerm target, FieldInstance fi, Type t) throws SemanticException { XTerm v; - XName field = XTerms.makeName(fi.def(), Types.get(fi.def().container()) + "#" + fi.name().toString()); + //XName field = XTerms.makeName(fi.def(), Types.get(fi.def().container()) + "#" + fi.name().toString()); + XName field = XTerms.makeName(fi.def(), fi.name().toString()); if (fi.flags().isStatic()) { Type container = Types.get(fi.def().container()); container = X10TypeMixin.baseType(container); Modified: trunk/x10.runtime/src-x10/x10/array/BaseArray.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/array/BaseArray.x10 2009-11-27 11:34:28 UTC (rev 12199) +++ trunk/x10.runtime/src-x10/x10/array/BaseArray.x10 2009-11-27 16:51:51 UTC (rev 12200) @@ -27,7 +27,7 @@ - public static def makeVar1[T](region: Region, init:(Point)=>T): Array[T](region) { + public static def makeVar1[T](region: Region, init:(Point(region.rank))=>T): Array[T](region) { val dist = Dist.makeConstant(region); // XXX _.x10 shd have Dist(Region) type? return makeVar1[T](dist, init) as Array[T](region); // would eliminate cast here } @@ -36,27 +36,27 @@ return makeVar1[T](dist) as Array[T](region); // would eliminate cast here } - public static def makeVal1[T](region: Region, init: (Point)=>T): Array[T] { + public static def makeVal1[T](region: Region, init: (Point(region.rank))=>T): Array[T](region) { val dist = Dist.makeConstant(region); return makeVal1[T](dist, init); } - public static def makeVal1[T](region: Region): Array[T] { + public static def makeVal1[T](region: Region): Array[T](region) { val dist = Dist.makeConstant(region); return makeVal1[T](dist); } - public static def makeVal1[T](dist: Dist, init: (Point)=>T): Array[T] { + public static def makeVal1[T](dist: Dist, init: (Point(dist.rank))=>T): Array[T](dist) { return makeVar1[T](dist, init); // XXX for now } - public static def makeVal1[T](dist: Dist): Array[T] { + public static def makeVal1[T](dist: Dist): Array[T](dist) { return makeVar1[T](dist); // XXX for now } - public static def makeVar1[T](dist: Dist, init: (Point)=>T): Array[T](dist) { + public static def makeVar1[T](dist: Dist, init: (Point(dist.rank))=>T): Array[T](dist) { if (dist.constant) { if (checkBounds || checkPlace) - return at (dist.onePlace) { new LocalArray[T](dist as Dist{constant,onePlace==here}, init) as Array[T](dist) }; // XXXXX ??? + return at (dist.onePlace) { new LocalArray[T](dist as Dist{constant,onePlace==here,self==dist}, init) }; else - return at (dist.onePlace) { new FastArray[T](dist as Dist{constant,onePlace==here}, init) as Array[T](dist) }; // XXXXX ??? + return at (dist.onePlace) { new FastArray[T](dist as Dist{constant,onePlace==here,self==dist}, init) }; } else { return new DistArray[T](dist, init); @@ -184,11 +184,11 @@ // views // - public safe global def restriction(r: Region(rank)): Array[T] { + public safe global def restriction(r: Region(rank)): Array[T](rank) { return restriction(dist.restriction(r)); } - public safe global def restriction(p: Place): Array[T] { + public safe global def restriction(p: Place): Array[T](rank) { return restriction(dist.restriction(p)); } @@ -267,24 +267,24 @@ // ops // - public safe global operator this | (r: Region(rank)): Array[T] = restriction(r); - public safe global operator this | (p: Place): Array[T] = restriction(p); + public safe global operator this | (r: Region(rank)) = restriction(r); + public safe global operator this | (p: Place) = restriction(p); - incomplete public safe global operator + this: Array[T]; - incomplete public safe global operator - this: Array[T]; + incomplete public safe global operator + this: Array[T](dist); + incomplete public safe global operator - this: Array[T](dist); - incomplete public safe global operator this + (that: Array[T]): Array[T]; - incomplete public safe global operator this - (that: Array[T]): Array[T]; - incomplete public safe global operator this * (that: Array[T]): Array[T]; - incomplete public safe global operator this / (that: Array[T]): Array[T]; - incomplete public safe global operator this % (that: Array[T]): Array[T]; + incomplete public safe global operator this + (that: Array[T](dist)): Array[T](dist); + incomplete public safe global operator this - (that: Array[T](dist)): Array[T](dist); + incomplete public safe global operator this * (that: Array[T](dist)): Array[T](dist); + incomplete public safe global operator this / (that: Array[T](dist)): Array[T](dist); + incomplete public safe global operator this % (that: Array[T](dist)): Array[T](dist); - incomplete public safe global operator this == (x: Array[T]): boolean; - incomplete public safe global operator this < (x: Array[T]): boolean; - incomplete public safe global operator this > (x: Array[T]): boolean; - incomplete public safe global operator this <= (x: Array[T]): boolean; - incomplete public safe global operator this >= (x: Array[T]): boolean; - incomplete public safe global operator this != (x: Array[T]): boolean; + incomplete public safe global operator this == (x: Array[T](dist)): boolean; + incomplete public safe global operator this < (x: Array[T](dist)): boolean; + incomplete public safe global operator this > (x: Array[T](dist)): boolean; + incomplete public safe global operator this <= (x: Array[T](dist)): boolean; + incomplete public safe global operator this >= (x: Array[T](dist)): boolean; + incomplete public safe global operator this != (x: Array[T](dist)): boolean; // incomplete public global def sum(): T; // XTENLANG-116 Modified: trunk/x10.runtime/src-x10/x10/array/DistArray.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/array/DistArray.x10 2009-11-27 11:34:28 UTC (rev 12199) +++ trunk/x10.runtime/src-x10/x10/array/DistArray.x10 2009-11-27 16:51:51 UTC (rev 12200) @@ -92,7 +92,7 @@ return v; } - def this(dist: Dist, init: (Point)=>T): DistArray[T]{self.dist==dist} { + def this(dist: Dist, init: (Point(dist.rank))=>T): DistArray[T]{self.dist==dist} { super(dist); val plsInit:()=>LocalState[T]! = () => { @@ -100,7 +100,7 @@ val localLayout = layout(region); val localRaw = Rail.make[T](localLayout.size()); - for (pt:Point in region) { + for (pt in region) { localRaw(localLayout.offset(pt)) = init(pt); } Modified: trunk/x10.runtime/src-x10/x10/array/FastArray.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/array/FastArray.x10 2009-11-27 11:34:28 UTC (rev 12199) +++ trunk/x10.runtime/src-x10/x10/array/FastArray.x10 2009-11-27 16:51:51 UTC (rev 12200) @@ -136,7 +136,7 @@ // // - def this(dist: Dist{constant}, init: (Point)=>T){here == dist.onePlace}: FastArray[T]{self.dist==dist} { + def this(dist: Dist{constant}, init: (Point{self.rank==dist.rank})=>T){here == dist.onePlace}: FastArray[T]{self.dist==dist} { super(dist); Modified: trunk/x10.runtime/src-x10/x10/array/LocalArray.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/array/LocalArray.x10 2009-11-27 11:34:28 UTC (rev 12199) +++ trunk/x10.runtime/src-x10/x10/array/LocalArray.x10 2009-11-27 16:51:51 UTC (rev 12200) @@ -11,7 +11,7 @@ // TODO: Need to come through and clean up place types and global methods. // This is a completely local array.... -final class LocalArray[T] extends BaseArray[T] { +final public class LocalArray[T] extends BaseArray[T] { private global val raw:Rail[T]{self.at(dist.onePlace)}; private global val layout:RectLayout; @@ -120,7 +120,7 @@ raw = r; } - def this(dist: Dist{constant}, init: (Point)=>T){here == dist.onePlace}:LocalArray[T]{self.dist==dist} { + def this(dist: Dist{constant}, init: (Point(dist.rank))=>T){here == dist.onePlace}:LocalArray[T]{self.dist==dist} { super(dist); layout = layout(region); Modified: trunk/x10.runtime/src-x10/x10/lang/Array.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Array.x10 2009-11-27 11:34:28 UTC (rev 12199) +++ trunk/x10.runtime/src-x10/x10/lang/Array.x10 2009-11-27 16:51:51 UTC (rev 12200) @@ -47,15 +47,15 @@ public static def make[T](region:Region)=makeVar[T](region); public static def make[T](dist: Dist)= makeVar[T](dist); - public static def make[T](region:Region, init: (Point)=>T)= makeVar[T](region, init); - public static def make[T](dist: Dist, init: (Point)=>T)= makeVar[T](dist, init); + public static def make[T](region:Region, init: (Point(region.rank))=>T)= makeVar[T](region, init); + public static def make[T](dist: Dist, init: (Point(dist.rank))=>T)= makeVar[T](dist, init); public static def makeVar[T](region: Region)= BaseArray.makeVar1[T](region); - public static def makeVar[T](region: Region, init: (Point)=>T): Array[T](region) + public static def makeVar[T](region: Region, init: (Point(region.rank))=>T): Array[T](region) = BaseArray.makeVar1[T](region, init) as Array[T](region); - public static def makeVar[T](dist: Dist, init:(Point)=>T): Array[T](dist) + public static def makeVar[T](dist: Dist, init:(Point(dist.rank))=>T): Array[T](dist) = BaseArray.makeVar1[T](dist, init); public static def makeVar[T](dist: Dist): Array[T](dist) = BaseArray.makeVar1[T](dist); @@ -66,10 +66,10 @@ public static def makeVal[T](dist: Dist): Array[T](dist) = BaseArray.makeVal1[T](dist) as Array[T](dist); - public static def makeVal[T](region: Region, init: (Point)=>T): Array[T](region) + public static def makeVal[T](region: Region, init: (Point(region.rank))=>T): Array[T](region) = BaseArray.makeVal1[T](region, init) as Array[T](region); - public static def makeVal[T](dist: Dist, init: (Point)=>T): Array[T](dist) + public static def makeVal[T](dist: Dist, init: (Point(dist.rank))=>T): Array[T](dist) = BaseArray.makeVal1[T](dist, init) as Array[T](dist); public static def make[T](rail: Rail[T]): Array[T]{rank==1&&rect&&zeroBased} @@ -77,7 +77,7 @@ public static def make[T](rail: ValRail[T]): Array[T]{rank==1&&rect&&zeroBased} = BaseArray.makeVar1[T](rail); - public static def make[T](size: nat, init: (Point)=>T): Array[T](1) + public static def make[T](size: nat, init: (Point(1))=>T): Array[T](1) = makeVar[T](0..size-1, init) as Array[T](1); public static def makeFast[T](region: Region) @@ -88,11 +88,11 @@ = makeVar[T](dist) as FastArray[T]{dist==dist}; - public static def makeFast[T](region: Region, init: (Point)=>T) + public static def makeFast[T](region: Region, init: (Point(region.rank))=>T) = BaseArray.makeVar1[T](region, init) as FastArray[T]{region==region}; - public static def makeFast[T](dist: Dist, init: (Point)=>T) + public static def makeFast[T](dist: Dist, init: (Point(dist.rank))=>T) = BaseArray.makeVar1[T](dist, init) as FastArray[T]{dist==dist}; @@ -116,16 +116,16 @@ public abstract safe global def restriction(r: Region(rank)): Array[T](rank); public abstract safe global def restriction(p: Place): Array[T](rank); - public abstract safe global operator + this: Array[T]; - public abstract safe global operator - this: Array[T]; + public abstract safe global operator + this: Array[T](rank); + public abstract safe global operator - this: Array[T](rank); - public abstract safe global operator this + (that: Array[T]): Array[T]; - public abstract safe global operator this - (that: Array[T]): Array[T]; - public abstract safe global operator this * (that: Array[T]): Array[T]; - public abstract safe global operator this / (that: Array[T]): Array[T]; + public abstract safe global operator this + (that: Array[T](dist)): Array[T](dist); + public abstract safe global operator this - (that: Array[T](dist)): Array[T](dist); + public abstract safe global operator this * (that: Array[T](dist)): Array[T](dist); + public abstract safe global operator this / (that: Array[T](dist)): Array[T](dist); - public abstract safe global operator this | (r: Region(rank)): Array[T]; - public abstract safe global operator this | (p: Place): Array[T]; + public abstract safe global operator this | (r: Region(rank)): Array[T](dist); + public abstract safe global operator this | (p: Place): Array[T](dist); // @@ -153,8 +153,8 @@ // // - public static operator [T](r: Rail[T]): Array[T] = make(r); - public static operator [T](r: ValRail[T]): Array[T] = make(r); + public static operator [T](r: Rail[T]): Array[T](1) = make(r); + public static operator [T](r: ValRail[T]): Array[T](1) = make(r); public global def iterator(): Iterator[Point(rank)] = region.iterator() as Iterator[Point(rank)]; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <vj...@us...> - 2009-11-27 23:36:36
|
Revision: 12201 http://x10.svn.sourceforge.net/x10/?rev=12201&view=rev Author: vj0 Date: 2009-11-27 23:36:26 +0000 (Fri, 27 Nov 2009) Log Message: ----------- Changed Object.location ==> Object.home. Fixed all tests. Modified Paths: -------------- trunk/x10.compiler/src/x10/ast/PlacedClosure_c.java trunk/x10.compiler/src/x10/ast/X10Call_c.java trunk/x10.compiler/src/x10/ast/X10ClassDecl_c.java trunk/x10.compiler/src/x10/ast/X10Field_c.java trunk/x10.compiler/src/x10/ast/X10New_c.java trunk/x10.compiler/src/x10/ast/X10Special_c.java trunk/x10.compiler/src/x10/parser/X10Parser.java trunk/x10.compiler/src/x10/parser/X10Parserprs.java trunk/x10.compiler/src/x10/parser/X10Parsersym.java trunk/x10.compiler/src/x10/parser/x10.g trunk/x10.compiler/src/x10/types/X10ClassDef_c.java trunk/x10.compiler/src/x10/types/X10Context_c.java trunk/x10.compiler/src/x10/types/X10TypeSystem.java trunk/x10.compiler/src/x10/types/X10TypeSystem_c.java trunk/x10.compiler/src/x10/types/XTypeTranslator.java trunk/x10.compiler/src/x10/util/Any.java trunk/x10.compiler/src/x10/util/Struct.java trunk/x10.compiler/src/x10/visit/Desugarer.java trunk/x10.compiler/src/x10/visit/X10PrettyPrinterVisitor.java trunk/x10.constraints/src/x10/constraint/XConstraint_c.java trunk/x10.constraints/src/x10/constraint/XPromise_c.java trunk/x10.runtime/src-java/x10/core/Ref.java trunk/x10.runtime/src-java/x10/runtime/impl/java/PlaceLocalHandle.java trunk/x10.runtime/src-java/x10/runtime/impl/java/Runtime.java trunk/x10.runtime/src-java/x10/runtime/impl/java/Thread.java trunk/x10.runtime/src-x10/x10/array/FastArray.x10 trunk/x10.runtime/src-x10/x10/lang/Object.x10 trunk/x10.runtime/src-x10/x10/lang/System.x10 trunk/x10.runtime/src-x10/x10/runtime/Future_c.x10 trunk/x10.runtime/src-x10/x10/runtime/Runtime.x10 trunk/x10.runtime/src-x10/x10/runtime/RuntimeClock.x10 trunk/x10.runtime/src-x10/x10/runtime/Thread.x10 trunk/x10.tests/examples/Benchmarks/DistRandomAccess1.x10 trunk/x10.tests/examples/Constructs/Array/FlattenPlaceCast.x10 trunk/x10.tests/examples/Constructs/Array/UserDefinedArray.x10 trunk/x10.tests/examples/Constructs/Async/AsyncNext.x10 trunk/x10.tests/examples/Constructs/Async/AsyncTest5.x10 trunk/x10.tests/examples/Constructs/At/AtNext.x10 trunk/x10.tests/examples/Constructs/AtEach/AtEach.x10 trunk/x10.tests/examples/Constructs/AtEach/AtEach2.x10 trunk/x10.tests/examples/Constructs/AtEach/AtEachLoopOnArray.x10 trunk/x10.tests/examples/Constructs/Atomic/Atomic1.x10 trunk/x10.tests/examples/Constructs/Atomic/Atomic2.x10 trunk/x10.tests/examples/Constructs/Atomic/AtomicMethodTest.x10 trunk/x10.tests/examples/Constructs/Atomic/AtomicTest.x10 trunk/x10.tests/examples/Constructs/Atomic/AwaitTest.x10 trunk/x10.tests/examples/Constructs/Atomic/ConditionalAtomicQueue.x10 trunk/x10.tests/examples/Constructs/Atomic/ConditionalAtomicTest.x10 trunk/x10.tests/examples/Constructs/GC/RemoteRef.x10 trunk/x10.tests/examples/Constructs/Place/AtThisIntoAtHere.x10 trunk/x10.tests/examples/Constructs/Place/AtThisIntoAtHere_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Place/B_AtThisIntoAtHere.x10 trunk/x10.tests/examples/Constructs/Place/B_AtThisIntoAtHere_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Place/FieldReceiverIsExpr.x10 trunk/x10.tests/examples/Constructs/Types/PrimitiveHasLocation_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Types/PrimitiveLiteralHasLocation_MustFailCompile.x10 trunk/x10.tests/examples/Issues/XTENLANG_131.x10 trunk/x10.tests/examples/Issues/XTENLANG_257.x10 Modified: trunk/x10.compiler/src/x10/ast/PlacedClosure_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/PlacedClosure_c.java 2009-11-27 16:51:51 UTC (rev 12200) +++ trunk/x10.compiler/src/x10/ast/PlacedClosure_c.java 2009-11-27 23:36:26 UTC (rev 12201) @@ -128,7 +128,7 @@ } try { d= d.substitute(src, d.self()); - pt = XConstrainedTerm.make(ts.locVar(src,xc), d); + pt = XConstrainedTerm.make(ts.homeVar(src,xc), d); } catch (XFailure z) { assert false; throw new InternalCompilerError("Cannot construct placeTerm from " + Modified: trunk/x10.compiler/src/x10/ast/X10Call_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10Call_c.java 2009-11-27 16:51:51 UTC (rev 12200) +++ trunk/x10.compiler/src/x10/ast/X10Call_c.java 2009-11-27 23:36:26 UTC (rev 12201) @@ -76,8 +76,7 @@ import x10.visit.TryTypeChecker; /** - * A method call wrapper to rewrite getLocation() calls on primitives - * and array operator calls. And perform other dep type processing on some selected method calls. + * Representation of an X10 method call. * @author Igor */ public class X10Call_c extends Call_c implements X10Call, X10ProcedureCall { Modified: trunk/x10.compiler/src/x10/ast/X10ClassDecl_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10ClassDecl_c.java 2009-11-27 16:51:51 UTC (rev 12200) +++ trunk/x10.compiler/src/x10/ast/X10ClassDecl_c.java 2009-11-27 23:36:26 UTC (rev 12201) @@ -357,7 +357,7 @@ } } - // Now add this.location == currentLocation + // Now add this.home == currentHome /* XConstrainedTerm placeTerm = xc.currentPlaceTerm().copy(); XRoot thisVar = type.thisVar(); XTerm placeVar = ((X10TypeSystem) type.typeSystem()).locVar(type.thisVar(), xc); Modified: trunk/x10.compiler/src/x10/ast/X10Field_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10Field_c.java 2009-11-27 16:51:51 UTC (rev 12200) +++ trunk/x10.compiler/src/x10/ast/X10Field_c.java 2009-11-27 23:36:26 UTC (rev 12201) @@ -57,10 +57,7 @@ /** - * An immutable representation of an X10 Field access. It is the same as a Java - * field access except for accesses of the field "location" for value types. - * In this implementation such field accesses are implemented by the method call - * x10.lang.Runtime.here(). + * An immutable representation of an X10 Field access. * * @author vj May 23, 2005 */ Modified: trunk/x10.compiler/src/x10/ast/X10New_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10New_c.java 2009-11-27 16:51:51 UTC (rev 12200) +++ trunk/x10.compiler/src/x10/ast/X10New_c.java 2009-11-27 23:36:26 UTC (rev 12201) @@ -543,7 +543,7 @@ * variables whose types are determined by the static type of the receiver * and the actual arguments to the call. * - * Also add the self.location==here clause. + * Also add the self.home==here clause. * * @param tc * @return @@ -555,12 +555,12 @@ Type type = xci.returnType(); X10TypeSystem ts = (X10TypeSystem) tc.typeSystem(); - // Add self.location == here to the return type. + // Add self.home == here to the return type. if (! ts.isStructType(type)) { XTerm selfVar = X10TypeMixin.selfVar(type); X10TypeSystem xts = (X10TypeSystem) tc.typeSystem(); X10Context xc = (X10Context) tc.context(); - XTerm locVar = xts.locVar(selfVar, xc); + XTerm locVar = xts.homeVar(selfVar, xc); type = X10TypeMixin.addBinding(type, locVar, xc.currentPlaceTerm()); // Add self != null Modified: trunk/x10.compiler/src/x10/ast/X10Special_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10Special_c.java 2009-11-27 16:51:51 UTC (rev 12200) +++ trunk/x10.compiler/src/x10/ast/X10Special_c.java 2009-11-27 23:36:26 UTC (rev 12201) @@ -147,7 +147,7 @@ XVar var = (XVar) xts.xtypeTranslator().trans(cc, this, c); cc.addSelfBinding(var); cc.setThisVar(var); - XTerm locVar = xts.locVar(var, c); + XTerm locVar = xts.homeVar(var, c); XConstrainedTerm thisPlace = c.currentThisPlace(); assert locVar != null; assert thisPlace != null; Modified: trunk/x10.compiler/src/x10/parser/X10Parser.java =================================================================== --- trunk/x10.compiler/src/x10/parser/X10Parser.java 2009-11-27 16:51:51 UTC (rev 12200) +++ trunk/x10.compiler/src/x10/parser/X10Parser.java 2009-11-27 23:36:26 UTC (rev 12201) @@ -1,5 +1,5 @@ -//#line 18 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" +//#line 18 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" // // Licensed Material // (C) Copyright IBM Corp, 2006 @@ -9,7 +9,7 @@ import lpg.runtime.*; -//#line 28 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" +//#line 28 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" import java.util.Arrays; import java.util.ArrayList; import java.util.Collections; @@ -287,7 +287,7 @@ // - //#line 322 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 322 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" private ErrorQueue eq; private X10TypeSystem ts; private X10NodeFactory nf; @@ -862,10 +862,10 @@ // Rule 1: TypeName ::= TypeName . ErrorId // case 1: { - //#line 8 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 6 "C:/eclipsews/v9/x10.compiler/src/x10/parser/MissingId.gi" + //#line 8 "C:/eclipsews/head/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 6 "C:/eclipsews/head/x10.compiler/src/x10/parser/MissingId.gi" ParsedName TypeName = (ParsedName) getRhsSym(1); - //#line 8 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 8 "C:/eclipsews/head/lpg.generator/templates/java/btParserTemplateF.gi" setResult(new ParsedName(nf, ts, pos(getLeftSpan(), getRightSpan()), @@ -878,10 +878,10 @@ // Rule 2: PackageName ::= PackageName . ErrorId // case 2: { - //#line 18 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 16 "C:/eclipsews/v9/x10.compiler/src/x10/parser/MissingId.gi" + //#line 18 "C:/eclipsews/head/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 16 "C:/eclipsews/head/x10.compiler/src/x10/parser/MissingId.gi" ParsedName PackageName = (ParsedName) getRhsSym(1); - //#line 18 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 18 "C:/eclipsews/head/lpg.generator/templates/java/btParserTemplateF.gi" setResult(new ParsedName(nf, ts, pos(getLeftSpan(), getRightSpan()), @@ -894,10 +894,10 @@ // Rule 3: ExpressionName ::= AmbiguousName . ErrorId // case 3: { - //#line 28 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 26 "C:/eclipsews/v9/x10.compiler/src/x10/parser/MissingId.gi" + //#line 28 "C:/eclipsews/head/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 26 "C:/eclipsews/head/x10.compiler/src/x10/parser/MissingId.gi" ParsedName AmbiguousName = (ParsedName) getRhsSym(1); - //#line 28 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 28 "C:/eclipsews/head/lpg.generator/templates/java/btParserTemplateF.gi" setResult(new ParsedName(nf, ts, pos(getLeftSpan(), getRightSpan()), @@ -910,10 +910,10 @@ // Rule 4: MethodName ::= AmbiguousName . ErrorId // case 4: { - //#line 38 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 36 "C:/eclipsews/v9/x10.compiler/src/x10/parser/MissingId.gi" + //#line 38 "C:/eclipsews/head/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 36 "C:/eclipsews/head/x10.compiler/src/x10/parser/MissingId.gi" ParsedName AmbiguousName = (ParsedName) getRhsSym(1); - //#line 38 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 38 "C:/eclipsews/head/lpg.generator/templates/java/btParserTemplateF.gi" setResult(new ParsedName(nf, ts, pos(getLeftSpan(), getRightSpan()), @@ -926,10 +926,10 @@ // Rule 5: PackageOrTypeName ::= PackageOrTypeName . ErrorId // case 5: { - //#line 48 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 46 "C:/eclipsews/v9/x10.compiler/src/x10/parser/MissingId.gi" + //#line 48 "C:/eclipsews/head/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 46 "C:/eclipsews/head/x10.compiler/src/x10/parser/MissingId.gi" ParsedName PackageOrTypeName = (ParsedName) getRhsSym(1); - //#line 48 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 48 "C:/eclipsews/head/lpg.generator/templates/java/btParserTemplateF.gi" setResult(new ParsedName(nf, ts, pos(getLeftSpan(), getRightSpan()), @@ -942,10 +942,10 @@ // Rule 6: AmbiguousName ::= AmbiguousName . ErrorId // case 6: { - //#line 58 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 56 "C:/eclipsews/v9/x10.compiler/src/x10/parser/MissingId.gi" + //#line 58 "C:/eclipsews/head/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 56 "C:/eclipsews/head/x10.compiler/src/x10/parser/MissingId.gi" ParsedName AmbiguousName = (ParsedName) getRhsSym(1); - //#line 58 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 58 "C:/eclipsews/head/lpg.generator/templates/java/btParserTemplateF.gi" setResult(new ParsedName(nf, ts, pos(getLeftSpan(), getRightSpan()), @@ -958,10 +958,10 @@ // Rule 7: FieldAccess ::= Primary . ErrorId // case 7: { - //#line 68 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 66 "C:/eclipsews/v9/x10.compiler/src/x10/parser/MissingId.gi" + //#line 68 "C:/eclipsews/head/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 66 "C:/eclipsews/head/x10.compiler/src/x10/parser/MissingId.gi" Expr Primary = (Expr) getRhsSym(1); - //#line 68 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 68 "C:/eclipsews/head/lpg.generator/templates/java/btParserTemplateF.gi" setResult(nf.Field(pos(), Primary, nf.Id(pos(getRightSpan()), "*"))); break; @@ -971,9 +971,9 @@ // Rule 8: FieldAccess ::= super . ErrorId // case 8: { - //#line 74 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 74 "C:/eclipsews/head/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 74 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 74 "C:/eclipsews/head/lpg.generator/templates/java/btParserTemplateF.gi" setResult(nf.Field(pos(getRightSpan()), nf.Super(pos(getLeftSpan())), nf.Id(pos(getRightSpan()), "*"))); break; @@ -983,12 +983,12 @@ // Rule 9: FieldAccess ::= ClassName . super$sup . ErrorId // case 9: { - //#line 80 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 78 "C:/eclipsews/v9/x10.compiler/src/x10/parser/MissingId.gi" + //#line 80 "C:/eclipsews/head/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 78 "C:/eclipsews/head/x10.compiler/src/x10/parser/MissingId.gi" ParsedName ClassName = (ParsedName) getRhsSym(1); - //#line 78 "C:/eclipsews/v9/x10.compiler/src/x10/parser/MissingId.gi" + //#line 78 "C:/eclipsews/head/x10.compiler/src/x10/parser/MissingId.gi" IToken sup = (IToken) getRhsIToken(3); - //#line 80 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 80 "C:/eclipsews/head/lpg.generator/templates/java/btParserTemplateF.gi" setResult(nf.Field(pos(getRightSpan()), nf.Super(pos(getRhsFirstTokenIndex(3)), ClassName.toType()), nf.Id(pos(getRightSpan()), "*"))); break; @@ -998,12 +998,12 @@ // Rule 10: MethodInvocation ::= MethodPrimaryPrefix ( ArgumentListopt ) // case 10: { - //#line 87 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 85 "C:/eclipsews/v9/x10.compiler/src/x10/parser/MissingId.gi" + //#line 87 "C:/eclipsews/head/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 85 "C:/eclipsews/head/x10.compiler/src/x10/parser/MissingId.gi" Object MethodPrimaryPrefix = (Object) getRhsSym(1); - //#line 85 "C:/eclipsews/v9/x10.compiler/src/x10/parser/MissingId.gi" + //#line 85 "C:/eclipsews/head/x10.compiler/src/x10/parser/MissingId.gi" List ArgumentListopt = (List) getRhsSym(3); - //#line 87 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 87 "C:/eclipsews/head/lpg.generator/templates/java/btParserTemplateF.gi" Expr Primary = (Expr) ((Object[]) MethodPrimaryPrefix)[0]; polyglot.lex.Identifier identifier = (polyglot.lex.Identifier) ((Object[]) MethodPrimaryPrefix)[1]; setResult(nf.Call(pos(), Primary, nf.Id(pos(), identifier.getIdentifier()), ArgumentListopt)); @@ -1014,12 +1014,12 @@ // Rule 11: MethodInvocation ::= MethodSuperPrefix ( ArgumentListopt ) // case 11: { - //#line 94 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 92 "C:/eclipsews/v9/x10.compiler/src/x10/parser/MissingId.gi" + //#line 94 "C:/eclipsews/head/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 92 "C:/eclipsews/head/x10.compiler/src/x10/parser/MissingId.gi" polyglot.lex.Identifier MethodSuperPrefix = (polyglot.lex.Identifier) getRhsSym(1); - //#line 92 "C:/eclipsews/v9/x10.compiler/src/x10/parser/MissingId.gi" + //#line 92 "C:/eclipsews/head/x10.compiler/src/x10/parser/MissingId.gi" List ArgumentListopt = (List) getRhsSym(3); - //#line 94 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 94 "C:/eclipsews/head/lpg.generator/templates/java/btParserTemplateF.gi" polyglot.lex.Identifier identifier = MethodSuperPrefix; setResult(nf.Call(pos(), nf.Super(pos(getLeftSpan())), nf.Id(pos(), identifier.getIdentifier()), ArgumentListopt)); break; @@ -1029,12 +1029,12 @@ // Rule 12: MethodInvocation ::= MethodClassNameSuperPrefix ( ArgumentListopt ) // case 12: { - //#line 100 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 98 "C:/eclipsews/v9/x10.compiler/src/x10/parser/MissingId.gi" + //#line 100 "C:/eclipsews/head/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 98 "C:/eclipsews/head/x10.compiler/src/x10/parser/MissingId.gi" Object MethodClassNameSuperPrefix = (Object) getRhsSym(1); - //#line 98 "C:/eclipsews/v9/x10.compiler/src/x10/parser/MissingId.gi" + //#line 98 "C:/eclipsews/head/x10.compiler/src/x10/parser/MissingId.gi" List ArgumentListopt = (List) getRhsSym(3); - //#line 100 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 100 "C:/eclipsews/head/lpg.generator/templates/java/btParserTemplateF.gi" ParsedName ClassName = (ParsedName) ((Object[]) MethodClassNameSuperPrefix)[0]; JPGPosition super_pos = (JPGPosition) ((Object[]) MethodClassNameSuperPrefix)[1]; polyglot.lex.Identifier identifier = (polyglot.lex.Identifier) ((Object[]) MethodClassNameSuperPrefix)[2]; @@ -1046,12 +1046,12 @@ // Rule 13: MethodPrimaryPrefix ::= Primary . ErrorId$ErrorId // case 13: { - //#line 109 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 107 "C:/eclipsews/v9/x10.compiler/src/x10/parser/MissingId.gi" + //#line 109 "C:/eclipsews/head/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 107 "C:/eclipsews/head/x10.compiler/src/x10/parser/MissingId.gi" Expr Primary = (Expr) getRhsSym(1); - //#line 107 "C:/eclipsews/v9/x10.compiler/src/x10/parser/MissingId.gi" + //#line 107 "C:/eclipsews/head/x10.compiler/src/x10/parser/MissingId.gi" IToken ErrorId = (IToken) getRhsIToken(3); - //#line 109 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 109 "C:/eclipsews/head/lpg.generator/templates/java/btParserTemplateF.gi" Object[] a = new Object[2]; a[0] = Primary; a[1] = id(getRhsFirstTokenIndex(3)); @@ -1063,10 +1063,10 @@ // Rule 14: MethodSuperPrefix ::= super . ErrorId$ErrorId // case 14: { - //#line 117 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 115 "C:/eclipsews/v9/x10.compiler/src/x10/parser/MissingId.gi" + //#line 117 "C:/eclipsews/head/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 115 "C:/eclipsews/head/x10.compiler/src/x10/parser/MissingId.gi" IToken ErrorId = (IToken) getRhsIToken(3); - //#line 117 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 117 "C:/eclipsews/head/lpg.generator/templates/java/btParserTemplateF.gi" setResult(id(getRhsFirstTokenIndex(3))); break; } @@ -1075,14 +1075,14 @@ // Rule 15: MethodClassNameSuperPrefix ::= ClassName . super$sup . ErrorId$ErrorId // case 15: { - //#line 122 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 120 "C:/eclipsews/v9/x10.compiler/src/x10/parser/MissingId.gi" + //#line 122 "C:/eclipsews/head/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 120 "C:/eclipsews/head/x10.compiler/src/x10/parser/MissingId.gi" ParsedName ClassName = (ParsedName) getRhsSym(1); - //#line 120 "C:/eclipsews/v9/x10.compiler/src/x10/parser/MissingId.gi" + //#line 120 "C:/eclipsews/head/x10.compiler/src/x10/parser/MissingId.gi" IToken sup = (IToken) getRhsIToken(3); - //#line 120 "C:/eclipsews/v9/x10.compiler/src/x10/parser/MissingId.gi" + //#line 120 "C:/eclipsews/head/x10.compiler/src/x10/parser/MissingId.gi" IToken ErrorId = (IToken) getRhsIToken(5); - //#line 122 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 122 "C:/eclipsews/head/lpg.generator/templates/java/btParserTemplateF.gi" Object[] a = new Object[3]; a[0] = ClassName; a[1] = pos(getRhsFirstTokenIndex(3)); @@ -1095,20 +1095,20 @@ // Rule 16: TypeDefDeclaration ::= TypeDefModifiersopt type Identifier TypeParametersopt FormalParametersopt WhereClauseopt = Type ; // case 16: { - //#line 892 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 890 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 892 "C:/eclipsews/head/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 890 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" List TypeDefModifiersopt = (List) getRhsSym(1); - //#line 890 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 890 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" Id Identifier = (Id) getRhsSym(3); - //#line 890 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 890 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" List TypeParametersopt = (List) getRhsSym(4); - //#line 890 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 890 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" List FormalParametersopt = (List) getRhsSym(5); - //#line 890 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 890 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" DepParameterExpr WhereClauseopt = (DepParameterExpr) getRhsSym(6); - //#line 890 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 890 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" TypeNode Type = (TypeNode) getRhsSym(8); - //#line 892 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 892 "C:/eclipsews/head/lpg.generator/templates/java/btParserTemplateF.gi" FlagsNode f = extractFlags(TypeDefModifiersopt); List annotations = extractAnnotations(TypeDefModifiersopt); for (Formal v : (List<Formal>) FormalParametersopt) { @@ -1124,18 +1124,18 @@ // Rule 17: TypeDefDeclaration ::= TypeDefModifiersopt type Identifier TypeParametersopt FormalParametersopt WhereClauseopt ; // case 17: { - //#line 904 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 902 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 904 "C:/eclipsews/head/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 902 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" List TypeDefModifiersopt = (List) getRhsSym(1); - //#line 902 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 902 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" Id Identifier = (Id) getRhsSym(3); - //#line 902 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 902 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" List TypeParametersopt = (List) getRhsSym(4); - //#line 902 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 902 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" List FormalParametersopt = (List) getRhsSym(5); - //#line 902 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 902 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" DepParameterExpr WhereClauseopt = (DepParameterExpr) getRhsSym(6); - //#line 904 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 904 "C:/eclipsews/head/lpg.generator/templates/java/btParserTemplateF.gi" FlagsNode f = extractFlags(TypeDefModifiersopt); List annotations = extractAnnotations(TypeDefModifiersopt); for (Formal v : (List<Formal>) FormalParametersopt) { @@ -1151,10 +1151,10 @@ // Rule 18: Properties ::= ( PropertyList ) // case 18: { - //#line 917 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 915 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 917 "C:/eclipsews/head/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 915 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" List PropertyList = (List) getRhsSym(2); - //#line 917 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 917 "C:/eclipsews/head/lpg.generator/templates/java/btParserTemplateF.gi" setResult(PropertyList); break; } @@ -1162,10 +1162,10 @@ // Rule 19: PropertyList ::= Property // case 19: { - //#line 922 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 920 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 922 "C:/eclipsews/head/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 920 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" PropertyDecl Property = (PropertyDecl) getRhsSym(1); - //#line 922 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 922 "C:/eclipsews/head/lpg.generator/templates/java/btParserTemplateF.gi" List l = new TypedList(new LinkedList(), PropertyDecl.class, false); l.add(Property); setResult(l); @@ -1176,12 +1176,12 @@ // Rule 20: PropertyList ::= PropertyList , Property // case 20: { - //#line 929 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 927 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 929 "C:/eclipsews/head/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 927 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" List PropertyList = (List) getRhsSym(1); - //#line 927 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 927 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" PropertyDecl Property = (PropertyDecl) getRhsSym(3); - //#line 929 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 929 "C:/eclipsews/head/lpg.generator/templates/java/btParserTemplateF.gi" PropertyList.add(Property); break; } @@ -1190,14 +1190,14 @@ // Rule 21: Property ::= Annotationsopt Identifier ResultType // case 21: { - //#line 936 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 934 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 936 "C:/eclipsews/head/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 934 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" List Annotationsopt = (List) getRhsSym(1); - //#line 934 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 934 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" Id Identifier = (Id) getRhsSym(2); - //#line 934 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 934 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" TypeNode ResultType = (TypeNode) getRhsSym(3); - //#line 936 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 936 "C:/eclipsews/head/lpg.generator/templates/java/btParserTemplateF.gi" List annotations = extractAnnotations(Annotationsopt); PropertyDecl cd = nf.PropertyDecl(pos(), nf.FlagsNode(pos(), Flags.PUBLIC.Final()), ResultType, Identifier); cd = (PropertyDecl) ((X10Ext) cd.ext()).annotations(annotations); @@ -1209,24 +1209,24 @@ // Rule 22: MethodDeclaration ::= MethodModifiersopt def Identifier TypeParametersopt FormalParameters WhereClauseopt ResultTypeopt Throwsopt MethodBody // case 22: { - //#line 945 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 943 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 945 "C:/eclipsews/head/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 943 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" List MethodModifiersopt = (List) getRhsSym(1); - //#line 943 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 943 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" Id Identifier = (Id) getRhsSym(3); - //#line 943 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 943 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" List TypeParametersopt = (List) getRhsSym(4); - //#line 943 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 943 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" List FormalParameters = (List) getRhsSym(5); - //#line 943 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 943 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" DepParameterExpr WhereClauseopt = (DepParameterExpr) getRhsSym(6); - //#line 943 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 943 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" TypeNode ResultTypeopt = (TypeNode) getRhsSym(7); - //#line 943 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 943 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" List Throwsopt = (List) getRhsSym(8); - //#line 943 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 943 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" Block MethodBody = (Block) getRhsSym(9); - //#line 945 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 945 "C:/eclipsews/head/lpg.generator/templates/java/btParserTemplateF.gi" if (Identifier.id().toString().equals("this")) { ConstructorDecl cd = nf.X10ConstructorDecl(pos(), extractFlags(MethodModifiersopt), @@ -1260,26 +1260,26 @@ // Rule 23: MethodDeclaration ::= MethodModifiersopt operator TypeParametersopt ( FormalParameter$fp1 ) BinOp ( FormalParameter$fp2 ) WhereClauseopt ResultTypeopt Throwsopt MethodBody // case 23: { - //#line 975 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 973 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 975 "C:/eclipsews/head/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 973 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" List MethodModifiersopt = (List) getRhsSym(1); - //#line 973 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 973 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" List TypeParametersopt = (List) getRhsSym(3); - //#line 973 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 973 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" X10Formal fp1 = (X10Formal) getRhsSym(5); - //#line 973 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 973 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" Binary.Operator BinOp = (Binary.Operator) getRhsSym(7); - //#line 973 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 973 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" X10Formal fp2 = (X10Formal) getRhsSym(9); - //#line 973 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 973 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" DepParameterExpr WhereClauseopt = (DepParameterExpr) getRhsSym(11); - //#line 973 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 973 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" TypeNode ResultTypeopt = (TypeNode) getRhsSym(12); - //#line 973 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 973 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" List Throwsopt = (List) getRhsSym(13); - //#line 973 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 973 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" Block MethodBody = (Block) getRhsSym(14); - //#line 975 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 975 "C:/eclipsews/head/lpg.generator/templates/java/btParserTemplateF.gi" MethodDecl md = nf.X10MethodDecl(pos(getRhsFirstTokenIndex(1), getRhsLastTokenIndex(14)), extractFlags(MethodModifiersopt), ResultTypeopt == null ? nf.UnknownTypeNode(pos()) : ResultTypeopt, @@ -1300,24 +1300,24 @@ // Rule 24: MethodDeclaration ::= MethodModifiersopt operator TypeParametersopt PrefixOp ( FormalParameter$fp2 ) WhereClauseopt ResultTypeopt Throwsopt MethodBody // case 24: { - //#line 992 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 990 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 992 "C:/eclipsews/head/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 990 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" List MethodModifiersopt = (List) getRhsSym(1); - //#line 990 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 990 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" List TypeParametersopt = (List) getRhsSym(3); - //#line 990 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 990 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" Unary.Operator PrefixOp = (Unary.Operator) getRhsSym(4); - //#line 990 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 990 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" X10Formal fp2 = (X10Formal) getRhsSym(6); - //#line 990 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 990 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" DepParameterExpr WhereClauseopt = (DepParameterExpr) getRhsSym(8); - //#line 990 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 990 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" TypeNode ResultTypeopt = (TypeNode) getRhsSym(9); - //#line 990 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 990 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" List Throwsopt = (List) getRhsSym(10); - //#line 990 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 990 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" Block MethodBody = (Block) getRhsSym(11); - //#line 992 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 992 "C:/eclipsews/head/lpg.generator/templates/java/btParserTemplateF.gi" MethodDecl md = nf.X10MethodDecl(pos(getRhsFirstTokenIndex(1), getRhsLastTokenIndex(11)), extractFlags(MethodModifiersopt), ResultTypeopt == null ? nf.UnknownTypeNode(pos()) : ResultTypeopt, @@ -1338,24 +1338,24 @@ // Rule 25: MethodDeclaration ::= MethodModifiersopt operator TypeParametersopt this BinOp ( FormalParameter$fp2 ) WhereClauseopt ResultTypeopt Throwsopt MethodBody // case 25: { - //#line 1009 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1007 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1009 "C:/eclipsews/head/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1007 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" List MethodModifiersopt = (List) getRhsSym(1); - //#line 1007 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1007 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" List TypeParametersopt = (List) getRhsSym(3); - //#line 1007 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1007 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" Binary.Operator BinOp = (Binary.Operator) getRhsSym(5); - //#line 1007 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1007 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" X10Formal fp2 = (X10Formal) getRhsSym(7); - //#line 1007 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1007 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" DepParameterExpr WhereClauseopt = (DepParameterExpr) getRhsSym(9); - //#line 1007 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1007 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" TypeNode ResultTypeopt = (TypeNode) getRhsSym(10); - //#line 1007 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1007 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" List Throwsopt = (List) getRhsSym(11); - //#line 1007 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1007 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" Block MethodBody = (Block) getRhsSym(12); - //#line 1009 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1009 "C:/eclipsews/head/lpg.generator/templates/java/btParserTemplateF.gi" MethodDecl md = nf.X10MethodDecl(pos(getRhsFirstTokenIndex(1), getRhsLastTokenIndex(12)), extractFlags(MethodModifiersopt), ResultTypeopt == null ? nf.UnknownTypeNode(pos()) : ResultTypeopt, @@ -1377,24 +1377,24 @@ // Rule 26: MethodDeclaration ::= MethodModifiersopt operator TypeParametersopt ( FormalParameter$fp1 ) BinOp this WhereClauseopt ResultTypeopt Throwsopt MethodBody // case 26: { - //#line 1027 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1025 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1027 "C:/eclipsews/head/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1025 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" List MethodModifiersopt = (List) getRhsSym(1); - //#line 1025 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1025 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" List TypeParametersopt = (List) getRhsSym(3); - //#line 1025 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1025 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" X10Formal fp1 = (X10Formal) getRhsSym(5); - //#line 1025 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1025 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" Binary.Operator BinOp = (Binary.Operator) getRhsSym(7); - //#line 1025 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1025 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" DepParameterExpr WhereClauseopt = (DepParameterExpr) getRhsSym(9); - //#line 1025 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1025 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" TypeNode ResultTypeopt = (TypeNode) getRhsSym(10); - //#line 1025 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1025 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" List Throwsopt = (List) getRhsSym(11); - //#line 1025 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1025 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" Block MethodBody = (Block) getRhsSym(12); - //#line 1027 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1027 "C:/eclipsews/head/lpg.generator/templates/java/btParserTemplateF.gi" Name op = X10Binary_c.invBinaryMethodName(BinOp); MethodDecl md = nf.X10MethodDecl(pos(getRhsFirstTokenIndex(1), getRhsLastTokenIndex(12)), extractFlags(MethodModifiersopt), @@ -1417,22 +1417,22 @@ // Rule 27: MethodDeclaration ::= MethodModifiersopt operator TypeParametersopt PrefixOp this WhereClauseopt ResultTypeopt Throwsopt MethodBody // case 27: { - //#line 1046 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1044 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1046 "C:/eclipsews/head/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1044 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" List MethodModifiersopt = (List) getRhsSym(1); - //#line 1044 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1044 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" List TypeParametersopt = (List) getRhsSym(3); - //#line 1044 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1044 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" Unary.Operator PrefixOp = (Unary.Operator) getRhsSym(4); - //#line 1044 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1044 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" DepParameterExpr WhereClauseopt = (DepParameterExpr) getRhsSym(6); - //#line 1044 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1044 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" TypeNode ResultTypeopt = (TypeNode) getRhsSym(7); - //#line 1044 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1044 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" List Throwsopt = (List) getRhsSym(8); - //#line 1044 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1044 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" Block MethodBody = (Block) getRhsSym(9); - //#line 1046 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1046 "C:/eclipsews/head/lpg.generator/templates/java/btParserTemplateF.gi" MethodDecl md = nf.X10MethodDecl(pos(getRhsFirstTokenIndex(1), getRhsLastTokenIndex(9)), extractFlags(MethodModifiersopt), ResultTypeopt == null ? nf.UnknownTypeNode(pos()) : ResultTypeopt, @@ -1453,22 +1453,22 @@ // Rule 28: MethodDeclaration ::= MethodModifiersopt operator this TypeParametersopt FormalParameters WhereClauseopt ResultTypeopt Throwsopt MethodBody // case 28: { - //#line 1063 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1061 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1063 "C:/eclipsews/head/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1061 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" List MethodModifiersopt = (List) getRhsSym(1); - //#line 1061 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1061 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" List TypeParametersopt = (List) getRhsSym(4); - //#line 1061 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1061 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" List FormalParameters = (List) getRhsSym(5); - //#line 1061 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1061 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" DepParameterExpr WhereClauseopt = (DepParameterExpr) getRhsSym(6); - //#line 1061 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1061 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" TypeNode ResultTypeopt = (TypeNode) getRhsSym(7); - //#line 1061 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1061 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" List Throwsopt = (List) getRhsSym(8); - //#line 1061 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1061 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" Block MethodBody = (Block) getRhsSym(9); - //#line 1063 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1063 "C:/eclipsews/head/lpg.generator/templates/java/btParserTemplateF.gi" MethodDecl md = nf.X10MethodDecl(pos(getRhsFirstTokenIndex(1), getRhsLastTokenIndex(9)), extractFlags(MethodModifiersopt), ResultTypeopt == null ? nf.UnknownTypeNode(pos()) : ResultTypeopt, @@ -1489,24 +1489,24 @@ // Rule 29: MethodDeclaration ::= MethodModifiersopt operator this TypeParametersopt FormalParameters = ( FormalParameter$fp2 ) WhereClauseopt ResultTypeopt Throwsopt MethodBody // case 29: { - //#line 1080 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1078 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1080 "C:/eclipsews/head/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1078 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" List MethodModifiersopt = (List) getRhsSym(1); - //#line 1078 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1078 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" List TypeParametersopt = (List) getRhsSym(4); - //#line 1078 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1078 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" List FormalParameters = (List) getRhsSym(5); - //#line 1078 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1078 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" X10Formal fp2 = (X10Formal) getRhsSym(8); - //#line 1078 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1078 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" DepParameterExpr WhereClauseopt = (DepParameterExpr) getRhsSym(10); - //#line 1078 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1078 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" TypeNode ResultTypeopt = (TypeNode) getRhsSym(11); - //#line 1078 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1078 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" List Throwsopt = (List) getRhsSym(12); - //#line 1078 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1078 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" Block MethodBody = (Block) getRhsSym(13); - //#line 1080 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1080 "C:/eclipsews/head/lpg.generator/templates/java/btParserTemplateF.gi" MethodDecl md = nf.X10MethodDecl(pos(getRhsFirstTokenIndex(1), getRhsLastTokenIndex(13)), extractFlags(MethodModifiersopt), ResultTypeopt == null ? nf.UnknownTypeNode(pos()) : ResultTypeopt, @@ -1527,22 +1527,22 @@ // Rule 30: MethodDeclaration ::= MethodModifiersopt operator TypeParametersopt ( FormalParameter$fp1 ) as Type WhereClauseopt Throwsopt MethodBody // case 30: { - //#line 1097 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1095 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1097 "C:/eclipsews/head/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1095 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" List MethodModifiersopt = (List) getRhsSym(1); - //#line 1095 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1095 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" List TypeParametersopt = (List) getRhsSym(3); - //#line 1095 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1095 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" X10Formal fp1 = (X10Formal) getRhsSym(5); - //#line 1095 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1095 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" TypeNode Type = (TypeNode) getRhsSym(8); - //#line 1095 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1095 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" DepParameterExpr WhereClauseopt = (DepParameterExpr) getRhsSym(9); - //#line 1095 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1095 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" List Throwsopt = (List) getRhsSym(10); - //#line 1095 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1095 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" Block MethodBody = (Block) getRhsSym(11); - //#line 1097 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1097 "C:/eclipsews/head/lpg.generator/templates/java/btParserTemplateF.gi" MethodDecl md = nf.X10MethodDecl(pos(getRhsFirstTokenIndex(1), getRhsLastTokenIndex(11)), extractFlags(MethodModifiersopt), Type, @@ -1563,22 +1563,22 @@ // Rule 31: MethodDeclaration ::= MethodModifiersopt operator TypeParametersopt ( FormalParameter$fp1 ) as ? WhereClauseopt ResultTypeopt Throwsopt MethodBody // case 31: { - //#line 1114 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1112 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1114 "C:/eclipsews/head/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1112 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" List MethodModifiersopt = (List) getRhsSym(1); - //#line 1112 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1112 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" List TypeParametersopt = (List) getRhsSym(3); - //#line 1112 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1112 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" X10Formal fp1 = (X10Formal) getRhsSym(5); - //#line 1112 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1112 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" DepParameterExpr WhereClauseopt = (DepParameterExpr) getRhsSym(9); - //#line 1112 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1112 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" TypeNode ResultTypeopt = (TypeNode) getRhsSym(10); - //#line 1112 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1112 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" List Throwsopt = (List) getRhsSym(11); - //#line 1112 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1112 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" Block MethodBody = (Block) getRhsSym(12); - //#line 1114 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1114 "C:/eclipsews/head/lpg.generator/templates/java/btParserTemplateF.gi" MethodDecl md = nf.X10MethodDecl(pos(getRhsFirstTokenIndex(1), getRhsLastTokenIndex(12)), extractFlags(MethodModifiersopt), ResultTypeopt == null ? nf.UnknownTypeNode(pos()) : ResultTypeopt, @@ -1599,22 +1599,22 @@ // Rule 32: MethodDeclaration ::= MethodModifiersopt operator TypeParametersopt ( FormalParameter$fp1 ) WhereClauseopt ResultTypeopt Throwsopt MethodBody // case 32: { - //#line 1131 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1129 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1131 "C:/eclipsews/head/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1129 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" List MethodModifiersopt = (List) getRhsSym(1); - //#line 1129 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" + //#line 1129 "C:/eclipsews/head/x10.compiler/src/x10/parser/x10.g" List TypeParametersopt = (List) getRhsSym(3); - //#line 1129 "C:/eclipsews/v9/x10.compiler/src/x... [truncated message content] |
From: <vj...@us...> - 2009-11-27 23:39:02
|
Revision: 12202 http://x10.svn.sourceforge.net/x10/?rev=12202&view=rev Author: vj0 Date: 2009-11-27 23:38:51 +0000 (Fri, 27 Nov 2009) Log Message: ----------- Fix irritating warnings generated by build.xml. Modified Paths: -------------- trunk/x10.common/build.xml trunk/x10.compiler/build.xml trunk/x10.constraints/build.xml trunk/x10.dist/build.xml trunk/x10.runtime/build.xml trunk/x10.tests/build.xml Modified: trunk/x10.common/build.xml =================================================================== --- trunk/x10.common/build.xml 2009-11-27 23:36:26 UTC (rev 12201) +++ trunk/x10.common/build.xml 2009-11-27 23:38:51 UTC (rev 12202) @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE project [<!ENTITY buildfile SYSTEM "file:./build-user.xml">]> +<!DOCTYPE project [<!ENTITY buildfile SYSTEM "./build-user.xml">]> <project name="x10.common" default="build" basedir="."> &buildfile; <property name="x10.home" value="${basedir}/.."/> Modified: trunk/x10.compiler/build.xml =================================================================== --- trunk/x10.compiler/build.xml 2009-11-27 23:36:26 UTC (rev 12201) +++ trunk/x10.compiler/build.xml 2009-11-27 23:38:51 UTC (rev 12202) @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE project [<!ENTITY buildfile SYSTEM "file:./build-user.xml">]> +<!DOCTYPE project [<!ENTITY buildfile SYSTEM "./build-user.xml">]> <project name="x10.compiler" default="dist" basedir="."> &buildfile; <property name="x10.home" value="${basedir}/.."/> Modified: trunk/x10.constraints/build.xml =================================================================== --- trunk/x10.constraints/build.xml 2009-11-27 23:36:26 UTC (rev 12201) +++ trunk/x10.constraints/build.xml 2009-11-27 23:38:51 UTC (rev 12202) @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE project [<!ENTITY buildfile SYSTEM "file:./build-user.xml">]> +<!DOCTYPE project [<!ENTITY buildfile SYSTEM "./build-user.xml">]> <project name="x10.constraints" default="build" basedir="."> &buildfile; <property name="x10.home" value="${basedir}/.."/> Modified: trunk/x10.dist/build.xml =================================================================== --- trunk/x10.dist/build.xml 2009-11-27 23:36:26 UTC (rev 12201) +++ trunk/x10.dist/build.xml 2009-11-27 23:38:51 UTC (rev 12202) @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE project [<!ENTITY buildfile SYSTEM "file:./build-user.xml">]> +<!DOCTYPE project [<!ENTITY buildfile SYSTEM "./build-user.xml">]> <project name="x10.dist" default="dist" basedir="."> &buildfile; <property name="x10.home" value="${basedir}/.."/> Modified: trunk/x10.runtime/build.xml =================================================================== --- trunk/x10.runtime/build.xml 2009-11-27 23:36:26 UTC (rev 12201) +++ trunk/x10.runtime/build.xml 2009-11-27 23:38:51 UTC (rev 12202) @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE project [<!ENTITY buildfile SYSTEM "file:./build-user.xml">]> +<!DOCTYPE project [<!ENTITY buildfile SYSTEM "./build-user.xml">]> <project name="x10.runtime" default="dist" basedir="."> &buildfile; <property name="x10.home" value="${basedir}/.."/> Modified: trunk/x10.tests/build.xml =================================================================== --- trunk/x10.tests/build.xml 2009-11-27 23:36:26 UTC (rev 12201) +++ trunk/x10.tests/build.xml 2009-11-27 23:38:51 UTC (rev 12202) @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE project [<!ENTITY buildfile SYSTEM "file:./build-user.xml">]> +<!DOCTYPE project [<!ENTITY buildfile SYSTEM "./build-user.xml">]> <project name="x10.tests" default="exec" basedir="."> &buildfile; <property name="bin" location="${basedir}/bin"/> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dgr...@us...> - 2009-11-30 20:52:14
|
Revision: 12213 http://x10.svn.sourceforge.net/x10/?rev=12213&view=rev Author: dgrove-oss Date: 2009-11-30 20:51:41 +0000 (Mon, 30 Nov 2009) Log Message: ----------- fix a couple hunderd Java-warnings, mostly related to raw GenericTypes. Now down to 1175 warnings in x10.compiler/x10.runtime. Modified Paths: -------------- trunk/x10.common/src/x10/config/Configuration.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/Clocked.java trunk/x10.compiler/src/x10/ast/Closure_c.java trunk/x10.compiler/src/x10/ast/SettableAssign_c.java trunk/x10.compiler/src/x10/ast/X10Formal_c.java trunk/x10.compiler/src/x10/ast/X10MethodDecl_c.java trunk/x10.compiler/src/x10/extension/X10ClassBodyExt_c.java trunk/x10.compiler/src/x10/parser/X10Lexer.java trunk/x10.compiler/src/x10/plugin/LoadPlugins.java trunk/x10.compiler/src/x10/types/X10Context_c.java trunk/x10.compiler/src/x10/visit/AnnotationChecker.java trunk/x10.compiler/src/x10/visit/AsyncElimination.java trunk/x10.compiler/src/x10/visit/X10Translator.java trunk/x10.compiler/src/x10cpp/extension/X10ClassBodyExt_c.java trunk/x10.compiler/src/x10cpp/types/X10CPPContext_c.java trunk/x10.compiler/src/x10cpp/visit/ASTQuery.java trunk/x10.compiler/src/x10cpp/visit/Emitter.java trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java trunk/x10.compiler/src/x10cpp/visit/SharedVarsMethods.java trunk/x10.compiler/src/x10cpp/visit/X10CPPTranslator.java trunk/x10.compiler/src/x10cpp/visit/XCDProcessor.java trunk/x10.runtime/src-java/x10/runtime/impl/java/PreLoader.java trunk/x10.runtime/src-java/x10/runtime/impl/java/Report.java trunk/x10.runtime/src-java/x10/runtime/rewrite/Runtime.java trunk/x10.runtime/src-java/x10/runtime/rewrite/X10RuntimeClassloader.java trunk/x10.runtime/src-java/x10/types/Types.java Modified: trunk/x10.common/src/x10/config/Configuration.java =================================================================== --- trunk/x10.common/src/x10/config/Configuration.java 2009-11-30 18:15:32 UTC (rev 12212) +++ trunk/x10.common/src/x10/config/Configuration.java 2009-11-30 20:51:41 UTC (rev 12213) @@ -83,7 +83,7 @@ * @throws OptionError if the argument is invalid * @throws ConfigurationError if there was a problem processing the argument */ - protected static void set(Class cls, String key, String val) + protected static void set(Class<?> cls, String key, String val) throws ConfigurationError, OptionError { assert (key != null); @@ -96,7 +96,7 @@ key = key.substring(0, key.indexOf('[')); } Field f = cls.getField(key); - Class t = f.getType(); + Class<?> t = f.getType(); Object o = null; // TODO: implement arrays as described above // FIXME: do we need support for Object arrays? @@ -178,7 +178,7 @@ * @param cfg the configuration resource name * @throws ConfigurationError if unable to process the resource */ - public static void readConfiguration(Class cls, String cfg) + public static void readConfiguration(Class<?> cls, String cfg) throws ConfigurationError { if (cfg == null) @@ -219,7 +219,7 @@ * @throws OptionError if the argument is invalid * @throws ConfigurationError if there was a problem processing the argument */ - protected static void parseArgument(Class cls, String arg) + protected static void parseArgument(Class<?> cls, String arg) throws OptionError, ConfigurationError { if (arg.length() < 1 || arg.charAt(0) != '-') @@ -239,7 +239,7 @@ /** * Return a human-readable string representation of a given type. */ - private static String typeToString(Class t) { + private static String typeToString(Class<?> t) { if (t.isPrimitive()) return t.toString(); if (t.isArray()) @@ -260,7 +260,7 @@ * @param cls the configuration class * @return array of two-element String arrays */ - protected static String[][] options(Class cls) { + protected static String[][] options(Class<?> cls) { Field[] flds = cls.getFields(); int num = 0; for (int i = 0; i < flds.length; i++) { @@ -278,7 +278,7 @@ // f is guaranteed to be public if (!Modifier.isStatic(m) || Modifier.isFinal(m)) continue; - Class t = f.getType(); + Class<?> t = f.getType(); String type = typeToString(t); String desc = ""; Object v = null; Modified: trunk/x10.compiler/src/x10/ast/Async_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/Async_c.java 2009-11-30 18:15:32 UTC (rev 12212) +++ trunk/x10.compiler/src/x10/ast/Async_c.java 2009-11-30 20:51:41 UTC (rev 12213) @@ -54,9 +54,9 @@ public Expr place; public Stmt body; - protected List clocks; + protected List<Expr> clocks; - public Async_c(Position pos, Expr place, List clocks, Stmt body) { + public Async_c(Position pos, Expr place, List<Expr> clocks, Stmt body) { super(pos); this.place = place; this.clocks = clocks; @@ -75,12 +75,12 @@ } /** Expression */ - public List clocks() { + public List<Expr> clocks() { return this.clocks; } /** clock */ - public Clocked clocks(List clocks) { + public Clocked clocks(List<Expr> clocks) { Async_c n = (Async_c) copy(); n.clocks = clocks; return n; @@ -327,7 +327,7 @@ return succs; } - private static final Collection TOPICS = + private static final Collection<String> TOPICS = CollectionUtil.list(Report.types, Report.context); } Modified: trunk/x10.compiler/src/x10/ast/AtStmt_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/AtStmt_c.java 2009-11-30 18:15:32 UTC (rev 12212) +++ trunk/x10.compiler/src/x10/ast/AtStmt_c.java 2009-11-30 20:51:41 UTC (rev 12213) @@ -242,7 +242,7 @@ return succs; } - private static final Collection TOPICS = + private static final Collection<String> TOPICS = CollectionUtil.list(Report.types, Report.context); } Modified: trunk/x10.compiler/src/x10/ast/Clocked.java =================================================================== --- trunk/x10.compiler/src/x10/ast/Clocked.java 2009-11-30 18:15:32 UTC (rev 12212) +++ trunk/x10.compiler/src/x10/ast/Clocked.java 2009-11-30 20:51:41 UTC (rev 12213) @@ -13,6 +13,7 @@ import java.util.List; import polyglot.ast.CompoundStmt; +import polyglot.ast.Expr; /** * The node constructed for [ateach,foreach,async] clocked (C) [stmt]. @@ -21,7 +22,7 @@ public interface Clocked extends CompoundStmt { /** Get the clock. */ - List clocks(); + List<Expr> clocks(); - Clocked clocks(List clocks); + Clocked clocks(List<Expr> clocks); } Modified: trunk/x10.compiler/src/x10/ast/Closure_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/Closure_c.java 2009-11-30 18:15:32 UTC (rev 12212) +++ trunk/x10.compiler/src/x10/ast/Closure_c.java 2009-11-30 20:51:41 UTC (rev 12213) @@ -75,7 +75,7 @@ ClassType typeContainer; DepParameterExpr guard; - private static final Collection TOPICS = + private static final Collection<String> TOPICS = CollectionUtil.list(Report.types, Report.context); public Closure_c(Position pos) { Modified: trunk/x10.compiler/src/x10/ast/SettableAssign_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/SettableAssign_c.java 2009-11-30 18:15:32 UTC (rev 12212) +++ trunk/x10.compiler/src/x10/ast/SettableAssign_c.java 2009-11-30 20:51:41 UTC (rev 12213) @@ -179,7 +179,7 @@ /** Visit the children of the expression. */ public Assign visitLeft(NodeVisitor v) { Expr array = (Expr) visitChild(this.array, v); - List index = visitList(this.index, v); + List<Expr> index = visitList(this.index, v); return reconstruct(array, index); } @@ -273,8 +273,8 @@ v.visitCFG(right(), this, EXIT); } - public List throwTypes(TypeSystem ts) { - List l = new ArrayList(super.throwTypes(ts)); + public List<Type> throwTypes(TypeSystem ts) { + List<Type> l = new ArrayList<Type>(super.throwTypes(ts)); l.add(ts.NullPointerException()); l.add(ts.OutOfBoundsException()); return l; @@ -305,8 +305,8 @@ w.write ("("); w.begin(0); - for(Iterator i = index.iterator(); i.hasNext();) { - Expr e = (Expr) i.next(); + for(Iterator<Expr> i = index.iterator(); i.hasNext();) { + Expr e = i.next(); print(e, w, tr); if (i.hasNext()) { w.write(","); Modified: trunk/x10.compiler/src/x10/ast/X10Formal_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10Formal_c.java 2009-11-30 18:15:32 UTC (rev 12212) +++ trunk/x10.compiler/src/x10/ast/X10Formal_c.java 2009-11-30 20:51:41 UTC (rev 12213) @@ -313,7 +313,7 @@ NodeFactory nf = tc.nodeFactory(); if (vars == null || vars.isEmpty()) return null; X10NodeFactory x10nf = (X10NodeFactory) nf; - List<Stmt> stmts = new TypedList(new ArrayList(vars.size()), Stmt.class, false); + List<Stmt> stmts = new TypedList<Stmt>(new ArrayList<Stmt>(vars.size()), Stmt.class, false); Local arrayBase =nf.Local(pos, name); if (bli != null) arrayBase = (Local) arrayBase.localInstance(bli.asInstance()).type(bli.asInstance().type()); Modified: trunk/x10.compiler/src/x10/ast/X10MethodDecl_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10MethodDecl_c.java 2009-11-30 18:15:32 UTC (rev 12212) +++ trunk/x10.compiler/src/x10/ast/X10MethodDecl_c.java 2009-11-30 20:51:41 UTC (rev 12213) @@ -956,6 +956,6 @@ return nn; } - private static final Collection TOPICS = + private static final Collection<String> TOPICS = CollectionUtil.list(Report.types, Report.context); } Modified: trunk/x10.compiler/src/x10/extension/X10ClassBodyExt_c.java =================================================================== --- trunk/x10.compiler/src/x10/extension/X10ClassBodyExt_c.java 2009-11-30 18:15:32 UTC (rev 12212) +++ trunk/x10.compiler/src/x10/extension/X10ClassBodyExt_c.java 2009-11-30 20:51:41 UTC (rev 12213) @@ -23,6 +23,7 @@ import polyglot.ast.Call; import polyglot.ast.Call_c; import polyglot.ast.ClassBody_c; +import polyglot.ast.ClassMember; import polyglot.ast.Expr; import polyglot.ast.Formal; import polyglot.ast.Formal_c; @@ -31,6 +32,7 @@ import polyglot.ast.MethodDecl_c; import polyglot.ast.Node; import polyglot.ast.NodeFactory; +import polyglot.ast.Stmt; import polyglot.ast.TypeNode; import polyglot.frontend.ExtensionInfo; import polyglot.types.ClassType; @@ -370,7 +372,7 @@ // FIXME: [IP] This looks like a bug -- in the stub, we do something else if the method is overloaded Name nativeName = generateX10NativeName(nativeMethod); MethodDecl_c newNative = (MethodDecl_c)nativeMethod.name(nativeMethod.name().id(nativeName)); - ArrayList newFormals = new ArrayList(); + ArrayList<Formal> newFormals = new ArrayList<Formal>(); TypeNode longType = nf.CanonicalTypeNode(nativeMethod.position(), typeSystem.Long()); TypeNode arrayOfIntType = nf.CanonicalTypeNode(nativeMethod.position(), @@ -456,7 +458,7 @@ Position pos = nativeMethod.position(); MethodDecl_c nativeWrapper = nativeMethod; - ArrayList newArgs = new ArrayList(); + ArrayList<Expr> newArgs = new ArrayList<Expr>(); // FIXME: [IP] This looks like a bug -- in the stub, we do something else if the method is overloaded Name jniName = generateX10NativeName(nativeMethod); @@ -468,7 +470,7 @@ Name descriptorName = KgetDescriptorMethod; - ArrayList args = new ArrayList(); + ArrayList<Expr> args = new ArrayList<Expr>(); for (ListIterator i = nativeMethod.formals().listIterator(); i.hasNext();) { Formal_c parameter = (Formal_c) i.next(); @@ -572,7 +574,7 @@ // past that point... jniCall = (Call) jniCall.type(nativeMethod.returnType().type()); - ArrayList newStmts = new ArrayList(); + ArrayList<Stmt> newStmts = new ArrayList<Stmt>(); if (nativeMethod.methodDef().returnType().get().isVoid()) newStmts.add(nf.Eval(pos, (Expr)jniCall)); else @@ -816,11 +818,11 @@ boolean seenNativeMethodDecl = false; ClassBody_c cb = (ClassBody_c) node(); - List members = cb.members(); - Map methodHash = null; - ArrayList newListOfMembers = new ArrayList(); - for (ListIterator i = members.listIterator(); i.hasNext();) { - Object o = i.next(); + List<ClassMember> members = cb.members(); + Map<Name,MethodDecl> methodHash = null; + ArrayList<ClassMember> newListOfMembers = new ArrayList<ClassMember>(); + for (ListIterator<ClassMember> i = members.listIterator(); i.hasNext();) { + ClassMember o = i.next(); if (o instanceof MethodDecl) { MethodDecl_c md = (MethodDecl_c) o; MethodDef mi = md.methodDef(); @@ -864,7 +866,7 @@ } private Map<Name,MethodDecl> buildNativeMethodHash(List members) { - Map<Name,MethodDecl> methodHash = new HashMap(); + Map<Name,MethodDecl> methodHash = new HashMap<Name, MethodDecl>(); for (ListIterator j = members.listIterator(); j.hasNext();) { Object theObj = j.next(); if (!(theObj instanceof MethodDecl)) Modified: trunk/x10.compiler/src/x10/parser/X10Lexer.java =================================================================== --- trunk/x10.compiler/src/x10/parser/X10Lexer.java 2009-11-30 18:15:32 UTC (rev 12212) +++ trunk/x10.compiler/src/x10/parser/X10Lexer.java 2009-11-30 20:51:41 UTC (rev 12213) @@ -423,7 +423,7 @@ public X10Lexer(java.io.Reader reader, String filename, int tab) throws java.io.IOException { - ArrayList buffers = new ArrayList(); + ArrayList<char[]> buffers = new ArrayList<char[]>(); int size = 0; while (true) { @@ -432,13 +432,13 @@ if (n < 0) break; size += n; - buffers.add((Object) block); + buffers.add(block); } char buffer[] = new char[size]; for (int i = 0; i < buffers.size(); i++) { - char block[] = (char []) buffers.get(i); + char block[] = buffers.get(i); int blocksize = (size / block.length > 0 ? block.length : size); size -= blocksize; System.arraycopy(block, 0, buffer, i * block.length, blocksize); Modified: trunk/x10.compiler/src/x10/plugin/LoadPlugins.java =================================================================== --- trunk/x10.compiler/src/x10/plugin/LoadPlugins.java 2009-11-30 18:15:32 UTC (rev 12212) +++ trunk/x10.compiler/src/x10/plugin/LoadPlugins.java 2009-11-30 20:51:41 UTC (rev 12213) @@ -107,7 +107,7 @@ // Now load the plugin from the class file. try { // System.out.println("classpath = " + System.getProperty("java.class.path")); - Class c = Class.forName(pluginName.toString()); + Class<?> c = Class.forName(pluginName.toString()); Object o = c.newInstance(); if (o instanceof CompilerPlugin) { // OK, it's a plugin! Modified: trunk/x10.compiler/src/x10/types/X10Context_c.java =================================================================== --- trunk/x10.compiler/src/x10/types/X10Context_c.java 2009-11-30 18:15:32 UTC (rev 12212) +++ trunk/x10.compiler/src/x10/types/X10Context_c.java 2009-11-30 20:51:41 UTC (rev 12213) @@ -426,7 +426,7 @@ return varWhoseTypeIsBeingElaborated; } - private static final Collection TOPICS = + private static final Collection<String> TOPICS = CollectionUtil.list(Report.types, Report.context); /** Modified: trunk/x10.compiler/src/x10/visit/AnnotationChecker.java =================================================================== --- trunk/x10.compiler/src/x10/visit/AnnotationChecker.java 2009-11-30 18:15:32 UTC (rev 12212) +++ trunk/x10.compiler/src/x10/visit/AnnotationChecker.java 2009-11-30 20:51:41 UTC (rev 12213) @@ -49,10 +49,10 @@ init(); - List annotations = ((X10Ext) n.ext()).annotations(); + List<AnnotationNode> annotations = ((X10Ext) n.ext()).annotations(); - for (Iterator i = annotations.iterator(); i.hasNext(); ) { - AnnotationNode a = (AnnotationNode) i.next(); + for (Iterator<AnnotationNode> i = annotations.iterator(); i.hasNext(); ) { + AnnotationNode a = i.next(); X10ClassType at = a.annotationInterface(); if (n instanceof TypeNode && ! at.isSubtype(TA, context)) { throw new SemanticException("Annotations on types must implement " + TA, n.position()); Modified: trunk/x10.compiler/src/x10/visit/AsyncElimination.java =================================================================== --- trunk/x10.compiler/src/x10/visit/AsyncElimination.java 2009-11-30 18:15:32 UTC (rev 12212) +++ trunk/x10.compiler/src/x10/visit/AsyncElimination.java 2009-11-30 20:51:41 UTC (rev 12213) @@ -140,7 +140,7 @@ * - does not allocate other objects / arrays **/ private boolean isOptimizableExpr_(Expr e) { - final Set critical = new HashSet(); + final Set<Node> critical = new HashSet<Node>(); e.visit( new NodeVisitor() { public Node leave( Node old, Node n, NodeVisitor v) { if ( n instanceof ProcedureCall || Modified: trunk/x10.compiler/src/x10/visit/X10Translator.java =================================================================== --- trunk/x10.compiler/src/x10/visit/X10Translator.java 2009-11-30 18:15:32 UTC (rev 12212) +++ trunk/x10.compiler/src/x10/visit/X10Translator.java 2009-11-30 20:51:41 UTC (rev 12213) @@ -71,7 +71,7 @@ NodeFactory nf = nodeFactory(); TargetFactory tf = this.tf; int outputWidth = job.compiler().outputWidth(); - Collection outputFiles = job.compiler().outputFiles(); + Collection<String> outputFiles = job.compiler().outputFiles(); try { File of; Modified: trunk/x10.compiler/src/x10cpp/extension/X10ClassBodyExt_c.java =================================================================== --- trunk/x10.compiler/src/x10cpp/extension/X10ClassBodyExt_c.java 2009-11-30 18:15:32 UTC (rev 12212) +++ trunk/x10.compiler/src/x10cpp/extension/X10ClassBodyExt_c.java 2009-11-30 20:51:41 UTC (rev 12213) @@ -19,7 +19,9 @@ import java.util.Map; import polyglot.ast.ClassBody_c; +import polyglot.ast.ClassMember; import polyglot.ast.Formal_c; +import polyglot.ast.Id; import polyglot.ast.MethodDecl; import polyglot.ast.MethodDecl_c; import polyglot.ast.Node; @@ -412,13 +414,13 @@ return JNImangle(canonicalTypeString(type)) + EXTERN_STUB_SUFFIX; } - private Map buildNativeMethodHash(List members) { - Map methodHash = new HashMap(); - for (ListIterator j = members.listIterator(); j.hasNext();) { + private Map<Id, MethodDecl> buildNativeMethodHash(List<ClassMember> members) { + Map<Id, MethodDecl> methodHash = new HashMap<Id, MethodDecl>(); + for (ListIterator<ClassMember> j = members.listIterator(); j.hasNext();) { Object theObj = j.next(); if (!(theObj instanceof MethodDecl)) continue; - MethodDecl_c methodDecl = (MethodDecl_c) theObj; + MethodDecl methodDecl = (MethodDecl) theObj; if (!X10Flags.isExtern(methodDecl.methodDef().flags())) continue; Modified: trunk/x10.compiler/src/x10cpp/types/X10CPPContext_c.java =================================================================== --- trunk/x10.compiler/src/x10cpp/types/X10CPPContext_c.java 2009-11-30 18:15:32 UTC (rev 12212) +++ trunk/x10.compiler/src/x10cpp/types/X10CPPContext_c.java 2009-11-30 20:51:41 UTC (rev 12213) @@ -133,7 +133,7 @@ public ClassifiedStream templateFunctions = null; public ClassifiedStream structHeader = null; - public ArrayList<VarInstance> variables = new ArrayList<VarInstance>(); + public ArrayList<VarInstance<?>> variables = new ArrayList<VarInstance<?>>(); private void putYourVariablesHere(ArrayList<VarInstance> vars) { vars.addAll(variables); @@ -224,7 +224,7 @@ public Object copy() { X10CPPContext_c res = (X10CPPContext_c) super.copy(); - res.variables = new ArrayList<VarInstance>(); // or whatever the initial value is + res.variables = new ArrayList<VarInstance<?>>(); // or whatever the initial value is res.inClosure = false; res.stackAllocateClosure = false; res.closureOuter = null; Modified: trunk/x10.compiler/src/x10cpp/visit/ASTQuery.java =================================================================== --- trunk/x10.compiler/src/x10cpp/visit/ASTQuery.java 2009-11-30 18:15:32 UTC (rev 12212) +++ trunk/x10.compiler/src/x10cpp/visit/ASTQuery.java 2009-11-30 20:51:41 UTC (rev 12213) @@ -49,6 +49,7 @@ import x10.extension.X10Ext; import x10.types.X10ClassDef; import x10.types.X10ClassType; +import x10.types.X10MethodInstance; import x10.types.X10TypeMixin; import x10.types.X10TypeSystem; import x10.types.X10TypeSystem_c; @@ -209,7 +210,7 @@ return true; } - static final ArrayList knownAsyncArrayCopyMethods = new ArrayList(); + static final ArrayList<X10MethodInstance> knownAsyncArrayCopyMethods = new ArrayList<X10MethodInstance>(); /* -- SPMD compilation -- boolean isAsyncArrayCopy(Call_c n) { @@ -235,7 +236,7 @@ */ - static final ArrayList knownArrayCopyMethods = new ArrayList(); + static final ArrayList<X10MethodInstance> knownArrayCopyMethods = new ArrayList<X10MethodInstance>(); boolean isAsyncArrayCopy(Async_c n) { X10TypeSystem ts = (X10TypeSystem) tr.typeSystem(); Modified: trunk/x10.compiler/src/x10cpp/visit/Emitter.java =================================================================== --- trunk/x10.compiler/src/x10cpp/visit/Emitter.java 2009-11-30 18:15:32 UTC (rev 12212) +++ trunk/x10.compiler/src/x10cpp/visit/Emitter.java 2009-11-30 20:51:41 UTC (rev 12213) @@ -874,13 +874,13 @@ return; } - public void printDeclarationList(CodeWriter w, X10CPPContext_c c, ArrayList vars) { + public void printDeclarationList(CodeWriter w, X10CPPContext_c c, ArrayList<VarInstance<?>> vars) { printDeclarationList(w, c, vars, true, false); } - void printDeclarationList(CodeWriter w, X10CPPContext_c c, ArrayList vars, boolean saved_this_mechanism, boolean writable) { + void printDeclarationList(CodeWriter w, X10CPPContext_c c, ArrayList<VarInstance<?>> vars, boolean saved_this_mechanism, boolean writable) { for (int i = 0; i < vars.size(); i++) { - VarInstance var = (VarInstance)vars.get(i); + VarInstance<?> var = vars.get(i); Type t = var.type(); String type = translateType(t, true); if (writable && !var.name().toString().equals(THIS)) // this is a temporary ref Modified: trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java =================================================================== --- trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java 2009-11-30 18:15:32 UTC (rev 12212) +++ trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java 2009-11-30 20:51:41 UTC (rev 12213) @@ -3772,7 +3772,7 @@ emitter.enterClosure(c); ClosureDef closureDef = n.closureDef(); - CodeInstance ci = closureDef.methodContainer().get(); + CodeInstance<?> ci = closureDef.methodContainer().get(); X10ClassType hostClassType = (X10ClassType) closureDef.typeContainer().get(); X10ClassDef hostClassDef = hostClassType.x10Def(); X10TypeSystem_c xts = (X10TypeSystem_c) tr.typeSystem(); Modified: trunk/x10.compiler/src/x10cpp/visit/SharedVarsMethods.java =================================================================== --- trunk/x10.compiler/src/x10cpp/visit/SharedVarsMethods.java 2009-11-30 18:15:32 UTC (rev 12212) +++ trunk/x10.compiler/src/x10cpp/visit/SharedVarsMethods.java 2009-11-30 20:51:41 UTC (rev 12213) @@ -18,6 +18,7 @@ import polyglot.types.TypeSystem; import polyglot.types.VarInstance; import x10.ast.ConstantDistMaker_c; +import x10.types.X10MethodInstance; import x10.types.X10ParsedClassType; import x10.types.X10TypeSystem; import x10.types.X10TypeSystem_c; @@ -109,9 +110,9 @@ ((X10ParsedClassType) distribution.type()).isConstantDist(); } */ - static final ArrayList knownSafeClasses = new ArrayList(); - static final ArrayList knownSafeMethods = new ArrayList(); - static final ArrayList knownSafeFields = new ArrayList(); + static final ArrayList<ReferenceType> knownSafeClasses = new ArrayList<ReferenceType>(); + static final ArrayList<X10MethodInstance> knownSafeMethods = new ArrayList<X10MethodInstance>(); + static final ArrayList<FieldInstance> knownSafeFields = new ArrayList<FieldInstance>(); static void populateKnownSafeEntries(Translator tr){ populateKnownSafeClasses(tr); populateKnownSafeMethodsAndFields(tr); @@ -170,8 +171,7 @@ } } - static final ArrayList knownIgnoredExternMethods = new ArrayList(); - static final ArrayList knownInlinableMethods = new ArrayList(); + static final ArrayList<X10MethodInstance> knownInlinableMethods = new ArrayList<X10MethodInstance>(); static void populateIninableMethodsIfEmpty(Translator tr) { X10CPPContext_c context = (X10CPPContext_c) tr.context(); Modified: trunk/x10.compiler/src/x10cpp/visit/X10CPPTranslator.java =================================================================== --- trunk/x10.compiler/src/x10cpp/visit/X10CPPTranslator.java 2009-11-30 18:15:32 UTC (rev 12212) +++ trunk/x10.compiler/src/x10cpp/visit/X10CPPTranslator.java 2009-11-30 20:51:41 UTC (rev 12213) @@ -312,7 +312,7 @@ DelegateTargetFactory tf = (DelegateTargetFactory) this.tf; int outputWidth = job.compiler().outputWidth(); - Collection outputFiles = job.compiler().outputFiles(); + Collection<String> outputFiles = job.compiler().outputFiles(); try { String opfPath; Modified: trunk/x10.compiler/src/x10cpp/visit/XCDProcessor.java =================================================================== --- trunk/x10.compiler/src/x10cpp/visit/XCDProcessor.java 2009-11-30 18:15:32 UTC (rev 12212) +++ trunk/x10.compiler/src/x10cpp/visit/XCDProcessor.java 2009-11-30 20:51:41 UTC (rev 12213) @@ -32,7 +32,7 @@ this.tr = tr; } - static HashMap translationCache_ = new HashMap(); + static HashMap<String,String> translationCache_ = new HashMap<String,String>(); /** * Pretty-print a given object. @@ -51,7 +51,7 @@ } } static String translate(String id) { - String cached = (String) translationCache_.get(id); + String cached = translationCache_.get(id); if (cached != null) return cached; try { @@ -254,24 +254,6 @@ } } - /** - * A list of one object that has an infinite circular iterator. - */ - public class CircularList extends AbstractList { - // FIXME: Igor, where do we need this class? -[Krishna]. - private Object o; - public CircularList(Object o) { this.o = o; } - public Iterator iterator() { - return new Iterator() { - public boolean hasNext() { return true; } - public Object next() { return o; } - public void remove() { return; } - }; - } - public Object get(int i) { return o; } - public int size() { return -1; } - } - private static List asList(Object a, Object b) { List<Object> l = new ArrayList<Object>(2); l.add(a); l.add(b); return l; Modified: trunk/x10.runtime/src-java/x10/runtime/impl/java/PreLoader.java =================================================================== --- trunk/x10.runtime/src-java/x10/runtime/impl/java/PreLoader.java 2009-11-30 18:15:32 UTC (rev 12212) +++ trunk/x10.runtime/src-java/x10/runtime/impl/java/PreLoader.java 2009-11-30 20:51:41 UTC (rev 12213) @@ -37,14 +37,14 @@ preLoad(PreLoader.class); } private static final String TRUE = "true"; - private static final Map inited = new HashMap(); + private static final Map<String, String> inited = new HashMap<String, String>(); private static final ClassLoader bootstrap = Object.class.getClassLoader(); /** * Recursively pre-load the given class and all the classes it statically * references. * @param c the class to pre-load */ - public static void preLoad(Class c) { + public static void preLoad(Class<?> c) { preLoad(getClassFile(c), c); } /** @@ -53,14 +53,14 @@ * @param c the class to pre-load * @param intern whether to intern string constants */ - public static void preLoad(Class c, boolean intern) { + public static void preLoad(Class<?> c, boolean intern) { if (c.getClassLoader() == bootstrap) return; preLoad(getClassFile(c), c, intern); } - private static void preLoad(String name, Class c) { + private static void preLoad(String name, Class<?> c) { preLoad(name, c, true); } - private static void preLoad(String name, Class c, boolean intern) { + private static void preLoad(String name, Class<?> c, boolean intern) { if (inited.get(name) != null) return; inited.put(name, TRUE); // System.err.println("Pre-loading '"+name+"'"); @@ -74,7 +74,7 @@ for (int i = 0; i < ref_classes.length; i++) { String nm = toClassName(ref_classes[i]); try { - Class u = Class.forName(nm); + Class<?> u = Class.forName(nm); // System.err.println(i+": "+nm+" -> "+u); // Skip arrays if (nm.charAt(0) == '[') continue; @@ -87,10 +87,10 @@ } } catch (IOException e) { e.printStackTrace(System.err); assert false; } } - private static InputStream getClassAsStream(Class c) throws IOException { + private static InputStream getClassAsStream(Class<?> c) throws IOException { return getClassAsStream(getClassFile(c), c); } - private static InputStream getClassAsStream(String name, Class c) throws IOException { + private static InputStream getClassAsStream(String name, Class<?> c) throws IOException { InputStream cin = c.getClassLoader().getResourceAsStream(name); if (cin == null) throw new IOException("Class file "+name+" cannot be found"); @@ -102,10 +102,10 @@ private static String toFileName(String n) { return n.replace('.','/')+".class"; } - private static String getClassFile(Class c) { + private static String getClassFile(Class<?> c) { return toFileName(c.getName()); } - private static byte[] getClassBytes(String name, Class c) throws IOException { + private static byte[] getClassBytes(String name, Class<?> c) throws IOException { InputStream cin = getClassAsStream(name, c); byte[] classbytes = new byte[cin.available()]; if (cin.read(classbytes) != classbytes.length) Modified: trunk/x10.runtime/src-java/x10/runtime/impl/java/Report.java =================================================================== --- trunk/x10.runtime/src-java/x10/runtime/impl/java/Report.java 2009-11-30 18:15:32 UTC (rev 12212) +++ trunk/x10.runtime/src-java/x10/runtime/impl/java/Report.java 2009-11-30 20:51:41 UTC (rev 12213) @@ -27,17 +27,17 @@ /** A collection of string names of topics which can be used with the -report command-line switch */ - public static Collection topics = new HashSet(); + public static Collection<String> topics = new HashSet<String>(); /** A collection of string names of topics which we should always check if we should report. */ - public static Stack should_report = new Stack(); + public static Stack<String> should_report = new Stack<String>(); /** * The topics that the user has selected to report, mapped to the level * they want to report them to. */ - protected static Map reportTopics = new HashMap(); // Map[String, Integer] + protected static Map<String,Integer> reportTopics = new HashMap<String,Integer>(); // Map[String, Integer] /** * Indicates if there is no reporting at all. @@ -89,16 +89,16 @@ * <code>level</code> should be reported, based on use of the * -report command-line switches given by the user. */ - public static boolean should_report(Collection topics, int level) { + public static boolean should_report(Collection<String> topics, int level) { if (noReporting) return false; - for (Iterator i = should_report.iterator(); i.hasNext();) { - String topic = (String) i.next(); + for (Iterator<String> i = should_report.iterator(); i.hasNext();) { + String topic = i.next(); if (level(topic) >= level) return true; } if (topics != null) { - for (Iterator i = topics.iterator(); i.hasNext();) { - String topic = (String) i.next(); + for (Iterator<String> i = topics.iterator(); i.hasNext();) { + String topic = i.next(); if (level(topic) >= level) return true; } } Modified: trunk/x10.runtime/src-java/x10/runtime/rewrite/Runtime.java =================================================================== --- trunk/x10.runtime/src-java/x10/runtime/rewrite/Runtime.java 2009-11-30 18:15:32 UTC (rev 12212) +++ trunk/x10.runtime/src-java/x10/runtime/rewrite/Runtime.java 2009-11-30 20:51:41 UTC (rev 12213) @@ -47,30 +47,30 @@ public static boolean recoverZ(Object o) { return false; } public static Object recoverL(Object o) { return null; } - public static boolean instanceof$(boolean r, Class c) { return r; } - public static boolean instanceof$(boolean r, Class c, Class d) { return r; } - public static boolean instanceof$(boolean r, Class c, Class d, Class e) { return r; } - public static boolean instanceof$(boolean r, Class c, Class d, Class e, Class f) { return r; } - public static boolean instanceof$(boolean r, Class c, Class d, Class e, Class f, Class g) { return r; } - public static boolean instanceof$(boolean r, Class c, Class d, Class e, Class f, Class g, Class h) { return r; } - public static boolean instanceof$(boolean r, Class c, Class d, Class e, Class f, Class g, Class h, Class i) { return r; } - public static boolean instanceof$(boolean r, Class c, Class d, Class e, Class f, Class g, Class h, Class i, Class... j) { return r; } - public static Object cast$(Object o, Class c) { return o; } - public static Object cast$(Object o, Class c, Class d) { return o; } - public static Object cast$(Object o, Class c, Class d, Class e) { return o; } - public static Object cast$(Object o, Class c, Class d, Class e, Class f) { return o; } - public static Object cast$(Object o, Class c, Class d, Class e, Class f, Class g) { return o; } - public static Object cast$(Object o, Class c, Class d, Class e, Class f, Class g, Class h) { return o; } - public static Object cast$(Object o, Class c, Class d, Class e, Class f, Class g, Class h, Class i) { return o; } - public static Object cast$(Object o, Class c, Class d, Class e, Class f, Class g, Class h, Class i, Class... j) { return o; } + public static boolean instanceof$(boolean r, Class<?> c) { return r; } + public static boolean instanceof$(boolean r, Class<?> c, Class<?> d) { return r; } + public static boolean instanceof$(boolean r, Class<?> c, Class<?> d, Class<?> e) { return r; } + public static boolean instanceof$(boolean r, Class<?> c, Class<?> d, Class<?> e, Class<?> f) { return r; } + public static boolean instanceof$(boolean r, Class<?> c, Class<?> d, Class<?> e, Class<?> f, Class<?> g) { return r; } + public static boolean instanceof$(boolean r, Class<?> c, Class<?> d, Class<?> e, Class<?> f, Class<?> g, Class<?> h) { return r; } + public static boolean instanceof$(boolean r, Class<?> c, Class<?> d, Class<?> e, Class<?> f, Class<?> g, Class<?> h, Class<?> i) { return r; } + public static boolean instanceof$(boolean r, Class<?> c, Class<?> d, Class<?> e, Class<?> f, Class<?> g, Class<?> h, Class<?> i, Class<?>... j) { return r; } + public static Object cast$(Object o, Class<?> c) { return o; } + public static Object cast$(Object o, Class<?> c, Class<?> d) { return o; } + public static Object cast$(Object o, Class<?> c, Class<?> d, Class<?> e) { return o; } + public static Object cast$(Object o, Class<?> c, Class<?> d, Class<?> e, Class<?> f) { return o; } + public static Object cast$(Object o, Class<?> c, Class<?> d, Class<?> e, Class<?> f, Class<?> g) { return o; } + public static Object cast$(Object o, Class<?> c, Class<?> d, Class<?> e, Class<?> f, Class<?> g, Class<?> h) { return o; } + public static Object cast$(Object o, Class<?> c, Class<?> d, Class<?> e, Class<?> f, Class<?> g, Class<?> h, Class<?> i) { return o; } + public static Object cast$(Object o, Class<?> c, Class<?> d, Class<?> e, Class<?> f, Class<?> g, Class<?> h, Class<?> i, Class<?>... j) { return o; } - public static Object newarray$(Object o, Class c) { return o; } - public static Object newarray$(Object o, Class c, Class d) { return o; } - public static Object newarray$(Object o, Class c, Class d, Class e) { return o; } - public static Object newarray$(Object o, Class c, Class d, Class e, Class f) { return o; } - public static Object newarray$(Object o, Class c, Class d, Class e, Class f, Class g) { return o; } - public static Object newarray$(Object o, Class c, Class d, Class e, Class f, Class g, Class h) { return o; } - public static Object newarray$(Object o, Class c, Class d, Class e, Class f, Class g, Class h, Class i) { return o; } - public static Object newarray$(Object o, Class c, Class d, Class e, Class f, Class g, Class h, Class i, Class... j) { return o; } + public static Object newarray$(Object o, Class<?> c) { return o; } + public static Object newarray$(Object o, Class<?> c, Class<?> d) { return o; } + public static Object newarray$(Object o, Class<?> c, Class<?> d, Class<?> e) { return o; } + public static Object newarray$(Object o, Class<?> c, Class<?> d, Class<?> e, Class<?> f) { return o; } + public static Object newarray$(Object o, Class<?> c, Class<?> d, Class<?> e, Class<?> f, Class<?> g) { return o; } + public static Object newarray$(Object o, Class<?> c, Class<?> d, Class<?> e, Class<?> f, Class<?> g, Class<?> h) { return o; } + public static Object newarray$(Object o, Class<?> c, Class<?> d, Class<?> e, Class<?> f, Class<?> g, Class<?> h, Class<?> i) { return o; } + public static Object newarray$(Object o, Class<?> c, Class<?> d, Class<?> e, Class<?> f, Class<?> g, Class<?> h, Class<?> i, Class<?>... j) { return o; } } Modified: trunk/x10.runtime/src-java/x10/runtime/rewrite/X10RuntimeClassloader.java =================================================================== --- trunk/x10.runtime/src-java/x10/runtime/rewrite/X10RuntimeClassloader.java 2009-11-30 18:15:32 UTC (rev 12212) +++ trunk/x10.runtime/src-java/x10/runtime/rewrite/X10RuntimeClassloader.java 2009-11-30 20:51:41 UTC (rev 12213) @@ -57,7 +57,7 @@ private static final String INSTANTIATE_INTERFACES = "x10.generics.InstantiateInterfaces"; private final Method INSTANTIATE_INTERFACES_VALUE; private static final String INSTANTIATE_TYPE = "x10.generics.InstantiateType"; - private static final Class[] NO_PARAMETERS = { }; + private static final Class<?>[] NO_PARAMETERS = { }; private Method getValueMethod(String container) { try { Class<? extends Annotation> pc = (Class<? extends Annotation>)loadClass(container); @@ -410,7 +410,7 @@ return type.substring(1, type.length()-1); } - public final Class<?> instantiate(Class<?> c, Class[] p) { + public final Class<?> instantiate(Class<?> c, Class<?>[] p) { try { String base = c.getName(); String[] formals = extractParameters(c, PARAMETERS_VALUE); @@ -425,19 +425,19 @@ } } - public final Class<?> instantiate(Class<?> c, Class p) { + public final Class<?> instantiate(Class<?> c, Class<?> p) { return instantiate(c, new Class[] { p }); } - public final Class<?> instantiate(Class<?> c, Class p, Class q) { + public final Class<?> instantiate(Class<?> c, Class<?> p, Class<?> q) { return instantiate(c, new Class[] { p, q }); } - public final Class<?> instantiate(Class<?> c, Class p, Class q, Class r) { + public final Class<?> instantiate(Class<?> c, Class<?> p, Class<?> q, Class<?> r) { return instantiate(c, new Class[] { p, q, r }); } - public final Class<?> instantiate(Class<?> c, Class p, Class q, Class r, Class s) { + public final Class<?> instantiate(Class<?> c, Class<?> p, Class<?> q, Class<?> r, Class<?> s) { return instantiate(c, new Class[] { p, q, r, s }); } @@ -792,7 +792,7 @@ Class<?> c = getClass(container.replace('/','.')); if (c != null) { MethodSig sig = MethodSig.fromSignature(signature); - Class[] argTypes = new Class[sig.argTypes.length]; + Class<?>[] argTypes = new Class[sig.argTypes.length]; for (int i = 0; i < argTypes.length; i++) { argTypes[i] = getClass(typeFromSignature(sig.argTypes[i])); } @@ -842,7 +842,7 @@ Class<?> c = getClass(container.replace('/','.')); if (c != null) { MethodSig sig = MethodSig.fromSignature(signature); - Class[] argTypes = new Class[sig.argTypes.length]; + Class<?>[] argTypes = new Class[sig.argTypes.length]; for (int i = 0; i < argTypes.length; i++) argTypes[i] = getClass(typeFromSignature(sig.argTypes[i])); parms = extractParameters(c.getDeclaredMethod(name, argTypes), p, INSTANTIATE_SUPERCLASS_VALUE); Modified: trunk/x10.runtime/src-java/x10/types/Types.java =================================================================== --- trunk/x10.runtime/src-java/x10/types/Types.java 2009-11-30 18:15:32 UTC (rev 12212) +++ trunk/x10.runtime/src-java/x10/types/Types.java 2009-11-30 20:51:41 UTC (rev 12213) @@ -25,7 +25,7 @@ return (T) o; } - public static Type runtimeType(Class c) { + public static Type runtimeType(Class<?> c) { return new RuntimeType(c); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dgr...@us...> - 2009-12-02 21:19:08
|
Revision: 12236 http://x10.svn.sourceforge.net/x10/?rev=12236&view=rev Author: dgrove-oss Date: 2009-12-02 21:18:52 +0000 (Wed, 02 Dec 2009) Log Message: ----------- Work in progress on cleaning up C++ native classes to remove 1.7isms. Rename Value to Closure, since the only remaining usage of Value was as the implementation-level parent of all closure literal classes. Modified Paths: -------------- trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java trunk/x10.runtime/src-cpp/Makefile trunk/x10.runtime/src-cpp/x10/lang/Object.cc trunk/x10.runtime/src-cpp/x10/lang/ValRail.h trunk/x10.runtime/src-cpp/x10aux/bootstrap.h trunk/x10.runtime/src-cpp/x10aux/init_dispatcher.cc trunk/x10.runtime/src-cpp/x10aux/network.cc Added Paths: ----------- trunk/x10.runtime/src-cpp/x10/lang/Closure.cc trunk/x10.runtime/src-cpp/x10/lang/Closure.h Removed Paths: ------------- trunk/x10.runtime/src-cpp/x10/lang/Value.cc trunk/x10.runtime/src-cpp/x10/lang/Value.h Modified: trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java =================================================================== --- trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java 2009-12-02 20:21:55 UTC (rev 12235) +++ trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java 2009-12-02 21:18:52 UTC (rev 12236) @@ -3841,13 +3841,13 @@ String superType = Emitter.translateType(sup.typeArguments(supArgs)); String superTypeRef = Emitter.translateType(sup.typeArguments(supArgs), true); - inc.write("#include <x10/lang/Value.h>"); inc.newline(); + inc.write("#include <x10/lang/Closure.h>"); inc.newline(); String header = getHeader(sup); inc.write("#include <"+header+">"); inc.newline(); // class header if (!freeTypeParams.isEmpty()) emitter.printTemplateSignature(freeTypeParams, inc); - inc.write("class "+cname+" : public x10::lang::Value {"); + inc.write("class "+cname+" : public x10::lang::Closure {"); inc.newline(4); inc.begin(0); inc.write("public:") ; inc.newline(); inc.forceNewline(); Modified: trunk/x10.runtime/src-cpp/Makefile =================================================================== --- trunk/x10.runtime/src-cpp/Makefile 2009-12-02 20:21:55 UTC (rev 12235) +++ trunk/x10.runtime/src-cpp/Makefile 2009-12-02 21:18:52 UTC (rev 12236) @@ -238,6 +238,7 @@ x10/io/File__NativeFile.o \ x10/io/InputStreamReader__InputStream.o \ x10/io/OutputStreamWriter__OutputStream.o \ + x10/lang/Closure.o \ x10/lang/Fun.o \ x10/lang/Object.o \ x10/lang/Rail.o \ @@ -246,7 +247,6 @@ x10/lang/String.o \ x10/lang/Struct.o \ x10/lang/Throwable.o \ - x10/lang/Value.o \ x10/lang/ValRail.o \ x10/runtime/Deque.o \ x10/runtime/Lock.o \ Copied: trunk/x10.runtime/src-cpp/x10/lang/Closure.cc (from rev 12228, trunk/x10.runtime/src-cpp/x10/lang/Value.cc) =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Closure.cc (rev 0) +++ trunk/x10.runtime/src-cpp/x10/lang/Closure.cc 2009-12-02 21:18:52 UTC (rev 12236) @@ -0,0 +1,44 @@ +#include <sstream> + +#include <x10aux/ref.h> +#include <x10aux/alloc.h> + +#include <x10/lang/Closure.h> +#include <x10/lang/String.h> + +using namespace x10::lang; +using namespace x10aux; + +const serialization_id_t Closure::_serialization_id = + DeserializationDispatcher::addDeserializer(Closure::_deserializer<Ref>); + +void Closure::_serialize(x10aux::ref<Closure> this_, + x10aux::serialization_buffer &buf, + x10aux::addr_map &m) +{ + x10aux::serialization_id_t id = this_->_get_serialization_id(); + _S_("Serializing a "<<ANSI_SER<<ANSI_BOLD<<"value id "<<id<<ANSI_RESET<<" to buf: "<<&buf); + buf.write(id,m); + _S_("Serializing the "<<ANSI_SER<<"value body"<<ANSI_RESET<<" to buf: "<<&buf); + this_->_serialize_body(buf, m); +} + +x10aux::ref<Closure> Closure::_make() { + return (new (x10aux::alloc<Closure>()) Closure())->_constructor(); +} + +x10aux::ref<x10::lang::String> x10::lang::Closure::toString() { + return String::Lit("Closure without toString defined."); +} + +x10_boolean +Closure::_struct_equals(x10aux::ref<Object> other) { + if (!_type()->concreteInstanceOf(other)) + return false; + // now compare fields but there aren't any + return true; +} + +RTT_CC_DECLS1(Closure, "x10.lang.Closure", Object) + +// vim:tabstop=4:shiftwidth=4:expandtab Copied: trunk/x10.runtime/src-cpp/x10/lang/Closure.h (from rev 12228, trunk/x10.runtime/src-cpp/x10/lang/Value.h) =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Closure.h (rev 0) +++ trunk/x10.runtime/src-cpp/x10/lang/Closure.h 2009-12-02 21:18:52 UTC (rev 12236) @@ -0,0 +1,74 @@ +#ifndef X10_LANG_CLOSURE_H +#define X10_LANG_CLOSURE_H + +#include <x10aux/config.h> +#include <x10aux/ref.h> +#include <x10aux/serialization.h> +#include <x10aux/RTT.h> + +#include <x10/lang/Object.h> +namespace x10 { namespace lang { class String; } } + +namespace x10 { + + namespace lang { + + class Closure : public Object { + public: + RTT_H_DECLS_CLASS + + Closure() { + location = x10aux::here; + } + + static x10aux::ref<Closure> _make(); + + x10aux::ref<Closure> _constructor() { return this; } + + static const x10aux::serialization_id_t _serialization_id; + + virtual x10aux::serialization_id_t _get_serialization_id() { return _serialization_id; }; + + virtual void _serialize_body(x10aux::serialization_buffer &, x10aux::addr_map &) { + // there are no fields + } + + template<class T> static x10aux::ref<T> _deserializer(x10aux::deserialization_buffer &); + + void _deserialize_body(x10aux::deserialization_buffer &) { + // there are no fields + } + + static void _serialize(x10aux::ref<Closure> this_, + x10aux::serialization_buffer &buf, + x10aux::addr_map &m); + + template<class T> static x10aux::ref<T> _deserialize(x10aux::deserialization_buffer &buf); + + virtual x10_int hashCode() { + // All instances of Closure are equal, so their hashcodes can be too. + return 0; + } + + virtual x10aux::ref<String> toString(); + + virtual x10_boolean _struct_equals(x10aux::ref<Object> other); + }; + + template<class T> x10aux::ref<T> Closure::_deserialize(x10aux::deserialization_buffer &buf){ + // extract the id and execute a callback to instantiate the right concrete class + _S_("Deserializing a "<<ANSI_SER<<ANSI_BOLD<<"value"<<ANSI_RESET<< + " (expecting id) from buf: "<<&buf); + return x10aux::DeserializationDispatcher::create<T>(buf); + } + + template<class T> x10aux::ref<T> Closure::_deserializer(x10aux::deserialization_buffer &) { + x10aux::ref<Closure> this_ = new (x10aux::alloc<Closure>()) Closure(); + return this_; + } + } +} + + +#endif +// vim:tabstop=4:shiftwidth=4:expandtab Modified: trunk/x10.runtime/src-cpp/x10/lang/Object.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Object.cc 2009-12-02 20:21:55 UTC (rev 12235) +++ trunk/x10.runtime/src-cpp/x10/lang/Object.cc 2009-12-02 21:18:52 UTC (rev 12236) @@ -3,9 +3,7 @@ #include <x10/lang/Object.h> #include <x10/lang/Ref.h> -#include <x10/lang/Value.h> - using namespace x10::lang; using namespace x10aux; Modified: trunk/x10.runtime/src-cpp/x10/lang/ValRail.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/ValRail.h 2009-12-02 20:21:55 UTC (rev 12235) +++ trunk/x10.runtime/src-cpp/x10/lang/ValRail.h 2009-12-02 21:18:52 UTC (rev 12236) @@ -8,7 +8,6 @@ #include <x10aux/basic_functions.h> #include <x10/lang/Ref.h> -#include <x10/lang/Value.h> /// HACK!!!! #include <x10/lang/Fun_0_1.h> #include <x10/lang/Iterable.h> #include <x10/lang/RailIterator.h> Deleted: trunk/x10.runtime/src-cpp/x10/lang/Value.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Value.cc 2009-12-02 20:21:55 UTC (rev 12235) +++ trunk/x10.runtime/src-cpp/x10/lang/Value.cc 2009-12-02 21:18:52 UTC (rev 12236) @@ -1,44 +0,0 @@ -#include <sstream> - -#include <x10aux/ref.h> -#include <x10aux/alloc.h> - -#include <x10/lang/Value.h> -#include <x10/lang/String.h> - -using namespace x10::lang; -using namespace x10aux; - -const serialization_id_t Value::_serialization_id = - DeserializationDispatcher::addDeserializer(Value::_deserializer<Ref>); - -void Value::_serialize(x10aux::ref<Value> this_, - x10aux::serialization_buffer &buf, - x10aux::addr_map &m) -{ - x10aux::serialization_id_t id = this_->_get_serialization_id(); - _S_("Serializing a "<<ANSI_SER<<ANSI_BOLD<<"value id "<<id<<ANSI_RESET<<" to buf: "<<&buf); - buf.write(id,m); - _S_("Serializing the "<<ANSI_SER<<"value body"<<ANSI_RESET<<" to buf: "<<&buf); - this_->_serialize_body(buf, m); -} - -x10aux::ref<Value> Value::_make() { - return (new (x10aux::alloc<Value>()) Value())->_constructor(); -} - -x10aux::ref<x10::lang::String> x10::lang::Value::toString() { - return String::Lit("Value without toString defined."); -} - -x10_boolean -Value::_struct_equals(x10aux::ref<Object> other) { - if (!_type()->concreteInstanceOf(other)) - return false; - // now compare fields but there aren't any - return true; -} - -RTT_CC_DECLS1(Value, "x10.lang.Value", Object) - -// vim:tabstop=4:shiftwidth=4:expandtab Deleted: trunk/x10.runtime/src-cpp/x10/lang/Value.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Value.h 2009-12-02 20:21:55 UTC (rev 12235) +++ trunk/x10.runtime/src-cpp/x10/lang/Value.h 2009-12-02 21:18:52 UTC (rev 12236) @@ -1,76 +0,0 @@ -#ifndef X10_LANG_VALUE_H -#define X10_LANG_VALUE_H - -#include <x10aux/config.h> -#include <x10aux/ref.h> -#include <x10aux/serialization.h> -#include <x10aux/RTT.h> - -#include <x10/lang/Object.h> -namespace x10 { namespace lang { class String; } } - -namespace x10 { - - namespace lang { - - class Value : public Object { - public: - RTT_H_DECLS_CLASS - - Value() { - location = x10aux::here; - } - - static x10aux::ref<Value> _make(); - - x10aux::ref<Value> _constructor() { return this; } - - static const x10aux::serialization_id_t _serialization_id; - - virtual x10aux::serialization_id_t _get_serialization_id() { return _serialization_id; }; - - virtual void _serialize_body(x10aux::serialization_buffer &, x10aux::addr_map &) { - // there are no fields - } - - template<class T> static x10aux::ref<T> _deserializer(x10aux::deserialization_buffer &); - - void _deserialize_body(x10aux::deserialization_buffer &) { - // there are no fields - } - - static void _serialize(x10aux::ref<Value> this_, - x10aux::serialization_buffer &buf, - x10aux::addr_map &m); - - template<class T> static x10aux::ref<T> _deserialize(x10aux::deserialization_buffer &buf); - - - - virtual x10_int hashCode() { - // All instances of Value are equal, so their hashcodes can be too. - return 0; - } - - virtual x10aux::ref<String> toString(); - - virtual x10_boolean _struct_equals(x10aux::ref<Object> other); - }; - - template<class T> x10aux::ref<T> Value::_deserialize(x10aux::deserialization_buffer &buf){ - // extract the id and execute a callback to instantiate the right concrete class - _S_("Deserializing a "<<ANSI_SER<<ANSI_BOLD<<"value"<<ANSI_RESET<< - " (expecting id) from buf: "<<&buf); - return x10aux::DeserializationDispatcher::create<T>(buf); - } - - template<class T> x10aux::ref<T> Value::_deserializer(x10aux::deserialization_buffer &) { - x10aux::ref<Value> this_ = new (x10aux::alloc<Value>()) Value(); - return this_; - } - } -} - - -#endif -// vim:tabstop=4:shiftwidth=4:expandtab Modified: trunk/x10.runtime/src-cpp/x10aux/bootstrap.h =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/bootstrap.h 2009-12-02 20:21:55 UTC (rev 12235) +++ trunk/x10.runtime/src-cpp/x10aux/bootstrap.h 2009-12-02 21:18:52 UTC (rev 12236) @@ -16,6 +16,7 @@ #include <x10/lang/Throwable.h> #include <x10/runtime/Thread.h> +#include <x10/lang/Closure.h> #include <stdio.h> @@ -26,7 +27,7 @@ namespace x10aux { - class StaticInitClosure : public x10::lang::Value + class StaticInitClosure : public x10::lang::Closure { public: @@ -57,7 +58,7 @@ typedef void (*ApplicationMainFunction)(ref<x10::lang::Rail<ref<x10::lang::String> > >); - class BootStrapClosure : public x10::lang::Value + class BootStrapClosure : public x10::lang::Closure { protected: Modified: trunk/x10.runtime/src-cpp/x10aux/init_dispatcher.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/init_dispatcher.cc 2009-12-02 20:21:55 UTC (rev 12235) +++ trunk/x10.runtime/src-cpp/x10aux/init_dispatcher.cc 2009-12-02 21:18:52 UTC (rev 12236) @@ -1,6 +1,8 @@ #include <x10aux/config.h> #include <x10aux/init_dispatcher.h> + #include <x10/runtime/Runtime.h> +#include <x10/lang/Closure.h> #include <stdio.h> @@ -16,7 +18,7 @@ } } -class InitClosure : public x10::lang::Value +class InitClosure : public x10::lang::Closure { protected: Initializer init; Modified: trunk/x10.runtime/src-cpp/x10aux/network.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/network.cc 2009-12-02 20:21:55 UTC (rev 12235) +++ trunk/x10.runtime/src-cpp/x10aux/network.cc 2009-12-02 21:18:52 UTC (rev 12236) @@ -13,7 +13,7 @@ #include <x10/lang/VoidFun_0_0.h> #include <x10/lang/String.h> // for debug output -#include <x10/lang/Value.h> // for x10_runtime_Runtime__closure__6 +#include <x10/lang/Closure.h> // for x10_runtime_Runtime__closure__6 #include <x10/runtime/RID.h> using namespace x10::lang; @@ -121,29 +121,29 @@ /* // FIXME: this is perhaps the worst hack i've ever done -struct x10_runtime_Runtime__closure__8 : x10::lang::Value { +struct x10_runtime_Runtime__closure__8 : x10::lang::Closure { static const x10aux::serialization_id_t _serialization_id; x10aux::ref<x10::lang::VoidFun_0_0> body; x10::runtime::RID rid; }; -struct x10_runtime_Runtime__closure__7 : x10::lang::Value { +struct x10_runtime_Runtime__closure__7 : x10::lang::Closure { static const x10aux::serialization_id_t _serialization_id; x10aux::ref<x10::lang::VoidFun_0_0> body; x10::runtime::RID rid; }; -struct x10_runtime_Runtime__closure__6 : x10::lang::Value { +struct x10_runtime_Runtime__closure__6 : x10::lang::Closure { static const x10aux::serialization_id_t _serialization_id; x10aux::ref<x10::lang::VoidFun_0_0> body; x10::runtime::RID rid; }; -struct x10_runtime_Runtime__closure__5 : x10::lang::Value { +struct x10_runtime_Runtime__closure__5 : x10::lang::Closure { static const x10aux::serialization_id_t _serialization_id; x10aux::ref<x10::lang::VoidFun_0_0> body; x10::runtime::RID rid; }; */ -struct x10_runtime_Runtime__closure__6__hack : x10::lang::Value { +struct x10_runtime_Runtime__closure__6__hack : x10::lang::Closure { static const x10aux::serialization_id_t _serialization_id; x10aux::ref<x10::lang::VoidFun_0_0> body; x10::runtime::RID rid; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ta...@us...> - 2009-12-04 16:42:55
|
Revision: 12256 http://x10.svn.sourceforge.net/x10/?rev=12256&view=rev Author: tardieu Date: 2009-12-04 16:42:35 +0000 (Fri, 04 Dec 2009) Log Message: ----------- working on finish (removed RID, used non-immortal remote refs, using global methods) removed free boolean (ie unconditionally dealloc async body) partially fixed race when async get processed before runtime is initialized (race still exists) Modified Paths: -------------- trunk/x10.compiler/src/x10/visit/Desugarer.java trunk/x10.runtime/src-cpp/x10/lang/Rail.cc trunk/x10.runtime/src-cpp/x10aux/bootstrap.h trunk/x10.runtime/src-cpp/x10aux/network.cc trunk/x10.runtime/src-cpp/x10aux/network.h trunk/x10.runtime/src-x10/x10/runtime/Activity.x10 trunk/x10.runtime/src-x10/x10/runtime/FinishState.x10 trunk/x10.runtime/src-x10/x10/runtime/FinishStates.x10 trunk/x10.runtime/src-x10/x10/runtime/RemoteFinish.x10 trunk/x10.runtime/src-x10/x10/runtime/RootFinish.x10 trunk/x10.runtime/src-x10/x10/runtime/Runtime.x10 Removed Paths: ------------- trunk/x10.runtime/src-x10/x10/runtime/RID.x10 Modified: trunk/x10.compiler/src/x10/visit/Desugarer.java =================================================================== --- trunk/x10.compiler/src/x10/visit/Desugarer.java 2009-12-04 15:06:46 UTC (rev 12255) +++ trunk/x10.compiler/src/x10/visit/Desugarer.java 2009-12-04 16:42:35 UTC (rev 12256) @@ -386,9 +386,6 @@ synth.toBlock(body), xContext()); exprs.add(closure); types.add(closure.closureDef().asType()); - Expr free = (Expr) xnf.BooleanLit(pos, true).typeCheck(this); - exprs.add(free); - types.add(free.type()); Stmt result = xnf.Eval(pos, synth.makeStaticCall(pos, xts.Runtime(), RUN_ASYNC, exprs, xts.Void(), types, xContext())); Modified: trunk/x10.runtime/src-cpp/x10/lang/Rail.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Rail.cc 2009-12-04 15:06:46 UTC (rev 12255) +++ trunk/x10.runtime/src-cpp/x10/lang/Rail.cc 2009-12-04 16:42:35 UTC (rev 12256) @@ -29,9 +29,8 @@ void x10::lang::Rail_notifyEnclosingFinish(deserialization_buffer& buf) { - x10::runtime::RID rid = buf.read<x10::runtime::RID>(); + ref<Object> fs = buf.read<ref<Object> >(); ref<x10::runtime::Runtime> rt = x10::runtime::Runtime::FMGL(runtime)->get(); - ref<Object> fs = rt->FMGL(finishStates)->get(rid); // olivier says the incr should be just after the notifySubActivitySpawn (fs.operator->()->*(findITable<x10::runtime::FinishState>(fs->_getITables())->notifyActivityCreation))(); (fs.operator->()->*(findITable<x10::runtime::FinishState>(fs->_getITables())->notifyActivityTermination))(); @@ -44,9 +43,7 @@ ref<x10::runtime::Runtime> rt = x10::runtime::Runtime::FMGL(runtime)->get(); ref<Object> fs = rt->currentState(); (fs.operator->()->*(findITable<x10::runtime::FinishState>(fs->_getITables())->notifySubActivitySpawn))(x10::lang::Place_methods::_make(dst)); - rt->FMGL(finishStates)->put(fs); - x10::runtime::RID rid = (fs.operator->()->*(findITable<x10::runtime::FinishState>(fs->_getITables())->rid))(); - buf.write(rid, m); + buf.write(fs, m); } void x10::lang::Rail_serializeAndSendPut(Place dst_place_, ref<Object> df, x10_ubyte code, Modified: trunk/x10.runtime/src-cpp/x10aux/bootstrap.h =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/bootstrap.h 2009-12-04 15:06:46 UTC (rev 12255) +++ trunk/x10.runtime/src-cpp/x10aux/bootstrap.h 2009-12-04 16:42:35 UTC (rev 12256) @@ -103,7 +103,7 @@ #endif setlinebuf(stdout); - x10rt_init(ac,av); + x10aux::network_init(ac,av); x10aux::ref<x10::lang::Rail<x10aux::ref<x10::lang::String> > > args = x10aux::null; @@ -112,15 +112,15 @@ #endif x10aux::place_local::initialize(); - x10aux::DeserializationDispatcher::registerHandlers(); - - args = x10aux::convert_args(ac, av); - // Initialise enough state to make this 'main' thread look like a normal x10 thread // (e.g. make Thread::CurrentThread work properly). x10::runtime::Thread::_make(x10aux::null, x10::lang::String::Lit("thread-main")); x10aux::initialize_xrx(); + x10aux::DeserializationDispatcher::registerHandlers(); + + args = x10aux::convert_args(ac, av); + // Construct closure to invoke the static initialisers at place 0 x10aux::ref<x10::lang::VoidFun_0_0> init_closure = x10aux::ref<StaticInitClosure>(new (x10aux::alloc<x10::lang::VoidFun_0_0>(sizeof(x10aux::StaticInitClosure))) Modified: trunk/x10.runtime/src-cpp/x10aux/network.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/network.cc 2009-12-04 15:06:46 UTC (rev 12255) +++ trunk/x10.runtime/src-cpp/x10aux/network.cc 2009-12-04 16:42:35 UTC (rev 12256) @@ -14,8 +14,9 @@ #include <x10/lang/String.h> // for debug output #include <x10/lang/Closure.h> // for x10_runtime_Runtime__closure__6 -#include <x10/runtime/RID.h> +#include <x10/runtime/Runtime.h> + using namespace x10::lang; using namespace x10aux; @@ -110,13 +111,17 @@ void x10aux::registration_complete (void) { + x10aux::kernel_put = + x10rt_register_put_receiver(NULL, NULL, kernel_put_finder, kernel_put_notifier); x10rt_registration_complete(); + x10aux::x10rt_initialized = true; +} + +void x10aux::network_init (int ac, char **av) { + x10rt_init(ac, av); x10aux::here = x10rt_here(); x10aux::num_places = x10rt_nplaces(); x10aux::num_hosts = x10rt_nhosts(); - x10aux::kernel_put = - x10rt_register_put_receiver(NULL, NULL, kernel_put_finder, kernel_put_notifier); - x10aux::x10rt_initialized = true; } /* @@ -146,7 +151,7 @@ struct x10_runtime_Runtime__closure__6__hack : x10::lang::Closure { static const x10aux::serialization_id_t _serialization_id; x10aux::ref<x10::lang::VoidFun_0_0> body; - x10::runtime::RID rid; + x10aux::ref<x10::lang::Object> fs; }; void x10aux::run_at(x10aux::place p, x10aux::ref<Object> body) { @@ -191,7 +196,7 @@ x10aux::ref<x10::lang::Object> real_body = body_->body; - x10::runtime::RID rid = body_->rid; + x10aux::ref<x10::lang::Object> fs = body_->fs; serialization_id_t real_sid = real_body->_get_serialization_id(); msg_type real_id = DeserializationDispatcher::getMsgType(real_sid); @@ -200,7 +205,7 @@ <<ref<Object>(real_body)->toString()->c_str()<<" id "<<real_id <<" sid "<<real_sid<<" at GPU: "<<p); - x10::runtime::RID::_serialize(rid, buf, m); + buf.write(fs, m); real_body->_serialize_body(buf, m); unsigned long sz = buf.length(); @@ -266,7 +271,7 @@ { _X_(ANSI_X10RT<<"Receiving a kernel pre callback, deserialising..."<<ANSI_RESET); x10aux::deserialization_buffer buf(static_cast<char*>(p.msg)); - buf.read<x10::runtime::RID>(); + buf.read<x10aux::ref<x10::lang::Object> >(); // note: high bytes thrown away in implicit conversion serialization_id_t sid = x10aux::DeserializationDispatcher::getSerializationId(p.type); x10aux::CUDAPre pre = x10aux::DeserializationDispatcher::getCUDAPre(sid); @@ -280,9 +285,8 @@ _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)); - x10::runtime::RID rid = buf.read<x10::runtime::RID>(); + x10aux::ref<x10::lang::Object> fs = buf.read<x10aux::ref<x10::lang::Object> >(); x10aux::ref<x10::runtime::Runtime> rt = x10::runtime::Runtime::FMGL(runtime)->get(); - x10aux::ref<x10::lang::Object> fs = rt->FMGL(finishStates)->get(rid); (fs.operator->()->*(x10aux::findITable<x10::runtime::FinishState>(fs->_getITables())->notifyActivityCreation))(); (fs.operator->()->*(x10aux::findITable<x10::runtime::FinishState>(fs->_getITables())->notifyActivityTermination))(); } Modified: trunk/x10.runtime/src-cpp/x10aux/network.h =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/network.h 2009-12-04 15:06:46 UTC (rev 12255) +++ trunk/x10.runtime/src-cpp/x10aux/network.h 2009-12-04 16:42:35 UTC (rev 12256) @@ -60,6 +60,8 @@ void registration_complete (void); + void network_init (int ac, char **av); + inline void *msg_realloc(void *old, size_t old_sz, size_t new_sz) { return x10rt_msg_realloc(old, old_sz, new_sz); } Modified: trunk/x10.runtime/src-x10/x10/runtime/Activity.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/runtime/Activity.x10 2009-12-04 15:06:46 UTC (rev 12255) +++ trunk/x10.runtime/src-x10/x10/runtime/Activity.x10 2009-12-04 16:42:35 UTC (rev 12256) @@ -17,15 +17,12 @@ /** * the finish state governing the execution of this activity */ - val finishState:FinishState!; + val finishState:FinishState; + /** * safe to run pending jobs while waiting for a finish (temporary) */ val safe:Boolean; - /** - * whether to dealloc the body after executing it - */ - private val free:Boolean; /** * The user-specified code for this activity. @@ -42,30 +39,22 @@ * The finish states for the finish statements currently executed by this activity. * Lazily created. */ - var finishStack:Stack[FinishState!]!; + var finishStack:Stack[FinishState]!; /** * Create activity. */ - def this(body:()=>Void, finishState:FinishState!, safe:Boolean) { - this(body, finishState, safe, false); - } - - /** - * Create activity. - */ - def this(body:()=>Void, finishState:FinishState!, safe:Boolean, free:Boolean) { + def this(body:()=>Void, finishState:FinishState, safe:Boolean) { this.finishState = finishState; this.safe = safe; finishState.notifyActivityCreation(); this.body = body; - this.free = free; } /** * Create clocked activity. */ - def this(body:()=>Void, finishState:FinishState{self.at(here)}, clocks:ValRail[Clock], phases:ValRail[Int]) { + def this(body:()=>Void, finishState:FinishState, clocks:ValRail[Clock], phases:ValRail[Int]) { this(body, finishState, false); clockPhases = ClockPhases.make(clocks, phases); } @@ -81,11 +70,8 @@ } if (null != clockPhases) clockPhases.drop(); finishState.notifyActivityTermination(); - if (free) NativeRuntime.dealloc(body); + NativeRuntime.dealloc(body); } - - // [DC] The correct thing to do here is do toString() on the closure - // public def toString():String = name; } // vim:shiftwidth=4:tabstop=4:expandtab Modified: trunk/x10.runtime/src-x10/x10/runtime/FinishState.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/runtime/FinishState.x10 2009-12-04 15:06:46 UTC (rev 12255) +++ trunk/x10.runtime/src-x10/x10/runtime/FinishState.x10 2009-12-04 16:42:35 UTC (rev 12256) @@ -9,27 +9,28 @@ package x10.runtime; /** - * @author tardieu + * @author tardieu */ interface FinishState { /** - * An activity created under this finish has been created. Increment the count - * associated with the finish. + * An activity is spawned under this finish (called by spawner). */ - def notifySubActivitySpawn(place:Place):Void; + global def notifySubActivitySpawn(place:Place):Void; + /** + * An activity is created under this finish (called by spawnee). + */ + global def notifyActivityCreation():Void; + /** * An activity created under this finish has terminated. + * Also called be the activity governing the finish when it completes the finish body. */ - def notifyActivityTermination():Void; + global def notifyActivityTermination():Void; /** * Push an exception onto the stack. */ - def pushException(t:Throwable):Void; - - def rid(): RID; - - def notifyActivityCreation():Void; + global def pushException(t:Throwable):Void; } Modified: trunk/x10.runtime/src-x10/x10/runtime/FinishStates.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/runtime/FinishStates.x10 2009-12-04 15:06:46 UTC (rev 12255) +++ trunk/x10.runtime/src-x10/x10/runtime/FinishStates.x10 2009-12-04 16:42:35 UTC (rev 12256) @@ -8,60 +8,29 @@ package x10.runtime; +import x10.util.concurrent.atomic.AtomicInteger; import x10.util.HashMap; -import x10.util.concurrent.atomic.AtomicInteger; - -import x10.io.Console; - /** * @author tardieu */ -class FinishStates { +class FinishStates implements (RootFinish)=>RemoteFinish { - private val map = new HashMap[RID, FinishState!](); - private val count = new AtomicInteger(0); + private val map = new HashMap[RootFinish, RemoteFinish!](); private val lock = new Lock(); - def put(finishState:FinishState!):Void { - if (finishState.rid().id == -1) { - lock.lock(); - if (finishState.rid().id == -1) { - val rootFinish = finishState as RootFinish!; - rootFinish.rid = RID(here, count.getAndIncrement()); - map.put(rootFinish.rid, rootFinish); - } - lock.unlock(); - } - } - - def get(rid:RID):FinishState! { + public def apply(rootFinish:RootFinish):RemoteFinish { lock.lock(); - val finishState = map.getOrElse(rid, null); + val finishState = map.getOrElse(rootFinish, null); if (null != finishState) { lock.unlock(); return finishState; } - val remoteFinish = new RemoteFinish(rid); - map.put(rid, remoteFinish); + val remoteFinish = new RemoteFinish(); + map.put(rootFinish, remoteFinish); lock.unlock(); return remoteFinish; } - - def findRoot(rid:RID):RootFinish { - lock.lock(); - val finishState = map.getOrElse(rid, null); - lock.unlock(); - return finishState as RootFinish; - } - - def removeRoot(rootFinish:RootFinish!):Void{ - if (rootFinish.rid.id != -1) { - lock.lock(); - map.remove(rootFinish.rid); - lock.unlock(); - } - } } // vim:shiftwidth=4:tabstop=4:expandtab Deleted: trunk/x10.runtime/src-x10/x10/runtime/RID.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/runtime/RID.x10 2009-12-04 15:06:46 UTC (rev 12255) +++ trunk/x10.runtime/src-x10/x10/runtime/RID.x10 2009-12-04 16:42:35 UTC (rev 12256) @@ -1,9 +0,0 @@ -package x10.runtime; - -public final struct RID(place:Place, id:Int) { - public def this(place:Place, id:Int) = property(place, id); - - public def hashCode():Int = id; - public incomplete def toString():String; - -} Modified: trunk/x10.runtime/src-x10/x10/runtime/RemoteFinish.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/runtime/RemoteFinish.x10 2009-12-04 15:06:46 UTC (rev 12255) +++ trunk/x10.runtime/src-x10/x10/runtime/RemoteFinish.x10 2009-12-04 16:42:35 UTC (rev 12256) @@ -16,7 +16,7 @@ /** * @author tardieu */ -class RemoteFinish implements FinishState { +class RemoteFinish { /** * The Exception Stack is used to collect exceptions * issued when activities associated with this finish state terminate abruptly. @@ -38,14 +38,6 @@ private var count:AtomicInteger = new AtomicInteger(0); - private val rid:RID; - - def this(rid:RID) { - this.rid = rid; - } - - public def rid():RID = rid; - public def notifyActivityCreation():Void { count.getAndIncrement(); } @@ -65,7 +57,7 @@ /** * An activity created under this finish has terminated. */ - public def notifyActivityTermination():Void { + public def notifyActivityTermination(r:RootFinish):Void { lock.lock(); counts(here.id)--; if (count.decrementAndGet() > 0) { @@ -79,7 +71,6 @@ for (var i:Int=0; i<Place.MAX_PLACES; i++) counts(i) = 0; length = 1; lock.unlock(); - val r = rid; if (null != e) { val t:Throwable; if (e.size() == 1) { @@ -87,12 +78,12 @@ } else { t = new MultipleExceptions(e); } - val closure = () => { Runtime.findRoot(r).notify(m, t); NativeRuntime.deallocObject(m); }; - NativeRuntime.runAt(rid.place.id, closure); + val closure = () => { (r as RootFinish!).notify(m, t); NativeRuntime.deallocObject(m); }; + NativeRuntime.runAt(r.home.id, closure); NativeRuntime.dealloc(closure); } else { - val closure = () => { Runtime.findRoot(r).notify(m) ; NativeRuntime.deallocObject(m); }; - NativeRuntime.runAt(rid.place.id, closure); + val closure = () => { (r as RootFinish!).notify(m); NativeRuntime.deallocObject(m); }; + NativeRuntime.runAt(r.home.id, closure); NativeRuntime.dealloc(closure); } NativeRuntime.deallocObject(m); @@ -101,7 +92,6 @@ for (var i:Int=0; i<Place.MAX_PLACES; i++) counts(i) = 0; length = 1; lock.unlock(); - val r = rid; if (null != e) { val t:Throwable; if (e.size() == 1) { @@ -109,12 +99,12 @@ } else { t = new MultipleExceptions(e); } - val closure = () => { Runtime.findRoot(r).notify2(m, t); NativeRuntime.deallocObject(m); }; - NativeRuntime.runAt(rid.place.id, closure); + val closure = () => { (r as RootFinish!).notify2(m, t); NativeRuntime.deallocObject(m); }; + NativeRuntime.runAt(r.home.id, closure); NativeRuntime.dealloc(closure); } else { - val closure = () => { Runtime.findRoot(r).notify2(m) ; NativeRuntime.deallocObject(m); }; - NativeRuntime.runAt(rid.place.id, closure); + val closure = () => { (r as RootFinish!).notify2(m) ; NativeRuntime.deallocObject(m); }; + NativeRuntime.runAt(r.home.id, closure); NativeRuntime.dealloc(closure); } NativeRuntime.deallocObject(m); Modified: trunk/x10.runtime/src-x10/x10/runtime/RootFinish.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/runtime/RootFinish.x10 2009-12-04 15:06:46 UTC (rev 12255) +++ trunk/x10.runtime/src-x10/x10/runtime/RootFinish.x10 2009-12-04 16:42:35 UTC (rev 12256) @@ -14,27 +14,45 @@ /** * @author tardieu */ -class RootFinish extends Latch implements FinishState { +class RootFinish extends Latch implements FinishState, Mortal { private val counts:Rail[Int]!; - private var exceptions:Stack[Throwable]!; - var rid:RID = RID(here, -1); - - public def rid():RID = rid; - - public def notifyActivityCreation():Void {} - def this() { val c = Rail.make[Int](Place.MAX_PLACES, (Int)=>0); c(here.id) = 1; counts = c; } + + private def notifySubActivitySpawnLocal(place:Place):Void { + lock(); + counts(place.parent().id)++; + unlock(); + } + private def notifyActivityTerminationLocal():Void { + lock(); + counts(here.id)--; + for(var i:Int=0; i<Place.MAX_PLACES; i++) { + if (counts(i) != 0) { + unlock(); + return; + } + } + release(); + unlock(); + } + + private def pushExceptionLocal(t:Throwable):Void { + lock(); + if (null == exceptions) exceptions = new Stack[Throwable](); + exceptions.push(t); + unlock(); + } + def waitForFinish(safe:Boolean):Void { if (!NativeRuntime.NO_STEALS && safe) Runtime.join(this); await(); - Runtime.removeRoot(this); if (null != exceptions) { if (exceptions.size() == 1) { val t = exceptions.peek(); @@ -76,38 +94,40 @@ } def notify(rail:ValRail[Int]!, t:Throwable):Void { - pushException(t); + pushExceptionLocal(t); notify(rail); } def notify2(rail:ValRail[Pair[Int,Int]]!, t:Throwable):Void { - pushException(t); + pushExceptionLocal(t); notify2(rail); } - public def notifySubActivitySpawn(place:Place):Void { - lock(); - counts(place.parent().id)++; - unlock(); + public global def notifySubActivitySpawn(place:Place):Void { + if (here.equals(home)) { + (this as RootFinish!).notifySubActivitySpawnLocal(place); + } else { + Runtime.proxy(this).notifySubActivitySpawn(place); + } } + + public global def notifyActivityCreation():Void { + if (!here.equals(home)) Runtime.proxy(this).notifyActivityCreation(); + } - public def notifyActivityTermination():Void { - lock(); - counts(here.id)--; - for(var i:Int=0; i<Place.MAX_PLACES; i++) { - if (counts(i) != 0) { - unlock(); - return; - } - } - release(); - unlock(); + public global def notifyActivityTermination():Void { + if (here.equals(home)) { + (this as RootFinish!).notifyActivityTerminationLocal(); + } else { + Runtime.proxy(this).notifyActivityTermination(this); + } } - public def pushException(t:Throwable):Void { - lock(); - if (null == exceptions) exceptions = new Stack[Throwable](); - exceptions.push(t); - unlock(); + public global def pushException(t:Throwable):Void { + if (here.equals(home)) { + (this as RootFinish!).pushExceptionLocal(t); + } else { + Runtime.proxy(this).pushException(t); + } } } Modified: trunk/x10.runtime/src-x10/x10/runtime/Runtime.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/runtime/Runtime.x10 2009-12-04 15:06:46 UTC (rev 12255) +++ trunk/x10.runtime/src-x10/x10/runtime/Runtime.x10 2009-12-04 16:42:35 UTC (rev 12256) @@ -45,12 +45,9 @@ */ private const runtime = PlaceLocalHandle.createHandle[Runtime](); + static def proxy(rootFinish:RootFinish) = runtime().finishStates(rootFinish); + /** - * Return the current runtime - */ - //private static def runtime() = runtime.get() as Runtime!; - - /** * Return the current worker */ private static def worker():Worker! = Thread.currentThread().worker(); @@ -109,68 +106,49 @@ runtime().pool.release(); } - static def findRoot(rid:RID) = runtime().finishStates.findRoot(rid) as RootFinish!; - - static def removeRoot(rootFinish:RootFinish!) { - runtime().finishStates.removeRoot(rootFinish); - } - - // async -> at statement -> at expression -> future // do not introduce cycles!!! /** * Run async */ - public static def runAsync(place:Place, clocks:ValRail[Clock], body:()=>Void, Boolean):Void { + public static def runAsync(place:Place, clocks:ValRail[Clock], body:()=>Void):Void { val state = currentState(); val phases = clockPhases().register(clocks); state.notifySubActivitySpawn(place); if (place.id == Thread.currentThread().locInt()) { execute(new Activity(body, state, clocks, phases)); } else { - runtime().finishStates.put(state); - val rid = state.rid(); - val c = ()=>execute(new Activity(body, runtime().finishStates.get(rid), clocks, phases)); + val c = ()=>execute(new Activity(body, state, clocks, phases)); NativeRuntime.runAt(place.id, c); } } - public static def runAsync(place:Place, body:()=>Void, free:Boolean):Void { + public static def runAsync(place:Place, body:()=>Void):Void { val state = currentState(); state.notifySubActivitySpawn(place); val ok = safe(); if (place.id == Thread.currentThread().locInt()) { - execute(new Activity(body, state, ok, free)); + execute(new Activity(body, state, ok)); } else { - runtime().finishStates.put(state); - val rid = state.rid(); var closure:()=>Void; // val closure = -// ok ? (free ? ()=>execute(new Activity(body, runtime().finishStates.get(rid), true, true)) -// : ()=>execute(new Activity(body, runtime().finishStates.get(rid), true, false))) -// : (free ? ()=>execute(new Activity(body, runtime().finishStates.get(rid), false, true)) -// : ()=>execute(new Activity(body, runtime().finishStates.get(rid), false, false))); +// ok ? (free ? ()=>execute(new Activity(body, state, true, true)) +// : ()=>execute(new Activity(body, state, true, false))) +// : (free ? ()=>execute(new Activity(body, state, false, true)) +// : ()=>execute(new Activity(body, state, false, false))); // Workaround for XTENLANG_614 if (ok) { - if (free) { - closure = ()=>execute(new Activity(body, runtime().finishStates.get(rid), true, true)); - } else { - closure = ()=>execute(new Activity(body, runtime().finishStates.get(rid), true, false)); - } + closure = ()=>execute(new Activity(body, state, true)); } else { - if (free) { - closure = ()=>execute(new Activity(body, runtime().finishStates.get(rid), false, true)); - } else { - closure = ()=>execute(new Activity(body, runtime().finishStates.get(rid), false, false)); - } + closure = ()=>execute(new Activity(body, state, false)); } NativeRuntime.runAt(place.id, closure); NativeRuntime.dealloc(closure); } } - public static def runAsync(clocks:ValRail[Clock], body:()=>Void, Boolean):Void { + public static def runAsync(clocks:ValRail[Clock], body:()=>Void):Void { val state = currentState(); val phases = clockPhases().register(clocks); state.notifySubActivitySpawn(here); @@ -178,13 +156,9 @@ } public static def runAsync(body:()=>Void):Void { - runAsync(body, false); - } - - public static def runAsync(body:()=>Void, free:Boolean):Void { val state = currentState(); state.notifySubActivitySpawn(here); - execute(new Activity(body, state, safe(), free)); + execute(new Activity(body, state, safe())); } /** @@ -192,10 +166,10 @@ */ public static def runAt(place:Place, body:()=>Void):Void { //avoid creating another closure - //finish async (place) body(); - startFinish(); - runAsync(place, body, false); - stopFinish(); + finish async (place) body(); + //startFinish(); + //runAsync(place, body); + //stopFinish(); } /** @@ -324,11 +298,11 @@ /** * Return the innermost finish state for the current activity */ - private static def currentState(): FinishState! { + private static def currentState():RootFinish { val a = activity(); if (null == a.finishStack || a.finishStack.isEmpty()) - return a.finishState; - return a.finishStack.peek(); + return a.finishState as RootFinish; + return a.finishStack.peek() as RootFinish; } /** @@ -338,7 +312,7 @@ public static def startFinish():Void { val a = activity(); if (null == a.finishStack) - a.finishStack = new Stack[FinishState!](); + a.finishStack = new Stack[FinishState](); a.finishStack.push(new RootFinish()); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ipe...@us...> - 2009-12-13 23:04:34
|
Revision: 12299 http://x10.svn.sourceforge.net/x10/?rev=12299&view=rev Author: ipeshansky Date: 2009-12-13 23:04:20 +0000 (Sun, 13 Dec 2009) Log Message: ----------- Implement serialization of cyclic graphs (fixes XTENLANG-695). Make addr_map a field of serialization_buffer and deserialization_buffer and avoid passing it as a parameter. Modified Paths: -------------- trunk/x10.compiler/src/x10cpp/visit/Emitter.java trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java trunk/x10.runtime/src-cpp/x10/io/FileReader__FileInputStream.cc trunk/x10.runtime/src-cpp/x10/io/FileReader__FileInputStream.h trunk/x10.runtime/src-cpp/x10/io/FileWriter__FileOutputStream.cc trunk/x10.runtime/src-cpp/x10/io/FileWriter__FileOutputStream.h trunk/x10.runtime/src-cpp/x10/io/File__NativeFile.cc trunk/x10.runtime/src-cpp/x10/io/File__NativeFile.h trunk/x10.runtime/src-cpp/x10/io/InputStreamReader__InputStream.cc trunk/x10.runtime/src-cpp/x10/io/InputStreamReader__InputStream.h trunk/x10.runtime/src-cpp/x10/io/OutputStreamWriter__OutputStream.cc trunk/x10.runtime/src-cpp/x10/io/OutputStreamWriter__OutputStream.h trunk/x10.runtime/src-cpp/x10/lang/Closure.cc trunk/x10.runtime/src-cpp/x10/lang/Closure.h trunk/x10.runtime/src-cpp/x10/lang/Object.cc trunk/x10.runtime/src-cpp/x10/lang/Object.h trunk/x10.runtime/src-cpp/x10/lang/Rail.cc trunk/x10.runtime/src-cpp/x10/lang/Rail.h trunk/x10.runtime/src-cpp/x10/lang/Ref.cc trunk/x10.runtime/src-cpp/x10/lang/Ref.h trunk/x10.runtime/src-cpp/x10/lang/String.cc trunk/x10.runtime/src-cpp/x10/lang/String.h trunk/x10.runtime/src-cpp/x10/lang/Struct.cc trunk/x10.runtime/src-cpp/x10/lang/Struct.struct_h trunk/x10.runtime/src-cpp/x10/lang/Throwable.cc trunk/x10.runtime/src-cpp/x10/lang/Throwable.h trunk/x10.runtime/src-cpp/x10/lang/ValRail.h trunk/x10.runtime/src-cpp/x10/runtime/Deque.cc trunk/x10.runtime/src-cpp/x10/runtime/Deque.h trunk/x10.runtime/src-cpp/x10/runtime/PlaceLocalHandle.struct_h trunk/x10.runtime/src-cpp/x10/runtime/Thread.cc trunk/x10.runtime/src-cpp/x10/runtime/Thread.h trunk/x10.runtime/src-cpp/x10/util/GrowableRail.h trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicBoolean.cc trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicBoolean.h trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicInteger.cc trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicInteger.h trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicLong.cc trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicLong.h trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicReference.h trunk/x10.runtime/src-cpp/x10aux/fun_utils.h trunk/x10.runtime/src-cpp/x10aux/network.cc trunk/x10.runtime/src-cpp/x10aux/serialization.cc trunk/x10.runtime/src-cpp/x10aux/serialization.h trunk/x10.runtime/src-cpp/x10aux/static_init.h Modified: trunk/x10.compiler/src/x10cpp/visit/Emitter.java =================================================================== --- trunk/x10.compiler/src/x10cpp/visit/Emitter.java 2009-12-13 22:44:42 UTC (rev 12298) +++ trunk/x10.compiler/src/x10cpp/visit/Emitter.java 2009-12-13 23:04:20 UTC (rev 12299) @@ -928,17 +928,15 @@ h.write("public: "); h.write("static void "+SERIALIZE_METHOD+"("); h.begin(0); h.write(make_ref(klass)+" this_,"); h.newline(); - h.write(SERIALIZATION_BUFFER+"& buf,"); h.newline(); - h.write("x10aux::addr_map& m);"); h.end(); + h.write(SERIALIZATION_BUFFER+"& buf);"); h.end(); h.newline(); h.forceNewline(); printTemplateSignature(ct.typeArguments(), w); w.write("void "+klass+"::"+SERIALIZE_METHOD+"("); w.begin(0); w.write(make_ref(klass)+" this_,"); w.newline(); - w.write(SERIALIZATION_BUFFER+"& buf,"); w.newline(); - w.write("x10aux::addr_map& m) {"); w.end(); w.newline(4); w.begin(0); - w.write( "_serialize_reference(this_, buf, m);"); w.newline(); + w.write(SERIALIZATION_BUFFER+"& buf) {"); w.end(); w.newline(4); w.begin(0); + w.write( "_serialize_reference(this_, buf);"); w.newline(); w.write( "if (this_ != x10aux::null) {"); w.newline(4); w.begin(0); - w.write( "this_->_serialize_body(buf, m);"); w.end(); w.newline(); + w.write( "this_->_serialize_body(buf);"); w.end(); w.newline(); w.write( "}"); w.end(); w.newline(); w.write("}"); w.newline(); w.forceNewline(); @@ -961,16 +959,16 @@ h.write("public: "); if (!type.flags().isFinal()) h.write("virtual "); - h.write("void "+SERIALIZE_BODY_METHOD+"("+SERIALIZATION_BUFFER+"& buf, x10aux::addr_map& m);"); + h.write("void "+SERIALIZE_BODY_METHOD+"("+SERIALIZATION_BUFFER+"& buf);"); h.newline(0); h.forceNewline(); printTemplateSignature(ct.typeArguments(), w); w.write("void "+klass+"::"+SERIALIZE_BODY_METHOD+ - "("+SERIALIZATION_BUFFER+"& buf, x10aux::addr_map& m) {"); + "("+SERIALIZATION_BUFFER+"& buf) {"); w.newline(4); w.begin(0); Type parent = type.superClass(); if (parent != null && parent.isClass()) { - w.write(translateType(parent)+"::"+SERIALIZE_BODY_METHOD+"(buf, m);"); + w.write(translateType(parent)+"::"+SERIALIZE_BODY_METHOD+"(buf);"); w.newline(); } for (int i = 0; i < type.fields().size(); i++) { @@ -982,7 +980,7 @@ if (!X10Flags.toX10Flags(f.flags()).isGlobal()) // only serialize global fields of classes continue; String fieldName = mangled_field_name(f.name().toString()); - w.write("buf.write(this->"+fieldName+",m);"); w.newline(); + w.write("buf.write(this->"+fieldName+");"); w.newline(); } w.end(); w.newline(); w.write("}"); @@ -1069,15 +1067,15 @@ sh.forceNewline(); // _serialize() - sh.write("static void "+SERIALIZE_METHOD+"("+klass+" this_, "+SERIALIZATION_BUFFER+"& buf, x10aux::addr_map& m);"); + sh.write("static void "+SERIALIZE_METHOD+"("+klass+" this_, "+SERIALIZATION_BUFFER+"& buf);"); sh.newline(0); sh.forceNewline(); printTemplateSignature(ct.typeArguments(), w); - w.write("void "+klass+"::"+SERIALIZE_METHOD+"("+klass+" this_, "+SERIALIZATION_BUFFER+"& buf, x10aux::addr_map& m) {"); + w.write("void "+klass+"::"+SERIALIZE_METHOD+"("+klass+" this_, "+SERIALIZATION_BUFFER+"& buf) {"); w.newline(4); w.begin(0); Type parent = type.superClass(); if (parent != null) { - w.write(translateType(parent)+"::"+SERIALIZE_METHOD+"(this_, buf, m);"); + w.write(translateType(parent)+"::"+SERIALIZE_METHOD+"(this_, buf);"); w.newline(); } for (int i = 0; i < type.fields().size(); i++) { @@ -1087,7 +1085,7 @@ if (f.flags().isStatic() || query.isSyntheticField(f.name().toString())) continue; String fieldName = mangled_field_name(f.name().toString()); - w.write("buf.write(this_->"+fieldName+",m);"); w.newline(); + w.write("buf.write(this_->"+fieldName+");"); w.newline(); } w.end(); w.newline(); w.write("}"); Modified: trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java =================================================================== --- trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java 2009-12-13 22:44:42 UTC (rev 12298) +++ trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java 2009-12-13 23:04:20 UTC (rev 12299) @@ -1166,9 +1166,8 @@ /* Serialization redirection methods */ h.write("static void "+SERIALIZE_METHOD+"("); h.begin(0); h.write(Emitter.translateType(currentClass, true)+" this_,"); h.newline(); - h.write(SERIALIZATION_BUFFER+"& buf,"); h.newline(); - h.write("x10aux::addr_map& m) {"); h.end(); h.newline(4); h.begin(0); - h.write("x10::lang::Object::"+SERIALIZE_METHOD+"(this_, buf, m);"); h.end(); h.newline(); + h.write(SERIALIZATION_BUFFER+"& buf) {"); h.end(); h.newline(4); h.begin(0); + h.write("x10::lang::Object::"+SERIALIZE_METHOD+"(this_, buf);"); h.end(); h.newline(); h.write("}"); h.newline(); h.forceNewline(); h.write("public: template<class __T> static "); @@ -4007,7 +4006,7 @@ } protected void generateClosureSerializationFunctions(X10CPPContext_c c, String cnamet, StreamWrapper inc, Block block) { - inc.write("void "+SERIALIZE_BODY_METHOD+"("+SERIALIZATION_BUFFER+" &buf, x10aux::addr_map& m) {"); + inc.write("void "+SERIALIZE_BODY_METHOD+"("+SERIALIZATION_BUFFER+" &buf) {"); inc.newline(4); inc.begin(0); // FIXME: factor out this loop for (int i = 0; i < c.variables.size(); i++) { @@ -4017,7 +4016,7 @@ if (name.equals(THIS)) name = SAVED_THIS; else name = mangled_non_method_name(name); - inc.write("buf.write(this->" + name + ", m);"); + inc.write("buf.write(this->" + name + ");"); } inc.end(); inc.newline(); inc.write("}"); inc.newline(); inc.forceNewline(); @@ -4547,10 +4546,10 @@ // otherwise overloads don't seem to work properly sw.write("("+make_ref(type)+")"); sw.write("x10aux::alloc_rail<"); - emitter.printType(T, sw); + sw.write(Emitter.translateType(T, true)); sw.write(","); sw.allowBreak(0, " "); - sw.write(Emitter.translateType(c.type())); + sw.write(type); sw.write(" >("+c.arguments().size()); for (Expr e : c.arguments()) { sw.write(","); Modified: trunk/x10.runtime/src-cpp/x10/io/FileReader__FileInputStream.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/io/FileReader__FileInputStream.cc 2009-12-13 22:44:42 UTC (rev 12298) +++ trunk/x10.runtime/src-cpp/x10/io/FileReader__FileInputStream.cc 2009-12-13 23:04:20 UTC (rev 12299) @@ -17,14 +17,14 @@ const x10aux::serialization_id_t FileReader__FileInputStream::_serialization_id = x10aux::DeserializationDispatcher::addDeserializer(FileReader__FileInputStream::_deserializer<x10::lang::Ref>); -void FileReader__FileInputStream::_serialize_body(x10aux::serialization_buffer& buf, x10aux::addr_map& m) { - InputStreamReader__InputStream::_serialize_body(buf, m); +void FileReader__FileInputStream::_serialize_body(x10aux::serialization_buffer& buf) { + InputStreamReader__InputStream::_serialize_body(buf); // This class simply has no global state. // TODO: attempting to serialize _inputStream is nonsensical. // The old 1.7 definition of this class simply didn't work either, // it just silently didn't serialize the FILEPtrInputSteam field. // assert(false); - // buf.write(this->_inputStream,m); + // buf.write(this->_inputStream); } void FileReader__FileInputStream::_deserialize_body(x10aux::deserialization_buffer& buf) { Modified: trunk/x10.runtime/src-cpp/x10/io/FileReader__FileInputStream.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/io/FileReader__FileInputStream.h 2009-12-13 22:44:42 UTC (rev 12298) +++ trunk/x10.runtime/src-cpp/x10/io/FileReader__FileInputStream.h 2009-12-13 23:04:20 UTC (rev 12299) @@ -48,7 +48,7 @@ virtual x10aux::serialization_id_t _get_serialization_id() { return _serialization_id; } - virtual void _serialize_body(x10aux::serialization_buffer& buf, x10aux::addr_map& m); + virtual void _serialize_body(x10aux::serialization_buffer& buf); template<class __T> static x10aux::ref<__T> _deserializer(x10aux::deserialization_buffer& buf); void _deserialize_body(x10aux::deserialization_buffer& buf); // No specialized serialization methods - not optimizing this final class Modified: trunk/x10.runtime/src-cpp/x10/io/FileWriter__FileOutputStream.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/io/FileWriter__FileOutputStream.cc 2009-12-13 22:44:42 UTC (rev 12298) +++ trunk/x10.runtime/src-cpp/x10/io/FileWriter__FileOutputStream.cc 2009-12-13 23:04:20 UTC (rev 12299) @@ -20,14 +20,14 @@ const x10aux::serialization_id_t FileWriter__FileOutputStream::_serialization_id = x10aux::DeserializationDispatcher::addDeserializer(FileWriter__FileOutputStream::_deserializer<x10::lang::Ref>); -void FileWriter__FileOutputStream::_serialize_body(x10aux::serialization_buffer& buf, x10aux::addr_map& m) { - OutputStreamWriter__OutputStream::_serialize_body(buf, m); +void FileWriter__FileOutputStream::_serialize_body(x10aux::serialization_buffer& buf) { + OutputStreamWriter__OutputStream::_serialize_body(buf); // This class simply has no global state. // TODO: attempting to serialize _outputStream is nonsensical. // The old 1.7 definition of this class simply didn't work either, // it just silently didn't serialize the FILEPtrInputSteam field. // assert(false); - // buf.write(this->_outputStream,m); + // buf.write(this->_outputStream); } void FileWriter__FileOutputStream::_deserialize_body(x10aux::deserialization_buffer& buf) { Modified: trunk/x10.runtime/src-cpp/x10/io/FileWriter__FileOutputStream.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/io/FileWriter__FileOutputStream.h 2009-12-13 22:44:42 UTC (rev 12298) +++ trunk/x10.runtime/src-cpp/x10/io/FileWriter__FileOutputStream.h 2009-12-13 23:04:20 UTC (rev 12299) @@ -52,7 +52,7 @@ virtual x10aux::serialization_id_t _get_serialization_id() { return _serialization_id; } - virtual void _serialize_body(x10aux::serialization_buffer& buf, x10aux::addr_map& m); + virtual void _serialize_body(x10aux::serialization_buffer& buf); template<class __T> static x10aux::ref<__T> _deserializer(x10aux::deserialization_buffer& buf); void _deserialize_body(x10aux::deserialization_buffer& buf); // No specialized serialization methods - not optimizing this final class Modified: trunk/x10.runtime/src-cpp/x10/io/File__NativeFile.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/io/File__NativeFile.cc 2009-12-13 22:44:42 UTC (rev 12298) +++ trunk/x10.runtime/src-cpp/x10/io/File__NativeFile.cc 2009-12-13 23:04:20 UTC (rev 12299) @@ -20,8 +20,8 @@ return (new (x10aux::alloc<File__NativeFile>()) File__NativeFile())->_constructor(s); } -void File__NativeFile::_serialize_body(serialization_buffer &buf, addr_map &m) { - this->Ref::_serialize_body(buf, m); +void File__NativeFile::_serialize_body(serialization_buffer &buf) { + this->Ref::_serialize_body(buf); } void File__NativeFile::_deserialize_body(deserialization_buffer& buf) { Modified: trunk/x10.runtime/src-cpp/x10/io/File__NativeFile.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/io/File__NativeFile.h 2009-12-13 22:44:42 UTC (rev 12298) +++ trunk/x10.runtime/src-cpp/x10/io/File__NativeFile.h 2009-12-13 23:04:20 UTC (rev 12299) @@ -37,7 +37,7 @@ virtual x10aux::serialization_id_t _get_serialization_id() { return _serialization_id; }; - virtual void _serialize_body(x10aux::serialization_buffer &buf, x10aux::addr_map &m); + virtual void _serialize_body(x10aux::serialization_buffer &buf); template<class T> static x10aux::ref<T> _deserializer(x10aux::deserialization_buffer &buf); Modified: trunk/x10.runtime/src-cpp/x10/io/InputStreamReader__InputStream.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/io/InputStreamReader__InputStream.cc 2009-12-13 22:44:42 UTC (rev 12298) +++ trunk/x10.runtime/src-cpp/x10/io/InputStreamReader__InputStream.cc 2009-12-13 23:04:20 UTC (rev 12299) @@ -25,8 +25,8 @@ return i; } -void InputStreamReader__InputStream::_serialize_body(x10aux::serialization_buffer& buf, x10aux::addr_map& m) { - x10::lang::Ref::_serialize_body(buf, m); +void InputStreamReader__InputStream::_serialize_body(x10aux::serialization_buffer& buf) { + x10::lang::Ref::_serialize_body(buf); } void InputStreamReader__InputStream::_deserialize_body(x10aux::deserialization_buffer& buf) { Modified: trunk/x10.runtime/src-cpp/x10/io/InputStreamReader__InputStream.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/io/InputStreamReader__InputStream.h 2009-12-13 22:44:42 UTC (rev 12298) +++ trunk/x10.runtime/src-cpp/x10/io/InputStreamReader__InputStream.h 2009-12-13 23:04:20 UTC (rev 12299) @@ -48,7 +48,7 @@ virtual x10_boolean markSupported() { return false; } // Serialization - virtual void _serialize_body(x10aux::serialization_buffer& buf, x10aux::addr_map& m); + virtual void _serialize_body(x10aux::serialization_buffer& buf); void _deserialize_body(x10aux::deserialization_buffer& buf); }; } Modified: trunk/x10.runtime/src-cpp/x10/io/OutputStreamWriter__OutputStream.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/io/OutputStreamWriter__OutputStream.cc 2009-12-13 22:44:42 UTC (rev 12298) +++ trunk/x10.runtime/src-cpp/x10/io/OutputStreamWriter__OutputStream.cc 2009-12-13 23:04:20 UTC (rev 12299) @@ -35,8 +35,8 @@ this->write((x10_int) b->operator[](off + i)); } -void OutputStreamWriter__OutputStream::_serialize_body(x10aux::serialization_buffer& buf, x10aux::addr_map& m) { - x10::lang::Ref::_serialize_body(buf, m); +void OutputStreamWriter__OutputStream::_serialize_body(x10aux::serialization_buffer& buf) { + x10::lang::Ref::_serialize_body(buf); } void OutputStreamWriter__OutputStream::_deserialize_body(x10aux::deserialization_buffer& buf) { Modified: trunk/x10.runtime/src-cpp/x10/io/OutputStreamWriter__OutputStream.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/io/OutputStreamWriter__OutputStream.h 2009-12-13 22:44:42 UTC (rev 12298) +++ trunk/x10.runtime/src-cpp/x10/io/OutputStreamWriter__OutputStream.h 2009-12-13 23:04:20 UTC (rev 12299) @@ -33,7 +33,7 @@ virtual void write(x10aux::ref<x10::lang::ValRail<x10_byte> > b, x10_int off, x10_int len); // Serialization - virtual void _serialize_body(x10aux::serialization_buffer& buf, x10aux::addr_map& m); + virtual void _serialize_body(x10aux::serialization_buffer& buf); void _deserialize_body(x10aux::deserialization_buffer& buf); }; } Modified: trunk/x10.runtime/src-cpp/x10/lang/Closure.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Closure.cc 2009-12-13 22:44:42 UTC (rev 12298) +++ trunk/x10.runtime/src-cpp/x10/lang/Closure.cc 2009-12-13 23:04:20 UTC (rev 12299) @@ -13,14 +13,13 @@ DeserializationDispatcher::addDeserializer(Closure::_deserializer<Ref>); void Closure::_serialize(x10aux::ref<Closure> this_, - x10aux::serialization_buffer &buf, - x10aux::addr_map &m) + x10aux::serialization_buffer &buf) { x10aux::serialization_id_t id = this_->_get_serialization_id(); _S_("Serializing a "<<ANSI_SER<<ANSI_BOLD<<"value id "<<id<<ANSI_RESET<<" to buf: "<<&buf); - buf.write(id,m); + buf.write(id); _S_("Serializing the "<<ANSI_SER<<"value body"<<ANSI_RESET<<" to buf: "<<&buf); - this_->_serialize_body(buf, m); + this_->_serialize_body(buf); } x10aux::ref<Closure> Closure::_make() { Modified: trunk/x10.runtime/src-cpp/x10/lang/Closure.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Closure.h 2009-12-13 22:44:42 UTC (rev 12298) +++ trunk/x10.runtime/src-cpp/x10/lang/Closure.h 2009-12-13 23:04:20 UTC (rev 12299) @@ -29,7 +29,7 @@ virtual x10aux::serialization_id_t _get_serialization_id() { return _serialization_id; }; - virtual void _serialize_body(x10aux::serialization_buffer &, x10aux::addr_map &) { + virtual void _serialize_body(x10aux::serialization_buffer &) { // there are no fields } @@ -40,8 +40,7 @@ } static void _serialize(x10aux::ref<Closure> this_, - x10aux::serialization_buffer &buf, - x10aux::addr_map &m); + x10aux::serialization_buffer &buf); template<class T> static x10aux::ref<T> _deserialize(x10aux::deserialization_buffer &buf); Modified: trunk/x10.runtime/src-cpp/x10/lang/Object.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Object.cc 2009-12-13 22:44:42 UTC (rev 12298) +++ trunk/x10.runtime/src-cpp/x10/lang/Object.cc 2009-12-13 23:04:20 UTC (rev 12299) @@ -7,23 +7,21 @@ using namespace x10::lang; using namespace x10aux; -void Object::_serialize_interface(x10aux::serialization_buffer &buf, - x10aux::addr_map &m) +void Object::_serialize_interface(x10aux::serialization_buffer &buf) { _S_("Serializing the "<<ANSI_SER<<"interface body"<<ANSI_RESET<<" to buf: "<<&buf); - this->_serialize_body(buf, m); + this->_serialize_body(buf); } void Object::_serialize(x10aux::ref<Object> this_, - x10aux::serialization_buffer &buf, - x10aux::addr_map &m) + x10aux::serialization_buffer &buf) { bool isNull = this_.isNull(); x10aux::serialization_id_t id = isNull ? 0 : this_->_get_interface_serialization_id(); _S_("Serializing an "<<ANSI_SER<<ANSI_BOLD<<"interface id "<<id<<ANSI_RESET<<" to buf: "<<&buf); - buf.write(id, m); + buf.write(id); if (!isNull) { - this_->_serialize_interface(buf, m); + this_->_serialize_interface(buf); } } Modified: trunk/x10.runtime/src-cpp/x10/lang/Object.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Object.h 2009-12-13 22:44:42 UTC (rev 12298) +++ trunk/x10.runtime/src-cpp/x10/lang/Object.h 2009-12-13 23:04:20 UTC (rev 12299) @@ -33,7 +33,7 @@ virtual x10aux::serialization_id_t _get_serialization_id() = 0; - virtual void _serialize_body(x10aux::serialization_buffer &, x10aux::addr_map &) = 0; + virtual void _serialize_body(x10aux::serialization_buffer &) = 0; // This pair of functions should be overridden to not emit/extract the id in subclasses // that satisfy the following property: @@ -49,8 +49,7 @@ // Note these functions are static as we want to dispatch on the static type. static void _serialize(x10aux::ref<Object> this_, - x10aux::serialization_buffer &buf, - x10aux::addr_map &m); + x10aux::serialization_buffer &buf); // Should only be overridden in Ref virtual x10aux::serialization_id_t _get_interface_serialization_id() { @@ -58,7 +57,7 @@ return _get_serialization_id(); } // Should only be overridden in Ref - virtual void _serialize_interface(x10aux::serialization_buffer &buf, x10aux::addr_map &m); + virtual void _serialize_interface(x10aux::serialization_buffer &buf); template<class T> static x10aux::ref<T> _deserialize(x10aux::deserialization_buffer &buf); Modified: trunk/x10.runtime/src-cpp/x10/lang/Rail.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Rail.cc 2009-12-13 22:44:42 UTC (rev 12298) +++ trunk/x10.runtime/src-cpp/x10/lang/Rail.cc 2009-12-13 23:04:20 UTC (rev 12299) @@ -36,25 +36,24 @@ (fs.operator->()->*(findITable<x10::runtime::FinishState>(fs->_getITables())->notifyActivityTermination))(); } -void x10::lang::Rail_serialize_finish_state (place dst, serialization_buffer &buf, addr_map &m) +void x10::lang::Rail_serialize_finish_state (place dst, serialization_buffer &buf) { // dst is the place where the finish update will occur, i.e. where the notifier runs dst = x10aux::parent(dst); ref<x10::runtime::Runtime> rt = x10::runtime::Runtime::FMGL(runtime)->get(); ref<Object> fs = rt->currentState(); (fs.operator->()->*(findITable<x10::runtime::FinishState>(fs->_getITables())->notifySubActivitySpawn))(x10::lang::Place_methods::_make(dst)); - buf.write(fs, m); + buf.write(fs); } void x10::lang::Rail_serializeAndSendPut(Place dst_place_, ref<Object> df, x10_ubyte code, serialization_id_t _id, void* data, size_t size) { serialization_buffer buf; - addr_map m; buf.realloc_func = x10aux::put_realloc; - buf.write(code, m); - buf.write(df, m); - Rail_serialize_finish_state (dst_place_.FMGL(id), buf, m); + buf.write(code); + buf.write(df); + Rail_serialize_finish_state (dst_place_.FMGL(id), buf); x10aux::send_put(dst_place_.FMGL(id), _id, buf, data, size); } @@ -62,11 +61,10 @@ serialization_id_t _id, void* data, size_t size) { serialization_buffer buf; - addr_map m; buf.realloc_func = x10aux::put_realloc; - buf.write(code, m); - buf.write(df, m); - Rail_serialize_finish_state (x10aux::here, buf, m); + buf.write(code); + buf.write(df); + Rail_serialize_finish_state (x10aux::here, buf); x10aux::send_get(src_place_.FMGL(id), _id, buf, data, size); } Modified: trunk/x10.runtime/src-cpp/x10/lang/Rail.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Rail.h 2009-12-13 22:44:42 UTC (rev 12298) +++ trunk/x10.runtime/src-cpp/x10/lang/Rail.h 2009-12-13 23:04:20 UTC (rev 12299) @@ -100,10 +100,9 @@ virtual x10aux::serialization_id_t _get_serialization_id() { return _serialization_id; }; static void _serialize(R this_, - x10aux::serialization_buffer &buf, - x10aux::addr_map &m); + x10aux::serialization_buffer &buf); - void _serialize_body(x10aux::serialization_buffer &buf, x10aux::addr_map &m); + void _serialize_body(x10aux::serialization_buffer &buf); void _deserialize_body(x10aux::deserialization_buffer &buf); @@ -171,8 +170,7 @@ void Rail_notifyEnclosingFinish(x10aux::deserialization_buffer& buf); void Rail_serialize_finish_state(x10aux::place dst_place, - x10aux::serialization_buffer& buf, - x10aux::addr_map &m); + x10aux::serialization_buffer& buf); void Rail_serializeAndSendPut(x10::lang::Place dst_place_, x10aux::ref<x10::lang::Object> df, x10_ubyte code, x10aux::serialization_id_t _id, @@ -469,13 +467,12 @@ return; } x10aux::serialization_buffer buf; - x10aux::addr_map m; buf.realloc_func = x10aux::put_realloc; x10_ubyte code = 0; - buf.write(code, m); - buf.write(dst, m); - buf.write(dst_off, m); - Rail_serialize_finish_state(dst_place, buf, m); + buf.write(code); + buf.write(dst); + buf.write(dst_off); + Rail_serialize_finish_state(dst_place, buf); x10aux::send_put(dst_place, _copy_to_serialization_id, buf, &_data[src_off], len * sizeof(T)); @@ -550,12 +547,11 @@ return; } x10aux::serialization_buffer buf; - x10aux::addr_map m; buf.realloc_func = x10aux::put_realloc; x10_ubyte code = 2; - buf.write(code, m); - buf.write(df, m); - buf.write(n, m); + buf.write(code); + buf.write(df); + buf.write(n); x10aux::send_put(dst_place, _copy_to_serialization_id, buf, &_data[src_off], len * sizeof(T)); @@ -593,12 +589,11 @@ return; } x10aux::serialization_buffer buf; - x10aux::addr_map m; buf.realloc_func = x10aux::put_realloc; x10_ubyte code = 255; - buf.write(code, m); - buf.write(df, m); - buf.write(n, m); + buf.write(code); + buf.write(df); + buf.write(n); x10aux::send_put(dst_place, _copy_to_serialization_id, buf, &_data[src_off], len * sizeof(T)); @@ -747,13 +742,12 @@ return; } x10aux::serialization_buffer buf; - x10aux::addr_map m; buf.realloc_func = x10aux::get_realloc; x10_ubyte code = 0; - buf.write(code, m); - buf.write(src, m); - buf.write(src_off, m); - Rail_serialize_finish_state(x10aux::here, buf, m); + buf.write(code); + buf.write(src); + buf.write(src_off); + Rail_serialize_finish_state(x10aux::here, buf); x10aux::send_get(src_place, _copy_from_serialization_id, buf, &_data[src_off], len * sizeof(T)); } // }}} @@ -821,18 +815,17 @@ // Specialized serialization template <class T> void Rail<T>::_serialize(x10aux::ref<Rail<T> > this_, - x10aux::serialization_buffer &buf, - x10aux::addr_map &m) { - Ref::_serialize_reference(this_, buf, m); + x10aux::serialization_buffer &buf) { + Ref::_serialize_reference(this_, buf); if (this_ != x10aux::null) { - this_->_serialize_body(buf, m); + this_->_serialize_body(buf); } } - template <class T> void Rail<T>::_serialize_body(x10aux::serialization_buffer &buf, x10aux::addr_map &m) { + template <class T> void Rail<T>::_serialize_body(x10aux::serialization_buffer &buf) { x10_int length = this->FMGL(length); - buf.write(length, m); - this->Ref::_serialize_body(buf, m); // intentional change of order + buf.write(length); + this->Ref::_serialize_body(buf); // intentional change of order } template <class T> void Rail<T>::_deserialize_body(x10aux::deserialization_buffer &buf) { Modified: trunk/x10.runtime/src-cpp/x10/lang/Ref.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Ref.cc 2009-12-13 22:44:42 UTC (rev 12298) +++ trunk/x10.runtime/src-cpp/x10/lang/Ref.cc 2009-12-13 23:04:20 UTC (rev 12299) @@ -43,44 +43,44 @@ const serialization_id_t Ref::_serialization_id = DeserializationDispatcher::addDeserializer(Ref::_deserializer<Ref>); -void Ref::_serialize(ref<Ref> this_, serialization_buffer &buf, addr_map &m) +void Ref::_serialize(ref<Ref> this_, serialization_buffer &buf) { serialization_id_t id = this_.isNull() ? 0 : this_->_get_serialization_id(); _S_("Serializing a "<<ANSI_SER<<ANSI_BOLD<<"class id "<<id<<ANSI_RESET<<" to buf: "<<&buf); - buf.write(id, m); + buf.write(id); // FIXME: maybe optimize nulls by moving the call below into the conditional? - _serialize_reference(this_, buf, m); + _serialize_reference(this_, buf); if (!this_.isNull()) { _S_("Serializing the "<<ANSI_SER<<"class body"<<ANSI_RESET<<" to buf: "<<&buf); - this_->_serialize_body(buf, m); + this_->_serialize_body(buf); } } const serialization_id_t Ref::_interface_serialization_id = DeserializationDispatcher::addDeserializer(Ref::_deserialize<Ref>); -void Ref::_serialize_interface(serialization_buffer &buf, addr_map &m) +void Ref::_serialize_interface(serialization_buffer &buf) { - _serialize(this, buf, m); + _serialize(this, buf); } -void Ref::_serialize_reference(ref<Ref> this_, serialization_buffer &buf, addr_map &m) +void Ref::_serialize_reference(ref<Ref> this_, serialization_buffer &buf) { bool isNull = this_.isNull(); x10_int loc = isNull ? 0 : this_->location; - buf.write(loc, m); + buf.write(loc); if (isNull) { _S_("Serializing a "<<ANSI_SER<<ANSI_BOLD<<"null reference"<<ANSI_RESET<<" to buf: "<<&buf); - buf.write((x10_addr_t)0, m); + buf.write((x10_addr_t)0); } else if (loc == x10aux::here) { _S_("Serialising a "<<ANSI_SER<<ANSI_BOLD<<"local Ref"<<ANSI_RESET<< " object of type "<<this_->_type()->name()); - buf.write((x10_addr_t)(size_t)this_.operator->(), m); + buf.write((x10_addr_t)(size_t)this_.operator->()); } else { _S_("Serialising a "<<ANSI_SER<<ANSI_BOLD<<"remote Ref"<<ANSI_RESET<< " object of type "<<this_->_type()->name()<<" (loc="<<loc<<")"); x10_addr_t tmp = get_remote_ref(this_.operator->()); - buf.write(tmp, m); + buf.write(tmp); } } Modified: trunk/x10.runtime/src-cpp/x10/lang/Ref.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Ref.h 2009-12-13 22:44:42 UTC (rev 12298) +++ trunk/x10.runtime/src-cpp/x10/lang/Ref.h 2009-12-13 23:04:20 UTC (rev 12299) @@ -32,8 +32,7 @@ static const x10aux::serialization_id_t _serialization_id; static void _serialize(x10aux::ref<Ref> this_, - x10aux::serialization_buffer &buf, - x10aux::addr_map &m); + x10aux::serialization_buffer &buf); static const x10aux::serialization_id_t _interface_serialization_id; // Do not override @@ -42,17 +41,16 @@ return _interface_serialization_id; } // Do not override - virtual void _serialize_interface(x10aux::serialization_buffer &buf, x10aux::addr_map &m); + virtual void _serialize_interface(x10aux::serialization_buffer &buf); // A helper method for serializing reference state // Client responsible for checking for null static void _serialize_reference(x10aux::ref<Ref> this_, - x10aux::serialization_buffer &buf, - x10aux::addr_map &m); + x10aux::serialization_buffer &buf); virtual x10aux::serialization_id_t _get_serialization_id() { return _serialization_id; }; - virtual void _serialize_body(x10aux::serialization_buffer &buf, x10aux::addr_map &m) { } + virtual void _serialize_body(x10aux::serialization_buffer &buf) { } template<class T> static x10aux::ref<T> _deserializer(x10aux::deserialization_buffer &); Modified: trunk/x10.runtime/src-cpp/x10/lang/String.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/String.cc 2009-12-13 22:44:42 UTC (rev 12298) +++ trunk/x10.runtime/src-cpp/x10/lang/String.cc 2009-12-13 23:04:20 UTC (rev 12299) @@ -294,21 +294,21 @@ DeserializationDispatcher::addDeserializer(String::_deserializer<Ref>); // Specialized serialization -void String::_serialize(x10aux::ref<String> this_, x10aux::serialization_buffer &buf, x10aux::addr_map &m) { - Ref::_serialize_reference(this_, buf, m); +void String::_serialize(x10aux::ref<String> this_, x10aux::serialization_buffer &buf) { + Ref::_serialize_reference(this_, buf); if (this_ != x10aux::null) { - this_->_serialize_body(buf, m); + this_->_serialize_body(buf); } } -void String::_serialize_body(x10aux::serialization_buffer& buf, x10aux::addr_map &m) { - this->Ref::_serialize_body(buf, m); +void String::_serialize_body(x10aux::serialization_buffer& buf) { + this->Ref::_serialize_body(buf); // only support strings that are shorter than 4billion chars x10_int sz = FMGL(content_length); - buf.write(sz, m); + buf.write(sz); const char* content = FMGL(content); for (x10_int i = 0; i < sz; ++i) { - buf.write((x10_char)content[i], m); + buf.write((x10_char)content[i]); } } Modified: trunk/x10.runtime/src-cpp/x10/lang/String.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/String.h 2009-12-13 22:44:42 UTC (rev 12298) +++ trunk/x10.runtime/src-cpp/x10/lang/String.h 2009-12-13 23:04:20 UTC (rev 12299) @@ -104,14 +104,13 @@ x10aux::ref<ValRail<x10_byte> > bytes(); static void _serialize(x10aux::ref<String> this_, - x10aux::serialization_buffer &buf, - x10aux::addr_map &m); + x10aux::serialization_buffer &buf); static const x10aux::serialization_id_t _serialization_id; virtual x10aux::serialization_id_t _get_serialization_id() { return _serialization_id; }; - virtual void _serialize_body(x10aux::serialization_buffer& buf, x10aux::addr_map &m); + virtual void _serialize_body(x10aux::serialization_buffer& buf); template<class T> static x10aux::ref<T> _deserializer(x10aux::deserialization_buffer &buf); Modified: trunk/x10.runtime/src-cpp/x10/lang/Struct.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Struct.cc 2009-12-13 22:44:42 UTC (rev 12298) +++ trunk/x10.runtime/src-cpp/x10/lang/Struct.cc 2009-12-13 23:04:20 UTC (rev 12299) @@ -14,7 +14,7 @@ return true; } -void Struct::_serialize(Struct this_, serialization_buffer& buf, addr_map& m) { +void Struct::_serialize(Struct this_, serialization_buffer& buf) { } void Struct::_deserialize_body(deserialization_buffer& buf) { Modified: trunk/x10.runtime/src-cpp/x10/lang/Struct.struct_h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Struct.struct_h 2009-12-13 22:44:42 UTC (rev 12298) +++ trunk/x10.runtime/src-cpp/x10/lang/Struct.struct_h 2009-12-13 23:04:20 UTC (rev 12299) @@ -18,7 +18,7 @@ x10_boolean _struct_equals(x10::lang::Struct that); - static void _serialize(x10::lang::Struct this_, x10aux::serialization_buffer& buf, x10aux::addr_map& m); + static void _serialize(x10::lang::Struct this_, x10aux::serialization_buffer& buf); void _deserialize_body(x10aux::deserialization_buffer& buf); Modified: trunk/x10.runtime/src-cpp/x10/lang/Throwable.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Throwable.cc 2009-12-13 22:44:42 UTC (rev 12298) +++ trunk/x10.runtime/src-cpp/x10/lang/Throwable.cc 2009-12-13 23:04:20 UTC (rev 12299) @@ -36,10 +36,10 @@ DeserializationDispatcher::addDeserializer(Throwable::_deserializer<Ref>); void -Throwable::_serialize_body(x10aux::serialization_buffer &buf, x10aux::addr_map &m) { - this->Ref::_serialize_body(buf, m); - buf.write(FMGL(cause), m); - buf.write(FMGL(message), m); +Throwable::_serialize_body(x10aux::serialization_buffer &buf) { + this->Ref::_serialize_body(buf); + buf.write(FMGL(cause)); + buf.write(FMGL(message)); // TODO: serialize the trace } Modified: trunk/x10.runtime/src-cpp/x10/lang/Throwable.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Throwable.h 2009-12-13 22:44:42 UTC (rev 12298) +++ trunk/x10.runtime/src-cpp/x10/lang/Throwable.h 2009-12-13 23:04:20 UTC (rev 12299) @@ -64,7 +64,7 @@ virtual x10aux::serialization_id_t _get_serialization_id() { return _serialization_id; }; - virtual void _serialize_body(x10aux::serialization_buffer &buf, x10aux::addr_map &m); + virtual void _serialize_body(x10aux::serialization_buffer &buf); template<class T> static x10aux::ref<T> _deserializer(x10aux::deserialization_buffer &buf); Modified: trunk/x10.runtime/src-cpp/x10/lang/ValRail.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/ValRail.h 2009-12-13 22:44:42 UTC (rev 12298) +++ trunk/x10.runtime/src-cpp/x10/lang/ValRail.h 2009-12-13 23:04:20 UTC (rev 12299) @@ -81,10 +81,9 @@ virtual x10aux::serialization_id_t _get_serialization_id() { return _serialization_id; }; static void _serialize(x10aux::ref<ValRail<T> > this_, - x10aux::serialization_buffer &buf, - x10aux::addr_map &m); + x10aux::serialization_buffer &buf); - void _serialize_body(x10aux::serialization_buffer &buf, x10aux::addr_map &m); + void _serialize_body(x10aux::serialization_buffer &buf); void _deserialize_body(x10aux::deserialization_buffer &buf); @@ -181,21 +180,20 @@ // Specialized serialization template <class T> void ValRail<T>::_serialize(x10aux::ref<ValRail<T> > this_, - x10aux::serialization_buffer &buf, - x10aux::addr_map &m) { - Ref::_serialize_reference(this_, buf, m); + x10aux::serialization_buffer &buf) { + Ref::_serialize_reference(this_, buf); if (this_ != x10aux::null) { - this_->_serialize_body(buf, m); + this_->_serialize_body(buf); } } - template <class T> void ValRail<T>::_serialize_body(x10aux::serialization_buffer &buf, x10aux::addr_map &m) { + template <class T> void ValRail<T>::_serialize_body(x10aux::serialization_buffer &buf) { x10_int length = this->FMGL(length); - buf.write(length, m); - this->Ref::_serialize_body(buf, m); // intentional change of order + buf.write(length); + this->Ref::_serialize_body(buf); // intentional change of order T* raw = this->raw(); for (x10_int i=0 ; i<length ; ++i) { - buf.write(raw[i], m); // avoid bounds check + buf.write(raw[i]); // avoid bounds check } } Modified: trunk/x10.runtime/src-cpp/x10/runtime/Deque.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/runtime/Deque.cc 2009-12-13 22:44:42 UTC (rev 12298) +++ trunk/x10.runtime/src-cpp/x10/runtime/Deque.cc 2009-12-13 23:04:20 UTC (rev 12299) @@ -109,8 +109,8 @@ return NULL; } -void Deque::_serialize_body(serialization_buffer &buf, addr_map &m) { - this->Ref::_serialize_body(buf, m); +void Deque::_serialize_body(serialization_buffer &buf) { + this->Ref::_serialize_body(buf); } void Deque::_deserialize_body(deserialization_buffer& buf) { Modified: trunk/x10.runtime/src-cpp/x10/runtime/Deque.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/runtime/Deque.h 2009-12-13 22:44:42 UTC (rev 12298) +++ trunk/x10.runtime/src-cpp/x10/runtime/Deque.h 2009-12-13 23:04:20 UTC (rev 12299) @@ -34,7 +34,7 @@ virtual x10aux::serialization_id_t _get_serialization_id() { return _serialization_id; }; - virtual void _serialize_body(x10aux::serialization_buffer &buf, x10aux::addr_map &m); + virtual void _serialize_body(x10aux::serialization_buffer &buf); template<class T> static x10aux::ref<T> _deserializer(x10aux::deserialization_buffer &buf); Modified: trunk/x10.runtime/src-cpp/x10/runtime/PlaceLocalHandle.struct_h =================================================================== --- trunk/x10.runtime/src-cpp/x10/runtime/PlaceLocalHandle.struct_h 2009-12-13 22:44:42 UTC (rev 12298) +++ trunk/x10.runtime/src-cpp/x10/runtime/PlaceLocalHandle.struct_h 2009-12-13 23:04:20 UTC (rev 12299) @@ -63,7 +63,7 @@ return FMGL(id) == that->FMGL(id); } - static void _serialize(PlaceLocalHandle<T> this_, x10aux::serialization_buffer &buf, x10aux::addr_map &m); + static void _serialize(PlaceLocalHandle<T> this_, x10aux::serialization_buffer &buf); static PlaceLocalHandle<T> _deserialize(x10aux::deserialization_buffer& buf); }; @@ -81,9 +81,9 @@ template<class T> x10aux::RuntimeType PlaceLocalHandle<T>::rtt; - template <class T> void PlaceLocalHandle<T>::_serialize(PlaceLocalHandle<T> this_, x10aux::serialization_buffer &buf, x10aux::addr_map &m) { + template <class T> void PlaceLocalHandle<T>::_serialize(PlaceLocalHandle<T> this_, x10aux::serialization_buffer &buf) { // NOTE specialized semantics. Only id is serialized, cached and localStorage are place local! - buf.write(this_->FMGL(id),m); + buf.write(this_->FMGL(id)); } template<class T> PlaceLocalHandle<T> PlaceLocalHandle<T>::_deserialize(x10aux::deserialization_buffer& buf) { Modified: trunk/x10.runtime/src-cpp/x10/runtime/Thread.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/runtime/Thread.cc 2009-12-13 22:44:42 UTC (rev 12298) +++ trunk/x10.runtime/src-cpp/x10/runtime/Thread.cc 2009-12-13 23:04:20 UTC (rev 12299) @@ -465,8 +465,8 @@ __thread_name = name; } -void Thread::_serialize_body(serialization_buffer &buf, addr_map &m) { - this->Ref::_serialize_body(buf, m); +void Thread::_serialize_body(serialization_buffer &buf) { + this->Ref::_serialize_body(buf); } void Thread::_deserialize_body(deserialization_buffer& buf) { Modified: trunk/x10.runtime/src-cpp/x10/runtime/Thread.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/runtime/Thread.h 2009-12-13 22:44:42 UTC (rev 12298) +++ trunk/x10.runtime/src-cpp/x10/runtime/Thread.h 2009-12-13 23:04:20 UTC (rev 12299) @@ -69,7 +69,7 @@ virtual x10aux::serialization_id_t _get_serialization_id() { return _serialization_id; }; - virtual void _serialize_body(x10aux::serialization_buffer &buf, x10aux::addr_map &m); + virtual void _serialize_body(x10aux::serialization_buffer &buf); template<class T> static x10aux::ref<T> _deserializer(x10aux::deserialization_buffer &buf); Modified: trunk/x10.runtime/src-cpp/x10/util/GrowableRail.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/util/GrowableRail.h 2009-12-13 22:44:42 UTC (rev 12298) +++ trunk/x10.runtime/src-cpp/x10/util/GrowableRail.h 2009-12-13 23:04:20 UTC (rev 12299) @@ -40,7 +40,7 @@ virtual x10aux::serialization_id_t _get_serialization_id() { return _serialization_id; }; - virtual void _serialize_body(x10aux::serialization_buffer &buf, x10aux::addr_map &m); + virtual void _serialize_body(x10aux::serialization_buffer &buf); template<class U> static x10aux::ref<U> _deserializer(x10aux::deserialization_buffer &buf); @@ -182,8 +182,8 @@ template<class T> x10aux::RuntimeType GrowableRail<T>::rtt; - template<class T> void GrowableRail<T>::_serialize_body(x10aux::serialization_buffer &buf, x10aux::addr_map &m) { - this->x10::lang::Ref::_serialize_body(buf, m); + template<class T> void GrowableRail<T>::_serialize_body(x10aux::serialization_buffer &buf) { + this->x10::lang::Ref::_serialize_body(buf); } template<class T> template<class U> x10aux::ref<U> GrowableRail<T>::_deserializer(x10aux::deserialization_buffer &buf) { Modified: trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicBoolean.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicBoolean.cc 2009-12-13 22:44:42 UTC (rev 12298) +++ trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicBoolean.cc 2009-12-13 23:04:20 UTC (rev 12299) @@ -23,8 +23,8 @@ return this_; } -void AtomicBoolean::_serialize_body(x10aux::serialization_buffer &buf, x10aux::addr_map &m) { - this->Ref::_serialize_body(buf, m); +void AtomicBoolean::_serialize_body(x10aux::serialization_buffer &buf) { + this->Ref::_serialize_body(buf); } void AtomicBoolean::_deserialize_body(x10aux::deserialization_buffer& buf) { Modified: trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicBoolean.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicBoolean.h 2009-12-13 22:44:42 UTC (rev 12298) +++ trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicBoolean.h 2009-12-13 23:04:20 UTC (rev 12299) @@ -38,7 +38,7 @@ virtual x10aux::serialization_id_t _get_serialization_id() { return _serialization_id; }; - virtual void _serialize_body(x10aux::serialization_buffer &buf, x10aux::addr_map &m); + virtual void _serialize_body(x10aux::serialization_buffer &buf); template<class T> static x10aux::ref<T> _deserializer(x10aux::deserialization_buffer &buf); Modified: trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicInteger.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicInteger.cc 2009-12-13 22:44:42 UTC (rev 12298) +++ trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicInteger.cc 2009-12-13 23:04:20 UTC (rev 12299) @@ -23,8 +23,8 @@ return this_; } -void AtomicInteger::_serialize_body(x10aux::serialization_buffer &buf, x10aux::addr_map &m) { - this->Ref::_serialize_body(buf, m); +void AtomicInteger::_serialize_body(x10aux::serialization_buffer &buf) { + this->Ref::_serialize_body(buf); } void AtomicInteger::_deserialize_body(x10aux::deserialization_buffer& buf) { Modified: trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicInteger.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicInteger.h 2009-12-13 22:44:42 UTC (rev 12298) +++ trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicInteger.h 2009-12-13 23:04:20 UTC (rev 12299) @@ -38,7 +38,7 @@ virtual x10aux::serialization_id_t _get_serialization_id() { return _serialization_id; }; - virtual void _serialize_body(x10aux::serialization_buffer &buf, x10aux::addr_map &m); + virtual void _serialize_body(x10aux::serialization_buffer &buf); template<class T> static x10aux::ref<T> _deserializer(x10aux::deserialization_buffer &buf); Modified: trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicLong.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicLong.cc 2009-12-13 22:44:42 UTC (rev 12298) +++ trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicLong.cc 2009-12-13 23:04:20 UTC (rev 12299) @@ -23,8 +23,8 @@ return this_; } -void AtomicLong::_serialize_body(x10aux::serialization_buffer &buf, x10aux::addr_map &m) { - this->Ref::_serialize_body(buf, m); +void AtomicLong::_serialize_body(x10aux::serialization_buffer &buf) { + this->Ref::_serialize_body(buf); } void AtomicLong::_deserialize_body(x10aux::deserialization_buffer& buf) { Modified: trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicLong.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicLong.h 2009-12-13 22:44:42 UTC (rev 12298) +++ trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicLong.h 2009-12-13 23:04:20 UTC (rev 12299) @@ -38,7 +38,7 @@ virtual x10aux::serialization_id_t _get_serialization_id() { return _serialization_id; }; - virtual void _serialize_body(x10aux::serialization_buffer &buf, x10aux::addr_map &m); + virtual void _serialize_body(x10aux::serialization_buffer &buf); template<class T> static x10aux::ref<T> _deserializer(x10aux::deserialization_buffer &buf); Modified: trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicReference.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicReference.h 2009-12-13 22:44:42 UTC (rev 12298) +++ trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicReference.h 2009-12-13 23:04:20 UTC (rev 12299) @@ -48,7 +48,7 @@ virtual x10aux::serialization_id_t _get_serialization_id() { return _serialization_id; }; - virtual void _serialize_body(x10aux::serialization_buffer &buf, x10aux::addr_map &m); + virtual void _serialize_body(x10aux::serialization_buffer &buf); template<class U> static x10aux::ref<U> _deserializer(x10aux::deserialization_buffer &buf); @@ -131,8 +131,8 @@ template<class T> x10aux::RuntimeType AtomicReference<T>::rtt; template<class T> void - AtomicReference<T>::_serialize_body(x10aux::serialization_buffer &buf, x10aux::addr_map &m) { - this->Ref::_serialize_body(buf, m); + AtomicReference<T>::_serialize_body(x10aux::serialization_buffer &buf) { + this->Ref::_serialize_body(buf); } template<class T> void Modified: trunk/x10.runtime/src-cpp/x10aux/fun_utils.h =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/fun_utils.h 2009-12-13 22:44:42 UTC (rev 12298) +++ trunk/x10.runtime/src-cpp/x10aux/fun_utils.h 2009-12-13 23:04:20 UTC (rev 12299) @@ -7,15 +7,13 @@ namespace x10aux { class serialization_buffer; - class addr_map; class AnyFun { public: static void _serialize(ref<AnyFun> this_, - x10aux::serialization_buffer &buf, - x10aux::addr_map &m) { - x10::lang::Object::_serialize(this_, buf, m); + x10aux::serialization_buffer &buf) { + x10::lang::Object::_serialize(this_, buf); } template<class T> static x10aux::ref<T> _deserialize(x10aux::deserialization_buffer &buf) { Modified: trunk/x10.runtime/src-cpp/x10aux/network.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/network.cc 2009-12-13 22:44:42 UTC (rev 12298) +++ trunk/x10.runtime/src-cpp/x10aux/network.cc 2009-12-13 23:04:20 UTC (rev 12299) @@ -160,7 +160,6 @@ assert(p<num_places); // this is ensured by XRX runtime serialization_buffer buf; - addr_map m; serialization_id_t sid = body->_get_serialization_id(); msg_type id = DeserializationDispatcher::getMsgType(sid); @@ -171,7 +170,7 @@ if (!is_cuda(p)) { - body->_serialize_body(buf, m); + body->_serialize_body(buf); unsigned long sz = buf.length(); serialized_bytes += sz; asyncs_sent++; @@ -205,8 +204,8 @@ <<ref<Object>(real_body)->toString()->c_str()<<" id "<<real_id <<" sid "<<real_sid<<" at GPU: "<<p); - buf.write(fs, m); - real_body->_serialize_body(buf, m); + buf.write(fs); + real_body->_serialize_body(buf); unsigned long sz = buf.length(); serialized_bytes += sz; asyncs_sent++; @@ -404,10 +403,9 @@ { bool finished = false; x10aux::serialization_buffer buf; - addr_map m; buf.realloc_func = x10aux::put_realloc; - buf.write((x10_ulong)(size_t)&finished, m); - buf.write(addr, m); + buf.write((x10_ulong)(size_t)&finished); + buf.write(addr); size_t len = buf.length(); x10rt_msg_params p = {gpu, kernel_put, buf.steal(), len}; x10rt_send_put(p, var, sz); Modified: trunk/x10.runtime/src-cpp/x10aux/serialization.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/serialization.cc 2009-12-13 22:44:42 UTC (rev 12298) +++ trunk/x10.runtime/src-cpp/x10aux/serialization.cc 2009-12-13 23:04:20 UTC (rev 12299) @@ -6,8 +6,6 @@ using namespace x10aux; using namespace x10::lang; -#if 0 -NOT USED AT PRESENT void addr_map::_grow() { _ptrs = (const void**) ::memcpy(new (x10aux::alloc<const void*>((_size<<1)*sizeof(const void*))) const void*[_size<<1], _ptrs, _size*sizeof(const void*)); _size <<= 1; @@ -20,27 +18,33 @@ _ptrs[_top++] = ptr; } -bool addr_map::_find(const void* ptr) { - for (int i = 0; i < _top; i++) { - if (_ptrs[i] == ptr) { - return true; +int addr_map::_find(const void* ptr) { + for (int i = -1; i >= -_top; i--) { + if (_ptrs[_top+i] == ptr) { + return i; } } - return false; + return 0; } -bool addr_map::ensure_unique(const void* p) { - if (_find(p)) { - return false; +const void* addr_map::_get(int pos) { + if (pos < -_top || pos >= 0) + return NULL; + return _ptrs[_top+pos]; +} + +int addr_map::_position(const void* p) { + int pos = _find(p); + if (pos != 0) { + return pos; } _add(p); - return true; + return 0; } -#endif serialization_buffer::serialization_buffer (void) // do not use GC - : realloc_func(x10aux::msg_realloc), buffer(NULL), limit(NULL), cursor(NULL) + : realloc_func(x10aux::msg_realloc), buffer(NULL), limit(NULL), cursor(NULL), map() { } void serialization_buffer::grow (void) { @@ -56,3 +60,5 @@ limit = buffer + new_capacity; cursor = buffer + new_length; } +// vim:tabstop=4:shiftwidth=4:expandtab:textwidth=100 + Modified: trunk/x10.runtime/src-cpp/x10aux/serialization.h =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/serialization.h 2009-12-13 22:44:42 UTC (rev 12298) +++ trunk/x10.runtime/src-cpp/x10aux/serialization.h 2009-12-13 23:04:20 UTC (rev 12299) @@ -125,21 +125,15 @@ // addr_map can be used to detect and properly handle cycles when serialising object graphs // it can also be used to avoid serialising two copies of an object when serialising a DAG. - // - // [DC] instead of threading this around everywhere, why don't we encapsulate it within the - // serialization_buffer? That way the serialiation buffer always has it available, and noone - // else has to be troubled by it. - // [IP] if we had proper cycle handling, we could. As it stands now, we have to be able to - // handle two refs to the same object being written into the same buffer. For that we need - // to reset the addr_map between them (but only up to a certain point). That code is too - // complex to implement right now. class addr_map { int _size; const void** _ptrs; int _top; void _grow(); void _add(const void* ptr); -... [truncated message content] |
From: <ipe...@us...> - 2009-12-18 07:45:04
|
Revision: 12322 http://x10.svn.sourceforge.net/x10/?rev=12322&view=rev Author: ipeshansky Date: 2009-12-18 07:44:56 +0000 (Fri, 18 Dec 2009) Log Message: ----------- Add a 'squeakyclean' rule to x10.dist/build.xml to clean everything but BDWGC and downloaded files. Modified Paths: -------------- trunk/x10.dist/build.xml trunk/x10.runtime/build.xml Modified: trunk/x10.dist/build.xml =================================================================== --- trunk/x10.dist/build.xml 2009-12-18 07:39:37 UTC (rev 12321) +++ trunk/x10.dist/build.xml 2009-12-18 07:44:56 UTC (rev 12322) @@ -59,19 +59,27 @@ </delete> </target> - <target name="distclean" depends="clean"> + <target name="squeakyclean" depends="clean"> <delete dir="${etc}" /> <mkdir dir="${etc}" /> <delete dir="${incdir}" /> <mkdir dir="${incdir}" /> + <!-- TODO: remove generated libs, but not downloaded ones <delete dir="${lib}" /> <mkdir dir="${lib}" /> + --> <ant antfile="${x10.constraints.location}/build.xml" target="clean" inheritAll="false" dir="${x10.constraints.location}"/> <ant antfile="${x10.common.location}/build.xml" target="clean" inheritAll="false" dir="${x10.common.location}"/> <ant antfile="${x10.runtime.location}/build.xml" target="clean" inheritAll="false" dir="${x10.runtime.location}"/> <ant antfile="${x10.compiler.location}/build.xml" target="clean" inheritAll="false" dir="${x10.compiler.location}"/> </target> + <target name="distclean" depends="squeakyclean"> + <delete dir="${lib}" /> + <mkdir dir="${lib}" /> + <ant antfile="${x10.runtime.location}/build.xml" target="distclean" inheritAll="false" dir="${x10.runtime.location}"/> + </target> + <target name="dist-java" depends="init,build,common-jar,constraints-jar,compiler-jar,runtime-java"/> <target name="dist-cpp" depends="dist-java,runtime-cpp"/> <target name="dist" depends="dist-java,dist-cpp"/> Modified: trunk/x10.runtime/build.xml =================================================================== --- trunk/x10.runtime/build.xml 2009-12-18 07:39:37 UTC (rev 12321) +++ trunk/x10.runtime/build.xml 2009-12-18 07:44:56 UTC (rev 12322) @@ -73,7 +73,7 @@ <isfalse value="${DISABLE_GC}" /> <or> <os family="unix" name="linux"/> - <os family="mac"/> + <os family="mac"/> <os family="windows"/> </or> </and> @@ -109,11 +109,14 @@ <property name="available.procs" value="2"/> </target> + <target name="distclean" depends="distclean-java,distclean-cpp"/> <target name="clean" depends="clean-java,clean-cpp"/> + <target name="distclean-java" depends="clean-java"/> <target name="clean-java"> <delete dir="${build}"/> </target> - <target name="clean-cpp" depends="available-procs,clean-bdwgc"> + <target name="distclean-cpp" depends="clean-cpp,clean-bdwgc"/> + <target name="clean-cpp" depends="available-procs"> <exec executable="${make.exe}" failonerror="true" dir="${basedir}/src-cpp"> <arg value="-j1" /> <arg value="clean"/> @@ -172,6 +175,7 @@ </ejc> </target> <property name="gen" location="${build}/gen"/> + <!-- TODO: check the generated files with respect to the compiler jar --> <target name="check-xrx" depends="init"> <fileset id="xrx.files" dir="${basedir}/src-x10" includes="**/*.x10"/> <uptodate property="xrx.uptodate"> @@ -252,12 +256,12 @@ <target name="build-bdwgc" depends="check-bdwgc,download-bdwgc,convert-bdwgc-paths,available-procs" unless="bdwgc.skip.build"> <sequential> <echo message="Installing BDWGC to ${bdwgc.platform.dir}"/> - <if> - <conditions> + <if> + <conditions> <os family="unix" name="linux"/> - </conditions> - <sequential> - <exec executable="${bash.exe}" dir="${bdwgc.dir}/src" failonerror="true"> + </conditions> + <sequential> + <exec executable="${bash.exe}" dir="${bdwgc.dir}/src" failonerror="true"> <arg value="${bdwgc.dir}/src/configure" /> <arg value="-enable-threads=posix" /> <arg value="-enable-thread-local-alloc" /> @@ -265,29 +269,29 @@ </exec> </sequential> </if> - <if> - <conditions> - <os family="mac"/> - </conditions> - <sequential> - <exec executable="${bash.exe}" dir="${bdwgc.dir}/src" failonerror="true"> + <if> + <conditions> + <os family="mac"/> + </conditions> + <sequential> + <exec executable="${bash.exe}" dir="${bdwgc.dir}/src" failonerror="true"> <arg value="${bdwgc.dir}/src/configure" /> <arg value="-enable-threads=posix" /> <arg value="-enable-thread-local-alloc" /> - <arg value="CFLAGS=-D_XOPEN_SOURCE" /> + <arg value="CFLAGS=-D_XOPEN_SOURCE" /> <arg value="--prefix=${bdwgc.platform.dir}/install" /> </exec> </sequential> </if> - <if> - <conditions> + <if> + <conditions> <os family="unix" name="aix"/> - </conditions> - <sequential> - <exec executable="${bash.exe}" dir="${bdwgc.dir}/src" failonerror="true"> - <env key="OBJECT_MODE" value="32_64" /> - <env key="CFLAGS" value="-Wa,-mppc64 -Wa,-a64 -maix64 -D__ppc64__" /> - <env key="CXXFLAGS" value="-Wa,-mppc64 -Wa,-a64 -maix64 -D__ppc64__" /> + </conditions> + <sequential> + <exec executable="${bash.exe}" dir="${bdwgc.dir}/src" failonerror="true"> + <env key="OBJECT_MODE" value="32_64" /> + <env key="CFLAGS" value="-Wa,-mppc64 -Wa,-a64 -maix64 -D__ppc64__" /> + <env key="CXXFLAGS" value="-Wa,-mppc64 -Wa,-a64 -maix64 -D__ppc64__" /> <arg value="${bdwgc.dir}/src/configure" /> <arg value="-enable-threads=aix" /> <!-- TODO: <arg value="-enable-thread-local-alloc" /> --> @@ -295,12 +299,12 @@ </exec> </sequential> </if> - <if> - <conditions> + <if> + <conditions> <os family="windows"/> - </conditions> - <sequential> - <exec executable="${bash.exe}" dir="${bdwgc.dir}/src" failonerror="true"> + </conditions> + <sequential> + <exec executable="${bash.exe}" dir="${bdwgc.dir}/src" failonerror="true"> <arg value="${bdwgc.dir}/src/configure" /> <arg value="-enable-threads=posix" /> <arg value="-enable-thread-local-alloc" /> @@ -309,11 +313,11 @@ </sequential> </if> <exec executable="${make.exe}" dir="${bdwgc.dir}/src" failonerror="true"> - <env key="OBJECT_MODE" value="32_64" /> + <env key="OBJECT_MODE" value="32_64" /> <arg value="-j${available.procs}" /> </exec> <exec executable="${make.exe}" dir="${bdwgc.dir}/src" failonerror="true"> - <env key="OBJECT_MODE" value="32_64" /> + <env key="OBJECT_MODE" value="32_64" /> <arg value="install" /> </exec> </sequential> @@ -338,15 +342,15 @@ failonerror="true" /> <move file="${bdwgc.dir}/bdwgc" tofile="${bdwgc.dir}/src" /> - <if> - <conditions> + <if> + <conditions> <os family="unix" name="aix"/> - </conditions> - <sequential> - <patch patchfile="${basedir}/src-cpp/bdwgc-patches/fixPPCHeaderFiles.patch.txt" - dir="${bdwgc.dir}/src" strip="0" /> - <patch patchfile="${basedir}/src-cpp/bdwgc-patches/linkerHackConfigure.patch.txt" - dir="${bdwgc.dir}/src" strip="0" /> + </conditions> + <sequential> + <patch patchfile="${basedir}/src-cpp/bdwgc-patches/fixPPCHeaderFiles.patch.txt" + dir="${bdwgc.dir}/src" strip="0" /> + <patch patchfile="${basedir}/src-cpp/bdwgc-patches/linkerHackConfigure.patch.txt" + dir="${bdwgc.dir}/src" strip="0" /> </sequential> </if> </sequential> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ipe...@us...> - 2009-12-18 14:04:12
|
Revision: 12323 http://x10.svn.sourceforge.net/x10/?rev=12323&view=rev Author: ipeshansky Date: 2009-12-18 14:04:03 +0000 (Fri, 18 Dec 2009) Log Message: ----------- Ensure that references are tracked in the same order on serialization and deserialization (secondary fix for XTENLANG-695). More detailed serialization tracing. Modified Paths: -------------- trunk/x10.compiler/src/x10cpp/visit/Emitter.java trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java trunk/x10.runtime/src-cpp/x10/io/FileReader__FileInputStream.h trunk/x10.runtime/src-cpp/x10/io/FileWriter__FileOutputStream.h trunk/x10.runtime/src-cpp/x10/io/File__NativeFile.h trunk/x10.runtime/src-cpp/x10/lang/Closure.h trunk/x10.runtime/src-cpp/x10/lang/Rail.h trunk/x10.runtime/src-cpp/x10/lang/Ref.h trunk/x10.runtime/src-cpp/x10/lang/String.h trunk/x10.runtime/src-cpp/x10/lang/ValRail.h trunk/x10.runtime/src-cpp/x10/runtime/Deque.h trunk/x10.runtime/src-cpp/x10/runtime/Thread.h trunk/x10.runtime/src-cpp/x10/util/GrowableRail.h trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicBoolean.h trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicInteger.h trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicLong.h trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicReference.h trunk/x10.runtime/src-cpp/x10aux/serialization.h trunk/x10.runtime/src-x10/x10/runtime/Thread.x10 trunk/x10.runtime/src-x10/x10/util/concurrent/atomic/AtomicBoolean.x10 trunk/x10.runtime/src-x10/x10/util/concurrent/atomic/AtomicInteger.x10 trunk/x10.runtime/src-x10/x10/util/concurrent/atomic/AtomicLong.x10 trunk/x10.runtime/src-x10/x10/util/concurrent/atomic/AtomicReference.x10 Modified: trunk/x10.compiler/src/x10cpp/visit/Emitter.java =================================================================== --- trunk/x10.compiler/src/x10cpp/visit/Emitter.java 2009-12-18 07:44:56 UTC (rev 12322) +++ trunk/x10.compiler/src/x10cpp/visit/Emitter.java 2009-12-18 14:04:03 UTC (rev 12323) @@ -998,6 +998,7 @@ sw.newline(4); sw.begin(0); sw.writeln(make_ref(klass)+" this_ = "+ "new (x10aux::alloc_remote"+chevrons(klass)+"()) "+klass+"();"); + sw.writeln("buf.record_reference(this_);"); sw.writeln("this_->"+DESERIALIZE_BODY_METHOD+"(buf);"); sw.write("return this_;"); sw.end(); sw.newline(); Modified: trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java =================================================================== --- trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java 2009-12-18 07:44:56 UTC (rev 12322) +++ trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java 2009-12-18 14:04:03 UTC (rev 12323) @@ -4026,6 +4026,8 @@ inc.write(make_ref(cnamet)+" this_ = new (x10aux::alloc"+chevrons(cnamet)+"()) "+ cnamet+"("+SERIALIZATION_MARKER+"());"); inc.newline(); + inc.write("buf.record_reference(this_); // TODO: avoid; closure"); + inc.newline(); // FIXME: factor out this loop for (int i = 0; i < c.variables.size(); i++) { VarInstance var = (VarInstance) c.variables.get(i); Modified: trunk/x10.runtime/src-cpp/x10/io/FileReader__FileInputStream.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/io/FileReader__FileInputStream.h 2009-12-18 07:44:56 UTC (rev 12322) +++ trunk/x10.runtime/src-cpp/x10/io/FileReader__FileInputStream.h 2009-12-18 14:04:03 UTC (rev 12323) @@ -59,7 +59,8 @@ // The old 1.7 definition of this class simply didn't work either, // it just silently didn't serialize the FILEPtrInputSteam field. // assert(false); - x10aux::ref<FileReader__FileInputStream> this_ = new (x10aux::alloc_remote<FileReader__FileInputStream>()) FileReader__FileInputStream (NULL); + x10aux::ref<FileReader__FileInputStream> this_ = new (x10aux::alloc_remote<FileReader__FileInputStream>()) FileReader__FileInputStream(NULL); + buf.record_reference(this_); this_->_deserialize_body(buf); return this_; } Modified: trunk/x10.runtime/src-cpp/x10/io/FileWriter__FileOutputStream.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/io/FileWriter__FileOutputStream.h 2009-12-18 07:44:56 UTC (rev 12322) +++ trunk/x10.runtime/src-cpp/x10/io/FileWriter__FileOutputStream.h 2009-12-18 14:04:03 UTC (rev 12323) @@ -64,6 +64,7 @@ // it just silently didn't serialize the FILEPtrInputSteam field. // assert(false); x10aux::ref<FileWriter__FileOutputStream> this_ = new (x10aux::alloc_remote<FileWriter__FileOutputStream>()) FileWriter__FileOutputStream(NULL); + buf.record_reference(this_); this_->_deserialize_body(buf); return this_; } Modified: trunk/x10.runtime/src-cpp/x10/io/File__NativeFile.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/io/File__NativeFile.h 2009-12-18 07:44:56 UTC (rev 12322) +++ trunk/x10.runtime/src-cpp/x10/io/File__NativeFile.h 2009-12-18 14:04:03 UTC (rev 12323) @@ -71,6 +71,7 @@ template<class T> x10aux::ref<T> File__NativeFile::_deserializer(x10aux::deserialization_buffer &buf) { x10aux::ref<File__NativeFile> this_ = new (x10aux::alloc_remote<File__NativeFile>()) File__NativeFile(); + buf.record_reference(this_); // TODO: avoid; no global refs; final class this_->_deserialize_body(buf); return this_; } Modified: trunk/x10.runtime/src-cpp/x10/lang/Closure.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Closure.h 2009-12-18 07:44:56 UTC (rev 12322) +++ trunk/x10.runtime/src-cpp/x10/lang/Closure.h 2009-12-18 14:04:03 UTC (rev 12323) @@ -61,8 +61,9 @@ return x10aux::DeserializationDispatcher::create<T>(buf); } - template<class T> x10aux::ref<T> Closure::_deserializer(x10aux::deserialization_buffer &) { + template<class T> x10aux::ref<T> Closure::_deserializer(x10aux::deserialization_buffer &buf) { x10aux::ref<Closure> this_ = new (x10aux::alloc<Closure>()) Closure(); + buf.record_reference(this_); // TODO: avoid; closure return this_; } } Modified: trunk/x10.runtime/src-cpp/x10/lang/Rail.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Rail.h 2009-12-18 07:44:56 UTC (rev 12322) +++ trunk/x10.runtime/src-cpp/x10/lang/Rail.h 2009-12-18 14:04:03 UTC (rev 12323) @@ -837,6 +837,7 @@ x10_int length = buf.read<x10_int>(); // Don't allocate any storage for the data - it's a remote rail R this_ = x10aux::alloc_rail_remote<T,Rail<T> >(0); + buf.record_reference(this_); // TODO: avoid; no global refs; final class // But the above set the length to 0, so set it correctly const_cast<x10_int&>(this_->FMGL(length)) = length; this_->_deserialize_body(buf); Modified: trunk/x10.runtime/src-cpp/x10/lang/Ref.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Ref.h 2009-12-18 07:44:56 UTC (rev 12322) +++ trunk/x10.runtime/src-cpp/x10/lang/Ref.h 2009-12-18 14:04:03 UTC (rev 12323) @@ -116,6 +116,7 @@ template<class T> x10aux::ref<T> Ref::_deserializer(x10aux::deserialization_buffer &buf) { x10aux::ref<Ref> this_ = new (x10aux::alloc_remote<Ref>()) Ref(); + buf.record_reference(this_); this_->_deserialize_body(buf); return this_; } Modified: trunk/x10.runtime/src-cpp/x10/lang/String.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/String.h 2009-12-18 07:44:56 UTC (rev 12322) +++ trunk/x10.runtime/src-cpp/x10/lang/String.h 2009-12-18 14:04:03 UTC (rev 12323) @@ -156,6 +156,7 @@ template<class T> x10aux::ref<T> String::_deserializer(x10aux::deserialization_buffer& buf) { x10aux::ref<String> this_ = new (x10aux::alloc_remote<String>()) String(); + buf.record_reference(this_); // TODO: avoid; no global refs; final class this_->_deserialize_body(buf); return this_; } Modified: trunk/x10.runtime/src-cpp/x10/lang/ValRail.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/ValRail.h 2009-12-18 07:44:56 UTC (rev 12322) +++ trunk/x10.runtime/src-cpp/x10/lang/ValRail.h 2009-12-18 14:04:03 UTC (rev 12323) @@ -210,6 +210,7 @@ template <class T> template<class S> x10aux::ref<S> ValRail<T>::_deserializer(x10aux::deserialization_buffer &buf) { x10_int length = buf.read<x10_int>(); x10aux::ref<ValRail<T> > this_ = x10aux::alloc_rail_remote<T,ValRail<T> >(length); + buf.record_reference(this_); // TODO: avoid; no global refs; final class this_->_deserialize_body(buf); return this_; } Modified: trunk/x10.runtime/src-cpp/x10/runtime/Deque.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/runtime/Deque.h 2009-12-18 07:44:56 UTC (rev 12322) +++ trunk/x10.runtime/src-cpp/x10/runtime/Deque.h 2009-12-18 14:04:03 UTC (rev 12323) @@ -152,6 +152,7 @@ template<class T> x10aux::ref<T> Deque::_deserializer(x10aux::deserialization_buffer &buf) { x10aux::ref<Deque> this_ = new (x10aux::alloc_remote<Deque>()) Deque(); + buf.record_reference(this_); // TODO: avoid; no global refs; final class this_->_deserialize_body(buf); return this_; } Modified: trunk/x10.runtime/src-cpp/x10/runtime/Thread.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/runtime/Thread.h 2009-12-18 07:44:56 UTC (rev 12322) +++ trunk/x10.runtime/src-cpp/x10/runtime/Thread.h 2009-12-18 14:04:03 UTC (rev 12323) @@ -244,6 +244,7 @@ template<class T> x10aux::ref<T> Thread::_deserializer(x10aux::deserialization_buffer &buf) { x10aux::ref<Thread> this_ = new (x10aux::alloc_remote<Thread>()) Thread(); + buf.record_reference(this_); // TODO: avoid; no global refs; final class this_->_deserialize_body(buf); return this_; } Modified: trunk/x10.runtime/src-cpp/x10/util/GrowableRail.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/util/GrowableRail.h 2009-12-18 07:44:56 UTC (rev 12322) +++ trunk/x10.runtime/src-cpp/x10/util/GrowableRail.h 2009-12-18 14:04:03 UTC (rev 12323) @@ -188,6 +188,7 @@ template<class T> template<class U> x10aux::ref<U> GrowableRail<T>::_deserializer(x10aux::deserialization_buffer &buf) { x10aux::ref<GrowableRail> this_ = new (x10aux::alloc_remote<GrowableRail>()) GrowableRail(); + buf.record_reference(this_); // TODO: avoid; no global refs; final class this_->_deserialize_body(buf); return this_; } Modified: trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicBoolean.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicBoolean.h 2009-12-18 07:44:56 UTC (rev 12322) +++ trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicBoolean.h 2009-12-18 14:04:03 UTC (rev 12323) @@ -84,6 +84,7 @@ template<class T> x10aux::ref<T> AtomicBoolean::_deserializer(x10aux::deserialization_buffer &buf) { x10aux::ref<AtomicBoolean> this_ = new (x10aux::alloc_remote<AtomicBoolean>()) AtomicBoolean(); + buf.record_reference(this_); // TODO: avoid; no global refs; final class this_->_deserialize_body(buf); return this_; } Modified: trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicInteger.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicInteger.h 2009-12-18 07:44:56 UTC (rev 12322) +++ trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicInteger.h 2009-12-18 14:04:03 UTC (rev 12323) @@ -116,6 +116,7 @@ template<class T> x10aux::ref<T> AtomicInteger::_deserializer(x10aux::deserialization_buffer &buf) { x10aux::ref<AtomicInteger> this_ = new (x10aux::alloc_remote<AtomicInteger>()) AtomicInteger(); + buf.record_reference(this_); // TODO: avoid; no global refs; final class this_->_deserialize_body(buf); return this_; } Modified: trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicLong.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicLong.h 2009-12-18 07:44:56 UTC (rev 12322) +++ trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicLong.h 2009-12-18 14:04:03 UTC (rev 12323) @@ -116,6 +116,7 @@ template<class T> x10aux::ref<T> AtomicLong::_deserializer(x10aux::deserialization_buffer &buf) { x10aux::ref<AtomicLong> this_ = new (x10aux::alloc_remote<AtomicLong>()) AtomicLong(); + buf.record_reference(this_); // TODO: avoid; no global refs; final class this_->_deserialize_body(buf); return this_; } Modified: trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicReference.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicReference.h 2009-12-18 07:44:56 UTC (rev 12322) +++ trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicReference.h 2009-12-18 14:04:03 UTC (rev 12323) @@ -144,6 +144,7 @@ AtomicReference<T>::_deserializer(x10aux::deserialization_buffer &buf) { x10aux::ref<AtomicReference<T> > this_ = new (x10aux::alloc_remote<AtomicReference<T> >()) AtomicReference<T> (); + buf.record_reference(this_); // TODO: avoid; no global refs; final class this_->_deserialize_body(buf); return this_; } Modified: trunk/x10.runtime/src-cpp/x10aux/serialization.h =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/serialization.h 2009-12-18 07:44:56 UTC (rev 12322) +++ trunk/x10.runtime/src-cpp/x10aux/serialization.h 2009-12-18 14:04:03 UTC (rev 12323) @@ -106,6 +106,10 @@ * Deserialisation of Ref instances is handled through special casing in Ref::_deserialize. The * address is read from the stream, and either the local address, a remote proxy, or null is * returned as appropriate. + * + * Classes must call buf.register_reference(R) on the deserialization buffer buf right after + * allocating the object in the DeserializationDispatcher callback (where R is the newly allocated + * object). */ @@ -143,10 +147,18 @@ { } /* Returns 0 if the pointer has not been recorded yet */ template<class T> int previous_position(const ref<T>& r) { - return _position((void*) r.operator->()); + int pos = _position((void*) r.operator->()); + if (pos == 0) { + _S_("\t\tRecorded new reference "<<((void*) r.operator->())<<" of type "<<ANSI_SER<<ANSI_BOLD<<TYPENAME(T)<<ANSI_RESET<<" at "<<(_top+pos-1)<<" (absolute) in map: "<<this); + } else { + _S_("\t\tFound repeated reference "<<((void*) r.operator->())<<" of type "<<ANSI_SER<<ANSI_BOLD<<TYPENAME(T)<<ANSI_RESET<<" at "<<(_top+pos)<<" (absolute) in map: "<<this); + } + return pos; } template<class T> ref<T> get_at_position(int pos) { - return ref<T>((T*)_get(pos)); + T* val = (T*)_get(pos); + _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); } void reset() { _top = 0; assert (false); } ~addr_map() { x10aux::dealloc(_ptrs); } @@ -254,12 +266,14 @@ // serialized via the appropriate function interface. If they are ever serialized // via their exact type, this code will break (if the first captured variable in // the closure happens to have a value of -1). - int pos = buf.map.previous_position(val); - if (pos != 0) { - _S_("\tRepeated ("<<pos<<") serialization of a "<<ANSI_SER<<ANSI_BOLD<<TYPENAME(T)<<ANSI_RESET<<" into buf: "<<&buf); - buf.write((x10_uint) 0xFFFFFFFF); - buf.write((x10_int) pos); - return; + if (!val.isNull()) { + int pos = buf.map.previous_position(val); + if (pos != 0) { + _S_("\tRepeated ("<<pos<<") serialization of a "<<ANSI_SER<<ANSI_BOLD<<TYPENAME(T)<<ANSI_RESET<<" into buf: "<<&buf); + buf.write((x10_uint) 0xFFFFFFFF); + buf.write((x10_int) pos); + return; + } } // Depends what T is (interface/Ref/Closure) T::_serialize(val,buf); @@ -294,10 +308,21 @@ cursor = saved_cursor; return val; } + // This has to be called every time a remote reference is created, but + // before the rest of the object is deserialized! + template<typename T> bool record_reference(ref<T> ref); // So it can access the addr_map template<class T> friend struct Read; }; + + template<typename T> bool deserialization_buffer::record_reference(ref<T> ref) { + int pos = map.previous_position(ref); + if (pos != 0) { + _S_("\t"<<ANSI_SER<<ANSI_BOLD<<"OOPS!"<<ANSI_RESET<<" Attempting to repeatedly record a reference "<<((void*)ref.operator->())<<" (already found at position "<<pos<<") in buf: "<<this); + } + return !pos; + } // Case for non-refs (includes simple primitives like x10_int and all structs) template<class T> struct deserialization_buffer::Read { @@ -355,12 +380,7 @@ return buf.map.get_at_position<T>(pos); } // Dispatch because we don't know what it is - ref<T> res = T::template _deserialize<T>(buf); - int pos = buf.map.previous_position(res); - if (pos != 0) { - _S_("\t"<<ANSI_SER<<ANSI_BOLD<<"OOPS!"<<ANSI_RESET<<" Deserialized value found at position ("<<pos<<") in buf: "<<&buf); - } - return res; + return T::template _deserialize<T>(buf); } template<typename T> GPUSAFE T deserialization_buffer::read() { Modified: trunk/x10.runtime/src-x10/x10/runtime/Thread.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/runtime/Thread.x10 2009-12-18 07:44:56 UTC (rev 12322) +++ trunk/x10.runtime/src-x10/x10/runtime/Thread.x10 2009-12-18 14:04:03 UTC (rev 12323) @@ -26,7 +26,7 @@ @NativeRep("java", "x10.runtime.impl.java.Thread", null, null) @NativeRep("c++", "x10aux::ref<x10::runtime::Thread>", "x10::runtime::Thread", null) -public class Thread { +final class Thread { /** * Allocates new thread in current place Modified: trunk/x10.runtime/src-x10/x10/util/concurrent/atomic/AtomicBoolean.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/util/concurrent/atomic/AtomicBoolean.x10 2009-12-18 07:44:56 UTC (rev 12322) +++ trunk/x10.runtime/src-x10/x10/util/concurrent/atomic/AtomicBoolean.x10 2009-12-18 14:04:03 UTC (rev 12323) @@ -14,7 +14,7 @@ @NativeRep("java", "java.util.concurrent.atomic.AtomicBoolean", null, null) @NativeRep("c++", "x10aux::ref<x10::util::concurrent::atomic::AtomicBoolean>", "x10::util::concurrent::atomic::AtomicBoolean", null) -public class AtomicBoolean { +public final class AtomicBoolean { public native def this():AtomicBoolean; public native def this(val:boolean):AtomicBoolean; Modified: trunk/x10.runtime/src-x10/x10/util/concurrent/atomic/AtomicInteger.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/util/concurrent/atomic/AtomicInteger.x10 2009-12-18 07:44:56 UTC (rev 12322) +++ trunk/x10.runtime/src-x10/x10/util/concurrent/atomic/AtomicInteger.x10 2009-12-18 14:04:03 UTC (rev 12323) @@ -12,12 +12,12 @@ import x10.compiler.Native; import x10.compiler.NativeRep; -/** - vj: Making this a struct is a hack to get around place types. +/* + * vj: Making the methods global is a hack for the Java backend. */ @NativeRep("java", "java.util.concurrent.atomic.AtomicInteger", null, null) @NativeRep("c++", "x10aux::ref<x10::util::concurrent::atomic::AtomicInteger>", "x10::util::concurrent::atomic::AtomicInteger", null) -public class AtomicInteger { +public final class AtomicInteger { public native def this(): AtomicInteger; public native def this(val:int): AtomicInteger; Modified: trunk/x10.runtime/src-x10/x10/util/concurrent/atomic/AtomicLong.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/util/concurrent/atomic/AtomicLong.x10 2009-12-18 07:44:56 UTC (rev 12322) +++ trunk/x10.runtime/src-x10/x10/util/concurrent/atomic/AtomicLong.x10 2009-12-18 14:04:03 UTC (rev 12323) @@ -14,7 +14,7 @@ @NativeRep("java", "java.util.concurrent.atomic.AtomicLong", null, null) @NativeRep("c++", "x10aux::ref<x10::util::concurrent::atomic::AtomicLong>", "x10::util::concurrent::atomic::AtomicLong", null) -public class AtomicLong { +public final class AtomicLong { public native def this():AtomicLong; public native def this(val:long):AtomicLong; Modified: trunk/x10.runtime/src-x10/x10/util/concurrent/atomic/AtomicReference.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/util/concurrent/atomic/AtomicReference.x10 2009-12-18 07:44:56 UTC (rev 12322) +++ trunk/x10.runtime/src-x10/x10/util/concurrent/atomic/AtomicReference.x10 2009-12-18 14:04:03 UTC (rev 12323) @@ -14,7 +14,7 @@ @NativeRep("java", "java.util.concurrent.atomic.AtomicReference<#1>", null, null) @NativeRep("c++", "x10aux::ref<x10::util::concurrent::atomic::AtomicReference<#1 > >", "x10::util::concurrent::atomic::AtomicReference<#1 >", null) -public class AtomicReference[T]{T<:Object} { +public final class AtomicReference[T]{T<:Object} { // Unusable due to compiler bug. See http://jira.codehaus.org/browse/XTENLANG-127 // public native def this():AtomicReference[T]; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dgr...@us...> - 2009-12-18 18:23:22
|
Revision: 12325 http://x10.svn.sourceforge.net/x10/?rev=12325&view=rev Author: dgrove-oss Date: 2009-12-18 18:23:11 +0000 (Fri, 18 Dec 2009) Log Message: ----------- Work in progress on making the C++ and X10 level views of the class hierarchy more consistient. (1) Introduce a C++ level superclass of Object and Closure called Reference. This provides a place to define implementation-level virtual methods that are available on all Object and Closure subclasses (but not on structs). (2) Move equals and hashcode down to Ref (since they are at least for the moment not defined on Closure). (3) Fix various 1.7isms in the RTT defintions. In particular, (a) structs don't have Object as a parent (b) Closure doesn't have Object as a parent (c) Interfaces don't have Object as a parent. (4) Closure is an abstract class, therefore it doesn't need a consturctor or most of the serialization/deserialization methods. Modified Paths: -------------- trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java trunk/x10.runtime/src-cpp/Makefile trunk/x10.runtime/src-cpp/x10/lang/Closure.cc trunk/x10.runtime/src-cpp/x10/lang/Closure.h trunk/x10.runtime/src-cpp/x10/lang/Fun.cc trunk/x10.runtime/src-cpp/x10/lang/Object.cc trunk/x10.runtime/src-cpp/x10/lang/Object.h trunk/x10.runtime/src-cpp/x10/lang/Rail.cc trunk/x10.runtime/src-cpp/x10/lang/Rail.h trunk/x10.runtime/src-cpp/x10/lang/ValRail.h trunk/x10.runtime/src-cpp/x10/runtime/Thread.cc trunk/x10.runtime/src-cpp/x10/runtime/Thread.h trunk/x10.runtime/src-cpp/x10aux/RTT.cc trunk/x10.runtime/src-cpp/x10aux/RTT.h trunk/x10.runtime/src-cpp/x10aux/basic_functions.h trunk/x10.runtime/src-cpp/x10aux/bootstrap.h trunk/x10.runtime/src-cpp/x10aux/class_cast.h trunk/x10.runtime/src-cpp/x10aux/fun_utils.h trunk/x10.runtime/src-cpp/x10aux/init_dispatcher.cc trunk/x10.runtime/src-cpp/x10aux/itables.h trunk/x10.runtime/src-cpp/x10aux/network.cc trunk/x10.runtime/src-cpp/x10aux/network.h trunk/x10.runtime/src-cpp/x10aux/ref.cc trunk/x10.runtime/src-cpp/x10aux/ref.h trunk/x10.runtime/src-cpp/x10aux/serialization.h Added Paths: ----------- trunk/x10.runtime/src-cpp/x10/lang/Reference.cc trunk/x10.runtime/src-cpp/x10/lang/Reference.h Modified: trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java =================================================================== --- trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java 2009-12-18 15:45:34 UTC (rev 12324) +++ trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java 2009-12-18 18:23:11 UTC (rev 12325) @@ -1167,21 +1167,23 @@ 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::Object::"+SERIALIZE_METHOD+"(this_, buf);"); h.end(); h.newline(); + h.write("x10::lang::Reference::"+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::Object::"+DESERIALIZE_METHOD+"<__T>(buf);"); h.end(); h.newline(); + h.write("return x10::lang::Reference::"+DESERIALIZE_METHOD+"<__T>(buf);"); h.end(); h.newline(); h.write("}"); h.newline(); h.forceNewline(); /* equals redirection method: Something of an interface type is a subclass of Object even if C++ doesn't know that... */ + // FIXME: XTENLANG-752. This is wrong in X10 2.0 because closures implement interfaces, but are not objects. h.write("x10_boolean equals(x10aux::ref<x10::lang::Object> that) {"); h.newline(4); h.begin(0); h.write("return x10aux::class_cast_unchecked<x10aux::ref<x10::lang::Object> >(this)->equals(that);"); h.end(); h.newline(); h.write("}"); h.newline(); h.forceNewline(); /* hashCode redirection method: Something of an interface type is a subclass of Object even if C++ doesn't know that... */ + // FIXME: XTENLANG-752. This is wrong in X10 2.0 because closures implement interfaces, but are not objects. h.write("x10_int hashCode() {"); h.newline(4); h.begin(0); h.write("return x10aux::class_cast_unchecked<x10aux::ref<x10::lang::Object> >(this)->hashCode();"); h.end(); h.newline(); @@ -2808,7 +2810,7 @@ if (t.isClass()) { X10ClassType clsType = (X10ClassType)t.toClass(); if (clsType.flags().isInterface()) { - invokeInterface(n, (Expr) target, args, make_ref("x10::lang::Object"), clsType, mi, needsPlaceCheck, needsNullCheck); + invokeInterface(n, (Expr) target, args, make_ref("x10::lang::Reference"), clsType, mi, needsPlaceCheck, needsNullCheck); sw.end(); return; } @@ -2951,7 +2953,7 @@ sw.allowBreak(0, " "); } boolean needsCast = true; - sw.write("(((x10::lang::Object*)("); + sw.write("(((x10::lang::Reference*)("); if (!replicate) { sw.write("_"); } else { @@ -3635,7 +3637,7 @@ if (needsNullCheck) sw.write(")"); sw.writeln(")->iterator();"); } - sw.write((doubleTemplate ? "typename " : "")+iteratorType+"::"+(doubleTemplate ? "template ":"")+"itable<x10::lang::Object> *"+itableName+" = x10aux::findITable"+chevrons(iteratorType)+"("+name+"->_getITables());"); sw.newline(); + sw.write((doubleTemplate ? "typename " : "")+iteratorType+"::"+(doubleTemplate ? "template ":"")+"itable<x10::lang::Reference> *"+itableName+" = x10aux::findITable"+chevrons(iteratorType)+"("+name+"->_getITables());"); sw.newline(); sw.write("for ("); sw.begin(0); @@ -4279,7 +4281,7 @@ } catch (SemanticException e) { assert (false); } - invokeInterface(c, target, args, make_ref("x10::lang::Object"), t.toClass(), ami, needsPlaceCheck, needsNullCheck); + invokeInterface(c, target, args, make_ref("x10::lang::Reference"), t.toClass(), ami, needsPlaceCheck, needsNullCheck); return; } else { if (needsPlaceCheck) sw.write("x10aux::placeCheck("); Modified: trunk/x10.runtime/src-cpp/Makefile =================================================================== --- trunk/x10.runtime/src-cpp/Makefile 2009-12-18 15:45:34 UTC (rev 12324) +++ trunk/x10.runtime/src-cpp/Makefile 2009-12-18 18:23:11 UTC (rev 12325) @@ -243,6 +243,7 @@ x10/lang/Object.o \ x10/lang/Rail.o \ x10/lang/Ref.o \ + x10/lang/Reference.o \ x10/lang/String.o \ x10/lang/Struct.o \ x10/lang/Throwable.o \ Modified: trunk/x10.runtime/src-cpp/x10/lang/Closure.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Closure.cc 2009-12-18 15:45:34 UTC (rev 12324) +++ trunk/x10.runtime/src-cpp/x10/lang/Closure.cc 2009-12-18 18:23:11 UTC (rev 12325) @@ -9,9 +9,6 @@ using namespace x10::lang; using namespace x10aux; -const serialization_id_t Closure::_serialization_id = - DeserializationDispatcher::addDeserializer(Closure::_deserializer<Ref>); - void Closure::_serialize(x10aux::ref<Closure> this_, x10aux::serialization_buffer &buf) { @@ -22,22 +19,8 @@ this_->_serialize_body(buf); } -x10aux::ref<Closure> Closure::_make() { - return (new (x10aux::alloc<Closure>()) Closure())->_constructor(); -} - x10aux::ref<x10::lang::String> x10::lang::Closure::toString() { return String::Lit("Closure without toString defined."); } -x10_boolean -Closure::_struct_equals(x10aux::ref<Object> other) { - if (!_type()->concreteInstanceOf(other)) - return false; - // now compare fields but there aren't any - return true; -} - -RTT_CC_DECLS1(Closure, "x10.lang.Closure", Object) - // vim:tabstop=4:shiftwidth=4:expandtab Modified: trunk/x10.runtime/src-cpp/x10/lang/Closure.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Closure.h 2009-12-18 15:45:34 UTC (rev 12324) +++ trunk/x10.runtime/src-cpp/x10/lang/Closure.h 2009-12-18 18:23:11 UTC (rev 12325) @@ -6,52 +6,35 @@ #include <x10aux/serialization.h> #include <x10aux/RTT.h> -#include <x10/lang/Object.h> +#include <x10/lang/Reference.h> namespace x10 { namespace lang { class String; } } namespace x10 { namespace lang { - class Closure : public Object { + /** + * This is a class that exists only at the C++ implementation level, + * not at the X10 language level. Therefore it does not have an + * associated RTT. + * + * The purpose of this class is to provide a common C++ level superclass + * for all X10 closures. This provides a class in which to locate object model + * and other serialization/deserialization functions that are common for all + * concrete Closure instances. This is an abstract class. + */ + class Closure : public Reference { public: - RTT_H_DECLS_CLASS - Closure() { location = x10aux::here; } - static x10aux::ref<Closure> _make(); - - x10aux::ref<Closure> _constructor() { return this; } - - static const x10aux::serialization_id_t _serialization_id; - - virtual x10aux::serialization_id_t _get_serialization_id() { return _serialization_id; }; - - virtual void _serialize_body(x10aux::serialization_buffer &) { - // there are no fields - } - - template<class T> static x10aux::ref<T> _deserializer(x10aux::deserialization_buffer &); - - void _deserialize_body(x10aux::deserialization_buffer &) { - // there are no fields - } - static void _serialize(x10aux::ref<Closure> this_, x10aux::serialization_buffer &buf); template<class T> static x10aux::ref<T> _deserialize(x10aux::deserialization_buffer &buf); - virtual x10_int hashCode() { - // All instances of Closure are equal, so their hashcodes can be too. - return 0; - } - virtual x10aux::ref<String> toString(); - - virtual x10_boolean _struct_equals(x10aux::ref<Object> other); }; template<class T> x10aux::ref<T> Closure::_deserialize(x10aux::deserialization_buffer &buf){ @@ -60,12 +43,6 @@ " (expecting id) from buf: "<<&buf); return x10aux::DeserializationDispatcher::create<T>(buf); } - - template<class T> x10aux::ref<T> Closure::_deserializer(x10aux::deserialization_buffer &buf) { - x10aux::ref<Closure> this_ = new (x10aux::alloc<Closure>()) Closure(); - buf.record_reference(this_); // TODO: avoid; closure - return this_; - } } } Modified: trunk/x10.runtime/src-cpp/x10/lang/Fun.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Fun.cc 2009-12-18 15:45:34 UTC (rev 12324) +++ trunk/x10.runtime/src-cpp/x10/lang/Fun.cc 2009-12-18 18:23:11 UTC (rev 12325) @@ -2,7 +2,6 @@ #include <x10aux/alloc.h> #include <x10aux/RTT.h> -#include <x10/lang/Object.h> #include <x10/lang/Fun_0_0.h> #include <x10/lang/Fun_0_1.h> #include <x10/lang/Fun_0_2.h> @@ -38,6 +37,7 @@ x10aux::RuntimeType Fun_0_8<void,void,void,void,void,void,void,void,void>::rtt; x10aux::RuntimeType Fun_0_9<void,void,void,void,void,void,void,void,void,void>::rtt; +x10aux::RuntimeType VoidFun_0_0::rtt; x10aux::RuntimeType VoidFun_0_1<void>::rtt; x10aux::RuntimeType VoidFun_0_2<void,void>::rtt; x10aux::RuntimeType VoidFun_0_3<void,void,void>::rtt; @@ -48,28 +48,31 @@ x10aux::RuntimeType VoidFun_0_8<void,void,void,void,void,void,void,void>::rtt; x10aux::RuntimeType VoidFun_0_9<void,void,void,void,void,void,void,void,void>::rtt; -RTT_CC_DECLS1(VoidFun_0_0, "x10.lang.VoidFun", Object) - namespace x10 { namespace lang { + void + VoidFun_0_0::_initRTT() { + rtt.canonical = &(VoidFun_0_0::rtt); + rtt.init(&rtt, "x10::lang::VoidFun_0_0", 0, NULL, 0, NULL, NULL); + } + + void _initRTTHelper_Fun_0_0(RuntimeType *location, const RuntimeType *rtt0) { - const RuntimeType* parents[1] = { Object::getRTT() }; const RuntimeType* params[1] = { rtt0 }; RuntimeType::Variance variances[1] = { RuntimeType::covariant }; const RuntimeType* canonical = getRTT<Fun_0_0<void> >(); const char *name = alloc_printf("x10.lang.Fun_0_0[%s]",rtt0->name()); - location->init(canonical, name, 1, parents, 1, params, variances); + location->init(canonical, name, 0, NULL, 1, params, variances); } void _initRTTHelper_Fun_0_1(RuntimeType *location, const RuntimeType *rtt0, const RuntimeType *rtt1) { - const RuntimeType* parents[1] = { Object::getRTT() }; const RuntimeType* params[2] = { rtt0, rtt1 }; RuntimeType::Variance variances[2] = { RuntimeType::covariant, RuntimeType::contravariant }; const RuntimeType* canonical = getRTT<Fun_0_1<void, void> >(); const char *name = alloc_printf("x10.lang.Fun_0_1[%s,%s]", rtt0->name(), rtt1->name()); - location->init(canonical, name, 1, parents, 2, params, variances); + location->init(canonical, name, 0, NULL, 2, params, variances); } void @@ -77,13 +80,12 @@ const RuntimeType *rtt0, const RuntimeType *rtt1, const RuntimeType *rtt2) { - const RuntimeType* parents[1] = { Object::getRTT() }; const RuntimeType* params[3] = { rtt0, rtt1, rtt2 }; RuntimeType::Variance variances[] = { RuntimeType::covariant, RuntimeType::contravariant, RuntimeType::contravariant }; const char *name = alloc_printf("x10.lang.Fun_0_2[%s,%s,%s]", rtt0->name(), rtt1->name(), rtt2->name()); const RuntimeType* canonical = getRTT<Fun_0_2<void, void, void> >(); - location->init(canonical, name, 1, parents, 3, params, variances); + location->init(canonical, name, 0, NULL, 3, params, variances); } void @@ -92,13 +94,12 @@ const RuntimeType *rtt1, const RuntimeType *rtt2, const RuntimeType *rtt3) { - const RuntimeType* parents[1] = { Object::getRTT() }; const RuntimeType* params[4] = { rtt0, rtt1, rtt2, rtt3 }; RuntimeType::Variance variances[4] = { RuntimeType::covariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant }; const char *name = alloc_printf("x10.lang.Fun_0_3[%s,%s,%s,%s]", rtt0->name(), rtt1->name(), rtt2->name(), rtt3->name()); const RuntimeType* canonical = getRTT<Fun_0_3<void, void, void, void> >(); - location->init(canonical, name, 1, parents, 4, params, variances); + location->init(canonical, name, 0, NULL, 4, params, variances); } void @@ -108,13 +109,12 @@ const RuntimeType *rtt2, const RuntimeType *rtt3, const RuntimeType *rtt4) { - const RuntimeType* parents[1] = { Object::getRTT() }; const RuntimeType* params[5] = { rtt0, rtt1, rtt2, rtt3, rtt4 }; RuntimeType::Variance variances[5] = { RuntimeType::covariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant }; const RuntimeType* canonical = getRTT<Fun_0_4<void, void, void, void, void> >(); const char *name = alloc_printf("x10.lang.Fun_0_4[%s,%s,%s,%s,%s]", rtt0->name(), rtt1->name(), rtt2->name(), rtt3->name(), rtt4->name()); - location->init(canonical, name, 1, parents, 5, params, variances); + location->init(canonical, name, 0, NULL, 5, params, variances); } void @@ -125,7 +125,6 @@ const RuntimeType *rtt3, const RuntimeType *rtt4, const RuntimeType *rtt5) { - const RuntimeType* parents[1] = { Object::getRTT() }; const RuntimeType* params[6] = { rtt0, rtt1, rtt2, rtt3, rtt4, rtt5 }; RuntimeType::Variance variances[6] = { RuntimeType::covariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant }; @@ -133,7 +132,7 @@ const char *name = alloc_printf("x10.lang.Fun_0_5[%s,%s,%s,%s,%s,%s]", rtt0->name(), rtt1->name(), rtt2->name(), rtt3->name(), rtt4->name(), rtt5->name()); - location->init(canonical, name, 1, parents, 6, params, variances); + location->init(canonical, name, 0, NULL, 6, params, variances); } void @@ -145,7 +144,6 @@ const RuntimeType *rtt4, const RuntimeType *rtt5, const RuntimeType *rtt6) { - const RuntimeType* parents[1] = { Object::getRTT() }; const RuntimeType* params[7] = { rtt0, rtt1, rtt2, rtt3, rtt4, rtt5, rtt6 }; RuntimeType::Variance variances[7] = { RuntimeType::covariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant }; @@ -153,7 +151,7 @@ const char *name = alloc_printf("x10.lang.Fun_0_6[%s,%s,%s,%s,%s,%s,%s]", rtt0->name(), rtt1->name(), rtt2->name(), rtt3->name(), rtt4->name(), rtt5->name(), rtt6->name()); - location->init(canonical, name, 1, parents, 7, params, variances); + location->init(canonical, name, 0, NULL, 7, params, variances); } void @@ -166,7 +164,6 @@ const RuntimeType *rtt5, const RuntimeType *rtt6, const RuntimeType *rtt7) { - const RuntimeType* parents[1] = { Object::getRTT() }; const RuntimeType* params[8] = { rtt0, rtt1, rtt2, rtt3, rtt4, rtt5, rtt6, rtt7 }; RuntimeType::Variance variances[8] = { RuntimeType::covariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant }; @@ -174,7 +171,7 @@ const char *name = alloc_printf("x10.lang.Fun_0_7[%s,%s,%s,%s,%s,%s,%s,%s]", rtt0->name(), rtt1->name(), rtt2->name(), rtt3->name(), rtt4->name(), rtt5->name(), rtt6->name(), rtt7->name()); - location->init(canonical, name, 1, parents, 8, params, variances); + location->init(canonical, name, 0, NULL, 8, params, variances); } void @@ -188,7 +185,6 @@ const RuntimeType *rtt6, const RuntimeType *rtt7, const RuntimeType *rtt8) { - const RuntimeType* parents[1] = { Object::getRTT() }; const RuntimeType* params[9] = { rtt0, rtt1, rtt2, rtt3, rtt4, rtt5, rtt6, rtt7, rtt8 }; RuntimeType::Variance variances[9] = { RuntimeType::covariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant }; @@ -196,7 +192,7 @@ const char *name = alloc_printf("x10.lang.Fun_0_8[%s,%s,%s,%s,%s,%s,%s,%s,%s]", rtt0->name(), rtt1->name(), rtt2->name(), rtt3->name(), rtt4->name(), rtt5->name(), rtt6->name(), rtt7->name(), rtt8->name()); - location->init(canonical, name, 1, parents, 9, params, variances); + location->init(canonical, name, 0, NULL, 9, params, variances); } void @@ -211,7 +207,6 @@ const RuntimeType *rtt7, const RuntimeType *rtt8, const RuntimeType *rtt9) { - const RuntimeType* parents[1] = { Object::getRTT() }; const RuntimeType* params[10] = { rtt0, rtt1, rtt2, rtt3, rtt4, rtt5, rtt6, rtt7, rtt8, rtt9 }; RuntimeType::Variance variances[10] = { RuntimeType::covariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant }; @@ -219,30 +214,28 @@ const char *name = alloc_printf("x10.lang.Fun_0_9[%s,%s,%s,%s,%s,%s,%s,%s,%s,%s]", rtt0->name(), rtt1->name(), rtt2->name(), rtt3->name(), rtt4->name(), rtt5->name(), rtt6->name(), rtt7->name(), rtt8->name(), rtt9->name()); - location->init(canonical, name, 1, parents, 10, params, variances); + location->init(canonical, name, 0, NULL, 10, params, variances); } void _initRTTHelper_VoidFun_0_1(RuntimeType *location, const RuntimeType *rtt1) { - const RuntimeType* parents[1] = { Object::getRTT() }; const RuntimeType* params[1] = { rtt1 }; RuntimeType::Variance variances[] = { RuntimeType::contravariant }; const RuntimeType* canonical = getRTT<VoidFun_0_1<void> >(); const char *name = alloc_printf("x10.lang.VoidFun_0_1[%s]", rtt1->name()); - location->init(canonical, name, 1, parents, 1, params, variances); + location->init(canonical, name, 0, NULL, 1, params, variances); } void _initRTTHelper_VoidFun_0_2(RuntimeType *location, const RuntimeType *rtt1, const RuntimeType *rtt2) { - const RuntimeType* parents[1] = { Object::getRTT() }; const RuntimeType* params[2] = { rtt1, rtt2 }; RuntimeType::Variance variances[2] = { RuntimeType::contravariant, RuntimeType::contravariant }; const RuntimeType* canonical = getRTT<VoidFun_0_2<void, void> >(); const char *name = alloc_printf("x10.lang.VoidFun_0_2[%s,%s]", rtt1->name(), rtt2->name()); - location->init(canonical, name, 1, parents, 2, params, variances); + location->init(canonical, name, 0, NULL, 2, params, variances); } void @@ -250,13 +243,12 @@ const RuntimeType *rtt1, const RuntimeType *rtt2, const RuntimeType *rtt3) { - const RuntimeType* parents[1] = { Object::getRTT() }; const RuntimeType* params[3] = { rtt1, rtt2, rtt3 }; RuntimeType::Variance variances[3] = { RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant }; const RuntimeType* canonical = getRTT<VoidFun_0_3<void, void, void> >(); const char *name = alloc_printf("x10.lang.VoidFun_0_3[%s,%s,%s]", rtt1->name(), rtt2->name(), rtt3->name()); - location->init(canonical, name, 1, parents, 3, params, variances); + location->init(canonical, name, 0, NULL, 3, params, variances); } void @@ -265,13 +257,12 @@ const RuntimeType *rtt2, const RuntimeType *rtt3, const RuntimeType *rtt4) { - const RuntimeType* parents[1] = { Object::getRTT() }; const RuntimeType* params[4] = { rtt1, rtt2, rtt3, rtt4 }; RuntimeType::Variance variances[4] = { RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant }; const RuntimeType* canonical = getRTT<VoidFun_0_4<void, void, void, void> >(); const char *name = alloc_printf("x10.lang.VoidFun_0_4[%s,%s,%s,%s]", rtt1->name(), rtt2->name(), rtt3->name(), rtt4->name()); - location->init(canonical, name, 1, parents, 4, params, variances); + location->init(canonical, name, 0, NULL, 4, params, variances); } void @@ -281,14 +272,13 @@ const RuntimeType *rtt3, const RuntimeType *rtt4, const RuntimeType *rtt5) { - const RuntimeType* parents[1] = { Object::getRTT() }; const RuntimeType* params[5] = { rtt1, rtt2, rtt3, rtt4, rtt5 }; RuntimeType::Variance variances[5] = { RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant }; const RuntimeType* canonical = getRTT<VoidFun_0_5<void, void, void, void, void> >(); const char *name = alloc_printf("x10.lang.VoidFun_0_5[%s,%s,%s,%s,%s]", rtt1->name(), rtt2->name(), rtt3->name(), rtt4->name(), rtt5->name()); - location->init(canonical, name, 1, parents, 5, params, variances); + location->init(canonical, name, 0, NULL, 5, params, variances); } void @@ -299,7 +289,6 @@ const RuntimeType *rtt4, const RuntimeType *rtt5, const RuntimeType *rtt6) { - const RuntimeType* parents[1] = { Object::getRTT() }; const RuntimeType* params[6] = { rtt1, rtt2, rtt3, rtt4, rtt5, rtt6 }; RuntimeType::Variance variances[6] = { RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant }; @@ -307,7 +296,7 @@ const char *name = alloc_printf("x10.lang.VoidFun_0_6[%s,%s,%s,%s,%s,%s]", rtt1->name(), rtt2->name(), rtt3->name(), rtt4->name(), rtt5->name(), rtt6->name()); - location->init(canonical, name, 1, parents, 6, params, variances); + location->init(canonical, name, 0, NULL, 6, params, variances); } void @@ -319,7 +308,6 @@ const RuntimeType *rtt5, const RuntimeType *rtt6, const RuntimeType *rtt7) { - const RuntimeType* parents[1] = { Object::getRTT() }; const RuntimeType* params[7] = { rtt1, rtt2, rtt3, rtt4, rtt5, rtt6, rtt7 }; RuntimeType::Variance variances[7] = { RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant }; @@ -327,7 +315,7 @@ const char *name = alloc_printf("x10.lang.VoidFun_0_7[%s,%s,%s,%s,%s,%s,%s]", rtt1->name(), rtt2->name(), rtt3->name(), rtt4->name(), rtt5->name(), rtt6->name(), rtt7->name()); - location->init(canonical, name, 1, parents, 7, params, variances); + location->init(canonical, name, 0, NULL, 7, params, variances); } void @@ -340,7 +328,6 @@ const RuntimeType *rtt6, const RuntimeType *rtt7, const RuntimeType *rtt8) { - const RuntimeType* parents[1] = { Object::getRTT() }; const RuntimeType* params[8] = { rtt1, rtt2, rtt3, rtt4, rtt5, rtt6, rtt7, rtt8 }; RuntimeType::Variance variances[8] = { RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant }; @@ -349,7 +336,7 @@ rtt1->name(), rtt2->name(), rtt3->name(), rtt4->name(), rtt5->name(), rtt6->name(), rtt7->name(), rtt8->name()); - location->init(canonical, name, 1, parents, 8, params, variances); + location->init(canonical, name, 0, NULL, 8, params, variances); } void @@ -363,7 +350,6 @@ const RuntimeType *rtt7, const RuntimeType *rtt8, const RuntimeType *rtt9) { - const RuntimeType* parents[1] = { Object::getRTT() }; const RuntimeType* params[9] = { rtt1, rtt2, rtt3, rtt4, rtt5, rtt6, rtt7, rtt8, rtt9 }; RuntimeType::Variance variances[9] = { RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant, RuntimeType::contravariant }; @@ -372,7 +358,7 @@ rtt1->name(), rtt2->name(), rtt3->name(), rtt4->name(), rtt5->name(), rtt6->name(), rtt7->name(), rtt8->name(), rtt9->name()); - location->init(canonical, name, 1, parents, 9, params, variances); + location->init(canonical, name, 0, NULL, 9, params, variances); } } } Modified: trunk/x10.runtime/src-cpp/x10/lang/Object.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Object.cc 2009-12-18 15:45:34 UTC (rev 12324) +++ trunk/x10.runtime/src-cpp/x10/lang/Object.cc 2009-12-18 18:23:11 UTC (rev 12325) @@ -7,24 +7,6 @@ using namespace x10::lang; using namespace x10aux; -void Object::_serialize_interface(x10aux::serialization_buffer &buf) -{ - _S_("Serializing the "<<ANSI_SER<<"interface body"<<ANSI_RESET<<" to buf: "<<&buf); - this->_serialize_body(buf); -} - -void Object::_serialize(x10aux::ref<Object> this_, - x10aux::serialization_buffer &buf) -{ - bool isNull = this_.isNull(); - x10aux::serialization_id_t id = isNull ? 0 : this_->_get_interface_serialization_id(); - _S_("Serializing an "<<ANSI_SER<<ANSI_BOLD<<"interface id "<<id<<ANSI_RESET<<" to buf: "<<&buf); - buf.write(id); - if (!isNull) { - this_->_serialize_interface(buf); - } -} - x10_boolean Object::equals(x10aux::ref<Object> other) { return this->_struct_equals(other); } Modified: trunk/x10.runtime/src-cpp/x10/lang/Object.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Object.h 2009-12-18 15:45:34 UTC (rev 12324) +++ trunk/x10.runtime/src-cpp/x10/lang/Object.h 2009-12-18 18:23:11 UTC (rev 12325) @@ -1,14 +1,8 @@ #ifndef X10_LANG_OBJECT_H #define X10_LANG_OBJECT_H -#include <x10aux/config.h> -#include <x10aux/ref.h> -#include <x10aux/RTT.h> -#include <x10aux/itables.h> +#include <x10/lang/Reference.h> -#include <x10aux/serialization.h> -#include <x10aux/deserialization_dispatcher.h> - namespace x10 { namespace lang { @@ -16,7 +10,7 @@ class String; class Ref; - class Object { + class Object : public Reference { private: static x10aux::itable_entry _itables[1]; @@ -24,67 +18,20 @@ RTT_H_DECLS_CLASS virtual x10aux::itable_entry* _getITables() { return _itables; } - - x10aux::place location; Object(){ } virtual ~Object() { } - - virtual x10aux::serialization_id_t _get_serialization_id() = 0; - virtual void _serialize_body(x10aux::serialization_buffer &) = 0; - - // This pair of functions should be overridden to not emit/extract the id in subclasses - // that satisfy the following property: - // - // "All instances of all my subclasses are de/serialised by the same code" - // - // Examples of classes that satisfy this property: All final classes, and root classes - // in hierarchies that use double dispatch for deserialization (to save serialization id - // space). - // - // If one of these functions is overridden, the other should be too. - // - // Note these functions are static as we want to dispatch on the static type. - - static void _serialize(x10aux::ref<Object> this_, - x10aux::serialization_buffer &buf); - - // Should only be overridden in Ref - virtual x10aux::serialization_id_t _get_interface_serialization_id() { - _S_("===> Object's _get_interface_serialization_id() called"); - return _get_serialization_id(); - } - // Should only be overridden in Ref - virtual void _serialize_interface(x10aux::serialization_buffer &buf); - - template<class T> static x10aux::ref<T> _deserialize(x10aux::deserialization_buffer &buf); - virtual x10_boolean equals(x10aux::ref<Object> other); virtual x10_int hashCode() = 0; - virtual x10aux::ref<String> toString() = 0; - // Needed for linking - non-values should not override virtual x10_boolean _struct_equals(x10aux::ref<Object> other) { if (other == x10aux::ref<Object>(this)) return true; return false; } - }; - - template<class T> x10aux::ref<T> Object::_deserialize(x10aux::deserialization_buffer &buf) { - x10aux::serialization_id_t id = buf.peek<x10aux::serialization_id_t>(); - if (id == 0) { - buf.read<x10aux::serialization_id_t>(); - return x10aux::null; - } - // extract the id and execute a callback to instantiate the right concrete class - _S_("Deserializing an "<<ANSI_SER<<ANSI_BOLD<<"interface"<<ANSI_RESET<< - " (expecting id " << id << ") from buf: "<<&buf); - return x10aux::DeserializationDispatcher::create<T>(buf); - } } } Modified: trunk/x10.runtime/src-cpp/x10/lang/Rail.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Rail.cc 2009-12-18 15:45:34 UTC (rev 12324) +++ trunk/x10.runtime/src-cpp/x10/lang/Rail.cc 2009-12-18 18:23:11 UTC (rev 12325) @@ -29,7 +29,7 @@ void x10::lang::Rail_notifyEnclosingFinish(deserialization_buffer& buf) { - ref<Object> fs = buf.read<ref<Object> >(); + ref<Reference> fs = buf.read<ref<Reference> >(); ref<x10::runtime::Runtime> rt = x10::runtime::Runtime::FMGL(runtime)->get(); // olivier says the incr should be just after the notifySubActivitySpawn (fs.operator->()->*(findITable<x10::runtime::FinishState>(fs->_getITables())->notifyActivityCreation))(); @@ -41,7 +41,7 @@ // dst is the place where the finish update will occur, i.e. where the notifier runs dst = x10aux::parent(dst); ref<x10::runtime::Runtime> rt = x10::runtime::Runtime::FMGL(runtime)->get(); - ref<Object> fs = rt->currentState(); + ref<Reference> fs = rt->currentState(); (fs.operator->()->*(findITable<x10::runtime::FinishState>(fs->_getITables())->notifySubActivitySpawn))(x10::lang::Place_methods::_make(dst)); buf.write(fs); } Modified: trunk/x10.runtime/src-cpp/x10/lang/Rail.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Rail.h 2009-12-18 15:45:34 UTC (rev 12324) +++ trunk/x10.runtime/src-cpp/x10/lang/Rail.h 2009-12-18 18:23:11 UTC (rev 12325) @@ -233,10 +233,10 @@ template <class T> x10aux::ref<Rail<T> > Rail<T>::make(x10_int length, x10aux::ref<Fun_0_1<x10_int,T> > init ) { R rail = x10aux::alloc_rail<T,Rail<T> >(length); - x10aux::ref<x10::lang::Object> initAsObj = init; - typename Fun_0_1<x10_int,T>::template itable<x10::lang::Object> *it = x10aux::findITable<Fun_0_1<x10_int,T> >(initAsObj->_getITables()); + x10aux::ref<x10::lang::Reference> initAsRef = init; + typename Fun_0_1<x10_int,T>::template itable<x10::lang::Reference> *it = x10aux::findITable<Fun_0_1<x10_int,T> >(initAsRef->_getITables()); for (x10_int i=0 ; i<length ; ++i) { - (*rail)[i] = (initAsObj.operator->()->*(it->apply))(i); + (*rail)[i] = (initAsRef.operator->()->*(it->apply))(i); } return rail; } @@ -285,10 +285,10 @@ template <class T> void Rail<T>::reset(x10aux::ref<Fun_0_1<x10_int,T> > init) { - x10aux::ref<x10::lang::Object> initAsObj = init; - typename Fun_0_1<x10_int,T>::template itable<x10::lang::Object> *it = x10aux::findITable<Fun_0_1<x10_int,T> >(initAsObj->_getITables()); + x10aux::ref<x10::lang::Reference> initAsRef = init; + typename Fun_0_1<x10_int,T>::template itable<x10::lang::Reference> *it = x10aux::findITable<Fun_0_1<x10_int,T> >(initAsRef->_getITables()); for (x10_int i=0 ; i<FMGL(length) ; ++i) { - (*this)[i] = (initAsObj.operator->()->*(it->apply))(i); + (*this)[i] = (initAsRef.operator->()->*(it->apply))(i); } } @@ -332,7 +332,7 @@ break; } case 1: case 2: { // get closure with which to find rail+offset - x10aux::ref<Object> bf = buf.read<x10aux::ref<Fun_0_0<P> > >(); + 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); dst_off = pair.FMGL(second); @@ -341,7 +341,7 @@ } case 255: { // {{{ on death row dst_off = 0; - x10aux::ref<Object> bf = buf.read<x10aux::ref<Fun_0_0<R> > >(); + x10aux::ref<Reference> bf = buf.read<x10aux::ref<Fun_0_0<R> > >(); this_ = (bf.operator->()->*(x10aux::findITable<Fun_0_0<R> >(bf->_getITables())->apply))(); x10aux::dealloc(bf.operator->()); break; @@ -372,16 +372,16 @@ Rail_notifyEnclosingFinish(buf); } break; case 1: { - x10aux::ref<Object> bf = buf.read<x10aux::ref<Fun_0_0<P> > >(); + x10aux::ref<Reference> bf = buf.read<x10aux::ref<Fun_0_0<P> > >(); x10aux::dealloc(bf.operator->()); Rail_notifyEnclosingFinish(buf); break; } // case 255 on death row case 255: case 2: { - x10aux::ref<Object> bf = buf.read<x10aux::ref<Fun_0_0<P> > >(); + x10aux::ref<Reference> bf = buf.read<x10aux::ref<Fun_0_0<P> > >(); x10aux::dealloc(bf.operator->()); - x10aux::ref<Object> vf = buf.read<x10aux::ref<VoidFun_0_0> >(); + x10aux::ref<Reference> vf = buf.read<x10aux::ref<VoidFun_0_0> >(); (vf.operator->()->*(x10aux::findITable<VoidFun_0_0>(vf->_getITables())->apply))(); x10aux::dealloc(vf.operator->()); break; @@ -492,7 +492,7 @@ // check beginning and end of range x10aux::checkRailBounds(src_off, FMGL(length)); x10aux::checkRailBounds(src_off+len-1, FMGL(length)); - x10aux::ref<Object> df = dst_finder; + x10aux::ref<Reference> df = dst_finder; if (dst_place == x10aux::here) { P pair = (df.operator->()->*(x10aux::findITable<Fun_0_0<P> >(df->_getITables())->apply))(); R dst = pair.FMGL(first); @@ -527,8 +527,8 @@ // check beginning and end of range x10aux::checkRailBounds(src_off, FMGL(length)); x10aux::checkRailBounds(src_off+len-1, FMGL(length)); - x10aux::ref<Object> df = dst_finder; - x10aux::ref<Object> n = notifier; + x10aux::ref<Reference> df = dst_finder; + x10aux::ref<Reference> n = notifier; if (dst_place == x10aux::here) { P pair = (df.operator->()->*(x10aux::findITable<Fun_0_0<P> >(df->_getITables())->apply))(); R dst = pair.FMGL(first); @@ -570,8 +570,8 @@ // check beginning and end of range x10aux::checkRailBounds(src_off, FMGL(length)); x10aux::checkRailBounds(src_off+len-1, FMGL(length)); - x10aux::ref<Object> df = dst_finder; - x10aux::ref<Object> n = notifier; + x10aux::ref<Reference> df = dst_finder; + x10aux::ref<Reference> n = notifier; if (dst_place == x10aux::here) { x10aux::ref<Rail<T> > dst = (df.operator->()->*(x10aux::findITable<Fun_0_0<x10aux::ref<Rail<T> > > >(df->_getITables())->apply))(); x10_int dst_off = 0; @@ -624,7 +624,7 @@ break; } case 1: { // get rail+offset from closure - x10aux::ref<Object> bf = buf.read<x10aux::ref<Fun_0_0<P> > >(); + 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); src_off = pair.FMGL(second); @@ -657,7 +657,7 @@ Rail_notifyEnclosingFinish(buf); } break; case 1: { - x10aux::ref<Object> bf = buf.read<x10aux::ref<Fun_0_0<P> > >(); + x10aux::ref<Reference> bf = buf.read<x10aux::ref<Fun_0_0<P> > >(); x10aux::dealloc(bf.operator->()); Rail_notifyEnclosingFinish(buf); break; @@ -766,7 +766,7 @@ // check beginning and end of range x10aux::checkRailBounds(dst_off, FMGL(length)); x10aux::checkRailBounds(dst_off+len-1, FMGL(length)); - x10aux::ref<Object> df = dst_finder; + x10aux::ref<Reference> df = dst_finder; if (src_place == x10aux::here) { P pair = (df.operator->()->*(x10aux::findITable<Fun_0_0<P> >(df->_getITables())->apply))(); R src = pair.FMGL(first); Copied: trunk/x10.runtime/src-cpp/x10/lang/Reference.cc (from rev 12290, trunk/x10.runtime/src-cpp/x10/lang/Object.cc) =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Reference.cc (rev 0) +++ trunk/x10.runtime/src-cpp/x10/lang/Reference.cc 2009-12-18 18:23:11 UTC (rev 12325) @@ -0,0 +1,28 @@ +#include <x10aux/config.h> +#include <x10aux/alloc.h> + +#include <x10/lang/Reference.h> +#include <x10/lang/Ref.h> + +using namespace x10::lang; +using namespace x10aux; + +void Reference::_serialize_interface(x10aux::serialization_buffer &buf) +{ + _S_("Serializing the "<<ANSI_SER<<"interface body"<<ANSI_RESET<<" to buf: "<<&buf); + this->_serialize_body(buf); +} + +void Reference::_serialize(x10aux::ref<Reference> this_, + x10aux::serialization_buffer &buf) +{ + bool isNull = this_.isNull(); + x10aux::serialization_id_t id = isNull ? 0 : this_->_get_interface_serialization_id(); + _S_("Serializing an "<<ANSI_SER<<ANSI_BOLD<<"interface id "<<id<<ANSI_RESET<<" to buf: "<<&buf); + buf.write(id); + if (!isNull) { + this_->_serialize_interface(buf); + } +} + +// vim:tabstop=4:shiftwidth=4:expandtab Copied: trunk/x10.runtime/src-cpp/x10/lang/Reference.h (from rev 12290, trunk/x10.runtime/src-cpp/x10/lang/Object.h) =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Reference.h (rev 0) +++ trunk/x10.runtime/src-cpp/x10/lang/Reference.h 2009-12-18 18:23:11 UTC (rev 12325) @@ -0,0 +1,101 @@ +#ifndef X10_LANG_REFERENCE_H +#define X10_LANG_REFERENCE_H + +#include <x10aux/config.h> +#include <x10aux/ref.h> +#include <x10aux/RTT.h> +#include <x10aux/itables.h> + +#include <x10aux/serialization.h> +#include <x10aux/deserialization_dispatcher.h> + +namespace x10 { + + namespace lang { + + class String; + + /** + * This is a class that exists only at the C++ implementation level, + * not at the X10 language level. Therefore it does not have an + * associated RTT. + * + * The purpose of this class is to provide a common C++ level superclass + * for Object (X10 objects) and Closure (X10 closures). The common superclass + * is needed because pointers to instances of both of these classes could + * appear in variables of interface type and we need a common C++ level + * ancestor class so that virtual dispatch will work. + * This class is intentionally not a parent of Structs, because Structs + * don't have virtual methods and cannot be pointed to by variables of + * interface type. + */ + class Reference { + public: + x10aux::place location; + + Reference(){ } + virtual ~Reference() { } + + /********************************************************************************* + * Implementation-level object model functions assumed to be defined for all types + *********************************************************************************/ + virtual x10aux::itable_entry* _getITables() = 0; + + virtual const x10aux::RuntimeType *_type() const = 0; + + + /********************************************************************************* + * X10-level functions assumed to be defined for all types + *********************************************************************************/ + virtual x10aux::ref<String> toString() = 0; + + + /********************************************************************************* + * Serialization/Deserialization functions assumed to be defined for all types + *********************************************************************************/ + virtual x10aux::serialization_id_t _get_serialization_id() = 0; + virtual void _serialize_body(x10aux::serialization_buffer &) = 0; + + // This pair of functions should be overridden to not emit/extract the id in subclasses + // that satisfy the following property: + // + // "All instances of all my subclasses are de/serialised by the same code" + // + // Examples of classes that satisfy this property: All final classes, and root classes + // in hierarchies that use double dispatch for deserialization (to save serialization id + // space). + // + // If one of these functions is overridden, the other should be too. + // + // Note these functions are static as we want to dispatch on the static type. + + static void _serialize(x10aux::ref<Reference> this_, + x10aux::serialization_buffer &buf); + + // Should only be overridden in Ref + virtual x10aux::serialization_id_t _get_interface_serialization_id() { + _S_("===> Reference's _get_interface_serialization_id() called"); + return _get_serialization_id(); + } + // Should only be overridden in Ref + virtual void _serialize_interface(x10aux::serialization_buffer &buf); + + template<class T> static x10aux::ref<T> _deserialize(x10aux::deserialization_buffer &buf); + }; + + template<class T> x10aux::ref<T> Reference::_deserialize(x10aux::deserialization_buffer &buf) { + x10aux::serialization_id_t id = buf.peek<x10aux::serialization_id_t>(); + if (id == 0) { + buf.read<x10aux::serialization_id_t>(); + return x10aux::null; + } + // extract the id and execute a callback to instantiate the right concrete class + _S_("Deserializing an "<<ANSI_SER<<ANSI_BOLD<<"interface"<<ANSI_RESET<< + " (expecting id " << id << ") from buf: "<<&buf); + return x10aux::DeserializationDispatcher::create<T>(buf); + } + } +} + +#endif +// vim:tabstop=4:shiftwidth=4:expandtab:textwidth=100 Modified: trunk/x10.runtime/src-cpp/x10/lang/ValRail.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/ValRail.h 2009-12-18 15:45:34 UTC (rev 12324) +++ trunk/x10.runtime/src-cpp/x10/lang/ValRail.h 2009-12-18 18:23:11 UTC (rev 12325) @@ -156,10 +156,10 @@ template<class T> x10aux::ref<ValRail<T> > ValRail<T>::make(x10_int length, x10aux::ref<Fun_0_1<x10_int,T> > init ) { x10aux::ref<ValRail<T> > rail = x10aux::alloc_rail<T,ValRail<T> >(length); - x10aux::ref<x10::lang::Object> initAsObj = init; - typename Fun_0_1<x10_int,T>::template itable<x10::lang::Object> *it = x10aux::findITable<Fun_0_1<x10_int,T> >(initAsObj->_getITables()); + x10aux::ref<x10::lang::Reference> initAsRef = init; + typename Fun_0_1<x10_int,T>::template itable<x10::lang::Reference> *it = x10aux::findITable<Fun_0_1<x10_int,T> >(initAsRef->_getITables()); for (x10_int i=0 ; i<length ; ++i) { - (*rail)[i] = (initAsObj.operator->()->*(it->apply))(i); + (*rail)[i] = (initAsRef.operator->()->*(it->apply))(i); } return rail; } Modified: trunk/x10.runtime/src-cpp/x10/runtime/Thread.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/runtime/Thread.cc 2009-12-18 15:45:34 UTC (rev 12324) +++ trunk/x10.runtime/src-cpp/x10/runtime/Thread.cc 2009-12-18 18:23:11 UTC (rev 12325) @@ -66,7 +66,7 @@ // this thread is now running tp->__thread_running = true; - ref<Object> taskBody = nullCheck(tp->__taskBody); + ref<Reference> taskBody = nullCheck(tp->__taskBody); (taskBody.operator->()->*(x10aux::findITable<VoidFun_0_0>(taskBody->_getITables())->apply))(); // finished running Modified: trunk/x10.runtime/src-cpp/x10/runtime/Thread.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/runtime/Thread.h 2009-12-18 15:45:34 UTC (rev 12324) +++ trunk/x10.runtime/src-cpp/x10/runtime/Thread.h 2009-12-18 18:23:11 UTC (rev 12325) @@ -20,7 +20,7 @@ namespace x10 { namespace lang { class String; - class Object; + class Reference; } } Modified: trunk/x10.runtime/src-cpp/x10aux/RTT.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/RTT.cc 2009-12-18 15:45:34 UTC (rev 12324) +++ trunk/x10.runtime/src-cpp/x10aux/RTT.cc 2009-12-18 18:23:11 UTC (rev 12325) @@ -3,6 +3,7 @@ #include <x10aux/alloc.h> #include <x10aux/atomic_ops.h> +#include <x10/lang/Reference.h> #include <x10/lang/Object.h> #include <cstdarg> @@ -90,63 +91,51 @@ } void RuntimeType::initBooleanType() { - const RuntimeType* parents[1] = {x10::lang::Object::getRTT()}; - BooleanType.init(&BooleanType, "x10.lang.Boolean", 1, parents, 0, NULL, NULL); + BooleanType.init(&BooleanType, "x10.lang.Boolean", 0, NULL, 0, NULL, NULL); BooleanType.containsPtrs = false; } void RuntimeType::initByteType() { - const RuntimeType* parents[1] = {x10::lang::Object::getRTT()}; - ByteType.init(&ByteType, "x10.lang.Byte", 1, parents, 0, NULL, NULL); + ByteType.init(&ByteType, "x10.lang.Byte", 0, NULL, 0, NULL, NULL); ByteType.containsPtrs = false; } void RuntimeType::initCharType() { - const RuntimeType* parents[1] = {x10::lang::Object::getRTT()}; - CharType.init(&CharType, "x10.lang.Char", 1, parents, 0, NULL, NULL); + CharType.init(&CharType, "x10.lang.Char", 0, NULL, 0, NULL, NULL); CharType.containsPtrs = false; } void RuntimeType::initShortType() { - const RuntimeType* parents[1] = {x10::lang::Object::getRTT()}; - ShortType.init(&ShortType, "x10.lang.Short", 1, parents, 0, NULL, NULL); + ShortType.init(&ShortType, "x10.lang.Short", 0, NULL, 0, NULL, NULL); ShortType.containsPtrs = false; } void RuntimeType::initIntType() { - const RuntimeType* parents[1] = {x10::lang::Object::getRTT()}; - IntType.init(&IntType, "x10.lang.Int", 1, parents, 0, NULL, NULL); + IntType.init(&IntType, "x10.lang.Int", 0, NULL, 0, NULL, NULL); IntType.containsPtrs = false; } void RuntimeType::initFloatType() { - const RuntimeType* parents[1] = {x10::lang::Object::getRTT()}; - FloatType.init(&FloatType, "x10.lang.Float", 1, parents, 0, NULL, NULL); + FloatType.init(&FloatType, "x10.lang.Float", 0, NULL, 0, NULL, NULL); FloatType.containsPtrs = false; } void RuntimeType::initLongType() { - const RuntimeType* parents[1] = {x10::lang::Object::getRTT()}; - LongType.init(&LongType, "x10.lang.Long", 1, parents, 0, NULL, NULL); + LongType.init(&LongType, "x10.lang.Long", 0, NULL, 0, NULL, NULL); LongType.containsPtrs = false; } void RuntimeType::initDoubleType() { - const RuntimeType* parents[1] = {x10::lang::Object::getRTT()}; - DoubleType.init(&DoubleType, "x10.lang.Double", 1, parents, 0, NULL, NULL); + DoubleType.init(&DoubleType, "x10.lang.Double", 0, NULL, 0, NULL, NULL); DoubleType.containsPtrs = false; } void RuntimeType::initUByteType() { - const RuntimeType* parents[1] = {x10::lang::Object::getRTT()}; - UByteType.init(&UByteType, "x10.lang.UByte", 1, parents, 0, NULL, NULL); + UByteType.init(&UByteType, "x10.lang.UByte", 0, NULL, 0, NULL, NULL); UByteType.containsPtrs = false; } void RuntimeType::initUShortType() { - const RuntimeType* parents[1] = {x10::lang::Object::getRTT()}; - UShortType.init(&UShortType, "x10.lang.UShort", 1, parents, 0, NULL, NULL); + UShortType.init(&UShortType, "x10.lang.UShort", 0, NULL, 0, NULL, NULL); UShortType.containsPtrs = false; } void RuntimeType::initUIntType() { - const RuntimeType* parents[1] = {x10::lang::Object::getRTT()}; - UIntType.init(&UIntType, "x10.lang.UInt", 1, parents, 0, NULL, NULL); + UIntType.init(&UIntType, "x10.lang.UInt", 0, NULL, 0, NULL, NULL); UIntType.containsPtrs = false; } void RuntimeType::initULongType() { - const RuntimeType* parents[1] = {x10::lang::Object::getRTT()}; - ULongType.init(&ULongType, "x10.lang.ULong", 1, parents, 0, NULL, NULL); + ULongType.init(&ULongType, "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 2009-12-18 15:45:34 UTC (rev 12324) +++ trunk/x10.runtime/src-cpp/x10aux/RTT.h 2009-12-18 18:23:11 UTC (rev 12325) @@ -31,6 +31,7 @@ namespace x10 { namespace lang { class Object; + class Reference; } } @@ -221,7 +222,8 @@ template<> inline const char *typeName<char>() { return "char"; } template<> inline const char *typeName<const RuntimeType*>() { return "const RuntimeType *"; } template<> inline const char *typeName<RuntimeType::Variance>() { return "Variance"; } - + template<> inline const char *typeName<x10::lang::Reference>() { return "interface"; } + template<class T, class S> struct Instanceof { static x10_boolean _(S v) { return false; } }; Modified: trunk/x10.runtime/src-cpp/x10aux/basic_functions.h =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/basic_functions.h 2009-12-18 15:45:34 UTC (rev 12324) +++ trunk/x10.runtime/src-cpp/x10aux/basic_functions.h 2009-12-18 18:23:11 UTC (rev 12325) @@ -209,8 +209,8 @@ template<class T> ref<x10::lang::String> to_string(ref<T> x) { - ref<x10::lang::Object> asObj = x; - return nullCheck(asObj)->toString(); + ref<x10::lang::Reference> asRef = x; + return nullCheck(asRef)->toString(); } template<class T> ref<x10::lang::String> to_string(T x) { Modified: trunk/x10.runtime/src-cpp/x10aux/bootstrap.h =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/bootstrap.h 2009-12-18 15:45:34 UTC (rev 12324) +++ trunk/x10.runtime/src-cpp/x10aux/bootstrap.h 2009-12-18 18:23:11 UTC (rev 12325) @@ -44,16 +44,20 @@ StaticInitClosure() { } - virtual x10_boolean _struct_equals(x10aux::ref<x10::lang::Object> p0) { - return false; // FIXME: should we be able to compare function types structurally? - } - const x10aux::RuntimeType *_type() const {return x10aux::getRTT<x10::lang::VoidFun_0_0>();} ref<x10::lang::String> toString() { return x10::lang::String::Lit("x10aux::StaticInitClosure ("__FILELINE__")"); } + virtual x10aux::serialization_id_t _get_serialization_id() { + assert(false); // We should never be serializing this closure + return 0; + } + + virtual void _serialize_body(x10aux::serialization_buffer &) { + assert(false); // We should never be serializing this closure + } }; typedef void (*ApplicationMainFunction)(ref<x10::lang::Rail<ref<x10::lang::String> > >); @@ -82,16 +86,20 @@ ... [truncated message content] |
From: <dgr...@us...> - 2009-12-19 04:18:48
|
Revision: 12336 http://x10.svn.sourceforge.net/x10/?rev=12336&view=rev Author: dgrove-oss Date: 2009-12-19 04:18:40 +0000 (Sat, 19 Dec 2009) Log Message: ----------- WIP on C++ codegen for XTENLANG-754 C++ backend now supports boxing a struct "up" to an interface type and doing instanceof/checkcast operations on the boxed interface. Invocation of interface methods on the "boxed struct" will not work, yet as we need to augment to codegen for struct itables to generate an additional itable thunk class where the receiver parameter is defined to be an IBox<S> instead of a S&. I'll work on this over the weekend (don't think it's too hard, but I may not finish it before calling it a night tonight). After interface method invocation on boxed structs works, I will merge the trunk changes to the newEquals branch and start looking at C++ codegen issues with Any on the branch. Modified Paths: -------------- trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java trunk/x10.runtime/src-cpp/x10aux/class_cast.h Added Paths: ----------- trunk/x10.runtime/src-cpp/x10/lang/IBox.h Modified: trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java =================================================================== --- trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java 2009-12-19 03:19:17 UTC (rev 12335) +++ trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java 2009-12-19 04:18:40 UTC (rev 12336) @@ -1179,14 +1179,16 @@ /* equals redirection method: Something of an interface type is a subclass of Object even if C++ doesn't know that... */ // FIXME: XTENLANG-752. This is wrong in X10 2.0 because closures implement interfaces, but are not objects. h.write("x10_boolean equals(x10aux::ref<x10::lang::Object> that) {"); h.newline(4); h.begin(0); - h.write("return x10aux::class_cast_unchecked<x10aux::ref<x10::lang::Object> >(this)->equals(that);"); + h.write("return x10aux::class_cast_unchecked<x10aux::ref<x10::lang::Object> >("+ + Emitter.translateType(currentClass, true)+"(this))->equals(that);"); h.end(); h.newline(); h.write("}"); h.newline(); h.forceNewline(); /* hashCode redirection method: Something of an interface type is a subclass of Object even if C++ doesn't know that... */ // FIXME: XTENLANG-752. This is wrong in X10 2.0 because closures implement interfaces, but are not objects. h.write("x10_int hashCode() {"); h.newline(4); h.begin(0); - h.write("return x10aux::class_cast_unchecked<x10aux::ref<x10::lang::Object> >(this)->hashCode();"); + h.write("return x10aux::class_cast_unchecked<x10aux::ref<x10::lang::Object> >("+ + Emitter.translateType(currentClass, true)+"(this))->hashCode();"); h.end(); h.newline(); h.write("}"); h.newline(); h.forceNewline(); Added: trunk/x10.runtime/src-cpp/x10/lang/IBox.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/IBox.h (rev 0) +++ trunk/x10.runtime/src-cpp/x10/lang/IBox.h 2009-12-19 04:18:40 UTC (rev 12336) @@ -0,0 +1,69 @@ +#ifndef X10_LANG_IBOX_H +#define X10_LANG_IBOX_H + +#include <x10/lang/Reference.h> + +namespace x10 { + namespace lang { + + class String; + + template <class T> inline x10aux::itable_entry* getITablesForIBox(T value) { return value->_getITables(); } // TODO: Very soon will be changed to _getITablesForIBox() + + // TODO: As soon as we change the basic numeric types to implement interfaces + // at the X10 level, we will have to change this code to return to the + // itables for IBox that we handwrite for the primitives. + inline x10aux::itable_entry *getITablesForIBox(x10_boolean) { return NULL; } + inline x10aux::itable_entry *getITablesForIBox(x10_byte) { return NULL; } + inline x10aux::itable_entry *getITablesForIBox(x10_ubyte) { return NULL; } + inline x10aux::itable_entry *getITablesForIBox(x10_char) { return NULL; } + inline x10aux::itable_entry *getITablesForIBox(x10_short) { return NULL; } + inline x10aux::itable_entry *getITablesForIBox(x10_ushort) { return NULL; } + inline x10aux::itable_entry *getITablesForIBox(x10_int) { return NULL; } + inline x10aux::itable_entry *getITablesForIBox(x10_uint) { return NULL; } + inline x10aux::itable_entry *getITablesForIBox(x10_long) { return NULL; } + inline x10aux::itable_entry *getITablesForIBox(x10_ulong) { return NULL; } + inline x10aux::itable_entry *getITablesForIBox(x10_float) { return NULL; } + inline x10aux::itable_entry *getITablesForIBox(x10_double) { return NULL; } + + + /** + * This is a class that exists only at the C++ implementation level, + * not at the X10 language level. Therefore it does not have an + * associated RTT. + * + * The purpose of this class is to enable struct values to be boxed + * when they are assigned/casts to variables of interface types. + * When that happens, all we need to provide is a + */ + template <class T> class IBox : public Reference { + public: + T value; + + IBox(T val) : value(val) { + location = x10aux::here; + } + + virtual x10aux::itable_entry* _getITables() { return getITablesForIBox(value); } + + virtual const x10aux::RuntimeType *_type() const { return x10aux::getRTT<T>(); } + static const x10aux::RuntimeType* getRTT() { return x10aux::getRTT<T>(); } + + virtual x10aux::ref<String> toString() { return x10aux::to_string(value); } + + // TODO: Need to implement serialization/deserialization support for this class! + + virtual x10aux::serialization_id_t _get_serialization_id() { + assert(false); + return -1000; + } + + virtual void _serialize_body(x10aux::serialization_buffer &) { + assert(false); + } + }; + } +} + + +#endif Modified: trunk/x10.runtime/src-cpp/x10aux/class_cast.h =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/class_cast.h 2009-12-19 03:19:17 UTC (rev 12335) +++ trunk/x10.runtime/src-cpp/x10aux/class_cast.h 2009-12-19 04:18:40 UTC (rev 12336) @@ -9,33 +9,21 @@ #include <x10aux/basic_functions.h> #include <x10/lang/Reference.h> +#include <x10/lang/IBox.h> namespace x10aux { + /* + * Throughout this file: + * T stands for "to" + * F stands for "from" + */ + extern void throwClassCastException() X10_PRAGMA_NORETURN; template<typename T, typename F> GPUSAFE T class_cast(F obj); template<typename T, typename F> GPUSAFE T class_cast(F obj, bool checked); - template<class T> struct CAST_TRACER { - CAST_TRACER(T val_) : val(val_) { } - T val; - T get() { return val; } - }; - template<class T> struct CAST_TRACER<ref<T> > { - CAST_TRACER(ref<T> val_) : val(val_) { } - ref<T> val; - T* get() { return val.operator->(); } - }; - #ifndef NO_IOSTREAM - template<class T> std::ostream& operator<<(std::ostream& o, CAST_TRACER<T> t) { - return o << t.get(); - } - #endif - - // T stands for "to" - // F stands for "from" - template<class T> static GPUSAFE ref<T> real_class_cast(ref<x10::lang::Reference> obj, bool checked) { if (obj == x10aux::null) { // NULL passes any class cast check and remains NULL @@ -67,15 +55,63 @@ template<class T, class F> struct ClassCastNotPrimitive<ref<T>,ref<F> > { static GPUSAFE ref<T> _(ref<F> obj, bool checked) { - _CAST_("Ref to ref cast "<<TYPENAME(T)<<" to "<<TYPENAME(T)); + _CAST_("Ref to ref cast "<<TYPENAME(F)<<" to "<<TYPENAME(T)); return real_class_cast<T>(obj, checked); } }; + template<class T, class F> struct ClassCastNotPrimitive<ref<T>,F> { + static GPUSAFE ref<T> _(F val, bool checked) { + _CAST_("Struct to ref cast "<<TYPENAME(F)<<" to "<<TYPENAME(T)); + if (checked) { + const RuntimeType *from = getRTT<F>(); + const RuntimeType *to = getRTT<ref<T> >(); + #ifndef NO_EXCEPTIONS + _CAST_(from->name()<<" to "<<to->name()); + if (!from->subtypeOf(to)) { + throwClassCastException(); + } + #else + (void) from; (void) to; + _CAST_("UNCHECKED! "<<from->name()<<" to "<<to->name()); + #endif + } + x10aux::ref<x10::lang::IBox<F> > obj = new (x10aux::alloc<x10::lang::IBox<F> >()) x10::lang::IBox<F>(val); + return obj; + } + }; + + template<class T, class F> struct ClassCastNotPrimitive<T,ref<F> > { + static GPUSAFE T _(ref<F> val, bool checked) { + _CAST_("Ref to struct cast "<<TYPENAME(F)<<" to "<<TYPENAME(T)); + if (val == x10aux::null) { + // NULL cannot be cast to a struct. + _CAST_("Special case: null cannot be cast to "<<TYPENAME(T)); + throwClassCastException(); + } + if (checked) { + x10aux::ref<x10::lang::Reference> asRef = val; + const RuntimeType *from = asRef->_type(); + const RuntimeType *to = getRTT<T>(); + #ifndef NO_EXCEPTIONS + _CAST_(from->name()<<" to "<<to->name()); + if (!from->subtypeOf(to)) { + throwClassCastException(); + } + #else + (void) from; (void) to; + _CAST_("UNCHECKED! "<<from->name()<<" to "<<to->name()); + #endif + } + x10aux::ref<x10::lang::IBox<T> > ibox = val; + return ibox->value; + } + }; + // This is the second level that recognises primitive casts template<class T, class F> struct ClassCastPrimitive { static GPUSAFE T _(F obj, bool checked) { // if we get here it's not a primitive cast - _CAST_("Not a primitive cast "<<TYPENAME(T)<<" to "<<TYPENAME(T)); + _CAST_("Not a primitive cast "<<TYPENAME(F)<<" to "<<TYPENAME(T)); return ClassCastNotPrimitive<T,F>::_(obj, checked); } }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dgr...@us...> - 2009-12-21 14:41:15
|
Revision: 12340 http://x10.svn.sourceforge.net/x10/?rev=12340&view=rev Author: dgrove-oss Date: 2009-12-21 14:41:08 +0000 (Mon, 21 Dec 2009) Log Message: ----------- XTENLANG-754 : conversions of structs to boxed interfaces Add additional itable thunk class to be used for IBox<S>. Interface method invocation for structs boxed to interface types now works in C++ backend (and still works in Java backend, since nothing needed to be changed there). Modified Paths: -------------- trunk/x10.compiler/src/x10cpp/visit/ITable.java trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java trunk/x10.runtime/src-cpp/x10/lang/IBox.h Modified: trunk/x10.compiler/src/x10cpp/visit/ITable.java =================================================================== --- trunk/x10.compiler/src/x10cpp/visit/ITable.java 2009-12-20 17:50:07 UTC (rev 12339) +++ trunk/x10.compiler/src/x10cpp/visit/ITable.java 2009-12-21 14:41:08 UTC (rev 12340) @@ -176,7 +176,7 @@ String interfaceCType = Emitter.translateType(interfaceType, false); String clsCType = Emitter.translateType(cls, false); X10ClassDef cd = ((X10ClassType) cls).x10Def(); - String thunkType = Emitter.mangled_non_method_name(cd.name().toString()) + "_ithunk"+itableNum; + String thunkBaseType = Emitter.mangled_non_method_name(cd.name().toString()); String thunkParams = ""; if (cls.typeArguments().size() != 0) { String args = ""; @@ -193,56 +193,63 @@ if (cd.package_() != null) { Emitter.openNamespaces(sw, cd.package_().get().fullName()); sw.newline(); } - if (!cls.typeArguments().isEmpty()) { - emitter.printTemplateSignature(cls.typeArguments(), sw); - } - sw.write("class "+thunkType+" : public "+clsCType+" {"); sw.newline(); - sw.write("public:"); sw.newline(4); sw.begin(0); - sw.write("static "+(doubleTemplate ? "typename ":"")+interfaceCType+ - (doubleTemplate ? "::template itable<":"::itable<")+thunkType+thunkParams+" > itable;"); - sw.newline(); - - for (MethodInstance meth : methods) { - sw.write(Emitter.translateType(meth.returnType())); - sw.write(" "); - sw.write(Emitter.mangled_method_name(meth.name().toString())); - sw.write("("); - boolean first = true; - int argNum=0; - for (Type f : meth.formalTypes()) { - if (!first) sw.write(", "); - sw.write(Emitter.translateType(f, true)+" arg"+(argNum++)); - first = false; + for (int i=0; i<2; i++) { + boolean ibox = i == 1; + String thunkType = thunkBaseType + (ibox ? "_iboxithunk":"_ithunk")+itableNum; + String parentCType = ibox ? "x10::lang::IBox"+chevrons(clsCType) : clsCType; + String recvArg = ibox ? "this->value" : "*this"; + + if (!cls.typeArguments().isEmpty()) { + emitter.printTemplateSignature(cls.typeArguments(), sw); } - sw.write(") {"); sw.newline(4); sw.begin(0); - if (!meth.returnType().isVoid()) sw.write("return "); - sw.write(Emitter.structMethodClass(cls, true, true)+"::"+Emitter.mangled_method_name(meth.name().toString())+"(*this"); - for (int i=0; i<meth.formalTypes().size(); i++) { - sw.write(", arg"+i); - } - sw.write(");"); + sw.write("class "+thunkType+" : public "+parentCType+" {"); sw.newline(); + sw.write("public:"); sw.newline(4); sw.begin(0); + sw.write("static "+(doubleTemplate ? "typename ":"")+interfaceCType+ + (doubleTemplate ? "::template itable<":"::itable<")+thunkType+thunkParams+" > itable;"); + sw.newline(); + + for (MethodInstance meth : methods) { + sw.write(Emitter.translateType(meth.returnType())); + sw.write(" "); + sw.write(Emitter.mangled_method_name(meth.name().toString())); + sw.write("("); + boolean first = true; + int argNum=0; + for (Type f : meth.formalTypes()) { + if (!first) sw.write(", "); + sw.write(Emitter.translateType(f, true)+" arg"+(argNum++)); + first = false; + } + sw.write(") {"); sw.newline(4); sw.begin(0); + if (!meth.returnType().isVoid()) sw.write("return "); + sw.write(Emitter.structMethodClass(cls, true, true)+"::"+Emitter.mangled_method_name(meth.name().toString())+"("+recvArg); + for (int j=0; j<meth.formalTypes().size(); j++) { + sw.write(", arg"+j); + } + sw.write(");"); + sw.end(); sw.newline(); + sw.write("}"); sw.newline(); + } sw.end(); sw.newline(); - sw.write("}"); sw.newline(); - } - sw.end(); sw.newline(); - sw.write("};"); sw.newline(); - - if (!cls.typeArguments().isEmpty()) { - emitter.printTemplateSignature(cls.typeArguments(), sw); - } - sw.write((doubleTemplate ? "typename " : "")+interfaceCType+(doubleTemplate ? "::template itable<" : "::itable<")+ - thunkType+thunkParams+" > "+" "+thunkType+thunkParams+"::itable"); - if (!isEmpty()) { - int methodNum = 0; - sw.write("("); - for (MethodInstance meth : methods) { - if (methodNum > 0) sw.write(", "); - sw.write("&"+thunkType+thunkParams+"::"+Emitter.mangled_method_name(meth.name().toString())); - methodNum++; + sw.write("};"); sw.newline(); + + if (!cls.typeArguments().isEmpty()) { + emitter.printTemplateSignature(cls.typeArguments(), sw); + } + sw.write((doubleTemplate ? "typename " : "")+interfaceCType+(doubleTemplate ? "::template itable<" : "::itable<")+ + thunkType+thunkParams+" > "+" "+thunkType+thunkParams+"::itable"); + if (!isEmpty()) { + int methodNum = 0; + sw.write("("); + for (MethodInstance meth : methods) { + if (methodNum > 0) sw.write(", "); + sw.write("&"+thunkType+thunkParams+"::"+Emitter.mangled_method_name(meth.name().toString())); + methodNum++; + } + sw.write(")"); } - sw.write(")"); + sw.write(";"); sw.newline(); } - sw.write(";"); sw.newline(); if (cd.package_() != null) { Emitter.closeNamespaces(sw, cd.package_().get().fullName()); sw.newline(); } Modified: trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java =================================================================== --- trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java 2009-12-20 17:50:07 UTC (rev 12339) +++ trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java 2009-12-21 14:41:08 UTC (rev 12340) @@ -1293,7 +1293,7 @@ List<ClassMember> members = n.members(); - generateITablesForStruct(currentClass, xts, "", sh, h); + generateITablesForStruct(currentClass, xts, sh, h); if (!members.isEmpty()) { String className = Emitter.translateType(currentClass); @@ -1490,32 +1490,12 @@ } private void generateITablesForStruct(X10ClassType currentClass, - X10TypeSystem xts, String maybeVirtual, ClassifiedStream sh, + X10TypeSystem xts, ClassifiedStream sh, ClassifiedStream h) { List<X10ClassType> allInterfaces = xts.allImplementedInterfaces(currentClass); int numInterfaces = allInterfaces.size() - 1; // IGNORE ANY by subtracting 1 if (numInterfaces > 0 && !currentClass.flags().isAbstract()) { - /* ITables declarations */ - sh.writeln("static x10aux::itable_entry _itables["+(numInterfaces+1)+"];"); sh.forceNewline(); - sh.writeln(maybeVirtual+"x10aux::itable_entry* _getITables() { return _itables; }"); sh.forceNewline(); - int itableNum = 0; - - /* ITables initialization */ - itableNum = 0; - for (Type interfaceType : allInterfaces) { - if (xts.isAny(interfaceType)) continue; // IGNORE ANY - ITable itable = ITable.getITable((X10ClassType) X10TypeMixin.baseType(interfaceType)); - itable.emitITableInitialization(currentClass, itableNum, emitter, h, sw); - itableNum += 1; - } - - if (!currentClass.typeArguments().isEmpty()) { - emitter.printTemplateSignature(currentClass.typeArguments(), sw); - } - String clsCType = Emitter.translateType(currentClass, false); - sw.write("x10aux::itable_entry "+clsCType+"::_itables["+(numInterfaces+1)+"] = {"); - itableNum = 0; - String thunkBaseName = Emitter.mangled_non_method_name(currentClass.name().toString()) + "_ithunk"; + String thunkBaseName = Emitter.mangled_non_method_name(currentClass.name().toString()); String thunkParams = ""; if (currentClass.typeArguments().size() != 0) { String args = ""; @@ -1526,14 +1506,39 @@ args +=", "; } thunkParams = chevrons(args); - } + } + + /* ITables declarations */ + sh.writeln("static x10aux::itable_entry _itables["+(numInterfaces+1)+"];"); sh.forceNewline(); + sh.writeln("x10aux::itable_entry* _getITables() { return _itables; }"); sh.forceNewline(); + sh.writeln("static x10aux::itable_entry _iboxitables["+(numInterfaces+1)+"];"); sh.forceNewline(); + sh.writeln("x10aux::itable_entry* _getIBoxITables() { return _iboxitables; }"); sh.forceNewline(); + + /* ITables initialization */ + int itableNum = 0; for (Type interfaceType : allInterfaces) { if (xts.isAny(interfaceType)) continue; // IGNORE ANY - sw.write("x10aux::itable_entry(x10aux::getRTT"+chevrons(Emitter.translateType(interfaceType, false))+"(), &"+ - thunkBaseName+itableNum+thunkParams+"::itable), "); + ITable itable = ITable.getITable((X10ClassType) X10TypeMixin.baseType(interfaceType)); + itable.emitITableInitialization(currentClass, itableNum, emitter, h, sw); itableNum += 1; } - sw.write("x10aux::itable_entry(NULL, (void*)x10aux::getRTT"+chevrons(Emitter.translateType(currentClass, false))+"())};"); sw.newline(); + + String clsCType = Emitter.translateType(currentClass, false); + for (int i=0; i<2; i++) { + String ibox = i == 0 ? "" : "ibox"; + if (!currentClass.typeArguments().isEmpty()) { + emitter.printTemplateSignature(currentClass.typeArguments(), sw); + } + sw.write("x10aux::itable_entry "+clsCType+"::_"+ibox+"itables["+(numInterfaces+1)+"] = {"); + itableNum = 0; + for (Type interfaceType : allInterfaces) { + if (xts.isAny(interfaceType)) continue; // IGNORE ANY + sw.write("x10aux::itable_entry(x10aux::getRTT"+chevrons(Emitter.translateType(interfaceType, false))+"(), &"+ + thunkBaseName+"_"+ibox+"ithunk"+itableNum+thunkParams+"::itable), "); + itableNum += 1; + } + sw.write("x10aux::itable_entry(NULL, (void*)x10aux::getRTT"+chevrons(Emitter.translateType(currentClass, false))+"())};"); sw.newline(); + } } } Modified: trunk/x10.runtime/src-cpp/x10/lang/IBox.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/IBox.h 2009-12-20 17:50:07 UTC (rev 12339) +++ trunk/x10.runtime/src-cpp/x10/lang/IBox.h 2009-12-21 14:41:08 UTC (rev 12340) @@ -8,7 +8,7 @@ class String; - template <class T> inline x10aux::itable_entry* getITablesForIBox(T value) { return value->_getITables(); } // TODO: Very soon will be changed to _getITablesForIBox() + template <class T> inline x10aux::itable_entry* getITablesForIBox(T value) { return value->_getIBoxITables(); } // TODO: As soon as we change the basic numeric types to implement interfaces // at the X10 level, we will have to change this code to return to the This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lun...@us...> - 2009-12-21 22:20:51
|
Revision: 12380 http://x10.svn.sourceforge.net/x10/?rev=12380&view=rev Author: lunnikri Date: 2009-12-21 22:20:37 +0000 (Mon, 21 Dec 2009) Log Message: ----------- Fixed error message mentioned in XTENLANG-630. Modified Paths: -------------- trunk/x10.compiler/src/x10/ast/X10Cast_c.java trunk/x10.constraints/src/x10/constraint/XFormula_c.java Modified: trunk/x10.compiler/src/x10/ast/X10Cast_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10Cast_c.java 2009-12-21 22:03:17 UTC (rev 12379) +++ trunk/x10.compiler/src/x10/ast/X10Cast_c.java 2009-12-21 22:20:37 UTC (rev 12380) @@ -190,7 +190,7 @@ String c = convert == ConversionType.UNKNOWN_CONVERSION ? "cast" : "implicitly convert"; - throw new SemanticException("Golden!! Cannot " + c + " expression of type \n\"" + throw new SemanticException("Cannot " + c + " expression of type \n\"" + fromType + "\"\n to type \"" + toType + "\".", position()); Modified: trunk/x10.constraints/src/x10/constraint/XFormula_c.java =================================================================== --- trunk/x10.constraints/src/x10/constraint/XFormula_c.java 2009-12-21 22:03:17 UTC (rev 12379) +++ trunk/x10.constraints/src/x10/constraint/XFormula_c.java 2009-12-21 22:20:37 UTC (rev 12380) @@ -102,7 +102,7 @@ for (int i = 0; i < arguments.size(); i++) { XTerm arg = arguments.get(i); if (arg == null) { - System.err.println("XFormula_c: Golden: null arg in " + this); + // System.err.println("XFormula_c: Golden: null arg in " + this); continue; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dgr...@us...> - 2009-12-22 17:32:13
|
Revision: 12393 http://x10.svn.sourceforge.net/x10/?rev=12393&view=rev Author: dgrove-oss Date: 2009-12-22 17:32:04 +0000 (Tue, 22 Dec 2009) Log Message: ----------- Merge changes from newEquals branch to trunk. Since svn mergeinfo on the branch was broken in various ways, I did the merge by constructing two patches: newEquals: -r12334:12349 newEquals: -r12351:12386 and then applying them and fixing a couple of additional problems. Since the merge was done via patch instead of svn merge, the history of the individual commits on the branch, is only found by looking at the branch, not here in the trunk. Sigh. Modified Paths: -------------- trunk/x10.compiler/src/x10/ast/X10ClassDecl_c.java trunk/x10.compiler/src/x10/types/X10TypeEnv_c.java trunk/x10.compiler/src/x10/types/X10TypeSystem.java trunk/x10.compiler/src/x10/types/X10TypeSystem_c.java trunk/x10.compiler/src/x10/util/Struct.java trunk/x10.compiler/src/x10/visit/X10PrettyPrinterVisitor.java trunk/x10.compiler/src/x10cpp/visit/Emitter.java trunk/x10.compiler/src/x10cpp/visit/ITable.java trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java trunk/x10.constraints/src/x10/constraint/XFormula_c.java trunk/x10.dist/.launchConfigs/x10c.launch trunk/x10.runtime/src-cpp/Makefile trunk/x10.runtime/src-cpp/x10/lang/Closure.cc trunk/x10.runtime/src-cpp/x10/lang/Closure.h trunk/x10.runtime/src-cpp/x10/lang/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/Rail.h trunk/x10.runtime/src-cpp/x10/lang/Ref.cc trunk/x10.runtime/src-cpp/x10/lang/Ref.h trunk/x10.runtime/src-cpp/x10/lang/Reference.h trunk/x10.runtime/src-cpp/x10/lang/String.cc trunk/x10.runtime/src-cpp/x10/lang/Struct.struct_h trunk/x10.runtime/src-cpp/x10/lang/ValRail.h trunk/x10.runtime/src-cpp/x10/lang/VoidFun_0_0.h trunk/x10.runtime/src-cpp/x10/lang/VoidFun_0_1.h trunk/x10.runtime/src-cpp/x10/lang/VoidFun_0_2.h trunk/x10.runtime/src-cpp/x10/lang/VoidFun_0_3.h trunk/x10.runtime/src-cpp/x10/lang/VoidFun_0_4.h trunk/x10.runtime/src-cpp/x10/lang/VoidFun_0_5.h trunk/x10.runtime/src-cpp/x10/lang/VoidFun_0_6.h trunk/x10.runtime/src-cpp/x10/lang/VoidFun_0_7.h trunk/x10.runtime/src-cpp/x10/lang/VoidFun_0_8.h trunk/x10.runtime/src-cpp/x10/lang/VoidFun_0_9.h trunk/x10.runtime/src-cpp/x10aux/basic_functions.cc trunk/x10.runtime/src-cpp/x10aux/basic_functions.h trunk/x10.runtime/src-cpp/x10aux/bootstrap.cc trunk/x10.runtime/src-cpp/x10aux/init_dispatcher.cc trunk/x10.runtime/src-java/x10/core/Ref.java trunk/x10.runtime/src-java/x10/core/Struct.java trunk/x10.runtime/src-x10/x10/array/BaseArray.x10 trunk/x10.runtime/src-x10/x10/array/BaseDist.x10 trunk/x10.runtime/src-x10/x10/array/BaseRegion.x10 trunk/x10.runtime/src-x10/x10/array/EmptyRegion.x10 trunk/x10.runtime/src-x10/x10/array/FullRegion.x10 trunk/x10.runtime/src-x10/x10/array/PolyMat.x10 trunk/x10.runtime/src-x10/x10/array/PolyRegion.x10 trunk/x10.runtime/src-x10/x10/array/RectLayout.x10 trunk/x10.runtime/src-x10/x10/array/RectRegion.x10 trunk/x10.runtime/src-x10/x10/array/Row.x10 trunk/x10.runtime/src-x10/x10/array/UnionRegion.x10 trunk/x10.runtime/src-x10/x10/io/ByteWriter.x10 trunk/x10.runtime/src-x10/x10/io/StringWriter.x10 trunk/x10.runtime/src-x10/x10/lang/Boolean.x10 trunk/x10.runtime/src-x10/x10/lang/Box.x10 trunk/x10.runtime/src-x10/x10/lang/Byte.x10 trunk/x10.runtime/src-x10/x10/lang/Cell.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/Dist.x10 trunk/x10.runtime/src-x10/x10/lang/Double.x10 trunk/x10.runtime/src-x10/x10/lang/Equals.x10 trunk/x10.runtime/src-x10/x10/lang/Float.x10 trunk/x10.runtime/src-x10/x10/lang/Int.x10 trunk/x10.runtime/src-x10/x10/lang/Long.x10 trunk/x10.runtime/src-x10/x10/lang/Object.x10 trunk/x10.runtime/src-x10/x10/lang/Place.x10 trunk/x10.runtime/src-x10/x10/lang/Point.x10 trunk/x10.runtime/src-x10/x10/lang/RankMismatchException.x10 trunk/x10.runtime/src-x10/x10/lang/Region.x10 trunk/x10.runtime/src-x10/x10/lang/Short.x10 trunk/x10.runtime/src-x10/x10/lang/String.x10 trunk/x10.runtime/src-x10/x10/lang/Throwable.x10 trunk/x10.runtime/src-x10/x10/lang/UByte.x10 trunk/x10.runtime/src-x10/x10/lang/UInt.x10 trunk/x10.runtime/src-x10/x10/lang/ULong.x10 trunk/x10.runtime/src-x10/x10/lang/UShort.x10 trunk/x10.runtime/src-x10/x10/lang/ValRail.x10 trunk/x10.runtime/src-x10/x10/runtime/PlaceLocalHandle.x10 trunk/x10.runtime/src-x10/x10/runtime/Runtime.x10 trunk/x10.runtime/src-x10/x10/util/Option.x10 trunk/x10.runtime/src-x10/x10/util/OptionsParser.x10 trunk/x10.runtime/src-x10/x10/util/Pair.x10 trunk/x10.runtime/src-x10/x10/util/StringBuilder.x10 trunk/x10.runtime/src-x10/x10/util/ValRailBuilder.x10 trunk/x10.runtime/src-x10/x10/util/concurrent/atomic/AtomicBoolean.x10 trunk/x10.runtime/src-x10/x10/util/concurrent/atomic/AtomicInteger.x10 trunk/x10.runtime/src-x10/x10/util/concurrent/atomic/AtomicLong.x10 trunk/x10.runtime/src-x10/x10/util/concurrent/atomic/AtomicReference.x10 trunk/x10.runtime/src-x10/x10/util/concurrent/atomic/Fences.x10 Added Paths: ----------- trunk/x10.runtime/src-cpp/x10/lang/Any.cc trunk/x10.runtime/src-cpp/x10/lang/Any.h trunk/x10.runtime/src-x10/x10/lang/Any.x10 Removed Paths: ------------- trunk/x10.compiler/src/x10/util/Any.java Modified: trunk/x10.compiler/src/x10/ast/X10ClassDecl_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10ClassDecl_c.java 2009-12-22 16:07:30 UTC (rev 12392) +++ trunk/x10.compiler/src/x10/ast/X10ClassDecl_c.java 2009-12-22 17:32:04 UTC (rev 12393) @@ -250,18 +250,8 @@ X10Flags flags = X10Flags.toX10Flags(flags().flags()); if (flags.isStruct() || (flags.isInterface() && ! name.toString().equals("Any")) - || thisType.fullName().equals(QName.make("x10.lang.Object")) || xts.isParameterType(thisType.asType())) { - - // We need to lazily set the superclass, otherwise we go into an infinite loop - // during bootstrapping: Object, refers to Int, refers to Object, ... - final LazyRef<Type> ANY = Types.lazyRef(null); - ANY.setResolver(new Runnable() { - public void run() { - ANY.update(xts.Any()); - } - }); - thisType.addInterface(ANY); + thisType.addInterface(xts.lazyAny()); } super.setInterfaces(ts, thisType); Modified: trunk/x10.compiler/src/x10/types/X10TypeEnv_c.java =================================================================== --- trunk/x10.compiler/src/x10/types/X10TypeEnv_c.java 2009-12-22 16:07:30 UTC (rev 12392) +++ trunk/x10.compiler/src/x10/types/X10TypeEnv_c.java 2009-12-22 17:32:04 UTC (rev 12393) @@ -111,6 +111,22 @@ MethodInstance mj = ts.findImplementingMethod(ct, mi, context); if (mj == null) { + if (X10TypeMixin.isStruct(ct)) { + // Ignore checking requirement if the method is equals(Any), and ct is a struct. + if (mi.name().toString().equals("equals")) { + List<Type> argTypes = mi.formalTypes(); + if (argTypes.size() == 1 && ts.typeEquals(argTypes.get(0), ts.Any(), ts.emptyContext())) { + continue; + } + } + // Ignore checking requirement if the method is hashCode(), and ct is a struct. + if (mi.name().toString().equals("hashCode")) { + List<Type> argTypes = mi.formalTypes(); + if (argTypes.size() == 0) { + continue; + } + } + } if (!ct.flags().isAbstract()) { throw new SemanticException(ct.fullName() + " should be " + "declared abstract; it does not define " + @@ -686,6 +702,7 @@ t2 = xt2.clearFlags(X10Flags.ROOTED); }*/ + if (xt1.isProto() || xt2.isProto()) { if (xt1.isProto() != xt2.isProto()) return false; @@ -697,11 +714,13 @@ } if (xt1.isX10Struct() || xt2.isX10Struct()) { - if (xt1.isX10Struct() != xt2.isX10Struct()) - return false; - if (! ts.typeEquals(X10TypeMixin.baseType(xt1), X10TypeMixin.baseType(xt2), - xcontext)) - return false; + if (xt1.isX10Struct() && xt2.isX10Struct()) { + if (xt1.isX10Struct() != xt2.isX10Struct()) + return false; + if (! ts.typeEquals(X10TypeMixin.baseType(xt1), X10TypeMixin.baseType(xt2), + xcontext)) + return false; + } xt1 = X10TypeMixin.makeRef(xt1); xt2 = X10TypeMixin.makeRef(xt2); // now keep going, the clause entailment will be checked by the Modified: trunk/x10.compiler/src/x10/types/X10TypeSystem.java =================================================================== --- trunk/x10.compiler/src/x10/types/X10TypeSystem.java 2009-12-22 16:07:30 UTC (rev 12392) +++ trunk/x10.compiler/src/x10/types/X10TypeSystem.java 2009-12-22 17:32:04 UTC (rev 12393) @@ -24,6 +24,7 @@ import polyglot.types.CodeInstance; import polyglot.types.Context; import polyglot.types.Flags; +import polyglot.types.LazyRef; import polyglot.types.LocalDef; import polyglot.types.Name; import polyglot.types.Ref; @@ -443,4 +444,6 @@ boolean isExactlyFunctionType(Type t); Name homeName(); + + LazyRef<Type> lazyAny(); } Modified: trunk/x10.compiler/src/x10/types/X10TypeSystem_c.java =================================================================== --- trunk/x10.compiler/src/x10/types/X10TypeSystem_c.java 2009-12-22 16:07:30 UTC (rev 12392) +++ trunk/x10.compiler/src/x10/types/X10TypeSystem_c.java 2009-12-22 17:32:04 UTC (rev 12393) @@ -447,7 +447,7 @@ cd.kind(ClassDef.TOP_LEVEL); cd.superType(null); // interfaces have no superclass // Functions implement the Any interface. - //cd.setInterfaces(Collections.<Ref<? extends Type>> singletonList(Types.ref(Any()))); + cd.setInterfaces(Collections.<Ref<? extends Type>> singletonList(Types.ref(Any()))); cd.flags(X10Flags.toX10Flags(Flags.PUBLIC.Abstract().Interface())); final List<Ref<? extends Type>> typeParams = new ArrayList<Ref<? extends Type>>(); @@ -1459,9 +1459,18 @@ public Type Any() { if (ANY_ != null) return ANY_; - return ANY_ = x10.util.Any.makeDef(this).asType(); + return ANY_ = load("x10.lang.Any"); // x10.util.Any.makeDef(this).asType(); } + public LazyRef<Type> lazyAny() { + final LazyRef<Type> ANY = Types.lazyRef(null); + ANY.setResolver(new Runnable() { + public void run() { + ANY.update(Any()); + } + }); + return ANY; + } Type STRUCT_ = null; public Type Struct() { if (STRUCT_ != null) Deleted: trunk/x10.compiler/src/x10/util/Any.java =================================================================== --- trunk/x10.compiler/src/x10/util/Any.java 2009-12-22 16:07:30 UTC (rev 12392) +++ trunk/x10.compiler/src/x10/util/Any.java 2009-12-22 17:32:04 UTC (rev 12393) @@ -1,212 +0,0 @@ -package x10.util; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import polyglot.ast.Expr; -import polyglot.types.ClassDef; -import polyglot.types.ClassType; -import polyglot.types.Flags; -import polyglot.types.LazyRef; -import polyglot.types.LocalDef; -import polyglot.types.Name; -import polyglot.types.QName; -import polyglot.types.Ref; -import polyglot.types.SemanticException; -import polyglot.types.Type; -import polyglot.types.Types; -import polyglot.util.Position; -import x10.ast.X10StringLit_c; -import x10.constraint.XName; -import x10.constraint.XNameWrapper; -import x10.constraint.XRoot; -import x10.constraint.XTerms; -import x10.types.X10ClassDef; -import x10.types.X10ClassDef_c; -import x10.types.X10ClassType; -import x10.types.X10Flags; -import x10.types.X10MethodDef; -import x10.types.X10ParsedClassType; -import x10.types.X10ParsedClassType_c; -import x10.types.X10TypeSystem; -import x10.types.X10TypeSystem_c; - -public class Any { - - public static X10ClassDef makeDef(final X10TypeSystem_c xts) { - - final Position pos = Position.COMPILER_GENERATED; - - - String name = "Any"; - X10ClassDef cd = (X10ClassDef) new X10ClassDef_c(xts, null) { - - @Override - public ClassType asType() { - if (asType == null) { - X10ClassDef cd = this; - asType = new X10ParsedClassType_c(this); - } - return asType; - } - }; - - cd.position(pos); - // interface Any .... - cd.name(Name.make(name)); - // package x10.lang; - try { - cd.setPackage(Types.ref(xts.packageForName(QName.make("x10.lang")))); - } - catch (SemanticException e) { - assert false; - } - QName fullName = QName.make("x10.lang", name); - - cd.kind(ClassDef.TOP_LEVEL); - cd.superType(null); // interfaces have no superclass - // Functions implement the Any interface. - //cd.setInterfaces(Collections.<Ref<? extends Type>> singletonList(Types.ref(Any()))); - cd.flags(X10Flags.toX10Flags(Flags.PUBLIC.Abstract().Interface())); - - // NOTE: don't call cd.asType() until after the type parameters are - // added. - X10ParsedClassType ct = (X10ParsedClassType) cd.asType(); - xts.systemResolver().install(fullName, ct); - - String fullNameWithThis = fullName + "#this"; - //String fullNameWithThis = "this"; - XName thisName = new XNameWrapper<Object>(new Object(), fullNameWithThis); - XRoot thisVar = XTerms.makeLocal(thisName); - - final LazyRef<X10ParsedClassType> PLACE = Types.lazyRef(null); - PLACE.setResolver(new Runnable() { - public void run() { - PLACE.update((X10ParsedClassType) xts.Place()); - } - }); - final LazyRef<X10ParsedClassType> STRING = Types.lazyRef(null); - STRING.setResolver(new Runnable() { - public void run() { - STRING.update((X10ParsedClassType) xts.String()); - } - }); - final LazyRef<X10ParsedClassType> BOOLEAN = Types.lazyRef(null); - BOOLEAN.setResolver(new Runnable() { - public void run() { - BOOLEAN.update((X10ParsedClassType) xts.Boolean()); - } - }); - final LazyRef<X10ParsedClassType> OBJECT = Types.lazyRef(null); - OBJECT.setResolver(new Runnable() { - public void run() { - OBJECT.update((X10ParsedClassType) xts.Object()); - } - }); - - - X10MethodDef mi; - List<Expr> list; - X10ClassType ann; - - // @Native("java", "x10.lang.Place.place(x10.core.Ref.home(#0))") - // property def home():Place - mi = xts.methodDef(pos, Types.ref(ct), - X10Flags.toX10Flags(Flags.PUBLIC.Abstract()).Property().Global(), PLACE, - xts.homeName(), - Collections.EMPTY_LIST, - Collections.EMPTY_LIST, - thisVar, - Collections.EMPTY_LIST, - null, - null, - Collections.EMPTY_LIST, - null); - final LazyRef<X10ParsedClassType> NATIVE_LOC = Types.lazyRef(null); - NATIVE_LOC.setResolver(new Runnable() { - public void run() { - List<Expr> list = new ArrayList<Expr>(2); - list.add(new X10StringLit_c(pos, "java")); - list.add(new X10StringLit_c(pos, "x10.lang.Place.place(x10.core.Ref.home(#0))")); - X10ParsedClassType ann= (X10ParsedClassType) ((X10ParsedClassType) xts.NativeType()).propertyInitializers(list); - NATIVE_LOC.update(ann); - } - }); - mi.setDefAnnotations(Collections.<Ref<? extends Type>> singletonList(NATIVE_LOC)); - cd.addMethod(mi); - - // @Native("java", "x10.core.Ref.at(#0, #1)") - // property def at(p:Object):boolean; - List<LocalDef> parameters = xts.dummyLocalDefs(Collections.<Ref<? extends Type>> singletonList(OBJECT)); - mi = xts.methodDef(pos, Types.ref(ct), - X10Flags.toX10Flags(Flags.PUBLIC.Abstract()).Property(), BOOLEAN, - Name.make("at"), - Collections.EMPTY_LIST, - Collections.<Ref<? extends Type>> singletonList(OBJECT), - thisVar, - parameters, - null, - null, - Collections.EMPTY_LIST, - null); - - final LazyRef<X10ParsedClassType> NATIVE_AT_1 = Types.lazyRef(null); - NATIVE_AT_1.setResolver(new Runnable() { - public void run() { - List<Expr> list = new ArrayList<Expr>(2); - list.add(new X10StringLit_c(pos, "java")); - list.add(new X10StringLit_c(pos, "x10.core.Ref.at(#0, #1)")); - X10ParsedClassType ann= (X10ParsedClassType) ((X10ParsedClassType) xts.NativeType()).propertyInitializers(list); - NATIVE_AT_1.update(ann); - } - }); - mi.setDefAnnotations(Collections.<Ref<? extends Type>> singletonList(NATIVE_AT_1)); - cd.addMethod(mi); - - // @Native("java", "x10.core.Ref.at(#0, #1.id)") - // property def at(p:Place):boolean; - parameters = xts.dummyLocalDefs(Collections.<Ref<? extends Type>> singletonList(PLACE)); - mi = xts.methodDef(pos, Types.ref(ct), - X10Flags.toX10Flags(Flags.PUBLIC.Abstract()).Property(), BOOLEAN, - Name.make("at"), - Collections.EMPTY_LIST, - Collections.<Ref<? extends Type>> singletonList(PLACE), - thisVar, - parameters, - null, - null, - Collections.EMPTY_LIST, - null); - final LazyRef<X10ParsedClassType> NATIVE_AT_2 = Types.lazyRef(null); - NATIVE_AT_2.setResolver(new Runnable() { - public void run() { - List<Expr> list = new ArrayList<Expr>(2); - list.add(new X10StringLit_c(pos, "java")); - list.add(new X10StringLit_c(pos, "x10.core.Ref.at(#0, #1.id)")); - X10ParsedClassType ann= (X10ParsedClassType) ((X10ParsedClassType) xts.NativeType()).propertyInitializers(list); - NATIVE_AT_2.update(ann); - } - }); - mi.setDefAnnotations(Collections.<Ref<? extends Type>> singletonList(NATIVE_AT_2)); - cd.addMethod(mi); - - //@NativeRep("java", "x10.core.Any", null, null) - final LazyRef<X10ParsedClassType> NATIVE_REP = Types.lazyRef(null); - NATIVE_REP.setResolver(new Runnable() { - public void run() { - List<Expr> list = new ArrayList<Expr>(4); - list.add(new X10StringLit_c(pos, "java")); - list.add(new X10StringLit_c(pos, "x10.core.Any")); - list.add(null); - list.add(null); - X10ParsedClassType ann = (X10ParsedClassType) ((X10ParsedClassType) xts.NativeRep()).propertyInitializers(list); - - NATIVE_REP.update(ann); - } - }); - - cd.setDefAnnotations(Collections.<Ref<? extends Type>> singletonList(NATIVE_REP)); - return cd; - } -} Modified: trunk/x10.compiler/src/x10/util/Struct.java =================================================================== --- trunk/x10.compiler/src/x10/util/Struct.java 2009-12-22 16:07:30 UTC (rev 12392) +++ trunk/x10.compiler/src/x10/util/Struct.java 2009-12-22 17:32:04 UTC (rev 12393) @@ -1,270 +1,302 @@ -package x10.util; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import polyglot.ast.Expr; -import polyglot.ast.MethodDecl; -import polyglot.ast.TypeNode; -import polyglot.types.ClassDef; -import polyglot.types.ClassType; -import polyglot.types.Flags; -import polyglot.types.LazyRef; -import polyglot.types.LocalDef; -import polyglot.types.Name; -import polyglot.types.QName; -import polyglot.types.Ref; -import polyglot.types.SemanticException; -import polyglot.types.Type; -import polyglot.types.Types; -import polyglot.util.Position; -import x10.ast.AnnotationNode; -import x10.ast.X10StringLit_c; -import x10.constraint.XName; -import x10.constraint.XNameWrapper; -import x10.constraint.XRoot; -import x10.constraint.XTerms; -import x10.extension.X10Ext; -import x10.types.X10ClassDef; -import x10.types.X10ClassDef_c; -import x10.types.X10ClassType; -import x10.types.X10ConstructorDef; -import x10.types.X10Flags; -import x10.types.X10MethodDef; -import x10.types.X10ParsedClassType; -import x10.types.X10ParsedClassType_c; -import x10.types.X10TypeSystem; -import x10.types.X10TypeSystem_c; - -public class Struct { - public static X10ClassDef makeDef(final X10TypeSystem_c xts) { - - final Position pos = Position.COMPILER_GENERATED; - - String name = "Struct"; - X10ClassDef cd = (X10ClassDef) new X10ClassDef_c(xts, null) { - - @Override - public ClassType asType() { - if (asType == null) { - X10ClassDef cd = this; - asType = new X10ParsedClassType_c(this); - } - return asType; - } - }; - - cd.position(pos); - cd.name(Name.make(name)); - try { - cd.setPackage(Types.ref(xts.packageForName(QName.make("x10.lang")))); - } - catch (SemanticException e) { - assert false; - } - - QName fullName = QName.make("x10.lang", name); - cd.kind(ClassDef.TOP_LEVEL); - cd.superType(null); // base class has no superclass - // Functions implement the Any interface. - //cd.setInterfaces(Collections.<Ref<? extends Type>> singletonList(Types.ref(Any()))); - cd.flags(X10Flags.toX10Flags(Flags.PUBLIC.Abstract()).Struct()); - - - // NOTE: don't call cd.asType() until after the type parameters are - // added. - X10ParsedClassType ct = (X10ParsedClassType) cd.asType(); - xts.systemResolver().install(fullName, ct); - - String fullNameWithThis = fullName + "#this"; - //String fullNameWithThis = "this"; - XName thisName = new XNameWrapper<Object>(new Object(), fullNameWithThis); - XRoot thisVar = XTerms.makeLocal(thisName); - - final LazyRef<X10ParsedClassType> PLACE = Types.lazyRef(null); - PLACE.setResolver(new Runnable() { - public void run() { - PLACE.update((X10ParsedClassType) xts.Place()); - } - }); - final LazyRef<X10ParsedClassType> STRING = Types.lazyRef(null); - STRING.setResolver(new Runnable() { - public void run() { - STRING.update((X10ParsedClassType) xts.String()); - } - }); - final LazyRef<X10ParsedClassType> BOOLEAN = Types.lazyRef(null); - BOOLEAN.setResolver(new Runnable() { - public void run() { - BOOLEAN.update((X10ParsedClassType) xts.Boolean()); - } - }); - final LazyRef<X10ParsedClassType> OBJECT = Types.lazyRef(null); - OBJECT.setResolver(new Runnable() { - public void run() { - OBJECT.update((X10ParsedClassType) xts.Object()); - } - }); - X10ConstructorDef ci = (X10ConstructorDef) xts.constructorDef(pos, Types.ref(ct), Flags.PUBLIC.Native(), - Collections.EMPTY_LIST, - Collections.EMPTY_LIST); - cd.addConstructor(ci); - - X10MethodDef mi; - List<Expr> list; - X10ClassType ann; - - // @Native("java", "x10.lang.Place.place(x10.core.Ref.home(#0))") - // property def home():Place - mi = xts.methodDef(pos, Types.ref(ct), - X10Flags.toX10Flags(Flags.PUBLIC.Native()).Property().Global().Safe(), - PLACE, - xts.homeName(), - Collections.EMPTY_LIST, - Collections.EMPTY_LIST, - thisVar, - Collections.EMPTY_LIST, - null, - null, - Collections.EMPTY_LIST, - null); - final LazyRef<X10ParsedClassType> NATIVE_LOC = Types.lazyRef(null); - NATIVE_LOC.setResolver(new Runnable() { - public void run() { - List<Expr> list = new ArrayList<Expr>(2); - list.add(new X10StringLit_c(pos, "java")); - list.add(new X10StringLit_c(pos, "x10.lang.Place.place(x10.core.Ref.home(#0))")); - X10ParsedClassType ann= (X10ParsedClassType) ((X10ParsedClassType) xts.NativeType()).propertyInitializers(list); - NATIVE_LOC.update(ann); - } - }); - mi.setDefAnnotations(Collections.<Ref<? extends Type>> singletonList(NATIVE_LOC)); - cd.addMethod(mi); - - // @Native("java", "x10.core.Ref.at(#0, #1)") - // property def at(p:Object):boolean; - List<LocalDef> parameters = xts.dummyLocalDefs(Collections.<Ref<? extends Type>> singletonList(OBJECT)); - mi = xts.methodDef(pos, Types.ref(ct), - X10Flags.toX10Flags(Flags.PUBLIC.Native()).Property().Safe(), - BOOLEAN, - Name.make("at"), - Collections.EMPTY_LIST, - Collections.<Ref<? extends Type>> singletonList(OBJECT), - thisVar, - parameters, - null, - null, - Collections.EMPTY_LIST, - null); - final LazyRef<X10ParsedClassType> NATIVE_AT_1 = Types.lazyRef(null); - NATIVE_AT_1.setResolver(new Runnable() { - public void run() { - List<Expr> list = new ArrayList<Expr>(2); - list.add(new X10StringLit_c(pos, "java")); - list.add(new X10StringLit_c(pos, "x10.core.Ref.at(#0, #1)")); - X10ParsedClassType ann= (X10ParsedClassType) ((X10ParsedClassType) xts.NativeType()).propertyInitializers(list); - NATIVE_AT_1.update(ann); - } - }); - mi.setDefAnnotations(Collections.<Ref<? extends Type>> singletonList(NATIVE_AT_1)); - cd.addMethod(mi); - - mi = xts.methodDef(pos, - Types.ref(ct), - X10Flags.toX10Flags(Flags.PUBLIC.Native().Final()).Global().Safe(), - STRING, - Name.make("typeName"), - Collections.EMPTY_LIST, - Collections.EMPTY_LIST, - thisVar, - Collections.EMPTY_LIST, - null, - null, - Collections.EMPTY_LIST, - null - ); - final LazyRef<X10ParsedClassType> NATIVE_TYPE_NAME = Types.lazyRef(null); - NATIVE_TYPE_NAME.setResolver(new Runnable() { - public void run() { - List<Expr> list = new ArrayList<Expr>(2); - list.add(new X10StringLit_c(pos, "java")); - list.add(new X10StringLit_c(pos, "x10.core.Ref.typeName(#0)")); - X10ParsedClassType ann= (X10ParsedClassType) ((X10ParsedClassType) xts.NativeType()).propertyInitializers(list); - NATIVE_TYPE_NAME.update(ann); - } - }); - - mi.setDefAnnotations(Collections.<Ref<? extends Type>> singletonList(NATIVE_TYPE_NAME)); - cd.addMethod(mi); - - - - // @Native("java", "x10.core.Ref.at(#0, #1.id)") - // property def at(p:Place):boolean; - parameters = xts.dummyLocalDefs(Collections.<Ref<? extends Type>> singletonList(PLACE)); - mi = xts.methodDef(pos, Types.ref(ct), - X10Flags.toX10Flags(Flags.PUBLIC.Native()).Property().Safe(), - BOOLEAN, - Name.make("at"), - Collections.EMPTY_LIST, - Collections.<Ref<? extends Type>> singletonList(PLACE), - thisVar, - parameters, - null, - null, - Collections.EMPTY_LIST, - null); - final LazyRef<X10ParsedClassType> NATIVE_AT_2 = Types.lazyRef(null); - NATIVE_AT_2.setResolver(new Runnable() { - public void run() { - List<Expr> list = new ArrayList<Expr>(2); - list.add(new X10StringLit_c(pos, "java")); - list.add(new X10StringLit_c(pos, "x10.core.Ref.at(#0, #1.id)")); - X10ParsedClassType ann= (X10ParsedClassType) ((X10ParsedClassType) xts.NativeType()).propertyInitializers(list); - NATIVE_AT_2.update(ann); - } - }); - mi.setDefAnnotations(Collections.<Ref<? extends Type>> singletonList(NATIVE_AT_2)); - cd.addMethod(mi); - - //@NativeRep("java", "x10.core.Struct", null, null) - final LazyRef<X10ParsedClassType> NATIVE_REP = Types.lazyRef(null); - NATIVE_REP.setResolver(new Runnable() { - public void run() { - List<Expr> list = new ArrayList<Expr>(4); - list.add(new X10StringLit_c(pos, "java")); - list.add(new X10StringLit_c(pos, "x10.core.Struct")); - list.add(null); - list.add(null); - X10ParsedClassType ann = (X10ParsedClassType) ((X10ParsedClassType) xts.NativeRep()).propertyInitializers(list); - - NATIVE_REP.update(ann); - } - }); - - - //@NativeRep("c++", "x10::lang::Struct", "x10::lang::Struct", null) - final LazyRef<X10ParsedClassType> NATIVE_REP_CPP = Types.lazyRef(null); - NATIVE_REP_CPP.setResolver(new Runnable() { - public void run() { - List<Expr> list = new ArrayList<Expr>(4); - list.add(new X10StringLit_c(pos, "c++")); - list.add(new X10StringLit_c(pos, "x10::lang::Struct")); - list.add(new X10StringLit_c(pos, "x10::lang::Struct")); - list.add(null); - X10ParsedClassType ann = (X10ParsedClassType) ((X10ParsedClassType) xts.NativeRep()).propertyInitializers(list); - - NATIVE_REP_CPP.update(ann); - } - }); - - List<Ref<? extends Type>> cd_ann = new ArrayList<Ref<? extends Type>>(); - cd_ann.add(NATIVE_REP); - cd_ann.add(NATIVE_REP_CPP); - cd.setDefAnnotations(cd_ann); -// cd.setDefAnnotations(Collections.<Ref<? extends Type>> singletonList(NATIVE_REP)); - return cd; - } - -} +package x10.util; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import polyglot.ast.Expr; +import polyglot.ast.MethodDecl; +import polyglot.ast.TypeNode; +import polyglot.types.ClassDef; +import polyglot.types.ClassType; +import polyglot.types.Flags; +import polyglot.types.LazyRef; +import polyglot.types.LocalDef; +import polyglot.types.Name; +import polyglot.types.QName; +import polyglot.types.Ref; +import polyglot.types.SemanticException; +import polyglot.types.Type; +import polyglot.types.Types; +import polyglot.util.Position; +import x10.ast.AnnotationNode; +import x10.ast.X10StringLit_c; +import x10.constraint.XName; +import x10.constraint.XNameWrapper; +import x10.constraint.XRoot; +import x10.constraint.XTerms; +import x10.extension.X10Ext; +import x10.types.X10ClassDef; +import x10.types.X10ClassDef_c; +import x10.types.X10ClassType; +import x10.types.X10ConstructorDef; +import x10.types.X10Flags; +import x10.types.X10MethodDef; +import x10.types.X10ParsedClassType; +import x10.types.X10ParsedClassType_c; +import x10.types.X10TypeSystem; +import x10.types.X10TypeSystem_c; + +public class Struct { + public static X10ClassDef makeDef(final X10TypeSystem_c xts) { + + final Position pos = Position.COMPILER_GENERATED; + + String name = "Struct"; + X10ClassDef cd = (X10ClassDef) new X10ClassDef_c(xts, null) { + + @Override + public ClassType asType() { + if (asType == null) { + X10ClassDef cd = this; + asType = new X10ParsedClassType_c(this); + } + return asType; + } + }; + + cd.position(pos); + cd.name(Name.make(name)); + try { + cd.setPackage(Types.ref(xts.packageForName(QName.make("x10.lang")))); + } + catch (SemanticException e) { + assert false; + } + + QName fullName = QName.make("x10.lang", name); + cd.kind(ClassDef.TOP_LEVEL); + cd.superType(null); // base class has no superclass + + cd.setInterfaces(Collections.<Ref<? extends Type>> singletonList(xts.lazyAny())); + cd.flags(X10Flags.toX10Flags(Flags.PUBLIC.Abstract()).Struct()); + + + // NOTE: don't call cd.asType() until after the type parameters are + // added. + X10ParsedClassType ct = (X10ParsedClassType) cd.asType(); + xts.systemResolver().install(fullName, ct); + + String fullNameWithThis = fullName + "#this"; + //String fullNameWithThis = "this"; + XName thisName = new XNameWrapper<Object>(new Object(), fullNameWithThis); + XRoot thisVar = XTerms.makeLocal(thisName); + + final LazyRef<X10ParsedClassType> PLACE = Types.lazyRef(null); + PLACE.setResolver(new Runnable() { + public void run() { + PLACE.update((X10ParsedClassType) xts.Place()); + } + }); + final LazyRef<X10ParsedClassType> STRING = Types.lazyRef(null); + STRING.setResolver(new Runnable() { + public void run() { + STRING.update((X10ParsedClassType) xts.String()); + } + }); + final LazyRef<X10ParsedClassType> BOOLEAN = Types.lazyRef(null); + BOOLEAN.setResolver(new Runnable() { + public void run() { + BOOLEAN.update((X10ParsedClassType) xts.Boolean()); + } + }); + final LazyRef<X10ParsedClassType> OBJECT = Types.lazyRef(null); + OBJECT.setResolver(new Runnable() { + public void run() { + OBJECT.update((X10ParsedClassType) xts.Object()); + } + }); + X10ConstructorDef ci = (X10ConstructorDef) xts.constructorDef(pos, Types.ref(ct), Flags.PUBLIC.Native(), + Collections.EMPTY_LIST, + Collections.EMPTY_LIST); + cd.addConstructor(ci); + + X10MethodDef mi; + List<Expr> list; + X10ClassType ann; + + // @Native("java", "x10.lang.Place.place(x10.core.Ref.home(#0))") + // property def home():Place + mi = xts.methodDef(pos, Types.ref(ct), + X10Flags.toX10Flags(Flags.PUBLIC.Native()).Property().Global().Safe(), + PLACE, + xts.homeName(), + Collections.EMPTY_LIST, + Collections.EMPTY_LIST, + thisVar, + Collections.EMPTY_LIST, + null, + null, + Collections.EMPTY_LIST, + null); + final LazyRef<X10ParsedClassType> NATIVE_LOC = Types.lazyRef(null); + NATIVE_LOC.setResolver(new Runnable() { + public void run() { + List<Expr> list = new ArrayList<Expr>(2); + list.add(new X10StringLit_c(pos, "java")); + list.add(new X10StringLit_c(pos, "x10.lang.Place.place(x10.core.Ref.home(#0))")); + X10ParsedClassType ann= (X10ParsedClassType) ((X10ParsedClassType) xts.NativeType()).propertyInitializers(list); + NATIVE_LOC.update(ann); + } + }); + mi.setDefAnnotations(Collections.<Ref<? extends Type>> singletonList(NATIVE_LOC)); + cd.addMethod(mi); + + // @Native("java", "x10.core.Ref.at(#0, #1)") + // property def at(p:Object):boolean; + List<LocalDef> parameters = xts.dummyLocalDefs(Collections.<Ref<? extends Type>> singletonList(OBJECT)); + mi = xts.methodDef(pos, Types.ref(ct), + X10Flags.toX10Flags(Flags.PUBLIC.Native()).Property().Safe(), + BOOLEAN, + Name.make("at"), + Collections.EMPTY_LIST, + Collections.<Ref<? extends Type>> singletonList(OBJECT), + thisVar, + parameters, + null, + null, + Collections.EMPTY_LIST, + null); + final LazyRef<X10ParsedClassType> NATIVE_AT_1 = Types.lazyRef(null); + NATIVE_AT_1.setResolver(new Runnable() { + public void run() { + List<Expr> list = new ArrayList<Expr>(2); + list.add(new X10StringLit_c(pos, "java")); + list.add(new X10StringLit_c(pos, "x10.core.Ref.at(#0, #1)")); + X10ParsedClassType ann= (X10ParsedClassType) ((X10ParsedClassType) xts.NativeType()).propertyInitializers(list); + NATIVE_AT_1.update(ann); + } + }); + mi.setDefAnnotations(Collections.<Ref<? extends Type>> singletonList(NATIVE_AT_1)); + cd.addMethod(mi); + + // @Native("java", "x10.core.Ref.typeName(#0)") + // native final global safe def typeName():String; + mi = xts.methodDef(pos, + Types.ref(ct), + X10Flags.toX10Flags(Flags.PUBLIC.Native().Final()).Global().Safe(), + STRING, + Name.make("typeName"), + Collections.EMPTY_LIST, + Collections.EMPTY_LIST, + thisVar, + Collections.EMPTY_LIST, + null, + null, + Collections.EMPTY_LIST, + null + ); + final LazyRef<X10ParsedClassType> NATIVE_TYPE_NAME = Types.lazyRef(null); + NATIVE_TYPE_NAME.setResolver(new Runnable() { + public void run() { + List<Expr> list = new ArrayList<Expr>(2); + list.add(new X10StringLit_c(pos, "java")); + list.add(new X10StringLit_c(pos, "x10.core.Ref.typeName(#0)")); + X10ParsedClassType ann= (X10ParsedClassType) ((X10ParsedClassType) xts.NativeType()).propertyInitializers(list); + NATIVE_TYPE_NAME.update(ann); + } + }); + + mi.setDefAnnotations(Collections.<Ref<? extends Type>> singletonList(NATIVE_TYPE_NAME)); + cd.addMethod(mi); + + // @Native("java", "\"<struct>\"") + // native global safe def toString():String; + mi = xts.methodDef(pos, + Types.ref(ct), + X10Flags.toX10Flags(Flags.PUBLIC.Native()).Global().Safe(), + STRING, + Name.make("toString"), + Collections.EMPTY_LIST, + Collections.EMPTY_LIST, + thisVar, + Collections.EMPTY_LIST, + null, + null, + Collections.EMPTY_LIST, + null + ); + final LazyRef<X10ParsedClassType> NATIVE_TYPE_NAME2 = Types.lazyRef(null); + NATIVE_TYPE_NAME2.setResolver(new Runnable() { + public void run() { + List<Expr> list = new ArrayList<Expr>(2); + list.add(new X10StringLit_c(pos, "java")); + list.add(new X10StringLit_c(pos, "\"<struct>\"")); + X10ParsedClassType ann= (X10ParsedClassType) ((X10ParsedClassType) xts.NativeType()).propertyInitializers(list); + NATIVE_TYPE_NAME2.update(ann); + } + }); + + mi.setDefAnnotations(Collections.<Ref<? extends Type>> singletonList(NATIVE_TYPE_NAME2)); + cd.addMethod(mi); + + + + // @Native("java", "x10.core.Ref.at(#0, #1.id)") + // property def at(p:Place):boolean; + parameters = xts.dummyLocalDefs(Collections.<Ref<? extends Type>> singletonList(PLACE)); + mi = xts.methodDef(pos, Types.ref(ct), + X10Flags.toX10Flags(Flags.PUBLIC.Native()).Property().Safe(), + BOOLEAN, + Name.make("at"), + Collections.EMPTY_LIST, + Collections.<Ref<? extends Type>> singletonList(PLACE), + thisVar, + parameters, + null, + null, + Collections.EMPTY_LIST, + null); + final LazyRef<X10ParsedClassType> NATIVE_AT_2 = Types.lazyRef(null); + NATIVE_AT_2.setResolver(new Runnable() { + public void run() { + List<Expr> list = new ArrayList<Expr>(2); + list.add(new X10StringLit_c(pos, "java")); + list.add(new X10StringLit_c(pos, "x10.core.Ref.at(#0, #1.id)")); + X10ParsedClassType ann= (X10ParsedClassType) ((X10ParsedClassType) xts.NativeType()).propertyInitializers(list); + NATIVE_AT_2.update(ann); + } + }); + mi.setDefAnnotations(Collections.<Ref<? extends Type>> singletonList(NATIVE_AT_2)); + cd.addMethod(mi); + + //@NativeRep("java", "x10.core.Struct", null, null) + final LazyRef<X10ParsedClassType> NATIVE_REP = Types.lazyRef(null); + NATIVE_REP.setResolver(new Runnable() { + public void run() { + List<Expr> list = new ArrayList<Expr>(4); + list.add(new X10StringLit_c(pos, "java")); + list.add(new X10StringLit_c(pos, "x10.core.Struct")); + list.add(null); + list.add(null); + X10ParsedClassType ann = (X10ParsedClassType) ((X10ParsedClassType) xts.NativeRep()).propertyInitializers(list); + + NATIVE_REP.update(ann); + } + }); + + + //@NativeRep("c++", "x10::lang::Struct", "x10::lang::Struct", null) + final LazyRef<X10ParsedClassType> NATIVE_REP_CPP = Types.lazyRef(null); + NATIVE_REP_CPP.setResolver(new Runnable() { + public void run() { + List<Expr> list = new ArrayList<Expr>(4); + list.add(new X10StringLit_c(pos, "c++")); + list.add(new X10StringLit_c(pos, "x10::lang::Struct")); + list.add(new X10StringLit_c(pos, "x10::lang::Struct")); + list.add(null); + X10ParsedClassType ann = (X10ParsedClassType) ((X10ParsedClassType) xts.NativeRep()).propertyInitializers(list); + + NATIVE_REP_CPP.update(ann); + } + }); + + List<Ref<? extends Type>> cd_ann = new ArrayList<Ref<? extends Type>>(); + cd_ann.add(NATIVE_REP); + cd_ann.add(NATIVE_REP_CPP); + cd.setDefAnnotations(cd_ann); +// cd.setDefAnnotations(Collections.<Ref<? extends Type>> singletonList(NATIVE_REP)); + return cd; + } + +} Modified: trunk/x10.compiler/src/x10/visit/X10PrettyPrinterVisitor.java =================================================================== --- trunk/x10.compiler/src/x10/visit/X10PrettyPrinterVisitor.java 2009-12-22 16:07:30 UTC (rev 12392) +++ trunk/x10.compiler/src/x10/visit/X10PrettyPrinterVisitor.java 2009-12-22 17:32:04 UTC (rev 12393) @@ -560,7 +560,7 @@ w.write("x10.core.Ref"); } - // Filter out x10.lang.Object from the interfaces. + // Filter out x10.lang.Any from the interfaces. List<TypeNode> interfaces = new ArrayList<TypeNode>(); for (TypeNode tn: n.interfaces()) { @@ -568,11 +568,13 @@ interfaces.add(tn); } } - if (n.flags().flags().isInterface() && interfaces.isEmpty()) { + /* Interfaces automatically extend Any + if (n.flags().flags().isInterface() && interfaces.isEmpty()) { + X10TypeSystem ts = (X10TypeSystem) tr.typeSystem(); interfaces.add(tr.nodeFactory().CanonicalTypeNode(n.position(), ts.Any())); } - +*/ if (!interfaces.isEmpty()) { w.allowBreak(2); if (flags.isInterface()) { Modified: trunk/x10.compiler/src/x10cpp/visit/Emitter.java =================================================================== --- trunk/x10.compiler/src/x10cpp/visit/Emitter.java 2009-12-22 16:07:30 UTC (rev 12392) +++ trunk/x10.compiler/src/x10cpp/visit/Emitter.java 2009-12-22 17:32:04 UTC (rev 12393) @@ -603,12 +603,10 @@ X10TypeSystem_c xts = (X10TypeSystem_c) ct.typeSystem(); String x10name = ct.fullName().toString(); int numParents = 0; - if (ct.superClass() != null && !xts.isAny(ct.superClass())) { + if (ct.superClass() != null) { numParents++; } - for (Type iface: ct.interfaces()) { - if (!xts.isAny(iface)) numParents++; - } + numParents += ct.interfaces().size(); if (ct.typeArguments().isEmpty()) { boolean first = true; @@ -617,12 +615,11 @@ h.write("rtt.canonical = &rtt;"); h.newline(); if (numParents > 0) { h.write("const x10aux::RuntimeType* parents["+numParents+"] = { "); - if (ct.superClass() != null && !xts.isAny(ct.superClass())) { + if (ct.superClass() != null) { h.write("x10aux::getRTT" + chevrons(translateType(ct.superClass())) + "()"); first = false; } for (Type iface : ct.interfaces()) { - if (xts.isAny(iface)) continue; // IGNORE ANY if (!first) h.write(", "); h.write("x10aux::getRTT"+chevrons(translateType(iface))+"()"); first = false; @@ -648,12 +645,11 @@ h.write("rtt.canonical = &rtt;"); h.newline(); if (numParents > 0) { h.write("const x10aux::RuntimeType* parents["+numParents+"] = { "); - if (ct.superClass() != null && !xts.isAny(ct.superClass())) { + if (ct.superClass() != null) { h.write("x10aux::getRTT" + chevrons(translateType(ct.superClass())) + "()"); first = false; } for (Type iface : ct.interfaces()) { - if (xts.isAny(iface)) continue; // IGNORE ANY if (!first) h.write(", "); h.write("x10aux::getRTT"+chevrons(translateType(iface))+"()"); first = false; Modified: trunk/x10.compiler/src/x10cpp/visit/ITable.java =================================================================== --- trunk/x10.compiler/src/x10cpp/visit/ITable.java 2009-12-22 16:07:30 UTC (rev 12392) +++ trunk/x10.compiler/src/x10cpp/visit/ITable.java 2009-12-22 17:32:04 UTC (rev 12393) @@ -41,7 +41,6 @@ */ private ITable(X10ClassType interfaceType) { assert interfaceType.flags().isInterface() : "Cannot create an ITable for a non-interface type"; - assert !((X10TypeSystem)interfaceType.typeSystem()).isAny(interfaceType) : "Should be ignoring Any in C++ backend"; this.interfaceType = interfaceType; methods = collectMethods(interfaceType); Arrays.sort(methods, new MethodComparator()); @@ -64,8 +63,6 @@ uniqueMethods.addAll(interfaceType.methods()); for (X10ClassType superInterface : ((X10TypeSystem)interfaceType.typeSystem()).allImplementedInterfaces(interfaceType)) { - if (xts.isAny(superInterface)) continue; // IGNORE ANY - for (MethodInstance newMethod : superInterface.methods()) { boolean duplicate = false; for (MethodInstance oldMethod : uniqueMethods) { @@ -209,7 +206,7 @@ sw.newline(); for (MethodInstance meth : methods) { - sw.write(Emitter.translateType(meth.returnType())); + sw.write(Emitter.translateType(meth.returnType(), true)); sw.write(" "); sw.write(Emitter.mangled_method_name(meth.name().toString())); sw.write("("); Modified: trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java =================================================================== --- trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java 2009-12-22 16:07:30 UTC (rev 12392) +++ trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java 2009-12-22 17:32:04 UTC (rev 12393) @@ -637,12 +637,6 @@ // emit no c++ code as this is a native rep class return; } - - if (xts.isAny(def.asType())) { - // HACK: We don't need Any in the C++ backend, but we do in the Java backend. - // So, here we want to ignore the class decl for x10.lang.Any - return; - } assert (!def.isNested()) : ("Nested class alert!"); @@ -755,7 +749,6 @@ } for (TypeNode i : n.interfaces()) { ClassType ct = i.type().toClass(); - if (xts.isAny(ct)) continue; // IGNORE ANY X10ClassDef icd = (X10ClassDef) ct.def(); if (icd != def) { String header = getHeader(ct); @@ -806,7 +799,6 @@ ArrayList<ClassType> types = referencedTypes(n, def); for (ClassType ct : types) { - if (xts.isAny(ct)) continue; // IGNORE ANY X10ClassDef cd = (X10ClassDef) ct.def(); if (cd == def) continue; @@ -1176,23 +1168,6 @@ h.write("return x10::lang::Reference::"+DESERIALIZE_METHOD+"<__T>(buf);"); h.end(); h.newline(); h.write("}"); h.newline(); h.forceNewline(); - /* equals redirection method: Something of an interface type is a subclass of Object even if C++ doesn't know that... */ - // FIXME: XTENLANG-752. This is wrong in X10 2.0 because closures implement interfaces, but are not objects. - h.write("x10_boolean equals(x10aux::ref<x10::lang::Object> that) {"); h.newline(4); h.begin(0); - h.write("return x10aux::class_cast_unchecked<x10aux::ref<x10::lang::Object> >("+ - Emitter.translateType(currentClass, true)+"(this))->equals(that);"); - h.end(); h.newline(); - h.write("}"); h.newline(); h.forceNewline(); - - /* hashCode redirection method: Something of an interface type is a subclass of Object even if C++ doesn't know that... */ - // FIXME: XTENLANG-752. This is wrong in X10 2.0 because closures implement interfaces, but are not objects. - h.write("x10_int hashCode() {"); h.newline(4); h.begin(0); - h.write("return x10aux::class_cast_unchecked<x10aux::ref<x10::lang::Object> >("+ - Emitter.translateType(currentClass, true)+"(this))->hashCode();"); - h.end(); h.newline(); - h.write("}"); h.newline(); h.forceNewline(); - - if (!members.isEmpty()) { String className = Emitter.translateType(currentClass); @@ -1382,6 +1357,19 @@ sw.forceNewline(); } + // Deal with the methods of Any. + + // We must define them all in the struct_methods class so they can be picked up by the ITables + // FIXME: The at methods are stubbed out so linking will work. + // We need real implementations before we can actually call them successfully! + // What are the desired semantics, since a struct is "at" all places...? + // FIXME: The home method should call Place_methods::make(here) instead of doing a C++ level construction. + h.writeln("static x10_boolean at("+Emitter.translateType(currentClass, false)+" this_, x10aux::ref<x10::lang::Ref> obj) { /* FIXME What are the desired semantics? */ return true; }"); + h.writeln("static x10_boolean at("+Emitter.translateType(currentClass, false)+" this_, x10::lang::Place place) { /* FIXME What are the desired semantics ? */ return true; }"); + h.writeln("static x10::lang::Place home("+Emitter.translateType(currentClass, false)+" this_) { /* FIXME */ x10::lang::Place tmp; tmp->FMGL(id)=x10aux::here; return tmp; }"); + + h.writeln("static x10aux::ref<x10::lang::String> typeName("+Emitter.translateType(currentClass, false)+" this_) { return this_->typeName(); }"); + // All types support toString. If there is no user-defined toString, then we define one here. // We also have to define a redirection method so that toString is actually defined // on the struct class, not just in the structMethods. This is to fit in with @@ -1452,14 +1440,13 @@ private void generateITablesForClass(X10ClassType currentClass, X10TypeSystem xts, String maybeVirtual, ClassifiedStream h) { List<X10ClassType> allInterfaces = xts.allImplementedInterfaces(currentClass); - int numInterfaces = allInterfaces.size() - 1; // IGNORE ANY by subtracting 1 + int numInterfaces = allInterfaces.size(); if (numInterfaces > 0 && !currentClass.flags().isAbstract()) { /* ITables declarations */ h.write("static x10aux::itable_entry _itables["+(numInterfaces+1)+"];"); h.newline(); h.forceNewline(); h.write(maybeVirtual+"x10aux::itable_entry* _getITables() { return _itables; }"); h.newline(); h.forceNewline(); int itableNum = 0; for (Type interfaceType : allInterfaces) { - if (xts.isAny(interfaceType)) continue; // IGNORE ANY ITable itable = ITable.getITable((X10ClassType) X10TypeMixin.baseType(interfaceType)); itable.emitITableDecl(currentClass, itableNum, emitter, h); itableNum += 1; @@ -1469,7 +1456,6 @@ /* ITables initialization */ itableNum = 0; for (Type interfaceType : allInterfaces) { - if (xts.isAny(interfaceType)) continue; // IGNORE ANY ITable itable = ITable.getITable((X10ClassType) X10TypeMixin.baseType(interfaceType)); itable.emitITableInitialization(currentClass, itableNum, emitter, h, sw); itableNum += 1; @@ -1481,7 +1467,6 @@ sw.write("x10aux::itable_entry "+Emitter.translateType(currentClass)+"::_itables["+(numInterfaces+1)+"] = {"); itableNum = 0; for (Type interfaceType : allInterfaces) { - if (xts.isAny(interfaceType)) continue; // IGNORE ANY sw.write("x10aux::itable_entry(x10aux::getRTT"+chevrons(Emitter.translateType(interfaceType, false))+"(), &_itable_"+itableNum+"), "); itableNum += 1; } @@ -1493,7 +1478,7 @@ X10TypeSystem xts, ClassifiedStream sh, ClassifiedStream h) { List<X10ClassType> allInterfaces = xts.allImplementedInterfaces(currentClass); - int numInterfaces = allInterfaces.size() - 1; // IGNORE ANY by subtracting 1 + int numInterfaces = allInterfaces.size(); if (numInterfaces > 0 && !currentClass.flags().isAbstract()) { String thunkBaseName = Emitter.mangled_non_method_name(currentClass.name().toString()); String thunkParams = ""; @@ -1517,7 +1502,6 @@ /* ITables initialization */ int itableNum = 0; for (Type interfaceType : allInterfaces) { - if (xts.isAny(interfaceType)) continue; // IGNORE ANY ITable itable = ITable.getITable((X10ClassType) X10TypeMixin.baseType(interfaceType)); itable.emitITableInitialization(currentClass, itableNum, emitter, h, sw); itableNum += 1; @@ -1532,7 +1516,6 @@ sw.write("x10aux::itable_entry "+clsCType+"::_"+ibox+"itables["+(numInterfaces+1)+"] = {"); itableNum = 0; for (Type interfaceType : allInterfaces) { - if (xts.isAny(interfaceType)) continue; // IGNORE ANY sw.write("x10aux::itable_entry(x10aux::getRTT"+chevrons(Emitter.translateType(interfaceType, false))+"(), &"+ thunkBaseName+"_"+ibox+"ithunk"+itableNum+thunkParams+"::itable), "); itableNum += 1; @@ -3953,7 +3936,7 @@ if (in_template_closure) emitter.printTemplateSignature(freeTypeParams, inc); inc.write((in_template_closure ? "typename ": "")+superType+(in_template_closure ? "::template itable ": "::itable")+chevrons(cnamet)+ - cnamet+"::_itable(&"+cnamet+"::apply);"); + cnamet+"::_itable(&"+cnamet+"::apply, &"+cnamet+"::at, &"+cnamet+"::at, &"+cnamet+"::home, &"+cnamet+"::toString, &"+cnamet+"::typeName);"); if (in_template_closure) emitter.printTemplateSignature(freeTypeParams, inc); Modified: trunk/x10.constraints/src/x10/constraint/XFormula_c.java =================================================================== --- trunk/x10.constraints/src/x10/constraint/XFormula_c.java 2009-12-22 16:07:30 UTC (rev 12392) +++ trunk/x10.constraints/src/x10/constraint/XFormula_c.java 2009-12-22 17:32:04 UTC (rev 12393) @@ -102,7 +102,7 @@ for (int i = 0; i < arguments.size(); i++) { XTerm arg = arguments.get(i); if (arg == null) { - // System.err.println("XFormula_c: Golden: null arg in " + this); + // System.err.println("XFormula_c: null arg in " + this); continue; } Modified: trunk/x10.dist/.launchConfigs/x10c.launch =================================================================== --- trunk/x10.dist/.launchConfigs/x10c.launch 2009-12-22 16:07:30 UTC (rev 12392) +++ trunk/x10.dist/.launchConfigs/x10c.launch 2009-12-22 17:32:04 UTC (rev 12393) @@ -1,26 +1,26 @@ -<?xml version="1.0" encoding="UTF-8"?> -<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication"> -<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS"> -<listEntry value="/polyglot3/src/polyglot/main/Main.java"/> -</listAttribute> -<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES"> -<listEntry value="1"/> -</listAttribute> -<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/> -<listAttribute key="org.eclipse.debug.ui.favoriteGroups"> -<listEntry value="org.eclipse.debug.ui.launchGroup.run"/> -<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/> -</listAttribute> -<listAttribute key="org.eclipse.jdt.launching.CLASSPATH"> -<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry containerPath="org.eclipse.jdt.launching.JRE_CONTAINER" javaProject="x10.compiler" path="1" type="4"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry path="3" projectName="polyglot3" type="1"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry path="3" projectName="x10.constraints" type="1"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry id="org.eclipse.jdt.launching.classpathentry.defaultClasspath"> <memento exportedEntriesOnly="false" project="x10.compiler"/> </runtimeClasspathEntry> "/> -</listAttribute> -<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="false"/> -<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="polyglot.main.Main"/> -<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-extclass x10.ExtensionInfo "${resource_loc}" -sourcepath "${workspace_loc:x10.runtime/src-x10}" -sourcepath "${workspace_loc:x10.dist}/lib/x10.jar" -sourcepath "${workspace_loc:x10.tests}/examples/x10lib" -noserial -assert -post "javac -source 1.5" -d out -disable CheckNativeAnnotations "/> -<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="x10.compiler"/> -<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-ea"/> -<stringAttribute key="org.eclipse.jdt.launching.WORKING_DIRECTORY" value="${container_loc}"/> -</launchConfiguration> +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication"> +<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS"> +<listEntry value="/polyglot3/src/polyglot/main/Main.java"/> +</listAttribute> +<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES"> +<listEntry value="1"/> +</listAttribute> +<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/> +<listAttribute key="org.eclipse.debug.ui.favoriteGroups"> +<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/> +<listEntry value="org.eclipse.debug.ui.launchGroup.run"/> +</listAttribute> +<listAttribute key="org.eclipse.jdt.launching.CLASSPATH"> +<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry containerPath="org.eclipse.jdt.launching.JRE_CONTAINER" javaProject="x10.compiler" path="1" type="4"/> "/> +<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry path="3" projectName="polyglot3" type="1"/> "/> +<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry path="3" projectName="x10.constraints" type="1"/> "/> +<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry id="org.eclipse.jdt.launching.classpathentry.defaultClasspath"> <memento exportedEntriesOnly="false" project="x10.compiler"/> </runtimeClasspathEntry> "/> +</listAttribute> +<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="false"/> +<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="polyglot.main.Main"/> +<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-extclass x10.ExtensionInfo "${resource_loc}" -sourcepath "${workspace_loc:x10.runtime/src-x10}" -sourcepath "${workspace_loc:x10.dist}/lib/x10.jar" -sourcepath "${workspace_loc:x10.tests}/examples/x10lib" -noserial -ass... [truncated message content] |
From: <dgr...@us...> - 2009-12-22 18:41:07
|
Revision: 12396 http://x10.svn.sourceforge.net/x10/?rev=12396&view=rev Author: dgrove-oss Date: 2009-12-22 18:40:40 +0000 (Tue, 22 Dec 2009) Log Message: ----------- run x10.dist/releng/normalizeSVNProperties to fix properties on files that were added with improperly configured svn clients. Modified Paths: -------------- trunk/x10.compiler/src/x10/ast/AmbHereThis_c.java trunk/x10.compiler/src/x10/ast/PlacedClosure.java trunk/x10.compiler/src/x10/ast/PlacedClosure_c.java trunk/x10.compiler/src/x10/util/Struct.java trunk/x10.compiler/src/x10/visit/TryTypeChecker.java trunk/x10.compiler/src/x10/visit/TryVisitorI.java trunk/x10.constraints/src/x10/constraint/XConstrainedTerm.java trunk/x10.runtime/src-java/x10/core/Struct.java trunk/x10.runtime/src-x10/x10/lang/Any.x10 trunk/x10.runtime/src-x10/x10/lang/Cell.x10 trunk/x10.runtime/src-x10/x10/lang/Complex.x10 trunk/x10.runtime/src-x10/x10/lang/Top.x10 trunk/x10.runtime/src-x10/x10/lang/flat.x10 trunk/x10.runtime/src-x10/x10/util/Option.x10 trunk/x10.runtime/src-x10/x10/util/OptionsParser.x10 trunk/x10.runtime/src-x10/x10/util/Pair.x10 trunk/x10.tests/examples/Constructs/At/AtFieldWrite.x10 trunk/x10.tests/examples/Constructs/At/AtFieldWrite_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Call/StructCall.x10 trunk/x10.tests/examples/Constructs/Call/StructCall2_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Call/StructCall3_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Call/StructCall_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Cast/InlineConstraint.x10 trunk/x10.tests/examples/Constructs/Cast/MacroConstraint.x10 trunk/x10.tests/examples/Constructs/Closures/ClosureCall0a_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Closures/ClosureCall1b_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Closures/ClosureCall1c_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Closures/ClosureCall1d_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Conversion/SubtypeCheckForUserDefinedConversion_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Fun/FunIsNotObject_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Fun/GuardedFunctionInvocation.x10 trunk/x10.tests/examples/Constructs/Fun/GuardedFunctionInvocationWithType.x10 trunk/x10.tests/examples/Constructs/Fun/GuardedFunctionInvocation_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Generics/Bounds7.x10 trunk/x10.tests/examples/Constructs/Place/AtCheck.x10 trunk/x10.tests/examples/Constructs/Place/AtCheck2.x10 trunk/x10.tests/examples/Constructs/Place/AtCheck2_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Place/AtThisIntoAtHere.x10 trunk/x10.tests/examples/Constructs/Place/AtThisIntoAtHere_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Place/At_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Place/B_AtThisIntoAtHere.x10 trunk/x10.tests/examples/Constructs/Place/B_AtThisIntoAtHere_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Place/B_CheckThisTypeInCall.x10 trunk/x10.tests/examples/Constructs/Place/B_CheckThisTypeInCallMacro.x10 trunk/x10.tests/examples/Constructs/Place/CheckThisTypeInCall.x10 trunk/x10.tests/examples/Constructs/Place/FieldReceiverIsExpr.x10 trunk/x10.tests/examples/Constructs/Place/FieldWrite.x10 trunk/x10.tests/examples/Constructs/Place/FutureFielAccessRev_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Place/FutureFieldAccessStatic_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Place/FutureFieldAccessStruct.x10 trunk/x10.tests/examples/Constructs/Place/FutureFieldAccess_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Place/FutureGlobalMethodInvoke.x10 trunk/x10.tests/examples/Constructs/Place/FutureGlobalMethodInvokeRev.x10 trunk/x10.tests/examples/Constructs/Place/FutureGlobalMethodInvokeStatic.x10 trunk/x10.tests/examples/Constructs/Place/FutureGlobalMethodInvokeStruct.x10 trunk/x10.tests/examples/Constructs/Place/FutureMethodInvokeRev_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Place/FutureMethodInvokeStatic_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Place/FutureMethodInvoke_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Place/FuturePropertyAccess.x10 trunk/x10.tests/examples/Constructs/Place/FuturePropertyAccessRev.x10 trunk/x10.tests/examples/Constructs/Place/FuturePropertyAccessStatic.x10 trunk/x10.tests/examples/Constructs/Place/FutureVarFieldAccessRev_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Place/FutureVarFieldAccessStatic_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Place/FutureVarFieldAccess_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Place/GlobalAccess.x10 trunk/x10.tests/examples/Constructs/Place/PlaceCheckStringBuilder_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Structs/StructCannotHaveVarField_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Structs/StructCannotSubclassClass_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Structs/StructImplicitCoercionToInterface.x10 trunk/x10.tests/examples/Constructs/XtenTwoOhTypeSsytem/ObjectIsNotParameterType2_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/XtenTwoOhTypeSsytem/ObjectIsNotParameterType3_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/XtenTwoOhTypeSsytem/ObjectIsNotParameterType4_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/XtenTwoOhTypeSsytem/ObjectIsNotParameterType_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/XtenTwoOhTypeSsytem/ParameterTypeIsNotObject2_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/XtenTwoOhTypeSsytem/ParameterTypeIsNotObject3_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/XtenTwoOhTypeSsytem/ParameterTypeIsNotObject4_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/XtenTwoOhTypeSsytem/ParameterTypeIsNotObject_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/XtenTwoOhTypeSsytem/PrimitiveIsNotParameterType_MustFailCompile.x10 trunk/x10.tests/examples/Issues/XTENLANG_298_MustFailCompile.x10 trunk/x10.tests/tests/Constructs/Proto/Cast_MustFailCompile.x10 trunk/x10.tests/tests/Constructs/Proto/Coercion2_MustFailCompile.x10 trunk/x10.tests/tests/Constructs/Proto/Coercion_MustFailCompile.x10 trunk/x10.tests/tests/Constructs/Proto/ConstructorMustReturnProto_MustFailCompile.x10 trunk/x10.tests/tests/Constructs/Proto/CovariantCall.x10 trunk/x10.tests/tests/Constructs/Proto/MethodMustReturnProto_MustFailCompile.x10 trunk/x10.tests/tests/Constructs/Proto/ProtoAssign.x10 trunk/x10.tests/tests/Constructs/Proto/ProtoAssignField.x10 trunk/x10.tests/tests/Constructs/Proto/ProtoCall_MustFailCompile.x10 trunk/x10.tests/tests/Constructs/Proto/ProtoCatch_MustFailCompile.x10 trunk/x10.tests/tests/Constructs/Proto/ProtoField_MustFailCompile.x10 trunk/x10.tests/tests/Constructs/Proto/ProtoImplements_MustFailCompile.x10 trunk/x10.tests/tests/Constructs/Proto/ProtoReadField_MustFailCompile.x10 trunk/x10.tests/tests/Constructs/Proto/ProtoSuper_MustFailCompile.x10 trunk/x10.tests/tests/Constructs/Proto/StaticMethod_MustFailCompile.x10 Property Changed: ---------------- trunk/SafeX10/src/Effects.x10 trunk/x10.common/contrib/ant/IfTask.java trunk/x10.compiler/src/x10/ast/AmbHereThis_c.java trunk/x10.compiler/src/x10/ast/PlacedClosure.java trunk/x10.compiler/src/x10/ast/PlacedClosure_c.java trunk/x10.compiler/src/x10/optimizations/LoopUnroller.java trunk/x10.compiler/src/x10/optimizations/Optimizer.java trunk/x10.compiler/src/x10/util/Struct.java trunk/x10.compiler/src/x10/visit/TryTypeChecker.java trunk/x10.compiler/src/x10/visit/TryVisitorI.java trunk/x10.compiler/src/x10cpp/postcompiler/AIX_CXXCommandBuilder.java trunk/x10.compiler/src/x10cpp/postcompiler/CXXCommandBuilder.java trunk/x10.compiler/src/x10cpp/postcompiler/Cygwin_CXXCommandBuilder.java trunk/x10.compiler/src/x10cpp/postcompiler/Linux_CXXCommandBuilder.java trunk/x10.compiler/src/x10cpp/postcompiler/MacOSX_CXXCommandBuilder.java trunk/x10.compiler/src/x10cpp/postcompiler/SunOS_CXXCommandBuilder.java trunk/x10.constraints/src/x10/constraint/XConstrainedTerm.java trunk/x10.dist/samples/CUDABlackScholes.x10 trunk/x10.dist/samples/CUDAKernelTest.x10 trunk/x10.dist/samples/CUDATopology.x10 trunk/x10.dist/samples/HelloWholeWorld.x10 trunk/x10.dist/samples/KMeansCUDA.x10 trunk/x10.dist/samples/StructSpheres.x10 trunk/x10.doc/src/x10doc/ExtensionInfo.java trunk/x10.doc/src/x10doc/doc/X10ClassDoc.java trunk/x10.doc/src/x10doc/doc/X10ConstructorDoc.java trunk/x10.doc/src/x10doc/doc/X10Doc.java trunk/x10.doc/src/x10doc/doc/X10FieldDoc.java trunk/x10.doc/src/x10doc/doc/X10MethodDoc.java trunk/x10.doc/src/x10doc/doc/X10PackageDoc.java trunk/x10.doc/src/x10doc/doc/X10Parameter.java trunk/x10.doc/src/x10doc/doc/X10ParameterizedType.java trunk/x10.doc/src/x10doc/doc/X10RootDoc.java trunk/x10.doc/src/x10doc/doc/X10SeeTag.java trunk/x10.doc/src/x10doc/doc/X10Tag.java trunk/x10.doc/src/x10doc/doc/X10Type.java trunk/x10.doc/src/x10doc/doc/X10TypeDefDoc.java trunk/x10.doc/src/x10doc/doc/X10TypeVariable.java trunk/x10.doc/src/x10doc/goals/ASTTraversalGoal.java trunk/x10.doc/src/x10doc/visit/X10DocGenerator.java trunk/x10.man/oopsla08/Jif.x10 trunk/x10.man/oopsla08/LO.x10 trunk/x10.man/oopsla08/Ownership.x10 trunk/x10.man/oopsla08/array.x10 trunk/x10.man/oopsla08/dist.x10 trunk/x10.man/oopsla08/place.x10 trunk/x10.man/oopsla08/point.x10 trunk/x10.man/oopsla08/region.x10 trunk/x10.man/oopsla08/sor.x10 trunk/x10.man/oopsla08/tree.x10 trunk/x10.man/v0.1/FixedPointMPI.c trunk/x10.man/v0.4/HashTable.x10 trunk/x10.man/v0.4/Latch.x10 trunk/x10.man/v1.5/HashTable.x10 trunk/x10.man/v1.5/Latch.x10 trunk/x10.runtime/src-cpp/x10/lang/Any.cc trunk/x10.runtime/src-cpp/x10/lang/Any.h trunk/x10.runtime/src-cpp/x10/lang/IBox.h trunk/x10.runtime/src-cpp/x10/lang/Struct.cc trunk/x10.runtime/src-cpp/x10/lang/Struct.h trunk/x10.runtime/src-cpp/x10aux/static_init.cc trunk/x10.runtime/src-cpp/x10aux/static_init.h trunk/x10.runtime/src-cpp/x10rt/common/x10rt_cuda.cc trunk/x10.runtime/src-cpp/x10rt/common/x10rt_front.cc trunk/x10.runtime/src-cpp/x10rt/common/x10rt_internal.h trunk/x10.runtime/src-cpp/x10rt/common/x10rt_logical.cc trunk/x10.runtime/src-cpp/x10rt/include/x10rt_cuda.h trunk/x10.runtime/src-cpp/x10rt/include/x10rt_front.h trunk/x10.runtime/src-cpp/x10rt/include/x10rt_logical.h trunk/x10.runtime/src-cpp/x10rt/include/x10rt_net.h trunk/x10.runtime/src-cpp/x10rt/include/x10rt_types.h trunk/x10.runtime/src-cpp/x10rt/mpi/x10rt_mpi.cc trunk/x10.runtime/src-cpp/x10rt/standalone/x10rt_standalone.cc trunk/x10.runtime/src-cpp/x10rt/test/x10rt_basic.cc trunk/x10.runtime/src-cpp/x10rt/test/x10rt_gups.cc trunk/x10.runtime/src-cpp/x10rt/test/x10rt_topology.cc trunk/x10.runtime/src-java/x10/core/Any.java trunk/x10.runtime/src-java/x10/core/Struct.java trunk/x10.runtime/src-x10/x10/compiler/CUDAUtilities.x10 trunk/x10.runtime/src-x10/x10/compiler/Immediate.x10 trunk/x10.runtime/src-x10/x10/compiler/Unroll.x10 trunk/x10.runtime/src-x10/x10/lang/Any.x10 trunk/x10.runtime/src-x10/x10/lang/Cell.x10 trunk/x10.runtime/src-x10/x10/lang/Complex.x10 trunk/x10.runtime/src-x10/x10/lang/Mortal.x10 trunk/x10.runtime/src-x10/x10/lang/Top.x10 trunk/x10.runtime/src-x10/x10/lang/flat.x10 trunk/x10.runtime/src-x10/x10/runtime/FinishStates.x10 trunk/x10.runtime/src-x10/x10/runtime/RemoteOperation.x10 trunk/x10.runtime/src-x10/x10/util/DistributedRail.x10 trunk/x10.runtime/src-x10/x10/util/Option.x10 trunk/x10.runtime/src-x10/x10/util/OptionsParser.x10 trunk/x10.runtime/src-x10/x10/util/Pair.x10 trunk/x10.tests/examples/Constructs/At/AtFieldWrite.x10 trunk/x10.tests/examples/Constructs/At/AtFieldWrite_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Call/StructCall.x10 trunk/x10.tests/examples/Constructs/Call/StructCall2_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Call/StructCall3_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Call/StructCall_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Cast/InlineConstraint.x10 trunk/x10.tests/examples/Constructs/Cast/MacroConstraint.x10 trunk/x10.tests/examples/Constructs/Closures/ClosureCall0a_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Closures/ClosureCall1b_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Closures/ClosureCall1c_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Closures/ClosureCall1d_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Conversion/SubtypeCheckForUserDefinedConversion_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Fun/FunIsNotObject_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Fun/GuardedFunctionInvocation.x10 trunk/x10.tests/examples/Constructs/Fun/GuardedFunctionInvocationWithType.x10 trunk/x10.tests/examples/Constructs/Fun/GuardedFunctionInvocation_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Generics/Bounds7.x10 trunk/x10.tests/examples/Constructs/Place/AtCheck.x10 trunk/x10.tests/examples/Constructs/Place/AtCheck2.x10 trunk/x10.tests/examples/Constructs/Place/AtCheck2_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Place/AtThisIntoAtHere.x10 trunk/x10.tests/examples/Constructs/Place/AtThisIntoAtHere_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Place/At_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Place/B_AtThisIntoAtHere.x10 trunk/x10.tests/examples/Constructs/Place/B_AtThisIntoAtHere_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Place/B_CheckThisTypeInCall.x10 trunk/x10.tests/examples/Constructs/Place/B_CheckThisTypeInCallMacro.x10 trunk/x10.tests/examples/Constructs/Place/CheckThisTypeInCall.x10 trunk/x10.tests/examples/Constructs/Place/FieldReceiverIsExpr.x10 trunk/x10.tests/examples/Constructs/Place/FieldWrite.x10 trunk/x10.tests/examples/Constructs/Place/FutureFielAccessRev_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Place/FutureFieldAccessStatic_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Place/FutureFieldAccessStruct.x10 trunk/x10.tests/examples/Constructs/Place/FutureFieldAccess_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Place/FutureGlobalMethodInvoke.x10 trunk/x10.tests/examples/Constructs/Place/FutureGlobalMethodInvokeRev.x10 trunk/x10.tests/examples/Constructs/Place/FutureGlobalMethodInvokeStatic.x10 trunk/x10.tests/examples/Constructs/Place/FutureGlobalMethodInvokeStruct.x10 trunk/x10.tests/examples/Constructs/Place/FutureMethodInvokeRev_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Place/FutureMethodInvokeStatic_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Place/FutureMethodInvoke_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Place/FuturePropertyAccess.x10 trunk/x10.tests/examples/Constructs/Place/FuturePropertyAccessRev.x10 trunk/x10.tests/examples/Constructs/Place/FuturePropertyAccessStatic.x10 trunk/x10.tests/examples/Constructs/Place/FutureVarFieldAccessRev_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Place/FutureVarFieldAccessStatic_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Place/FutureVarFieldAccess_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Place/GlobalAccess.x10 trunk/x10.tests/examples/Constructs/Place/PlaceCheckStringBuilder_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Structs/GenericStructTest.x10 trunk/x10.tests/examples/Constructs/Structs/StructCannotHaveVarField_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Structs/StructCannotSubclassClass_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Structs/StructEquality.x10 trunk/x10.tests/examples/Constructs/Structs/StructGenericInterfaceTest.x10 trunk/x10.tests/examples/Constructs/Structs/StructImplicitCoercionToInterface.x10 trunk/x10.tests/examples/Constructs/Structs/StructInterface.x10 trunk/x10.tests/examples/Constructs/Structs/StructInterfaceGenericTest.x10 trunk/x10.tests/examples/Constructs/Structs/StructInterfaceTest.x10 trunk/x10.tests/examples/Constructs/Structs/StructTest1.x10 trunk/x10.tests/examples/Constructs/Structs/StructTest2.x10 trunk/x10.tests/examples/Constructs/Structs/TestComplex.x10 trunk/x10.tests/examples/Constructs/XtenTwoOhTypeSsytem/ObjectIsNotParameterType2_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/XtenTwoOhTypeSsytem/ObjectIsNotParameterType3_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/XtenTwoOhTypeSsytem/ObjectIsNotParameterType4_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/XtenTwoOhTypeSsytem/ObjectIsNotParameterType_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/XtenTwoOhTypeSsytem/ParameterTypeIsNotObject2_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/XtenTwoOhTypeSsytem/ParameterTypeIsNotObject3_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/XtenTwoOhTypeSsytem/ParameterTypeIsNotObject4_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/XtenTwoOhTypeSsytem/ParameterTypeIsNotObject_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/XtenTwoOhTypeSsytem/PrimitiveIsNotParameterType_MustFailCompile.x10 trunk/x10.tests/examples/Issues/XTENLANG_298_MustFailCompile.x10 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 trunk/x10.tests/tests/Constructs/Proto/Cast_MustFailCompile.x10 trunk/x10.tests/tests/Constructs/Proto/Coercion2_MustFailCompile.x10 trunk/x10.tests/tests/Constructs/Proto/Coercion_MustFailCompile.x10 trunk/x10.tests/tests/Constructs/Proto/ConstructorMustReturnProto_MustFailCompile.x10 trunk/x10.tests/tests/Constructs/Proto/CovariantCall.x10 trunk/x10.tests/tests/Constructs/Proto/MethodMustReturnProto_MustFailCompile.x10 trunk/x10.tests/tests/Constructs/Proto/ProtoAssign.x10 trunk/x10.tests/tests/Constructs/Proto/ProtoAssignField.x10 trunk/x10.tests/tests/Constructs/Proto/ProtoCall_MustFailCompile.x10 trunk/x10.tests/tests/Constructs/Proto/ProtoCatch_MustFailCompile.x10 trunk/x10.tests/tests/Constructs/Proto/ProtoField_MustFailCompile.x10 trunk/x10.tests/tests/Constructs/Proto/ProtoImplements_MustFailCompile.x10 trunk/x10.tests/tests/Constructs/Proto/ProtoReadField_MustFailCompile.x10 trunk/x10.tests/tests/Constructs/Proto/ProtoSuper_MustFailCompile.x10 trunk/x10.tests/tests/Constructs/Proto/StaticMethod_MustFailCompile.x10 Property changes on: trunk/SafeX10/src/Effects.x10 ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Property changes on: trunk/x10.common/contrib/ant/IfTask.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Modified: trunk/x10.compiler/src/x10/ast/AmbHereThis_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/AmbHereThis_c.java 2009-12-22 18:25:19 UTC (rev 12395) +++ trunk/x10.compiler/src/x10/ast/AmbHereThis_c.java 2009-12-22 18:40:40 UTC (rev 12396) @@ -1,43 +1,43 @@ -package x10.ast; - -import java.util.List; - -import polyglot.ast.Expr_c; -import polyglot.ast.Node; -import polyglot.ast.Receiver; -import polyglot.ast.Term; -import polyglot.types.SemanticException; -import polyglot.util.Position; -import polyglot.visit.CFGBuilder; -import polyglot.visit.ContextVisitor; - -public class AmbHereThis_c extends Expr_c { - - public AmbHereThis_c(Position pos) { - super(pos); - } - - /** - * Visit this term in evaluation order. - */ - @Override - public List acceptCFG(CFGBuilder v, List succs) { - return succs; - } - - public Term firstChild() { - return null; - } - - /** 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()); - } - - public String toString() { - return "hereOrThis"; - } -} +package x10.ast; + +import java.util.List; + +import polyglot.ast.Expr_c; +import polyglot.ast.Node; +import polyglot.ast.Receiver; +import polyglot.ast.Term; +import polyglot.types.SemanticException; +import polyglot.util.Position; +import polyglot.visit.CFGBuilder; +import polyglot.visit.ContextVisitor; + +public class AmbHereThis_c extends Expr_c { + + public AmbHereThis_c(Position pos) { + super(pos); + } + + /** + * Visit this term in evaluation order. + */ + @Override + public List acceptCFG(CFGBuilder v, List succs) { + return succs; + } + + public Term firstChild() { + return null; + } + + /** 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()); + } + + public String toString() { + return "hereOrThis"; + } +} Property changes on: trunk/x10.compiler/src/x10/ast/AmbHereThis_c.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Modified: trunk/x10.compiler/src/x10/ast/PlacedClosure.java =================================================================== --- trunk/x10.compiler/src/x10/ast/PlacedClosure.java 2009-12-22 18:25:19 UTC (rev 12395) +++ trunk/x10.compiler/src/x10/ast/PlacedClosure.java 2009-12-22 18:40:40 UTC (rev 12396) @@ -1,14 +1,14 @@ -/** - * - */ -package x10.ast; - -/** - * An abstraction for future(p) Expr and at(p) Expr - * - * @author vj - * - */ -public interface PlacedClosure extends RemoteActivityInvocation, Closure { - -} +/** + * + */ +package x10.ast; + +/** + * An abstraction for future(p) Expr and at(p) Expr + * + * @author vj + * + */ +public interface PlacedClosure extends RemoteActivityInvocation, Closure { + +} Property changes on: trunk/x10.compiler/src/x10/ast/PlacedClosure.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Modified: trunk/x10.compiler/src/x10/ast/PlacedClosure_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/PlacedClosure_c.java 2009-12-22 18:25:19 UTC (rev 12395) +++ trunk/x10.compiler/src/x10/ast/PlacedClosure_c.java 2009-12-22 18:40:40 UTC (rev 12396) @@ -1,233 +1,233 @@ -/** - * - */ -package x10.ast; - -import java.util.Collections; -import java.util.List; - -import polyglot.ast.Block; -import polyglot.ast.Expr; -import polyglot.ast.Formal; -import polyglot.ast.Node; -import polyglot.ast.Term; -import polyglot.ast.TypeNode; -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; -import polyglot.visit.ContextVisitor; -import polyglot.visit.NodeVisitor; -import polyglot.visit.PruningVisitor; -import polyglot.visit.TypeChecker; -import x10.constraint.XConstrainedTerm; -import x10.constraint.XConstraint; -import x10.constraint.XConstraint_c; -import x10.constraint.XFailure; -import x10.constraint.XTerm; -import x10.types.ClosureDef; -import x10.types.X10Context; -import x10.types.X10TypeMixin; -import x10.types.X10TypeSystem; - -/** - * A common abstraction for a closure that may execute at a given place, - * viz future (p) expr and at (p) expr. - * - * @author vj - * - */ -public class PlacedClosure_c extends Closure_c implements PlacedClosure { - - - protected Expr place; - - public PlacedClosure_c(Position p, Expr place, TypeNode returnType, Block body) { - super(p, Collections.EMPTY_LIST, returnType, null, - Collections.EMPTY_LIST, body); - this.place = place; - } - - /** Get the RemoteActivity's place. */ - public Expr place() { - return place; - } - - /** Set the RemoteActivity's place. */ - public RemoteActivityInvocation place(Expr place) { - this.place = place; - return this; - } - - /** Visit the children of the expression. - * vj: TODO: I use a hack below to bypass - * visiting the embedded stmt if the visitor is a ReachChecker. - * Otherwise a reach error is generated that is in fact spurious. - * There must be a way to convince the ReachChecker legitimately that this statement - * is reachable if the future is reachable. - * */ - public Node visitChildren( NodeVisitor v ) { - Expr place = (Expr) visitChild( this.place, v ); - PlacedClosure_c n = (PlacedClosure_c) super.visitChildren(v); - if (n.place != place) { - if (n == this) n = (PlacedClosure_c) copy(); - n.place = place; - } - 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 { - //System.err.println("PlacedClosure_c: Golden! evaluating placeterm for " + this); - Type placeType = place.type(); - XConstraint d = X10TypeMixin.xclause(placeType); - d = (d==null) ? new XConstraint_c() : d.copy(); - XConstraint pc = null; - XTerm term = null; - XConstrainedTerm pt = null; - boolean placeIsPlace = ts.isImplicitCastValid(placeType, ts.Place(), xc); - if (placeIsPlace) { - term = ts.xtypeTranslator().trans(pc, place, xc); - if (term == null) { - term = XConstraint_c.genUQV(); - } - try { - pt = XConstrainedTerm.instantiate(d, term); - } catch (XFailure z) { - - throw new InternalCompilerError("Cannot construct placeTerm from " + - term + " and constraint " + d + "."); - } - } else { - boolean placeIsRef = ts.isImplicitCastValid(placeType, ts.Object(), xc); - if (placeIsRef) { - XTerm src = ts.xtypeTranslator().trans(pc, place, xc); - if (src == null) { - src = XConstraint_c.genUQV(); - } - 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 - public Node typeCheckOverride(Node parent, ContextVisitor tc) throws SemanticException { - - X10TypeSystem ts = (X10TypeSystem) tc.typeSystem(); - NodeVisitor v = tc.enter(parent, this); - - if (v instanceof PruningVisitor) { - return this; - } - ClosureDef def = (ClosureDef) this.codeDef(); - if (def.placeTerm() == null) { - Expr e = (Expr) visitChild(place, v); - def.setPlaceTerm(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. - - return null; - } - - - public Node typeCheck(ContextVisitor tc) throws SemanticException { - X10Context xc = (X10Context) tc.context(); - if (xc.inSequentialCode()) - throw new SemanticException("at may not be invoked in sequential code.", position()); - Node n = super.typeCheck(tc); - return n; - } - - protected X10Context pushPlaceTerm(X10Context xc) { - ClosureDef def = (ClosureDef) codeDef(); - XConstrainedTerm pt = def.placeTerm(); - if (pt != null) { - xc = (X10Context) xc.pushPlace(pt); - } - return xc; - } - @Override - public Context enterChildScope(Node child, Context c) { - X10Context xc = (X10Context) super.enterChildScope(child, c); - if (child == body) { - xc = pushPlaceTerm(xc); - addDecls(xc); - } - return xc; - } - - /** - * Return the first (sub)term performed when evaluating this - * term. - */ - public Term firstChild() { - return returnType; - } - - /** - * Visit this term in evaluation order. - */ - public List<Term> acceptCFG(CFGBuilder v, List<Term> succs) { - v.visitCFG(returnType, place, ENTRY); - - // If building the CFG for the enclosing code, don't thread - // in the closure body. Otherwise, we're building the CFG - // for the closure itself. - if (! succs.isEmpty()) { - v.visitCFG(place, this, EXIT); - } - else { - v.visitCFG(place, body, ENTRY); - v.visitCFG(body, this, EXIT); - } - - /* - v.visitCFG(returnType, FlowGraph.EDGE_KEY_TRUE, body, ENTRY, - FlowGraph.EDGE_KEY_FALSE, this, EXIT); - */ - return succs; - } - - public Type childExpectedType(Expr child, AscriptionVisitor av) { - X10TypeSystem ts = (X10TypeSystem) av.typeSystem(); - if ( child == place ) { - return ts.Place(); - } - return child.type(); - } - -} +/** + * + */ +package x10.ast; + +import java.util.Collections; +import java.util.List; + +import polyglot.ast.Block; +import polyglot.ast.Expr; +import polyglot.ast.Formal; +import polyglot.ast.Node; +import polyglot.ast.Term; +import polyglot.ast.TypeNode; +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; +import polyglot.visit.ContextVisitor; +import polyglot.visit.NodeVisitor; +import polyglot.visit.PruningVisitor; +import polyglot.visit.TypeChecker; +import x10.constraint.XConstrainedTerm; +import x10.constraint.XConstraint; +import x10.constraint.XConstraint_c; +import x10.constraint.XFailure; +import x10.constraint.XTerm; +import x10.types.ClosureDef; +import x10.types.X10Context; +import x10.types.X10TypeMixin; +import x10.types.X10TypeSystem; + +/** + * A common abstraction for a closure that may execute at a given place, + * viz future (p) expr and at (p) expr. + * + * @author vj + * + */ +public class PlacedClosure_c extends Closure_c implements PlacedClosure { + + + protected Expr place; + + public PlacedClosure_c(Position p, Expr place, TypeNode returnType, Block body) { + super(p, Collections.EMPTY_LIST, returnType, null, + Collections.EMPTY_LIST, body); + this.place = place; + } + + /** Get the RemoteActivity's place. */ + public Expr place() { + return place; + } + + /** Set the RemoteActivity's place. */ + public RemoteActivityInvocation place(Expr place) { + this.place = place; + return this; + } + + /** Visit the children of the expression. + * vj: TODO: I use a hack below to bypass + * visiting the embedded stmt if the visitor is a ReachChecker. + * Otherwise a reach error is generated that is in fact spurious. + * There must be a way to convince the ReachChecker legitimately that this statement + * is reachable if the future is reachable. + * */ + public Node visitChildren( NodeVisitor v ) { + Expr place = (Expr) visitChild( this.place, v ); + PlacedClosure_c n = (PlacedClosure_c) super.visitChildren(v); + if (n.place != place) { + if (n == this) n = (PlacedClosure_c) copy(); + n.place = place; + } + 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 { + //System.err.println("PlacedClosure_c: Golden! evaluating placeterm for " + this); + Type placeType = place.type(); + XConstraint d = X10TypeMixin.xclause(placeType); + d = (d==null) ? new XConstraint_c() : d.copy(); + XConstraint pc = null; + XTerm term = null; + XConstrainedTerm pt = null; + boolean placeIsPlace = ts.isImplicitCastValid(placeType, ts.Place(), xc); + if (placeIsPlace) { + term = ts.xtypeTranslator().trans(pc, place, xc); + if (term == null) { + term = XConstraint_c.genUQV(); + } + try { + pt = XConstrainedTerm.instantiate(d, term); + } catch (XFailure z) { + + throw new InternalCompilerError("Cannot construct placeTerm from " + + term + " and constraint " + d + "."); + } + } else { + boolean placeIsRef = ts.isImplicitCastValid(placeType, ts.Object(), xc); + if (placeIsRef) { + XTerm src = ts.xtypeTranslator().trans(pc, place, xc); + if (src == null) { + src = XConstraint_c.genUQV(); + } + 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 + public Node typeCheckOverride(Node parent, ContextVisitor tc) throws SemanticException { + + X10TypeSystem ts = (X10TypeSystem) tc.typeSystem(); + NodeVisitor v = tc.enter(parent, this); + + if (v instanceof PruningVisitor) { + return this; + } + ClosureDef def = (ClosureDef) this.codeDef(); + if (def.placeTerm() == null) { + Expr e = (Expr) visitChild(place, v); + def.setPlaceTerm(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. + + return null; + } + + + public Node typeCheck(ContextVisitor tc) throws SemanticException { + X10Context xc = (X10Context) tc.context(); + if (xc.inSequentialCode()) + throw new SemanticException("at may not be invoked in sequential code.", position()); + Node n = super.typeCheck(tc); + return n; + } + + protected X10Context pushPlaceTerm(X10Context xc) { + ClosureDef def = (ClosureDef) codeDef(); + XConstrainedTerm pt = def.placeTerm(); + if (pt != null) { + xc = (X10Context) xc.pushPlace(pt); + } + return xc; + } + @Override + public Context enterChildScope(Node child, Context c) { + X10Context xc = (X10Context) super.enterChildScope(child, c); + if (child == body) { + xc = pushPlaceTerm(xc); + addDecls(xc); + } + return xc; + } + + /** + * Return the first (sub)term performed when evaluating this + * term. + */ + public Term firstChild() { + return returnType; + } + + /** + * Visit this term in evaluation order. + */ + public List<Term> acceptCFG(CFGBuilder v, List<Term> succs) { + v.visitCFG(returnType, place, ENTRY); + + // If building the CFG for the enclosing code, don't thread + // in the closure body. Otherwise, we're building the CFG + // for the closure itself. + if (! succs.isEmpty()) { + v.visitCFG(place, this, EXIT); + } + else { + v.visitCFG(place, body, ENTRY); + v.visitCFG(body, this, EXIT); + } + + /* + v.visitCFG(returnType, FlowGraph.EDGE_KEY_TRUE, body, ENTRY, + FlowGraph.EDGE_KEY_FALSE, this, EXIT); + */ + return succs; + } + + public Type childExpectedType(Expr child, AscriptionVisitor av) { + X10TypeSystem ts = (X10TypeSystem) av.typeSystem(); + if ( child == place ) { + return ts.Place(); + } + return child.type(); + } + +} Property changes on: trunk/x10.compiler/src/x10/ast/PlacedClosure_c.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Property changes on: trunk/x10.compiler/src/x10/optimizations/LoopUnroller.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Property changes on: trunk/x10.compiler/src/x10/optimizations/Optimizer.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Modified: trunk/x10.compiler/src/x10/util/Struct.java =================================================================== --- trunk/x10.compiler/src/x10/util/Struct.java 2009-12-22 18:25:19 UTC (rev 12395) +++ trunk/x10.compiler/src/x10/util/Struct.java 2009-12-22 18:40:40 UTC (rev 12396) @@ -1,302 +1,302 @@ -package x10.util; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import polyglot.ast.Expr; -import polyglot.ast.MethodDecl; -import polyglot.ast.TypeNode; -import polyglot.types.ClassDef; -import polyglot.types.ClassType; -import polyglot.types.Flags; -import polyglot.types.LazyRef; -import polyglot.types.LocalDef; -import polyglot.types.Name; -import polyglot.types.QName; -import polyglot.types.Ref; -import polyglot.types.SemanticException; -import polyglot.types.Type; -import polyglot.types.Types; -import polyglot.util.Position; -import x10.ast.AnnotationNode; -import x10.ast.X10StringLit_c; -import x10.constraint.XName; -import x10.constraint.XNameWrapper; -import x10.constraint.XRoot; -import x10.constraint.XTerms; -import x10.extension.X10Ext; -import x10.types.X10ClassDef; -import x10.types.X10ClassDef_c; -import x10.types.X10ClassType; -import x10.types.X10ConstructorDef; -import x10.types.X10Flags; -import x10.types.X10MethodDef; -import x10.types.X10ParsedClassType; -import x10.types.X10ParsedClassType_c; -import x10.types.X10TypeSystem; -import x10.types.X10TypeSystem_c; - -public class Struct { - public static X10ClassDef makeDef(final X10TypeSystem_c xts) { - - final Position pos = Position.COMPILER_GENERATED; - - String name = "Struct"; - X10ClassDef cd = (X10ClassDef) new X10ClassDef_c(xts, null) { - - @Override - public ClassType asType() { - if (asType == null) { - X10ClassDef cd = this; - asType = new X10ParsedClassType_c(this); - } - return asType; - } - }; - - cd.position(pos); - cd.name(Name.make(name)); - try { - cd.setPackage(Types.ref(xts.packageForName(QName.make("x10.lang")))); - } - catch (SemanticException e) { - assert false; - } - - QName fullName = QName.make("x10.lang", name); - cd.kind(ClassDef.TOP_LEVEL); - cd.superType(null); // base class has no superclass - - cd.setInterfaces(Collections.<Ref<? extends Type>> singletonList(xts.lazyAny())); - cd.flags(X10Flags.toX10Flags(Flags.PUBLIC.Abstract()).Struct()); - - - // NOTE: don't call cd.asType() until after the type parameters are - // added. - X10ParsedClassType ct = (X10ParsedClassType) cd.asType(); - xts.systemResolver().install(fullName, ct); - - String fullNameWithThis = fullName + "#this"; - //String fullNameWithThis = "this"; - XName thisName = new XNameWrapper<Object>(new Object(), fullNameWithThis); - XRoot thisVar = XTerms.makeLocal(thisName); - - final LazyRef<X10ParsedClassType> PLACE = Types.lazyRef(null); - PLACE.setResolver(new Runnable() { - public void run() { - PLACE.update((X10ParsedClassType) xts.Place()); - } - }); - final LazyRef<X10ParsedClassType> STRING = Types.lazyRef(null); - STRING.setResolver(new Runnable() { - public void run() { - STRING.update((X10ParsedClassType) xts.String()); - } - }); - final LazyRef<X10ParsedClassType> BOOLEAN = Types.lazyRef(null); - BOOLEAN.setResolver(new Runnable() { - public void run() { - BOOLEAN.update((X10ParsedClassType) xts.Boolean()); - } - }); - final LazyRef<X10ParsedClassType> OBJECT = Types.lazyRef(null); - OBJECT.setResolver(new Runnable() { - public void run() { - OBJECT.update((X10ParsedClassType) xts.Object()); - } - }); - X10ConstructorDef ci = (X10ConstructorDef) xts.constructorDef(pos, Types.ref(ct), Flags.PUBLIC.Native(), - Collections.EMPTY_LIST, - Collections.EMPTY_LIST); - cd.addConstructor(ci); - - X10MethodDef mi; - List<Expr> list; - X10ClassType ann; - - // @Native("java", "x10.lang.Place.place(x10.core.Ref.home(#0))") - // property def home():Place - mi = xts.methodDef(pos, Types.ref(ct), - X10Flags.toX10Flags(Flags.PUBLIC.Native()).Property().Global().Safe(), - PLACE, - xts.homeName(), - Collections.EMPTY_LIST, - Collections.EMPTY_LIST, - thisVar, - Collections.EMPTY_LIST, - null, - null, - Collections.EMPTY_LIST, - null); - final LazyRef<X10ParsedClassType> NATIVE_LOC = Types.lazyRef(null); - NATIVE_LOC.setResolver(new Runnable() { - public void run() { - List<Expr> list = new ArrayList<Expr>(2); - list.add(new X10StringLit_c(pos, "java")); - list.add(new X10StringLit_c(pos, "x10.lang.Place.place(x10.core.Ref.home(#0))")); - X10ParsedClassType ann= (X10ParsedClassType) ((X10ParsedClassType) xts.NativeType()).propertyInitializers(list); - NATIVE_LOC.update(ann); - } - }); - mi.setDefAnnotations(Collections.<Ref<? extends Type>> singletonList(NATIVE_LOC)); - cd.addMethod(mi); - - // @Native("java", "x10.core.Ref.at(#0, #1)") - // property def at(p:Object):boolean; - List<LocalDef> parameters = xts.dummyLocalDefs(Collections.<Ref<? extends Type>> singletonList(OBJECT)); - mi = xts.methodDef(pos, Types.ref(ct), - X10Flags.toX10Flags(Flags.PUBLIC.Native()).Property().Safe(), - BOOLEAN, - Name.make("at"), - Collections.EMPTY_LIST, - Collections.<Ref<? extends Type>> singletonList(OBJECT), - thisVar, - parameters, - null, - null, - Collections.EMPTY_LIST, - null); - final LazyRef<X10ParsedClassType> NATIVE_AT_1 = Types.lazyRef(null); - NATIVE_AT_1.setResolver(new Runnable() { - public void run() { - List<Expr> list = new ArrayList<Expr>(2); - list.add(new X10StringLit_c(pos, "java")); - list.add(new X10StringLit_c(pos, "x10.core.Ref.at(#0, #1)")); - X10ParsedClassType ann= (X10ParsedClassType) ((X10ParsedClassType) xts.NativeType()).propertyInitializers(list); - NATIVE_AT_1.update(ann); - } - }); - mi.setDefAnnotations(Collections.<Ref<? extends Type>> singletonList(NATIVE_AT_1)); - cd.addMethod(mi); - - // @Native("java", "x10.core.Ref.typeName(#0)") - // native final global safe def typeName():String; - mi = xts.methodDef(pos, - Types.ref(ct), - X10Flags.toX10Flags(Flags.PUBLIC.Native().Final()).Global().Safe(), - STRING, - Name.make("typeName"), - Collections.EMPTY_LIST, - Collections.EMPTY_LIST, - thisVar, - Collections.EMPTY_LIST, - null, - null, - Collections.EMPTY_LIST, - null - ); - final LazyRef<X10ParsedClassType> NATIVE_TYPE_NAME = Types.lazyRef(null); - NATIVE_TYPE_NAME.setResolver(new Runnable() { - public void run() { - List<Expr> list = new ArrayList<Expr>(2); - list.add(new X10StringLit_c(pos, "java")); - list.add(new X10StringLit_c(pos, "x10.core.Ref.typeName(#0)")); - X10ParsedClassType ann= (X10ParsedClassType) ((X10ParsedClassType) xts.NativeType()).propertyInitializers(list); - NATIVE_TYPE_NAME.update(ann); - } - }); - - mi.setDefAnnotations(Collections.<Ref<? extends Type>> singletonList(NATIVE_TYPE_NAME)); - cd.addMethod(mi); - - // @Native("java", "\"<struct>\"") - // native global safe def toString():String; - mi = xts.methodDef(pos, - Types.ref(ct), - X10Flags.toX10Flags(Flags.PUBLIC.Native()).Global().Safe(), - STRING, - Name.make("toString"), - Collections.EMPTY_LIST, - Collections.EMPTY_LIST, - thisVar, - Collections.EMPTY_LIST, - null, - null, - Collections.EMPTY_LIST, - null - ); - final LazyRef<X10ParsedClassType> NATIVE_TYPE_NAME2 = Types.lazyRef(null); - NATIVE_TYPE_NAME2.setResolver(new Runnable() { - public void run() { - List<Expr> list = new ArrayList<Expr>(2); - list.add(new X10StringLit_c(pos, "java")); - list.add(new X10StringLit_c(pos, "\"<struct>\"")); - X10ParsedClassType ann= (X10ParsedClassType) ((X10ParsedClassType) xts.NativeType()).propertyInitializers(list); - NATIVE_TYPE_NAME2.update(ann); - } - }); - - mi.setDefAnnotations(Collections.<Ref<? extends Type>> singletonList(NATIVE_TYPE_NAME2)); - cd.addMethod(mi); - - - - // @Native("java", "x10.core.Ref.at(#0, #1.id)") - // property def at(p:Place):boolean; - parameters = xts.dummyLocalDefs(Collections.<Ref<? extends Type>> singletonList(PLACE)); - mi = xts.methodDef(pos, Types.ref(ct), - X10Flags.toX10Flags(Flags.PUBLIC.Native()).Property().Safe(), - BOOLEAN, - Name.make("at"), - Collections.EMPTY_LIST, - Collections.<Ref<? extends Type>> singletonList(PLACE), - thisVar, - parameters, - null, - null, - Collections.EMPTY_LIST, - null); - final LazyRef<X10ParsedClassType> NATIVE_AT_2 = Types.lazyRef(null); - NATIVE_AT_2.setResolver(new Runnable() { - public void run() { - List<Expr> list = new ArrayList<Expr>(2); - list.add(new X10StringLit_c(pos, "java")); - list.add(new X10StringLit_c(pos, "x10.core.Ref.at(#0, #1.id)")); - X10ParsedClassType ann= (X10ParsedClassType) ((X10ParsedClassType) xts.NativeType()).propertyInitializers(list); - NATIVE_AT_2.update(ann); - } - }); - mi.setDefAnnotations(Collections.<Ref<? extends Type>> singletonList(NATIVE_AT_2)); - cd.addMethod(mi); - - //@NativeRep("java", "x10.core.Struct", null, null) - final LazyRef<X10ParsedClassType> NATIVE_REP = Types.lazyRef(null); - NATIVE_REP.setResolver(new Runnable() { - public void run() { - List<Expr> list = new ArrayList<Expr>(4); - list.add(new X10StringLit_c(pos, "java")); - list.add(new X10StringLit_c(pos, "x10.core.Struct")); - list.add(null); - list.add(null); - X10ParsedClassType ann = (X10ParsedClassType) ((X10ParsedClassType) xts.NativeRep()).propertyInitializers(list); - - NATIVE_REP.update(ann); - } - }); - - - //@NativeRep("c++", "x10::lang::Struct", "x10::lang::Struct", null) - final LazyRef<X10ParsedClassType> NATIVE_REP_CPP = Types.lazyRef(null); - NATIVE_REP_CPP.setResolver(new Runnable() { - public void run() { - List<Expr> list = new ArrayList<Expr>(4); - list.add(new X10StringLit_c(pos, "c++")); - list.add(new X10StringLit_c(pos, "x10::lang::Struct")); - list.add(new X10StringLit_c(pos, "x10::lang::Struct")); - list.add(null); - X10ParsedClassType ann = (X10ParsedClassType) ((X10ParsedClassType) xts.NativeRep()).propertyInitializers(list); - - NATIVE_REP_CPP.update(ann); - } - }); - - List<Ref<? extends Type>> cd_ann = new ArrayList<Ref<? extends Type>>(); - cd_ann.add(NATIVE_REP); - cd_ann.add(NATIVE_REP_CPP); - cd.setDefAnnotations(cd_ann); -// cd.setDefAnnotations(Collections.<Ref<? extends Type>> singletonList(NATIVE_REP)); - return cd; - } - -} +package x10.util; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import polyglot.ast.Expr; +import polyglot.ast.MethodDecl; +import polyglot.ast.TypeNode; +import polyglot.types.ClassDef; +import polyglot.types.ClassType; +import polyglot.types.Flags; +import polyglot.types.LazyRef; +import polyglot.types.LocalDef; +import polyglot.types.Name; +import polyglot.types.QName; +import polyglot.types.Ref; +import polyglot.types.SemanticException; +import polyglot.types.Type; +import polyglot.types.Types; +import polyglot.util.Position; +import x10.ast.AnnotationNode; +import x10.ast.X10StringLit_c; +import x10.constraint.XName; +import x10.constraint.XNameWrapper; +import x10.constraint.XRoot; +import x10.constraint.XTerms; +import x10.extension.X10Ext; +import x10.types.X10ClassDef; +import x10.types.X10ClassDef_c; +import x10.types.X10ClassType; +import x10.types.X10ConstructorDef; +import x10.types.X10Flags; +import x10.types.X10MethodDef; +import x10.types.X10ParsedClassType; +import x10.types.X10ParsedClassType_c; +import x10.types.X10TypeSystem; +import x10.types.X10TypeSystem_c; + +public class Struct { + public static X10ClassDef makeDef(final X10TypeSystem_c xts) { + + final Position pos = Position.COMPILER_GENERATED; + + String name = "Struct"; + X10ClassDef cd = (X10ClassDef) new X10ClassDef_c(xts, null) { + + @Override + public ClassType asType() { + if (asType == null) { + X10ClassDef cd = this; + asType = new X10ParsedClassType_c(this); + } + return asType; + } + }; + + cd.position(pos); + cd.name(Name.make(name)); + try { + cd.setPackage(Types.ref(xts.packageForName(QName.make("x10.lang")))); + } + catch (SemanticException e) { + assert false; + } + + QName fullName = QName.make("x10.lang", name); + cd.kind(ClassDef.TOP_LEVEL); + cd.superType(null); // base class has no superclass + + cd.setInterfaces(Collections.<Ref<? extends Type>> singletonList(xts.lazyAny())); + cd.flags(X10Flags.toX10Flags(Flags.PUBLIC.Abstract()).Struct()); + + + // NOTE: don't call cd.asType() until after the type parameters are + // added. + X10ParsedClassType ct = (X10ParsedClassType) cd.asType(); + xts.systemResolver().install(fullName, ct); + + String fullNameWithThis = fullName + "#this"; + //String fullNameWithThis = "this"; + XName thisName = new XNameWrapper<Object>(new Object(), fullNameWithThis); + XRoot thisVar = XTerms.makeLocal(thisName); + + final LazyRef<X10ParsedClassType> PLACE = Types.lazyRef(null); + PLACE.setResolver(new Runnable() { + public void run() { + PLACE.update((X10ParsedClassType) xts.Place()); + } + }); + final LazyRef<X10ParsedClassType> STRING = Types.lazyRef(null); + STRING.setResolver(new Runnable() { + public void run() { + STRING.update((X10ParsedClassType) xts.String()); + } + }); + final LazyRef<X10ParsedClassType> BOOLEAN = Types.lazyRef(null); + BOOLEAN.setResolver(new Runnable() { + public void run() { + BOOLEAN.update((X10ParsedClassType) xts.Boolean()); + } + }); + final LazyRef<X10ParsedClassType> OBJECT = Types.lazyRef(null); + OBJECT.setResolver(new Runnable() { + public void run() { + OBJECT.update((X10ParsedClassType) xts.Object()); + } + }); + X10ConstructorDef ci = (X10ConstructorDef) xts.constructorDef(pos, Types.ref(ct), Flags.PUBLIC.Native(), + Collections.EMPTY_LIST, + Collections.EMPTY_LIST); + cd.addConstructor(ci); + + X10MethodDef mi; + List<Expr> list; + X10ClassType ann; + + // @Native("java", "x10.lang.Place.place(x10.core.Ref.home(#0))") + // property def home():Place + mi = xts.methodDef(pos, Types.ref(ct), + X10Flags.toX10Flags(Flags.PUBLIC.Native()).Property().Global().Safe(), + PLACE, + xts.homeName(), + Collections.EMPTY_LIST, + Collections.EMPTY_LIST, + thisVar, + Collections.EMPTY_LIST, + null, + null, + Collections.EMPTY_LIST, + null); + final LazyRef<X10ParsedClassType> NATIVE_LOC = Types.lazyRef(null); + NATIVE_LOC.setResolver(new Runnable() { + public void run() { + List<Expr> list = new ArrayList<Expr>(2); + list.add(new X10StringLit_c(pos, "java")); + list.add(new X10StringLit_c(pos, "x10.lang.Place.place(x10.core.Ref.home(#0))")); + X10ParsedClassType ann= (X10ParsedClassType) ((X10ParsedClassType) xts.NativeType()).propertyInitializers(list); + NATIVE_LOC.update(ann); + } + }); + mi.setDefAnnotations(Collections.<Ref<? extends Type>> singletonList(NATIVE_LOC)); + cd.addMethod(mi); + + // @Native("java", "x10.core.Ref.at(#0, #1)") + // property def at(p:Object):boolean; + List<LocalDef> parameters = xts.dummyLocalDefs(Collections.<Ref<? extends Type>> singletonList(OBJECT)); + mi = xts.methodDef(pos, Types.ref(ct), + X10Flags.toX10Flags(Flags.PUBLIC.Native()).Property().Safe(), + BOOLEAN, + Name.make("at"), + Collections.EMPTY_LIST, + Collections.<Ref<? extends Type>> singletonList(OBJECT), + thisVar, + parameters, + null, + null, + Collections.EMPTY_LIST, + null); + final LazyRef<X10ParsedClassType> NATIVE_AT_1 = Types.lazyRef(null); + NATIVE_AT_1.setResolver(new Runnable() { + public void run() { + List<Expr> list = new ArrayList<Expr>(2); + list.add(new X10StringLit_c(pos, "java")); + list.add(new X10StringLit_c(pos, "x10.core.Ref.at(#0, #1)")); + X10ParsedClassType ann= (X10ParsedClassType) ((X10ParsedClassType) xts.NativeType()).propertyInitializers(list); + NATIVE_AT_1.update(ann); + } + }); + mi.setDefAnnotations(Collections.<Ref<? extends Type>> singletonList(NATIVE_AT_1)); + cd.addMethod(mi); + + // @Native("java", "x10.core.Ref.typeName(#0)") + // native final global safe def typeName():String; + mi = xts.methodDef(pos, + Types.ref(ct), + X10Flags.toX10Flags(Flags.PUBLIC.Native().Final()).Global().Safe(), + STRING, + Name.make("typeName"), + Collections.EMPTY_LIST, + Collections.EMPTY_LIST, + thisVar, + Collections.EMPTY_LIST, + null, + null, + Collections.EMPTY_LIST, + null + ); + final LazyRef<X10ParsedClassType> NATIVE_TYPE_NAME = Types.lazyRef(null); + NATIVE_TYPE_NAME.setResolver(new Runnable() { + public void run() { + List<Expr> list = new ArrayList<Expr>(2); + list.add(new X10StringLit_c(pos, "java")); + list.add(new X10StringLit_c(pos, "x10.core.Ref.typeName(#0)")); + X10ParsedClassType ann= (X10ParsedClassType) ((X10ParsedClassType) xts.NativeType()).propertyInitializers(list); + NATIVE_TYPE_NAME.update(ann); + } + }); + + mi.setDefAnnotations(Collections.<Ref<? extends Type>> singletonList(NATIVE_TYPE_NAME)); + cd.addMethod(mi); + + // @Native("java", "\"<struct>\"") + // native global safe def toString():String; + mi = xts.methodDef(pos, + Types.ref(ct), + X10Flags.toX10Flags(Flags.PUBLIC.Native()).Global().Safe(), + STRING, + Name.make("toString"), + Collections.EMPTY_LIST, + Collections.EMPTY_LIST, + thisVar, + Collections.EMPTY_LIST, + null, + null, + Collections.EMPTY_LIST, + null + ); + final LazyRef<X10ParsedClassType> NATIVE_TYPE_NAME2 = Types.lazyRef(null); + NATIVE_TYPE_NAME2.setResolver(new Runnable() { + public void run() { + List<Expr> list = new ArrayList<Expr>(2); + list.add(new X10StringLit_c(pos, "java")); + list.add(new X10StringLit_c(pos, "\"<struct>\"")); + X10ParsedClassType ann= (X10ParsedClassType) ((X10ParsedClassType) xts.NativeType()).propertyInitializers(list); + NATIVE_TYPE_NAME2.update(ann); + } + }); + + mi.setDefAnnotations(Collections.<Ref<? extends Type>> singletonList(NATIVE_TYPE_NAME2)); + cd.addMethod(mi); + + + + // @Native("java", "x10.core.Ref.at(#0, #1.id)") + // property def at(p:Place):boolean; + parameters = xts.dummyLocalDefs(Collections.<Ref<? extends Type>> singletonList(PLACE)); + mi = xts.methodDef(pos, Types.ref(ct), + X10Flags.toX10Flags(Flags.PUBLIC.Native()).Property().Safe(), + BOOLEAN, + Name.make("at"), + Collections.EMPTY_LIST, + Collections.<Ref<? extends Type>> singletonList(PLACE), + thisVar, + parameters, + null, + null, + Collections.EMPTY_LIST, + null); + final LazyRef<X10ParsedClassType> NATIVE_AT_2 = Types.lazyRef(null); + NATIVE_AT_2.setResolver(new Runnable() { + public void run() { + List<Expr> list = new ArrayList<Expr>(2); + list.add(new X10StringLit_c(pos, "java")); + list.add(new X10StringLit_c(pos, "x10.core.Ref.at(#0, #1.id)")); + X10ParsedClassType ann= (X10ParsedClassType) ((X10ParsedClassType) xts.NativeType()).propertyInitializers(list); + NATIVE_AT_2.update(ann); + } + }); + mi.setDefAnnotations(Collections.<Ref<? extends Type>> singletonList(NATIVE_AT_2)); + cd.addMethod(mi); + + //@NativeRep("java", "x10.core.Struct", null, null) + final LazyRef<X10ParsedClassType> NATIVE_REP = Types.lazyRef(null); + NATIVE_REP.setResolver(new Runnable() { + public void run() { + List<Expr> list = new ArrayList<Expr>(4); + list.add(new X10StringLit_c(pos, "java")); + list.add(new X10StringLit_c(pos, "x10.core.Struct")); + list.add(null); + list.add(null); + X10ParsedClassType ann = (X10ParsedClassType) ((X10ParsedClassType) xts.NativeRep()).propertyInitializers(list); + + NATIVE_REP.u... [truncated message content] |
From: <ta...@us...> - 2009-12-23 23:10:28
|
Revision: 12411 http://x10.svn.sourceforge.net/x10/?rev=12411&view=rev Author: tardieu Date: 2009-12-23 23:10:15 +0000 (Wed, 23 Dec 2009) Log Message: ----------- Implemented @NativeClass and @NativeDef The NativeClassVisitor goal adds to each class annotated @NativeClass a field of the specified native class and redirects its @NativeDef methods to that field. E.g., @NativeClass("java", "java.util.concurrent", "ReentrantLock") class Lock { @NativeDef("java") def lock() {} } is compiled into class Lock ... { private java.util.concurrent.ReentrantLock __NATIVE_FIELD__ = new java...Lock(); void lock() { __NATIVE_FIELD__.lock(); } } See x10.runtime.Lock for a complete example. Modified Paths: -------------- trunk/x10.compiler/src/x10/ExtensionInfo.java trunk/x10.compiler/src/x10cpp/ExtensionInfo.java trunk/x10.runtime/src-x10/x10/runtime/Lock.x10 Added Paths: ----------- trunk/x10.compiler/src/x10/visit/NativeClassVisitor.java trunk/x10.runtime/src-x10/x10/compiler/NativeClass.x10 trunk/x10.runtime/src-x10/x10/compiler/NativeDef.x10 Modified: trunk/x10.compiler/src/x10/ExtensionInfo.java =================================================================== --- trunk/x10.compiler/src/x10/ExtensionInfo.java 2009-12-23 20:52:13 UTC (rev 12410) +++ trunk/x10.compiler/src/x10/ExtensionInfo.java 2009-12-23 23:10:15 UTC (rev 12411) @@ -67,6 +67,7 @@ import x10.visit.ExprFlattener; import x10.visit.FieldInitializerMover; import x10.visit.Inliner; +import x10.visit.NativeClassVisitor; import x10.visit.RewriteAtomicMethodVisitor; import x10.visit.RewriteExternVisitor; import x10.visit.StaticNestedClassRemover; @@ -278,6 +279,8 @@ goals.add(PropertyAssignmentsChecked(job)); goals.add(X10Expanded(job)); + goals.add(NativeClassVisitor(job)); + goals.add(Serialized(job)); // goals.add(CodeGenBarrier()); goals.add(CheckNativeAnnotations(job)); @@ -445,6 +448,12 @@ return new VisitorGoal("CheckNativeAnnotations", job, new CheckNativeAnnotationsVisitor(job, ts, nf, "java")).intern(this); } + public Goal NativeClassVisitor(Job job) { + TypeSystem ts = extInfo.typeSystem(); + NodeFactory nf = extInfo.nodeFactory(); + return new VisitorGoal("NativeClassVisitor", job, new NativeClassVisitor(job, ts, nf, "java")).intern(this); + } + public Goal Desugarer(Job job) { TypeSystem ts = extInfo.typeSystem(); NodeFactory nf = extInfo.nodeFactory(); Added: trunk/x10.compiler/src/x10/visit/NativeClassVisitor.java =================================================================== --- trunk/x10.compiler/src/x10/visit/NativeClassVisitor.java (rev 0) +++ trunk/x10.compiler/src/x10/visit/NativeClassVisitor.java 2009-12-23 23:10:15 UTC (rev 12411) @@ -0,0 +1,204 @@ +/* + * + * (C) Copyright IBM Corporation 2006-2008 + * + * This file is part of X10 Language. + * + */ +package x10.visit; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import polyglot.ast.CanonicalTypeNode; +import polyglot.ast.ClassBody; +import polyglot.ast.ClassMember; +import polyglot.ast.Expr; +import polyglot.ast.Formal; +import polyglot.ast.IntLit; +import polyglot.ast.Node; +import polyglot.ast.NodeFactory; +import polyglot.ast.Receiver; +import polyglot.ast.TypeNode; +import polyglot.frontend.Job; +import polyglot.types.ConstructorInstance; +import polyglot.types.ClassDef; +import polyglot.types.ClassType; +import polyglot.types.Flags; +import polyglot.types.FieldDef; +import polyglot.types.Name; +import polyglot.types.QName; +import polyglot.types.SemanticException; +import polyglot.types.Type; +import polyglot.types.Types; +import polyglot.types.Ref; +import polyglot.types.TypeSystem; +import polyglot.util.Position; +import polyglot.visit.ContextVisitor; +import polyglot.visit.NodeVisitor; +import x10.ast.AnnotationNode; +import x10.ast.X10ClassDecl; +import x10.ast.X10MethodDecl; +import x10.ast.X10NodeFactory; +import x10.extension.X10Ext; +import x10.types.X10ClassDef; +import x10.types.X10ClassType; +import x10.types.X10Flags; +import x10.types.X10MethodDef; +import x10.types.X10TypeMixin; +import x10.types.X10TypeSystem; + +/** + * Visitor that expands @NativeClass and @NativeDef annotations. + */ +public class NativeClassVisitor extends ContextVisitor { + final String theLanguage; + final X10TypeSystem xts; + final X10NodeFactory xnf; + final Position pos; + final Name fieldName; + + public NativeClassVisitor(Job job, TypeSystem ts, NodeFactory nf, String theLanguage) { + super(job, ts, nf); + xts = (X10TypeSystem) ts; + xnf = (X10NodeFactory) nf; + this.theLanguage = theLanguage; + pos = Position.COMPILER_GENERATED; + fieldName = Name.make("__NATIVE_FIELD__"); + } + + public boolean isNativeMethod(X10MethodDef def) { + try { + Type t = (Type) xts.systemResolver().find(QName.make("x10.compiler.NativeDef")); + List<Type> as = def.annotationsMatching(t); + for (Type at : as) { + String lang = getPropertyInit(at, 0); + if (theLanguage.equals(lang)) { + return true; + } + } + } + catch (SemanticException e) {} + return false; + } + + public String getNativeClassName(X10ClassDef def) { + try { + Type t = (Type) xts.systemResolver().find(QName.make("x10.compiler.NativeClass")); + List<Type> as = def.annotationsMatching(t); + for (Type at : as) { + String lang = getPropertyInit(at, 0); + if (theLanguage.equals(lang)) { + return getPropertyInit(at, 2); + } + } + } + catch (SemanticException e) {} + return null; + } + + + public String getNativeClassPackage(X10ClassDef def) { + try { + Type t = (Type) xts.systemResolver().find(QName.make("x10.compiler.NativeClass")); + List<Type> as = def.annotationsMatching(t); + for (Type at : as) { + String lang = getPropertyInit(at, 0); + if (theLanguage.equals(lang)) { + return getPropertyInit(at, 1); + } + } + } + catch (SemanticException e) {} + return null; + } + + String getPropertyInit(Type at, int index) throws SemanticException { + at = X10TypeMixin.baseType(at); + if (at instanceof X10ClassType) { + X10ClassType act = (X10ClassType) at; + if (index < act.propertyInitializers().size()) { + Expr e = act.propertyInitializer(index); + if (e.isConstant() && e.constantValue() instanceof String) { + return (String) e.constantValue(); + } + else { + throw new SemanticException("Property initializer for @" + at + " must be a string literal."); + } + } + } + return null; + } + + protected Node leaveCall(Node parent, Node old, Node n, NodeVisitor v) throws SemanticException { + if (!(n instanceof X10ClassDecl)) + return n; + + X10ClassDecl cd = (X10ClassDecl) n; + X10ClassDef cf = (X10ClassDef) cd.classDef(); + + String cn = getNativeClassName(cf); + + if (cn == null) + return n; + +// System.err.println("processing @NativeClass(\"" + cn + "\") class " + cd.name()); + + ClassBody cb = cd.body(); + List<ClassMember> cm = new ArrayList<ClassMember>(); + + ClassDef def = xts.createClassDef(); + def.name(Name.make(cn)); + def.kind(ClassDef.TOP_LEVEL); + def.setFromEncodedClassFile(); + Flags flags = X10Flags.GLOBAL.Private().Final(); + def.setFlags(flags); + def.setPackage(Types.ref(ts.packageForName(QName.make(getNativeClassPackage(cf))))); + ClassType ft = def.asType(); + FieldDef ff = xts.fieldDef(pos, Types.ref(cf.asType()), flags, Types.ref(ft), fieldName); + ConstructorInstance ci = xts.constructorDef(pos, Types.ref(ft), flags, + Collections.<Ref<? extends Type>>emptyList(), + Collections.<Ref<? extends Type>>emptyList()).asInstance(); + CanonicalTypeNode tn = xnf.CanonicalTypeNode(pos, ft); + Expr init = xnf.New(pos, tn, Collections.<Expr>emptyList()).constructorInstance(ci).type(ft); + + for (ClassMember m : cb.members()) { + if (m instanceof X10MethodDecl) { + X10MethodDecl md = (X10MethodDecl) m; + X10MethodDef mf = (X10MethodDef) md.methodDef(); + + if (!isNativeMethod(mf)) { + cm.add(m); + continue; + } + +// System.err.println("processing " + mf); + + + List<Expr> args = new ArrayList<Expr>(); + for (Formal f : md.formals()) + args.add(xnf.Local(pos, f.name())); + + Receiver r = xnf.This(pos).type(cf.asType()); + Receiver t = xnf.Field(pos, r, xnf.Id(pos, fieldName)).fieldInstance(ff.asInstance()).type(ft); + Expr expr = xnf.Call(pos, t, md.name(), args).methodInstance(mf.asInstance()).type(md.returnType().type()); + + if (md.returnType().type().isVoid()) { + cm.add((X10MethodDecl) md.body(xnf.Block(pos, xnf.Eval(pos, expr)))); + } else { + cm.add((X10MethodDecl) md.body(xnf.Block(pos, xnf.Return(pos, expr)))); + } + continue; + } + cm.add(m); + } + + cm.add(xnf.FieldDecl(pos, xnf.FlagsNode(pos, flags), tn, xnf.Id(pos, fieldName), init).fieldDef(ff)); + + X10Ext ext = ((X10Ext) cd.ext()); + ext.annotations(Collections.<AnnotationNode>emptyList()); + + return cd.body(cb.members(cm));//.ext(ext); + } +} Modified: trunk/x10.compiler/src/x10cpp/ExtensionInfo.java =================================================================== --- trunk/x10.compiler/src/x10cpp/ExtensionInfo.java 2009-12-23 20:52:13 UTC (rev 12410) +++ trunk/x10.compiler/src/x10cpp/ExtensionInfo.java 2009-12-23 23:10:15 UTC (rev 12411) @@ -35,6 +35,7 @@ import x10.ast.X10NodeFactory_c; import x10.optimizations.Optimizer; import x10.visit.CheckNativeAnnotationsVisitor; +import x10.visit.NativeClassVisitor; import x10.visit.StaticNestedClassRemover; import x10.visit.X10InnerClassRemover; import x10cpp.ast.X10CPPDelFactory_c; @@ -131,6 +132,11 @@ NodeFactory nf = extInfo.nodeFactory(); return new VisitorGoal("CheckNativeAnnotations", job, new CheckNativeAnnotationsVisitor(job, ts, nf, "c++")).intern(this); } + public Goal NativeClassVisitor(Job job) { + TypeSystem ts = extInfo.typeSystem(); + NodeFactory nf = extInfo.nodeFactory(); + return new VisitorGoal("NativeClassVisitor", job, new NativeClassVisitor(job, ts, nf, "c++")).intern(this); + } public Goal InnerClassesRemoved(Job job) { TypeSystem ts = extInfo.typeSystem(); NodeFactory nf = extInfo.nodeFactory(); Added: trunk/x10.runtime/src-x10/x10/compiler/NativeClass.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/compiler/NativeClass.x10 (rev 0) +++ trunk/x10.runtime/src-x10/x10/compiler/NativeClass.x10 2009-12-23 23:10:15 UTC (rev 12411) @@ -0,0 +1,13 @@ +/* + * + * (C) Copyright IBM Corporation 2006-2008. + * + * This file is part of X10 Language. + * + */ + +package x10.compiler; + +import x10.lang.annotations.ClassAnnotation; + +public interface NativeClass(lang:String, packageName:String, className:String) extends ClassAnnotation { } Added: trunk/x10.runtime/src-x10/x10/compiler/NativeDef.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/compiler/NativeDef.x10 (rev 0) +++ trunk/x10.runtime/src-x10/x10/compiler/NativeDef.x10 2009-12-23 23:10:15 UTC (rev 12411) @@ -0,0 +1,13 @@ +/* + * + * (C) Copyright IBM Corporation 2006-2008. + * + * This file is part of X10 Language. + * + */ + +package x10.compiler; + +import x10.lang.annotations.MethodAnnotation; + +public interface NativeDef(lang:String) extends MethodAnnotation { } Modified: trunk/x10.runtime/src-x10/x10/runtime/Lock.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/runtime/Lock.x10 2009-12-23 20:52:13 UTC (rev 12410) +++ trunk/x10.runtime/src-x10/x10/runtime/Lock.x10 2009-12-23 23:10:15 UTC (rev 12411) @@ -9,41 +9,33 @@ */ package x10.runtime; -import x10.compiler.Native; -import x10.compiler.NativeRep; +import x10.compiler.NativeClass; +import x10.compiler.NativeDef; /** * A low-level lock that provides a subset of * the functionality of java.util.concurrent.locks.ReentrantLock. * The API is subsetted to that which is also supported by pthread_mutex. */ +@NativeClass("java", "java.util.concurrent.locks", "ReentrantLock") +@NativeClass("c++", "x10.runtime", "Lock__ReentrantLock") public class Lock { - @NativeRep("java", "java.util.concurrent.locks.ReentrantLock", null, null) - @NativeRep("c++", "x10aux::ref<x10::runtime::Lock__ReentrantLock>", "x10::runtime::Lock__ReentrantLock", null) - static class ReentrantLock {} + @NativeDef("java") + @NativeDef("c++") + public def lock() {} - private val lock = new ReentrantLock(); + @NativeDef("java") + @NativeDef("c++") + public def tryLock() {} - public def lock() { - @Native("java", "lock.lock();") - @Native("c++", "FMGL(lock)->lock();") {} - } + @NativeDef("java") + @NativeDef("c++") + public def unlock() {} - public def tryLock() { - @Native("java", "lock.tryLock();") - @Native("c++", "FMGL(lock)->tryLock();") {} - } - - public def unlock() { - @Native("java", "lock.unlock();") - @Native("c++", "FMGL(lock)->unlock();") {} - } - - public def getHoldCount() { - @Native("java", "return lock.getHoldCount();") - @Native("c++", "return FMGL(lock)->getHoldCount();") { return 0; } - } + @NativeDef("java") + @NativeDef("c++") + public def getHoldCount() = 0; } // vim:shiftwidth=4:tabstop=4:expandtab This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ta...@us...> - 2009-12-23 23:58:11
|
Revision: 12412 http://x10.svn.sourceforge.net/x10/?rev=12412&view=rev Author: tardieu Date: 2009-12-23 23:57:50 +0000 (Wed, 23 Dec 2009) Log Message: ----------- added comments, reporting minor tweaks Modified Paths: -------------- trunk/x10.compiler/src/x10/visit/NativeClassVisitor.java trunk/x10.runtime/src-x10/x10/runtime/Lock.x10 Modified: trunk/x10.compiler/src/x10/visit/NativeClassVisitor.java =================================================================== --- trunk/x10.compiler/src/x10/visit/NativeClassVisitor.java 2009-12-23 23:10:15 UTC (rev 12411) +++ trunk/x10.compiler/src/x10/visit/NativeClassVisitor.java 2009-12-23 23:57:50 UTC (rev 12412) @@ -20,13 +20,16 @@ import polyglot.ast.Node; import polyglot.ast.NodeFactory; import polyglot.ast.Receiver; +import polyglot.ast.Stmt; import polyglot.ast.TypeNode; import polyglot.frontend.Job; +import polyglot.main.Report; import polyglot.types.ConstructorInstance; import polyglot.types.ClassDef; import polyglot.types.ClassType; import polyglot.types.Flags; import polyglot.types.FieldDef; +import polyglot.types.MethodInstance; import polyglot.types.Name; import polyglot.types.QName; import polyglot.types.SemanticException; @@ -132,6 +135,7 @@ } protected Node leaveCall(Node parent, Node old, Node n, NodeVisitor v) throws SemanticException { + // look for @NativeClass class declarations if (!(n instanceof X10ClassDecl)) return n; @@ -143,26 +147,32 @@ if (cn == null) return n; -// System.err.println("processing @NativeClass(\"" + cn + "\") class " + cd.name()); + if (Report.should_report("nativeclass", 1)) + Report.report(1, "Processing @NativeClass " + cd); ClassBody cb = cd.body(); List<ClassMember> cm = new ArrayList<ClassMember>(); + // create fake def for native class ClassDef def = xts.createClassDef(); def.name(Name.make(cn)); def.kind(ClassDef.TOP_LEVEL); def.setFromEncodedClassFile(); - Flags flags = X10Flags.GLOBAL.Private().Final(); - def.setFlags(flags); + def.setFlags(X10Flags.NONE); def.setPackage(Types.ref(ts.packageForName(QName.make(getNativeClassPackage(cf))))); ClassType ft = def.asType(); + + // add field with native type + Flags flags = X10Flags.GLOBAL.Private().Final(); FieldDef ff = xts.fieldDef(pos, Types.ref(cf.asType()), flags, Types.ref(ft), fieldName); ConstructorInstance ci = xts.constructorDef(pos, Types.ref(ft), flags, Collections.<Ref<? extends Type>>emptyList(), Collections.<Ref<? extends Type>>emptyList()).asInstance(); CanonicalTypeNode tn = xnf.CanonicalTypeNode(pos, ft); Expr init = xnf.New(pos, tn, Collections.<Expr>emptyList()).constructorInstance(ci).type(ft); + cm.add(xnf.FieldDecl(pos, xnf.FlagsNode(pos, flags), tn, xnf.Id(pos, fieldName), init).fieldDef(ff)); + // look for @NativeDef methods for (ClassMember m : cb.members()) { if (m instanceof X10MethodDecl) { X10MethodDecl md = (X10MethodDecl) m; @@ -173,32 +183,35 @@ continue; } -// System.err.println("processing " + mf); + if (Report.should_report("nativeclass", 2)) + Report.report(1, "Processing @NativeDef " + md); - + // turn formals into arguments of delegate call List<Expr> args = new ArrayList<Expr>(); for (Formal f : md.formals()) args.add(xnf.Local(pos, f.name())); - Receiver r = xnf.This(pos).type(cf.asType()); - Receiver t = xnf.Field(pos, r, xnf.Id(pos, fieldName)).fieldInstance(ff.asInstance()).type(ft); - Expr expr = xnf.Call(pos, t, md.name(), args).methodInstance(mf.asInstance()).type(md.returnType().type()); + // call delegate + Receiver special = xnf.This(pos).type(cf.asType()); + Receiver field = xnf.Field(pos, special, xnf.Id(pos, fieldName)).fieldInstance(ff.asInstance()).type(ft); + // HACK: reuse x10 method instance for delegate method but make it global + MethodInstance mi = mf.asInstance(); + mi = (MethodInstance) mi.flags(((X10Flags) mi.flags()).Global()); + Expr expr = xnf.Call(pos, field, md.name(), args).methodInstance(mi).type(md.returnType().type()); + // void vs. non-void methods + Stmt body; if (md.returnType().type().isVoid()) { - cm.add((X10MethodDecl) md.body(xnf.Block(pos, xnf.Eval(pos, expr)))); + body = xnf.Eval(pos, expr); } else { - cm.add((X10MethodDecl) md.body(xnf.Block(pos, xnf.Return(pos, expr)))); + body = xnf.Return(pos, expr); } + cm.add((X10MethodDecl) md.body(xnf.Block(pos, body))); continue; } cm.add(m); } - cm.add(xnf.FieldDecl(pos, xnf.FlagsNode(pos, flags), tn, xnf.Id(pos, fieldName), init).fieldDef(ff)); - - X10Ext ext = ((X10Ext) cd.ext()); - ext.annotations(Collections.<AnnotationNode>emptyList()); - - return cd.body(cb.members(cm));//.ext(ext); + return cd.body(cb.members(cm)); } } Modified: trunk/x10.runtime/src-x10/x10/runtime/Lock.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/runtime/Lock.x10 2009-12-23 23:10:15 UTC (rev 12411) +++ trunk/x10.runtime/src-x10/x10/runtime/Lock.x10 2009-12-23 23:57:50 UTC (rev 12412) @@ -23,19 +23,19 @@ @NativeDef("java") @NativeDef("c++") - public def lock() {} + public def lock():Void {} @NativeDef("java") @NativeDef("c++") - public def tryLock() {} + public def tryLock():Void {} @NativeDef("java") @NativeDef("c++") - public def unlock() {} + public def unlock():Void {} @NativeDef("java") @NativeDef("c++") - public def getHoldCount() = 0; + public def getHoldCount():Int = 0; } // vim:shiftwidth=4:tabstop=4:expandtab This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ta...@us...> - 2009-12-24 02:43:07
|
Revision: 12413 http://x10.svn.sourceforge.net/x10/?rev=12413&view=rev Author: tardieu Date: 2009-12-24 02:20:49 +0000 (Thu, 24 Dec 2009) Log Message: ----------- added support for native methods in @NativeClass classes native methods are considered @NativeDef for all backends applied to x10.runtime.Deque renamed Deque to X10Deque to avoid name clash Modified Paths: -------------- trunk/x10.compiler/src/x10/visit/NativeClassVisitor.java trunk/x10.runtime/src-cpp/x10/runtime/Deque.cc trunk/x10.runtime/src-cpp/x10/runtime/Deque.h trunk/x10.runtime/src-java/x10/runtime/impl/java/Deque.java trunk/x10.runtime/src-x10/x10/runtime/Lock.x10 trunk/x10.runtime/src-x10/x10/runtime/Worker.x10 Added Paths: ----------- trunk/x10.runtime/src-x10/x10/runtime/X10Deque.x10 Removed Paths: ------------- trunk/x10.runtime/src-x10/x10/runtime/Deque.x10 Modified: trunk/x10.compiler/src/x10/visit/NativeClassVisitor.java =================================================================== --- trunk/x10.compiler/src/x10/visit/NativeClassVisitor.java 2009-12-23 23:57:50 UTC (rev 12412) +++ trunk/x10.compiler/src/x10/visit/NativeClassVisitor.java 2009-12-24 02:20:49 UTC (rev 12413) @@ -101,7 +101,6 @@ return null; } - public String getNativeClassPackage(X10ClassDef def) { try { Type t = (Type) xts.systemResolver().find(QName.make("x10.compiler.NativeClass")); @@ -172,13 +171,13 @@ Expr init = xnf.New(pos, tn, Collections.<Expr>emptyList()).constructorInstance(ci).type(ft); cm.add(xnf.FieldDecl(pos, xnf.FlagsNode(pos, flags), tn, xnf.Id(pos, fieldName), init).fieldDef(ff)); - // look for @NativeDef methods + // look for @NativeDef methods and native methods for (ClassMember m : cb.members()) { if (m instanceof X10MethodDecl) { X10MethodDecl md = (X10MethodDecl) m; X10MethodDef mf = (X10MethodDef) md.methodDef(); - if (!isNativeMethod(mf)) { + if (!isNativeMethod(mf) && !mf.flags().isNative()) { cm.add(m); continue; } @@ -189,14 +188,14 @@ // turn formals into arguments of delegate call List<Expr> args = new ArrayList<Expr>(); for (Formal f : md.formals()) - args.add(xnf.Local(pos, f.name())); - + args.add(xnf.Local(pos, f.name()).localInstance(f.localDef().asInstance()).type(f.type().type())); + // call delegate Receiver special = xnf.This(pos).type(cf.asType()); Receiver field = xnf.Field(pos, special, xnf.Id(pos, fieldName)).fieldInstance(ff.asInstance()).type(ft); - // HACK: reuse x10 method instance for delegate method but make it global + // HACK: reuse x10 method instance for delegate method but make it global and non-native MethodInstance mi = mf.asInstance(); - mi = (MethodInstance) mi.flags(((X10Flags) mi.flags()).Global()); + mi = (MethodInstance) mi.flags(((X10Flags) mi.flags()).Global().clearNative()); Expr expr = xnf.Call(pos, field, md.name(), args).methodInstance(mi).type(md.returnType().type()); // void vs. non-void methods @@ -206,6 +205,10 @@ } else { body = xnf.Return(pos, expr); } + + // clear native flag + md = (X10MethodDecl) md.flags(xnf.FlagsNode(pos, md.flags().flags().clearNative())); + mf.setFlags(mf.flags().clearNative()); cm.add((X10MethodDecl) md.body(xnf.Block(pos, body))); continue; } Modified: trunk/x10.runtime/src-cpp/x10/runtime/Deque.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/runtime/Deque.cc 2009-12-23 23:57:50 UTC (rev 12412) +++ trunk/x10.runtime/src-cpp/x10/runtime/Deque.cc 2009-12-24 02:20:49 UTC (rev 12413) @@ -66,7 +66,7 @@ } while (++b != bf); } -void Deque::pushTask(x10aux::ref<x10::lang::Object> t) { +void Deque::push(x10aux::ref<x10::lang::Object> t) { Slots *q = queue; int mask = q->capacity - 1; int s = sp; @@ -79,7 +79,7 @@ } } -ref<Object> Deque::deqTask() { +ref<Object> Deque::steal() { Object *t; Slots *q; int i; @@ -94,7 +94,7 @@ return null; } -ref<Object> Deque::popTask() { +ref<Object> Deque::poll() { int s = sp; while (s != base) { Slots *q = queue; Modified: trunk/x10.runtime/src-cpp/x10/runtime/Deque.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/runtime/Deque.h 2009-12-23 23:57:50 UTC (rev 12412) +++ trunk/x10.runtime/src-cpp/x10/runtime/Deque.h 2009-12-24 02:20:49 UTC (rev 12413) @@ -87,20 +87,20 @@ * Pushes a task. Called only by current thread. * @param t the task. Caller must ensure nonnull */ - void pushTask(x10aux::ref<x10::lang::Object> t); + void push(x10aux::ref<x10::lang::Object> t); /** * Tries to take a task from the base of the queue, failing if * either empty or contended. * @return a task, or null if none or contended. */ - x10aux::ref<x10::lang::Object> deqTask(); + x10aux::ref<x10::lang::Object> steal(); /** * Returns a popped task, or null if empty. Ensures active status * if nonnull. Called only by current thread. */ - x10aux::ref<x10::lang::Object> popTask(); + x10aux::ref<x10::lang::Object> poll(); /** * Returns next task to pop. @@ -113,7 +113,7 @@ /** * Returns an estimate of the number of tasks in the queue. */ - inline int getQueueSize() { + inline int size() { int n = sp - base; return n < 0 ? 0 : n; // suppress momentarily negative values } Modified: trunk/x10.runtime/src-java/x10/runtime/impl/java/Deque.java =================================================================== --- trunk/x10.runtime/src-java/x10/runtime/impl/java/Deque.java 2009-12-23 23:57:50 UTC (rev 12412) +++ trunk/x10.runtime/src-java/x10/runtime/impl/java/Deque.java 2009-12-24 02:20:49 UTC (rev 12413) @@ -88,7 +88,7 @@ * Pushes a task. Called only by current thread. * @param t the task. Caller must ensure nonnull */ - public final void pushTask(Object t) { + public final void push(Object t) { Object[] q = queue; int mask = q.length - 1; int s = sp; @@ -105,7 +105,7 @@ * either empty or contended. * @return a task, or null if none or contended. */ - public final Object deqTask() { + public final Object steal() { Object t; Object[] q; int i; @@ -124,7 +124,7 @@ * Returns a popped task, or null if empty. Ensures active status * if nonnull. Called only by current thread. */ - public final Object popTask() { + public final Object poll() { int s = sp; while (s != base) { Object[] q = queue; @@ -176,7 +176,7 @@ /** * Returns an estimate of the number of tasks in the queue. */ - public final int getQueueSize() { + public final int size() { int n = sp - base; return n < 0? 0 : n; // suppress momentarily negative values } Deleted: trunk/x10.runtime/src-x10/x10/runtime/Deque.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/runtime/Deque.x10 2009-12-23 23:57:50 UTC (rev 12412) +++ trunk/x10.runtime/src-x10/x10/runtime/Deque.x10 2009-12-24 02:20:49 UTC (rev 12413) @@ -1,37 +0,0 @@ -/* - * - * (C) Copyright IBM Corporation 2006-2008. - * - * This file is part of X10 Language. - * - */ -package x10.runtime; - -import x10.compiler.Native; -import x10.compiler.NativeRep; - -/** - * Interface with native runtime - * @author tardieu - */ -@NativeRep("java", "x10.runtime.impl.java.Deque", null, null) -@NativeRep("c++", "x10aux::ref<x10::runtime::Deque>", "x10::runtime::Deque", null) -public final class Deque { - @Native("java", "#0.getQueueSize()") - @Native("c++", "(#0)->getQueueSize()") - public native def size():Int; - - @Native("java", "#0.popTask()") - @Native("c++", "(#0)->popTask()") - public native def poll():Object; - - @Native("java", "#0.pushTask(#1)") - @Native("c++", "(#0)->pushTask(#1)") - public native def push(t:Object):Void; - - @Native("java", "#0.deqTask()") - @Native("c++", "(#0)->deqTask()") - public native def steal():Object; -} - -// vim:shiftwidth=4:tabstop=4:expandtab Modified: trunk/x10.runtime/src-x10/x10/runtime/Lock.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/runtime/Lock.x10 2009-12-23 23:57:50 UTC (rev 12412) +++ trunk/x10.runtime/src-x10/x10/runtime/Lock.x10 2009-12-24 02:20:49 UTC (rev 12413) @@ -20,22 +20,13 @@ @NativeClass("java", "java.util.concurrent.locks", "ReentrantLock") @NativeClass("c++", "x10.runtime", "Lock__ReentrantLock") public class Lock { + public native def lock():Void; - @NativeDef("java") - @NativeDef("c++") - public def lock():Void {} + public native def tryLock():Void; - @NativeDef("java") - @NativeDef("c++") - public def tryLock():Void {} + public native def unlock():Void; - @NativeDef("java") - @NativeDef("c++") - public def unlock():Void {} - - @NativeDef("java") - @NativeDef("c++") - public def getHoldCount():Int = 0; + public native def getHoldCount():Int; } // vim:shiftwidth=4:tabstop=4:expandtab Modified: trunk/x10.runtime/src-x10/x10/runtime/Worker.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/runtime/Worker.x10 2009-12-23 23:57:50 UTC (rev 12412) +++ trunk/x10.runtime/src-x10/x10/runtime/Worker.x10 2009-12-24 02:20:49 UTC (rev 12413) @@ -24,7 +24,7 @@ private var activity:Activity = null; // pending activities - private val queue = new Deque(); + private val queue = new X10Deque(); // random number generator for this worker private val random:Random!; Copied: trunk/x10.runtime/src-x10/x10/runtime/X10Deque.x10 (from rev 12410, trunk/x10.runtime/src-x10/x10/runtime/Deque.x10) =================================================================== --- trunk/x10.runtime/src-x10/x10/runtime/X10Deque.x10 (rev 0) +++ trunk/x10.runtime/src-x10/x10/runtime/X10Deque.x10 2009-12-24 02:20:49 UTC (rev 12413) @@ -0,0 +1,29 @@ +/* + * + * (C) Copyright IBM Corporation 2006-2008. + * + * This file is part of X10 Language. + * + */ +package x10.runtime; + +import x10.compiler.NativeClass; +import x10.compiler.NativeDef; + +/** + * Interface with native runtime + * @author tardieu + */ +@NativeClass("java", "x10.runtime.impl.java", "Deque") +@NativeClass("c++", "x10.runtime", "Deque") +public final class X10Deque { + public native def size():Int; + + public native def poll():Object; + + public native def push(t:Object):Void; + + public native def steal():Object; +} + +// vim:shiftwidth=4:tabstop=4:expandtab This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ta...@us...> - 2009-12-24 14:06:25
|
Revision: 12414 http://x10.svn.sourceforge.net/x10/?rev=12414&view=rev Author: tardieu Date: 2009-12-24 14:06:18 +0000 (Thu, 24 Dec 2009) Log Message: ----------- added support for native constructors in @NativeClass Modified Paths: -------------- trunk/x10.compiler/src/x10/visit/NativeClassVisitor.java trunk/x10.runtime/src-x10/x10/runtime/Lock.x10 trunk/x10.runtime/src-x10/x10/runtime/X10Deque.x10 Modified: trunk/x10.compiler/src/x10/visit/NativeClassVisitor.java =================================================================== --- trunk/x10.compiler/src/x10/visit/NativeClassVisitor.java 2009-12-24 02:20:49 UTC (rev 12413) +++ trunk/x10.compiler/src/x10/visit/NativeClassVisitor.java 2009-12-24 14:06:18 UTC (rev 12414) @@ -11,9 +11,11 @@ import java.util.Collections; import java.util.List; +import polyglot.ast.Assign; import polyglot.ast.CanonicalTypeNode; import polyglot.ast.ClassBody; import polyglot.ast.ClassMember; +import polyglot.ast.ConstructorDecl; import polyglot.ast.Expr; import polyglot.ast.Formal; import polyglot.ast.IntLit; @@ -41,10 +43,13 @@ import polyglot.visit.ContextVisitor; import polyglot.visit.NodeVisitor; import x10.ast.AnnotationNode; +import x10.ast.X10ConstructorDecl; import x10.ast.X10ClassDecl; import x10.ast.X10MethodDecl; import x10.ast.X10NodeFactory; import x10.extension.X10Ext; +import x10.types.X10Def; +import x10.types.X10ConstructorDef; import x10.types.X10ClassDef; import x10.types.X10ClassType; import x10.types.X10Flags; @@ -71,48 +76,39 @@ fieldName = Name.make("__NATIVE_FIELD__"); } - public boolean isNativeMethod(X10MethodDef def) { - try { - Type t = (Type) xts.systemResolver().find(QName.make("x10.compiler.NativeDef")); - List<Type> as = def.annotationsMatching(t); - for (Type at : as) { - String lang = getPropertyInit(at, 0); - if (theLanguage.equals(lang)) { - return true; - } + public boolean isNativeDef(X10Def def) throws SemanticException { + Type t = (Type) xts.systemResolver().find(QName.make("x10.compiler.NativeDef")); + List<Type> as = def.annotationsMatching(t); + for (Type at : as) { + String lang = getPropertyInit(at, 0); + if (theLanguage.equals(lang)) { + return true; } } - catch (SemanticException e) {} return false; } - public String getNativeClassName(X10ClassDef def) { - try { - Type t = (Type) xts.systemResolver().find(QName.make("x10.compiler.NativeClass")); - List<Type> as = def.annotationsMatching(t); - for (Type at : as) { - String lang = getPropertyInit(at, 0); - if (theLanguage.equals(lang)) { - return getPropertyInit(at, 2); - } + public String getNativeClassName(X10ClassDef def) throws SemanticException { + Type t = (Type) xts.systemResolver().find(QName.make("x10.compiler.NativeClass")); + List<Type> as = def.annotationsMatching(t); + for (Type at : as) { + String lang = getPropertyInit(at, 0); + if (theLanguage.equals(lang)) { + return getPropertyInit(at, 2); } } - catch (SemanticException e) {} return null; } - public String getNativeClassPackage(X10ClassDef def) { - try { - Type t = (Type) xts.systemResolver().find(QName.make("x10.compiler.NativeClass")); - List<Type> as = def.annotationsMatching(t); - for (Type at : as) { - String lang = getPropertyInit(at, 0); - if (theLanguage.equals(lang)) { - return getPropertyInit(at, 1); - } + public String getNativeClassPackage(X10ClassDef def) throws SemanticException { + Type t = (Type) xts.systemResolver().find(QName.make("x10.compiler.NativeClass")); + List<Type> as = def.annotationsMatching(t); + for (Type at : as) { + String lang = getPropertyInit(at, 0); + if (theLanguage.equals(lang)) { + return getPropertyInit(at, 1); } } - catch (SemanticException e) {} return null; } @@ -164,20 +160,21 @@ // add field with native type Flags flags = X10Flags.GLOBAL.Private().Final(); FieldDef ff = xts.fieldDef(pos, Types.ref(cf.asType()), flags, Types.ref(ft), fieldName); - ConstructorInstance ci = xts.constructorDef(pos, Types.ref(ft), flags, - Collections.<Ref<? extends Type>>emptyList(), - Collections.<Ref<? extends Type>>emptyList()).asInstance(); CanonicalTypeNode tn = xnf.CanonicalTypeNode(pos, ft); - Expr init = xnf.New(pos, tn, Collections.<Expr>emptyList()).constructorInstance(ci).type(ft); - cm.add(xnf.FieldDecl(pos, xnf.FlagsNode(pos, flags), tn, xnf.Id(pos, fieldName), init).fieldDef(ff)); + cm.add(xnf.FieldDecl(pos, xnf.FlagsNode(pos, flags), tn, xnf.Id(pos, fieldName)).fieldDef(ff)); - // look for @NativeDef methods and native methods + Receiver special = xnf.This(pos).type(cf.asType()); + Receiver field = xnf.Field(pos, special, xnf.Id(pos, fieldName)).fieldInstance(ff.asInstance()).type(ft); + + Boolean hasNativeConstructor = false; + + // look for native methods and constructors for (ClassMember m : cb.members()) { if (m instanceof X10MethodDecl) { X10MethodDecl md = (X10MethodDecl) m; X10MethodDef mf = (X10MethodDef) md.methodDef(); - if (!isNativeMethod(mf) && !mf.flags().isNative()) { + if (!isNativeDef(mf) && !mf.flags().isNative()) { cm.add(m); continue; } @@ -190,12 +187,11 @@ for (Formal f : md.formals()) args.add(xnf.Local(pos, f.name()).localInstance(f.localDef().asInstance()).type(f.type().type())); - // call delegate - Receiver special = xnf.This(pos).type(cf.asType()); - Receiver field = xnf.Field(pos, special, xnf.Id(pos, fieldName)).fieldInstance(ff.asInstance()).type(ft); // HACK: reuse x10 method instance for delegate method but make it global and non-native MethodInstance mi = mf.asInstance(); mi = (MethodInstance) mi.flags(((X10Flags) mi.flags()).Global().clearNative()); + + // call delegate Expr expr = xnf.Call(pos, field, md.name(), args).methodInstance(mi).type(md.returnType().type()); // void vs. non-void methods @@ -212,9 +208,44 @@ cm.add((X10MethodDecl) md.body(xnf.Block(pos, body))); continue; } + + if (m instanceof X10ConstructorDecl) { + X10ConstructorDecl xd = (X10ConstructorDecl) m; + X10ConstructorDef xf = (X10ConstructorDef) xd.constructorDef(); + + if (!isNativeDef(xf) && !xf.flags().isNative()) { + // TODO: check that non-native constructors invoke native constructors + cm.add(m); + continue; + } + + hasNativeConstructor = true; + + if (Report.should_report("nativeclass", 2)) + Report.report(1, "Processing @NativeDef " + xd); + + // turn formals into arguments of delegate call + List<Expr> args = new ArrayList<Expr>(); + for (Formal f : xd.formals()) + args.add(xnf.Local(pos, f.name()).localInstance(f.localDef().asInstance()).type(f.type().type())); + + ConstructorInstance xi = xf.asInstance(); + xi = (ConstructorInstance) xi.flags(((X10Flags) xi.flags()).clearNative()); + Expr init = xnf.New(pos, tn, args).constructorInstance(xi).type(ft); + Stmt body = xnf.Eval(pos, xnf.FieldAssign(pos, special, xnf.Id(pos, fieldName), Assign.ASSIGN, init).fieldInstance(ff.asInstance()).type(ft)); + + xd = (X10ConstructorDecl) xd.flags(xnf.FlagsNode(pos, xd.flags().flags().clearNative())); + xf.setFlags(xf.flags().clearNative()); + cm.add((X10ConstructorDecl) xd.body(xnf.Block(pos, body))); + continue; + } cm.add(m); } + if (!hasNativeConstructor) { + throw new SemanticException("@NativeClass " + cd.name() + " must be declare a native constructor."); + } + return cd.body(cb.members(cm)); } } Modified: trunk/x10.runtime/src-x10/x10/runtime/Lock.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/runtime/Lock.x10 2009-12-24 02:20:49 UTC (rev 12413) +++ trunk/x10.runtime/src-x10/x10/runtime/Lock.x10 2009-12-24 14:06:18 UTC (rev 12414) @@ -20,6 +20,8 @@ @NativeClass("java", "java.util.concurrent.locks", "ReentrantLock") @NativeClass("c++", "x10.runtime", "Lock__ReentrantLock") public class Lock { + public native def this(); + public native def lock():Void; public native def tryLock():Void; Modified: trunk/x10.runtime/src-x10/x10/runtime/X10Deque.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/runtime/X10Deque.x10 2009-12-24 02:20:49 UTC (rev 12413) +++ trunk/x10.runtime/src-x10/x10/runtime/X10Deque.x10 2009-12-24 14:06:18 UTC (rev 12414) @@ -17,6 +17,8 @@ @NativeClass("java", "x10.runtime.impl.java", "Deque") @NativeClass("c++", "x10.runtime", "Deque") public final class X10Deque { + public native def this(); + public native def size():Int; public native def poll():Object; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |