mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-21 20:26:41 +00:00
go fmt
This commit is contained in:
parent
9f93253f63
commit
ed0f8d1d93
1 changed files with 45 additions and 45 deletions
58
vm/vm_jit.go
58
vm/vm_jit.go
|
|
@ -20,42 +20,42 @@ import "errors"
|
|||
|
||||
type JitVm struct {
|
||||
env Environment
|
||||
me ContextRef
|
||||
me ContextRef
|
||||
}
|
||||
|
||||
type i256 [32]byte
|
||||
|
||||
const (
|
||||
Gas = iota
|
||||
address
|
||||
Caller
|
||||
Origin
|
||||
CallValue
|
||||
CallDataSize
|
||||
GasPrice
|
||||
CoinBase
|
||||
TimeStamp
|
||||
Number
|
||||
Difficulty
|
||||
GasLimit
|
||||
CodeSize
|
||||
Gas = iota
|
||||
address
|
||||
Caller
|
||||
Origin
|
||||
CallValue
|
||||
CallDataSize
|
||||
GasPrice
|
||||
CoinBase
|
||||
TimeStamp
|
||||
Number
|
||||
Difficulty
|
||||
GasLimit
|
||||
CodeSize
|
||||
|
||||
_size
|
||||
_size
|
||||
|
||||
ReturnDataOffset = CallValue // Reuse 2 fields for return data reference
|
||||
ReturnDataSize = CallDataSize
|
||||
SuicideDestAddress = address ///< Suicide balance destination address
|
||||
ReturnDataOffset = CallValue // Reuse 2 fields for return data reference
|
||||
ReturnDataSize = CallDataSize
|
||||
SuicideDestAddress = address ///< Suicide balance destination address
|
||||
)
|
||||
|
||||
type RuntimeData struct {
|
||||
elems [_size]i256
|
||||
elems [_size]i256
|
||||
callData *byte
|
||||
code *byte
|
||||
code *byte
|
||||
}
|
||||
|
||||
func hash2llvm(h []byte) i256 {
|
||||
var m i256
|
||||
copy(m[len(m) - len(h):], h) // right aligned copy
|
||||
copy(m[len(m)-len(h):], h) // right aligned copy
|
||||
return m
|
||||
}
|
||||
|
||||
|
|
@ -70,8 +70,8 @@ func llvm2hash(m *i256) []byte { //TODO: It should copy data
|
|||
|
||||
func big2llvm(n *big.Int) i256 {
|
||||
m := hash2llvm(n.Bytes())
|
||||
for i, l := 0, len(m); i < l / 2; i++ {
|
||||
m[i], m[l - i - 1] = m[l - i - 1], m[i]
|
||||
for i, l := 0, len(m); i < l/2; i++ {
|
||||
m[i], m[l-i-1] = m[l-i-1], m[i]
|
||||
}
|
||||
|
||||
return m
|
||||
|
|
@ -81,7 +81,7 @@ func llvm2big(m *i256) *big.Int {
|
|||
n := big.NewInt(0)
|
||||
for i := 0; i < len(m); i++ {
|
||||
b := big.NewInt(int64(m[i]))
|
||||
b.Lsh(b, uint(i) * 8)
|
||||
b.Lsh(b, uint(i)*8)
|
||||
n.Add(n, b)
|
||||
}
|
||||
return n
|
||||
|
|
@ -123,8 +123,8 @@ func (self *JitVm) Run(me, caller ContextRef, code []byte, value, gas, price *bi
|
|||
data.code = &code[0]
|
||||
}
|
||||
|
||||
r := C.evmjit_run(unsafe.Pointer(&data), unsafe.Pointer(self));
|
||||
fmt.Printf("JIT result: %d\n", r);
|
||||
r := C.evmjit_run(unsafe.Pointer(&data), unsafe.Pointer(self))
|
||||
fmt.Printf("JIT result: %d\n", r)
|
||||
|
||||
if r >= 100 {
|
||||
err = errors.New("OOG from JIT")
|
||||
|
|
@ -148,7 +148,7 @@ func (self *JitVm) Env() Environment {
|
|||
//export env_sha3
|
||||
func env_sha3(dataPtr *byte, length uint64, hashPtr unsafe.Pointer) {
|
||||
data := llvm2bytes(dataPtr, length)
|
||||
hash := crypto.Sha3(data);
|
||||
hash := crypto.Sha3(data)
|
||||
|
||||
hashHdr := reflect.SliceHeader{
|
||||
Data: uintptr(hashPtr),
|
||||
|
|
@ -219,7 +219,7 @@ func env_call(_vm unsafe.Pointer, _gas unsafe.Pointer, _receiveAddr unsafe.Point
|
|||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return false
|
||||
}
|
||||
|
||||
//export env_create
|
||||
|
|
@ -245,7 +245,7 @@ func env_create(_vm unsafe.Pointer, _gas unsafe.Pointer, _value unsafe.Pointer,
|
|||
}
|
||||
|
||||
//export env_log
|
||||
func env_log(_vm unsafe.Pointer, dataPtr *byte, dataLen uint64, _topic1 unsafe.Pointer, _topic2 unsafe.Pointer, _topic3 unsafe.Pointer, _topic4 unsafe.Pointer) {
|
||||
func env_log(_vm unsafe.Pointer, dataPtr *byte, dataLen uint64, _topic1 unsafe.Pointer, _topic2 unsafe.Pointer, _topic3 unsafe.Pointer, _topic4 unsafe.Pointer) {
|
||||
vm := (*JitVm)(_vm)
|
||||
|
||||
dataRef := llvm2bytes(dataPtr, dataLen)
|
||||
|
|
|
|||
Loading…
Reference in a new issue