Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(577)

Side by Side Diff: test/unittests/interpreter/bytecode-peephole-optimizer-unittest.cc

Issue 2263253002: [interpreter] Make the binary op with Smi bytecode handlers collect type feedback. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Update. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/cctest/interpreter/test-interpreter.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/factory.h" 7 #include "src/factory.h"
8 #include "src/interpreter/bytecode-label.h" 8 #include "src/interpreter/bytecode-label.h"
9 #include "src/interpreter/bytecode-peephole-optimizer.h" 9 #include "src/interpreter/bytecode-peephole-optimizer.h"
10 #include "src/objects-inl.h" 10 #include "src/objects-inl.h"
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 {Bytecode::kBitwiseAnd, Bytecode::kBitwiseAndSmi}, 451 {Bytecode::kBitwiseAnd, Bytecode::kBitwiseAndSmi},
452 {Bytecode::kBitwiseOr, Bytecode::kBitwiseOrSmi}, 452 {Bytecode::kBitwiseOr, Bytecode::kBitwiseOrSmi},
453 {Bytecode::kShiftLeft, Bytecode::kShiftLeftSmi}, 453 {Bytecode::kShiftLeft, Bytecode::kShiftLeftSmi},
454 {Bytecode::kShiftRight, Bytecode::kShiftRightSmi}}; 454 {Bytecode::kShiftRight, Bytecode::kShiftRightSmi}};
455 455
456 for (auto operator_replacement : operator_replacement_pairs) { 456 for (auto operator_replacement : operator_replacement_pairs) {
457 uint32_t imm_operand = 17; 457 uint32_t imm_operand = 17;
458 BytecodeNode first(Bytecode::kLdaSmi, imm_operand); 458 BytecodeNode first(Bytecode::kLdaSmi, imm_operand);
459 first.source_info().Clone({3, true}); 459 first.source_info().Clone({3, true});
460 uint32_t reg_operand = Register(0).ToOperand(); 460 uint32_t reg_operand = Register(0).ToOperand();
461 BytecodeNode second(operator_replacement[0], reg_operand, 1); 461 uint32_t idx_operand = 1;
462 BytecodeNode second(operator_replacement[0], reg_operand, idx_operand);
462 optimizer()->Write(&first); 463 optimizer()->Write(&first);
463 optimizer()->Write(&second); 464 optimizer()->Write(&second);
464 Flush(); 465 Flush();
465 CHECK_EQ(write_count(), 1); 466 CHECK_EQ(write_count(), 1);
466 CHECK_EQ(last_written().bytecode(), operator_replacement[1]); 467 CHECK_EQ(last_written().bytecode(), operator_replacement[1]);
467 CHECK_EQ(last_written().operand_count(), 2); 468 CHECK_EQ(last_written().operand_count(), 3);
468 CHECK_EQ(last_written().operand(0), imm_operand); 469 CHECK_EQ(last_written().operand(0), imm_operand);
469 CHECK_EQ(last_written().operand(1), reg_operand); 470 CHECK_EQ(last_written().operand(1), reg_operand);
471 CHECK_EQ(last_written().operand(2), idx_operand);
470 CHECK_EQ(last_written().source_info(), first.source_info()); 472 CHECK_EQ(last_written().source_info(), first.source_info());
471 Reset(); 473 Reset();
472 } 474 }
473 } 475 }
474 476
475 TEST_F(BytecodePeepholeOptimizerTest, NotMergingLdaSmiWithBinaryOp) { 477 TEST_F(BytecodePeepholeOptimizerTest, NotMergingLdaSmiWithBinaryOp) {
476 Bytecode operator_replacement_pairs[][2] = { 478 Bytecode operator_replacement_pairs[][2] = {
477 {Bytecode::kAdd, Bytecode::kAddSmi}, 479 {Bytecode::kAdd, Bytecode::kAddSmi},
478 {Bytecode::kSub, Bytecode::kSubSmi}, 480 {Bytecode::kSub, Bytecode::kSubSmi},
479 {Bytecode::kBitwiseAnd, Bytecode::kBitwiseAndSmi}, 481 {Bytecode::kBitwiseAnd, Bytecode::kBitwiseAndSmi},
(...skipping 22 matching lines...) Expand all
502 {Bytecode::kAdd, Bytecode::kAddSmi}, 504 {Bytecode::kAdd, Bytecode::kAddSmi},
503 {Bytecode::kSub, Bytecode::kSubSmi}, 505 {Bytecode::kSub, Bytecode::kSubSmi},
504 {Bytecode::kBitwiseAnd, Bytecode::kBitwiseAndSmi}, 506 {Bytecode::kBitwiseAnd, Bytecode::kBitwiseAndSmi},
505 {Bytecode::kBitwiseOr, Bytecode::kBitwiseOrSmi}, 507 {Bytecode::kBitwiseOr, Bytecode::kBitwiseOrSmi},
506 {Bytecode::kShiftLeft, Bytecode::kShiftLeftSmi}, 508 {Bytecode::kShiftLeft, Bytecode::kShiftLeftSmi},
507 {Bytecode::kShiftRight, Bytecode::kShiftRightSmi}}; 509 {Bytecode::kShiftRight, Bytecode::kShiftRightSmi}};
508 510
509 for (auto operator_replacement : operator_replacement_pairs) { 511 for (auto operator_replacement : operator_replacement_pairs) {
510 BytecodeNode first(Bytecode::kLdaZero); 512 BytecodeNode first(Bytecode::kLdaZero);
511 uint32_t reg_operand = Register(0).ToOperand(); 513 uint32_t reg_operand = Register(0).ToOperand();
512 BytecodeNode second(operator_replacement[0], reg_operand, 1); 514 uint32_t idx_operand = 1;
515 BytecodeNode second(operator_replacement[0], reg_operand, idx_operand);
513 optimizer()->Write(&first); 516 optimizer()->Write(&first);
514 optimizer()->Write(&second); 517 optimizer()->Write(&second);
515 Flush(); 518 Flush();
516 CHECK_EQ(write_count(), 1); 519 CHECK_EQ(write_count(), 1);
517 CHECK_EQ(last_written().bytecode(), operator_replacement[1]); 520 CHECK_EQ(last_written().bytecode(), operator_replacement[1]);
518 CHECK_EQ(last_written().operand_count(), 2); 521 CHECK_EQ(last_written().operand_count(), 3);
519 CHECK_EQ(last_written().operand(0), 0); 522 CHECK_EQ(last_written().operand(0), 0);
520 CHECK_EQ(last_written().operand(1), reg_operand); 523 CHECK_EQ(last_written().operand(1), reg_operand);
524 CHECK_EQ(last_written().operand(2), idx_operand);
521 Reset(); 525 Reset();
522 } 526 }
523 } 527 }
524 528
525 } // namespace interpreter 529 } // namespace interpreter
526 } // namespace internal 530 } // namespace internal
527 } // namespace v8 531 } // namespace v8
OLDNEW
« no previous file with comments | « test/cctest/interpreter/test-interpreter.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698