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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 sweeping_time_(0.0), | 134 sweeping_time_(0.0), |
135 last_idle_notification_time_(0.0), | 135 last_idle_notification_time_(0.0), |
136 last_gc_time_(0.0), | 136 last_gc_time_(0.0), |
137 scavenge_collector_(nullptr), | 137 scavenge_collector_(nullptr), |
138 mark_compact_collector_(nullptr), | 138 mark_compact_collector_(nullptr), |
139 memory_allocator_(nullptr), | 139 memory_allocator_(nullptr), |
140 store_buffer_(this), | 140 store_buffer_(this), |
141 incremental_marking_(nullptr), | 141 incremental_marking_(nullptr), |
142 gc_idle_time_handler_(nullptr), | 142 gc_idle_time_handler_(nullptr), |
143 memory_reducer_(nullptr), | 143 memory_reducer_(nullptr), |
144 object_stats_(nullptr), | 144 live_object_stats_(nullptr), |
| 145 dead_object_stats_(nullptr), |
145 scavenge_job_(nullptr), | 146 scavenge_job_(nullptr), |
146 idle_scavenge_observer_(nullptr), | 147 idle_scavenge_observer_(nullptr), |
147 full_codegen_bytes_generated_(0), | 148 full_codegen_bytes_generated_(0), |
148 crankshaft_codegen_bytes_generated_(0), | 149 crankshaft_codegen_bytes_generated_(0), |
149 new_space_allocation_counter_(0), | 150 new_space_allocation_counter_(0), |
150 old_generation_allocation_counter_(0), | 151 old_generation_allocation_counter_(0), |
151 old_generation_size_at_last_gc_(0), | 152 old_generation_size_at_last_gc_(0), |
152 gcs_since_last_deopt_(0), | 153 gcs_since_last_deopt_(0), |
153 global_pretenuring_feedback_(nullptr), | 154 global_pretenuring_feedback_(nullptr), |
154 ring_buffer_full_(false), | 155 ring_buffer_full_(false), |
(...skipping 5165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5320 tracer_ = new GCTracer(this); | 5321 tracer_ = new GCTracer(this); |
5321 | 5322 |
5322 scavenge_collector_ = new Scavenger(this); | 5323 scavenge_collector_ = new Scavenger(this); |
5323 | 5324 |
5324 mark_compact_collector_ = new MarkCompactCollector(this); | 5325 mark_compact_collector_ = new MarkCompactCollector(this); |
5325 | 5326 |
5326 gc_idle_time_handler_ = new GCIdleTimeHandler(); | 5327 gc_idle_time_handler_ = new GCIdleTimeHandler(); |
5327 | 5328 |
5328 memory_reducer_ = new MemoryReducer(this); | 5329 memory_reducer_ = new MemoryReducer(this); |
5329 | 5330 |
5330 object_stats_ = new ObjectStats(this); | 5331 if (FLAG_track_gc_object_stats) { |
5331 object_stats_->ClearObjectStats(true); | 5332 live_object_stats_ = new ObjectStats(this); |
| 5333 dead_object_stats_ = new ObjectStats(this); |
| 5334 } |
5332 | 5335 |
5333 scavenge_job_ = new ScavengeJob(); | 5336 scavenge_job_ = new ScavengeJob(); |
5334 | 5337 |
5335 LOG(isolate_, IntPtrTEvent("heap-capacity", Capacity())); | 5338 LOG(isolate_, IntPtrTEvent("heap-capacity", Capacity())); |
5336 LOG(isolate_, IntPtrTEvent("heap-available", Available())); | 5339 LOG(isolate_, IntPtrTEvent("heap-available", Available())); |
5337 | 5340 |
5338 store_buffer()->SetUp(); | 5341 store_buffer()->SetUp(); |
5339 | 5342 |
5340 mark_compact_collector()->SetUp(); | 5343 mark_compact_collector()->SetUp(); |
5341 | 5344 |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5479 | 5482 |
5480 delete gc_idle_time_handler_; | 5483 delete gc_idle_time_handler_; |
5481 gc_idle_time_handler_ = nullptr; | 5484 gc_idle_time_handler_ = nullptr; |
5482 | 5485 |
5483 if (memory_reducer_ != nullptr) { | 5486 if (memory_reducer_ != nullptr) { |
5484 memory_reducer_->TearDown(); | 5487 memory_reducer_->TearDown(); |
5485 delete memory_reducer_; | 5488 delete memory_reducer_; |
5486 memory_reducer_ = nullptr; | 5489 memory_reducer_ = nullptr; |
5487 } | 5490 } |
5488 | 5491 |
5489 delete object_stats_; | 5492 if (live_object_stats_ != nullptr) { |
5490 object_stats_ = nullptr; | 5493 delete live_object_stats_; |
| 5494 live_object_stats_ = nullptr; |
| 5495 } |
| 5496 |
| 5497 if (dead_object_stats_ != nullptr) { |
| 5498 delete dead_object_stats_; |
| 5499 dead_object_stats_ = nullptr; |
| 5500 } |
5491 | 5501 |
5492 delete scavenge_job_; | 5502 delete scavenge_job_; |
5493 scavenge_job_ = nullptr; | 5503 scavenge_job_ = nullptr; |
5494 | 5504 |
5495 isolate_->global_handles()->TearDown(); | 5505 isolate_->global_handles()->TearDown(); |
5496 | 5506 |
5497 external_string_table_.TearDown(); | 5507 external_string_table_.TearDown(); |
5498 | 5508 |
5499 delete tracer_; | 5509 delete tracer_; |
5500 tracer_ = nullptr; | 5510 tracer_ = nullptr; |
(...skipping 870 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6371 } | 6381 } |
6372 } | 6382 } |
6373 | 6383 |
6374 | 6384 |
6375 size_t Heap::NumberOfTrackedHeapObjectTypes() { | 6385 size_t Heap::NumberOfTrackedHeapObjectTypes() { |
6376 return ObjectStats::OBJECT_STATS_COUNT; | 6386 return ObjectStats::OBJECT_STATS_COUNT; |
6377 } | 6387 } |
6378 | 6388 |
6379 | 6389 |
6380 size_t Heap::ObjectCountAtLastGC(size_t index) { | 6390 size_t Heap::ObjectCountAtLastGC(size_t index) { |
6381 if (index >= ObjectStats::OBJECT_STATS_COUNT) return 0; | 6391 if (live_object_stats_ == nullptr || index >= ObjectStats::OBJECT_STATS_COUNT) |
6382 return object_stats_->object_count_last_gc(index); | 6392 return 0; |
| 6393 return live_object_stats_->object_count_last_gc(index); |
6383 } | 6394 } |
6384 | 6395 |
6385 | 6396 |
6386 size_t Heap::ObjectSizeAtLastGC(size_t index) { | 6397 size_t Heap::ObjectSizeAtLastGC(size_t index) { |
6387 if (index >= ObjectStats::OBJECT_STATS_COUNT) return 0; | 6398 if (live_object_stats_ == nullptr || index >= ObjectStats::OBJECT_STATS_COUNT) |
6388 return object_stats_->object_size_last_gc(index); | 6399 return 0; |
| 6400 return live_object_stats_->object_size_last_gc(index); |
6389 } | 6401 } |
6390 | 6402 |
6391 | 6403 |
6392 bool Heap::GetObjectTypeName(size_t index, const char** object_type, | 6404 bool Heap::GetObjectTypeName(size_t index, const char** object_type, |
6393 const char** object_sub_type) { | 6405 const char** object_sub_type) { |
6394 if (index >= ObjectStats::OBJECT_STATS_COUNT) return false; | 6406 if (index >= ObjectStats::OBJECT_STATS_COUNT) return false; |
6395 | 6407 |
6396 switch (static_cast<int>(index)) { | 6408 switch (static_cast<int>(index)) { |
6397 #define COMPARE_AND_RETURN_NAME(name) \ | 6409 #define COMPARE_AND_RETURN_NAME(name) \ |
6398 case name: \ | 6410 case name: \ |
(...skipping 29 matching lines...) Expand all Loading... |
6428 } | 6440 } |
6429 | 6441 |
6430 | 6442 |
6431 // static | 6443 // static |
6432 int Heap::GetStaticVisitorIdForMap(Map* map) { | 6444 int Heap::GetStaticVisitorIdForMap(Map* map) { |
6433 return StaticVisitorBase::GetVisitorId(map); | 6445 return StaticVisitorBase::GetVisitorId(map); |
6434 } | 6446 } |
6435 | 6447 |
6436 } // namespace internal | 6448 } // namespace internal |
6437 } // namespace v8 | 6449 } // namespace v8 |
OLD | NEW |