Chromium Code Reviews| Index: src/objects.cc |
| diff --git a/src/objects.cc b/src/objects.cc |
| index 733a1f8208d63d8777fad4bcb4489e3f0e021f1a..cae8547227c3eb52ad6f22739b9442a29b684a5e 100644 |
| --- a/src/objects.cc |
| +++ b/src/objects.cc |
| @@ -9876,6 +9876,10 @@ MaybeObject* JSObject::SetFastElement(uint32_t index, |
| ElementsKind kind = HasFastHoleyElements() |
| ? FAST_HOLEY_ELEMENTS |
| : FAST_ELEMENTS; |
| + |
| + MaybeObject* trans = PossiblyTransitionArrayBoilerplate(kind); |
| + if (trans->IsFailure()) return trans; |
| + |
| MaybeObject* maybe_new_map = GetElementsTransitionMap(GetIsolate(), |
| kind); |
| if (!maybe_new_map->To(&new_map)) return maybe_new_map; |
| @@ -10407,14 +10411,31 @@ Handle<Object> JSObject::TransitionElementsKind(Handle<JSObject> object, |
| MaybeObject* JSObject::PossiblyTransitionArrayBoilerplate( |
| ElementsKind to_kind) { |
| MaybeObject* ret = NULL; |
| - if (IsJSArray()) { |
| - AllocationSiteInfo* info = AllocationSiteInfo::FindForJSObject(this); |
| - if (info != NULL) { |
| - JSObject* payload = JSObject::cast(info->payload()); |
| - if (payload->GetElementsKind() != to_kind) { |
| - if (IsMoreGeneralElementsKindTransition(payload->GetElementsKind(), |
| - to_kind)) { |
| - ret = payload->TransitionElementsKind(to_kind); |
| + if (!FLAG_track_allocation_sites || !IsJSArray()) { |
| + return ret; |
| + } |
| + |
| + AllocationSiteInfo* info = AllocationSiteInfo::FindForJSObject(this); |
| + if (info == NULL) { |
| + return ret; |
| + } |
| + |
| + if (info->payload()->IsJSArray()) { |
|
danno
2013/01/10 22:58:59
You might not need this additional checks yet if y
mvstanton
2013/01/11 13:43:01
Ah, this if is a relic (or forebearer?) of the cha
|
| + JSArray* payload = JSArray::cast(info->payload()); |
| + ElementsKind kind = payload->GetElementsKind(); |
| + if (IsMoreGeneralElementsKindTransition(kind, to_kind)) { |
| + // 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 (FLAG_trace_track_allocation_sites) { |
| + PrintF( |
| + "AllocationSiteInfo: JSArray %p boilerplate updated %s->%s\n", |
| + reinterpret_cast<void*>(this), |
| + ElementsKindToString(kind), |
| + ElementsKindToString(to_kind)); |
| } |
| } |
| } |