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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « src/objects.h ('k') | src/runtime/runtime.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 // 4 //
5 // Review notes: 5 // Review notes:
6 // 6 //
7 // - The use of macros in these inline functions may seem superfluous 7 // - The use of macros in these inline functions may seem superfluous
8 // but it is absolutely needed to make sure gcc generates optimal 8 // but it is absolutely needed to make sure gcc generates optimal
9 // code. gcc is not happy when attempting to inline too deep. 9 // code. gcc is not happy when attempting to inline too deep.
10 // 10 //
(...skipping 1686 matching lines...) Expand 10 before | Expand all | Expand 10 after
1697 } 1697 }
1698 set_pretenure_decision(kMaybeTenure); 1698 set_pretenure_decision(kMaybeTenure);
1699 } else { 1699 } else {
1700 set_pretenure_decision(kDontTenure); 1700 set_pretenure_decision(kDontTenure);
1701 } 1701 }
1702 } 1702 }
1703 return false; 1703 return false;
1704 } 1704 }
1705 1705
1706 1706
1707 int AllocationSite::GetInitialElementsCapacity() {
1708 if (FLAG_initial_capacity_mode != 2) {
1709 return JSArray::PreallocatedArrayElements();
1710 }
1711
1712 if (SitePointsToLiteral()) return 0;
1713 int value = Smi::cast(transition_info())->value();
1714 return InitialElementsCapacity::decode(value);
1715 }
1716
1717
1718 void AllocationSite::DigestInitialElementsCapacityFeedback(int new_length) {
1719 if (FLAG_initial_capacity_mode != 2) return;
1720
1721 if (new_length > 0 && !SitePointsToLiteral()) {
1722 int to_store = (new_length + (new_length >> 1) + 16) / 4;
1723 int old_capacity = GetInitialElementsCapacity();
1724 if (to_store > old_capacity &&
1725 InitialElementsCapacity::is_valid(to_store)) {
1726 int value = Smi::cast(transition_info())->value();
1727 set_transition_info(
1728 Smi::FromInt(InitialElementsCapacity::update(value, to_store)),
1729 SKIP_WRITE_BARRIER);
1730 if (FLAG_trace_track_allocation_sites) {
1731 PrintF("Initial elements capacity for site %p, updated to %d.\n",
1732 static_cast<void*>(this), to_store);
1733 }
1734 }
1735 }
1736 }
1737
1738
1707 inline bool AllocationSite::DigestPretenuringFeedback( 1739 inline bool AllocationSite::DigestPretenuringFeedback(
1708 bool maximum_size_scavenge) { 1740 bool maximum_size_scavenge) {
1709 bool deopt = false; 1741 bool deopt = false;
1710 int create_count = memento_create_count(); 1742 int create_count = memento_create_count();
1711 int found_count = memento_found_count(); 1743 int found_count = memento_found_count();
1712 bool minimum_mementos_created = create_count >= kPretenureMinimumCreated; 1744 bool minimum_mementos_created = create_count >= kPretenureMinimumCreated;
1713 double ratio = 1745 double ratio =
1714 minimum_mementos_created || FLAG_trace_pretenuring_statistics ? 1746 minimum_mementos_created || FLAG_trace_pretenuring_statistics ?
1715 static_cast<double>(found_count) / create_count : 0.0; 1747 static_cast<double>(found_count) / create_count : 0.0;
1716 PretenureDecision current_decision = pretenure_decision(); 1748 PretenureDecision current_decision = pretenure_decision();
(...skipping 5540 matching lines...) Expand 10 before | Expand all | Expand 10 after
7257 #undef READ_SHORT_FIELD 7289 #undef READ_SHORT_FIELD
7258 #undef WRITE_SHORT_FIELD 7290 #undef WRITE_SHORT_FIELD
7259 #undef READ_BYTE_FIELD 7291 #undef READ_BYTE_FIELD
7260 #undef WRITE_BYTE_FIELD 7292 #undef WRITE_BYTE_FIELD
7261 #undef NOBARRIER_READ_BYTE_FIELD 7293 #undef NOBARRIER_READ_BYTE_FIELD
7262 #undef NOBARRIER_WRITE_BYTE_FIELD 7294 #undef NOBARRIER_WRITE_BYTE_FIELD
7263 7295
7264 } } // namespace v8::internal 7296 } } // namespace v8::internal
7265 7297
7266 #endif // V8_OBJECTS_INL_H_ 7298 #endif // V8_OBJECTS_INL_H_
OLDNEW
« 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