WebAssembly: Implement the WebAssembly.compile and WebAssembly.validate
https://bugs.webkit.org/show_bug.cgi?id=165936
Reviewed by Mark Lam.
JSTests:
* wasm/js-api/Module-compile.js: Added.
(async.testPromiseAPI):
* wasm/js-api/test_basic_api.js:
(const.c.in.constructorProperties.switch):
* wasm/js-api/validate.js: Added.
(assert.truthy.WebAssembly.validate.builder.WebAssembly):
Source/JavaScriptCore:
The APIs are documented here:
- https://github.com/WebAssembly/design/blob/master/JS.md#webassemblycompile
- https://github.com/WebAssembly/design/blob/master/JS.md#webassemblyvalidate
* wasm/JSWebAssembly.cpp:
(JSC::webAssemblyCompileFunc):
(JSC::webAssemblyValidateFunc):
(JSC::JSWebAssembly::finishCreation):
* wasm/WasmPlan.cpp:
(JSC::Wasm::Plan::parseAndValidateModule):
(JSC::Wasm::Plan::run):
* wasm/WasmPlan.h:
* wasm/js/JSWebAssemblyHelpers.h:
(JSC::getWasmBufferFromValue):
* wasm/js/WebAssemblyModuleConstructor.cpp:
(JSC::constructJSWebAssemblyModule):
(JSC::callJSWebAssemblyModule):
(JSC::WebAssemblyModuleConstructor::createModule):
* wasm/js/WebAssemblyModuleConstructor.h:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@209979 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/JSTests/ChangeLog b/JSTests/ChangeLog
index 8e4127f..5f544e1 100644
--- a/JSTests/ChangeLog
+++ b/JSTests/ChangeLog
@@ -1,3 +1,17 @@
+2016-12-18 Saam Barati <sbarati@apple.com>
+
+ WebAssembly: Implement the WebAssembly.compile and WebAssembly.validate
+ https://bugs.webkit.org/show_bug.cgi?id=165936
+
+ Reviewed by Mark Lam.
+
+ * wasm/js-api/Module-compile.js: Added.
+ (async.testPromiseAPI):
+ * wasm/js-api/test_basic_api.js:
+ (const.c.in.constructorProperties.switch):
+ * wasm/js-api/validate.js: Added.
+ (assert.truthy.WebAssembly.validate.builder.WebAssembly):
+
2016-12-16 Mark Lam <mark.lam@apple.com>
De-duplicate finally blocks.
diff --git a/JSTests/wasm/js-api/Module-compile.js b/JSTests/wasm/js-api/Module-compile.js
new file mode 100644
index 0000000..33ab513
--- /dev/null
+++ b/JSTests/wasm/js-api/Module-compile.js
@@ -0,0 +1,58 @@
+import * as assert from '../assert.js';
+import Builder from '../Builder.js';
+
+let done = false;
+async function testPromiseAPI() {
+ {
+ // Can't declare more than one memory.
+ const builder = (new Builder())
+ .Type().End()
+ .Import().Memory("imp", "memory", {initial: 20}).End()
+ .Function().End()
+ .Memory().InitialMaxPages(1, 1).End()
+ .Export().End()
+ .Code()
+ .End();
+
+ let threw = false;
+ try {
+ await WebAssembly.compile(builder.WebAssembly().get());
+ } catch(e) {
+ threw = true;
+ assert.truthy(e instanceof WebAssembly.CompileError);
+ assert.truthy(e.message === "WebAssembly.Module doesn't parse at byte 34 / 43: Memory section cannot exist if an Import has a memory (evaluating 'WebAssembly.compile(builder.WebAssembly().get())')");
+ }
+ assert.truthy(threw);
+ }
+
+ {
+ let threw = false;
+ try {
+ await WebAssembly.compile(20);
+ } catch(e) {
+ threw = true;
+ assert.truthy(e instanceof TypeError);
+ assert.eq(e.message, "first argument must be an ArrayBufferView or an ArrayBuffer (evaluating 'WebAssembly.compile(20)')");
+ }
+ assert.truthy(threw);
+ }
+
+ {
+ const builder = (new Builder())
+ .Type().End()
+ .Import().Memory("imp", "memory", {initial: 20}).End()
+ .Function().End()
+ .Export().End()
+ .Code()
+ .End();
+
+ let module = await WebAssembly.compile(builder.WebAssembly().get());
+ assert.truthy(module instanceof WebAssembly.Module);
+ }
+
+ done = true;
+}
+
+testPromiseAPI();
+drainMicrotasks();
+assert.truthy(done);
diff --git a/JSTests/wasm/js-api/test_basic_api.js b/JSTests/wasm/js-api/test_basic_api.js
index fa411d5..43b7d7d 100644
--- a/JSTests/wasm/js-api/test_basic_api.js
+++ b/JSTests/wasm/js-api/test_basic_api.js
@@ -52,7 +52,7 @@
switch (c) {
case "Module":
for (const invalid of invalidConstructorInputs)
- assert.throws(() => new WebAssembly[c](invalid), TypeError, `first argument to WebAssembly.Module must be an ArrayBufferView or an ArrayBuffer (evaluating 'new WebAssembly[c](invalid)')`);
+ assert.throws(() => new WebAssembly[c](invalid), TypeError, `first argument must be an ArrayBufferView or an ArrayBuffer (evaluating 'new WebAssembly[c](invalid)')`);
for (const buffer of [new ArrayBuffer(), new DataView(new ArrayBuffer()), new Int8Array(), new Uint8Array(), new Uint8ClampedArray(), new Int16Array(), new Uint16Array(), new Int32Array(), new Uint32Array(), new Float32Array(), new Float64Array()])
// FIXME the following should be WebAssembly.CompileError. https://bugs.webkit.org/show_bug.cgi?id=163768
assert.throws(() => new WebAssembly[c](buffer), Error, `WebAssembly.Module doesn't parse at byte 0 / 0: expected a module of at least 8 bytes (evaluating 'new WebAssembly[c](buffer)')`);
@@ -97,8 +97,3 @@
default: throw new Error(`Implementation error: unexpected constructor property "${c}"`);
}
}
-
-// FIXME Implement and test these APIs further. For now they just throw. https://bugs.webkit.org/show_bug.cgi?id=159775
-for (const f in functionProperties) {
- assert.throws(() => WebAssembly[f](), Error, `WebAssembly doesn't yet implement the ${f} function property`);
-}
diff --git a/JSTests/wasm/js-api/validate.js b/JSTests/wasm/js-api/validate.js
new file mode 100644
index 0000000..3993abe
--- /dev/null
+++ b/JSTests/wasm/js-api/validate.js
@@ -0,0 +1,27 @@
+import * as assert from '../assert.js';
+import Builder from '../Builder.js';
+
+{
+ const builder = (new Builder())
+ .Type().End()
+ .Import().Memory("imp", "memory", {initial: 20}).End()
+ .Function().End()
+ .Memory().InitialMaxPages(1, 1).End()
+ .Export().End()
+ .Code()
+ .End();
+
+ assert.truthy(!WebAssembly.validate(builder.WebAssembly().get()));
+}
+
+{
+ const builder = (new Builder())
+ .Type().End()
+ .Import().Memory("imp", "memory", {initial: 20}).End()
+ .Function().End()
+ .Export().End()
+ .Code()
+ .End();
+
+ assert.truthy(WebAssembly.validate(builder.WebAssembly().get()));
+}
diff --git a/Source/JavaScriptCore/ChangeLog b/Source/JavaScriptCore/ChangeLog
index 0b80b3d..ef55193 100644
--- a/Source/JavaScriptCore/ChangeLog
+++ b/Source/JavaScriptCore/ChangeLog
@@ -1,3 +1,30 @@
+2016-12-18 Saam Barati <sbarati@apple.com>
+
+ WebAssembly: Implement the WebAssembly.compile and WebAssembly.validate
+ https://bugs.webkit.org/show_bug.cgi?id=165936
+
+ Reviewed by Mark Lam.
+
+ The APIs are documented here:
+ - https://github.com/WebAssembly/design/blob/master/JS.md#webassemblycompile
+ - https://github.com/WebAssembly/design/blob/master/JS.md#webassemblyvalidate
+
+ * wasm/JSWebAssembly.cpp:
+ (JSC::webAssemblyCompileFunc):
+ (JSC::webAssemblyValidateFunc):
+ (JSC::JSWebAssembly::finishCreation):
+ * wasm/WasmPlan.cpp:
+ (JSC::Wasm::Plan::parseAndValidateModule):
+ (JSC::Wasm::Plan::run):
+ * wasm/WasmPlan.h:
+ * wasm/js/JSWebAssemblyHelpers.h:
+ (JSC::getWasmBufferFromValue):
+ * wasm/js/WebAssemblyModuleConstructor.cpp:
+ (JSC::constructJSWebAssemblyModule):
+ (JSC::callJSWebAssemblyModule):
+ (JSC::WebAssemblyModuleConstructor::createModule):
+ * wasm/js/WebAssemblyModuleConstructor.h:
+
2016-12-18 Mark Lam <mark.lam@apple.com>
Rename finallyActionRegister to completionTypeRegister and only store int JSValues in it.
diff --git a/Source/JavaScriptCore/wasm/JSWebAssembly.cpp b/Source/JavaScriptCore/wasm/JSWebAssembly.cpp
index 7a3d7ac..161e94b 100644
--- a/Source/JavaScriptCore/wasm/JSWebAssembly.cpp
+++ b/Source/JavaScriptCore/wasm/JSWebAssembly.cpp
@@ -28,13 +28,57 @@
#if ENABLE(WEBASSEMBLY)
+#include "Exception.h"
#include "FunctionPrototype.h"
#include "JSCInlines.h"
+#include "JSPromiseDeferred.h"
+#include "JSWebAssemblyHelpers.h"
+#include "WasmPlan.h"
+#include "WebAssemblyModuleConstructor.h"
namespace JSC {
STATIC_ASSERT_IS_TRIVIALLY_DESTRUCTIBLE(JSWebAssembly);
+EncodedJSValue JSC_HOST_CALL webAssemblyValidateFunc(ExecState*);
+EncodedJSValue JSC_HOST_CALL webAssemblyCompileFunc(ExecState*);
+
+EncodedJSValue JSC_HOST_CALL webAssemblyCompileFunc(ExecState* exec)
+{
+ VM& vm = exec->vm();
+ auto catchScope = DECLARE_CATCH_SCOPE(vm);
+
+ JSPromiseDeferred* promise = JSPromiseDeferred::create(exec, exec->lexicalGlobalObject());
+ RETURN_IF_EXCEPTION(catchScope, { });
+
+ // FIXME: Make this truly asynchronous:
+ // https://bugs.webkit.org/show_bug.cgi?id=166016
+ JSValue module = WebAssemblyModuleConstructor::createModule(exec, exec->lexicalGlobalObject()->WebAssemblyModuleStructure());
+ if (Exception* exception = catchScope.exception()) {
+ catchScope.clearException();
+ promise->reject(exec, exception);
+ return JSValue::encode(promise->promise());
+ }
+
+ promise->resolve(exec, module);
+ return JSValue::encode(promise->promise());
+}
+
+EncodedJSValue JSC_HOST_CALL webAssemblyValidateFunc(ExecState* exec)
+{
+ VM& vm = exec->vm();
+ auto scope = DECLARE_THROW_SCOPE(vm);
+
+ size_t byteOffset;
+ size_t byteSize;
+ uint8_t* base = getWasmBufferFromValue(exec, exec->argument(0), byteOffset, byteSize);
+ RETURN_IF_EXCEPTION(scope, { });
+ Wasm::Plan plan(&vm, base + byteOffset, byteSize);
+ // FIXME: We might want to throw an OOM exception here if we detect that something will OOM.
+ // https://bugs.webkit.org/show_bug.cgi?id=166015
+ return JSValue::encode(jsBoolean(plan.parseAndValidateModule()));
+}
+
const ClassInfo JSWebAssembly::s_info = { "WebAssembly", &Base::s_info, 0, CREATE_METHOD_TABLE(JSWebAssembly) };
JSWebAssembly* JSWebAssembly::create(VM& vm, JSGlobalObject* globalObject, Structure* structure)
@@ -49,10 +93,12 @@
return Structure::create(vm, globalObject, prototype, TypeInfo(ObjectType, StructureFlags), info());
}
-void JSWebAssembly::finishCreation(VM& vm, JSGlobalObject*)
+void JSWebAssembly::finishCreation(VM& vm, JSGlobalObject* globalObject)
{
Base::finishCreation(vm);
ASSERT(inherits(info()));
+ JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("validate", webAssemblyValidateFunc, DontEnum, 1);
+ JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("compile", webAssemblyCompileFunc, DontEnum, 1);
}
JSWebAssembly::JSWebAssembly(VM& vm, Structure* structure)
diff --git a/Source/JavaScriptCore/wasm/WasmPlan.cpp b/Source/JavaScriptCore/wasm/WasmPlan.cpp
index 1c0e019..9dea8ba 100644
--- a/Source/JavaScriptCore/wasm/WasmPlan.cpp
+++ b/Source/JavaScriptCore/wasm/WasmPlan.cpp
@@ -58,14 +58,14 @@
{
}
-void Plan::run()
+bool Plan::parseAndValidateModule()
{
{
ModuleParser moduleParser(m_vm, m_source, m_sourceLength);
auto parseResult = moduleParser.parse();
if (!parseResult) {
m_errorMessage = parseResult.error();
- return; // FIXME return an Expected.
+ return false;
}
m_moduleInformation = WTFMove(parseResult->module);
m_functionLocationInBinary = WTFMove(parseResult->functionLocationInBinary);
@@ -73,6 +73,34 @@
m_functionIndexSpace.buffer = parseResult->functionIndexSpace.releaseBuffer();
}
+ for (unsigned functionIndex = 0; functionIndex < m_functionLocationInBinary.size(); ++functionIndex) {
+ if (verbose)
+ dataLogLn("Processing function starting at: ", m_functionLocationInBinary[functionIndex].start, " and ending at: ", m_functionLocationInBinary[functionIndex].end);
+ const uint8_t* functionStart = m_source + m_functionLocationInBinary[functionIndex].start;
+ size_t functionLength = m_functionLocationInBinary[functionIndex].end - m_functionLocationInBinary[functionIndex].start;
+ ASSERT(Checked<uintptr_t>(bitwise_cast<uintptr_t>(functionStart)) + functionLength <= Checked<uintptr_t>(bitwise_cast<uintptr_t>(m_source)) + m_sourceLength);
+ Signature* signature = m_moduleInformation->internalFunctionSignatures[functionIndex];
+
+ auto validationResult = validateFunction(functionStart, functionLength, signature, m_functionIndexSpace, *m_moduleInformation);
+ if (!validationResult) {
+ if (verbose) {
+ for (unsigned i = 0; i < functionLength; ++i)
+ dataLog(RawPointer(reinterpret_cast<void*>(functionStart[i])), ", ");
+ dataLogLn();
+ }
+ m_errorMessage = validationResult.error(); // FIXME make this an Expected.
+ return false;
+ }
+ }
+
+ return true;
+}
+
+void Plan::run()
+{
+ if (!parseAndValidateModule())
+ return;
+
auto tryReserveCapacity = [this] (auto& vector, size_t size, const char* what) {
if (UNLIKELY(!vector.tryReserveCapacity(size))) {
StringBuilder builder;
@@ -84,6 +112,7 @@
}
return true;
};
+
Vector<Vector<UnlinkedWasmToWasmCall>> unlinkedWasmToWasmCalls;
if (!tryReserveCapacity(m_wasmToJSStubs, m_moduleInformation->importFunctions.size(), " WebAssembly to JavaScript stubs")
|| !tryReserveCapacity(unlinkedWasmToWasmCalls, m_functionLocationInBinary.size(), " unlinked WebAssembly to WebAssembly calls")
@@ -112,16 +141,7 @@
unsigned functionIndexSpace = m_wasmToJSStubs.size() + functionIndex;
ASSERT(m_functionIndexSpace.buffer.get()[functionIndexSpace].signature == signature);
- auto validateResult = validateFunction(functionStart, functionLength, signature, m_functionIndexSpace, *m_moduleInformation);
- if (!validateResult) {
- if (verbose) {
- for (unsigned i = 0; i < functionLength; ++i)
- dataLog(RawPointer(reinterpret_cast<void*>(functionStart[i])), ", ");
- dataLogLn();
- }
- m_errorMessage = validateResult.error(); // FIXME make this an Expected.
- return;
- }
+ ASSERT(validateFunction(functionStart, functionLength, signature, m_functionIndexSpace, *m_moduleInformation));
unlinkedWasmToWasmCalls.uncheckedAppend(Vector<UnlinkedWasmToWasmCall>());
auto parseAndCompileResult = parseAndCompile(*m_vm, functionStart, functionLength, signature, unlinkedWasmToWasmCalls.at(functionIndex), m_functionIndexSpace, *m_moduleInformation);
diff --git a/Source/JavaScriptCore/wasm/WasmPlan.h b/Source/JavaScriptCore/wasm/WasmPlan.h
index 2aedebd..34879c0 100644
--- a/Source/JavaScriptCore/wasm/WasmPlan.h
+++ b/Source/JavaScriptCore/wasm/WasmPlan.h
@@ -48,6 +48,8 @@
JS_EXPORT_PRIVATE Plan(VM*, const uint8_t*, size_t);
JS_EXPORT_PRIVATE ~Plan();
+ bool parseAndValidateModule();
+
JS_EXPORT_PRIVATE void run();
JS_EXPORT_PRIVATE void initializeCallees(JSGlobalObject*, std::function<void(unsigned, JSWebAssemblyCallee*, JSWebAssemblyCallee*)>);
diff --git a/Source/JavaScriptCore/wasm/js/JSWebAssemblyHelpers.h b/Source/JavaScriptCore/wasm/js/JSWebAssemblyHelpers.h
index 2527878..abd9804 100644
--- a/Source/JavaScriptCore/wasm/js/JSWebAssemblyHelpers.h
+++ b/Source/JavaScriptCore/wasm/js/JSWebAssemblyHelpers.h
@@ -27,6 +27,7 @@
#if ENABLE(WEBASSEMBLY)
+#include "JSArrayBuffer.h"
#include "JSCJSValue.h"
namespace JSC {
@@ -46,6 +47,30 @@
return static_cast<uint32_t>(doubleValue);
}
+ALWAYS_INLINE uint8_t* getWasmBufferFromValue(ExecState* exec, JSValue value, size_t& byteOffset, size_t& byteSize)
+{
+ VM& vm = exec->vm();
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ // If the given bytes argument is not a BufferSource, a TypeError exception is thrown.
+ JSArrayBuffer* arrayBuffer = value.getObject() ? jsDynamicCast<JSArrayBuffer*>(value.getObject()) : nullptr;
+ JSArrayBufferView* arrayBufferView = value.getObject() ? jsDynamicCast<JSArrayBufferView*>(value.getObject()) : nullptr;
+ if (!(arrayBuffer || arrayBufferView)) {
+ throwException(exec, throwScope, createTypeError(exec,
+ ASCIILiteral("first argument must be an ArrayBufferView or an ArrayBuffer"), defaultSourceAppender, runtimeTypeForValue(value)));
+ return nullptr;
+ }
+
+ if (arrayBufferView ? arrayBufferView->isNeutered() : arrayBuffer->impl()->isNeutered()) {
+ throwException(exec, throwScope, createTypeError(exec,
+ ASCIILiteral("underlying TypedArray has been detatched from the ArrayBuffer"), defaultSourceAppender, runtimeTypeForValue(value)));
+ return nullptr;
+ }
+
+ byteOffset = arrayBufferView ? arrayBufferView->byteOffset() : 0;
+ byteSize = arrayBufferView ? arrayBufferView->length() : arrayBuffer->impl()->byteLength();
+ return arrayBufferView ? static_cast<uint8_t*>(arrayBufferView->vector()) : static_cast<uint8_t*>(arrayBuffer->impl()->data());
+}
+
} // namespace JSC
#endif // ENABLE(WEBASSEMBLY)
diff --git a/Source/JavaScriptCore/wasm/js/WebAssemblyModuleConstructor.cpp b/Source/JavaScriptCore/wasm/js/WebAssemblyModuleConstructor.cpp
index de8f4a3..2673fc0 100644
--- a/Source/JavaScriptCore/wasm/js/WebAssemblyModuleConstructor.cpp
+++ b/Source/JavaScriptCore/wasm/js/WebAssemblyModuleConstructor.cpp
@@ -35,6 +35,7 @@
#include "JSTypedArrays.h"
#include "JSWebAssemblyCallee.h"
#include "JSWebAssemblyCompileError.h"
+#include "JSWebAssemblyHelpers.h"
#include "JSWebAssemblyModule.h"
#include "SymbolTable.h"
#include "WasmPlan.h"
@@ -52,34 +53,40 @@
@end
*/
-static EncodedJSValue JSC_HOST_CALL constructJSWebAssemblyModule(ExecState* state)
+static EncodedJSValue JSC_HOST_CALL constructJSWebAssemblyModule(ExecState* exec)
+{
+ VM& vm = exec->vm();
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ auto* structure = InternalFunction::createSubclassStructure(exec, exec->newTarget(), exec->lexicalGlobalObject()->WebAssemblyModuleStructure());
+ RETURN_IF_EXCEPTION(throwScope, { });
+ throwScope.release();
+ return JSValue::encode(WebAssemblyModuleConstructor::createModule(exec, structure));
+}
+
+static EncodedJSValue JSC_HOST_CALL callJSWebAssemblyModule(ExecState* state)
{
VM& vm = state->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
- JSValue val = state->argument(0);
+ return JSValue::encode(throwConstructorCannotBeCalledAsFunctionTypeError(state, scope, "WebAssembly.Module"));
+}
- // If the given bytes argument is not a BufferSource, a TypeError exception is thrown.
- JSArrayBuffer* arrayBuffer = val.getObject() ? jsDynamicCast<JSArrayBuffer*>(val.getObject()) : nullptr;
- JSArrayBufferView* arrayBufferView = val.getObject() ? jsDynamicCast<JSArrayBufferView*>(val.getObject()) : nullptr;
- if (!(arrayBuffer || arrayBufferView))
- return JSValue::encode(throwException(state, scope, createTypeError(state, ASCIILiteral("first argument to WebAssembly.Module must be an ArrayBufferView or an ArrayBuffer"), defaultSourceAppender, runtimeTypeForValue(val))));
+JSValue WebAssemblyModuleConstructor::createModule(ExecState* state, Structure* structure)
+{
+ VM& vm = state->vm();
+ auto scope = DECLARE_THROW_SCOPE(vm);
- if (arrayBufferView ? arrayBufferView->isNeutered() : arrayBuffer->impl()->isNeutered())
- return JSValue::encode(throwException(state, scope, createTypeError(state, ASCIILiteral("underlying TypedArray has been detatched from the ArrayBuffer"), defaultSourceAppender, runtimeTypeForValue(val))));
-
- size_t byteOffset = arrayBufferView ? arrayBufferView->byteOffset() : 0;
- size_t byteSize = arrayBufferView ? arrayBufferView->length() : arrayBuffer->impl()->byteLength();
- const auto* base = arrayBufferView ? static_cast<uint8_t*>(arrayBufferView->vector()) : static_cast<uint8_t*>(arrayBuffer->impl()->data());
+ size_t byteOffset;
+ size_t byteSize;
+ uint8_t* base = getWasmBufferFromValue(state, state->argument(0), byteOffset, byteSize);
+ RETURN_IF_EXCEPTION(scope, { });
Wasm::Plan plan(&vm, base + byteOffset, byteSize);
// On failure, a new WebAssembly.CompileError is thrown.
plan.run();
if (plan.failed())
- return JSValue::encode(throwException(state, scope, createWebAssemblyCompileError(state, plan.errorMessage())));
+ return throwException(state, scope, createWebAssemblyCompileError(state, plan.errorMessage()));
// On success, a new WebAssembly.Module object is returned with [[Module]] set to the validated Ast.module.
- auto* structure = InternalFunction::createSubclassStructure(state, state->newTarget(), asInternalFunction(state->jsCallee())->globalObject()->WebAssemblyModuleStructure());
- RETURN_IF_EXCEPTION(scope, { });
// The export symbol table is the same for all Instances of a Module.
SymbolTable* exportSymbolTable = SymbolTable::create(vm);
@@ -96,14 +103,8 @@
result->setJSEntrypointCallee(vm, calleeIndex, jsEntrypointCallee);
result->setWasmEntrypointCallee(vm, calleeIndex, wasmEntrypointCallee);
});
- return JSValue::encode(result);
-}
-static EncodedJSValue JSC_HOST_CALL callJSWebAssemblyModule(ExecState* state)
-{
- VM& vm = state->vm();
- auto scope = DECLARE_THROW_SCOPE(vm);
- return JSValue::encode(throwConstructorCannotBeCalledAsFunctionTypeError(state, scope, "WebAssembly.Module"));
+ return result;
}
WebAssemblyModuleConstructor* WebAssemblyModuleConstructor::create(VM& vm, Structure* structure, WebAssemblyModulePrototype* thisPrototype)
diff --git a/Source/JavaScriptCore/wasm/js/WebAssemblyModuleConstructor.h b/Source/JavaScriptCore/wasm/js/WebAssemblyModuleConstructor.h
index e45f1a1..cf21add 100644
--- a/Source/JavaScriptCore/wasm/js/WebAssemblyModuleConstructor.h
+++ b/Source/JavaScriptCore/wasm/js/WebAssemblyModuleConstructor.h
@@ -44,6 +44,8 @@
DECLARE_INFO;
+ static JSValue createModule(ExecState*, Structure*);
+
protected:
void finishCreation(VM&, WebAssemblyModulePrototype*);