OLD | NEW |
---|---|
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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/objects.h" | 5 #include "src/objects.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 #include <iomanip> | 8 #include <iomanip> |
9 #include <memory> | 9 #include <memory> |
10 #include <sstream> | 10 #include <sstream> |
(...skipping 16005 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
16016 while (current->IsAllocationSite()) { | 16016 while (current->IsAllocationSite()) { |
16017 AllocationSite* current_site = AllocationSite::cast(current); | 16017 AllocationSite* current_site = AllocationSite::cast(current); |
16018 if (current_site->nested_site() == this) { | 16018 if (current_site->nested_site() == this) { |
16019 return true; | 16019 return true; |
16020 } | 16020 } |
16021 current = current_site->weak_next(); | 16021 current = current_site->weak_next(); |
16022 } | 16022 } |
16023 return false; | 16023 return false; |
16024 } | 16024 } |
16025 | 16025 |
16026 | 16026 template <AllocationSiteUpdateMode update_or_check> |
16027 void AllocationSite::DigestTransitionFeedback(Handle<AllocationSite> site, | 16027 bool AllocationSite::DigestTransitionFeedback(Handle<AllocationSite> site, |
16028 ElementsKind to_kind) { | 16028 ElementsKind to_kind) { |
16029 Isolate* isolate = site->GetIsolate(); | 16029 Isolate* isolate = site->GetIsolate(); |
16030 bool result = false; | |
16030 | 16031 |
16031 if (site->SitePointsToLiteral() && site->transition_info()->IsJSArray()) { | 16032 if (site->SitePointsToLiteral() && site->transition_info()->IsJSArray()) { |
16032 Handle<JSArray> transition_info = | 16033 Handle<JSArray> transition_info = |
16033 handle(JSArray::cast(site->transition_info())); | 16034 handle(JSArray::cast(site->transition_info())); |
16034 ElementsKind kind = transition_info->GetElementsKind(); | 16035 ElementsKind kind = transition_info->GetElementsKind(); |
16035 // if kind is holey ensure that to_kind is as well. | 16036 // if kind is holey ensure that to_kind is as well. |
16036 if (IsHoleyElementsKind(kind)) { | 16037 if (IsHoleyElementsKind(kind)) { |
16037 to_kind = GetHoleyElementsKind(to_kind); | 16038 to_kind = GetHoleyElementsKind(to_kind); |
16038 } | 16039 } |
16039 if (IsMoreGeneralElementsKindTransition(kind, to_kind)) { | 16040 if (IsMoreGeneralElementsKindTransition(kind, to_kind)) { |
16040 // If the array is huge, it's not likely to be defined in a local | 16041 // If the array is huge, it's not likely to be defined in a local |
16041 // function, so we shouldn't make new instances of it very often. | 16042 // function, so we shouldn't make new instances of it very often. |
16042 uint32_t length = 0; | 16043 uint32_t length = 0; |
16043 CHECK(transition_info->length()->ToArrayLength(&length)); | 16044 CHECK(transition_info->length()->ToArrayLength(&length)); |
16044 if (length <= kMaximumArrayBytesToPretransition) { | 16045 if (length <= kMaximumArrayBytesToPretransition) { |
16046 if (update_or_check == AllocationSiteUpdateMode::kCheckOnly) { | |
16047 return true; | |
16048 } | |
16045 if (FLAG_trace_track_allocation_sites) { | 16049 if (FLAG_trace_track_allocation_sites) { |
16046 bool is_nested = site->IsNestedSite(); | 16050 bool is_nested = site->IsNestedSite(); |
16047 PrintF( | 16051 PrintF( |
16048 "AllocationSite: JSArray %p boilerplate %s updated %s->%s\n", | 16052 "AllocationSite: JSArray %p boilerplate %s updated %s->%s\n", |
16049 reinterpret_cast<void*>(*site), | 16053 reinterpret_cast<void*>(*site), |
16050 is_nested ? "(nested)" : "", | 16054 is_nested ? "(nested)" : "", |
16051 ElementsKindToString(kind), | 16055 ElementsKindToString(kind), |
16052 ElementsKindToString(to_kind)); | 16056 ElementsKindToString(to_kind)); |
16053 } | 16057 } |
16054 JSObject::TransitionElementsKind(transition_info, to_kind); | 16058 JSObject::TransitionElementsKind(transition_info, to_kind); |
16055 site->dependent_code()->DeoptimizeDependentCodeGroup( | 16059 site->dependent_code()->DeoptimizeDependentCodeGroup( |
16056 isolate, DependentCode::kAllocationSiteTransitionChangedGroup); | 16060 isolate, DependentCode::kAllocationSiteTransitionChangedGroup); |
16061 result = true; | |
16057 } | 16062 } |
16058 } | 16063 } |
16059 } else { | 16064 } else { |
16060 ElementsKind kind = site->GetElementsKind(); | 16065 ElementsKind kind = site->GetElementsKind(); |
16061 // if kind is holey ensure that to_kind is as well. | 16066 // if kind is holey ensure that to_kind is as well. |
16062 if (IsHoleyElementsKind(kind)) { | 16067 if (IsHoleyElementsKind(kind)) { |
16063 to_kind = GetHoleyElementsKind(to_kind); | 16068 to_kind = GetHoleyElementsKind(to_kind); |
16064 } | 16069 } |
16065 if (IsMoreGeneralElementsKindTransition(kind, to_kind)) { | 16070 if (IsMoreGeneralElementsKindTransition(kind, to_kind)) { |
16071 if (update_or_check == AllocationSiteUpdateMode::kCheckOnly) return true; | |
16066 if (FLAG_trace_track_allocation_sites) { | 16072 if (FLAG_trace_track_allocation_sites) { |
16067 PrintF("AllocationSite: JSArray %p site updated %s->%s\n", | 16073 PrintF("AllocationSite: JSArray %p site updated %s->%s\n", |
16068 reinterpret_cast<void*>(*site), | 16074 reinterpret_cast<void*>(*site), |
16069 ElementsKindToString(kind), | 16075 ElementsKindToString(kind), |
16070 ElementsKindToString(to_kind)); | 16076 ElementsKindToString(to_kind)); |
16071 } | 16077 } |
16072 site->SetElementsKind(to_kind); | 16078 site->SetElementsKind(to_kind); |
16073 site->dependent_code()->DeoptimizeDependentCodeGroup( | 16079 site->dependent_code()->DeoptimizeDependentCodeGroup( |
16074 isolate, DependentCode::kAllocationSiteTransitionChangedGroup); | 16080 isolate, DependentCode::kAllocationSiteTransitionChangedGroup); |
16081 result = true; | |
16075 } | 16082 } |
16076 } | 16083 } |
16084 return false; | |
Jakob Kummerow
2016/08/16 15:15:01
Did you mean to "return result" here?
| |
16077 } | 16085 } |
16078 | 16086 |
16079 | 16087 |
16080 const char* AllocationSite::PretenureDecisionName(PretenureDecision decision) { | 16088 const char* AllocationSite::PretenureDecisionName(PretenureDecision decision) { |
16081 switch (decision) { | 16089 switch (decision) { |
16082 case kUndecided: return "undecided"; | 16090 case kUndecided: return "undecided"; |
16083 case kDontTenure: return "don't tenure"; | 16091 case kDontTenure: return "don't tenure"; |
16084 case kMaybeTenure: return "maybe tenure"; | 16092 case kMaybeTenure: return "maybe tenure"; |
16085 case kTenure: return "tenure"; | 16093 case kTenure: return "tenure"; |
16086 case kZombie: return "zombie"; | 16094 case kZombie: return "zombie"; |
16087 default: UNREACHABLE(); | 16095 default: UNREACHABLE(); |
16088 } | 16096 } |
16089 return NULL; | 16097 return NULL; |
16090 } | 16098 } |
16091 | 16099 |
16092 | 16100 template <AllocationSiteUpdateMode update_or_check> |
16093 void JSObject::UpdateAllocationSite(Handle<JSObject> object, | 16101 bool JSObject::UpdateAllocationSite(Handle<JSObject> object, |
16094 ElementsKind to_kind) { | 16102 ElementsKind to_kind) { |
16095 if (!object->IsJSArray()) return; | 16103 if (!object->IsJSArray()) return false; |
16096 | 16104 |
16097 Heap* heap = object->GetHeap(); | 16105 Heap* heap = object->GetHeap(); |
16098 if (!heap->InNewSpace(*object)) return; | 16106 if (!heap->InNewSpace(*object)) return false; |
16099 | 16107 |
16100 Handle<AllocationSite> site; | 16108 Handle<AllocationSite> site; |
16101 { | 16109 { |
16102 DisallowHeapAllocation no_allocation; | 16110 DisallowHeapAllocation no_allocation; |
16103 | 16111 |
16104 AllocationMemento* memento = | 16112 AllocationMemento* memento = |
16105 heap->FindAllocationMemento<Heap::kForRuntime>(*object); | 16113 heap->FindAllocationMemento<Heap::kForRuntime>(*object); |
16106 if (memento == NULL) return; | 16114 if (memento == NULL) return false; |
16107 | 16115 |
16108 // Walk through to the Allocation Site | 16116 // Walk through to the Allocation Site |
16109 site = handle(memento->GetAllocationSite()); | 16117 site = handle(memento->GetAllocationSite()); |
16110 } | 16118 } |
16111 AllocationSite::DigestTransitionFeedback(site, to_kind); | 16119 return AllocationSite::DigestTransitionFeedback<update_or_check>(site, |
16120 to_kind); | |
16112 } | 16121 } |
16113 | 16122 |
16123 template bool | |
16124 JSObject::UpdateAllocationSite<AllocationSiteUpdateMode::kCheckOnly>( | |
16125 Handle<JSObject> object, ElementsKind to_kind); | |
16114 | 16126 |
16115 void JSObject::TransitionElementsKind(Handle<JSObject> object, | 16127 void JSObject::TransitionElementsKind(Handle<JSObject> object, |
16116 ElementsKind to_kind) { | 16128 ElementsKind to_kind) { |
16117 ElementsKind from_kind = object->GetElementsKind(); | 16129 ElementsKind from_kind = object->GetElementsKind(); |
16118 | 16130 |
16119 if (IsFastHoleyElementsKind(from_kind)) { | 16131 if (IsFastHoleyElementsKind(from_kind)) { |
16120 to_kind = GetHoleyElementsKind(to_kind); | 16132 to_kind = GetHoleyElementsKind(to_kind); |
16121 } | 16133 } |
16122 | 16134 |
16123 if (from_kind == to_kind) return; | 16135 if (from_kind == to_kind) return; |
(...skipping 3742 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
19866 for (PrototypeIterator iter(isolate, this, kStartAtReceiver, | 19878 for (PrototypeIterator iter(isolate, this, kStartAtReceiver, |
19867 PrototypeIterator::END_AT_NULL); | 19879 PrototypeIterator::END_AT_NULL); |
19868 !iter.IsAtEnd(); iter.AdvanceIgnoringProxies()) { | 19880 !iter.IsAtEnd(); iter.AdvanceIgnoringProxies()) { |
19869 if (iter.GetCurrent<Object>()->IsJSProxy()) return true; | 19881 if (iter.GetCurrent<Object>()->IsJSProxy()) return true; |
19870 } | 19882 } |
19871 return false; | 19883 return false; |
19872 } | 19884 } |
19873 | 19885 |
19874 } // namespace internal | 19886 } // namespace internal |
19875 } // namespace v8 | 19887 } // namespace v8 |
OLD | NEW |