Skip to content

Commit f357cb4

Browse files
committed
[JSC] Fix floating point negation in WasmBBQJIT
https://bugs.webkit.org/show_bug.cgi?id=253262 rdar://106161437 Reviewed by Justin Michaud. This patch aligns WasmBBQJIT to exactly how f32 / f64 negation is implemented in Air. This is required since wasm cares NaN's bit patterns. * Source/JavaScriptCore/wasm/WasmBBQJIT.cpp: (JSC::Wasm::BBQJIT::addF32Neg): (JSC::Wasm::BBQJIT::addF64Neg): Canonical link: https://commits.webkit.org/261102@main
1 parent b9dad07 commit f357cb4

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

Source/JavaScriptCore/wasm/WasmBBQJIT.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5640,8 +5640,9 @@ class BBQJIT {
56405640
BLOCK(Value::fromF32(-operand.asF32())),
56415641
BLOCK(
56425642
#if CPU(X86_64)
5643-
m_jit.xorFloat(m_scratchFPR, m_scratchFPR);
5644-
m_jit.subFloat(operandLocation.asFPR(), m_scratchFPR, resultLocation.asFPR());
5643+
m_jit.moveFloatTo32(operandLocation.asFPR(), m_scratchGPR);
5644+
m_jit.xor32(TrustedImm32(bitwise_cast<uint32_t>(static_cast<float>(-0.0))), m_scratchGPR);
5645+
m_jit.move32ToFloat(m_scratchGPR, resultLocation.asFPR());
56455646
#else
56465647
m_jit.negateFloat(operandLocation.asFPR(), resultLocation.asFPR());
56475648
#endif
@@ -5656,8 +5657,9 @@ class BBQJIT {
56565657
BLOCK(Value::fromF64(-operand.asF64())),
56575658
BLOCK(
56585659
#if CPU(X86_64)
5659-
m_jit.xorDouble(m_scratchFPR, m_scratchFPR);
5660-
m_jit.subDouble(operandLocation.asFPR(), m_scratchFPR, resultLocation.asFPR());
5660+
m_jit.moveDoubleTo64(operandLocation.asFPR(), m_scratchGPR);
5661+
m_jit.xor64(TrustedImm64(bitwise_cast<uint64_t>(static_cast<double>(-0.0))), m_scratchGPR);
5662+
m_jit.move64ToDouble(m_scratchGPR, resultLocation.asFPR());
56615663
#else
56625664
m_jit.negateDouble(operandLocation.asFPR(), resultLocation.asFPR());
56635665
#endif

0 commit comments

Comments
 (0)