Skip to content

Commit 83de155

Browse files
committed
Bug 1944011 - Part 29: Generate boilerplate for LWasmAtomicBinopI64. r=jandem
Also updates lowering on 32-bit platforms to directly allocate an LInt64Allocation instead of two LAllocations. (This matches the JS code for atomics, too.) Differential Revision: https://phabricator.services.mozilla.com/D235802
1 parent 79083ed commit 83de155

14 files changed

+52
-142
lines changed

js/src/jit/LIROps.yaml

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4965,7 +4965,14 @@
49654965
gen_boilerplate: false
49664966

49674967
- name: WasmAtomicBinopI64
4968-
gen_boilerplate: false
4968+
result_type: Int64
4969+
operands:
4970+
memoryBase: WordSized
4971+
ptr: WordSized
4972+
value: Int64
4973+
arguments:
4974+
access: const wasm::MemoryAccessDesc&
4975+
operation: AtomicOp
49694976

49704977
- name: WasmAtomicExchangeI64
49714978
gen_boilerplate: false
@@ -5056,7 +5063,15 @@
50565063
gen_boilerplate: false
50575064

50585065
- name: WasmAtomicBinopI64
5059-
gen_boilerplate: false
5066+
result_type: Int64
5067+
operands:
5068+
ptr: WordSized
5069+
value: Int64
5070+
memoryBase: WordSized
5071+
arguments:
5072+
access: const wasm::MemoryAccessDesc&
5073+
operation: AtomicOp
5074+
num_temps64: 1
50605075

50615076
- name: WasmAtomicExchangeI64
50625077
gen_boilerplate: false
@@ -5148,7 +5163,13 @@
51485163
gen_boilerplate: false
51495164

51505165
- name: WasmAtomicBinopI64
5151-
gen_boilerplate: false
5166+
result_type: Int64
5167+
operands:
5168+
ptr: WordSized
5169+
value: Int64
5170+
memoryBase: WordSized
5171+
num_temps64: 1
5172+
mir_op: WasmAtomicBinopHeap
51525173

51535174
- name: WasmAtomicExchangeI64
51545175
gen_boilerplate: false
@@ -5195,7 +5216,13 @@
51955216
gen_boilerplate: false
51965217

51975218
- name: WasmAtomicBinopI64
5198-
gen_boilerplate: false
5219+
result_type: Int64
5220+
operands:
5221+
ptr: WordSized
5222+
value: Int64
5223+
memoryBase: WordSized
5224+
num_temps64: 1
5225+
mir_op: WasmAtomicBinopHeap
51995226

52005227
- name: WasmAtomicExchangeI64
52015228
gen_boilerplate: false
@@ -5230,7 +5257,13 @@
52305257
gen_boilerplate: false
52315258

52325259
- name: WasmAtomicBinopI64
5233-
gen_boilerplate: false
5260+
result_type: Int64
5261+
operands:
5262+
ptr: WordSized
5263+
value: Int64
5264+
memoryBase: WordSized
5265+
num_temps64: 1
5266+
mir_op: WasmAtomicBinopHeap
52345267

52355268
- name: WasmAtomicExchangeI64
52365269
gen_boilerplate: false

js/src/jit/arm/CodeGenerator-arm.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2674,7 +2674,7 @@ void CodeGenerator::visitWasmAtomicBinopI64(LWasmAtomicBinopI64* lir) {
26742674
Register64 out = ToOutRegister64(lir);
26752675

26762676
BaseIndex addr(memoryBase, ptr, TimesOne, lir->access().offset32());
2677-
Register64 tmp(ToRegister(lir->tmpHigh()), ToRegister(lir->tmpLow()));
2677+
Register64 tmp = ToRegister64(lir->temp0());
26782678
masm.wasmAtomicFetchOp64(lir->access(), lir->operation(), value, addr, tmp,
26792679
out);
26802680
}

js/src/jit/arm/LIR-arm.h

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -331,35 +331,6 @@ class LWasmCompareExchangeI64
331331
const LAllocation* memoryBase() { return getOperand(1 + 2 * INT64_PIECES); }
332332
};
333333

334-
class LWasmAtomicBinopI64
335-
: public LInstructionHelper<INT64_PIECES, 2 + INT64_PIECES, 2> {
336-
const wasm::MemoryAccessDesc& access_;
337-
AtomicOp op_;
338-
339-
public:
340-
LIR_HEADER(WasmAtomicBinopI64);
341-
342-
LWasmAtomicBinopI64(const LAllocation& ptr, const LInt64Allocation& value,
343-
const LAllocation& memoryBase, const LDefinition& tmpLow,
344-
const LDefinition& tmpHigh,
345-
const wasm::MemoryAccessDesc& access, AtomicOp op)
346-
: LInstructionHelper(classOpcode), access_(access), op_(op) {
347-
setOperand(0, ptr);
348-
setInt64Operand(1, value);
349-
setOperand(3, memoryBase);
350-
setTemp(0, tmpLow);
351-
setTemp(1, tmpHigh);
352-
}
353-
354-
const LAllocation* ptr() { return getOperand(0); }
355-
LInt64Allocation value() { return getInt64Operand(1); }
356-
const LAllocation* memoryBase() { return getOperand(3); }
357-
const wasm::MemoryAccessDesc& access() { return access_; }
358-
AtomicOp operation() const { return op_; }
359-
const LDefinition* tmpLow() { return getTemp(0); }
360-
const LDefinition* tmpHigh() { return getTemp(1); }
361-
};
362-
363334
class LWasmAtomicExchangeI64
364335
: public LInstructionHelper<INT64_PIECES, 2 + INT64_PIECES, 0> {
365336
const wasm::MemoryAccessDesc& access_;

js/src/jit/arm/Lowering-arm.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1041,7 +1041,7 @@ void LIRGenerator::visitWasmAtomicBinopHeap(MWasmAtomicBinopHeap* ins) {
10411041
if (ins->access().type() == Scalar::Int64) {
10421042
auto* lir = new (alloc()) LWasmAtomicBinopI64(
10431043
useRegister(ins->base()), useInt64Fixed(ins->value(), FetchOpVal64),
1044-
memoryBase, tempFixed(FetchOpTmpLo), tempFixed(FetchOpTmpHi),
1044+
memoryBase, tempInt64Fixed(Register64(FetchOpTmpHi, FetchOpTmpLo)),
10451045
ins->access(), ins->operation());
10461046
defineInt64Fixed(lir, ins,
10471047
LInt64Allocation(LAllocation(AnyRegister(FetchOpOutHi)),

js/src/jit/loong64/CodeGenerator-loong64.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2341,7 +2341,7 @@ void CodeGenerator::visitWasmAtomicBinopI64(LWasmAtomicBinopI64* lir) {
23412341
Register ptr = ToRegister(lir->ptr());
23422342
Register64 value = ToRegister64(lir->value());
23432343
Register64 output = ToOutRegister64(lir);
2344-
Register64 temp(ToRegister(lir->getTemp(0)));
2344+
Register64 temp = ToRegister64(lir->temp0());
23452345
uint32_t offset = lir->mir()->access().offset32();
23462346

23472347
BaseIndex addr(memoryBase, ptr, TimesOne, offset);

js/src/jit/loong64/LIR-loong64.h

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -179,27 +179,6 @@ class LWasmAtomicExchangeI64
179179
}
180180
};
181181

182-
class LWasmAtomicBinopI64
183-
: public LInstructionHelper<INT64_PIECES, 2 + INT64_PIECES, 2> {
184-
public:
185-
LIR_HEADER(WasmAtomicBinopI64);
186-
187-
LWasmAtomicBinopI64(const LAllocation& ptr, const LInt64Allocation& value,
188-
const LAllocation& memoryBase)
189-
: LInstructionHelper(classOpcode) {
190-
setOperand(0, ptr);
191-
setInt64Operand(1, value);
192-
setOperand(1 + INT64_PIECES, memoryBase);
193-
}
194-
195-
const LAllocation* ptr() { return getOperand(0); }
196-
LInt64Allocation value() { return getInt64Operand(1); }
197-
const LAllocation* memoryBase() { return getOperand(1 + INT64_PIECES); }
198-
const MWasmAtomicBinopHeap* mir() const {
199-
return mir_->toWasmAtomicBinopHeap();
200-
}
201-
};
202-
203182
class LDivOrModI64 : public LBinaryMath<1> {
204183
public:
205184
LIR_HEADER(DivOrModI64)

js/src/jit/loong64/Lowering-loong64.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -984,9 +984,9 @@ void LIRGenerator::visitWasmAtomicBinopHeap(MWasmAtomicBinopHeap* ins) {
984984
: LGeneralReg(HeapReg);
985985

986986
if (ins->access().type() == Scalar::Int64) {
987-
auto* lir = new (alloc()) LWasmAtomicBinopI64(
988-
useRegister(base), useInt64Register(ins->value()), memoryBase);
989-
lir->setTemp(0, temp());
987+
auto* lir = new (alloc())
988+
LWasmAtomicBinopI64(useRegister(base), useInt64Register(ins->value()),
989+
memoryBase, tempInt64());
990990
defineInt64(lir, ins);
991991
return;
992992
}

js/src/jit/mips-shared/CodeGenerator-mips-shared.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2040,11 +2040,7 @@ void CodeGenerator::visitWasmAtomicBinopI64(LWasmAtomicBinopI64* lir) {
20402040
Register ptr = ToRegister(lir->ptr());
20412041
Register64 value = ToRegister64(lir->value());
20422042
Register64 output = ToOutRegister64(lir);
2043-
#ifdef JS_CODEGEN_MIPS32
2044-
Register64 temp(ToRegister(lir->getTemp(0)), ToRegister(lir->getTemp(1)));
2045-
#else
2046-
Register64 temp(ToRegister(lir->getTemp(0)));
2047-
#endif
2043+
Register64 temp = ToRegister64(lir->temp0());
20482044
uint32_t offset = lir->mir()->access().offset32();
20492045

20502046
BaseIndex addr(memoryBase, ptr, TimesOne, offset);

js/src/jit/mips-shared/LIR-mips-shared.h

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -254,27 +254,6 @@ class LWasmAtomicExchangeI64
254254
}
255255
};
256256

257-
class LWasmAtomicBinopI64
258-
: public LInstructionHelper<INT64_PIECES, 2 + INT64_PIECES, 2> {
259-
public:
260-
LIR_HEADER(WasmAtomicBinopI64);
261-
262-
LWasmAtomicBinopI64(const LAllocation& ptr, const LInt64Allocation& value,
263-
const LAllocation& memoryBase)
264-
: LInstructionHelper(classOpcode) {
265-
setOperand(0, ptr);
266-
setInt64Operand(1, value);
267-
setOperand(1 + INT64_PIECES, memoryBase);
268-
}
269-
270-
const LAllocation* ptr() { return getOperand(0); }
271-
LInt64Allocation value() { return getInt64Operand(1); }
272-
const LAllocation* memoryBase() { return getOperand(1 + INT64_PIECES); }
273-
const MWasmAtomicBinopHeap* mir() const {
274-
return mir_->toWasmAtomicBinopHeap();
275-
}
276-
};
277-
278257
} // namespace jit
279258
} // namespace js
280259

js/src/jit/mips-shared/Lowering-mips-shared.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -808,12 +808,9 @@ void LIRGenerator::visitWasmAtomicBinopHeap(MWasmAtomicBinopHeap* ins) {
808808
: LGeneralReg(HeapReg);
809809

810810
if (ins->access().type() == Scalar::Int64) {
811-
auto* lir = new (alloc()) LWasmAtomicBinopI64(
812-
useRegister(base), useInt64Register(ins->value()), memoryBase);
813-
lir->setTemp(0, temp());
814-
#ifdef JS_CODEGEN_MIPS32
815-
lir->setTemp(1, temp());
816-
#endif
811+
auto* lir = new (alloc())
812+
LWasmAtomicBinopI64(useRegister(base), useInt64Register(ins->value()),
813+
memoryBase, tempInt64());
817814
defineInt64(lir, ins);
818815
return;
819816
}

0 commit comments

Comments
 (0)