Skip to content

Commit 11798b1

Browse files
authored
[NFC] Rename "calling" in the fuzzer to "export" (#8479)
Now that we log more exports than just functions that we call (globals), this makes more sense.
1 parent fae74dc commit 11798b1

67 files changed

Lines changed: 567 additions & 568 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

scripts/fuzz_opt.py

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -432,8 +432,8 @@ def pick_initial_contents():
432432
# Host limits are reported as [host limit REASON]
433433
HOST_LIMIT_PREFIX = '[host limit '
434434

435-
# --fuzz-exec reports calls as [fuzz-exec] calling foo
436-
FUZZ_EXEC_CALL_PREFIX = '[fuzz-exec] calling'
435+
# --fuzz-exec reports calls as [fuzz-exec] export foo
436+
FUZZ_EXEC_EXPORT_PREFIX = '[fuzz-exec] export'
437437

438438
# --fuzz-exec reports a stack limit using this notation
439439
STACK_LIMIT = '[trap stack limit]'
@@ -449,11 +449,11 @@ def pick_initial_contents():
449449
EXCEPTION_PREFIX = 'exception thrown: '
450450

451451

452-
# given a call line that includes FUZZ_EXEC_CALL_PREFIX, return the export that
453-
# is called
454-
def get_export_from_call_line(call_line):
455-
assert FUZZ_EXEC_CALL_PREFIX in call_line
456-
return call_line.split(FUZZ_EXEC_CALL_PREFIX)[1].strip()
452+
# given an export line that includes FUZZ_EXEC_EXPORT_PREFIX, return the export
453+
# that is called
454+
def get_export_from_export_line(export_line):
455+
assert FUZZ_EXEC_EXPORT_PREFIX in export_line
456+
return export_line.split(FUZZ_EXEC_EXPORT_PREFIX)[1].strip()
457457

458458

459459
# compare two strings, strictly
@@ -795,7 +795,7 @@ class BinaryenInterpreter:
795795
def run(self, wasm):
796796
output = run_bynterp(wasm, ['--fuzz-exec-before'])
797797
if output != IGNORE:
798-
calls = output.count(FUZZ_EXEC_CALL_PREFIX)
798+
calls = output.count(FUZZ_EXEC_EXPORT_PREFIX)
799799
errors = output.count(TRAP_PREFIX) + output.count(HOST_LIMIT_PREFIX)
800800
if errors > calls / 2:
801801
# A significant amount of execution on this testcase
@@ -1140,14 +1140,14 @@ def fix_number(x):
11401140
# we can't test this function, which the trap is in the middle of.
11411141
# erase everything from this function's output and onward, so we
11421142
# only compare the previous trap-free code
1143-
call_start = interpreter.rindex(FUZZ_EXEC_CALL_PREFIX, 0, trap_index)
1143+
call_start = interpreter.rindex(FUZZ_EXEC_EXPORT_PREFIX, 0, trap_index)
11441144
call_end = interpreter.index('\n', call_start)
1145-
call_line = interpreter[call_start:call_end]
1145+
export_line = interpreter[call_start:call_end]
11461146
# fix up the call line so it matches the JS
1147-
fixed_call_line = fix_output_for_js(call_line)
1148-
before = before[:before.index(fixed_call_line)]
1149-
after = after[:after.index(fixed_call_line)]
1150-
interpreter = interpreter[:interpreter.index(call_line)]
1147+
fixed_export_line = fix_output_for_js(export_line)
1148+
before = before[:before.index(fixed_export_line)]
1149+
after = after[:after.index(fixed_export_line)]
1150+
interpreter = interpreter[:interpreter.index(export_line)]
11511151

11521152
if compare_before_to_after:
11531153
compare_between_vms(before, after, 'Wasm2JS (before/after)')
@@ -1302,14 +1302,14 @@ def handle_pair(self, input, before_wasm, after_wasm, opts):
13021302
# finding the call line right before us. that is, the output looks
13031303
# like this:
13041304
#
1305-
# [fuzz-exec] calling foo
1305+
# [fuzz-exec] export foo
13061306
# .. stuff happening during foo ..
1307-
# [fuzz-exec] calling bar
1307+
# [fuzz-exec] export bar
13081308
# .. stuff happening during bar ..
13091309
#
13101310
# if the trap happened during bar, the relevant call line is
1311-
# "[fuzz-exec] calling bar".
1312-
call_start = before.rfind(FUZZ_EXEC_CALL_PREFIX, 0, trap_index)
1311+
# "[fuzz-exec] export bar".
1312+
call_start = before.rfind(FUZZ_EXEC_EXPORT_PREFIX, 0, trap_index)
13131313
if call_start < 0:
13141314
# the trap happened before we called an export, so it occured
13151315
# during startup (the start function, or memory segment
@@ -1320,17 +1320,17 @@ def handle_pair(self, input, before_wasm, after_wasm, opts):
13201320
# be prefixes of each other
13211321
call_end = before.index(os.linesep, call_start) + 1
13221322
# we now know the contents of the call line after which the trap
1323-
# happens, which is something like "[fuzz-exec] calling bar", and
1323+
# happens, which is something like "[fuzz-exec] export bar", and
13241324
# it is unique since it contains the function being called.
1325-
call_line = before[call_start:call_end]
1326-
trapping_export = get_export_from_call_line(call_line)
1325+
export_line = before[call_start:call_end]
1326+
trapping_export = get_export_from_export_line(export_line)
13271327

13281328
# now that we know the trapping export, we can leave only the safe
13291329
# ones that are before it
13301330
safe_exports = []
13311331
for line in before.splitlines():
1332-
if FUZZ_EXEC_CALL_PREFIX in line:
1333-
export = get_export_from_call_line(line)
1332+
if FUZZ_EXEC_EXPORT_PREFIX in line:
1333+
export = get_export_from_export_line(line)
13341334
if export == trapping_export:
13351335
break
13361336
safe_exports.append(export)
@@ -1446,10 +1446,10 @@ def traps_in_instantiation(output):
14461446
trap_index = output.find('*exception*')
14471447
if trap_index == -1:
14481448
return False
1449-
call_index = output.find(FUZZ_EXEC_CALL_PREFIX)
1450-
if call_index == -1:
1449+
export_index = output.find(FUZZ_EXEC_EXPORT_PREFIX)
1450+
if export_index == -1:
14511451
return True
1452-
return trap_index < call_index
1452+
return trap_index < export_index
14531453

14541454

14551455
# Tests wasm-merge
@@ -1584,8 +1584,8 @@ def handle(self, wasm):
15841584
# primary module, but only the original ones.
15851585
exports = []
15861586
for line in output.splitlines():
1587-
if FUZZ_EXEC_CALL_PREFIX in line:
1588-
exports.append(get_export_from_call_line(line))
1587+
if FUZZ_EXEC_EXPORT_PREFIX in line:
1588+
exports.append(get_export_from_export_line(line))
15891589

15901590
# pick which to split out, with a random rate of picking (biased towards
15911591
# 0.5).
@@ -1779,7 +1779,7 @@ def handle_pair(self, input, before_wasm, after_wasm, opts):
17791779
fuzz_file,
17801780
'extracted'])
17811781
if get_exports('extracted.0.wasm', ['func']):
1782-
assert FUZZ_EXEC_CALL_PREFIX in output
1782+
assert FUZZ_EXEC_EXPORT_PREFIX in output
17831783

17841784
def ensure(self):
17851785
# The first time we actually run, set things up: make a bundle like the
@@ -1892,7 +1892,7 @@ def handle(self, wasm):
18921892
# wasm files.
18931893
exports = get_exports(wasm, ['func', 'global'])
18941894
exports += get_exports(second_wasm, ['func', 'global'])
1895-
calls_in_output = output.count(FUZZ_EXEC_CALL_PREFIX)
1895+
calls_in_output = output.count(FUZZ_EXEC_EXPORT_PREFIX)
18961896
if calls_in_output == 0:
18971897
print(f'warning: no calls in output. output:\n{output}')
18981898
assert calls_in_output == len(exports), exports
@@ -2009,11 +2009,11 @@ def compare_to_merged_output(self, output, merged_output):
20092009
b = merged_output_lines[i]
20102010
if a == b:
20112011
continue
2012-
if a.startswith(FUZZ_EXEC_CALL_PREFIX):
2012+
if a.startswith(FUZZ_EXEC_EXPORT_PREFIX):
20132013
# Fix up
2014-
# [fuzz-exec] calling foo/bar
2014+
# [fuzz-exec] export foo/bar
20152015
# for different foo/bar. Just copy the original.
2016-
assert b.startswith(FUZZ_EXEC_CALL_PREFIX)
2016+
assert b.startswith(FUZZ_EXEC_EXPORT_PREFIX)
20172017
merged_output_lines[i] = output_lines[i]
20182018
elif a.startswith(FUZZ_EXEC_NOTE_RESULT):
20192019
# Fix up
@@ -2272,7 +2272,7 @@ def handle(self, wasm):
22722272
# any logging before the first call.)
22732273
line_groups = [['before calls']]
22742274
for line in out.splitlines():
2275-
if line.startswith(FUZZ_EXEC_CALL_PREFIX):
2275+
if line.startswith(FUZZ_EXEC_EXPORT_PREFIX):
22762276
line_groups.append([line])
22772277
else:
22782278
line_groups[-1].append(line)

scripts/fuzz_shell.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@ function build(binary, isSecond) {
630630
}
631631

632632
// Execute the task.
633-
console.log(`[fuzz-exec] calling ${task.name}${task.deferred ? ' (after defer)' : ''}`);
633+
console.log(`[fuzz-exec] export ${task.name}${task.deferred ? ' (after defer)' : ''}`);
634634
let result;
635635
try {
636636
result = task.func();

scripts/update_lit_checks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
ITEM_RE = re.compile(r'(?:^\s*\(rec\s*)?(^\s*)\((' + ALL_ITEMS + r')\s+(' + ITEM_NAME + ').*$',
5656
re.MULTILINE)
5757

58-
FUZZ_EXEC_FUNC = re.compile(r'^\[fuzz-exec\] calling (?P<name>\S*)$')
58+
FUZZ_EXEC_FUNC = re.compile(r'^\[fuzz-exec\] export (?P<name>\S*)$')
5959

6060
ANNOTATION_RE = re.compile(r'^\s*\(\@.*')
6161

src/tools/execution-results.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ struct ExecutionResults {
488488
// opts)
489489
for (auto& exp : wasm.exports) {
490490
if (exp->kind == ExternalKind::Function) {
491-
std::cout << "[fuzz-exec] calling " << exp->name << "\n";
491+
std::cout << "[fuzz-exec] export " << exp->name << "\n";
492492
auto* func = wasm.getFunction(*exp->getInternalName());
493493
FunctionResult ret = run(func, wasm, instance);
494494
results[exp->name] = ret;
@@ -503,9 +503,8 @@ struct ExecutionResults {
503503
}
504504
}
505505
} else if (exp->kind == ExternalKind::Global) {
506-
// Log the global's value. (We use "calling" here to match the output
507-
// for calls, which simplifies the fuzzer.)
508-
std::cout << "[fuzz-exec] calling " << exp->name << "\n";
506+
// Log the global's value.
507+
std::cout << "[fuzz-exec] export " << exp->name << "\n";
509508
Literals* value = instance.getExportedGlobalOrNull(exp->name);
510509
assert(value);
511510
assert(value->size() == 1);

src/tools/wasm2c-wrapper.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ int main(int argc, char** argv) {
159159

160160
auto* func = wasm.getFunction(*exp->getInternalName());
161161

162-
ret += std::string(" puts(\"[fuzz-exec] calling ") +
162+
ret += std::string(" puts(\"[fuzz-exec] export ") +
163163
exp->name.toString() + "\");\n";
164164
auto result = func->getResults();
165165

test/lit/d8/fuzz_shell.wast

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@
1414
;;
1515
;; RUN: v8 %S/../../../scripts/fuzz_shell.js -- %t.wasm | filecheck %s
1616
;;
17-
;; CHECK: [fuzz-exec] calling test
17+
;; CHECK: [fuzz-exec] export test
1818
;; CHECK: [fuzz-exec] note result: test => 42
1919

test/lit/d8/fuzz_shell_exceptions.wast

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@
3939
;;
4040
;; RUN: v8 %S/../../../scripts/fuzz_shell.js -- %t.wasm | filecheck %s
4141
;;
42-
;; CHECK: [fuzz-exec] calling throwing-js
42+
;; CHECK: [fuzz-exec] export throwing-js
4343
;; CHECK: exception thrown: Error: js exception
44-
;; CHECK: [fuzz-exec] calling throwing-tag
44+
;; CHECK: [fuzz-exec] export throwing-tag
4545
;; CHECK: exception thrown: [object WebAssembly.Exception]
46-
;; CHECK: [fuzz-exec] calling throwing-jstag-null
46+
;; CHECK: [fuzz-exec] export throwing-jstag-null
4747
;; CHECK: exception thrown: null
4848

4949

test/lit/d8/fuzz_shell_jspi.wast

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -49,32 +49,32 @@
4949
;; we get a random-like ordering, which includes some defers (each of which has
5050
;; a later finish), showing that we interleave stacks.
5151
;;
52-
;; CHECK: [fuzz-exec] calling a
53-
;; CHECK: [fuzz-exec] calling b
52+
;; CHECK: [fuzz-exec] export a
53+
;; CHECK: [fuzz-exec] export b
5454
;; CHECK: [fuzz-exec] note result: a => 10
55-
;; CHECK: [fuzz-exec] calling b
55+
;; CHECK: [fuzz-exec] export b
5656
;; CHECK: [fuzz-exec] note result: b => 20
57-
;; CHECK: [fuzz-exec] calling a
57+
;; CHECK: [fuzz-exec] export a
5858
;; CHECK: (jspi: defer a)
59-
;; CHECK: [fuzz-exec] calling d
59+
;; CHECK: [fuzz-exec] export d
6060
;; CHECK: (jspi: defer d)
61-
;; CHECK: [fuzz-exec] calling e
61+
;; CHECK: [fuzz-exec] export e
6262
;; CHECK: [fuzz-exec] note result: b => 20
63-
;; CHECK: [fuzz-exec] calling c
63+
;; CHECK: [fuzz-exec] export c
6464
;; CHECK: [fuzz-exec] note result: e => 50
65-
;; CHECK: [fuzz-exec] calling c
65+
;; CHECK: [fuzz-exec] export c
6666
;; CHECK: (jspi: defer c)
67-
;; CHECK: [fuzz-exec] calling c
67+
;; CHECK: [fuzz-exec] export c
6868
;; CHECK: (jspi: finish c)
6969
;; CHECK: [fuzz-exec] note result: c => 30
70-
;; CHECK: [fuzz-exec] calling d
70+
;; CHECK: [fuzz-exec] export d
7171
;; CHECK: [fuzz-exec] note result: c => 30
72-
;; CHECK: [fuzz-exec] calling d
72+
;; CHECK: [fuzz-exec] export d
7373
;; CHECK: (jspi: finish d)
7474
;; CHECK: [fuzz-exec] note result: d => 40
75-
;; CHECK: [fuzz-exec] calling e
75+
;; CHECK: [fuzz-exec] export e
7676
;; CHECK: [fuzz-exec] note result: d => 40
77-
;; CHECK: [fuzz-exec] calling a
77+
;; CHECK: [fuzz-exec] export a
7878
;; CHECK: (jspi: finish a)
7979
;; CHECK: [fuzz-exec] note result: a => 10
8080
;; CHECK: [fuzz-exec] note result: e => 50

test/lit/d8/fuzz_shell_sleep.wast

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,20 +53,20 @@
5353
;; func2 is more because we do not have a toplevel await, see comment in
5454
;; fuzz_shell_jspi.wast.)
5555
;;
56-
;; CHECK: [fuzz-exec] calling func2
56+
;; CHECK: [fuzz-exec] export func2
5757
;; CHECK: [fuzz-exec] note result: func2 => 2
58-
;; CHECK: [fuzz-exec] calling func1
58+
;; CHECK: [fuzz-exec] export func1
5959
;; CHECK: (jspi: defer func1)
60-
;; CHECK: [fuzz-exec] calling func3
60+
;; CHECK: [fuzz-exec] export func3
6161
;; CHECK: [fuzz-exec] note result: func3 => 3
62-
;; CHECK: [fuzz-exec] calling func1 (after defer)
62+
;; CHECK: [fuzz-exec] export func1 (after defer)
6363
;; CHECK: (jspi: finish func1)
6464
;; CHECK: [fuzz-exec] note result: func1 => 1
65-
;; CHECK: [fuzz-exec] calling func5
65+
;; CHECK: [fuzz-exec] export func5
6666
;; CHECK: (jspi: defer func5)
67-
;; CHECK: [fuzz-exec] calling func4
67+
;; CHECK: [fuzz-exec] export func4
6868
;; CHECK: [fuzz-exec] note result: func4 => 4
69-
;; CHECK: [fuzz-exec] calling func5 (after defer)
69+
;; CHECK: [fuzz-exec] export func5 (after defer)
7070
;; CHECK: (jspi: finish func5)
7171
;; CHECK: [fuzz-exec] note result: func5 => 5
7272

0 commit comments

Comments
 (0)