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 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 | 231 |
232 TEST_F(AstDecoderTest, GetLocal0_param) { | 232 TEST_F(AstDecoderTest, GetLocal0_param) { |
233 EXPECT_VERIFIES(sigs.i_i(), kCodeGetLocal0); | 233 EXPECT_VERIFIES(sigs.i_i(), kCodeGetLocal0); |
234 } | 234 } |
235 | 235 |
236 TEST_F(AstDecoderTest, GetLocal0_local) { | 236 TEST_F(AstDecoderTest, GetLocal0_local) { |
237 AddLocals(kAstI32, 1); | 237 AddLocals(kAstI32, 1); |
238 EXPECT_VERIFIES(sigs.i_v(), kCodeGetLocal0); | 238 EXPECT_VERIFIES(sigs.i_v(), kCodeGetLocal0); |
239 } | 239 } |
240 | 240 |
| 241 TEST_F(AstDecoderTest, TooManyLocals) { |
| 242 AddLocals(kAstI32, 4034986500); |
| 243 EXPECT_FAILURE(sigs.i_v(), kCodeGetLocal0); |
| 244 } |
| 245 |
241 TEST_F(AstDecoderTest, GetLocal0_param_n) { | 246 TEST_F(AstDecoderTest, GetLocal0_param_n) { |
242 FunctionSig* array[] = {sigs.i_i(), sigs.i_ii(), sigs.i_iii()}; | 247 FunctionSig* array[] = {sigs.i_i(), sigs.i_ii(), sigs.i_iii()}; |
243 | 248 |
244 for (size_t i = 0; i < arraysize(array); i++) { | 249 for (size_t i = 0; i < arraysize(array); i++) { |
245 EXPECT_VERIFIES(array[i], kCodeGetLocal0); | 250 EXPECT_VERIFIES(array[i], kCodeGetLocal0); |
246 } | 251 } |
247 } | 252 } |
248 | 253 |
249 TEST_F(AstDecoderTest, GetLocalN_local) { | 254 TEST_F(AstDecoderTest, GetLocalN_local) { |
250 for (byte i = 1; i < 8; i++) { | 255 for (byte i = 1; i < 8; i++) { |
(...skipping 11 matching lines...) Expand all Loading... |
262 | 267 |
263 TEST_F(AstDecoderTest, GetLocal1_fail_no_locals) { | 268 TEST_F(AstDecoderTest, GetLocal1_fail_no_locals) { |
264 EXPECT_FAILURE(sigs.i_i(), kCodeGetLocal1); | 269 EXPECT_FAILURE(sigs.i_i(), kCodeGetLocal1); |
265 } | 270 } |
266 | 271 |
267 TEST_F(AstDecoderTest, GetLocal_off_end) { | 272 TEST_F(AstDecoderTest, GetLocal_off_end) { |
268 static const byte code[] = {kExprGetLocal}; | 273 static const byte code[] = {kExprGetLocal}; |
269 EXPECT_FAILURE(sigs.i_i(), code); | 274 EXPECT_FAILURE(sigs.i_i(), code); |
270 } | 275 } |
271 | 276 |
| 277 TEST_F(AstDecoderTest, NumLocalBelowLimit) { |
| 278 AddLocals(kAstI32, kMaxNumWasmLocals - 1); |
| 279 EXPECT_VERIFIES_INLINE(sigs.v_v(), WASM_NOP); |
| 280 } |
| 281 |
| 282 TEST_F(AstDecoderTest, NumLocalAtLimit) { |
| 283 AddLocals(kAstI32, kMaxNumWasmLocals); |
| 284 EXPECT_VERIFIES_INLINE(sigs.v_v(), WASM_NOP); |
| 285 } |
| 286 |
| 287 TEST_F(AstDecoderTest, NumLocalAboveLimit) { |
| 288 AddLocals(kAstI32, kMaxNumWasmLocals + 1); |
| 289 EXPECT_FAILURE_INLINE(sigs.v_v(), WASM_NOP); |
| 290 } |
| 291 |
272 TEST_F(AstDecoderTest, GetLocal_varint) { | 292 TEST_F(AstDecoderTest, GetLocal_varint) { |
273 const int kMaxLocals = 8000000; | 293 const int kMaxLocals = kMaxNumWasmLocals; |
274 AddLocals(kAstI32, kMaxLocals); | 294 AddLocals(kAstI32, kMaxLocals); |
275 | 295 |
276 for (int index = 0; index < kMaxLocals; index = index * 11 + 5) { | 296 for (int index = 0; index < kMaxLocals; index = index * 11 + 5) { |
277 EXPECT_VERIFIES_INLINE(sigs.i_i(), kExprGetLocal, U32V_1(index)); | 297 EXPECT_VERIFIES_INLINE(sigs.i_i(), kExprGetLocal, U32V_1(index)); |
278 EXPECT_VERIFIES_INLINE(sigs.i_i(), kExprGetLocal, U32V_2(index)); | 298 EXPECT_VERIFIES_INLINE(sigs.i_i(), kExprGetLocal, U32V_2(index)); |
279 EXPECT_VERIFIES_INLINE(sigs.i_i(), kExprGetLocal, U32V_3(index)); | 299 EXPECT_VERIFIES_INLINE(sigs.i_i(), kExprGetLocal, U32V_3(index)); |
280 EXPECT_VERIFIES_INLINE(sigs.i_i(), kExprGetLocal, U32V_4(index)); | 300 EXPECT_VERIFIES_INLINE(sigs.i_i(), kExprGetLocal, U32V_4(index)); |
281 } | 301 } |
282 | 302 |
283 EXPECT_VERIFIES_INLINE(sigs.i_i(), kExprGetLocal, U32V_5(kMaxLocals - 1)); | 303 EXPECT_VERIFIES_INLINE(sigs.i_i(), kExprGetLocal, U32V_5(kMaxLocals - 1)); |
(...skipping 2277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2561 iter.next(); | 2581 iter.next(); |
2562 EXPECT_TRUE(iter.has_next()); | 2582 EXPECT_TRUE(iter.has_next()); |
2563 EXPECT_EQ(kExprI8Const, iter.current()); | 2583 EXPECT_EQ(kExprI8Const, iter.current()); |
2564 iter.next(); | 2584 iter.next(); |
2565 EXPECT_FALSE(iter.has_next()); | 2585 EXPECT_FALSE(iter.has_next()); |
2566 } | 2586 } |
2567 | 2587 |
2568 } // namespace wasm | 2588 } // namespace wasm |
2569 } // namespace internal | 2589 } // namespace internal |
2570 } // namespace v8 | 2590 } // namespace v8 |
OLD | NEW |