-
-
Save Sunjammer/3cc26143f212c43c6acc5a7899180a75 to your computer and use it in GitHub Desktop.
JS code generation bug?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//stack is an inline property performing array access | |
function popStack():Int | |
{ | |
var v = memory[STACK_OFFSET + stack - 1]; | |
stack--; | |
return v; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//The produced code moves the decrement of stack in a way that makes the return value invalid | |
popStack: function() { | |
this.memory[4] -= 1; | |
return this.memory[384 + this.memory[4] - 1]; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Introducing a trace statement to force order fixes this | |
function popStack():Int | |
{ | |
var v = memory[STACK_OFFSET + stack - 1]; | |
trace("Popping"); | |
stack--; | |
return v; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
popStack: function() { | |
var v = this.memory[384 + this.memory[4] - 1]; | |
console.log("Popping"); | |
this.memory[4] -= 1; | |
return v; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment