mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-21 20:26:41 +00:00
Remove backup VM from JitVm
This commit is contained in:
parent
2261660fc2
commit
9f93253f63
1 changed files with 10 additions and 7 deletions
17
vm/vm_jit.go
17
vm/vm_jit.go
|
|
@ -16,11 +16,11 @@ import "C"
|
||||||
import "unsafe"
|
import "unsafe"
|
||||||
import "fmt"
|
import "fmt"
|
||||||
import "reflect"
|
import "reflect"
|
||||||
|
import "errors"
|
||||||
|
|
||||||
type JitVm struct {
|
type JitVm struct {
|
||||||
env Environment
|
env Environment
|
||||||
me ContextRef
|
me ContextRef
|
||||||
backup *DebugVm
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type i256 [32]byte
|
type i256 [32]byte
|
||||||
|
|
@ -97,12 +97,11 @@ func llvm2bytes(data *byte, length uint64) []byte {
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewJitVm(env Environment) *JitVm {
|
func NewJitVm(env Environment) *JitVm {
|
||||||
backupVm := NewDebugVm(env)
|
return &JitVm{env: env}
|
||||||
return &JitVm{env: env, backup: backupVm}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *JitVm) Run(me, caller ContextRef, code []byte, value, gas, price *big.Int, callData []byte) (ret []byte, err error) {
|
func (self *JitVm) Run(me, caller ContextRef, code []byte, value, gas, price *big.Int, callData []byte) (ret []byte, err error) {
|
||||||
self.me = me
|
self.me = me // FIXME: Make sure Run() is not used more than once
|
||||||
|
|
||||||
var data RuntimeData
|
var data RuntimeData
|
||||||
data.elems[Gas] = big2llvm(gas)
|
data.elems[Gas] = big2llvm(gas)
|
||||||
|
|
@ -127,15 +126,19 @@ func (self *JitVm) Run(me, caller ContextRef, code []byte, value, gas, price *bi
|
||||||
r := C.evmjit_run(unsafe.Pointer(&data), unsafe.Pointer(self));
|
r := C.evmjit_run(unsafe.Pointer(&data), unsafe.Pointer(self));
|
||||||
fmt.Printf("JIT result: %d\n", r);
|
fmt.Printf("JIT result: %d\n", r);
|
||||||
|
|
||||||
return self.backup.Run(me, caller, code, value, gas, price, callData)
|
if r >= 100 {
|
||||||
|
err = errors.New("OOG from JIT")
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *JitVm) Printf(format string, v ...interface{}) VirtualMachine {
|
func (self *JitVm) Printf(format string, v ...interface{}) VirtualMachine {
|
||||||
return self.backup.Printf(format, v)
|
return self
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *JitVm) Endl() VirtualMachine {
|
func (self *JitVm) Endl() VirtualMachine {
|
||||||
return self.backup.Endl()
|
return self
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *JitVm) Env() Environment {
|
func (self *JitVm) Env() Environment {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue