| OLD | NEW |
| 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 top_resource_(NULL), | 76 top_resource_(NULL), |
| 77 long_jump_base_(NULL), | 77 long_jump_base_(NULL), |
| 78 no_callback_scope_depth_(0), | 78 no_callback_scope_depth_(0), |
| 79 #if defined(DEBUG) | 79 #if defined(DEBUG) |
| 80 top_handle_scope_(NULL), | 80 top_handle_scope_(NULL), |
| 81 no_handle_scope_depth_(0), | 81 no_handle_scope_depth_(0), |
| 82 no_safepoint_scope_depth_(0), | 82 no_safepoint_scope_depth_(0), |
| 83 #endif | 83 #endif |
| 84 reusable_handles_(), | 84 reusable_handles_(), |
| 85 saved_stack_limit_(0), | 85 saved_stack_limit_(0), |
| 86 defer_oob_messages_count_(0), |
| 86 deferred_interrupts_mask_(0), | 87 deferred_interrupts_mask_(0), |
| 87 deferred_interrupts_(0), | 88 deferred_interrupts_(0), |
| 88 stack_overflow_count_(0), | 89 stack_overflow_count_(0), |
| 89 cha_(NULL), | 90 cha_(NULL), |
| 90 deopt_id_(0), | 91 deopt_id_(0), |
| 91 pending_functions_(GrowableObjectArray::null()), | 92 pending_functions_(GrowableObjectArray::null()), |
| 92 sticky_error_(Error::null()), | 93 sticky_error_(Error::null()), |
| 93 compiler_stats_(NULL), | 94 compiler_stats_(NULL), |
| 94 REUSABLE_HANDLE_LIST(REUSABLE_HANDLE_INITIALIZERS) | 95 REUSABLE_HANDLE_LIST(REUSABLE_HANDLE_INITIALIZERS) |
| 95 REUSABLE_HANDLE_LIST(REUSABLE_HANDLE_SCOPE_INIT) | 96 REUSABLE_HANDLE_LIST(REUSABLE_HANDLE_SCOPE_INIT) |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 410 return 0; // No interrupt was requested. | 411 return 0; // No interrupt was requested. |
| 411 } | 412 } |
| 412 uword interrupt_bits = stack_limit_ & kInterruptsMask; | 413 uword interrupt_bits = stack_limit_ & kInterruptsMask; |
| 413 stack_limit_ = saved_stack_limit_; | 414 stack_limit_ = saved_stack_limit_; |
| 414 return interrupt_bits; | 415 return interrupt_bits; |
| 415 } | 416 } |
| 416 | 417 |
| 417 | 418 |
| 418 void Thread::DeferOOBMessageInterrupts() { | 419 void Thread::DeferOOBMessageInterrupts() { |
| 419 MonitorLocker ml(thread_lock_); | 420 MonitorLocker ml(thread_lock_); |
| 421 defer_oob_messages_count_++; |
| 422 if (defer_oob_messages_count_ > 1) { |
| 423 // OOB message interrupts are already deferred. |
| 424 return; |
| 425 } |
| 420 ASSERT(deferred_interrupts_mask_ == 0); | 426 ASSERT(deferred_interrupts_mask_ == 0); |
| 421 deferred_interrupts_mask_ = kMessageInterrupt; | 427 deferred_interrupts_mask_ = kMessageInterrupt; |
| 422 | 428 |
| 423 if (stack_limit_ != saved_stack_limit_) { | 429 if (stack_limit_ != saved_stack_limit_) { |
| 424 // Defer any interrupts which are currently pending. | 430 // Defer any interrupts which are currently pending. |
| 425 deferred_interrupts_ = stack_limit_ & deferred_interrupts_mask_; | 431 deferred_interrupts_ = stack_limit_ & deferred_interrupts_mask_; |
| 426 | 432 |
| 427 // Clear deferrable interrupts, if present. | 433 // Clear deferrable interrupts, if present. |
| 428 stack_limit_ &= ~deferred_interrupts_mask_; | 434 stack_limit_ &= ~deferred_interrupts_mask_; |
| 429 | 435 |
| 430 if ((stack_limit_ & kInterruptsMask) == 0) { | 436 if ((stack_limit_ & kInterruptsMask) == 0) { |
| 431 // No other pending interrupts. Restore normal stack limit. | 437 // No other pending interrupts. Restore normal stack limit. |
| 432 stack_limit_ = saved_stack_limit_; | 438 stack_limit_ = saved_stack_limit_; |
| 433 } | 439 } |
| 434 } | 440 } |
| 435 if (FLAG_trace_service && FLAG_trace_service_verbose) { | 441 if (FLAG_trace_service && FLAG_trace_service_verbose) { |
| 436 OS::Print("[+%" Pd64 "ms] Isolate %s deferring OOB interrupts\n", | 442 OS::Print("[+%" Pd64 "ms] Isolate %s deferring OOB interrupts\n", |
| 437 Dart::timestamp(), isolate()->name()); | 443 Dart::timestamp(), isolate()->name()); |
| 438 } | 444 } |
| 439 } | 445 } |
| 440 | 446 |
| 441 | 447 |
| 442 void Thread::RestoreOOBMessageInterrupts() { | 448 void Thread::RestoreOOBMessageInterrupts() { |
| 443 MonitorLocker ml(thread_lock_); | 449 MonitorLocker ml(thread_lock_); |
| 450 defer_oob_messages_count_--; |
| 451 if (defer_oob_messages_count_ > 0) { |
| 452 return; |
| 453 } |
| 454 ASSERT(defer_oob_messages_count_ == 0); |
| 444 ASSERT(deferred_interrupts_mask_ == kMessageInterrupt); | 455 ASSERT(deferred_interrupts_mask_ == kMessageInterrupt); |
| 445 deferred_interrupts_mask_ = 0; | 456 deferred_interrupts_mask_ = 0; |
| 446 if (deferred_interrupts_ != 0) { | 457 if (deferred_interrupts_ != 0) { |
| 447 if (stack_limit_ == saved_stack_limit_) { | 458 if (stack_limit_ == saved_stack_limit_) { |
| 448 stack_limit_ = kInterruptStackLimit & ~kInterruptsMask; | 459 stack_limit_ = kInterruptStackLimit & ~kInterruptsMask; |
| 449 } | 460 } |
| 450 stack_limit_ |= deferred_interrupts_; | 461 stack_limit_ |= deferred_interrupts_; |
| 451 deferred_interrupts_ = 0; | 462 deferred_interrupts_ = 0; |
| 452 } | 463 } |
| 453 if (FLAG_trace_service && FLAG_trace_service_verbose) { | 464 if (FLAG_trace_service && FLAG_trace_service_verbose) { |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 731 | 742 |
| 732 DisableThreadInterruptsScope::~DisableThreadInterruptsScope() { | 743 DisableThreadInterruptsScope::~DisableThreadInterruptsScope() { |
| 733 if (thread() != NULL) { | 744 if (thread() != NULL) { |
| 734 OSThread* os_thread = thread()->os_thread(); | 745 OSThread* os_thread = thread()->os_thread(); |
| 735 ASSERT(os_thread != NULL); | 746 ASSERT(os_thread != NULL); |
| 736 os_thread->EnableThreadInterrupts(); | 747 os_thread->EnableThreadInterrupts(); |
| 737 } | 748 } |
| 738 } | 749 } |
| 739 | 750 |
| 740 } // namespace dart | 751 } // namespace dart |
| OLD | NEW |