| 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 674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 685 } | 685 } |
| 686 #endif // !defined(PRODUCT) | 686 #endif // !defined(PRODUCT) |
| 687 return kError; | 687 return kError; |
| 688 } | 688 } |
| 689 } | 689 } |
| 690 return kOK; | 690 return kOK; |
| 691 } | 691 } |
| 692 | 692 |
| 693 void Isolate::FlagsInitialize(Dart_IsolateFlags* api_flags) { | 693 void Isolate::FlagsInitialize(Dart_IsolateFlags* api_flags) { |
| 694 api_flags->version = DART_FLAGS_CURRENT_VERSION; | 694 api_flags->version = DART_FLAGS_CURRENT_VERSION; |
| 695 #define INIT_FROM_FLAG(name, isolate_flag, flag) api_flags->isolate_flag = flag; | 695 #define INIT_FROM_FLAG(name, bitname, isolate_flag, flag) \ |
| 696 api_flags->isolate_flag = flag; |
| 696 ISOLATE_FLAG_LIST(INIT_FROM_FLAG) | 697 ISOLATE_FLAG_LIST(INIT_FROM_FLAG) |
| 697 #undef INIT_FROM_FLAG | 698 #undef INIT_FROM_FLAG |
| 699 api_flags->use_dart_frontend = false; |
| 698 } | 700 } |
| 699 | 701 |
| 700 void Isolate::FlagsCopyTo(Dart_IsolateFlags* api_flags) const { | 702 void Isolate::FlagsCopyTo(Dart_IsolateFlags* api_flags) const { |
| 701 api_flags->version = DART_FLAGS_CURRENT_VERSION; | 703 api_flags->version = DART_FLAGS_CURRENT_VERSION; |
| 702 #define INIT_FROM_FIELD(name, isolate_flag, flag) \ | 704 #define INIT_FROM_FIELD(name, bitname, isolate_flag, flag) \ |
| 703 api_flags->isolate_flag = name(); | 705 api_flags->isolate_flag = name(); |
| 704 ISOLATE_FLAG_LIST(INIT_FROM_FIELD) | 706 ISOLATE_FLAG_LIST(INIT_FROM_FIELD) |
| 705 #undef INIT_FROM_FIELD | 707 #undef INIT_FROM_FIELD |
| 708 api_flags->use_dart_frontend = use_dart_frontend(); |
| 706 } | 709 } |
| 707 | 710 |
| 711 void Isolate::FlagsCopyFrom(const Dart_IsolateFlags& api_flags) { |
| 708 #if !defined(PRODUCT) | 712 #if !defined(PRODUCT) |
| 709 void Isolate::FlagsCopyFrom(const Dart_IsolateFlags& api_flags) { | 713 #define SET_FROM_FLAG(name, bitname, isolate_flag, flag) \ |
| 710 #define SET_FROM_FLAG(name, isolate_flag, flag) \ | 714 isolate_flags_ = bitname##Bit::update(api_flags.isolate_flag, isolate_flags_); |
| 711 name##_ = api_flags.isolate_flag; | |
| 712 ISOLATE_FLAG_LIST(SET_FROM_FLAG) | 715 ISOLATE_FLAG_LIST(SET_FROM_FLAG) |
| 713 #undef SET_FROM_FLAG | 716 #undef SET_FROM_FLAG |
| 717 #endif // !defined(PRODUCT) |
| 718 set_use_dart_frontend(api_flags.use_dart_frontend); |
| 714 // Leave others at defaults. | 719 // Leave others at defaults. |
| 715 } | 720 } |
| 716 #endif // !defined(PRODUCT) | |
| 717 | 721 |
| 718 #if defined(DEBUG) | 722 #if defined(DEBUG) |
| 719 // static | 723 // static |
| 720 void BaseIsolate::AssertCurrent(BaseIsolate* isolate) { | 724 void BaseIsolate::AssertCurrent(BaseIsolate* isolate) { |
| 721 ASSERT(isolate == Isolate::Current()); | 725 ASSERT(isolate == Isolate::Current()); |
| 722 } | 726 } |
| 723 | 727 |
| 724 void BaseIsolate::AssertCurrentThreadIsMutator() const { | 728 void BaseIsolate::AssertCurrentThreadIsMutator() const { |
| 725 ASSERT(Isolate::Current() == this); | 729 ASSERT(Isolate::Current() == this); |
| 726 ASSERT(Thread::Current()->IsMutatorThread()); | 730 ASSERT(Thread::Current()->IsMutatorThread()); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 742 : BaseIsolate(), | 746 : BaseIsolate(), |
| 743 store_buffer_(new StoreBuffer()), | 747 store_buffer_(new StoreBuffer()), |
| 744 heap_(NULL), | 748 heap_(NULL), |
| 745 user_tag_(0), | 749 user_tag_(0), |
| 746 current_tag_(UserTag::null()), | 750 current_tag_(UserTag::null()), |
| 747 default_tag_(UserTag::null()), | 751 default_tag_(UserTag::null()), |
| 748 ic_miss_code_(Code::null()), | 752 ic_miss_code_(Code::null()), |
| 749 object_store_(NULL), | 753 object_store_(NULL), |
| 750 class_table_(), | 754 class_table_(), |
| 751 single_step_(false), | 755 single_step_(false), |
| 752 errors_fatal_(true), | 756 isolate_flags_(0), |
| 753 is_runnable_(false), | 757 background_compiler_disabled_depth_(0), |
| 754 is_service_isolate_(false), | 758 background_compiler_(NULL), |
| 755 compilation_allowed_(true), | |
| 756 all_classes_finalized_(false), | |
| 757 remapping_cids_(false), | |
| 758 #if !defined(PRODUCT) | 759 #if !defined(PRODUCT) |
| 759 resume_request_(false), | |
| 760 has_attempted_reload_(false), | |
| 761 should_pause_post_service_request_(false), | |
| 762 debugger_name_(NULL), | 760 debugger_name_(NULL), |
| 763 debugger_(NULL), | 761 debugger_(NULL), |
| 764 last_resume_timestamp_(OS::GetCurrentTimeMillis()), | 762 last_resume_timestamp_(OS::GetCurrentTimeMillis()), |
| 765 last_allocationprofile_accumulator_reset_timestamp_(0), | 763 last_allocationprofile_accumulator_reset_timestamp_(0), |
| 766 last_allocationprofile_gc_timestamp_(0), | 764 last_allocationprofile_gc_timestamp_(0), |
| 767 vm_tag_counters_(), | 765 vm_tag_counters_(), |
| 768 pending_service_extension_calls_(GrowableObjectArray::null()), | 766 pending_service_extension_calls_(GrowableObjectArray::null()), |
| 769 registered_service_extension_handlers_(GrowableObjectArray::null()), | 767 registered_service_extension_handlers_(GrowableObjectArray::null()), |
| 770 metrics_list_head_(NULL), | 768 metrics_list_head_(NULL), |
| 771 pause_loop_monitor_(NULL), | 769 pause_loop_monitor_(NULL), |
| (...skipping 30 matching lines...) Expand all Loading... |
| 802 message_handler_(NULL), | 800 message_handler_(NULL), |
| 803 spawn_state_(NULL), | 801 spawn_state_(NULL), |
| 804 gc_prologue_callback_(NULL), | 802 gc_prologue_callback_(NULL), |
| 805 gc_epilogue_callback_(NULL), | 803 gc_epilogue_callback_(NULL), |
| 806 defer_finalization_count_(0), | 804 defer_finalization_count_(0), |
| 807 pending_deopts_(new MallocGrowableArray<PendingLazyDeopt>), | 805 pending_deopts_(new MallocGrowableArray<PendingLazyDeopt>), |
| 808 deopt_context_(NULL), | 806 deopt_context_(NULL), |
| 809 tag_table_(GrowableObjectArray::null()), | 807 tag_table_(GrowableObjectArray::null()), |
| 810 deoptimized_code_array_(GrowableObjectArray::null()), | 808 deoptimized_code_array_(GrowableObjectArray::null()), |
| 811 sticky_error_(Error::null()), | 809 sticky_error_(Error::null()), |
| 812 background_compiler_(NULL), | |
| 813 background_compiler_disabled_depth_(0), | |
| 814 next_(NULL), | 810 next_(NULL), |
| 815 loading_invalidation_gen_(kInvalidGen), | 811 loading_invalidation_gen_(kInvalidGen), |
| 816 top_level_parsing_count_(0), | 812 top_level_parsing_count_(0), |
| 817 field_list_mutex_(new Mutex()), | 813 field_list_mutex_(new Mutex()), |
| 818 boxed_field_list_(GrowableObjectArray::null()), | 814 boxed_field_list_(GrowableObjectArray::null()), |
| 819 spawn_count_monitor_(new Monitor()), | 815 spawn_count_monitor_(new Monitor()), |
| 820 spawn_count_(0), | 816 spawn_count_(0), |
| 821 handler_info_cache_(), | 817 handler_info_cache_(), |
| 822 catch_entry_state_cache_() { | 818 catch_entry_state_cache_() { |
| 823 NOT_IN_PRODUCT(FlagsCopyFrom(api_flags)); | 819 FlagsCopyFrom(api_flags); |
| 820 SetErrorsFatal(true); |
| 821 set_compilation_allowed(true); |
| 824 // TODO(asiva): A Thread is not available here, need to figure out | 822 // TODO(asiva): A Thread is not available here, need to figure out |
| 825 // how the vm_tag (kEmbedderTagId) can be set, these tags need to | 823 // how the vm_tag (kEmbedderTagId) can be set, these tags need to |
| 826 // move to the OSThread structure. | 824 // move to the OSThread structure. |
| 827 set_user_tag(UserTags::kDefaultUserTag); | 825 set_user_tag(UserTags::kDefaultUserTag); |
| 828 } | 826 } |
| 829 | 827 |
| 830 #undef REUSABLE_HANDLE_SCOPE_INIT | 828 #undef REUSABLE_HANDLE_SCOPE_INIT |
| 831 #undef REUSABLE_HANDLE_INITIALIZERS | 829 #undef REUSABLE_HANDLE_INITIALIZERS |
| 832 | 830 |
| 833 Isolate::~Isolate() { | 831 Isolate::~Isolate() { |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1057 (AtomicOperations::LoadRelaxed(&no_reload_scope_depth_) == 0) && | 1055 (AtomicOperations::LoadRelaxed(&no_reload_scope_depth_) == 0) && |
| 1058 IsolateCreationEnabled(); | 1056 IsolateCreationEnabled(); |
| 1059 } | 1057 } |
| 1060 | 1058 |
| 1061 bool Isolate::ReloadSources(JSONStream* js, | 1059 bool Isolate::ReloadSources(JSONStream* js, |
| 1062 bool force_reload, | 1060 bool force_reload, |
| 1063 const char* root_script_url, | 1061 const char* root_script_url, |
| 1064 const char* packages_url, | 1062 const char* packages_url, |
| 1065 bool dont_delete_reload_context) { | 1063 bool dont_delete_reload_context) { |
| 1066 ASSERT(!IsReloading()); | 1064 ASSERT(!IsReloading()); |
| 1067 has_attempted_reload_ = true; | 1065 SetHasAttemptedReload(true); |
| 1068 reload_context_ = new IsolateReloadContext(this, js); | 1066 reload_context_ = new IsolateReloadContext(this, js); |
| 1069 reload_context_->Reload(force_reload, root_script_url, packages_url); | 1067 reload_context_->Reload(force_reload, root_script_url, packages_url); |
| 1070 bool success = !reload_context_->reload_aborted(); | 1068 bool success = !reload_context_->reload_aborted(); |
| 1071 if (!dont_delete_reload_context) { | 1069 if (!dont_delete_reload_context) { |
| 1072 DeleteReloadContext(); | 1070 DeleteReloadContext(); |
| 1073 } | 1071 } |
| 1074 return success; | 1072 return success; |
| 1075 } | 1073 } |
| 1076 | 1074 |
| 1077 void Isolate::DeleteReloadContext() { | 1075 void Isolate::DeleteReloadContext() { |
| (...skipping 759 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1837 #ifndef PRODUCT | 1835 #ifndef PRODUCT |
| 1838 if (IsReloading()) { | 1836 if (IsReloading()) { |
| 1839 raw_class = reload_context()->GetClassForHeapWalkAt(cid); | 1837 raw_class = reload_context()->GetClassForHeapWalkAt(cid); |
| 1840 } else { | 1838 } else { |
| 1841 raw_class = class_table()->At(cid); | 1839 raw_class = class_table()->At(cid); |
| 1842 } | 1840 } |
| 1843 #else | 1841 #else |
| 1844 raw_class = class_table()->At(cid); | 1842 raw_class = class_table()->At(cid); |
| 1845 #endif // !PRODUCT | 1843 #endif // !PRODUCT |
| 1846 ASSERT(raw_class != NULL); | 1844 ASSERT(raw_class != NULL); |
| 1847 ASSERT(remapping_cids_ || raw_class->ptr()->id_ == cid); | 1845 ASSERT(remapping_cids() || raw_class->ptr()->id_ == cid); |
| 1848 return raw_class; | 1846 return raw_class; |
| 1849 } | 1847 } |
| 1850 | 1848 |
| 1851 void Isolate::AddPendingDeopt(uword fp, uword pc) { | 1849 void Isolate::AddPendingDeopt(uword fp, uword pc) { |
| 1852 // GrowableArray::Add is not atomic and may be interrupt by a profiler | 1850 // GrowableArray::Add is not atomic and may be interrupt by a profiler |
| 1853 // stack walk. | 1851 // stack walk. |
| 1854 MallocGrowableArray<PendingLazyDeopt>* old_pending_deopts = pending_deopts_; | 1852 MallocGrowableArray<PendingLazyDeopt>* old_pending_deopts = pending_deopts_; |
| 1855 MallocGrowableArray<PendingLazyDeopt>* new_pending_deopts = | 1853 MallocGrowableArray<PendingLazyDeopt>* new_pending_deopts = |
| 1856 new MallocGrowableArray<PendingLazyDeopt>(old_pending_deopts->length() + | 1854 new MallocGrowableArray<PendingLazyDeopt>(old_pending_deopts->length() + |
| 1857 1); | 1855 1); |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1937 } else if (message_handler()->is_paused_on_start() || | 1935 } else if (message_handler()->is_paused_on_start() || |
| 1938 message_handler()->should_pause_on_start()) { | 1936 message_handler()->should_pause_on_start()) { |
| 1939 ASSERT((debugger() == NULL) || (debugger()->PauseEvent() == NULL)); | 1937 ASSERT((debugger() == NULL) || (debugger()->PauseEvent() == NULL)); |
| 1940 ServiceEvent pause_event(this, ServiceEvent::kPauseStart); | 1938 ServiceEvent pause_event(this, ServiceEvent::kPauseStart); |
| 1941 jsobj.AddProperty("pauseEvent", &pause_event); | 1939 jsobj.AddProperty("pauseEvent", &pause_event); |
| 1942 } else if (message_handler()->is_paused_on_exit() && | 1940 } else if (message_handler()->is_paused_on_exit() && |
| 1943 ((debugger() == NULL) || (debugger()->PauseEvent() == NULL))) { | 1941 ((debugger() == NULL) || (debugger()->PauseEvent() == NULL))) { |
| 1944 ServiceEvent pause_event(this, ServiceEvent::kPauseExit); | 1942 ServiceEvent pause_event(this, ServiceEvent::kPauseExit); |
| 1945 jsobj.AddProperty("pauseEvent", &pause_event); | 1943 jsobj.AddProperty("pauseEvent", &pause_event); |
| 1946 } else if ((debugger() != NULL) && (debugger()->PauseEvent() != NULL) && | 1944 } else if ((debugger() != NULL) && (debugger()->PauseEvent() != NULL) && |
| 1947 !resume_request_) { | 1945 !ResumeRequest()) { |
| 1948 jsobj.AddProperty("pauseEvent", debugger()->PauseEvent()); | 1946 jsobj.AddProperty("pauseEvent", debugger()->PauseEvent()); |
| 1949 } else { | 1947 } else { |
| 1950 ServiceEvent pause_event(this, ServiceEvent::kResume); | 1948 ServiceEvent pause_event(this, ServiceEvent::kResume); |
| 1951 | 1949 |
| 1952 if (debugger() != NULL) { | 1950 if (debugger() != NULL) { |
| 1953 // TODO(turnidge): Don't compute a full stack trace. | 1951 // TODO(turnidge): Don't compute a full stack trace. |
| 1954 DebuggerStackTrace* stack = debugger()->StackTrace(); | 1952 DebuggerStackTrace* stack = debugger()->StackTrace(); |
| 1955 if (stack->Length() > 0) { | 1953 if (stack->Length() > 0) { |
| 1956 pause_event.set_top_frame(stack->FrameAt(0)); | 1954 pause_event.set_top_frame(stack->FrameAt(0)); |
| 1957 } | 1955 } |
| (...skipping 876 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2834 void IsolateSpawnState::DecrementSpawnCount() { | 2832 void IsolateSpawnState::DecrementSpawnCount() { |
| 2835 ASSERT(spawn_count_monitor_ != NULL); | 2833 ASSERT(spawn_count_monitor_ != NULL); |
| 2836 ASSERT(spawn_count_ != NULL); | 2834 ASSERT(spawn_count_ != NULL); |
| 2837 MonitorLocker ml(spawn_count_monitor_); | 2835 MonitorLocker ml(spawn_count_monitor_); |
| 2838 ASSERT(*spawn_count_ > 0); | 2836 ASSERT(*spawn_count_ > 0); |
| 2839 *spawn_count_ = *spawn_count_ - 1; | 2837 *spawn_count_ = *spawn_count_ - 1; |
| 2840 ml.Notify(); | 2838 ml.Notify(); |
| 2841 } | 2839 } |
| 2842 | 2840 |
| 2843 } // namespace dart | 2841 } // namespace dart |
| OLD | NEW |