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

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

Issue 2324733002: [wasm] Do not support grow_memory for asmjs modules. (Closed)
Patch Set: Created 4 years, 3 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
« no previous file with comments | « src/compiler/wasm-compiler.cc ('k') | src/wasm/wasm-opcodes.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/wasm/ast-decoder.cc
diff --git a/src/wasm/ast-decoder.cc b/src/wasm/ast-decoder.cc
index 48db8e9e68089e74f6fe6a8b42cadd353178a3dd..fbb3360451c7c6681c8b652160d479f74fde0b67 100644
--- a/src/wasm/ast-decoder.cc
+++ b/src/wasm/ast-decoder.cc
@@ -1229,7 +1229,14 @@ class WasmFullDecoder : public WasmDecoder {
case kExprF64StoreMem:
len = DecodeStoreMem(kAstF64, MachineType::Float64());
break;
-
+ case kExprGrowMemory:
+ if (module_->origin != kAsmJsOrigin) {
+ Push(kAstI32, BUILD(GrowMemory, Pop(0, kAstI32).node));
+ break;
+ } else {
+ error("grow_memory is not supported for asmjs modules");
+ return;
titzer 2016/09/08 08:16:29 No need to return here; the error will cause the m
ahaas 2016/09/09 10:52:28 Done.
+ }
case kExprMemorySize:
Push(kAstI32, BUILD(MemSize, 0));
break;
@@ -1279,8 +1286,36 @@ class WasmFullDecoder : public WasmDecoder {
break;
}
default:
- error("Invalid opcode");
- return;
+ // Deal with special asmjs opcodes.
+ if (module_->origin == kAsmJsOrigin) {
+ sig = WasmOpcodes::AsmjsSignature(opcode);
+ if (sig) {
+ // Fast case of a simple operator.
+ TFNode* node;
titzer 2016/09/08 08:16:29 Factor this switch out to an inline method?
ahaas 2016/09/09 10:52:28 Done.
+ switch (sig->parameter_count()) {
+ case 1: {
+ Value val = Pop(0, sig->GetParam(0));
+ node = BUILD(Unop, opcode, val.node, position());
+ break;
+ }
+ case 2: {
+ Value rval = Pop(1, sig->GetParam(1));
+ Value lval = Pop(0, sig->GetParam(0));
+ node =
+ BUILD(Binop, opcode, lval.node, rval.node, position());
+ break;
+ }
+ default:
+ UNREACHABLE();
+ node = nullptr;
+ break;
+ }
+ Push(GetReturnType(sig), node);
+ }
+ } else {
+ error("Invalid opcode");
+ return;
+ }
}
} // end complex bytecode
« no previous file with comments | « src/compiler/wasm-compiler.cc ('k') | src/wasm/wasm-opcodes.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698