Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(44)

Side by Side Diff: src/heap/heap.cc

Issue 1815153002: Introduce EmbedderHeapTracer (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix formatting Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« include/v8.h ('K') | « src/heap/heap.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 : AllocationObserver(step_size), heap_(heap) {} 61 : AllocationObserver(step_size), heap_(heap) {}
62 62
63 void Step(int bytes_allocated, Address, size_t) override { 63 void Step(int bytes_allocated, Address, size_t) override {
64 heap_.ScheduleIdleScavengeIfNeeded(bytes_allocated); 64 heap_.ScheduleIdleScavengeIfNeeded(bytes_allocated);
65 } 65 }
66 66
67 private: 67 private:
68 Heap& heap_; 68 Heap& heap_;
69 }; 69 };
70 70
71
72 Heap::Heap() 71 Heap::Heap()
73 : amount_of_external_allocated_memory_(0), 72 : amount_of_external_allocated_memory_(0),
74 amount_of_external_allocated_memory_at_last_global_gc_(0), 73 amount_of_external_allocated_memory_at_last_global_gc_(0),
75 isolate_(NULL), 74 isolate_(NULL),
76 code_range_size_(0), 75 code_range_size_(0),
77 // semispace_size_ should be a power of 2 and old_generation_size_ should 76 // semispace_size_ should be a power of 2 and old_generation_size_ should
78 // be a multiple of Page::kPageSize. 77 // be a multiple of Page::kPageSize.
79 reserved_semispace_size_(8 * (kPointerSize / 4) * MB), 78 reserved_semispace_size_(8 * (kPointerSize / 4) * MB),
80 max_semi_space_size_(8 * (kPointerSize / 4) * MB), 79 max_semi_space_size_(8 * (kPointerSize / 4) * MB),
81 initial_semispace_size_(Page::kPageSize), 80 initial_semispace_size_(Page::kPageSize),
(...skipping 27 matching lines...) Expand all
109 remembered_unmapped_pages_index_(0), 108 remembered_unmapped_pages_index_(0),
110 #ifdef DEBUG 109 #ifdef DEBUG
111 allocation_timeout_(0), 110 allocation_timeout_(0),
112 #endif // DEBUG 111 #endif // DEBUG
113 old_generation_allocation_limit_(initial_old_generation_size_), 112 old_generation_allocation_limit_(initial_old_generation_size_),
114 old_gen_exhausted_(false), 113 old_gen_exhausted_(false),
115 optimize_for_memory_usage_(false), 114 optimize_for_memory_usage_(false),
116 inline_allocation_disabled_(false), 115 inline_allocation_disabled_(false),
117 total_regexp_code_generated_(0), 116 total_regexp_code_generated_(0),
118 tracer_(nullptr), 117 tracer_(nullptr),
118 embedder_heap_tracer_(nullptr),
119 high_survival_rate_period_length_(0), 119 high_survival_rate_period_length_(0),
120 promoted_objects_size_(0), 120 promoted_objects_size_(0),
121 promotion_ratio_(0), 121 promotion_ratio_(0),
122 semi_space_copied_object_size_(0), 122 semi_space_copied_object_size_(0),
123 previous_semi_space_copied_object_size_(0), 123 previous_semi_space_copied_object_size_(0),
124 semi_space_copied_rate_(0), 124 semi_space_copied_rate_(0),
125 nodes_died_in_new_space_(0), 125 nodes_died_in_new_space_(0),
126 nodes_copied_in_new_space_(0), 126 nodes_copied_in_new_space_(0),
127 nodes_promoted_(0), 127 nodes_promoted_(0),
128 maximum_size_scavenges_(0), 128 maximum_size_scavenges_(0),
(...skipping 1167 matching lines...) Expand 10 before | Expand all | Expand 10 after
1296 incremental_marking()->NotifyOfHighPromotionRate(); 1296 incremental_marking()->NotifyOfHighPromotionRate();
1297 } 1297 }
1298 1298
1299 { 1299 {
1300 Heap::PretenuringScope pretenuring_scope(this); 1300 Heap::PretenuringScope pretenuring_scope(this);
1301 1301
1302 if (collector == MARK_COMPACTOR) { 1302 if (collector == MARK_COMPACTOR) {
1303 UpdateOldGenerationAllocationCounter(); 1303 UpdateOldGenerationAllocationCounter();
1304 // Perform mark-sweep with optional compaction. 1304 // Perform mark-sweep with optional compaction.
1305 MarkCompact(); 1305 MarkCompact();
1306 if (embedder_heap_tracer()) {
1307 embedder_heap_tracer()->ClearTracingMarks(
1308 reinterpret_cast<v8::Isolate*>(isolate()));
1309 }
1310
1306 old_gen_exhausted_ = false; 1311 old_gen_exhausted_ = false;
1307 old_generation_size_configured_ = true; 1312 old_generation_size_configured_ = true;
1308 // This should be updated before PostGarbageCollectionProcessing, which 1313 // This should be updated before PostGarbageCollectionProcessing, which
1309 // can cause another GC. Take into account the objects promoted during GC. 1314 // can cause another GC. Take into account the objects promoted during GC.
1310 old_generation_allocation_counter_ += 1315 old_generation_allocation_counter_ +=
1311 static_cast<size_t>(promoted_objects_size_); 1316 static_cast<size_t>(promoted_objects_size_);
1312 old_generation_size_at_last_gc_ = PromotedSpaceSizeOfObjects(); 1317 old_generation_size_at_last_gc_ = PromotedSpaceSizeOfObjects();
1313 } else { 1318 } else {
1314 Scavenge(); 1319 Scavenge();
1315 } 1320 }
(...skipping 4195 matching lines...) Expand 10 before | Expand all | Expand 10 after
5511 DCHECK(callback != NULL); 5516 DCHECK(callback != NULL);
5512 for (int i = 0; i < gc_epilogue_callbacks_.length(); ++i) { 5517 for (int i = 0; i < gc_epilogue_callbacks_.length(); ++i) {
5513 if (gc_epilogue_callbacks_[i].callback == callback) { 5518 if (gc_epilogue_callbacks_[i].callback == callback) {
5514 gc_epilogue_callbacks_.Remove(i); 5519 gc_epilogue_callbacks_.Remove(i);
5515 return; 5520 return;
5516 } 5521 }
5517 } 5522 }
5518 UNREACHABLE(); 5523 UNREACHABLE();
5519 } 5524 }
5520 5525
5526 void Heap::SetEmbedderHeapTracer(EmbedderHeapTracer* tracer) {
5527 DCHECK(tracer != nullptr);
5528 embedder_heap_tracer_ = tracer;
5529 }
5530
5531 void Heap::UnsetEmbedderHeapTracer() {
5532 DCHECK(embedder_heap_tracer_ != nullptr);
5533 embedder_heap_tracer_ = nullptr;
5534 }
5521 5535
5522 // TODO(ishell): Find a better place for this. 5536 // TODO(ishell): Find a better place for this.
5523 void Heap::AddWeakObjectToCodeDependency(Handle<HeapObject> obj, 5537 void Heap::AddWeakObjectToCodeDependency(Handle<HeapObject> obj,
5524 Handle<DependentCode> dep) { 5538 Handle<DependentCode> dep) {
5525 DCHECK(!InNewSpace(*obj)); 5539 DCHECK(!InNewSpace(*obj));
5526 DCHECK(!InNewSpace(*dep)); 5540 DCHECK(!InNewSpace(*dep));
5527 Handle<WeakHashTable> table(weak_object_to_code_table(), isolate()); 5541 Handle<WeakHashTable> table(weak_object_to_code_table(), isolate());
5528 table = WeakHashTable::Put(table, obj, dep); 5542 table = WeakHashTable::Put(table, obj, dep);
5529 if (*table != weak_object_to_code_table()) 5543 if (*table != weak_object_to_code_table())
5530 set_weak_object_to_code_table(*table); 5544 set_weak_object_to_code_table(*table);
(...skipping 875 matching lines...) Expand 10 before | Expand all | Expand 10 after
6406 } 6420 }
6407 6421
6408 6422
6409 // static 6423 // static
6410 int Heap::GetStaticVisitorIdForMap(Map* map) { 6424 int Heap::GetStaticVisitorIdForMap(Map* map) {
6411 return StaticVisitorBase::GetVisitorId(map); 6425 return StaticVisitorBase::GetVisitorId(map);
6412 } 6426 }
6413 6427
6414 } // namespace internal 6428 } // namespace internal
6415 } // namespace v8 6429 } // namespace v8
OLDNEW
« include/v8.h ('K') | « src/heap/heap.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698