Changeset 3373
- Timestamp:
- 02/05/09 11:00:25 (10 months ago)
- Location:
- trunk
- Files:
-
- 8 modified
-
ProjectFortress/src/com/sun/fortress/interpreter/evaluator/Evaluator.java (modified) (5 diffs)
-
ProjectFortress/src/com/sun/fortress/interpreter/evaluator/tasks/BaseTask.java (modified) (1 diff)
-
ProjectFortress/src/com/sun/fortress/interpreter/evaluator/tasks/FortressTaskRunner.java (modified) (2 diffs)
-
ProjectFortress/src/com/sun/fortress/interpreter/evaluator/tasks/FortressTaskRunnerGroup.java (modified) (1 diff)
-
ProjectFortress/src/com/sun/fortress/interpreter/evaluator/tasks/TupleTask.java (modified) (3 diffs)
-
ProjectFortress/src/com/sun/fortress/tests/unit_tests/TestTask.java (modified) (2 diffs)
-
ProjectFortress/third_party/jsr166y/jsr166y.jar (modified) (previous)
-
README.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ProjectFortress/src/com/sun/fortress/interpreter/evaluator/Evaluator.java
r3272 r3373 235 235 // We ask lhs to accept twice (with this and an LHSEvaluator) in 236 236 // the operator case. Might this cause the world to break? 237 237 238 public FValue forAssignment(Assignment x) { 238 239 Option<FunctionalRef> possOp = x.getAssignOp(); … … 356 357 357 358 public FValue forDo(Do x) { 359 FValue res; 358 360 int s = x.getFronts().size(); 361 System.out.println("forDo with s = " + s + " x = " + x); 362 359 363 if (s == 0) return FVoid.V; 360 364 if (s == 1) { … … 364 368 FValue region = regionExp.accept(this); 365 369 } 366 if (f.isAtomicBlock()) 367 return forAtomicExpr(ExprFactory.makeAtomicExpr(NodeUtil.getSpan(x), f)); 368 return f.accept(new Evaluator(this)); 370 if (f.isAtomicBlock()) { 371 res = forAtomicExpr(ExprFactory.makeAtomicExpr(NodeUtil.getSpan(x), f)); 372 } else { 373 res = f.accept(new Evaluator(this)); 374 } 375 return res; 369 376 } 370 377 371 TupleTask[] tasks = new TupleTask[s]; 372 List<Expr> locs = new ArrayList<Expr>(0); 373 for (int i = 0; i < s; i++) { 374 Block f = x.getFronts().get(i); 375 if (f.getLoc().isSome()) { 376 locs.add(f.getLoc().unwrap()); 377 } 378 if (f.isAtomicBlock()) 379 tasks[i] = new TupleTask(ExprFactory.makeAtomicExpr(NodeUtil.getSpan(x), f), this); 380 else 381 tasks[i] = new TupleTask(f, new Evaluator(this)); 382 } 383 if (locs.size()>0) { 384 List<FValue> regions = evalExprListParallel(locs); 385 } 386 BaseTask currentTask = FortressTaskRunner.getTask(); 387 TupleTask.forkJoin(tasks); 388 FortressTaskRunner.setCurrentTask(currentTask); 389 390 for (int i = 0; i < s; i++) { 391 if (tasks[i].causedException()) { 392 Throwable t = tasks[i].taskException(); 393 if (t instanceof Error) { 394 throw (Error)t; 395 } else if (t instanceof RuntimeException) { 396 throw (RuntimeException)t; 397 } else { 398 error(x.getFronts().get(i), errorMsg("Wrapped Exception",t)); 399 } 400 } 401 } 378 List<TupleTask> tasks = new ArrayList<TupleTask>(); 379 380 for (int i = 0; i < s; i++) { 381 Block f = x.getFronts().get(i); 382 383 if (f.getLoc().isSome()) { 384 Expr regionExp = f.getLoc().unwrap(); 385 FValue region = regionExp.accept(this); 386 } 387 if (f.isAtomicBlock()) 388 tasks.add(new TupleTask(ExprFactory.makeAtomicExpr(NodeUtil.getSpan(x), f), this)); 389 else { 390 tasks.add(new TupleTask(f, new Evaluator(this))); 391 } 392 } 393 394 BaseTask currentTask = FortressTaskRunner.getTask(); 395 TupleTask.invokeAll(tasks); 396 FortressTaskRunner.setCurrentTask(currentTask); 397 398 for (TupleTask t : tasks) { 399 if (t.causedException()) { 400 Throwable th = t.taskException(); 401 if (th instanceof Error) { 402 throw (Error)th; 403 } else if (th instanceof RuntimeException) { 404 throw (RuntimeException)th; 405 } else { 406 error(t.getExpr(), errorMsg("Wrapped Exception",th)); 407 } 408 } 409 } 402 410 return FVoid.V; 403 411 } … … 466 474 int sz = exprs.size(); 467 475 ArrayList<FValue> resList = new ArrayList<FValue>(sz); 468 476 ArrayList<TupleTask> TupleTasks = new ArrayList<TupleTask>(sz); 469 477 if (sz==1) { 470 478 resList.add(exprs.get(0).accept(this)); 471 479 } else if (sz > 1) { 472 TupleTask[] tasks = new TupleTask[exprs.size()]; 473 int count = 0; 474 for (Expr e : exprs) { 475 tasks[count++] = new TupleTask(e, this); 476 } 480 for (Expr expr : exprs) 481 // We want to add things to the front of the list. 482 TupleTasks.add(0, new TupleTask(expr, this)); 483 477 484 BaseTask currentTask = FortressTaskRunner.getTask(); 478 TupleTask. forkJoin(tasks);485 TupleTask.invokeAll(TupleTasks); 479 486 FortressTaskRunner.setCurrentTask(currentTask); 480 for (int i = 0; i < count; i++) { 481 if (tasks[i].causedException()) { 482 Throwable t = tasks[i].taskException(); 487 488 for (TupleTask task : TupleTasks) { 489 if (task.causedException()) { 490 Throwable t = task.taskException(); 483 491 if (t instanceof Error) { 484 492 throw (Error)t; … … 486 494 throw (RuntimeException)t; 487 495 } else { 488 error(exprs.get(i), errorMsg("Wrapped Exception",t));496 error(task.getExpr(), errorMsg("Wrapped Exception",t)); 489 497 } 490 498 } 491 resList.add(tasks[i].getRes()); 492 } 493 } 499 resList.add(0,task.getRes()); 500 } 501 } 502 503 if (resList.size() != exprs.size()) 504 bug("We should have the same number of results as we did exprs resList = " + 505 resList + " exprs = " + exprs ); 494 506 return resList; 495 507 } -
trunk/ProjectFortress/src/com/sun/fortress/interpreter/evaluator/tasks/BaseTask.java
r2692 r3373 18 18 package com.sun.fortress.interpreter.evaluator.tasks; 19 19 20 import jsr166y. forkjoin.*;20 import jsr166y.*; 21 21 import java.util.concurrent.atomic.AtomicInteger; 22 22 -
trunk/ProjectFortress/src/com/sun/fortress/interpreter/evaluator/tasks/FortressTaskRunner.java
r2794 r3373 18 18 package com.sun.fortress.interpreter.evaluator.tasks; 19 19 20 import jsr166y. forkjoin.*;20 import jsr166y.*; 21 21 import com.sun.fortress.exceptions.FortressError; 22 22 import com.sun.fortress.exceptions.transactions.AbortedException; … … 144 144 // Someday figure out how aborted transactions get this far... 145 145 Transaction me = getTransaction(); 146 if (me != null && !me.isActive()) 146 if (me != null && !me.isActive()) { 147 147 throw new AbortedException(me, "Got to doit with an aborted current transaction"); 148 } 148 149 try { 149 150 T result = doItOnce(xaction); -
trunk/ProjectFortress/src/com/sun/fortress/interpreter/evaluator/tasks/FortressTaskRunnerGroup.java
r1331 r3373 18 18 package com.sun.fortress.interpreter.evaluator.tasks; 19 19 20 import jsr166y. forkjoin.*;20 import jsr166y.*; 21 21 22 22 public class FortressTaskRunnerGroup extends ForkJoinPool { -
trunk/ProjectFortress/src/com/sun/fortress/interpreter/evaluator/tasks/TupleTask.java
r2794 r3373 18 18 package com.sun.fortress.interpreter.evaluator.tasks; 19 19 20 import jsr166y. forkjoin.ForkJoinWorkerThread;20 import jsr166y.ForkJoinWorkerThread; 21 21 import com.sun.fortress.interpreter.evaluator.Evaluator; 22 22 import com.sun.fortress.interpreter.evaluator.Environment; … … 67 67 68 68 public FValue getRes() { return res;} 69 public Expr getExpr() {return expr;} 70 71 // Commented out because not supported in new jsr166y library. 69 72 70 73 // This is a static method of jsr166y.forkjoin.RecursiveAction, … … 74 77 // Actual code cribbed from jsr166y.forkjoin.ForkJoinTask. 75 78 // However we rely on the invariant that the TupleTasks are all non-null. 76 public static void forkJoin(TupleTask []tasks) {77 if (true) { // switch to false for standard version.78 int last = tasks.length - 1;79 Throwable ex = null;80 for (int i = last; i > 0; --i) {81 tasks[i].fork();82 }83 ex = tasks[0].exec();84 for (int i = 1; i <= last; ++i) {85 TupleTask t = tasks[i];86 boolean pop = ForkJoinWorkerThread.removeIfNextLocalTask(t);87 if (ex != null)88 t.cancel();89 else if (!pop)90 ex = t.quietlyJoin();91 else92 ex = t.exec();93 }94 if (ex != null)95 bug(ex);96 } else {97 BaseTask.forkJoin(tasks);98 }99 }79 // public static void forkJoin(TupleTask []tasks) { 80 // if (true) { // switch to false for standard version. 81 // int last = tasks.length - 1; 82 // Throwable ex = null; 83 // for (int i = last; i > 0; --i) { 84 // tasks[i].fork(); 85 // } 86 // ex = tasks[0].exec(); 87 // for (int i = 1; i <= last; ++i) { 88 // TupleTask t = tasks[i]; 89 // boolean pop = ForkJoinWorkerThread.removeIfNextLocalTask(t); 90 // if (ex != null) 91 // t.cancel(); 92 // else if (!pop) 93 // ex = t.quietlyJoin(); 94 // else 95 // ex = t.exec(); 96 // } 97 // if (ex != null) 98 // bug(ex); 99 // } else { 100 // BaseTask.forkJoin(tasks); 101 // } 102 // } 100 103 } -
trunk/ProjectFortress/src/com/sun/fortress/tests/unit_tests/TestTask.java
r2449 r3373 34 34 Assert.assertEquals(rs1.size(), 1); 35 35 36 36 37 // Verify that multiple threads adding to a readset don't stomp on each other. 37 38 ReadSet rs2 = new ReadSet(); … … 44 45 } 45 46 46 TestTask2.forkJoin(tasks);47 Assert.assertEquals(rs2.size(), taskcount * transcount);47 // TestTask2.forkJoin(tasks); 48 // Assert.assertEquals(rs2.size(), taskcount * transcount); 48 49 } 49 50 -
trunk/README.txt
r3322 r3373 107 107 will need to have access to the following: 108 108 109 * J2SDK 1. 5or later. See http://java.sun.com/javase/downloads/index.jsp109 * J2SDK 1.6 or later. See http://java.sun.com/javase/downloads/index.jsp 110 110 * Ant 1.6.5 or later. See http://ant.apache.org/bindownload.cgi 111 111 * Bash version 2.5 or later, installed at /bin/bash.

