aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorJeffrey Wilcke <jeffrey@ethereum.org>2015-05-20 18:06:04 +0800
committerJeffrey Wilcke <jeffrey@ethereum.org>2015-05-20 18:06:04 +0800
commit9bde7fd72e738865e6ed3208495f966f4f21daac (patch)
treec88a1f8e2f11f08086a6887a1fe9212e0ddff0fd /core
parent8fe8ec84f6a0cbc51d6018af7269952062279234 (diff)
parent9617aa8e19b660ead51c201b76c510ea079f40eb (diff)
downloaddexon-9bde7fd72e738865e6ed3208495f966f4f21daac.tar
dexon-9bde7fd72e738865e6ed3208495f966f4f21daac.tar.gz
dexon-9bde7fd72e738865e6ed3208495f966f4f21daac.tar.bz2
dexon-9bde7fd72e738865e6ed3208495f966f4f21daac.tar.lz
dexon-9bde7fd72e738865e6ed3208495f966f4f21daac.tar.xz
dexon-9bde7fd72e738865e6ed3208495f966f4f21daac.tar.zst
dexon-9bde7fd72e738865e6ed3208495f966f4f21daac.zip
Merge pull request #1043 from obscuren/test_fixes
core/vm: optimisation on RETURN and updated tests
Diffstat (limited to 'core')
-rw-r--r--core/vm/memory.go12
-rw-r--r--core/vm/vm.go2
2 files changed, 13 insertions, 1 deletions
diff --git a/core/vm/memory.go b/core/vm/memory.go
index b77d486eb..d20aa9591 100644
--- a/core/vm/memory.go
+++ b/core/vm/memory.go
@@ -49,6 +49,18 @@ func (self *Memory) Get(offset, size int64) (cpy []byte) {
return
}
+func (self *Memory) GetPtr(offset, size int64) []byte {
+ if size == 0 {
+ return nil
+ }
+
+ if len(self.store) > int(offset) {
+ return self.store[offset : offset+size]
+ }
+
+ return nil
+}
+
func (m *Memory) Len() int {
return len(m.store)
}
diff --git a/core/vm/vm.go b/core/vm/vm.go
index 927b67293..35fa19d03 100644
--- a/core/vm/vm.go
+++ b/core/vm/vm.go
@@ -695,7 +695,7 @@ func (self *Vm) Run(context *Context, callData []byte) (ret []byte, err error) {
self.Printf("resume %x (%v)", context.Address(), context.Gas)
case RETURN:
offset, size := stack.pop(), stack.pop()
- ret := mem.Get(offset.Int64(), size.Int64())
+ ret := mem.GetPtr(offset.Int64(), size.Int64())
self.Printf(" => [%v, %v] (%d) 0x%x", offset, size, len(ret), ret).Endl()