Commit 84c5db54 authored by hydai's avatar hydai Committed by Péter Szilágyi

core/vm: remove JIT VM codes (#16362)

parent 23ac7833
...@@ -17,19 +17,8 @@ ...@@ -17,19 +17,8 @@
/* /*
Package vm implements the Ethereum Virtual Machine. Package vm implements the Ethereum Virtual Machine.
The vm package implements two EVMs, a byte code VM and a JIT VM. The BC The vm package implements one EVM, a byte code VM. The BC (Byte Code) VM loops
(Byte Code) VM loops over a set of bytes and executes them according to the set over a set of bytes and executes them according to the set of rules defined
of rules defined in the Ethereum yellow paper. When the BC VM is invoked it in the Ethereum yellow paper.
invokes the JIT VM in a separate goroutine and compiles the byte code in JIT
instructions.
The JIT VM, when invoked, loops around a set of pre-defined instructions until
it either runs of gas, causes an internal error, returns or stops.
The JIT optimiser attempts to pre-compile instructions in to chunks or segments
such as multiple PUSH operations and static JUMPs. It does this by analysing the
opcodes and attempts to match certain regions to known sets. Whenever the
optimiser finds said segments it creates a new instruction and replaces the
first occurrence in the sequence.
*/ */
package vm package vm
...@@ -32,7 +32,7 @@ type twoOperandTest struct { ...@@ -32,7 +32,7 @@ type twoOperandTest struct {
func testTwoOperandOp(t *testing.T, tests []twoOperandTest, opFn func(pc *uint64, evm *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error)) { func testTwoOperandOp(t *testing.T, tests []twoOperandTest, opFn func(pc *uint64, evm *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error)) {
var ( var (
env = NewEVM(Context{}, nil, params.TestChainConfig, Config{EnableJit: false, ForceJit: false}) env = NewEVM(Context{}, nil, params.TestChainConfig, Config{})
stack = newstack() stack = newstack()
pc = uint64(0) pc = uint64(0)
) )
...@@ -68,7 +68,7 @@ func testTwoOperandOp(t *testing.T, tests []twoOperandTest, opFn func(pc *uint64 ...@@ -68,7 +68,7 @@ func testTwoOperandOp(t *testing.T, tests []twoOperandTest, opFn func(pc *uint64
func TestByteOp(t *testing.T) { func TestByteOp(t *testing.T) {
var ( var (
env = NewEVM(Context{}, nil, params.TestChainConfig, Config{EnableJit: false, ForceJit: false}) env = NewEVM(Context{}, nil, params.TestChainConfig, Config{})
stack = newstack() stack = newstack()
) )
tests := []struct { tests := []struct {
...@@ -198,7 +198,7 @@ func TestSLT(t *testing.T) { ...@@ -198,7 +198,7 @@ func TestSLT(t *testing.T) {
func opBenchmark(bench *testing.B, op func(pc *uint64, evm *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error), args ...string) { func opBenchmark(bench *testing.B, op func(pc *uint64, evm *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error), args ...string) {
var ( var (
env = NewEVM(Context{}, nil, params.TestChainConfig, Config{EnableJit: false, ForceJit: false}) env = NewEVM(Context{}, nil, params.TestChainConfig, Config{})
stack = newstack() stack = newstack()
) )
// convert args // convert args
......
...@@ -28,10 +28,6 @@ import ( ...@@ -28,10 +28,6 @@ import (
type Config struct { type Config struct {
// Debug enabled debugging Interpreter options // Debug enabled debugging Interpreter options
Debug bool Debug bool
// EnableJit enabled the JIT VM
EnableJit bool
// ForceJit forces the JIT VM
ForceJit bool
// Tracer is the op code logger // Tracer is the op code logger
Tracer Tracer Tracer Tracer
// NoRecursion disabled Interpreter call, callcode, // NoRecursion disabled Interpreter call, callcode,
...@@ -47,7 +43,7 @@ type Config struct { ...@@ -47,7 +43,7 @@ type Config struct {
// Interpreter is used to run Ethereum based contracts and will utilise the // Interpreter is used to run Ethereum based contracts and will utilise the
// passed evmironment to query external sources for state information. // passed evmironment to query external sources for state information.
// The Interpreter will run the byte code VM or JIT VM based on the passed // The Interpreter will run the byte code VM based on the passed
// configuration. // configuration.
type Interpreter struct { type Interpreter struct {
evm *EVM evm *EVM
......
...@@ -48,7 +48,7 @@ type dummyStateDB struct { ...@@ -48,7 +48,7 @@ type dummyStateDB struct {
func TestStoreCapture(t *testing.T) { func TestStoreCapture(t *testing.T) {
var ( var (
env = NewEVM(Context{}, nil, params.TestChainConfig, Config{EnableJit: false, ForceJit: false}) env = NewEVM(Context{}, nil, params.TestChainConfig, Config{})
logger = NewStructLogger(nil) logger = NewStructLogger(nil)
mem = NewMemory() mem = NewMemory()
stack = newstack() stack = newstack()
......
...@@ -41,7 +41,6 @@ type Config struct { ...@@ -41,7 +41,6 @@ type Config struct {
GasLimit uint64 GasLimit uint64
GasPrice *big.Int GasPrice *big.Int
Value *big.Int Value *big.Int
DisableJit bool // "disable" so it's enabled by default
Debug bool Debug bool
EVMConfig vm.Config EVMConfig vm.Config
...@@ -92,8 +91,7 @@ func setDefaults(cfg *Config) { ...@@ -92,8 +91,7 @@ func setDefaults(cfg *Config) {
// It returns the EVM's return value, the new state and an error if it failed. // It returns the EVM's return value, the new state and an error if it failed.
// //
// Executes sets up a in memory, temporarily, environment for the execution of // Executes sets up a in memory, temporarily, environment for the execution of
// the given code. It enabled the JIT by default and make sure that it's restored // the given code. It makes sure that it's restored to it's original state afterwards.
// to it's original state afterwards.
func Execute(code, input []byte, cfg *Config) ([]byte, *state.StateDB, error) { func Execute(code, input []byte, cfg *Config) ([]byte, *state.StateDB, error) {
if cfg == nil { if cfg == nil {
cfg = new(Config) cfg = new(Config)
......
This diff is collapsed.
// Copyright 2015 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
// The go-ethereum library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// The go-ethereum library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
// +build !evmjit
package vm
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment