From 82b486fe9b02638d00cb3282a77dffaea157aa3c Mon Sep 17 00:00:00 2001 From: win7-7 Date: Tue, 30 Dec 2025 06:25:00 +0200 Subject: [PATCH] 1337444 - wasm: runtime crash involving i64 globals 1337444: Fix regalloc of load/store i64 globals; --- js/src/jit/Lowering.cpp | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/js/src/jit/Lowering.cpp b/js/src/jit/Lowering.cpp index 2ac1cd2602..c0ae566ae7 100644 --- a/js/src/jit/Lowering.cpp +++ b/js/src/jit/Lowering.cpp @@ -4244,22 +4244,37 @@ LIRGenerator::visitWasmBoundsCheck(MWasmBoundsCheck* ins) void LIRGenerator::visitWasmLoadGlobalVar(MWasmLoadGlobalVar* ins) { - LAllocation tlsPtr = useRegisterAtStart(ins->tlsPtr()); - if (ins->type() == MIRType::Int64) + if (ins->type() == MIRType::Int64) { +#ifdef JS_PUNBOX64 + LAllocation tlsPtr = useRegisterAtStart(ins->tlsPtr()); +#else + LAllocation tlsPtr = useRegister(ins->tlsPtr()); +#endif defineInt64(new(alloc()) LWasmLoadGlobalVarI64(tlsPtr), ins); - else + } else { + LAllocation tlsPtr = useRegisterAtStart(ins->tlsPtr()); define(new(alloc()) LWasmLoadGlobalVar(tlsPtr), ins); + } } void LIRGenerator::visitWasmStoreGlobalVar(MWasmStoreGlobalVar* ins) { MDefinition* value = ins->value(); - LAllocation tlsPtr = useRegisterAtStart(ins->tlsPtr()); - if (value->type() == MIRType::Int64) - add(new(alloc()) LWasmStoreGlobalVarI64(useInt64RegisterAtStart(value), tlsPtr), ins); - else - add(new(alloc()) LWasmStoreGlobalVar(useRegisterAtStart(value), tlsPtr), ins); + if (value->type() == MIRType::Int64) { +#ifdef JS_PUNBOX64 + LAllocation tlsPtr = useRegisterAtStart(ins->tlsPtr()); + LInt64Allocation valueAlloc = useInt64RegisterAtStart(value); +#else + LAllocation tlsPtr = useRegister(ins->tlsPtr()); + LInt64Allocation valueAlloc = useInt64Register(value); +#endif + add(new(alloc()) LWasmStoreGlobalVarI64(valueAlloc, tlsPtr), ins); + } else { + LAllocation tlsPtr = useRegisterAtStart(ins->tlsPtr()); + LAllocation valueAlloc = useRegisterAtStart(value); + add(new(alloc()) LWasmStoreGlobalVar(valueAlloc, tlsPtr), ins); + } } void