Chromium Code Reviews| Index: src/objects.cc |
| diff --git a/src/objects.cc b/src/objects.cc |
| index a5420fc593534daefadb1914903c05a27e8e24b7..914f46da016ff58c6e50dcf57ae9872633a2fe7c 100644 |
| --- a/src/objects.cc |
| +++ b/src/objects.cc |
| @@ -9350,25 +9350,10 @@ MaybeObject* JSObject::SetFastDoubleElementsCapacityAndLength( |
| } |
| -MaybeObject* JSArray::Initialize(int capacity) { |
| - Heap* heap = GetHeap(); |
| +MaybeObject* JSArray::Initialize(int capacity, int length) { |
| ASSERT(capacity >= 0); |
| - set_length(Smi::FromInt(0)); |
| - FixedArrayBase* new_elements; |
| - if (capacity == 0) { |
| - new_elements = heap->empty_fixed_array(); |
| - } else { |
| - ElementsKind elements_kind = GetElementsKind(); |
| - MaybeObject* maybe_obj; |
| - if (IsFastDoubleElementsKind(elements_kind)) { |
| - maybe_obj = heap->AllocateFixedDoubleArrayWithHoles(capacity); |
| - } else { |
| - maybe_obj = heap->AllocateFixedArrayWithHoles(capacity); |
| - } |
| - if (!maybe_obj->To(&new_elements)) return maybe_obj; |
| - } |
| - set_elements(new_elements); |
| - return this; |
| + return GetHeap()->AllocateJSArrayStorage(this, length, capacity, |
| + INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE); |
| } |
| @@ -10048,7 +10033,7 @@ MaybeObject* JSObject::SetFastElement(uint32_t index, |
| ? FAST_HOLEY_DOUBLE_ELEMENTS |
| : FAST_DOUBLE_ELEMENTS; |
| - MaybeObject* trans = PossiblyTransitionArrayBoilerplate(to_kind); |
| + MaybeObject* trans = UpdateAllocationSiteInfo(to_kind); |
| if (trans->IsFailure()) return trans; |
|
Toon Verwaest
2013/02/21 12:13:03
MaybeObject* maybe_failure = ...;
if (maybe_failur
|
| MaybeObject* maybe = |
| @@ -10065,7 +10050,7 @@ MaybeObject* JSObject::SetFastElement(uint32_t index, |
| ? FAST_HOLEY_ELEMENTS |
| : FAST_ELEMENTS; |
| - MaybeObject* trans = PossiblyTransitionArrayBoilerplate(kind); |
| + MaybeObject* trans = UpdateAllocationSiteInfo(kind); |
|
Toon Verwaest
2013/02/21 12:13:03
MaybeObject* maybe_failure = ...;
if (maybe_failur
|
| if (trans->IsFailure()) return trans; |
| MaybeObject* maybe_new_map = GetElementsTransitionMap(GetIsolate(), |
| @@ -10613,34 +10598,25 @@ Handle<Object> JSObject::TransitionElementsKind(Handle<JSObject> object, |
| } |
| -// TODO(mvstanton): rename this method to reflect what it actually does. |
| -// If a boilerplate object is discovered, then it will transition it. |
| -// If instead there is a elements kind, then update it as long as the |
| -// to_kind variable is more general than what we find, but don't |
| -// ever take the double->fastobject transition (that represents poisoning), |
| -// just ignore that case. |
| -MaybeObject* JSObject::PossiblyTransitionArrayBoilerplate( |
| - ElementsKind to_kind) { |
| - MaybeObject* ret = NULL; |
| +MaybeObject* JSObject::UpdateAllocationSiteInfo(ElementsKind to_kind) { |
| if (!FLAG_track_allocation_sites || !IsJSArray()) { |
| - return ret; |
| + return NULL; |
|
Toon Verwaest
2013/02/21 12:13:03
return this;
mvstanton
2013/02/27 14:37:07
Done.
|
| } |
| AllocationSiteInfo* info = AllocationSiteInfo::FindForJSObject(this); |
| if (info == NULL) { |
| - return ret; |
| + return NULL; |
|
Toon Verwaest
2013/02/21 12:13:03
return this;
mvstanton
2013/02/27 14:37:07
Done.
|
| } |
| if (info->payload()->IsJSArray()) { |
| JSArray* payload = JSArray::cast(info->payload()); |
| ElementsKind kind = payload->GetElementsKind(); |
| - if (IsMoreGeneralElementsKindTransition(kind, to_kind)) { |
| + if (AllocationSiteInfo::GetMode(kind, to_kind) == TRACK_ALLOCATION_SITE) { |
| // If the array is huge, it's not likely to be defined in a local |
| // function, so we shouldn't make new instances of it very often. |
| uint32_t length = 0; |
| CHECK(payload->length()->ToArrayIndex(&length)); |
| - if (length <= 8*1024) { |
| - ret = payload->TransitionElementsKind(to_kind); |
| + if (length <= AllocationSiteInfo::kMaximumArrayBytesToPretransition) { |
| if (FLAG_trace_track_allocation_sites) { |
| PrintF( |
| "AllocationSiteInfo: JSArray %p boilerplate updated %s->%s\n", |
| @@ -10648,6 +10624,7 @@ MaybeObject* JSObject::PossiblyTransitionArrayBoilerplate( |
| ElementsKindToString(kind), |
| ElementsKindToString(to_kind)); |
| } |
| + return payload->TransitionElementsKind(to_kind); |
| } |
| } |
| } else if (info->payload()->IsJSGlobalPropertyCell()) { |
| @@ -10656,11 +10633,7 @@ MaybeObject* JSObject::PossiblyTransitionArrayBoilerplate( |
| if (cell_contents->IsSmi()) { |
| ElementsKind kind = static_cast<ElementsKind>( |
| Smi::cast(cell_contents)->value()); |
| - // Specifically exclude DOUBLE(HOLEY) -> FAST(HOLEY) |
| - bool double_to_fast = IsFastDoubleElementsKind(kind) && |
| - IsFastObjectElementsKind(to_kind); |
| - if (IsMoreGeneralElementsKindTransition(kind, to_kind) && |
| - !double_to_fast) { |
| + if (AllocationSiteInfo::GetMode(kind, to_kind) == TRACK_ALLOCATION_SITE) { |
| if (FLAG_trace_track_allocation_sites) { |
| PrintF("AllocationSiteInfo: JSArray %p info updated %s->%s\n", |
| reinterpret_cast<void*>(this), |
| @@ -10671,7 +10644,7 @@ MaybeObject* JSObject::PossiblyTransitionArrayBoilerplate( |
| } |
| } |
| } |
| - return ret; |
| + return this; |
| } |
| @@ -10685,7 +10658,7 @@ MaybeObject* JSObject::TransitionElementsKind(ElementsKind to_kind) { |
| if (from_kind == to_kind) return this; |
| - MaybeObject* trans = PossiblyTransitionArrayBoilerplate(to_kind); |
| + MaybeObject* trans = UpdateAllocationSiteInfo(to_kind); |
| if (trans->IsFailure()) return trans; |
|
Toon Verwaest
2013/02/21 12:13:03
MaybeObject* maybe_failure = ...;
if (maybe_failur
mvstanton
2013/02/27 14:37:07
Done.
|
| Isolate* isolate = GetIsolate(); |