Skip to content

Commit 643ddb6

Browse files
authored
Revert "feat(decoder): move cache to heap (#357)" (#485)
This reverts commit 2ab3482.
1 parent a155876 commit 643ddb6

File tree

4 files changed

+4
-217
lines changed

4 files changed

+4
-217
lines changed

src/decoder.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,8 @@ pub struct DefaultDecoder {
2323
factories: Vec<InstructionFactory>,
2424
mop: bool,
2525
version: u32,
26-
// Use a cache of instructions to avoid decoding the same instruction
27-
// twice, pc is the key and the instruction is the value.
28-
//
29-
// Use Vector so that the data is on the heap. Otherwise, if there is
30-
// a vm call chain, it will quickly consume Rust's 2M stack space.
31-
instructions_cache: Vec<(u64, u64)>,
26+
// use a cache of instructions to avoid decoding the same instruction twice, pc is the key and the instruction is the value
27+
instructions_cache: [(u64, u64); INSTRUCTION_CACHE_SIZE],
3228
}
3329

3430
impl DefaultDecoder {
@@ -38,7 +34,7 @@ impl DefaultDecoder {
3834
factories: vec![],
3935
mop,
4036
version,
41-
instructions_cache: vec![(u64::MAX as u64, 0); INSTRUCTION_CACHE_SIZE],
37+
instructions_cache: [(u64::MAX, 0); INSTRUCTION_CACHE_SIZE],
4238
}
4339
}
4440

@@ -886,7 +882,7 @@ impl InstDecoder for DefaultDecoder {
886882
}
887883

888884
fn reset_instructions_cache(&mut self) -> Result<(), Error> {
889-
self.instructions_cache = vec![(u64::MAX, 0); INSTRUCTION_CACHE_SIZE];
885+
self.instructions_cache = [(u64::MAX, 0); INSTRUCTION_CACHE_SIZE];
890886
Ok(())
891887
}
892888
}

tests/programs/spawn

-6.9 KB
Binary file not shown.

tests/programs/spawn.c

Lines changed: 0 additions & 36 deletions
This file was deleted.

tests/test_spawn.rs

Lines changed: 0 additions & 173 deletions
This file was deleted.

0 commit comments

Comments
 (0)