Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 547 class VerifyNonPointerSpacePointersVisitor: public ObjectVisitor { | 547 class VerifyNonPointerSpacePointersVisitor: public ObjectVisitor { |
| 548 public: | 548 public: |
| 549 void VisitPointers(Object** start, Object**end) { | 549 void VisitPointers(Object** start, Object**end) { |
| 550 for (Object** current = start; current < end; current++) { | 550 for (Object** current = start; current < end; current++) { |
| 551 if ((*current)->IsHeapObject()) { | 551 if ((*current)->IsHeapObject()) { |
| 552 ASSERT(!Heap::InNewSpace(HeapObject::cast(*current))); | 552 ASSERT(!Heap::InNewSpace(HeapObject::cast(*current))); |
| 553 } | 553 } |
| 554 } | 554 } |
| 555 } | 555 } |
| 556 }; | 556 }; |
| 557 | |
| 558 | |
| 559 static void VerifyNonPointerSpacePointers() { | |
|
Erik Corry
2009/05/07 09:53:01
If you move the flag test into this you and put an
Kevin Millikin (Chromium)
2009/05/07 10:24:02
Not a clear win. I actually prefer seeing at the
| |
| 560 // Verify that there are no pointers to new space in spaces where we | |
| 561 // do not expect them. | |
| 562 VerifyNonPointerSpacePointersVisitor v; | |
| 563 HeapObjectIterator code_it(Heap::code_space()); | |
| 564 while (code_it.has_next()) { | |
| 565 HeapObject* object = code_it.next(); | |
| 566 if (object->IsCode()) { | |
| 567 Code::cast(object)->ConvertICTargetsFromAddressToObject(); | |
| 568 object->Iterate(&v); | |
| 569 Code::cast(object)->ConvertICTargetsFromObjectToAddress(); | |
| 570 } else { | |
| 571 // If we find non-code objects in code space (e.g., free list | |
| 572 // nodes) we want to verify them as well. | |
| 573 object->Iterate(&v); | |
| 574 } | |
| 575 } | |
| 576 | |
| 577 HeapObjectIterator data_it(Heap::old_data_space()); | |
| 578 while (data_it.has_next()) data_it.next()->Iterate(&v); | |
| 579 } | |
| 557 #endif | 580 #endif |
| 558 | 581 |
| 559 void Heap::Scavenge() { | 582 void Heap::Scavenge() { |
| 560 #ifdef DEBUG | 583 #ifdef DEBUG |
| 561 if (FLAG_enable_slow_asserts) { | 584 if (FLAG_enable_slow_asserts) VerifyNonPointerSpacePointers(); |
| 562 VerifyNonPointerSpacePointersVisitor v; | |
| 563 HeapObjectIterator it(code_space_); | |
| 564 while (it.has_next()) { | |
| 565 HeapObject* object = it.next(); | |
| 566 if (object->IsCode()) { | |
| 567 Code::cast(object)->ConvertICTargetsFromAddressToObject(); | |
| 568 } | |
| 569 object->Iterate(&v); | |
| 570 if (object->IsCode()) { | |
| 571 Code::cast(object)->ConvertICTargetsFromObjectToAddress(); | |
| 572 } | |
| 573 } | |
| 574 } | |
| 575 #endif | 585 #endif |
| 576 | 586 |
| 577 gc_state_ = SCAVENGE; | 587 gc_state_ = SCAVENGE; |
| 578 | 588 |
| 579 // Implements Cheney's copying algorithm | 589 // Implements Cheney's copying algorithm |
| 580 LOG(ResourceEvent("scavenge", "begin")); | 590 LOG(ResourceEvent("scavenge", "begin")); |
| 581 | 591 |
| 582 scavenge_count_++; | 592 scavenge_count_++; |
| 583 if (new_space_.Capacity() < new_space_.MaximumCapacity() && | 593 if (new_space_.Capacity() < new_space_.MaximumCapacity() && |
| 584 scavenge_count_ > new_space_growth_limit_) { | 594 scavenge_count_ > new_space_growth_limit_) { |
| (...skipping 2802 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3387 #ifdef DEBUG | 3397 #ifdef DEBUG |
| 3388 bool Heap::GarbageCollectionGreedyCheck() { | 3398 bool Heap::GarbageCollectionGreedyCheck() { |
| 3389 ASSERT(FLAG_gc_greedy); | 3399 ASSERT(FLAG_gc_greedy); |
| 3390 if (Bootstrapper::IsActive()) return true; | 3400 if (Bootstrapper::IsActive()) return true; |
| 3391 if (disallow_allocation_failure()) return true; | 3401 if (disallow_allocation_failure()) return true; |
| 3392 return CollectGarbage(0, NEW_SPACE); | 3402 return CollectGarbage(0, NEW_SPACE); |
| 3393 } | 3403 } |
| 3394 #endif | 3404 #endif |
| 3395 | 3405 |
| 3396 } } // namespace v8::internal | 3406 } } // namespace v8::internal |
| OLD | NEW |