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 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
417 if (!Compiler::ParseAndAnalyze(info.parse_info())) { | 417 if (!Compiler::ParseAndAnalyze(info.parse_info())) { |
418 TRACE("Not inlining %s into %s because parsing failed\n", | 418 TRACE("Not inlining %s into %s because parsing failed\n", |
419 shared_info->DebugName()->ToCString().get(), | 419 shared_info->DebugName()->ToCString().get(), |
420 info_->shared_info()->DebugName()->ToCString().get()); | 420 info_->shared_info()->DebugName()->ToCString().get()); |
421 if (info_->isolate()->has_pending_exception()) { | 421 if (info_->isolate()->has_pending_exception()) { |
422 info_->isolate()->clear_pending_exception(); | 422 info_->isolate()->clear_pending_exception(); |
423 } | 423 } |
424 return NoChange(); | 424 return NoChange(); |
425 } | 425 } |
426 | 426 |
427 // In strong mode, in case of too few arguments we need to throw a TypeError | |
428 // so we must not inline this call. | |
429 int parameter_count = info.literal()->parameter_count(); | |
430 if (is_strong(info.language_mode()) && | |
431 call.formal_arguments() < parameter_count) { | |
432 TRACE("Not inlining %s into %s because too few arguments for strong mode\n", | |
433 shared_info->DebugName()->ToCString().get(), | |
434 info_->shared_info()->DebugName()->ToCString().get()); | |
435 return NoChange(); | |
436 } | |
437 | |
438 if (!Compiler::EnsureDeoptimizationSupport(&info)) { | 427 if (!Compiler::EnsureDeoptimizationSupport(&info)) { |
439 TRACE("Not inlining %s into %s because deoptimization support failed\n", | 428 TRACE("Not inlining %s into %s because deoptimization support failed\n", |
440 shared_info->DebugName()->ToCString().get(), | 429 shared_info->DebugName()->ToCString().get(), |
441 info_->shared_info()->DebugName()->ToCString().get()); | 430 info_->shared_info()->DebugName()->ToCString().get()); |
442 return NoChange(); | 431 return NoChange(); |
443 } | 432 } |
444 // Remember that we inlined this function. This needs to be called right | 433 // Remember that we inlined this function. This needs to be called right |
445 // after we ensure deoptimization support so that the code flusher | 434 // after we ensure deoptimization support so that the code flusher |
446 // does not remove the code with the deoptimization support. | 435 // does not remove the code with the deoptimization support. |
447 info_->AddInlinedFunction(shared_info); | 436 info_->AddInlinedFunction(shared_info); |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
548 const CallFunctionParameters& p = CallFunctionParametersOf(node->op()); | 537 const CallFunctionParameters& p = CallFunctionParametersOf(node->op()); |
549 if (p.tail_call_mode() == TailCallMode::kAllow) { | 538 if (p.tail_call_mode() == TailCallMode::kAllow) { |
550 frame_state = CreateTailCallerFrameState(node, frame_state); | 539 frame_state = CreateTailCallerFrameState(node, frame_state); |
551 } | 540 } |
552 } | 541 } |
553 | 542 |
554 // Insert argument adaptor frame if required. The callees formal parameter | 543 // Insert argument adaptor frame if required. The callees formal parameter |
555 // count (i.e. value outputs of start node minus target, receiver, new target, | 544 // count (i.e. value outputs of start node minus target, receiver, new target, |
556 // arguments count and context) have to match the number of arguments passed | 545 // arguments count and context) have to match the number of arguments passed |
557 // to the call. | 546 // to the call. |
| 547 int parameter_count = info.literal()->parameter_count(); |
558 DCHECK_EQ(parameter_count, start->op()->ValueOutputCount() - 5); | 548 DCHECK_EQ(parameter_count, start->op()->ValueOutputCount() - 5); |
559 if (call.formal_arguments() != parameter_count) { | 549 if (call.formal_arguments() != parameter_count) { |
560 frame_state = CreateArtificialFrameState( | 550 frame_state = CreateArtificialFrameState( |
561 node, frame_state, call.formal_arguments(), | 551 node, frame_state, call.formal_arguments(), |
562 FrameStateType::kArgumentsAdaptor, shared_info); | 552 FrameStateType::kArgumentsAdaptor, shared_info); |
563 } | 553 } |
564 | 554 |
565 return InlineCall(node, new_target, context, frame_state, start, end); | 555 return InlineCall(node, new_target, context, frame_state, start, end); |
566 } | 556 } |
567 | 557 |
568 } // namespace compiler | 558 } // namespace compiler |
569 } // namespace internal | 559 } // namespace internal |
570 } // namespace v8 | 560 } // namespace v8 |
OLD | NEW |