diff --git a/src/engine/Engine.v3 b/src/engine/Engine.v3 index 24b616d1..0f643d25 100644 --- a/src/engine/Engine.v3 +++ b/src/engine/Engine.v3 @@ -19,6 +19,21 @@ class Engine { return FileLoadResult.ParseError(code, filename, section, error_index, error_pos, error_msg); } } + + def loadWasmFileWithTiering(path: string, tiering_override: ExecutionStrategy) -> FileLoadResult { + var data = System.fileLoad(path); + if (data == null) return FileLoadResult.FileNotFound(path); + var limits = Limits.new().set(extensions); + var bp = BinParser.new(extensions, limits, path); + bp.tiering = tiering_override; + var r = bp.push(data, 0, data.length).finish(); + match (r) { + Ok(module) => + return FileLoadResult.Ok(module); + Error(code, filename, section, error_index, error_pos, error_msg) => + return FileLoadResult.ParseError(code, filename, section, error_index, error_pos, error_msg); + } + } } type FileLoadResult { case Ok(module: Module); diff --git a/src/engine/Execute.v3 b/src/engine/Execute.v3 index 75b046c9..37be7581 100644 --- a/src/engine/Execute.v3 +++ b/src/engine/Execute.v3 @@ -204,6 +204,15 @@ component ExecuteOptions { } return false; } + // Returns the execution strategy for a given flag, or default if not found. + def getModeOrDefault(name: string) -> ExecutionStrategy { + for (l = modes; l != null; l = l.tail) { + var t = l.head; + if (Strings.equal(t.0,name)) return t.1; + } + return default; + } + // Print help for the supported modes. def printHelp(out: TraceBuilder) { var H = out.putsln, L = out.ln; diff --git a/src/monitors/MonitorOptions.v3 b/src/monitors/MonitorOptions.v3 index d714b80d..c6cb266b 100644 --- a/src/monitors/MonitorOptions.v3 +++ b/src/monitors/MonitorOptions.v3 @@ -43,8 +43,8 @@ component MonitorOptions { if (Strings.endsWith(name, ".wasm")) { var engine = Engine.new(); engine.extensions = Extension.set.all; - - var result = engine.loadWasmFile(name); // TODO: limits + var tiering_override = ExecuteOptions.getModeOrDefault("jit"); + var result = engine.loadWasmFileWithTiering(name, tiering_override); // TODO: limits match (result) { Ok(m) => { monitors.put(WhammMonitor.new(m));