tor-browser

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

commit 59023469376c0c56bcd0b8d66bce8359bd427659
parent 21a87fad7ce2fc34cc7af996de29f7d19020c2a6
Author: Jan de Mooij <jdemooij@mozilla.com>
Date:   Fri, 12 Dec 2025 10:35:54 +0000

Bug 2005479 part 6 - Use generate_lir: true for ResizableTypedArrayLength and ResizableDataViewByteLength. r=iain

Move SynchronizeLoad and SynchronizeStore helper functions from
Lowering.cpp to MIR.h so they can be used from both CodeGenerator and
Lowering.

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

Diffstat:
Mjs/src/jit/CodeGenerator.cpp | 8++++----
Mjs/src/jit/LIROps.yaml | 18------------------
Mjs/src/jit/Lowering.cpp | 20++------------------
Mjs/src/jit/MIR.h | 16++++++++++++++++
Mjs/src/jit/MIROps.yaml | 4++++
5 files changed, 26 insertions(+), 40 deletions(-)

diff --git a/js/src/jit/CodeGenerator.cpp b/js/src/jit/CodeGenerator.cpp @@ -11502,8 +11502,8 @@ void CodeGenerator::visitResizableTypedArrayLength( Register out = ToRegister(lir->output()); Register temp = ToRegister(lir->temp0()); - masm.loadResizableTypedArrayLengthIntPtr(lir->synchronization(), obj, out, - temp); + auto sync = SynchronizeLoad(lir->mir()->requiresMemoryBarrier()); + masm.loadResizableTypedArrayLengthIntPtr(sync, obj, out, temp); } void CodeGenerator::visitResizableDataViewByteLength( @@ -11512,8 +11512,8 @@ void CodeGenerator::visitResizableDataViewByteLength( Register out = ToRegister(lir->output()); Register temp = ToRegister(lir->temp0()); - masm.loadResizableDataViewByteLengthIntPtr(lir->synchronization(), obj, out, - temp); + auto sync = SynchronizeLoad(lir->mir()->requiresMemoryBarrier()); + masm.loadResizableDataViewByteLengthIntPtr(sync, obj, out, temp); } void CodeGenerator::visitGrowableSharedArrayBufferByteLength( diff --git a/js/src/jit/LIROps.yaml b/js/src/jit/LIROps.yaml @@ -1964,24 +1964,6 @@ num_temps: 3 mir_op: true -# Read the length of a resizable typed array. -- name: ResizableTypedArrayLength - result_type: WordSized - operands: - object: WordSized - arguments: - synchronization: js::jit::Synchronization - num_temps: 1 - -# Read the byte length of a resizable data view. -- name: ResizableDataViewByteLength - result_type: WordSized - operands: - object: WordSized - arguments: - synchronization: js::jit::Synchronization - num_temps: 1 - # Double to IntPtr, eligible for accessing into a TypedArray or DataView. If # the index isn't exactly representable as an IntPtr, depending on the # supportOOB flag on the MIR instruction, either bail out or produce an IntPtr diff --git a/js/src/jit/Lowering.cpp b/js/src/jit/Lowering.cpp @@ -4458,20 +4458,6 @@ void LIRGenerator::visitGetNextEntryForIterator(MGetNextEntryForIterator* ins) { define(lir, ins); } -static auto SynchronizeLoad(MemoryBarrierRequirement requiresBarrier) { - if (requiresBarrier == MemoryBarrierRequirement::Required) { - return Synchronization::Load(); - } - return Synchronization::None(); -} - -static auto SynchronizeStore(MemoryBarrierRequirement requiresBarrier) { - if (requiresBarrier == MemoryBarrierRequirement::Required) { - return Synchronization::Store(); - } - return Synchronization::None(); -} - void LIRGenerator::visitArrayBufferByteLength(MArrayBufferByteLength* ins) { MOZ_ASSERT(ins->object()->type() == MIRType::Object); MOZ_ASSERT(ins->type() == MIRType::IntPtr); @@ -4530,9 +4516,8 @@ void LIRGenerator::visitResizableTypedArrayLength( MOZ_ASSERT(ins->object()->type() == MIRType::Object); MOZ_ASSERT(ins->type() == MIRType::IntPtr); - auto sync = SynchronizeLoad(ins->requiresMemoryBarrier()); auto* lir = new (alloc()) - LResizableTypedArrayLength(useRegister(ins->object()), temp(), sync); + LResizableTypedArrayLength(useRegister(ins->object()), temp()); define(lir, ins); } @@ -4541,9 +4526,8 @@ void LIRGenerator::visitResizableDataViewByteLength( MOZ_ASSERT(ins->object()->type() == MIRType::Object); MOZ_ASSERT(ins->type() == MIRType::IntPtr); - auto sync = SynchronizeLoad(ins->requiresMemoryBarrier()); auto* lir = new (alloc()) - LResizableDataViewByteLength(useRegister(ins->object()), temp(), sync); + LResizableDataViewByteLength(useRegister(ins->object()), temp()); define(lir, ins); } diff --git a/js/src/jit/MIR.h b/js/src/jit/MIR.h @@ -1364,6 +1364,22 @@ enum class MemoryBarrierRequirement : bool { Required, }; +inline Synchronization SynchronizeLoad( + MemoryBarrierRequirement requiresBarrier) { + if (requiresBarrier == MemoryBarrierRequirement::Required) { + return Synchronization::Load(); + } + return Synchronization::None(); +} + +inline Synchronization SynchronizeStore( + MemoryBarrierRequirement requiresBarrier) { + if (requiresBarrier == MemoryBarrierRequirement::Required) { + return Synchronization::Store(); + } + return Synchronization::None(); +} + MIR_OPCODE_CLASS_GENERATED // Truncation barrier. This is intended for protecting its input against diff --git a/js/src/jit/MIROps.yaml b/js/src/jit/MIROps.yaml @@ -1842,6 +1842,8 @@ congruent_to: custom alias_set: custom compute_range: custom + generate_lir: true + lir_temps: 1 # Read the byteLength of a resizable dataview. - name: ResizableDataViewByteLength @@ -1856,6 +1858,8 @@ congruent_to: custom alias_set: custom compute_range: custom + generate_lir: true + lir_temps: 1 # Read the byte length of a growable shared array buffer as IntPtr. - name: GrowableSharedArrayBufferByteLength