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

Side by Side Diff: src/heap.h

Issue 8519002: Start incremental marking on idle notification. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments. Created 9 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 | Annotate | Revision Log
« no previous file with comments | « src/api.cc ('k') | src/heap.cc » ('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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 1250 matching lines...) Expand 10 before | Expand all | Expand 10 after
1261 intptr_t OldGenAllocationLimit(intptr_t old_gen_size) { 1261 intptr_t OldGenAllocationLimit(intptr_t old_gen_size) {
1262 const int divisor = FLAG_stress_compaction ? 8 : 2; 1262 const int divisor = FLAG_stress_compaction ? 8 : 2;
1263 intptr_t limit = 1263 intptr_t limit =
1264 Max(old_gen_size + old_gen_size / divisor, kMinimumAllocationLimit); 1264 Max(old_gen_size + old_gen_size / divisor, kMinimumAllocationLimit);
1265 limit += new_space_.Capacity(); 1265 limit += new_space_.Capacity();
1266 limit *= old_gen_limit_factor_; 1266 limit *= old_gen_limit_factor_;
1267 intptr_t halfway_to_the_max = (old_gen_size + max_old_generation_size_) / 2; 1267 intptr_t halfway_to_the_max = (old_gen_size + max_old_generation_size_) / 2;
1268 return Min(limit, halfway_to_the_max); 1268 return Min(limit, halfway_to_the_max);
1269 } 1269 }
1270 1270
1271 // Can be called when the embedding application is idle. 1271 // Implements the corresponding V8 API function.
1272 bool IdleNotification(); 1272 bool IdleNotification(int hint);
1273 1273
1274 // Declare all the root indices. 1274 // Declare all the root indices.
1275 enum RootListIndex { 1275 enum RootListIndex {
1276 #define ROOT_INDEX_DECLARATION(type, name, camel_name) k##camel_name##RootIndex, 1276 #define ROOT_INDEX_DECLARATION(type, name, camel_name) k##camel_name##RootIndex,
1277 STRONG_ROOT_LIST(ROOT_INDEX_DECLARATION) 1277 STRONG_ROOT_LIST(ROOT_INDEX_DECLARATION)
1278 #undef ROOT_INDEX_DECLARATION 1278 #undef ROOT_INDEX_DECLARATION
1279 1279
1280 // Utility type maps 1280 // Utility type maps
1281 #define DECLARE_STRUCT_MAP(NAME, Name, name) k##Name##MapRootIndex, 1281 #define DECLARE_STRUCT_MAP(NAME, Name, name) k##Name##MapRootIndex,
1282 STRUCT_LIST(DECLARE_STRUCT_MAP) 1282 STRUCT_LIST(DECLARE_STRUCT_MAP)
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
1385 } 1385 }
1386 1386
1387 Marking* marking() { 1387 Marking* marking() {
1388 return &marking_; 1388 return &marking_;
1389 } 1389 }
1390 1390
1391 IncrementalMarking* incremental_marking() { 1391 IncrementalMarking* incremental_marking() {
1392 return &incremental_marking_; 1392 return &incremental_marking_;
1393 } 1393 }
1394 1394
1395 bool IsSweepingComplete() {
1396 return old_data_space()->IsSweepingComplete() &&
1397 old_pointer_space()->IsSweepingComplete();
1398 }
1399
1400 bool AdvanceSweepers(int step_size) {
1401 bool sweeping_complete = old_data_space()->AdvanceSweeper(step_size);
1402 sweeping_complete &= old_pointer_space()->AdvanceSweeper(step_size);
1403 return sweeping_complete;
1404 }
1405
1395 ExternalStringTable* external_string_table() { 1406 ExternalStringTable* external_string_table() {
1396 return &external_string_table_; 1407 return &external_string_table_;
1397 } 1408 }
1398 1409
1399 // Returns the current sweep generation. 1410 // Returns the current sweep generation.
1400 int sweep_generation() { 1411 int sweep_generation() {
1401 return sweep_generation_; 1412 return sweep_generation_;
1402 } 1413 }
1403 1414
1404 inline Isolate* isolate(); 1415 inline Isolate* isolate();
(...skipping 15 matching lines...) Expand all
1420 void QueueMemoryChunkForFree(MemoryChunk* chunk); 1431 void QueueMemoryChunkForFree(MemoryChunk* chunk);
1421 void FreeQueuedChunks(); 1432 void FreeQueuedChunks();
1422 1433
1423 // Completely clear the Instanceof cache (to stop it keeping objects alive 1434 // Completely clear the Instanceof cache (to stop it keeping objects alive
1424 // around a GC). 1435 // around a GC).
1425 inline void CompletelyClearInstanceofCache(); 1436 inline void CompletelyClearInstanceofCache();
1426 1437
1427 // The roots that have an index less than this are always in old space. 1438 // The roots that have an index less than this are always in old space.
1428 static const int kOldSpaceRoots = 0x20; 1439 static const int kOldSpaceRoots = 0x20;
1429 1440
1441 bool idle_notification_will_schedule_next_gc() {
1442 return idle_notification_will_schedule_next_gc_;
1443 }
1444
1430 private: 1445 private:
1431 Heap(); 1446 Heap();
1432 1447
1433 // This can be calculated directly from a pointer to the heap; however, it is 1448 // This can be calculated directly from a pointer to the heap; however, it is
1434 // more expedient to get at the isolate directly from within Heap methods. 1449 // more expedient to get at the isolate directly from within Heap methods.
1435 Isolate* isolate_; 1450 Isolate* isolate_;
1436 1451
1437 intptr_t code_range_size_; 1452 intptr_t code_range_size_;
1438 int reserved_semispace_size_; 1453 int reserved_semispace_size_;
1439 int max_semispace_size_; 1454 int max_semispace_size_;
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
1745 bool IsIncreasingSurvivalTrend() { 1760 bool IsIncreasingSurvivalTrend() {
1746 return survival_rate_trend() == INCREASING; 1761 return survival_rate_trend() == INCREASING;
1747 } 1762 }
1748 1763
1749 bool IsHighSurvivalRate() { 1764 bool IsHighSurvivalRate() {
1750 return high_survival_rate_period_length_ > 0; 1765 return high_survival_rate_period_length_ > 0;
1751 } 1766 }
1752 1767
1753 void SelectScavengingVisitorsTable(); 1768 void SelectScavengingVisitorsTable();
1754 1769
1770 void StartIdleRound() {
1771 mark_sweeps_since_idle_round_started_ = 0;
1772 ms_count_at_last_idle_notification_ = ms_count_;
1773 }
1774
1775 void FinishIdleRound() {
1776 mark_sweeps_since_idle_round_started_ = kMaxMarkSweepsInIdleRound;
1777 gc_count_when_last_idle_round_finished_ = gc_count_;
1778 }
1779
1780 bool EnoughGarbageSinceLastIdleRound() {
1781 return (gc_count_ - gc_count_when_last_idle_round_finished_ > 4);
ulan 2011/11/11 13:27:26 We agreed to count only scavenges here, but for th
Erik Corry 2011/11/14 23:05:17 I really think we should just add the extra counte
ulan 2011/11/15 09:08:43 Done.
1782 }
1783
1784 bool WorthStartingGCWhenIdle() {
1785 if (contexts_disposed_ > 0) {
1786 return true;
1787 }
1788 if (mark_sweeps_since_idle_round_started_ < kMaxMarkSweepsInIdleRound) {
1789 return incremental_marking()->WorthActivating();
1790 }
1791 if (EnoughGarbageSinceLastIdleRound()) {
1792 return incremental_marking()->WorthActivating() &&
1793 NextGCIsLikelyToBeFull();
1794 }
1795 return false;
1796 }
1797
1798 // Returns true if no more GC work is left.
1799 bool IdleGlobalGC();
1800
1755 static const int kInitialSymbolTableSize = 2048; 1801 static const int kInitialSymbolTableSize = 2048;
1756 static const int kInitialEvalCacheSize = 64; 1802 static const int kInitialEvalCacheSize = 64;
1757 1803
1758 // Maximum GC pause. 1804 // Maximum GC pause.
1759 int max_gc_pause_; 1805 int max_gc_pause_;
1760 1806
1761 // Maximum size of objects alive after GC. 1807 // Maximum size of objects alive after GC.
1762 intptr_t max_alive_after_gc_; 1808 intptr_t max_alive_after_gc_;
1763 1809
1764 // Minimal interval between two subsequent collections. 1810 // Minimal interval between two subsequent collections.
1765 int min_in_mutator_; 1811 int min_in_mutator_;
1766 1812
1767 // Size of objects alive after last GC. 1813 // Size of objects alive after last GC.
1768 intptr_t alive_after_last_gc_; 1814 intptr_t alive_after_last_gc_;
1769 1815
1770 double last_gc_end_timestamp_; 1816 double last_gc_end_timestamp_;
1771 1817
1772 MarkCompactCollector mark_compact_collector_; 1818 MarkCompactCollector mark_compact_collector_;
1773 1819
1774 StoreBuffer store_buffer_; 1820 StoreBuffer store_buffer_;
1775 1821
1776 Marking marking_; 1822 Marking marking_;
1777 1823
1778 IncrementalMarking incremental_marking_; 1824 IncrementalMarking incremental_marking_;
1779 1825
1780 int number_idle_notifications_; 1826 int number_idle_notifications_;
1781 unsigned int last_idle_notification_gc_count_; 1827 unsigned int last_idle_notification_gc_count_;
1782 bool last_idle_notification_gc_count_init_; 1828 bool last_idle_notification_gc_count_init_;
1783 1829
1830 bool idle_notification_will_schedule_next_gc_;
1831 int mark_sweeps_since_idle_round_started_;
1832 int ms_count_at_last_idle_notification_;
1833 unsigned int gc_count_at_last_idle_gc_;
1834 unsigned int gc_count_when_last_idle_round_finished_;
1835
1836 static const int kMaxMarkSweepsInIdleRound = 7;
1837
1784 // Shared state read by the scavenge collector and set by ScavengeObject. 1838 // Shared state read by the scavenge collector and set by ScavengeObject.
1785 PromotionQueue promotion_queue_; 1839 PromotionQueue promotion_queue_;
1786 1840
1787 // Flag is set when the heap has been configured. The heap can be repeatedly 1841 // Flag is set when the heap has been configured. The heap can be repeatedly
1788 // configured through the API until it is setup. 1842 // configured through the API until it is setup.
1789 bool configured_; 1843 bool configured_;
1790 1844
1791 ExternalStringTable external_string_table_; 1845 ExternalStringTable external_string_table_;
1792 1846
1793 VisitorDispatchTable<ScavengingCallback> scavenging_visitors_table_; 1847 VisitorDispatchTable<ScavengingCallback> scavenging_visitors_table_;
(...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after
2478 2532
2479 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); 2533 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer);
2480 }; 2534 };
2481 #endif // DEBUG || LIVE_OBJECT_LIST 2535 #endif // DEBUG || LIVE_OBJECT_LIST
2482 2536
2483 } } // namespace v8::internal 2537 } } // namespace v8::internal
2484 2538
2485 #undef HEAP 2539 #undef HEAP
2486 2540
2487 #endif // V8_HEAP_H_ 2541 #endif // V8_HEAP_H_
OLDNEW
« no previous file with comments | « src/api.cc ('k') | src/heap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698