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

Unified Diff: runtime/vm/heap.cc

Issue 2363823002: Fix for issue 27380 - VM stuck in deadlock with background finalization and background compiler thr… (Closed)
Patch Set: Created 4 years, 3 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/exceptions.cc ('k') | runtime/vm/pages.h » ('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 fd22740abb4cf19fd94ec30ba3dd59720b629247..c3353d276231028b1ad6b2c3730b12b01c241163 100644
--- a/runtime/vm/heap.cc
+++ b/runtime/vm/heap.cc
@@ -89,18 +89,18 @@ uword Heap::AllocateOld(intptr_t size, HeapPage::PageType type) {
// If we are in the process of running a sweep, wait for the sweeper to free
// memory.
Thread* thread = Thread::Current();
- {
- MonitorLocker ml(old_space_.tasks_lock());
- addr = old_space_.TryAllocate(size, type);
- while ((addr == 0) && (old_space_.tasks() > 0)) {
- ml.WaitWithSafepointCheck(thread);
+ if (thread->CanCollectGarbage()) {
+ {
+ MonitorLocker ml(old_space_.tasks_lock());
addr = old_space_.TryAllocate(size, type);
+ while ((addr == 0) && (old_space_.tasks() > 0)) {
+ ml.WaitWithSafepointCheck(thread);
+ addr = old_space_.TryAllocate(size, type);
+ }
+ }
+ if (addr != 0) {
+ return addr;
}
- }
- if (addr != 0) {
- return addr;
- }
- if (thread->CanCollectGarbage()) {
// All GC tasks finished without allocating successfully. Run a full GC.
CollectAllGarbage();
addr = old_space_.TryAllocate(size, type);
« no previous file with comments | « runtime/vm/exceptions.cc ('k') | runtime/vm/pages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698