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

Unified Diff: runtime/vm/heap.cc

Issue 2998663002: Reverts CLs related to the TLAB due to heap exhaustion. (Closed)
Patch Set: 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
« no previous file with comments | « runtime/vm/heap.h ('k') | runtime/vm/isolate.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/heap.cc
diff --git a/runtime/vm/heap.cc b/runtime/vm/heap.cc
index 70a34f2e325cee60f511f9601aaa712d8f2808fe..7cdbf210ae2a50e27149b688ce83e2ad31dbf145 100644
--- a/runtime/vm/heap.cc
+++ b/runtime/vm/heap.cc
@@ -58,72 +58,23 @@ Heap::~Heap() {
}
}
-void Heap::FillRemainingTLAB(Thread* thread) {
- uword start = thread->top();
- uword end = thread->end();
- ASSERT(end >= start);
- intptr_t size = end - start;
- ASSERT(Utils::IsAligned(size, kObjectAlignment));
- 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);
- thread->set_top(0);
- thread->set_end(0);
-}
-
-intptr_t Heap::CalculateTLABSize() {
- intptr_t size = new_space_.end() - new_space_.top();
- return Utils::RoundDown(size, kObjectAlignment);
-}
-
uword Heap::AllocateNew(intptr_t size) {
ASSERT(Thread::Current()->no_safepoint_scope_depth() == 0);
// Currently, only the Dart thread may allocate in new space.
isolate()->AssertCurrentThreadIsMutator();
Thread* thread = Thread::Current();
uword addr = new_space_.TryAllocateInTLAB(thread, size);
- if (addr != 0) {
- return addr;
- }
-
- intptr_t tlab_size = CalculateTLABSize();
- if ((tlab_size > 0) && (size > tlab_size)) {
- return AllocateOld(size, HeapPage::kData);
- }
-
- AbandonRemainingTLAB(thread);
- 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);
- return addr;
- }
- }
-
- ASSERT(!thread->HasActiveTLAB());
-
- // 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.
- CollectGarbage(kNew);
- tlab_size = CalculateTLABSize();
- uword tlab_top = new_space_.TryAllocateNewTLAB(thread, tlab_size);
- if (tlab_top != 0) {
+ if (addr == 0) {
+ // 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.
+ CollectGarbage(kNew);
addr = new_space_.TryAllocateInTLAB(thread, size);
- // It is possible a GC doesn't clear enough space.
- // In that case, we must fall through and allocate into old space.
- if (addr != 0) {
- return addr;
+ if (addr == 0) {
+ return AllocateOld(size, HeapPage::kData);
}
}
- return AllocateOld(size, HeapPage::kData);
+ return addr;
}
uword Heap::AllocateOld(intptr_t size, HeapPage::PageType type) {
@@ -625,7 +576,7 @@ 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_
- new_space_.MakeNewSpaceIterable();
+ new_space_.FlushTLS();
ObjectSet* allocated_set =
CreateAllocatedObjectSet(stack_zone.GetZone(), mark_expectation);
« no previous file with comments | « runtime/vm/heap.h ('k') | runtime/vm/isolate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698