diff --git a/js/src/jit-test/tests/class/bug1720032-1.js b/js/src/jit-test/tests/class/bug1720032-1.js new file mode 100644 index 000000000000..551c66d903de --- /dev/null +++ b/js/src/jit-test/tests/class/bug1720032-1.js @@ -0,0 +1,27 @@ +function main() { + class Base {} + + class Derived extends Base { + constructor() { + super(); + + let v = 0xffff; + + try { + // Ensure this statement doesn't get DCE'ed. + v &= 0xff; + + // Returning a primitive value throws. + return 0; + } catch {} + + assertEq(v, 255); + } + } + + for (let i = 0; i < 15; i++) { + new Derived(); + } +} +main(); +main(); diff --git a/js/src/jit-test/tests/class/bug1720032-2.js b/js/src/jit-test/tests/class/bug1720032-2.js new file mode 100644 index 000000000000..7ca7a8df06d7 --- /dev/null +++ b/js/src/jit-test/tests/class/bug1720032-2.js @@ -0,0 +1,27 @@ +function main() { + class Base {} + + class Derived extends Base { + constructor() { + let v = 0xffff; + + try { + // Ensure this statement doesn't get DCE'ed. + v &= 0xff; + + // Accessing |this| throws when |super()| wasn't yet called. + this; + } catch {} + + assertEq(v, 255); + + super(); + } + } + + for (let i = 0; i < 15; i++) { + new Derived(); + } +} +main(); +main(); diff --git a/js/src/jit-test/tests/class/bug1720032-3.js b/js/src/jit-test/tests/class/bug1720032-3.js new file mode 100644 index 000000000000..e087e8e0f8ed --- /dev/null +++ b/js/src/jit-test/tests/class/bug1720032-3.js @@ -0,0 +1,27 @@ +function main() { + class Base {} + + class Derived extends Base { + constructor() { + super(); + + let v = 0xffff; + + try { + // Ensure this statement doesn't get DCE'ed. + v &= 0xff; + + // Calling |super()| twice throws an error. + super(); + } catch {} + + assertEq(v, 255); + } + } + + for (let i = 0; i < 15; i++) { + new Derived(); + } +} +main(); +main(); diff --git a/js/src/jit/MIR.cpp b/js/src/jit/MIR.cpp index 3eb3e95a7db8..2325fdf9dde5 100644 --- a/js/src/jit/MIR.cpp +++ b/js/src/jit/MIR.cpp @@ -5826,6 +5826,18 @@ AliasSet MCheckObjCoercible::getAliasSet() const { return AliasSet::Store(AliasSet::ExceptionState); } +AliasSet MCheckReturn::getAliasSet() const { + return AliasSet::Store(AliasSet::ExceptionState); +} + +AliasSet MCheckThis::getAliasSet() const { + return AliasSet::Store(AliasSet::ExceptionState); +} + +AliasSet MCheckThisReinit::getAliasSet() const { + return AliasSet::Store(AliasSet::ExceptionState); +} + AliasSet MIsPackedArray::getAliasSet() const { return AliasSet::Load(AliasSet::ObjectFields); } diff --git a/js/src/jit/MIROps.yaml b/js/src/jit/MIROps.yaml index fa4ae72b0d06..c346de394d1e 100644 --- a/js/src/jit/MIROps.yaml +++ b/js/src/jit/MIROps.yaml @@ -1913,7 +1913,7 @@ thisValue: Value result_type: Value guard: true - alias_set: none + alias_set: custom - name: CheckThis operands: @@ -1921,7 +1921,7 @@ result_type: Value guard: true folds_to: custom - alias_set: none + alias_set: custom - name: AsyncResolve operands: @@ -1953,7 +1953,7 @@ result_type: Value guard: true folds_to: custom - alias_set: none + alias_set: custom - name: Generator gen_boilerplate: false diff --git a/js/src/jit/WarpBuilder.cpp b/js/src/jit/WarpBuilder.cpp index 6d6f0905be00..9ec73e7b13b5 100644 --- a/js/src/jit/WarpBuilder.cpp +++ b/js/src/jit/WarpBuilder.cpp @@ -2139,20 +2139,20 @@ bool WarpBuilder::build_CheckClassHeritage(BytecodeLocation loc) { return resumeAfter(ins, loc); } -bool WarpBuilder::build_CheckThis(BytecodeLocation) { +bool WarpBuilder::build_CheckThis(BytecodeLocation loc) { MDefinition* def = current->pop(); auto* ins = MCheckThis::New(alloc(), def); current->add(ins); current->push(ins); - return true; + return resumeAfter(ins, loc); } -bool WarpBuilder::build_CheckThisReinit(BytecodeLocation) { +bool WarpBuilder::build_CheckThisReinit(BytecodeLocation loc) { MDefinition* def = current->pop(); auto* ins = MCheckThisReinit::New(alloc(), def); current->add(ins); current->push(ins); - return true; + return resumeAfter(ins, loc); } bool WarpBuilder::build_Generator(BytecodeLocation loc) { @@ -2401,7 +2401,7 @@ bool WarpBuilder::build_AsyncAwait(BytecodeLocation loc) { return resumeAfter(asyncAwait, loc); } -bool WarpBuilder::build_CheckReturn(BytecodeLocation) { +bool WarpBuilder::build_CheckReturn(BytecodeLocation loc) { MOZ_ASSERT(!script_->noScriptRval()); MDefinition* returnValue = current->getSlot(info().returnValueSlot()); @@ -2410,7 +2410,7 @@ bool WarpBuilder::build_CheckReturn(BytecodeLocation) { auto* ins = MCheckReturn::New(alloc(), returnValue, thisValue); current->add(ins); current->setSlot(info().returnValueSlot(), ins); - return true; + return resumeAfter(ins, loc); } void WarpBuilder::buildCheckLexicalOp(BytecodeLocation loc) {