aboutsummaryrefslogtreecommitdiffstats
path: root/vm
diff options
context:
space:
mode:
authorPaweł Bylica <pawel.bylica@imapp.pl>2015-01-27 01:02:09 +0800
committerPaweł Bylica <pawel.bylica@imapp.pl>2015-01-27 01:02:09 +0800
commit079c59b929d5e09eebad6169c22f146bd2f060af (patch)
tree93b3825d1c34d0c39ba92ed991921457898cac7d /vm
parentc71aff99dbb45d5998049604109457aa34ecf573 (diff)
downloadgo-tangerine-079c59b929d5e09eebad6169c22f146bd2f060af.tar
go-tangerine-079c59b929d5e09eebad6169c22f146bd2f060af.tar.gz
go-tangerine-079c59b929d5e09eebad6169c22f146bd2f060af.tar.bz2
go-tangerine-079c59b929d5e09eebad6169c22f146bd2f060af.tar.lz
go-tangerine-079c59b929d5e09eebad6169c22f146bd2f060af.tar.xz
go-tangerine-079c59b929d5e09eebad6169c22f146bd2f060af.tar.zst
go-tangerine-079c59b929d5e09eebad6169c22f146bd2f060af.zip
Update JitVm to new EVM JIT ABI (C interface)
Diffstat (limited to 'vm')
-rw-r--r--vm/vm_jit.go28
1 files changed, 11 insertions, 17 deletions
diff --git a/vm/vm_jit.go b/vm/vm_jit.go
index 4c0988df9..38cab57da 100644
--- a/vm/vm_jit.go
+++ b/vm/vm_jit.go
@@ -3,17 +3,10 @@
package vm
/*
-#include <stdint.h>
-#include <stdlib.h>
-struct evmjit_result
-{
- int32_t returnCode;
- uint64_t returnDataSize;
- void* returnData;
-};
-
-struct evmjit_result evmjit_run(void* _data, void* _env);
+void* evmjit_create();
+int evmjit_run(void* _jit, void* _data, void* _env);
+void evmjit_destroy(void* _jit);
// Shared library evmjit (e.g. libevmjit.so) is expected to be installed in /usr/local/lib
// More: https://github.com/ethereum/evmjit
@@ -188,17 +181,17 @@ func (self *JitVm) Run(me, caller ContextRef, code []byte, value, gas, price *bi
self.data.code = getDataPtr(code)
self.data.codeSize = uint64(len(code))
- result := C.evmjit_run(unsafe.Pointer(&self.data), unsafe.Pointer(self))
+ jit := C.evmjit_create()
+ retCode := C.evmjit_run(jit, unsafe.Pointer(&self.data), unsafe.Pointer(self))
- if result.returnCode >= 100 {
+ if retCode < 0 {
err = errors.New("OOG from JIT")
gas.SetInt64(0) // Set gas to 0, JIT does not bother
} else {
gas.SetInt64(self.data.gas)
- if result.returnCode == 1 { // RETURN
- ret = C.GoBytes(result.returnData, C.int(result.returnDataSize))
- C.free(result.returnData)
- } else if result.returnCode == 2 { // SUICIDE
+ if retCode == 1 { // RETURN
+ ret = C.GoBytes(unsafe.Pointer(self.data.callData), C.int(self.data.callDataSize))
+ } else if retCode == 2 { // SUICIDE
// TODO: Suicide support logic should be moved to Env to be shared by VM implementations
state := self.Env().State()
receiverAddr := llvm2hashRef(bswap(&self.data.address))
@@ -208,7 +201,8 @@ func (self *JitVm) Run(me, caller ContextRef, code []byte, value, gas, price *bi
state.Delete(me.Address())
}
}
-
+
+ C.evmjit_destroy(jit);
return
}