aboutsummaryrefslogtreecommitdiffstats
path: root/core/vm/instructions.go
diff options
context:
space:
mode:
authorJeffrey Wilcke <jeffrey@ethereum.org>2017-05-23 16:39:53 +0800
committerJeffrey Wilcke <jeffrey@ethereum.org>2017-05-23 16:39:53 +0800
commita816e756625d39fc9b544f97dfa218d885996f33 (patch)
tree724b97e491a02b8935b8856f4585405178dd3e45 /core/vm/instructions.go
parent3ee75bec9fd3a023b9636a9f09cce99dc487bfaa (diff)
downloaddexon-a816e756625d39fc9b544f97dfa218d885996f33.tar
dexon-a816e756625d39fc9b544f97dfa218d885996f33.tar.gz
dexon-a816e756625d39fc9b544f97dfa218d885996f33.tar.bz2
dexon-a816e756625d39fc9b544f97dfa218d885996f33.tar.lz
dexon-a816e756625d39fc9b544f97dfa218d885996f33.tar.xz
dexon-a816e756625d39fc9b544f97dfa218d885996f33.tar.zst
dexon-a816e756625d39fc9b544f97dfa218d885996f33.zip
core/vm: improved push instructions
Improved push instructions by removing unnecessary big int allocations and by making it int instead of big.Int
Diffstat (limited to 'core/vm/instructions.go')
-rw-r--r--core/vm/instructions.go19
1 files changed, 16 insertions, 3 deletions
diff --git a/core/vm/instructions.go b/core/vm/instructions.go
index fa4dbe428..c0ac911ac 100644
--- a/core/vm/instructions.go
+++ b/core/vm/instructions.go
@@ -706,10 +706,23 @@ func makeLog(size int) executionFunc {
}
// make push instruction function
-func makePush(size uint64, bsize *big.Int) executionFunc {
+func makePush(size uint64, pushByteSize int) executionFunc {
return func(pc *uint64, evm *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
- byts := getData(contract.Code, evm.interpreter.intPool.get().SetUint64(*pc+1), bsize)
- stack.push(new(big.Int).SetBytes(byts))
+ codeLen := len(contract.Code)
+
+ startMin := codeLen
+ if int(*pc+1) < startMin {
+ startMin = int(*pc + 1)
+ }
+
+ endMin := codeLen
+ if startMin+pushByteSize < endMin {
+ endMin = startMin + pushByteSize
+ }
+
+ integer := evm.interpreter.intPool.get()
+ stack.push(integer.SetBytes(common.RightPadBytes(contract.Code[startMin:endMin], pushByteSize)))
+
*pc += size
return nil, nil
}