| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "test/unittests/test-utils.h" | 5 #include "test/unittests/test-utils.h" |
| 6 | 6 |
| 7 #include "src/v8.h" | 7 #include "src/v8.h" |
| 8 | 8 |
| 9 #include "test/cctest/wasm/test-signatures.h" | 9 #include "test/cctest/wasm/test-signatures.h" |
| 10 | 10 |
| (...skipping 1075 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1086 } | 1086 } |
| 1087 | 1087 |
| 1088 TEST_F(AstDecoderTest, LoadMemOffset) { | 1088 TEST_F(AstDecoderTest, LoadMemOffset) { |
| 1089 for (int offset = 0; offset < 128; offset += 7) { | 1089 for (int offset = 0; offset < 128; offset += 7) { |
| 1090 byte code[] = {kExprI8Const, 0, kExprI32LoadMem, ZERO_ALIGNMENT, | 1090 byte code[] = {kExprI8Const, 0, kExprI32LoadMem, ZERO_ALIGNMENT, |
| 1091 static_cast<byte>(offset)}; | 1091 static_cast<byte>(offset)}; |
| 1092 EXPECT_VERIFIES(sigs.i_i(), code); | 1092 EXPECT_VERIFIES(sigs.i_i(), code); |
| 1093 } | 1093 } |
| 1094 } | 1094 } |
| 1095 | 1095 |
| 1096 TEST_F(AstDecoderTest, LoadMemAlignment) { |
| 1097 struct { |
| 1098 WasmOpcode instruction; |
| 1099 uint32_t maximum_aligment; |
| 1100 } values[] = { |
| 1101 {kExprI32LoadMem8U, 0}, // -- |
| 1102 {kExprI32LoadMem8S, 0}, // -- |
| 1103 {kExprI32LoadMem16U, 1}, // -- |
| 1104 {kExprI32LoadMem16S, 1}, // -- |
| 1105 {kExprI64LoadMem8U, 0}, // -- |
| 1106 {kExprI64LoadMem8S, 0}, // -- |
| 1107 {kExprI64LoadMem16U, 1}, // -- |
| 1108 {kExprI64LoadMem16S, 1}, // -- |
| 1109 {kExprI64LoadMem32U, 2}, // -- |
| 1110 {kExprI64LoadMem32S, 2}, // -- |
| 1111 {kExprI32LoadMem, 2}, // -- |
| 1112 {kExprI64LoadMem, 3}, // -- |
| 1113 {kExprF32LoadMem, 2}, // -- |
| 1114 {kExprF64LoadMem, 3}, // -- |
| 1115 }; |
| 1116 |
| 1117 for (int i = 0; i < arraysize(values); i++) { |
| 1118 for (byte alignment = 0; alignment <= 4; alignment++) { |
| 1119 byte code[] = {kExprI8Const, 0, static_cast<byte>(values[i].instruction), |
| 1120 alignment, ZERO_OFFSET}; |
| 1121 if (static_cast<uint32_t>(alignment) <= values[i].maximum_aligment) { |
| 1122 EXPECT_VERIFIES(sigs.v_i(), code); |
| 1123 } else { |
| 1124 EXPECT_FAILURE(sigs.v_i(), code); |
| 1125 } |
| 1126 } |
| 1127 } |
| 1128 } |
| 1129 |
| 1096 TEST_F(AstDecoderTest, StoreMemOffset) { | 1130 TEST_F(AstDecoderTest, StoreMemOffset) { |
| 1097 for (int offset = 0; offset < 128; offset += 7) { | 1131 for (int offset = 0; offset < 128; offset += 7) { |
| 1098 byte code[] = {WASM_STORE_MEM_OFFSET(MachineType::Int32(), offset, | 1132 byte code[] = {WASM_STORE_MEM_OFFSET(MachineType::Int32(), offset, |
| 1099 WASM_ZERO, WASM_ZERO)}; | 1133 WASM_ZERO, WASM_ZERO)}; |
| 1100 EXPECT_VERIFIES(sigs.i_i(), code); | 1134 EXPECT_VERIFIES(sigs.i_i(), code); |
| 1101 } | 1135 } |
| 1102 } | 1136 } |
| 1103 | 1137 |
| 1104 #define BYTE0(x) ((x)&0x7F) | 1138 #define BYTE0(x) ((x)&0x7F) |
| 1105 #define BYTE1(x) ((x >> 7) & 0x7F) | 1139 #define BYTE1(x) ((x >> 7) & 0x7F) |
| (...skipping 1475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2581 iter.next(); | 2615 iter.next(); |
| 2582 EXPECT_TRUE(iter.has_next()); | 2616 EXPECT_TRUE(iter.has_next()); |
| 2583 EXPECT_EQ(kExprI8Const, iter.current()); | 2617 EXPECT_EQ(kExprI8Const, iter.current()); |
| 2584 iter.next(); | 2618 iter.next(); |
| 2585 EXPECT_FALSE(iter.has_next()); | 2619 EXPECT_FALSE(iter.has_next()); |
| 2586 } | 2620 } |
| 2587 | 2621 |
| 2588 } // namespace wasm | 2622 } // namespace wasm |
| 2589 } // namespace internal | 2623 } // namespace internal |
| 2590 } // namespace v8 | 2624 } // namespace v8 |
| OLD | NEW |