summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xscripts/fuzz_opt.py18
-rw-r--r--src/tools/wasm2c-wrapper.h7
2 files changed, 20 insertions, 5 deletions
diff --git a/scripts/fuzz_opt.py b/scripts/fuzz_opt.py
index b3310cad0..7efb2043a 100755
--- a/scripts/fuzz_opt.py
+++ b/scripts/fuzz_opt.py
@@ -15,6 +15,7 @@ BINARYEN_CORES=1 BINARYEN_PASS_DEBUG=1 afl-fuzz -i afl-testcases/ -o afl-finding
script covers different options being passed)
'''
+import contextlib
import os
import difflib
import math
@@ -87,6 +88,17 @@ def randomize_pass_debug():
print('randomized pass debug:', os.environ.get('BINARYEN_PASS_DEBUG', ''))
+@contextlib.contextmanager
+def no_pass_debug():
+ old_env = os.environ.copy()
+ if os.environ.get('BINARYEN_PASS_DEBUG'):
+ del os.environ['BINARYEN_PASS_DEBUG']
+ try:
+ yield
+ finally:
+ os.environ.update(old_env)
+
+
def randomize_feature_opts():
global FEATURE_OPTS
FEATURE_OPTS = CONSTANT_FEATURE_OPTS[:]
@@ -380,7 +392,11 @@ class CompareVMs(TestCaseHandler):
compile_cmd += ['-Os']
else:
compile_cmd += ['-Oz']
- run(compile_cmd)
+ # avoid pass-debug on the emcc invocation itself (which runs
+ # binaryen to optimize the wasm), as the wasm here can be very
+ # large and it isn't what we are focused on testing here
+ with no_pass_debug():
+ run(compile_cmd)
return run_vm(['d8', 'a.out.js'])
def can_run(self):
diff --git a/src/tools/wasm2c-wrapper.h b/src/tools/wasm2c-wrapper.h
index aa36dd782..74ae21202 100644
--- a/src/tools/wasm2c-wrapper.h
+++ b/src/tools/wasm2c-wrapper.h
@@ -98,14 +98,13 @@ int main(int argc, char** argv) {
// For each export in the wasm, emit code to call it and log its result,
// similar to the other wrappers.
- size_t exportIndex = 0;
-
- for (auto& exp : wasm.exports) {
+ for (size_t i = 0; i < wasm.exports.size(); i++) {
+ auto& exp = wasm.exports[i];
if (exp->kind != ExternalKind::Function) {
continue;
}
- ret += " case " + std::to_string(exportIndex++) + ":\n";
+ ret += " case " + std::to_string(i) + ":\n";
auto* func = wasm.getFunction(exp->value);