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
508891e6
Unverified
Commit
508891e6
authored
4 years ago
by
Péter Szilágyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core/vm: use pointers to operations vs. copy by value
parent
9e88224e
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
165 deletions
+19
-165
eips.go
core/vm/eips.go
+5
-10
interpreter.go
core/vm/interpreter.go
+3
-3
jump_table.go
core/vm/jump_table.go
+11
-152
No files found.
core/vm/eips.go
View file @
508891e6
...
...
@@ -68,12 +68,11 @@ func enable1884(jt *JumpTable) {
jt
[
EXTCODEHASH
]
.
constantGas
=
params
.
ExtcodeHashGasEIP1884
// New opcode
jt
[
SELFBALANCE
]
=
operation
{
jt
[
SELFBALANCE
]
=
&
operation
{
execute
:
opSelfBalance
,
constantGas
:
GasFastStep
,
minStack
:
minStack
(
0
,
1
),
maxStack
:
maxStack
(
0
,
1
),
valid
:
true
,
}
}
...
...
@@ -87,12 +86,11 @@ func opSelfBalance(pc *uint64, interpreter *EVMInterpreter, callContext *callCtx
// - Adds an opcode that returns the current chain’s EIP-155 unique identifier
func
enable1344
(
jt
*
JumpTable
)
{
// New opcode
jt
[
CHAINID
]
=
operation
{
jt
[
CHAINID
]
=
&
operation
{
execute
:
opChainID
,
constantGas
:
GasQuickStep
,
minStack
:
minStack
(
0
,
1
),
maxStack
:
maxStack
(
0
,
1
),
valid
:
true
,
}
}
...
...
@@ -113,29 +111,26 @@ func enable2200(jt *JumpTable) {
// - Adds opcodes that jump to and return from subroutines
func
enable2315
(
jt
*
JumpTable
)
{
// New opcode
jt
[
BEGINSUB
]
=
operation
{
jt
[
BEGINSUB
]
=
&
operation
{
execute
:
opBeginSub
,
constantGas
:
GasQuickStep
,
minStack
:
minStack
(
0
,
0
),
maxStack
:
maxStack
(
0
,
0
),
valid
:
true
,
}
// New opcode
jt
[
JUMPSUB
]
=
operation
{
jt
[
JUMPSUB
]
=
&
operation
{
execute
:
opJumpSub
,
constantGas
:
GasSlowStep
,
minStack
:
minStack
(
1
,
0
),
maxStack
:
maxStack
(
1
,
0
),
jumps
:
true
,
valid
:
true
,
}
// New opcode
jt
[
RETURNSUB
]
=
operation
{
jt
[
RETURNSUB
]
=
&
operation
{
execute
:
opReturnSub
,
constantGas
:
GasFastStep
,
minStack
:
minStack
(
0
,
0
),
maxStack
:
maxStack
(
0
,
0
),
valid
:
true
,
jumps
:
true
,
}
}
This diff is collapsed.
Click to expand it.
core/vm/interpreter.go
View file @
508891e6
...
...
@@ -32,7 +32,7 @@ type Config struct {
NoRecursion
bool
// Disables call, callcode, delegate call and create
EnablePreimageRecording
bool
// Enables recording of SHA3/keccak preimages
JumpTable
[
256
]
operation
// EVM instruction table, automatically populated if unset
JumpTable
[
256
]
*
operation
// EVM instruction table, automatically populated if unset
EWASMInterpreter
string
// External EWASM interpreter options
EVMInterpreter
string
// External EVM interpreter options
...
...
@@ -96,7 +96,7 @@ func NewEVMInterpreter(evm *EVM, cfg Config) *EVMInterpreter {
// We use the STOP instruction whether to see
// the jump table was initialised. If it was not
// we'll set the default jump table.
if
!
cfg
.
JumpTable
[
STOP
]
.
valid
{
if
cfg
.
JumpTable
[
STOP
]
==
nil
{
var
jt
JumpTable
switch
{
case
evm
.
chainRules
.
IsYoloV1
:
...
...
@@ -221,7 +221,7 @@ func (in *EVMInterpreter) Run(contract *Contract, input []byte, readOnly bool) (
// enough stack items available to perform the operation.
op
=
contract
.
GetOp
(
pc
)
operation
:=
in
.
cfg
.
JumpTable
[
op
]
if
!
operation
.
valid
{
if
operation
==
nil
{
return
nil
,
&
ErrInvalidOpCode
{
opcode
:
op
}
}
// Validate stack
...
...
This diff is collapsed.
Click to expand it.
core/vm/jump_table.go
View file @
508891e6
This diff is collapsed.
Click to expand it.
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