Skip to content
This repository
Browse code

Regression bugfix: a pausable method without pausable calls was gener…

…ating incorrect code
  • Loading branch information...
commit e58f97924f1ff540b8896881f3f471a0dcdbe5b0 1 parent bf6da33
Sriram Srinivasan authored
2  src/kilim/Constants.java
@@ -9,7 +9,7 @@
9 9
10 10 public interface Constants extends Opcodes {
11 11
12   - String KILIM_VERSION = "0.7.1";
  12 + String KILIM_VERSION = "0.7.2";
13 13
14 14 // Type descriptors
15 15 String D_BOOLEAN = "Z";
2  src/kilim/analysis/CallWeaver.java
@@ -179,7 +179,7 @@ public CallWeaver(MethodWeaver mw, BasicBlock aBB) {
179 179 resumeLabel = new Label();
180 180 assignRegisters();
181 181 stateClassName = createStateClass();
182   - methodWeaver.ensureMaxStack(getNumBottom() + 2); // Fiber + state
  182 + methodWeaver.ensureMaxStack(getNumBottom() + 3); //
183 183 }
184 184
185 185 /**
4 src/kilim/analysis/MethodWeaver.java
@@ -317,7 +317,9 @@ private void genPrelude(MethodVisitor mv) {
317 317
318 318 mv.visitVarInsn(ALOAD, lastVar);
319 319 if (lastVar < fiberVar) {
320   - mv.visitInsn(DUP); // for storing into fiberVar
  320 + if (callWeavers.size() > 0) {
  321 + mv.visitInsn(DUP); // for storing into fiberVar
  322 + }
321 323 mv.visitVarInsn(ASTORE, getFiberVar());
322 324 }
323 325
41 test/kilim/test/TestMailbox.java
@@ -60,7 +60,21 @@ public void run() {
60 60 assertTrue(mb.getnb() == null);
61 61 }
62 62
63   - public void testSimpleTask() {
  63 + public void testSimpleTask_NotPausing() {
  64 + final int numMsgs = 100;
  65 + Mailbox<Msg> mainmb = new Mailbox<Msg>();
  66 +
  67 + for (int i = 0; i < numMsgs ; i++) {
  68 + TaskMB_NoPause t = new TaskMB_NoPause(mainmb, numMsgs);
  69 + t.start();
  70 + }
  71 + for (int i = 0; i < numMsgs ; i++) {
  72 + Msg m = mainmb.getb(1000);
  73 + assertTrue(m.num == i);
  74 + }
  75 + }
  76 +
  77 + public void testSimpleTask_Pausing() {
64 78
65 79 Mailbox<Msg> mainmb = new Mailbox<Msg>();
66 80
@@ -70,7 +84,7 @@ public void testSimpleTask() {
70 84
71 85 for (int i = 0; i < nTasks ; i++) {
72 86 TaskMB t = new TaskMB(mainmb);
73   - t.start();
  87 + t.start();
74 88 t.mymb.putnb(new Msg(i, nTimes));
75 89 }
76 90
@@ -225,6 +239,29 @@ public void execute() throws Pausable {
225 239 }
226 240
227 241
  242 +/**
  243 + * A Task that only makes nonpausing calls.
  244 + * @author s
  245 + */
  246 +class TaskMB_NoPause extends Task {
  247 + Mailbox<Msg> mainmb;
  248 + int numMsgs;
  249 +
  250 + TaskMB_NoPause(Mailbox<Msg> ms, int numMsgs) {
  251 + mainmb = ms;
  252 + this.numMsgs = numMsgs;
  253 + }
  254 +
  255 + public void execute() throws Pausable {
  256 + int n = numMsgs;
  257 +
  258 + for (int i = 0; i < n; i++) {
  259 + mainmb.putnb(new Msg(id, i));
  260 + }
  261 + }
  262 +}
  263 +
  264 +
228 265
229 266 class SelectTaskMB extends Task {
230 267 Mailbox<Msg> mymb1, mymb2;

0 comments on commit e58f979

Please sign in to comment.
Something went wrong with that request. Please try again.