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

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

Issue 1309033007: Old-gen marking on separate thread (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Address comments. Created 5 years, 3 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) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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/thread.h" 5 #include "vm/thread.h"
6 6
7 #include "vm/growable_array.h" 7 #include "vm/growable_array.h"
8 #include "vm/isolate.h" 8 #include "vm/isolate.h"
9 #include "vm/lockers.h" 9 #include "vm/lockers.h"
10 #include "vm/object.h" 10 #include "vm/object.h"
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 #undef ASSERT_VM_HEAP 126 #undef ASSERT_VM_HEAP
127 127
128 #define INIT_VALUE(type_name, member_name, init_expr, default_init_value) \ 128 #define INIT_VALUE(type_name, member_name, init_expr, default_init_value) \
129 ASSERT(member_name == default_init_value); \ 129 ASSERT(member_name == default_init_value); \
130 member_name = (init_expr); 130 member_name = (init_expr);
131 CACHED_CONSTANTS_LIST(INIT_VALUE) 131 CACHED_CONSTANTS_LIST(INIT_VALUE)
132 #undef INIT_VALUE 132 #undef INIT_VALUE
133 } 133 }
134 134
135 135
136 void Thread::Schedule(Isolate* isolate) { 136 void Thread::Schedule(Isolate* isolate, bool bypass_safepoint) {
137 State st; 137 State st;
138 if (isolate->thread_registry()->RestoreStateTo(this, &st)) { 138 if (isolate->thread_registry()->RestoreStateTo(this, &st, bypass_safepoint)) {
139 ASSERT(isolate->thread_registry()->Contains(this)); 139 ASSERT(isolate->thread_registry()->Contains(this));
140 state_ = st; 140 state_ = st;
141 } 141 }
142 } 142 }
143 143
144 144
145 void Thread::Unschedule() { 145 void Thread::Unschedule(bool bypass_safepoint) {
146 ThreadRegistry* reg = isolate_->thread_registry(); 146 ThreadRegistry* reg = isolate_->thread_registry();
147 ASSERT(reg->Contains(this)); 147 ASSERT(reg->Contains(this));
148 reg->SaveStateFrom(this, state_); 148 reg->SaveStateFrom(this, state_, bypass_safepoint);
149 ClearState(); 149 ClearState();
150 } 150 }
151 151
152 152
153 void Thread::EnterIsolate(Isolate* isolate) { 153 void Thread::EnterIsolate(Isolate* isolate) {
154 Thread* thread = Thread::Current(); 154 Thread* thread = Thread::Current();
155 ASSERT(thread != NULL); 155 ASSERT(thread != NULL);
156 ASSERT(thread->isolate() == NULL); 156 ASSERT(thread->isolate() == NULL);
157 ASSERT(!isolate->HasMutatorThread()); 157 ASSERT(!isolate->HasMutatorThread());
158 thread->isolate_ = isolate; 158 thread->isolate_ = isolate;
(...skipping 23 matching lines...) Expand all
182 } else { 182 } else {
183 isolate->set_vm_tag(VMTag::kLoadWaitTagId); 183 isolate->set_vm_tag(VMTag::kLoadWaitTagId);
184 } 184 }
185 isolate->ClearMutatorThread(); 185 isolate->ClearMutatorThread();
186 thread->isolate_ = NULL; 186 thread->isolate_ = NULL;
187 ASSERT(Isolate::Current() == NULL); 187 ASSERT(Isolate::Current() == NULL);
188 thread->heap_ = NULL; 188 thread->heap_ = NULL;
189 } 189 }
190 190
191 191
192 void Thread::EnterIsolateAsHelper(Isolate* isolate) { 192 void Thread::EnterIsolateAsHelper(Isolate* isolate, bool bypass_safepoint) {
193 Thread* thread = Thread::Current(); 193 Thread* thread = Thread::Current();
194 ASSERT(thread != NULL); 194 ASSERT(thread != NULL);
195 ASSERT(thread->isolate() == NULL); 195 ASSERT(thread->isolate() == NULL);
196 thread->isolate_ = isolate; 196 thread->isolate_ = isolate;
197 ASSERT(thread->store_buffer_block_ == NULL); 197 ASSERT(thread->store_buffer_block_ == NULL);
198 // TODO(koda): Use StoreBufferAcquire once we properly flush before Scavenge. 198 // TODO(koda): Use StoreBufferAcquire once we properly flush before Scavenge.
199 thread->store_buffer_block_ = 199 thread->store_buffer_block_ =
200 thread->isolate()->store_buffer()->PopEmptyBlock(); 200 thread->isolate()->store_buffer()->PopEmptyBlock();
201 ASSERT(isolate->heap() != NULL); 201 ASSERT(isolate->heap() != NULL);
202 thread->heap_ = isolate->heap(); 202 thread->heap_ = isolate->heap();
203 ASSERT(thread->thread_interrupt_callback_ == NULL); 203 ASSERT(thread->thread_interrupt_callback_ == NULL);
204 ASSERT(thread->thread_interrupt_data_ == NULL); 204 ASSERT(thread->thread_interrupt_data_ == NULL);
205 // Do not update isolate->mutator_thread, but perform sanity check: 205 // Do not update isolate->mutator_thread, but perform sanity check:
206 // this thread should not be both the main mutator and helper. 206 // this thread should not be both the main mutator and helper.
207 ASSERT(!isolate->MutatorThreadIsCurrentThread()); 207 ASSERT(!isolate->MutatorThreadIsCurrentThread());
208 thread->Schedule(isolate); 208 thread->Schedule(isolate, bypass_safepoint);
209 } 209 }
210 210
211 211
212 void Thread::ExitIsolateAsHelper() { 212 void Thread::ExitIsolateAsHelper(bool bypass_safepoint) {
213 Thread* thread = Thread::Current(); 213 Thread* thread = Thread::Current();
214 Isolate* isolate = thread->isolate(); 214 Isolate* isolate = thread->isolate();
215 ASSERT(isolate != NULL); 215 ASSERT(isolate != NULL);
216 thread->Unschedule(); 216 thread->Unschedule(bypass_safepoint);
217 // TODO(koda): Move store_buffer_block_ into State. 217 // TODO(koda): Move store_buffer_block_ into State.
218 thread->StoreBufferRelease(); 218 thread->StoreBufferRelease();
219 thread->isolate_ = NULL; 219 thread->isolate_ = NULL;
220 thread->heap_ = NULL; 220 thread->heap_ = NULL;
221 ASSERT(!isolate->MutatorThreadIsCurrentThread()); 221 ASSERT(!isolate->MutatorThreadIsCurrentThread());
222 } 222 }
223 223
224 224
225 // TODO(koda): Make non-static and invoke in SafepointThreads. 225 // TODO(koda): Make non-static and invoke in SafepointThreads.
226 void Thread::PrepareForGC() { 226 void Thread::PrepareForGC() {
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 #define COMPUTE_OFFSET(type_name, member_name, expr, default_init_value) \ 320 #define COMPUTE_OFFSET(type_name, member_name, expr, default_init_value) \
321 ASSERT((expr)->IsVMHeapObject()); \ 321 ASSERT((expr)->IsVMHeapObject()); \
322 if (object.raw() == expr) return Thread::member_name##offset(); 322 if (object.raw() == expr) return Thread::member_name##offset();
323 CACHED_VM_OBJECTS_LIST(COMPUTE_OFFSET) 323 CACHED_VM_OBJECTS_LIST(COMPUTE_OFFSET)
324 #undef COMPUTE_OFFSET 324 #undef COMPUTE_OFFSET
325 UNREACHABLE(); 325 UNREACHABLE();
326 return -1; 326 return -1;
327 } 327 }
328 328
329 } // namespace dart 329 } // namespace dart
OLDNEW
« runtime/vm/gc_marker.cc ('K') | « runtime/vm/thread.h ('k') | runtime/vm/thread_registry.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698