| 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/compiler/js-inlining.h" | 5 #include "src/compiler/js-inlining.h" |
| 6 | 6 |
| 7 #include "src/ast.h" | 7 #include "src/ast.h" |
| 8 #include "src/ast-numbering.h" | 8 #include "src/ast-numbering.h" |
| 9 #include "src/compiler.h" | 9 #include "src/compiler.h" |
| 10 #include "src/compiler/all-nodes.h" | 10 #include "src/compiler/all-nodes.h" |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 | 131 |
| 132 // {inliner_inputs} counts JSFunction, Receiver, arguments, but not | 132 // {inliner_inputs} counts JSFunction, Receiver, arguments, but not |
| 133 // context, effect, control. | 133 // context, effect, control. |
| 134 int inliner_inputs = call->op()->ValueInputCount(); | 134 int inliner_inputs = call->op()->ValueInputCount(); |
| 135 // Iterate over all uses of the start node. | 135 // Iterate over all uses of the start node. |
| 136 for (Edge edge : start->use_edges()) { | 136 for (Edge edge : start->use_edges()) { |
| 137 Node* use = edge.from(); | 137 Node* use = edge.from(); |
| 138 switch (use->opcode()) { | 138 switch (use->opcode()) { |
| 139 case IrOpcode::kParameter: { | 139 case IrOpcode::kParameter: { |
| 140 int index = 1 + ParameterIndexOf(use->op()); | 140 int index = 1 + ParameterIndexOf(use->op()); |
| 141 DCHECK_LE(index, inlinee_context_index); |
| 141 if (index < inliner_inputs && index < inlinee_context_index) { | 142 if (index < inliner_inputs && index < inlinee_context_index) { |
| 142 // There is an input from the call, and the index is a value | 143 // There is an input from the call, and the index is a value |
| 143 // projection but not the context, so rewire the input. | 144 // projection but not the context, so rewire the input. |
| 144 Replace(use, call->InputAt(index)); | 145 Replace(use, call->InputAt(index)); |
| 145 } else if (index == inlinee_context_index) { | 146 } else if (index == inlinee_context_index) { |
| 147 // The projection is requesting the inlinee function context. |
| 146 Replace(use, context); | 148 Replace(use, context); |
| 147 } else if (index < inlinee_context_index) { | 149 } else { |
| 148 // Call has fewer arguments than required, fill with undefined. | 150 // Call has fewer arguments than required, fill with undefined. |
| 149 Replace(use, jsgraph_->UndefinedConstant()); | 151 Replace(use, jsgraph_->UndefinedConstant()); |
| 150 } else { | |
| 151 // We got too many arguments, discard for now. | |
| 152 // TODO(sigurds): Fix to treat arguments array correctly. | |
| 153 } | 152 } |
| 154 break; | 153 break; |
| 155 } | 154 } |
| 156 default: | 155 default: |
| 157 if (NodeProperties::IsEffectEdge(edge)) { | 156 if (NodeProperties::IsEffectEdge(edge)) { |
| 158 edge.UpdateTo(effect); | 157 edge.UpdateTo(effect); |
| 159 } else if (NodeProperties::IsControlEdge(edge)) { | 158 } else if (NodeProperties::IsControlEdge(edge)) { |
| 160 edge.UpdateTo(control); | 159 edge.UpdateTo(control); |
| 161 } else if (NodeProperties::IsFrameStateEdge(edge)) { | 160 } else if (NodeProperties::IsFrameStateEdge(edge)) { |
| 162 edge.UpdateTo(frame_state); | 161 edge.UpdateTo(frame_state); |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 return NoChange(); | 311 return NoChange(); |
| 313 } | 312 } |
| 314 | 313 |
| 315 if (!Compiler::EnsureDeoptimizationSupport(&info)) { | 314 if (!Compiler::EnsureDeoptimizationSupport(&info)) { |
| 316 TRACE("Not inlining %s into %s because deoptimization support failed\n", | 315 TRACE("Not inlining %s into %s because deoptimization support failed\n", |
| 317 function->shared()->DebugName()->ToCString().get(), | 316 function->shared()->DebugName()->ToCString().get(), |
| 318 info_->shared_info()->DebugName()->ToCString().get()); | 317 info_->shared_info()->DebugName()->ToCString().get()); |
| 319 return NoChange(); | 318 return NoChange(); |
| 320 } | 319 } |
| 321 | 320 |
| 322 if (info.scope()->arguments() != NULL && is_sloppy(info.language_mode())) { | |
| 323 // For now do not inline functions that use their arguments array. | |
| 324 TRACE("Not inlining %s into %s because inlinee uses arguments array\n", | |
| 325 function->shared()->DebugName()->ToCString().get(), | |
| 326 info_->shared_info()->DebugName()->ToCString().get()); | |
| 327 return NoChange(); | |
| 328 } | |
| 329 | |
| 330 TRACE("Inlining %s into %s\n", | 321 TRACE("Inlining %s into %s\n", |
| 331 function->shared()->DebugName()->ToCString().get(), | 322 function->shared()->DebugName()->ToCString().get(), |
| 332 info_->shared_info()->DebugName()->ToCString().get()); | 323 info_->shared_info()->DebugName()->ToCString().get()); |
| 333 | 324 |
| 334 Graph graph(info.zone()); | 325 Graph graph(info.zone()); |
| 335 JSGraph jsgraph(info.isolate(), &graph, jsgraph_->common(), | 326 JSGraph jsgraph(info.isolate(), &graph, jsgraph_->common(), |
| 336 jsgraph_->javascript(), jsgraph_->machine()); | 327 jsgraph_->javascript(), jsgraph_->machine()); |
| 337 AstGraphBuilder graph_builder(local_zone_, &info, &jsgraph); | 328 AstGraphBuilder graph_builder(local_zone_, &info, &jsgraph); |
| 338 graph_builder.CreateGraph(false); | 329 graph_builder.CreateGraph(false); |
| 339 | 330 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 365 | 356 |
| 366 // Remember that we inlined this function. | 357 // Remember that we inlined this function. |
| 367 info_->AddInlinedFunction(info.shared_info()); | 358 info_->AddInlinedFunction(info.shared_info()); |
| 368 | 359 |
| 369 return InlineCall(node, context, frame_state, start, end); | 360 return InlineCall(node, context, frame_state, start, end); |
| 370 } | 361 } |
| 371 | 362 |
| 372 } // namespace compiler | 363 } // namespace compiler |
| 373 } // namespace internal | 364 } // namespace internal |
| 374 } // namespace v8 | 365 } // namespace v8 |
| OLD | NEW |