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 "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/interpreter/constant-array-builder.h" | 10 #include "src/interpreter/constant-array-builder.h" |
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
410 } | 410 } |
411 optimizer()->Write(&third); | 411 optimizer()->Write(&third); |
412 CHECK_EQ(write_count(), 2); | 412 CHECK_EQ(write_count(), 2); |
413 CHECK_EQ(last_written().bytecode(), Bytecode::kLdar); | 413 CHECK_EQ(last_written().bytecode(), Bytecode::kLdar); |
414 CHECK_EQ(last_written().operand(0), operands[expected_operand_count - 1]); | 414 CHECK_EQ(last_written().operand(0), operands[expected_operand_count - 1]); |
415 Flush(); | 415 Flush(); |
416 CHECK_EQ(last_written().bytecode(), third.bytecode()); | 416 CHECK_EQ(last_written().bytecode(), third.bytecode()); |
417 } | 417 } |
418 | 418 |
419 TEST_F(BytecodePeepholeOptimizerTest, MergeLdaGlobalStar) { | 419 TEST_F(BytecodePeepholeOptimizerTest, MergeLdaGlobalStar) { |
420 const uint32_t operands[] = {54321, 19191, | 420 const uint32_t operands[] = {19191, |
421 static_cast<uint32_t>(Register(1).ToOperand())}; | 421 static_cast<uint32_t>(Register(1).ToOperand())}; |
422 const int expected_operand_count = static_cast<int>(arraysize(operands)); | 422 const int expected_operand_count = static_cast<int>(arraysize(operands)); |
423 | 423 |
424 BytecodeNode first(Bytecode::kLdaGlobal, operands[0], operands[1]); | 424 BytecodeNode first(Bytecode::kLdaGlobal, operands[0]); |
425 BytecodeNode second(Bytecode::kStar, operands[2]); | 425 BytecodeNode second(Bytecode::kStar, operands[1]); |
426 BytecodeNode third(Bytecode::kReturn); | 426 BytecodeNode third(Bytecode::kReturn); |
427 optimizer()->Write(&first); | 427 optimizer()->Write(&first); |
428 optimizer()->Write(&second); | 428 optimizer()->Write(&second); |
429 CHECK_EQ(write_count(), 1); | 429 CHECK_EQ(write_count(), 1); |
430 CHECK_EQ(last_written().bytecode(), Bytecode::kLdrGlobal); | 430 CHECK_EQ(last_written().bytecode(), Bytecode::kLdrGlobal); |
431 CHECK_EQ(last_written().operand_count(), expected_operand_count); | 431 CHECK_EQ(last_written().operand_count(), expected_operand_count); |
432 for (int i = 0; i < expected_operand_count; ++i) { | 432 for (int i = 0; i < expected_operand_count; ++i) { |
433 CHECK_EQ(last_written().operand(i), operands[i]); | 433 CHECK_EQ(last_written().operand(i), operands[i]); |
434 } | 434 } |
435 optimizer()->Write(&third); | 435 optimizer()->Write(&third); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
485 CHECK_EQ(write_count(), 2); | 485 CHECK_EQ(write_count(), 2); |
486 CHECK_EQ(last_written().bytecode(), Bytecode::kLdar); | 486 CHECK_EQ(last_written().bytecode(), Bytecode::kLdar); |
487 CHECK_EQ(last_written().operand(0), operands[expected_operand_count - 1]); | 487 CHECK_EQ(last_written().operand(0), operands[expected_operand_count - 1]); |
488 Flush(); | 488 Flush(); |
489 CHECK_EQ(last_written().bytecode(), third.bytecode()); | 489 CHECK_EQ(last_written().bytecode(), third.bytecode()); |
490 } | 490 } |
491 | 491 |
492 } // namespace interpreter | 492 } // namespace interpreter |
493 } // namespace internal | 493 } // namespace internal |
494 } // namespace v8 | 494 } // namespace v8 |
OLD | NEW |