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

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

Issue 2324733002: [wasm] Do not support grow_memory for asmjs modules. (Closed)
Patch Set: Fixed a typo 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 7ecc59f71243d6919ace40b2930da09b0318caa7..42b5a1ea421846678c8345b15553d2418b549bf2 100644
--- a/src/wasm/ast-decoder.cc
+++ b/src/wasm/ast-decoder.cc
@@ -721,26 +721,7 @@ class WasmFullDecoder : public WasmDecoder {
FunctionSig* sig = WasmOpcodes::Signature(opcode);
if (sig) {
- // Fast case of a simple operator.
- TFNode* node;
- 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);
+ BuildSimpleOperator(opcode, sig);
} else {
// Complex bytecode.
switch (opcode) {
@@ -1236,7 +1217,14 @@ class WasmFullDecoder : public WasmDecoder {
case kExprF64StoreMem:
len = DecodeStoreMem(kAstF64, MachineType::Float64());
break;
-
+ case kExprGrowMemory:
+ if (module_->origin != kAsmJsOrigin) {
+ Value val = Pop(0, kAstI32);
+ Push(kAstI32, BUILD(GrowMemory, val.node));
+ } else {
+ error("grow_memory is not supported for asmjs modules");
+ }
+ break;
case kExprMemorySize:
Push(kAstI32, BUILD(MemSize, 0));
break;
@@ -1286,8 +1274,16 @@ 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) {
+ BuildSimpleOperator(opcode, sig);
+ }
+ } else {
+ error("Invalid opcode");
+ return;
+ }
}
} // end complex bytecode
@@ -1914,6 +1910,28 @@ class WasmFullDecoder : public WasmDecoder {
DCHECK_EQ(pc_ - start_, offset); // overflows cannot happen
return offset;
}
+
+ inline void BuildSimpleOperator(WasmOpcode opcode, FunctionSig* sig) {
+ TFNode* node;
+ 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);
+ }
};
bool DecodeLocalDecls(AstLocalDecls& decls, const byte* start,
« 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