good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
bor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open
bor
Commits
2b3c55f2
Commit
2b3c55f2
authored
Mar 3, 2015
by
Jeffrey Wilcke
Browse files
Options
Downloads
Plain Diff
Merge pull request #413 from chfast/pr/jit_build_fixes
JIT build fixes
parents
827ea434
e72173dc
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
vm/vm_jit.go
+12
-13
12 additions, 13 deletions
vm/vm_jit.go
with
12 additions
and
13 deletions
vm/vm_jit.go
+
12
−
13
View file @
2b3c55f2
...
@@ -50,6 +50,7 @@ type RuntimeData struct {
...
@@ -50,6 +50,7 @@ type RuntimeData struct {
timestamp
int64
timestamp
int64
code
*
byte
code
*
byte
codeSize
uint64
codeSize
uint64
codeHash
i256
}
}
func
hash2llvm
(
h
[]
byte
)
i256
{
func
hash2llvm
(
h
[]
byte
)
i256
{
...
@@ -180,6 +181,7 @@ func (self *JitVm) Run(me, caller ContextRef, code []byte, value, gas, price *bi
...
@@ -180,6 +181,7 @@ func (self *JitVm) Run(me, caller ContextRef, code []byte, value, gas, price *bi
self
.
data
.
timestamp
=
self
.
env
.
Time
()
self
.
data
.
timestamp
=
self
.
env
.
Time
()
self
.
data
.
code
=
getDataPtr
(
code
)
self
.
data
.
code
=
getDataPtr
(
code
)
self
.
data
.
codeSize
=
uint64
(
len
(
code
))
self
.
data
.
codeSize
=
uint64
(
len
(
code
))
self
.
data
.
codeHash
=
hash2llvm
(
crypto
.
Sha3
(
code
))
// TODO: Get already computed hash?
jit
:=
C
.
evmjit_create
()
jit
:=
C
.
evmjit_create
()
retCode
:=
C
.
evmjit_run
(
jit
,
unsafe
.
Pointer
(
&
self
.
data
),
unsafe
.
Pointer
(
self
))
retCode
:=
C
.
evmjit_run
(
jit
,
unsafe
.
Pointer
(
&
self
.
data
),
unsafe
.
Pointer
(
self
))
...
@@ -197,12 +199,12 @@ func (self *JitVm) Run(me, caller ContextRef, code []byte, value, gas, price *bi
...
@@ -197,12 +199,12 @@ func (self *JitVm) Run(me, caller ContextRef, code []byte, value, gas, price *bi
receiverAddr
:=
llvm2hashRef
(
bswap
(
&
self
.
data
.
address
))
receiverAddr
:=
llvm2hashRef
(
bswap
(
&
self
.
data
.
address
))
receiver
:=
state
.
GetOrNewStateObject
(
receiverAddr
)
receiver
:=
state
.
GetOrNewStateObject
(
receiverAddr
)
balance
:=
state
.
GetBalance
(
me
.
Address
())
balance
:=
state
.
GetBalance
(
me
.
Address
())
receiver
.
Add
Amount
(
balance
)
receiver
.
Add
Balance
(
balance
)
state
.
Delete
(
me
.
Address
())
state
.
Delete
(
me
.
Address
())
}
}
}
}
C
.
evmjit_destroy
(
jit
)
;
C
.
evmjit_destroy
(
jit
)
return
return
}
}
...
@@ -278,7 +280,7 @@ func env_blockhash(_vm unsafe.Pointer, _number unsafe.Pointer, _result unsafe.Po
...
@@ -278,7 +280,7 @@ func env_blockhash(_vm unsafe.Pointer, _number unsafe.Pointer, _result unsafe.Po
}
}
//export env_call
//export env_call
func
env_call
(
_vm
unsafe
.
Pointer
,
_gas
unsafe
.
Po
int
er
,
_receiveAddr
unsafe
.
Pointer
,
_value
unsafe
.
Pointer
,
inDataPtr
unsafe
.
Pointer
,
inDataLen
uint64
,
outDataPtr
*
byte
,
outDataLen
uint64
,
_codeAddr
unsafe
.
Pointer
)
bool
{
func
env_call
(
_vm
unsafe
.
Pointer
,
_gas
*
int
64
,
_receiveAddr
unsafe
.
Pointer
,
_value
unsafe
.
Pointer
,
inDataPtr
unsafe
.
Pointer
,
inDataLen
uint64
,
outDataPtr
*
byte
,
outDataLen
uint64
,
_codeAddr
unsafe
.
Pointer
)
bool
{
vm
:=
(
*
JitVm
)(
_vm
)
vm
:=
(
*
JitVm
)(
_vm
)
//fmt.Printf("env_call (depth %d)\n", vm.Env().Depth())
//fmt.Printf("env_call (depth %d)\n", vm.Env().Depth())
...
@@ -297,8 +299,7 @@ func env_call(_vm unsafe.Pointer, _gas unsafe.Pointer, _receiveAddr unsafe.Point
...
@@ -297,8 +299,7 @@ func env_call(_vm unsafe.Pointer, _gas unsafe.Pointer, _receiveAddr unsafe.Point
inData
:=
C
.
GoBytes
(
inDataPtr
,
C
.
int
(
inDataLen
))
inData
:=
C
.
GoBytes
(
inDataPtr
,
C
.
int
(
inDataLen
))
outData
:=
llvm2bytesRef
(
outDataPtr
,
outDataLen
)
outData
:=
llvm2bytesRef
(
outDataPtr
,
outDataLen
)
codeAddr
:=
llvm2hash
((
*
i256
)(
_codeAddr
))
codeAddr
:=
llvm2hash
((
*
i256
)(
_codeAddr
))
llvmGas
:=
(
*
i256
)(
_gas
)
gas
:=
big
.
NewInt
(
*
_gas
)
gas
:=
llvm2big
(
llvmGas
)
var
out
[]
byte
var
out
[]
byte
var
err
error
var
err
error
if
bytes
.
Equal
(
codeAddr
,
receiveAddr
)
{
if
bytes
.
Equal
(
codeAddr
,
receiveAddr
)
{
...
@@ -306,7 +307,7 @@ func env_call(_vm unsafe.Pointer, _gas unsafe.Pointer, _receiveAddr unsafe.Point
...
@@ -306,7 +307,7 @@ func env_call(_vm unsafe.Pointer, _gas unsafe.Pointer, _receiveAddr unsafe.Point
}
else
{
}
else
{
out
,
err
=
vm
.
env
.
CallCode
(
vm
.
me
,
codeAddr
,
inData
,
gas
,
vm
.
price
,
value
)
out
,
err
=
vm
.
env
.
CallCode
(
vm
.
me
,
codeAddr
,
inData
,
gas
,
vm
.
price
,
value
)
}
}
*
llvmGas
=
big2llvm
(
gas
)
*
_gas
=
gas
.
Int64
(
)
if
err
==
nil
{
if
err
==
nil
{
copy
(
outData
,
out
)
copy
(
outData
,
out
)
return
true
return
true
...
@@ -317,7 +318,7 @@ func env_call(_vm unsafe.Pointer, _gas unsafe.Pointer, _receiveAddr unsafe.Point
...
@@ -317,7 +318,7 @@ func env_call(_vm unsafe.Pointer, _gas unsafe.Pointer, _receiveAddr unsafe.Point
}
}
//export env_create
//export env_create
func
env_create
(
_vm
unsafe
.
Pointer
,
_gas
unsafe
.
Po
int
er
,
_value
unsafe
.
Pointer
,
initDataPtr
unsafe
.
Pointer
,
initDataLen
uint64
,
_result
unsafe
.
Pointer
)
{
func
env_create
(
_vm
unsafe
.
Pointer
,
_gas
*
int
64
,
_value
unsafe
.
Pointer
,
initDataPtr
unsafe
.
Pointer
,
initDataLen
uint64
,
_result
unsafe
.
Pointer
)
{
vm
:=
(
*
JitVm
)(
_vm
)
vm
:=
(
*
JitVm
)(
_vm
)
value
:=
llvm2big
((
*
i256
)(
_value
))
value
:=
llvm2big
((
*
i256
)(
_value
))
...
@@ -325,9 +326,7 @@ func env_create(_vm unsafe.Pointer, _gas unsafe.Pointer, _value unsafe.Pointer,
...
@@ -325,9 +326,7 @@ func env_create(_vm unsafe.Pointer, _gas unsafe.Pointer, _value unsafe.Pointer,
result
:=
(
*
i256
)(
_result
)
result
:=
(
*
i256
)(
_result
)
*
result
=
i256
{}
*
result
=
i256
{}
llvmGas
:=
(
*
i256
)(
_gas
)
gas
:=
big
.
NewInt
(
*
_gas
)
gas
:=
llvm2big
(
llvmGas
)
ret
,
suberr
,
ref
:=
vm
.
env
.
Create
(
vm
.
me
,
nil
,
initData
,
gas
,
vm
.
price
,
value
)
ret
,
suberr
,
ref
:=
vm
.
env
.
Create
(
vm
.
me
,
nil
,
initData
,
gas
,
vm
.
price
,
value
)
if
suberr
==
nil
{
if
suberr
==
nil
{
dataGas
:=
big
.
NewInt
(
int64
(
len
(
ret
)))
// TODO: Nto the best design. env.Create can do it, it has the reference to gas counter
dataGas
:=
big
.
NewInt
(
int64
(
len
(
ret
)))
// TODO: Nto the best design. env.Create can do it, it has the reference to gas counter
...
@@ -335,7 +334,7 @@ func env_create(_vm unsafe.Pointer, _gas unsafe.Pointer, _value unsafe.Pointer,
...
@@ -335,7 +334,7 @@ func env_create(_vm unsafe.Pointer, _gas unsafe.Pointer, _value unsafe.Pointer,
gas
.
Sub
(
gas
,
dataGas
)
gas
.
Sub
(
gas
,
dataGas
)
*
result
=
hash2llvm
(
ref
.
Address
())
*
result
=
hash2llvm
(
ref
.
Address
())
}
}
*
llvmGas
=
big2llvm
(
gas
)
*
_gas
=
gas
.
Int64
(
)
}
}
//export env_log
//export env_log
...
@@ -358,7 +357,7 @@ func env_log(_vm unsafe.Pointer, dataPtr unsafe.Pointer, dataLen uint64, _topic1
...
@@ -358,7 +357,7 @@ func env_log(_vm unsafe.Pointer, dataPtr unsafe.Pointer, dataLen uint64, _topic1
topics
=
append
(
topics
,
llvm2hash
((
*
i256
)(
_topic4
)))
topics
=
append
(
topics
,
llvm2hash
((
*
i256
)(
_topic4
)))
}
}
vm
.
Env
()
.
AddLog
(
state
.
NewLog
(
vm
.
me
.
Address
(),
topics
,
data
))
vm
.
Env
()
.
AddLog
(
state
.
NewLog
(
vm
.
me
.
Address
(),
topics
,
data
,
vm
.
env
.
BlockNumber
()
.
Uint64
()
))
}
}
//export env_extcode
//export env_extcode
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment