| Index: src/objects.cc
|
| diff --git a/src/objects.cc b/src/objects.cc
|
| index 4525f3cd3cb9a0a258ca7f9dca311462e31ecd45..6083be7f68ab82c0665aea19d6041f965b6b1cf0 100644
|
| --- a/src/objects.cc
|
| +++ b/src/objects.cc
|
| @@ -9342,25 +9342,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);
|
| }
|
|
|
|
|
| @@ -10049,8 +10034,8 @@ MaybeObject* JSObject::SetFastElement(uint32_t index,
|
| ? FAST_HOLEY_DOUBLE_ELEMENTS
|
| : FAST_DOUBLE_ELEMENTS;
|
|
|
| - MaybeObject* trans = PossiblyTransitionArrayBoilerplate(to_kind);
|
| - if (trans->IsFailure()) return trans;
|
| + MaybeObject* maybe_failure = UpdateAllocationSiteInfo(to_kind);
|
| + if (maybe_failure->IsFailure()) return maybe_failure;
|
|
|
| MaybeObject* maybe =
|
| SetFastDoubleElementsCapacityAndLength(new_capacity, array_length);
|
| @@ -10066,8 +10051,8 @@ MaybeObject* JSObject::SetFastElement(uint32_t index,
|
| ? FAST_HOLEY_ELEMENTS
|
| : FAST_ELEMENTS;
|
|
|
| - MaybeObject* trans = PossiblyTransitionArrayBoilerplate(kind);
|
| - if (trans->IsFailure()) return trans;
|
| + MaybeObject* maybe_failure = UpdateAllocationSiteInfo(kind);
|
| + if (maybe_failure->IsFailure()) return maybe_failure;
|
|
|
| MaybeObject* maybe_new_map = GetElementsTransitionMap(GetIsolate(),
|
| kind);
|
| @@ -10614,34 +10599,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 this;
|
| }
|
|
|
| AllocationSiteInfo* info = AllocationSiteInfo::FindForJSObject(this);
|
| if (info == NULL) {
|
| - return ret;
|
| + return this;
|
| }
|
|
|
| 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",
|
| @@ -10649,6 +10625,7 @@ MaybeObject* JSObject::PossiblyTransitionArrayBoilerplate(
|
| ElementsKindToString(kind),
|
| ElementsKindToString(to_kind));
|
| }
|
| + return payload->TransitionElementsKind(to_kind);
|
| }
|
| }
|
| } else if (info->payload()->IsJSGlobalPropertyCell()) {
|
| @@ -10657,11 +10634,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),
|
| @@ -10672,7 +10645,7 @@ MaybeObject* JSObject::PossiblyTransitionArrayBoilerplate(
|
| }
|
| }
|
| }
|
| - return ret;
|
| + return this;
|
| }
|
|
|
|
|
| @@ -10686,8 +10659,8 @@ MaybeObject* JSObject::TransitionElementsKind(ElementsKind to_kind) {
|
|
|
| if (from_kind == to_kind) return this;
|
|
|
| - MaybeObject* trans = PossiblyTransitionArrayBoilerplate(to_kind);
|
| - if (trans->IsFailure()) return trans;
|
| + MaybeObject* maybe_failure = UpdateAllocationSiteInfo(to_kind);
|
| + if (maybe_failure->IsFailure()) return maybe_failure;
|
|
|
| Isolate* isolate = GetIsolate();
|
| if (elements() == isolate->heap()->empty_fixed_array() ||
|
|
|