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
Родитель 5bfcd08a49
Коммит ddce1750e2
2 изменённых файлов: 13 добавлений и 3 удалений

Просмотреть файл

@ -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;

Просмотреть файл

@ -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: