Skip to content

Commit cc02503

Browse files
remove defensive malformed check in main loop
1 parent 899f989 commit cc02503

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

bench.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@ This file documents the coremark bench results to document performance improveme
22
- ac6b813: avg ≈ 500 (introduced benchmarking without criterion)
33
- 5f4af0c: avg = 529.773949, n = 20 (improved leb128 handling with unsafe)
44
- we try to avoid unsafe code in module/validator/instance directly
5-
- current: avg = 810.367084, n = 20 (use a dense offset table instead of hashmap, better leb128, and cold path hinting)
5+
- 899f989: avg = 810.367084, n = 20 (improve leb128 handling, move sidetable to using arrays, label error creation as cold paths)
66
- rust hashmaps are apparently very bad, this might be because of our memory access pattern, when we interpret the control op codes (corresponding to side table entries) they are kind of accessed sequentially, so even btreemap yields better results
77
- current design: two-level indirection (one array covering all possible code indices and directing them to a densely packed side table)
88
- we also try to not use nightly features... making error creation cold path is a really elegant solution in this regard
99
- repr(C) for the SideTableEntry struct caused mysterious improvements, not sure if it is a fluke
10+
- current: avg = 855.71814, n = 20 (remove defensive malformed check in main loop)
11+
- since the module is already validated at run time, there is no reason for the check to exist, it was a remnant of early development phase that lacked proper handling for some malformed modules
1012

1113

1214
Hardware Overview:

src/instance.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -861,7 +861,6 @@ impl Instance {
861861
}}}
862862

863863
loop {
864-
if pc >= bytes.len() { return Err(Error::malformed(UNEXPECTED_END)); }
865864
match next_op!() {
866865
0x00 => return Err(Error::trap(UNREACHABLE)),
867866
0x01 | 0xbc | 0xbd | 0xbe | 0xbf => {} // nop and reinterprets (no-op on raw bits)

0 commit comments

Comments
 (0)