This commit is contained in:
Daniel Lubarov 2022-09-05 10:12:23 -07:00
parent aaf7ace396
commit 9b259cb917
2 changed files with 5 additions and 4 deletions

View File

@ -10,7 +10,6 @@
/// Note that this correctly handles exp(0, 0) == 1.
global exp:
jumpdest
// stack: x, e, retdest
dup2
// stack: e, x, e, retdest
@ -27,7 +26,6 @@ global exp:
jump
step_case:
jumpdest
// stack: x, e, retdest
push recursion_return
// stack: recursion_return, x, e, retdest
@ -43,7 +41,6 @@ step_case:
// stack: x * x, e / 2, recursion_return, x, e, retdest
%jump(exp)
recursion_return:
jumpdest
// stack: exp(x * x, e / 2), x, e, retdest
push 2
// stack: 2, exp(x * x, e / 2), x, e, retdest

View File

@ -250,7 +250,7 @@ impl<'a> Interpreter<'a> {
0x58 => todo!(), // "GETPC",
0x59 => todo!(), // "MSIZE",
0x5a => todo!(), // "GAS",
0x5b => (), // "JUMPDEST",
0x5b => self.run_jumpdest(), // "JUMPDEST",
0x5c => todo!(), // "GET_STATE_ROOT",
0x5d => todo!(), // "SET_STATE_ROOT",
0x5e => todo!(), // "GET_RECEIPT_ROOT",
@ -490,6 +490,10 @@ impl<'a> Interpreter<'a> {
}
}
fn run_jumpdest(&mut self) {
assert!(!self.kernel_mode, "JUMPDEST is not needed in kernel code");
}
fn jump_to(&mut self, offset: usize) {
// The JUMPDEST rule is not enforced in kernel mode.
if !self.kernel_mode && self.jumpdests.binary_search(&offset).is_err() {