| Index: runtime/vm/thread.cc
|
| diff --git a/runtime/vm/thread.cc b/runtime/vm/thread.cc
|
| index 84ce5ad0d8c84477f561db7dd6ecfd0ca41c8403..d451975dcba04dbdaa105f6f8f3b757d3d85b707 100644
|
| --- a/runtime/vm/thread.cc
|
| +++ b/runtime/vm/thread.cc
|
| @@ -26,11 +26,9 @@
|
|
|
| namespace dart {
|
|
|
| -
|
| DECLARE_FLAG(bool, trace_service);
|
| DECLARE_FLAG(bool, trace_service_verbose);
|
|
|
| -
|
| Thread::~Thread() {
|
| // We should cleanly exit any isolate before destruction.
|
| ASSERT(isolate_ == NULL);
|
| @@ -58,7 +56,6 @@ Thread::~Thread() {
|
|
|
| #define REUSABLE_HANDLE_INITIALIZERS(object) object##_handle_(NULL),
|
|
|
| -
|
| Thread::Thread(Isolate* isolate)
|
| : BaseThread(false),
|
| stack_limit_(0),
|
| @@ -148,7 +145,6 @@ Thread::Thread(Isolate* isolate)
|
| }
|
| }
|
|
|
| -
|
| static const struct ALIGN16 {
|
| uint64_t a;
|
| uint64_t b;
|
| @@ -187,7 +183,6 @@ static const struct ALIGN16 {
|
| uint32_t d;
|
| } float_zerow_constant = {0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000};
|
|
|
| -
|
| void Thread::InitVMConstants() {
|
| #define ASSERT_VM_HEAP(type_name, member_name, init_expr, default_init_value) \
|
| ASSERT((init_expr)->IsOldObject());
|
| @@ -219,7 +214,6 @@ void Thread::InitVMConstants() {
|
| #undef REUSABLE_HANDLE_ALLOCATION
|
| }
|
|
|
| -
|
| #ifndef PRODUCT
|
| // Collect information about each individual zone associated with this thread.
|
| void Thread::PrintJSON(JSONStream* stream) const {
|
| @@ -233,7 +227,6 @@ void Thread::PrintJSON(JSONStream* stream) const {
|
| }
|
| #endif
|
|
|
| -
|
| RawGrowableObjectArray* Thread::pending_functions() {
|
| if (pending_functions_ == GrowableObjectArray::null()) {
|
| pending_functions_ = GrowableObjectArray::New(Heap::kOld);
|
| @@ -241,39 +234,32 @@ RawGrowableObjectArray* Thread::pending_functions() {
|
| return pending_functions_;
|
| }
|
|
|
| -
|
| void Thread::clear_pending_functions() {
|
| pending_functions_ = GrowableObjectArray::null();
|
| }
|
|
|
| -
|
| void Thread::set_active_exception(const Object& value) {
|
| ASSERT(!value.IsNull());
|
| active_exception_ = value.raw();
|
| }
|
|
|
| -
|
| void Thread::set_active_stacktrace(const Object& value) {
|
| active_stacktrace_ = value.raw();
|
| }
|
|
|
| -
|
| RawError* Thread::sticky_error() const {
|
| return sticky_error_;
|
| }
|
|
|
| -
|
| void Thread::set_sticky_error(const Error& value) {
|
| ASSERT(!value.IsNull());
|
| sticky_error_ = value.raw();
|
| }
|
|
|
| -
|
| void Thread::clear_sticky_error() {
|
| sticky_error_ = Error::null();
|
| }
|
|
|
| -
|
| RawError* Thread::get_and_clear_sticky_error() {
|
| NoSafepointScope nss;
|
| RawError* return_value = sticky_error_;
|
| @@ -281,7 +267,6 @@ RawError* Thread::get_and_clear_sticky_error() {
|
| return return_value;
|
| }
|
|
|
| -
|
| const char* Thread::TaskKindToCString(TaskKind kind) {
|
| switch (kind) {
|
| case kUnknownTask:
|
| @@ -300,28 +285,23 @@ const char* Thread::TaskKindToCString(TaskKind kind) {
|
| }
|
| }
|
|
|
| -
|
| RawStackTrace* Thread::async_stack_trace() const {
|
| return async_stack_trace_;
|
| }
|
|
|
| -
|
| void Thread::set_async_stack_trace(const StackTrace& stack_trace) {
|
| ASSERT(!stack_trace.IsNull());
|
| async_stack_trace_ = stack_trace.raw();
|
| }
|
|
|
| -
|
| void Thread::set_raw_async_stack_trace(RawStackTrace* raw_stack_trace) {
|
| async_stack_trace_ = raw_stack_trace;
|
| }
|
|
|
| -
|
| void Thread::clear_async_stack_trace() {
|
| async_stack_trace_ = StackTrace::null();
|
| }
|
|
|
| -
|
| bool Thread::EnterIsolate(Isolate* isolate) {
|
| const bool kIsMutatorThread = true;
|
| Thread* thread = isolate->ScheduleThread(kIsMutatorThread);
|
| @@ -334,7 +314,6 @@ bool Thread::EnterIsolate(Isolate* isolate) {
|
| return false;
|
| }
|
|
|
| -
|
| void Thread::ExitIsolate() {
|
| Thread* thread = Thread::Current();
|
| ASSERT(thread != NULL && thread->IsMutatorThread());
|
| @@ -355,7 +334,6 @@ void Thread::ExitIsolate() {
|
| isolate->UnscheduleThread(thread, kIsMutatorThread);
|
| }
|
|
|
| -
|
| bool Thread::EnterIsolateAsHelper(Isolate* isolate,
|
| TaskKind kind,
|
| bool bypass_safepoint) {
|
| @@ -377,7 +355,6 @@ bool Thread::EnterIsolateAsHelper(Isolate* isolate,
|
| return false;
|
| }
|
|
|
| -
|
| void Thread::ExitIsolateAsHelper(bool bypass_safepoint) {
|
| Thread* thread = Thread::Current();
|
| ASSERT(thread != NULL);
|
| @@ -393,7 +370,6 @@ void Thread::ExitIsolateAsHelper(bool bypass_safepoint) {
|
| isolate->UnscheduleThread(thread, kIsNotMutatorThread, bypass_safepoint);
|
| }
|
|
|
| -
|
| void Thread::PrepareForGC() {
|
| ASSERT(IsAtSafepoint());
|
| // Prevent scheduling another GC by ignoring the threshold.
|
| @@ -405,7 +381,6 @@ void Thread::PrepareForGC() {
|
| store_buffer_block_ = isolate()->store_buffer()->PopEmptyBlock();
|
| }
|
|
|
| -
|
| void Thread::SetStackLimitFromStackBase(uword stack_base) {
|
| // Set stack limit.
|
| #if !defined(TARGET_ARCH_DBC)
|
| @@ -422,7 +397,6 @@ void Thread::SetStackLimitFromStackBase(uword stack_base) {
|
| #endif // !defined(TARGET_ARCH_DBC)
|
| }
|
|
|
| -
|
| void Thread::SetStackLimit(uword limit) {
|
| // The thread setting the stack limit is not necessarily the thread which
|
| // the stack limit is being set on.
|
| @@ -434,12 +408,10 @@ void Thread::SetStackLimit(uword limit) {
|
| saved_stack_limit_ = limit;
|
| }
|
|
|
| -
|
| void Thread::ClearStackLimit() {
|
| SetStackLimit(~static_cast<uword>(0));
|
| }
|
|
|
| -
|
| /* static */
|
| uword Thread::GetCurrentStackPointer() {
|
| #if !defined(TARGET_ARCH_DBC)
|
| @@ -466,13 +438,11 @@ uword Thread::GetCurrentStackPointer() {
|
| #endif
|
| }
|
|
|
| -
|
| void Thread::ScheduleInterrupts(uword interrupt_bits) {
|
| MonitorLocker ml(thread_lock_);
|
| ScheduleInterruptsLocked(interrupt_bits);
|
| }
|
|
|
| -
|
| void Thread::ScheduleInterruptsLocked(uword interrupt_bits) {
|
| ASSERT(thread_lock_->IsOwnedByCurrentThread());
|
| ASSERT((interrupt_bits & ~kInterruptsMask) == 0); // Must fit in mask.
|
| @@ -493,7 +463,6 @@ void Thread::ScheduleInterruptsLocked(uword interrupt_bits) {
|
| stack_limit_ |= interrupt_bits;
|
| }
|
|
|
| -
|
| uword Thread::GetAndClearInterrupts() {
|
| MonitorLocker ml(thread_lock_);
|
| if (stack_limit_ == saved_stack_limit_) {
|
| @@ -504,7 +473,6 @@ uword Thread::GetAndClearInterrupts() {
|
| return interrupt_bits;
|
| }
|
|
|
| -
|
| bool Thread::ZoneIsOwnedByThread(Zone* zone) const {
|
| ASSERT(zone != NULL);
|
| Zone* current = zone_;
|
| @@ -517,7 +485,6 @@ bool Thread::ZoneIsOwnedByThread(Zone* zone) const {
|
| return false;
|
| }
|
|
|
| -
|
| void Thread::DeferOOBMessageInterrupts() {
|
| MonitorLocker ml(thread_lock_);
|
| defer_oob_messages_count_++;
|
| @@ -546,7 +513,6 @@ void Thread::DeferOOBMessageInterrupts() {
|
| }
|
| }
|
|
|
| -
|
| void Thread::RestoreOOBMessageInterrupts() {
|
| MonitorLocker ml(thread_lock_);
|
| defer_oob_messages_count_--;
|
| @@ -569,7 +535,6 @@ void Thread::RestoreOOBMessageInterrupts() {
|
| }
|
| }
|
|
|
| -
|
| RawError* Thread::HandleInterrupts() {
|
| uword interrupt_bits = GetAndClearInterrupts();
|
| if ((interrupt_bits & kVMInterrupt) != 0) {
|
| @@ -602,20 +567,17 @@ RawError* Thread::HandleInterrupts() {
|
| return Error::null();
|
| }
|
|
|
| -
|
| uword Thread::GetAndClearStackOverflowFlags() {
|
| uword stack_overflow_flags = stack_overflow_flags_;
|
| stack_overflow_flags_ = 0;
|
| return stack_overflow_flags;
|
| }
|
|
|
| -
|
| void Thread::StoreBufferBlockProcess(StoreBuffer::ThresholdPolicy policy) {
|
| StoreBufferRelease(policy);
|
| StoreBufferAcquire();
|
| }
|
|
|
| -
|
| void Thread::StoreBufferAddObject(RawObject* obj) {
|
| store_buffer_block_->Push(obj);
|
| if (store_buffer_block_->IsFull()) {
|
| @@ -623,7 +585,6 @@ void Thread::StoreBufferAddObject(RawObject* obj) {
|
| }
|
| }
|
|
|
| -
|
| void Thread::StoreBufferAddObjectGC(RawObject* obj) {
|
| store_buffer_block_->Push(obj);
|
| if (store_buffer_block_->IsFull()) {
|
| @@ -631,24 +592,20 @@ void Thread::StoreBufferAddObjectGC(RawObject* obj) {
|
| }
|
| }
|
|
|
| -
|
| void Thread::StoreBufferRelease(StoreBuffer::ThresholdPolicy policy) {
|
| StoreBufferBlock* block = store_buffer_block_;
|
| store_buffer_block_ = NULL;
|
| isolate()->store_buffer()->PushBlock(block, policy);
|
| }
|
|
|
| -
|
| void Thread::StoreBufferAcquire() {
|
| store_buffer_block_ = isolate()->store_buffer()->PopNonFullBlock();
|
| }
|
|
|
| -
|
| bool Thread::IsMutatorThread() const {
|
| return ((isolate_ != NULL) && (isolate_->mutator_thread() == this));
|
| }
|
|
|
| -
|
| bool Thread::CanCollectGarbage() const {
|
| // We grow the heap instead of triggering a garbage collection when a
|
| // thread is at a safepoint in the following situations :
|
| @@ -659,17 +616,14 @@ bool Thread::CanCollectGarbage() const {
|
| return !IsAtSafepoint();
|
| }
|
|
|
| -
|
| bool Thread::IsExecutingDartCode() const {
|
| return (top_exit_frame_info() == 0) && (vm_tag() == VMTag::kDartTagId);
|
| }
|
|
|
| -
|
| bool Thread::HasExitedDartCode() const {
|
| return (top_exit_frame_info() != 0) && (vm_tag() != VMTag::kDartTagId);
|
| }
|
|
|
| -
|
| template <class C>
|
| C* Thread::AllocateReusableHandle() {
|
| C* handle = reinterpret_cast<C*>(reusable_handles_.AllocateScopedHandle());
|
| @@ -677,14 +631,12 @@ C* Thread::AllocateReusableHandle() {
|
| return handle;
|
| }
|
|
|
| -
|
| void Thread::ClearReusableHandles() {
|
| #define CLEAR_REUSABLE_HANDLE(object) *object##_handle_ = object::null();
|
| REUSABLE_HANDLE_LIST(CLEAR_REUSABLE_HANDLE)
|
| #undef CLEAR_REUSABLE_HANDLE
|
| }
|
|
|
| -
|
| void Thread::VisitObjectPointers(ObjectPointerVisitor* visitor,
|
| bool validate_frames) {
|
| ASSERT(visitor != NULL);
|
| @@ -736,7 +688,6 @@ void Thread::VisitObjectPointers(ObjectPointerVisitor* visitor,
|
| }
|
| }
|
|
|
| -
|
| bool Thread::CanLoadFromThread(const Object& object) {
|
| #define CHECK_OBJECT(type_name, member_name, expr, default_init_value) \
|
| if (object.raw() == expr) return true;
|
| @@ -745,7 +696,6 @@ bool Thread::CanLoadFromThread(const Object& object) {
|
| return false;
|
| }
|
|
|
| -
|
| intptr_t Thread::OffsetFromThread(const Object& object) {
|
| #define COMPUTE_OFFSET(type_name, member_name, expr, default_init_value) \
|
| ASSERT((expr)->IsVMHeapObject()); \
|
| @@ -756,7 +706,6 @@ intptr_t Thread::OffsetFromThread(const Object& object) {
|
| return -1;
|
| }
|
|
|
| -
|
| bool Thread::ObjectAtOffset(intptr_t offset, Object* object) {
|
| if (Isolate::Current() == Dart::vm_isolate()) {
|
| // --disassemble-stubs runs before all the references through
|
| @@ -774,7 +723,6 @@ bool Thread::ObjectAtOffset(intptr_t offset, Object* object) {
|
| return false;
|
| }
|
|
|
| -
|
| intptr_t Thread::OffsetFromThread(const RuntimeEntry* runtime_entry) {
|
| #define COMPUTE_OFFSET(name) \
|
| if (runtime_entry->function() == k##name##RuntimeEntry.function()) { \
|
| @@ -794,13 +742,11 @@ intptr_t Thread::OffsetFromThread(const RuntimeEntry* runtime_entry) {
|
| return -1;
|
| }
|
|
|
| -
|
| bool Thread::IsValidHandle(Dart_Handle object) const {
|
| return IsValidLocalHandle(object) || IsValidZoneHandle(object) ||
|
| IsValidScopedHandle(object);
|
| }
|
|
|
| -
|
| bool Thread::IsValidLocalHandle(Dart_Handle object) const {
|
| ApiLocalScope* scope = api_top_scope_;
|
| while (scope != NULL) {
|
| @@ -812,7 +758,6 @@ bool Thread::IsValidLocalHandle(Dart_Handle object) const {
|
| return false;
|
| }
|
|
|
| -
|
| intptr_t Thread::CountLocalHandles() const {
|
| intptr_t total = 0;
|
| ApiLocalScope* scope = api_top_scope_;
|
| @@ -823,7 +768,6 @@ intptr_t Thread::CountLocalHandles() const {
|
| return total;
|
| }
|
|
|
| -
|
| bool Thread::IsValidZoneHandle(Dart_Handle object) const {
|
| Zone* zone = zone_;
|
| while (zone != NULL) {
|
| @@ -835,7 +779,6 @@ bool Thread::IsValidZoneHandle(Dart_Handle object) const {
|
| return false;
|
| }
|
|
|
| -
|
| intptr_t Thread::CountZoneHandles() const {
|
| intptr_t count = 0;
|
| Zone* zone = zone_;
|
| @@ -847,7 +790,6 @@ intptr_t Thread::CountZoneHandles() const {
|
| return count;
|
| }
|
|
|
| -
|
| bool Thread::IsValidScopedHandle(Dart_Handle object) const {
|
| Zone* zone = zone_;
|
| while (zone != NULL) {
|
| @@ -859,7 +801,6 @@ bool Thread::IsValidScopedHandle(Dart_Handle object) const {
|
| return false;
|
| }
|
|
|
| -
|
| intptr_t Thread::CountScopedHandles() const {
|
| intptr_t count = 0;
|
| Zone* zone = zone_;
|
| @@ -871,7 +812,6 @@ intptr_t Thread::CountScopedHandles() const {
|
| return count;
|
| }
|
|
|
| -
|
| int Thread::ZoneSizeInBytes() const {
|
| int total = 0;
|
| ApiLocalScope* scope = api_top_scope_;
|
| @@ -882,7 +822,6 @@ int Thread::ZoneSizeInBytes() const {
|
| return total;
|
| }
|
|
|
| -
|
| void Thread::UnwindScopes(uword stack_marker) {
|
| // Unwind all scopes using the same stack_marker, i.e. all scopes allocated
|
| // under the same top_exit_frame_info.
|
| @@ -895,22 +834,18 @@ void Thread::UnwindScopes(uword stack_marker) {
|
| }
|
| }
|
|
|
| -
|
| void Thread::EnterSafepointUsingLock() {
|
| isolate()->safepoint_handler()->EnterSafepointUsingLock(this);
|
| }
|
|
|
| -
|
| void Thread::ExitSafepointUsingLock() {
|
| isolate()->safepoint_handler()->ExitSafepointUsingLock(this);
|
| }
|
|
|
| -
|
| void Thread::BlockForSafepoint() {
|
| isolate()->safepoint_handler()->BlockForSafepoint(this);
|
| }
|
|
|
| -
|
| DisableThreadInterruptsScope::DisableThreadInterruptsScope(Thread* thread)
|
| : StackResource(thread) {
|
| if (thread != NULL) {
|
| @@ -920,7 +855,6 @@ DisableThreadInterruptsScope::DisableThreadInterruptsScope(Thread* thread)
|
| }
|
| }
|
|
|
| -
|
| DisableThreadInterruptsScope::~DisableThreadInterruptsScope() {
|
| if (thread() != NULL) {
|
| OSThread* os_thread = thread()->os_thread();
|
|
|