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/common/wasm/test-signatures.h" | 9 #include "test/common/wasm/test-signatures.h" |
10 | 10 |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 AddLocals(kAstI32, kMaxNumWasmLocals); | 307 AddLocals(kAstI32, kMaxNumWasmLocals); |
308 EXPECT_VERIFIES(v_v, WASM_NOP); | 308 EXPECT_VERIFIES(v_v, WASM_NOP); |
309 } | 309 } |
310 | 310 |
311 TEST_F(AstDecoderTest, NumLocalAboveLimit) { | 311 TEST_F(AstDecoderTest, NumLocalAboveLimit) { |
312 AddLocals(kAstI32, kMaxNumWasmLocals + 1); | 312 AddLocals(kAstI32, kMaxNumWasmLocals + 1); |
313 EXPECT_FAILURE(v_v, WASM_NOP); | 313 EXPECT_FAILURE(v_v, WASM_NOP); |
314 } | 314 } |
315 | 315 |
316 TEST_F(AstDecoderTest, GetLocal_varint) { | 316 TEST_F(AstDecoderTest, GetLocal_varint) { |
317 const int kMaxLocals = kMaxNumWasmLocals; | 317 const int kMaxLocals = kMaxNumWasmLocals - 1; |
318 AddLocals(kAstI32, kMaxLocals); | 318 AddLocals(kAstI32, kMaxLocals); |
319 | 319 |
320 EXPECT_VERIFIES(i_i, kExprGetLocal, U32V_1(66)); | 320 EXPECT_VERIFIES(i_i, kExprGetLocal, U32V_1(66)); |
321 EXPECT_VERIFIES(i_i, kExprGetLocal, U32V_2(7777)); | 321 EXPECT_VERIFIES(i_i, kExprGetLocal, U32V_2(7777)); |
322 EXPECT_VERIFIES(i_i, kExprGetLocal, U32V_3(888888)); | 322 EXPECT_VERIFIES(i_i, kExprGetLocal, U32V_3(8888)); |
323 EXPECT_VERIFIES(i_i, kExprGetLocal, U32V_4(3999999)); | 323 EXPECT_VERIFIES(i_i, kExprGetLocal, U32V_4(9999)); |
324 | 324 |
325 EXPECT_VERIFIES(i_i, kExprGetLocal, U32V_5(kMaxLocals - 1)); | 325 EXPECT_VERIFIES(i_i, kExprGetLocal, U32V_5(kMaxLocals - 1)); |
326 | 326 |
327 EXPECT_FAILURE(i_i, kExprGetLocal, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF); | 327 EXPECT_FAILURE(i_i, kExprGetLocal, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF); |
328 | 328 |
329 EXPECT_VERIFIES(i_i, kExprGetLocal, U32V_4(kMaxLocals - 1)); | 329 EXPECT_VERIFIES(i_i, kExprGetLocal, U32V_4(kMaxLocals - 1)); |
330 EXPECT_VERIFIES(i_i, kExprGetLocal, U32V_4(kMaxLocals)); | 330 EXPECT_VERIFIES(i_i, kExprGetLocal, U32V_4(kMaxLocals)); |
331 EXPECT_FAILURE(i_i, kExprGetLocal, U32V_4(kMaxLocals + 1)); | 331 EXPECT_FAILURE(i_i, kExprGetLocal, U32V_4(kMaxLocals + 1)); |
332 | 332 |
333 EXPECT_FAILURE(i_v, kExprGetLocal, U32V_4(kMaxLocals)); | 333 EXPECT_FAILURE(i_v, kExprGetLocal, U32V_4(kMaxLocals)); |
334 EXPECT_FAILURE(i_v, kExprGetLocal, U32V_4(kMaxLocals + 1)); | 334 EXPECT_FAILURE(i_v, kExprGetLocal, U32V_4(kMaxLocals + 1)); |
335 } | 335 } |
336 | 336 |
| 337 TEST_F(AstDecoderTest, GetLocal_toomany) { |
| 338 AddLocals(kAstI32, kMaxNumWasmLocals - 100); |
| 339 AddLocals(kAstI32, 100); |
| 340 |
| 341 EXPECT_VERIFIES(i_v, kExprGetLocal, U32V_1(66)); |
| 342 EXPECT_FAILURE(i_i, kExprGetLocal, U32V_1(66)); |
| 343 } |
| 344 |
337 TEST_F(AstDecoderTest, Binops_off_end) { | 345 TEST_F(AstDecoderTest, Binops_off_end) { |
338 byte code1[] = {0}; // [opcode] | 346 byte code1[] = {0}; // [opcode] |
339 for (size_t i = 0; i < arraysize(kInt32BinopOpcodes); i++) { | 347 for (size_t i = 0; i < arraysize(kInt32BinopOpcodes); i++) { |
340 code1[0] = kInt32BinopOpcodes[i]; | 348 code1[0] = kInt32BinopOpcodes[i]; |
341 EXPECT_FAILURE_C(i_i, code1); | 349 EXPECT_FAILURE_C(i_i, code1); |
342 } | 350 } |
343 | 351 |
344 byte code3[] = {kExprGetLocal, 0, 0}; // [expr] [opcode] | 352 byte code3[] = {kExprGetLocal, 0, 0}; // [expr] [opcode] |
345 for (size_t i = 0; i < arraysize(kInt32BinopOpcodes); i++) { | 353 for (size_t i = 0; i < arraysize(kInt32BinopOpcodes); i++) { |
346 code3[2] = kInt32BinopOpcodes[i]; | 354 code3[2] = kInt32BinopOpcodes[i]; |
(...skipping 2356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2703 iter.next(); | 2711 iter.next(); |
2704 EXPECT_TRUE(iter.has_next()); | 2712 EXPECT_TRUE(iter.has_next()); |
2705 EXPECT_EQ(kExprI8Const, iter.current()); | 2713 EXPECT_EQ(kExprI8Const, iter.current()); |
2706 iter.next(); | 2714 iter.next(); |
2707 EXPECT_FALSE(iter.has_next()); | 2715 EXPECT_FALSE(iter.has_next()); |
2708 } | 2716 } |
2709 | 2717 |
2710 } // namespace wasm | 2718 } // namespace wasm |
2711 } // namespace internal | 2719 } // namespace internal |
2712 } // namespace v8 | 2720 } // namespace v8 |
OLD | NEW |