Skip to content

Commit 9de7805

Browse files
committed
[interpreter] Add flag for controlling call budget
1 parent 40dca73 commit 9de7805

File tree

4 files changed

+8
-4
lines changed

4 files changed

+8
-4
lines changed

interpreter/exec/eval.ml

+2-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ type config =
7373
}
7474

7575
let frame inst locals = {inst; locals}
76-
let config inst vs es = {frame = frame inst []; code = vs, es; budget = 300}
76+
let config inst vs es =
77+
{frame = frame inst []; code = vs, es; budget = !Flags.budget}
7778

7879
let plain e = Plain e.it @@ e.at
7980

interpreter/main/flags.ml

+1
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ let print_sig = ref false
55
let dry = ref false
66
let width = ref 80
77
let harness = ref true
8+
let budget = ref 256

interpreter/main/main.ml

+4-2
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,13 @@ let argspec = Arg.align
2424
" read script from file";
2525
"-o", Arg.String (fun file -> add_arg ("(output " ^ quote file ^ ")")),
2626
" write module to file";
27+
"-b", Arg.Int (fun n -> Flags.budget := n),
28+
" configure call depth budget (default is " ^ string_of_int !Flags.budget ^ ")";
2729
"-w", Arg.Int (fun n -> Flags.width := n),
28-
" configure output width (default is 80)";
30+
" configure output width (default is " ^ string_of_int !Flags.width ^ ")";
2931
"-s", Arg.Set Flags.print_sig, " show module signatures";
3032
"-u", Arg.Set Flags.unchecked, " unchecked, do not perform validation";
31-
"-h", Arg.Clear Flags.harness, " exclude harness for JS conversion";
33+
"-j", Arg.Clear Flags.harness, " exclude harness for JS conversion";
3234
"-d", Arg.Set Flags.dry, " dry, do not run program";
3335
"-t", Arg.Set Flags.trace, " trace execution";
3436
"-v", Arg.Unit banner, " show version"

test/build.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def ensure_wasm_executable(path_to_wasm):
6060
def convert_one_wast_file(inputs):
6161
wast_file, js_file = inputs
6262
print('Compiling {} to JS...'.format(wast_file))
63-
return run(WASM_EXEC, wast_file, '-h', '-o', js_file)
63+
return run(WASM_EXEC, wast_file, '-j', '-o', js_file)
6464

6565
def convert_wast_to_js(out_js_dir):
6666
"""Compile all the wast files to JS and store the results in the JS dir."""

0 commit comments

Comments
 (0)