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/scopeinfo.h" | 9 #include "src/ast/scopeinfo.h" |
10 #include "src/base/bits.h" | 10 #include "src/base/bits.h" |
(...skipping 1042 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1053 | 1053 |
1054 return next_gc_likely_to_collect_more; | 1054 return next_gc_likely_to_collect_more; |
1055 } | 1055 } |
1056 | 1056 |
1057 | 1057 |
1058 int Heap::NotifyContextDisposed(bool dependant_context) { | 1058 int Heap::NotifyContextDisposed(bool dependant_context) { |
1059 if (!dependant_context) { | 1059 if (!dependant_context) { |
1060 tracer()->ResetSurvivalEvents(); | 1060 tracer()->ResetSurvivalEvents(); |
1061 old_generation_size_configured_ = false; | 1061 old_generation_size_configured_ = false; |
1062 MemoryReducer::Event event; | 1062 MemoryReducer::Event event; |
1063 event.type = MemoryReducer::kContextDisposed; | 1063 event.type = MemoryReducer::kPossibleGarbage; |
1064 event.time_ms = MonotonicallyIncreasingTimeInMs(); | 1064 event.time_ms = MonotonicallyIncreasingTimeInMs(); |
1065 memory_reducer_->NotifyContextDisposed(event); | 1065 memory_reducer_->NotifyPossibleGarbage(event); |
1066 } | 1066 } |
1067 if (isolate()->concurrent_recompilation_enabled()) { | 1067 if (isolate()->concurrent_recompilation_enabled()) { |
1068 // Flush the queued recompilation tasks. | 1068 // Flush the queued recompilation tasks. |
1069 isolate()->optimizing_compile_dispatcher()->Flush(); | 1069 isolate()->optimizing_compile_dispatcher()->Flush(); |
1070 } | 1070 } |
1071 AgeInlineCaches(); | 1071 AgeInlineCaches(); |
1072 number_of_disposed_maps_ = retained_maps()->Length(); | 1072 number_of_disposed_maps_ = retained_maps()->Length(); |
1073 tracer()->AddContextDisposalTime(MonotonicallyIncreasingTimeInMs()); | 1073 tracer()->AddContextDisposalTime(MonotonicallyIncreasingTimeInMs()); |
1074 return ++contexts_disposed_; | 1074 return ++contexts_disposed_; |
1075 } | 1075 } |
(...skipping 3029 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4105 } | 4105 } |
4106 | 4106 |
4107 | 4107 |
4108 bool Heap::HasHighFragmentation(intptr_t used, intptr_t committed) { | 4108 bool Heap::HasHighFragmentation(intptr_t used, intptr_t committed) { |
4109 const intptr_t kSlack = 16 * MB; | 4109 const intptr_t kSlack = 16 * MB; |
4110 // Fragmentation is high if committed > 2 * used + kSlack. | 4110 // Fragmentation is high if committed > 2 * used + kSlack. |
4111 // Rewrite the exression to avoid overflow. | 4111 // Rewrite the exression to avoid overflow. |
4112 return committed - used > used + kSlack; | 4112 return committed - used > used + kSlack; |
4113 } | 4113 } |
4114 | 4114 |
4115 void Heap::SetOptimizeForMemoryUsage() { | |
4116 // 2 pages for each old generation space + 1 page for new space. | |
jochen (gone - plz use gerrit)
2016/02/22 09:40:09
that's lo_space and old_space and?
ulan
2016/02/22 10:05:32
Expanded the comment. It is old, code, and map spa
| |
4117 const int kMinCommittedMemory = 7 * Page::kPageSize; | |
4118 if (ms_count_ == 0 && CommittedMemory() > kMinCommittedMemory) { | |
jochen (gone - plz use gerrit)
2016/02/22 09:40:09
I guess this method is invoked every time a tab go
ulan
2016/02/22 10:05:32
yes
| |
4119 MemoryReducer::Event event; | |
4120 event.type = MemoryReducer::kPossibleGarbage; | |
4121 event.time_ms = MonotonicallyIncreasingTimeInMs(); | |
4122 memory_reducer_->NotifyPossibleGarbage(event); | |
4123 } | |
4124 optimize_for_memory_usage_ = true; | |
4125 } | |
4115 | 4126 |
4116 void Heap::ReduceNewSpaceSize() { | 4127 void Heap::ReduceNewSpaceSize() { |
4117 // TODO(ulan): Unify this constant with the similar constant in | 4128 // TODO(ulan): Unify this constant with the similar constant in |
4118 // GCIdleTimeHandler once the change is merged to 4.5. | 4129 // GCIdleTimeHandler once the change is merged to 4.5. |
4119 static const size_t kLowAllocationThroughput = 1000; | 4130 static const size_t kLowAllocationThroughput = 1000; |
4120 const size_t allocation_throughput = | 4131 const size_t allocation_throughput = |
4121 tracer()->CurrentAllocationThroughputInBytesPerMillisecond(); | 4132 tracer()->CurrentAllocationThroughputInBytesPerMillisecond(); |
4122 | 4133 |
4123 if (FLAG_predictable) return; | 4134 if (FLAG_predictable) return; |
4124 | 4135 |
(...skipping 2160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6285 } | 6296 } |
6286 | 6297 |
6287 | 6298 |
6288 // static | 6299 // static |
6289 int Heap::GetStaticVisitorIdForMap(Map* map) { | 6300 int Heap::GetStaticVisitorIdForMap(Map* map) { |
6290 return StaticVisitorBase::GetVisitorId(map); | 6301 return StaticVisitorBase::GetVisitorId(map); |
6291 } | 6302 } |
6292 | 6303 |
6293 } // namespace internal | 6304 } // namespace internal |
6294 } // namespace v8 | 6305 } // namespace v8 |
OLD | NEW |