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

Unified Diff: src/elements.cc

Issue 11818021: Allocation Info Tracking, continued. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Review feedback 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.cc ('k') | src/heap.h » ('j') | src/heap.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/elements.cc
diff --git a/src/elements.cc b/src/elements.cc
index 1b6c433e37e61c1f6e5f09cb7535a0be7d5d3444..779764ea7b452de227241785803b6f2fe3154dd7 100644
--- a/src/elements.cc
+++ b/src/elements.cc
@@ -1978,6 +1978,11 @@ MUST_USE_RESULT MaybeObject* ArrayConstructInitializeElements(
JSArray* array, Arguments* args) {
Heap* heap = array->GetIsolate()->heap();
+ // Optimize the case where there are no parameters passed.
+ if (args->length() == 0) {
+ return array->Initialize(JSArray::kPreallocatedArrayElements);
+ }
+
// Optimize the case where there is one argument and the argument is a
// small smi.
if (args->length() == 1) {
@@ -1985,41 +1990,27 @@ MUST_USE_RESULT MaybeObject* ArrayConstructInitializeElements(
if (obj->IsSmi()) {
int len = Smi::cast(obj)->value();
if (len > 0 && len < JSObject::kInitialMaxFastElementArray) {
- FixedArrayBase* fixed_array;
ElementsKind elements_kind = array->GetElementsKind();
- {
- MaybeObject* maybe_obj;
- if (IsFastDoubleElementsKind(elements_kind)) {
- maybe_obj = heap->AllocateFixedDoubleArrayWithHoles(len);
- } else {
- maybe_obj = heap->AllocateFixedArrayWithHoles(len);
- }
- if (!maybe_obj->To(&fixed_array)) return maybe_obj;
- }
+ MaybeObject* maybe_array = array->Initialize(len, len);
+ if (maybe_array->IsFailure()) return maybe_array;
+
if (!IsFastHoleyElementsKind(elements_kind)) {
elements_kind = GetHoleyElementsKind(elements_kind);
- MaybeObject* maybe_array =
- array->TransitionElementsKind(elements_kind);
+ maybe_array = array->TransitionElementsKind(elements_kind);
if (maybe_array->IsFailure()) return maybe_array;
}
- // We do not use SetContent to skip the unnecessary elements type check.
- array->set_elements(fixed_array);
- array->set_length(Smi::cast(obj));
+
return array;
} else if (len == 0) {
return array->Initialize(JSArray::kPreallocatedArrayElements);
}
}
+
// Take the argument as the length.
- { MaybeObject* maybe_obj = array->Initialize(0);
- if (!maybe_obj->ToObject(&obj)) return maybe_obj;
- }
- return array->SetElementsLength((*args)[0]);
- }
+ MaybeObject* maybe_obj = array->Initialize(0);
+ if (!maybe_obj->To(&obj)) return maybe_obj;
- // Optimize the case where there are no parameters passed.
- if (args->length() == 0) {
- return array->Initialize(JSArray::kPreallocatedArrayElements);
+ return array->SetElementsLength((*args)[0]);
}
// Set length and elements on the array.
« no previous file with comments | « src/builtins.cc ('k') | src/heap.h » ('j') | src/heap.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698