| Index: runtime/vm/heap.cc
|
| diff --git a/runtime/vm/heap.cc b/runtime/vm/heap.cc
|
| index eccf14fe5827583fa16be668d843e1e80dd5a389..882436724e7f5ea4464dd26ec752a0d13f27ca6d 100644
|
| --- a/runtime/vm/heap.cc
|
| +++ b/runtime/vm/heap.cc
|
| @@ -57,7 +57,7 @@ Heap::~Heap() {
|
| }
|
| }
|
|
|
| -void Heap::AbandonRemainingTLAB(Thread* thread) {
|
| +void Heap::MakeTLABIterable(Thread* thread) {
|
| uword start = thread->top();
|
| uword end = thread->end();
|
| ASSERT(end >= start);
|
| @@ -69,8 +69,11 @@ void Heap::AbandonRemainingTLAB(Thread* thread) {
|
| if (size >= kObjectAlignment) {
|
| FreeListElement::AsElement(start, size);
|
| ASSERT(RawObject::FromAddr(start)->Size() == size);
|
| - ASSERT((start + size) == new_space_.top());
|
| }
|
| +}
|
| +
|
| +void Heap::AbandonRemainingTLAB(Thread* thread) {
|
| + MakeTLABIterable(thread);
|
| thread->set_top(0);
|
| thread->set_end(0);
|
| }
|
| @@ -96,11 +99,14 @@ uword Heap::AllocateNew(intptr_t size) {
|
| }
|
|
|
| AbandonRemainingTLAB(thread);
|
| +
|
| + // TODO(danunez): Lock for new space here
|
| if (tlab_size > 0) {
|
| uword tlab_top = new_space_.TryAllocateNewTLAB(thread, tlab_size);
|
| if (tlab_top != 0) {
|
| addr = new_space_.TryAllocateInTLAB(thread, size);
|
| ASSERT(addr != 0);
|
| + // TODO(danunez): Unlock for new space here
|
| return addr;
|
| }
|
| }
|
| @@ -110,9 +116,16 @@ uword Heap::AllocateNew(intptr_t size) {
|
| // This call to CollectGarbage might end up "reusing" a collection spawned
|
| // from a different thread and will be racing to allocate the requested
|
| // memory with other threads being released after the collection.
|
| +
|
| + // TODO(danunez): Ensure that once we start collecting garbage, everything
|
| + // stops allocating.
|
| + // Safepoint should be dealing with this, but we need to make sure somehow.
|
| CollectGarbage(kNew);
|
| tlab_size = CalculateTLABSize();
|
| uword tlab_top = new_space_.TryAllocateNewTLAB(thread, tlab_size);
|
| +
|
| + // TODO(danunez): Unlock for new space here. Regardless of the outcome, we
|
| + // don't need the new space.
|
| if (tlab_top != 0) {
|
| addr = new_space_.TryAllocateInTLAB(thread, size);
|
| // It is possible a GC doesn't clear enough space.
|
| @@ -603,14 +616,14 @@ bool Heap::VerifyGC(MarkExpectation mark_expectation) const {
|
| StackZone stack_zone(Thread::Current());
|
|
|
| // Change the new space's top_ with the more up-to-date thread's view of top_
|
| - uword saved_top = new_space_.FlushTLS();
|
| + new_space_.FlushTLS();
|
|
|
| ObjectSet* allocated_set =
|
| CreateAllocatedObjectSet(stack_zone.GetZone(), mark_expectation);
|
| VerifyPointersVisitor visitor(isolate(), allocated_set);
|
| + // TODO(danunez): Need to lock and unlock for new space here.
|
| VisitObjectPointers(&visitor);
|
|
|
| - new_space_.UnflushTLS(saved_top);
|
| // Only returning a value so that Heap::Validate can be called from an ASSERT.
|
| return true;
|
| }
|
|
|