tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 5c7c123fbe7a69e1bec07702c50e162d7a34bdc6
parent 19db3bf02015ce95a67727a16b66b9f8023e2363
Author: André Bargull <andre.bargull@gmail.com>
Date:   Wed, 17 Dec 2025 13:42:06 +0000

Bug 2002522 - Part 1: Fix deprecated this capture in js/src. r=spidermonkey-reviewers,jandem

Implicit `this` capture for the `[=]` default capture is deprecated in C++20.

Also see bug 1775161.

Differential Revision: https://phabricator.services.mozilla.com/D274121

Diffstat:
Mjs/src/jit/CodeGenerator.cpp | 304+++++++++++++++++++++++++++++++++++++++++--------------------------------------
Mjs/src/jit/JitScript.cpp | 2+-
Mjs/src/jit/arm/CodeGenerator-arm.cpp | 8++++----
Mjs/src/jit/arm64/CodeGenerator-arm64.cpp | 10+++++-----
Mjs/src/jit/loong64/CodeGenerator-loong64.cpp | 2+-
Mjs/src/jit/mips-shared/CodeGenerator-mips-shared.cpp | 2+-
Mjs/src/jit/riscv64/CodeGenerator-riscv64.cpp | 2+-
Mjs/src/jit/x86-shared/CodeGenerator-x86-shared.cpp | 17+++++++++--------
Mjs/src/jsapi-tests/testGCHooks.cpp | 6+++---
9 files changed, 183 insertions(+), 170 deletions(-)

diff --git a/js/src/jit/CodeGenerator.cpp b/js/src/jit/CodeGenerator.cpp @@ -3222,7 +3222,7 @@ void CodeGenerator::visitRegExpMatcher(LRegExpMatcher* lir) { masm.reserveStack(RegExpReservedStack); - auto* ool = new (alloc()) LambdaOutOfLineCode([=](OutOfLineCode& ool) { + auto* ool = new (alloc()) LambdaOutOfLineCode([=, this](OutOfLineCode& ool) { Register lastIndex = ToRegister(lir->lastIndex()); Register input = ToRegister(lir->string()); Register regexp = ToRegister(lir->regexp()); @@ -3278,7 +3278,7 @@ void CodeGenerator::visitRegExpExecMatch(LRegExpExecMatch* lir) { masm.reserveStack(RegExpReservedStack); - auto* ool = new (alloc()) LambdaOutOfLineCode([=](OutOfLineCode& ool) { + auto* ool = new (alloc()) LambdaOutOfLineCode([=, this](OutOfLineCode& ool) { Register input = ToRegister(lir->string()); Register regexp = ToRegister(lir->regexp()); @@ -3409,7 +3409,7 @@ void CodeGenerator::visitRegExpSearcher(LRegExpSearcher* lir) { masm.reserveStack(RegExpReservedStack); - auto* ool = new (alloc()) LambdaOutOfLineCode([=](OutOfLineCode& ool) { + auto* ool = new (alloc()) LambdaOutOfLineCode([=, this](OutOfLineCode& ool) { Register lastIndex = ToRegister(lir->lastIndex()); Register input = ToRegister(lir->string()); Register regexp = ToRegister(lir->regexp()); @@ -3563,7 +3563,7 @@ void CodeGenerator::visitRegExpExecTest(LRegExpExecTest* lir) { masm.reserveStack(RegExpReservedStack); - auto* ool = new (alloc()) LambdaOutOfLineCode([=](OutOfLineCode& ool) { + auto* ool = new (alloc()) LambdaOutOfLineCode([=, this](OutOfLineCode& ool) { Register input = ToRegister(lir->string()); Register regexp = ToRegister(lir->regexp()); @@ -5697,7 +5697,7 @@ void CodeGenerator::emitElementPostWriteBarrier( return; } - auto* ool = new (alloc()) LambdaOutOfLineCode([=](OutOfLineCode& ool) { + auto* ool = new (alloc()) LambdaOutOfLineCode([=, this](OutOfLineCode& ool) { masm.PushRegsInMask(liveVolatileRegs); if (indexDiff != 0) { @@ -7010,43 +7010,44 @@ void CodeGenerator::emitAllocateSpaceForApply(T* apply, Register calleeReg, !apply->hasSingleTarget() || apply->getSingleTarget()->nargs() > 0; if (canUnderflow) { - auto* ool = new (alloc()) LambdaOutOfLineCode([=](OutOfLineCode& ool) { - // Align the JitFrameLayout on the JitStackAlignment by allocating - // callee->nargs() slots, possibly rounded up to the nearest odd - // number (see below). Leave callee->nargs() in `scratch` for the - // undef loop. - if (apply->hasSingleTarget()) { - uint32_t nargs = apply->getSingleTarget()->nargs(); - uint32_t numSlots = JitStackValueAlignment == 1 ? nargs : nargs | 1; - masm.subFromStackPtr(Imm32((numSlots) * sizeof(Value))); - masm.move32(Imm32(nargs), scratch); - } else { - // `scratch` contains callee->nargs() - if (JitStackValueAlignment > 1) { - masm.orPtr(Imm32(1), scratch); - } - masm.lshiftPtr(Imm32(ValueShift), scratch); - masm.subFromStackPtr(scratch); - - // We need callee->nargs in `scratch`. If we rounded it up - // above, we need to reload it. If we only shifted it, we can - // simply shift it back. - if (JitStackValueAlignment > 1) { - masm.loadFunctionArgCount(calleeReg, scratch); - } else { - masm.rshiftPtr(Imm32(ValueShift), scratch); - } - } - - // Count from callee->nargs() down to argc, storing undefined values. - Label loop; - masm.bind(&loop); - masm.sub32(Imm32(1), scratch); - masm.storeValue(UndefinedValue(), - BaseValueIndex(masm.getStackPointer(), scratch)); - masm.branch32(Assembler::Above, scratch, argcreg, &loop); - masm.jump(ool.rejoin()); - }); + auto* ool = + new (alloc()) LambdaOutOfLineCode([=, this](OutOfLineCode& ool) { + // Align the JitFrameLayout on the JitStackAlignment by allocating + // callee->nargs() slots, possibly rounded up to the nearest odd + // number (see below). Leave callee->nargs() in `scratch` for the + // undef loop. + if (apply->hasSingleTarget()) { + uint32_t nargs = apply->getSingleTarget()->nargs(); + uint32_t numSlots = JitStackValueAlignment == 1 ? nargs : nargs | 1; + masm.subFromStackPtr(Imm32((numSlots) * sizeof(Value))); + masm.move32(Imm32(nargs), scratch); + } else { + // `scratch` contains callee->nargs() + if (JitStackValueAlignment > 1) { + masm.orPtr(Imm32(1), scratch); + } + masm.lshiftPtr(Imm32(ValueShift), scratch); + masm.subFromStackPtr(scratch); + + // We need callee->nargs in `scratch`. If we rounded it up + // above, we need to reload it. If we only shifted it, we can + // simply shift it back. + if (JitStackValueAlignment > 1) { + masm.loadFunctionArgCount(calleeReg, scratch); + } else { + masm.rshiftPtr(Imm32(ValueShift), scratch); + } + } + + // Count from callee->nargs() down to argc, storing undefined values. + Label loop; + masm.bind(&loop); + masm.sub32(Imm32(1), scratch); + masm.storeValue(UndefinedValue(), + BaseValueIndex(masm.getStackPointer(), scratch)); + masm.branch32(Assembler::Above, scratch, argcreg, &loop); + masm.jump(ool.rejoin()); + }); addOutOfLineCode(ool, apply->mir()); oolRejoin = ool->rejoin(); @@ -7133,46 +7134,47 @@ void CodeGenerator::emitAllocateSpaceForConstructAndPushNewTarget( bool canUnderflow = !construct->hasSingleTarget() || construct->getSingleTarget()->nargs() > 0; if (canUnderflow) { - auto* ool = new (alloc()) LambdaOutOfLineCode([=](OutOfLineCode& ool) { - // Align the JitFrameLayout on the JitStackAlignment by allocating - // callee->nargs() slots, rounded down to the nearest odd number (see - // below). Leave callee->nargs() in `scratch` for the undef loop. - if (construct->hasSingleTarget()) { - uint32_t nargs = construct->getSingleTarget()->nargs(); - uint32_t numSlots = - JitStackValueAlignment == 1 ? nargs : ((nargs + 1) & ~1) - 1; - masm.subFromStackPtr(Imm32((numSlots) * sizeof(Value))); - masm.move32(Imm32(nargs), scratch); - } else { - // `scratch` contains callee->nargs() - if (JitStackValueAlignment > 1) { - // Round down to nearest odd number. - masm.addPtr(Imm32(1), scratch); - masm.andPtr(Imm32(~1), scratch); - masm.subPtr(Imm32(1), scratch); - } - masm.lshiftPtr(Imm32(ValueShift), scratch); - masm.subFromStackPtr(scratch); - - // We need callee->nargs in `scratch`. If we rounded it down - // above, we need to reload it. If we only shifted it, we can - // simply shift it back. - if (JitStackValueAlignment > 1) { - masm.loadFunctionArgCount(calleeReg, scratch); - } else { - masm.rshiftPtr(Imm32(ValueShift), scratch); - } - } - - // Count from callee->nargs() down to argc, storing undefined values. - Label loop; - masm.bind(&loop); - masm.sub32(Imm32(1), scratch); - masm.storeValue(UndefinedValue(), - BaseValueIndex(masm.getStackPointer(), scratch)); - masm.branch32(Assembler::Above, scratch, argcreg, &loop); - masm.jump(ool.rejoin()); - }); + auto* ool = + new (alloc()) LambdaOutOfLineCode([=, this](OutOfLineCode& ool) { + // Align the JitFrameLayout on the JitStackAlignment by allocating + // callee->nargs() slots, rounded down to the nearest odd number (see + // below). Leave callee->nargs() in `scratch` for the undef loop. + if (construct->hasSingleTarget()) { + uint32_t nargs = construct->getSingleTarget()->nargs(); + uint32_t numSlots = + JitStackValueAlignment == 1 ? nargs : ((nargs + 1) & ~1) - 1; + masm.subFromStackPtr(Imm32((numSlots) * sizeof(Value))); + masm.move32(Imm32(nargs), scratch); + } else { + // `scratch` contains callee->nargs() + if (JitStackValueAlignment > 1) { + // Round down to nearest odd number. + masm.addPtr(Imm32(1), scratch); + masm.andPtr(Imm32(~1), scratch); + masm.subPtr(Imm32(1), scratch); + } + masm.lshiftPtr(Imm32(ValueShift), scratch); + masm.subFromStackPtr(scratch); + + // We need callee->nargs in `scratch`. If we rounded it down + // above, we need to reload it. If we only shifted it, we can + // simply shift it back. + if (JitStackValueAlignment > 1) { + masm.loadFunctionArgCount(calleeReg, scratch); + } else { + masm.rshiftPtr(Imm32(ValueShift), scratch); + } + } + + // Count from callee->nargs() down to argc, storing undefined values. + Label loop; + masm.bind(&loop); + masm.sub32(Imm32(1), scratch); + masm.storeValue(UndefinedValue(), + BaseValueIndex(masm.getStackPointer(), scratch)); + masm.branch32(Assembler::Above, scratch, argcreg, &loop); + masm.jump(ool.rejoin()); + }); addOutOfLineCode(ool, construct->mir()); oolRejoin = ool->rejoin(); @@ -7975,7 +7977,7 @@ void CodeGenerator::visitCheckOverRecursed(LCheckOverRecursed* lir) { // Since Ion frames exist on the C stack, the stack limit may be // dynamically set by JS_SetThreadStackLimit() and JS_SetNativeStackQuota(). - auto* ool = new (alloc()) LambdaOutOfLineCode([=](OutOfLineCode& ool) { + auto* ool = new (alloc()) LambdaOutOfLineCode([=, this](OutOfLineCode& ool) { // The OOL path is hit if the recursion depth has been exceeded. // Throw an InternalError for over-recursion. @@ -8665,7 +8667,7 @@ void CodeGenerator::visitNewArray(LNewArray* lir) { return; } - auto* ool = new (alloc()) LambdaOutOfLineCode([=](OutOfLineCode& ool) { + auto* ool = new (alloc()) LambdaOutOfLineCode([=, this](OutOfLineCode& ool) { visitNewArrayCallVM(lir); masm.jump(ool.rejoin()); }); @@ -9064,7 +9066,7 @@ void CodeGenerator::visitNewObject(LNewObject* lir) { return; } - auto* ool = new (alloc()) LambdaOutOfLineCode([=](OutOfLineCode& ool) { + auto* ool = new (alloc()) LambdaOutOfLineCode([=, this](OutOfLineCode& ool) { visitNewObjectVMCall(lir); masm.jump(ool.rejoin()); }); @@ -9777,7 +9779,7 @@ void CodeGenerator::visitBoxNonStrictThis(LBoxNonStrictThis* lir) { ValueOperand value = ToValue(lir->value()); Register output = ToRegister(lir->output()); - auto* ool = new (alloc()) LambdaOutOfLineCode([=](OutOfLineCode& ool) { + auto* ool = new (alloc()) LambdaOutOfLineCode([=, this](OutOfLineCode& ool) { Label notNullOrUndefined; { Label isNullOrUndefined; @@ -10238,7 +10240,8 @@ void CodeGenerator::visitWasmCall(LWasmCall* lir) { Label* nullCheckFailed = nullptr; #ifndef WASM_HAS_HEAPREG { - auto* ool = new (alloc()) LambdaOutOfLineCode([=](OutOfLineCode& ool) { + auto* ool = new ( + alloc()) LambdaOutOfLineCode([=, this](OutOfLineCode& ool) { masm.wasmTrap(wasm::Trap::IndirectCallToNull, desc.toTrapSiteDesc()); }); if (lir->isCatchable()) { @@ -11285,7 +11288,7 @@ void CodeGenerator::visitWasmPostWriteBarrierWholeCell( Register value = ToRegister(lir->value()); Register temp = ToRegister(lir->temp0()); MOZ_ASSERT(ToRegister(lir->instance()) == InstanceReg); - auto* ool = new (alloc()) LambdaOutOfLineCode([=](OutOfLineCode& ool) { + auto* ool = new (alloc()) LambdaOutOfLineCode([=, this](OutOfLineCode& ool) { // Skip the barrier if this object was previously added to the store buffer. // We perform this check out of line because in practice the prior guards // eliminate most calls to the barrier. @@ -11326,7 +11329,7 @@ void CodeGenerator::visitWasmPostWriteBarrierEdgeAtIndex( Register index = ToRegister(lir->index()); Register temp = ToRegister(lir->temp0()); MOZ_ASSERT(ToRegister(lir->instance()) == InstanceReg); - auto* ool = new (alloc()) LambdaOutOfLineCode([=](OutOfLineCode& ool) { + auto* ool = new (alloc()) LambdaOutOfLineCode([=, this](OutOfLineCode& ool) { saveLiveVolatile(lir); masm.Push(InstanceReg); int32_t framePushedAfterInstance = masm.framePushed(); @@ -11729,7 +11732,7 @@ void CodeGenerator::visitGuardNumberToIntPtrIndex( return; } - auto* ool = new (alloc()) LambdaOutOfLineCode([=](OutOfLineCode& ool) { + auto* ool = new (alloc()) LambdaOutOfLineCode([=, this](OutOfLineCode& ool) { // Substitute the invalid index with an arbitrary out-of-bounds index. masm.movePtr(ImmWord(-1), output); masm.jump(ool.rejoin()); @@ -15902,7 +15905,7 @@ void CodeGenerator::visitStoreElementHoleT(LStoreElementHoleT* lir) { Register index = ToRegister(lir->index()); Register temp = ToRegister(lir->temp0()); - auto* ool = new (alloc()) LambdaOutOfLineCode([=](OutOfLineCode& ool) { + auto* ool = new (alloc()) LambdaOutOfLineCode([=, this](OutOfLineCode& ool) { Label bail; masm.prepareOOBStoreElement(obj, index, elements, temp, &bail, liveVolatileRegs(lir)); @@ -15941,7 +15944,7 @@ void CodeGenerator::visitStoreElementHoleV(LStoreElementHoleV* lir) { ValueOperand value = ToValue(lir->value()); Register temp = ToRegister(lir->temp0()); - auto* ool = new (alloc()) LambdaOutOfLineCode([=](OutOfLineCode& ool) { + auto* ool = new (alloc()) LambdaOutOfLineCode([=, this](OutOfLineCode& ool) { Label bail; masm.prepareOOBStoreElement(obj, index, elements, temp, &bail, liveVolatileRegs(lir)); @@ -15992,7 +15995,7 @@ void CodeGenerator::visitArrayPush(LArrayPush* lir) { ValueOperand value = ToValue(lir->value()); Register spectreTemp = ToTempRegisterOrInvalid(lir->temp1()); - auto* ool = new (alloc()) LambdaOutOfLineCode([=](OutOfLineCode& ool) { + auto* ool = new (alloc()) LambdaOutOfLineCode([=, this](OutOfLineCode& ool) { Register temp = ToRegister(lir->temp0()); LiveRegisterSet liveRegs = liveVolatileRegs(lir); @@ -17792,7 +17795,7 @@ void CodeGenerator::visitUnboxFloatingPoint(LUnboxFloatingPoint* lir) { // Out-of-line path to convert int32 to double or bailout // if this instruction is fallible. - auto* ool = new (alloc()) LambdaOutOfLineCode([=](OutOfLineCode& ool) { + auto* ool = new (alloc()) LambdaOutOfLineCode([=, this](OutOfLineCode& ool) { ValueOperand value = ToValue(lir->input()); if (lir->mir()->fallible()) { @@ -18069,7 +18072,7 @@ void CodeGenerator::visitLoadElementAndUnbox(LLoadElementAndUnbox* ins) { void CodeGenerator::emitMaybeAtomizeSlot(LInstruction* ins, Register stringReg, Address slotAddr, TypedOrValueRegister dest) { - auto* ool = new (alloc()) LambdaOutOfLineCode([=](OutOfLineCode& ool) { + auto* ool = new (alloc()) LambdaOutOfLineCode([=, this](OutOfLineCode& ool) { // This code is called with a non-atomic string in |stringReg|. // When it returns, |stringReg| contains an unboxed pointer to an // atomized version of that string, and |slotAddr| contains a @@ -18932,7 +18935,7 @@ void CodeGenerator::visitTypeOfV(LTypeOfV* lir) { Label done; - auto* ool = new (alloc()) LambdaOutOfLineCode([=](OutOfLineCode& ool) { + auto* ool = new (alloc()) LambdaOutOfLineCode([=, this](OutOfLineCode& ool) { ValueOperand input = ToValue(lir->input()); Register temp = ToTempUnboxRegister(lir->temp0()); Register output = ToRegister(lir->output()); @@ -19109,7 +19112,7 @@ void CodeGenerator::visitTypeOfIsNonPrimitiveV(LTypeOfIsNonPrimitiveV* lir) { auto* mir = lir->mir(); - auto* ool = new (alloc()) LambdaOutOfLineCode([=](OutOfLineCode& ool) { + auto* ool = new (alloc()) LambdaOutOfLineCode([=, this](OutOfLineCode& ool) { ValueOperand input = ToValue(lir->input()); Register output = ToRegister(lir->output()); Register temp = ToTempUnboxRegister(lir->temp0()); @@ -19170,7 +19173,7 @@ void CodeGenerator::visitTypeOfIsNonPrimitiveO(LTypeOfIsNonPrimitiveO* lir) { auto* mir = lir->mir(); - auto* ool = new (alloc()) LambdaOutOfLineCode([=](OutOfLineCode& ool) { + auto* ool = new (alloc()) LambdaOutOfLineCode([=, this](OutOfLineCode& ool) { Register input = ToRegister(lir->input()); Register output = ToRegister(lir->output()); @@ -20430,7 +20433,7 @@ void CodeGenerator::visitIsCallableO(LIsCallableO* ins) { Register object = ToRegister(ins->object()); Register output = ToRegister(ins->output()); - auto* ool = new (alloc()) LambdaOutOfLineCode([=](OutOfLineCode& ool) { + auto* ool = new (alloc()) LambdaOutOfLineCode([=, this](OutOfLineCode& ool) { emitIsCallableOOL(object, output); masm.jump(ool.rejoin()); }); @@ -20449,7 +20452,7 @@ void CodeGenerator::visitIsCallableV(LIsCallableV* ins) { Label notObject; masm.fallibleUnboxObject(val, temp, &notObject); - auto* ool = new (alloc()) LambdaOutOfLineCode([=](OutOfLineCode& ool) { + auto* ool = new (alloc()) LambdaOutOfLineCode([=, this](OutOfLineCode& ool) { emitIsCallableOOL(temp, output); masm.jump(ool.rejoin()); }); @@ -20468,7 +20471,7 @@ void CodeGenerator::visitIsConstructor(LIsConstructor* ins) { Register object = ToRegister(ins->object()); Register output = ToRegister(ins->output()); - auto* ool = new (alloc()) LambdaOutOfLineCode([=](OutOfLineCode& ool) { + auto* ool = new (alloc()) LambdaOutOfLineCode([=, this](OutOfLineCode& ool) { saveVolatile(output); using Fn = bool (*)(JSObject* obj); masm.setupAlignedABICall(); @@ -20963,7 +20966,7 @@ void CodeGenerator::visitInterruptCheck(LInterruptCheck* lir) { void CodeGenerator::visitWasmInterruptCheck(LWasmInterruptCheck* lir) { MOZ_ASSERT(gen->compilingWasm()); - auto* ool = new (alloc()) LambdaOutOfLineCode([=](OutOfLineCode& ool) { + auto* ool = new (alloc()) LambdaOutOfLineCode([=, this](OutOfLineCode& ool) { emitResumableWasmTrapOOL(lir, masm.framePushed(), lir->mir()->trapSiteDesc(), wasm::Trap::CheckInterrupt); @@ -20990,7 +20993,7 @@ void CodeGenerator::visitWasmRefAsNonNull(LWasmRefAsNonNull* lir) { Label nonNull; Register ref = ToRegister(lir->ref()); - auto* ool = new (alloc()) LambdaOutOfLineCode([=](OutOfLineCode& ool) { + auto* ool = new (alloc()) LambdaOutOfLineCode([=, this](OutOfLineCode& ool) { masm.wasmTrap(wasm::Trap::NullPointerDereference, mir->trapSiteDesc()); }); addOutOfLineCode(ool, mir); @@ -21087,7 +21090,7 @@ void CodeGenerator::visitWasmRefCastAbstract(LWasmRefCastAbstract* ins) { Register scratch1 = ToTempRegisterOrInvalid(ins->temp0()); Register scratch2 = Register::Invalid(); MOZ_ASSERT(ref == ToRegister(ins->output())); - auto* ool = new (alloc()) LambdaOutOfLineCode([=](OutOfLineCode& ool) { + auto* ool = new (alloc()) LambdaOutOfLineCode([=, this](OutOfLineCode& ool) { masm.wasmTrap(wasm::Trap::BadCast, mir->trapSiteDesc()); }); addOutOfLineCode(ool, ins->mir()); @@ -21112,7 +21115,7 @@ void CodeGenerator::visitWasmRefCastConcrete(LWasmRefCastConcrete* ins) { Register scratch1 = ToRegister(ins->temp0()); Register scratch2 = ToTempRegisterOrInvalid(ins->temp1()); MOZ_ASSERT(ref == ToRegister(ins->output())); - auto* ool = new (alloc()) LambdaOutOfLineCode([=](OutOfLineCode& ool) { + auto* ool = new (alloc()) LambdaOutOfLineCode([=, this](OutOfLineCode& ool) { masm.wasmTrap(wasm::Trap::BadCast, mir->trapSiteDesc()); }); addOutOfLineCode(ool, ins->mir()); @@ -21197,12 +21200,13 @@ void CodeGenerator::visitWasmNewStructObject(LWasmNewStructObject* lir) { Register instance = ToRegister(lir->instance()); MOZ_ASSERT(instance == InstanceReg); - auto* ool = new (alloc()) LambdaOutOfLineCode([=](OutOfLineCode& ool) { - masm.move32(Imm32(typeDefIndex), temp); - callWasmStructAllocFun(lir, fun, temp, allocSite, output, - mir->trapSiteDesc()); - masm.jump(ool.rejoin()); - }); + auto* ool = + new (alloc()) LambdaOutOfLineCode([=, this](OutOfLineCode& ool) { + masm.move32(Imm32(typeDefIndex), temp); + callWasmStructAllocFun(lir, fun, temp, allocSite, output, + mir->trapSiteDesc()); + masm.jump(ool.rejoin()); + }); addOutOfLineCode(ool, lir->mir()); size_t offsetOfTypeDefData = wasm::Instance::offsetInData( @@ -21290,13 +21294,14 @@ void CodeGenerator::visitWasmNewArrayObject(LWasmNewArrayObject* lir) { Register instance = ToRegister(lir->instance()); MOZ_ASSERT(instance == InstanceReg); - auto* ool = new (alloc()) LambdaOutOfLineCode([=](OutOfLineCode& ool) { - masm.move32(Imm32(typeDefIndex), temp0); - masm.move32(Imm32(numElements), temp1); - callWasmArrayAllocFun(lir, fun, temp1, temp0, allocSite, output, - mir->trapSiteDesc()); - masm.jump(ool.rejoin()); - }); + auto* ool = + new (alloc()) LambdaOutOfLineCode([=, this](OutOfLineCode& ool) { + masm.move32(Imm32(typeDefIndex), temp0); + masm.move32(Imm32(numElements), temp1); + callWasmArrayAllocFun(lir, fun, temp1, temp0, allocSite, output, + mir->trapSiteDesc()); + masm.jump(ool.rejoin()); + }); addOutOfLineCode(ool, lir->mir()); size_t offsetOfTypeDefData = wasm::Instance::offsetInData( @@ -21314,12 +21319,13 @@ void CodeGenerator::visitWasmNewArrayObject(LWasmNewArrayObject* lir) { MOZ_ASSERT(instance == InstanceReg); Register numElements = ToRegister(lir->numElements()); - auto* ool = new (alloc()) LambdaOutOfLineCode([=](OutOfLineCode& ool) { - masm.move32(Imm32(typeDefIndex), temp0); - callWasmArrayAllocFun(lir, fun, numElements, temp0, allocSite, output, - mir->trapSiteDesc()); - masm.jump(ool.rejoin()); - }); + auto* ool = + new (alloc()) LambdaOutOfLineCode([=, this](OutOfLineCode& ool) { + masm.move32(Imm32(typeDefIndex), temp0); + callWasmArrayAllocFun(lir, fun, numElements, temp0, allocSite, output, + mir->trapSiteDesc()); + masm.jump(ool.rejoin()); + }); addOutOfLineCode(ool, lir->mir()); size_t offsetOfTypeDefData = wasm::Instance::offsetInData( @@ -21359,9 +21365,10 @@ void CodeGenerator::visitWasmBoundsCheck(LWasmBoundsCheck* ins) { Register ptr = ToRegister(ins->ptr()); if (ins->boundsCheckLimit()->isConstant()) { - auto* ool = new (alloc()) LambdaOutOfLineCode([=](OutOfLineCode& ool) { - masm.wasmTrap(wasm::Trap::OutOfBounds, mir->trapSiteDesc()); - }); + auto* ool = + new (alloc()) LambdaOutOfLineCode([=, this](OutOfLineCode& ool) { + masm.wasmTrap(wasm::Trap::OutOfBounds, mir->trapSiteDesc()); + }); addOutOfLineCode(ool, mir); masm.branch32(Assembler::AboveOrEqual, ptr, Imm32(ins->boundsCheckLimit()->toConstant()->toInt32()), @@ -21379,9 +21386,10 @@ void CodeGenerator::visitWasmBoundsCheck(LWasmBoundsCheck* ins) { masm.wasmTrap(wasm::Trap::OutOfBounds, mir->trapSiteDesc()); masm.bind(&ok); } else { - auto* ool = new (alloc()) LambdaOutOfLineCode([=](OutOfLineCode& ool) { - masm.wasmTrap(wasm::Trap::OutOfBounds, mir->trapSiteDesc()); - }); + auto* ool = + new (alloc()) LambdaOutOfLineCode([=, this](OutOfLineCode& ool) { + masm.wasmTrap(wasm::Trap::OutOfBounds, mir->trapSiteDesc()); + }); addOutOfLineCode(ool, mir); masm.wasmBoundsCheck32(Assembler::AboveOrEqual, ptr, boundsCheckLimit, ool->entry()); @@ -21393,9 +21401,10 @@ void CodeGenerator::visitWasmBoundsCheck64(LWasmBoundsCheck64* ins) { Register64 ptr = ToRegister64(ins->ptr()); if (IsConstant(ins->boundsCheckLimit())) { - auto* ool = new (alloc()) LambdaOutOfLineCode([=](OutOfLineCode& ool) { - masm.wasmTrap(wasm::Trap::OutOfBounds, mir->trapSiteDesc()); - }); + auto* ool = + new (alloc()) LambdaOutOfLineCode([=, this](OutOfLineCode& ool) { + masm.wasmTrap(wasm::Trap::OutOfBounds, mir->trapSiteDesc()); + }); addOutOfLineCode(ool, mir); masm.branch64(Assembler::AboveOrEqual, ptr, Imm64(ToInt64(ins->boundsCheckLimit())), ool->entry()); @@ -21410,9 +21419,10 @@ void CodeGenerator::visitWasmBoundsCheck64(LWasmBoundsCheck64* ins) { masm.wasmTrap(wasm::Trap::OutOfBounds, mir->trapSiteDesc()); masm.bind(&ok); } else { - auto* ool = new (alloc()) LambdaOutOfLineCode([=](OutOfLineCode& ool) { - masm.wasmTrap(wasm::Trap::OutOfBounds, mir->trapSiteDesc()); - }); + auto* ool = + new (alloc()) LambdaOutOfLineCode([=, this](OutOfLineCode& ool) { + masm.wasmTrap(wasm::Trap::OutOfBounds, mir->trapSiteDesc()); + }); addOutOfLineCode(ool, mir); masm.wasmBoundsCheck64(Assembler::AboveOrEqual, ptr, boundsCheckLimit, ool->entry()); @@ -21432,9 +21442,10 @@ void CodeGenerator::visitWasmBoundsCheckInstanceField( masm.wasmTrap(wasm::Trap::OutOfBounds, mir->trapSiteDesc()); masm.bind(&ok); } else { - auto* ool = new (alloc()) LambdaOutOfLineCode([=](OutOfLineCode& ool) { - masm.wasmTrap(wasm::Trap::OutOfBounds, mir->trapSiteDesc()); - }); + auto* ool = + new (alloc()) LambdaOutOfLineCode([=, this](OutOfLineCode& ool) { + masm.wasmTrap(wasm::Trap::OutOfBounds, mir->trapSiteDesc()); + }); addOutOfLineCode(ool, mir); masm.wasmBoundsCheck32(Assembler::Condition::AboveOrEqual, ptr, Address(instance, ins->offset()), ool->entry()); @@ -21454,9 +21465,10 @@ void CodeGenerator::visitWasmBoundsCheckInstanceField64( masm.wasmTrap(wasm::Trap::OutOfBounds, mir->trapSiteDesc()); masm.bind(&ok); } else { - auto* ool = new (alloc()) LambdaOutOfLineCode([=](OutOfLineCode& ool) { - masm.wasmTrap(wasm::Trap::OutOfBounds, mir->trapSiteDesc()); - }); + auto* ool = + new (alloc()) LambdaOutOfLineCode([=, this](OutOfLineCode& ool) { + masm.wasmTrap(wasm::Trap::OutOfBounds, mir->trapSiteDesc()); + }); addOutOfLineCode(ool, mir); masm.wasmBoundsCheck64(Assembler::Condition::AboveOrEqual, ptr, Address(instance, ins->offset()), ool->entry()); @@ -21476,7 +21488,7 @@ void CodeGenerator::visitWasmBoundsCheckRange32(LWasmBoundsCheckRange32* ins) { void CodeGenerator::visitWasmAlignmentCheck(LWasmAlignmentCheck* ins) { const MWasmAlignmentCheck* mir = ins->mir(); Register ptr = ToRegister(ins->ptr()); - auto* ool = new (alloc()) LambdaOutOfLineCode([=](OutOfLineCode& ool) { + auto* ool = new (alloc()) LambdaOutOfLineCode([=, this](OutOfLineCode& ool) { masm.wasmTrap(wasm::Trap::UnalignedAccess, mir->trapSiteDesc()); }); addOutOfLineCode(ool, mir); @@ -21492,7 +21504,7 @@ void CodeGenerator::visitWasmAlignmentCheck64(LWasmAlignmentCheck64* ins) { #else Register r = ptr.low; #endif - auto* ool = new (alloc()) LambdaOutOfLineCode([=](OutOfLineCode& ool) { + auto* ool = new (alloc()) LambdaOutOfLineCode([=, this](OutOfLineCode& ool) { masm.wasmTrap(wasm::Trap::UnalignedAccess, mir->trapSiteDesc()); }); addOutOfLineCode(ool, mir); @@ -21948,7 +21960,7 @@ void CodeGenerator::visitReinterpretCastToI64(LReinterpretCastToI64* lir) { void CodeGenerator::visitNaNToZero(LNaNToZero* lir) { FloatRegister input = ToFloatRegister(lir->input()); - auto* ool = new (alloc()) LambdaOutOfLineCode([=](OutOfLineCode& ool) { + auto* ool = new (alloc()) LambdaOutOfLineCode([=, this](OutOfLineCode& ool) { FloatRegister output = ToFloatRegister(lir->output()); masm.loadConstantDouble(0.0, output); masm.jump(ool.rejoin()); @@ -22772,7 +22784,7 @@ void CodeGenerator::visitWeakMapGetObject(LWeakMapGetObject* ins) { using Entry = WeakMapObject::Map::Entry; masm.loadValue(Address(scratch, Entry::offsetOfValue()), output); - auto* ool = new (alloc()) LambdaOutOfLineCode([=](OutOfLineCode& ool) { + auto* ool = new (alloc()) LambdaOutOfLineCode([=, this](OutOfLineCode& ool) { // Unboxed, tenured GC cell that needs to be barriered is in scratch. LiveRegisterSet regsToSave(RegisterSet::Volatile()); diff --git a/js/src/jit/JitScript.cpp b/js/src/jit/JitScript.cpp @@ -950,7 +950,7 @@ void JitScript::addSizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf, size_t* data, size_t* allocSites) const { *data += mallocSizeOf(this); - forEachICScript([=](const ICScript* script) { + forEachICScript([=, this](const ICScript* script) { // |data| already includes the outer ICScript because it's part of the // JitScript. if (script != &icScript_) { diff --git a/js/src/jit/arm/CodeGenerator-arm.cpp b/js/src/jit/arm/CodeGenerator-arm.cpp @@ -83,7 +83,7 @@ void CodeGeneratorARM::bailoutIf(Assembler::Condition condition, InlineScriptTree* tree = snapshot->mir()->block()->trackedTree(); auto* ool = new (alloc()) LambdaOutOfLineCode( - [=](OutOfLineCode& ool) { emitBailoutOOL(snapshot); }); + [=, this](OutOfLineCode& ool) { emitBailoutOOL(snapshot); }); // All bailout code is associated with the bytecodeSite of the block we are // bailing out from. @@ -101,7 +101,7 @@ void CodeGeneratorARM::bailoutFrom(Label* label, LSnapshot* snapshot) { InlineScriptTree* tree = snapshot->mir()->block()->trackedTree(); auto* ool = new (alloc()) LambdaOutOfLineCode( - [=](OutOfLineCode& ool) { emitBailoutOOL(snapshot); }); + [=, this](OutOfLineCode& ool) { emitBailoutOOL(snapshot); }); // All bailout code is associated with the bytecodeSite of the block we are // bailing out from. @@ -1826,7 +1826,7 @@ void CodeGenerator::visitWasmAddOffset(LWasmAddOffset* lir) { ScratchRegisterScope scratch(masm); masm.ma_add(base, Imm32(mir->offset()), out, scratch, SetCC); - auto* ool = new (alloc()) LambdaOutOfLineCode([=](OutOfLineCode& ool) { + auto* ool = new (alloc()) LambdaOutOfLineCode([=, this](OutOfLineCode& ool) { masm.wasmTrap(wasm::Trap::OutOfBounds, mir->trapSiteDesc()); }); addOutOfLineCode(ool, mir); @@ -1842,7 +1842,7 @@ void CodeGenerator::visitWasmAddOffset64(LWasmAddOffset64* lir) { ScratchRegisterScope scratch(masm); masm.ma_add(base.low, Imm32(mir->offset()), out.low, scratch, SetCC); masm.ma_adc(base.high, Imm32(mir->offset() >> 32), out.high, scratch, SetCC); - auto* ool = new (alloc()) LambdaOutOfLineCode([=](OutOfLineCode& ool) { + auto* ool = new (alloc()) LambdaOutOfLineCode([=, this](OutOfLineCode& ool) { masm.wasmTrap(wasm::Trap::OutOfBounds, mir->trapSiteDesc()); }); addOutOfLineCode(ool, mir); diff --git a/js/src/jit/arm64/CodeGenerator-arm64.cpp b/js/src/jit/arm64/CodeGenerator-arm64.cpp @@ -84,7 +84,7 @@ void CodeGeneratorARM64::bailoutIf(Assembler::Condition condition, InlineScriptTree* tree = snapshot->mir()->block()->trackedTree(); auto* ool = new (alloc()) LambdaOutOfLineCode( - [=](OutOfLineCode& ool) { emitBailoutOOL(snapshot); }); + [=, this](OutOfLineCode& ool) { emitBailoutOOL(snapshot); }); addOutOfLineCode(ool, new (alloc()) BytecodeSite(tree, tree->script()->code())); @@ -99,7 +99,7 @@ void CodeGeneratorARM64::bailoutIfZero(Assembler::Condition condition, InlineScriptTree* tree = snapshot->mir()->block()->trackedTree(); auto* ool = new (alloc()) LambdaOutOfLineCode( - [=](OutOfLineCode& ool) { emitBailoutOOL(snapshot); }); + [=, this](OutOfLineCode& ool) { emitBailoutOOL(snapshot); }); addOutOfLineCode(ool, new (alloc()) BytecodeSite(tree, tree->script()->code())); @@ -118,7 +118,7 @@ void CodeGeneratorARM64::bailoutFrom(Label* label, LSnapshot* snapshot) { InlineScriptTree* tree = snapshot->mir()->block()->trackedTree(); auto* ool = new (alloc()) LambdaOutOfLineCode( - [=](OutOfLineCode& ool) { emitBailoutOOL(snapshot); }); + [=, this](OutOfLineCode& ool) { emitBailoutOOL(snapshot); }); addOutOfLineCode(ool, new (alloc()) BytecodeSite(tree, tree->script()->code())); @@ -2650,7 +2650,7 @@ void CodeGenerator::visitWasmAddOffset(LWasmAddOffset* lir) { masm.Adds(ARMRegister(out, 32), ARMRegister(base, 32), Operand(mir->offset())); - auto* ool = new (alloc()) LambdaOutOfLineCode([=](OutOfLineCode& ool) { + auto* ool = new (alloc()) LambdaOutOfLineCode([=, this](OutOfLineCode& ool) { masm.wasmTrap(wasm::Trap::OutOfBounds, mir->trapSiteDesc()); }); addOutOfLineCode(ool, mir); @@ -2664,7 +2664,7 @@ void CodeGenerator::visitWasmAddOffset64(LWasmAddOffset64* lir) { masm.Adds(ARMRegister(out.reg, 64), ARMRegister(base.reg, 64), Operand(mir->offset())); - auto* ool = new (alloc()) LambdaOutOfLineCode([=](OutOfLineCode& ool) { + auto* ool = new (alloc()) LambdaOutOfLineCode([=, this](OutOfLineCode& ool) { masm.wasmTrap(wasm::Trap::OutOfBounds, mir->trapSiteDesc()); }); addOutOfLineCode(ool, mir); diff --git a/js/src/jit/loong64/CodeGenerator-loong64.cpp b/js/src/jit/loong64/CodeGenerator-loong64.cpp @@ -88,7 +88,7 @@ void CodeGeneratorLOONG64::bailoutFrom(Label* label, LSnapshot* snapshot) { encode(snapshot); InlineScriptTree* tree = snapshot->mir()->block()->trackedTree(); - auto* ool = new (alloc()) LambdaOutOfLineCode([=](OutOfLineCode& ool) { + auto* ool = new (alloc()) LambdaOutOfLineCode([=, this](OutOfLineCode& ool) { // Push snapshotOffset and make sure stack is aligned. masm.subPtr(Imm32(sizeof(Value)), StackPointer); masm.storePtr(ImmWord(snapshot->snapshotOffset()), diff --git a/js/src/jit/mips-shared/CodeGenerator-mips-shared.cpp b/js/src/jit/mips-shared/CodeGenerator-mips-shared.cpp @@ -97,7 +97,7 @@ void CodeGeneratorMIPSShared::bailoutFrom(Label* label, LSnapshot* snapshot) { encode(snapshot); InlineScriptTree* tree = snapshot->mir()->block()->trackedTree(); - auto* ool = new (alloc()) LambdaOutOfLineCode([=](OutOfLineCode& ool) { + auto* ool = new (alloc()) LambdaOutOfLineCode([=, this](OutOfLineCode& ool) { // Push snapshotOffset and make sure stack is aligned. masm.subPtr(Imm32(sizeof(Value)), StackPointer); masm.storePtr(ImmWord(snapshot->snapshotOffset()), diff --git a/js/src/jit/riscv64/CodeGenerator-riscv64.cpp b/js/src/jit/riscv64/CodeGenerator-riscv64.cpp @@ -87,7 +87,7 @@ void CodeGeneratorRiscv64::bailoutFrom(Label* label, LSnapshot* snapshot) { encode(snapshot); InlineScriptTree* tree = snapshot->mir()->block()->trackedTree(); - auto* ool = new (alloc()) LambdaOutOfLineCode([=](OutOfLineCode& ool) { + auto* ool = new (alloc()) LambdaOutOfLineCode([=, this](OutOfLineCode& ool) { // Push snapshotOffset and make sure stack is aligned. masm.subPtr(Imm32(sizeof(Value)), StackPointer); masm.storePtr(ImmWord(snapshot->snapshotOffset()), diff --git a/js/src/jit/x86-shared/CodeGenerator-x86-shared.cpp b/js/src/jit/x86-shared/CodeGenerator-x86-shared.cpp @@ -329,7 +329,7 @@ void CodeGenerator::visitAsmJSLoadHeap(LAsmJSLoadHeap* ins) { OutOfLineCode* ool = nullptr; if (mir->needsBoundsCheck()) { - ool = new (alloc()) LambdaOutOfLineCode([=](OutOfLineCode& ool) { + ool = new (alloc()) LambdaOutOfLineCode([=, this](OutOfLineCode& ool) { switch (accessType) { case Scalar::Int64: case Scalar::BigInt64: @@ -401,7 +401,7 @@ void CodeGenerator::visitWasmAddOffset(LWasmAddOffset* lir) { masm.move32(base, out); } masm.add32(Imm32(mir->offset()), out); - auto* ool = new (alloc()) LambdaOutOfLineCode([=](OutOfLineCode& ool) { + auto* ool = new (alloc()) LambdaOutOfLineCode([=, this](OutOfLineCode& ool) { masm.wasmTrap(wasm::Trap::OutOfBounds, mir->trapSiteDesc()); }); addOutOfLineCode(ool, mir); @@ -417,7 +417,7 @@ void CodeGenerator::visitWasmAddOffset64(LWasmAddOffset64* lir) { masm.move64(base, out); } masm.add64(Imm64(mir->offset()), out); - auto* ool = new (alloc()) LambdaOutOfLineCode([=](OutOfLineCode& ool) { + auto* ool = new (alloc()) LambdaOutOfLineCode([=, this](OutOfLineCode& ool) { masm.wasmTrap(wasm::Trap::OutOfBounds, mir->trapSiteDesc()); }); addOutOfLineCode(ool, mir); @@ -522,7 +522,7 @@ void CodeGeneratorX86Shared::bailout(const T& binder, LSnapshot* snapshot) { // All bailout code is associated with the bytecodeSite of the block we are // bailing out from. InlineScriptTree* tree = snapshot->mir()->block()->trackedTree(); - auto* ool = new (alloc()) LambdaOutOfLineCode([=](OutOfLineCode& ool) { + auto* ool = new (alloc()) LambdaOutOfLineCode([=, this](OutOfLineCode& ool) { masm.push(Imm32(snapshot->snapshotOffset())); masm.jmp(&deoptLabel_); }); @@ -682,7 +682,7 @@ void CodeGenerator::visitAddI(LAddI* ins) { if (ins->snapshot()) { if (ins->recoversInput()) { auto* ool = new (alloc()) LambdaOutOfLineCode( - [=](OutOfLineCode& ool) { emitUndoALUOperationOOL(ins); }); + [=, this](OutOfLineCode& ool) { emitUndoALUOperationOOL(ins); }); addOutOfLineCode(ool, ins->mir()); masm.j(Assembler::Overflow, ool->entry()); } else { @@ -720,7 +720,7 @@ void CodeGenerator::visitSubI(LSubI* ins) { if (ins->snapshot()) { if (ins->recoversInput()) { auto* ool = new (alloc()) LambdaOutOfLineCode( - [=](OutOfLineCode& ool) { emitUndoALUOperationOOL(ins); }); + [=, this](OutOfLineCode& ool) { emitUndoALUOperationOOL(ins); }); addOutOfLineCode(ool, ins->mir()); masm.j(Assembler::Overflow, ool->entry()); } else { @@ -848,7 +848,8 @@ void CodeGenerator::visitMulI(LMulI* ins) { if (mul->canBeNegativeZero()) { // Jump to an OOL path if the result is 0. - auto* ool = new (alloc()) LambdaOutOfLineCode([=](OutOfLineCode& ool) { + auto* ool = new ( + alloc()) LambdaOutOfLineCode([=, this](OutOfLineCode& ool) { Register result = ToRegister(ins->output()); Operand lhsCopy = ToOperand(ins->lhsCopy()); Operand rhs = ToOperand(ins->rhs()); @@ -887,7 +888,7 @@ static void TrapIfDivideByZero(MacroAssembler& masm, LIR* lir, Register rhs) { OutOfLineCode* CodeGeneratorX86Shared::emitOutOfLineZeroForDivideByZero( Register rhs, Register output) { // Truncated division by zero is zero: (±Infinity|0 == 0) and (NaN|0 == 0). - auto* ool = new (alloc()) LambdaOutOfLineCode([=](OutOfLineCode& ool) { + auto* ool = new (alloc()) LambdaOutOfLineCode([=, this](OutOfLineCode& ool) { masm.mov(ImmWord(0), output); masm.jmp(ool.rejoin()); }); diff --git a/js/src/jsapi-tests/testGCHooks.cpp b/js/src/jsapi-tests/testGCHooks.cpp @@ -77,8 +77,8 @@ BEGIN_TEST(testGCRootsRemoved) { gSliceCallbackCount = 0; JS::SetGCSliceCallback(cx, RootsRemovedGCSliceCallback); - auto byebye = - mozilla::MakeScopeExit([=] { JS::SetGCSliceCallback(cx, nullptr); }); + auto byebye = mozilla::MakeScopeExit( + [=, this] { JS::SetGCSliceCallback(cx, nullptr); }); JS::RootedObject obj(cx, JS_NewPlainObject(cx)); CHECK(obj); @@ -253,7 +253,7 @@ BEGIN_TEST(testGCTree) { // Automate the callback clearing. Otherwise if a CHECK fails, it will get // cluttered with additional failures from the callback unexpectedly firing // during the final shutdown GC. - auto byebye = mozilla::MakeScopeExit([=] { + auto byebye = mozilla::MakeScopeExit([=, this] { JS::SetGCSliceCallback(cx, nullptr); JS_SetGCCallback(cx, nullptr, nullptr); });