Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1340)

Unified Diff: runtime/vm/heap.cc

Issue 2992753002: Prepares allocation for proper sync with mutator and bg threads. (Closed)
Patch Set: Adds locking when creating new TLABs Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: runtime/vm/heap.cc
diff --git a/runtime/vm/heap.cc b/runtime/vm/heap.cc
index 70a34f2e325cee60f511f9601aaa712d8f2808fe..c31e008033a5a042c1864c9b8794d9407921584f 100644
--- a/runtime/vm/heap.cc
+++ b/runtime/vm/heap.cc
@@ -58,7 +58,7 @@ Heap::~Heap() {
}
}
-void Heap::FillRemainingTLAB(Thread* thread) {
+void Heap::MakeTLABIterable(Thread* thread) {
uword start = thread->top();
uword end = thread->end();
ASSERT(end >= start);
@@ -67,12 +67,11 @@ void Heap::FillRemainingTLAB(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) {
- FillRemainingTLAB(thread);
+ MakeTLABIterable(thread);
thread->set_top(0);
thread->set_end(0);
}
@@ -112,6 +111,9 @@ 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);
@@ -630,6 +632,7 @@ bool Heap::VerifyGC(MarkExpectation mark_expectation) const {
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.
rmacnak 2017/08/10 18:37:06 This function should already be always running dur
danunez 2017/08/10 20:36:46 Done.
VisitObjectPointers(&visitor);
// Only returning a value so that Heap::Validate can be called from an ASSERT.
« no previous file with comments | « runtime/vm/heap.h ('k') | runtime/vm/scavenger.h » ('j') | runtime/vm/scavenger.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698