Bug 999358 - Fix MLambdaArrow to initialize the unused extended slot too. r=terrence

This commit is contained in:
Jan de Mooij 2014-04-23 11:31:43 +02:00
parent ad74eb79fd
commit ce2ec33fdf
2 changed files with 13 additions and 3 deletions

View File

@ -1012,9 +1012,12 @@ CodeGenerator::visitLambdaArrow(LLambdaArrow *lir)
emitLambdaInit(output, scopeChain, info);
// Store the lexical |this| value.
// Initialize extended slots. Lexical |this| is stored in the first one.
MOZ_ASSERT(info.flags & JSFunction::EXTENDED);
masm.storeValue(thisv, Address(output, FunctionExtended::offsetOfArrowThisSlot()));
static_assert(FunctionExtended::NUM_EXTENDED_SLOTS == 2, "All slots must be initialized");
static_assert(FunctionExtended::ARROW_THIS_SLOT == 0, "|this| must be stored in first slot");
masm.storeValue(thisv, Address(output, FunctionExtended::offsetOfExtendedSlot(0)));
masm.storeValue(UndefinedValue(), Address(output, FunctionExtended::offsetOfExtendedSlot(1)));
masm.bind(ool->rejoin());
return true;

View File

@ -544,8 +544,15 @@ class FunctionExtended : public JSFunction
public:
static const unsigned NUM_EXTENDED_SLOTS = 2;
/* Arrow functions store their lexical |this| in the first extended slot. */
static const unsigned ARROW_THIS_SLOT = 0;
static inline size_t offsetOfExtendedSlot(unsigned which) {
MOZ_ASSERT(which < NUM_EXTENDED_SLOTS);
return offsetof(FunctionExtended, extendedSlots) + which * sizeof(HeapValue);
}
static inline size_t offsetOfArrowThisSlot() {
return offsetof(FunctionExtended, extendedSlots) + 0 * sizeof(HeapValue);
return offsetOfExtendedSlot(ARROW_THIS_SLOT);
}
private: