| OLD | NEW |
| 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 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 | 352 |
| 353 | 353 |
| 354 bool Heap::InNewSpace(Object* object) { | 354 bool Heap::InNewSpace(Object* object) { |
| 355 bool result = new_space_.Contains(object); | 355 bool result = new_space_.Contains(object); |
| 356 DCHECK(!result || // Either not in new space | 356 DCHECK(!result || // Either not in new space |
| 357 gc_state_ != NOT_IN_GC || // ... or in the middle of GC | 357 gc_state_ != NOT_IN_GC || // ... or in the middle of GC |
| 358 InToSpace(object)); // ... or in to-space (where we allocate). | 358 InToSpace(object)); // ... or in to-space (where we allocate). |
| 359 return result; | 359 return result; |
| 360 } | 360 } |
| 361 | 361 |
| 362 | |
| 363 bool Heap::InNewSpace(Address address) { return new_space_.Contains(address); } | |
| 364 | |
| 365 | |
| 366 bool Heap::InFromSpace(Object* object) { | 362 bool Heap::InFromSpace(Object* object) { |
| 367 return new_space_.FromSpaceContains(object); | 363 return new_space_.FromSpaceContains(object); |
| 368 } | 364 } |
| 369 | 365 |
| 370 | 366 |
| 371 bool Heap::InToSpace(Object* object) { | 367 bool Heap::InToSpace(Object* object) { |
| 372 return new_space_.ToSpaceContains(object); | 368 return new_space_.ToSpaceContains(object); |
| 373 } | 369 } |
| 374 | 370 |
| 371 bool Heap::InOldSpace(Object* object) { return old_space_->Contains(object); } |
| 375 | 372 |
| 376 bool Heap::InOldSpace(Address address) { return old_space_->Contains(address); } | 373 bool Heap::InNewSpaceSlow(Address address) { |
| 377 | 374 return new_space_.ContainsSlow(address); |
| 378 | |
| 379 bool Heap::InOldSpace(Object* object) { | |
| 380 return InOldSpace(reinterpret_cast<Address>(object)); | |
| 381 } | 375 } |
| 382 | 376 |
| 377 bool Heap::InOldSpaceSlow(Address address) { |
| 378 return old_space_->ContainsSlow(address); |
| 379 } |
| 383 | 380 |
| 384 bool Heap::OldGenerationAllocationLimitReached() { | 381 bool Heap::OldGenerationAllocationLimitReached() { |
| 385 if (!incremental_marking()->IsStopped()) return false; | 382 if (!incremental_marking()->IsStopped()) return false; |
| 386 return OldGenerationSpaceAvailable() < 0; | 383 return OldGenerationSpaceAvailable() < 0; |
| 387 } | 384 } |
| 388 | 385 |
| 389 | 386 |
| 390 bool Heap::ShouldBePromoted(Address old_address, int object_size) { | 387 bool Heap::ShouldBePromoted(Address old_address, int object_size) { |
| 391 NewSpacePage* page = NewSpacePage::FromAddress(old_address); | 388 NewSpacePage* page = NewSpacePage::FromAddress(old_address); |
| 392 Address age_mark = new_space_.age_mark(); | 389 Address age_mark = new_space_.age_mark(); |
| 393 return page->IsFlagSet(MemoryChunk::NEW_SPACE_BELOW_AGE_MARK) && | 390 return page->IsFlagSet(MemoryChunk::NEW_SPACE_BELOW_AGE_MARK) && |
| 394 (!page->ContainsLimit(age_mark) || old_address < age_mark); | 391 (!page->ContainsLimit(age_mark) || old_address < age_mark); |
| 395 } | 392 } |
| 396 | 393 |
| 397 | 394 void Heap::RecordWrite(Object* object, int offset, Object* o) { |
| 398 void Heap::RecordWrite(Address address, int offset) { | 395 if (!InNewSpace(o) || !object->IsHeapObject() || InNewSpace(object)) { |
| 399 if (!InNewSpace(address)) store_buffer_.Mark(address + offset); | 396 return; |
| 397 } |
| 398 store_buffer_.Mark(HeapObject::cast(object)->address() + offset); |
| 400 } | 399 } |
| 401 | 400 |
| 402 | 401 |
| 403 void Heap::RecordWrites(Address address, int start, int len) { | |
| 404 if (!InNewSpace(address)) { | |
| 405 for (int i = 0; i < len; i++) { | |
| 406 store_buffer_.Mark(address + start + i * kPointerSize); | |
| 407 } | |
| 408 } | |
| 409 } | |
| 410 | |
| 411 | |
| 412 bool Heap::AllowedToBeMigrated(HeapObject* obj, AllocationSpace dst) { | 402 bool Heap::AllowedToBeMigrated(HeapObject* obj, AllocationSpace dst) { |
| 413 // Object migration is governed by the following rules: | 403 // Object migration is governed by the following rules: |
| 414 // | 404 // |
| 415 // 1) Objects in new-space can be migrated to the old space | 405 // 1) Objects in new-space can be migrated to the old space |
| 416 // that matches their target space or they stay in new-space. | 406 // that matches their target space or they stay in new-space. |
| 417 // 2) Objects in old-space stay in the same space when migrating. | 407 // 2) Objects in old-space stay in the same space when migrating. |
| 418 // 3) Fillers (two or more words) can migrate due to left-trimming of | 408 // 3) Fillers (two or more words) can migrate due to left-trimming of |
| 419 // fixed arrays in new-space or old space. | 409 // fixed arrays in new-space or old space. |
| 420 // 4) Fillers (one word) can never migrate, they are skipped by | 410 // 4) Fillers (one word) can never migrate, they are skipped by |
| 421 // incremental marking explicitly to prevent invalid pattern. | 411 // incremental marking explicitly to prevent invalid pattern. |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 735 | 725 |
| 736 void VerifySmisVisitor::VisitPointers(Object** start, Object** end) { | 726 void VerifySmisVisitor::VisitPointers(Object** start, Object** end) { |
| 737 for (Object** current = start; current < end; current++) { | 727 for (Object** current = start; current < end; current++) { |
| 738 CHECK((*current)->IsSmi()); | 728 CHECK((*current)->IsSmi()); |
| 739 } | 729 } |
| 740 } | 730 } |
| 741 } // namespace internal | 731 } // namespace internal |
| 742 } // namespace v8 | 732 } // namespace v8 |
| 743 | 733 |
| 744 #endif // V8_HEAP_HEAP_INL_H_ | 734 #endif // V8_HEAP_HEAP_INL_H_ |
| OLD | NEW |