From: <ta...@us...> - 2008-11-18 21:51:53
|
Revision: 6842 http://x10.svn.sourceforge.net/x10/?rev=6842&view=rev Author: tardieu Date: 2008-11-18 21:51:49 +0000 (Tue, 18 Nov 2008) Log Message: ----------- implemented simple compiler-generated names for activities and futures Modified Paths: -------------- trunk/x10.compiler.p3/data/Async.xcd trunk/x10.compiler.p3/data/Future.xcd trunk/x10.compiler.p3/data/ateach.xcd trunk/x10.compiler.p3/data/foreach.xcd trunk/x10.compiler.p3/src/polyglot/ext/x10/visit/X10PrettyPrinterVisitor.java trunk/x10.runtime.17/src-x10/x10/runtime/Activity.x10 trunk/x10.runtime.17/src-x10/x10/runtime/Future_c.x10 trunk/x10.runtime.17/src-x10/x10/runtime/Runtime.x10 Modified: trunk/x10.compiler.p3/data/Async.xcd =================================================================== --- trunk/x10.compiler.p3/data/Async.xcd 2008-11-18 21:28:23 UTC (rev 6841) +++ trunk/x10.compiler.p3/data/Async.xcd 2008-11-18 21:51:49 UTC (rev 6842) @@ -1,7 +1,7 @@ -// SYNOPSIS: async(#0) clocked(#1) #2 +// SYNOPSIS: async(#0) clocked(#1) #2 #3=position x10.runtime.Runtime.runAsync(#0, #1, new x10.core.fun.VoidFun_0_0() { public void apply() { #2 } - }); + }, "async-#3"); Modified: trunk/x10.compiler.p3/data/Future.xcd =================================================================== --- trunk/x10.compiler.p3/data/Future.xcd 2008-11-18 21:28:23 UTC (rev 6841) +++ trunk/x10.compiler.p3/data/Future.xcd 2008-11-18 21:51:49 UTC (rev 6842) @@ -1,4 +1,4 @@ -// SYNOPSIS: future[#1](#0) #2 #3=run-time type for #1 +// SYNOPSIS: future[#1](#0) #2 #3=run-time type for #1 #4=position x10.runtime.Runtime.evalFuture(#3, #0, new x10.core.fun.Fun_0_0<#1>() { public #1 apply() { @@ -7,4 +7,4 @@ public x10.types.Type<?> rtt_x10$lang$Fun_0_0_U() { return #3; } - }) + }, "future-#4") Modified: trunk/x10.compiler.p3/data/ateach.xcd =================================================================== --- trunk/x10.compiler.p3/data/ateach.xcd 2008-11-18 21:28:23 UTC (rev 6841) +++ trunk/x10.compiler.p3/data/ateach.xcd 2008-11-18 21:51:49 UTC (rev 6842) @@ -1,4 +1,4 @@ -// SYNOPSIS: ateach (#0 #2: #1 in #3) clocked(#5) {#4} #6=locals #7=boxed type +// SYNOPSIS: ateach (#0 #2: #1 in #3) clocked(#5) {#4} #6=locals #7=boxed type #8=position { x10.lang.Dist #2__distCopy = #3; // make copy to avoid recomputation for (x10.core.Iterator<#7> #2__ = #2__distCopy.iterator(); #2__.hasNext(); ) { @@ -9,6 +9,6 @@ public void apply() { #4 } - }); + }, "ateach-#8"); } } Modified: trunk/x10.compiler.p3/data/foreach.xcd =================================================================== --- trunk/x10.compiler.p3/data/foreach.xcd 2008-11-18 21:28:23 UTC (rev 6841) +++ trunk/x10.compiler.p3/data/foreach.xcd 2008-11-18 21:51:49 UTC (rev 6842) @@ -1,4 +1,4 @@ -// SYNOPSIS: foreach (#0 #2: #1 in #3) clocked(#5) {#4} #6=locals #7=boxed type +// SYNOPSIS: foreach (#0 #2: #1 in #3) clocked(#5) {#4} #6=locals #7=boxed type #8=position for (x10.core.Iterator<#7> #2__ = (#3).iterator(); #2__.hasNext(); ) { #0 #1 #2 = #2__.next(); #6 @@ -7,5 +7,5 @@ public void apply() { #4 } - }); + }, "foreach-#8"); } Modified: trunk/x10.compiler.p3/src/polyglot/ext/x10/visit/X10PrettyPrinterVisitor.java =================================================================== --- trunk/x10.compiler.p3/src/polyglot/ext/x10/visit/X10PrettyPrinterVisitor.java 2008-11-18 21:28:23 UTC (rev 6841) +++ trunk/x10.compiler.p3/src/polyglot/ext/x10/visit/X10PrettyPrinterVisitor.java 2008-11-18 21:51:49 UTC (rev 6842) @@ -2470,7 +2470,8 @@ new Template("Async", a.place(), processClocks(a), - a.body()).expand(tr2); + a.body(), + a.position().nameAndLineString()).expand(tr2); } public void visit(AtStmt_c a) { @@ -2478,7 +2479,8 @@ new Template("At", a.place(), a.body(), - getUniqueId_()).expand(tr2); + getUniqueId_(), + a.position().nameAndLineString()).expand(tr2); } public void visit(Atomic_c a) { @@ -2499,12 +2501,12 @@ public void visit(Future_c f) { Translator tr2 = ((X10Translator) tr).inInnerClass(true); - new Template("Future", f.place(), new TypeExpander(f.returnType().type(), true, true, false, false), f.body(), new RuntimeTypeExpander(f.returnType().type())).expand(tr2); + new Template("Future", f.place(), new TypeExpander(f.returnType().type(), true, true, false, false), f.body(), new RuntimeTypeExpander(f.returnType().type()), f.position().nameAndLineString()).expand(tr2); } public void visit(AtExpr_c f) { Translator tr2 = ((X10Translator) tr).inInnerClass(true); - new Template("AtExpr", f.place(), new TypeExpander(f.returnType().type(), true, true, false, false), f.body(), new RuntimeTypeExpander(f.returnType().type())).expand(tr2); + new Template("AtExpr", f.place(), new TypeExpander(f.returnType().type(), true, true, false, false), f.body(), new RuntimeTypeExpander(f.returnType().type()), f.position().nameAndLineString()).expand(tr2); } public void visit(Formal_c f) { @@ -2585,7 +2587,8 @@ new Join("\n", new Join("\n", l.locals()), l.body()), processClocks(l), new Join("\n", l.locals()), - new TypeExpander(l.formal().type().type(), PRINT_TYPE_PARAMS | BOX_PRIMITIVES) + new TypeExpander(l.formal().type().type(), PRINT_TYPE_PARAMS | BOX_PRIMITIVES), + l.position().nameAndLineString() ).expand(tr2); } Modified: trunk/x10.runtime.17/src-x10/x10/runtime/Activity.x10 =================================================================== --- trunk/x10.runtime.17/src-x10/x10/runtime/Activity.x10 2008-11-18 21:28:23 UTC (rev 6841) +++ trunk/x10.runtime.17/src-x10/x10/runtime/Activity.x10 2008-11-18 21:51:49 UTC (rev 6842) @@ -13,14 +13,14 @@ /** * @author tardieu */ -class Activity(clockPhases:ClockPhases, finishStack:Stack[FinishState]) { +class Activity(clockPhases:ClockPhases, finishStack:Stack[FinishState], name:String) { private val body:()=>Void; /** * Create an activity. */ - def this(body:()=>Void, state:FinishState) { - property(new ClockPhases(), new Stack[FinishState]()); + def this(body:()=>Void, state:FinishState, name:String) { + property(new ClockPhases(), new Stack[FinishState](), name); this.body = body; finishStack.push(state); } @@ -28,8 +28,8 @@ /** * Create a clocked activity. */ - def this(body:()=>Void, state:FinishState, clocks:ValRail[Clock_c], phases:ValRail[Int]) { - this(body, state); + def this(body:()=>Void, state:FinishState, clocks:ValRail[Clock_c], phases:ValRail[Int], name:String) { + this(body, state, name); clockPhases.register(clocks, phases); } @@ -45,4 +45,6 @@ clockPhases.drop(); finishStack.peek().notifySubActivityTermination(); } + + public def toString():String = name; } Modified: trunk/x10.runtime.17/src-x10/x10/runtime/Future_c.x10 =================================================================== --- trunk/x10.runtime.17/src-x10/x10/runtime/Future_c.x10 2008-11-18 21:28:23 UTC (rev 6841) +++ trunk/x10.runtime.17/src-x10/x10/runtime/Future_c.x10 2008-11-18 21:51:49 UTC (rev 6842) @@ -15,7 +15,7 @@ * The representation of an X10 future expression. * @author tardieu */ -public value Future_c[T] extends Future[T] { +public value Future_c[T](name:String) extends Future[T] { /** * CountDownLatch for signaling and wait -- can be replaced by a boolean latch */ @@ -31,7 +31,8 @@ private val eval:()=>T; - public def this(eval:()=>T) { + public def this(eval:()=>T, name:String) { + property(name); this.eval = eval; result = new GrowableRail[T](); } @@ -63,5 +64,7 @@ } finally { cdl.countDown(); } - } + } + + public def toString():String = name; } Modified: trunk/x10.runtime.17/src-x10/x10/runtime/Runtime.x10 =================================================================== --- trunk/x10.runtime.17/src-x10/x10/runtime/Runtime.x10 2008-11-18 21:28:23 UTC (rev 6841) +++ trunk/x10.runtime.17/src-x10/x10/runtime/Runtime.x10 2008-11-18 21:51:49 UTC (rev 6842) @@ -66,7 +66,7 @@ // temporary: printStackTrace call moved to Main template (native code) // try { val state = new FinishState(); - val activity = new Activity(body, state); + val activity = new Activity(body, state, "root"); Thread.currentThread().activity(activity); state.notifySubActivitySpawn(); activity.run(); @@ -103,21 +103,21 @@ /** * Run async */ - public static def runAsync(place:Place, clocks:ValRail[Clock_c], body:()=>Void):Void { + public static def runAsync(place:Place, clocks:ValRail[Clock_c], body:()=>Void, name:String):Void { at (current().location) { val state = current().finishStack.peek(); val phases = Rail.makeVal[Int](clocks.length, (i:Nat)=>clocks(i).phase_c()); state.notifySubActivitySpawn(); - at (place) pool.execute(new Activity(body, state, clocks, phases)); + at (place) pool.execute(new Activity(body, state, clocks, phases, name)); } } /** * Eval future expression */ - public static def evalFuture[T](place:Place, eval:()=>T):Future[T] { + public static def evalFuture[T](place:Place, eval:()=>T, name:String):Future[T] { return at (place) { - val futur = new Future_c[T](eval); + val futur = new Future_c[T](eval, name); async futur.run(); futur }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |