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

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

Issue 1409173002: More work for background compilation; move pending_functions_ from ObjectStore to Thread. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Better code. Created 5 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/thread.h ('k') | no next file » | 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) 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/log.h" 10 #include "vm/log.h"
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 178
179 Thread::Thread(bool init_vm_constants) 179 Thread::Thread(bool init_vm_constants)
180 : id_(OSThread::GetCurrentThreadId()), 180 : id_(OSThread::GetCurrentThreadId()),
181 thread_interrupt_callback_(NULL), 181 thread_interrupt_callback_(NULL),
182 thread_interrupt_data_(NULL), 182 thread_interrupt_data_(NULL),
183 isolate_(NULL), 183 isolate_(NULL),
184 heap_(NULL), 184 heap_(NULL),
185 timeline_block_(NULL), 185 timeline_block_(NULL),
186 store_buffer_block_(NULL), 186 store_buffer_block_(NULL),
187 log_(new class Log()), 187 log_(new class Log()),
188 deopt_id_(0),
189 vm_tag_(0),
190 REUSABLE_HANDLE_LIST(REUSABLE_HANDLE_INITIALIZERS) 188 REUSABLE_HANDLE_LIST(REUSABLE_HANDLE_INITIALIZERS)
191 REUSABLE_HANDLE_LIST(REUSABLE_HANDLE_SCOPE_INIT) 189 REUSABLE_HANDLE_LIST(REUSABLE_HANDLE_SCOPE_INIT)
192 reusable_handles_(), 190 reusable_handles_(),
193 cha_(NULL), 191 cha_(NULL),
192 deopt_id_(0),
193 vm_tag_(0),
194 pending_functions_(GrowableObjectArray::null()),
194 no_callback_scope_depth_(0), 195 no_callback_scope_depth_(0),
195 thread_list_next_(NULL) { 196 thread_list_next_(NULL) {
196 ClearState(); 197 ClearState();
197 198
198 #define DEFAULT_INIT(type_name, member_name, init_expr, default_init_value) \ 199 #define DEFAULT_INIT(type_name, member_name, init_expr, default_init_value) \
199 member_name = default_init_value; 200 member_name = default_init_value;
200 CACHED_CONSTANTS_LIST(DEFAULT_INIT) 201 CACHED_CONSTANTS_LIST(DEFAULT_INIT)
201 #undef DEFAULT_INIT 202 #undef DEFAULT_INIT
202 203
203 #define DEFAULT_INIT(name) \ 204 #define DEFAULT_INIT(name) \
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 #undef INIT_VALUE 244 #undef INIT_VALUE
244 245
245 // Setup the thread specific reusable handles. 246 // Setup the thread specific reusable handles.
246 #define REUSABLE_HANDLE_ALLOCATION(object) \ 247 #define REUSABLE_HANDLE_ALLOCATION(object) \
247 this->object##_handle_ = this->AllocateReusableHandle<object>(); 248 this->object##_handle_ = this->AllocateReusableHandle<object>();
248 REUSABLE_HANDLE_LIST(REUSABLE_HANDLE_ALLOCATION) 249 REUSABLE_HANDLE_LIST(REUSABLE_HANDLE_ALLOCATION)
249 #undef REUSABLE_HANDLE_ALLOCATION 250 #undef REUSABLE_HANDLE_ALLOCATION
250 } 251 }
251 252
252 253
254 void Thread::ClearState() {
255 memset(&state_, 0, sizeof(state_));
256 pending_functions_ = GrowableObjectArray::null();
257 }
258
259
260 RawGrowableObjectArray* Thread::pending_functions() {
261 if (pending_functions_ == GrowableObjectArray::null()) {
262 pending_functions_ = GrowableObjectArray::New(Heap::kOld);
263 }
264 return pending_functions_;
265 }
266
267
253 void Thread::Schedule(Isolate* isolate, bool bypass_safepoint) { 268 void Thread::Schedule(Isolate* isolate, bool bypass_safepoint) {
254 State st; 269 State st;
255 if (isolate->thread_registry()->RestoreStateTo(this, &st, bypass_safepoint)) { 270 if (isolate->thread_registry()->RestoreStateTo(this, &st, bypass_safepoint)) {
256 ASSERT(isolate->thread_registry()->Contains(this)); 271 ASSERT(isolate->thread_registry()->Contains(this));
257 state_ = st; 272 state_ = st;
258 } 273 }
259 } 274 }
260 275
261 276
262 void Thread::Unschedule(bool bypass_safepoint) { 277 void Thread::Unschedule(bool bypass_safepoint) {
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 REUSABLE_HANDLE_LIST(CLEAR_REUSABLE_HANDLE) 437 REUSABLE_HANDLE_LIST(CLEAR_REUSABLE_HANDLE)
423 #undef CLEAR_REUSABLE_HANDLE 438 #undef CLEAR_REUSABLE_HANDLE
424 } 439 }
425 440
426 441
427 void Thread::VisitObjectPointers(ObjectPointerVisitor* visitor) { 442 void Thread::VisitObjectPointers(ObjectPointerVisitor* visitor) {
428 ASSERT(visitor != NULL); 443 ASSERT(visitor != NULL);
429 444
430 // Visit objects in thread specific handles area. 445 // Visit objects in thread specific handles area.
431 reusable_handles_.VisitObjectPointers(visitor); 446 reusable_handles_.VisitObjectPointers(visitor);
447
448 if (pending_functions_ != GrowableObjectArray::null()) {
449 visitor->VisitPointer(
450 reinterpret_cast<RawObject**>(&pending_functions_));
451 }
432 } 452 }
433 453
434 454
435 void Thread::SetThreadInterrupter(ThreadInterruptCallback callback, 455 void Thread::SetThreadInterrupter(ThreadInterruptCallback callback,
436 void* data) { 456 void* data) {
437 ASSERT(Thread::Current() == this); 457 ASSERT(Thread::Current() == this);
438 thread_interrupt_callback_ = callback; 458 thread_interrupt_callback_ = callback;
439 thread_interrupt_data_ = data; 459 thread_interrupt_data_ = data;
440 } 460 }
441 461
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 Thread* ThreadIterator::Next() { 543 Thread* ThreadIterator::Next() {
524 ASSERT(Thread::thread_list_lock_ != NULL); 544 ASSERT(Thread::thread_list_lock_ != NULL);
525 ASSERT(Thread::thread_list_lock_->IsOwnedByCurrentThread()); 545 ASSERT(Thread::thread_list_lock_->IsOwnedByCurrentThread());
526 Thread* current = next_; 546 Thread* current = next_;
527 next_ = next_->thread_list_next_; 547 next_ = next_->thread_list_next_;
528 return current; 548 return current;
529 } 549 }
530 550
531 551
532 } // namespace dart 552 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/thread.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698