| 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 1139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1150 // | 1150 // |
| 1151 // Please note this function does not perform a garbage collection. | 1151 // Please note this function does not perform a garbage collection. |
| 1152 MUST_USE_RESULT inline MaybeObject* PrepareForCompare(String* str); | 1152 MUST_USE_RESULT inline MaybeObject* PrepareForCompare(String* str); |
| 1153 | 1153 |
| 1154 // Converts the given boolean condition to JavaScript boolean value. | 1154 // Converts the given boolean condition to JavaScript boolean value. |
| 1155 inline Object* ToBoolean(bool condition); | 1155 inline Object* ToBoolean(bool condition); |
| 1156 | 1156 |
| 1157 // Performs garbage collection operation. | 1157 // Performs garbage collection operation. |
| 1158 // Returns whether there is a chance that another major GC could | 1158 // Returns whether there is a chance that another major GC could |
| 1159 // collect more garbage. | 1159 // collect more garbage. |
| 1160 inline bool CollectGarbage(AllocationSpace space, | 1160 inline bool CollectGarbage( |
| 1161 const char* gc_reason = NULL); | 1161 AllocationSpace space, |
| 1162 const char* gc_reason = NULL, |
| 1163 const GCCallbackFlags gc_callback_flags = kNoGCCallbackFlags); |
| 1162 | 1164 |
| 1163 static const int kNoGCFlags = 0; | 1165 static const int kNoGCFlags = 0; |
| 1164 static const int kSweepPreciselyMask = 1; | 1166 static const int kSweepPreciselyMask = 1; |
| 1165 static const int kReduceMemoryFootprintMask = 2; | 1167 static const int kReduceMemoryFootprintMask = 2; |
| 1166 static const int kAbortIncrementalMarkingMask = 4; | 1168 static const int kAbortIncrementalMarkingMask = 4; |
| 1167 | 1169 |
| 1168 // Making the heap iterable requires us to sweep precisely and abort any | 1170 // Making the heap iterable requires us to sweep precisely and abort any |
| 1169 // incremental marking as well. | 1171 // incremental marking as well. |
| 1170 static const int kMakeHeapIterableMask = | 1172 static const int kMakeHeapIterableMask = |
| 1171 kSweepPreciselyMask | kAbortIncrementalMarkingMask; | 1173 kSweepPreciselyMask | kAbortIncrementalMarkingMask; |
| 1172 | 1174 |
| 1173 // Performs a full garbage collection. If (flags & kMakeHeapIterableMask) is | 1175 // Performs a full garbage collection. If (flags & kMakeHeapIterableMask) is |
| 1174 // non-zero, then the slower precise sweeper is used, which leaves the heap | 1176 // non-zero, then the slower precise sweeper is used, which leaves the heap |
| 1175 // in a state where we can iterate over the heap visiting all objects. | 1177 // in a state where we can iterate over the heap visiting all objects. |
| 1176 void CollectAllGarbage(int flags, const char* gc_reason = NULL); | 1178 void CollectAllGarbage( |
| 1179 int flags, |
| 1180 const char* gc_reason = NULL, |
| 1181 const GCCallbackFlags gc_callback_flags = kNoGCCallbackFlags); |
| 1177 | 1182 |
| 1178 // Last hope GC, should try to squeeze as much as possible. | 1183 // Last hope GC, should try to squeeze as much as possible. |
| 1179 void CollectAllAvailableGarbage(const char* gc_reason = NULL); | 1184 void CollectAllAvailableGarbage(const char* gc_reason = NULL); |
| 1180 | 1185 |
| 1181 // Check whether the heap is currently iterable. | 1186 // Check whether the heap is currently iterable. |
| 1182 bool IsHeapIterable(); | 1187 bool IsHeapIterable(); |
| 1183 | 1188 |
| 1184 // Ensure that we have swept all spaces in such a way that we can iterate | 1189 // Ensure that we have swept all spaces in such a way that we can iterate |
| 1185 // over all objects. May cause a GC. | 1190 // over all objects. May cause a GC. |
| 1186 void EnsureHeapIsIterable(); | 1191 void EnsureHeapIsIterable(); |
| (...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1694 } | 1699 } |
| 1695 | 1700 |
| 1696 // Returns the current sweep generation. | 1701 // Returns the current sweep generation. |
| 1697 int sweep_generation() { | 1702 int sweep_generation() { |
| 1698 return sweep_generation_; | 1703 return sweep_generation_; |
| 1699 } | 1704 } |
| 1700 | 1705 |
| 1701 inline Isolate* isolate(); | 1706 inline Isolate* isolate(); |
| 1702 | 1707 |
| 1703 void CallGCPrologueCallbacks(GCType gc_type, GCCallbackFlags flags); | 1708 void CallGCPrologueCallbacks(GCType gc_type, GCCallbackFlags flags); |
| 1704 void CallGCEpilogueCallbacks(GCType gc_type); | 1709 void CallGCEpilogueCallbacks(GCType gc_type, GCCallbackFlags flags); |
| 1705 | 1710 |
| 1706 inline bool OldGenerationAllocationLimitReached(); | 1711 inline bool OldGenerationAllocationLimitReached(); |
| 1707 | 1712 |
| 1708 inline void DoScavengeObject(Map* map, HeapObject** slot, HeapObject* obj) { | 1713 inline void DoScavengeObject(Map* map, HeapObject** slot, HeapObject* obj) { |
| 1709 scavenging_visitors_table_.GetVisitor(map)(map, slot, obj); | 1714 scavenging_visitors_table_.GetVisitor(map)(map, slot, obj); |
| 1710 } | 1715 } |
| 1711 | 1716 |
| 1712 void QueueMemoryChunkForFree(MemoryChunk* chunk); | 1717 void QueueMemoryChunkForFree(MemoryChunk* chunk); |
| 1713 void FreeQueuedChunks(); | 1718 void FreeQueuedChunks(); |
| 1714 | 1719 |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2035 } | 2040 } |
| 2036 | 2041 |
| 2037 // Code that should be run before and after each GC. Includes some | 2042 // Code that should be run before and after each GC. Includes some |
| 2038 // reporting/verification activities when compiled with DEBUG set. | 2043 // reporting/verification activities when compiled with DEBUG set. |
| 2039 void GarbageCollectionPrologue(); | 2044 void GarbageCollectionPrologue(); |
| 2040 void GarbageCollectionEpilogue(); | 2045 void GarbageCollectionEpilogue(); |
| 2041 | 2046 |
| 2042 // Pretenuring decisions are made based on feedback collected during new | 2047 // Pretenuring decisions are made based on feedback collected during new |
| 2043 // space evacuation. Note that between feedback collection and calling this | 2048 // space evacuation. Note that between feedback collection and calling this |
| 2044 // method object in old space must not move. | 2049 // method object in old space must not move. |
| 2050 // Right now we only process pretenuring feedback in high promotion mode. |
| 2045 void ProcessPretenuringFeedback(); | 2051 void ProcessPretenuringFeedback(); |
| 2046 | 2052 |
| 2047 // Checks whether a global GC is necessary | 2053 // Checks whether a global GC is necessary |
| 2048 GarbageCollector SelectGarbageCollector(AllocationSpace space, | 2054 GarbageCollector SelectGarbageCollector(AllocationSpace space, |
| 2049 const char** reason); | 2055 const char** reason); |
| 2050 | 2056 |
| 2051 // Performs garbage collection operation. | 2057 // Performs garbage collection operation. |
| 2052 // Returns whether there is a chance that another major GC could | 2058 // Returns whether there is a chance that another major GC could |
| 2053 // collect more garbage. | 2059 // collect more garbage. |
| 2054 bool CollectGarbage(AllocationSpace space, | 2060 bool CollectGarbage( |
| 2055 GarbageCollector collector, | 2061 AllocationSpace space, |
| 2056 const char* gc_reason, | 2062 GarbageCollector collector, |
| 2057 const char* collector_reason); | 2063 const char* gc_reason, |
| 2064 const char* collector_reason, |
| 2065 const GCCallbackFlags gc_callback_flags = kNoGCCallbackFlags); |
| 2058 | 2066 |
| 2059 // Performs garbage collection | 2067 // Performs garbage collection |
| 2060 // Returns whether there is a chance another major GC could | 2068 // Returns whether there is a chance another major GC could |
| 2061 // collect more garbage. | 2069 // collect more garbage. |
| 2062 bool PerformGarbageCollection(GarbageCollector collector, | 2070 bool PerformGarbageCollection( |
| 2063 GCTracer* tracer); | 2071 GarbageCollector collector, |
| 2072 GCTracer* tracer, |
| 2073 const GCCallbackFlags gc_callback_flags = kNoGCCallbackFlags); |
| 2064 | 2074 |
| 2065 inline void UpdateOldSpaceLimits(); | 2075 inline void UpdateOldSpaceLimits(); |
| 2066 | 2076 |
| 2067 // Selects the proper allocation space depending on the given object | 2077 // Selects the proper allocation space depending on the given object |
| 2068 // size, pretenuring decision, and preferred old-space. | 2078 // size, pretenuring decision, and preferred old-space. |
| 2069 static AllocationSpace SelectSpace(int object_size, | 2079 static AllocationSpace SelectSpace(int object_size, |
| 2070 AllocationSpace preferred_old_space, | 2080 AllocationSpace preferred_old_space, |
| 2071 PretenureFlag pretenure) { | 2081 PretenureFlag pretenure) { |
| 2072 ASSERT(preferred_old_space == OLD_POINTER_SPACE || | 2082 ASSERT(preferred_old_space == OLD_POINTER_SPACE || |
| 2073 preferred_old_space == OLD_DATA_SPACE); | 2083 preferred_old_space == OLD_DATA_SPACE); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2161 // Performs a major collection in the whole heap. | 2171 // Performs a major collection in the whole heap. |
| 2162 void MarkCompact(GCTracer* tracer); | 2172 void MarkCompact(GCTracer* tracer); |
| 2163 | 2173 |
| 2164 // Code to be run before and after mark-compact. | 2174 // Code to be run before and after mark-compact. |
| 2165 void MarkCompactPrologue(); | 2175 void MarkCompactPrologue(); |
| 2166 | 2176 |
| 2167 void ProcessNativeContexts(WeakObjectRetainer* retainer, bool record_slots); | 2177 void ProcessNativeContexts(WeakObjectRetainer* retainer, bool record_slots); |
| 2168 void ProcessArrayBuffers(WeakObjectRetainer* retainer, bool record_slots); | 2178 void ProcessArrayBuffers(WeakObjectRetainer* retainer, bool record_slots); |
| 2169 void ProcessAllocationSites(WeakObjectRetainer* retainer, bool record_slots); | 2179 void ProcessAllocationSites(WeakObjectRetainer* retainer, bool record_slots); |
| 2170 | 2180 |
| 2181 // Deopts all code that contains allocation instruction which are tenured or |
| 2182 // not tenured. Moreover it clears the pretenuring allocation site statistics. |
| 2183 void ResetAllAllocationSitesDependentCode(PretenureFlag flag); |
| 2184 |
| 2185 // Evaluates local pretenuring for the old space and calls |
| 2186 // ResetAllTenuredAllocationSitesDependentCode if too many objects died in |
| 2187 // the old space. |
| 2188 void EvaluateOldSpaceLocalPretenuring(uint64_t size_of_objects_before_gc); |
| 2189 |
| 2171 // Called on heap tear-down. | 2190 // Called on heap tear-down. |
| 2172 void TearDownArrayBuffers(); | 2191 void TearDownArrayBuffers(); |
| 2173 | 2192 |
| 2174 // Record statistics before and after garbage collection. | 2193 // Record statistics before and after garbage collection. |
| 2175 void ReportStatisticsBeforeGC(); | 2194 void ReportStatisticsBeforeGC(); |
| 2176 void ReportStatisticsAfterGC(); | 2195 void ReportStatisticsAfterGC(); |
| 2177 | 2196 |
| 2178 // Slow part of scavenge object. | 2197 // Slow part of scavenge object. |
| 2179 static void ScavengeObjectSlow(HeapObject** p, HeapObject* object); | 2198 static void ScavengeObjectSlow(HeapObject** p, HeapObject* object); |
| 2180 | 2199 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 2204 void FlushNumberStringCache(); | 2223 void FlushNumberStringCache(); |
| 2205 | 2224 |
| 2206 void UpdateSurvivalRateTrend(int start_new_space_size); | 2225 void UpdateSurvivalRateTrend(int start_new_space_size); |
| 2207 | 2226 |
| 2208 enum SurvivalRateTrend { INCREASING, STABLE, DECREASING, FLUCTUATING }; | 2227 enum SurvivalRateTrend { INCREASING, STABLE, DECREASING, FLUCTUATING }; |
| 2209 | 2228 |
| 2210 static const int kYoungSurvivalRateHighThreshold = 90; | 2229 static const int kYoungSurvivalRateHighThreshold = 90; |
| 2211 static const int kYoungSurvivalRateLowThreshold = 10; | 2230 static const int kYoungSurvivalRateLowThreshold = 10; |
| 2212 static const int kYoungSurvivalRateAllowedDeviation = 15; | 2231 static const int kYoungSurvivalRateAllowedDeviation = 15; |
| 2213 | 2232 |
| 2233 static const int kOldSurvivalRateLowThreshold = 20; |
| 2234 |
| 2214 int young_survivors_after_last_gc_; | 2235 int young_survivors_after_last_gc_; |
| 2215 int high_survival_rate_period_length_; | 2236 int high_survival_rate_period_length_; |
| 2216 int low_survival_rate_period_length_; | 2237 int low_survival_rate_period_length_; |
| 2217 double survival_rate_; | 2238 double survival_rate_; |
| 2218 SurvivalRateTrend previous_survival_rate_trend_; | 2239 SurvivalRateTrend previous_survival_rate_trend_; |
| 2219 SurvivalRateTrend survival_rate_trend_; | 2240 SurvivalRateTrend survival_rate_trend_; |
| 2220 | 2241 |
| 2221 void set_survival_rate_trend(SurvivalRateTrend survival_rate_trend) { | 2242 void set_survival_rate_trend(SurvivalRateTrend survival_rate_trend) { |
| 2222 ASSERT(survival_rate_trend != FLUCTUATING); | 2243 ASSERT(survival_rate_trend != FLUCTUATING); |
| 2223 previous_survival_rate_trend_ = survival_rate_trend_; | 2244 previous_survival_rate_trend_ = survival_rate_trend_; |
| (...skipping 772 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2996 DisallowHeapAllocation no_allocation; // i.e. no gc allowed. | 3017 DisallowHeapAllocation no_allocation; // i.e. no gc allowed. |
| 2997 | 3018 |
| 2998 private: | 3019 private: |
| 2999 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); | 3020 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); |
| 3000 }; | 3021 }; |
| 3001 #endif // DEBUG | 3022 #endif // DEBUG |
| 3002 | 3023 |
| 3003 } } // namespace v8::internal | 3024 } } // namespace v8::internal |
| 3004 | 3025 |
| 3005 #endif // V8_HEAP_H_ | 3026 #endif // V8_HEAP_H_ |
| OLD | NEW |