Diff
Modified: trunk/Source/_javascript_Core/CMakeLists.txt (287458 => 287459)
--- trunk/Source/_javascript_Core/CMakeLists.txt 2021-12-27 07:46:43 UTC (rev 287458)
+++ trunk/Source/_javascript_Core/CMakeLists.txt 2021-12-27 10:04:25 UTC (rev 287459)
@@ -1244,7 +1244,7 @@
wasm/WasmExceptionType.h
wasm/WasmFaultSignalHandler.h
wasm/WasmFormat.h
- wasm/WasmFunctionCodeBlock.h
+ wasm/WasmFunctionCodeBlockGenerator.h
wasm/WasmHandlerInfo.h
wasm/WasmIndexOrName.h
wasm/WasmLLIntTierUpCounter.h
Modified: trunk/Source/_javascript_Core/ChangeLog (287458 => 287459)
--- trunk/Source/_javascript_Core/ChangeLog 2021-12-27 07:46:43 UTC (rev 287458)
+++ trunk/Source/_javascript_Core/ChangeLog 2021-12-27 10:04:25 UTC (rev 287459)
@@ -1,3 +1,66 @@
+2021-12-27 Yusuke Suzuki <[email protected]>
+
+ Consider merging Wasm::FunctionCodeBlock and Wasm::LLIntCallee
+ https://bugs.webkit.org/show_bug.cgi?id=203691
+
+ Reviewed by Filip Pizlo.
+
+ This patch merges Wasm::FunctionCodeBlock into Wasm::LLIntCallee since both
+ are one-on-one and what they want to represent are the same. We change
+ Wasm::FunctionCodeBlock to Wasm::FunctionCodeBlockGenerator so that we can
+ use FixedVector in Wasm::LLIntCallee which makes Wasm::LLIntCallee small,
+ and this is similar to what JS side is doing (UnlinkedCodeBlockGenerator).
+
+ * CMakeLists.txt:
+ * _javascript_Core.xcodeproj/project.pbxproj:
+ * Sources.txt:
+ * bytecode/BytecodeDumper.cpp:
+ (JSC::Wasm::BytecodeDumper::dumpBlock):
+ (JSC::Wasm::BytecodeDumper::dumpConstants):
+ (JSC::Wasm::BytecodeDumper::constantName const):
+ * bytecode/BytecodeDumper.h:
+ * interpreter/Interpreter.cpp:
+ (JSC::CatchInfo::CatchInfo):
+ * llint/LLIntOffsetsExtractor.cpp:
+ * llint/WebAssembly.asm:
+ * wasm/WasmCallee.cpp:
+ (JSC::Wasm::LLIntCallee::LLIntCallee):
+ (JSC::Wasm::LLIntCallee::outOfLineJumpOffset):
+ (JSC::Wasm::LLIntCallee::outOfLineJumpTarget):
+ (JSC::Wasm::LLIntCallee::linkExceptionHandlers): Deleted.
+ * wasm/WasmCallee.h:
+ (JSC::Wasm::Callee::llintFunctionCodeBlock const): Deleted.
+ * wasm/WasmFunctionCodeBlockGenerator.cpp: Renamed from Source/_javascript_Core/wasm/WasmFunctionCodeBlock.cpp.
+ (JSC::Wasm::FunctionCodeBlockGenerator::setInstructions):
+ (JSC::Wasm::FunctionCodeBlockGenerator::addOutOfLineJumpTarget):
+ (JSC::Wasm::FunctionCodeBlockGenerator::outOfLineJumpOffset):
+ (JSC::Wasm::FunctionCodeBlockGenerator::addSignature):
+ (JSC::Wasm::FunctionCodeBlockGenerator::addJumpTable):
+ (JSC::Wasm::FunctionCodeBlockGenerator::numberOfJumpTables const):
+ * wasm/WasmFunctionCodeBlockGenerator.h: Renamed from Source/_javascript_Core/wasm/WasmFunctionCodeBlock.h.
+ (JSC::Wasm::FunctionCodeBlockGenerator::FunctionCodeBlockGenerator):
+ (JSC::Wasm::FunctionCodeBlockGenerator::tierUpCounter):
+ * wasm/WasmGeneratorTraits.h:
+ * wasm/WasmLLIntGenerator.cpp:
+ (JSC::Wasm::parseAndCompileBytecode):
+ (JSC::Wasm::LLIntGenerator::LLIntGenerator):
+ (JSC::Wasm::LLIntGenerator::finalize):
+ (JSC::Wasm::LLIntGenerator::addLoop):
+ (JSC::Wasm::LLIntGenerator::addSwitch):
+ * wasm/WasmLLIntGenerator.h:
+ * wasm/WasmLLIntPlan.cpp:
+ (JSC::Wasm::LLIntPlan::compileFunction):
+ (JSC::Wasm::LLIntPlan::didCompleteCompilation):
+ * wasm/WasmLLIntPlan.h:
+ * wasm/WasmLLIntTierUpCounter.h:
+ (JSC::Wasm::LLIntTierUpCounter::LLIntTierUpCounter):
+ * wasm/WasmSlowPaths.cpp:
+ (JSC::LLInt::shouldJIT):
+ (JSC::LLInt::jitCompileAndSetHeuristics):
+ (JSC::LLInt::WASM_SLOW_PATH_DECL):
+ (JSC::LLInt::doWasmCallIndirect):
+ (JSC::LLInt::doWasmCallRef):
+
2021-12-26 Yusuke Suzuki <[email protected]>
[JSC] Use SlowPathReturnType instead of EncodedMatchResult
Modified: trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj (287458 => 287459)
--- trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj 2021-12-27 07:46:43 UTC (rev 287458)
+++ trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj 2021-12-27 10:04:25 UTC (rev 287459)
@@ -778,7 +778,7 @@
1442566215EDE98D0066A49B /* JSWithScope.h in Headers */ = {isa = PBXBuildFile; fileRef = 1442566015EDE98D0066A49B /* JSWithScope.h */; settings = {ATTRIBUTES = (Private, ); }; };
144836E7132DA7BE005BE785 /* ConservativeRoots.h in Headers */ = {isa = PBXBuildFile; fileRef = 149DAAF212EB559D0083B12B /* ConservativeRoots.h */; settings = {ATTRIBUTES = (Private, ); }; };
144CA3502224180100817789 /* CachedBytecode.h in Headers */ = {isa = PBXBuildFile; fileRef = 144CA34F221F037900817789 /* CachedBytecode.h */; settings = {ATTRIBUTES = (Private, ); }; };
- 1450FA1C2357BDBE0093CD4D /* WasmFunctionCodeBlock.h in Headers */ = {isa = PBXBuildFile; fileRef = 14C5AD6B22F33FC000F1FB83 /* WasmFunctionCodeBlock.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ 1450FA1C2357BDBE0093CD4D /* WasmFunctionCodeBlockGenerator.h in Headers */ = {isa = PBXBuildFile; fileRef = 14C5AD6B22F33FC000F1FB83 /* WasmFunctionCodeBlockGenerator.h */; settings = {ATTRIBUTES = (Private, ); }; };
1450FA1F2357BEC90093CD4D /* WasmLLIntTierUpCounter.h in Headers */ = {isa = PBXBuildFile; fileRef = 1450FA1E2357BEC40093CD4D /* WasmLLIntTierUpCounter.h */; settings = {ATTRIBUTES = (Private, ); }; };
145722861437E140005FDE26 /* StrongInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = 145722851437E140005FDE26 /* StrongInlines.h */; settings = {ATTRIBUTES = (Private, ); }; };
145FF2C8243BB9D600569E71 /* ECMAMode.h in Headers */ = {isa = PBXBuildFile; fileRef = 145FF2C7243BB99A00569E71 /* ECMAMode.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -3558,11 +3558,11 @@
14C1F9CF22EA51FD0040B145 /* Wasm.rb */ = {isa = PBXFileReference; lastKnownFileType = text.script.ruby; path = Wasm.rb; sourceTree = "<group>"; };
14C5AD6522F1866C00F1FB83 /* BytecodeGeneratorBase.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BytecodeGeneratorBase.h; sourceTree = "<group>"; };
14C5AD6622F1866C00F1FB83 /* BytecodeGeneratorBaseInlines.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BytecodeGeneratorBaseInlines.h; sourceTree = "<group>"; };
- 14C5AD6722F33FBF00F1FB83 /* WasmFunctionCodeBlock.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WasmFunctionCodeBlock.cpp; sourceTree = "<group>"; };
+ 14C5AD6722F33FBF00F1FB83 /* WasmFunctionCodeBlockGenerator.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WasmFunctionCodeBlockGenerator.cpp; sourceTree = "<group>"; };
14C5AD6822F33FBF00F1FB83 /* WasmLLIntGenerator.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WasmLLIntGenerator.cpp; sourceTree = "<group>"; };
14C5AD6922F33FBF00F1FB83 /* WasmLLIntGenerator.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WasmLLIntGenerator.h; sourceTree = "<group>"; };
14C5AD6A22F33FBF00F1FB83 /* WasmLLIntPlan.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WasmLLIntPlan.cpp; sourceTree = "<group>"; };
- 14C5AD6B22F33FC000F1FB83 /* WasmFunctionCodeBlock.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WasmFunctionCodeBlock.h; sourceTree = "<group>"; };
+ 14C5AD6B22F33FC000F1FB83 /* WasmFunctionCodeBlockGenerator.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WasmFunctionCodeBlockGenerator.h; sourceTree = "<group>"; };
14C5AD6C22F33FC000F1FB83 /* WasmLLIntPlan.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WasmLLIntPlan.h; sourceTree = "<group>"; };
14CA958A16AB50DE00938A06 /* StaticPropertyAnalyzer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StaticPropertyAnalyzer.h; sourceTree = "<group>"; };
14CA958C16AB50FA00938A06 /* ObjectAllocationProfile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ObjectAllocationProfile.h; sourceTree = "<group>"; };
@@ -7218,8 +7218,8 @@
5381B9381E60E97D0090F794 /* WasmFaultSignalHandler.h */,
AD2FCC321DC4045300B3E736 /* WasmFormat.cpp */,
7BC547D21B69599B00959B58 /* WasmFormat.h */,
- 14C5AD6722F33FBF00F1FB83 /* WasmFunctionCodeBlock.cpp */,
- 14C5AD6B22F33FC000F1FB83 /* WasmFunctionCodeBlock.h */,
+ 14C5AD6722F33FBF00F1FB83 /* WasmFunctionCodeBlockGenerator.cpp */,
+ 14C5AD6B22F33FC000F1FB83 /* WasmFunctionCodeBlockGenerator.h */,
53F40E8A1D5901BB0099A1B6 /* WasmFunctionParser.h */,
1487CE16237741000044429C /* WasmGeneratorTraits.h */,
E38350082390D9370036316D /* WasmGlobal.cpp */,
@@ -7255,13 +7255,13 @@
ADD8FA431EB3077100DF542F /* WasmNameSectionParser.h */,
5311BD481EA581E500525281 /* WasmOMGPlan.cpp */,
5311BD491EA581E500525281 /* WasmOMGPlan.h */,
- 527E6CEA2772B9C5005E0782 /* WasmOSREntryPlan.cpp */,
- 527E6CEB2772B9C5005E0782 /* WasmOSREntryPlan.h */,
53C6FEF01E8AFE0C00B18425 /* WasmOpcodeOrigin.cpp */,
53C6FEEE1E8ADFA900B18425 /* WasmOpcodeOrigin.h */,
E39D8B2C23021E1E00265852 /* WasmOperations.cpp */,
E39D8B2D23021E1E00265852 /* WasmOperations.h */,
E3C694B123026873006FBE42 /* WasmOSREntryData.h */,
+ 527E6CEA2772B9C5005E0782 /* WasmOSREntryPlan.cpp */,
+ 527E6CEB2772B9C5005E0782 /* WasmOSREntryPlan.h */,
ADB6F67C1E15D7500082F384 /* WasmPageCount.cpp */,
79B759731DFA4C600052174C /* WasmPageCount.h */,
53F40E8C1D5901F20099A1B6 /* WasmParser.h */,
@@ -9715,7 +9715,6 @@
A7E5A3A81797432D00E893C0 /* CompilationResult.h in Headers */,
0F4F11E8209BCDAB00709654 /* CompilerTimingScope.h in Headers */,
0FDCE12A1FAFA85F006F3901 /* CompleteSubspace.h in Headers */,
- 527E6CEC2772B9CB005E0782 /* WasmOSREntryPlan.h in Headers */,
0FD2FD9420B52BDE00F09441 /* CompleteSubspaceInlines.h in Headers */,
BC18C3F40E16F5CD00B34460 /* Completion.h in Headers */,
0F6FC751196110A800E1D02D /* ComplexGetStatus.h in Headers */,
@@ -10957,7 +10956,7 @@
79DAE27A1E03C82200B526AA /* WasmExceptionType.h in Headers */,
5381B9391E60E97D0090F794 /* WasmFaultSignalHandler.h in Headers */,
7BC547D31B6959A100959B58 /* WasmFormat.h in Headers */,
- 1450FA1C2357BDBE0093CD4D /* WasmFunctionCodeBlock.h in Headers */,
+ 1450FA1C2357BDBE0093CD4D /* WasmFunctionCodeBlockGenerator.h in Headers */,
53F40E8B1D5901BB0099A1B6 /* WasmFunctionParser.h in Headers */,
E383500A2390D93B0036316D /* WasmGlobal.h in Headers */,
148521D826EAEBFE00CC1D1A /* WasmHandlerInfo.h in Headers */,
@@ -10979,6 +10978,7 @@
E39D8B2E23021E2600265852 /* WasmOperations.h in Headers */,
53B4BD121F68B32500D2BEA3 /* WasmOps.h in Headers */,
E3C694B323026877006FBE42 /* WasmOSREntryData.h in Headers */,
+ 527E6CEC2772B9CB005E0782 /* WasmOSREntryPlan.h in Headers */,
79B759761DFA4C600052174C /* WasmPageCount.h in Headers */,
53F40E8D1D5901F20099A1B6 /* WasmParser.h in Headers */,
531374BD1D5CE67600AF7A0B /* WasmPlan.h in Headers */,
Modified: trunk/Source/_javascript_Core/Sources.txt (287458 => 287459)
--- trunk/Source/_javascript_Core/Sources.txt 2021-12-27 07:46:43 UTC (rev 287458)
+++ trunk/Source/_javascript_Core/Sources.txt 2021-12-27 10:04:25 UTC (rev 287459)
@@ -1082,7 +1082,7 @@
wasm/WasmEntryPlan.cpp
wasm/WasmFaultSignalHandler.cpp
wasm/WasmFormat.cpp
-wasm/WasmFunctionCodeBlock.cpp
+wasm/WasmFunctionCodeBlockGenerator.cpp
wasm/WasmGlobal.cpp
wasm/WasmHandlerInfo.cpp
wasm/WasmIndexOrName.cpp
Modified: trunk/Source/_javascript_Core/bytecode/BytecodeDumper.cpp (287458 => 287459)
--- trunk/Source/_javascript_Core/bytecode/BytecodeDumper.cpp 2021-12-27 07:46:43 UTC (rev 287458)
+++ trunk/Source/_javascript_Core/bytecode/BytecodeDumper.cpp 2021-12-27 10:04:25 UTC (rev 287459)
@@ -34,7 +34,7 @@
#include "JSCJSValueInlines.h"
#include "UnlinkedCodeBlockGenerator.h"
#include "UnlinkedMetadataTableInlines.h"
-#include "WasmFunctionCodeBlock.h"
+#include "WasmFunctionCodeBlockGenerator.h"
#include "WasmGeneratorTraits.h"
#include "WasmModuleInformation.h"
#include "WasmSignatureInlines.h"
@@ -325,7 +325,7 @@
namespace Wasm {
-void BytecodeDumper::dumpBlock(FunctionCodeBlock* block, const ModuleInformation& moduleInformation, PrintStream& out)
+void BytecodeDumper::dumpBlock(FunctionCodeBlockGenerator* block, const ModuleInformation& moduleInformation, PrintStream& out)
{
size_t instructionCount = 0;
size_t wide16InstructionCount = 0;
@@ -371,7 +371,7 @@
void BytecodeDumper::dumpConstants()
{
- FunctionCodeBlock* block = this->block();
+ FunctionCodeBlockGenerator* block = this->block();
if (!block->constants().isEmpty()) {
this->m_out.printf("\nConstants:\n");
unsigned i = 0;
@@ -385,7 +385,7 @@
CString BytecodeDumper::constantName(VirtualRegister index) const
{
- FunctionCodeBlock* block = this->block();
+ FunctionCodeBlockGenerator* block = this->block();
auto value = formatConstant(block->getConstantType(index), block->getConstant(index));
return toCString(value, "(", VirtualRegister(index), ")");
}
Modified: trunk/Source/_javascript_Core/bytecode/BytecodeDumper.h (287458 => 287459)
--- trunk/Source/_javascript_Core/bytecode/BytecodeDumper.h 2021-12-27 07:46:43 UTC (rev 287458)
+++ trunk/Source/_javascript_Core/bytecode/BytecodeDumper.h 2021-12-27 10:04:25 UTC (rev 287459)
@@ -129,15 +129,15 @@
namespace Wasm {
-class FunctionCodeBlock;
+class FunctionCodeBlockGenerator;
struct ModuleInformation;
-class BytecodeDumper final : public JSC::BytecodeDumper<FunctionCodeBlock> {
+class BytecodeDumper final : public JSC::BytecodeDumper<FunctionCodeBlockGenerator> {
public:
- static void dumpBlock(FunctionCodeBlock*, const ModuleInformation&, PrintStream& out);
+ static void dumpBlock(FunctionCodeBlockGenerator*, const ModuleInformation&, PrintStream& out);
private:
- using JSC::BytecodeDumper<FunctionCodeBlock>::BytecodeDumper;
+ using JSC::BytecodeDumper<FunctionCodeBlockGenerator>::BytecodeDumper;
void dumpConstants();
CString constantName(VirtualRegister index) const final;
Modified: trunk/Source/_javascript_Core/interpreter/Interpreter.cpp (287458 => 287459)
--- trunk/Source/_javascript_Core/interpreter/Interpreter.cpp 2021-12-27 07:46:43 UTC (rev 287458)
+++ trunk/Source/_javascript_Core/interpreter/Interpreter.cpp 2021-12-27 10:04:25 UTC (rev 287459)
@@ -545,8 +545,8 @@
if (m_valid) {
m_type = HandlerType::Catch;
m_nativeCode = handler->m_nativeCode;
- if (const Wasm::FunctionCodeBlock* codeBlock = callee->llintFunctionCodeBlock())
- m_catchPCForInterpreter = codeBlock->instructions().at(handler->m_target).ptr();
+ if (callee->compilationMode() == Wasm::CompilationMode::LLIntMode)
+ m_catchPCForInterpreter = static_cast<const Wasm::LLIntCallee*>(callee)->instructions().at(handler->m_target).ptr();
else
m_catchPCForInterpreter = nullptr;
}
Modified: trunk/Source/_javascript_Core/llint/LLIntOffsetsExtractor.cpp (287458 => 287459)
--- trunk/Source/_javascript_Core/llint/LLIntOffsetsExtractor.cpp 2021-12-27 07:46:43 UTC (rev 287458)
+++ trunk/Source/_javascript_Core/llint/LLIntOffsetsExtractor.cpp 2021-12-27 10:04:25 UTC (rev 287459)
@@ -71,7 +71,7 @@
#include "VM.h"
#include "ValueProfile.h"
#include "WasmCallingConvention.h"
-#include "WasmFunctionCodeBlock.h"
+#include "WasmFunctionCodeBlockGenerator.h"
#include "WasmInstance.h"
#include "Watchdog.h"
#include "WebAssemblyFunction.h"
@@ -93,7 +93,11 @@
using UnlinkedSimpleJumpTableFixedVector = FixedVector<UnlinkedSimpleJumpTable>;
using UnlinkedStringJumpTableFixedVector = FixedVector<UnlinkedStringJumpTable>;
using Int32FixedVector = FixedVector<int32_t>;
+ using Int64FixedVector = FixedVector<uint64_t>;
using VoidPointerFixedVector = FixedVector<void*>;
+#if ENABLE(WEBASSEMBLY)
+ using WasmJumpTableFixedVector = FixedVector<Wasm::JumpTable>;
+#endif
public:
static const int64_t* dummy();
Modified: trunk/Source/_javascript_Core/llint/WebAssembly.asm (287458 => 287459)
--- trunk/Source/_javascript_Core/llint/WebAssembly.asm 2021-12-27 07:46:43 UTC (rev 287458)
+++ trunk/Source/_javascript_Core/llint/WebAssembly.asm 2021-12-27 10:04:25 UTC (rev 287459)
@@ -113,7 +113,7 @@
macro checkSwitchToJIT(increment, action)
loadp CodeBlock[cfr], ws0
- baddis increment, Wasm::FunctionCodeBlock::m_tierUpCounter + Wasm::LLIntTierUpCounter::m_counter[ws0], .continue
+ baddis increment, Wasm::LLIntCallee::m_tierUpCounter + Wasm::LLIntTierUpCounter::m_counter[ws0], .continue
action()
.continue:
end
@@ -277,7 +277,7 @@
macro restoreStackPointerAfterCall()
loadp CodeBlock[cfr], ws1
- loadi Wasm::FunctionCodeBlock::m_numCalleeLocals[ws1], ws1
+ loadi Wasm::LLIntCallee::m_numCalleeLocals[ws1], ws1
lshiftp 3, ws1
addp maxFrameExtentForSlowPathCall, ws1
subp cfr, ws1, sp
@@ -297,7 +297,7 @@
codeBlockSetter(ws0)
# Get new sp in ws1 and check stack height.
- loadi Wasm::FunctionCodeBlock::m_numCalleeLocals[ws0], ws1
+ loadi Wasm::LLIntCallee::m_numCalleeLocals[ws0], ws1
lshiftp 3, ws1
addp maxFrameExtentForSlowPathCall, ws1
subp cfr, ws1, ws1
@@ -322,10 +322,10 @@
checkSwitchToJITForPrologue(ws0)
# Set up the PC.
- loadp Wasm::FunctionCodeBlock::m_instructionsRawPointer[ws0], PB
+ loadp Wasm::LLIntCallee::m_instructionsRawPointer[ws0], PB
move 0, PC
- loadi Wasm::FunctionCodeBlock::m_numVars[ws0], ws1
+ loadi Wasm::LLIntCallee::m_numVars[ws0], ws1
subi NumberOfWasmArguments + CalleeSaveSpaceAsVirtualRegisters, ws1
btiz ws1, .zeroInitializeLocalsDone
negi ws1
@@ -389,9 +389,9 @@
jmp .done
.constant:
loadp CodeBlock[cfr], t6
- loadp Wasm::FunctionCodeBlock::m_constants + VectorBufferOffset[t6], t6
+ loadp Wasm::LLIntCallee::m_constants[t6], t6
subp firstConstantIndex, index
- loader([t6, index, 8])
+ loader((constexpr (Int64FixedVector::Storage::offsetOfData()))[t6, index, 8])
.done:
end)
end
@@ -507,7 +507,6 @@
macro wasmCodeBlockGetter(targetRegister)
loadp Callee[cfr], targetRegister
andp ~3, targetRegister
- loadp Wasm::LLIntCallee::m_codeBlock[targetRegister], targetRegister
end
op(wasm_function_prologue, macro ()
@@ -621,7 +620,7 @@
traceExecution()
checkStackPointerAlignment(t2, 0xdead00e1)
loadp CodeBlock[cfr], t2 // t2<CodeBlock> = cfr.CodeBlock
- loadi Wasm::FunctionCodeBlock::m_numVars[t2], t2 // t2<size_t> = t2<CodeBlock>.m_numVars
+ loadi Wasm::LLIntCallee::m_numVars[t2], t2 // t2<size_t> = t2<CodeBlock>.m_numVars
subq CalleeSaveSpaceAsVirtualRegisters + NumberOfWasmArguments, t2
btiz t2, .opEnterDone
move cfr, t1
@@ -670,11 +669,12 @@
wgetu(ctx, m_tableIndex, t1)
loadp CodeBlock[cfr], t2
- loadp Wasm::FunctionCodeBlock::m_jumpTables + VectorBufferOffset[t2], t2
- muli sizeof Wasm::FunctionCodeBlock::JumpTable, t1
+ loadp Wasm::LLIntCallee::m_jumpTables[t2], t2
+ muli sizeof Wasm::JumpTable, t1
addp t1, t2
- loadi VectorSizeOffset[t2], t3
+ loadp (constexpr (WasmJumpTableFixedVector::Storage::offsetOfData()))[t2], t2
+ loadi Wasm::JumpTable::Storage::m_size[t2], t3
bib t0, t3, .inBounds
.outOfBounds:
@@ -681,15 +681,14 @@
subi t3, 1, t0
.inBounds:
- loadp VectorBufferOffset[t2], t2
- muli sizeof Wasm::FunctionCodeBlock::JumpTableEntry, t0
+ muli sizeof Wasm::JumpTableEntry, t0
- loadi Wasm::FunctionCodeBlock::JumpTableEntry::startOffset[t2, t0], t1
- loadi Wasm::FunctionCodeBlock::JumpTableEntry::dropCount[t2, t0], t3
- loadi Wasm::FunctionCodeBlock::JumpTableEntry::keepCount[t2, t0], t5
+ loadi (constexpr (Wasm::JumpTable::Storage::offsetOfData())) + Wasm::JumpTableEntry::startOffset[t2, t0], t1
+ loadi (constexpr (Wasm::JumpTable::Storage::offsetOfData())) + Wasm::JumpTableEntry::dropCount[t2, t0], t3
+ loadi (constexpr (Wasm::JumpTable::Storage::offsetOfData())) + Wasm::JumpTableEntry::keepCount[t2, t0], t5
dropKeep(t1, t3, t5)
- loadis Wasm::FunctionCodeBlock::JumpTableEntry::target[t2, t0], t3
+ loadis (constexpr (Wasm::JumpTable::Storage::offsetOfData())) + Wasm::JumpTableEntry::target[t2, t0], t3
assert(macro(ok) btinz t3, .ok end)
wasmDispatchIndirect(t3)
end)
@@ -833,7 +832,7 @@
move PB, wasmInstance
loadi ArgumentCountIncludingThis + TagOffset[cfr], PC
loadp CodeBlock[cfr], PB
- loadp Wasm::FunctionCodeBlock::m_instructionsRawPointer[PB], PB
+ loadp Wasm::LLIntCallee::m_instructionsRawPointer[PB], PB
wgetu(ctx, m_stackOffset, ws1)
lshifti 3, ws1
@@ -2853,7 +2852,7 @@
reloadMemoryRegistersFromInstance(wasmInstance, ws0, ws1)
loadp CodeBlock[cfr], PB
- loadp Wasm::FunctionCodeBlock::m_instructionsRawPointer[PB], PB
+ loadp Wasm::LLIntCallee::m_instructionsRawPointer[PB], PB
loadp VM::targetInterpreterPCForThrow[t3], PC
subp PB, PC
Modified: trunk/Source/_javascript_Core/wasm/WasmCallee.cpp (287458 => 287459)
--- trunk/Source/_javascript_Core/wasm/WasmCallee.cpp 2021-12-27 07:46:43 UTC (rev 287458)
+++ trunk/Source/_javascript_Core/wasm/WasmCallee.cpp 2021-12-27 10:04:25 UTC (rev 287459)
@@ -76,21 +76,28 @@
{
}
-LLIntCallee::LLIntCallee(std::unique_ptr<FunctionCodeBlock> codeBlock, size_t index, std::pair<const Name*, RefPtr<NameSection>>&& name)
+LLIntCallee::LLIntCallee(FunctionCodeBlockGenerator& generator, size_t index, std::pair<const Name*, RefPtr<NameSection>>&& name)
: Callee(Wasm::CompilationMode::LLIntMode, index, WTFMove(name))
- , m_codeBlock(WTFMove(codeBlock))
+ , m_functionIndex(generator.m_functionIndex)
+ , m_numVars(generator.m_numVars)
+ , m_numCalleeLocals(generator.m_numCalleeLocals)
+ , m_numArguments(generator.m_numArguments)
+ , m_constantTypes(WTFMove(generator.m_constantTypes))
+ , m_constants(WTFMove(generator.m_constants))
+ , m_instructions(WTFMove(generator.m_instructions))
+ , m_instructionsRawPointer(generator.m_instructionsRawPointer)
+ , m_jumpTargets(WTFMove(generator.m_jumpTargets))
+ , m_signatures(WTFMove(generator.m_signatures))
+ , m_outOfLineJumpTargets(WTFMove(generator.m_outOfLineJumpTargets))
+ , m_tierUpCounter(WTFMove(generator.m_tierUpCounter))
+ , m_jumpTables(WTFMove(generator.m_jumpTables))
{
- linkExceptionHandlers();
-}
-
-void LLIntCallee::linkExceptionHandlers()
-{
- if (size_t count = m_codeBlock->numberOfExceptionHandlers()) {
+ if (size_t count = generator.numberOfExceptionHandlers()) {
m_exceptionHandlers = FixedVector<HandlerInfo>(count);
for (size_t i = 0; i < count; i++) {
- const UnlinkedHandlerInfo& unlinkedHandler = m_codeBlock->exceptionHandler(i);
+ const UnlinkedHandlerInfo& unlinkedHandler = generator.exceptionHandler(i);
HandlerInfo& handler = m_exceptionHandlers[i];
- auto& instruction = *m_codeBlock->instructions().at(unlinkedHandler.m_target).ptr();
+ auto& instruction = *m_instructions->at(unlinkedHandler.m_target).ptr();
CodeLocationLabel<ExceptionHandlerPtrTag> target;
if (unlinkedHandler.m_type == HandlerType::Catch)
target = CodeLocationLabel<ExceptionHandlerPtrTag>(LLInt::handleWasmCatch(instruction.width<WasmOpcodeTraits>()).code());
@@ -137,6 +144,19 @@
return { nullptr, nullptr };
}
+InstructionStream::Offset LLIntCallee::outOfLineJumpOffset(InstructionStream::Offset bytecodeOffset)
+{
+ ASSERT(m_outOfLineJumpTargets.contains(bytecodeOffset));
+ return m_outOfLineJumpTargets.get(bytecodeOffset);
+}
+
+const Instruction* LLIntCallee::outOfLineJumpTarget(const Instruction* pc)
+{
+ int offset = bytecodeOffset(pc);
+ int target = outOfLineJumpOffset(offset);
+ return m_instructions->at(offset + target).ptr();
+}
+
void OptimizingJITCallee::linkExceptionHandlers(Vector<UnlinkedHandlerInfo> unlinkedExceptionHandlers, Vector<CodeLocationLabel<ExceptionHandlerPtrTag>> exceptionHandlerLocations)
{
size_t count = unlinkedExceptionHandlers.size();
Modified: trunk/Source/_javascript_Core/wasm/WasmCallee.h (287458 => 287459)
--- trunk/Source/_javascript_Core/wasm/WasmCallee.h 2021-12-27 07:46:43 UTC (rev 287458)
+++ trunk/Source/_javascript_Core/wasm/WasmCallee.h 2021-12-27 10:04:25 UTC (rev 287459)
@@ -31,7 +31,7 @@
#include "RegisterAtOffsetList.h"
#include "WasmCompilationMode.h"
#include "WasmFormat.h"
-#include "WasmFunctionCodeBlock.h"
+#include "WasmFunctionCodeBlockGenerator.h"
#include "WasmHandlerInfo.h"
#include "WasmIndexOrName.h"
#include "WasmLLIntTierUpCounter.h"
@@ -65,8 +65,6 @@
void dump(PrintStream&) const;
- virtual FunctionCodeBlock* llintFunctionCodeBlock() const { return nullptr; }
-
protected:
JS_EXPORT_PRIVATE Callee(Wasm::CompilationMode);
JS_EXPORT_PRIVATE Callee(Wasm::CompilationMode, size_t, std::pair<const Name*, RefPtr<NameSection>>&&);
@@ -214,9 +212,9 @@
friend LLIntOffsetsExtractor;
public:
- static Ref<LLIntCallee> create(std::unique_ptr<FunctionCodeBlock> codeBlock, size_t index, std::pair<const Name*, RefPtr<NameSection>>&& name)
+ static Ref<LLIntCallee> create(FunctionCodeBlockGenerator& generator, size_t index, std::pair<const Name*, RefPtr<NameSection>>&& name)
{
- return adoptRef(*new LLIntCallee(WTFMove(codeBlock), index, WTFMove(name)));
+ return adoptRef(*new LLIntCallee(generator, index, WTFMove(name)));
}
JS_EXPORT_PRIVATE void setEntrypoint(MacroAssemblerCodePtr<WasmEntryPtrTag>);
@@ -224,6 +222,49 @@
JS_EXPORT_PRIVATE RegisterAtOffsetList* calleeSaveRegisters() final;
JS_EXPORT_PRIVATE std::tuple<void*, void*> range() const final;
+ uint32_t functionIndex() const { return m_functionIndex; }
+ unsigned numVars() const { return m_numVars; }
+ unsigned numCalleeLocals() const { return m_numCalleeLocals; }
+ uint32_t numArguments() const { return m_numArguments; }
+ const FixedVector<Type>& constantTypes() const { return m_constantTypes; }
+ const FixedVector<uint64_t>& constants() const { return m_constants; }
+ const InstructionStream& instructions() const { return *m_instructions; }
+
+ ALWAYS_INLINE uint64_t getConstant(VirtualRegister reg) const { return m_constants[reg.toConstantIndex()]; }
+ ALWAYS_INLINE Type getConstantType(VirtualRegister reg) const
+ {
+ ASSERT(Options::dumpGeneratedWasmBytecodes());
+ return m_constantTypes[reg.toConstantIndex()];
+ }
+
+ InstructionStream::Offset numberOfJumpTargets() { return m_jumpTargets.size(); }
+ InstructionStream::Offset lastJumpTarget() { return m_jumpTargets.last(); }
+
+ const Instruction* outOfLineJumpTarget(const Instruction*);
+ InstructionStream::Offset outOfLineJumpOffset(InstructionStream::Offset);
+ InstructionStream::Offset outOfLineJumpOffset(const InstructionStream::Ref& instruction)
+ {
+ return outOfLineJumpOffset(instruction.offset());
+ }
+
+ inline InstructionStream::Offset bytecodeOffset(const Instruction* returnAddress)
+ {
+ const auto* instructionsBegin = m_instructions->at(0).ptr();
+ const auto* instructionsEnd = reinterpret_cast<const Instruction*>(reinterpret_cast<uintptr_t>(instructionsBegin) + m_instructions->size());
+ RELEASE_ASSERT(returnAddress >= instructionsBegin && returnAddress < instructionsEnd);
+ return returnAddress - instructionsBegin;
+ }
+
+ LLIntTierUpCounter& tierUpCounter() { return m_tierUpCounter; }
+
+ const Signature& signature(unsigned index) const
+ {
+ return *m_signatures[index];
+ }
+
+ const JumpTable& jumpTable(unsigned tableIndex) const;
+ unsigned numberOfJumpTables() const;
+
#if ENABLE(WEBASSEMBLY_B3JIT)
JITCallee* replacement(MemoryMode mode) { return m_replacements[static_cast<uint8_t>(mode)].get(); }
void setReplacement(Ref<JITCallee>&& replacement, MemoryMode mode)
@@ -236,21 +277,34 @@
{
m_osrEntryCallees[static_cast<uint8_t>(mode)] = WTFMove(osrEntryCallee);
}
-
- LLIntTierUpCounter& tierUpCounter() { return m_codeBlock->tierUpCounter(); }
- FunctionCodeBlock* llintFunctionCodeBlock() const final { return m_codeBlock.get(); }
#endif
+ using OutOfLineJumpTargets = HashMap<InstructionStream::Offset, int>;
+
private:
- LLIntCallee(std::unique_ptr<FunctionCodeBlock>, size_t index, std::pair<const Name*, RefPtr<NameSection>>&&);
+ LLIntCallee(FunctionCodeBlockGenerator&, size_t index, std::pair<const Name*, RefPtr<NameSection>>&&);
- void linkExceptionHandlers();
+ uint32_t m_functionIndex { 0 };
+ // Used for the number of WebAssembly locals, as in https://webassembly.github.io/spec/core/syntax/modules.html#syntax-local
+ unsigned m_numVars { 0 };
+ // Number of VirtualRegister. The naming is unfortunate, but has to match UnlinkedCodeBlock
+ unsigned m_numCalleeLocals { 0 };
+ uint32_t m_numArguments { 0 };
+ FixedVector<Type> m_constantTypes;
+ FixedVector<uint64_t> m_constants;
+ std::unique_ptr<InstructionStream> m_instructions;
+ const void* m_instructionsRawPointer { nullptr };
+ FixedVector<InstructionStream::Offset> m_jumpTargets;
+ FixedVector<const Signature*> m_signatures;
+ OutOfLineJumpTargets m_outOfLineJumpTargets;
+ LLIntTierUpCounter m_tierUpCounter;
+ FixedVector<JumpTable> m_jumpTables;
+
#if ENABLE(WEBASSEMBLY_B3JIT)
RefPtr<JITCallee> m_replacements[Wasm::NumberOfMemoryModes];
RefPtr<OSREntryCallee> m_osrEntryCallees[Wasm::NumberOfMemoryModes];
#endif
- std::unique_ptr<FunctionCodeBlock> m_codeBlock;
MacroAssemblerCodePtr<WasmEntryPtrTag> m_entrypoint;
};
Deleted: trunk/Source/_javascript_Core/wasm/WasmFunctionCodeBlock.cpp (287458 => 287459)
--- trunk/Source/_javascript_Core/wasm/WasmFunctionCodeBlock.cpp 2021-12-27 07:46:43 UTC (rev 287458)
+++ trunk/Source/_javascript_Core/wasm/WasmFunctionCodeBlock.cpp 2021-12-27 10:04:25 UTC (rev 287459)
@@ -1,91 +0,0 @@
-/*
- * Copyright (C) 2019 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-
-#include "config.h"
-#include "WasmFunctionCodeBlock.h"
-
-#if ENABLE(WEBASSEMBLY)
-
-#include "InstructionStream.h"
-
-namespace JSC { namespace Wasm {
-
-void FunctionCodeBlock::setInstructions(std::unique_ptr<InstructionStream> instructions)
-{
- m_instructions = WTFMove(instructions);
- m_instructionsRawPointer = m_instructions->rawPointer();
-}
-
-void FunctionCodeBlock::addOutOfLineJumpTarget(InstructionStream::Offset bytecodeOffset, int target)
-{
- RELEASE_ASSERT(target);
- m_outOfLineJumpTargets.set(bytecodeOffset, target);
-}
-
-InstructionStream::Offset FunctionCodeBlock::outOfLineJumpOffset(InstructionStream::Offset bytecodeOffset)
-{
- ASSERT(m_outOfLineJumpTargets.contains(bytecodeOffset));
- return m_outOfLineJumpTargets.get(bytecodeOffset);
-}
-
-const Instruction* FunctionCodeBlock::outOfLineJumpTarget(const Instruction* pc)
-{
- int offset = bytecodeOffset(pc);
- int target = outOfLineJumpOffset(offset);
- return m_instructions->at(offset + target).ptr();
-}
-
-unsigned FunctionCodeBlock::addSignature(const Signature& signature)
-{
- unsigned index = m_signatures.size();
- m_signatures.append(&signature);
- return index;
-}
-
-const Signature& FunctionCodeBlock::signature(unsigned index) const
-{
- return *m_signatures[index];
-}
-
-auto FunctionCodeBlock::addJumpTable(size_t numberOfEntries) -> JumpTable&
-{
- m_jumpTables.append(JumpTable(numberOfEntries));
- return m_jumpTables.last();
-}
-
-auto FunctionCodeBlock::jumpTable(unsigned tableIndex) const -> const JumpTable&
-{
- return m_jumpTables[tableIndex];
-}
-
-unsigned FunctionCodeBlock::numberOfJumpTables() const
-{
- return m_jumpTables.size();
-}
-
-} } // namespace JSC::Wasm
-
-#endif // ENABLE(WEBASSEMBLY)
Deleted: trunk/Source/_javascript_Core/wasm/WasmFunctionCodeBlock.h (287458 => 287459)
--- trunk/Source/_javascript_Core/wasm/WasmFunctionCodeBlock.h 2021-12-27 07:46:43 UTC (rev 287458)
+++ trunk/Source/_javascript_Core/wasm/WasmFunctionCodeBlock.h 2021-12-27 10:04:25 UTC (rev 287459)
@@ -1,153 +0,0 @@
-/*
- * Copyright (C) 2019-2021 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#pragma once
-
-#if ENABLE(WEBASSEMBLY)
-
-#include "BytecodeConventions.h"
-#include "HandlerInfo.h"
-#include "InstructionStream.h"
-#include "MacroAssemblerCodeRef.h"
-#include "WasmHandlerInfo.h"
-#include "WasmLLIntTierUpCounter.h"
-#include "WasmOps.h"
-#include <wtf/HashMap.h>
-#include <wtf/Vector.h>
-
-namespace JSC {
-
-class JITCode;
-class LLIntOffsetsExtractor;
-
-template<typename Traits>
-class BytecodeGeneratorBase;
-
-namespace Wasm {
-
-class Signature;
-struct GeneratorTraits;
-
-// FIXME: Consider merging this with LLIntCallee
-// https://bugs.webkit.org/show_bug.cgi?id=203691
-class FunctionCodeBlock {
- WTF_MAKE_FAST_ALLOCATED;
- WTF_MAKE_NONCOPYABLE(FunctionCodeBlock);
-
- friend BytecodeGeneratorBase<GeneratorTraits>;
- friend LLIntOffsetsExtractor;
- friend class LLIntGenerator;
-
-public:
- FunctionCodeBlock(uint32_t functionIndex)
- : m_functionIndex(functionIndex)
- {
- }
-
- uint32_t functionIndex() const { return m_functionIndex; }
- unsigned numVars() const { return m_numVars; }
- unsigned numCalleeLocals() const { return m_numCalleeLocals; }
- uint32_t numArguments() const { return m_numArguments; }
- const Vector<Type>& constantTypes() const { return m_constantTypes; }
- const Vector<uint64_t>& constants() const { return m_constants; }
- const InstructionStream& instructions() const { return *m_instructions; }
-
- void setNumVars(unsigned numVars) { m_numVars = numVars; }
- void setNumCalleeLocals(unsigned numCalleeLocals) { m_numCalleeLocals = numCalleeLocals; }
-
- ALWAYS_INLINE uint64_t getConstant(VirtualRegister reg) const { return m_constants[reg.toConstantIndex()]; }
- ALWAYS_INLINE Type getConstantType(VirtualRegister reg) const
- {
- ASSERT(Options::dumpGeneratedWasmBytecodes());
- return m_constantTypes[reg.toConstantIndex()];
- }
-
- void setInstructions(std::unique_ptr<InstructionStream>);
- void addJumpTarget(InstructionStream::Offset jumpTarget) { m_jumpTargets.append(jumpTarget); }
- InstructionStream::Offset numberOfJumpTargets() { return m_jumpTargets.size(); }
- InstructionStream::Offset lastJumpTarget() { return m_jumpTargets.last(); }
-
- void addOutOfLineJumpTarget(InstructionStream::Offset, int target);
- const Instruction* outOfLineJumpTarget(const Instruction*);
- InstructionStream::Offset outOfLineJumpOffset(InstructionStream::Offset);
- InstructionStream::Offset outOfLineJumpOffset(const InstructionStream::Ref& instruction)
- {
- return outOfLineJumpOffset(instruction.offset());
- }
-
- inline InstructionStream::Offset bytecodeOffset(const Instruction* returnAddress)
- {
- const auto* instructionsBegin = m_instructions->at(0).ptr();
- const auto* instructionsEnd = reinterpret_cast<const Instruction*>(reinterpret_cast<uintptr_t>(instructionsBegin) + m_instructions->size());
- RELEASE_ASSERT(returnAddress >= instructionsBegin && returnAddress < instructionsEnd);
- return returnAddress - instructionsBegin;
- }
-
- LLIntTierUpCounter& tierUpCounter() { return m_tierUpCounter; }
-
- unsigned addSignature(const Signature&);
- const Signature& signature(unsigned index) const;
-
- struct JumpTableEntry {
- int target { 0 };
- unsigned startOffset;
- unsigned dropCount;
- unsigned keepCount;
- };
-
- using JumpTable = Vector<JumpTableEntry>;
- JumpTable& addJumpTable(size_t numberOfEntries);
- const JumpTable& jumpTable(unsigned tableIndex) const;
- unsigned numberOfJumpTables() const;
-
- size_t numberOfExceptionHandlers() const { return m_exceptionHandlers.size(); }
- UnlinkedHandlerInfo& exceptionHandler(int index) { return m_exceptionHandlers[index]; }
- void addExceptionHandler(const UnlinkedHandlerInfo& handler) { m_exceptionHandlers.append(handler); }
-
-private:
- using OutOfLineJumpTargets = HashMap<InstructionStream::Offset, int>;
-
- uint32_t m_functionIndex;
-
- // Used for the number of WebAssembly locals, as in https://webassembly.github.io/spec/core/syntax/modules.html#syntax-local
- unsigned m_numVars { 0 };
- // Number of VirtualRegister. The naming is unfortunate, but has to match UnlinkedCodeBlock
- unsigned m_numCalleeLocals { 0 };
- uint32_t m_numArguments { 0 };
- Vector<Type> m_constantTypes;
- Vector<uint64_t> m_constants;
- std::unique_ptr<InstructionStream> m_instructions;
- const void* m_instructionsRawPointer { nullptr };
- Vector<InstructionStream::Offset> m_jumpTargets;
- Vector<const Signature*> m_signatures;
- OutOfLineJumpTargets m_outOfLineJumpTargets;
- LLIntTierUpCounter m_tierUpCounter;
- Vector<JumpTable> m_jumpTables;
- Vector<UnlinkedHandlerInfo> m_exceptionHandlers;
-};
-
-} } // namespace JSC::Wasm
-
-#endif // ENABLE(WEBASSEMBLY)
Copied: trunk/Source/_javascript_Core/wasm/WasmFunctionCodeBlockGenerator.cpp (from rev 287458, trunk/Source/_javascript_Core/wasm/WasmFunctionCodeBlock.cpp) (0 => 287459)
--- trunk/Source/_javascript_Core/wasm/WasmFunctionCodeBlockGenerator.cpp (rev 0)
+++ trunk/Source/_javascript_Core/wasm/WasmFunctionCodeBlockGenerator.cpp 2021-12-27 10:04:25 UTC (rev 287459)
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+#include "config.h"
+#include "WasmFunctionCodeBlockGenerator.h"
+
+#if ENABLE(WEBASSEMBLY)
+
+#include "InstructionStream.h"
+
+namespace JSC { namespace Wasm {
+
+void FunctionCodeBlockGenerator::setInstructions(std::unique_ptr<InstructionStream> instructions)
+{
+ m_instructions = WTFMove(instructions);
+ m_instructionsRawPointer = m_instructions->rawPointer();
+}
+
+void FunctionCodeBlockGenerator::addOutOfLineJumpTarget(InstructionStream::Offset bytecodeOffset, int target)
+{
+ RELEASE_ASSERT(target);
+ m_outOfLineJumpTargets.set(bytecodeOffset, target);
+}
+
+InstructionStream::Offset FunctionCodeBlockGenerator::outOfLineJumpOffset(InstructionStream::Offset bytecodeOffset)
+{
+ ASSERT(m_outOfLineJumpTargets.contains(bytecodeOffset));
+ return m_outOfLineJumpTargets.get(bytecodeOffset);
+}
+
+unsigned FunctionCodeBlockGenerator::addSignature(const Signature& signature)
+{
+ unsigned index = m_signatures.size();
+ m_signatures.append(&signature);
+ return index;
+}
+
+auto FunctionCodeBlockGenerator::addJumpTable(size_t numberOfEntries) -> JumpTable&
+{
+ m_jumpTables.append(JumpTable(numberOfEntries));
+ return m_jumpTables.last();
+}
+
+unsigned FunctionCodeBlockGenerator::numberOfJumpTables() const
+{
+ return m_jumpTables.size();
+}
+
+} } // namespace JSC::Wasm
+
+#endif // ENABLE(WEBASSEMBLY)
Copied: trunk/Source/_javascript_Core/wasm/WasmFunctionCodeBlockGenerator.h (from rev 287458, trunk/Source/_javascript_Core/wasm/WasmFunctionCodeBlock.h) (0 => 287459)
--- trunk/Source/_javascript_Core/wasm/WasmFunctionCodeBlockGenerator.h (rev 0)
+++ trunk/Source/_javascript_Core/wasm/WasmFunctionCodeBlockGenerator.h 2021-12-27 10:04:25 UTC (rev 287459)
@@ -0,0 +1,151 @@
+/*
+ * Copyright (C) 2019-2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(WEBASSEMBLY)
+
+#include "BytecodeConventions.h"
+#include "HandlerInfo.h"
+#include "InstructionStream.h"
+#include "MacroAssemblerCodeRef.h"
+#include "WasmHandlerInfo.h"
+#include "WasmLLIntTierUpCounter.h"
+#include "WasmOps.h"
+#include <wtf/HashMap.h>
+#include <wtf/Vector.h>
+
+namespace JSC {
+
+class JITCode;
+class LLIntOffsetsExtractor;
+
+template<typename Traits>
+class BytecodeGeneratorBase;
+
+namespace Wasm {
+
+class LLIntCallee;
+class Signature;
+struct GeneratorTraits;
+
+struct JumpTableEntry {
+ int target { 0 };
+ unsigned startOffset;
+ unsigned dropCount;
+ unsigned keepCount;
+};
+
+using JumpTable = FixedVector<JumpTableEntry>;
+
+class FunctionCodeBlockGenerator {
+ WTF_MAKE_FAST_ALLOCATED;
+ WTF_MAKE_NONCOPYABLE(FunctionCodeBlockGenerator);
+
+ friend BytecodeGeneratorBase<GeneratorTraits>;
+ friend LLIntOffsetsExtractor;
+ friend class LLIntGenerator;
+ friend class LLIntCallee;
+
+public:
+ FunctionCodeBlockGenerator(uint32_t functionIndex)
+ : m_functionIndex(functionIndex)
+ {
+ }
+
+ uint32_t functionIndex() const { return m_functionIndex; }
+ unsigned numVars() const { return m_numVars; }
+ unsigned numCalleeLocals() const { return m_numCalleeLocals; }
+ uint32_t numArguments() const { return m_numArguments; }
+ const Vector<Type>& constantTypes() const { return m_constantTypes; }
+ const Vector<uint64_t>& constants() const { return m_constants; }
+ const InstructionStream& instructions() const { return *m_instructions; }
+
+ void setNumVars(unsigned numVars) { m_numVars = numVars; }
+ void setNumCalleeLocals(unsigned numCalleeLocals) { m_numCalleeLocals = numCalleeLocals; }
+
+ ALWAYS_INLINE uint64_t getConstant(VirtualRegister reg) const { return m_constants[reg.toConstantIndex()]; }
+ ALWAYS_INLINE Type getConstantType(VirtualRegister reg) const
+ {
+ ASSERT(Options::dumpGeneratedWasmBytecodes());
+ return m_constantTypes[reg.toConstantIndex()];
+ }
+
+ void setInstructions(std::unique_ptr<InstructionStream>);
+ void addJumpTarget(InstructionStream::Offset jumpTarget) { m_jumpTargets.append(jumpTarget); }
+ InstructionStream::Offset numberOfJumpTargets() { return m_jumpTargets.size(); }
+ InstructionStream::Offset lastJumpTarget() { return m_jumpTargets.last(); }
+
+ void addOutOfLineJumpTarget(InstructionStream::Offset, int target);
+ InstructionStream::Offset outOfLineJumpOffset(InstructionStream::Offset);
+ InstructionStream::Offset outOfLineJumpOffset(const InstructionStream::Ref& instruction)
+ {
+ return outOfLineJumpOffset(instruction.offset());
+ }
+
+ inline InstructionStream::Offset bytecodeOffset(const Instruction* returnAddress)
+ {
+ const auto* instructionsBegin = m_instructions->at(0).ptr();
+ const auto* instructionsEnd = reinterpret_cast<const Instruction*>(reinterpret_cast<uintptr_t>(instructionsBegin) + m_instructions->size());
+ RELEASE_ASSERT(returnAddress >= instructionsBegin && returnAddress < instructionsEnd);
+ return returnAddress - instructionsBegin;
+ }
+
+ HashMap<InstructionStream::Offset, LLIntTierUpCounter::OSREntryData>& tierUpCounter() { return m_tierUpCounter; }
+
+ unsigned addSignature(const Signature&);
+
+ JumpTable& addJumpTable(size_t numberOfEntries);
+ unsigned numberOfJumpTables() const;
+
+ size_t numberOfExceptionHandlers() const { return m_exceptionHandlers.size(); }
+ UnlinkedHandlerInfo& exceptionHandler(int index) { return m_exceptionHandlers[index]; }
+ void addExceptionHandler(const UnlinkedHandlerInfo& handler) { m_exceptionHandlers.append(handler); }
+
+private:
+ using OutOfLineJumpTargets = HashMap<InstructionStream::Offset, int>;
+
+ uint32_t m_functionIndex;
+
+ // Used for the number of WebAssembly locals, as in https://webassembly.github.io/spec/core/syntax/modules.html#syntax-local
+ unsigned m_numVars { 0 };
+ // Number of VirtualRegister. The naming is unfortunate, but has to match UnlinkedCodeBlock
+ unsigned m_numCalleeLocals { 0 };
+ uint32_t m_numArguments { 0 };
+ Vector<Type> m_constantTypes;
+ Vector<uint64_t> m_constants;
+ std::unique_ptr<InstructionStream> m_instructions;
+ const void* m_instructionsRawPointer { nullptr };
+ Vector<InstructionStream::Offset> m_jumpTargets;
+ Vector<const Signature*> m_signatures;
+ OutOfLineJumpTargets m_outOfLineJumpTargets;
+ HashMap<InstructionStream::Offset, LLIntTierUpCounter::OSREntryData> m_tierUpCounter;
+ Vector<JumpTable> m_jumpTables;
+ Vector<UnlinkedHandlerInfo> m_exceptionHandlers;
+};
+
+} } // namespace JSC::Wasm
+
+#endif // ENABLE(WEBASSEMBLY)
Modified: trunk/Source/_javascript_Core/wasm/WasmGeneratorTraits.h (287458 => 287459)
--- trunk/Source/_javascript_Core/wasm/WasmGeneratorTraits.h 2021-12-27 07:46:43 UTC (rev 287458)
+++ trunk/Source/_javascript_Core/wasm/WasmGeneratorTraits.h 2021-12-27 10:04:25 UTC (rev 287459)
@@ -36,7 +36,7 @@
using OpcodeTraits = WasmOpcodeTraits;
using OpcodeID = WasmOpcodeID;
using OpNop = WasmNop;
- using CodeBlock = std::unique_ptr<FunctionCodeBlock>;
+ using CodeBlock = std::unique_ptr<FunctionCodeBlockGenerator>;
static constexpr OpcodeID opcodeForDisablingOptimizations = wasm_unreachable;
};
Modified: trunk/Source/_javascript_Core/wasm/WasmLLIntGenerator.cpp (287458 => 287459)
--- trunk/Source/_javascript_Core/wasm/WasmLLIntGenerator.cpp 2021-12-27 07:46:43 UTC (rev 287458)
+++ trunk/Source/_javascript_Core/wasm/WasmLLIntGenerator.cpp 2021-12-27 10:04:25 UTC (rev 287459)
@@ -35,7 +35,7 @@
#include "Label.h"
#include "WasmCallingConvention.h"
#include "WasmContextInlines.h"
-#include "WasmFunctionCodeBlock.h"
+#include "WasmFunctionCodeBlockGenerator.h"
#include "WasmFunctionParser.h"
#include "WasmGeneratorTraits.h"
#include <variant>
@@ -193,7 +193,7 @@
LLIntGenerator(ModuleInformation&, unsigned functionIndex, const Signature&);
- std::unique_ptr<FunctionCodeBlock> finalize();
+ std::unique_ptr<FunctionCodeBlockGenerator> finalize();
template<typename ExpressionListA, typename ExpressionListB>
void unifyValuesWithBlock(const ExpressionListA& destinations, const ExpressionListB& values)
@@ -500,7 +500,7 @@
bool m_usesExceptions { false };
};
-Expected<std::unique_ptr<FunctionCodeBlock>, String> parseAndCompileBytecode(const uint8_t* functionStart, size_t functionLength, const Signature& signature, ModuleInformation& info, uint32_t functionIndex)
+Expected<std::unique_ptr<FunctionCodeBlockGenerator>, String> parseAndCompileBytecode(const uint8_t* functionStart, size_t functionLength, const Signature& signature, ModuleInformation& info, uint32_t functionIndex)
{
LLIntGenerator llintGenerator(info, functionIndex, signature);
FunctionParser<LLIntGenerator> parser(llintGenerator, functionStart, functionLength, signature, info);
@@ -525,7 +525,7 @@
}
LLIntGenerator::LLIntGenerator(ModuleInformation& info, unsigned functionIndex, const Signature&)
- : BytecodeGeneratorBase(makeUnique<FunctionCodeBlock>(functionIndex), 0)
+ : BytecodeGeneratorBase(makeUnique<FunctionCodeBlockGenerator>(functionIndex), 0)
, m_info(info)
, m_functionIndex(functionIndex)
{
@@ -543,7 +543,7 @@
WasmEnter::emit(this);
}
-std::unique_ptr<FunctionCodeBlock> LLIntGenerator::finalize()
+std::unique_ptr<FunctionCodeBlockGenerator> LLIntGenerator::finalize()
{
RELEASE_ASSERT(m_codeBlock);
@@ -983,7 +983,7 @@
WasmLoopHint::emit(this);
- m_codeBlock->tierUpCounter().addOSREntryDataForLoop(m_lastInstruction.offset(), { loopIndex, WTFMove(osrEntryData) });
+ m_codeBlock->tierUpCounter().add(m_lastInstruction.offset(), LLIntTierUpCounter::OSREntryData { loopIndex, WTFMove(osrEntryData) });
return { };
}
@@ -1226,7 +1226,7 @@
materializeConstantsAndLocals(expressionStack);
unsigned tableIndex = m_codeBlock->numberOfJumpTables();
- FunctionCodeBlock::JumpTable& jumpTable = m_codeBlock->addJumpTable(targets.size() + 1);
+ auto& jumpTable = m_codeBlock->addJumpTable(targets.size() + 1);
WasmSwitch::emit(this, condition, tableIndex);
Modified: trunk/Source/_javascript_Core/wasm/WasmLLIntGenerator.h (287458 => 287459)
--- trunk/Source/_javascript_Core/wasm/WasmLLIntGenerator.h 2021-12-27 07:46:43 UTC (rev 287458)
+++ trunk/Source/_javascript_Core/wasm/WasmLLIntGenerator.h 2021-12-27 10:04:25 UTC (rev 287459)
@@ -32,11 +32,11 @@
namespace JSC { namespace Wasm {
-class FunctionCodeBlock;
+class FunctionCodeBlockGenerator;
class Signature;
struct ModuleInformation;
-Expected<std::unique_ptr<FunctionCodeBlock>, String> parseAndCompileBytecode(const uint8_t*, size_t, const Signature&, ModuleInformation&, uint32_t functionIndex);
+Expected<std::unique_ptr<FunctionCodeBlockGenerator>, String> parseAndCompileBytecode(const uint8_t*, size_t, const Signature&, ModuleInformation&, uint32_t functionIndex);
} } // namespace JSC::Wasm
Modified: trunk/Source/_javascript_Core/wasm/WasmLLIntPlan.cpp (287458 => 287459)
--- trunk/Source/_javascript_Core/wasm/WasmLLIntPlan.cpp 2021-12-27 07:46:43 UTC (rev 287458)
+++ trunk/Source/_javascript_Core/wasm/WasmLLIntPlan.cpp 2021-12-27 10:04:25 UTC (rev 287459)
@@ -85,7 +85,7 @@
ASSERT_UNUSED(functionIndexSpace, m_moduleInformation->signatureIndexFromFunctionIndexSpace(functionIndexSpace) == signatureIndex);
m_unlinkedWasmToWasmCalls[functionIndex] = Vector<UnlinkedWasmToWasmCall>();
- Expected<std::unique_ptr<FunctionCodeBlock>, String> parseAndCompileResult = parseAndCompileBytecode(function.data.data(), function.data.size(), signature, m_moduleInformation.get(), functionIndex);
+ Expected<std::unique_ptr<FunctionCodeBlockGenerator>, String> parseAndCompileResult = parseAndCompileBytecode(function.data.data(), function.data.size(), signature, m_moduleInformation.get(), functionIndex);
if (UNLIKELY(!parseAndCompileResult)) {
Locker locker { m_lock };
@@ -115,7 +115,7 @@
if (UNLIKELY(Options::dumpGeneratedWasmBytecodes()))
BytecodeDumper::dumpBlock(m_wasmInternalFunctions[i].get(), m_moduleInformation, WTF::dataFile());
- m_calleesVector[i] = LLIntCallee::create(WTFMove(m_wasmInternalFunctions[i]), functionIndexSpace, m_moduleInformation->nameSection->get(functionIndexSpace));
+ m_calleesVector[i] = LLIntCallee::create(*m_wasmInternalFunctions[i], functionIndexSpace, m_moduleInformation->nameSection->get(functionIndexSpace));
entrypoints[i] = jit.label();
#if CPU(X86_64)
CCallHelpers::Address calleeSlot(CCallHelpers::stackPointerRegister, CallFrameSlot::callee * static_cast<int>(sizeof(Register)) - sizeof(CPURegister));
Modified: trunk/Source/_javascript_Core/wasm/WasmLLIntPlan.h (287458 => 287459)
--- trunk/Source/_javascript_Core/wasm/WasmLLIntPlan.h 2021-12-27 07:46:43 UTC (rev 287458)
+++ trunk/Source/_javascript_Core/wasm/WasmLLIntPlan.h 2021-12-27 10:04:25 UTC (rev 287459)
@@ -28,7 +28,7 @@
#if ENABLE(WEBASSEMBLY)
#include "WasmEntryPlan.h"
-#include "WasmFunctionCodeBlock.h"
+#include "WasmFunctionCodeBlockGenerator.h"
namespace JSC {
@@ -87,7 +87,7 @@
bool prepareImpl() final;
void didCompleteCompilation() WTF_REQUIRES_LOCK(m_lock) final;
- Vector<std::unique_ptr<FunctionCodeBlock>> m_wasmInternalFunctions;
+ Vector<std::unique_ptr<FunctionCodeBlockGenerator>> m_wasmInternalFunctions;
const Ref<LLIntCallee>* m_callees { nullptr };
Vector<Ref<LLIntCallee>> m_calleesVector;
EmbedderEntrypointCalleeMap m_embedderCallees;
Modified: trunk/Source/_javascript_Core/wasm/WasmLLIntTierUpCounter.h (287458 => 287459)
--- trunk/Source/_javascript_Core/wasm/WasmLLIntTierUpCounter.h 2021-12-27 07:46:43 UTC (rev 287458)
+++ trunk/Source/_javascript_Core/wasm/WasmLLIntTierUpCounter.h 2021-12-27 10:04:25 UTC (rev 287459)
@@ -44,7 +44,13 @@
Compiled,
};
- LLIntTierUpCounter()
+ struct OSREntryData {
+ uint32_t loopIndex;
+ Vector<VirtualRegister> values;
+ };
+
+ LLIntTierUpCounter(HashMap<InstructionStream::Offset, OSREntryData>&& osrEntryData)
+ : m_osrEntryData(WTFMove(osrEntryData))
{
optimizeAfterWarmUp();
}
@@ -70,11 +76,6 @@
setNewThreshold(Options::thresholdForOMGOptimizeSoon());
}
- struct OSREntryData {
- uint32_t loopIndex;
- Vector<VirtualRegister> values;
- };
-
void addOSREntryDataForLoop(InstructionStream::Offset, OSREntryData&&);
const OSREntryData& osrEntryDataForLoop(InstructionStream::Offset) const;
Modified: trunk/Source/_javascript_Core/wasm/WasmSlowPaths.cpp (287458 => 287459)
--- trunk/Source/_javascript_Core/wasm/WasmSlowPaths.cpp 2021-12-27 07:46:43 UTC (rev 287458)
+++ trunk/Source/_javascript_Core/wasm/WasmSlowPaths.cpp 2021-12-27 10:04:25 UTC (rev 287459)
@@ -35,7 +35,7 @@
#include "LLIntData.h"
#include "WasmBBQPlan.h"
#include "WasmCallee.h"
-#include "WasmFunctionCodeBlock.h"
+#include "WasmFunctionCodeBlockGenerator.h"
#include "WasmInstance.h"
#include "WasmModuleInformation.h"
#include "WasmOMGPlan.h"
@@ -71,18 +71,18 @@
WASM_RETURN_TWO((retagCodePtr<callTargetTag, JSEntrySlowPathPtrTag>(callTarget)), targetInstance); \
} while (false)
-#define CODE_BLOCK() \
- bitwise_cast<Wasm::FunctionCodeBlock*>(callFrame->codeBlock())
+#define CALLEE() \
+ static_cast<Wasm::LLIntCallee*>(callFrame->callee().asWasmCallee())
#define READ(virtualRegister) \
(virtualRegister.isConstant() \
- ? JSValue::decode(CODE_BLOCK()->getConstant(virtualRegister)) \
+ ? JSValue::decode(CALLEE()->getConstant(virtualRegister)) \
: callFrame->r(virtualRegister))
#if ENABLE(WEBASSEMBLY_B3JIT)
enum class RequiredWasmJIT { Any, OMG };
-inline bool shouldJIT(Wasm::FunctionCodeBlock* codeBlock, RequiredWasmJIT requiredJIT = RequiredWasmJIT::Any)
+inline bool shouldJIT(Wasm::LLIntCallee* callee, RequiredWasmJIT requiredJIT = RequiredWasmJIT::Any)
{
if (requiredJIT == RequiredWasmJIT::OMG) {
if (!Options::useOMGJIT())
@@ -93,14 +93,14 @@
if (!Options::wasmLLIntTiersUpToBBQ() && !Options::useOMGJIT())
return false;
}
- if (!Options::wasmFunctionIndexRangeToCompile().isInRange(codeBlock->functionIndex()))
+ if (!Options::wasmFunctionIndexRangeToCompile().isInRange(callee->functionIndex()))
return false;
return true;
}
-inline bool jitCompileAndSetHeuristics(Wasm::LLIntCallee* callee, Wasm::FunctionCodeBlock* codeBlock, Wasm::Instance* instance)
+inline bool jitCompileAndSetHeuristics(Wasm::LLIntCallee* callee, Wasm::Instance* instance)
{
- Wasm::LLIntTierUpCounter& tierUpCounter = codeBlock->tierUpCounter();
+ Wasm::LLIntTierUpCounter& tierUpCounter = callee->tierUpCounter();
if (!tierUpCounter.checkIfOptimizationThresholdReached()) {
dataLogLnIf(Options::verboseOSR(), " JIT threshold should be lifted.");
return false;
@@ -129,7 +129,7 @@
}
if (compile) {
- uint32_t functionIndex = codeBlock->functionIndex();
+ uint32_t functionIndex = callee->functionIndex();
RefPtr<Wasm::Plan> plan;
if (Options::wasmLLIntTiersUpToBBQ())
plan = adoptRef(*new Wasm::BBQPlan(instance->context(), const_cast<Wasm::ModuleInformation&>(instance->module().moduleInformation()), functionIndex, instance->calleeGroup(), Wasm::Plan::dontFinalize()));
@@ -150,11 +150,10 @@
{
UNUSED_PARAM(pc);
- Wasm::LLIntCallee* callee = static_cast<Wasm::LLIntCallee*>(callFrame->callee().asWasmCallee());
- Wasm::FunctionCodeBlock* codeBlock = CODE_BLOCK();
+ Wasm::LLIntCallee* callee = CALLEE();
- if (!shouldJIT(codeBlock)) {
- codeBlock->tierUpCounter().deferIndefinitely();
+ if (!shouldJIT(callee)) {
+ callee->tierUpCounter().deferIndefinitely();
WASM_RETURN_TWO(nullptr, nullptr);
}
@@ -161,9 +160,9 @@
if (!Options::useWasmLLIntPrologueOSR())
WASM_RETURN_TWO(nullptr, nullptr);
- dataLogLnIf(Options::verboseOSR(), *callee, ": Entered prologue_osr with tierUpCounter = ", codeBlock->tierUpCounter());
+ dataLogLnIf(Options::verboseOSR(), *callee, ": Entered prologue_osr with tierUpCounter = ", callee->tierUpCounter());
- if (!jitCompileAndSetHeuristics(callee, codeBlock, instance))
+ if (!jitCompileAndSetHeuristics(callee, instance))
WASM_RETURN_TWO(nullptr, nullptr);
WASM_RETURN_TWO(callee->replacement(instance->memory()->mode())->entrypoint().executableAddress(), nullptr);
@@ -171,18 +170,17 @@
WASM_SLOW_PATH_DECL(loop_osr)
{
- Wasm::LLIntCallee* callee = static_cast<Wasm::LLIntCallee*>(callFrame->callee().asWasmCallee());
- Wasm::FunctionCodeBlock* codeBlock = CODE_BLOCK();
- Wasm::LLIntTierUpCounter& tierUpCounter = codeBlock->tierUpCounter();
+ Wasm::LLIntCallee* callee = CALLEE();
+ Wasm::LLIntTierUpCounter& tierUpCounter = callee->tierUpCounter();
- if (!Options::useWebAssemblyOSR() || !Options::useWasmLLIntLoopOSR() || !shouldJIT(codeBlock, RequiredWasmJIT::OMG)) {
+ if (!Options::useWebAssemblyOSR() || !Options::useWasmLLIntLoopOSR() || !shouldJIT(callee, RequiredWasmJIT::OMG)) {
slow_path_wasm_prologue_osr(callFrame, pc, instance);
WASM_RETURN_TWO(nullptr, nullptr);
}
- dataLogLnIf(Options::verboseOSR(), *callee, ": Entered loop_osr with tierUpCounter = ", codeBlock->tierUpCounter());
+ dataLogLnIf(Options::verboseOSR(), *callee, ": Entered loop_osr with tierUpCounter = ", callee->tierUpCounter());
- unsigned loopOSREntryBytecodeOffset = codeBlock->bytecodeOffset(pc);
+ unsigned loopOSREntryBytecodeOffset = callee->bytecodeOffset(pc);
const auto& osrEntryData = tierUpCounter.osrEntryDataForLoop(loopOSREntryBytecodeOffset);
if (!tierUpCounter.checkIfOptimizationThresholdReached()) {
@@ -227,7 +225,7 @@
}
if (compile) {
- Ref<Wasm::Plan> plan = adoptRef(*static_cast<Wasm::Plan*>(new Wasm::OSREntryPlan(instance->context(), Ref<Wasm::Module>(instance->module()), Ref<Wasm::Callee>(*callee), codeBlock->functionIndex(), osrEntryData.loopIndex, instance->memory()->mode(), Wasm::Plan::dontFinalize())));
+ Ref<Wasm::Plan> plan = adoptRef(*static_cast<Wasm::Plan*>(new Wasm::OSREntryPlan(instance->context(), Ref<Wasm::Module>(instance->module()), Ref<Wasm::Callee>(*callee), callee->functionIndex(), osrEntryData.loopIndex, instance->memory()->mode(), Wasm::Plan::dontFinalize())));
Wasm::ensureWorklist().enqueue(plan.copyRef());
if (UNLIKELY(!Options::useConcurrentJIT()))
plan->waitForCompletion();
@@ -243,19 +241,18 @@
WASM_SLOW_PATH_DECL(epilogue_osr)
{
- Wasm::LLIntCallee* callee = static_cast<Wasm::LLIntCallee*>(callFrame->callee().asWasmCallee());
- Wasm::FunctionCodeBlock* codeBlock = CODE_BLOCK();
+ Wasm::LLIntCallee* callee = CALLEE();
- if (!shouldJIT(codeBlock)) {
- codeBlock->tierUpCounter().deferIndefinitely();
+ if (!shouldJIT(callee)) {
+ callee->tierUpCounter().deferIndefinitely();
WASM_END_IMPL();
}
if (!Options::useWasmLLIntEpilogueOSR())
WASM_END_IMPL();
- dataLogLnIf(Options::verboseOSR(), *callee, ": Entered epilogue_osr with tierUpCounter = ", codeBlock->tierUpCounter());
+ dataLogLnIf(Options::verboseOSR(), *callee, ": Entered epilogue_osr with tierUpCounter = ", callee->tierUpCounter());
- jitCompileAndSetHeuristics(callee, codeBlock, instance);
+ jitCompileAndSetHeuristics(callee, instance);
WASM_END_IMPL();
}
#endif
@@ -270,9 +267,9 @@
WasmOpcodeID opcodeID = pc->opcodeID<WasmOpcodeTraits>();
dataLogF("<%p> %p / %p: executing bc#%zu, %s, pc = %p\n",
&Thread::current(),
- callFrame->codeBlock(),
+ CALLEE(),
callFrame,
- static_cast<intptr_t>(CODE_BLOCK()->bytecodeOffset(pc)),
+ static_cast<intptr_t>(CALLEE()->bytecodeOffset(pc)),
pc->name<WasmOpcodeTraits>(),
pc);
if (opcodeID == wasm_enter) {
@@ -290,7 +287,7 @@
{
UNUSED_PARAM(instance);
- pc = CODE_BLOCK()->outOfLineJumpTarget(pc);
+ pc = CALLEE()->outOfLineJumpTarget(pc);
WASM_END_IMPL();
}
@@ -477,7 +474,7 @@
if (function.signatureIndex == Wasm::Signature::invalidIndex)
WASM_THROW(Wasm::ExceptionType::NullTableEntry);
- const Wasm::Signature& callSignature = CODE_BLOCK()->signature(signatureIndex);
+ const Wasm::Signature& callSignature = CALLEE()->signature(signatureIndex);
if (function.signatureIndex != Wasm::SignatureInformation::get(callSignature))
WASM_THROW(Wasm::ExceptionType::BadSignature);
@@ -519,7 +516,7 @@
if (calleeInstance != callerInstance)
calleeInstance->setCachedStackLimit(callerInstance->cachedStackLimit());
- ASSERT(function.signatureIndex == Wasm::SignatureInformation::get(CODE_BLOCK()->signature(signatureIndex)));
+ ASSERT(function.signatureIndex == Wasm::SignatureInformation::get(CALLEE()->signature(signatureIndex)));
UNUSED_PARAM(signatureIndex);
WASM_CALL_RETURN(calleeInstance, function.entrypointLoadLocation->executableAddress(), WasmEntryPtrTag);
}