Bug 1204028: Evaluate LHS reference before RHS in destructuring

Issue #73
[Depends on] Bug 1147371: Implement IteratorClose
This commit is contained in:
janekptacijarabaci 2018-03-20 12:40:00 +01:00 committed by Roy Tam
commit 2f27d8433c
11 changed files with 1743 additions and 97 deletions

View file

@ -1147,7 +1147,7 @@ BaselineCompiler::emit_JSOP_PICK()
// after : A B D E C
// First, move value at -(amount + 1) into R0.
int depth = -(GET_INT8(pc) + 1);
int32_t depth = -(GET_INT8(pc) + 1);
masm.loadValue(frame.addressOfStackValue(frame.peek(depth)), R0);
// Move the other values down.
@ -1165,6 +1165,34 @@ BaselineCompiler::emit_JSOP_PICK()
return true;
}
bool
BaselineCompiler::emit_JSOP_UNPICK()
{
frame.syncStack(0);
// Pick takes the top of the stack value and moves it under the nth value.
// For instance, unpick 2:
// before: A B C D E
// after : A B E C D
// First, move value at -1 into R0.
masm.loadValue(frame.addressOfStackValue(frame.peek(-1)), R0);
// Move the other values up.
int32_t depth = -(GET_INT8(pc) + 1);
for (int32_t i = -1; i > depth; i--) {
Address source = frame.addressOfStackValue(frame.peek(i - 1));
Address dest = frame.addressOfStackValue(frame.peek(i));
masm.loadValue(source, R1);
masm.storeValue(R1, dest);
}
// Store R0 under the nth value.
Address dest = frame.addressOfStackValue(frame.peek(depth));
masm.storeValue(R0, dest);
return true;
}
bool
BaselineCompiler::emit_JSOP_GOTO()
{