| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/ast.h" | 5 #include "src/ast.h" |
| 6 #include "src/ast-numbering.h" | 6 #include "src/ast-numbering.h" |
| 7 #include "src/compiler/access-builder.h" | 7 #include "src/compiler/access-builder.h" |
| 8 #include "src/compiler/ast-graph-builder.h" | 8 #include "src/compiler/ast-graph-builder.h" |
| 9 #include "src/compiler/common-operator.h" | 9 #include "src/compiler/common-operator.h" |
| 10 #include "src/compiler/generic-node-inl.h" | 10 #include "src/compiler/generic-node-inl.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 | 25 |
| 26 | 26 |
| 27 namespace v8 { | 27 namespace v8 { |
| 28 namespace internal { | 28 namespace internal { |
| 29 namespace compiler { | 29 namespace compiler { |
| 30 | 30 |
| 31 class InlinerVisitor : public NullNodeVisitor { | 31 class InlinerVisitor : public NullNodeVisitor { |
| 32 public: | 32 public: |
| 33 explicit InlinerVisitor(JSInliner* inliner) : inliner_(inliner) {} | 33 explicit InlinerVisitor(JSInliner* inliner) : inliner_(inliner) {} |
| 34 | 34 |
| 35 GenericGraphVisit::Control Post(Node* node) { | 35 void Post(Node* node) { |
| 36 switch (node->opcode()) { | 36 switch (node->opcode()) { |
| 37 case IrOpcode::kJSCallFunction: | 37 case IrOpcode::kJSCallFunction: |
| 38 inliner_->TryInlineJSCall(node); | 38 inliner_->TryInlineJSCall(node); |
| 39 break; | 39 break; |
| 40 case IrOpcode::kJSCallRuntime: | 40 case IrOpcode::kJSCallRuntime: |
| 41 if (FLAG_turbo_inlining_intrinsics) { | 41 if (FLAG_turbo_inlining_intrinsics) { |
| 42 inliner_->TryInlineRuntimeCall(node); | 42 inliner_->TryInlineRuntimeCall(node); |
| 43 } | 43 } |
| 44 break; | 44 break; |
| 45 default: | 45 default: |
| 46 break; | 46 break; |
| 47 } | 47 } |
| 48 return GenericGraphVisit::CONTINUE; | |
| 49 } | 48 } |
| 50 | 49 |
| 51 private: | 50 private: |
| 52 JSInliner* inliner_; | 51 JSInliner* inliner_; |
| 53 }; | 52 }; |
| 54 | 53 |
| 55 | 54 |
| 56 void JSInliner::Inline() { | 55 void JSInliner::Inline() { |
| 57 InlinerVisitor visitor(this); | 56 InlinerVisitor visitor(this); |
| 58 jsgraph_->graph()->VisitNodeInputsFromEnd(&visitor); | 57 jsgraph_->graph()->VisitNodeInputsFromEnd(&visitor); |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 public: | 159 public: |
| 161 CopyVisitor(Graph* source_graph, Graph* target_graph, Zone* temp_zone) | 160 CopyVisitor(Graph* source_graph, Graph* target_graph, Zone* temp_zone) |
| 162 : copies_(source_graph->NodeCount(), NULL, temp_zone), | 161 : copies_(source_graph->NodeCount(), NULL, temp_zone), |
| 163 sentinels_(source_graph->NodeCount(), NULL, temp_zone), | 162 sentinels_(source_graph->NodeCount(), NULL, temp_zone), |
| 164 source_graph_(source_graph), | 163 source_graph_(source_graph), |
| 165 target_graph_(target_graph), | 164 target_graph_(target_graph), |
| 166 temp_zone_(temp_zone), | 165 temp_zone_(temp_zone), |
| 167 sentinel_op_(IrOpcode::kDead, Operator::kNoProperties, "sentinel", 0, 0, | 166 sentinel_op_(IrOpcode::kDead, Operator::kNoProperties, "sentinel", 0, 0, |
| 168 0, 0, 0, 0) {} | 167 0, 0, 0, 0) {} |
| 169 | 168 |
| 170 GenericGraphVisit::Control Post(Node* original) { | 169 void Post(Node* original) { |
| 171 NodeVector inputs(temp_zone_); | 170 NodeVector inputs(temp_zone_); |
| 172 for (InputIter it = original->inputs().begin(); | 171 for (InputIter it = original->inputs().begin(); |
| 173 it != original->inputs().end(); ++it) { | 172 it != original->inputs().end(); ++it) { |
| 174 inputs.push_back(GetCopy(*it)); | 173 inputs.push_back(GetCopy(*it)); |
| 175 } | 174 } |
| 176 | 175 |
| 177 // Reuse the operator in the copy. This assumes that op lives in a zone | 176 // Reuse the operator in the copy. This assumes that op lives in a zone |
| 178 // that lives longer than graph()'s zone. | 177 // that lives longer than graph()'s zone. |
| 179 Node* copy = | 178 Node* copy = |
| 180 target_graph_->NewNode(original->op(), static_cast<int>(inputs.size()), | 179 target_graph_->NewNode(original->op(), static_cast<int>(inputs.size()), |
| 181 (inputs.empty() ? NULL : &inputs.front())); | 180 (inputs.empty() ? NULL : &inputs.front())); |
| 182 copies_[original->id()] = copy; | 181 copies_[original->id()] = copy; |
| 183 return GenericGraphVisit::CONTINUE; | |
| 184 } | 182 } |
| 185 | 183 |
| 186 Node* GetCopy(Node* original) { | 184 Node* GetCopy(Node* original) { |
| 187 Node* copy = copies_[original->id()]; | 185 Node* copy = copies_[original->id()]; |
| 188 if (copy == NULL) { | 186 if (copy == NULL) { |
| 189 copy = GetSentinel(original); | 187 copy = GetSentinel(original); |
| 190 } | 188 } |
| 191 DCHECK_NE(NULL, copy); | 189 DCHECK_NE(NULL, copy); |
| 192 return copy; | 190 return copy; |
| 193 } | 191 } |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 488 info_->shared_info()->DebugName()->ToCString().get()); | 486 info_->shared_info()->DebugName()->ToCString().get()); |
| 489 } | 487 } |
| 490 NodeProperties::ReplaceWithValue(call_node, r.first, r.second); | 488 NodeProperties::ReplaceWithValue(call_node, r.first, r.second); |
| 491 call_node->RemoveAllInputs(); | 489 call_node->RemoveAllInputs(); |
| 492 DCHECK_EQ(0, call_node->UseCount()); | 490 DCHECK_EQ(0, call_node->UseCount()); |
| 493 } | 491 } |
| 494 } | 492 } |
| 495 } | 493 } |
| 496 } | 494 } |
| 497 } // namespace v8::internal::compiler | 495 } // namespace v8::internal::compiler |
| OLD | NEW |