| 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 "platform/assert.h" | 8 #include "platform/assert.h" |
| 9 #include "platform/json.h" | 9 #include "platform/json.h" |
| 10 #include "vm/code_observers.h" | 10 #include "vm/code_observers.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 DEFINE_FLAG(bool, break_at_isolate_spawn, false, | 50 DEFINE_FLAG(bool, break_at_isolate_spawn, false, |
| 51 "Insert a one-time breakpoint at the entrypoint for all spawned " | 51 "Insert a one-time breakpoint at the entrypoint for all spawned " |
| 52 "isolates"); | 52 "isolates"); |
| 53 DEFINE_FLAG(charp, isolate_log_filter, NULL, | 53 DEFINE_FLAG(charp, isolate_log_filter, NULL, |
| 54 "Log isolates whose name include the filter. " | 54 "Log isolates whose name include the filter. " |
| 55 "Default: service isolate log messages are suppressed."); | 55 "Default: service isolate log messages are suppressed."); |
| 56 | 56 |
| 57 // Quick access to the locally defined isolate() method. | 57 // Quick access to the locally defined isolate() method. |
| 58 #define I (isolate()) | 58 #define I (isolate()) |
| 59 | 59 |
| 60 | |
| 61 #if defined(DEBUG) | 60 #if defined(DEBUG) |
| 62 // Helper class to ensure that a live origin_id is never reused | 61 // Helper class to ensure that a live origin_id is never reused |
| 63 // and assigned to an isolate. | 62 // and assigned to an isolate. |
| 64 class VerifyOriginId : public IsolateVisitor { | 63 class VerifyOriginId : public IsolateVisitor { |
| 65 public: | 64 public: |
| 66 explicit VerifyOriginId(Dart_Port id) : id_(id) {} | 65 explicit VerifyOriginId(Dart_Port id) : id_(id) {} |
| 67 | 66 |
| 68 void VisitIsolate(Isolate* isolate) { | 67 void VisitIsolate(Isolate* isolate) { |
| 69 ASSERT(isolate->origin_id() != id_); | 68 ASSERT(isolate->origin_id() != id_); |
| 70 } | 69 } |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 if (message->RedirectToDeliveryFailurePort()) { | 363 if (message->RedirectToDeliveryFailurePort()) { |
| 365 PortMap::PostMessage(message); | 364 PortMap::PostMessage(message); |
| 366 } else { | 365 } else { |
| 367 delete message; | 366 delete message; |
| 368 } | 367 } |
| 369 return true; | 368 return true; |
| 370 } | 369 } |
| 371 } | 370 } |
| 372 | 371 |
| 373 // Parse the message. | 372 // Parse the message. |
| 374 SnapshotReader reader(message->data(), message->len(), Snapshot::kMessage, | 373 MessageSnapshotReader reader(message->data(), |
| 375 I, zone.GetZone()); | 374 message->len(), |
| 375 I, zone.GetZone()); |
| 376 const Object& msg_obj = Object::Handle(I, reader.ReadObject()); | 376 const Object& msg_obj = Object::Handle(I, reader.ReadObject()); |
| 377 if (msg_obj.IsError()) { | 377 if (msg_obj.IsError()) { |
| 378 // An error occurred while reading the message. | 378 // An error occurred while reading the message. |
| 379 delete message; | 379 delete message; |
| 380 return ProcessUnhandledException(Error::Cast(msg_obj)); | 380 return ProcessUnhandledException(Error::Cast(msg_obj)); |
| 381 } | 381 } |
| 382 if (!msg_obj.IsNull() && !msg_obj.IsInstance()) { | 382 if (!msg_obj.IsNull() && !msg_obj.IsInstance()) { |
| 383 // TODO(turnidge): We need to decide what an isolate does with | 383 // TODO(turnidge): We need to decide what an isolate does with |
| 384 // malformed messages. If they (eventually) come from a remote | 384 // malformed messages. If they (eventually) come from a remote |
| 385 // machine, then it might make sense to drop the message entirely. | 385 // machine, then it might make sense to drop the message entirely. |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 669 stack_frame_index_(-1), | 669 stack_frame_index_(-1), |
| 670 last_allocationprofile_accumulator_reset_timestamp_(0), | 670 last_allocationprofile_accumulator_reset_timestamp_(0), |
| 671 last_allocationprofile_gc_timestamp_(0), | 671 last_allocationprofile_gc_timestamp_(0), |
| 672 object_id_ring_(NULL), | 672 object_id_ring_(NULL), |
| 673 trace_buffer_(NULL), | 673 trace_buffer_(NULL), |
| 674 profiler_data_(NULL), | 674 profiler_data_(NULL), |
| 675 thread_state_(NULL), | 675 thread_state_(NULL), |
| 676 tag_table_(GrowableObjectArray::null()), | 676 tag_table_(GrowableObjectArray::null()), |
| 677 current_tag_(UserTag::null()), | 677 current_tag_(UserTag::null()), |
| 678 default_tag_(UserTag::null()), | 678 default_tag_(UserTag::null()), |
| 679 deoptimized_code_array_(GrowableObjectArray::null()), |
| 679 metrics_list_head_(NULL), | 680 metrics_list_head_(NULL), |
| 680 cha_(NULL), | 681 cha_(NULL), |
| 681 next_(NULL), | 682 next_(NULL), |
| 682 pause_loop_monitor_(NULL), | 683 pause_loop_monitor_(NULL), |
| 683 REUSABLE_HANDLE_LIST(REUSABLE_HANDLE_INITIALIZERS) | 684 REUSABLE_HANDLE_LIST(REUSABLE_HANDLE_INITIALIZERS) |
| 684 REUSABLE_HANDLE_LIST(REUSABLE_HANDLE_SCOPE_INIT) | 685 REUSABLE_HANDLE_LIST(REUSABLE_HANDLE_SCOPE_INIT) |
| 685 reusable_handles_() { | 686 reusable_handles_() { |
| 686 } | 687 } |
| 687 #undef REUSABLE_HANDLE_SCOPE_INIT | 688 #undef REUSABLE_HANDLE_SCOPE_INIT |
| 688 #undef REUSABLE_HANDLE_INITIALIZERS | 689 #undef REUSABLE_HANDLE_INITIALIZERS |
| (...skipping 1168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1857 } | 1858 } |
| 1858 | 1859 |
| 1859 | 1860 |
| 1860 static RawInstance* DeserializeObject(Isolate* isolate, | 1861 static RawInstance* DeserializeObject(Isolate* isolate, |
| 1861 Zone* zone, | 1862 Zone* zone, |
| 1862 uint8_t* obj_data, | 1863 uint8_t* obj_data, |
| 1863 intptr_t obj_len) { | 1864 intptr_t obj_len) { |
| 1864 if (obj_data == NULL) { | 1865 if (obj_data == NULL) { |
| 1865 return Instance::null(); | 1866 return Instance::null(); |
| 1866 } | 1867 } |
| 1867 SnapshotReader reader(obj_data, obj_len, Snapshot::kMessage, isolate, zone); | 1868 MessageSnapshotReader reader(obj_data, |
| 1869 obj_len, |
| 1870 isolate, |
| 1871 zone); |
| 1868 const Object& obj = Object::Handle(isolate, reader.ReadObject()); | 1872 const Object& obj = Object::Handle(isolate, reader.ReadObject()); |
| 1869 ASSERT(!obj.IsError()); | 1873 ASSERT(!obj.IsError()); |
| 1870 Instance& instance = Instance::Handle(isolate); | 1874 Instance& instance = Instance::Handle(isolate); |
| 1871 instance ^= obj.raw(); // Can't use Instance::Cast because may be null. | 1875 instance ^= obj.raw(); // Can't use Instance::Cast because may be null. |
| 1872 return instance.raw(); | 1876 return instance.raw(); |
| 1873 } | 1877 } |
| 1874 | 1878 |
| 1875 | 1879 |
| 1876 IsolateSpawnState::IsolateSpawnState(Dart_Port parent_port, | 1880 IsolateSpawnState::IsolateSpawnState(Dart_Port parent_port, |
| 1877 const Function& func, | 1881 const Function& func, |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2034 serialized_message_, serialized_message_len_); | 2038 serialized_message_, serialized_message_len_); |
| 2035 } | 2039 } |
| 2036 | 2040 |
| 2037 | 2041 |
| 2038 void IsolateSpawnState::Cleanup() { | 2042 void IsolateSpawnState::Cleanup() { |
| 2039 SwitchIsolateScope switch_scope(I); | 2043 SwitchIsolateScope switch_scope(I); |
| 2040 Dart::ShutdownIsolate(); | 2044 Dart::ShutdownIsolate(); |
| 2041 } | 2045 } |
| 2042 | 2046 |
| 2043 } // namespace dart | 2047 } // namespace dart |
| OLD | NEW |