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

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

Issue 2285643002: [wasm] Validate the alignment of load and store instructions. (Closed)
Patch Set: Add alignment and maximum alignment information to the error message. 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/wasm/ast-decoder.h ('k') | src/wasm/wasm-interpreter.cc » ('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 a778ad13beb9e92efce1fdf42fa66fa7e995f1be..40d4a0bac6256918f334fa09d9e9a550a2d538b5 100644
--- a/src/wasm/ast-decoder.cc
+++ b/src/wasm/ast-decoder.cc
@@ -401,7 +401,7 @@ class WasmDecoder : public Decoder {
FOREACH_STORE_MEM_OPCODE(DECLARE_OPCODE_CASE)
#undef DECLARE_OPCODE_CASE
{
- MemoryAccessOperand operand(this, pc);
+ MemoryAccessOperand operand(this, pc, UINT32_MAX);
return 1 + operand.length;
}
case kExprBr:
@@ -1378,7 +1378,9 @@ class WasmFullDecoder : public WasmDecoder {
}
int DecodeLoadMem(LocalType type, MachineType mem_type) {
- MemoryAccessOperand operand(this, pc_);
+ MemoryAccessOperand operand(this, pc_,
+ ElementSizeLog2Of(mem_type.representation()));
+
Value index = Pop(0, kAstI32);
TFNode* node = BUILD(LoadMem, type, mem_type, index.node, operand.offset,
operand.alignment, position());
@@ -1387,7 +1389,8 @@ class WasmFullDecoder : public WasmDecoder {
}
int DecodeStoreMem(LocalType type, MachineType mem_type) {
- MemoryAccessOperand operand(this, pc_);
+ MemoryAccessOperand operand(this, pc_,
+ ElementSizeLog2Of(mem_type.representation()));
Value val = Pop(1, type);
Value index = Pop(0, kAstI32);
BUILD(StoreMem, mem_type, index.node, operand.offset, operand.alignment,
« no previous file with comments | « src/wasm/ast-decoder.h ('k') | src/wasm/wasm-interpreter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698