Skip to content

Commit

Permalink
Revert "Remove Icode_SWAP as it was unused"
Browse files Browse the repository at this point in the history
This reverts commit b845d14.
  • Loading branch information
andreabergia committed Nov 27, 2024
1 parent b5a3170 commit b45336f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
7 changes: 6 additions & 1 deletion rhino/src/main/java/org/mozilla/javascript/Icode.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@ abstract class Icode {
// Stack: ... value2 value1 -> ... value2 value1 value2 value1
Icode_DUP2 = Icode_DUP - 1,

// Stack: ... value2 value1 -> ... value1 value2
Icode_SWAP = Icode_DUP2 - 1,

// Stack: ... value1 -> ...
Icode_POP = Icode_DUP2 - 1,
Icode_POP = Icode_SWAP - 1,

// Store stack top into return register and then pop it
Icode_POP_RESULT = Icode_POP - 1,
Expand Down Expand Up @@ -179,6 +182,8 @@ static String bytecodeName(int bytecode) {
return "DUP";
case Icode_DUP2:
return "DUP2";
case Icode_SWAP:
return "SWAP";
case Icode_POP:
return "POP";
case Icode_POP_RESULT:
Expand Down
10 changes: 10 additions & 0 deletions rhino/src/main/java/org/mozilla/javascript/Interpreter.java
Original file line number Diff line number Diff line change
Expand Up @@ -1539,6 +1539,16 @@ private static Object interpretLoop(Context cx, CallFrame frame, Object throwabl
sDbl[stackTop + 2] = sDbl[stackTop];
stackTop += 2;
continue Loop;
case Icode_SWAP:
{
Object o = stack[stackTop];
stack[stackTop] = stack[stackTop - 1];
stack[stackTop - 1] = o;
double d = sDbl[stackTop];
sDbl[stackTop] = sDbl[stackTop - 1];
sDbl[stackTop - 1] = d;
continue Loop;
}
case Token.RETURN:
frame.result = stack[stackTop];
frame.resultDbl = sDbl[stackTop];
Expand Down

0 comments on commit b45336f

Please sign in to comment.