diff options
author | Jeffrey Wilcke <geffobscura@gmail.com> | 2015-08-11 06:16:38 +0800 |
---|---|---|
committer | Jeffrey Wilcke <geffobscura@gmail.com> | 2015-08-11 06:16:38 +0800 |
commit | 32395ddb891f3a32bc1295296a0887ed9479eeb0 (patch) | |
tree | bc1742819b8d68ecdce8cdf4f16b16d362074cdd /core/vm/jit.go | |
parent | 2fcf7f1241648dc2c0ed90a122c5945f25b3ce1a (diff) | |
download | go-tangerine-32395ddb891f3a32bc1295296a0887ed9479eeb0.tar.gz go-tangerine-32395ddb891f3a32bc1295296a0887ed9479eeb0.tar.zst go-tangerine-32395ddb891f3a32bc1295296a0887ed9479eeb0.zip |
core/vm: fixed jit error & added inline docs
opNumber did not create a new big int which could lead to the block's
number being modified.
Diffstat (limited to 'core/vm/jit.go')
-rw-r--r-- | core/vm/jit.go | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/core/vm/jit.go b/core/vm/jit.go index d5c2d7830..084d2a3f3 100644 --- a/core/vm/jit.go +++ b/core/vm/jit.go @@ -83,6 +83,7 @@ type Program struct { code []byte } +// NewProgram returns a new JIT program func NewProgram(code []byte) *Program { program := &Program{ Id: crypto.Sha3Hash(code), @@ -113,6 +114,7 @@ func (p *Program) addInstr(op OpCode, pc uint64, fn instrFn, data *big.Int) { p.mapping[pc] = len(p.instructions) - 1 } +// CompileProgram compiles the given program and return an error when it fails func CompileProgram(program *Program) (err error) { if progStatus(atomic.LoadInt32(&program.status)) == progCompile { return nil @@ -272,6 +274,8 @@ func CompileProgram(program *Program) (err error) { return nil } +// RunProgram runs the program given the enviroment and context and returns an +// error if the execution failed (non-consensus) func RunProgram(program *Program, env Environment, context *Context, input []byte) ([]byte, error) { return runProgram(program, 0, NewMemory(), newstack(), env, context, input) } @@ -352,6 +356,8 @@ func runProgram(program *Program, pcstart uint64, mem *Memory, stack *stack, env pc++ } + context.Input = nil + return context.Return(nil), nil } |