| 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 Heap::~Heap() { | 51 Heap::~Heap() { |
| 52 delete barrier_; | 52 delete barrier_; |
| 53 delete barrier_done_; | 53 delete barrier_done_; |
| 54 | 54 |
| 55 for (int sel = 0; sel < kNumWeakSelectors; sel++) { | 55 for (int sel = 0; sel < kNumWeakSelectors; sel++) { |
| 56 delete new_weak_tables_[sel]; | 56 delete new_weak_tables_[sel]; |
| 57 delete old_weak_tables_[sel]; | 57 delete old_weak_tables_[sel]; |
| 58 } | 58 } |
| 59 } | 59 } |
| 60 | 60 |
| 61 void Heap::FillRemainingTLAB(Thread* thread) { | 61 void Heap::MakeTLABIterable(Thread* thread) { |
| 62 uword start = thread->top(); | 62 uword start = thread->top(); |
| 63 uword end = thread->end(); | 63 uword end = thread->end(); |
| 64 ASSERT(end >= start); | 64 ASSERT(end >= start); |
| 65 intptr_t size = end - start; | 65 intptr_t size = end - start; |
| 66 ASSERT(Utils::IsAligned(size, kObjectAlignment)); | 66 ASSERT(Utils::IsAligned(size, kObjectAlignment)); |
| 67 if (size >= kObjectAlignment) { | 67 if (size >= kObjectAlignment) { |
| 68 FreeListElement::AsElement(start, size); | 68 FreeListElement::AsElement(start, size); |
| 69 ASSERT(RawObject::FromAddr(start)->Size() == size); | 69 ASSERT(RawObject::FromAddr(start)->Size() == size); |
| 70 ASSERT((start + size) == new_space_.top()); | |
| 71 } | 70 } |
| 72 } | 71 } |
| 73 | 72 |
| 74 void Heap::AbandonRemainingTLAB(Thread* thread) { | 73 void Heap::AbandonRemainingTLAB(Thread* thread) { |
| 75 FillRemainingTLAB(thread); | 74 MakeTLABIterable(thread); |
| 76 thread->set_top(0); | 75 thread->set_top(0); |
| 77 thread->set_end(0); | 76 thread->set_end(0); |
| 78 } | 77 } |
| 79 | 78 |
| 80 intptr_t Heap::CalculateTLABSize() { | 79 intptr_t Heap::CalculateTLABSize() { |
| 81 intptr_t size = new_space_.end() - new_space_.top(); | 80 intptr_t size = new_space_.end() - new_space_.top(); |
| 82 return Utils::RoundDown(size, kObjectAlignment); | 81 return Utils::RoundDown(size, kObjectAlignment); |
| 83 } | 82 } |
| 84 | 83 |
| 85 uword Heap::AllocateNew(intptr_t size) { | 84 uword Heap::AllocateNew(intptr_t size) { |
| (...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 623 | 622 |
| 624 bool Heap::VerifyGC(MarkExpectation mark_expectation) const { | 623 bool Heap::VerifyGC(MarkExpectation mark_expectation) const { |
| 625 StackZone stack_zone(Thread::Current()); | 624 StackZone stack_zone(Thread::Current()); |
| 626 | 625 |
| 627 // Change the new space's top_ with the more up-to-date thread's view of top_ | 626 // Change the new space's top_ with the more up-to-date thread's view of top_ |
| 628 new_space_.MakeNewSpaceIterable(); | 627 new_space_.MakeNewSpaceIterable(); |
| 629 | 628 |
| 630 ObjectSet* allocated_set = | 629 ObjectSet* allocated_set = |
| 631 CreateAllocatedObjectSet(stack_zone.GetZone(), mark_expectation); | 630 CreateAllocatedObjectSet(stack_zone.GetZone(), mark_expectation); |
| 632 VerifyPointersVisitor visitor(isolate(), allocated_set); | 631 VerifyPointersVisitor visitor(isolate(), allocated_set); |
| 632 |
| 633 VisitObjectPointers(&visitor); | 633 VisitObjectPointers(&visitor); |
| 634 | 634 |
| 635 // Only returning a value so that Heap::Validate can be called from an ASSERT. | 635 // Only returning a value so that Heap::Validate can be called from an ASSERT. |
| 636 return true; | 636 return true; |
| 637 } | 637 } |
| 638 | 638 |
| 639 void Heap::PrintSizes() const { | 639 void Heap::PrintSizes() const { |
| 640 OS::PrintErr( | 640 OS::PrintErr( |
| 641 "New space (%" Pd64 "k of %" Pd64 | 641 "New space (%" Pd64 "k of %" Pd64 |
| 642 "k) " | 642 "k) " |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 899 : StackResource(thread) { | 899 : StackResource(thread) { |
| 900 Dart::vm_isolate()->heap()->WriteProtect(false); | 900 Dart::vm_isolate()->heap()->WriteProtect(false); |
| 901 } | 901 } |
| 902 | 902 |
| 903 WritableVMIsolateScope::~WritableVMIsolateScope() { | 903 WritableVMIsolateScope::~WritableVMIsolateScope() { |
| 904 ASSERT(Dart::vm_isolate()->heap()->UsedInWords(Heap::kNew) == 0); | 904 ASSERT(Dart::vm_isolate()->heap()->UsedInWords(Heap::kNew) == 0); |
| 905 Dart::vm_isolate()->heap()->WriteProtect(true); | 905 Dart::vm_isolate()->heap()->WriteProtect(true); |
| 906 } | 906 } |
| 907 | 907 |
| 908 } // namespace dart | 908 } // namespace dart |
| OLD | NEW |