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

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

Issue 2314783002: [heap] Removes spaces.h include from heap.h (Closed)
Patch Set: Move data structures used in debug mode Created 4 years, 3 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.cc ('k') | src/heap/spaces.h » ('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 #ifndef V8_HEAP_HEAP_INL_H_ 5 #ifndef V8_HEAP_HEAP_INL_H_
6 #define V8_HEAP_HEAP_INL_H_ 6 #define V8_HEAP_HEAP_INL_H_
7 7
8 #include <cmath> 8 #include <cmath>
9 9
10 #include "src/base/platform/platform.h" 10 #include "src/base/platform/platform.h"
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 case NEW_SPACE: 165 case NEW_SPACE:
166 return new_space(); 166 return new_space();
167 case LO_SPACE: 167 case LO_SPACE:
168 return lo_space(); 168 return lo_space();
169 default: 169 default:
170 return paged_space(idx); 170 return paged_space(idx);
171 } 171 }
172 } 172 }
173 173
174 Address* Heap::NewSpaceAllocationTopAddress() { 174 Address* Heap::NewSpaceAllocationTopAddress() {
175 return new_space_.allocation_top_address(); 175 return new_space_->allocation_top_address();
176 } 176 }
177 177
178 Address* Heap::NewSpaceAllocationLimitAddress() { 178 Address* Heap::NewSpaceAllocationLimitAddress() {
179 return new_space_.allocation_limit_address(); 179 return new_space_->allocation_limit_address();
180 } 180 }
181 181
182 Address* Heap::OldSpaceAllocationTopAddress() { 182 Address* Heap::OldSpaceAllocationTopAddress() {
183 return old_space_->allocation_top_address(); 183 return old_space_->allocation_top_address();
184 } 184 }
185 185
186 Address* Heap::OldSpaceAllocationLimitAddress() { 186 Address* Heap::OldSpaceAllocationLimitAddress() {
187 return old_space_->allocation_limit_address(); 187 return old_space_->allocation_limit_address();
188 } 188 }
189 189
190 bool Heap::HeapIsFullEnoughToStartIncrementalMarking(intptr_t limit) { 190 bool Heap::HeapIsFullEnoughToStartIncrementalMarking(intptr_t limit) {
191 if (FLAG_stress_compaction && (gc_count_ & 1) != 0) return true; 191 if (FLAG_stress_compaction && (gc_count_ & 1) != 0) return true;
192 192
193 intptr_t adjusted_allocation_limit = limit - new_space_.Capacity(); 193 intptr_t adjusted_allocation_limit = limit - new_space_->Capacity();
194 194
195 if (PromotedTotalSize() >= adjusted_allocation_limit) return true; 195 if (PromotedTotalSize() >= adjusted_allocation_limit) return true;
196 196
197 if (HighMemoryPressure()) return true; 197 if (HighMemoryPressure()) return true;
198 198
199 return false; 199 return false;
200 } 200 }
201 201
202 void Heap::UpdateNewSpaceAllocationCounter() { 202 void Heap::UpdateNewSpaceAllocationCounter() {
203 new_space_allocation_counter_ = NewSpaceAllocationCounter(); 203 new_space_allocation_counter_ = NewSpaceAllocationCounter();
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 isolate_->counters()->objs_since_last_young()->Increment(); 326 isolate_->counters()->objs_since_last_young()->Increment();
327 #endif 327 #endif
328 328
329 bool large_object = size_in_bytes > kMaxRegularHeapObjectSize; 329 bool large_object = size_in_bytes > kMaxRegularHeapObjectSize;
330 HeapObject* object = nullptr; 330 HeapObject* object = nullptr;
331 AllocationResult allocation; 331 AllocationResult allocation;
332 if (NEW_SPACE == space) { 332 if (NEW_SPACE == space) {
333 if (large_object) { 333 if (large_object) {
334 space = LO_SPACE; 334 space = LO_SPACE;
335 } else { 335 } else {
336 allocation = new_space_.AllocateRaw(size_in_bytes, alignment); 336 allocation = new_space_->AllocateRaw(size_in_bytes, alignment);
337 if (allocation.To(&object)) { 337 if (allocation.To(&object)) {
338 OnAllocationEvent(object, size_in_bytes); 338 OnAllocationEvent(object, size_in_bytes);
339 } 339 }
340 return allocation; 340 return allocation;
341 } 341 }
342 } 342 }
343 343
344 // Here we only allocate in the old generation. 344 // Here we only allocate in the old generation.
345 if (OLD_SPACE == space) { 345 if (OLD_SPACE == space) {
346 if (large_object) { 346 if (large_object) {
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 reinterpret_cast<byte*>(string) + ExternalString::kResourceOffset - 465 reinterpret_cast<byte*>(string) + ExternalString::kResourceOffset -
466 kHeapObjectTag); 466 kHeapObjectTag);
467 467
468 // Dispose of the C++ object if it has not already been disposed. 468 // Dispose of the C++ object if it has not already been disposed.
469 if (*resource_addr != NULL) { 469 if (*resource_addr != NULL) {
470 (*resource_addr)->Dispose(); 470 (*resource_addr)->Dispose();
471 *resource_addr = NULL; 471 *resource_addr = NULL;
472 } 472 }
473 } 473 }
474 474
475 Address Heap::NewSpaceTop() { return new_space_->top(); }
476
477 bool Heap::DeoptMaybeTenuredAllocationSites() {
478 return new_space_->IsAtMaximumCapacity() && maximum_size_scavenges_ == 0;
479 }
475 480
476 bool Heap::InNewSpace(Object* object) { 481 bool Heap::InNewSpace(Object* object) {
477 // Inlined check from NewSpace::Contains. 482 // Inlined check from NewSpace::Contains.
478 bool result = 483 bool result =
479 object->IsHeapObject() && 484 object->IsHeapObject() &&
480 Page::FromAddress(HeapObject::cast(object)->address())->InNewSpace(); 485 Page::FromAddress(HeapObject::cast(object)->address())->InNewSpace();
481 DCHECK(!result || // Either not in new space 486 DCHECK(!result || // Either not in new space
482 gc_state_ != NOT_IN_GC || // ... or in the middle of GC 487 gc_state_ != NOT_IN_GC || // ... or in the middle of GC
483 InToSpace(object)); // ... or in to-space (where we allocate). 488 InToSpace(object)); // ... or in to-space (where we allocate).
484 return result; 489 return result;
485 } 490 }
486 491
487 bool Heap::InFromSpace(Object* object) { 492 bool Heap::InFromSpace(Object* object) {
488 return object->IsHeapObject() && 493 return object->IsHeapObject() &&
489 MemoryChunk::FromAddress(HeapObject::cast(object)->address()) 494 MemoryChunk::FromAddress(HeapObject::cast(object)->address())
490 ->IsFlagSet(Page::IN_FROM_SPACE); 495 ->IsFlagSet(Page::IN_FROM_SPACE);
491 } 496 }
492 497
493 498
494 bool Heap::InToSpace(Object* object) { 499 bool Heap::InToSpace(Object* object) {
495 return object->IsHeapObject() && 500 return object->IsHeapObject() &&
496 MemoryChunk::FromAddress(HeapObject::cast(object)->address()) 501 MemoryChunk::FromAddress(HeapObject::cast(object)->address())
497 ->IsFlagSet(Page::IN_TO_SPACE); 502 ->IsFlagSet(Page::IN_TO_SPACE);
498 } 503 }
499 504
500 bool Heap::InOldSpace(Object* object) { return old_space_->Contains(object); } 505 bool Heap::InOldSpace(Object* object) { return old_space_->Contains(object); }
501 506
502 bool Heap::InNewSpaceSlow(Address address) { 507 bool Heap::InNewSpaceSlow(Address address) {
503 return new_space_.ContainsSlow(address); 508 return new_space_->ContainsSlow(address);
504 } 509 }
505 510
506 bool Heap::InOldSpaceSlow(Address address) { 511 bool Heap::InOldSpaceSlow(Address address) {
507 return old_space_->ContainsSlow(address); 512 return old_space_->ContainsSlow(address);
508 } 513 }
509 514
510 bool Heap::OldGenerationAllocationLimitReached() { 515 bool Heap::OldGenerationAllocationLimitReached() {
511 if (!incremental_marking()->IsStopped() && !ShouldOptimizeForMemoryUsage()) { 516 if (!incremental_marking()->IsStopped() && !ShouldOptimizeForMemoryUsage()) {
512 return false; 517 return false;
513 } 518 }
514 return OldGenerationSpaceAvailable() < 0; 519 return OldGenerationSpaceAvailable() < 0;
515 } 520 }
516 521
517 template <PromotionMode promotion_mode> 522 template <PromotionMode promotion_mode>
518 bool Heap::ShouldBePromoted(Address old_address, int object_size) { 523 bool Heap::ShouldBePromoted(Address old_address, int object_size) {
519 Page* page = Page::FromAddress(old_address); 524 Page* page = Page::FromAddress(old_address);
520 Address age_mark = new_space_.age_mark(); 525 Address age_mark = new_space_->age_mark();
521 526
522 if (promotion_mode == PROMOTE_MARKED) { 527 if (promotion_mode == PROMOTE_MARKED) {
523 MarkBit mark_bit = ObjectMarking::MarkBitFrom(old_address); 528 MarkBit mark_bit = ObjectMarking::MarkBitFrom(old_address);
524 if (!Marking::IsWhite(mark_bit)) { 529 if (!Marking::IsWhite(mark_bit)) {
525 return true; 530 return true;
526 } 531 }
527 } 532 }
528 533
529 return page->IsFlagSet(MemoryChunk::NEW_SPACE_BELOW_AGE_MARK) && 534 return page->IsFlagSet(MemoryChunk::NEW_SPACE_BELOW_AGE_MARK) &&
530 (!page->ContainsLimit(age_mark) || old_address < age_mark); 535 (!page->ContainsLimit(age_mark) || old_address < age_mark);
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
876 881
877 void VerifySmisVisitor::VisitPointers(Object** start, Object** end) { 882 void VerifySmisVisitor::VisitPointers(Object** start, Object** end) {
878 for (Object** current = start; current < end; current++) { 883 for (Object** current = start; current < end; current++) {
879 CHECK((*current)->IsSmi()); 884 CHECK((*current)->IsSmi());
880 } 885 }
881 } 886 }
882 } // namespace internal 887 } // namespace internal
883 } // namespace v8 888 } // namespace v8
884 889
885 #endif // V8_HEAP_HEAP_INL_H_ 890 #endif // V8_HEAP_HEAP_INL_H_
OLDNEW
« no previous file with comments | « src/heap/heap.cc ('k') | src/heap/spaces.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698