Index: runtime/vm/heap.cc |
=================================================================== |
--- runtime/vm/heap.cc (revision 39568) |
+++ runtime/vm/heap.cc (working copy) |
@@ -8,6 +8,7 @@ |
#include "platform/utils.h" |
#include "vm/flags.h" |
#include "vm/isolate.h" |
+#include "vm/lockers.h" |
#include "vm/object.h" |
#include "vm/object_set.h" |
#include "vm/os.h" |
@@ -81,12 +82,22 @@ |
ASSERT(isolate()->no_gc_scope_depth() == 0); |
uword addr = old_space_->TryAllocate(size, type); |
if (addr == 0) { |
- CollectAllGarbage(); |
- addr = old_space_->TryAllocate(size, type, PageSpace::kForceGrowth); |
+ { |
+ MonitorLocker ml(old_space_->tasks_lock()); |
+ addr = old_space_->TryAllocate(size, type); |
+ while ((addr == 0) && (old_space_->tasks())) { |
koda
2014/08/26 23:34:48
Add missing "> 0" (or, per my other comment, "has_
Ivan Posva
2014/08/27 01:00:22
Uiuiuiui! That should not have happened.
|
+ ml.Wait(); |
+ addr = old_space_->TryAllocate(size, type); |
+ } |
+ } |
if (addr == 0) { |
- OS::PrintErr("Exhausted heap space, trying to allocate %" Pd " bytes.\n", |
- size); |
- return 0; |
+ CollectAllGarbage(); |
+ addr = old_space_->TryAllocate(size, type, PageSpace::kForceGrowth); |
koda
2014/08/26 23:34:48
Explain why there's no point in waiting for sweepe
Ivan Posva
2014/08/27 01:00:22
We should be waiting for sweepers here, but I miss
|
+ if (addr == 0) { |
+ OS::PrintErr( |
+ "Exhausted heap space, trying to allocate %" Pd " bytes.\n", size); |
+ return 0; |
+ } |
} |
} |
return addr; |