aboutsummaryrefslogtreecommitdiffstats
path: root/core/vm/interpreter.go
diff options
context:
space:
mode:
authorGuillaume Ballet <gballet@gmail.com>2018-07-03 18:06:42 +0800
committerPéter Szilágyi <peterke@gmail.com>2018-07-03 18:06:42 +0800
commit4e5d1f1c39159de42511770bd390ad583ebd57a5 (patch)
treed1ce3fb28c78dc6bdc73026eacfee92fa71ce447 /core/vm/interpreter.go
parentd57e85ecc91608a9095479365308a285f05c755d (diff)
downloadgo-tangerine-4e5d1f1c39159de42511770bd390ad583ebd57a5.tar.gz
go-tangerine-4e5d1f1c39159de42511770bd390ad583ebd57a5.tar.zst
go-tangerine-4e5d1f1c39159de42511770bd390ad583ebd57a5.zip
core/vm: reuse bigint pools across transactions (#17070)
* core/vm: A pool for int pools * core/vm: fix rebase issue * core/vm: push leftover stack items after execution, not before
Diffstat (limited to 'core/vm/interpreter.go')
-rw-r--r--core/vm/interpreter.go12
1 files changed, 11 insertions, 1 deletions
diff --git a/core/vm/interpreter.go b/core/vm/interpreter.go
index 7090e0261..0d6038cbb 100644
--- a/core/vm/interpreter.go
+++ b/core/vm/interpreter.go
@@ -77,7 +77,6 @@ func NewInterpreter(evm *EVM, cfg Config) *Interpreter {
evm: evm,
cfg: cfg,
gasTable: evm.ChainConfig().GasTable(evm.BlockNumber),
- intPool: newIntPool(),
}
}
@@ -104,6 +103,14 @@ func (in *Interpreter) enforceRestrictions(op OpCode, operation operation, stack
// considered a revert-and-consume-all-gas operation except for
// errExecutionReverted which means revert-and-keep-gas-left.
func (in *Interpreter) Run(contract *Contract, input []byte) (ret []byte, err error) {
+ if in.intPool == nil {
+ in.intPool = poolOfIntPools.get()
+ defer func() {
+ poolOfIntPools.put(in.intPool)
+ in.intPool = nil
+ }()
+ }
+
// Increment the call depth which is restricted to 1024
in.evm.depth++
defer func() { in.evm.depth-- }()
@@ -133,6 +140,9 @@ func (in *Interpreter) Run(contract *Contract, input []byte) (ret []byte, err er
)
contract.Input = input
+ // Reclaim the stack as an int pool when the execution stops
+ defer func() { in.intPool.put(stack.data...) }()
+
if in.cfg.Debug {
defer func() {
if err != nil {