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
fc2a061d
Commit
fc2a061d
authored
Jun 10, 2015
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core/vm: unexported stack again. No longer required
parent
065aff9f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
16 deletions
+16
-16
gas.go
core/vm/gas.go
+1
-1
stack.go
core/vm/stack.go
+12
-12
vm.go
core/vm/vm.go
+3
-3
No files found.
core/vm/gas.go
View file @
fc2a061d
...
...
@@ -21,7 +21,7 @@ var (
GasContractByte
=
big
.
NewInt
(
200
)
)
func
baseCheck
(
op
OpCode
,
stack
*
S
tack
,
gas
*
big
.
Int
)
error
{
func
baseCheck
(
op
OpCode
,
stack
*
s
tack
,
gas
*
big
.
Int
)
error
{
// PUSH and DUP are a bit special. They all cost the same but we do want to have checking on stack push limit
// PUSH is also allowed to calculate the same price for all PUSHes
// DUP requirements are handled elsewhere (except for the stack limit check)
...
...
core/vm/stack.go
View file @
fc2a061d
...
...
@@ -5,20 +5,20 @@ import (
"math/big"
)
func
new
Stack
()
*
S
tack
{
return
&
S
tack
{}
func
new
stack
()
*
s
tack
{
return
&
s
tack
{}
}
type
S
tack
struct
{
type
s
tack
struct
{
data
[]
*
big
.
Int
ptr
int
}
func
(
st
*
S
tack
)
Data
()
[]
*
big
.
Int
{
func
(
st
*
s
tack
)
Data
()
[]
*
big
.
Int
{
return
st
.
data
}
func
(
st
*
S
tack
)
push
(
d
*
big
.
Int
)
{
func
(
st
*
s
tack
)
push
(
d
*
big
.
Int
)
{
// NOTE push limit (1024) is checked in baseCheck
stackItem
:=
new
(
big
.
Int
)
.
Set
(
d
)
if
len
(
st
.
data
)
>
st
.
ptr
{
...
...
@@ -29,36 +29,36 @@ func (st *Stack) push(d *big.Int) {
st
.
ptr
++
}
func
(
st
*
S
tack
)
pop
()
(
ret
*
big
.
Int
)
{
func
(
st
*
s
tack
)
pop
()
(
ret
*
big
.
Int
)
{
st
.
ptr
--
ret
=
st
.
data
[
st
.
ptr
]
return
}
func
(
st
*
S
tack
)
len
()
int
{
func
(
st
*
s
tack
)
len
()
int
{
return
st
.
ptr
}
func
(
st
*
S
tack
)
swap
(
n
int
)
{
func
(
st
*
s
tack
)
swap
(
n
int
)
{
st
.
data
[
st
.
len
()
-
n
],
st
.
data
[
st
.
len
()
-
1
]
=
st
.
data
[
st
.
len
()
-
1
],
st
.
data
[
st
.
len
()
-
n
]
}
func
(
st
*
S
tack
)
dup
(
n
int
)
{
func
(
st
*
s
tack
)
dup
(
n
int
)
{
st
.
push
(
st
.
data
[
st
.
len
()
-
n
])
}
func
(
st
*
S
tack
)
peek
()
*
big
.
Int
{
func
(
st
*
s
tack
)
peek
()
*
big
.
Int
{
return
st
.
data
[
st
.
len
()
-
1
]
}
func
(
st
*
S
tack
)
require
(
n
int
)
error
{
func
(
st
*
s
tack
)
require
(
n
int
)
error
{
if
st
.
len
()
<
n
{
return
fmt
.
Errorf
(
"stack underflow (%d <=> %d)"
,
len
(
st
.
data
),
n
)
}
return
nil
}
func
(
st
*
S
tack
)
Print
()
{
func
(
st
*
s
tack
)
Print
()
{
fmt
.
Println
(
"### stack ###"
)
if
len
(
st
.
data
)
>
0
{
for
i
,
val
:=
range
st
.
data
{
...
...
core/vm/vm.go
View file @
fc2a061d
...
...
@@ -75,7 +75,7 @@ func (self *Vm) Run(context *Context, input []byte) (ret []byte, err error) {
op
OpCode
// current opcode
codehash
=
crypto
.
Sha3Hash
(
code
)
// codehash is used when doing jump dest caching
mem
=
NewMemory
()
// bound memory
stack
=
new
S
tack
()
// local stack
stack
=
new
s
tack
()
// local stack
pc
=
uint64
(
0
)
// program counter
statedb
=
self
.
env
.
State
()
// current state
...
...
@@ -632,7 +632,7 @@ func (self *Vm) Run(context *Context, input []byte) (ret []byte, err error) {
// calculateGasAndSize calculates the required given the opcode and stack items calculates the new memorysize for
// the operation. This does not reduce gas or resizes the memory.
func
(
self
*
Vm
)
calculateGasAndSize
(
context
*
Context
,
caller
ContextRef
,
op
OpCode
,
statedb
*
state
.
StateDB
,
mem
*
Memory
,
stack
*
S
tack
)
(
*
big
.
Int
,
*
big
.
Int
,
error
)
{
func
(
self
*
Vm
)
calculateGasAndSize
(
context
*
Context
,
caller
ContextRef
,
op
OpCode
,
statedb
*
state
.
StateDB
,
mem
*
Memory
,
stack
*
s
tack
)
(
*
big
.
Int
,
*
big
.
Int
,
error
)
{
var
(
gas
=
new
(
big
.
Int
)
newMemSize
*
big
.
Int
=
new
(
big
.
Int
)
...
...
@@ -789,7 +789,7 @@ func (self *Vm) RunPrecompiled(p *PrecompiledAccount, input []byte, context *Con
// log emits a log event to the environment for each opcode encountered. This is not to be confused with the
// LOG* opcode.
func
(
self
*
Vm
)
log
(
pc
uint64
,
op
OpCode
,
gas
*
big
.
Int
,
memory
*
Memory
,
stack
*
S
tack
,
context
*
Context
)
{
func
(
self
*
Vm
)
log
(
pc
uint64
,
op
OpCode
,
gas
*
big
.
Int
,
memory
*
Memory
,
stack
*
s
tack
,
context
*
Context
)
{
if
Debug
{
mem
:=
make
([]
byte
,
len
(
memory
.
Data
()))
copy
(
mem
,
memory
.
Data
())
...
...
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