Chromium Code Reviews| Index: src/objects.cc |
| diff --git a/src/objects.cc b/src/objects.cc |
| index 5ea9b5a4e490a3faae793e3da5a18e0d4d37463e..6029c98b5b9fd5949464a23db79e2ddae28e03fd 100644 |
| --- a/src/objects.cc |
| +++ b/src/objects.cc |
| @@ -11584,6 +11584,9 @@ DependentCode* DependentCode::ForObject(Handle<HeapObject> object, |
| AllowDeferredHandleDereference dependencies_are_safe; |
| if (group == DependentCode::kPropertyCellChangedGroup) { |
| return Handle<PropertyCell>::cast(object)->dependent_code(); |
| + } else if (group == DependentCode::kAllocationSiteTenuringChangedGroup || |
| + group == DependentCode::kAllocationSiteTransitionChangedGroup) { |
| + return Handle<AllocationSite>::cast(object)->dependent_code(); |
| } |
| return Handle<Map>::cast(object)->dependent_code(); |
| } |
| @@ -12743,21 +12746,12 @@ bool AllocationSite::IsNestedSite() { |
| } |
| -MaybeObject* JSObject::UpdateAllocationSite(ElementsKind to_kind) { |
| - if (!FLAG_track_allocation_sites || !IsJSArray()) { |
| - return this; |
| - } |
| - |
| - AllocationMemento* memento = AllocationMemento::FindForJSObject(this); |
| - if (memento == NULL || !memento->IsValid()) { |
| - return this; |
| - } |
| +MaybeObject* AllocationSite::DigestTransitionFeedback(ElementsKind to_kind) { |
| + Isolate* isolate = GetIsolate(); |
| - // Walk through to the Allocation Site |
| - AllocationSite* site = memento->GetAllocationSite(); |
| - if (site->SitePointsToLiteral() && |
| - site->transition_info()->IsJSArray()) { |
| - JSArray* transition_info = JSArray::cast(site->transition_info()); |
| + if (SitePointsToLiteral() && |
|
Toon Verwaest
2013/11/06 16:42:44
nit: merge lines
mvstanton
2013/11/07 16:34:05
Done.
|
| + transition_info()->IsJSArray()) { |
| + JSArray* transition_info = JSArray::cast(this->transition_info()); |
| ElementsKind kind = transition_info->GetElementsKind(); |
| // if kind is holey ensure that to_kind is as well. |
| if (IsHoleyElementsKind(kind)) { |
| @@ -12768,9 +12762,9 @@ MaybeObject* JSObject::UpdateAllocationSite(ElementsKind to_kind) { |
| // function, so we shouldn't make new instances of it very often. |
| uint32_t length = 0; |
| CHECK(transition_info->length()->ToArrayIndex(&length)); |
| - if (length <= AllocationSite::kMaximumArrayBytesToPretransition) { |
| + if (length <= kMaximumArrayBytesToPretransition) { |
| if (FLAG_trace_track_allocation_sites) { |
| - bool is_nested = site->IsNestedSite(); |
| + bool is_nested = IsNestedSite(); |
| PrintF( |
| "AllocationSite: JSArray %p boilerplate %s updated %s->%s\n", |
| reinterpret_cast<void*>(this), |
| @@ -12778,11 +12772,14 @@ MaybeObject* JSObject::UpdateAllocationSite(ElementsKind to_kind) { |
| ElementsKindToString(kind), |
| ElementsKindToString(to_kind)); |
| } |
| - return transition_info->TransitionElementsKind(to_kind); |
| + MaybeObject* result = transition_info->TransitionElementsKind(to_kind); |
| + if (result->IsFailure()) return result; |
| + dependent_code()->DeoptimizeDependentCodeGroup( |
| + isolate, DependentCode::kAllocationSiteTransitionChangedGroup); |
| } |
| } |
| } else { |
| - ElementsKind kind = site->GetElementsKind(); |
| + ElementsKind kind = GetElementsKind(); |
| // if kind is holey ensure that to_kind is as well. |
| if (IsHoleyElementsKind(kind)) { |
| to_kind = GetHoleyElementsKind(to_kind); |
| @@ -12794,13 +12791,50 @@ MaybeObject* JSObject::UpdateAllocationSite(ElementsKind to_kind) { |
| ElementsKindToString(kind), |
| ElementsKindToString(to_kind)); |
| } |
| - site->set_transition_info(Smi::FromInt(to_kind)); |
| + SetElementsKind(to_kind); |
| + dependent_code()->DeoptimizeDependentCodeGroup( |
| + isolate, DependentCode::kAllocationSiteTransitionChangedGroup); |
| } |
| } |
| return this; |
| } |
| +void AllocationSite::AddDependentCompilationInfo(Reason reason, |
| + CompilationInfo* info) { |
| + DependentCode::DependencyGroup group = ToDependencyGroup(reason); |
| + Handle<DependentCode> dep(dependent_code()); |
| + Handle<DependentCode> codes = |
| + DependentCode::Insert(dep, group, info->object_wrapper()); |
| + if (*codes != dependent_code()) set_dependent_code(*codes); |
| + info->dependencies(group)->Add(Handle<HeapObject>(this), info->zone()); |
| +} |
| + |
| + |
| +void AllocationSite::AddDependentCode(Reason reason, Handle<Code> code) { |
| + DependentCode::DependencyGroup group = ToDependencyGroup(reason); |
| + Handle<DependentCode> codes = DependentCode::Insert( |
| + Handle<DependentCode>(dependent_code()), group, code); |
| + if (*codes != dependent_code()) set_dependent_code(*codes); |
| +} |
| + |
| + |
| +MaybeObject* JSObject::UpdateAllocationSite(ElementsKind to_kind) { |
| + if (!FLAG_track_allocation_sites || !IsJSArray()) { |
| + return this; |
| + } |
| + |
| + AllocationMemento* memento = AllocationMemento::FindForJSObject(this); |
| + if (memento == NULL || !memento->IsValid()) { |
| + return this; |
| + } |
| + |
| + // Walk through to the Allocation Site |
| + AllocationSite* site = memento->GetAllocationSite(); |
| + return site->DigestTransitionFeedback(to_kind); |
| +} |
| + |
| + |
| MaybeObject* JSObject::TransitionElementsKind(ElementsKind to_kind) { |
| ASSERT(!map()->is_observed()); |
| ElementsKind from_kind = map()->elements_kind(); |