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

Unified Diff: test/unittests/wasm/ast-decoder-unittest.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/wasm-interpreter.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/unittests/wasm/ast-decoder-unittest.cc
diff --git a/test/unittests/wasm/ast-decoder-unittest.cc b/test/unittests/wasm/ast-decoder-unittest.cc
index f491ec0b57e58dc43cd2d638495f36f35afa323d..ef33d65f3bfbff3d7f7a0e0516b024a62382a4fa 100644
--- a/test/unittests/wasm/ast-decoder-unittest.cc
+++ b/test/unittests/wasm/ast-decoder-unittest.cc
@@ -1093,6 +1093,40 @@ TEST_F(AstDecoderTest, LoadMemOffset) {
}
}
+TEST_F(AstDecoderTest, LoadMemAlignment) {
+ struct {
+ WasmOpcode instruction;
+ uint32_t maximum_aligment;
+ } values[] = {
+ {kExprI32LoadMem8U, 0}, // --
+ {kExprI32LoadMem8S, 0}, // --
+ {kExprI32LoadMem16U, 1}, // --
+ {kExprI32LoadMem16S, 1}, // --
+ {kExprI64LoadMem8U, 0}, // --
+ {kExprI64LoadMem8S, 0}, // --
+ {kExprI64LoadMem16U, 1}, // --
+ {kExprI64LoadMem16S, 1}, // --
+ {kExprI64LoadMem32U, 2}, // --
+ {kExprI64LoadMem32S, 2}, // --
+ {kExprI32LoadMem, 2}, // --
+ {kExprI64LoadMem, 3}, // --
+ {kExprF32LoadMem, 2}, // --
+ {kExprF64LoadMem, 3}, // --
+ };
+
+ for (int i = 0; i < arraysize(values); i++) {
+ for (byte alignment = 0; alignment <= 4; alignment++) {
+ byte code[] = {kExprI8Const, 0, static_cast<byte>(values[i].instruction),
+ alignment, ZERO_OFFSET};
+ if (static_cast<uint32_t>(alignment) <= values[i].maximum_aligment) {
+ EXPECT_VERIFIES(sigs.v_i(), code);
+ } else {
+ EXPECT_FAILURE(sigs.v_i(), code);
+ }
+ }
+ }
+}
+
TEST_F(AstDecoderTest, StoreMemOffset) {
for (int offset = 0; offset < 128; offset += 7) {
byte code[] = {WASM_STORE_MEM_OFFSET(MachineType::Int32(), offset,
« no previous file with comments | « src/wasm/wasm-interpreter.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698