mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 10:22:23 +00:00
core/vm: save jumpdest analysis locally
This commit is contained in:
parent
880f6981a5
commit
72f655d421
1 changed files with 9 additions and 4 deletions
|
|
@ -50,6 +50,7 @@ type Contract struct {
|
||||||
self ContractRef
|
self ContractRef
|
||||||
|
|
||||||
jumpdests destinations // Aggregated result of JUMPDEST analysis.
|
jumpdests destinations // Aggregated result of JUMPDEST analysis.
|
||||||
|
analysis bitvec // Locally cached result of JUMPDEST analysis
|
||||||
|
|
||||||
Code []byte
|
Code []byte
|
||||||
CodeHash *common.Hash
|
CodeHash *common.Hash
|
||||||
|
|
@ -105,10 +106,14 @@ func (c *Contract) validJumpdest(dest *big.Int) bool {
|
||||||
}
|
}
|
||||||
return analysis.codeSegment(udest)
|
return analysis.codeSegment(udest)
|
||||||
}
|
}
|
||||||
//Don't have the hash, most likely a piece of initcode not already in state trie
|
// We don't have the code hash, most likely a piece of initcode not already
|
||||||
analysis = codeBitmap(c.Code)
|
// in state trie. In that case, we do an analysis, and save it locally, so
|
||||||
// Don't bother saving this
|
// we don't have to recalculate it for every JUMP instruction in the execution
|
||||||
return analysis.codeSegment(udest)
|
// However, we don't save it within the parent context
|
||||||
|
if c.analysis == nil {
|
||||||
|
c.analysis = codeBitmap(c.Code)
|
||||||
|
}
|
||||||
|
return c.analysis.codeSegment(udest)
|
||||||
}
|
}
|
||||||
|
|
||||||
// AsDelegate sets the contract to be a delegate call and returns the current
|
// AsDelegate sets the contract to be a delegate call and returns the current
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue