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-numbering.h" | 10 #include "src/ast-numbering.h" |
(...skipping 6597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6608 return New<HConstant>(info->constant()); | 6608 return New<HConstant>(info->constant()); |
6609 } else { | 6609 } else { |
6610 return New<HCheckValue>(value, Handle<JSFunction>::cast(info->constant())); | 6610 return New<HCheckValue>(value, Handle<JSFunction>::cast(info->constant())); |
6611 } | 6611 } |
6612 } | 6612 } |
6613 | 6613 |
6614 | 6614 |
6615 void HOptimizedGraphBuilder::HandlePolymorphicNamedFieldAccess( | 6615 void HOptimizedGraphBuilder::HandlePolymorphicNamedFieldAccess( |
6616 PropertyAccessType access_type, Expression* expr, FeedbackVectorSlot slot, | 6616 PropertyAccessType access_type, Expression* expr, FeedbackVectorSlot slot, |
6617 BailoutId ast_id, BailoutId return_id, HValue* object, HValue* value, | 6617 BailoutId ast_id, BailoutId return_id, HValue* object, HValue* value, |
6618 SmallMapList* maps, Handle<String> name) { | 6618 SmallMapList* maps, Handle<Name> name) { |
6619 // Something did not match; must use a polymorphic load. | 6619 // Something did not match; must use a polymorphic load. |
6620 int count = 0; | 6620 int count = 0; |
6621 HBasicBlock* join = NULL; | 6621 HBasicBlock* join = NULL; |
6622 HBasicBlock* number_block = NULL; | 6622 HBasicBlock* number_block = NULL; |
6623 bool handled_string = false; | 6623 bool handled_string = false; |
6624 | 6624 |
6625 bool handle_smi = false; | 6625 bool handle_smi = false; |
6626 STATIC_ASSERT(kMaxLoadPolymorphism == kMaxStorePolymorphism); | 6626 STATIC_ASSERT(kMaxLoadPolymorphism == kMaxStorePolymorphism); |
6627 int i; | 6627 int i; |
6628 for (i = 0; i < maps->length() && count < kMaxLoadPolymorphism; ++i) { | 6628 for (i = 0; i < maps->length() && count < kMaxLoadPolymorphism; ++i) { |
(...skipping 994 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7623 Deoptimizer::kUnknownMapInPolymorphicElementAccess); | 7623 Deoptimizer::kUnknownMapInPolymorphicElementAccess); |
7624 set_current_block(join); | 7624 set_current_block(join); |
7625 return access_type == STORE ? val : Pop(); | 7625 return access_type == STORE ? val : Pop(); |
7626 } | 7626 } |
7627 | 7627 |
7628 | 7628 |
7629 HValue* HOptimizedGraphBuilder::HandleKeyedElementAccess( | 7629 HValue* HOptimizedGraphBuilder::HandleKeyedElementAccess( |
7630 HValue* obj, HValue* key, HValue* val, Expression* expr, | 7630 HValue* obj, HValue* key, HValue* val, Expression* expr, |
7631 FeedbackVectorSlot slot, BailoutId ast_id, BailoutId return_id, | 7631 FeedbackVectorSlot slot, BailoutId ast_id, BailoutId return_id, |
7632 PropertyAccessType access_type, bool* has_side_effects) { | 7632 PropertyAccessType access_type, bool* has_side_effects) { |
7633 if (key->ActualValue()->IsConstant()) { | 7633 // A keyed name access with type feedback may contain the name. |
| 7634 Handle<TypeFeedbackVector> vector = |
| 7635 handle(current_feedback_vector(), isolate()); |
| 7636 HValue* expected_key = key; |
| 7637 if (!key->ActualValue()->IsConstant()) { |
| 7638 Name* name = nullptr; |
| 7639 if (access_type == LOAD) { |
| 7640 KeyedLoadICNexus nexus(vector, slot); |
| 7641 name = nexus.FindFirstName(); |
| 7642 } else if (FLAG_vector_stores) { |
| 7643 KeyedStoreICNexus nexus(vector, slot); |
| 7644 name = nexus.FindFirstName(); |
| 7645 } |
| 7646 if (name != nullptr) { |
| 7647 Handle<Name> handle_name(name); |
| 7648 expected_key = Add<HConstant>(handle_name); |
| 7649 // We need a check against the key. |
| 7650 bool in_new_space = isolate()->heap()->InNewSpace(*handle_name); |
| 7651 Unique<Name> unique_name = Unique<Name>::CreateUninitialized(handle_name); |
| 7652 Add<HCheckValue>(key, unique_name, in_new_space); |
| 7653 } |
| 7654 } |
| 7655 if (expected_key->ActualValue()->IsConstant()) { |
7634 Handle<Object> constant = | 7656 Handle<Object> constant = |
7635 HConstant::cast(key->ActualValue())->handle(isolate()); | 7657 HConstant::cast(expected_key->ActualValue())->handle(isolate()); |
7636 uint32_t array_index; | 7658 uint32_t array_index; |
7637 if (constant->IsString() && | 7659 if ((constant->IsString() && |
7638 !Handle<String>::cast(constant)->AsArrayIndex(&array_index)) { | 7660 !Handle<String>::cast(constant)->AsArrayIndex(&array_index)) || |
| 7661 constant->IsSymbol()) { |
7639 if (!constant->IsUniqueName()) { | 7662 if (!constant->IsUniqueName()) { |
7640 constant = isolate()->factory()->InternalizeString( | 7663 constant = isolate()->factory()->InternalizeString( |
7641 Handle<String>::cast(constant)); | 7664 Handle<String>::cast(constant)); |
7642 } | 7665 } |
7643 HValue* access = | 7666 HValue* access = |
7644 BuildNamedAccess(access_type, ast_id, return_id, expr, slot, obj, | 7667 BuildNamedAccess(access_type, ast_id, return_id, expr, slot, obj, |
7645 Handle<String>::cast(constant), val, false); | 7668 Handle<Name>::cast(constant), val, false); |
7646 if (access == NULL || access->IsPhi() || | 7669 if (access == NULL || access->IsPhi() || |
7647 HInstruction::cast(access)->IsLinked()) { | 7670 HInstruction::cast(access)->IsLinked()) { |
7648 *has_side_effects = false; | 7671 *has_side_effects = false; |
7649 } else { | 7672 } else { |
7650 HInstruction* instr = HInstruction::cast(access); | 7673 HInstruction* instr = HInstruction::cast(access); |
7651 AddInstruction(instr); | 7674 AddInstruction(instr); |
7652 *has_side_effects = instr->HasObservableSideEffects(); | 7675 *has_side_effects = instr->HasObservableSideEffects(); |
7653 } | 7676 } |
7654 return access; | 7677 return access; |
7655 } | 7678 } |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7807 } | 7830 } |
7808 } | 7831 } |
7809 ast_context()->ReturnInstruction(result, expr->id()); | 7832 ast_context()->ReturnInstruction(result, expr->id()); |
7810 return true; | 7833 return true; |
7811 } | 7834 } |
7812 | 7835 |
7813 | 7836 |
7814 HValue* HOptimizedGraphBuilder::BuildNamedAccess( | 7837 HValue* HOptimizedGraphBuilder::BuildNamedAccess( |
7815 PropertyAccessType access, BailoutId ast_id, BailoutId return_id, | 7838 PropertyAccessType access, BailoutId ast_id, BailoutId return_id, |
7816 Expression* expr, FeedbackVectorSlot slot, HValue* object, | 7839 Expression* expr, FeedbackVectorSlot slot, HValue* object, |
7817 Handle<String> name, HValue* value, bool is_uninitialized) { | 7840 Handle<Name> name, HValue* value, bool is_uninitialized) { |
7818 SmallMapList* maps; | 7841 SmallMapList* maps; |
7819 ComputeReceiverTypes(expr, object, &maps, zone()); | 7842 ComputeReceiverTypes(expr, object, &maps, zone()); |
7820 DCHECK(maps != NULL); | 7843 DCHECK(maps != NULL); |
7821 | 7844 |
7822 if (maps->length() > 0) { | 7845 if (maps->length() > 0) { |
7823 PropertyAccessInfo info(this, access, maps->first(), name); | 7846 PropertyAccessInfo info(this, access, maps->first(), name); |
7824 if (!info.CanAccessAsMonomorphic(maps)) { | 7847 if (!info.CanAccessAsMonomorphic(maps)) { |
7825 HandlePolymorphicNamedFieldAccess(access, expr, slot, ast_id, return_id, | 7848 HandlePolymorphicNamedFieldAccess(access, expr, slot, ast_id, return_id, |
7826 object, value, maps, name); | 7849 object, value, maps, name); |
7827 return NULL; | 7850 return NULL; |
(...skipping 5851 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13679 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 13702 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
13680 } | 13703 } |
13681 | 13704 |
13682 #ifdef DEBUG | 13705 #ifdef DEBUG |
13683 graph_->Verify(false); // No full verify. | 13706 graph_->Verify(false); // No full verify. |
13684 #endif | 13707 #endif |
13685 } | 13708 } |
13686 | 13709 |
13687 } // namespace internal | 13710 } // namespace internal |
13688 } // namespace v8 | 13711 } // namespace v8 |
OLD | NEW |