Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (292371 => 292372)
--- trunk/Source/_javascript_Core/ChangeLog 2022-04-05 03:59:22 UTC (rev 292371)
+++ trunk/Source/_javascript_Core/ChangeLog 2022-04-05 04:10:35 UTC (rev 292372)
@@ -1,3 +1,82 @@
+2022-04-04 Yusuke Suzuki <[email protected]>
+
+ [JSC] Store CodeBlock in caller side
+ https://bugs.webkit.org/show_bug.cgi?id=238535
+
+ Reviewed by Saam Barati.
+
+ This patch changes the calling convention of JS functions. Now, we need to store CodeBlock to the stack in the caller side instead.
+ This helps LLInt, unlinked Baseline, and DFG since we no longer need to load CodeBlock from callee via costly dependent loads: unlinked
+ ones cannot embed CodeBlock raw pointer into the machine code itself. So we needed to load it from callee. But now, caller puts the
+ right CodeBlock pointer into the stack so we do not need that code. And in most cases, caller already knows CodeBlock since it is tied
+ to actually used machine code pointer.
+ OSR entry also materializes CodeBlock in the stack in the OSR entry side instead of doing it in the callee side.
+
+ This contributes to 0.3% progression in Speedometer2.
+
+ * assembler/CPU.h:
+ (JSC::prologueStackPointerDelta):
+ * bytecode/CallLinkInfo.cpp:
+ (JSC::CallLinkInfo::setMonomorphicCallee):
+ (JSC::CallLinkInfo::clearCallee):
+ (JSC::CallLinkInfo::revertCallToStub):
+ (JSC::CallLinkInfo::emitFastPathImpl):
+ (JSC::CallLinkInfo::setStub):
+ (JSC::OptimizingCallLinkInfo::emitDirectFastPath):
+ (JSC::OptimizingCallLinkInfo::emitDirectTailCallFastPath):
+ (JSC::OptimizingCallLinkInfo::initializeDirectCall):
+ (JSC::OptimizingCallLinkInfo::setDirectCallTarget):
+ * bytecode/CallLinkInfo.h:
+ (JSC::CallLinkInfo::offsetOfCodeBlock):
+ * bytecode/Repatch.cpp:
+ (JSC::linkMonomorphicCall):
+ (JSC::linkDirectCall):
+ (JSC::linkPolymorphicCall):
+ * bytecode/RepatchInlines.h:
+ (JSC::virtualForWithFunction):
+ * dfg/DFGJITCompiler.cpp:
+ (JSC::DFG::JITCompiler::compileEntry):
+ * dfg/DFGOSREntry.cpp:
+ (JSC::DFG::prepareOSREntry):
+ (JSC::DFG::prepareCatchOSREntry):
+ * dfg/DFGSpeculativeJIT.cpp:
+ (JSC::DFG::SpeculativeJIT::compileCurrentBlock):
+ * dfg/DFGThunks.cpp:
+ (JSC::DFG::osrEntryThunkGenerator):
+ * ftl/FTLAbstractHeapRepository.h:
+ * ftl/FTLLink.cpp:
+ (JSC::FTL::link):
+ * ftl/FTLLowerDFGToB3.cpp:
+ (JSC::FTL::DFG::LowerDFGToB3::lower):
+ * interpreter/CallFrame.h:
+ * jit/AssemblyHelpers.h:
+ (JSC::AssemblyHelpers::calleeFrameCodeBlockBeforeCall):
+ (JSC::AssemblyHelpers::calleeFrameCodeBlockBeforeTailCall):
+ (JSC::AssemblyHelpers::prologueStackPointerDelta): Deleted.
+ * jit/CCallHelpers.h:
+ (JSC::CCallHelpers::prepareForTailCallSlow):
+ * jit/JIT.cpp:
+ (JSC::JIT::compileAndLinkWithoutFinalizing):
+ (JSC::JIT::emitPutCodeBlockToFrameInPrologue): Deleted.
+ * jit/JIT.h:
+ * jit/JITOperations.cpp:
+ (JSC::JSC_DEFINE_JIT_OPERATION):
+ * jit/JITOperations.h:
+ * jit/ThunkGenerators.cpp:
+ (JSC::virtualThunkFor):
+ (JSC::boundFunctionCallGenerator):
+ (JSC::remoteFunctionCallGenerator):
+ * llint/LowLevelInterpreter.asm:
+ * llint/LowLevelInterpreter32_64.asm:
+ * llint/LowLevelInterpreter64.asm:
+ * llint/WebAssembly.asm:
+ * runtime/FunctionExecutable.h:
+ * runtime/JSCast.h:
+ * runtime/VM.cpp:
+ (JSC::VM::getRemoteFunction):
+ * wasm/WasmOperations.cpp:
+ (JSC::Wasm::doOSREntry):
+
2022-04-04 Saam Barati <[email protected]>
Turn off LLInt ICs in captive portal mode
Modified: trunk/Source/_javascript_Core/assembler/CPU.h (292371 => 292372)
--- trunk/Source/_javascript_Core/assembler/CPU.h 2022-04-05 03:59:22 UTC (rev 292371)
+++ trunk/Source/_javascript_Core/assembler/CPU.h 2022-04-05 04:10:35 UTC (rev 292372)
@@ -168,5 +168,23 @@
ALWAYS_INLINE int32_t hwPhysicalCPUMax() { return kernTCSMAwareNumberOfProcessorCores(); }
#endif
+constexpr size_t prologueStackPointerDelta()
+{
+#if ENABLE(C_LOOP)
+ // Prologue saves the framePointerRegister and linkRegister
+ return 2 * sizeof(CPURegister);
+#elif CPU(X86_64)
+ // Prologue only saves the framePointerRegister
+ return sizeof(CPURegister);
+#elif CPU(ARM_THUMB2) || CPU(ARM64) || CPU(MIPS) || CPU(RISCV64)
+ // Prologue saves the framePointerRegister and linkRegister
+ return 2 * sizeof(CPURegister);
+#else
+#error unsupported architectures
+#endif
+}
+
+
+
} // namespace JSC
Modified: trunk/Source/_javascript_Core/bytecode/CallLinkInfo.cpp (292371 => 292372)
--- trunk/Source/_javascript_Core/bytecode/CallLinkInfo.cpp 2022-04-05 03:59:22 UTC (rev 292371)
+++ trunk/Source/_javascript_Core/bytecode/CallLinkInfo.cpp 2022-04-05 04:10:35 UTC (rev 292372)
@@ -108,17 +108,19 @@
return m_doneLocation;
}
-void CallLinkInfo::setMonomorphicCallee(VM& vm, JSCell* owner, JSObject* callee, MacroAssemblerCodePtr<JSEntryPtrTag> codePtr)
+void CallLinkInfo::setMonomorphicCallee(VM& vm, JSCell* owner, JSObject* callee, CodeBlock* codeBlock, MacroAssemblerCodePtr<JSEntryPtrTag> codePtr)
{
RELEASE_ASSERT(!isDirect());
RELEASE_ASSERT(!(bitwise_cast<uintptr_t>(callee) & polymorphicCalleeMask));
m_calleeOrCodeBlock.set(vm, owner, callee);
- if (isDataIC())
+ if (isDataIC()) {
+ u.dataIC.m_codeBlock = codeBlock;
u.dataIC.m_monomorphicCallDestination = codePtr;
- else {
+ } else {
#if ENABLE(JIT)
MacroAssembler::repatchNearCall(static_cast<OptimizingCallLinkInfo*>(this)->m_callLocation, CodeLocationLabel<JSEntryPtrTag>(codePtr));
+ MacroAssembler::repatchPointer(u.codeIC.m_codeBlockLocation, codeBlock);
MacroAssembler::repatchPointer(u.codeIC.m_calleeLocation, callee);
#else
RELEASE_ASSERT_NOT_REACHED();
@@ -130,10 +132,12 @@
{
RELEASE_ASSERT(!isDirect());
m_calleeOrCodeBlock.clear();
- if (isDataIC())
+ if (isDataIC()) {
+ u.dataIC.m_codeBlock = nullptr;
u.dataIC.m_monomorphicCallDestination = nullptr;
- else if (!clearedByJettison()) {
+ } else if (!clearedByJettison()) {
#if ENABLE(JIT)
+ MacroAssembler::repatchPointer(u.codeIC.m_codeBlockLocation, nullptr);
MacroAssembler::repatchPointer(u.codeIC.m_calleeLocation, nullptr);
#else
RELEASE_ASSERT_NOT_REACHED();
@@ -298,9 +302,11 @@
if (isDataIC()) {
m_calleeOrCodeBlock.clear();
+ u.dataIC.m_codeBlock = nullptr;
u.dataIC.m_monomorphicCallDestination = nullptr;
} else {
#if ENABLE(JIT)
+ MacroAssembler::repatchPointer(u.codeIC.m_codeBlockLocation, nullptr);
CCallHelpers::revertJumpReplacementToBranchPtrWithPatch(
CCallHelpers::startOfBranchPtrWithPatchOnRegister(u.codeIC.m_calleeLocation), calleeGPR(), nullptr);
#else
@@ -366,9 +372,18 @@
if (isTailCall) {
prepareForTailCall();
+
+ GPRReg scratchGPR = CCallHelpers::selectScratchGPR(calleeGPR, callLinkInfoGPR);
+ jit.loadPtr(CCallHelpers::Address(callLinkInfoGPR, offsetOfCodeBlock()), scratchGPR);
+ jit.storePtr(scratchGPR, CCallHelpers::calleeFrameCodeBlockBeforeTailCall());
+
goPolymorphic.link(&jit); // Polymorphic stub handles tail call stack prep.
jit.farJump(CCallHelpers::Address(callLinkInfoGPR, offsetOfMonomorphicCallDestination()), JSEntryPtrTag);
} else {
+ GPRReg scratchGPR = CCallHelpers::selectScratchGPR(calleeGPR, callLinkInfoGPR);
+ jit.loadPtr(CCallHelpers::Address(callLinkInfoGPR, offsetOfCodeBlock()), scratchGPR);
+ jit.storePtr(scratchGPR, CCallHelpers::calleeFrameCodeBlockBeforeCall());
+
goPolymorphic.link(&jit);
jit.call(CCallHelpers::Address(callLinkInfoGPR, offsetOfMonomorphicCallDestination()), JSEntryPtrTag);
}
@@ -377,15 +392,20 @@
slowPath.append(jit.branchPtrWithPatch(CCallHelpers::NotEqual, calleeGPR, calleeCheck, CCallHelpers::TrustedImmPtr(nullptr)));
CCallHelpers::Call call;
+ CCallHelpers::DataLabelPtr codeBlockStore;
if (isTailCall) {
prepareForTailCall();
+ codeBlockStore = jit.storePtrWithPatch(CCallHelpers::TrustedImmPtr(nullptr), CCallHelpers::calleeFrameCodeBlockBeforeTailCall());
call = jit.nearTailCall();
- } else
+ } else {
+ codeBlockStore = jit.storePtrWithPatch(CCallHelpers::TrustedImmPtr(nullptr), CCallHelpers::calleeFrameCodeBlockBeforeCall());
call = jit.nearCall();
+ }
RELEASE_ASSERT(callLinkInfo);
jit.addLinkTask([=] (LinkBuffer& linkBuffer) {
static_cast<OptimizingCallLinkInfo*>(callLinkInfo)->m_callLocation = linkBuffer.locationOfNearCall<JSInternalPtrTag>(call);
+ callLinkInfo->u.codeIC.m_codeBlockLocation = linkBuffer.locationOf<JSInternalPtrTag>(codeBlockStore);
callLinkInfo->u.codeIC.m_calleeLocation = linkBuffer.locationOf<JSInternalPtrTag>(calleeCheck);
});
}
@@ -414,8 +434,10 @@
if (isDataIC()) {
*bitwise_cast<uintptr_t*>(m_calleeOrCodeBlock.slot()) = polymorphicCalleeMask;
+ u.dataIC.m_codeBlock = nullptr; // PolymorphicCallStubRoutine will set CodeBlock inside it.
u.dataIC.m_monomorphicCallDestination = m_stub->code().code().retagged<JSEntryPtrTag>();
} else {
+ MacroAssembler::repatchPointer(u.codeIC.m_codeBlockLocation, nullptr);
MacroAssembler::replaceWithJump(
MacroAssembler::startOfBranchPtrWithPatchOnRegister(u.codeIC.m_calleeLocation),
CodeLocationLabel<JITStubRoutinePtrTag>(m_stub->code().code()));
@@ -479,9 +501,11 @@
ASSERT(UseDataIC::No == this->useDataIC());
+ auto codeBlockStore = jit.storePtrWithPatch(CCallHelpers::TrustedImmPtr(nullptr), CCallHelpers::calleeFrameCodeBlockBeforeCall());
auto call = jit.nearCall();
jit.addLinkTask([=, this] (LinkBuffer& linkBuffer) {
m_callLocation = linkBuffer.locationOfNearCall<JSInternalPtrTag>(call);
+ u.codeIC.m_codeBlockLocation = linkBuffer.locationOf<JSInternalPtrTag>(codeBlockStore);
});
jit.addLateLinkTask([this] (LinkBuffer&) {
initializeDirectCall();
@@ -504,9 +528,11 @@
jit.emitNops(CCallHelpers::patchableJumpSize());
prepareForTailCall();
+ auto codeBlockStore = jit.storePtrWithPatch(CCallHelpers::TrustedImmPtr(nullptr), CCallHelpers::calleeFrameCodeBlockBeforeTailCall());
auto call = jit.nearTailCall();
jit.addLinkTask([=, this] (LinkBuffer& linkBuffer) {
m_callLocation = linkBuffer.locationOfNearCall<JSInternalPtrTag>(call);
+ u.codeIC.m_codeBlockLocation = linkBuffer.locationOf<JSInternalPtrTag>(codeBlockStore);
});
jit.addLateLinkTask([this] (LinkBuffer&) {
initializeDirectCall();
@@ -517,6 +543,7 @@
{
RELEASE_ASSERT(isDirect());
ASSERT(m_callLocation);
+ ASSERT(u.codeIC.m_codeBlockLocation);
if (isTailCall()) {
RELEASE_ASSERT(fastPathStart());
CCallHelpers::emitJITCodeOver(fastPathStart(), scopedLambda<void(CCallHelpers&)>([&](CCallHelpers& jit) {
@@ -529,7 +556,7 @@
MacroAssembler::repatchNearCall(m_callLocation, slowPathStart());
}
-void OptimizingCallLinkInfo::setDirectCallTarget(CodeLocationLabel<JSEntryPtrTag> target)
+void OptimizingCallLinkInfo::setDirectCallTarget(CodeBlock* codeBlock, CodeLocationLabel<JSEntryPtrTag> target)
{
RELEASE_ASSERT(isDirect());
@@ -543,6 +570,7 @@
}
MacroAssembler::repatchNearCall(m_callLocation, target);
+ MacroAssembler::repatchPointer(u.codeIC.m_codeBlockLocation, codeBlock);
}
#endif
Modified: trunk/Source/_javascript_Core/bytecode/CallLinkInfo.h (292371 => 292372)
--- trunk/Source/_javascript_Core/bytecode/CallLinkInfo.h 2022-04-05 03:59:22 UTC (rev 292371)
+++ trunk/Source/_javascript_Core/bytecode/CallLinkInfo.h 2022-04-05 04:10:35 UTC (rev 292372)
@@ -199,7 +199,7 @@
CodeLocationLabel<JSInternalPtrTag> doneLocation();
- void setMonomorphicCallee(VM&, JSCell*, JSObject* callee, MacroAssemblerCodePtr<JSEntryPtrTag>);
+ void setMonomorphicCallee(VM&, JSCell*, JSObject* callee, CodeBlock*, MacroAssemblerCodePtr<JSEntryPtrTag>);
void setSlowPathCallDestination(MacroAssemblerCodePtr<JSEntryPtrTag>);
void clearCallee();
JSObject* callee();
@@ -317,6 +317,11 @@
return OBJECT_OFFSETOF(CallLinkInfo, m_calleeOrCodeBlock);
}
+ static ptrdiff_t offsetOfCodeBlock()
+ {
+ return OBJECT_OFFSETOF(CallLinkInfo, u) + OBJECT_OFFSETOF(UnionType, dataIC.m_codeBlock);
+ }
+
static ptrdiff_t offsetOfMonomorphicCallDestination()
{
return OBJECT_OFFSETOF(CallLinkInfo, u) + OBJECT_OFFSETOF(UnionType, dataIC.m_monomorphicCallDestination);
@@ -401,14 +406,16 @@
MacroAssemblerCodePtr<JSEntryPtrTag> m_slowPathCallDestination;
union UnionType {
UnionType()
- : dataIC { nullptr }
+ : dataIC { nullptr, nullptr }
{ }
struct DataIC {
+ CodeBlock* m_codeBlock; // This is weekly held. And cleared whenever m_monomorphicCallDestination is changed.
MacroAssemblerCodePtr<JSEntryPtrTag> m_monomorphicCallDestination;
} dataIC;
struct {
+ CodeLocationDataLabelPtr<JSInternalPtrTag> m_codeBlockLocation;
CodeLocationDataLabelPtr<JSInternalPtrTag> m_calleeLocation;
} codeIC;
} u;
@@ -503,7 +510,7 @@
void emitDirectFastPath(CCallHelpers&);
void emitDirectTailCallFastPath(CCallHelpers&, ScopedLambda<void()>&& prepareForTailCall);
void initializeDirectCall();
- void setDirectCallTarget(CodeLocationLabel<JSEntryPtrTag>);
+ void setDirectCallTarget(CodeBlock*, CodeLocationLabel<JSEntryPtrTag>);
void emitSlowPath(VM&, CCallHelpers&);
MacroAssembler::JumpList emitFastPath(CCallHelpers&, GPRReg calleeGPR, GPRReg callLinkInfoGPR) WARN_UNUSED_RETURN;
Modified: trunk/Source/_javascript_Core/bytecode/Repatch.cpp (292371 => 292372)
--- trunk/Source/_javascript_Core/bytecode/Repatch.cpp 2022-04-05 03:59:22 UTC (rev 292371)
+++ trunk/Source/_javascript_Core/bytecode/Repatch.cpp 2022-04-05 04:10:35 UTC (rev 292372)
@@ -117,7 +117,7 @@
ASSERT(owner);
ASSERT(!callLinkInfo.isLinked());
- callLinkInfo.setMonomorphicCallee(vm, owner, callee, codePtr);
+ callLinkInfo.setMonomorphicCallee(vm, owner, callee, calleeCodeBlock, codePtr);
callLinkInfo.setLastSeenCallee(vm, owner, callee);
if (shouldDumpDisassemblyFor(callerCodeBlock))
@@ -1567,7 +1567,7 @@
if (shouldDumpDisassemblyFor(callerCodeBlock))
dataLog("Linking call in ", FullCodeOrigin(callerCodeBlock, callLinkInfo.codeOrigin()), " to ", pointerDump(calleeCodeBlock), ", entrypoint at ", codePtr, "\n");
- callLinkInfo.setDirectCallTarget(CodeLocationLabel<JSEntryPtrTag>(codePtr));
+ callLinkInfo.setDirectCallTarget(jsCast<FunctionCodeBlock*>(calleeCodeBlock), CodeLocationLabel<JSEntryPtrTag>(codePtr));
if (calleeCodeBlock)
calleeCodeBlock->linkIncomingCall(callFrame, &callLinkInfo);
@@ -1790,7 +1790,8 @@
while (binarySwitch.advance(stubJit)) {
size_t caseIndex = binarySwitch.caseIndex();
- CallVariant variant = callCases[caseIndex].variant();
+ PolymorphicCallCase& callCase = callCases[caseIndex];
+ CallVariant variant = callCase.variant();
MacroAssemblerCodePtr<JSEntryPtrTag> codePtr;
if (variant.executable()) {
@@ -1813,14 +1814,23 @@
bool needsDoneJump = false;
if (frameShuffler) {
CallFrameShuffler(stubJit, frameShuffler->snapshot()).prepareForTailCall();
+ if (callCase.codeBlock())
+ stubJit.storePtr(CCallHelpers::TrustedImmPtr(callCase.codeBlock()), CCallHelpers::calleeFrameCodeBlockBeforeTailCall());
calls[caseIndex].call = stubJit.nearTailCall();
} else if (callLinkInfo.isTailCall()) {
stubJit.prepareForTailCallSlow();
+ if (callCase.codeBlock())
+ stubJit.storePtr(CCallHelpers::TrustedImmPtr(callCase.codeBlock()), CCallHelpers::calleeFrameCodeBlockBeforeTailCall());
calls[caseIndex].call = stubJit.nearTailCall();
} else {
- if (isDataIC)
+ ASSERT(!callLinkInfo.isTailCall());
+ if (isDataIC) {
+ if (callCase.codeBlock())
+ stubJit.storePtr(CCallHelpers::TrustedImmPtr(callCase.codeBlock()), CCallHelpers::calleeFrameCodeBlockBeforeTailCall());
calls[caseIndex].call = stubJit.nearTailCall();
- else {
+ } else {
+ if (callCase.codeBlock())
+ stubJit.storePtr(CCallHelpers::TrustedImmPtr(callCase.codeBlock()), CCallHelpers::calleeFrameCodeBlockBeforeCall());
calls[caseIndex].call = stubJit.nearCall();
needsDoneJump = true;
}
Modified: trunk/Source/_javascript_Core/bytecode/RepatchInlines.h (292371 => 292372)
--- trunk/Source/_javascript_Core/bytecode/RepatchInlines.h 2022-04-05 03:59:22 UTC (rev 292371)
+++ trunk/Source/_javascript_Core/bytecode/RepatchInlines.h 2022-04-05 04:10:35 UTC (rev 292372)
@@ -195,8 +195,8 @@
DeferTraps deferTraps(vm); // We can't jettison if we're going to call this CodeBlock.
- if (UNLIKELY(!executable->hasJITCodeFor(kind))) {
- FunctionExecutable* functionExecutable = static_cast<FunctionExecutable*>(executable);
+ if (!executable->isHostFunction()) {
+ FunctionExecutable* functionExecutable = jsCast<FunctionExecutable*>(executable);
auto handleThrowException = [&] () {
void* throwTarget = vm.getCTIThrowExceptionFromCallSlowPath().code().executableAddress();
@@ -212,6 +212,7 @@
functionExecutable->prepareForExecution<FunctionExecutable>(vm, function, scope, kind, *codeBlockSlot);
RETURN_IF_EXCEPTION(throwScope, handleThrowException());
}
+
// FIXME: Support wasm IC.
// https://bugs.webkit.org/show_bug.cgi?id=220339
return encodeResult(executable->entrypointFor(
Modified: trunk/Source/_javascript_Core/dfg/DFGJITCompiler.cpp (292371 => 292372)
--- trunk/Source/_javascript_Core/dfg/DFGJITCompiler.cpp 2022-04-05 03:59:22 UTC (rev 292371)
+++ trunk/Source/_javascript_Core/dfg/DFGJITCompiler.cpp 2022-04-05 04:10:35 UTC (rev 292372)
@@ -40,6 +40,7 @@
#include "JSCJSValueInlines.h"
#include "LinkBuffer.h"
#include "MaxFrameExtentForSlowPathCall.h"
+#include "ProbeContext.h"
#include "ThunkGenerators.h"
#include "VM.h"
@@ -110,7 +111,12 @@
// check) which will be dependent on stack layout. (We'd need to account for this in
// both normal return code and when jumping to an exception handler).
emitFunctionPrologue();
- emitPutToCallFrameHeader(m_codeBlock, CallFrameSlot::codeBlock);
+#if ASSERT_ENABLED
+ probeDebug([=](Probe::Context& ctx) {
+ CodeBlock* codeBlock = ctx.fp<CallFrame*>()->codeBlock();
+ RELEASE_ASSERT(codeBlock->jitType() == JITType::DFGJIT);
+ });
+#endif
}
void JITCompiler::compileSetupRegistersForEntry()
Modified: trunk/Source/_javascript_Core/dfg/DFGOSREntry.cpp (292371 => 292372)
--- trunk/Source/_javascript_Core/dfg/DFGOSREntry.cpp 2022-04-05 03:59:22 UTC (rev 292371)
+++ trunk/Source/_javascript_Core/dfg/DFGOSREntry.cpp 2022-04-05 04:10:35 UTC (rev 292372)
@@ -334,9 +334,9 @@
}
}
#endif
-
+
// 7) Fix the call frame to have the right code block.
-
+
*bitwise_cast<CodeBlock**>(pivot - (CallFrameSlot::codeBlock + 1)) = codeBlock;
dataLogLnIf(Options::verboseOSR(), " OSR returning data buffer ", RawPointer(scratch));
@@ -408,6 +408,10 @@
// The active length of catchOSREntryBuffer will be zeroed by ClearCatchLocals node.
dfgCommon->catchOSREntryBuffer->setActiveLength(sizeof(JSValue) * index);
+
+ // At this point, we're committed to triggering an OSR entry immediately after we return. Hence, it is safe to modify stack here.
+ callFrame->setCodeBlock(optimizedCodeBlock);
+
return catchEntrypoint->machineCode;
}
Modified: trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT.cpp (292371 => 292372)
--- trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT.cpp 2022-04-05 03:59:22 UTC (rev 292371)
+++ trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT.cpp 2022-04-05 04:10:35 UTC (rev 292372)
@@ -2217,7 +2217,7 @@
m_jit.addPtr(CCallHelpers::TrustedImm32(-(m_jit.graph().frameRegisterCount() * sizeof(Register))), GPRInfo::callFrameRegister, CCallHelpers::stackPointerRegister);
m_jit.emitSaveCalleeSaves();
m_jit.emitMaterializeTagCheckRegisters();
- m_jit.emitPutToCallFrameHeader(m_jit.codeBlock(), CallFrameSlot::codeBlock);
+ // CodeBlock in the stack is already replaced in OSR entry.
}
m_stream->appendAndLog(VariableEvent::reset());
@@ -11298,7 +11298,7 @@
m_jit.loadPtr(MacroAssembler::Address(executable.gpr(), FunctionExecutable::offsetOfRareData()), result.gpr());
slowCases.append(m_jit.branchTestPtr(MacroAssembler::Zero, result.gpr()));
- m_jit.loadPtr(MacroAssembler::Address(result.gpr(), FunctionExecutable::offsetOfAsStringInRareData()), result.gpr());
+ m_jit.loadPtr(MacroAssembler::Address(result.gpr(), FunctionExecutable::RareData::offsetOfAsString()), result.gpr());
JITCompiler::Jump continuation = m_jit.jump();
isNativeExecutable.link(&m_jit);
Modified: trunk/Source/_javascript_Core/dfg/DFGThunks.cpp (292371 => 292372)
--- trunk/Source/_javascript_Core/dfg/DFGThunks.cpp 2022-04-05 03:59:22 UTC (rev 292371)
+++ trunk/Source/_javascript_Core/dfg/DFGThunks.cpp 2022-04-05 04:10:35 UTC (rev 292372)
@@ -37,6 +37,7 @@
#include "GPRInfo.h"
#include "LinkBuffer.h"
#include "MacroAssembler.h"
+#include "ProbeContext.h"
namespace JSC { namespace DFG {
@@ -148,6 +149,7 @@
jit.negPtr(GPRInfo::regT1, GPRInfo::regT2);
jit.getEffectiveAddress(MacroAssembler::BaseIndex(GPRInfo::callFrameRegister, GPRInfo::regT2, MacroAssembler::TimesEight), MacroAssembler::stackPointerRegister);
+ // Copying locals and header from scratch buffer to the new CallFrame. This also replaces
MacroAssembler::Label loop = jit.label();
jit.subPtr(MacroAssembler::TrustedImm32(1), GPRInfo::regT1);
jit.negPtr(GPRInfo::regT1, GPRInfo::regT4);
@@ -160,6 +162,14 @@
jit.abortWithReason(DFGUnreasonableOSREntryJumpDestination);
ok.link(&jit);
+
+#if ASSERT_ENABLED
+ jit.probeDebug([](Probe::Context& ctx) {
+ CodeBlock* codeBlock = ctx.fp<CallFrame*>()->codeBlock();
+ RELEASE_ASSERT(JITCode::isOptimizingJIT(codeBlock->jitType()));
+ });
+#endif
+
jit.restoreCalleeSavesFromEntryFrameCalleeSavesBuffer(vm.topEntryFrame);
jit.emitMaterializeTagCheckRegisters();
Modified: trunk/Source/_javascript_Core/ftl/FTLAbstractHeapRepository.h (292371 => 292372)
--- trunk/Source/_javascript_Core/ftl/FTLAbstractHeapRepository.h 2022-04-05 03:59:22 UTC (rev 292371)
+++ trunk/Source/_javascript_Core/ftl/FTLAbstractHeapRepository.h 2022-04-05 04:10:35 UTC (rev 292372)
@@ -78,7 +78,7 @@
macro(DirectArguments_mappedArguments, DirectArguments::offsetOfMappedArguments()) \
macro(DirectArguments_modifiedArgumentsDescriptor, DirectArguments::offsetOfModifiedArgumentsDescriptor()) \
macro(FunctionExecutable_rareData, FunctionExecutable::offsetOfRareData()) \
- macro(FunctionExecutableRareData_asString, FunctionExecutable::offsetOfAsStringInRareData()) \
+ macro(FunctionExecutableRareData_asString, FunctionExecutable::RareData::offsetOfAsString()) \
macro(FunctionRareData_allocator, FunctionRareData::offsetOfObjectAllocationProfile() + ObjectAllocationProfileWithPrototype::offsetOfAllocator()) \
macro(FunctionRareData_structure, FunctionRareData::offsetOfObjectAllocationProfile() + ObjectAllocationProfileWithPrototype::offsetOfStructure()) \
macro(FunctionRareData_prototype, FunctionRareData::offsetOfObjectAllocationProfile() + ObjectAllocationProfileWithPrototype::offsetOfPrototype()) \
Modified: trunk/Source/_javascript_Core/ftl/FTLLink.cpp (292371 => 292372)
--- trunk/Source/_javascript_Core/ftl/FTLLink.cpp 2022-04-05 03:59:22 UTC (rev 292371)
+++ trunk/Source/_javascript_Core/ftl/FTLLink.cpp 2022-04-05 04:10:35 UTC (rev 292372)
@@ -59,7 +59,7 @@
std::unique_ptr<LinkBuffer> linkBuffer;
CCallHelpers::Address frame = CCallHelpers::Address(
- CCallHelpers::stackPointerRegister, -static_cast<int32_t>(AssemblyHelpers::prologueStackPointerDelta()));
+ CCallHelpers::stackPointerRegister, -static_cast<int32_t>(prologueStackPointerDelta()));
switch (graph.m_plan.mode()) {
case JITCompilationMode::FTL: {
Modified: trunk/Source/_javascript_Core/ftl/FTLLowerDFGToB3.cpp (292371 => 292372)
--- trunk/Source/_javascript_Core/ftl/FTLLowerDFGToB3.cpp 2022-04-05 03:59:22 UTC (rev 292371)
+++ trunk/Source/_javascript_Core/ftl/FTLLowerDFGToB3.cpp 2022-04-05 04:10:35 UTC (rev 292372)
@@ -198,15 +198,14 @@
{
m_proc.setNumEntrypoints(m_graph.m_numberOfEntrypoints);
- CodeBlock* codeBlock = m_graph.m_codeBlock;
Ref<B3::Air::PrologueGenerator> catchPrologueGenerator = createSharedTask<B3::Air::PrologueGeneratorFunction>(
- [codeBlock] (CCallHelpers& jit, B3::Air::Code& code) {
+ [](CCallHelpers& jit, B3::Air::Code& code) {
AllowMacroScratchRegisterUsage allowScratch(jit);
jit.addPtr(CCallHelpers::TrustedImm32(-code.frameSize()), GPRInfo::callFrameRegister, CCallHelpers::stackPointerRegister);
jit.emitSave(code.calleeSaveRegisterAtOffsetList());
- jit.emitPutToCallFrameHeader(codeBlock, VirtualRegister(CallFrameSlot::codeBlock));
+ // CodeBlock in the stack is already replaced in FTL::prepareOSREntry.
});
for (unsigned catchEntrypointIndex : m_graph.m_entrypointIndexToCatchBytecodeIndex.keys()) {
@@ -272,9 +271,7 @@
m_proc.addFastConstant(m_numberTag->key());
m_proc.addFastConstant(m_notCellMask->key());
- // We don't want the CodeBlock to have a weak pointer to itself because
- // that would cause it to always get collected.
- m_out.storePtr(m_out.constIntPtr(bitwise_cast<intptr_t>(codeBlock())), addressFor(VirtualRegister(CallFrameSlot::codeBlock)));
+ // When running FTL code, we already store CodeBlock to CallFrameSlot::codeBlock.
// Stack Overflow Check.
unsigned exitFrameSize = m_graph.requiredRegisterCountForExit() * sizeof(Register);
@@ -293,6 +290,13 @@
unsigned ftlFrameSize = params.proc().frameSize();
unsigned maxFrameSize = std::max(exitFrameSize, ftlFrameSize);
+#if ASSERT_ENABLED
+ jit.probeDebug([=](Probe::Context& ctx) {
+ CodeBlock* codeBlock = ctx.fp<CallFrame*>()->codeBlock();
+ RELEASE_ASSERT(codeBlock->jitType() == JITType::FTLJIT);
+ });
+#endif
+
jit.addPtr(MacroAssembler::TrustedImm32(-maxFrameSize), fp, scratch);
MacroAssembler::JumpList stackOverflow;
if (UNLIKELY(maxFrameSize > Options::reservedZoneSize()))
Modified: trunk/Source/_javascript_Core/interpreter/CallFrame.h (292371 => 292372)
--- trunk/Source/_javascript_Core/interpreter/CallFrame.h 2022-04-05 03:59:22 UTC (rev 292371)
+++ trunk/Source/_javascript_Core/interpreter/CallFrame.h 2022-04-05 04:10:35 UTC (rev 292372)
@@ -23,6 +23,7 @@
#pragma once
#include "AbstractPC.h"
+#include "CPU.h"
#include "CalleeBits.h"
#include "MacroAssemblerCodeRef.h"
#include "Register.h"
@@ -104,7 +105,42 @@
static constexpr int sizeInRegisters = 2 * sizeof(CPURegister) / sizeof(Register);
};
static_assert(CallerFrameAndPC::sizeInRegisters == sizeof(CallerFrameAndPC) / sizeof(Register), "CallerFrameAndPC::sizeInRegisters is incorrect.");
+ static_assert(sizeof(CallerFrameAndPC) >= prologueStackPointerDelta());
+#if !CPU(X86_64)
+ // Only x86_64 "call" pushes return address on the stack. Other architecture pushes in the function prologue after the call.
+ static_assert(sizeof(CallerFrameAndPC) == prologueStackPointerDelta());
+#endif
+ // Layout of CallFrame
+ //
+ // | ...... | |
+ // +----------------------------+ |
+ // | argN | v lower address
+ // +----------------------------+
+ // | arg1 |
+ // +----------------------------+
+ // | arg0 |
+ // +----------------------------+
+ // | this |
+ // +----------------------------+
+ // | argumentCountIncludingThis |
+ // +----------------------------+
+ // | callee |
+ // +----------------------------+
+ // | codeBlock |
+ // +----------------------------+
+ // | return-address |
+ // +----------------------------+
+ // | callerFrame |
+ // +----------------------------+ <- callee's cfr is pointing this address
+ // | local0 |
+ // +----------------------------+
+ // | local1 |
+ // +----------------------------+
+ // | localN |
+ // +----------------------------+
+ // | ...... |
+
enum class CallFrameSlot {
codeBlock = CallerFrameAndPC::sizeInRegisters,
callee = codeBlock + 1,
Modified: trunk/Source/_javascript_Core/jit/AssemblyHelpers.h (292371 => 292372)
--- trunk/Source/_javascript_Core/jit/AssemblyHelpers.h 2022-04-05 03:59:22 UTC (rev 292371)
+++ trunk/Source/_javascript_Core/jit/AssemblyHelpers.h 2022-04-05 04:10:35 UTC (rev 292372)
@@ -406,12 +406,6 @@
}
#if CPU(X86_64)
- static constexpr size_t prologueStackPointerDelta()
- {
- // Prologue only saves the framePointerRegister
- return sizeof(void*);
- }
-
void emitFunctionPrologue()
{
push(framePointerRegister);
@@ -477,12 +471,6 @@
#endif // CPU(X86_64)
#if CPU(ARM_THUMB2) || CPU(ARM64)
- static constexpr size_t prologueStackPointerDelta()
- {
- // Prologue saves the framePointerRegister and linkRegister
- return 2 * sizeof(void*);
- }
-
void emitFunctionPrologue()
{
tagReturnAddress();
@@ -528,12 +516,6 @@
#endif
#if CPU(MIPS)
- static constexpr size_t prologueStackPointerDelta()
- {
- // Prologue saves the framePointerRegister and returnAddressRegister
- return 2 * sizeof(void*);
- }
-
void emitFunctionPrologue()
{
pushPair(framePointerRegister, returnAddressRegister);
@@ -568,12 +550,6 @@
#endif
#if CPU(RISCV64)
- static constexpr size_t prologueStackPointerDelta()
- {
- // Prologue saves the framePointerRegister and returnAddressRegister
- return 2 * sizeof(void*);
- }
-
void emitFunctionPrologue()
{
pushPair(framePointerRegister, linkRegister);
@@ -1281,6 +1257,17 @@
return calleeFrameSlot(VirtualRegister(0)).withOffset(CallFrame::callerFrameOffset());
}
+ static Address calleeFrameCodeBlockBeforeCall()
+ {
+ return calleeFramePayloadSlot(CallFrameSlot::codeBlock);
+ }
+
+ static Address calleeFrameCodeBlockBeforeTailCall()
+ {
+ // The stackPointerRegister state is "after the call, but before the function prologue".
+ return calleeFramePayloadSlot(CallFrameSlot::codeBlock).withOffset(sizeof(CallerFrameAndPC) - prologueStackPointerDelta());
+ }
+
static GPRReg selectScratchGPR(RegisterSet preserved)
{
GPRReg registers[] = {
Modified: trunk/Source/_javascript_Core/jit/CCallHelpers.h (292371 => 292372)
--- trunk/Source/_javascript_Core/jit/CCallHelpers.h 2022-04-05 03:59:22 UTC (rev 292371)
+++ trunk/Source/_javascript_Core/jit/CCallHelpers.h 2022-04-05 04:10:35 UTC (rev 292372)
@@ -744,12 +744,20 @@
farJump(GPRInfo::regT1, ExceptionHandlerPtrTag);
}
- void prepareForTailCallSlow(GPRReg preservedGPR = InvalidGPRReg)
+ void prepareForTailCallSlow(GPRReg preservedGPR1 = InvalidGPRReg, GPRReg preservedGPR2 = InvalidGPRReg)
{
- GPRReg temp1 = preservedGPR == GPRInfo::regT0 ? GPRInfo::regT3 : GPRInfo::regT0;
- GPRReg temp2 = preservedGPR == GPRInfo::regT1 ? GPRInfo::regT3 : GPRInfo::regT1;
- GPRReg temp3 = preservedGPR == GPRInfo::regT2 ? GPRInfo::regT3 : GPRInfo::regT2;
+ RegisterSet preserved;
+ if (preservedGPR1 != InvalidGPRReg)
+ preserved.add(preservedGPR1);
+ if (preservedGPR2 != InvalidGPRReg)
+ preserved.add(preservedGPR2);
+ GPRReg temp1 = selectScratchGPR(preserved);
+ preserved.add(temp1);
+ GPRReg temp2 = selectScratchGPR(preserved);
+ preserved.add(temp2);
+ GPRReg temp3 = selectScratchGPR(preserved);
+
GPRReg newFramePointer = temp1;
GPRReg newFrameSizeGPR = temp2;
{
Modified: trunk/Source/_javascript_Core/jit/JIT.cpp (292371 => 292372)
--- trunk/Source/_javascript_Core/jit/JIT.cpp 2022-04-05 03:59:22 UTC (rev 292371)
+++ trunk/Source/_javascript_Core/jit/JIT.cpp 2022-04-05 04:10:35 UTC (rev 292372)
@@ -203,28 +203,6 @@
slowPathCall.call();
}
-void JIT::emitPutCodeBlockToFrameInPrologue(GPRReg result)
-{
- RELEASE_ASSERT(m_unlinkedCodeBlock->codeType() == FunctionCode);
- emitGetFromCallFrameHeaderPtr(CallFrameSlot::callee, result);
- loadPtr(Address(result, JSFunction::offsetOfExecutableOrRareData()), result);
- auto hasExecutable = branchTestPtr(Zero, result, CCallHelpers::TrustedImm32(JSFunction::rareDataTag));
- loadPtr(Address(result, FunctionRareData::offsetOfExecutable() - JSFunction::rareDataTag), result);
- hasExecutable.link(this);
- if (m_unlinkedCodeBlock->isConstructor())
- loadPtr(Address(result, FunctionExecutable::offsetOfCodeBlockForConstruct()), result);
- else
- loadPtr(Address(result, FunctionExecutable::offsetOfCodeBlockForCall()), result);
- emitPutToCallFrameHeader(result, CallFrameSlot::codeBlock);
-
-#if ASSERT_ENABLED
- probeDebug([=] (Probe::Context& ctx) {
- CodeBlock* codeBlock = ctx.fp<CallFrame*>()->codeBlock();
- RELEASE_ASSERT(codeBlock->jitType() == JITType::BaselineJIT);
- });
-#endif
-}
-
void JIT::privateCompileMainPass()
{
if (JITInternal::verbose)
@@ -751,10 +729,8 @@
m_pcToCodeOriginMapBuilder.appendItem(label(), CodeOrigin(BytecodeIndex(0)));
std::optional<JITSizeStatistics::Marker> sizeMarker;
- if (UNLIKELY(Options::dumpBaselineJITSizeStatistics())) {
- String id = makeString("Baseline_prologue");
- sizeMarker = m_vm->jitSizeStatistics->markStart(id, *this);
- }
+ if (UNLIKELY(Options::dumpBaselineJITSizeStatistics()))
+ sizeMarker = m_vm->jitSizeStatistics->markStart("Baseline_prologue"_s, *this);
Label entryLabel(this);
if (m_disassembler)
@@ -765,8 +741,15 @@
nop();
emitFunctionPrologue();
- if (m_unlinkedCodeBlock->codeType() == FunctionCode)
- emitPutCodeBlockToFrameInPrologue();
+#if ASSERT_ENABLED
+ probeDebug([=](Probe::Context& ctx) {
+ CodeBlock* codeBlock = ctx.fp<CallFrame*>()->codeBlock();
+ if (codeBlock->jitType() != JITType::BaselineJIT) {
+ dataLogLn("FP ", RawPointer(ctx.fp<CallFrame*>()));
+ RELEASE_ASSERT_NOT_REACHED();
+ }
+ });
+#endif
Label beginLabel(this);
@@ -829,7 +812,17 @@
m_arityCheck = label();
emitFunctionPrologue();
- emitPutCodeBlockToFrameInPrologue(regT0);
+ RELEASE_ASSERT(m_unlinkedCodeBlock->codeType() == FunctionCode);
+#if ASSERT_ENABLED
+ probeDebug([=](Probe::Context& ctx) {
+ CodeBlock* codeBlock = ctx.fp<CallFrame*>()->codeBlock();
+ if (codeBlock->jitType() != JITType::BaselineJIT) {
+ dataLogLn("FP ", RawPointer(ctx.fp<CallFrame*>()));
+ RELEASE_ASSERT_NOT_REACHED();
+ }
+ });
+#endif
+ emitGetFromCallFrameHeaderPtr(CallFrameSlot::codeBlock, regT0);
store8(TrustedImm32(0), Address(regT0, CodeBlock::offsetOfShouldAlwaysBeInlined()));
load32(payloadFor(CallFrameSlot::argumentCountIncludingThis), regT1);
Modified: trunk/Source/_javascript_Core/jit/JIT.h (292371 => 292372)
--- trunk/Source/_javascript_Core/jit/JIT.h 2022-04-05 03:59:22 UTC (rev 292371)
+++ trunk/Source/_javascript_Core/jit/JIT.h 2022-04-05 04:10:35 UTC (rev 292372)
@@ -261,8 +261,6 @@
void loadCodeBlockConstantTag(VirtualRegister, RegisterID);
#endif
- void emitPutCodeBlockToFrameInPrologue(GPRReg result = regT0);
-
void exceptionCheck(Jump jumpToHandler)
{
m_exceptionChecks.append(jumpToHandler);
Modified: trunk/Source/_javascript_Core/jit/JITOperations.cpp (292371 => 292372)
--- trunk/Source/_javascript_Core/jit/JITOperations.cpp 2022-04-05 03:59:22 UTC (rev 292371)
+++ trunk/Source/_javascript_Core/jit/JITOperations.cpp 2022-04-05 04:10:35 UTC (rev 292372)
@@ -158,7 +158,7 @@
RELEASE_AND_RETURN(scope, JSValue::encode(getWrappedValue(globalObject, globalObject, JSValue::decode(encodedValue))));
}
-JSC_DEFINE_JIT_OPERATION(operationMaterializeRemoteFunctionTargetCode, void*, (JSRemoteFunction* callee))
+JSC_DEFINE_JIT_OPERATION(operationMaterializeRemoteFunctionTargetCode, SlowPathReturnType, (JSRemoteFunction* callee))
{
JSGlobalObject* globalObject = callee->globalObject();
VM& vm = globalObject->vm();
@@ -175,14 +175,14 @@
// Force the executable to cache its arity entrypoint.
{
DeferTraps deferTraps(vm); // We can't jettison any code until after we link the call.
+ CodeBlock* codeBlockSlot = nullptr;
if (!executable->isHostFunction()) {
JSScope* scope = targetFunction->scopeUnchecked();
FunctionExecutable* functionExecutable = static_cast<FunctionExecutable*>(executable);
- CodeBlock* codeBlockSlot = nullptr;
functionExecutable->prepareForExecution<FunctionExecutable>(vm, targetFunction, scope, CodeForCall, codeBlockSlot);
- RETURN_IF_EXCEPTION(throwScope, nullptr);
+ RETURN_IF_EXCEPTION(throwScope, encodeResult(nullptr, nullptr));
}
- return executable->entrypointFor(CodeForCall, MustCheckArity).executableAddress();
+ return encodeResult(executable->entrypointFor(CodeForCall, MustCheckArity).executableAddress(), codeBlockSlot);
}
}
Modified: trunk/Source/_javascript_Core/jit/JITOperations.h (292371 => 292372)
--- trunk/Source/_javascript_Core/jit/JITOperations.h 2022-04-05 03:59:22 UTC (rev 292371)
+++ trunk/Source/_javascript_Core/jit/JITOperations.h 2022-04-05 04:10:35 UTC (rev 292372)
@@ -161,7 +161,7 @@
JSC_DECLARE_JIT_OPERATION(operationThrowIteratorResultIsNotObject, void, (JSGlobalObject*));
JSC_DECLARE_JIT_OPERATION(operationGetWrappedValueForCaller, EncodedJSValue, (JSRemoteFunction*, EncodedJSValue));
JSC_DECLARE_JIT_OPERATION(operationGetWrappedValueForTarget, EncodedJSValue, (JSRemoteFunction*, EncodedJSValue));
-JSC_DECLARE_JIT_OPERATION(operationMaterializeRemoteFunctionTargetCode, void*, (JSRemoteFunction*));
+JSC_DECLARE_JIT_OPERATION(operationMaterializeRemoteFunctionTargetCode, SlowPathReturnType, (JSRemoteFunction*));
JSC_DECLARE_JIT_OPERATION(operationThrowRemoteFunctionException, EncodedJSValue, (JSRemoteFunction*));
JSC_DECLARE_JIT_OPERATION(operationThrowStackOverflowError, void, (CodeBlock*));
Modified: trunk/Source/_javascript_Core/jit/ThunkGenerators.cpp (292371 => 292372)
--- trunk/Source/_javascript_Core/jit/ThunkGenerators.cpp 2022-04-05 03:59:22 UTC (rev 292371)
+++ trunk/Source/_javascript_Core/jit/ThunkGenerators.cpp 2022-04-05 04:10:35 UTC (rev 292372)
@@ -288,25 +288,29 @@
// Now we know we have a JSFunction.
- jit.loadPtr(CCallHelpers::Address(GPRInfo::regT0, JSFunction::offsetOfExecutableOrRareData()), GPRInfo::regT4);
- auto hasExecutable = jit.branchTestPtr(CCallHelpers::Zero, GPRInfo::regT4, CCallHelpers::TrustedImm32(JSFunction::rareDataTag));
- jit.loadPtr(CCallHelpers::Address(GPRInfo::regT4, FunctionRareData::offsetOfExecutable() - JSFunction::rareDataTag), GPRInfo::regT4);
+ jit.loadPtr(CCallHelpers::Address(GPRInfo::regT0, JSFunction::offsetOfExecutableOrRareData()), GPRInfo::regT0);
+ auto hasExecutable = jit.branchTestPtr(CCallHelpers::Zero, GPRInfo::regT0, CCallHelpers::TrustedImm32(JSFunction::rareDataTag));
+ jit.loadPtr(CCallHelpers::Address(GPRInfo::regT0, FunctionRareData::offsetOfExecutable() - JSFunction::rareDataTag), GPRInfo::regT0);
hasExecutable.link(&jit);
jit.loadPtr(
- CCallHelpers::Address(GPRInfo::regT4, ExecutableBase::offsetOfJITCodeWithArityCheckFor(kind)),
+ CCallHelpers::Address(GPRInfo::regT0, ExecutableBase::offsetOfJITCodeWithArityCheckFor(kind)),
GPRInfo::regT4);
slowCase.append(jit.branchTestPtr(CCallHelpers::Zero, GPRInfo::regT4));
- // Now we know that we have a CodeBlock, and we're committed to making a fast
- // call.
+ // Now we know that we have a CodeBlock, and we're committed to making a fast call.
+ auto isNative = jit.branchIfNotType(GPRInfo::regT0, FunctionExecutableType);
+ jit.loadPtr(
+ CCallHelpers::Address(GPRInfo::regT0, FunctionExecutable::offsetOfCodeBlockFor(kind)),
+ GPRInfo::regT5);
+
// Make a tail call. This will return back to JIT code.
- JSInterfaceJIT::Label callCode(jit.label());
emitPointerValidation(jit, GPRInfo::regT4, JSEntryPtrTag);
if (isTailCall) {
jit.preserveReturnAddressAfterCall(GPRInfo::regT0);
- jit.prepareForTailCallSlow(GPRInfo::regT4);
+ jit.prepareForTailCallSlow(GPRInfo::regT4, GPRInfo::regT5);
}
+ jit.storePtr(GPRInfo::regT5, CCallHelpers::calleeFrameCodeBlockBeforeTailCall());
jit.farJump(GPRInfo::regT4, JSEntryPtrTag);
// NullSetterFunctionType does not get the fast path support. But it is OK since using NullSetterFunctionType is extremely rare.
@@ -314,8 +318,15 @@
slowCase.append(jit.branchIfNotType(GPRInfo::regT0, InternalFunctionType));
void* executableAddress = vm.getCTIInternalFunctionTrampolineFor(kind).executableAddress();
jit.move(CCallHelpers::TrustedImmPtr(executableAddress), GPRInfo::regT4);
- jit.jump().linkTo(callCode, &jit);
+ isNative.link(&jit);
+ emitPointerValidation(jit, GPRInfo::regT4, JSEntryPtrTag);
+ if (isTailCall) {
+ jit.preserveReturnAddressAfterCall(GPRInfo::regT0);
+ jit.prepareForTailCallSlow(GPRInfo::regT4);
+ }
+ jit.farJump(GPRInfo::regT4, JSEntryPtrTag);
+
slowCase.link(&jit);
// Here we don't know anything, so revert to the full slow path.
@@ -1386,11 +1397,20 @@
jit.loadPtr(
CCallHelpers::Address(
GPRInfo::regT0, ExecutableBase::offsetOfJITCodeWithArityCheckFor(CodeForCall)),
- GPRInfo::regT0);
- CCallHelpers::Jump noCode = jit.branchTestPtr(CCallHelpers::Zero, GPRInfo::regT0);
+ GPRInfo::regT1);
+ CCallHelpers::Jump noCode = jit.branchTestPtr(CCallHelpers::Zero, GPRInfo::regT1);
+
+ auto isNative = jit.branchIfNotType(GPRInfo::regT0, FunctionExecutableType);
+ jit.loadPtr(
+ CCallHelpers::Address(
+ GPRInfo::regT0, FunctionExecutable::offsetOfCodeBlockForCall()),
+ GPRInfo::regT2);
+ jit.storeCell(GPRInfo::regT2, CCallHelpers::calleeFrameCodeBlockBeforeCall());
+
+ isNative.link(&jit);
- emitPointerValidation(jit, GPRInfo::regT0, JSEntryPtrTag);
- jit.call(GPRInfo::regT0, JSEntryPtrTag);
+ emitPointerValidation(jit, GPRInfo::regT1, JSEntryPtrTag);
+ jit.call(GPRInfo::regT1, JSEntryPtrTag);
jit.emitFunctionEpilogue();
jit.ret();
@@ -1532,13 +1552,14 @@
jit.loadPtr(
CCallHelpers::Address(
GPRInfo::regT1, ExecutableBase::offsetOfJITCodeWithArityCheckFor(CodeForCall)),
- GPRInfo::regT1);
- auto codeExists = jit.branchTestPtr(CCallHelpers::NonZero, GPRInfo::regT1);
+ GPRInfo::regT2);
+ auto codeExists = jit.branchTestPtr(CCallHelpers::NonZero, GPRInfo::regT2);
// The calls to operationGetWrappedValueForTarget above may GC, and any GC can potentially jettison the JIT code in the target JSFunction.
// If we find that the JIT code is null (i.e. has been jettisoned), then we need to re-materialize it for the call below. Note that we know
// that operationMaterializeRemoteFunctionTargetCode should be able to re-materialize the JIT code (except for any OOME) because we only
// went down this code path after we found a non-null JIT code (in the noCode check) above i.e. it should be possible to materialize the JIT code.
+ // FIXME: Windows x64 is not supported since operationMaterializeRemoteFunctionTargetCode returns SlowPathReturnType.
jit.setupArguments<decltype(operationMaterializeRemoteFunctionTargetCode)>(GPRInfo::regT0);
jit.prepareCallOperation(vm);
jit.move(CCallHelpers::TrustedImmPtr(tagCFunction<OperationPtrTag>(operationMaterializeRemoteFunctionTargetCode)), GPRInfo::nonArgGPR0);
@@ -1545,20 +1566,31 @@
emitPointerValidation(jit, GPRInfo::nonArgGPR0, OperationPtrTag);
jit.call(GPRInfo::nonArgGPR0, OperationPtrTag);
exceptionChecks.append(jit.emitJumpIfException(vm));
- jit.move(GPRInfo::returnValueGPR, GPRInfo::regT1);
+ jit.storeCell(GPRInfo::returnValueGPR2, CCallHelpers::calleeFrameCodeBlockBeforeCall());
+ jit.move(GPRInfo::returnValueGPR, GPRInfo::regT2);
+ auto materialized = jit.jump();
codeExists.link(&jit);
+ auto isNative = jit.branchIfNotType(GPRInfo::regT1, FunctionExecutableType);
+ jit.loadPtr(
+ CCallHelpers::Address(
+ GPRInfo::regT1, FunctionExecutable::offsetOfCodeBlockForCall()),
+ GPRInfo::regT3);
+ jit.storeCell(GPRInfo::regT3, CCallHelpers::calleeFrameCodeBlockBeforeCall());
+
+ isNative.link(&jit);
+ materialized.link(&jit);
// Based on the check above, we should be good with this. On ARM64, emitPointerValidation will do this.
#if ASSERT_ENABLED && !CPU(ARM64E)
{
- CCallHelpers::Jump checkNotNull = jit.branchTestPtr(CCallHelpers::NonZero, GPRInfo::regT1);
+ CCallHelpers::Jump checkNotNull = jit.branchTestPtr(CCallHelpers::NonZero, GPRInfo::regT2);
jit.abortWithReason(TGInvalidPointer);
checkNotNull.link(&jit);
}
#endif
- emitPointerValidation(jit, GPRInfo::regT1, JSEntryPtrTag);
- jit.call(GPRInfo::regT1, JSEntryPtrTag);
+ emitPointerValidation(jit, GPRInfo::regT2, JSEntryPtrTag);
+ jit.call(GPRInfo::regT2, JSEntryPtrTag);
// Wrap return value
#if USE(JSVALUE64)
Modified: trunk/Source/_javascript_Core/llint/LowLevelInterpreter.asm (292371 => 292372)
--- trunk/Source/_javascript_Core/llint/LowLevelInterpreter.asm 2022-04-05 03:59:22 UTC (rev 292371)
+++ trunk/Source/_javascript_Core/llint/LowLevelInterpreter.asm 2022-04-05 04:10:35 UTC (rev 292372)
@@ -170,6 +170,7 @@
const StackAlignmentMask = StackAlignment - 1
const CallerFrameAndPCSize = constexpr (sizeof(CallerFrameAndPC))
+const PrologueStackPointerDelta = constexpr (prologueStackPointerDelta())
const CallerFrame = 0
const ReturnPC = CallerFrame + MachineRegisterSize
@@ -566,6 +567,7 @@
const DerivedArrayType = constexpr DerivedArrayType
const ProxyObjectType = constexpr ProxyObjectType
const HeapBigIntType = constexpr HeapBigIntType
+const FunctionExecutableType = constexpr FunctionExecutableType
# The typed array types need to be numbered in a particular order because of the manually written
# switch statement in get_by_val and put_by_val.
@@ -1192,7 +1194,8 @@
end
end
-macro prepareForRegularCall(temp1, temp2, temp3, temp4)
+macro prepareForRegularCall(temp1, temp2, temp3, temp4, storeCodeBlock)
+ storeCodeBlock(CodeBlock + PayloadOffset - CallerFrameAndPCSize[sp])
end
macro invokeForRegularCall(opcodeName, size, opcodeStruct, valueProfileName, dstVirtualRegister, dispatch, callee, maybeOldCFR, callPtrTag)
@@ -1208,7 +1211,7 @@
# sp points to the new frame + CallerFrameAndPCSize
# We leave cfr temp4 to use it for untagging.
-macro prepareForTailCall(temp1, temp2, temp3, temp4)
+macro prepareForTailCall(temp1, temp2, temp3, temp4, storeCodeBlock)
restoreCalleeSavesUsedByLLInt()
loadi PayloadOffset + ArgumentCountIncludingThis[cfr], temp2
@@ -1263,6 +1266,8 @@
end
move temp1, sp
+
+ storeCodeBlock(CodeBlock + PayloadOffset - PrologueStackPointerDelta[sp])
end
macro invokeForTailCall(opcodeName, size, opcodeStruct, valueProfileName, dstVirtualRegister, dispatch, callee, maybeOldCFR, callPtrTag)
@@ -1303,7 +1308,7 @@
macro (callee, calleeFramePtr)
btpz calleeFramePtr, .dontUpdateSP
move calleeFramePtr, sp
- prepareCall(t2, t3, t4, t1)
+ prepareCall(t2, t3, t4, t1, macro(address) end)
.dontUpdateSP:
callTargetFunction(%opcodeName%_slow, size, opcodeStruct, valueProfileName, dstVirtualRegister, dispatch, callee, JSEntrySlowPathPtrTag)
end)
@@ -1482,44 +1487,6 @@
end)
end
-macro functionForCallCodeBlockGetter(targetRegister)
- if JSVALUE64
- loadp Callee[cfr], targetRegister
- else
- loadp Callee + PayloadOffset[cfr], targetRegister
- end
- loadp JSFunction::m_executableOrRareData[targetRegister], targetRegister
- btpz targetRegister, (constexpr JSFunction::rareDataTag), .isExecutable
- loadp (FunctionRareData::m_executable - (constexpr JSFunction::rareDataTag))[targetRegister], targetRegister
-.isExecutable:
- loadp FunctionExecutable::m_codeBlockForCall[targetRegister], targetRegister
-end
-
-macro functionForConstructCodeBlockGetter(targetRegister)
- if JSVALUE64
- loadp Callee[cfr], targetRegister
- else
- loadp Callee + PayloadOffset[cfr], targetRegister
- end
- loadp JSFunction::m_executableOrRareData[targetRegister], targetRegister
- btpz targetRegister, (constexpr JSFunction::rareDataTag), .isExecutable
- loadp (FunctionRareData::m_executable - (constexpr JSFunction::rareDataTag))[targetRegister], targetRegister
-.isExecutable:
- loadp FunctionExecutable::m_codeBlockForConstruct[targetRegister], targetRegister
-end
-
-macro notFunctionCodeBlockGetter(targetRegister)
- loadp CodeBlock[cfr], targetRegister
-end
-
-macro functionCodeBlockSetter(sourceRegister)
- storep sourceRegister, CodeBlock[cfr]
-end
-
-macro notFunctionCodeBlockSetter(sourceRegister)
- # Nothing to do!
-end
-
macro convertCalleeToVM(callee)
btpnz callee, (constexpr PreciseAllocation::halfAlignment), .preciseAllocation
andp MarkedBlockMask, callee
@@ -1532,7 +1499,7 @@
# Do the bare minimum required to execute code. Sets up the PC, leave the CodeBlock*
# in t1. May also trigger prologue entry OSR.
-macro prologue(codeBlockGetter, codeBlockSetter, osrSlowPath, traceSlowPath)
+macro prologue(osrSlowPath, traceSlowPath)
# Set up the call frame and check if we should OSR.
preserveCallerPCAndCFR()
@@ -1541,8 +1508,7 @@
callSlowPath(traceSlowPath)
addp maxFrameExtentForSlowPathCall, sp
end
- codeBlockGetter(t1)
- codeBlockSetter(t1)
+ loadp CodeBlock[cfr], t1
if not (C_LOOP or C_LOOP_WIN)
loadp CodeBlock::m_unlinkedCode[t1], t0
baddis 5, (UnlinkedCodeBlock::m_llintExecuteCounter + BaselineExecutionCounter::m_counter)[t0], .continue
@@ -1582,7 +1548,7 @@
jmp r0, JSEntryPtrTag
end
.recover:
- notFunctionCodeBlockGetter(t1)
+ loadp CodeBlock[cfr], t1
.continue:
end
@@ -1621,7 +1587,7 @@
.stackHeightOKGetCodeBlock:
# Stack check slow path returned that the stack was ok.
# Since they were clobbered, need to get CodeBlock and new sp
- notFunctionCodeBlockGetter(t1)
+ loadp CodeBlock[cfr], t1
getFrameRegisterSizeForCodeBlock(t1, t0)
subp cfr, t0, t0
@@ -2024,25 +1990,25 @@
noWide(llint_op_enter)
op(llint_program_prologue, macro ()
- prologue(notFunctionCodeBlockGetter, notFunctionCodeBlockSetter, _llint_entry_osr, _llint_trace_prologue)
+ prologue(_llint_entry_osr, _llint_trace_prologue)
dispatch(0)
end)
op(llint_module_program_prologue, macro ()
- prologue(notFunctionCodeBlockGetter, notFunctionCodeBlockSetter, _llint_entry_osr, _llint_trace_prologue)
+ prologue(_llint_entry_osr, _llint_trace_prologue)
dispatch(0)
end)
op(llint_eval_prologue, macro ()
- prologue(notFunctionCodeBlockGetter, notFunctionCodeBlockSetter, _llint_entry_osr, _llint_trace_prologue)
+ prologue(_llint_entry_osr, _llint_trace_prologue)
dispatch(0)
end)
op(llint_function_for_call_prologue, macro ()
- prologue(functionForCallCodeBlockGetter, functionCodeBlockSetter, _llint_entry_osr_function_for_call, _llint_trace_prologue_function_for_call)
+ prologue(_llint_entry_osr_function_for_call, _llint_trace_prologue_function_for_call)
functionInitialization(0)
dispatch(0)
end)
@@ -2049,7 +2015,7 @@
op(llint_function_for_construct_prologue, macro ()
- prologue(functionForConstructCodeBlockGetter, functionCodeBlockSetter, _llint_entry_osr_function_for_construct, _llint_trace_prologue_function_for_construct)
+ prologue(_llint_entry_osr_function_for_construct, _llint_trace_prologue_function_for_construct)
functionInitialization(1)
dispatch(0)
end)
@@ -2056,7 +2022,7 @@
op(llint_function_for_call_arity_check, macro ()
- prologue(functionForCallCodeBlockGetter, functionCodeBlockSetter, _llint_entry_osr_function_for_call_arityCheck, _llint_trace_arityCheck_for_call)
+ prologue(_llint_entry_osr_function_for_call_arityCheck, _llint_trace_arityCheck_for_call)
functionArityCheck(llint_function_for_call_arity_check, .functionForCallBegin, _slow_path_call_arityCheck)
.functionForCallBegin:
functionInitialization(0)
@@ -2064,7 +2030,7 @@
end)
op(llint_function_for_construct_arity_check, macro ()
- prologue(functionForConstructCodeBlockGetter, functionCodeBlockSetter, _llint_entry_osr_function_for_construct_arityCheck, _llint_trace_arityCheck_for_construct)
+ prologue(_llint_entry_osr_function_for_construct_arityCheck, _llint_trace_arityCheck_for_construct)
functionArityCheck(llint_function_for_construct_arity_check, .functionForConstructBegin, _slow_path_construct_arityCheck)
.functionForConstructBegin:
functionInitialization(1)
@@ -2525,7 +2491,7 @@
untagReturnAddress sp
btpz r1, .doNotTrash
preserveReturnAddressAfterCall(t1)
- prepareForTailCall(t1, t2, t3, t4)
+ prepareForTailCall(t1, t2, t3, t4, macro(address) end)
untagReturnAddress t4
.doNotTrash:
jmp t0, JSEntryPtrTag
@@ -2534,7 +2500,7 @@
# 64bit:t0 32bit(t0,t1) is callee
# t2 is CallLinkInfo*
# t3 is caller's JSGlobalObject
-macro virtualThunkFor(offsetOfJITCodeWithArityCheck, internalFunctionTrampoline, prepareCall, slowCase)
+macro virtualThunkFor(offsetOfJITCodeWithArityCheck, offsetOfCodeBlock, internalFunctionTrampoline, prepareCall, slowCase)
addi 1, CallLinkInfo::m_slowPathCount[t2]
if JSVALUE64
btqnz t0, NotCellMask, slowCase
@@ -2542,14 +2508,19 @@
bineq t1, CellTag, slowCase
end
bbneq JSCell::m_type[t0], JSFunctionType, .notJSFunction
- loadp JSFunction::m_executableOrRareData[t0], t1
- btpz t1, (constexpr JSFunction::rareDataTag), .isExecutable
- loadp (FunctionRareData::m_executable - (constexpr JSFunction::rareDataTag))[t1], t1
+ loadp JSFunction::m_executableOrRareData[t0], t5
+ btpz t5, (constexpr JSFunction::rareDataTag), .isExecutable
+ loadp (FunctionRareData::m_executable - (constexpr JSFunction::rareDataTag))[t5], t5
.isExecutable:
- loadp offsetOfJITCodeWithArityCheck[t1], t1
- btpz t1, slowCase
+ loadp offsetOfJITCodeWithArityCheck[t5], t4
+ btpz t4, slowCase # When jumping to slowCase, t0, t1, t2, t3 needs to be unmodified.
+ move t4, t1
+ move 0, t0
+ bbneq JSCell::m_type[t5], FunctionExecutableType, .callCode
+ loadp offsetOfCodeBlock[t5], t0
.callCode:
prepareCall(t5, t2, t3, t4)
+ storep t0, CodeBlock + PayloadOffset - PrologueStackPointerDelta[sp]
jmp t1, JSEntryPtrTag
.notJSFunction:
bbneq JSCell::m_type[t0], InternalFunctionType, slowCase
@@ -2568,7 +2539,7 @@
# t2 is CallLinkInfo*
# t3 is caller's JSGlobalObject
op(llint_virtual_call_trampoline, macro ()
- virtualThunkFor(ExecutableBase::m_jitCodeForCallWithArityCheck, _llint_internal_function_call_trampoline, macro (temp1, temp2, temp3, temp4) end, .slowCase)
+ virtualThunkFor(ExecutableBase::m_jitCodeForCallWithArityCheck, FunctionExecutable::m_codeBlockForCall, _llint_internal_function_call_trampoline, macro (temp1, temp2, temp3, temp4) end, .slowCase)
.slowCase:
linkSlowPathFor(_llint_virtual_call)
end)
@@ -2577,7 +2548,7 @@
# t2 is CallLinkInfo*
# t3 is caller's JSGlobalObject
op(llint_virtual_construct_trampoline, macro ()
- virtualThunkFor(ExecutableBase::m_jitCodeForConstructWithArityCheck, _llint_internal_function_construct_trampoline, macro (temp1, temp2, temp3, temp4) end, .slowCase)
+ virtualThunkFor(ExecutableBase::m_jitCodeForConstructWithArityCheck, FunctionExecutable::m_codeBlockForConstruct, _llint_internal_function_construct_trampoline, macro (temp1, temp2, temp3, temp4) end, .slowCase)
.slowCase:
linkSlowPathFor(_llint_virtual_call)
end)
@@ -2586,9 +2557,9 @@
# t2 is CallLinkInfo*
# t3 is caller's JSGlobalObject
op(llint_virtual_tail_call_trampoline, macro ()
- virtualThunkFor(ExecutableBase::m_jitCodeForCallWithArityCheck, _llint_internal_function_call_trampoline, macro (temp1, temp2, temp3, temp4)
+ virtualThunkFor(ExecutableBase::m_jitCodeForCallWithArityCheck, FunctionExecutable::m_codeBlockForCall, _llint_internal_function_call_trampoline, macro (temp1, temp2, temp3, temp4)
preserveReturnAddressAfterCall(temp1)
- prepareForTailCall(temp1, temp2, temp3, temp4)
+ prepareForTailCall(temp1, temp2, temp3, temp4, macro(address) end)
untagReturnAddress temp4
end, .slowCase)
.slowCase:
Modified: trunk/Source/_javascript_Core/llint/LowLevelInterpreter32_64.asm (292371 => 292372)
--- trunk/Source/_javascript_Core/llint/LowLevelInterpreter32_64.asm 2022-04-05 03:59:22 UTC (rev 292371)
+++ trunk/Source/_javascript_Core/llint/LowLevelInterpreter32_64.asm 2022-04-05 04:10:35 UTC (rev 292372)
@@ -2259,7 +2259,10 @@
.notPolymorphic:
bpneq t0, t3, .opCallSlow
- prepareCall(t2, t3, t4, t1)
+ prepareCall(t2, t3, t4, t1, macro(address)
+ loadp %opcodeStruct%::Metadata::m_callLinkInfo.u.dataIC.m_codeBlock[t5], t2
+ storep t2, address
+ end)
.goPolymorphic:
loadp %opcodeStruct%::Metadata::m_callLinkInfo.u.dataIC.m_monomorphicCallDestination[t5], t5
@@ -2338,7 +2341,10 @@
.notPolymorphic:
bpneq t0, t3, .opCallSlow
- prepareCall(t2, t3, t4, t1)
+ prepareCall(t2, t3, t4, t1, macro(address)
+ loadp %opcodeStruct%::Metadata::m_callLinkInfo.u.dataIC.m_codeBlock[t5], t2
+ storep t2, address
+ end)
.goPolymorphic:
loadp %opcodeStruct%::Metadata::m_callLinkInfo.u.dataIC.m_monomorphicCallDestination[t5], t5
Modified: trunk/Source/_javascript_Core/llint/LowLevelInterpreter64.asm (292371 => 292372)
--- trunk/Source/_javascript_Core/llint/LowLevelInterpreter64.asm 2022-04-05 03:59:22 UTC (rev 292371)
+++ trunk/Source/_javascript_Core/llint/LowLevelInterpreter64.asm 2022-04-05 04:10:35 UTC (rev 292372)
@@ -2483,7 +2483,10 @@
.notPolymorphic:
bqneq t0, t1, .opCallSlow
- prepareCall(t2, t3, t4, t1)
+ prepareCall(t2, t3, t4, t1, macro(address)
+ loadp %opcodeStruct%::Metadata::m_callLinkInfo.u.dataIC.m_codeBlock[t5], t2
+ storep t2, address
+ end)
.goPolymorphic:
loadp %opcodeStruct%::Metadata::m_callLinkInfo.u.dataIC.m_monomorphicCallDestination[t5], t5
@@ -2561,7 +2564,10 @@
.notPolymorphic:
bqneq t0, t1, .opCallSlow
- prepareCall(t2, t3, t4, t1)
+ prepareCall(t2, t3, t4, t1, macro(address)
+ loadp %opcodeStruct%::Metadata::m_callLinkInfo.u.dataIC.m_codeBlock[t5], t2
+ storep t2, address
+ end)
.goPolymorphic:
loadp %opcodeStruct%::Metadata::m_callLinkInfo.u.dataIC.m_monomorphicCallDestination[t5], t5
Modified: trunk/Source/_javascript_Core/llint/WebAssembly.asm (292371 => 292372)
--- trunk/Source/_javascript_Core/llint/WebAssembly.asm 2022-04-05 03:59:22 UTC (rev 292371)
+++ trunk/Source/_javascript_Core/llint/WebAssembly.asm 2022-04-05 04:10:35 UTC (rev 292372)
@@ -147,7 +147,7 @@
jmp ws0, WasmEntryPtrTag
end
.recover:
- notFunctionCodeBlockGetter(codeBlockRegister)
+ loadp CodeBlock[cfr], codeBlockRegister
end)
end
end
@@ -283,7 +283,7 @@
subp cfr, ws1, sp
end
-macro wasmPrologue(codeBlockGetter, codeBlockSetter, loadWasmInstance)
+macro wasmPrologue(loadWasmInstance)
# Set up the call frame and check if we should OSR.
preserveCallerPCAndCFR()
preserveCalleeSavesUsedByWasm()
@@ -293,8 +293,9 @@
loadp Wasm::Instance::m_owner[wasmInstance], ws0
storep ws0, ThisArgumentOffset[cfr]
- codeBlockGetter(ws0)
- codeBlockSetter(ws0)
+ loadp Callee[cfr], ws0
+ andp ~3, ws0
+ storep ws0, CodeBlock[cfr]
# Get new sp in ws1 and check stack height.
loadi Wasm::LLIntCallee::m_numCalleeLocals[ws0], ws1
@@ -514,7 +515,7 @@
error
end
- wasmPrologue(wasmCodeBlockGetter, functionCodeBlockSetter, loadWasmInstanceFromTLS)
+ wasmPrologue(loadWasmInstanceFromTLS)
wasmNextInstruction()
end)
@@ -523,7 +524,7 @@
error
end
- wasmPrologue(wasmCodeBlockGetter, functionCodeBlockSetter, macro () end)
+ wasmPrologue(macro () end)
wasmNextInstruction()
end)
Modified: trunk/Source/_javascript_Core/runtime/FunctionExecutable.h (292371 => 292372)
--- trunk/Source/_javascript_Core/runtime/FunctionExecutable.h 2022-04-05 03:59:22 UTC (rev 292371)
+++ trunk/Source/_javascript_Core/runtime/FunctionExecutable.h 2022-04-05 04:10:35 UTC (rev 292372)
@@ -288,20 +288,26 @@
}
static inline ptrdiff_t offsetOfRareData() { return OBJECT_OFFSETOF(FunctionExecutable, m_rareData); }
- static inline ptrdiff_t offsetOfAsStringInRareData() { return OBJECT_OFFSETOF(RareData, m_asString); }
static inline ptrdiff_t offsetOfCodeBlockForCall() { return OBJECT_OFFSETOF(FunctionExecutable, m_codeBlockForCall); }
static inline ptrdiff_t offsetOfCodeBlockForConstruct() { return OBJECT_OFFSETOF(FunctionExecutable, m_codeBlockForConstruct); }
-private:
- friend class ExecutableBase;
- FunctionExecutable(VM&, const SourceCode&, UnlinkedFunctionExecutable*, Intrinsic, bool isInsideOrdinaryFunction);
-
- void finishCreation(VM&, ScriptExecutable* topLevelExecutable);
+ static ptrdiff_t offsetOfCodeBlockFor(CodeSpecializationKind kind)
+ {
+ switch (kind) {
+ case CodeForCall:
+ return OBJECT_OFFSETOF(FunctionExecutable, m_codeBlockForCall);
+ case CodeForConstruct:
+ return OBJECT_OFFSETOF(FunctionExecutable, m_codeBlockForConstruct);
+ }
+ RELEASE_ASSERT_NOT_REACHED();
+ return 0;
+ }
- friend class ScriptExecutable;
-
struct RareData {
WTF_MAKE_STRUCT_FAST_ALLOCATED;
+
+ static inline ptrdiff_t offsetOfAsString() { return OBJECT_OFFSETOF(RareData, m_asString); }
+
RefPtr<TypeSet> m_returnStatementTypeSet;
unsigned m_lineCount;
unsigned m_endColumn;
@@ -314,6 +320,14 @@
WriteBarrier<JSString> m_asString;
};
+private:
+ friend class ExecutableBase;
+ FunctionExecutable(VM&, const SourceCode&, UnlinkedFunctionExecutable*, Intrinsic, bool isInsideOrdinaryFunction);
+
+ void finishCreation(VM&, ScriptExecutable* topLevelExecutable);
+
+ friend class ScriptExecutable;
+
RareData& ensureRareData()
{
if (LIKELY(m_rareData))
Modified: trunk/Source/_javascript_Core/runtime/JSCast.h (292371 => 292372)
--- trunk/Source/_javascript_Core/runtime/JSCast.h 2022-04-05 03:59:22 UTC (rev 292371)
+++ trunk/Source/_javascript_Core/runtime/JSCast.h 2022-04-05 04:10:35 UTC (rev 292372)
@@ -89,6 +89,7 @@
macro(RegExpObject, JSType::RegExpObjectType, JSType::RegExpObjectType) \
macro(JSWebAssemblyModule, JSType::WebAssemblyModuleType, JSType::WebAssemblyModuleType) \
macro(DirectArguments, JSType::DirectArgumentsType, JSType::DirectArgumentsType) \
+ macro(FunctionExecutable, JSType::FunctionExecutableType, JSType::FunctionExecutableType) \
macro(ScopedArguments, JSType::ScopedArgumentsType, JSType::ScopedArgumentsType) \
macro(ClonedArguments, JSType::ClonedArgumentsType, JSType::ClonedArgumentsType) \
macro(JSGlobalObject, JSType::GlobalObjectType, JSType::GlobalObjectType) \
Modified: trunk/Source/_javascript_Core/runtime/VM.cpp (292371 => 292372)
--- trunk/Source/_javascript_Core/runtime/VM.cpp 2022-04-05 03:59:22 UTC (rev 292371)
+++ trunk/Source/_javascript_Core/runtime/VM.cpp 2022-04-05 04:10:35 UTC (rev 292372)
@@ -716,9 +716,17 @@
auto getOrCreate = [&] (Weak<NativeExecutable>& slot) -> NativeExecutable* {
if (auto* cached = slot.get())
return cached;
+
+ Intrinsic intrinsic = NoIntrinsic;
+ if (!slowCase) {
+#if !(OS(WINDOWS) && CPU(X86_64))
+ intrinsic = RemoteFunctionCallIntrinsic;
+#endif
+ }
+
NativeExecutable* result = getHostFunction(
slowCase ? remoteFunctionCallGeneric : remoteFunctionCallForJSFunction,
- slowCase ? NoIntrinsic : RemoteFunctionCallIntrinsic,
+ intrinsic,
callHostFunctionAsConstructor, nullptr, String());
slot = Weak<NativeExecutable>(result);
return result;
Modified: trunk/Source/_javascript_Core/wasm/WasmOperations.cpp (292371 => 292372)
--- trunk/Source/_javascript_Core/wasm/WasmOperations.cpp 2022-04-05 03:59:22 UTC (rev 292371)
+++ trunk/Source/_javascript_Core/wasm/WasmOperations.cpp 2022-04-05 04:10:35 UTC (rev 292372)
@@ -192,7 +192,7 @@
// pop(framePointerRegister);
context.fp() = bitwise_cast<UCPURegister*>(*framePointer);
context.sp() = framePointer + 1;
- static_assert(AssemblyHelpers::prologueStackPointerDelta() == sizeof(void*) * 1);
+ static_assert(prologueStackPointerDelta() == sizeof(void*) * 1);
#elif CPU(ARM64E) || CPU(ARM64)
// move(framePointerRegister, stackPointerRegister);
// popPair(framePointerRegister, linkRegister);
@@ -199,7 +199,7 @@
context.fp() = bitwise_cast<UCPURegister*>(*framePointer);
context.gpr(ARM64Registers::lr) = bitwise_cast<UCPURegister>(*(framePointer + 1));
context.sp() = framePointer + 2;
- static_assert(AssemblyHelpers::prologueStackPointerDelta() == sizeof(void*) * 2);
+ static_assert(prologueStackPointerDelta() == sizeof(void*) * 2);
#if CPU(ARM64E)
// LR needs to be untagged since OSR entry function prologue will tag it with SP. This is similar to tail-call.
context.gpr(ARM64Registers::lr) = bitwise_cast<UCPURegister>(untagCodePtrWithStackPointerForJITCall(context.gpr<void*>(ARM64Registers::lr), context.sp()));
@@ -210,7 +210,7 @@
context.fp() = bitwise_cast<UCPURegister*>(*framePointer);
context.gpr(RISCV64Registers::ra) = bitwise_cast<UCPURegister>(*(framePointer + 1));
context.sp() = framePointer + 2;
- static_assert(AssemblyHelpers::prologueStackPointerDelta() == sizeof(void*) * 2);
+ static_assert(prologueStackPointerDelta() == sizeof(void*) * 2);
#else
#error Unsupported architecture.
#endif