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 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 JSCallAccessor call(node); | 285 JSCallAccessor call(node); |
286 | 286 |
287 if (!function->shared()->IsInlineable()) { | 287 if (!function->shared()->IsInlineable()) { |
288 // Function must be inlineable. | 288 // Function must be inlineable. |
289 TRACE("Not inlining %s into %s because callee is not inlineable\n", | 289 TRACE("Not inlining %s into %s because callee is not inlineable\n", |
290 function->shared()->DebugName()->ToCString().get(), | 290 function->shared()->DebugName()->ToCString().get(), |
291 info_->shared_info()->DebugName()->ToCString().get()); | 291 info_->shared_info()->DebugName()->ToCString().get()); |
292 return NoChange(); | 292 return NoChange(); |
293 } | 293 } |
294 | 294 |
| 295 if (node->opcode() == IrOpcode::kJSCallConstruct && |
| 296 !function->IsConstructor()) { |
| 297 // Constructor must be constructable. |
| 298 TRACE("Not inlining %s into %s since constructor is not constructable.\n", |
| 299 function->shared()->DebugName()->ToCString().get(), |
| 300 info_->shared_info()->DebugName()->ToCString().get()); |
| 301 return NoChange(); |
| 302 } |
| 303 |
295 // Class constructors are callable, but [[Call]] will raise an exception. | 304 // Class constructors are callable, but [[Call]] will raise an exception. |
296 // See ES6 section 9.2.1 [[Call]] ( thisArgument, argumentsList ). | 305 // See ES6 section 9.2.1 [[Call]] ( thisArgument, argumentsList ). |
297 if (IsClassConstructor(function->shared()->kind())) { | 306 if (IsClassConstructor(function->shared()->kind())) { |
298 TRACE("Not inlining %s into %s because callee is classConstructor\n", | 307 TRACE("Not inlining %s into %s because callee is classConstructor\n", |
299 function->shared()->DebugName()->ToCString().get(), | 308 function->shared()->DebugName()->ToCString().get(), |
300 info_->shared_info()->DebugName()->ToCString().get()); | 309 info_->shared_info()->DebugName()->ToCString().get()); |
301 return NoChange(); | 310 return NoChange(); |
302 } | 311 } |
303 | 312 |
304 if (function->shared()->HasDebugInfo()) { | 313 if (function->shared()->HasDebugInfo()) { |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
412 | 421 |
413 Node* start = visitor.GetCopy(graph.start()); | 422 Node* start = visitor.GetCopy(graph.start()); |
414 Node* end = visitor.GetCopy(graph.end()); | 423 Node* end = visitor.GetCopy(graph.end()); |
415 Node* frame_state = call.frame_state_after(); | 424 Node* frame_state = call.frame_state_after(); |
416 Node* new_target = jsgraph_->UndefinedConstant(); | 425 Node* new_target = jsgraph_->UndefinedConstant(); |
417 | 426 |
418 // Insert nodes around the call that model the behavior required for a | 427 // Insert nodes around the call that model the behavior required for a |
419 // constructor dispatch and turn the constructor call into a regular call. | 428 // constructor dispatch and turn the constructor call into a regular call. |
420 // This models the behavior usually accomplished by our {JSConstructStub}. | 429 // This models the behavior usually accomplished by our {JSConstructStub}. |
421 // Note that the context has to be the callers context (input to call node). | 430 // Note that the context has to be the callers context (input to call node). |
| 431 // TODO(4544): Once we support inlining builtins, make sure no implicit |
| 432 // receiver is created for builtins that don't expect any. |
422 if (node->opcode() == IrOpcode::kJSCallConstruct) { | 433 if (node->opcode() == IrOpcode::kJSCallConstruct) { |
423 Node* effect = NodeProperties::GetEffectInput(node); | 434 Node* effect = NodeProperties::GetEffectInput(node); |
424 Node* context = NodeProperties::GetContextInput(node); | 435 Node* context = NodeProperties::GetContextInput(node); |
425 Node* create = jsgraph_->graph()->NewNode(jsgraph_->javascript()->Create(), | 436 Node* create = jsgraph_->graph()->NewNode(jsgraph_->javascript()->Create(), |
426 call.target(), call.new_target(), | 437 call.target(), call.new_target(), |
427 context, frame_state, effect); | 438 context, frame_state, effect); |
428 NodeProperties::ReplaceEffectInput(node, create); | 439 NodeProperties::ReplaceEffectInput(node, create); |
429 // TODO(4544): For now Runtime_GetNewTarget depends on the actual target to | 440 // TODO(4544): For now Runtime_GetNewTarget depends on the actual target to |
430 // coincide with the new target. Fix this! | 441 // coincide with the new target. Fix this! |
431 CHECK_EQ(call.target(), call.new_target()); | 442 CHECK_EQ(call.target(), call.new_target()); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
489 node, frame_state, call.formal_arguments(), | 500 node, frame_state, call.formal_arguments(), |
490 FrameStateType::kArgumentsAdaptor, info.shared_info()); | 501 FrameStateType::kArgumentsAdaptor, info.shared_info()); |
491 } | 502 } |
492 | 503 |
493 return InlineCall(node, new_target, context, frame_state, start, end); | 504 return InlineCall(node, new_target, context, frame_state, start, end); |
494 } | 505 } |
495 | 506 |
496 } // namespace compiler | 507 } // namespace compiler |
497 } // namespace internal | 508 } // namespace internal |
498 } // namespace v8 | 509 } // namespace v8 |
OLD | NEW |