| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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/isolate.h" | 5 #include "vm/isolate.h" |
| 6 | 6 |
| 7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
| 8 #include "include/dart_native_api.h" | 8 #include "include/dart_native_api.h" |
| 9 #include "platform/assert.h" | 9 #include "platform/assert.h" |
| 10 #include "platform/text_buffer.h" | 10 #include "platform/text_buffer.h" |
| (...skipping 741 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 752 origin_id_(0), | 752 origin_id_(0), |
| 753 pause_capability_(0), | 753 pause_capability_(0), |
| 754 terminate_capability_(0), | 754 terminate_capability_(0), |
| 755 errors_fatal_(true), | 755 errors_fatal_(true), |
| 756 init_callback_data_(NULL), | 756 init_callback_data_(NULL), |
| 757 environment_callback_(NULL), | 757 environment_callback_(NULL), |
| 758 library_tag_handler_(NULL), | 758 library_tag_handler_(NULL), |
| 759 api_state_(NULL), | 759 api_state_(NULL), |
| 760 #if !defined(PRODUCT) | 760 #if !defined(PRODUCT) |
| 761 debugger_(NULL), | 761 debugger_(NULL), |
| 762 #endif | |
| 763 resume_request_(false), | 762 resume_request_(false), |
| 764 last_resume_timestamp_(OS::GetCurrentTimeMillis()), | 763 last_resume_timestamp_(OS::GetCurrentTimeMillis()), |
| 764 #endif |
| 765 random_(), | 765 random_(), |
| 766 simulator_(NULL), | 766 simulator_(NULL), |
| 767 mutex_(new Mutex()), | 767 mutex_(new Mutex()), |
| 768 symbols_mutex_(new Mutex()), | 768 symbols_mutex_(new Mutex()), |
| 769 type_canonicalization_mutex_(new Mutex()), | 769 type_canonicalization_mutex_(new Mutex()), |
| 770 constant_canonicalization_mutex_(new Mutex()), | 770 constant_canonicalization_mutex_(new Mutex()), |
| 771 megamorphic_lookup_mutex_(new Mutex()), | 771 megamorphic_lookup_mutex_(new Mutex()), |
| 772 message_handler_(NULL), | 772 message_handler_(NULL), |
| 773 spawn_state_(NULL), | 773 spawn_state_(NULL), |
| 774 is_runnable_(false), | 774 is_runnable_(false), |
| (...skipping 1497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2272 String& handler_name = String::Handle(); | 2272 String& handler_name = String::Handle(); |
| 2273 for (intptr_t i = 0; i < handlers.Length(); i += kRegisteredEntrySize) { | 2273 for (intptr_t i = 0; i < handlers.Length(); i += kRegisteredEntrySize) { |
| 2274 handler_name ^= handlers.At(i + kRegisteredNameIndex); | 2274 handler_name ^= handlers.At(i + kRegisteredNameIndex); |
| 2275 ASSERT(!handler_name.IsNull()); | 2275 ASSERT(!handler_name.IsNull()); |
| 2276 if (handler_name.Equals(name)) { | 2276 if (handler_name.Equals(name)) { |
| 2277 return Instance::RawCast(handlers.At(i + kRegisteredHandlerIndex)); | 2277 return Instance::RawCast(handlers.At(i + kRegisteredHandlerIndex)); |
| 2278 } | 2278 } |
| 2279 } | 2279 } |
| 2280 return Instance::null(); | 2280 return Instance::null(); |
| 2281 } | 2281 } |
| 2282 #endif // !PRODUCT | |
| 2283 | 2282 |
| 2284 void Isolate::WakePauseEventHandler(Dart_Isolate isolate) { | 2283 void Isolate::WakePauseEventHandler(Dart_Isolate isolate) { |
| 2285 Isolate* iso = reinterpret_cast<Isolate*>(isolate); | 2284 Isolate* iso = reinterpret_cast<Isolate*>(isolate); |
| 2286 MonitorLocker ml(iso->pause_loop_monitor_); | 2285 MonitorLocker ml(iso->pause_loop_monitor_); |
| 2287 ml.Notify(); | 2286 ml.Notify(); |
| 2288 } | 2287 } |
| 2289 | 2288 |
| 2290 void Isolate::PauseEventHandler() { | 2289 void Isolate::PauseEventHandler() { |
| 2291 // We are stealing a pause event (like a breakpoint) from the | 2290 // We are stealing a pause event (like a breakpoint) from the |
| 2292 // embedder. We don't know what kind of thread we are on -- it | 2291 // embedder. We don't know what kind of thread we are on -- it |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2328 break; | 2327 break; |
| 2329 } | 2328 } |
| 2330 | 2329 |
| 2331 // Wait for more service messages. | 2330 // Wait for more service messages. |
| 2332 Monitor::WaitResult res = ml.Wait(); | 2331 Monitor::WaitResult res = ml.Wait(); |
| 2333 ASSERT(res == Monitor::kNotified); | 2332 ASSERT(res == Monitor::kNotified); |
| 2334 } | 2333 } |
| 2335 set_message_notify_callback(saved_notify_callback); | 2334 set_message_notify_callback(saved_notify_callback); |
| 2336 Dart_ExitScope(); | 2335 Dart_ExitScope(); |
| 2337 } | 2336 } |
| 2337 #endif // !PRODUCT |
| 2338 | 2338 |
| 2339 void Isolate::VisitIsolates(IsolateVisitor* visitor) { | 2339 void Isolate::VisitIsolates(IsolateVisitor* visitor) { |
| 2340 if (visitor == NULL) { | 2340 if (visitor == NULL) { |
| 2341 return; | 2341 return; |
| 2342 } | 2342 } |
| 2343 // The visitor could potentially run code that could safepoint so use | 2343 // The visitor could potentially run code that could safepoint so use |
| 2344 // SafepointMonitorLocker to ensure the lock has safepoint checks. | 2344 // SafepointMonitorLocker to ensure the lock has safepoint checks. |
| 2345 SafepointMonitorLocker ml(isolates_list_monitor_); | 2345 SafepointMonitorLocker ml(isolates_list_monitor_); |
| 2346 Isolate* current = isolates_list_head_; | 2346 Isolate* current = isolates_list_head_; |
| 2347 while (current) { | 2347 while (current) { |
| (...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2836 void IsolateSpawnState::DecrementSpawnCount() { | 2836 void IsolateSpawnState::DecrementSpawnCount() { |
| 2837 ASSERT(spawn_count_monitor_ != NULL); | 2837 ASSERT(spawn_count_monitor_ != NULL); |
| 2838 ASSERT(spawn_count_ != NULL); | 2838 ASSERT(spawn_count_ != NULL); |
| 2839 MonitorLocker ml(spawn_count_monitor_); | 2839 MonitorLocker ml(spawn_count_monitor_); |
| 2840 ASSERT(*spawn_count_ > 0); | 2840 ASSERT(*spawn_count_ > 0); |
| 2841 *spawn_count_ = *spawn_count_ - 1; | 2841 *spawn_count_ = *spawn_count_ - 1; |
| 2842 ml.Notify(); | 2842 ml.Notify(); |
| 2843 } | 2843 } |
| 2844 | 2844 |
| 2845 } // namespace dart | 2845 } // namespace dart |
| OLD | NEW |