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

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

Issue 1929503002: Reland of "[heap] Uncommit pooled pages concurrently" (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fixed pooling Created 4 years, 7 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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 old_generation_size_at_last_gc_(0), 150 old_generation_size_at_last_gc_(0),
151 gcs_since_last_deopt_(0), 151 gcs_since_last_deopt_(0),
152 global_pretenuring_feedback_(nullptr), 152 global_pretenuring_feedback_(nullptr),
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 chunks_queued_for_free_(NULL),
161 concurrent_unmapping_tasks_active_(0),
162 pending_unmapping_tasks_semaphore_(0),
163 gc_callbacks_depth_(0), 160 gc_callbacks_depth_(0),
164 deserialization_complete_(false), 161 deserialization_complete_(false),
165 strong_roots_list_(NULL), 162 strong_roots_list_(NULL),
166 array_buffer_tracker_(NULL), 163 array_buffer_tracker_(NULL),
167 heap_iterator_depth_(0), 164 heap_iterator_depth_(0),
168 force_oom_(false) { 165 force_oom_(false) {
169 // Allow build-time customization of the max semispace size. Building 166 // Allow build-time customization of the max semispace size. Building
170 // V8 with snapshots and a non-default max semispace size is much 167 // V8 with snapshots and a non-default max semispace size is much
171 // easier if you can define it as part of the build environment. 168 // easier if you can define it as part of the build environment.
172 #if defined(V8_MAX_SEMISPACE_SIZE) 169 #if defined(V8_MAX_SEMISPACE_SIZE)
(...skipping 5267 matching lines...) Expand 10 before | Expand all | Expand 10 after
5440 delete memory_reducer_; 5437 delete memory_reducer_;
5441 memory_reducer_ = nullptr; 5438 memory_reducer_ = nullptr;
5442 } 5439 }
5443 5440
5444 delete object_stats_; 5441 delete object_stats_;
5445 object_stats_ = nullptr; 5442 object_stats_ = nullptr;
5446 5443
5447 delete scavenge_job_; 5444 delete scavenge_job_;
5448 scavenge_job_ = nullptr; 5445 scavenge_job_ = nullptr;
5449 5446
5450 WaitUntilUnmappingOfFreeChunksCompleted();
5451
5452 delete array_buffer_tracker_; 5447 delete array_buffer_tracker_;
5453 array_buffer_tracker_ = nullptr; 5448 array_buffer_tracker_ = nullptr;
5454 5449
5455 isolate_->global_handles()->TearDown(); 5450 isolate_->global_handles()->TearDown();
5456 5451
5457 external_string_table_.TearDown(); 5452 external_string_table_.TearDown();
5458 5453
5459 delete tracer_; 5454 delete tracer_;
5460 tracer_ = nullptr; 5455 tracer_ = nullptr;
5461 5456
(...skipping 785 matching lines...) Expand 10 before | Expand all | Expand 10 after
6247 heap_->FinalizeExternalString(ExternalString::cast(new_space_strings_[i])); 6242 heap_->FinalizeExternalString(ExternalString::cast(new_space_strings_[i]));
6248 } 6243 }
6249 new_space_strings_.Free(); 6244 new_space_strings_.Free();
6250 for (int i = 0; i < old_space_strings_.length(); ++i) { 6245 for (int i = 0; i < old_space_strings_.length(); ++i) {
6251 heap_->FinalizeExternalString(ExternalString::cast(old_space_strings_[i])); 6246 heap_->FinalizeExternalString(ExternalString::cast(old_space_strings_[i]));
6252 } 6247 }
6253 old_space_strings_.Free(); 6248 old_space_strings_.Free();
6254 } 6249 }
6255 6250
6256 6251
6257 class Heap::UnmapFreeMemoryTask : public v8::Task {
6258 public:
6259 UnmapFreeMemoryTask(Heap* heap, MemoryChunk* head)
6260 : heap_(heap), head_(head) {}
6261 virtual ~UnmapFreeMemoryTask() {}
6262
6263 private:
6264 // v8::Task overrides.
6265 void Run() override {
6266 heap_->FreeQueuedChunks(head_);
6267 heap_->pending_unmapping_tasks_semaphore_.Signal();
6268 }
6269
6270 Heap* heap_;
6271 MemoryChunk* head_;
6272
6273 DISALLOW_COPY_AND_ASSIGN(UnmapFreeMemoryTask);
6274 };
6275
6276
6277 void Heap::WaitUntilUnmappingOfFreeChunksCompleted() {
6278 while (concurrent_unmapping_tasks_active_ > 0) {
6279 pending_unmapping_tasks_semaphore_.Wait();
6280 concurrent_unmapping_tasks_active_--;
6281 }
6282 }
6283
6284
6285 void Heap::QueueMemoryChunkForFree(MemoryChunk* chunk) {
6286 // PreFree logically frees the memory chunk. However, the actual freeing
6287 // will happen on a separate thread sometime later.
6288 memory_allocator()->PreFreeMemory(chunk);
6289
6290 // The chunks added to this queue will be freed by a concurrent thread.
6291 chunk->set_next_chunk(chunks_queued_for_free_);
6292 chunks_queued_for_free_ = chunk;
6293 }
6294
6295
6296 void Heap::FreeQueuedChunks() {
6297 if (chunks_queued_for_free_ != NULL) {
6298 if (FLAG_concurrent_sweeping) {
6299 V8::GetCurrentPlatform()->CallOnBackgroundThread(
6300 new UnmapFreeMemoryTask(this, chunks_queued_for_free_),
6301 v8::Platform::kShortRunningTask);
6302 } else {
6303 FreeQueuedChunks(chunks_queued_for_free_);
6304 pending_unmapping_tasks_semaphore_.Signal();
6305 }
6306 chunks_queued_for_free_ = NULL;
6307 } else {
6308 // If we do not have anything to unmap, we just signal the semaphore
6309 // that we are done.
6310 pending_unmapping_tasks_semaphore_.Signal();
6311 }
6312 concurrent_unmapping_tasks_active_++;
6313 }
6314
6315
6316 void Heap::FreeQueuedChunks(MemoryChunk* list_head) {
6317 MemoryChunk* next;
6318 MemoryChunk* chunk;
6319 for (chunk = list_head; chunk != NULL; chunk = next) {
6320 next = chunk->next_chunk();
6321 memory_allocator()->PerformFreeMemory(chunk);
6322 }
6323 }
6324
6325
6326 void Heap::RememberUnmappedPage(Address page, bool compacted) { 6252 void Heap::RememberUnmappedPage(Address page, bool compacted) {
6327 uintptr_t p = reinterpret_cast<uintptr_t>(page); 6253 uintptr_t p = reinterpret_cast<uintptr_t>(page);
6328 // Tag the page pointer to make it findable in the dump file. 6254 // Tag the page pointer to make it findable in the dump file.
6329 if (compacted) { 6255 if (compacted) {
6330 p ^= 0xc1ead & (Page::kPageSize - 1); // Cleared. 6256 p ^= 0xc1ead & (Page::kPageSize - 1); // Cleared.
6331 } else { 6257 } else {
6332 p ^= 0x1d1ed & (Page::kPageSize - 1); // I died. 6258 p ^= 0x1d1ed & (Page::kPageSize - 1); // I died.
6333 } 6259 }
6334 remembered_unmapped_pages_[remembered_unmapped_pages_index_] = 6260 remembered_unmapped_pages_[remembered_unmapped_pages_index_] =
6335 reinterpret_cast<Address>(p); 6261 reinterpret_cast<Address>(p);
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
6423 } 6349 }
6424 6350
6425 6351
6426 // static 6352 // static
6427 int Heap::GetStaticVisitorIdForMap(Map* map) { 6353 int Heap::GetStaticVisitorIdForMap(Map* map) {
6428 return StaticVisitorBase::GetVisitorId(map); 6354 return StaticVisitorBase::GetVisitorId(map);
6429 } 6355 }
6430 6356
6431 } // namespace internal 6357 } // namespace internal
6432 } // namespace v8 6358 } // 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