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

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

Issue 2012973002: Background finalization. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 6 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
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 17 matching lines...) Expand all
28 28
29 Heap::Heap(Isolate* isolate, 29 Heap::Heap(Isolate* isolate,
30 intptr_t max_new_gen_semi_words, 30 intptr_t max_new_gen_semi_words,
31 intptr_t max_old_gen_words, 31 intptr_t max_old_gen_words,
32 intptr_t max_external_words) 32 intptr_t max_external_words)
33 : isolate_(isolate), 33 : isolate_(isolate),
34 new_space_(this, max_new_gen_semi_words, kNewObjectAlignmentOffset), 34 new_space_(this, max_new_gen_semi_words, kNewObjectAlignmentOffset),
35 old_space_(this, max_old_gen_words, max_external_words), 35 old_space_(this, max_old_gen_words, max_external_words),
36 barrier_(new Monitor()), 36 barrier_(new Monitor()),
37 barrier_done_(new Monitor()), 37 barrier_done_(new Monitor()),
38 finalization_tasks_lock_(new Monitor()),
39 finalization_tasks_(0),
38 read_only_(false), 40 read_only_(false),
39 gc_new_space_in_progress_(false), 41 gc_new_space_in_progress_(false),
40 gc_old_space_in_progress_(false), 42 gc_old_space_in_progress_(false),
41 pretenure_policy_(0) { 43 pretenure_policy_(0) {
42 for (int sel = 0; 44 for (int sel = 0;
43 sel < kNumWeakSelectors; 45 sel < kNumWeakSelectors;
44 sel++) { 46 sel++) {
45 new_weak_tables_[sel] = new WeakTable(); 47 new_weak_tables_[sel] = new WeakTable();
46 old_weak_tables_[sel] = new WeakTable(); 48 old_weak_tables_[sel] = new WeakTable();
47 } 49 }
48 stats_.num_ = 0; 50 stats_.num_ = 0;
49 } 51 }
50 52
51 53
52 Heap::~Heap() { 54 Heap::~Heap() {
53 delete barrier_; 55 delete barrier_;
54 delete barrier_done_; 56 delete barrier_done_;
55 57
56 for (int sel = 0; 58 for (int sel = 0;
57 sel < kNumWeakSelectors; 59 sel < kNumWeakSelectors;
58 sel++) { 60 sel++) {
59 delete new_weak_tables_[sel]; 61 delete new_weak_tables_[sel];
60 delete old_weak_tables_[sel]; 62 delete old_weak_tables_[sel];
61 } 63 }
siva 2016/06/06 21:25:31 delete finalization_tasks_lock_;
rmacnak 2016/06/07 21:36:48 Done.
62 } 64 }
63 65
64 66
65 uword Heap::AllocateNew(intptr_t size) { 67 uword Heap::AllocateNew(intptr_t size) {
66 ASSERT(Thread::Current()->no_safepoint_scope_depth() == 0); 68 ASSERT(Thread::Current()->no_safepoint_scope_depth() == 0);
67 // Currently, only the Dart thread may allocate in new space. 69 // Currently, only the Dart thread may allocate in new space.
68 isolate()->AssertCurrentThreadIsMutator(); 70 isolate()->AssertCurrentThreadIsMutator();
69 uword addr = new_space_.TryAllocate(size); 71 uword addr = new_space_.TryAllocate(size);
70 if (addr == 0) { 72 if (addr == 0) {
71 // This call to CollectGarbage might end up "reusing" a collection spawned 73 // This call to CollectGarbage might end up "reusing" a collection spawned
(...skipping 843 matching lines...) Expand 10 before | Expand all | Expand 10 after
915 Dart::vm_isolate()->heap()->WriteProtect(false); 917 Dart::vm_isolate()->heap()->WriteProtect(false);
916 } 918 }
917 919
918 920
919 WritableVMIsolateScope::~WritableVMIsolateScope() { 921 WritableVMIsolateScope::~WritableVMIsolateScope() {
920 ASSERT(Dart::vm_isolate()->heap()->UsedInWords(Heap::kNew) == 0); 922 ASSERT(Dart::vm_isolate()->heap()->UsedInWords(Heap::kNew) == 0);
921 Dart::vm_isolate()->heap()->WriteProtect(true); 923 Dart::vm_isolate()->heap()->WriteProtect(true);
922 } 924 }
923 925
924 } // namespace dart 926 } // namespace dart
OLDNEW
« runtime/vm/dart_api_state.h ('K') | « runtime/vm/heap.h ('k') | runtime/vm/isolate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698