OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 11566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11577 start_indexes_[g] = start_indexes_[g - 1] + count; | 11577 start_indexes_[g] = start_indexes_[g - 1] + count; |
11578 } | 11578 } |
11579 } | 11579 } |
11580 | 11580 |
11581 | 11581 |
11582 DependentCode* DependentCode::ForObject(Handle<HeapObject> object, | 11582 DependentCode* DependentCode::ForObject(Handle<HeapObject> object, |
11583 DependencyGroup group) { | 11583 DependencyGroup group) { |
11584 AllowDeferredHandleDereference dependencies_are_safe; | 11584 AllowDeferredHandleDereference dependencies_are_safe; |
11585 if (group == DependentCode::kPropertyCellChangedGroup) { | 11585 if (group == DependentCode::kPropertyCellChangedGroup) { |
11586 return Handle<PropertyCell>::cast(object)->dependent_code(); | 11586 return Handle<PropertyCell>::cast(object)->dependent_code(); |
| 11587 } else if (group == DependentCode::kAllocationSiteTenuringChangedGroup || |
| 11588 group == DependentCode::kAllocationSiteTransitionChangedGroup) { |
| 11589 return Handle<AllocationSite>::cast(object)->dependent_code(); |
11587 } | 11590 } |
11588 return Handle<Map>::cast(object)->dependent_code(); | 11591 return Handle<Map>::cast(object)->dependent_code(); |
11589 } | 11592 } |
11590 | 11593 |
11591 | 11594 |
11592 Handle<DependentCode> DependentCode::Insert(Handle<DependentCode> entries, | 11595 Handle<DependentCode> DependentCode::Insert(Handle<DependentCode> entries, |
11593 DependencyGroup group, | 11596 DependencyGroup group, |
11594 Handle<Object> object) { | 11597 Handle<Object> object) { |
11595 GroupStartIndexes starts(*entries); | 11598 GroupStartIndexes starts(*entries); |
11596 int start = starts.at(group); | 11599 int start = starts.at(group); |
(...skipping 1139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12736 AllocationSite* current_site = AllocationSite::cast(current); | 12739 AllocationSite* current_site = AllocationSite::cast(current); |
12737 if (current_site->nested_site() == this) { | 12740 if (current_site->nested_site() == this) { |
12738 return true; | 12741 return true; |
12739 } | 12742 } |
12740 current = current_site->weak_next(); | 12743 current = current_site->weak_next(); |
12741 } | 12744 } |
12742 return false; | 12745 return false; |
12743 } | 12746 } |
12744 | 12747 |
12745 | 12748 |
12746 MaybeObject* JSObject::UpdateAllocationSite(ElementsKind to_kind) { | 12749 MaybeObject* AllocationSite::DigestTransitionFeedback(ElementsKind to_kind) { |
12747 if (!FLAG_track_allocation_sites || !IsJSArray()) { | 12750 Isolate* isolate = GetIsolate(); |
12748 return this; | |
12749 } | |
12750 | 12751 |
12751 AllocationMemento* memento = AllocationMemento::FindForJSObject(this); | 12752 if (SitePointsToLiteral() && transition_info()->IsJSArray()) { |
12752 if (memento == NULL || !memento->IsValid()) { | 12753 JSArray* transition_info = JSArray::cast(this->transition_info()); |
12753 return this; | |
12754 } | |
12755 | |
12756 // Walk through to the Allocation Site | |
12757 AllocationSite* site = memento->GetAllocationSite(); | |
12758 if (site->SitePointsToLiteral() && | |
12759 site->transition_info()->IsJSArray()) { | |
12760 JSArray* transition_info = JSArray::cast(site->transition_info()); | |
12761 ElementsKind kind = transition_info->GetElementsKind(); | 12754 ElementsKind kind = transition_info->GetElementsKind(); |
12762 // if kind is holey ensure that to_kind is as well. | 12755 // if kind is holey ensure that to_kind is as well. |
12763 if (IsHoleyElementsKind(kind)) { | 12756 if (IsHoleyElementsKind(kind)) { |
12764 to_kind = GetHoleyElementsKind(to_kind); | 12757 to_kind = GetHoleyElementsKind(to_kind); |
12765 } | 12758 } |
12766 if (IsMoreGeneralElementsKindTransition(kind, to_kind)) { | 12759 if (IsMoreGeneralElementsKindTransition(kind, to_kind)) { |
12767 // If the array is huge, it's not likely to be defined in a local | 12760 // If the array is huge, it's not likely to be defined in a local |
12768 // function, so we shouldn't make new instances of it very often. | 12761 // function, so we shouldn't make new instances of it very often. |
12769 uint32_t length = 0; | 12762 uint32_t length = 0; |
12770 CHECK(transition_info->length()->ToArrayIndex(&length)); | 12763 CHECK(transition_info->length()->ToArrayIndex(&length)); |
12771 if (length <= AllocationSite::kMaximumArrayBytesToPretransition) { | 12764 if (length <= kMaximumArrayBytesToPretransition) { |
12772 if (FLAG_trace_track_allocation_sites) { | 12765 if (FLAG_trace_track_allocation_sites) { |
12773 bool is_nested = site->IsNestedSite(); | 12766 bool is_nested = IsNestedSite(); |
12774 PrintF( | 12767 PrintF( |
12775 "AllocationSite: JSArray %p boilerplate %s updated %s->%s\n", | 12768 "AllocationSite: JSArray %p boilerplate %s updated %s->%s\n", |
12776 reinterpret_cast<void*>(this), | 12769 reinterpret_cast<void*>(this), |
12777 is_nested ? "(nested)" : "", | 12770 is_nested ? "(nested)" : "", |
12778 ElementsKindToString(kind), | 12771 ElementsKindToString(kind), |
12779 ElementsKindToString(to_kind)); | 12772 ElementsKindToString(to_kind)); |
12780 } | 12773 } |
12781 return transition_info->TransitionElementsKind(to_kind); | 12774 MaybeObject* result = transition_info->TransitionElementsKind(to_kind); |
| 12775 if (result->IsFailure()) return result; |
| 12776 dependent_code()->DeoptimizeDependentCodeGroup( |
| 12777 isolate, DependentCode::kAllocationSiteTransitionChangedGroup); |
12782 } | 12778 } |
12783 } | 12779 } |
12784 } else { | 12780 } else { |
12785 ElementsKind kind = site->GetElementsKind(); | 12781 ElementsKind kind = GetElementsKind(); |
12786 // if kind is holey ensure that to_kind is as well. | 12782 // if kind is holey ensure that to_kind is as well. |
12787 if (IsHoleyElementsKind(kind)) { | 12783 if (IsHoleyElementsKind(kind)) { |
12788 to_kind = GetHoleyElementsKind(to_kind); | 12784 to_kind = GetHoleyElementsKind(to_kind); |
12789 } | 12785 } |
12790 if (IsMoreGeneralElementsKindTransition(kind, to_kind)) { | 12786 if (IsMoreGeneralElementsKindTransition(kind, to_kind)) { |
12791 if (FLAG_trace_track_allocation_sites) { | 12787 if (FLAG_trace_track_allocation_sites) { |
12792 PrintF("AllocationSite: JSArray %p site updated %s->%s\n", | 12788 PrintF("AllocationSite: JSArray %p site updated %s->%s\n", |
12793 reinterpret_cast<void*>(this), | 12789 reinterpret_cast<void*>(this), |
12794 ElementsKindToString(kind), | 12790 ElementsKindToString(kind), |
12795 ElementsKindToString(to_kind)); | 12791 ElementsKindToString(to_kind)); |
12796 } | 12792 } |
12797 site->set_transition_info(Smi::FromInt(to_kind)); | 12793 SetElementsKind(to_kind); |
| 12794 dependent_code()->DeoptimizeDependentCodeGroup( |
| 12795 isolate, DependentCode::kAllocationSiteTransitionChangedGroup); |
12798 } | 12796 } |
12799 } | 12797 } |
12800 return this; | 12798 return this; |
12801 } | 12799 } |
12802 | 12800 |
12803 | 12801 |
| 12802 void AllocationSite::AddDependentCompilationInfo(Reason reason, |
| 12803 CompilationInfo* info) { |
| 12804 DependentCode::DependencyGroup group = ToDependencyGroup(reason); |
| 12805 Handle<DependentCode> dep(dependent_code()); |
| 12806 Handle<DependentCode> codes = |
| 12807 DependentCode::Insert(dep, group, info->object_wrapper()); |
| 12808 if (*codes != dependent_code()) set_dependent_code(*codes); |
| 12809 info->dependencies(group)->Add(Handle<HeapObject>(this), info->zone()); |
| 12810 } |
| 12811 |
| 12812 |
| 12813 void AllocationSite::AddDependentCode(Reason reason, Handle<Code> code) { |
| 12814 DependentCode::DependencyGroup group = ToDependencyGroup(reason); |
| 12815 Handle<DependentCode> codes = DependentCode::Insert( |
| 12816 Handle<DependentCode>(dependent_code()), group, code); |
| 12817 if (*codes != dependent_code()) set_dependent_code(*codes); |
| 12818 } |
| 12819 |
| 12820 |
| 12821 MaybeObject* JSObject::UpdateAllocationSite(ElementsKind to_kind) { |
| 12822 if (!FLAG_track_allocation_sites || !IsJSArray()) { |
| 12823 return this; |
| 12824 } |
| 12825 |
| 12826 AllocationMemento* memento = AllocationMemento::FindForJSObject(this); |
| 12827 if (memento == NULL || !memento->IsValid()) { |
| 12828 return this; |
| 12829 } |
| 12830 |
| 12831 // Walk through to the Allocation Site |
| 12832 AllocationSite* site = memento->GetAllocationSite(); |
| 12833 return site->DigestTransitionFeedback(to_kind); |
| 12834 } |
| 12835 |
| 12836 |
12804 MaybeObject* JSObject::TransitionElementsKind(ElementsKind to_kind) { | 12837 MaybeObject* JSObject::TransitionElementsKind(ElementsKind to_kind) { |
12805 ASSERT(!map()->is_observed()); | 12838 ASSERT(!map()->is_observed()); |
12806 ElementsKind from_kind = map()->elements_kind(); | 12839 ElementsKind from_kind = map()->elements_kind(); |
12807 | 12840 |
12808 if (IsFastHoleyElementsKind(from_kind)) { | 12841 if (IsFastHoleyElementsKind(from_kind)) { |
12809 to_kind = GetHoleyElementsKind(to_kind); | 12842 to_kind = GetHoleyElementsKind(to_kind); |
12810 } | 12843 } |
12811 | 12844 |
12812 if (from_kind == to_kind) return this; | 12845 if (from_kind == to_kind) return this; |
12813 | 12846 |
(...skipping 3649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16463 #define ERROR_MESSAGES_TEXTS(C, T) T, | 16496 #define ERROR_MESSAGES_TEXTS(C, T) T, |
16464 static const char* error_messages_[] = { | 16497 static const char* error_messages_[] = { |
16465 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) | 16498 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) |
16466 }; | 16499 }; |
16467 #undef ERROR_MESSAGES_TEXTS | 16500 #undef ERROR_MESSAGES_TEXTS |
16468 return error_messages_[reason]; | 16501 return error_messages_[reason]; |
16469 } | 16502 } |
16470 | 16503 |
16471 | 16504 |
16472 } } // namespace v8::internal | 16505 } } // namespace v8::internal |
OLD | NEW |