From 465c7eeaa28ceabe7541ea7cd534ba35c93fc75c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Thu, 29 Jun 2017 17:43:34 +0200 Subject: [PATCH] Defer construction valid_jump_destinations. --- ethcore/src/evm/interpreter/mod.rs | 8 ++++++-- evmbin/src/main.rs | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/ethcore/src/evm/interpreter/mod.rs b/ethcore/src/evm/interpreter/mod.rs index a4ff69c2a..99546a52d 100644 --- a/ethcore/src/evm/interpreter/mod.rs +++ b/ethcore/src/evm/interpreter/mod.rs @@ -113,7 +113,7 @@ impl evm::Evm for Interpreter { let mut informant = informant::EvmInformant::new(ext.depth()); 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::::new(Cost::from_u256(params.gas)?); let mut stack = VecStack::with_capacity(ext.schedule().stack_limit, U256::zero()); @@ -162,7 +162,11 @@ impl evm::Evm for Interpreter { // Advance match result { 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"); + let pos = self.verify_jump(position, jump_destinations)?; reader.position = pos; }, InstructionResult::StopExecutionNeedsReturn {gas, init_off, init_size, apply} => { diff --git a/evmbin/src/main.rs b/evmbin/src/main.rs index a7d90b90b..cfaba85e8 100644 --- a/evmbin/src/main.rs +++ b/evmbin/src/main.rs @@ -133,7 +133,7 @@ impl Args { spec::Spec::load(file)? }, None => { - spec::Spec::new_instant() + ethcore::ethereum::new_foundation() }, }) }