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 2758 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2769 memmove(mem, chars, len + 1); | 2769 memmove(mem, chars, len + 1); |
2770 return mem; | 2770 return mem; |
2771 } | 2771 } |
2772 | 2772 |
2773 | 2773 |
2774 IsolateSpawnState::IsolateSpawnState(Dart_Port parent_port, | 2774 IsolateSpawnState::IsolateSpawnState(Dart_Port parent_port, |
2775 Dart_Port origin_id, | 2775 Dart_Port origin_id, |
2776 void* init_data, | 2776 void* init_data, |
2777 const char* script_url, | 2777 const char* script_url, |
2778 const Function& func, | 2778 const Function& func, |
2779 SerializedObjectBuffer* message_buffer, | 2779 const Instance& message, |
2780 Monitor* spawn_count_monitor, | 2780 Monitor* spawn_count_monitor, |
2781 intptr_t* spawn_count, | 2781 intptr_t* spawn_count, |
2782 const char* package_root, | 2782 const char* package_root, |
2783 const char* package_config, | 2783 const char* package_config, |
2784 bool paused, | 2784 bool paused, |
2785 bool errors_are_fatal, | 2785 bool errors_are_fatal, |
2786 Dart_Port on_exit_port, | 2786 Dart_Port on_exit_port, |
2787 Dart_Port on_error_port) | 2787 Dart_Port on_error_port) |
2788 : isolate_(NULL), | 2788 : isolate_(NULL), |
2789 parent_port_(parent_port), | 2789 parent_port_(parent_port), |
(...skipping 21 matching lines...) Expand all Loading... |
2811 library_url_ = NewConstChar(lib_url.ToCString()); | 2811 library_url_ = NewConstChar(lib_url.ToCString()); |
2812 | 2812 |
2813 String& func_name = String::Handle(); | 2813 String& func_name = String::Handle(); |
2814 func_name ^= func.name(); | 2814 func_name ^= func.name(); |
2815 func_name ^= String::ScrubName(func_name); | 2815 func_name ^= String::ScrubName(func_name); |
2816 function_name_ = NewConstChar(func_name.ToCString()); | 2816 function_name_ = NewConstChar(func_name.ToCString()); |
2817 if (!cls.IsTopLevel()) { | 2817 if (!cls.IsTopLevel()) { |
2818 const String& class_name = String::Handle(cls.Name()); | 2818 const String& class_name = String::Handle(cls.Name()); |
2819 class_name_ = NewConstChar(class_name.ToCString()); | 2819 class_name_ = NewConstChar(class_name.ToCString()); |
2820 } | 2820 } |
2821 message_buffer->StealBuffer(&serialized_message_, &serialized_message_len_); | 2821 bool can_send_any_object = true; |
2822 | 2822 SerializeObject(message, &serialized_message_, &serialized_message_len_, |
| 2823 can_send_any_object); |
2823 // Inherit flags from spawning isolate. | 2824 // Inherit flags from spawning isolate. |
2824 Isolate::Current()->FlagsCopyTo(isolate_flags()); | 2825 Isolate::Current()->FlagsCopyTo(isolate_flags()); |
2825 } | 2826 } |
2826 | 2827 |
2827 | 2828 |
2828 IsolateSpawnState::IsolateSpawnState(Dart_Port parent_port, | 2829 IsolateSpawnState::IsolateSpawnState(Dart_Port parent_port, |
2829 void* init_data, | 2830 void* init_data, |
2830 const char* script_url, | 2831 const char* script_url, |
2831 const char* package_root, | 2832 const char* package_root, |
2832 const char* package_config, | 2833 const char* package_config, |
2833 SerializedObjectBuffer* args_buffer, | 2834 const Instance& args, |
2834 SerializedObjectBuffer* message_buffer, | 2835 const Instance& message, |
2835 Monitor* spawn_count_monitor, | 2836 Monitor* spawn_count_monitor, |
2836 intptr_t* spawn_count, | 2837 intptr_t* spawn_count, |
2837 bool paused, | 2838 bool paused, |
2838 bool errors_are_fatal, | 2839 bool errors_are_fatal, |
2839 Dart_Port on_exit_port, | 2840 Dart_Port on_exit_port, |
2840 Dart_Port on_error_port) | 2841 Dart_Port on_error_port) |
2841 : isolate_(NULL), | 2842 : isolate_(NULL), |
2842 parent_port_(parent_port), | 2843 parent_port_(parent_port), |
2843 origin_id_(ILLEGAL_PORT), | 2844 origin_id_(ILLEGAL_PORT), |
2844 init_data_(init_data), | 2845 init_data_(init_data), |
2845 on_exit_port_(on_exit_port), | 2846 on_exit_port_(on_exit_port), |
2846 on_error_port_(on_error_port), | 2847 on_error_port_(on_error_port), |
2847 script_url_(script_url), | 2848 script_url_(script_url), |
2848 package_root_(package_root), | 2849 package_root_(package_root), |
2849 package_config_(package_config), | 2850 package_config_(package_config), |
2850 library_url_(NULL), | 2851 library_url_(NULL), |
2851 class_name_(NULL), | 2852 class_name_(NULL), |
2852 function_name_(NULL), | 2853 function_name_(NULL), |
2853 serialized_args_(NULL), | 2854 serialized_args_(NULL), |
2854 serialized_args_len_(0), | 2855 serialized_args_len_(0), |
2855 serialized_message_(NULL), | 2856 serialized_message_(NULL), |
2856 serialized_message_len_(0), | 2857 serialized_message_len_(0), |
2857 spawn_count_monitor_(spawn_count_monitor), | 2858 spawn_count_monitor_(spawn_count_monitor), |
2858 spawn_count_(spawn_count), | 2859 spawn_count_(spawn_count), |
2859 isolate_flags_(), | 2860 isolate_flags_(), |
2860 paused_(paused), | 2861 paused_(paused), |
2861 errors_are_fatal_(errors_are_fatal) { | 2862 errors_are_fatal_(errors_are_fatal) { |
2862 function_name_ = NewConstChar("main"); | 2863 function_name_ = NewConstChar("main"); |
2863 args_buffer->StealBuffer(&serialized_args_, &serialized_args_len_); | 2864 bool can_send_any_object = false; |
2864 message_buffer->StealBuffer(&serialized_message_, &serialized_message_len_); | 2865 SerializeObject(args, &serialized_args_, &serialized_args_len_, |
2865 | 2866 can_send_any_object); |
| 2867 SerializeObject(message, &serialized_message_, &serialized_message_len_, |
| 2868 can_send_any_object); |
2866 // By default inherit flags from spawning isolate. These can be overridden | 2869 // By default inherit flags from spawning isolate. These can be overridden |
2867 // from the calling code. | 2870 // from the calling code. |
2868 Isolate::Current()->FlagsCopyTo(isolate_flags()); | 2871 Isolate::Current()->FlagsCopyTo(isolate_flags()); |
2869 } | 2872 } |
2870 | 2873 |
2871 | 2874 |
2872 IsolateSpawnState::~IsolateSpawnState() { | 2875 IsolateSpawnState::~IsolateSpawnState() { |
2873 delete[] script_url_; | 2876 delete[] script_url_; |
2874 delete[] package_root_; | 2877 delete[] package_root_; |
2875 delete[] package_config_; | 2878 delete[] package_config_; |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2973 void IsolateSpawnState::DecrementSpawnCount() { | 2976 void IsolateSpawnState::DecrementSpawnCount() { |
2974 ASSERT(spawn_count_monitor_ != NULL); | 2977 ASSERT(spawn_count_monitor_ != NULL); |
2975 ASSERT(spawn_count_ != NULL); | 2978 ASSERT(spawn_count_ != NULL); |
2976 MonitorLocker ml(spawn_count_monitor_); | 2979 MonitorLocker ml(spawn_count_monitor_); |
2977 ASSERT(*spawn_count_ > 0); | 2980 ASSERT(*spawn_count_ > 0); |
2978 *spawn_count_ = *spawn_count_ - 1; | 2981 *spawn_count_ = *spawn_count_ - 1; |
2979 ml.Notify(); | 2982 ml.Notify(); |
2980 } | 2983 } |
2981 | 2984 |
2982 } // namespace dart | 2985 } // namespace dart |
OLD | NEW |