commit dab845c9edf7165672bd6dbb8e8a28763ab379f9
parent 67234fcc689f987e58c2e60e6d6fd51f8244f633
Author: Daniel Minor <dminor@mozilla.com>
Date: Fri, 12 Dec 2025 14:12:36 +0000
Bug 1994828 - Add empty JS::CompileWasmModule; r=allstarschh
Compilation will be implemented in a follow-up bug, for now, we'll
fail unconditionally.
Differential Revision: https://phabricator.services.mozilla.com/D270152
Diffstat:
2 files changed, 41 insertions(+), 0 deletions(-)
diff --git a/js/public/Modules.h b/js/public/Modules.h
@@ -216,6 +216,22 @@ extern JS_PUBLIC_API JSObject* CreateDefaultExportSyntheticModule(
JSContext* cx, const Value& defaultExport);
/**
+ * Parse the given source buffer as a module in the scope of the current global
+ * of cx and return a source text module record.
+ */
+extern JS_PUBLIC_API JSObject* CompileWasmModule(
+ JSContext* cx, const ReadOnlyCompileOptions& options,
+ SourceText<char16_t>& srcBuf);
+
+/**
+ * Parse the given source buffer as a module in the scope of the current global
+ * of cx and return a source text module record.
+ */
+extern JS_PUBLIC_API JSObject* CompileWasmModule(
+ JSContext* cx, const ReadOnlyCompileOptions& options,
+ SourceText<mozilla::Utf8Unit>& srcBuf);
+
+/**
* Set a private value associated with a source text module record.
*/
extern JS_PUBLIC_API void SetModulePrivate(JSObject* module,
diff --git a/js/src/vm/Modules.cpp b/js/src/vm/Modules.cpp
@@ -299,6 +299,31 @@ JS_PUBLIC_API JSObject* JS::CreateDefaultExportSyntheticModule(
return moduleObject;
}
+JS_PUBLIC_API JSObject* JS::CompileWasmModule(
+ JSContext* cx, const ReadOnlyCompileOptions& options,
+ SourceText<mozilla::Utf8Unit>& srcBuf) {
+ // TODO: Compilation of wasm modules will be added in
+ // https://bugzilla.mozilla.org/show_bug.cgi?id=1997621.
+ // For now, we fail unconditionally.
+ JS_ReportErrorNumberUTF8(cx, GetErrorMessage, nullptr,
+ JSMSG_WASM_COMPILE_ERROR,
+ "Compilation of wasm modules not implemented.");
+
+ return nullptr;
+}
+
+JS_PUBLIC_API JSObject* JS::CompileWasmModule(
+ JSContext* cx, const ReadOnlyCompileOptions& options,
+ SourceText<char16_t>& srcBuf) {
+ // TODO: Compilation of wasm modules will be added in
+ // https://bugzilla.mozilla.org/show_bug.cgi?id=1997621.
+ // For now, we fail unconditionally.
+ JS_ReportErrorNumberUTF8(cx, GetErrorMessage, nullptr,
+ JSMSG_WASM_COMPILE_ERROR,
+ "Compilation of wasm modules not implemented.");
+ return nullptr;
+}
+
JS_PUBLIC_API void JS::SetModulePrivate(JSObject* module, const Value& value) {
JSRuntime* rt = module->zone()->runtimeFromMainThread();
module->as<ModuleObject>().scriptSourceObject()->setPrivate(rt, value);