Skip to content

Commit 93b0629

Browse files
authored
Simplify branch hint instrumentation (#8624)
The previous branch hint instrumentation logic would introduce a scratch local to hold the condition so it could be passed into both the logging function and the original branching instruction. The de-instrumentation pass would then need to find this local and attempt to undo the data flow change. Simplify all of this by having the logging function return the condition value so it can interpose between the condition and the branch without any new locals. De-instrumentation can now just replace the call to the log function with its condition parameter. To allow further simplification, also change the order of parameters to the logging function so the condition value is the first parameter. This ensures that we don't need to introduce a scratch local even when the condition is a `pop`, because the pop will remain the leftmost leaf expression in the catch body.
1 parent b3650ea commit 93b0629

File tree

8 files changed

+158
-561
lines changed

8 files changed

+158
-561
lines changed

scripts/fuzz_opt.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2281,7 +2281,7 @@ def handle(self, wasm):
22812281
for line in out.splitlines():
22822282
if line.startswith(LOG_BRANCH_PREFIX):
22832283
# (1:-1 strips away the '[', ']' at the edges)
2284-
_, _, id_, hint, actual = line[1:-1].split(' ')
2284+
_, _, actual, hint, id_ = line[1:-1].split(' ')
22852285
all_ids.add(id_)
22862286
if hint != actual:
22872287
# This hint was misleading.
@@ -2443,7 +2443,7 @@ def handle(self, wasm):
24432443
continue
24442444
for line in group:
24452445
if line.startswith(LOG_BRANCH_PREFIX):
2446-
_, _, id_, hint, actual = line[1:-1].split(' ')
2446+
_, _, actual, hint, id_ = line[1:-1].split(' ')
24472447
hint = int(hint)
24482448
actual = int(actual)
24492449
assert hint in (0, 1)

scripts/fuzz_shell.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -400,8 +400,9 @@ var baseImports = {
400400
});
401401
},
402402

403-
'log-branch': (id, expected, actual) => {
404-
console.log(`[LoggingExternalInterface log-branch ${id} ${expected} ${actual}]`);
403+
'log-branch': (actual, expected, id) => {
404+
console.log(`[LoggingExternalInterface log-branch ${actual} ${expected} ${id}]`);
405+
return actual;
405406
},
406407
},
407408
// Emscripten support.

0 commit comments

Comments
 (0)