mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-25 14:16:44 +00:00
cache size
This commit is contained in:
parent
d010b982ae
commit
50281f1d17
1 changed files with 19 additions and 0 deletions
|
|
@ -20,6 +20,7 @@ import (
|
|||
"math/big"
|
||||
"time"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/logger"
|
||||
"github.com/ethereum/go-ethereum/logger/glog"
|
||||
)
|
||||
|
|
@ -85,6 +86,8 @@ func OptimiseProgram(program *Program) {
|
|||
statsJump++
|
||||
|
||||
load = nil
|
||||
case instr.op == EXTCODESIZE:
|
||||
program.instructions[i] = codesize{}
|
||||
default:
|
||||
// create a new N pushes segment
|
||||
if len(load) > 1 {
|
||||
|
|
@ -97,6 +100,22 @@ func OptimiseProgram(program *Program) {
|
|||
}
|
||||
}
|
||||
|
||||
type codesize struct {
|
||||
size *big.Int
|
||||
}
|
||||
|
||||
func (instr codesize) do(program *Program, pc *uint64, env *Environment, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
|
||||
if instr.size == nil {
|
||||
addr := common.BigToAddress(stack.pop())
|
||||
instr.size = big.NewInt(int64(len(env.Db().GetCode(addr))))
|
||||
}
|
||||
stack.push(instr.size)
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (codesize) Op() OpCode { return EXTCODESIZE }
|
||||
func (codesize) halts() bool { return false }
|
||||
|
||||
// makePushSeg creates a new push segment from N amount of push instructions
|
||||
func makePushSeg(instrs []instruction) (pushSeg, int) {
|
||||
var (
|
||||
|
|
|
|||
Loading…
Reference in a new issue