| 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/ast.h" | 7 #include "src/ast/ast.h" |
| 8 #include "src/ast/ast-numbering.h" | 8 #include "src/ast/ast-numbering.h" |
| 9 #include "src/ast/scopes.h" | 9 #include "src/ast/scopes.h" |
| 10 #include "src/compiler.h" | 10 #include "src/compiler.h" |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 | 216 |
| 217 // Depending on whether the inlinee produces a value, we either replace value | 217 // Depending on whether the inlinee produces a value, we either replace value |
| 218 // uses with said value or kill value uses if no value can be returned. | 218 // uses with said value or kill value uses if no value can be returned. |
| 219 if (values.size() > 0) { | 219 if (values.size() > 0) { |
| 220 int const input_count = static_cast<int>(controls.size()); | 220 int const input_count = static_cast<int>(controls.size()); |
| 221 Node* control_output = jsgraph_->graph()->NewNode( | 221 Node* control_output = jsgraph_->graph()->NewNode( |
| 222 jsgraph_->common()->Merge(input_count), input_count, &controls.front()); | 222 jsgraph_->common()->Merge(input_count), input_count, &controls.front()); |
| 223 values.push_back(control_output); | 223 values.push_back(control_output); |
| 224 effects.push_back(control_output); | 224 effects.push_back(control_output); |
| 225 Node* value_output = jsgraph_->graph()->NewNode( | 225 Node* value_output = jsgraph_->graph()->NewNode( |
| 226 jsgraph_->common()->Phi(kMachAnyTagged, input_count), | 226 jsgraph_->common()->Phi(MachineRepresentation::kTagged, input_count), |
| 227 static_cast<int>(values.size()), &values.front()); | 227 static_cast<int>(values.size()), &values.front()); |
| 228 Node* effect_output = jsgraph_->graph()->NewNode( | 228 Node* effect_output = jsgraph_->graph()->NewNode( |
| 229 jsgraph_->common()->EffectPhi(input_count), | 229 jsgraph_->common()->EffectPhi(input_count), |
| 230 static_cast<int>(effects.size()), &effects.front()); | 230 static_cast<int>(effects.size()), &effects.front()); |
| 231 ReplaceWithValue(call, value_output, effect_output, control_output); | 231 ReplaceWithValue(call, value_output, effect_output, control_output); |
| 232 return Changed(value_output); | 232 return Changed(value_output); |
| 233 } else { | 233 } else { |
| 234 ReplaceWithValue(call, call, call, jsgraph_->Dead()); | 234 ReplaceWithValue(call, call, call, jsgraph_->Dead()); |
| 235 return Changed(call); | 235 return Changed(call); |
| 236 } | 236 } |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 448 Node* create = jsgraph_->graph()->NewNode(jsgraph_->javascript()->Create(), | 448 Node* create = jsgraph_->graph()->NewNode(jsgraph_->javascript()->Create(), |
| 449 call.target(), call.new_target(), | 449 call.target(), call.new_target(), |
| 450 context, frame_state, effect); | 450 context, frame_state, effect); |
| 451 NodeProperties::ReplaceEffectInput(node, create); | 451 NodeProperties::ReplaceEffectInput(node, create); |
| 452 // Insert a check of the return value to determine whether the return value | 452 // Insert a check of the return value to determine whether the return value |
| 453 // or the implicit receiver should be selected as a result of the call. | 453 // or the implicit receiver should be selected as a result of the call. |
| 454 Node* check = jsgraph_->graph()->NewNode( | 454 Node* check = jsgraph_->graph()->NewNode( |
| 455 jsgraph_->javascript()->CallRuntime(Runtime::kInlineIsJSReceiver, 1), | 455 jsgraph_->javascript()->CallRuntime(Runtime::kInlineIsJSReceiver, 1), |
| 456 node, context, node, start); | 456 node, context, node, start); |
| 457 Node* select = jsgraph_->graph()->NewNode( | 457 Node* select = jsgraph_->graph()->NewNode( |
| 458 jsgraph_->common()->Select(kMachAnyTagged), check, node, create); | 458 jsgraph_->common()->Select(MachineRepresentation::kTagged), check, node, |
| 459 create); |
| 459 NodeProperties::ReplaceUses(node, select, check, node, node); | 460 NodeProperties::ReplaceUses(node, select, check, node, node); |
| 460 NodeProperties::ReplaceValueInput(select, node, 1); | 461 NodeProperties::ReplaceValueInput(select, node, 1); |
| 461 NodeProperties::ReplaceValueInput(check, node, 0); | 462 NodeProperties::ReplaceValueInput(check, node, 0); |
| 462 NodeProperties::ReplaceEffectInput(check, node); | 463 NodeProperties::ReplaceEffectInput(check, node); |
| 463 receiver = create; // The implicit receiver. | 464 receiver = create; // The implicit receiver. |
| 464 } | 465 } |
| 465 | 466 |
| 466 // Swizzle the inputs of the {JSCallConstruct} node to look like inputs to a | 467 // Swizzle the inputs of the {JSCallConstruct} node to look like inputs to a |
| 467 // normal {JSCallFunction} node so that the rest of the inlining machinery | 468 // normal {JSCallFunction} node so that the rest of the inlining machinery |
| 468 // behaves as if we were dealing with a regular function invocation. | 469 // behaves as if we were dealing with a regular function invocation. |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 510 node, frame_state, call.formal_arguments(), | 511 node, frame_state, call.formal_arguments(), |
| 511 FrameStateType::kArgumentsAdaptor, info.shared_info()); | 512 FrameStateType::kArgumentsAdaptor, info.shared_info()); |
| 512 } | 513 } |
| 513 | 514 |
| 514 return InlineCall(node, new_target, context, frame_state, start, end); | 515 return InlineCall(node, new_target, context, frame_state, start, end); |
| 515 } | 516 } |
| 516 | 517 |
| 517 } // namespace compiler | 518 } // namespace compiler |
| 518 } // namespace internal | 519 } // namespace internal |
| 519 } // namespace v8 | 520 } // namespace v8 |
| OLD | NEW |