Chromium Code Reviews| Index: src/wasm/ast-decoder.cc |
| diff --git a/src/wasm/ast-decoder.cc b/src/wasm/ast-decoder.cc |
| index 70f7bfdd1d7306dd8908feef1a054dbcd1ac9337..a9e4a505aaa3bc4581421bcdb533258fcf4c41b2 100644 |
| --- a/src/wasm/ast-decoder.cc |
| +++ b/src/wasm/ast-decoder.cc |
| @@ -193,6 +193,23 @@ class WasmDecoder : public Decoder { |
| return false; |
| } |
| + inline bool Complete(const byte* pc, JITSingleFunctionOperand& operand) { |
|
Mircea Trofin
2016/07/12 02:49:13
Coding convention says pass-by-reference parameter
ritesht
2016/07/13 23:58:45
The other functions don't seem to use this. Maybe
|
| + ModuleEnv* m = module_; |
| + if (m && m->module && operand.sig_index < m->module->signatures.size()) { |
| + operand.sig = m->module->signatures[operand.sig_index]; |
| + return true; |
| + } |
| + return false; |
| + } |
| + |
| + inline bool Validate(const byte* pc, JITSingleFunctionOperand& operand) { |
| + if (Complete(pc, operand)) { |
|
Mircea Trofin
2016/07/12 02:49:13
same as above
ritesht
2016/07/13 23:58:45
Acknowledged.
|
| + return true; |
| + } |
| + error(pc, pc + 1, "invalid signature index"); |
| + return false; |
| + } |
| + |
| inline bool Validate(const byte* pc, BreakDepthOperand& operand, |
| ZoneVector<Control>& control) { |
| if (operand.arity > 1) { |
| @@ -287,6 +304,8 @@ class WasmDecoder : public Decoder { |
| ReturnArityOperand operand(this, pc); |
| return operand.arity; |
| } |
| + case kExprJITSingleFunction: |
| + return 3; |
| #define DECLARE_OPCODE_CASE(name, opcode, sig) \ |
| case kExpr##name: \ |
| @@ -339,7 +358,10 @@ class WasmDecoder : public Decoder { |
| CallImportOperand operand(this, pc); |
| return 1 + operand.length; |
| } |
| - |
| + case kExprJITSingleFunction: { |
| + JITSingleFunctionOperand operand(this, pc); |
| + return 1 + operand.length; |
| + } |
| case kExprSetLocal: |
| case kExprGetLocal: { |
| LocalIndexOperand operand(this, pc); |
| @@ -996,6 +1018,21 @@ class WasmFullDecoder : public WasmDecoder { |
| len = 1 + operand.length; |
| break; |
| } |
| + case kExprJITSingleFunction: { |
| + if (FLAG_wasm_jit_prototype) { |
| + JITSingleFunctionOperand operand(this, pc_); |
| + if (Validate(pc_, operand)) { |
| + Value index = Pop(2, kAstI32); |
| + Value length = Pop(1, kAstI32); |
| + Value base = Pop(0, kAstI32); |
| + TFNode* call = |
| + BUILD(JITSingleFunction, base.node, length.node, index.node, |
| + operand.sig_index, operand.sig); |
| + Push(kAstI32, call); |
| + break; |
| + } |
| + } |
| + } |
| default: |
| error("Invalid opcode"); |
| return; |
| @@ -1620,6 +1657,13 @@ bool PrintAst(base::AccountingAllocator* allocator, const FunctionBody& body, |
| } |
| break; |
| } |
| + case kExprJITSingleFunction: { |
| + JITSingleFunctionOperand operand(&i, i.pc()); |
| + if (decoder.Complete(i.pc(), operand)) { |
| + os << " // sig #" << operand.sig_index << ": " << *operand.sig; |
| + } |
| + break; |
| + } |
| case kExprReturn: { |
| ReturnArityOperand operand(&i, i.pc()); |
| os << " // arity=" << operand.arity; |