local variables not restored after yield inside loop #8

nqzero opened this Issue Oct 5, 2011 · 1 comment

2 participants


local variables aren't restored properly if the last instruction in a loop calls a Pausable method. eg:

public static String dummy() throws Pausable {
    return "xxxxxxx";
public static class FoodTask extends Task {
    public String [] foods = new String[10];
    public void execute() throws Pausable {
        for (int ii = 0; ii < foods.length; ii++) foods[ii] = dummy();
public static void main(String[] args) throws Exception {
    FoodTask ft = new FoodTask();
    Mailbox<ExitMsg> exitmb = new Mailbox<ExitMsg>();
    for (String food : ft.foods) System.out.format( "food: %s\n", food );

after the task completes, only foods[0] is non-null. variable ii is not being restored before assigning the result of the dummy() call. a workaround is to assign result of the pausable method to a temp variable, and then assign that to the array

@kilim kilim added a commit that referenced this issue Oct 5, 2011
@kilim Resolution to github issue #8.
Problem: In Frame.merge the operand stacks were being examined pointwise for differences, but due to an incorrect comparison, the analysis assumed that the stack had not changed.

TestYield/ExLoop are the relevant unit test and example code to exercise this functionality.

	modified:   .classpath
	modified:   src/kilim/analysis/Frame.java
	modified:   src/kilim/analysis/Usage.java
	modified:   src/kilim/tools/Asm.java
	modified:   src/kilim/tools/P.java
	modified:   test/kilim/test/TestYield.java
	new file:   test/kilim/test/ex/ExLoop.java
	modified:   test/kilim/test/ex/ExYieldStack.java

Fixed in commit 1b54ce9

@kilim kilim closed this Oct 5, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment