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

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

Issue 1965823002: Initial isolate reload support (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 7 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/compiler_stats.h" 7 #include "vm/compiler_stats.h"
8 #include "vm/dart_api_state.h" 8 #include "vm/dart_api_state.h"
9 #include "vm/growable_array.h" 9 #include "vm/growable_array.h"
10 #include "vm/isolate.h" 10 #include "vm/isolate.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 top_resource_(NULL), 78 top_resource_(NULL),
79 long_jump_base_(NULL), 79 long_jump_base_(NULL),
80 no_callback_scope_depth_(0), 80 no_callback_scope_depth_(0),
81 #if defined(DEBUG) 81 #if defined(DEBUG)
82 top_handle_scope_(NULL), 82 top_handle_scope_(NULL),
83 no_handle_scope_depth_(0), 83 no_handle_scope_depth_(0),
84 no_safepoint_scope_depth_(0), 84 no_safepoint_scope_depth_(0),
85 #endif 85 #endif
86 reusable_handles_(), 86 reusable_handles_(),
87 saved_stack_limit_(0), 87 saved_stack_limit_(0),
88 defer_oob_messages_count_(0),
88 deferred_interrupts_mask_(0), 89 deferred_interrupts_mask_(0),
89 deferred_interrupts_(0), 90 deferred_interrupts_(0),
90 stack_overflow_count_(0), 91 stack_overflow_count_(0),
91 cha_(NULL), 92 cha_(NULL),
92 deopt_id_(0), 93 deopt_id_(0),
93 pending_functions_(GrowableObjectArray::null()), 94 pending_functions_(GrowableObjectArray::null()),
94 sticky_error_(Error::null()), 95 sticky_error_(Error::null()),
95 compiler_stats_(NULL), 96 compiler_stats_(NULL),
96 REUSABLE_HANDLE_LIST(REUSABLE_HANDLE_INITIALIZERS) 97 REUSABLE_HANDLE_LIST(REUSABLE_HANDLE_INITIALIZERS)
97 REUSABLE_HANDLE_LIST(REUSABLE_HANDLE_SCOPE_INIT) 98 REUSABLE_HANDLE_LIST(REUSABLE_HANDLE_SCOPE_INIT)
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 return 0; // No interrupt was requested. 417 return 0; // No interrupt was requested.
417 } 418 }
418 uword interrupt_bits = stack_limit_ & kInterruptsMask; 419 uword interrupt_bits = stack_limit_ & kInterruptsMask;
419 stack_limit_ = saved_stack_limit_; 420 stack_limit_ = saved_stack_limit_;
420 return interrupt_bits; 421 return interrupt_bits;
421 } 422 }
422 423
423 424
424 void Thread::DeferOOBMessageInterrupts() { 425 void Thread::DeferOOBMessageInterrupts() {
425 MonitorLocker ml(thread_lock_); 426 MonitorLocker ml(thread_lock_);
427 defer_oob_messages_count_++;
428 if (defer_oob_messages_count_ > 1) {
429 // OOB message interrupts are already deferred.
430 return;
431 }
426 ASSERT(deferred_interrupts_mask_ == 0); 432 ASSERT(deferred_interrupts_mask_ == 0);
427 deferred_interrupts_mask_ = kMessageInterrupt; 433 deferred_interrupts_mask_ = kMessageInterrupt;
428 434
429 if (stack_limit_ != saved_stack_limit_) { 435 if (stack_limit_ != saved_stack_limit_) {
430 // Defer any interrupts which are currently pending. 436 // Defer any interrupts which are currently pending.
431 deferred_interrupts_ = stack_limit_ & deferred_interrupts_mask_; 437 deferred_interrupts_ = stack_limit_ & deferred_interrupts_mask_;
432 438
433 // Clear deferrable interrupts, if present. 439 // Clear deferrable interrupts, if present.
434 stack_limit_ &= ~deferred_interrupts_mask_; 440 stack_limit_ &= ~deferred_interrupts_mask_;
435 441
436 if ((stack_limit_ & kInterruptsMask) == 0) { 442 if ((stack_limit_ & kInterruptsMask) == 0) {
437 // No other pending interrupts. Restore normal stack limit. 443 // No other pending interrupts. Restore normal stack limit.
438 stack_limit_ = saved_stack_limit_; 444 stack_limit_ = saved_stack_limit_;
439 } 445 }
440 } 446 }
441 if (FLAG_trace_service && FLAG_trace_service_verbose) { 447 if (FLAG_trace_service && FLAG_trace_service_verbose) {
442 OS::Print("[+%" Pd64 "ms] Isolate %s deferring OOB interrupts\n", 448 OS::Print("[+%" Pd64 "ms] Isolate %s deferring OOB interrupts\n",
443 Dart::timestamp(), isolate()->name()); 449 Dart::timestamp(), isolate()->name());
444 } 450 }
445 } 451 }
446 452
447 453
448 void Thread::RestoreOOBMessageInterrupts() { 454 void Thread::RestoreOOBMessageInterrupts() {
449 MonitorLocker ml(thread_lock_); 455 MonitorLocker ml(thread_lock_);
456 defer_oob_messages_count_--;
457 if (defer_oob_messages_count_ > 0) {
458 return;
459 }
460 ASSERT(defer_oob_messages_count_ == 0);
450 ASSERT(deferred_interrupts_mask_ == kMessageInterrupt); 461 ASSERT(deferred_interrupts_mask_ == kMessageInterrupt);
451 deferred_interrupts_mask_ = 0; 462 deferred_interrupts_mask_ = 0;
452 if (deferred_interrupts_ != 0) { 463 if (deferred_interrupts_ != 0) {
453 if (stack_limit_ == saved_stack_limit_) { 464 if (stack_limit_ == saved_stack_limit_) {
454 stack_limit_ = kInterruptStackLimit & ~kInterruptsMask; 465 stack_limit_ = kInterruptStackLimit & ~kInterruptsMask;
455 } 466 }
456 stack_limit_ |= deferred_interrupts_; 467 stack_limit_ |= deferred_interrupts_;
457 deferred_interrupts_ = 0; 468 deferred_interrupts_ = 0;
458 } 469 }
459 if (FLAG_trace_service && FLAG_trace_service_verbose) { 470 if (FLAG_trace_service && FLAG_trace_service_verbose) {
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
737 748
738 DisableThreadInterruptsScope::~DisableThreadInterruptsScope() { 749 DisableThreadInterruptsScope::~DisableThreadInterruptsScope() {
739 if (thread() != NULL) { 750 if (thread() != NULL) {
740 OSThread* os_thread = thread()->os_thread(); 751 OSThread* os_thread = thread()->os_thread();
741 ASSERT(os_thread != NULL); 752 ASSERT(os_thread != NULL);
742 os_thread->EnableThreadInterrupts(); 753 os_thread->EnableThreadInterrupts();
743 } 754 }
744 } 755 }
745 756
746 } // namespace dart 757 } // namespace dart
OLDNEW
« runtime/vm/object.cc ('K') | « runtime/vm/thread.h ('k') | runtime/vm/unit_test.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698