1111
1212namespace Js
1313{
14- WebAssemblyModule::WebAssemblyModule (Js::ScriptContext* scriptContext, byte* binaryBuffer, uint binaryBufferLength, DynamicType * type) :
14+ WebAssemblyModule::WebAssemblyModule (Js::ScriptContext* scriptContext, const byte* binaryBuffer, uint binaryBufferLength, DynamicType * type) :
1515 DynamicObject (type),
1616 m_memory (),
1717 m_alloc (_u(" WebAssemblyModule" ), scriptContext->GetThreadContext ()->GetPageAllocator(), Js::Throw::OutOfMemory),
@@ -98,44 +98,31 @@ WebAssemblyModule::NewInstance(RecyclableObject* function, CallInfo callInfo, ..
9898 byteLength = arrayBuffer->GetByteLength ();
9999 }
100100
101- CompileScriptException se;
102- Js::Utf8SourceInfo* utf8SourceInfo;
103-
104- return CompileModule (scriptContext, (const char16*)buffer, nullptr , &se, &utf8SourceInfo, byteLength, false , bufferSrc);
101+ return CreateModule (scriptContext, buffer, byteLength, false , bufferSrc);
105102}
106103
107104/* static */
108105WebAssemblyModule *
109- WebAssemblyModule::CompileModule (
106+ WebAssemblyModule::CreateModule (
110107 ScriptContext* scriptContext,
111- const char16* script,
112- SRCINFO const * pSrcInfo,
113- CompileScriptException * pse,
114- Utf8SourceInfo** ppSourceInfo,
108+ const byte* buffer,
115109 const uint lengthBytes,
116110 bool validateOnly,
117111 Var bufferSrc)
118112{
119- WebAssemblyModule * WebAssemblyModule = nullptr ;
120- if (pSrcInfo == nullptr )
121- {
122- pSrcInfo = scriptContext->cache ->noContextGlobalSourceInfo ;
123- }
124-
125113 AutoProfilingPhase wasmPhase (scriptContext, Js::WasmPhase);
126114 Unused (wasmPhase);
127115
128- Assert (pse ! = nullptr ) ;
116+ WebAssemblyModule * WebAssemblyModule = nullptr ;
129117 Wasm::WasmReaderInfo * readerInfo = nullptr ;
130118 Js::FunctionBody * currentBody = nullptr ;
131119 try
132120 {
133121 Js::AutoDynamicCodeReference dynamicFunctionReference (scriptContext);
134- *ppSourceInfo = nullptr ;
135-
136- *ppSourceInfo = Utf8SourceInfo::New (scriptContext, (LPCUTF8)script, lengthBytes / sizeof (char16), lengthBytes, pSrcInfo, false );
122+ SRCINFO const * srcInfo = scriptContext->cache ->noContextGlobalSourceInfo ;
123+ Js::Utf8SourceInfo* utf8SourceInfo = Utf8SourceInfo::New (scriptContext, (LPCUTF8)buffer, lengthBytes / sizeof (char16), lengthBytes, srcInfo, false );
137124
138- Wasm::WasmModuleGenerator bytecodeGen (scriptContext, *ppSourceInfo , (byte*)script , lengthBytes, bufferSrc);
125+ Wasm::WasmModuleGenerator bytecodeGen (scriptContext, utf8SourceInfo , (byte*)buffer , lengthBytes, bufferSrc);
139126
140127 WebAssemblyModule = bytecodeGen.GenerateModule ();
141128
@@ -407,7 +394,7 @@ void WebAssemblyModule::AllocateFunctionExports(uint32 entries)
407394 m_exportCount = entries;
408395}
409396
410- void WebAssemblyModule::SetExport (uint32 iExport, uint32 funcIndex, char16* exportName, uint32 nameLength, Wasm::ExternalKinds::ExternalKind kind)
397+ void WebAssemblyModule::SetExport (uint32 iExport, uint32 funcIndex, const char16* exportName, uint32 nameLength, Wasm::ExternalKinds::ExternalKind kind)
411398{
412399 m_exports[iExport].funcIndex = funcIndex;
413400 m_exports[iExport].nameLength = nameLength;
@@ -432,7 +419,7 @@ WebAssemblyModule::AllocateFunctionImports(uint32 entries)
432419}
433420
434421void
435- WebAssemblyModule::SetFunctionImport (uint32 i, uint32 sigId, char16* modName, uint32 modNameLen, char16* fnName, uint32 fnNameLen, Wasm::ExternalKinds::ExternalKind kind)
422+ WebAssemblyModule::SetFunctionImport (uint32 i, uint32 sigId, const char16* modName, uint32 modNameLen, const char16* fnName, uint32 fnNameLen, Wasm::ExternalKinds::ExternalKind kind)
436423{
437424 m_imports[i].sigId = sigId;
438425 m_imports[i].modNameLen = modNameLen;
@@ -442,7 +429,7 @@ WebAssemblyModule::SetFunctionImport(uint32 i, uint32 sigId, char16* modName, ui
442429}
443430
444431void
445- WebAssemblyModule::AddGlobalImport (char16* modName, uint32 modNameLen, char16* fnName, uint32 fnNameLen, Wasm::ExternalKinds::ExternalKind kind, Wasm::WasmGlobal* importedGlobal)
432+ WebAssemblyModule::AddGlobalImport (const char16* modName, uint32 modNameLen, const char16* fnName, uint32 fnNameLen, Wasm::ExternalKinds::ExternalKind kind, Wasm::WasmGlobal* importedGlobal)
446433{
447434 Wasm::WasmImport* wi = Anew (&m_alloc, Wasm::WasmImport);
448435 wi->sigId = 0 ;
0 commit comments