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