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

Unified Diff: src/objects-inl.h

Issue 702243003: Basic array capacity feedback via allocation sites. Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Update. Created 6 years, 1 month 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/objects.h ('k') | src/runtime/runtime.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects-inl.h
diff --git a/src/objects-inl.h b/src/objects-inl.h
index cff5b61b527bec83db46b2efbc99d85898e0a1ae..c4f386eb1bf2c80872e7d5be40fba475ad2eb856 100644
--- a/src/objects-inl.h
+++ b/src/objects-inl.h
@@ -1704,6 +1704,38 @@ inline bool AllocationSite::MakePretenureDecision(
}
+int AllocationSite::GetInitialElementsCapacity() {
+ if (FLAG_initial_capacity_mode != 2) {
+ return JSArray::PreallocatedArrayElements();
+ }
+
+ if (SitePointsToLiteral()) return 0;
+ int value = Smi::cast(transition_info())->value();
+ return InitialElementsCapacity::decode(value);
+}
+
+
+void AllocationSite::DigestInitialElementsCapacityFeedback(int new_length) {
+ if (FLAG_initial_capacity_mode != 2) return;
+
+ if (new_length > 0 && !SitePointsToLiteral()) {
+ int to_store = (new_length + (new_length >> 1) + 16) / 4;
+ int old_capacity = GetInitialElementsCapacity();
+ if (to_store > old_capacity &&
+ InitialElementsCapacity::is_valid(to_store)) {
+ int value = Smi::cast(transition_info())->value();
+ set_transition_info(
+ Smi::FromInt(InitialElementsCapacity::update(value, to_store)),
+ SKIP_WRITE_BARRIER);
+ if (FLAG_trace_track_allocation_sites) {
+ PrintF("Initial elements capacity for site %p, updated to %d.\n",
+ static_cast<void*>(this), to_store);
+ }
+ }
+ }
+}
+
+
inline bool AllocationSite::DigestPretenuringFeedback(
bool maximum_size_scavenge) {
bool deopt = false;
« no previous file with comments | « src/objects.h ('k') | src/runtime/runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698