| 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 1055 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1066 } | 1066 } |
| 1067 | 1067 |
| 1068 TEST_F(AstDecoderTest, LoadMemOffset) { | 1068 TEST_F(AstDecoderTest, LoadMemOffset) { |
| 1069 for (int offset = 0; offset < 128; offset += 7) { | 1069 for (int offset = 0; offset < 128; offset += 7) { |
| 1070 byte code[] = {kExprI8Const, 0, kExprI32LoadMem, ZERO_ALIGNMENT, | 1070 byte code[] = {kExprI8Const, 0, kExprI32LoadMem, ZERO_ALIGNMENT, |
| 1071 static_cast<byte>(offset)}; | 1071 static_cast<byte>(offset)}; |
| 1072 EXPECT_VERIFIES(sigs.i_i(), code); | 1072 EXPECT_VERIFIES(sigs.i_i(), code); |
| 1073 } | 1073 } |
| 1074 } | 1074 } |
| 1075 | 1075 |
| 1076 TEST_F(AstDecoderTest, LoadMemAlignment) { |
| 1077 struct { |
| 1078 WasmOpcode instruction; |
| 1079 uint32_t maximum_aligment; |
| 1080 } values[] = { |
| 1081 {kExprI32LoadMem8U, 0}, // -- |
| 1082 {kExprI32LoadMem8S, 0}, // -- |
| 1083 {kExprI32LoadMem16U, 1}, // -- |
| 1084 {kExprI32LoadMem16S, 1}, // -- |
| 1085 {kExprI64LoadMem8U, 0}, // -- |
| 1086 {kExprI64LoadMem8S, 0}, // -- |
| 1087 {kExprI64LoadMem16U, 1}, // -- |
| 1088 {kExprI64LoadMem16S, 1}, // -- |
| 1089 {kExprI64LoadMem32U, 2}, // -- |
| 1090 {kExprI64LoadMem32S, 2}, // -- |
| 1091 {kExprI32LoadMem, 2}, // -- |
| 1092 {kExprI64LoadMem, 3}, // -- |
| 1093 {kExprF32LoadMem, 2}, // -- |
| 1094 {kExprF64LoadMem, 3}, // -- |
| 1095 }; |
| 1096 |
| 1097 for (int i = 0; i < arraysize(values); i++) { |
| 1098 for (byte alignment = 0; alignment <= 4; alignment++) { |
| 1099 byte code[] = {kExprI8Const, 0, static_cast<byte>(values[i].instruction), |
| 1100 alignment, ZERO_OFFSET}; |
| 1101 if (static_cast<uint32_t>(alignment) <= values[i].maximum_aligment) { |
| 1102 EXPECT_VERIFIES(sigs.v_i(), code); |
| 1103 } else { |
| 1104 EXPECT_FAILURE(sigs.v_i(), code); |
| 1105 } |
| 1106 } |
| 1107 } |
| 1108 } |
| 1109 |
| 1076 TEST_F(AstDecoderTest, StoreMemOffset) { | 1110 TEST_F(AstDecoderTest, StoreMemOffset) { |
| 1077 for (int offset = 0; offset < 128; offset += 7) { | 1111 for (int offset = 0; offset < 128; offset += 7) { |
| 1078 byte code[] = {WASM_STORE_MEM_OFFSET(MachineType::Int32(), offset, | 1112 byte code[] = {WASM_STORE_MEM_OFFSET(MachineType::Int32(), offset, |
| 1079 WASM_ZERO, WASM_ZERO)}; | 1113 WASM_ZERO, WASM_ZERO)}; |
| 1080 EXPECT_VERIFIES(sigs.i_i(), code); | 1114 EXPECT_VERIFIES(sigs.i_i(), code); |
| 1081 } | 1115 } |
| 1082 } | 1116 } |
| 1083 | 1117 |
| 1084 #define BYTE0(x) ((x)&0x7F) | 1118 #define BYTE0(x) ((x)&0x7F) |
| 1085 #define BYTE1(x) ((x >> 7) & 0x7F) | 1119 #define BYTE1(x) ((x >> 7) & 0x7F) |
| (...skipping 1475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2561 iter.next(); | 2595 iter.next(); |
| 2562 EXPECT_TRUE(iter.has_next()); | 2596 EXPECT_TRUE(iter.has_next()); |
| 2563 EXPECT_EQ(kExprI8Const, iter.current()); | 2597 EXPECT_EQ(kExprI8Const, iter.current()); |
| 2564 iter.next(); | 2598 iter.next(); |
| 2565 EXPECT_FALSE(iter.has_next()); | 2599 EXPECT_FALSE(iter.has_next()); |
| 2566 } | 2600 } |
| 2567 | 2601 |
| 2568 } // namespace wasm | 2602 } // namespace wasm |
| 2569 } // namespace internal | 2603 } // namespace internal |
| 2570 } // namespace v8 | 2604 } // namespace v8 |
| OLD | NEW |