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

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

Issue 1672853002: Move sticky_error_ from isolate to thread (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: r Created 4 years, 10 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/dart_api_state.h" 7 #include "vm/dart_api_state.h"
8 #include "vm/growable_array.h" 8 #include "vm/growable_array.h"
9 #include "vm/isolate.h" 9 #include "vm/isolate.h"
10 #include "vm/lockers.h" 10 #include "vm/lockers.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 #if defined(DEBUG) 55 #if defined(DEBUG)
56 top_handle_scope_(NULL), 56 top_handle_scope_(NULL),
57 no_handle_scope_depth_(0), 57 no_handle_scope_depth_(0),
58 no_safepoint_scope_depth_(0), 58 no_safepoint_scope_depth_(0),
59 #endif 59 #endif
60 reusable_handles_(), 60 reusable_handles_(),
61 cha_(NULL), 61 cha_(NULL),
62 deopt_id_(0), 62 deopt_id_(0),
63 vm_tag_(0), 63 vm_tag_(0),
64 pending_functions_(GrowableObjectArray::null()), 64 pending_functions_(GrowableObjectArray::null()),
65 sticky_error_(Error::null()),
65 REUSABLE_HANDLE_LIST(REUSABLE_HANDLE_INITIALIZERS) 66 REUSABLE_HANDLE_LIST(REUSABLE_HANDLE_INITIALIZERS)
66 REUSABLE_HANDLE_LIST(REUSABLE_HANDLE_SCOPE_INIT) 67 REUSABLE_HANDLE_LIST(REUSABLE_HANDLE_SCOPE_INIT)
67 safepoint_state_(0), 68 safepoint_state_(0),
68 execution_state_(kThreadInVM), 69 execution_state_(kThreadInVM),
69 next_(NULL) { 70 next_(NULL) {
70 #define DEFAULT_INIT(type_name, member_name, init_expr, default_init_value) \ 71 #define DEFAULT_INIT(type_name, member_name, init_expr, default_init_value) \
71 member_name = default_init_value; 72 member_name = default_init_value;
72 CACHED_CONSTANTS_LIST(DEFAULT_INIT) 73 CACHED_CONSTANTS_LIST(DEFAULT_INIT)
73 #undef DEFAULT_INIT 74 #undef DEFAULT_INIT
74 75
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 169
169 170
170 RawGrowableObjectArray* Thread::pending_functions() { 171 RawGrowableObjectArray* Thread::pending_functions() {
171 if (pending_functions_ == GrowableObjectArray::null()) { 172 if (pending_functions_ == GrowableObjectArray::null()) {
172 pending_functions_ = GrowableObjectArray::New(Heap::kOld); 173 pending_functions_ = GrowableObjectArray::New(Heap::kOld);
173 } 174 }
174 return pending_functions_; 175 return pending_functions_;
175 } 176 }
176 177
177 178
179 void Thread::clear_pending_functions() {
180 pending_functions_ = GrowableObjectArray::null();
181 }
182
183
184 RawError* Thread::sticky_error() const {
185 return sticky_error_;
186 }
187
188
189 void Thread::set_sticky_error(const Error& value) {
190 // TODO(asiva): Move sticky_error_ into thread specific area.
191 // ASSERT(Thread::Current()->IsMutatorThread());
siva 2016/02/05 22:46:36 This TODO and ASSERT can be removed now.
srdjan 2016/02/05 23:34:33 Done.
192 ASSERT(!value.IsNull());
193 sticky_error_ = value.raw();
194 }
195
196
197 void Thread::clear_sticky_error() {
198 sticky_error_ = Error::null();
199 }
200
201
178 bool Thread::EnterIsolate(Isolate* isolate) { 202 bool Thread::EnterIsolate(Isolate* isolate) {
179 const bool kIsMutatorThread = true; 203 const bool kIsMutatorThread = true;
180 Thread* thread = isolate->ScheduleThread(kIsMutatorThread); 204 Thread* thread = isolate->ScheduleThread(kIsMutatorThread);
181 if (thread != NULL) { 205 if (thread != NULL) {
182 ASSERT(thread->store_buffer_block_ == NULL); 206 ASSERT(thread->store_buffer_block_ == NULL);
183 thread->StoreBufferAcquire(); 207 thread->StoreBufferAcquire();
184 return true; 208 return true;
185 } 209 }
186 return false; 210 return false;
187 } 211 }
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 355
332 // Visit objects in thread specific handles area. 356 // Visit objects in thread specific handles area.
333 reusable_handles_.VisitObjectPointers(visitor); 357 reusable_handles_.VisitObjectPointers(visitor);
334 358
335 // Visit the pending functions. 359 // Visit the pending functions.
336 if (pending_functions_ != GrowableObjectArray::null()) { 360 if (pending_functions_ != GrowableObjectArray::null()) {
337 visitor->VisitPointer( 361 visitor->VisitPointer(
338 reinterpret_cast<RawObject**>(&pending_functions_)); 362 reinterpret_cast<RawObject**>(&pending_functions_));
339 } 363 }
340 364
365 if (sticky_error_ != Error::null()) {
366 visitor->VisitPointer(
367 reinterpret_cast<RawObject**>(&sticky_error_));
368 }
siva 2016/02/05 22:46:36 Why do we have these checks for NULL the visitor s
srdjan 2016/02/05 23:34:33 Do not remember why that was done. Removed both ch
369
341 // Visit the api local scope as it has all the api local handles. 370 // Visit the api local scope as it has all the api local handles.
342 ApiLocalScope* scope = api_top_scope_; 371 ApiLocalScope* scope = api_top_scope_;
343 while (scope != NULL) { 372 while (scope != NULL) {
344 scope->local_handles()->VisitObjectPointers(visitor); 373 scope->local_handles()->VisitObjectPointers(visitor);
345 scope = scope->previous(); 374 scope = scope->previous();
346 } 375 }
347 } 376 }
348 377
349 378
350 bool Thread::CanLoadFromThread(const Object& object) { 379 bool Thread::CanLoadFromThread(const Object& object) {
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 503
475 DisableThreadInterruptsScope::~DisableThreadInterruptsScope() { 504 DisableThreadInterruptsScope::~DisableThreadInterruptsScope() {
476 if (thread() != NULL) { 505 if (thread() != NULL) {
477 OSThread* os_thread = thread()->os_thread(); 506 OSThread* os_thread = thread()->os_thread();
478 ASSERT(os_thread != NULL); 507 ASSERT(os_thread != NULL);
479 os_thread->EnableThreadInterrupts(); 508 os_thread->EnableThreadInterrupts();
480 } 509 }
481 } 510 }
482 511
483 } // namespace dart 512 } // 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