| 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 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 if (!Compiler::ParseAndAnalyze(info.parse_info())) { | 388 if (!Compiler::ParseAndAnalyze(info.parse_info())) { |
| 389 TRACE("Not inlining %s into %s because parsing failed\n", | 389 TRACE("Not inlining %s into %s because parsing failed\n", |
| 390 shared_info->DebugName()->ToCString().get(), | 390 shared_info->DebugName()->ToCString().get(), |
| 391 info_->shared_info()->DebugName()->ToCString().get()); | 391 info_->shared_info()->DebugName()->ToCString().get()); |
| 392 if (info_->isolate()->has_pending_exception()) { | 392 if (info_->isolate()->has_pending_exception()) { |
| 393 info_->isolate()->clear_pending_exception(); | 393 info_->isolate()->clear_pending_exception(); |
| 394 } | 394 } |
| 395 return NoChange(); | 395 return NoChange(); |
| 396 } | 396 } |
| 397 | 397 |
| 398 // In strong mode, in case of too few arguments we need to throw a TypeError | |
| 399 // so we must not inline this call. | |
| 400 int parameter_count = info.literal()->parameter_count(); | |
| 401 if (is_strong(info.language_mode()) && | |
| 402 call.formal_arguments() < parameter_count) { | |
| 403 TRACE("Not inlining %s into %s because too few arguments for strong mode\n", | |
| 404 shared_info->DebugName()->ToCString().get(), | |
| 405 info_->shared_info()->DebugName()->ToCString().get()); | |
| 406 return NoChange(); | |
| 407 } | |
| 408 | |
| 409 if (!Compiler::EnsureDeoptimizationSupport(&info)) { | 398 if (!Compiler::EnsureDeoptimizationSupport(&info)) { |
| 410 TRACE("Not inlining %s into %s because deoptimization support failed\n", | 399 TRACE("Not inlining %s into %s because deoptimization support failed\n", |
| 411 shared_info->DebugName()->ToCString().get(), | 400 shared_info->DebugName()->ToCString().get(), |
| 412 info_->shared_info()->DebugName()->ToCString().get()); | 401 info_->shared_info()->DebugName()->ToCString().get()); |
| 413 return NoChange(); | 402 return NoChange(); |
| 414 } | 403 } |
| 415 // Remember that we inlined this function. This needs to be called right | 404 // Remember that we inlined this function. This needs to be called right |
| 416 // after we ensure deoptimization support so that the code flusher | 405 // after we ensure deoptimization support so that the code flusher |
| 417 // does not remove the code with the deoptimization support. | 406 // does not remove the code with the deoptimization support. |
| 418 info_->AddInlinedFunction(shared_info); | 407 info_->AddInlinedFunction(shared_info); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 505 jsgraph_->javascript()->ConvertReceiver(p.convert_mode()), | 494 jsgraph_->javascript()->ConvertReceiver(p.convert_mode()), |
| 506 call.receiver(), context, call.frame_state_before(), effect, start); | 495 call.receiver(), context, call.frame_state_before(), effect, start); |
| 507 NodeProperties::ReplaceValueInput(node, convert, 1); | 496 NodeProperties::ReplaceValueInput(node, convert, 1); |
| 508 NodeProperties::ReplaceEffectInput(node, convert); | 497 NodeProperties::ReplaceEffectInput(node, convert); |
| 509 } | 498 } |
| 510 | 499 |
| 511 // Insert argument adaptor frame if required. The callees formal parameter | 500 // Insert argument adaptor frame if required. The callees formal parameter |
| 512 // count (i.e. value outputs of start node minus target, receiver, new target, | 501 // count (i.e. value outputs of start node minus target, receiver, new target, |
| 513 // arguments count and context) have to match the number of arguments passed | 502 // arguments count and context) have to match the number of arguments passed |
| 514 // to the call. | 503 // to the call. |
| 504 int parameter_count = info.literal()->parameter_count(); |
| 515 DCHECK_EQ(parameter_count, start->op()->ValueOutputCount() - 5); | 505 DCHECK_EQ(parameter_count, start->op()->ValueOutputCount() - 5); |
| 516 if (call.formal_arguments() != parameter_count) { | 506 if (call.formal_arguments() != parameter_count) { |
| 517 frame_state = CreateArtificialFrameState( | 507 frame_state = CreateArtificialFrameState( |
| 518 node, frame_state, call.formal_arguments(), | 508 node, frame_state, call.formal_arguments(), |
| 519 FrameStateType::kArgumentsAdaptor, shared_info); | 509 FrameStateType::kArgumentsAdaptor, shared_info); |
| 520 } | 510 } |
| 521 | 511 |
| 522 return InlineCall(node, new_target, context, frame_state, start, end); | 512 return InlineCall(node, new_target, context, frame_state, start, end); |
| 523 } | 513 } |
| 524 | 514 |
| 525 } // namespace compiler | 515 } // namespace compiler |
| 526 } // namespace internal | 516 } // namespace internal |
| 527 } // namespace v8 | 517 } // namespace v8 |
| OLD | NEW |