| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 610 return old_pointer_space_->allocation_limit_address(); | 610 return old_pointer_space_->allocation_limit_address(); |
| 611 } | 611 } |
| 612 | 612 |
| 613 Address* OldDataSpaceAllocationTopAddress() { | 613 Address* OldDataSpaceAllocationTopAddress() { |
| 614 return old_data_space_->allocation_top_address(); | 614 return old_data_space_->allocation_top_address(); |
| 615 } | 615 } |
| 616 Address* OldDataSpaceAllocationLimitAddress() { | 616 Address* OldDataSpaceAllocationLimitAddress() { |
| 617 return old_data_space_->allocation_limit_address(); | 617 return old_data_space_->allocation_limit_address(); |
| 618 } | 618 } |
| 619 | 619 |
| 620 // Uncommit unused semi space. | |
| 621 bool UncommitFromSpace() { return new_space_.UncommitFromSpace(); } | |
| 622 | |
| 623 // Allocates and initializes a new JavaScript object based on a | 620 // Allocates and initializes a new JavaScript object based on a |
| 624 // constructor. | 621 // constructor. |
| 625 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation | 622 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation |
| 626 // failed. | 623 // failed. |
| 627 // Please note this does not perform a garbage collection. | 624 // Please note this does not perform a garbage collection. |
| 628 MUST_USE_RESULT MaybeObject* AllocateJSObject( | 625 MUST_USE_RESULT MaybeObject* AllocateJSObject( |
| 629 JSFunction* constructor, | 626 JSFunction* constructor, |
| 630 PretenureFlag pretenure = NOT_TENURED); | 627 PretenureFlag pretenure = NOT_TENURED); |
| 631 | 628 |
| 632 MUST_USE_RESULT MaybeObject* AllocateJSObjectWithAllocationSite( | 629 MUST_USE_RESULT MaybeObject* AllocateJSObjectWithAllocationSite( |
| (...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1168 // Returns a failure in case it was decided that flattening was | 1165 // Returns a failure in case it was decided that flattening was |
| 1169 // necessary and failed. Note, if flattening is not necessary the | 1166 // necessary and failed. Note, if flattening is not necessary the |
| 1170 // string might stay non-flat even when not a failure is returned. | 1167 // string might stay non-flat even when not a failure is returned. |
| 1171 // | 1168 // |
| 1172 // Please note this function does not perform a garbage collection. | 1169 // Please note this function does not perform a garbage collection. |
| 1173 MUST_USE_RESULT inline MaybeObject* PrepareForCompare(String* str); | 1170 MUST_USE_RESULT inline MaybeObject* PrepareForCompare(String* str); |
| 1174 | 1171 |
| 1175 // Converts the given boolean condition to JavaScript boolean value. | 1172 // Converts the given boolean condition to JavaScript boolean value. |
| 1176 inline Object* ToBoolean(bool condition); | 1173 inline Object* ToBoolean(bool condition); |
| 1177 | 1174 |
| 1178 // Code that should be run before and after each GC. Includes some | |
| 1179 // reporting/verification activities when compiled with DEBUG set. | |
| 1180 void GarbageCollectionPrologue(); | |
| 1181 void GarbageCollectionEpilogue(); | |
| 1182 | |
| 1183 // Performs garbage collection operation. | 1175 // Performs garbage collection operation. |
| 1184 // Returns whether there is a chance that another major GC could | 1176 // Returns whether there is a chance that another major GC could |
| 1185 // collect more garbage. | 1177 // collect more garbage. |
| 1186 bool CollectGarbage(AllocationSpace space, | |
| 1187 GarbageCollector collector, | |
| 1188 const char* gc_reason, | |
| 1189 const char* collector_reason); | |
| 1190 | |
| 1191 // Performs garbage collection operation. | |
| 1192 // Returns whether there is a chance that another major GC could | |
| 1193 // collect more garbage. | |
| 1194 inline bool CollectGarbage(AllocationSpace space, | 1178 inline bool CollectGarbage(AllocationSpace space, |
| 1195 const char* gc_reason = NULL); | 1179 const char* gc_reason = NULL); |
| 1196 | 1180 |
| 1197 static const int kNoGCFlags = 0; | 1181 static const int kNoGCFlags = 0; |
| 1198 static const int kSweepPreciselyMask = 1; | 1182 static const int kSweepPreciselyMask = 1; |
| 1199 static const int kReduceMemoryFootprintMask = 2; | 1183 static const int kReduceMemoryFootprintMask = 2; |
| 1200 static const int kAbortIncrementalMarkingMask = 4; | 1184 static const int kAbortIncrementalMarkingMask = 4; |
| 1201 | 1185 |
| 1202 // Making the heap iterable requires us to sweep precisely and abort any | 1186 // Making the heap iterable requires us to sweep precisely and abort any |
| 1203 // incremental marking as well. | 1187 // incremental marking as well. |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1422 return true; | 1406 return true; |
| 1423 #else | 1407 #else |
| 1424 #ifdef VERIFY_HEAP | 1408 #ifdef VERIFY_HEAP |
| 1425 return FLAG_verify_heap; | 1409 return FLAG_verify_heap; |
| 1426 #else | 1410 #else |
| 1427 return false; | 1411 return false; |
| 1428 #endif | 1412 #endif |
| 1429 #endif | 1413 #endif |
| 1430 } | 1414 } |
| 1431 | 1415 |
| 1432 // Fill in bogus values in from space | |
| 1433 void ZapFromSpace(); | |
| 1434 | |
| 1435 // Print short heap statistics. | 1416 // Print short heap statistics. |
| 1436 void PrintShortHeapStatistics(); | 1417 void PrintShortHeapStatistics(); |
| 1437 | 1418 |
| 1438 // Makes a new internalized string object | 1419 // Makes a new internalized string object |
| 1439 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation | 1420 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation |
| 1440 // failed. | 1421 // failed. |
| 1441 // Please note this function does not perform a garbage collection. | 1422 // Please note this function does not perform a garbage collection. |
| 1442 MUST_USE_RESULT MaybeObject* CreateInternalizedString( | 1423 MUST_USE_RESULT MaybeObject* CreateInternalizedString( |
| 1443 const char* str, int length, int hash); | 1424 const char* str, int length, int hash); |
| 1444 MUST_USE_RESULT MaybeObject* CreateInternalizedString(String* str); | 1425 MUST_USE_RESULT MaybeObject* CreateInternalizedString(String* str); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1468 void TracePathToGlobal(); | 1449 void TracePathToGlobal(); |
| 1469 #endif | 1450 #endif |
| 1470 | 1451 |
| 1471 // Callback function passed to Heap::Iterate etc. Copies an object if | 1452 // Callback function passed to Heap::Iterate etc. Copies an object if |
| 1472 // necessary, the object might be promoted to an old space. The caller must | 1453 // necessary, the object might be promoted to an old space. The caller must |
| 1473 // ensure the precondition that the object is (a) a heap object and (b) in | 1454 // ensure the precondition that the object is (a) a heap object and (b) in |
| 1474 // the heap's from space. | 1455 // the heap's from space. |
| 1475 static inline void ScavengePointer(HeapObject** p); | 1456 static inline void ScavengePointer(HeapObject** p); |
| 1476 static inline void ScavengeObject(HeapObject** p, HeapObject* object); | 1457 static inline void ScavengeObject(HeapObject** p, HeapObject* object); |
| 1477 | 1458 |
| 1478 // Commits from space if it is uncommitted. | |
| 1479 void EnsureFromSpaceIsCommitted(); | |
| 1480 | |
| 1481 // Support for partial snapshots. After calling this we have a linear | 1459 // Support for partial snapshots. After calling this we have a linear |
| 1482 // space to write objects in each space. | 1460 // space to write objects in each space. |
| 1483 void ReserveSpace(int *sizes, Address* addresses); | 1461 void ReserveSpace(int *sizes, Address* addresses); |
| 1484 | 1462 |
| 1485 // | 1463 // |
| 1486 // Support for the API. | 1464 // Support for the API. |
| 1487 // | 1465 // |
| 1488 | 1466 |
| 1489 bool CreateApiObjects(); | 1467 bool CreateApiObjects(); |
| 1490 | 1468 |
| 1491 // Attempt to find the number in a small cache. If we finds it, return | 1469 // Attempt to find the number in a small cache. If we finds it, return |
| 1492 // the string representation of the number. Otherwise return undefined. | 1470 // the string representation of the number. Otherwise return undefined. |
| 1493 Object* GetNumberStringCache(Object* number); | 1471 Object* GetNumberStringCache(Object* number); |
| 1494 | 1472 |
| 1495 // Update the cache with a new number-string pair. | 1473 // Update the cache with a new number-string pair. |
| 1496 void SetNumberStringCache(Object* number, String* str); | 1474 void SetNumberStringCache(Object* number, String* str); |
| 1497 | 1475 |
| 1498 // Adjusts the amount of registered external memory. | 1476 // Adjusts the amount of registered external memory. |
| 1499 // Returns the adjusted value. | 1477 // Returns the adjusted value. |
| 1500 inline intptr_t AdjustAmountOfExternalAllocatedMemory( | 1478 inline int64_t AdjustAmountOfExternalAllocatedMemory( |
| 1501 intptr_t change_in_bytes); | 1479 int64_t change_in_bytes); |
| 1502 | 1480 |
| 1503 // This is only needed for testing high promotion mode. | 1481 // This is only needed for testing high promotion mode. |
| 1504 void SetNewSpaceHighPromotionModeActive(bool mode) { | 1482 void SetNewSpaceHighPromotionModeActive(bool mode) { |
| 1505 new_space_high_promotion_mode_active_ = mode; | 1483 new_space_high_promotion_mode_active_ = mode; |
| 1506 } | 1484 } |
| 1507 | 1485 |
| 1508 // Returns the allocation mode (pre-tenuring) based on observed promotion | 1486 // Returns the allocation mode (pre-tenuring) based on observed promotion |
| 1509 // rates of previous collections. | 1487 // rates of previous collections. |
| 1510 inline PretenureFlag GetPretenureMode() { | 1488 inline PretenureFlag GetPretenureMode() { |
| 1511 return FLAG_pretenuring && new_space_high_promotion_mode_active_ | 1489 return FLAG_pretenuring && new_space_high_promotion_mode_active_ |
| 1512 ? TENURED : NOT_TENURED; | 1490 ? TENURED : NOT_TENURED; |
| 1513 } | 1491 } |
| 1514 | 1492 |
| 1515 inline Address* NewSpaceHighPromotionModeActiveAddress() { | 1493 inline Address* NewSpaceHighPromotionModeActiveAddress() { |
| 1516 return reinterpret_cast<Address*>(&new_space_high_promotion_mode_active_); | 1494 return reinterpret_cast<Address*>(&new_space_high_promotion_mode_active_); |
| 1517 } | 1495 } |
| 1518 | 1496 |
| 1519 inline intptr_t PromotedTotalSize() { | 1497 inline intptr_t PromotedTotalSize() { |
| 1520 return PromotedSpaceSizeOfObjects() + PromotedExternalMemorySize(); | 1498 int64_t total = PromotedSpaceSizeOfObjects() + PromotedExternalMemorySize(); |
| 1499 if (total > kMaxInt) return static_cast<intptr_t>(kMaxInt); |
| 1500 if (total < 0) return 0; |
| 1501 return static_cast<intptr_t>(total); |
| 1521 } | 1502 } |
| 1522 | 1503 |
| 1523 inline intptr_t OldGenerationSpaceAvailable() { | 1504 inline intptr_t OldGenerationSpaceAvailable() { |
| 1524 return old_generation_allocation_limit_ - PromotedTotalSize(); | 1505 return old_generation_allocation_limit_ - PromotedTotalSize(); |
| 1525 } | 1506 } |
| 1526 | 1507 |
| 1527 inline intptr_t OldGenerationCapacityAvailable() { | 1508 inline intptr_t OldGenerationCapacityAvailable() { |
| 1528 return max_old_generation_size_ - PromotedTotalSize(); | 1509 return max_old_generation_size_ - PromotedTotalSize(); |
| 1529 } | 1510 } |
| 1530 | 1511 |
| 1531 static const intptr_t kMinimumOldGenerationAllocationLimit = | 1512 static const intptr_t kMinimumOldGenerationAllocationLimit = |
| 1532 8 * (Page::kPageSize > MB ? Page::kPageSize : MB); | 1513 8 * (Page::kPageSize > MB ? Page::kPageSize : MB); |
| 1533 | 1514 |
| 1534 intptr_t OldGenerationAllocationLimit(intptr_t old_gen_size) { | 1515 intptr_t OldGenerationAllocationLimit(intptr_t old_gen_size) { |
| 1535 const int divisor = FLAG_stress_compaction ? 10 : | 1516 const int divisor = FLAG_stress_compaction ? 10 : |
| 1536 new_space_high_promotion_mode_active_ ? 1 : 3; | 1517 new_space_high_promotion_mode_active_ ? 1 : 3; |
| 1537 intptr_t limit = | 1518 intptr_t limit = |
| 1538 Max(old_gen_size + old_gen_size / divisor, | 1519 Max(old_gen_size + old_gen_size / divisor, |
| 1539 kMinimumOldGenerationAllocationLimit); | 1520 kMinimumOldGenerationAllocationLimit); |
| 1540 limit += new_space_.Capacity(); | 1521 limit += new_space_.Capacity(); |
| 1541 // TODO(hpayer): Can be removed when when pretenuring is supported for all | 1522 // TODO(hpayer): Can be removed when when pretenuring is supported for all |
| 1542 // allocation sites. | 1523 // allocation sites. |
| 1543 if (IsHighSurvivalRate() && IsStableOrIncreasingSurvivalTrend()) { | 1524 if (IsHighSurvivalRate() && IsStableOrIncreasingSurvivalTrend()) { |
| 1544 limit *= 2; | 1525 limit *= 2; |
| 1545 } | 1526 } |
| 1546 intptr_t halfway_to_the_max = (old_gen_size + max_old_generation_size_) / 2; | 1527 intptr_t halfway_to_the_max = (old_gen_size + max_old_generation_size_) / 2; |
| 1547 return Min(limit, halfway_to_the_max); | 1528 return Min(limit, halfway_to_the_max); |
| 1548 } | 1529 } |
| 1549 | 1530 |
| 1531 // Indicates whether inline bump-pointer allocation has been disabled. |
| 1532 bool inline_allocation_disabled() { return inline_allocation_disabled_; } |
| 1533 |
| 1534 // Switch whether inline bump-pointer allocation should be used. |
| 1535 void EnableInlineAllocation(); |
| 1536 void DisableInlineAllocation(); |
| 1537 |
| 1550 // Implements the corresponding V8 API function. | 1538 // Implements the corresponding V8 API function. |
| 1551 bool IdleNotification(int hint); | 1539 bool IdleNotification(int hint); |
| 1552 | 1540 |
| 1553 // Declare all the root indices. | 1541 // Declare all the root indices. |
| 1554 enum RootListIndex { | 1542 enum RootListIndex { |
| 1555 #define ROOT_INDEX_DECLARATION(type, name, camel_name) k##camel_name##RootIndex, | 1543 #define ROOT_INDEX_DECLARATION(type, name, camel_name) k##camel_name##RootIndex, |
| 1556 STRONG_ROOT_LIST(ROOT_INDEX_DECLARATION) | 1544 STRONG_ROOT_LIST(ROOT_INDEX_DECLARATION) |
| 1557 #undef ROOT_INDEX_DECLARATION | 1545 #undef ROOT_INDEX_DECLARATION |
| 1558 | 1546 |
| 1559 #define STRING_INDEX_DECLARATION(name, str) k##name##RootIndex, | 1547 #define STRING_INDEX_DECLARATION(name, str) k##name##RootIndex, |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1707 IncrementalMarking* incremental_marking() { | 1695 IncrementalMarking* incremental_marking() { |
| 1708 return &incremental_marking_; | 1696 return &incremental_marking_; |
| 1709 } | 1697 } |
| 1710 | 1698 |
| 1711 bool IsSweepingComplete() { | 1699 bool IsSweepingComplete() { |
| 1712 return !mark_compact_collector()->IsConcurrentSweepingInProgress() && | 1700 return !mark_compact_collector()->IsConcurrentSweepingInProgress() && |
| 1713 old_data_space()->IsLazySweepingComplete() && | 1701 old_data_space()->IsLazySweepingComplete() && |
| 1714 old_pointer_space()->IsLazySweepingComplete(); | 1702 old_pointer_space()->IsLazySweepingComplete(); |
| 1715 } | 1703 } |
| 1716 | 1704 |
| 1717 bool AdvanceSweepers(int step_size) { | 1705 bool AdvanceSweepers(int step_size); |
| 1718 ASSERT(!FLAG_parallel_sweeping && !FLAG_concurrent_sweeping); | |
| 1719 bool sweeping_complete = old_data_space()->AdvanceSweeper(step_size); | |
| 1720 sweeping_complete &= old_pointer_space()->AdvanceSweeper(step_size); | |
| 1721 return sweeping_complete; | |
| 1722 } | |
| 1723 | 1706 |
| 1724 bool EnsureSweepersProgressed(int step_size) { | 1707 bool EnsureSweepersProgressed(int step_size) { |
| 1725 bool sweeping_complete = old_data_space()->EnsureSweeperProgress(step_size); | 1708 bool sweeping_complete = old_data_space()->EnsureSweeperProgress(step_size); |
| 1726 sweeping_complete &= old_pointer_space()->EnsureSweeperProgress(step_size); | 1709 sweeping_complete &= old_pointer_space()->EnsureSweeperProgress(step_size); |
| 1727 return sweeping_complete; | 1710 return sweeping_complete; |
| 1728 } | 1711 } |
| 1729 | 1712 |
| 1730 ExternalStringTable* external_string_table() { | 1713 ExternalStringTable* external_string_table() { |
| 1731 return &external_string_table_; | 1714 return &external_string_table_; |
| 1732 } | 1715 } |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1793 int global_ic_age() { | 1776 int global_ic_age() { |
| 1794 return global_ic_age_; | 1777 return global_ic_age_; |
| 1795 } | 1778 } |
| 1796 | 1779 |
| 1797 void AgeInlineCaches() { | 1780 void AgeInlineCaches() { |
| 1798 global_ic_age_ = (global_ic_age_ + 1) & SharedFunctionInfo::ICAgeBits::kMax; | 1781 global_ic_age_ = (global_ic_age_ + 1) & SharedFunctionInfo::ICAgeBits::kMax; |
| 1799 } | 1782 } |
| 1800 | 1783 |
| 1801 bool flush_monomorphic_ics() { return flush_monomorphic_ics_; } | 1784 bool flush_monomorphic_ics() { return flush_monomorphic_ics_; } |
| 1802 | 1785 |
| 1803 intptr_t amount_of_external_allocated_memory() { | 1786 int64_t amount_of_external_allocated_memory() { |
| 1804 return amount_of_external_allocated_memory_; | 1787 return amount_of_external_allocated_memory_; |
| 1805 } | 1788 } |
| 1806 | 1789 |
| 1807 // ObjectStats are kept in two arrays, counts and sizes. Related stats are | 1790 // ObjectStats are kept in two arrays, counts and sizes. Related stats are |
| 1808 // stored in a contiguous linear buffer. Stats groups are stored one after | 1791 // stored in a contiguous linear buffer. Stats groups are stored one after |
| 1809 // another. | 1792 // another. |
| 1810 enum { | 1793 enum { |
| 1811 FIRST_CODE_KIND_SUB_TYPE = LAST_TYPE + 1, | 1794 FIRST_CODE_KIND_SUB_TYPE = LAST_TYPE + 1, |
| 1812 FIRST_FIXED_ARRAY_SUB_TYPE = | 1795 FIRST_FIXED_ARRAY_SUB_TYPE = |
| 1813 FIRST_CODE_KIND_SUB_TYPE + Code::NUMBER_OF_KINDS, | 1796 FIRST_CODE_KIND_SUB_TYPE + Code::NUMBER_OF_KINDS, |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1841 object_counts_[FIRST_FIXED_ARRAY_SUB_TYPE + array_sub_type]++; | 1824 object_counts_[FIRST_FIXED_ARRAY_SUB_TYPE + array_sub_type]++; |
| 1842 object_sizes_[FIRST_FIXED_ARRAY_SUB_TYPE + array_sub_type] += size; | 1825 object_sizes_[FIRST_FIXED_ARRAY_SUB_TYPE + array_sub_type] += size; |
| 1843 } | 1826 } |
| 1844 | 1827 |
| 1845 void CheckpointObjectStats(); | 1828 void CheckpointObjectStats(); |
| 1846 | 1829 |
| 1847 // We don't use a LockGuard here since we want to lock the heap | 1830 // We don't use a LockGuard here since we want to lock the heap |
| 1848 // only when FLAG_concurrent_recompilation is true. | 1831 // only when FLAG_concurrent_recompilation is true. |
| 1849 class RelocationLock { | 1832 class RelocationLock { |
| 1850 public: | 1833 public: |
| 1851 explicit RelocationLock(Heap* heap); | 1834 explicit RelocationLock(Heap* heap) : heap_(heap) { |
| 1835 if (FLAG_concurrent_recompilation) { |
| 1836 heap_->relocation_mutex_->Lock(); |
| 1837 } |
| 1838 } |
| 1839 |
| 1852 | 1840 |
| 1853 ~RelocationLock() { | 1841 ~RelocationLock() { |
| 1854 if (FLAG_concurrent_recompilation) { | 1842 if (FLAG_concurrent_recompilation) { |
| 1855 #ifdef DEBUG | |
| 1856 heap_->relocation_mutex_locked_by_optimizer_thread_ = false; | |
| 1857 #endif // DEBUG | |
| 1858 heap_->relocation_mutex_->Unlock(); | 1843 heap_->relocation_mutex_->Unlock(); |
| 1859 } | 1844 } |
| 1860 } | 1845 } |
| 1861 | 1846 |
| 1862 #ifdef DEBUG | |
| 1863 static bool IsLockedByOptimizerThread(Heap* heap) { | |
| 1864 return heap->relocation_mutex_locked_by_optimizer_thread_; | |
| 1865 } | |
| 1866 #endif // DEBUG | |
| 1867 | |
| 1868 private: | 1847 private: |
| 1869 Heap* heap_; | 1848 Heap* heap_; |
| 1870 }; | 1849 }; |
| 1871 | 1850 |
| 1872 MaybeObject* AddWeakObjectToCodeDependency(Object* obj, DependentCode* dep); | 1851 MaybeObject* AddWeakObjectToCodeDependency(Object* obj, DependentCode* dep); |
| 1873 | 1852 |
| 1874 DependentCode* LookupWeakObjectToCodeDependency(Object* obj); | 1853 DependentCode* LookupWeakObjectToCodeDependency(Object* obj); |
| 1875 | 1854 |
| 1876 void InitializeWeakObjectToCodeTable() { | 1855 void InitializeWeakObjectToCodeTable() { |
| 1877 set_weak_object_to_code_table(undefined_value()); | 1856 set_weak_object_to_code_table(undefined_value()); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1923 OldSpace* old_data_space_; | 1902 OldSpace* old_data_space_; |
| 1924 OldSpace* code_space_; | 1903 OldSpace* code_space_; |
| 1925 MapSpace* map_space_; | 1904 MapSpace* map_space_; |
| 1926 CellSpace* cell_space_; | 1905 CellSpace* cell_space_; |
| 1927 PropertyCellSpace* property_cell_space_; | 1906 PropertyCellSpace* property_cell_space_; |
| 1928 LargeObjectSpace* lo_space_; | 1907 LargeObjectSpace* lo_space_; |
| 1929 HeapState gc_state_; | 1908 HeapState gc_state_; |
| 1930 int gc_post_processing_depth_; | 1909 int gc_post_processing_depth_; |
| 1931 | 1910 |
| 1932 // Returns the amount of external memory registered since last global gc. | 1911 // Returns the amount of external memory registered since last global gc. |
| 1933 intptr_t PromotedExternalMemorySize(); | 1912 int64_t PromotedExternalMemorySize(); |
| 1934 | 1913 |
| 1935 unsigned int ms_count_; // how many mark-sweep collections happened | 1914 unsigned int ms_count_; // how many mark-sweep collections happened |
| 1936 unsigned int gc_count_; // how many gc happened | 1915 unsigned int gc_count_; // how many gc happened |
| 1937 | 1916 |
| 1938 // For post mortem debugging. | 1917 // For post mortem debugging. |
| 1939 static const int kRememberedUnmappedPages = 128; | 1918 static const int kRememberedUnmappedPages = 128; |
| 1940 int remembered_unmapped_pages_index_; | 1919 int remembered_unmapped_pages_index_; |
| 1941 Address remembered_unmapped_pages_[kRememberedUnmappedPages]; | 1920 Address remembered_unmapped_pages_[kRememberedUnmappedPages]; |
| 1942 | 1921 |
| 1943 // Total length of the strings we failed to flatten since the last GC. | 1922 // Total length of the strings we failed to flatten since the last GC. |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1977 | 1956 |
| 1978 // Used to adjust the limits that control the timing of the next GC. | 1957 // Used to adjust the limits that control the timing of the next GC. |
| 1979 intptr_t size_of_old_gen_at_last_old_space_gc_; | 1958 intptr_t size_of_old_gen_at_last_old_space_gc_; |
| 1980 | 1959 |
| 1981 // Limit on the amount of externally allocated memory allowed | 1960 // Limit on the amount of externally allocated memory allowed |
| 1982 // between global GCs. If reached a global GC is forced. | 1961 // between global GCs. If reached a global GC is forced. |
| 1983 intptr_t external_allocation_limit_; | 1962 intptr_t external_allocation_limit_; |
| 1984 | 1963 |
| 1985 // The amount of external memory registered through the API kept alive | 1964 // The amount of external memory registered through the API kept alive |
| 1986 // by global handles | 1965 // by global handles |
| 1987 intptr_t amount_of_external_allocated_memory_; | 1966 int64_t amount_of_external_allocated_memory_; |
| 1988 | 1967 |
| 1989 // Caches the amount of external memory registered at the last global gc. | 1968 // Caches the amount of external memory registered at the last global gc. |
| 1990 intptr_t amount_of_external_allocated_memory_at_last_global_gc_; | 1969 int64_t amount_of_external_allocated_memory_at_last_global_gc_; |
| 1991 | 1970 |
| 1992 // Indicates that an allocation has failed in the old generation since the | 1971 // Indicates that an allocation has failed in the old generation since the |
| 1993 // last GC. | 1972 // last GC. |
| 1994 bool old_gen_exhausted_; | 1973 bool old_gen_exhausted_; |
| 1995 | 1974 |
| 1975 // Indicates that inline bump-pointer allocation has been globally disabled |
| 1976 // for all spaces. This is used to disable allocations in generated code. |
| 1977 bool inline_allocation_disabled_; |
| 1978 |
| 1996 // Weak list heads, threaded through the objects. | 1979 // Weak list heads, threaded through the objects. |
| 1997 // List heads are initilized lazily and contain the undefined_value at start. | 1980 // List heads are initilized lazily and contain the undefined_value at start. |
| 1998 Object* native_contexts_list_; | 1981 Object* native_contexts_list_; |
| 1999 Object* array_buffers_list_; | 1982 Object* array_buffers_list_; |
| 2000 Object* allocation_sites_list_; | 1983 Object* allocation_sites_list_; |
| 2001 | 1984 |
| 2002 // WeakHashTable that maps objects embedded in optimized code to dependent | 1985 // WeakHashTable that maps objects embedded in optimized code to dependent |
| 2003 // code list. It is initilized lazily and contains the undefined_value at | 1986 // code list. It is initilized lazily and contains the undefined_value at |
| 2004 // start. | 1987 // start. |
| 2005 Object* weak_object_to_code_table_; | 1988 Object* weak_object_to_code_table_; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2068 // Support for computing object sizes during GC. | 2051 // Support for computing object sizes during GC. |
| 2069 HeapObjectCallback gc_safe_size_of_old_object_; | 2052 HeapObjectCallback gc_safe_size_of_old_object_; |
| 2070 static int GcSafeSizeOfOldObject(HeapObject* object); | 2053 static int GcSafeSizeOfOldObject(HeapObject* object); |
| 2071 | 2054 |
| 2072 // Update the GC state. Called from the mark-compact collector. | 2055 // Update the GC state. Called from the mark-compact collector. |
| 2073 void MarkMapPointersAsEncoded(bool encoded) { | 2056 void MarkMapPointersAsEncoded(bool encoded) { |
| 2074 ASSERT(!encoded); | 2057 ASSERT(!encoded); |
| 2075 gc_safe_size_of_old_object_ = &GcSafeSizeOfOldObject; | 2058 gc_safe_size_of_old_object_ = &GcSafeSizeOfOldObject; |
| 2076 } | 2059 } |
| 2077 | 2060 |
| 2061 // Code that should be run before and after each GC. Includes some |
| 2062 // reporting/verification activities when compiled with DEBUG set. |
| 2063 void GarbageCollectionPrologue(); |
| 2064 void GarbageCollectionEpilogue(); |
| 2065 |
| 2078 // Checks whether a global GC is necessary | 2066 // Checks whether a global GC is necessary |
| 2079 GarbageCollector SelectGarbageCollector(AllocationSpace space, | 2067 GarbageCollector SelectGarbageCollector(AllocationSpace space, |
| 2080 const char** reason); | 2068 const char** reason); |
| 2081 | 2069 |
| 2070 // Performs garbage collection operation. |
| 2071 // Returns whether there is a chance that another major GC could |
| 2072 // collect more garbage. |
| 2073 bool CollectGarbage(AllocationSpace space, |
| 2074 GarbageCollector collector, |
| 2075 const char* gc_reason, |
| 2076 const char* collector_reason); |
| 2077 |
| 2082 // Performs garbage collection | 2078 // Performs garbage collection |
| 2083 // Returns whether there is a chance another major GC could | 2079 // Returns whether there is a chance another major GC could |
| 2084 // collect more garbage. | 2080 // collect more garbage. |
| 2085 bool PerformGarbageCollection(GarbageCollector collector, | 2081 bool PerformGarbageCollection(GarbageCollector collector, |
| 2086 GCTracer* tracer); | 2082 GCTracer* tracer); |
| 2087 | 2083 |
| 2088 inline void UpdateOldSpaceLimits(); | 2084 inline void UpdateOldSpaceLimits(); |
| 2089 | 2085 |
| 2090 // Selects the proper allocation space depending on the given object | 2086 // Selects the proper allocation space depending on the given object |
| 2091 // size, pretenuring decision, and preferred old-space. | 2087 // size, pretenuring decision, and preferred old-space. |
| (...skipping 25 matching lines...) Expand all Loading... |
| 2117 | 2113 |
| 2118 bool CreateInitialMaps(); | 2114 bool CreateInitialMaps(); |
| 2119 bool CreateInitialObjects(); | 2115 bool CreateInitialObjects(); |
| 2120 | 2116 |
| 2121 // These five Create*EntryStub functions are here and forced to not be inlined | 2117 // These five Create*EntryStub functions are here and forced to not be inlined |
| 2122 // because of a gcc-4.4 bug that assigns wrong vtable entries. | 2118 // because of a gcc-4.4 bug that assigns wrong vtable entries. |
| 2123 NO_INLINE(void CreateJSEntryStub()); | 2119 NO_INLINE(void CreateJSEntryStub()); |
| 2124 NO_INLINE(void CreateJSConstructEntryStub()); | 2120 NO_INLINE(void CreateJSConstructEntryStub()); |
| 2125 | 2121 |
| 2126 void CreateFixedStubs(); | 2122 void CreateFixedStubs(); |
| 2123 void CreateStubsRequiringBuiltins(); |
| 2127 | 2124 |
| 2128 MUST_USE_RESULT MaybeObject* CreateOddball(const char* to_string, | 2125 MUST_USE_RESULT MaybeObject* CreateOddball(const char* to_string, |
| 2129 Object* to_number, | 2126 Object* to_number, |
| 2130 byte kind); | 2127 byte kind); |
| 2131 | 2128 |
| 2132 // Allocate a JSArray with no elements | 2129 // Allocate a JSArray with no elements |
| 2133 MUST_USE_RESULT MaybeObject* AllocateJSArray( | 2130 MUST_USE_RESULT MaybeObject* AllocateJSArray( |
| 2134 ElementsKind elements_kind, | 2131 ElementsKind elements_kind, |
| 2135 PretenureFlag pretenure = NOT_TENURED); | 2132 PretenureFlag pretenure = NOT_TENURED); |
| 2136 | 2133 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 2150 // Allocate a tenured JS global property cell initialized with the hole. | 2147 // Allocate a tenured JS global property cell initialized with the hole. |
| 2151 MUST_USE_RESULT MaybeObject* AllocatePropertyCell(); | 2148 MUST_USE_RESULT MaybeObject* AllocatePropertyCell(); |
| 2152 | 2149 |
| 2153 // Allocate Box. | 2150 // Allocate Box. |
| 2154 MUST_USE_RESULT MaybeObject* AllocateBox(Object* value, | 2151 MUST_USE_RESULT MaybeObject* AllocateBox(Object* value, |
| 2155 PretenureFlag pretenure); | 2152 PretenureFlag pretenure); |
| 2156 | 2153 |
| 2157 // Performs a minor collection in new generation. | 2154 // Performs a minor collection in new generation. |
| 2158 void Scavenge(); | 2155 void Scavenge(); |
| 2159 | 2156 |
| 2157 // Commits from space if it is uncommitted. |
| 2158 void EnsureFromSpaceIsCommitted(); |
| 2159 |
| 2160 // Uncommit unused semi space. |
| 2161 bool UncommitFromSpace() { return new_space_.UncommitFromSpace(); } |
| 2162 |
| 2163 // Fill in bogus values in from space |
| 2164 void ZapFromSpace(); |
| 2165 |
| 2160 static String* UpdateNewSpaceReferenceInExternalStringTableEntry( | 2166 static String* UpdateNewSpaceReferenceInExternalStringTableEntry( |
| 2161 Heap* heap, | 2167 Heap* heap, |
| 2162 Object** pointer); | 2168 Object** pointer); |
| 2163 | 2169 |
| 2164 Address DoScavenge(ObjectVisitor* scavenge_visitor, Address new_space_front); | 2170 Address DoScavenge(ObjectVisitor* scavenge_visitor, Address new_space_front); |
| 2165 static void ScavengeStoreBufferCallback(Heap* heap, | 2171 static void ScavengeStoreBufferCallback(Heap* heap, |
| 2166 MemoryChunk* page, | 2172 MemoryChunk* page, |
| 2167 StoreBufferEvent event); | 2173 StoreBufferEvent event); |
| 2168 | 2174 |
| 2169 // Performs a major collection in the whole heap. | 2175 // Performs a major collection in the whole heap. |
| (...skipping 908 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3078 DisallowHeapAllocation no_allocation; // i.e. no gc allowed. | 3084 DisallowHeapAllocation no_allocation; // i.e. no gc allowed. |
| 3079 | 3085 |
| 3080 private: | 3086 private: |
| 3081 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); | 3087 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); |
| 3082 }; | 3088 }; |
| 3083 #endif // DEBUG | 3089 #endif // DEBUG |
| 3084 | 3090 |
| 3085 } } // namespace v8::internal | 3091 } } // namespace v8::internal |
| 3086 | 3092 |
| 3087 #endif // V8_HEAP_H_ | 3093 #endif // V8_HEAP_H_ |
| OLD | NEW |