| 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 6541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6552 } | 6552 } |
| 6553 | 6553 |
| 6554 HValue* checked_holder = checked_object; | 6554 HValue* checked_holder = checked_object; |
| 6555 if (info->has_holder()) { | 6555 if (info->has_holder()) { |
| 6556 Handle<JSObject> prototype(JSObject::cast(info->map()->prototype())); | 6556 Handle<JSObject> prototype(JSObject::cast(info->map()->prototype())); |
| 6557 checked_holder = BuildCheckPrototypeMaps(prototype, info->holder()); | 6557 checked_holder = BuildCheckPrototypeMaps(prototype, info->holder()); |
| 6558 } | 6558 } |
| 6559 | 6559 |
| 6560 if (!info->IsFound()) { | 6560 if (!info->IsFound()) { |
| 6561 DCHECK(info->IsLoad()); | 6561 DCHECK(info->IsLoad()); |
| 6562 if (is_strong(function_language_mode())) { | 6562 return graph()->GetConstantUndefined(); |
| 6563 return New<HCallRuntime>( | |
| 6564 Runtime::FunctionForId(Runtime::kThrowStrongModeImplicitConversion), | |
| 6565 0); | |
| 6566 } else { | |
| 6567 return graph()->GetConstantUndefined(); | |
| 6568 } | |
| 6569 } | 6563 } |
| 6570 | 6564 |
| 6571 if (info->IsData()) { | 6565 if (info->IsData()) { |
| 6572 if (info->IsLoad()) { | 6566 if (info->IsLoad()) { |
| 6573 return BuildLoadNamedField(info, checked_holder); | 6567 return BuildLoadNamedField(info, checked_holder); |
| 6574 } else { | 6568 } else { |
| 6575 return BuildStoreNamedField(info, checked_object, value); | 6569 return BuildStoreNamedField(info, checked_object, value); |
| 6576 } | 6570 } |
| 6577 } | 6571 } |
| 6578 | 6572 |
| (...skipping 1883 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8462 // All declarations must be inlineable. | 8456 // All declarations must be inlineable. |
| 8463 ZoneList<Declaration*>* decls = target_info.scope()->declarations(); | 8457 ZoneList<Declaration*>* decls = target_info.scope()->declarations(); |
| 8464 int decl_count = decls->length(); | 8458 int decl_count = decls->length(); |
| 8465 for (int i = 0; i < decl_count; ++i) { | 8459 for (int i = 0; i < decl_count; ++i) { |
| 8466 if (!decls->at(i)->IsInlineable()) { | 8460 if (!decls->at(i)->IsInlineable()) { |
| 8467 TraceInline(target, caller, "target has non-trivial declaration"); | 8461 TraceInline(target, caller, "target has non-trivial declaration"); |
| 8468 return false; | 8462 return false; |
| 8469 } | 8463 } |
| 8470 } | 8464 } |
| 8471 | 8465 |
| 8472 // In strong mode it is an error to call a function with too few arguments. | |
| 8473 // In that case do not inline because then the arity check would be skipped. | |
| 8474 if (is_strong(function->language_mode()) && | |
| 8475 arguments_count < function->parameter_count()) { | |
| 8476 TraceInline(target, caller, | |
| 8477 "too few arguments passed to a strong function"); | |
| 8478 return false; | |
| 8479 } | |
| 8480 | |
| 8481 // Generate the deoptimization data for the unoptimized version of | 8466 // Generate the deoptimization data for the unoptimized version of |
| 8482 // the target function if we don't already have it. | 8467 // the target function if we don't already have it. |
| 8483 if (!Compiler::EnsureDeoptimizationSupport(&target_info)) { | 8468 if (!Compiler::EnsureDeoptimizationSupport(&target_info)) { |
| 8484 TraceInline(target, caller, "could not generate deoptimization info"); | 8469 TraceInline(target, caller, "could not generate deoptimization info"); |
| 8485 return false; | 8470 return false; |
| 8486 } | 8471 } |
| 8487 // Remember that we inlined this function. This needs to be called right | 8472 // Remember that we inlined this function. This needs to be called right |
| 8488 // after the EnsureDeoptimizationSupport call so that the code flusher | 8473 // after the EnsureDeoptimizationSupport call so that the code flusher |
| 8489 // does not remove the code with the deoptimization support. | 8474 // does not remove the code with the deoptimization support. |
| 8490 top_info()->AddInlinedFunction(target_info.shared_info()); | 8475 top_info()->AddInlinedFunction(target_info.shared_info()); |
| (...skipping 2172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10663 | 10648 |
| 10664 HInstruction* HOptimizedGraphBuilder::BuildIncrement( | 10649 HInstruction* HOptimizedGraphBuilder::BuildIncrement( |
| 10665 bool returns_original_input, | 10650 bool returns_original_input, |
| 10666 CountOperation* expr) { | 10651 CountOperation* expr) { |
| 10667 // The input to the count operation is on top of the expression stack. | 10652 // The input to the count operation is on top of the expression stack. |
| 10668 Representation rep = RepresentationFor(expr->type()); | 10653 Representation rep = RepresentationFor(expr->type()); |
| 10669 if (rep.IsNone() || rep.IsTagged()) { | 10654 if (rep.IsNone() || rep.IsTagged()) { |
| 10670 rep = Representation::Smi(); | 10655 rep = Representation::Smi(); |
| 10671 } | 10656 } |
| 10672 | 10657 |
| 10673 if (returns_original_input && !is_strong(function_language_mode())) { | 10658 if (returns_original_input) { |
| 10674 // We need an explicit HValue representing ToNumber(input). The | 10659 // We need an explicit HValue representing ToNumber(input). The |
| 10675 // actual HChange instruction we need is (sometimes) added in a later | 10660 // actual HChange instruction we need is (sometimes) added in a later |
| 10676 // phase, so it is not available now to be used as an input to HAdd and | 10661 // phase, so it is not available now to be used as an input to HAdd and |
| 10677 // as the return value. | 10662 // as the return value. |
| 10678 HInstruction* number_input = AddUncasted<HForceRepresentation>(Pop(), rep); | 10663 HInstruction* number_input = AddUncasted<HForceRepresentation>(Pop(), rep); |
| 10679 if (!rep.IsDouble()) { | 10664 if (!rep.IsDouble()) { |
| 10680 number_input->SetFlag(HInstruction::kFlexibleRepresentation); | 10665 number_input->SetFlag(HInstruction::kFlexibleRepresentation); |
| 10681 number_input->SetFlag(HInstruction::kCannotBeTagged); | 10666 number_input->SetFlag(HInstruction::kCannotBeTagged); |
| 10682 } | 10667 } |
| 10683 Push(number_input); | 10668 Push(number_input); |
| 10684 } | 10669 } |
| 10685 | 10670 |
| 10686 // The addition has no side effects, so we do not need | 10671 // The addition has no side effects, so we do not need |
| 10687 // to simulate the expression stack after this instruction. | 10672 // to simulate the expression stack after this instruction. |
| 10688 // Any later failures deopt to the load of the input or earlier. | 10673 // Any later failures deopt to the load of the input or earlier. |
| 10689 HConstant* delta = (expr->op() == Token::INC) | 10674 HConstant* delta = (expr->op() == Token::INC) |
| 10690 ? graph()->GetConstant1() | 10675 ? graph()->GetConstant1() |
| 10691 : graph()->GetConstantMinus1(); | 10676 : graph()->GetConstantMinus1(); |
| 10692 HInstruction* instr = AddUncasted<HAdd>(Top(), delta); | 10677 HInstruction* instr = AddUncasted<HAdd>(Top(), delta); |
| 10693 if (instr->IsAdd()) { | 10678 if (instr->IsAdd()) { |
| 10694 HAdd* add = HAdd::cast(instr); | 10679 HAdd* add = HAdd::cast(instr); |
| 10695 add->set_observed_input_representation(1, rep); | 10680 add->set_observed_input_representation(1, rep); |
| 10696 add->set_observed_input_representation(2, Representation::Smi()); | 10681 add->set_observed_input_representation(2, Representation::Smi()); |
| 10697 } | 10682 } |
| 10698 if (!is_strong(function_language_mode())) { | 10683 instr->ClearAllSideEffects(); |
| 10699 instr->ClearAllSideEffects(); | |
| 10700 } else { | |
| 10701 Add<HSimulate>(expr->ToNumberId(), REMOVABLE_SIMULATE); | |
| 10702 } | |
| 10703 instr->SetFlag(HInstruction::kCannotBeTagged); | 10684 instr->SetFlag(HInstruction::kCannotBeTagged); |
| 10704 return instr; | 10685 return instr; |
| 10705 } | 10686 } |
| 10706 | 10687 |
| 10707 | 10688 |
| 10708 void HOptimizedGraphBuilder::BuildStoreForEffect( | 10689 void HOptimizedGraphBuilder::BuildStoreForEffect( |
| 10709 Expression* expr, Property* prop, FeedbackVectorSlot slot, BailoutId ast_id, | 10690 Expression* expr, Property* prop, FeedbackVectorSlot slot, BailoutId ast_id, |
| 10710 BailoutId return_id, HValue* object, HValue* key, HValue* value) { | 10691 BailoutId return_id, HValue* object, HValue* key, HValue* value) { |
| 10711 EffectContext for_effect(this); | 10692 EffectContext for_effect(this); |
| 10712 Push(object); | 10693 Push(object); |
| (...skipping 2813 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13526 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 13507 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
| 13527 } | 13508 } |
| 13528 | 13509 |
| 13529 #ifdef DEBUG | 13510 #ifdef DEBUG |
| 13530 graph_->Verify(false); // No full verify. | 13511 graph_->Verify(false); // No full verify. |
| 13531 #endif | 13512 #endif |
| 13532 } | 13513 } |
| 13533 | 13514 |
| 13534 } // namespace internal | 13515 } // namespace internal |
| 13535 } // namespace v8 | 13516 } // namespace v8 |
| OLD | NEW |