OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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/crankshaft/hydrogen.h" | 5 #include "src/crankshaft/hydrogen.h" |
6 | 6 |
7 #include <sstream> | 7 #include <sstream> |
8 | 8 |
9 #include "src/allocation-site-scopes.h" | 9 #include "src/allocation-site-scopes.h" |
10 #include "src/ast/ast-numbering.h" | 10 #include "src/ast/ast-numbering.h" |
(...skipping 6533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6544 } | 6544 } |
6545 | 6545 |
6546 HValue* checked_holder = checked_object; | 6546 HValue* checked_holder = checked_object; |
6547 if (info->has_holder()) { | 6547 if (info->has_holder()) { |
6548 Handle<JSObject> prototype(JSObject::cast(info->map()->prototype())); | 6548 Handle<JSObject> prototype(JSObject::cast(info->map()->prototype())); |
6549 checked_holder = BuildCheckPrototypeMaps(prototype, info->holder()); | 6549 checked_holder = BuildCheckPrototypeMaps(prototype, info->holder()); |
6550 } | 6550 } |
6551 | 6551 |
6552 if (!info->IsFound()) { | 6552 if (!info->IsFound()) { |
6553 DCHECK(info->IsLoad()); | 6553 DCHECK(info->IsLoad()); |
6554 if (is_strong(function_language_mode())) { | 6554 return graph()->GetConstantUndefined(); |
6555 return New<HCallRuntime>( | |
6556 Runtime::FunctionForId(Runtime::kThrowStrongModeImplicitConversion), | |
6557 0); | |
6558 } else { | |
6559 return graph()->GetConstantUndefined(); | |
6560 } | |
6561 } | 6555 } |
6562 | 6556 |
6563 if (info->IsData()) { | 6557 if (info->IsData()) { |
6564 if (info->IsLoad()) { | 6558 if (info->IsLoad()) { |
6565 return BuildLoadNamedField(info, checked_holder); | 6559 return BuildLoadNamedField(info, checked_holder); |
6566 } else { | 6560 } else { |
6567 return BuildStoreNamedField(info, checked_object, value); | 6561 return BuildStoreNamedField(info, checked_object, value); |
6568 } | 6562 } |
6569 } | 6563 } |
6570 | 6564 |
(...skipping 1881 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8452 // All declarations must be inlineable. | 8446 // All declarations must be inlineable. |
8453 ZoneList<Declaration*>* decls = target_info.scope()->declarations(); | 8447 ZoneList<Declaration*>* decls = target_info.scope()->declarations(); |
8454 int decl_count = decls->length(); | 8448 int decl_count = decls->length(); |
8455 for (int i = 0; i < decl_count; ++i) { | 8449 for (int i = 0; i < decl_count; ++i) { |
8456 if (!decls->at(i)->IsInlineable()) { | 8450 if (!decls->at(i)->IsInlineable()) { |
8457 TraceInline(target, caller, "target has non-trivial declaration"); | 8451 TraceInline(target, caller, "target has non-trivial declaration"); |
8458 return false; | 8452 return false; |
8459 } | 8453 } |
8460 } | 8454 } |
8461 | 8455 |
8462 // In strong mode it is an error to call a function with too few arguments. | |
8463 // In that case do not inline because then the arity check would be skipped. | |
8464 if (is_strong(function->language_mode()) && | |
8465 arguments_count < function->parameter_count()) { | |
8466 TraceInline(target, caller, | |
8467 "too few arguments passed to a strong function"); | |
8468 return false; | |
8469 } | |
8470 | |
8471 // Generate the deoptimization data for the unoptimized version of | 8456 // Generate the deoptimization data for the unoptimized version of |
8472 // the target function if we don't already have it. | 8457 // the target function if we don't already have it. |
8473 if (!Compiler::EnsureDeoptimizationSupport(&target_info)) { | 8458 if (!Compiler::EnsureDeoptimizationSupport(&target_info)) { |
8474 TraceInline(target, caller, "could not generate deoptimization info"); | 8459 TraceInline(target, caller, "could not generate deoptimization info"); |
8475 return false; | 8460 return false; |
8476 } | 8461 } |
8477 // Remember that we inlined this function. This needs to be called right | 8462 // Remember that we inlined this function. This needs to be called right |
8478 // after the EnsureDeoptimizationSupport call so that the code flusher | 8463 // after the EnsureDeoptimizationSupport call so that the code flusher |
8479 // does not remove the code with the deoptimization support. | 8464 // does not remove the code with the deoptimization support. |
8480 top_info()->AddInlinedFunction(target_info.shared_info()); | 8465 top_info()->AddInlinedFunction(target_info.shared_info()); |
(...skipping 2156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10637 | 10622 |
10638 HInstruction* HOptimizedGraphBuilder::BuildIncrement( | 10623 HInstruction* HOptimizedGraphBuilder::BuildIncrement( |
10639 bool returns_original_input, | 10624 bool returns_original_input, |
10640 CountOperation* expr) { | 10625 CountOperation* expr) { |
10641 // The input to the count operation is on top of the expression stack. | 10626 // The input to the count operation is on top of the expression stack. |
10642 Representation rep = RepresentationFor(expr->type()); | 10627 Representation rep = RepresentationFor(expr->type()); |
10643 if (rep.IsNone() || rep.IsTagged()) { | 10628 if (rep.IsNone() || rep.IsTagged()) { |
10644 rep = Representation::Smi(); | 10629 rep = Representation::Smi(); |
10645 } | 10630 } |
10646 | 10631 |
10647 if (returns_original_input && !is_strong(function_language_mode())) { | 10632 if (returns_original_input) { |
10648 // We need an explicit HValue representing ToNumber(input). The | 10633 // We need an explicit HValue representing ToNumber(input). The |
10649 // actual HChange instruction we need is (sometimes) added in a later | 10634 // actual HChange instruction we need is (sometimes) added in a later |
10650 // phase, so it is not available now to be used as an input to HAdd and | 10635 // phase, so it is not available now to be used as an input to HAdd and |
10651 // as the return value. | 10636 // as the return value. |
10652 HInstruction* number_input = AddUncasted<HForceRepresentation>(Pop(), rep); | 10637 HInstruction* number_input = AddUncasted<HForceRepresentation>(Pop(), rep); |
10653 if (!rep.IsDouble()) { | 10638 if (!rep.IsDouble()) { |
10654 number_input->SetFlag(HInstruction::kFlexibleRepresentation); | 10639 number_input->SetFlag(HInstruction::kFlexibleRepresentation); |
10655 number_input->SetFlag(HInstruction::kCannotBeTagged); | 10640 number_input->SetFlag(HInstruction::kCannotBeTagged); |
10656 } | 10641 } |
10657 Push(number_input); | 10642 Push(number_input); |
10658 } | 10643 } |
10659 | 10644 |
10660 // The addition has no side effects, so we do not need | 10645 // The addition has no side effects, so we do not need |
10661 // to simulate the expression stack after this instruction. | 10646 // to simulate the expression stack after this instruction. |
10662 // Any later failures deopt to the load of the input or earlier. | 10647 // Any later failures deopt to the load of the input or earlier. |
10663 HConstant* delta = (expr->op() == Token::INC) | 10648 HConstant* delta = (expr->op() == Token::INC) |
10664 ? graph()->GetConstant1() | 10649 ? graph()->GetConstant1() |
10665 : graph()->GetConstantMinus1(); | 10650 : graph()->GetConstantMinus1(); |
10666 HInstruction* instr = AddUncasted<HAdd>(Top(), delta); | 10651 HInstruction* instr = AddUncasted<HAdd>(Top(), delta); |
10667 if (instr->IsAdd()) { | 10652 if (instr->IsAdd()) { |
10668 HAdd* add = HAdd::cast(instr); | 10653 HAdd* add = HAdd::cast(instr); |
10669 add->set_observed_input_representation(1, rep); | 10654 add->set_observed_input_representation(1, rep); |
10670 add->set_observed_input_representation(2, Representation::Smi()); | 10655 add->set_observed_input_representation(2, Representation::Smi()); |
10671 } | 10656 } |
10672 if (!is_strong(function_language_mode())) { | 10657 instr->ClearAllSideEffects(); |
10673 instr->ClearAllSideEffects(); | |
10674 } else { | |
10675 Add<HSimulate>(expr->ToNumberId(), REMOVABLE_SIMULATE); | |
10676 } | |
10677 instr->SetFlag(HInstruction::kCannotBeTagged); | 10658 instr->SetFlag(HInstruction::kCannotBeTagged); |
10678 return instr; | 10659 return instr; |
10679 } | 10660 } |
10680 | 10661 |
10681 | 10662 |
10682 void HOptimizedGraphBuilder::BuildStoreForEffect( | 10663 void HOptimizedGraphBuilder::BuildStoreForEffect( |
10683 Expression* expr, Property* prop, FeedbackVectorSlot slot, BailoutId ast_id, | 10664 Expression* expr, Property* prop, FeedbackVectorSlot slot, BailoutId ast_id, |
10684 BailoutId return_id, HValue* object, HValue* key, HValue* value) { | 10665 BailoutId return_id, HValue* object, HValue* key, HValue* value) { |
10685 EffectContext for_effect(this); | 10666 EffectContext for_effect(this); |
10686 Push(object); | 10667 Push(object); |
(...skipping 2827 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13514 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 13495 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
13515 } | 13496 } |
13516 | 13497 |
13517 #ifdef DEBUG | 13498 #ifdef DEBUG |
13518 graph_->Verify(false); // No full verify. | 13499 graph_->Verify(false); // No full verify. |
13519 #endif | 13500 #endif |
13520 } | 13501 } |
13521 | 13502 |
13522 } // namespace internal | 13503 } // namespace internal |
13523 } // namespace v8 | 13504 } // namespace v8 |
OLD | NEW |