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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 void Step(int bytes_allocated, Address, size_t) override { | 64 void Step(int bytes_allocated, Address, size_t) override { |
65 heap_.ScheduleIdleScavengeIfNeeded(bytes_allocated); | 65 heap_.ScheduleIdleScavengeIfNeeded(bytes_allocated); |
66 } | 66 } |
67 | 67 |
68 private: | 68 private: |
69 Heap& heap_; | 69 Heap& heap_; |
70 }; | 70 }; |
71 | 71 |
72 Heap::Heap() | 72 Heap::Heap() |
73 : external_memory_(0), | 73 : external_memory_(0), |
74 external_memory_limit_(kExternalAllocationLimit), | 74 external_memory_limit_(kExternalAllocationSoftLimit), |
75 external_memory_at_last_mark_compact_(0), | 75 external_memory_at_last_mark_compact_(0), |
76 isolate_(nullptr), | 76 isolate_(nullptr), |
77 code_range_size_(0), | 77 code_range_size_(0), |
78 // semispace_size_ should be a power of 2 and old_generation_size_ should | 78 // semispace_size_ should be a power of 2 and old_generation_size_ should |
79 // be a multiple of Page::kPageSize. | 79 // be a multiple of Page::kPageSize. |
80 max_semi_space_size_(8 * (kPointerSize / 4) * MB), | 80 max_semi_space_size_(8 * (kPointerSize / 4) * MB), |
81 initial_semispace_size_(Page::kPageSize), | 81 initial_semispace_size_(Page::kPageSize), |
82 max_old_generation_size_(700ul * (kPointerSize / 4) * MB), | 82 max_old_generation_size_(700ul * (kPointerSize / 4) * MB), |
83 initial_old_generation_size_(max_old_generation_size_ / | 83 initial_old_generation_size_(max_old_generation_size_ / |
84 kInitalOldGenerationLimitFactor), | 84 kInitalOldGenerationLimitFactor), |
(...skipping 811 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
896 break; | 896 break; |
897 } | 897 } |
898 } | 898 } |
899 set_current_gc_flags(kNoGCFlags); | 899 set_current_gc_flags(kNoGCFlags); |
900 new_space_.Shrink(); | 900 new_space_.Shrink(); |
901 UncommitFromSpace(); | 901 UncommitFromSpace(); |
902 } | 902 } |
903 | 903 |
904 | 904 |
905 void Heap::ReportExternalMemoryPressure(const char* gc_reason) { | 905 void Heap::ReportExternalMemoryPressure(const char* gc_reason) { |
| 906 if (external_memory_ > |
| 907 (external_memory_at_last_mark_compact_ + external_memory_hard_limit())) { |
| 908 CollectAllGarbage( |
| 909 kReduceMemoryFootprintMask | kFinalizeIncrementalMarkingMask, gc_reason, |
| 910 static_cast<GCCallbackFlags>(kGCCallbackFlagCollectAllAvailableGarbage | |
| 911 kGCCallbackFlagCollectAllExternalMemory)); |
| 912 return; |
| 913 } |
906 if (incremental_marking()->IsStopped()) { | 914 if (incremental_marking()->IsStopped()) { |
907 if (incremental_marking()->CanBeActivated()) { | 915 if (incremental_marking()->CanBeActivated()) { |
908 StartIncrementalMarking( | 916 StartIncrementalMarking( |
909 i::Heap::kNoGCFlags, | 917 i::Heap::kNoGCFlags, |
910 static_cast<GCCallbackFlags>( | 918 static_cast<GCCallbackFlags>( |
911 kGCCallbackFlagSynchronousPhantomCallbackProcessing | | 919 kGCCallbackFlagSynchronousPhantomCallbackProcessing | |
912 kGCCallbackFlagCollectAllExternalMemory), | 920 kGCCallbackFlagCollectAllExternalMemory), |
913 gc_reason); | 921 gc_reason); |
914 } else { | 922 } else { |
915 CollectAllGarbage(i::Heap::kNoGCFlags, gc_reason, | 923 CollectAllGarbage(i::Heap::kNoGCFlags, gc_reason, |
916 kGCCallbackFlagSynchronousPhantomCallbackProcessing); | 924 kGCCallbackFlagSynchronousPhantomCallbackProcessing); |
917 } | 925 } |
918 } else { | 926 } else { |
919 // Incremental marking is turned on an has already been started. | 927 // Incremental marking is turned on an has already been started. |
920 | 928 const double pressure = |
921 // TODO(mlippautz): Compute the time slice for incremental marking based on | 929 static_cast<double>(external_memory_ - |
922 // memory pressure. | 930 external_memory_at_last_mark_compact_ - |
923 double deadline = MonotonicallyIncreasingTimeInMs() + | 931 kExternalAllocationSoftLimit) / |
924 FLAG_external_allocation_limit_incremental_time; | 932 external_memory_hard_limit(); |
| 933 DCHECK_GE(1, pressure); |
| 934 const double kMaxStepSizeOnExternalLimit = 25; |
| 935 const double deadline = MonotonicallyIncreasingTimeInMs() + |
| 936 pressure * kMaxStepSizeOnExternalLimit; |
925 incremental_marking()->AdvanceIncrementalMarking( | 937 incremental_marking()->AdvanceIncrementalMarking( |
926 deadline, | 938 deadline, |
927 IncrementalMarking::StepActions(IncrementalMarking::GC_VIA_STACK_GUARD, | 939 IncrementalMarking::StepActions(IncrementalMarking::GC_VIA_STACK_GUARD, |
928 IncrementalMarking::FORCE_MARKING, | 940 IncrementalMarking::FORCE_MARKING, |
929 IncrementalMarking::FORCE_COMPLETION)); | 941 IncrementalMarking::FORCE_COMPLETION)); |
930 } | 942 } |
931 } | 943 } |
932 | 944 |
933 | 945 |
934 void Heap::EnsureFillerObjectAtTop() { | 946 void Heap::EnsureFillerObjectAtTop() { |
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1355 // Update relocatables. | 1367 // Update relocatables. |
1356 Relocatable::PostGarbageCollectionProcessing(isolate_); | 1368 Relocatable::PostGarbageCollectionProcessing(isolate_); |
1357 | 1369 |
1358 double gc_speed = tracer()->CombinedMarkCompactSpeedInBytesPerMillisecond(); | 1370 double gc_speed = tracer()->CombinedMarkCompactSpeedInBytesPerMillisecond(); |
1359 double mutator_speed = | 1371 double mutator_speed = |
1360 tracer()->CurrentOldGenerationAllocationThroughputInBytesPerMillisecond(); | 1372 tracer()->CurrentOldGenerationAllocationThroughputInBytesPerMillisecond(); |
1361 intptr_t old_gen_size = PromotedSpaceSizeOfObjects(); | 1373 intptr_t old_gen_size = PromotedSpaceSizeOfObjects(); |
1362 if (collector == MARK_COMPACTOR) { | 1374 if (collector == MARK_COMPACTOR) { |
1363 // Register the amount of external allocated memory. | 1375 // Register the amount of external allocated memory. |
1364 external_memory_at_last_mark_compact_ = external_memory_; | 1376 external_memory_at_last_mark_compact_ = external_memory_; |
1365 external_memory_limit_ = external_memory_ + kExternalAllocationLimit; | 1377 external_memory_limit_ = external_memory_ + kExternalAllocationSoftLimit; |
1366 SetOldGenerationAllocationLimit(old_gen_size, gc_speed, mutator_speed); | 1378 SetOldGenerationAllocationLimit(old_gen_size, gc_speed, mutator_speed); |
1367 } else if (HasLowYoungGenerationAllocationRate() && | 1379 } else if (HasLowYoungGenerationAllocationRate() && |
1368 old_generation_size_configured_) { | 1380 old_generation_size_configured_) { |
1369 DampenOldGenerationAllocationLimit(old_gen_size, gc_speed, mutator_speed); | 1381 DampenOldGenerationAllocationLimit(old_gen_size, gc_speed, mutator_speed); |
1370 } | 1382 } |
1371 | 1383 |
1372 { | 1384 { |
1373 GCCallbacksScope scope(this); | 1385 GCCallbacksScope scope(this); |
1374 if (scope.CheckReenter()) { | 1386 if (scope.CheckReenter()) { |
1375 AllowHeapAllocation allow_allocation; | 1387 AllowHeapAllocation allow_allocation; |
(...skipping 5134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6510 } | 6522 } |
6511 | 6523 |
6512 | 6524 |
6513 // static | 6525 // static |
6514 int Heap::GetStaticVisitorIdForMap(Map* map) { | 6526 int Heap::GetStaticVisitorIdForMap(Map* map) { |
6515 return StaticVisitorBase::GetVisitorId(map); | 6527 return StaticVisitorBase::GetVisitorId(map); |
6516 } | 6528 } |
6517 | 6529 |
6518 } // namespace internal | 6530 } // namespace internal |
6519 } // namespace v8 | 6531 } // namespace v8 |
OLD | NEW |