Update JitVm to new EVM JIT ABI (C interface)
This commit is contained in:
parent
c71aff99db
commit
079c59b929
28
vm/vm_jit.go
28
vm/vm_jit.go
|
@ -3,17 +3,10 @@
|
||||||
package vm
|
package vm
|
||||||
|
|
||||||
/*
|
/*
|
||||||
#include <stdint.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
struct evmjit_result
|
void* evmjit_create();
|
||||||
{
|
int evmjit_run(void* _jit, void* _data, void* _env);
|
||||||
int32_t returnCode;
|
void evmjit_destroy(void* _jit);
|
||||||
uint64_t returnDataSize;
|
|
||||||
void* returnData;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct evmjit_result evmjit_run(void* _data, void* _env);
|
|
||||||
|
|
||||||
// Shared library evmjit (e.g. libevmjit.so) is expected to be installed in /usr/local/lib
|
// Shared library evmjit (e.g. libevmjit.so) is expected to be installed in /usr/local/lib
|
||||||
// More: https://github.com/ethereum/evmjit
|
// 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.code = getDataPtr(code)
|
||||||
self.data.codeSize = uint64(len(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")
|
err = errors.New("OOG from JIT")
|
||||||
gas.SetInt64(0) // Set gas to 0, JIT does not bother
|
gas.SetInt64(0) // Set gas to 0, JIT does not bother
|
||||||
} else {
|
} else {
|
||||||
gas.SetInt64(self.data.gas)
|
gas.SetInt64(self.data.gas)
|
||||||
if result.returnCode == 1 { // RETURN
|
if retCode == 1 { // RETURN
|
||||||
ret = C.GoBytes(result.returnData, C.int(result.returnDataSize))
|
ret = C.GoBytes(unsafe.Pointer(self.data.callData), C.int(self.data.callDataSize))
|
||||||
C.free(result.returnData)
|
} else if retCode == 2 { // SUICIDE
|
||||||
} else if result.returnCode == 2 { // SUICIDE
|
|
||||||
// TODO: Suicide support logic should be moved to Env to be shared by VM implementations
|
// TODO: Suicide support logic should be moved to Env to be shared by VM implementations
|
||||||
state := self.Env().State()
|
state := self.Env().State()
|
||||||
receiverAddr := llvm2hashRef(bswap(&self.data.address))
|
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())
|
state.Delete(me.Address())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
C.evmjit_destroy(jit);
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue