| 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 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 CHECK_EQ(write_count(), 1); | 397 CHECK_EQ(write_count(), 1); |
| 398 CHECK_EQ(last_written().bytecode(), operator_replacement[1]); | 398 CHECK_EQ(last_written().bytecode(), operator_replacement[1]); |
| 399 CHECK_EQ(last_written().operand_count(), 3); | 399 CHECK_EQ(last_written().operand_count(), 3); |
| 400 CHECK_EQ(last_written().operand(0), 0u); | 400 CHECK_EQ(last_written().operand(0), 0u); |
| 401 CHECK_EQ(last_written().operand(1), reg_operand); | 401 CHECK_EQ(last_written().operand(1), reg_operand); |
| 402 CHECK_EQ(last_written().operand(2), idx_operand); | 402 CHECK_EQ(last_written().operand(2), idx_operand); |
| 403 Reset(); | 403 Reset(); |
| 404 } | 404 } |
| 405 } | 405 } |
| 406 | 406 |
| 407 TEST_F(BytecodePeepholeOptimizerTest, MergeLdaNullOrUndefinedWithCompareOp) { | |
| 408 Bytecode first_bytecodes[] = {Bytecode::kLdaUndefined, Bytecode::kLdaNull}; | |
| 409 | |
| 410 for (auto first_bytecode : first_bytecodes) { | |
| 411 uint32_t reg_operand = Register(0).ToOperand(); | |
| 412 uint32_t idx_operand = 1; | |
| 413 BytecodeNode first(first_bytecode); | |
| 414 BytecodeNode second(Bytecode::kTestEqual, reg_operand, idx_operand); | |
| 415 optimizer()->Write(&first); | |
| 416 optimizer()->Write(&second); | |
| 417 Flush(); | |
| 418 CHECK_EQ(write_count(), 1); | |
| 419 CHECK_EQ(last_written().bytecode(), Bytecode::kTestUndetectable); | |
| 420 CHECK_EQ(last_written().operand_count(), 1); | |
| 421 CHECK_EQ(last_written().operand(0), reg_operand); | |
| 422 Reset(); | |
| 423 } | |
| 424 } | |
| 425 | |
| 426 } // namespace interpreter | 407 } // namespace interpreter |
| 427 } // namespace internal | 408 } // namespace internal |
| 428 } // namespace v8 | 409 } // namespace v8 |
| OLD | NEW |