| OLD | NEW |
| 1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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 #include "testing/gmock/include/gmock/gmock.h" | 6 #include "testing/gmock/include/gmock/gmock.h" |
| 7 | 7 |
| 8 #include "src/v8.h" | 8 #include "src/v8.h" |
| 9 | 9 |
| 10 #include "src/wasm/wasm-interpreter.h" | 10 #include "src/wasm/wasm-interpreter.h" |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 }; | 156 }; |
| 157 EXPECT_PC_DELTAS({2, 3}, {4, 2}); | 157 EXPECT_PC_DELTAS({2, 3}, {4, 2}); |
| 158 } | 158 } |
| 159 | 159 |
| 160 TEST_F(ControlTransferTest, SimpleIfElse_v1) { | 160 TEST_F(ControlTransferTest, SimpleIfElse_v1) { |
| 161 byte code[] = { | 161 byte code[] = { |
| 162 kExprI32Const, // @0 | 162 kExprI32Const, // @0 |
| 163 0, // @1 | 163 0, // @1 |
| 164 kExprIf, // @2 | 164 kExprIf, // @2 |
| 165 kLocalVoid, // @3 | 165 kLocalVoid, // @3 |
| 166 kExprI8Const, // @4 | 166 kExprI32Const, // @4 |
| 167 0, // @5 | 167 0, // @5 |
| 168 kExprElse, // @6 | 168 kExprElse, // @6 |
| 169 kExprI8Const, // @7 | 169 kExprI32Const, // @7 |
| 170 0, // @8 | 170 0, // @8 |
| 171 kExprEnd // @9 | 171 kExprEnd // @9 |
| 172 }; | 172 }; |
| 173 EXPECT_PC_DELTAS({2, 5}, {6, 4}); | 173 EXPECT_PC_DELTAS({2, 5}, {6, 4}); |
| 174 } | 174 } |
| 175 | 175 |
| 176 TEST_F(ControlTransferTest, SimpleIfElse1) { | 176 TEST_F(ControlTransferTest, SimpleIfElse1) { |
| 177 byte code[] = { | 177 byte code[] = { |
| 178 kExprI32Const, // @0 | 178 kExprI32Const, // @0 |
| 179 0, // @1 | 179 0, // @1 |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 kExprNop, // @2 | 253 kExprNop, // @2 |
| 254 kExprBr, // @3 | 254 kExprBr, // @3 |
| 255 0, // @4 | 255 0, // @4 |
| 256 kExprEnd // @5 | 256 kExprEnd // @5 |
| 257 }; | 257 }; |
| 258 EXPECT_PC_DELTAS({3, 3}); | 258 EXPECT_PC_DELTAS({3, 3}); |
| 259 } | 259 } |
| 260 | 260 |
| 261 TEST_F(ControlTransferTest, Br_v1a) { | 261 TEST_F(ControlTransferTest, Br_v1a) { |
| 262 byte code[] = { | 262 byte code[] = { |
| 263 kExprBlock, // @0 | 263 kExprBlock, // @0 |
| 264 kLocalVoid, // @1 | 264 kLocalVoid, // @1 |
| 265 kExprI8Const, // @2 | 265 kExprI32Const, // @2 |
| 266 0, // @3 | 266 0, // @3 |
| 267 kExprBr, // @4 | 267 kExprBr, // @4 |
| 268 0, // @5 | 268 0, // @5 |
| 269 kExprEnd // @6 | 269 kExprEnd // @6 |
| 270 }; | 270 }; |
| 271 EXPECT_PC_DELTAS({4, 3}); | 271 EXPECT_PC_DELTAS({4, 3}); |
| 272 } | 272 } |
| 273 | 273 |
| 274 TEST_F(ControlTransferTest, Br_v1b) { | 274 TEST_F(ControlTransferTest, Br_v1b) { |
| 275 byte code[] = { | 275 byte code[] = { |
| 276 kExprBlock, // @0 | 276 kExprBlock, // @0 |
| 277 kLocalVoid, // @1 | 277 kLocalVoid, // @1 |
| 278 kExprI8Const, // @2 | 278 kExprI32Const, // @2 |
| 279 0, // @3 | 279 0, // @3 |
| 280 kExprBr, // @4 | 280 kExprBr, // @4 |
| 281 0, // @5 | 281 0, // @5 |
| 282 kExprEnd // @6 | 282 kExprEnd // @6 |
| 283 }; | 283 }; |
| 284 EXPECT_PC_DELTAS({4, 3}); | 284 EXPECT_PC_DELTAS({4, 3}); |
| 285 } | 285 } |
| 286 | 286 |
| 287 TEST_F(ControlTransferTest, Br_v1c) { | 287 TEST_F(ControlTransferTest, Br_v1c) { |
| 288 byte code[] = { | 288 byte code[] = { |
| 289 kExprI8Const, // @0 | 289 kExprI32Const, // @0 |
| 290 0, // @1 | 290 0, // @1 |
| 291 kExprBlock, // @2 | 291 kExprBlock, // @2 |
| 292 kLocalVoid, // @3 | 292 kLocalVoid, // @3 |
| 293 kExprBr, // @4 | 293 kExprBr, // @4 |
| 294 0, // @5 | 294 0, // @5 |
| 295 kExprEnd // @6 | 295 kExprEnd // @6 |
| 296 }; | 296 }; |
| 297 EXPECT_PC_DELTAS({4, 3}); | 297 EXPECT_PC_DELTAS({4, 3}); |
| 298 } | 298 } |
| 299 | 299 |
| 300 TEST_F(ControlTransferTest, Br2) { | 300 TEST_F(ControlTransferTest, Br2) { |
| 301 byte code[] = { | 301 byte code[] = { |
| 302 kExprBlock, // @0 | 302 kExprBlock, // @0 |
| 303 kLocalVoid, // @1 | 303 kLocalVoid, // @1 |
| 304 kExprNop, // @2 | 304 kExprNop, // @2 |
| 305 kExprNop, // @3 | 305 kExprNop, // @3 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 kExprNop, // @2 | 376 kExprNop, // @2 |
| 377 kExprBr, // @3 | 377 kExprBr, // @3 |
| 378 1, // @4 | 378 1, // @4 |
| 379 kExprEnd // @5 | 379 kExprEnd // @5 |
| 380 }; | 380 }; |
| 381 EXPECT_PC_DELTAS({3, 3}); | 381 EXPECT_PC_DELTAS({3, 3}); |
| 382 } | 382 } |
| 383 | 383 |
| 384 TEST_F(ControlTransferTest, BrTable0) { | 384 TEST_F(ControlTransferTest, BrTable0) { |
| 385 byte code[] = { | 385 byte code[] = { |
| 386 kExprBlock, // @0 | 386 kExprBlock, // @0 |
| 387 kLocalVoid, // @1 | 387 kLocalVoid, // @1 |
| 388 kExprI8Const, // @2 | 388 kExprI32Const, // @2 |
| 389 0, // @3 | 389 0, // @3 |
| 390 kExprBrTable, // @4 | 390 kExprBrTable, // @4 |
| 391 0, // @5 | 391 0, // @5 |
| 392 U32V_1(0), // @6 | 392 U32V_1(0), // @6 |
| 393 kExprEnd // @7 | 393 kExprEnd // @7 |
| 394 }; | 394 }; |
| 395 EXPECT_PC_DELTAS({4, 4}); | 395 EXPECT_PC_DELTAS({4, 4}); |
| 396 } | 396 } |
| 397 | 397 |
| 398 TEST_F(ControlTransferTest, BrTable0_v1a) { | 398 TEST_F(ControlTransferTest, BrTable0_v1a) { |
| 399 byte code[] = { | 399 byte code[] = { |
| 400 kExprBlock, // @0 | 400 kExprBlock, // @0 |
| 401 kLocalVoid, // @1 | 401 kLocalVoid, // @1 |
| 402 kExprI8Const, // @2 | 402 kExprI32Const, // @2 |
| 403 0, // @3 | 403 0, // @3 |
| 404 kExprI8Const, // @4 | 404 kExprI32Const, // @4 |
| 405 0, // @5 | 405 0, // @5 |
| 406 kExprBrTable, // @6 | 406 kExprBrTable, // @6 |
| 407 0, // @7 | 407 0, // @7 |
| 408 U32V_1(0), // @8 | 408 U32V_1(0), // @8 |
| 409 kExprEnd // @9 | 409 kExprEnd // @9 |
| 410 }; | 410 }; |
| 411 EXPECT_PC_DELTAS({6, 4}); | 411 EXPECT_PC_DELTAS({6, 4}); |
| 412 } | 412 } |
| 413 | 413 |
| 414 TEST_F(ControlTransferTest, BrTable0_v1b) { | 414 TEST_F(ControlTransferTest, BrTable0_v1b) { |
| 415 byte code[] = { | 415 byte code[] = { |
| 416 kExprBlock, // @0 | 416 kExprBlock, // @0 |
| 417 kLocalVoid, // @1 | 417 kLocalVoid, // @1 |
| 418 kExprI8Const, // @2 | 418 kExprI32Const, // @2 |
| 419 0, // @3 | 419 0, // @3 |
| 420 kExprI8Const, // @4 | 420 kExprI32Const, // @4 |
| 421 0, // @5 | 421 0, // @5 |
| 422 kExprBrTable, // @6 | 422 kExprBrTable, // @6 |
| 423 0, // @7 | 423 0, // @7 |
| 424 U32V_1(0), // @8 | 424 U32V_1(0), // @8 |
| 425 kExprEnd // @9 | 425 kExprEnd // @9 |
| 426 }; | 426 }; |
| 427 EXPECT_PC_DELTAS({6, 4}); | 427 EXPECT_PC_DELTAS({6, 4}); |
| 428 } | 428 } |
| 429 | 429 |
| 430 TEST_F(ControlTransferTest, BrTable1) { | 430 TEST_F(ControlTransferTest, BrTable1) { |
| 431 byte code[] = { | 431 byte code[] = { |
| 432 kExprBlock, // @0 | 432 kExprBlock, // @0 |
| 433 kLocalVoid, // @1 | 433 kLocalVoid, // @1 |
| 434 kExprI8Const, // @2 | 434 kExprI32Const, // @2 |
| 435 0, // @3 | 435 0, // @3 |
| 436 kExprBrTable, // @4 | 436 kExprBrTable, // @4 |
| 437 1, // @5 | 437 1, // @5 |
| 438 U32V_1(0), // @6 | 438 U32V_1(0), // @6 |
| 439 U32V_1(0), // @7 | 439 U32V_1(0), // @7 |
| 440 kExprEnd // @8 | 440 kExprEnd // @8 |
| 441 }; | 441 }; |
| 442 EXPECT_PC_DELTAS({4, 5}, {5, 4}); | 442 EXPECT_PC_DELTAS({4, 5}, {5, 4}); |
| 443 } | 443 } |
| 444 | 444 |
| 445 TEST_F(ControlTransferTest, BrTable2) { | 445 TEST_F(ControlTransferTest, BrTable2) { |
| 446 byte code[] = { | 446 byte code[] = { |
| 447 kExprBlock, // @0 | 447 kExprBlock, // @0 |
| 448 kLocalVoid, // @1 | 448 kLocalVoid, // @1 |
| 449 kExprBlock, // @2 | 449 kExprBlock, // @2 |
| 450 kLocalVoid, // @3 | 450 kLocalVoid, // @3 |
| 451 kExprI8Const, // @4 | 451 kExprI32Const, // @4 |
| 452 0, // @5 | 452 0, // @5 |
| 453 kExprBrTable, // @6 | 453 kExprBrTable, // @6 |
| 454 2, // @7 | 454 2, // @7 |
| 455 U32V_1(0), // @8 | 455 U32V_1(0), // @8 |
| 456 U32V_1(0), // @9 | 456 U32V_1(0), // @9 |
| 457 U32V_1(1), // @10 | 457 U32V_1(1), // @10 |
| 458 kExprEnd, // @11 | 458 kExprEnd, // @11 |
| 459 kExprEnd // @12 | 459 kExprEnd // @12 |
| 460 }; | 460 }; |
| 461 EXPECT_PC_DELTAS({6, 6}, {7, 5}, {8, 5}); | 461 EXPECT_PC_DELTAS({6, 6}, {7, 5}, {8, 5}); |
| 462 } | 462 } |
| 463 | 463 |
| 464 } // namespace wasm | 464 } // namespace wasm |
| 465 } // namespace internal | 465 } // namespace internal |
| 466 } // namespace v8 | 466 } // namespace v8 |
| OLD | NEW |