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

Unified Diff: src/builtins.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/builtins.h ('k') | src/elements.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/builtins.cc
diff --git a/src/builtins.cc b/src/builtins.cc
index 87a47462818b423b5b94bf6081c4b748d14c6c73..aa6920375b1a015d5a15e9ebea7f62719da599cb 100644
--- a/src/builtins.cc
+++ b/src/builtins.cc
@@ -203,17 +203,7 @@ RUNTIME_FUNCTION(MaybeObject*, ArrayConstructor_StubFailure) {
holey = (value > 0 && value < JSObject::kInitialMaxFastElementArray);
}
- // Allocate the initial map if absent.
- if (!function->has_initial_map()) {
- Object* initial_map;
- { MaybeObject* maybe_initial_map =
- isolate->heap()->AllocateInitialMap(*function);
- if (!maybe_initial_map->ToObject(&initial_map)) return maybe_initial_map;
- }
- function->set_initial_map(Map::cast(initial_map));
- Map::cast(initial_map)->set_constructor(*function);
- }
-
+ ASSERT(function->has_initial_map());
ElementsKind kind = function->initial_map()->elements_kind();
if (holey) {
kind = GetHoleyElementsKind(kind);
@@ -221,22 +211,22 @@ RUNTIME_FUNCTION(MaybeObject*, ArrayConstructor_StubFailure) {
MaybeObject* maybe_array;
if (*type_info != isolate->heap()->undefined_value()) {
- ASSERT(type_info->IsJSGlobalPropertyCell());
JSGlobalPropertyCell* cell = JSGlobalPropertyCell::cast(*type_info);
if (cell->value()->IsSmi()) {
Smi* smi = Smi::cast(cell->value());
ElementsKind to_kind = static_cast<ElementsKind>(smi->value());
- if (holey) {
+ if (holey && !IsFastHoleyElementsKind(to_kind)) {
to_kind = GetHoleyElementsKind(to_kind);
+ // Update the allocation site info to reflect the advice alteration.
+ cell->set_value(Smi::FromInt(to_kind));
}
- if (IsMoreGeneralElementsKindTransition(kind, to_kind)) {
- maybe_array = isolate->heap()->AllocateEmptyJSArray(to_kind);
+ AllocationSiteMode mode = AllocationSiteInfo::GetMode(to_kind);
+ if (mode == TRACK_ALLOCATION_SITE) {
+ maybe_array = isolate->heap()->AllocateEmptyJSArrayWithAllocationSite(
+ kind, type_info);
} else {
- AllocationSiteMode mode = AllocationSiteInfo::GetMode(kind);
- maybe_array = isolate->heap()->AllocateEmptyJSArray(kind,
- mode,
- &type_info);
+ maybe_array = isolate->heap()->AllocateEmptyJSArray(kind);
}
if (!maybe_array->To(&array)) return maybe_array;
}
@@ -265,24 +255,26 @@ static MaybeObject* ArrayCodeGenericCommon(Arguments* args,
array = JSArray::cast((*args)[0]);
// Initialize elements and length in case later allocations fail so that the
// array object is initialized in a valid state.
- array->set_length(Smi::FromInt(0));
- array->set_elements(heap->empty_fixed_array());
- AllocationSiteInfo* info = AllocationSiteInfo::FindForJSObject(array);
- ElementsKind to_kind = array->GetElementsKind();
- if (info != NULL && info->GetElementsKindPayload(&to_kind)) {
- if (IsMoreGeneralElementsKindTransition(array->GetElementsKind(),
- to_kind)) {
- // We have advice that we should change the elements kind
- if (FLAG_trace_track_allocation_sites) {
- PrintF("AllocationSiteInfo: pre-transitioning array %p(%s->%s)\n",
- reinterpret_cast<void*>(array),
- ElementsKindToString(array->GetElementsKind()),
- ElementsKindToString(to_kind));
- }
+ MaybeObject* maybe_array = array->Initialize(0);
+ if (maybe_array->IsFailure()) return maybe_array;
- MaybeObject* maybe_array =
- array->TransitionElementsKind(to_kind);
- if (maybe_array->IsFailure()) return maybe_array;
+ if (FLAG_optimize_constructed_arrays) {
+ AllocationSiteInfo* info = AllocationSiteInfo::FindForJSObject(array);
+ ElementsKind to_kind = array->GetElementsKind();
+ if (info != NULL && info->GetElementsKindPayload(&to_kind)) {
+ if (IsMoreGeneralElementsKindTransition(array->GetElementsKind(),
+ to_kind)) {
+ // We have advice that we should change the elements kind
+ if (FLAG_trace_track_allocation_sites) {
+ PrintF("AllocationSiteInfo: pre-transitioning array %p(%s->%s)\n",
+ reinterpret_cast<void*>(array),
+ ElementsKindToString(array->GetElementsKind()),
+ ElementsKindToString(to_kind));
+ }
+
+ maybe_array = array->TransitionElementsKind(to_kind);
+ if (maybe_array->IsFailure()) return maybe_array;
+ }
}
}
@@ -298,8 +290,6 @@ static MaybeObject* ArrayCodeGenericCommon(Arguments* args,
}
} else {
// Allocate the JS Array
- // TODO(mvstanton): There is no allocation info advice for this case.
- // How to address?
MaybeObject* maybe_obj = heap->AllocateJSObject(constructor);
if (!maybe_obj->To(&array)) return maybe_obj;
}
@@ -307,12 +297,7 @@ static MaybeObject* ArrayCodeGenericCommon(Arguments* args,
Arguments adjusted_arguments(args->length() - 1, args->arguments() - 1);
ASSERT(adjusted_arguments.length() < 1 ||
adjusted_arguments[0] == (*args)[1]);
- { MaybeObject* maybe_obj = ArrayConstructInitializeElements(array,
- &adjusted_arguments);
- if (!maybe_obj->To(&array)) return maybe_obj;
- }
-
- return array;
+ return ArrayConstructInitializeElements(array, &adjusted_arguments);
}
@@ -1183,8 +1168,6 @@ BUILTIN(ArrayConcat) {
heap->AllocateJSArrayAndStorage(elements_kind,
result_len,
result_len,
- DONT_TRACK_ALLOCATION_SITE,
- NULL,
mode);
if (!maybe_array->To(&result_array)) return maybe_array;
if (result_len == 0) return result_array;
« no previous file with comments | « src/builtins.h ('k') | src/elements.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698