Defer construction valid_jump_destinations.

This commit is contained in:
Tomasz Drwięga 2017-06-29 17:43:34 +02:00
parent 826bf28196
commit 465c7eeaa2
No known key found for this signature in database
GPG Key ID: D066F497E62CAF66
2 changed files with 7 additions and 3 deletions

View File

@ -113,7 +113,7 @@ impl<Cost: CostType> evm::Evm for Interpreter<Cost> {
let mut informant = informant::EvmInformant::new(ext.depth());
let code = &params.code.as_ref().expect("exec always called with code; qed");
let valid_jump_destinations = self.cache.jump_destinations(&params.code_hash, code);
let mut valid_jump_destinations = None;
let mut gasometer = Gasometer::<Cost>::new(Cost::from_u256(params.gas)?);
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
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(&params.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} => {

View File

@ -133,7 +133,7 @@ impl Args {
spec::Spec::load(file)?
},
None => {
spec::Spec::new_instant()
ethcore::ethereum::new_foundation()
},
})
}