aboutsummaryrefslogtreecommitdiffstats
path: root/core/vm/jit.go
diff options
context:
space:
mode:
authorNick Johnson <arachnid@notdot.net>2016-08-19 22:19:51 +0800
committerNick Johnson <arachnid@notdot.net>2016-08-22 16:26:15 +0800
commit781915f183c6e09474c6192d1aaba8e99c4990de (patch)
tree572ae2ca95d46c8a37e12a3d03cf3058caf06740 /core/vm/jit.go
parent475521dd747070372f84c2b0ac202e14216dc0e0 (diff)
downloadgo-tangerine-781915f183c6e09474c6192d1aaba8e99c4990de.tar.gz
go-tangerine-781915f183c6e09474c6192d1aaba8e99c4990de.tar.zst
go-tangerine-781915f183c6e09474c6192d1aaba8e99c4990de.zip
core/vm: Refactor tracing to make Tracer the main interface
This CL makes several refactors: - Define a Tracer interface, implementing the `CaptureState` method - Add the VM environment as the first argument of `Tracer.CaptureState` - Rename existing functionality `StructLogger` an make it an implementation of `Tracer` - Delete `StructLogCollector` and make `StructLogger` collect the logs directly - Change all callers to use the new `StructLogger` where necessary and extract logs from that. - Deletes the apparently obsolete and likely nonfunctional 'TraceCall' from the eth API. Callers that only wish accumulated logs can use the `StructLogger` implementation straightforwardly. Callers that wish to efficiently capture VM traces and operate on them without excessive copying can now implement the `Tracer` interface to receive VM state at each step and do with it as they wish. This CL also removes the accumulation of logs from the vm.Environment; this was necessary as part of the refactor, but also simplifies it by removing a responsibility that doesn't directly belong to the Environment.
Diffstat (limited to 'core/vm/jit.go')
-rw-r--r--core/vm/jit.go6
1 files changed, 3 insertions, 3 deletions
diff --git a/core/vm/jit.go b/core/vm/jit.go
index e2374df42..460a68ddd 100644
--- a/core/vm/jit.go
+++ b/core/vm/jit.go
@@ -303,7 +303,7 @@ func RunProgram(program *Program, env Environment, contract *Contract, input []b
return runProgram(program, 0, NewMemory(), newstack(), env, contract, input)
}
-func runProgram(program *Program, pcstart uint64, mem *Memory, stack *stack, env Environment, contract *Contract, input []byte) ([]byte, error) {
+func runProgram(program *Program, pcstart uint64, mem *Memory, stack *Stack, env Environment, contract *Contract, input []byte) ([]byte, error) {
contract.Input = input
var (
@@ -357,7 +357,7 @@ func validDest(dests map[uint64]struct{}, dest *big.Int) bool {
// jitCalculateGasAndSize 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 jitCalculateGasAndSize(env Environment, contract *Contract, instr instruction, statedb Database, mem *Memory, stack *stack) (*big.Int, *big.Int, error) {
+func jitCalculateGasAndSize(env Environment, contract *Contract, instr instruction, statedb Database, mem *Memory, stack *Stack) (*big.Int, *big.Int, error) {
var (
gas = new(big.Int)
newMemSize *big.Int = new(big.Int)
@@ -491,7 +491,7 @@ func jitCalculateGasAndSize(env Environment, contract *Contract, instr instructi
// jitBaseCheck is the same as baseCheck except it doesn't do the look up in the
// gas table. This is done during compilation instead.
-func jitBaseCheck(instr instruction, stack *stack, gas *big.Int) error {
+func jitBaseCheck(instr instruction, stack *Stack, gas *big.Int) error {
err := stack.require(instr.spop)
if err != nil {
return err