| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/scavenger.h" | 5 #include "vm/scavenger.h" |
| 6 | 6 |
| 7 #include "vm/dart.h" | 7 #include "vm/dart.h" |
| 8 #include "vm/dart_api_state.h" | 8 #include "vm/dart_api_state.h" |
| 9 #include "vm/isolate.h" | 9 #include "vm/isolate.h" |
| 10 #include "vm/lockers.h" | 10 #include "vm/lockers.h" |
| (...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 601 EnqueueWeakProperty(cur_weak); | 601 EnqueueWeakProperty(cur_weak); |
| 602 } | 602 } |
| 603 // Advance to next weak property in the queue. | 603 // Advance to next weak property in the queue. |
| 604 cur_weak = reinterpret_cast<RawWeakProperty*>(next_weak); | 604 cur_weak = reinterpret_cast<RawWeakProperty*>(next_weak); |
| 605 } | 605 } |
| 606 } | 606 } |
| 607 } | 607 } |
| 608 } | 608 } |
| 609 | 609 |
| 610 void Scavenger::UpdateMaxHeapCapacity() { | 610 void Scavenger::UpdateMaxHeapCapacity() { |
| 611 #if !defined(PRODUCT) |
| 611 if (heap_ == NULL) { | 612 if (heap_ == NULL) { |
| 612 // Some unit tests. | 613 // Some unit tests. |
| 613 return; | 614 return; |
| 614 } | 615 } |
| 615 ASSERT(to_ != NULL); | 616 ASSERT(to_ != NULL); |
| 616 ASSERT(heap_ != NULL); | 617 ASSERT(heap_ != NULL); |
| 617 Isolate* isolate = heap_->isolate(); | 618 Isolate* isolate = heap_->isolate(); |
| 618 ASSERT(isolate != NULL); | 619 ASSERT(isolate != NULL); |
| 619 isolate->GetHeapNewCapacityMaxMetric()->SetValue(to_->size_in_words() * | 620 isolate->GetHeapNewCapacityMaxMetric()->SetValue(to_->size_in_words() * |
| 620 kWordSize); | 621 kWordSize); |
| 622 #endif // !defined(PRODUCT) |
| 621 } | 623 } |
| 622 | 624 |
| 623 void Scavenger::UpdateMaxHeapUsage() { | 625 void Scavenger::UpdateMaxHeapUsage() { |
| 626 #if !defined(PRODUCT) |
| 624 if (heap_ == NULL) { | 627 if (heap_ == NULL) { |
| 625 // Some unit tests. | 628 // Some unit tests. |
| 626 return; | 629 return; |
| 627 } | 630 } |
| 628 ASSERT(to_ != NULL); | 631 ASSERT(to_ != NULL); |
| 629 ASSERT(heap_ != NULL); | 632 ASSERT(heap_ != NULL); |
| 630 Isolate* isolate = heap_->isolate(); | 633 Isolate* isolate = heap_->isolate(); |
| 631 ASSERT(isolate != NULL); | 634 ASSERT(isolate != NULL); |
| 632 isolate->GetHeapNewUsedMaxMetric()->SetValue(UsedInWords() * kWordSize); | 635 isolate->GetHeapNewUsedMaxMetric()->SetValue(UsedInWords() * kWordSize); |
| 636 #endif // !defined(PRODUCT) |
| 633 } | 637 } |
| 634 | 638 |
| 635 void Scavenger::EnqueueWeakProperty(RawWeakProperty* raw_weak) { | 639 void Scavenger::EnqueueWeakProperty(RawWeakProperty* raw_weak) { |
| 636 ASSERT(raw_weak->IsHeapObject()); | 640 ASSERT(raw_weak->IsHeapObject()); |
| 637 ASSERT(raw_weak->IsNewObject()); | 641 ASSERT(raw_weak->IsNewObject()); |
| 638 ASSERT(raw_weak->IsWeakProperty()); | 642 ASSERT(raw_weak->IsWeakProperty()); |
| 639 #if defined(DEBUG) | 643 #if defined(DEBUG) |
| 640 uword raw_addr = RawObject::ToAddr(raw_weak); | 644 uword raw_addr = RawObject::ToAddr(raw_weak); |
| 641 uword header = *reinterpret_cast<uword*>(raw_addr); | 645 uword header = *reinterpret_cast<uword*>(raw_addr); |
| 642 ASSERT(!IsForwarding(header)); | 646 ASSERT(!IsForwarding(header)); |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 915 } | 919 } |
| 916 | 920 |
| 917 Scavenge(); | 921 Scavenge(); |
| 918 | 922 |
| 919 // It is possible for objects to stay in the new space | 923 // It is possible for objects to stay in the new space |
| 920 // if the VM cannot create more pages for these objects. | 924 // if the VM cannot create more pages for these objects. |
| 921 ASSERT((UsedInWords() == 0) || failed_to_promote_); | 925 ASSERT((UsedInWords() == 0) || failed_to_promote_); |
| 922 } | 926 } |
| 923 | 927 |
| 924 } // namespace dart | 928 } // namespace dart |
| OLD | NEW |