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

Unified Diff: runtime/vm/heap.cc

Issue 2609643002: 1. Avoid potential dead lock due to lock-order-inversion (Closed)
Patch Set: Created 4 years 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 | « no previous file | runtime/vm/pages.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 da9e6790dab711e48223c9b4c9528e6d4d02be9b..23a380b5f90a9c1415a487722e8b4e32319a40cb 100644
--- a/runtime/vm/heap.cc
+++ b/runtime/vm/heap.cc
@@ -88,13 +88,13 @@ uword Heap::AllocateOld(intptr_t size, HeapPage::PageType type) {
Thread* thread = Thread::Current();
if (thread->CanCollectGarbage()) {
{
Vyacheslav Egorov (Google) 2016/12/31 11:09:48 this block of code is repeated twice - maybe make
siva 2017/01/05 19:06:10 Done.
+ // Wait for any GC tasks that are in progress.
MonitorLocker ml(old_space_.tasks_lock());
- addr = old_space_.TryAllocate(size, type);
- while ((addr == 0) && (old_space_.tasks() > 0)) {
+ while (old_space_.tasks() > 0) {
ml.WaitWithSafepointCheck(thread);
- addr = old_space_.TryAllocate(size, type);
}
}
+ addr = old_space_.TryAllocate(size, type);
if (addr != 0) {
return addr;
}
@@ -107,12 +107,11 @@ uword Heap::AllocateOld(intptr_t size, HeapPage::PageType type) {
// Wait for all of the concurrent tasks to finish before giving up.
{
MonitorLocker ml(old_space_.tasks_lock());
- addr = old_space_.TryAllocate(size, type);
- while ((addr == 0) && (old_space_.tasks() > 0)) {
+ while (old_space_.tasks() > 0) {
ml.WaitWithSafepointCheck(thread);
- addr = old_space_.TryAllocate(size, type);
}
}
+ addr = old_space_.TryAllocate(size, type);
if (addr != 0) {
return addr;
}
« no previous file with comments | « no previous file | runtime/vm/pages.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698