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

Side by Side Diff: runtime/vm/dart_api_state.cc

Issue 2481873005: clang-format runtime/vm (Closed)
Patch Set: Merge Created 4 years, 1 month 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/dart_api_state.h ('k') | runtime/vm/dart_entry.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) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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/dart_api_state.h" 5 #include "vm/dart_api_state.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/heap.h" 9 #include "vm/heap.h"
10 #include "vm/isolate.h" 10 #include "vm/isolate.h"
11 #include "vm/lockers.h" 11 #include "vm/lockers.h"
12 #include "vm/thread.h" 12 #include "vm/thread.h"
13 #include "vm/timeline.h" 13 #include "vm/timeline.h"
14 14
15 namespace dart { 15 namespace dart {
16 16
17 BackgroundFinalizer::BackgroundFinalizer(Isolate* isolate, 17 BackgroundFinalizer::BackgroundFinalizer(Isolate* isolate,
18 FinalizationQueue* queue) : 18 FinalizationQueue* queue)
19 isolate_(isolate), 19 : isolate_(isolate), queue_(queue) {
20 queue_(queue) {
21 ASSERT(FLAG_background_finalization); 20 ASSERT(FLAG_background_finalization);
22 PageSpace* old_space = isolate->heap()->old_space(); 21 PageSpace* old_space = isolate->heap()->old_space();
23 MonitorLocker ml(old_space->tasks_lock()); 22 MonitorLocker ml(old_space->tasks_lock());
24 old_space->set_tasks(old_space->tasks() + 1); 23 old_space->set_tasks(old_space->tasks() + 1);
25 } 24 }
26 25
27 26
28 void BackgroundFinalizer::Run() { 27 void BackgroundFinalizer::Run() {
29 bool result = Thread::EnterIsolateAsHelper(isolate_, 28 bool result = Thread::EnterIsolateAsHelper(isolate_, Thread::kFinalizerTask);
30 Thread::kFinalizerTask);
31 ASSERT(result); 29 ASSERT(result);
32 30
33 { 31 {
34 Thread* thread = Thread::Current(); 32 Thread* thread = Thread::Current();
35 TIMELINE_FUNCTION_GC_DURATION(thread, "BackgroundFinalization"); 33 TIMELINE_FUNCTION_GC_DURATION(thread, "BackgroundFinalization");
36 TransitionVMToNative transition(thread); 34 TransitionVMToNative transition(thread);
37 for (intptr_t i = 0; i < queue_->length(); i++) { 35 for (intptr_t i = 0; i < queue_->length(); i++) {
38 FinalizablePersistentHandle* handle = (*queue_)[i]; 36 FinalizablePersistentHandle* handle = (*queue_)[i];
39 FinalizablePersistentHandle::Finalize(isolate_, handle); 37 FinalizablePersistentHandle::Finalize(isolate_, handle);
40 } 38 }
41 delete queue_; 39 delete queue_;
42 } 40 }
43 41
44 // Exit isolate cleanly *before* notifying it, to avoid shutdown race. 42 // Exit isolate cleanly *before* notifying it, to avoid shutdown race.
45 Thread::ExitIsolateAsHelper(); 43 Thread::ExitIsolateAsHelper();
46 44
47 { 45 {
48 PageSpace* old_space = isolate_->heap()->old_space(); 46 PageSpace* old_space = isolate_->heap()->old_space();
49 MonitorLocker ml(old_space->tasks_lock()); 47 MonitorLocker ml(old_space->tasks_lock());
50 old_space->set_tasks(old_space->tasks() - 1); 48 old_space->set_tasks(old_space->tasks() - 1);
51 ml.NotifyAll(); 49 ml.NotifyAll();
52 } 50 }
53 } 51 }
54 52
55 } // namespace dart 53 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/dart_api_state.h ('k') | runtime/vm/dart_entry.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698