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

Side by Side 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, 2 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 unified diff | Download patch
« no previous file with comments | « runtime/vm/exceptions.cc ('k') | runtime/vm/pages.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/heap.h" 5 #include "vm/heap.h"
6 6
7 #include "platform/assert.h" 7 #include "platform/assert.h"
8 #include "platform/utils.h" 8 #include "platform/utils.h"
9 #include "vm/flags.h" 9 #include "vm/flags.h"
10 #include "vm/isolate.h" 10 #include "vm/isolate.h"
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 82
83 uword Heap::AllocateOld(intptr_t size, HeapPage::PageType type) { 83 uword Heap::AllocateOld(intptr_t size, HeapPage::PageType type) {
84 ASSERT(Thread::Current()->no_safepoint_scope_depth() == 0); 84 ASSERT(Thread::Current()->no_safepoint_scope_depth() == 0);
85 uword addr = old_space_.TryAllocate(size, type); 85 uword addr = old_space_.TryAllocate(size, type);
86 if (addr != 0) { 86 if (addr != 0) {
87 return addr; 87 return addr;
88 } 88 }
89 // If we are in the process of running a sweep, wait for the sweeper to free 89 // If we are in the process of running a sweep, wait for the sweeper to free
90 // memory. 90 // memory.
91 Thread* thread = Thread::Current(); 91 Thread* thread = Thread::Current();
92 { 92 if (thread->CanCollectGarbage()) {
93 MonitorLocker ml(old_space_.tasks_lock()); 93 {
94 addr = old_space_.TryAllocate(size, type); 94 MonitorLocker ml(old_space_.tasks_lock());
95 while ((addr == 0) && (old_space_.tasks() > 0)) {
96 ml.WaitWithSafepointCheck(thread);
97 addr = old_space_.TryAllocate(size, type); 95 addr = old_space_.TryAllocate(size, type);
96 while ((addr == 0) && (old_space_.tasks() > 0)) {
97 ml.WaitWithSafepointCheck(thread);
98 addr = old_space_.TryAllocate(size, type);
99 }
98 } 100 }
99 } 101 if (addr != 0) {
100 if (addr != 0) { 102 return addr;
101 return addr; 103 }
102 }
103 if (thread->CanCollectGarbage()) {
104 // All GC tasks finished without allocating successfully. Run a full GC. 104 // All GC tasks finished without allocating successfully. Run a full GC.
105 CollectAllGarbage(); 105 CollectAllGarbage();
106 addr = old_space_.TryAllocate(size, type); 106 addr = old_space_.TryAllocate(size, type);
107 if (addr != 0) { 107 if (addr != 0) {
108 return addr; 108 return addr;
109 } 109 }
110 // Wait for all of the concurrent tasks to finish before giving up. 110 // Wait for all of the concurrent tasks to finish before giving up.
111 { 111 {
112 MonitorLocker ml(old_space_.tasks_lock()); 112 MonitorLocker ml(old_space_.tasks_lock());
113 addr = old_space_.TryAllocate(size, type); 113 addr = old_space_.TryAllocate(size, type);
(...skipping 747 matching lines...) Expand 10 before | Expand all | Expand 10 after
861 Dart::vm_isolate()->heap()->WriteProtect(false); 861 Dart::vm_isolate()->heap()->WriteProtect(false);
862 } 862 }
863 863
864 864
865 WritableVMIsolateScope::~WritableVMIsolateScope() { 865 WritableVMIsolateScope::~WritableVMIsolateScope() {
866 ASSERT(Dart::vm_isolate()->heap()->UsedInWords(Heap::kNew) == 0); 866 ASSERT(Dart::vm_isolate()->heap()->UsedInWords(Heap::kNew) == 0);
867 Dart::vm_isolate()->heap()->WriteProtect(true); 867 Dart::vm_isolate()->heap()->WriteProtect(true);
868 } 868 }
869 869
870 } // namespace dart 870 } // namespace dart
OLDNEW
« 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