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

Unified Diff: src/heap.cc

Issue 15172003: Preallocate transitioned maps for TypedArrays. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 7 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
« src/heap.h ('K') | « src/heap.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/heap.cc
diff --git a/src/heap.cc b/src/heap.cc
index 6a6afc022e54aff302e78a78abf2ecdaaf7dd423..284cc114565a6b2740d7b4939ece02d6d722bdb7 100644
--- a/src/heap.cc
+++ b/src/heap.cc
@@ -2517,6 +2517,54 @@ bool Heap::CreateInitialMaps() {
}
set_external_double_array_map(Map::cast(obj));
+ { MaybeObject* maybe_obj = AllocateEmptyExternalArray(kExternalByteArray);
+ if (!maybe_obj->ToObject(&obj)) return false;
+ }
+ set_empty_external_byte_array(ExternalArray::cast(obj));
+
+ { MaybeObject* maybe_obj =
+ AllocateEmptyExternalArray(kExternalUnsignedByteArray);
+ if (!maybe_obj->ToObject(&obj)) return false;
+ }
+ set_empty_external_unsigned_byte_array(ExternalArray::cast(obj));
+
+ { MaybeObject* maybe_obj = AllocateEmptyExternalArray(kExternalShortArray);
+ if (!maybe_obj->ToObject(&obj)) return false;
+ }
+ set_empty_external_short_array(ExternalArray::cast(obj));
+
+ { MaybeObject* maybe_obj = AllocateEmptyExternalArray(
+ kExternalUnsignedShortArray);
+ if (!maybe_obj->ToObject(&obj)) return false;
+ }
+ set_empty_external_unsigned_short_array(ExternalArray::cast(obj));
+
+ { MaybeObject* maybe_obj = AllocateEmptyExternalArray(kExternalIntArray);
+ if (!maybe_obj->ToObject(&obj)) return false;
+ }
+ set_empty_external_int_array(ExternalArray::cast(obj));
+
+ { MaybeObject* maybe_obj =
+ AllocateEmptyExternalArray(kExternalUnsignedIntArray);
+ if (!maybe_obj->ToObject(&obj)) return false;
+ }
+ set_empty_external_unsigned_int_array(ExternalArray::cast(obj));
+
+ { MaybeObject* maybe_obj = AllocateEmptyExternalArray(kExternalFloatArray);
+ if (!maybe_obj->ToObject(&obj)) return false;
+ }
+ set_empty_external_float_array(ExternalArray::cast(obj));
+
+ { MaybeObject* maybe_obj = AllocateEmptyExternalArray(kExternalDoubleArray);
+ if (!maybe_obj->ToObject(&obj)) return false;
+ }
+ set_empty_external_double_array(ExternalArray::cast(obj));
+
+ { MaybeObject* maybe_obj = AllocateEmptyExternalArray(kExternalPixelArray);
+ if (!maybe_obj->ToObject(&obj)) return false;
+ }
+ set_empty_external_pixel_array(ExternalArray::cast(obj));
+
{ MaybeObject* maybe_obj = AllocateMap(CODE_TYPE, kVariableSizeSentinel);
if (!maybe_obj->ToObject(&obj)) return false;
}
@@ -3248,6 +3296,40 @@ Heap::RootListIndex Heap::RootIndexForExternalArrayType(
}
}
+Heap::RootListIndex Heap::RootIndexForEmptyExternalArray(
+ ElementsKind elementsKind) {
+ switch (elementsKind) {
+ case EXTERNAL_BYTE_ELEMENTS:
+ return kEmptyExternalByteArrayRootIndex;
+ case EXTERNAL_UNSIGNED_BYTE_ELEMENTS:
+ return kEmptyExternalUnsignedByteArrayRootIndex;
+ case EXTERNAL_SHORT_ELEMENTS:
+ return kEmptyExternalShortArrayRootIndex;
+ case EXTERNAL_UNSIGNED_SHORT_ELEMENTS:
+ return kEmptyExternalUnsignedShortArrayRootIndex;
+ case EXTERNAL_INT_ELEMENTS:
+ return kEmptyExternalIntArrayRootIndex;
+ case EXTERNAL_UNSIGNED_INT_ELEMENTS:
+ return kEmptyExternalUnsignedIntArrayRootIndex;
+ case EXTERNAL_FLOAT_ELEMENTS:
+ return kEmptyExternalFloatArrayRootIndex;
+ case EXTERNAL_DOUBLE_ELEMENTS:
+ return kEmptyExternalDoubleArrayRootIndex;
+ case EXTERNAL_PIXEL_ELEMENTS:
+ return kEmptyExternalPixelArrayRootIndex;
+ default:
+ UNREACHABLE();
+ return kUndefinedValueRootIndex;
+ }
+}
+
+ExternalArray* Heap::EmptyExternalArrayForMap(Map* map) {
+ return ExternalArray::cast(
+ roots_[RootIndexForEmptyExternalArray(map->elements_kind())]);
+}
+
+
+
MaybeObject* Heap::NumberFromDouble(double value, PretenureFlag pretenure) {
// We need to distinguish the minus zero value and this cannot be
@@ -4252,7 +4334,8 @@ MaybeObject* Heap::AllocateJSObjectFromMap(Map* map, PretenureFlag pretenure) {
InitializeJSObjectFromMap(JSObject::cast(obj),
FixedArray::cast(properties),
map);
- ASSERT(JSObject::cast(obj)->HasFastElements());
+ ASSERT(JSObject::cast(obj)->HasFastElements() ||
+ JSObject::cast(obj)->HasExternalArrayElements());
return obj;
}
@@ -5216,6 +5299,10 @@ MaybeObject* Heap::AllocateEmptyFixedArray() {
return result;
}
+MaybeObject* Heap::AllocateEmptyExternalArray(ExternalArrayType array_type) {
+ return AllocateExternalArray(0, array_type, NULL, TENURED);
+}
+
MaybeObject* Heap::AllocateRawFixedArray(int length) {
if (length < 0 || length > FixedArray::kMaxLength) {
« src/heap.h ('K') | « src/heap.h ('k') | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698