Skip to content

Commit 69fa271

Browse files
committed
1 parent 13b5f12 commit 69fa271

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

Source/JavaScriptCore/heap/MachineStackMarker.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,16 @@ static inline int osRedZoneAdjustment()
5959
// See http://people.freebsd.org/~obrien/amd64-elf-abi.pdf Section 3.2.2.
6060
redZoneAdjustment = -128;
6161
#elif CPU(ARM64)
62+
#if OS(DARWIN)
6263
// See https://developer.apple.com/library/ios/documentation/Xcode/Conceptual/iPhoneOSABIReference/Articles/ARM64FunctionCallingConventions.html#//apple_ref/doc/uid/TP40013702-SW7
6364
redZoneAdjustment = -128;
65+
#elif OS(WINDOWS)
66+
// https://devblogs.microsoft.com/oldnewthing/20220726-00/?p=106898
67+
redZoneAdjustment = -16;
68+
#else
69+
// There is no red zone.
70+
// https://stackoverflow.com/questions/77908878/aarch64-is-there-a-red-zone-on-linux-if-so-16-or-128-bytes
71+
#endif
6472
#endif
6573
return redZoneAdjustment;
6674
}

Source/JavaScriptCore/wasm/WasmBBQJIT.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3151,7 +3151,7 @@ ControlData WARN_UNUSED_RETURN BBQJIT::addTopLevel(BlockSignature signature)
31513151

31523152
m_pcToCodeOriginMapBuilder.appendItem(m_jit.label(), PCToCodeOriginMapBuilder::defaultCodeOrigin());
31533153
m_jit.emitFunctionPrologue();
3154-
emitSaveCalleeSaves();
3154+
emitPushCalleeSaves();
31553155
m_topLevel = ControlData(*this, BlockType::TopLevel, signature, 0);
31563156

31573157
JIT_COMMENT(m_jit, "Store boxed JIT callee");
@@ -3332,7 +3332,7 @@ MacroAssembler::Label BBQJIT::addLoopOSREntrypoint()
33323332
// - Don't need to zero our locals, since they are restored from the OSR entry scratch buffer anyway.
33333333
auto label = m_jit.label();
33343334
m_jit.emitFunctionPrologue();
3335-
emitSaveCalleeSaves();
3335+
emitPushCalleeSaves();
33363336

33373337
m_jit.move(CCallHelpers::TrustedImmPtr(CalleeBits::boxNativeCallee(&m_callee)), wasmScratchGPR);
33383338
static_assert(CallFrameSlot::codeBlock + 1 == CallFrameSlot::callee);
@@ -5318,8 +5318,15 @@ Expected<std::unique_ptr<InternalFunction>, String> parseAndCompileBBQ(Compilati
53185318
return result;
53195319
}
53205320

5321-
void BBQJIT::emitSaveCalleeSaves()
5321+
void BBQJIT::emitPushCalleeSaves()
53225322
{
5323+
size_t stackSizeForCalleeSaves = WTF::roundUpToMultipleOf<stackAlignmentBytes()>(RegisterAtOffsetList::bbqCalleeSaveRegisters().registerCount() * sizeof(UCPURegister));
5324+
#if CPU(X86_64) || CPU(ARM64)
5325+
m_jit.subPtr(GPRInfo::callFrameRegister, TrustedImm32(stackSizeForCalleeSaves), MacroAssembler::stackPointerRegister);
5326+
#else
5327+
m_jit.subPtr(GPRInfo::callFrameRegister, TrustedImm32(stackSizeForCalleeSaves), wasmScratchGPR);
5328+
m_jit.move(wasmScratchGPR, MacroAssembler::stackPointerRegister);
5329+
#endif
53235330
m_jit.emitSaveCalleeSavesFor(&RegisterAtOffsetList::bbqCalleeSaveRegisters());
53245331
}
53255332

Source/JavaScriptCore/wasm/WasmBBQJIT.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2230,7 +2230,7 @@ class BBQJIT {
22302230

22312231
void emitIncrementCallProfileCount(unsigned callProfileIndex);
22322232

2233-
void emitSaveCalleeSaves();
2233+
void emitPushCalleeSaves();
22342234
void emitRestoreCalleeSaves();
22352235

22362236
WasmOrigin origin();

0 commit comments

Comments
 (0)