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

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

Issue 2036643002: Reland "[heap] Fine-grained JSArrayBuffer tracking" (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Remove unneeded locking to avoid lock-inversion-order errors in TSAN Created 4 years, 6 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
« no previous file with comments | « src/heap/heap.h ('k') | src/heap/mark-compact.cc » ('j') | 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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 ring_buffer_full_(false), 153 ring_buffer_full_(false),
154 ring_buffer_end_(0), 154 ring_buffer_end_(0),
155 promotion_queue_(this), 155 promotion_queue_(this),
156 configured_(false), 156 configured_(false),
157 current_gc_flags_(Heap::kNoGCFlags), 157 current_gc_flags_(Heap::kNoGCFlags),
158 current_gc_callback_flags_(GCCallbackFlags::kNoGCCallbackFlags), 158 current_gc_callback_flags_(GCCallbackFlags::kNoGCCallbackFlags),
159 external_string_table_(this), 159 external_string_table_(this),
160 gc_callbacks_depth_(0), 160 gc_callbacks_depth_(0),
161 deserialization_complete_(false), 161 deserialization_complete_(false),
162 strong_roots_list_(NULL), 162 strong_roots_list_(NULL),
163 array_buffer_tracker_(NULL),
164 heap_iterator_depth_(0), 163 heap_iterator_depth_(0),
165 force_oom_(false) { 164 force_oom_(false) {
166 // Allow build-time customization of the max semispace size. Building 165 // Allow build-time customization of the max semispace size. Building
167 // V8 with snapshots and a non-default max semispace size is much 166 // V8 with snapshots and a non-default max semispace size is much
168 // easier if you can define it as part of the build environment. 167 // easier if you can define it as part of the build environment.
169 #if defined(V8_MAX_SEMISPACE_SIZE) 168 #if defined(V8_MAX_SEMISPACE_SIZE)
170 max_semi_space_size_ = reserved_semispace_size_ = V8_MAX_SEMISPACE_SIZE; 169 max_semi_space_size_ = reserved_semispace_size_ = V8_MAX_SEMISPACE_SIZE;
171 #endif 170 #endif
172 171
173 // Ensure old_generation_size_ is a multiple of kPageSize. 172 // Ensure old_generation_size_ is a multiple of kPageSize.
(...skipping 1454 matching lines...) Expand 10 before | Expand all | Expand 10 after
1628 1627
1629 scavenge_collector_->SelectScavengingVisitorsTable(); 1628 scavenge_collector_->SelectScavengingVisitorsTable();
1630 1629
1631 if (UsingEmbedderHeapTracer()) { 1630 if (UsingEmbedderHeapTracer()) {
1632 // Register found wrappers with embedder so he can add them to his marking 1631 // Register found wrappers with embedder so he can add them to his marking
1633 // deque and correctly manage the case when v8 scavenger collects the 1632 // deque and correctly manage the case when v8 scavenger collects the
1634 // wrappers by either keeping wrappables alive, or cleaning marking deque. 1633 // wrappers by either keeping wrappables alive, or cleaning marking deque.
1635 mark_compact_collector()->RegisterWrappersWithEmbedderHeapTracer(); 1634 mark_compact_collector()->RegisterWrappersWithEmbedderHeapTracer();
1636 } 1635 }
1637 1636
1638 array_buffer_tracker()->PrepareDiscoveryInNewSpace();
1639
1640 // Flip the semispaces. After flipping, to space is empty, from space has 1637 // Flip the semispaces. After flipping, to space is empty, from space has
1641 // live objects. 1638 // live objects.
1642 new_space_.Flip(); 1639 new_space_.Flip();
1643 new_space_.ResetAllocationInfo(); 1640 new_space_.ResetAllocationInfo();
1644 1641
1645 // We need to sweep newly copied objects which can be either in the 1642 // We need to sweep newly copied objects which can be either in the
1646 // to space or promoted to the old generation. For to-space 1643 // to space or promoted to the old generation. For to-space
1647 // objects, we treat the bottom of the to space as a queue. Newly 1644 // objects, we treat the bottom of the to space as a queue. Newly
1648 // copied and unswept objects lie between a 'front' mark and the 1645 // copied and unswept objects lie between a 'front' mark and the
1649 // allocation pointer. 1646 // allocation pointer.
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
1754 incremental_marking()->UpdateMarkingDequeAfterScavenge(); 1751 incremental_marking()->UpdateMarkingDequeAfterScavenge();
1755 1752
1756 ScavengeWeakObjectRetainer weak_object_retainer(this); 1753 ScavengeWeakObjectRetainer weak_object_retainer(this);
1757 ProcessYoungWeakReferences(&weak_object_retainer); 1754 ProcessYoungWeakReferences(&weak_object_retainer);
1758 1755
1759 DCHECK(new_space_front == new_space_.top()); 1756 DCHECK(new_space_front == new_space_.top());
1760 1757
1761 // Set age mark. 1758 // Set age mark.
1762 new_space_.set_age_mark(new_space_.top()); 1759 new_space_.set_age_mark(new_space_.top());
1763 1760
1764 array_buffer_tracker()->FreeDead(true); 1761 ArrayBufferTracker::FreeDeadInNewSpace(this);
1765 1762
1766 // Update how much has survived scavenge. 1763 // Update how much has survived scavenge.
1767 IncrementYoungSurvivorsCounter(static_cast<int>( 1764 IncrementYoungSurvivorsCounter(static_cast<int>(
1768 (PromotedSpaceSizeOfObjects() - survived_watermark) + new_space_.Size())); 1765 (PromotedSpaceSizeOfObjects() - survived_watermark) + new_space_.Size()));
1769 1766
1770 LOG(isolate_, ResourceEvent("scavenge", "end")); 1767 LOG(isolate_, ResourceEvent("scavenge", "end"));
1771 1768
1772 gc_state_ = NOT_IN_GC; 1769 gc_state_ = NOT_IN_GC;
1773 } 1770 }
1774 1771
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
2040 return object; 2037 return object;
2041 } 2038 }
2042 2039
2043 2040
2044 HeapObject* Heap::DoubleAlignForDeserialization(HeapObject* object, int size) { 2041 HeapObject* Heap::DoubleAlignForDeserialization(HeapObject* object, int size) {
2045 return AlignWithFiller(object, size - kPointerSize, size, kDoubleAligned); 2042 return AlignWithFiller(object, size - kPointerSize, size, kDoubleAligned);
2046 } 2043 }
2047 2044
2048 2045
2049 void Heap::RegisterNewArrayBuffer(JSArrayBuffer* buffer) { 2046 void Heap::RegisterNewArrayBuffer(JSArrayBuffer* buffer) {
2050 return array_buffer_tracker()->RegisterNew(buffer); 2047 ArrayBufferTracker::RegisterNew(this, buffer);
2051 } 2048 }
2052 2049
2053 2050
2054 void Heap::UnregisterArrayBuffer(JSArrayBuffer* buffer) { 2051 void Heap::UnregisterArrayBuffer(JSArrayBuffer* buffer) {
2055 return array_buffer_tracker()->Unregister(buffer); 2052 ArrayBufferTracker::Unregister(this, buffer);
2056 } 2053 }
2057 2054
2058 2055
2059 void Heap::ConfigureInitialOldGenerationSize() { 2056 void Heap::ConfigureInitialOldGenerationSize() {
2060 if (!old_generation_size_configured_ && tracer()->SurvivalEventsRecorded()) { 2057 if (!old_generation_size_configured_ && tracer()->SurvivalEventsRecorded()) {
2061 old_generation_allocation_limit_ = 2058 old_generation_allocation_limit_ =
2062 Max(kMinimumOldGenerationAllocationLimit, 2059 Max(kMinimumOldGenerationAllocationLimit,
2063 static_cast<intptr_t>( 2060 static_cast<intptr_t>(
2064 static_cast<double>(old_generation_allocation_limit_) * 2061 static_cast<double>(old_generation_allocation_limit_) *
2065 (tracer()->AverageSurvivalRatio() / 100))); 2062 (tracer()->AverageSurvivalRatio() / 100)));
(...skipping 3275 matching lines...) Expand 10 before | Expand all | Expand 10 after
5341 5338
5342 gc_idle_time_handler_ = new GCIdleTimeHandler(); 5339 gc_idle_time_handler_ = new GCIdleTimeHandler();
5343 5340
5344 memory_reducer_ = new MemoryReducer(this); 5341 memory_reducer_ = new MemoryReducer(this);
5345 5342
5346 object_stats_ = new ObjectStats(this); 5343 object_stats_ = new ObjectStats(this);
5347 object_stats_->ClearObjectStats(true); 5344 object_stats_->ClearObjectStats(true);
5348 5345
5349 scavenge_job_ = new ScavengeJob(); 5346 scavenge_job_ = new ScavengeJob();
5350 5347
5351 array_buffer_tracker_ = new ArrayBufferTracker(this);
5352
5353 LOG(isolate_, IntPtrTEvent("heap-capacity", Capacity())); 5348 LOG(isolate_, IntPtrTEvent("heap-capacity", Capacity()));
5354 LOG(isolate_, IntPtrTEvent("heap-available", Available())); 5349 LOG(isolate_, IntPtrTEvent("heap-available", Available()));
5355 5350
5356 store_buffer()->SetUp(); 5351 store_buffer()->SetUp();
5357 5352
5358 mark_compact_collector()->SetUp(); 5353 mark_compact_collector()->SetUp();
5359 5354
5360 idle_scavenge_observer_ = new IdleScavengeObserver( 5355 idle_scavenge_observer_ = new IdleScavengeObserver(
5361 *this, ScavengeJob::kBytesAllocatedBeforeNextIdleTask); 5356 *this, ScavengeJob::kBytesAllocatedBeforeNextIdleTask);
5362 new_space()->AddAllocationObserver(idle_scavenge_observer_); 5357 new_space()->AddAllocationObserver(idle_scavenge_observer_);
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
5502 delete memory_reducer_; 5497 delete memory_reducer_;
5503 memory_reducer_ = nullptr; 5498 memory_reducer_ = nullptr;
5504 } 5499 }
5505 5500
5506 delete object_stats_; 5501 delete object_stats_;
5507 object_stats_ = nullptr; 5502 object_stats_ = nullptr;
5508 5503
5509 delete scavenge_job_; 5504 delete scavenge_job_;
5510 scavenge_job_ = nullptr; 5505 scavenge_job_ = nullptr;
5511 5506
5512 delete array_buffer_tracker_;
5513 array_buffer_tracker_ = nullptr;
5514
5515 isolate_->global_handles()->TearDown(); 5507 isolate_->global_handles()->TearDown();
5516 5508
5517 external_string_table_.TearDown(); 5509 external_string_table_.TearDown();
5518 5510
5519 delete tracer_; 5511 delete tracer_;
5520 tracer_ = nullptr; 5512 tracer_ = nullptr;
5521 5513
5522 new_space_.TearDown(); 5514 new_space_.TearDown();
5523 5515
5524 if (old_space_ != NULL) { 5516 if (old_space_ != NULL) {
(...skipping 890 matching lines...) Expand 10 before | Expand all | Expand 10 after
6415 } 6407 }
6416 6408
6417 6409
6418 // static 6410 // static
6419 int Heap::GetStaticVisitorIdForMap(Map* map) { 6411 int Heap::GetStaticVisitorIdForMap(Map* map) {
6420 return StaticVisitorBase::GetVisitorId(map); 6412 return StaticVisitorBase::GetVisitorId(map);
6421 } 6413 }
6422 6414
6423 } // namespace internal 6415 } // namespace internal
6424 } // namespace v8 6416 } // namespace v8
OLDNEW
« no previous file with comments | « src/heap/heap.h ('k') | src/heap/mark-compact.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698