| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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/bit-vector.h" | 5 #include "src/bit-vector.h" |
| 6 #include "src/compiler/escape-analysis.h" | 6 #include "src/compiler/escape-analysis.h" |
| 7 #include "src/compiler/escape-analysis-reducer.h" | 7 #include "src/compiler/escape-analysis-reducer.h" |
| 8 #include "src/compiler/graph-visualizer.h" | 8 #include "src/compiler/graph-visualizer.h" |
| 9 #include "src/compiler/js-graph.h" | 9 #include "src/compiler/js-graph.h" |
| 10 #include "src/compiler/node-properties.h" | 10 #include "src/compiler/node-properties.h" |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 | 133 |
| 134 FieldAccess AccessAtIndex(int offset) { | 134 FieldAccess AccessAtIndex(int offset) { |
| 135 FieldAccess access = {kTaggedBase, offset, MaybeHandle<Name>(), Type::Any(), | 135 FieldAccess access = {kTaggedBase, offset, MaybeHandle<Name>(), Type::Any(), |
| 136 MachineType::AnyTagged()}; | 136 MachineType::AnyTagged()}; |
| 137 return access; | 137 return access; |
| 138 } | 138 } |
| 139 | 139 |
| 140 // ---------------------------------Assertion Helper-------------------------- | 140 // ---------------------------------Assertion Helper-------------------------- |
| 141 | 141 |
| 142 void ExpectReplacement(Node* node, Node* rep) { | 142 void ExpectReplacement(Node* node, Node* rep) { |
| 143 EXPECT_EQ(rep, escape_analysis()->GetReplacement(node, node->id())); | 143 EXPECT_EQ(rep, escape_analysis()->GetReplacement(node)); |
| 144 } | 144 } |
| 145 | 145 |
| 146 void ExpectReplacementPhi(Node* node, Node* left, Node* right) { | 146 void ExpectReplacementPhi(Node* node, Node* left, Node* right) { |
| 147 Node* rep = escape_analysis()->GetReplacement(node, node->id()); | 147 Node* rep = escape_analysis()->GetReplacement(node); |
| 148 ASSERT_NE(nullptr, rep); | 148 ASSERT_NE(nullptr, rep); |
| 149 ASSERT_EQ(IrOpcode::kPhi, rep->opcode()); | 149 ASSERT_EQ(IrOpcode::kPhi, rep->opcode()); |
| 150 EXPECT_EQ(left, NodeProperties::GetValueInput(rep, 0)); | 150 EXPECT_EQ(left, NodeProperties::GetValueInput(rep, 0)); |
| 151 EXPECT_EQ(right, NodeProperties::GetValueInput(rep, 1)); | 151 EXPECT_EQ(right, NodeProperties::GetValueInput(rep, 1)); |
| 152 } | 152 } |
| 153 | 153 |
| 154 void ExpectVirtual(Node* node) { | 154 void ExpectVirtual(Node* node) { |
| 155 EXPECT_TRUE(node->opcode() == IrOpcode::kAllocate || | 155 EXPECT_TRUE(node->opcode() == IrOpcode::kAllocate || |
| 156 node->opcode() == IrOpcode::kFinishRegion); | 156 node->opcode() == IrOpcode::kFinishRegion); |
| 157 EXPECT_TRUE(escape_analysis()->IsVirtual(node)); | 157 EXPECT_TRUE(escape_analysis()->IsVirtual(node)); |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 Node* effect2 = Store(AccessAtIndex(0), allocation, object2, finish, ifTrue); | 263 Node* effect2 = Store(AccessAtIndex(0), allocation, object2, finish, ifTrue); |
| 264 Node* merge = Merge2(ifFalse, ifTrue); | 264 Node* merge = Merge2(ifFalse, ifTrue); |
| 265 Node* phi = graph()->NewNode(common()->EffectPhi(2), effect1, effect2, merge); | 265 Node* phi = graph()->NewNode(common()->EffectPhi(2), effect1, effect2, merge); |
| 266 Node* load = Load(AccessAtIndex(0), finish, phi, merge); | 266 Node* load = Load(AccessAtIndex(0), finish, phi, merge); |
| 267 Node* result = Return(load, phi); | 267 Node* result = Return(load, phi); |
| 268 EndGraph(); | 268 EndGraph(); |
| 269 Analysis(); | 269 Analysis(); |
| 270 | 270 |
| 271 ExpectVirtual(allocation); | 271 ExpectVirtual(allocation); |
| 272 ExpectReplacementPhi(load, object1, object2); | 272 ExpectReplacementPhi(load, object1, object2); |
| 273 Node* replacement_phi = escape_analysis()->GetReplacement(load, load->id()); | 273 Node* replacement_phi = escape_analysis()->GetReplacement(load); |
| 274 | 274 |
| 275 Transformation(); | 275 Transformation(); |
| 276 | 276 |
| 277 ASSERT_EQ(replacement_phi, NodeProperties::GetValueInput(result, 0)); | 277 ASSERT_EQ(replacement_phi, NodeProperties::GetValueInput(result, 0)); |
| 278 } | 278 } |
| 279 | 279 |
| 280 | 280 |
| 281 TEST_F(EscapeAnalysisTest, DanglingLoadOrder) { | 281 TEST_F(EscapeAnalysisTest, DanglingLoadOrder) { |
| 282 Node* object1 = Constant(1); | 282 Node* object1 = Constant(1); |
| 283 Node* object2 = Constant(2); | 283 Node* object2 = Constant(2); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 296 ExpectReplacement(load2, object1); | 296 ExpectReplacement(load2, object1); |
| 297 | 297 |
| 298 Transformation(); | 298 Transformation(); |
| 299 | 299 |
| 300 ASSERT_EQ(object1, NodeProperties::GetValueInput(result, 0)); | 300 ASSERT_EQ(object1, NodeProperties::GetValueInput(result, 0)); |
| 301 } | 301 } |
| 302 | 302 |
| 303 } // namespace compiler | 303 } // namespace compiler |
| 304 } // namespace internal | 304 } // namespace internal |
| 305 } // namespace v8 | 305 } // namespace v8 |
| OLD | NEW |