Chromium Code Reviews

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

Issue 2285643002: [wasm] Validate the alignment of load and store instructions. (Closed)
Patch Set: signed unsigned mismatch Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
« no previous file with comments | « no previous file | src/wasm/ast-decoder.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/wasm/ast-decoder.h
diff --git a/src/wasm/ast-decoder.h b/src/wasm/ast-decoder.h
index c4f6c1679a0bfb89d6d1b9c9c9197305e25aeca2..cab20b40daa91b21e82b85a07c359ebfa8144daf 100644
--- a/src/wasm/ast-decoder.h
+++ b/src/wasm/ast-decoder.h
@@ -5,6 +5,8 @@
#ifndef V8_WASM_AST_DECODER_H_
#define V8_WASM_AST_DECODER_H_
+#include "src/base/bits.h"
+#include "src/machine-type.h"
#include "src/signature.h"
#include "src/wasm/decoder.h"
#include "src/wasm/wasm-opcodes.h"
@@ -183,10 +185,17 @@ struct MemoryAccessOperand {
uint32_t alignment;
uint32_t offset;
unsigned length;
- inline MemoryAccessOperand(Decoder* decoder, const byte* pc) {
+ inline MemoryAccessOperand(Decoder* decoder, const byte* pc,
titzer 2016/08/26 08:24:17 Why not just pass the maximum alignment size here?
ahaas 2016/09/01 17:18:29 Done.
+ MachineType type) {
unsigned alignment_length;
alignment =
decoder->checked_read_u32v(pc, 1, &alignment_length, "alignment");
+ if (type != MachineType::None() &&
+ ElementSizeLog2Of(type.representation()) <
+ static_cast<int>(alignment)) {
+ decoder->error(pc,
+ "alignment must be less or equal to natural alignment");
+ }
unsigned offset_length;
offset = decoder->checked_read_u32v(pc, 1 + alignment_length,
&offset_length, "offset");
« no previous file with comments | « no previous file | src/wasm/ast-decoder.cc » ('j') | no next file with comments »

Powered by Google App Engine