Merge pull request #5954 from paritytech/evm-defer
Avoid pre-computing jump destinations
This commit is contained in:
commit
36c91e4ed5
@ -113,7 +113,7 @@ impl<Cost: CostType> evm::Evm for Interpreter<Cost> {
|
|||||||
let mut informant = informant::EvmInformant::new(ext.depth());
|
let mut informant = informant::EvmInformant::new(ext.depth());
|
||||||
|
|
||||||
let code = ¶ms.code.as_ref().expect("exec always called with code; qed");
|
let code = ¶ms.code.as_ref().expect("exec always called with code; qed");
|
||||||
let valid_jump_destinations = self.cache.jump_destinations(¶ms.code_hash, code);
|
let mut valid_jump_destinations = None;
|
||||||
|
|
||||||
let mut gasometer = Gasometer::<Cost>::new(Cost::from_u256(params.gas)?);
|
let mut gasometer = Gasometer::<Cost>::new(Cost::from_u256(params.gas)?);
|
||||||
let mut stack = VecStack::with_capacity(ext.schedule().stack_limit, U256::zero());
|
let mut stack = VecStack::with_capacity(ext.schedule().stack_limit, U256::zero());
|
||||||
@ -162,7 +162,11 @@ impl<Cost: CostType> evm::Evm for Interpreter<Cost> {
|
|||||||
// Advance
|
// Advance
|
||||||
match result {
|
match result {
|
||||||
InstructionResult::JumpToPosition(position) => {
|
InstructionResult::JumpToPosition(position) => {
|
||||||
let pos = self.verify_jump(position, &valid_jump_destinations)?;
|
if valid_jump_destinations.is_none() {
|
||||||
|
valid_jump_destinations = Some(self.cache.jump_destinations(¶ms.code_hash, code));
|
||||||
|
}
|
||||||
|
let jump_destinations = valid_jump_destinations.as_ref().expect("jump_destinations are initialized on first jump; qed");
|
||||||
|
let pos = self.verify_jump(position, jump_destinations)?;
|
||||||
reader.position = pos;
|
reader.position = pos;
|
||||||
},
|
},
|
||||||
InstructionResult::StopExecutionNeedsReturn {gas, init_off, init_size, apply} => {
|
InstructionResult::StopExecutionNeedsReturn {gas, init_off, init_size, apply} => {
|
||||||
|
Loading…
Reference in New Issue
Block a user