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

Unified Diff: src/elements.cc

Issue 1340033002: builtins.cc return PackedElementsKind where applicable (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fullstop Created 5 years, 3 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/objects.cc » ('j') | no next file with comments »
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 32e6605ca2fbd04d07a80a387a825c6bec346482..ef3b2a43010dbde4b8e6a5a5e0ea927e1318df00 100644
--- a/src/elements.cc
+++ b/src/elements.cc
@@ -534,6 +534,24 @@ class ElementsAccessorBase : public ElementsAccessor {
return true;
}
+ static void TryTransitionResultArrayToPacked(Handle<JSArray> array) {
+ if (!IsHoleyElementsKind(kind())) return;
+ int length = Smi::cast(array->length())->value();
+ Handle<FixedArrayBase> backing_store(array->elements());
+ if (!ElementsAccessorSubclass::IsPackedImpl(array, backing_store, 0,
+ length)) {
+ return;
+ }
+ ElementsKind packed_kind = GetPackedElementsKind(kind());
+ Handle<Map> new_map =
+ JSObject::GetElementsTransitionMap(array, packed_kind);
+ JSObject::MigrateToMap(array, new_map);
+ if (FLAG_trace_elements_transitions) {
+ JSObject::PrintElementsTransition(stdout, array, kind(), backing_store,
+ packed_kind, backing_store);
+ }
+ }
+
virtual bool HasElement(Handle<JSObject> holder, uint32_t index,
Handle<FixedArrayBase> backing_store) final {
return ElementsAccessorSubclass::HasElementImpl(holder, index,
@@ -1445,6 +1463,8 @@ class FastElementsAccessor
FastElementsAccessorSubclass::CopyElementsImpl(
*backing_store, start, result_array->elements(), KindTraits::Kind, 0,
kPackedSizeNotKnown, result_len);
+ FastElementsAccessorSubclass::TryTransitionResultArrayToPacked(
+ result_array);
return result_array;
}
@@ -1499,6 +1519,8 @@ class FastElementsAccessor
receiver->set_elements(*backing_store);
}
receiver->set_length(Smi::FromInt(new_length));
+ FastElementsAccessorSubclass::TryTransitionResultArrayToPacked(
+ deleted_elements);
return deleted_elements;
}
« no previous file with comments | « src/builtins.cc ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698