Skip to content

Commit 5c40c80

Browse files
committed
WebAssembly: ModuleInformation should be a ref counted thing that can be shared across threads.
https://bugs.webkit.org/show_bug.cgi?id=170478 Reviewed by Saam Barati. Source/JavaScriptCore: ModuleInformation has been moved to its own file and is now ThreadSafeRefCounted. All the Strings we used to keep in the ModuleInformation have been switched to Vector<LChar> this has the advantage that it can be passed across threads. However, this does mean that we need to decode the utf8 strings in each thread. This is likely not a problem because: 1) most modules have few imports/exports/custom sections. 2) most of the time they are ascii so the conversion is cheap. 3) we only have to do it once per thread, and there shouldn't be too many. This patch also removes moduleSignatureIndicesToUniquedSignatureIndices since that information can already be recovered from the SignatureInformation. * JavaScriptCore.xcodeproj/project.pbxproj: * jsc.cpp: (functionTestWasmModuleFunctions): * runtime/Identifier.h: (JSC::Identifier::fromString): * wasm/WasmB3IRGenerator.cpp: (JSC::Wasm::parseAndCompile): * wasm/WasmB3IRGenerator.h: * wasm/WasmFormat.cpp: (JSC::Wasm::makeString): (JSC::Wasm::ModuleInformation::~ModuleInformation): Deleted. * wasm/WasmFormat.h: (JSC::Wasm::makeString): (JSC::Wasm::ModuleInformation::functionIndexSpaceSize): Deleted. (JSC::Wasm::ModuleInformation::isImportedFunctionFromFunctionIndexSpace): Deleted. (JSC::Wasm::ModuleInformation::signatureIndexFromFunctionIndexSpace): Deleted. (JSC::Wasm::ModuleInformation::importFunctionCount): Deleted. (JSC::Wasm::ModuleInformation::internalFunctionCount): Deleted. * wasm/WasmFunctionParser.h: (JSC::Wasm::FunctionParser<Context>::FunctionParser): * wasm/WasmModuleInformation.cpp: Copied from Source/JavaScriptCore/wasm/WasmValidate.h. (JSC::Wasm::ModuleInformation::~ModuleInformation): * wasm/WasmModuleInformation.h: Added. (JSC::Wasm::ModuleInformation::functionIndexSpaceSize): (JSC::Wasm::ModuleInformation::isImportedFunctionFromFunctionIndexSpace): (JSC::Wasm::ModuleInformation::signatureIndexFromFunctionIndexSpace): (JSC::Wasm::ModuleInformation::importFunctionCount): (JSC::Wasm::ModuleInformation::internalFunctionCount): (JSC::Wasm::ModuleInformation::ModuleInformation): * wasm/WasmModuleParser.cpp: * wasm/WasmModuleParser.h: (JSC::Wasm::ModuleParser::ModuleParser): * wasm/WasmParser.h: (JSC::Wasm::Parser<SuccessType>::consumeUTF8String): * wasm/WasmPlan.cpp: (JSC::Wasm::Plan::Plan): (JSC::Wasm::Plan::parseAndValidateModule): (JSC::Wasm::Plan::prepare): (JSC::Wasm::Plan::compileFunctions): (JSC::Wasm::Plan::complete): (JSC::Wasm::Plan::cancel): * wasm/WasmPlan.h: (JSC::Wasm::Plan::internalFunctionCount): (JSC::Wasm::Plan::takeModuleInformation): * wasm/WasmSignature.cpp: (JSC::Wasm::SignatureInformation::get): * wasm/WasmSignature.h: * wasm/WasmValidate.cpp: (JSC::Wasm::validateFunction): * wasm/WasmValidate.h: * wasm/js/JSWebAssemblyHelpers.h: (JSC::createSourceBufferFromValue): * wasm/js/JSWebAssemblyModule.cpp: (JSC::JSWebAssemblyModule::createStub): (JSC::JSWebAssemblyModule::JSWebAssemblyModule): (JSC::JSWebAssemblyModule::finishCreation): * wasm/js/JSWebAssemblyModule.h: (JSC::JSWebAssemblyModule::moduleInformation): (JSC::JSWebAssemblyModule::source): * wasm/js/WebAssemblyInstanceConstructor.cpp: (JSC::constructJSWebAssemblyInstance): * wasm/js/WebAssemblyModuleConstructor.cpp: (JSC::WebAssemblyModuleConstructor::createModule): * wasm/js/WebAssemblyModulePrototype.cpp: (JSC::webAssemblyModuleProtoCustomSections): (JSC::webAssemblyModuleProtoImports): (JSC::webAssemblyModuleProtoExports): * wasm/js/WebAssemblyModuleRecord.cpp: (JSC::WebAssemblyModuleRecord::link): * wasm/js/WebAssemblyModuleRecord.h: * wasm/js/WebAssemblyPrototype.cpp: (JSC::webAssemblyCompileFunc): (JSC::instantiate): (JSC::compileAndInstantiate): Source/WTF: This adds a new String::fromUTF8 that converts a vector of characters to a string. Also, it cleans up some style. * wtf/text/WTFString.h: (WTF::String::fromUTF8): * wtf/unicode/UTF8.cpp: (WTF::Unicode::convertLatin1ToUTF8): Canonical link: https://commits.webkit.org/187403@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@214919 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent b470a94 commit 5c40c80

33 files changed

Lines changed: 488 additions & 258 deletions

‎Source/JavaScriptCore/CMakeLists.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -943,6 +943,7 @@ set(JavaScriptCore_SOURCES
943943
wasm/WasmFormat.cpp
944944
wasm/WasmMemory.cpp
945945
wasm/WasmMemoryInformation.cpp
946+
wasm/WasmModuleInformation.cpp
946947
wasm/WasmModuleParser.cpp
947948
wasm/WasmPageCount.cpp
948949
wasm/WasmPlan.cpp

‎Source/JavaScriptCore/ChangeLog‎

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,101 @@
1+
2017-04-04 Keith Miller <keith_miller@apple.com>
2+
3+
WebAssembly: ModuleInformation should be a ref counted thing that can be shared across threads.
4+
https://bugs.webkit.org/show_bug.cgi?id=170478
5+
6+
Reviewed by Saam Barati.
7+
8+
ModuleInformation has been moved to its own file and is now
9+
ThreadSafeRefCounted. All the Strings we used to keep in the
10+
ModuleInformation have been switched to Vector<LChar> this has the
11+
advantage that it can be passed across threads. However, this does
12+
mean that we need to decode the utf8 strings in each thread. This
13+
is likely not a problem because:
14+
15+
1) most modules have few imports/exports/custom sections.
16+
2) most of the time they are ascii so the conversion is cheap.
17+
3) we only have to do it once per thread, and there shouldn't be too many.
18+
19+
This patch also removes
20+
moduleSignatureIndicesToUniquedSignatureIndices since that
21+
information can already be recovered from the
22+
SignatureInformation.
23+
24+
* JavaScriptCore.xcodeproj/project.pbxproj:
25+
* jsc.cpp:
26+
(functionTestWasmModuleFunctions):
27+
* runtime/Identifier.h:
28+
(JSC::Identifier::fromString):
29+
* wasm/WasmB3IRGenerator.cpp:
30+
(JSC::Wasm::parseAndCompile):
31+
* wasm/WasmB3IRGenerator.h:
32+
* wasm/WasmFormat.cpp:
33+
(JSC::Wasm::makeString):
34+
(JSC::Wasm::ModuleInformation::~ModuleInformation): Deleted.
35+
* wasm/WasmFormat.h:
36+
(JSC::Wasm::makeString):
37+
(JSC::Wasm::ModuleInformation::functionIndexSpaceSize): Deleted.
38+
(JSC::Wasm::ModuleInformation::isImportedFunctionFromFunctionIndexSpace): Deleted.
39+
(JSC::Wasm::ModuleInformation::signatureIndexFromFunctionIndexSpace): Deleted.
40+
(JSC::Wasm::ModuleInformation::importFunctionCount): Deleted.
41+
(JSC::Wasm::ModuleInformation::internalFunctionCount): Deleted.
42+
* wasm/WasmFunctionParser.h:
43+
(JSC::Wasm::FunctionParser<Context>::FunctionParser):
44+
* wasm/WasmModuleInformation.cpp: Copied from Source/JavaScriptCore/wasm/WasmValidate.h.
45+
(JSC::Wasm::ModuleInformation::~ModuleInformation):
46+
* wasm/WasmModuleInformation.h: Added.
47+
(JSC::Wasm::ModuleInformation::functionIndexSpaceSize):
48+
(JSC::Wasm::ModuleInformation::isImportedFunctionFromFunctionIndexSpace):
49+
(JSC::Wasm::ModuleInformation::signatureIndexFromFunctionIndexSpace):
50+
(JSC::Wasm::ModuleInformation::importFunctionCount):
51+
(JSC::Wasm::ModuleInformation::internalFunctionCount):
52+
(JSC::Wasm::ModuleInformation::ModuleInformation):
53+
* wasm/WasmModuleParser.cpp:
54+
* wasm/WasmModuleParser.h:
55+
(JSC::Wasm::ModuleParser::ModuleParser):
56+
* wasm/WasmParser.h:
57+
(JSC::Wasm::Parser<SuccessType>::consumeUTF8String):
58+
* wasm/WasmPlan.cpp:
59+
(JSC::Wasm::Plan::Plan):
60+
(JSC::Wasm::Plan::parseAndValidateModule):
61+
(JSC::Wasm::Plan::prepare):
62+
(JSC::Wasm::Plan::compileFunctions):
63+
(JSC::Wasm::Plan::complete):
64+
(JSC::Wasm::Plan::cancel):
65+
* wasm/WasmPlan.h:
66+
(JSC::Wasm::Plan::internalFunctionCount):
67+
(JSC::Wasm::Plan::takeModuleInformation):
68+
* wasm/WasmSignature.cpp:
69+
(JSC::Wasm::SignatureInformation::get):
70+
* wasm/WasmSignature.h:
71+
* wasm/WasmValidate.cpp:
72+
(JSC::Wasm::validateFunction):
73+
* wasm/WasmValidate.h:
74+
* wasm/js/JSWebAssemblyHelpers.h:
75+
(JSC::createSourceBufferFromValue):
76+
* wasm/js/JSWebAssemblyModule.cpp:
77+
(JSC::JSWebAssemblyModule::createStub):
78+
(JSC::JSWebAssemblyModule::JSWebAssemblyModule):
79+
(JSC::JSWebAssemblyModule::finishCreation):
80+
* wasm/js/JSWebAssemblyModule.h:
81+
(JSC::JSWebAssemblyModule::moduleInformation):
82+
(JSC::JSWebAssemblyModule::source):
83+
* wasm/js/WebAssemblyInstanceConstructor.cpp:
84+
(JSC::constructJSWebAssemblyInstance):
85+
* wasm/js/WebAssemblyModuleConstructor.cpp:
86+
(JSC::WebAssemblyModuleConstructor::createModule):
87+
* wasm/js/WebAssemblyModulePrototype.cpp:
88+
(JSC::webAssemblyModuleProtoCustomSections):
89+
(JSC::webAssemblyModuleProtoImports):
90+
(JSC::webAssemblyModuleProtoExports):
91+
* wasm/js/WebAssemblyModuleRecord.cpp:
92+
(JSC::WebAssemblyModuleRecord::link):
93+
* wasm/js/WebAssemblyModuleRecord.h:
94+
* wasm/js/WebAssemblyPrototype.cpp:
95+
(JSC::webAssemblyCompileFunc):
96+
(JSC::instantiate):
97+
(JSC::compileAndInstantiate):
98+
199
2017-04-04 Filip Pizlo <fpizlo@apple.com>
2100

3101
B3::fixSSA() needs a tune-up

‎Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1371,6 +1371,8 @@
13711371
53C6FEF11E8AFE0C00B18425 /* WasmOpcodeOrigin.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 53C6FEF01E8AFE0C00B18425 /* WasmOpcodeOrigin.cpp */; };
13721372
53D444DC1DAF08AB00B92784 /* B3WasmAddressValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 53D444DB1DAF08AB00B92784 /* B3WasmAddressValue.h */; };
13731373
53D444DE1DAF09A000B92784 /* B3WasmAddressValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 53D444DD1DAF09A000B92784 /* B3WasmAddressValue.cpp */; };
1374+
53E777E31E92E265007CBEC4 /* WasmModuleInformation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 53E777E11E92E265007CBEC4 /* WasmModuleInformation.cpp */; };
1375+
53E777E41E92E265007CBEC4 /* WasmModuleInformation.h in Headers */ = {isa = PBXBuildFile; fileRef = 53E777E21E92E265007CBEC4 /* WasmModuleInformation.h */; };
13741376
53F40E851D58F9770099A1B6 /* WasmSections.h in Headers */ = {isa = PBXBuildFile; fileRef = 53F40E841D58F9770099A1B6 /* WasmSections.h */; };
13751377
53F40E8B1D5901BB0099A1B6 /* WasmFunctionParser.h in Headers */ = {isa = PBXBuildFile; fileRef = 53F40E8A1D5901BB0099A1B6 /* WasmFunctionParser.h */; };
13761378
53F40E8D1D5901F20099A1B6 /* WasmParser.h in Headers */ = {isa = PBXBuildFile; fileRef = 53F40E8C1D5901F20099A1B6 /* WasmParser.h */; };
@@ -3883,6 +3885,8 @@
38833885
53C6FEF01E8AFE0C00B18425 /* WasmOpcodeOrigin.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WasmOpcodeOrigin.cpp; sourceTree = "<group>"; };
38843886
53D444DB1DAF08AB00B92784 /* B3WasmAddressValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = B3WasmAddressValue.h; path = b3/B3WasmAddressValue.h; sourceTree = "<group>"; };
38853887
53D444DD1DAF09A000B92784 /* B3WasmAddressValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = B3WasmAddressValue.cpp; path = b3/B3WasmAddressValue.cpp; sourceTree = "<group>"; };
3888+
53E777E11E92E265007CBEC4 /* WasmModuleInformation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WasmModuleInformation.cpp; sourceTree = "<group>"; };
3889+
53E777E21E92E265007CBEC4 /* WasmModuleInformation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WasmModuleInformation.h; sourceTree = "<group>"; };
38863890
53F256E11B87E28000B4B768 /* JSTypedArrayViewPrototype.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSTypedArrayViewPrototype.cpp; sourceTree = "<group>"; };
38873891
53F40E841D58F9770099A1B6 /* WasmSections.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WasmSections.h; sourceTree = "<group>"; };
38883892
53F40E8A1D5901BB0099A1B6 /* WasmFunctionParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WasmFunctionParser.h; sourceTree = "<group>"; };
@@ -6324,6 +6328,8 @@
63246328
535557131D9D9EA5006D583B /* WasmMemory.h */,
63256329
79B759711DFA4C600052174C /* WasmMemoryInformation.cpp */,
63266330
79B759721DFA4C600052174C /* WasmMemoryInformation.h */,
6331+
53E777E11E92E265007CBEC4 /* WasmModuleInformation.cpp */,
6332+
53E777E21E92E265007CBEC4 /* WasmModuleInformation.h */,
63276333
53F40E961D5A7BEC0099A1B6 /* WasmModuleParser.cpp */,
63286334
53F40E941D5A7AEF0099A1B6 /* WasmModuleParser.h */,
63296335
ADB6F67C1E15D7500082F384 /* WasmPageCount.cpp */,
@@ -8444,6 +8450,7 @@
84448450
0FFFC95A14EF90A900C72532 /* DFGCSEPhase.h in Headers */,
84458451
0F2FC77316E12F740038D976 /* DFGDCEPhase.h in Headers */,
84468452
0F8F2B9A172F0501007DBDA5 /* DFGDesiredIdentifiers.h in Headers */,
8453+
53E777E41E92E265007CBEC4 /* WasmModuleInformation.h in Headers */,
84478454
0FFC92141B94E83E0071DD66 /* DFGDesiredInferredType.h in Headers */,
84488455
C2C0F7CE17BBFC5B00464FE4 /* DFGDesiredTransitions.h in Headers */,
84498456
0FE8534C1723CDA500B618F5 /* DFGDesiredWatchpoints.h in Headers */,
@@ -10271,6 +10278,7 @@
1027110278
0FC0977214693AF900CF2442 /* DFGOSRExitCompiler64.cpp in Sources */,
1027210279
0F7025A91714B0FA00382C0E /* DFGOSRExitCompilerCommon.cpp in Sources */,
1027310280
0F392C891B46188400844728 /* DFGOSRExitFuzz.cpp in Sources */,
10281+
53E777E31E92E265007CBEC4 /* WasmModuleInformation.cpp in Sources */,
1027410282
0FEFC9AA1681A3B300567F53 /* DFGOSRExitJumpPlaceholder.cpp in Sources */,
1027510283
0F235BED17178E7300690C7F /* DFGOSRExitPreparation.cpp in Sources */,
1027610284
0F6237971AE45CA700D402EA /* DFGPhantomInsertionPhase.cpp in Sources */,

‎Source/JavaScriptCore/jsc.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3214,7 +3214,7 @@ static EncodedJSValue JSC_HOST_CALL functionTestWasmModuleFunctions(ExecState* e
32143214
lastIndex = calleeIndex;
32153215
});
32163216
}
3217-
std::unique_ptr<Wasm::ModuleInformation> moduleInformation = plan->takeModuleInformation();
3217+
Ref<Wasm::ModuleInformation> moduleInformation = plan->takeModuleInformation();
32183218
RELEASE_ASSERT(!moduleInformation->memory);
32193219

32203220
for (uint32_t i = 0; i < functionCount; ++i) {

‎Source/JavaScriptCore/runtime/Identifier.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ class Identifier {
122122
static Identifier fromString(ExecState*, const AtomicString&);
123123
static Identifier fromString(ExecState*, const String&);
124124
static Identifier fromString(ExecState*, const char*);
125+
static Identifier fromString(VM* vm, const Vector<LChar>& characters) { return fromString(vm, characters.data(), characters.size()); }
125126

126127
static Identifier fromUid(VM*, UniquedStringImpl* uid);
127128
static Identifier fromUid(ExecState*, UniquedStringImpl* uid);

‎Source/JavaScriptCore/wasm/WasmB3IRGenerator.cpp‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ class B3IRGenerator {
205205

206206
// Calls
207207
PartialResult WARN_UNUSED_RETURN addCall(uint32_t calleeIndex, const Signature&, Vector<ExpressionType>& args, ExpressionType& result);
208-
PartialResult WARN_UNUSED_RETURN addCallIndirect(const Signature&, SignatureIndex, Vector<ExpressionType>& args, ExpressionType& result);
208+
PartialResult WARN_UNUSED_RETURN addCallIndirect(const Signature&, Vector<ExpressionType>& args, ExpressionType& result);
209209
PartialResult WARN_UNUSED_RETURN addUnreachable();
210210

211211
void dump(const Vector<ControlEntry>& controlStack, const ExpressionList* expressionStack);
@@ -968,9 +968,8 @@ auto B3IRGenerator::addCall(uint32_t functionIndex, const Signature& signature,
968968
return { };
969969
}
970970

971-
auto B3IRGenerator::addCallIndirect(const Signature& signature, SignatureIndex signatureIndex, Vector<ExpressionType>& args, ExpressionType& result) -> PartialResult
971+
auto B3IRGenerator::addCallIndirect(const Signature& signature, Vector<ExpressionType>& args, ExpressionType& result) -> PartialResult
972972
{
973-
ASSERT(signatureIndex != Signature::invalidIndex);
974973
ExpressionType calleeIndex = args.takeLast();
975974
ASSERT(signature.argumentCount() == args.size());
976975

@@ -1017,7 +1016,7 @@ auto B3IRGenerator::addCallIndirect(const Signature& signature, SignatureIndex s
10171016

10181017
// Check the signature matches the value we expect.
10191018
{
1020-
ExpressionType expectedSignatureIndex = m_currentBlock->appendNew<Const32Value>(m_proc, origin(), signatureIndex);
1019+
ExpressionType expectedSignatureIndex = m_currentBlock->appendNew<Const32Value>(m_proc, origin(), SignatureInformation::get(signature));
10211020
CheckValue* check = m_currentBlock->appendNew<CheckValue>(m_proc, Check, origin(),
10221021
m_currentBlock->appendNew<Value>(m_proc, NotEqual, origin(), calleeSignatureIndex, expectedSignatureIndex));
10231022

@@ -1269,7 +1268,7 @@ auto B3IRGenerator::origin() -> Origin
12691268
return bitwise_cast<Origin>(OpcodeOrigin(m_parser->currentOpcode(), m_parser->currentOpcodeStartingOffset()));
12701269
}
12711270

1272-
Expected<std::unique_ptr<WasmInternalFunction>, String> parseAndCompile(CompilationContext& compilationContext, const uint8_t* functionStart, size_t functionLength, const Signature& signature, Vector<UnlinkedWasmToWasmCall>& unlinkedWasmToWasmCalls, const ModuleInformation& info, const Vector<SignatureIndex>& moduleSignatureIndicesToUniquedSignatureIndices, MemoryMode mode, unsigned optLevel)
1271+
Expected<std::unique_ptr<WasmInternalFunction>, String> parseAndCompile(CompilationContext& compilationContext, const uint8_t* functionStart, size_t functionLength, const Signature& signature, Vector<UnlinkedWasmToWasmCall>& unlinkedWasmToWasmCalls, const ModuleInformation& info, MemoryMode mode, unsigned optLevel)
12731272
{
12741273
auto result = std::make_unique<WasmInternalFunction>();
12751274

@@ -1292,7 +1291,7 @@ Expected<std::unique_ptr<WasmInternalFunction>, String> parseAndCompile(Compilat
12921291
procedure.setOptLevel(optLevel);
12931292

12941293
B3IRGenerator context(info, procedure, result.get(), unlinkedWasmToWasmCalls, mode);
1295-
FunctionParser<B3IRGenerator> parser(context, functionStart, functionLength, signature, info, moduleSignatureIndicesToUniquedSignatureIndices);
1294+
FunctionParser<B3IRGenerator> parser(context, functionStart, functionLength, signature, info);
12961295
WASM_FAIL_IF_HELPER_FAILS(parser.parse());
12971296

12981297
context.insertConstants();

‎Source/JavaScriptCore/wasm/WasmB3IRGenerator.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030
#include "B3Common.h"
3131
#include "B3Compilation.h"
3232
#include "CCallHelpers.h"
33-
#include "WasmFormat.h"
3433
#include "WasmMemory.h"
34+
#include "WasmModuleInformation.h"
3535
#include <wtf/Expected.h>
3636

3737
extern "C" void dumpProcedure(void*);
@@ -48,7 +48,7 @@ struct CompilationContext {
4848
CCallHelpers::Call jsEntrypointToWasmEntrypointCall;
4949
};
5050

51-
Expected<std::unique_ptr<WasmInternalFunction>, String> parseAndCompile(CompilationContext&, const uint8_t*, size_t, const Signature&, Vector<UnlinkedWasmToWasmCall>&, const ModuleInformation&, const Vector<SignatureIndex>&, MemoryMode, unsigned optLevel);
51+
Expected<std::unique_ptr<WasmInternalFunction>, String> parseAndCompile(CompilationContext&, const uint8_t*, size_t, const Signature&, Vector<UnlinkedWasmToWasmCall>&, const ModuleInformation&, MemoryMode, unsigned optLevel);
5252

5353
} } // namespace JSC::Wasm
5454

‎Source/JavaScriptCore/wasm/WasmFormat.cpp‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,12 @@ Segment::Ptr Segment::adoptPtr(Segment* segment)
5555
return Ptr(segment, &Segment::destroy);
5656
}
5757

58-
JS_EXPORT_PRIVATE ModuleInformation::~ModuleInformation() { }
58+
String makeString(const Vector<LChar>& characters)
59+
{
60+
String result = String::fromUTF8(characters);
61+
ASSERT(result);
62+
return result;
63+
}
5964

6065
} } // namespace JSC::Wasm
6166

‎Source/JavaScriptCore/wasm/WasmFormat.h‎

Lines changed: 7 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ static_assert(static_cast<int>(ExternalKind::Table) == 1, "Wasm needs Table t
8989
static_assert(static_cast<int>(ExternalKind::Memory) == 2, "Wasm needs Memory to have the value 2");
9090
static_assert(static_cast<int>(ExternalKind::Global) == 3, "Wasm needs Global to have the value 3");
9191

92-
static inline const char* makeString(ExternalKind kind)
92+
inline const char* makeString(ExternalKind kind)
9393
{
9494
switch (kind) {
9595
case ExternalKind::Function: return "function";
@@ -102,18 +102,20 @@ static inline const char* makeString(ExternalKind kind)
102102
}
103103

104104
struct Import {
105-
String module;
106-
String field;
105+
const Vector<LChar> module;
106+
const Vector<LChar> field;
107107
ExternalKind kind;
108108
unsigned kindIndex; // Index in the vector of the corresponding kind.
109109
};
110110

111111
struct Export {
112-
String field;
112+
const Vector<LChar> field;
113113
ExternalKind kind;
114114
unsigned kindIndex; // Index in the vector of the corresponding kind.
115115
};
116116

117+
String makeString(const Vector<LChar>& characters);
118+
117119
struct Global {
118120
enum Mutability : uint8_t {
119121
// FIXME auto-generate this. https://bugs.webkit.org/show_bug.cgi?id=165231
@@ -226,46 +228,10 @@ class TableInformation {
226228
};
227229

228230
struct CustomSection {
229-
String name;
231+
Vector<LChar> name;
230232
Vector<uint8_t> payload;
231233
};
232234

233-
struct ModuleInformation {
234-
Vector<Import> imports;
235-
Vector<SignatureIndex> importFunctionSignatureIndices;
236-
Vector<SignatureIndex> internalFunctionSignatureIndices;
237-
Vector<Ref<Signature>> usedSignatures;
238-
239-
MemoryInformation memory;
240-
241-
Vector<Export> exports;
242-
std::optional<uint32_t> startFunctionIndexSpace;
243-
Vector<Segment::Ptr> data;
244-
Vector<Element> elements;
245-
TableInformation tableInformation;
246-
Vector<Global> globals;
247-
unsigned firstInternalGlobal { 0 };
248-
Vector<CustomSection> customSections;
249-
250-
size_t functionIndexSpaceSize() const { return importFunctionSignatureIndices.size() + internalFunctionSignatureIndices.size(); }
251-
bool isImportedFunctionFromFunctionIndexSpace(size_t functionIndex) const
252-
{
253-
ASSERT(functionIndex < functionIndexSpaceSize());
254-
return functionIndex < importFunctionSignatureIndices.size();
255-
}
256-
SignatureIndex signatureIndexFromFunctionIndexSpace(size_t functionIndex) const
257-
{
258-
return isImportedFunctionFromFunctionIndexSpace(functionIndex)
259-
? importFunctionSignatureIndices[functionIndex]
260-
: internalFunctionSignatureIndices[functionIndex - importFunctionSignatureIndices.size()];
261-
}
262-
263-
uint32_t importFunctionCount() const { return importFunctionSignatureIndices.size(); }
264-
uint32_t internalFunctionCount() const { return internalFunctionSignatureIndices.size(); }
265-
266-
~ModuleInformation();
267-
};
268-
269235
struct UnlinkedWasmToWasmCall {
270236
CodeLocationCall callLocation;
271237
size_t functionIndex;

0 commit comments

Comments
 (0)