| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/heap/heap.h" | 5 #include "src/heap/heap.h" |
| 6 | 6 |
| 7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
| 8 #include "src/api.h" | 8 #include "src/api.h" |
| 9 #include "src/ast/context-slot-cache.h" | 9 #include "src/ast/context-slot-cache.h" |
| 10 #include "src/base/bits.h" | 10 #include "src/base/bits.h" |
| (...skipping 846 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 857 // handles, but won't collect weakly reachable objects until next | 857 // handles, but won't collect weakly reachable objects until next |
| 858 // major GC. Therefore if we collect aggressively and weak handle callback | 858 // major GC. Therefore if we collect aggressively and weak handle callback |
| 859 // has been invoked, we rerun major GC to release objects which become | 859 // has been invoked, we rerun major GC to release objects which become |
| 860 // garbage. | 860 // garbage. |
| 861 // Note: as weak callbacks can execute arbitrary code, we cannot | 861 // Note: as weak callbacks can execute arbitrary code, we cannot |
| 862 // hope that eventually there will be no weak callbacks invocations. | 862 // hope that eventually there will be no weak callbacks invocations. |
| 863 // Therefore stop recollecting after several attempts. | 863 // Therefore stop recollecting after several attempts. |
| 864 if (isolate()->concurrent_recompilation_enabled()) { | 864 if (isolate()->concurrent_recompilation_enabled()) { |
| 865 // The optimizing compiler may be unnecessarily holding on to memory. | 865 // The optimizing compiler may be unnecessarily holding on to memory. |
| 866 DisallowHeapAllocation no_recursive_gc; | 866 DisallowHeapAllocation no_recursive_gc; |
| 867 isolate()->optimizing_compile_dispatcher()->Flush(); | 867 isolate()->optimizing_compile_dispatcher()->Flush( |
| 868 OptimizingCompileDispatcher::BlockingBehavior::kDontBlock); |
| 868 } | 869 } |
| 869 isolate()->ClearSerializerData(); | 870 isolate()->ClearSerializerData(); |
| 870 set_current_gc_flags(kMakeHeapIterableMask | kReduceMemoryFootprintMask); | 871 set_current_gc_flags(kMakeHeapIterableMask | kReduceMemoryFootprintMask); |
| 871 isolate_->compilation_cache()->Clear(); | 872 isolate_->compilation_cache()->Clear(); |
| 872 const int kMaxNumberOfAttempts = 7; | 873 const int kMaxNumberOfAttempts = 7; |
| 873 const int kMinNumberOfAttempts = 2; | 874 const int kMinNumberOfAttempts = 2; |
| 874 for (int attempt = 0; attempt < kMaxNumberOfAttempts; attempt++) { | 875 for (int attempt = 0; attempt < kMaxNumberOfAttempts; attempt++) { |
| 875 if (!CollectGarbage(MARK_COMPACTOR, gc_reason, NULL, | 876 if (!CollectGarbage(MARK_COMPACTOR, gc_reason, NULL, |
| 876 v8::kGCCallbackFlagCollectAllAvailableGarbage) && | 877 v8::kGCCallbackFlagCollectAllAvailableGarbage) && |
| 877 attempt + 1 >= kMinNumberOfAttempts) { | 878 attempt + 1 >= kMinNumberOfAttempts) { |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1054 if (!dependant_context) { | 1055 if (!dependant_context) { |
| 1055 tracer()->ResetSurvivalEvents(); | 1056 tracer()->ResetSurvivalEvents(); |
| 1056 old_generation_size_configured_ = false; | 1057 old_generation_size_configured_ = false; |
| 1057 MemoryReducer::Event event; | 1058 MemoryReducer::Event event; |
| 1058 event.type = MemoryReducer::kPossibleGarbage; | 1059 event.type = MemoryReducer::kPossibleGarbage; |
| 1059 event.time_ms = MonotonicallyIncreasingTimeInMs(); | 1060 event.time_ms = MonotonicallyIncreasingTimeInMs(); |
| 1060 memory_reducer_->NotifyPossibleGarbage(event); | 1061 memory_reducer_->NotifyPossibleGarbage(event); |
| 1061 } | 1062 } |
| 1062 if (isolate()->concurrent_recompilation_enabled()) { | 1063 if (isolate()->concurrent_recompilation_enabled()) { |
| 1063 // Flush the queued recompilation tasks. | 1064 // Flush the queued recompilation tasks. |
| 1064 isolate()->optimizing_compile_dispatcher()->Flush(); | 1065 isolate()->optimizing_compile_dispatcher()->Flush( |
| 1066 OptimizingCompileDispatcher::BlockingBehavior::kDontBlock); |
| 1065 } | 1067 } |
| 1066 AgeInlineCaches(); | 1068 AgeInlineCaches(); |
| 1067 number_of_disposed_maps_ = retained_maps()->Length(); | 1069 number_of_disposed_maps_ = retained_maps()->Length(); |
| 1068 tracer()->AddContextDisposalTime(MonotonicallyIncreasingTimeInMs()); | 1070 tracer()->AddContextDisposalTime(MonotonicallyIncreasingTimeInMs()); |
| 1069 return ++contexts_disposed_; | 1071 return ++contexts_disposed_; |
| 1070 } | 1072 } |
| 1071 | 1073 |
| 1072 void Heap::StartIncrementalMarking(int gc_flags, | 1074 void Heap::StartIncrementalMarking(int gc_flags, |
| 1073 GarbageCollectionReason gc_reason, | 1075 GarbageCollectionReason gc_reason, |
| 1074 GCCallbackFlags gc_callback_flags) { | 1076 GCCallbackFlags gc_callback_flags) { |
| (...skipping 3326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4401 | 4403 |
| 4402 Heap* heap_; | 4404 Heap* heap_; |
| 4403 DISALLOW_COPY_AND_ASSIGN(MemoryPressureInterruptTask); | 4405 DISALLOW_COPY_AND_ASSIGN(MemoryPressureInterruptTask); |
| 4404 }; | 4406 }; |
| 4405 | 4407 |
| 4406 void Heap::CheckMemoryPressure() { | 4408 void Heap::CheckMemoryPressure() { |
| 4407 if (HighMemoryPressure()) { | 4409 if (HighMemoryPressure()) { |
| 4408 if (isolate()->concurrent_recompilation_enabled()) { | 4410 if (isolate()->concurrent_recompilation_enabled()) { |
| 4409 // The optimizing compiler may be unnecessarily holding on to memory. | 4411 // The optimizing compiler may be unnecessarily holding on to memory. |
| 4410 DisallowHeapAllocation no_recursive_gc; | 4412 DisallowHeapAllocation no_recursive_gc; |
| 4411 isolate()->optimizing_compile_dispatcher()->Flush(); | 4413 isolate()->optimizing_compile_dispatcher()->Flush( |
| 4414 OptimizingCompileDispatcher::BlockingBehavior::kDontBlock); |
| 4412 } | 4415 } |
| 4413 } | 4416 } |
| 4414 if (memory_pressure_level_.Value() == MemoryPressureLevel::kCritical) { | 4417 if (memory_pressure_level_.Value() == MemoryPressureLevel::kCritical) { |
| 4415 CollectGarbageOnMemoryPressure(); | 4418 CollectGarbageOnMemoryPressure(); |
| 4416 } else if (memory_pressure_level_.Value() == MemoryPressureLevel::kModerate) { | 4419 } else if (memory_pressure_level_.Value() == MemoryPressureLevel::kModerate) { |
| 4417 if (FLAG_incremental_marking && incremental_marking()->IsStopped()) { | 4420 if (FLAG_incremental_marking && incremental_marking()->IsStopped()) { |
| 4418 StartIncrementalMarking(kReduceMemoryFootprintMask, | 4421 StartIncrementalMarking(kReduceMemoryFootprintMask, |
| 4419 GarbageCollectionReason::kMemoryPressure); | 4422 GarbageCollectionReason::kMemoryPressure); |
| 4420 } | 4423 } |
| 4421 } | 4424 } |
| (...skipping 2054 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6476 } | 6479 } |
| 6477 | 6480 |
| 6478 | 6481 |
| 6479 // static | 6482 // static |
| 6480 int Heap::GetStaticVisitorIdForMap(Map* map) { | 6483 int Heap::GetStaticVisitorIdForMap(Map* map) { |
| 6481 return StaticVisitorBase::GetVisitorId(map); | 6484 return StaticVisitorBase::GetVisitorId(map); |
| 6482 } | 6485 } |
| 6483 | 6486 |
| 6484 } // namespace internal | 6487 } // namespace internal |
| 6485 } // namespace v8 | 6488 } // namespace v8 |
| OLD | NEW |