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

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

Issue 1625753002: Allocation sampling for paged/lo spaces (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: WIP: Allocation sampling for paged/lo spaces Created 4 years, 11 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
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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 namespace v8 { 46 namespace v8 {
47 namespace internal { 47 namespace internal {
48 48
49 49
50 struct Heap::StrongRootsList { 50 struct Heap::StrongRootsList {
51 Object** start; 51 Object** start;
52 Object** end; 52 Object** end;
53 StrongRootsList* next; 53 StrongRootsList* next;
54 }; 54 };
55 55
56 class IdleScavengeObserver : public InlineAllocationObserver { 56 class IdleScavengeObserver : public AllocationObserver {
57 public: 57 public:
58 IdleScavengeObserver(Heap& heap, intptr_t step_size) 58 IdleScavengeObserver(Heap& heap, intptr_t step_size)
59 : InlineAllocationObserver(step_size), heap_(heap) {} 59 : AllocationObserver(step_size), heap_(heap) {}
60 60
61 void Step(int bytes_allocated, Address, size_t) override { 61 void Step(int bytes_allocated, Address, size_t) override {
62 heap_.ScheduleIdleScavengeIfNeeded(bytes_allocated); 62 heap_.ScheduleIdleScavengeIfNeeded(bytes_allocated);
63 } 63 }
64 64
65 private: 65 private:
66 Heap& heap_; 66 Heap& heap_;
67 }; 67 };
68 68
69 69
(...skipping 1343 matching lines...) Expand 10 before | Expand all | Expand 10 after
1413 } else { 1413 } else {
1414 v8::Isolate* isolate = reinterpret_cast<v8::Isolate*>(this->isolate()); 1414 v8::Isolate* isolate = reinterpret_cast<v8::Isolate*>(this->isolate());
1415 gc_epilogue_callbacks_[i].callback(isolate, gc_type, gc_callback_flags); 1415 gc_epilogue_callbacks_[i].callback(isolate, gc_type, gc_callback_flags);
1416 } 1416 }
1417 } 1417 }
1418 } 1418 }
1419 } 1419 }
1420 1420
1421 1421
1422 void Heap::MarkCompact() { 1422 void Heap::MarkCompact() {
1423 PauseInlineAllocationObserversScope pause_observers(new_space()); 1423 PauseAllocationObserversScope pause_new_observers(new_space());
1424 PauseAllocationObserversScope pause_old_observers(old_space());
1425 PauseAllocationObserversScope pause_code_observers(code_space());
1426 PauseAllocationObserversScope pause_map_observers(map_space());
1427 PauseAllocationObserversScope pause_lo_observers(lo_space());
ofrobots 2016/01/26 00:38:25 This is just begging to be refactored :). Maybe k
mattloring 2016/01/30 00:38:03 Refactored to pause/unpause all spaces together.
1424 1428
1425 gc_state_ = MARK_COMPACT; 1429 gc_state_ = MARK_COMPACT;
1426 LOG(isolate_, ResourceEvent("markcompact", "begin")); 1430 LOG(isolate_, ResourceEvent("markcompact", "begin"));
1427 1431
1428 uint64_t size_of_objects_before_gc = SizeOfObjects(); 1432 uint64_t size_of_objects_before_gc = SizeOfObjects();
1429 1433
1430 mark_compact_collector()->Prepare(); 1434 mark_compact_collector()->Prepare();
1431 1435
1432 ms_count_++; 1436 ms_count_++;
1433 1437
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
1620 void Heap::Scavenge() { 1624 void Heap::Scavenge() {
1621 GCTracer::Scope gc_scope(tracer(), GCTracer::Scope::SCAVENGER_SCAVENGE); 1625 GCTracer::Scope gc_scope(tracer(), GCTracer::Scope::SCAVENGER_SCAVENGE);
1622 RelocationLock relocation_lock(this); 1626 RelocationLock relocation_lock(this);
1623 // There are soft limits in the allocation code, designed to trigger a mark 1627 // There are soft limits in the allocation code, designed to trigger a mark
1624 // sweep collection by failing allocations. There is no sense in trying to 1628 // sweep collection by failing allocations. There is no sense in trying to
1625 // trigger one during scavenge: scavenges allocation should always succeed. 1629 // trigger one during scavenge: scavenges allocation should always succeed.
1626 AlwaysAllocateScope scope(isolate()); 1630 AlwaysAllocateScope scope(isolate());
1627 1631
1628 // Bump-pointer allocations done during scavenge are not real allocations. 1632 // Bump-pointer allocations done during scavenge are not real allocations.
1629 // Pause the inline allocation steps. 1633 // Pause the inline allocation steps.
1630 PauseInlineAllocationObserversScope pause_observers(new_space()); 1634 PauseAllocationObserversScope pause_new_observers(new_space());
1635 PauseAllocationObserversScope pause_old_observers(old_space());
1636 PauseAllocationObserversScope pause_code_observers(code_space());
1637 PauseAllocationObserversScope pause_map_observers(map_space());
1638 PauseAllocationObserversScope pause_lo_observers(lo_space());
1631 1639
1632 #ifdef VERIFY_HEAP 1640 #ifdef VERIFY_HEAP
1633 if (FLAG_verify_heap) VerifyNonPointerSpacePointers(this); 1641 if (FLAG_verify_heap) VerifyNonPointerSpacePointers(this);
1634 #endif 1642 #endif
1635 1643
1636 gc_state_ = SCAVENGE; 1644 gc_state_ = SCAVENGE;
1637 1645
1638 // Implements Cheney's copying algorithm 1646 // Implements Cheney's copying algorithm
1639 LOG(isolate_, ResourceEvent("scavenge", "begin")); 1647 LOG(isolate_, ResourceEvent("scavenge", "begin"));
1640 1648
(...skipping 3521 matching lines...) Expand 10 before | Expand all | Expand 10 after
5162 5170
5163 LOG(isolate_, IntPtrTEvent("heap-capacity", Capacity())); 5171 LOG(isolate_, IntPtrTEvent("heap-capacity", Capacity()));
5164 LOG(isolate_, IntPtrTEvent("heap-available", Available())); 5172 LOG(isolate_, IntPtrTEvent("heap-available", Available()));
5165 5173
5166 store_buffer()->SetUp(); 5174 store_buffer()->SetUp();
5167 5175
5168 mark_compact_collector()->SetUp(); 5176 mark_compact_collector()->SetUp();
5169 5177
5170 idle_scavenge_observer_ = new IdleScavengeObserver( 5178 idle_scavenge_observer_ = new IdleScavengeObserver(
5171 *this, ScavengeJob::kBytesAllocatedBeforeNextIdleTask); 5179 *this, ScavengeJob::kBytesAllocatedBeforeNextIdleTask);
5172 new_space()->AddInlineAllocationObserver(idle_scavenge_observer_); 5180 new_space()->AddAllocationObserver(idle_scavenge_observer_);
5173 5181
5174 return true; 5182 return true;
5175 } 5183 }
5176 5184
5177 5185
5178 bool Heap::CreateHeapObjects() { 5186 bool Heap::CreateHeapObjects() {
5179 // Create initial maps. 5187 // Create initial maps.
5180 if (!CreateInitialMaps()) return false; 5188 if (!CreateInitialMaps()) return false;
5181 CreateApiObjects(); 5189 CreateApiObjects();
5182 5190
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
5262 map_space_->MaximumCommittedMemory()); 5270 map_space_->MaximumCommittedMemory());
5263 PrintF("maximum_committed_by_lo_space=%" V8_PTR_PREFIX "d ", 5271 PrintF("maximum_committed_by_lo_space=%" V8_PTR_PREFIX "d ",
5264 lo_space_->MaximumCommittedMemory()); 5272 lo_space_->MaximumCommittedMemory());
5265 PrintF("\n\n"); 5273 PrintF("\n\n");
5266 } 5274 }
5267 5275
5268 if (FLAG_verify_predictable) { 5276 if (FLAG_verify_predictable) {
5269 PrintAlloctionsHash(); 5277 PrintAlloctionsHash();
5270 } 5278 }
5271 5279
5272 new_space()->RemoveInlineAllocationObserver(idle_scavenge_observer_); 5280 new_space()->RemoveAllocationObserver(idle_scavenge_observer_);
5273 delete idle_scavenge_observer_; 5281 delete idle_scavenge_observer_;
5274 idle_scavenge_observer_ = nullptr; 5282 idle_scavenge_observer_ = nullptr;
5275 5283
5276 delete scavenge_collector_; 5284 delete scavenge_collector_;
5277 scavenge_collector_ = nullptr; 5285 scavenge_collector_ = nullptr;
5278 5286
5279 if (mark_compact_collector_ != nullptr) { 5287 if (mark_compact_collector_ != nullptr) {
5280 mark_compact_collector_->TearDown(); 5288 mark_compact_collector_->TearDown();
5281 delete mark_compact_collector_; 5289 delete mark_compact_collector_;
5282 mark_compact_collector_ = nullptr; 5290 mark_compact_collector_ = nullptr;
(...skipping 961 matching lines...) Expand 10 before | Expand all | Expand 10 after
6244 } 6252 }
6245 6253
6246 6254
6247 // static 6255 // static
6248 int Heap::GetStaticVisitorIdForMap(Map* map) { 6256 int Heap::GetStaticVisitorIdForMap(Map* map) {
6249 return StaticVisitorBase::GetVisitorId(map); 6257 return StaticVisitorBase::GetVisitorId(map);
6250 } 6258 }
6251 6259
6252 } // namespace internal 6260 } // namespace internal
6253 } // namespace v8 6261 } // namespace v8
OLDNEW
« no previous file with comments | « src/heap/heap.h ('k') | src/heap/incremental-marking.h » ('j') | src/heap/spaces.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698