OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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/heap.h" | 5 #include "vm/heap.h" |
6 | 6 |
7 #include "platform/assert.h" | 7 #include "platform/assert.h" |
8 #include "platform/utils.h" | 8 #include "platform/utils.h" |
9 #include "vm/flags.h" | 9 #include "vm/flags.h" |
10 #include "vm/isolate.h" | 10 #include "vm/isolate.h" |
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
511 intptr_t max_external_words) { | 511 intptr_t max_external_words) { |
512 ASSERT(isolate->heap() == NULL); | 512 ASSERT(isolate->heap() == NULL); |
513 Heap* heap = new Heap(isolate, | 513 Heap* heap = new Heap(isolate, |
514 max_new_gen_words, | 514 max_new_gen_words, |
515 max_old_gen_words, | 515 max_old_gen_words, |
516 max_external_words); | 516 max_external_words); |
517 isolate->set_heap(heap); | 517 isolate->set_heap(heap); |
518 } | 518 } |
519 | 519 |
520 | 520 |
521 void Heap::GetMergedAddressRange(uword* start, uword* end) const { | 521 void Heap::AddRegionsToObjectSet(ObjectSet* set) const { |
522 if (new_space_.CapacityInWords() != 0) { | 522 new_space_.AddRegionsToObjectSet(set); |
523 uword new_start; | 523 old_space_.AddRegionsToObjectSet(set); |
524 uword new_end; | |
525 new_space_.StartEndAddress(&new_start, &new_end); | |
526 *start = Utils::Minimum(new_start, *start); | |
527 *end = Utils::Maximum(new_end, *end); | |
528 } | |
529 if (old_space_.CapacityInWords() != 0) { | |
530 uword old_start; | |
531 uword old_end; | |
532 old_space_.StartEndAddress(&old_start, &old_end); | |
533 *start = Utils::Minimum(old_start, *start); | |
534 *end = Utils::Maximum(old_end, *end); | |
535 } | |
536 ASSERT(*start <= *end); | |
537 } | 524 } |
538 | 525 |
539 | 526 |
540 ObjectSet* Heap::CreateAllocatedObjectSet( | 527 ObjectSet* Heap::CreateAllocatedObjectSet( |
| 528 Zone* zone, |
541 MarkExpectation mark_expectation) const { | 529 MarkExpectation mark_expectation) const { |
542 uword start = static_cast<uword>(-1); | 530 ObjectSet* allocated_set = new(zone) ObjectSet(zone); |
543 uword end = 0; | |
544 Isolate* vm_isolate = Dart::vm_isolate(); | |
545 vm_isolate->heap()->GetMergedAddressRange(&start, &end); | |
546 this->GetMergedAddressRange(&start, &end); | |
547 | 531 |
548 ObjectSet* allocated_set = new ObjectSet(start, end); | 532 this->AddRegionsToObjectSet(allocated_set); |
549 { | 533 { |
550 VerifyObjectVisitor object_visitor( | 534 VerifyObjectVisitor object_visitor( |
551 isolate(), allocated_set, mark_expectation); | 535 isolate(), allocated_set, mark_expectation); |
552 this->VisitObjects(&object_visitor); | 536 this->VisitObjects(&object_visitor); |
553 } | 537 } |
| 538 |
| 539 Isolate* vm_isolate = Dart::vm_isolate(); |
| 540 vm_isolate->heap()->AddRegionsToObjectSet(allocated_set); |
554 { | 541 { |
555 // VM isolate heap is premarked. | 542 // VM isolate heap is premarked. |
556 VerifyObjectVisitor vm_object_visitor( | 543 VerifyObjectVisitor vm_object_visitor( |
557 isolate(), allocated_set, kRequireMarked); | 544 isolate(), allocated_set, kRequireMarked); |
558 vm_isolate->heap()->VisitObjects(&vm_object_visitor); | 545 vm_isolate->heap()->VisitObjects(&vm_object_visitor); |
559 } | 546 } |
| 547 |
560 return allocated_set; | 548 return allocated_set; |
561 } | 549 } |
562 | 550 |
563 | 551 |
564 bool Heap::Verify(MarkExpectation mark_expectation) const { | 552 bool Heap::Verify(MarkExpectation mark_expectation) const { |
565 // TODO(27373): Remove this test when the issue is fixed. | |
566 #if defined(ARCH_IS_64_BIT) | |
567 if ((Dart::snapshot_kind() == Snapshot::kAppNoJIT) || | |
568 (Dart::snapshot_kind() == Snapshot::kAppWithJIT)) { | |
569 return true; | |
570 } | |
571 #endif | |
572 HeapIterationScope heap_iteration_scope; | 553 HeapIterationScope heap_iteration_scope; |
573 return VerifyGC(mark_expectation); | 554 return VerifyGC(mark_expectation); |
574 } | 555 } |
575 | 556 |
576 | 557 |
577 bool Heap::VerifyGC(MarkExpectation mark_expectation) const { | 558 bool Heap::VerifyGC(MarkExpectation mark_expectation) const { |
578 ObjectSet* allocated_set = CreateAllocatedObjectSet(mark_expectation); | 559 StackZone stack_zone(Thread::Current()); |
| 560 ObjectSet* allocated_set = CreateAllocatedObjectSet(stack_zone.GetZone(), |
| 561 mark_expectation); |
579 VerifyPointersVisitor visitor(isolate(), allocated_set); | 562 VerifyPointersVisitor visitor(isolate(), allocated_set); |
580 VisitObjectPointers(&visitor); | 563 VisitObjectPointers(&visitor); |
581 delete allocated_set; | 564 |
582 // Only returning a value so that Heap::Validate can be called from an ASSERT. | 565 // Only returning a value so that Heap::Validate can be called from an ASSERT. |
583 return true; | 566 return true; |
584 } | 567 } |
585 | 568 |
586 | 569 |
587 void Heap::PrintSizes() const { | 570 void Heap::PrintSizes() const { |
588 OS::PrintErr("New space (%" Pd64 "k of %" Pd64 "k) " | 571 OS::PrintErr("New space (%" Pd64 "k of %" Pd64 "k) " |
589 "Old space (%" Pd64 "k of %" Pd64 "k)\n", | 572 "Old space (%" Pd64 "k of %" Pd64 "k)\n", |
590 (UsedInWords(kNew) / KBInWords), | 573 (UsedInWords(kNew) / KBInWords), |
591 (CapacityInWords(kNew) / KBInWords), | 574 (CapacityInWords(kNew) / KBInWords), |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
878 Dart::vm_isolate()->heap()->WriteProtect(false); | 861 Dart::vm_isolate()->heap()->WriteProtect(false); |
879 } | 862 } |
880 | 863 |
881 | 864 |
882 WritableVMIsolateScope::~WritableVMIsolateScope() { | 865 WritableVMIsolateScope::~WritableVMIsolateScope() { |
883 ASSERT(Dart::vm_isolate()->heap()->UsedInWords(Heap::kNew) == 0); | 866 ASSERT(Dart::vm_isolate()->heap()->UsedInWords(Heap::kNew) == 0); |
884 Dart::vm_isolate()->heap()->WriteProtect(true); | 867 Dart::vm_isolate()->heap()->WriteProtect(true); |
885 } | 868 } |
886 | 869 |
887 } // namespace dart | 870 } // namespace dart |
OLD | NEW |