| 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/compiler/js-inlining-heuristic.h" | 5 #include "src/compiler/js-inlining-heuristic.h" |
| 6 | 6 |
| 7 #include "src/compiler.h" | 7 #include "src/compiler.h" |
| 8 #include "src/compiler/node-matchers.h" | 8 #include "src/compiler/node-matchers.h" |
| 9 #include "src/objects-inl.h" | 9 #include "src/objects-inl.h" |
| 10 | 10 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 // Stop inlinining once the maximum allowed level is reached. | 68 // Stop inlinining once the maximum allowed level is reached. |
| 69 int level = 0; | 69 int level = 0; |
| 70 for (Node* frame_state = NodeProperties::GetFrameStateInput(node, 0); | 70 for (Node* frame_state = NodeProperties::GetFrameStateInput(node, 0); |
| 71 frame_state->opcode() == IrOpcode::kFrameState; | 71 frame_state->opcode() == IrOpcode::kFrameState; |
| 72 frame_state = NodeProperties::GetFrameStateInput(frame_state, 0)) { | 72 frame_state = NodeProperties::GetFrameStateInput(frame_state, 0)) { |
| 73 if (++level > FLAG_max_inlining_levels) return NoChange(); | 73 if (++level > FLAG_max_inlining_levels) return NoChange(); |
| 74 } | 74 } |
| 75 | 75 |
| 76 // Gather feedback on how often this call site has been hit before. | 76 // Gather feedback on how often this call site has been hit before. |
| 77 int calls = -1; // Same default as CallICNexus::ExtractCallCount. | 77 int calls = -1; // Same default as CallICNexus::ExtractCallCount. |
| 78 // TODO(turbofan): We also want call counts for constructor calls. |
| 78 if (node->opcode() == IrOpcode::kJSCallFunction) { | 79 if (node->opcode() == IrOpcode::kJSCallFunction) { |
| 79 CallFunctionParameters p = CallFunctionParametersOf(node->op()); | 80 CallFunctionParameters p = CallFunctionParametersOf(node->op()); |
| 80 if (p.feedback().IsValid()) { | 81 if (p.feedback().IsValid()) { |
| 81 CallICNexus nexus(p.feedback().vector(), p.feedback().slot()); | 82 CallICNexus nexus(p.feedback().vector(), p.feedback().slot()); |
| 82 calls = nexus.ExtractCallCount(); | 83 calls = nexus.ExtractCallCount(); |
| 83 } | 84 } |
| 84 } else if (node->opcode() == IrOpcode::kJSCallConstruct) { | |
| 85 CallConstructParameters p = CallConstructParametersOf(node->op()); | |
| 86 if (p.feedback().IsValid()) { | |
| 87 ConstructICNexus nexus(p.feedback().vector(), p.feedback().slot()); | |
| 88 calls = nexus.ExtractCallCount(); | |
| 89 } | |
| 90 } | 85 } |
| 91 | 86 |
| 92 // --------------------------------------------------------------------------- | 87 // --------------------------------------------------------------------------- |
| 93 // Everything above this line is part of the inlining heuristic. | 88 // Everything above this line is part of the inlining heuristic. |
| 94 // --------------------------------------------------------------------------- | 89 // --------------------------------------------------------------------------- |
| 95 | 90 |
| 96 // In the general case we remember the candidate for later. | 91 // In the general case we remember the candidate for later. |
| 97 candidates_.insert({function, node, calls}); | 92 candidates_.insert({function, node, calls}); |
| 98 return NoChange(); | 93 return NoChange(); |
| 99 } | 94 } |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 candidate.node->id(), candidate.calls, | 129 candidate.node->id(), candidate.calls, |
| 135 candidate.function->shared()->SourceSize(), | 130 candidate.function->shared()->SourceSize(), |
| 136 candidate.function->shared()->ast_node_count(), | 131 candidate.function->shared()->ast_node_count(), |
| 137 candidate.function->shared()->DebugName()->ToCString().get()); | 132 candidate.function->shared()->DebugName()->ToCString().get()); |
| 138 } | 133 } |
| 139 } | 134 } |
| 140 | 135 |
| 141 } // namespace compiler | 136 } // namespace compiler |
| 142 } // namespace internal | 137 } // namespace internal |
| 143 } // namespace v8 | 138 } // namespace v8 |
| OLD | NEW |