| 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/all-nodes.h" | 9 #include "src/compiler/all-nodes.h" |
| 10 #include "src/compiler/ast-graph-builder.h" | 10 #include "src/compiler/ast-graph-builder.h" |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 } | 257 } |
| 258 } | 258 } |
| 259 | 259 |
| 260 ReplaceWithValue(call, inlinee.value_output(), inlinee.effect_output(), | 260 ReplaceWithValue(call, inlinee.value_output(), inlinee.effect_output(), |
| 261 inlinee.control_output()); | 261 inlinee.control_output()); |
| 262 | 262 |
| 263 return Replace(inlinee.value_output()); | 263 return Replace(inlinee.value_output()); |
| 264 } | 264 } |
| 265 | 265 |
| 266 | 266 |
| 267 void JSInliner::AddClosureToFrameState(Node* frame_state, | |
| 268 Handle<JSFunction> jsfunction) { | |
| 269 FrameStateCallInfo call_info = OpParameter<FrameStateCallInfo>(frame_state); | |
| 270 const Operator* op = jsgraph_->common()->FrameState( | |
| 271 FrameStateType::JS_FRAME, call_info.bailout_id(), | |
| 272 call_info.state_combine(), jsfunction); | |
| 273 frame_state->set_op(op); | |
| 274 } | |
| 275 | |
| 276 | |
| 277 Node* JSInliner::CreateArgumentsAdaptorFrameState(JSCallFunctionAccessor* call, | 267 Node* JSInliner::CreateArgumentsAdaptorFrameState(JSCallFunctionAccessor* call, |
| 278 Handle<JSFunction> jsfunction, | |
| 279 Zone* temp_zone) { | 268 Zone* temp_zone) { |
| 280 const Operator* op = jsgraph_->common()->FrameState( | 269 const Operator* op = jsgraph_->common()->FrameState( |
| 281 FrameStateType::ARGUMENTS_ADAPTOR, BailoutId(-1), | 270 FrameStateType::ARGUMENTS_ADAPTOR, BailoutId(-1), |
| 282 OutputFrameStateCombine::Ignore(), jsfunction); | 271 OutputFrameStateCombine::Ignore()); |
| 283 const Operator* op0 = jsgraph_->common()->StateValues(0); | 272 const Operator* op0 = jsgraph_->common()->StateValues(0); |
| 284 Node* node0 = jsgraph_->graph()->NewNode(op0); | 273 Node* node0 = jsgraph_->graph()->NewNode(op0); |
| 285 NodeVector params(temp_zone); | 274 NodeVector params(temp_zone); |
| 286 params.push_back(call->receiver()); | 275 params.push_back(call->receiver()); |
| 287 for (size_t argument = 0; argument != call->formal_arguments(); ++argument) { | 276 for (size_t argument = 0; argument != call->formal_arguments(); ++argument) { |
| 288 params.push_back(call->formal_argument(argument)); | 277 params.push_back(call->formal_argument(argument)); |
| 289 } | 278 } |
| 290 const Operator* op_param = | 279 const Operator* op_param = |
| 291 jsgraph_->common()->StateValues(static_cast<int>(params.size())); | 280 jsgraph_->common()->StateValues(static_cast<int>(params.size())); |
| 292 Node* params_node = jsgraph_->graph()->NewNode( | 281 Node* params_node = jsgraph_->graph()->NewNode( |
| 293 op_param, static_cast<int>(params.size()), ¶ms.front()); | 282 op_param, static_cast<int>(params.size()), ¶ms.front()); |
| 294 return jsgraph_->graph()->NewNode(op, params_node, node0, node0, | 283 return jsgraph_->graph()->NewNode(op, params_node, node0, node0, |
| 295 jsgraph_->UndefinedConstant(), | 284 jsgraph_->UndefinedConstant(), |
| 296 call->frame_state()); | 285 call->jsfunction(), call->frame_state()); |
| 297 } | 286 } |
| 298 | 287 |
| 299 | 288 |
| 300 Reduction JSInliner::Reduce(Node* node) { | 289 Reduction JSInliner::Reduce(Node* node) { |
| 301 if (node->opcode() != IrOpcode::kJSCallFunction) return NoChange(); | 290 if (node->opcode() != IrOpcode::kJSCallFunction) return NoChange(); |
| 302 | 291 |
| 303 JSCallFunctionAccessor call(node); | 292 JSCallFunctionAccessor call(node); |
| 304 HeapObjectMatcher<JSFunction> match(call.jsfunction()); | 293 HeapObjectMatcher<JSFunction> match(call.jsfunction()); |
| 305 if (!match.HasValue()) return NoChange(); | 294 if (!match.HasValue()) return NoChange(); |
| 306 | 295 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 | 341 |
| 353 Node* outer_frame_state = call.frame_state(); | 342 Node* outer_frame_state = call.frame_state(); |
| 354 // Insert argument adaptor frame if required. | 343 // Insert argument adaptor frame if required. |
| 355 if (call.formal_arguments() != inlinee.formal_parameters()) { | 344 if (call.formal_arguments() != inlinee.formal_parameters()) { |
| 356 // In strong mode, in case of too few arguments we need to throw a | 345 // In strong mode, in case of too few arguments we need to throw a |
| 357 // TypeError so we must not inline this call. | 346 // TypeError so we must not inline this call. |
| 358 if (is_strong(info.language_mode()) && | 347 if (is_strong(info.language_mode()) && |
| 359 call.formal_arguments() < inlinee.formal_parameters()) { | 348 call.formal_arguments() < inlinee.formal_parameters()) { |
| 360 return NoChange(); | 349 return NoChange(); |
| 361 } | 350 } |
| 362 outer_frame_state = | 351 outer_frame_state = CreateArgumentsAdaptorFrameState(&call, info.zone()); |
| 363 CreateArgumentsAdaptorFrameState(&call, function, info.zone()); | |
| 364 } | 352 } |
| 365 | 353 |
| 366 for (Node* node : visitor.copies()) { | 354 for (Node* node : visitor.copies()) { |
| 367 if (node && node->opcode() == IrOpcode::kFrameState) { | 355 if (node && node->opcode() == IrOpcode::kFrameState) { |
| 368 DCHECK_EQ(1, OperatorProperties::GetFrameStateInputCount(node->op())); | 356 DCHECK_EQ(1, OperatorProperties::GetFrameStateInputCount(node->op())); |
| 369 AddClosureToFrameState(node, function); | |
| 370 NodeProperties::ReplaceFrameStateInput(node, 0, outer_frame_state); | 357 NodeProperties::ReplaceFrameStateInput(node, 0, outer_frame_state); |
| 371 } | 358 } |
| 372 } | 359 } |
| 373 | 360 |
| 374 return InlineCall(node, inlinee); | 361 return InlineCall(node, inlinee); |
| 375 } | 362 } |
| 376 | 363 |
| 377 } // namespace compiler | 364 } // namespace compiler |
| 378 } // namespace internal | 365 } // namespace internal |
| 379 } // namespace v8 | 366 } // namespace v8 |
| OLD | NEW |