From 033792b43a2dc2639876063fc1a256f2822f5a83 Mon Sep 17 00:00:00 2001 From: Peter Farber Date: Wed, 16 Oct 2024 15:51:49 -0400 Subject: [PATCH] chore(loader): introducing new formats for metering --- loader/src/index.cjs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/loader/src/index.cjs b/loader/src/index.cjs index 484ad70a8..b6b3f6dd1 100644 --- a/loader/src/index.cjs +++ b/loader/src/index.cjs @@ -110,7 +110,7 @@ const originalCompileStreaming = WebAssembly.compileStreaming const originalCompile = WebAssembly.compile const shouldApplyMetering = (importObject = {}) => { - return importObject.applyMetering && ['wasm32-unknown-emscripten4', 'wasm64-unknown-emscripten-draft_2024_02_15'].includes(importObject.format); + return ['wasm32-unknown-emscripten_metering', 'wasm64-unknown-emscripten_metering'].includes(importObject.format); } const applyMetering = (arrayBuffer, importObject) => { @@ -128,7 +128,7 @@ const applyMetering = (arrayBuffer, importObject) => { } // Override WebAssembly.compileStreaming to apply metering -WebAssembly.compileStreaming = async function (source, importObject = { applyMetering: false }) { +WebAssembly.compileStreaming = async function (source, importObject = { }) { if (!shouldApplyMetering(importObject)) return originalCompileStreaming(source) const arrayBuffer = await source.arrayBuffer() @@ -136,7 +136,7 @@ WebAssembly.compileStreaming = async function (source, importObject = { applyMet } // Override WebAssembly.compile to apply metering -WebAssembly.compile = async function (source, importObject = { applyMetering: false }) { +WebAssembly.compile = async function (source, importObject = { }) { if (!shouldApplyMetering(importObject)) return originalCompile(source) return applyMetering(source, importObject) @@ -167,9 +167,9 @@ module.exports = async function (binary, options) { options.wasmBinary = binary } - if (options.format === "wasm64-unknown-emscripten-draft_2024_02_15") { + if (options.format === "wasm64-unknown-emscripten-draft_2024_02_15" || options.format === "wasm64-unknown-emscripten_metering") { instance = await Wasm64(options) - } else if (options.format === "wasm32-unknown-emscripten4") { + } else if (options.format === "wasm32-unknown-emscripten4" || options.format === "wasm32-unknown-emscripten_metering") { instance = await Emscripten4(options) }