Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(888)

Unified Diff: src/objects.cc

Issue 11818021: Allocation Info Tracking, continued. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: A partial delta against Toon's previous review Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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() ||
« no previous file with comments | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698