Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1110)

Unified Diff: src/wasm/ast-decoder.cc

Issue 2137993003: [wasm] Adding feature to JIT a wasm function at runtime and hook up the compiled code into the indi… (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fixing unit test- Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/wasm/ast-decoder.cc
diff --git a/src/wasm/ast-decoder.cc b/src/wasm/ast-decoder.cc
index 70f7bfdd1d7306dd8908feef1a054dbcd1ac9337..facdab62eeecd7c568dc33180daee24dca7e1a88 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) {
+ 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)) {
+ 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: \
@@ -340,6 +359,10 @@ class WasmDecoder : public Decoder {
return 1 + operand.length;
}
+ case kExprJITSingleFunction: {
+ JITSingleFunctionOperand operand(this, pc);
+ return 1 + operand.length;
+ }
case kExprSetLocal:
case kExprGetLocal: {
LocalIndexOperand operand(this, pc);
@@ -996,6 +1019,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, position());
+ Push(kAstI32, call);
+ break;
+ }
+ }
+ }
default:
error("Invalid opcode");
return;
@@ -1620,6 +1658,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;

Powered by Google App Engine
This is Rietveld 408576698