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/objects-inl.h" | 10 #include "src/objects-inl.h" |
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
391 CHECK_EQ(write_count(), 2); | 391 CHECK_EQ(write_count(), 2); |
392 CHECK_EQ(last_written().bytecode(), Bytecode::kLdar); | 392 CHECK_EQ(last_written().bytecode(), Bytecode::kLdar); |
393 CHECK_EQ(last_written().operand(0), operands[expected_operand_count - 1]); | 393 CHECK_EQ(last_written().operand(0), operands[expected_operand_count - 1]); |
394 Flush(); | 394 Flush(); |
395 CHECK_EQ(last_written().bytecode(), third.bytecode()); | 395 CHECK_EQ(last_written().bytecode(), third.bytecode()); |
396 } | 396 } |
397 | 397 |
398 TEST_F(BytecodePeepholeOptimizerTest, MergeLdaContextSlotStar) { | 398 TEST_F(BytecodePeepholeOptimizerTest, MergeLdaContextSlotStar) { |
399 const uint32_t operands[] = { | 399 const uint32_t operands[] = { |
400 static_cast<uint32_t>(Register(200000).ToOperand()), 55005500, | 400 static_cast<uint32_t>(Register(200000).ToOperand()), 55005500, |
| 401 static_cast<uint32_t>(Register(0).ToOperand()), |
401 static_cast<uint32_t>(Register(1).ToOperand())}; | 402 static_cast<uint32_t>(Register(1).ToOperand())}; |
402 const int expected_operand_count = static_cast<int>(arraysize(operands)); | 403 const int expected_operand_count = static_cast<int>(arraysize(operands)); |
403 | 404 |
404 BytecodeNode first(Bytecode::kLdaContextSlot, operands[0], operands[1]); | 405 BytecodeNode first(Bytecode::kLdaContextSlot, operands[0], operands[1], |
405 BytecodeNode second(Bytecode::kStar, operands[2]); | 406 operands[2]); |
| 407 BytecodeNode second(Bytecode::kStar, operands[3]); |
406 BytecodeNode third(Bytecode::kReturn); | 408 BytecodeNode third(Bytecode::kReturn); |
407 optimizer()->Write(&first); | 409 optimizer()->Write(&first); |
408 optimizer()->Write(&second); | 410 optimizer()->Write(&second); |
409 CHECK_EQ(write_count(), 1); | 411 CHECK_EQ(write_count(), 1); |
410 CHECK_EQ(last_written().bytecode(), Bytecode::kLdrContextSlot); | 412 CHECK_EQ(last_written().bytecode(), Bytecode::kLdrContextSlot); |
411 CHECK_EQ(last_written().operand_count(), expected_operand_count); | 413 CHECK_EQ(last_written().operand_count(), expected_operand_count); |
412 for (int i = 0; i < expected_operand_count; ++i) { | 414 for (int i = 0; i < expected_operand_count; ++i) { |
413 CHECK_EQ(last_written().operand(i), operands[i]); | 415 CHECK_EQ(last_written().operand(i), operands[i]); |
414 } | 416 } |
415 optimizer()->Write(&third); | 417 optimizer()->Write(&third); |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
522 CHECK_EQ(last_written().operand(0), 0); | 524 CHECK_EQ(last_written().operand(0), 0); |
523 CHECK_EQ(last_written().operand(1), reg_operand); | 525 CHECK_EQ(last_written().operand(1), reg_operand); |
524 CHECK_EQ(last_written().operand(2), idx_operand); | 526 CHECK_EQ(last_written().operand(2), idx_operand); |
525 Reset(); | 527 Reset(); |
526 } | 528 } |
527 } | 529 } |
528 | 530 |
529 } // namespace interpreter | 531 } // namespace interpreter |
530 } // namespace internal | 532 } // namespace internal |
531 } // namespace v8 | 533 } // namespace v8 |
OLD | NEW |