diff options
author | Meng-Ying Yang <garfield@dexon.org> | 2019-03-05 16:34:05 +0800 |
---|---|---|
committer | Jhih-Ming Huang <jm.huang@cobinhood.com> | 2019-05-06 10:44:04 +0800 |
commit | f0a7aec8c783761bd8b7d6bc38053daa73ad14d9 (patch) | |
tree | ef5acd4a4ada040ac6a9d1425c16ecaad7e44780 | |
parent | 3fef4167b90d8340f53f89cfc12f270fab865aac (diff) | |
download | dexon-f0a7aec8c783761bd8b7d6bc38053daa73ad14d9.tar.gz dexon-f0a7aec8c783761bd8b7d6bc38053daa73ad14d9.tar.zst dexon-f0a7aec8c783761bd8b7d6bc38053daa73ad14d9.zip |
core: vm: sqlvm: add jump table
-rw-r--r-- | core/vm/sqlvm/runtime/jumptable.go | 26 | ||||
-rw-r--r-- | core/vm/sqlvm/runtime/runtime.go | 4 |
2 files changed, 27 insertions, 3 deletions
diff --git a/core/vm/sqlvm/runtime/jumptable.go b/core/vm/sqlvm/runtime/jumptable.go index 5ce6d9a8a..415a4e62b 100644 --- a/core/vm/sqlvm/runtime/jumptable.go +++ b/core/vm/sqlvm/runtime/jumptable.go @@ -1,6 +1,32 @@ package runtime var jumpTable = [256]OpFunction{ + // 0x10 + ADD: opAdd, + MUL: opMul, + SUB: opSub, + DIV: opDiv, + MOD: opMod, + + // 0x20 + LT: opLt, + GT: opGt, + EQ: opEq, + AND: opAnd, + OR: opOr, + NOT: opNot, + UNION: opUnion, + INTXN: opIntxn, + LIKE: opLike, + + // 0x40 + ZIP: opZip, + FIELD: opField, + PRUNE: opPrune, + SORT: opSort, + FILTER: opFilter, + CAST: opCast, + // 0x60 LOAD: opLoad, } diff --git a/core/vm/sqlvm/runtime/runtime.go b/core/vm/sqlvm/runtime/runtime.go index 5cae111c9..3b6d49a72 100644 --- a/core/vm/sqlvm/runtime/runtime.go +++ b/core/vm/sqlvm/runtime/runtime.go @@ -14,9 +14,7 @@ func Run(stateDB vm.StateDB, ins []Instruction, registers []*Operand) (ret []byt in.Input[i] = registers[in.Input[i].RegisterIndex] } } - opFunc := jumpTable[in.Op] - loadRegister(in.Input, registers) - errCode := opFunc(&common.Context{}, in.Input, registers, in.Output) + errCode := jumpTable[in.Op](&common.Context{}, in.Input, registers, in.Output) if errCode != nil { err = se.Error{ Position: in.Position, |