core/vm: avoid map lookups for accessing jumpdest analysis

This commit is contained in:
Martin Holst Swende 2020-08-04 15:40:23 +02:00
parent 82a9e11058
commit 8ead45c20b
No known key found for this signature in database
GPG Key ID: 683B438C05A5DDF0

View File

@ -112,7 +112,13 @@ func (c *Contract) validJumpSubdest(udest uint64) bool {
// isCode returns true if the provided PC location is an actual opcode, as // isCode returns true if the provided PC location is an actual opcode, as
// opposed to a data-segment following a PUSHN operation. // opposed to a data-segment following a PUSHN operation.
func (c *Contract) isCode(udest uint64) bool { func (c *Contract) isCode(udest uint64) bool {
// Do we already have an analysis laying around?
if c.analysis != nil {
return c.analysis.codeSegment(udest)
}
// Do we have a contract hash already? // Do we have a contract hash already?
// If we do have a hash, that means it's a 'regular' contract. For regular
// contracts ( not temporary initcode), we store the analysis in a map
if c.CodeHash != (common.Hash{}) { if c.CodeHash != (common.Hash{}) {
// Does parent context have the analysis? // Does parent context have the analysis?
analysis, exist := c.jumpdests[c.CodeHash] analysis, exist := c.jumpdests[c.CodeHash]