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 858 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
869 // Note: as weak callbacks can execute arbitrary code, we cannot | 869 // Note: as weak callbacks can execute arbitrary code, we cannot |
870 // hope that eventually there will be no weak callbacks invocations. | 870 // hope that eventually there will be no weak callbacks invocations. |
871 // Therefore stop recollecting after several attempts. | 871 // Therefore stop recollecting after several attempts. |
872 if (gc_reason == GarbageCollectionReason::kLastResort) { | 872 if (gc_reason == GarbageCollectionReason::kLastResort) { |
873 InvokeOutOfMemoryCallback(); | 873 InvokeOutOfMemoryCallback(); |
874 } | 874 } |
875 RuntimeCallTimerScope(isolate(), &RuntimeCallStats::GC_AllAvailableGarbage); | 875 RuntimeCallTimerScope(isolate(), &RuntimeCallStats::GC_AllAvailableGarbage); |
876 if (isolate()->concurrent_recompilation_enabled()) { | 876 if (isolate()->concurrent_recompilation_enabled()) { |
877 // The optimizing compiler may be unnecessarily holding on to memory. | 877 // The optimizing compiler may be unnecessarily holding on to memory. |
878 DisallowHeapAllocation no_recursive_gc; | 878 DisallowHeapAllocation no_recursive_gc; |
879 isolate()->optimizing_compile_dispatcher()->Flush(); | 879 isolate()->optimizing_compile_dispatcher()->Flush( |
| 880 OptimizingCompileDispatcher::BlockingBehavior::kDontBlock); |
880 } | 881 } |
881 isolate()->ClearSerializerData(); | 882 isolate()->ClearSerializerData(); |
882 set_current_gc_flags(kMakeHeapIterableMask | kReduceMemoryFootprintMask); | 883 set_current_gc_flags(kMakeHeapIterableMask | kReduceMemoryFootprintMask); |
883 isolate_->compilation_cache()->Clear(); | 884 isolate_->compilation_cache()->Clear(); |
884 const int kMaxNumberOfAttempts = 7; | 885 const int kMaxNumberOfAttempts = 7; |
885 const int kMinNumberOfAttempts = 2; | 886 const int kMinNumberOfAttempts = 2; |
886 for (int attempt = 0; attempt < kMaxNumberOfAttempts; attempt++) { | 887 for (int attempt = 0; attempt < kMaxNumberOfAttempts; attempt++) { |
887 if (!CollectGarbage(MARK_COMPACTOR, gc_reason, NULL, | 888 if (!CollectGarbage(MARK_COMPACTOR, gc_reason, NULL, |
888 v8::kGCCallbackFlagCollectAllAvailableGarbage) && | 889 v8::kGCCallbackFlagCollectAllAvailableGarbage) && |
889 attempt + 1 >= kMinNumberOfAttempts) { | 890 attempt + 1 >= kMinNumberOfAttempts) { |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1068 if (!dependant_context) { | 1069 if (!dependant_context) { |
1069 tracer()->ResetSurvivalEvents(); | 1070 tracer()->ResetSurvivalEvents(); |
1070 old_generation_size_configured_ = false; | 1071 old_generation_size_configured_ = false; |
1071 MemoryReducer::Event event; | 1072 MemoryReducer::Event event; |
1072 event.type = MemoryReducer::kPossibleGarbage; | 1073 event.type = MemoryReducer::kPossibleGarbage; |
1073 event.time_ms = MonotonicallyIncreasingTimeInMs(); | 1074 event.time_ms = MonotonicallyIncreasingTimeInMs(); |
1074 memory_reducer_->NotifyPossibleGarbage(event); | 1075 memory_reducer_->NotifyPossibleGarbage(event); |
1075 } | 1076 } |
1076 if (isolate()->concurrent_recompilation_enabled()) { | 1077 if (isolate()->concurrent_recompilation_enabled()) { |
1077 // Flush the queued recompilation tasks. | 1078 // Flush the queued recompilation tasks. |
1078 isolate()->optimizing_compile_dispatcher()->Flush(); | 1079 isolate()->optimizing_compile_dispatcher()->Flush( |
| 1080 OptimizingCompileDispatcher::BlockingBehavior::kDontBlock); |
1079 } | 1081 } |
1080 AgeInlineCaches(); | 1082 AgeInlineCaches(); |
1081 number_of_disposed_maps_ = retained_maps()->Length(); | 1083 number_of_disposed_maps_ = retained_maps()->Length(); |
1082 tracer()->AddContextDisposalTime(MonotonicallyIncreasingTimeInMs()); | 1084 tracer()->AddContextDisposalTime(MonotonicallyIncreasingTimeInMs()); |
1083 return ++contexts_disposed_; | 1085 return ++contexts_disposed_; |
1084 } | 1086 } |
1085 | 1087 |
1086 void Heap::StartIncrementalMarking(int gc_flags, | 1088 void Heap::StartIncrementalMarking(int gc_flags, |
1087 GarbageCollectionReason gc_reason, | 1089 GarbageCollectionReason gc_reason, |
1088 GCCallbackFlags gc_callback_flags) { | 1090 GCCallbackFlags gc_callback_flags) { |
(...skipping 3394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4483 | 4485 |
4484 Heap* heap_; | 4486 Heap* heap_; |
4485 DISALLOW_COPY_AND_ASSIGN(MemoryPressureInterruptTask); | 4487 DISALLOW_COPY_AND_ASSIGN(MemoryPressureInterruptTask); |
4486 }; | 4488 }; |
4487 | 4489 |
4488 void Heap::CheckMemoryPressure() { | 4490 void Heap::CheckMemoryPressure() { |
4489 if (HighMemoryPressure()) { | 4491 if (HighMemoryPressure()) { |
4490 if (isolate()->concurrent_recompilation_enabled()) { | 4492 if (isolate()->concurrent_recompilation_enabled()) { |
4491 // The optimizing compiler may be unnecessarily holding on to memory. | 4493 // The optimizing compiler may be unnecessarily holding on to memory. |
4492 DisallowHeapAllocation no_recursive_gc; | 4494 DisallowHeapAllocation no_recursive_gc; |
4493 isolate()->optimizing_compile_dispatcher()->Flush(); | 4495 isolate()->optimizing_compile_dispatcher()->Flush( |
| 4496 OptimizingCompileDispatcher::BlockingBehavior::kDontBlock); |
4494 } | 4497 } |
4495 } | 4498 } |
4496 if (memory_pressure_level_.Value() == MemoryPressureLevel::kCritical) { | 4499 if (memory_pressure_level_.Value() == MemoryPressureLevel::kCritical) { |
4497 CollectGarbageOnMemoryPressure(); | 4500 CollectGarbageOnMemoryPressure(); |
4498 } else if (memory_pressure_level_.Value() == MemoryPressureLevel::kModerate) { | 4501 } else if (memory_pressure_level_.Value() == MemoryPressureLevel::kModerate) { |
4499 if (FLAG_incremental_marking && incremental_marking()->IsStopped()) { | 4502 if (FLAG_incremental_marking && incremental_marking()->IsStopped()) { |
4500 StartIncrementalMarking(kReduceMemoryFootprintMask, | 4503 StartIncrementalMarking(kReduceMemoryFootprintMask, |
4501 GarbageCollectionReason::kMemoryPressure); | 4504 GarbageCollectionReason::kMemoryPressure); |
4502 } | 4505 } |
4503 } | 4506 } |
(...skipping 2102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6606 } | 6609 } |
6607 | 6610 |
6608 | 6611 |
6609 // static | 6612 // static |
6610 int Heap::GetStaticVisitorIdForMap(Map* map) { | 6613 int Heap::GetStaticVisitorIdForMap(Map* map) { |
6611 return StaticVisitorBase::GetVisitorId(map); | 6614 return StaticVisitorBase::GetVisitorId(map); |
6612 } | 6615 } |
6613 | 6616 |
6614 } // namespace internal | 6617 } // namespace internal |
6615 } // namespace v8 | 6618 } // namespace v8 |
OLD | NEW |