Bug 1185957 - Properly handle known derived class constructors in ion. (r=jandem)

This commit is contained in:
Eric Faust 2015-08-19 11:19:46 -07:00
parent 8c3cdc697d
commit 995f19e9f9
3 changed files with 26 additions and 3 deletions

View File

@ -0,0 +1,15 @@
// |jit-test| error: TypeError
load(libdir + "class.js");
var test = `
class test {
constructor() {};
}
(function() {
test()
})();
`;
if (classesEnabled())
eval(test);

View File

@ -3127,15 +3127,21 @@ CodeGenerator::visitCallKnown(LCallKnown* call)
// Native single targets are handled by LCallNative.
MOZ_ASSERT(!target->isNative());
MOZ_ASSERT_IF(target->isClassConstructor(), call->isConstructing());
// Missing arguments must have been explicitly appended by the IonBuilder.
DebugOnly<unsigned> numNonArgsOnStack = 1 + call->isConstructing();
MOZ_ASSERT(target->nargs() <= call->mir()->numStackArgs() - numNonArgsOnStack);
MOZ_ASSERT_IF(call->mir()->isConstructing(), target->isConstructor());
MOZ_ASSERT_IF(call->isConstructing(), target->isConstructor());
masm.checkStackAlignment();
if (target->isClassConstructor() && !call->isConstructing()) {
emitCallInvokeFunction(call, calleereg, call->isConstructing(), call->numActualArgs(), unusedStack);
return;
}
MOZ_ASSERT_IF(target->isClassConstructor(), call->isConstructing());
// The calleereg is known to be a non-native function, but might point to
// a LazyScript instead of a JSScript.
masm.branchIfFunctionHasNoScript(calleereg, &uncompiled);

View File

@ -456,9 +456,11 @@ LIRGenerator::visitCall(MCall* call)
MOZ_ASSERT(ok, "How can we not have four temp registers?");
lir = new(alloc()) LCallDOMNative(tempFixed(cxReg), tempFixed(objReg),
tempFixed(privReg), tempFixed(argsReg));
} else if (target && !(target->isClassConstructor() && !call->isConstructing())) {
} else if (target) {
// Call known functions.
if (target->isNative()) {
MOZ_ASSERT(!target->isClassConstructor());
Register cxReg, numReg, vpReg, tmpReg;
GetTempRegForIntArg(0, 0, &cxReg);
GetTempRegForIntArg(1, 0, &numReg);