Bug 876454 - Implement JSOP_LEAVEBLOCKEXPR and JSOP_LEAVEFORLETIN in the baseline compiler. r=evilpie
--- a/js/src/ion/BaselineCompiler.cpp
+++ b/js/src/ion/BaselineCompiler.cpp
@@ -2345,30 +2345,59 @@ BaselineCompiler::emit_JSOP_ENTERLET1()
{
return emitEnterBlock();
}
typedef bool (*LeaveBlockFn)(JSContext *, BaselineFrame *);
static const VMFunction LeaveBlockInfo = FunctionInfo<LeaveBlockFn>(ion::LeaveBlock);
bool
-BaselineCompiler::emit_JSOP_LEAVEBLOCK()
+BaselineCompiler::emitLeaveBlock()
{
// Call a stub to pop the block from the block chain.
prepareVMCall();
masm.loadBaselineFramePtr(BaselineFrameReg, R0.scratchReg());
pushArg(R0.scratchReg());
- if (!callVM(LeaveBlockInfo))
+ return callVM(LeaveBlockInfo);
+}
+
+bool
+BaselineCompiler::emit_JSOP_LEAVEBLOCK()
+{
+ if (!emitLeaveBlock())
return false;
- // Pop slots pushed by ENTERBLOCK.
- size_t n = StackUses(script, pc);
- frame.popn(n);
+ // Pop slots pushed by JSOP_ENTERBLOCK.
+ frame.popn(GET_UINT16(pc));
+ return true;
+}
+
+bool
+BaselineCompiler::emit_JSOP_LEAVEBLOCKEXPR()
+{
+ if (!emitLeaveBlock())
+ return false;
+
+ // Pop slots pushed by JSOP_ENTERBLOCK, but leave the topmost value
+ // on the stack.
+ frame.popRegsAndSync(1);
+ frame.popn(GET_UINT16(pc));
+ frame.push(R0);
+ return true;
+}
+
+bool
+BaselineCompiler::emit_JSOP_LEAVEFORLETIN()
+{
+ if (!emitLeaveBlock())
+ return false;
+
+ // Another op will pop the slots (after the enditer).
return true;
}
typedef bool (*GetAndClearExceptionFn)(JSContext *, MutableHandleValue);
static const VMFunction GetAndClearExceptionInfo =
FunctionInfo<GetAndClearExceptionFn>(GetAndClearException);
bool
--- a/js/src/ion/BaselineCompiler.h
+++ b/js/src/ion/BaselineCompiler.h
@@ -150,16 +150,18 @@ namespace ion {
_(JSOP_TYPEOFEXPR) \
_(JSOP_SETCALL) \
_(JSOP_THROW) \
_(JSOP_TRY) \
_(JSOP_ENTERBLOCK) \
_(JSOP_ENTERLET0) \
_(JSOP_ENTERLET1) \
_(JSOP_LEAVEBLOCK) \
+ _(JSOP_LEAVEBLOCKEXPR) \
+ _(JSOP_LEAVEFORLETIN) \
_(JSOP_EXCEPTION) \
_(JSOP_DEBUGGER) \
_(JSOP_ARGUMENTS) \
_(JSOP_RUNONCE) \
_(JSOP_REST) \
_(JSOP_TOID) \
_(JSOP_TABLESWITCH) \
_(JSOP_ITER) \
@@ -245,16 +247,17 @@ class BaselineCompiler : public Baseline
bool emitCall();
bool emitInitPropGetterSetter();
bool emitInitElemGetterSetter();
bool emitFormalArgAccess(uint32_t arg, bool get);
bool emitEnterBlock();
+ bool emitLeaveBlock();
bool addPCMappingEntry(bool addIndexEntry);
void getScopeCoordinateObject(Register reg);
Address getScopeCoordinateAddressFromObject(Register objReg, Register reg);
Address getScopeCoordinateAddress(Register reg);
};