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

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, tuned idle round starting conditions. 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') | src/heap.cc » ('J')
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 scavenges_since_last_idle_round_ = 0;
1778 }
1779
1780 bool EnoughGarbageSinceLastIdleRound() {
1781 return (scavenges_since_last_idle_round_ >= kIdleScavengeThreshold);
ulan 2011/11/23 16:18:06 The previous version would fail to start the idle
1782 }
1783
1784 bool WorthStartingGCWhenIdle() {
1785 if (contexts_disposed_ > 0) {
1786 return true;
1787 }
1788 return incremental_marking()->WorthActivating() && NextGCIsLikelyToBeFull();
1789 }
1790
1791 // Returns true if no more GC work is left.
1792 bool IdleGlobalGC();
1793
1755 static const int kInitialSymbolTableSize = 2048; 1794 static const int kInitialSymbolTableSize = 2048;
1756 static const int kInitialEvalCacheSize = 64; 1795 static const int kInitialEvalCacheSize = 64;
1757 1796
1758 // Maximum GC pause. 1797 // Maximum GC pause.
1759 int max_gc_pause_; 1798 int max_gc_pause_;
1760 1799
1761 // Maximum size of objects alive after GC. 1800 // Maximum size of objects alive after GC.
1762 intptr_t max_alive_after_gc_; 1801 intptr_t max_alive_after_gc_;
1763 1802
1764 // Minimal interval between two subsequent collections. 1803 // Minimal interval between two subsequent collections.
1765 int min_in_mutator_; 1804 int min_in_mutator_;
1766 1805
1767 // Size of objects alive after last GC. 1806 // Size of objects alive after last GC.
1768 intptr_t alive_after_last_gc_; 1807 intptr_t alive_after_last_gc_;
1769 1808
1770 double last_gc_end_timestamp_; 1809 double last_gc_end_timestamp_;
1771 1810
1772 MarkCompactCollector mark_compact_collector_; 1811 MarkCompactCollector mark_compact_collector_;
1773 1812
1774 StoreBuffer store_buffer_; 1813 StoreBuffer store_buffer_;
1775 1814
1776 Marking marking_; 1815 Marking marking_;
1777 1816
1778 IncrementalMarking incremental_marking_; 1817 IncrementalMarking incremental_marking_;
1779 1818
1780 int number_idle_notifications_; 1819 int number_idle_notifications_;
1781 unsigned int last_idle_notification_gc_count_; 1820 unsigned int last_idle_notification_gc_count_;
1782 bool last_idle_notification_gc_count_init_; 1821 bool last_idle_notification_gc_count_init_;
1783 1822
1823 bool idle_notification_will_schedule_next_gc_;
1824 int mark_sweeps_since_idle_round_started_;
1825 int ms_count_at_last_idle_notification_;
1826 unsigned int gc_count_at_last_idle_gc_;
1827 int scavenges_since_last_idle_round_;
1828
1829 static const int kMaxMarkSweepsInIdleRound = 7;
1830 static const int kIdleScavengeThreshold = 5;
1831
1784 // Shared state read by the scavenge collector and set by ScavengeObject. 1832 // Shared state read by the scavenge collector and set by ScavengeObject.
1785 PromotionQueue promotion_queue_; 1833 PromotionQueue promotion_queue_;
1786 1834
1787 // Flag is set when the heap has been configured. The heap can be repeatedly 1835 // Flag is set when the heap has been configured. The heap can be repeatedly
1788 // configured through the API until it is setup. 1836 // configured through the API until it is setup.
1789 bool configured_; 1837 bool configured_;
1790 1838
1791 ExternalStringTable external_string_table_; 1839 ExternalStringTable external_string_table_;
1792 1840
1793 VisitorDispatchTable<ScavengingCallback> scavenging_visitors_table_; 1841 VisitorDispatchTable<ScavengingCallback> scavenging_visitors_table_;
(...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after
2478 2526
2479 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); 2527 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer);
2480 }; 2528 };
2481 #endif // DEBUG || LIVE_OBJECT_LIST 2529 #endif // DEBUG || LIVE_OBJECT_LIST
2482 2530
2483 } } // namespace v8::internal 2531 } } // namespace v8::internal
2484 2532
2485 #undef HEAP 2533 #undef HEAP
2486 2534
2487 #endif // V8_HEAP_H_ 2535 #endif // V8_HEAP_H_
OLDNEW
« no previous file with comments | « src/api.cc ('k') | src/heap.cc » ('j') | src/heap.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698