| 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 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 } | 206 } |
| 207 | 207 |
| 208 | 208 |
| 209 #ifndef PRODUCT | 209 #ifndef PRODUCT |
| 210 // Collect information about each individual zone associated with this thread. | 210 // Collect information about each individual zone associated with this thread. |
| 211 void Thread::PrintJSON(JSONStream* stream) const { | 211 void Thread::PrintJSON(JSONStream* stream) const { |
| 212 JSONObject jsobj(stream); | 212 JSONObject jsobj(stream); |
| 213 jsobj.AddProperty("type", "_Thread"); | 213 jsobj.AddProperty("type", "_Thread"); |
| 214 jsobj.AddPropertyF("id", "threads/%" Pd "", | 214 jsobj.AddPropertyF("id", "threads/%" Pd "", |
| 215 OSThread::ThreadIdToIntPtr(os_thread()->trace_id())); | 215 OSThread::ThreadIdToIntPtr(os_thread()->trace_id())); |
| 216 jsobj.AddProperty("kind", TaskKindToCString(task_kind())); |
| 216 Zone* zone = zone_; | 217 Zone* zone = zone_; |
| 217 { | 218 { |
| 218 JSONArray zone_info_array(&jsobj, "zones"); | 219 JSONArray zone_info_array(&jsobj, "zones"); |
| 219 zone = zone_; | 220 zone = zone_; |
| 220 while (zone != NULL) { | 221 while (zone != NULL) { |
| 221 zone_info_array.AddValue(zone); | 222 zone_info_array.AddValue(zone); |
| 222 zone = zone->previous(); | 223 zone = zone->previous(); |
| 223 } | 224 } |
| 224 } | 225 } |
| 225 } | 226 } |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 ASSERT(!value.IsNull()); | 260 ASSERT(!value.IsNull()); |
| 260 sticky_error_ = value.raw(); | 261 sticky_error_ = value.raw(); |
| 261 } | 262 } |
| 262 | 263 |
| 263 | 264 |
| 264 void Thread::clear_sticky_error() { | 265 void Thread::clear_sticky_error() { |
| 265 sticky_error_ = Error::null(); | 266 sticky_error_ = Error::null(); |
| 266 } | 267 } |
| 267 | 268 |
| 268 | 269 |
| 270 const char* Thread::TaskKindToCString(TaskKind kind) { |
| 271 switch (kind) { |
| 272 case kUnknownTask: |
| 273 return "kUnknownTask"; |
| 274 case kMutatorTask: |
| 275 return "kMutatorTask"; |
| 276 case kCompilerTask: |
| 277 return "kCompilerTask"; |
| 278 case kSweeperTask: |
| 279 return "kSweeperTask"; |
| 280 case kMarkerTask: |
| 281 return "kMarkerTask"; |
| 282 case kFinalizerTask: |
| 283 return "kFinalizerTask"; |
| 284 default: |
| 285 UNREACHABLE(); |
| 286 return ""; |
| 287 } |
| 288 } |
| 289 |
| 290 |
| 269 bool Thread::EnterIsolate(Isolate* isolate) { | 291 bool Thread::EnterIsolate(Isolate* isolate) { |
| 270 const bool kIsMutatorThread = true; | 292 const bool kIsMutatorThread = true; |
| 271 Thread* thread = isolate->ScheduleThread(kIsMutatorThread); | 293 Thread* thread = isolate->ScheduleThread(kIsMutatorThread); |
| 272 if (thread != NULL) { | 294 if (thread != NULL) { |
| 273 ASSERT(thread->store_buffer_block_ == NULL); | 295 ASSERT(thread->store_buffer_block_ == NULL); |
| 274 thread->task_kind_ = kMutatorTask; | 296 thread->task_kind_ = kMutatorTask; |
| 275 thread->StoreBufferAcquire(); | 297 thread->StoreBufferAcquire(); |
| 276 return true; | 298 return true; |
| 277 } | 299 } |
| 278 return false; | 300 return false; |
| (...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 794 | 816 |
| 795 DisableThreadInterruptsScope::~DisableThreadInterruptsScope() { | 817 DisableThreadInterruptsScope::~DisableThreadInterruptsScope() { |
| 796 if (thread() != NULL) { | 818 if (thread() != NULL) { |
| 797 OSThread* os_thread = thread()->os_thread(); | 819 OSThread* os_thread = thread()->os_thread(); |
| 798 ASSERT(os_thread != NULL); | 820 ASSERT(os_thread != NULL); |
| 799 os_thread->EnableThreadInterrupts(); | 821 os_thread->EnableThreadInterrupts(); |
| 800 } | 822 } |
| 801 } | 823 } |
| 802 | 824 |
| 803 } // namespace dart | 825 } // namespace dart |
| OLD | NEW |