| 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-register-optimizer.h" | 9 #include "src/interpreter/bytecode-register-optimizer.h" |
| 10 #include "src/objects-inl.h" | 10 #include "src/objects-inl.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 TEST_F(BytecodeRegisterOptimizerTest, WriteNop) { | 67 TEST_F(BytecodeRegisterOptimizerTest, WriteNop) { |
| 68 Initialize(1, 1); | 68 Initialize(1, 1); |
| 69 BytecodeNode node(Bytecode::kNop); | 69 BytecodeNode node(Bytecode::kNop); |
| 70 optimizer()->Write(&node); | 70 optimizer()->Write(&node); |
| 71 CHECK_EQ(write_count(), 1); | 71 CHECK_EQ(write_count(), 1); |
| 72 CHECK_EQ(node, last_written()); | 72 CHECK_EQ(node, last_written()); |
| 73 } | 73 } |
| 74 | 74 |
| 75 TEST_F(BytecodeRegisterOptimizerTest, WriteNopExpression) { | 75 TEST_F(BytecodeRegisterOptimizerTest, WriteNopExpression) { |
| 76 Initialize(1, 1); | 76 Initialize(1, 1); |
| 77 BytecodeSourceInfo source_info(3, false); | 77 BytecodeNode node(Bytecode::kNop); |
| 78 BytecodeNode node(Bytecode::kNop, &source_info); | 78 node.source_info().MakeExpressionPosition(3); |
| 79 optimizer()->Write(&node); | 79 optimizer()->Write(&node); |
| 80 CHECK_EQ(write_count(), 1); | 80 CHECK_EQ(write_count(), 1); |
| 81 CHECK_EQ(node, last_written()); | 81 CHECK_EQ(node, last_written()); |
| 82 } | 82 } |
| 83 | 83 |
| 84 TEST_F(BytecodeRegisterOptimizerTest, WriteNopStatement) { | 84 TEST_F(BytecodeRegisterOptimizerTest, WriteNopStatement) { |
| 85 Initialize(1, 1); | 85 Initialize(1, 1); |
| 86 BytecodeSourceInfo source_info(3, true); | |
| 87 BytecodeNode node(Bytecode::kNop); | 86 BytecodeNode node(Bytecode::kNop); |
| 87 node.source_info().MakeStatementPosition(3); |
| 88 optimizer()->Write(&node); | 88 optimizer()->Write(&node); |
| 89 CHECK_EQ(write_count(), 1); | 89 CHECK_EQ(write_count(), 1); |
| 90 CHECK_EQ(node, last_written()); | 90 CHECK_EQ(node, last_written()); |
| 91 } | 91 } |
| 92 | 92 |
| 93 TEST_F(BytecodeRegisterOptimizerTest, TemporaryMaterializedForJump) { | 93 TEST_F(BytecodeRegisterOptimizerTest, TemporaryMaterializedForJump) { |
| 94 Initialize(1, 1); | 94 Initialize(1, 1); |
| 95 Register temp = NewTemporary(); | 95 Register temp = NewTemporary(); |
| 96 BytecodeNode node(Bytecode::kStar, temp.ToOperand()); | 96 BytecodeNode node(Bytecode::kStar, temp.ToOperand()); |
| 97 optimizer()->Write(&node); | 97 optimizer()->Write(&node); |
| 98 CHECK_EQ(write_count(), 0); | 98 CHECK_EQ(write_count(), 0); |
| 99 BytecodeLabel label; | 99 BytecodeLabel label; |
| 100 BytecodeNode jump(Bytecode::kJump, 0, nullptr); | 100 BytecodeNode jump(Bytecode::kJump, 0); |
| 101 optimizer()->WriteJump(&jump, &label); | 101 optimizer()->WriteJump(&jump, &label); |
| 102 CHECK_EQ(write_count(), 2); | 102 CHECK_EQ(write_count(), 2); |
| 103 CHECK_EQ(output()->at(0).bytecode(), Bytecode::kStar); | 103 CHECK_EQ(output()->at(0).bytecode(), Bytecode::kStar); |
| 104 CHECK_EQ(output()->at(0).operand(0), temp.ToOperand()); | 104 CHECK_EQ(output()->at(0).operand(0), temp.ToOperand()); |
| 105 CHECK_EQ(output()->at(1).bytecode(), Bytecode::kJump); | 105 CHECK_EQ(output()->at(1).bytecode(), Bytecode::kJump); |
| 106 } | 106 } |
| 107 | 107 |
| 108 TEST_F(BytecodeRegisterOptimizerTest, TemporaryMaterializedForBind) { | 108 TEST_F(BytecodeRegisterOptimizerTest, TemporaryMaterializedForBind) { |
| 109 Initialize(1, 1); | 109 Initialize(1, 1); |
| 110 Register temp = NewTemporary(); | 110 Register temp = NewTemporary(); |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 | 210 |
| 211 CHECK_EQ(output()->at(3).bytecode(), Bytecode::kCallJSRuntime); | 211 CHECK_EQ(output()->at(3).bytecode(), Bytecode::kCallJSRuntime); |
| 212 CHECK_EQ(output()->at(3).operand(0), 0); | 212 CHECK_EQ(output()->at(3).operand(0), 0); |
| 213 CHECK_EQ(output()->at(3).operand(1), temp0.ToOperand()); | 213 CHECK_EQ(output()->at(3).operand(1), temp0.ToOperand()); |
| 214 CHECK_EQ(output()->at(3).operand(2), 2); | 214 CHECK_EQ(output()->at(3).operand(2), 2); |
| 215 } | 215 } |
| 216 | 216 |
| 217 } // namespace interpreter | 217 } // namespace interpreter |
| 218 } // namespace internal | 218 } // namespace internal |
| 219 } // namespace v8 | 219 } // namespace v8 |
| OLD | NEW |