Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
468501cb
Commit
468501cb
authored
Jun 10, 2015
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core/vm: changed program counter to uint64
parent
7e58949c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
13 deletions
+13
-13
context.go
core/vm/context.go
+4
-4
vm.go
core/vm/vm.go
+9
-9
No files found.
core/vm/context.go
View file @
468501cb
...
...
@@ -49,13 +49,13 @@ func NewContext(caller ContextRef, object ContextRef, value, gas, price *big.Int
return
c
}
func
(
c
*
Context
)
GetOp
(
n
*
big
.
Int
)
OpCode
{
func
(
c
*
Context
)
GetOp
(
n
uint64
)
OpCode
{
return
OpCode
(
c
.
GetByte
(
n
))
}
func
(
c
*
Context
)
GetByte
(
n
*
big
.
Int
)
byte
{
if
n
.
Cmp
(
big
.
NewInt
(
int64
(
len
(
c
.
Code
))))
<
0
{
return
c
.
Code
[
n
.
Int64
()
]
func
(
c
*
Context
)
GetByte
(
n
uint64
)
byte
{
if
n
<
uint64
(
len
(
c
.
Code
))
{
return
c
.
Code
[
n
]
}
return
0
...
...
core/vm/vm.go
View file @
468501cb
...
...
@@ -81,17 +81,17 @@ func (self *Vm) Run(context *Context, callData []byte) (ret []byte, err error) {
codehash
=
crypto
.
Sha3Hash
(
code
)
mem
=
NewMemory
()
stack
=
newStack
()
pc
=
new
(
big
.
Int
)
pc
=
uint64
(
0
)
statedb
=
self
.
env
.
State
()
jump
=
func
(
from
*
big
.
Int
,
to
*
big
.
Int
)
error
{
jump
=
func
(
from
uint64
,
to
*
big
.
Int
)
error
{
if
!
context
.
jumpdests
.
has
(
codehash
,
code
,
to
)
{
nop
:=
context
.
GetOp
(
to
)
nop
:=
context
.
GetOp
(
to
.
Uint64
()
)
return
fmt
.
Errorf
(
"invalid jump destination (%v) %v"
,
nop
,
to
)
}
self
.
Printf
(
" ~> %v"
,
to
)
pc
=
to
pc
=
to
.
Uint64
()
self
.
Endl
()
...
...
@@ -519,11 +519,11 @@ func (self *Vm) Run(context *Context, callData []byte) (ret []byte, err error) {
stack
.
push
(
self
.
env
.
GasLimit
())
case
PUSH1
,
PUSH2
,
PUSH3
,
PUSH4
,
PUSH5
,
PUSH6
,
PUSH7
,
PUSH8
,
PUSH9
,
PUSH10
,
PUSH11
,
PUSH12
,
PUSH13
,
PUSH14
,
PUSH15
,
PUSH16
,
PUSH17
,
PUSH18
,
PUSH19
,
PUSH20
,
PUSH21
,
PUSH22
,
PUSH23
,
PUSH24
,
PUSH25
,
PUSH26
,
PUSH27
,
PUSH28
,
PUSH29
,
PUSH30
,
PUSH31
,
PUSH32
:
a
:=
big
.
NewInt
(
int64
(
op
-
PUSH1
+
1
)
)
byts
:=
getData
(
code
,
new
(
big
.
Int
)
.
Add
(
pc
,
big
.
NewInt
(
1
)),
a
)
size
:=
uint64
(
op
-
PUSH1
+
1
)
byts
:=
getData
(
code
,
new
(
big
.
Int
)
.
SetUint64
(
pc
+
1
),
new
(
big
.
Int
)
.
SetUint64
(
size
)
)
// push value to stack
stack
.
push
(
common
.
Bytes2Big
(
byts
))
pc
.
Add
(
pc
,
a
)
pc
+=
size
self
.
Printf
(
" => 0x%x"
,
byts
)
case
POP
:
...
...
@@ -603,7 +603,7 @@ func (self *Vm) Run(context *Context, callData []byte) (ret []byte, err error) {
case
JUMPDEST
:
case
PC
:
stack
.
push
(
pc
)
stack
.
push
(
new
(
big
.
Int
)
.
SetUint64
(
pc
)
)
case
MSIZE
:
stack
.
push
(
big
.
NewInt
(
int64
(
mem
.
Len
())))
case
GAS
:
...
...
@@ -708,7 +708,7 @@ func (self *Vm) Run(context *Context, callData []byte) (ret []byte, err error) {
return
nil
,
fmt
.
Errorf
(
"Invalid opcode %x"
,
op
)
}
pc
.
Add
(
pc
,
One
)
pc
++
self
.
Endl
()
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment