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

Side by Side Diff: src/heap/spaces-inl.h

Issue 1487853002: [heap] Move to LAB-based allocation for newspace evacuation. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Added comments describing LocalAllocationBuffer Created 5 years 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/spaces.cc ('k') | test/cctest/cctest.gyp » ('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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 #ifndef V8_HEAP_SPACES_INL_H_ 5 #ifndef V8_HEAP_SPACES_INL_H_
6 #define V8_HEAP_SPACES_INL_H_ 6 #define V8_HEAP_SPACES_INL_H_
7 7
8 #include "src/heap/incremental-marking.h"
8 #include "src/heap/spaces.h" 9 #include "src/heap/spaces.h"
9 #include "src/isolate.h" 10 #include "src/isolate.h"
10 #include "src/msan.h" 11 #include "src/msan.h"
11 #include "src/profiler/heap-profiler.h" 12 #include "src/profiler/heap-profiler.h"
12 #include "src/v8memory.h" 13 #include "src/v8memory.h"
13 14
14 namespace v8 { 15 namespace v8 {
15 namespace internal { 16 namespace internal {
16 17
17 18
(...skipping 24 matching lines...) Expand all
42 prev_page_ = next_page_; 43 prev_page_ = next_page_;
43 next_page_ = next_page_->next_page(); 44 next_page_ = next_page_->next_page();
44 return prev_page_; 45 return prev_page_;
45 } 46 }
46 47
47 48
48 // ----------------------------------------------------------------------------- 49 // -----------------------------------------------------------------------------
49 // SemiSpaceIterator 50 // SemiSpaceIterator
50 51
51 HeapObject* SemiSpaceIterator::Next() { 52 HeapObject* SemiSpaceIterator::Next() {
52 if (current_ == limit_) return NULL; 53 while (current_ != limit_) {
53 if (NewSpacePage::IsAtEnd(current_)) { 54 if (NewSpacePage::IsAtEnd(current_)) {
54 NewSpacePage* page = NewSpacePage::FromLimit(current_); 55 NewSpacePage* page = NewSpacePage::FromLimit(current_);
55 page = page->next_page(); 56 page = page->next_page();
56 DCHECK(!page->is_anchor()); 57 DCHECK(!page->is_anchor());
57 current_ = page->area_start(); 58 current_ = page->area_start();
58 if (current_ == limit_) return NULL; 59 if (current_ == limit_) return nullptr;
60 }
61 HeapObject* object = HeapObject::FromAddress(current_);
62 current_ += object->Size();
63 if (!object->IsFiller()) {
64 return object;
65 }
59 } 66 }
60 67 return nullptr;
61 HeapObject* object = HeapObject::FromAddress(current_);
62 int size = object->Size();
63
64 current_ += size;
65 return object;
66 } 68 }
67 69
68 70
69 HeapObject* SemiSpaceIterator::next_object() { return Next(); } 71 HeapObject* SemiSpaceIterator::next_object() { return Next(); }
70 72
71 73
72 // ----------------------------------------------------------------------------- 74 // -----------------------------------------------------------------------------
73 // NewSpacePageIterator 75 // NewSpacePageIterator
74 76
75 NewSpacePageIterator::NewSpacePageIterator(NewSpace* space) 77 NewSpacePageIterator::NewSpacePageIterator(NewSpace* space)
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 HeapObject* PagedSpace::AllocateLinearly(int size_in_bytes) { 314 HeapObject* PagedSpace::AllocateLinearly(int size_in_bytes) {
313 Address current_top = allocation_info_.top(); 315 Address current_top = allocation_info_.top();
314 Address new_top = current_top + size_in_bytes; 316 Address new_top = current_top + size_in_bytes;
315 if (new_top > allocation_info_.limit()) return NULL; 317 if (new_top > allocation_info_.limit()) return NULL;
316 318
317 allocation_info_.set_top(new_top); 319 allocation_info_.set_top(new_top);
318 return HeapObject::FromAddress(current_top); 320 return HeapObject::FromAddress(current_top);
319 } 321 }
320 322
321 323
324 AllocationResult LocalAllocationBuffer::AllocateRawAligned(
325 int size_in_bytes, AllocationAlignment alignment) {
326 Address current_top = allocation_info_.top();
327 int filler_size = Heap::GetFillToAlign(current_top, alignment);
328
329 Address new_top = current_top + filler_size + size_in_bytes;
330 if (new_top > allocation_info_.limit()) return AllocationResult::Retry();
331
332 allocation_info_.set_top(new_top);
333 if (filler_size > 0) {
334 return heap_->PrecedeWithFiller(HeapObject::FromAddress(current_top),
335 filler_size);
336 }
337
338 return AllocationResult(HeapObject::FromAddress(current_top));
339 }
340
341
322 HeapObject* PagedSpace::AllocateLinearlyAligned(int* size_in_bytes, 342 HeapObject* PagedSpace::AllocateLinearlyAligned(int* size_in_bytes,
323 AllocationAlignment alignment) { 343 AllocationAlignment alignment) {
324 Address current_top = allocation_info_.top(); 344 Address current_top = allocation_info_.top();
325 int filler_size = Heap::GetFillToAlign(current_top, alignment); 345 int filler_size = Heap::GetFillToAlign(current_top, alignment);
326 346
327 Address new_top = current_top + filler_size + *size_in_bytes; 347 Address new_top = current_top + filler_size + *size_in_bytes;
328 if (new_top > allocation_info_.limit()) return NULL; 348 if (new_top > allocation_info_.limit()) return NULL;
329 349
330 allocation_info_.set_top(new_top); 350 allocation_info_.set_top(new_top);
331 if (filler_size > 0) { 351 if (filler_size > 0) {
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 #ifdef V8_HOST_ARCH_32_BIT 495 #ifdef V8_HOST_ARCH_32_BIT
476 return alignment == kDoubleAligned 496 return alignment == kDoubleAligned
477 ? AllocateRawAligned(size_in_bytes, kDoubleAligned) 497 ? AllocateRawAligned(size_in_bytes, kDoubleAligned)
478 : AllocateRawUnaligned(size_in_bytes); 498 : AllocateRawUnaligned(size_in_bytes);
479 #else 499 #else
480 return AllocateRawUnaligned(size_in_bytes); 500 return AllocateRawUnaligned(size_in_bytes);
481 #endif 501 #endif
482 } 502 }
483 503
484 504
505 MUST_USE_RESULT inline AllocationResult NewSpace::AllocateRawSynchronized(
506 int size_in_bytes, AllocationAlignment alignment) {
507 base::LockGuard<base::Mutex> guard(&mutex_);
508 return AllocateRaw(size_in_bytes, alignment);
509 }
510
511
485 LargePage* LargePage::Initialize(Heap* heap, MemoryChunk* chunk) { 512 LargePage* LargePage::Initialize(Heap* heap, MemoryChunk* chunk) {
486 heap->incremental_marking()->SetOldSpacePageFlags(chunk); 513 heap->incremental_marking()->SetOldSpacePageFlags(chunk);
487 return static_cast<LargePage*>(chunk); 514 return static_cast<LargePage*>(chunk);
488 } 515 }
489 516
490 517
491 intptr_t LargeObjectSpace::Available() { 518 intptr_t LargeObjectSpace::Available() {
492 return ObjectSizeFor(heap()->isolate()->memory_allocator()->Available()); 519 return ObjectSizeFor(heap()->isolate()->memory_allocator()->Available());
493 } 520 }
494 521
522
523 LocalAllocationBuffer LocalAllocationBuffer::InvalidBuffer() {
524 return LocalAllocationBuffer(nullptr, AllocationInfo(nullptr, nullptr));
525 }
526
527
528 LocalAllocationBuffer LocalAllocationBuffer::FromResult(Heap* heap,
529 AllocationResult result,
530 intptr_t size) {
531 if (result.IsRetry()) return InvalidBuffer();
532 HeapObject* obj = nullptr;
533 bool ok = result.To(&obj);
534 USE(ok);
535 DCHECK(ok);
536 Address top = HeapObject::cast(obj)->address();
537 return LocalAllocationBuffer(heap, AllocationInfo(top, top + size));
538 }
539
540
541 bool LocalAllocationBuffer::TryMerge(LocalAllocationBuffer* other) {
542 if (allocation_info_.top() == other->allocation_info_.limit()) {
543 allocation_info_.set_top(other->allocation_info_.top());
544 other->allocation_info_.Reset(nullptr, nullptr);
545 return true;
546 }
547 return false;
548 }
549
495 } // namespace internal 550 } // namespace internal
496 } // namespace v8 551 } // namespace v8
497 552
498 #endif // V8_HEAP_SPACES_INL_H_ 553 #endif // V8_HEAP_SPACES_INL_H_
OLDNEW
« no previous file with comments | « src/heap/spaces.cc ('k') | test/cctest/cctest.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698