OLD | NEW |
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 Loading... |
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 Loading... |
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 Loading... |
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 30 matching lines...) Expand all Loading... |
1470 CellSpace* cell_space_; | 1485 CellSpace* cell_space_; |
1471 LargeObjectSpace* lo_space_; | 1486 LargeObjectSpace* lo_space_; |
1472 HeapState gc_state_; | 1487 HeapState gc_state_; |
1473 int gc_post_processing_depth_; | 1488 int gc_post_processing_depth_; |
1474 | 1489 |
1475 // Returns the amount of external memory registered since last global gc. | 1490 // Returns the amount of external memory registered since last global gc. |
1476 int PromotedExternalMemorySize(); | 1491 int PromotedExternalMemorySize(); |
1477 | 1492 |
1478 int ms_count_; // how many mark-sweep collections happened | 1493 int ms_count_; // how many mark-sweep collections happened |
1479 unsigned int gc_count_; // how many gc happened | 1494 unsigned int gc_count_; // how many gc happened |
| 1495 int scavenges_since_last_full_gc_; |
1480 | 1496 |
1481 // Total length of the strings we failed to flatten since the last GC. | 1497 // Total length of the strings we failed to flatten since the last GC. |
1482 int unflattened_strings_length_; | 1498 int unflattened_strings_length_; |
1483 | 1499 |
1484 #define ROOT_ACCESSOR(type, name, camel_name) \ | 1500 #define ROOT_ACCESSOR(type, name, camel_name) \ |
1485 inline void set_##name(type* value) { \ | 1501 inline void set_##name(type* value) { \ |
1486 /* The deserializer makes use of the fact that these common roots are */ \ | 1502 /* The deserializer makes use of the fact that these common roots are */ \ |
1487 /* never in new space and never on a page that is being compacted. */ \ | 1503 /* never in new space and never on a page that is being compacted. */ \ |
1488 ASSERT(k##camel_name##RootIndex >= kOldSpaceRoots || !InNewSpace(value)); \ | 1504 ASSERT(k##camel_name##RootIndex >= kOldSpaceRoots || !InNewSpace(value)); \ |
1489 roots_[k##camel_name##RootIndex] = value; \ | 1505 roots_[k##camel_name##RootIndex] = value; \ |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1745 bool IsIncreasingSurvivalTrend() { | 1761 bool IsIncreasingSurvivalTrend() { |
1746 return survival_rate_trend() == INCREASING; | 1762 return survival_rate_trend() == INCREASING; |
1747 } | 1763 } |
1748 | 1764 |
1749 bool IsHighSurvivalRate() { | 1765 bool IsHighSurvivalRate() { |
1750 return high_survival_rate_period_length_ > 0; | 1766 return high_survival_rate_period_length_ > 0; |
1751 } | 1767 } |
1752 | 1768 |
1753 void SelectScavengingVisitorsTable(); | 1769 void SelectScavengingVisitorsTable(); |
1754 | 1770 |
| 1771 void StartIdleRound() { |
| 1772 mark_sweeps_since_idle_round_started_ = 0; |
| 1773 ms_count_at_last_idle_notification_ = ms_count_; |
| 1774 } |
| 1775 |
| 1776 void FinishIdleRound() { |
| 1777 mark_sweeps_since_idle_round_started_ = kMaxMarkSweepsInIdleRound; |
| 1778 } |
| 1779 |
| 1780 bool EnoughGarbageSinceLastIdleRound() { |
| 1781 return (scavenges_since_last_full_gc_ > 4); |
| 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 |
| 1835 static const int kMaxMarkSweepsInIdleRound = 7; |
| 1836 |
1784 // Shared state read by the scavenge collector and set by ScavengeObject. | 1837 // Shared state read by the scavenge collector and set by ScavengeObject. |
1785 PromotionQueue promotion_queue_; | 1838 PromotionQueue promotion_queue_; |
1786 | 1839 |
1787 // Flag is set when the heap has been configured. The heap can be repeatedly | 1840 // Flag is set when the heap has been configured. The heap can be repeatedly |
1788 // configured through the API until it is setup. | 1841 // configured through the API until it is setup. |
1789 bool configured_; | 1842 bool configured_; |
1790 | 1843 |
1791 ExternalStringTable external_string_table_; | 1844 ExternalStringTable external_string_table_; |
1792 | 1845 |
1793 VisitorDispatchTable<ScavengingCallback> scavenging_visitors_table_; | 1846 VisitorDispatchTable<ScavengingCallback> scavenging_visitors_table_; |
(...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2478 | 2531 |
2479 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); | 2532 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); |
2480 }; | 2533 }; |
2481 #endif // DEBUG || LIVE_OBJECT_LIST | 2534 #endif // DEBUG || LIVE_OBJECT_LIST |
2482 | 2535 |
2483 } } // namespace v8::internal | 2536 } } // namespace v8::internal |
2484 | 2537 |
2485 #undef HEAP | 2538 #undef HEAP |
2486 | 2539 |
2487 #endif // V8_HEAP_H_ | 2540 #endif // V8_HEAP_H_ |
OLD | NEW |