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

Unified Diff: src/elements.cc

Issue 2252393002: [elements, turbofan] Implement simple GrowElements (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix Android build Created 4 years, 4 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/elements.h ('k') | src/objects.h » ('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 56d800168de6fc1c6e7747c9e5cb7fd34d1eb438..b4396dd90b7ff0c31c36fe41361365f4bb6e15fe 100644
--- a/src/elements.cc
+++ b/src/elements.cc
@@ -911,6 +911,30 @@ class ElementsAccessorBase : public ElementsAccessor {
Subclass::GrowCapacityAndConvertImpl(object, capacity);
}
+ bool GrowCapacity(Handle<JSObject> object, uint32_t index) final {
+ // This function is intended to be called from optimized code. We don't
+ // want to trigger lazy deopts there, so refuse to handle cases that would.
+ if (object->map()->is_prototype_map() ||
+ object->WouldConvertToSlowElements(index)) {
+ return false;
+ }
+ Handle<FixedArrayBase> old_elements(object->elements());
+ uint32_t new_capacity = JSObject::NewElementsCapacity(index + 1);
+ DCHECK(static_cast<uint32_t>(old_elements->length()) < new_capacity);
+ Handle<FixedArrayBase> elements =
+ ConvertElementsWithCapacity(object, old_elements, kind(), new_capacity);
+
+ DCHECK_EQ(object->GetElementsKind(), kind());
+ // Transition through the allocation site as well if present.
+ if (JSObject::UpdateAllocationSite<AllocationSiteUpdateMode::kCheckOnly>(
+ object, kind())) {
+ return false;
+ }
+
+ object->set_elements(*elements);
+ return true;
+ }
+
void Delete(Handle<JSObject> obj, uint32_t entry) final {
Subclass::DeleteImpl(obj, entry);
}
« no previous file with comments | « src/elements.h ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698