Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(102)

Side by Side Diff: runtime/vm/isolate.cc

Issue 1737693003: - Remove Isolate::Flags structure and store flags directly in isolate. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Address review comments. Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/vm/isolate.h ('k') | runtime/vm/jit_optimizer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 70
71 DEFINE_FLAG(int, new_gen_semi_max_size, (kWordSize <= 4) ? 16 : 32, 71 DEFINE_FLAG(int, new_gen_semi_max_size, (kWordSize <= 4) ? 16 : 32,
72 "Max size of new gen semi space in MB"); 72 "Max size of new gen semi space in MB");
73 DEFINE_FLAG(int, old_gen_heap_size, 0, 73 DEFINE_FLAG(int, old_gen_heap_size, 0,
74 "Max size of old gen heap size in MB, or 0 for unlimited," 74 "Max size of old gen heap size in MB, or 0 for unlimited,"
75 "e.g: --old_gen_heap_size=1024 allows up to 1024MB old gen heap"); 75 "e.g: --old_gen_heap_size=1024 allows up to 1024MB old gen heap");
76 DEFINE_FLAG(int, external_max_size, (kWordSize <= 4) ? 512 : 1024, 76 DEFINE_FLAG(int, external_max_size, (kWordSize <= 4) ? 512 : 1024,
77 "Max total size of external allocations in MB, or 0 for unlimited," 77 "Max total size of external allocations in MB, or 0 for unlimited,"
78 "e.g: --external_max_size=1024 allows up to 1024MB of externals"); 78 "e.g: --external_max_size=1024 allows up to 1024MB of externals");
79 79
80 // TODO(iposva): Make these isolate specific flags inaccessible using the
81 // regular FLAG_xyz pattern.
82 // These flags are per-isolate and only influence the defaults.
83 DEFINE_FLAG(bool, enable_asserts, false, "Enable assert statements.");
84 DEFINE_FLAG(bool, enable_type_checks, false, "Enable type checks.");
85 DEFINE_FLAG(bool, error_on_bad_override, false,
86 "Report error for bad overrides.");
87 DEFINE_FLAG(bool, error_on_bad_type, false,
88 "Report error for malformed types.");
89
90 DECLARE_FLAG(bool, warn_on_pause_with_no_debugger); 80 DECLARE_FLAG(bool, warn_on_pause_with_no_debugger);
91 81
82 NOT_IN_PRODUCT(
92 static void CheckedModeHandler(bool value) { 83 static void CheckedModeHandler(bool value) {
93 FLAG_enable_asserts = value; 84 FLAG_enable_asserts = value;
94 FLAG_enable_type_checks = value; 85 FLAG_enable_type_checks = value;
95 } 86 }
96 87
97 // --enable-checked-mode and --checked both enable checked mode which is 88 // --enable-checked-mode and --checked both enable checked mode which is
98 // equivalent to setting --enable-asserts and --enable-type-checks. 89 // equivalent to setting --enable-asserts and --enable-type-checks.
99 DEFINE_FLAG_HANDLER(CheckedModeHandler, 90 DEFINE_FLAG_HANDLER(CheckedModeHandler,
100 enable_checked_mode, 91 enable_checked_mode,
101 "Enable checked mode."); 92 "Enable checked mode.");
102 93
103 DEFINE_FLAG_HANDLER(CheckedModeHandler, 94 DEFINE_FLAG_HANDLER(CheckedModeHandler,
104 checked, 95 checked,
105 "Enable checked mode."); 96 "Enable checked mode.");
97 )
106 98
107 99
108 // Quick access to the locally defined thread() and isolate() methods. 100 // Quick access to the locally defined thread() and isolate() methods.
109 #define T (thread()) 101 #define T (thread())
110 #define I (isolate()) 102 #define I (isolate())
111 103
112 #if defined(DEBUG) 104 #if defined(DEBUG)
113 // Helper class to ensure that a live origin_id is never reused 105 // Helper class to ensure that a live origin_id is never reused
114 // and assigned to an isolate. 106 // and assigned to an isolate.
115 class VerifyOriginId : public IsolateVisitor { 107 class VerifyOriginId : public IsolateVisitor {
(...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after
705 } 697 }
706 } 698 }
707 } 699 }
708 return kError; 700 return kError;
709 } 701 }
710 } 702 }
711 return kOK; 703 return kOK;
712 } 704 }
713 705
714 706
715 Isolate::Flags::Flags() 707 void Isolate::FlagsInitialize(Dart_IsolateFlags* api_flags) {
716 : type_checks_(FLAG_enable_type_checks), 708 api_flags->version = DART_FLAGS_CURRENT_VERSION;
717 asserts_(FLAG_enable_asserts), 709 api_flags->enable_type_checks = FLAG_enable_type_checks;
718 error_on_bad_type_(FLAG_error_on_bad_type), 710 api_flags->enable_asserts = FLAG_enable_asserts;
719 error_on_bad_override_(FLAG_error_on_bad_override) {} 711 api_flags->enable_error_on_bad_type = FLAG_error_on_bad_type;
720 712 api_flags->enable_error_on_bad_override = FLAG_error_on_bad_override;
721
722 void Isolate::Flags::CopyFrom(const Flags& orig) {
723 type_checks_ = orig.type_checks();
724 asserts_ = orig.asserts();
725 error_on_bad_type_ = orig.error_on_bad_type();
726 error_on_bad_override_ = orig.error_on_bad_override();
727 } 713 }
728 714
729 715
730 void Isolate::Flags::CopyFrom(const Dart_IsolateFlags& api_flags) { 716 void Isolate::FlagsCopyTo(Dart_IsolateFlags* api_flags) const {
731 type_checks_ = api_flags.enable_type_checks;
732 asserts_ = api_flags.enable_asserts;
733 error_on_bad_type_ = api_flags.enable_error_on_bad_type;
734 error_on_bad_override_ = api_flags.enable_error_on_bad_override;
735 // Leave others at defaults.
736 }
737
738
739 void Isolate::Flags::CopyTo(Dart_IsolateFlags* api_flags) const {
740 api_flags->version = DART_FLAGS_CURRENT_VERSION; 717 api_flags->version = DART_FLAGS_CURRENT_VERSION;
741 api_flags->enable_type_checks = type_checks(); 718 api_flags->enable_type_checks = type_checks();
742 api_flags->enable_asserts = asserts(); 719 api_flags->enable_asserts = asserts();
743 api_flags->enable_error_on_bad_type = error_on_bad_type(); 720 api_flags->enable_error_on_bad_type = error_on_bad_type();
744 api_flags->enable_error_on_bad_override = error_on_bad_override(); 721 api_flags->enable_error_on_bad_override = error_on_bad_override();
745 } 722 }
746 723
747 724
748 #if defined(DEBUG) 725 NOT_IN_PRODUCT(
726 void Isolate::FlagsCopyFrom(const Dart_IsolateFlags& api_flags) {
727 type_checks_ = api_flags.enable_type_checks;
728 asserts_ = api_flags.enable_asserts;
729 error_on_bad_type_ = api_flags.enable_error_on_bad_type;
730 error_on_bad_override_ = api_flags.enable_error_on_bad_override;
731 // Leave others at defaults.
732 })
733
734
735 DEBUG_ONLY(
749 // static 736 // static
750 void BaseIsolate::AssertCurrent(BaseIsolate* isolate) { 737 void BaseIsolate::AssertCurrent(BaseIsolate* isolate) {
751 ASSERT(isolate == Isolate::Current()); 738 ASSERT(isolate == Isolate::Current());
752 } 739 }
753 740
754 void BaseIsolate::AssertCurrentThreadIsMutator() const { 741 void BaseIsolate::AssertCurrentThreadIsMutator() const {
755 ASSERT(Isolate::Current() == this); 742 ASSERT(Isolate::Current() == this);
756 ASSERT(Thread::Current()->IsMutatorThread()); 743 ASSERT(Thread::Current()->IsMutatorThread());
757 } 744 }
758 #endif // defined(DEBUG) 745 )
759 746
760 #if defined(DEBUG) 747 #if defined(DEBUG)
761 #define REUSABLE_HANDLE_SCOPE_INIT(object) \ 748 #define REUSABLE_HANDLE_SCOPE_INIT(object) \
762 reusable_##object##_handle_scope_active_(false), 749 reusable_##object##_handle_scope_active_(false),
763 #else 750 #else
764 #define REUSABLE_HANDLE_SCOPE_INIT(object) 751 #define REUSABLE_HANDLE_SCOPE_INIT(object)
765 #endif // defined(DEBUG) 752 #endif // defined(DEBUG)
766 753
767 #define REUSABLE_HANDLE_INITIALIZERS(object) \ 754 #define REUSABLE_HANDLE_INITIALIZERS(object) \
768 object##_handle_(NULL), 755 object##_handle_(NULL),
(...skipping 23 matching lines...) Expand all
792 object_store_(NULL), 779 object_store_(NULL),
793 top_exit_frame_info_(0), 780 top_exit_frame_info_(0),
794 init_callback_data_(NULL), 781 init_callback_data_(NULL),
795 environment_callback_(NULL), 782 environment_callback_(NULL),
796 library_tag_handler_(NULL), 783 library_tag_handler_(NULL),
797 api_state_(NULL), 784 api_state_(NULL),
798 debugger_(NULL), 785 debugger_(NULL),
799 resume_request_(false), 786 resume_request_(false),
800 last_resume_timestamp_(OS::GetCurrentTimeMillis()), 787 last_resume_timestamp_(OS::GetCurrentTimeMillis()),
801 has_compiled_code_(false), 788 has_compiled_code_(false),
802 flags_(),
803 random_(), 789 random_(),
804 simulator_(NULL), 790 simulator_(NULL),
805 mutex_(new Mutex()), 791 mutex_(new Mutex()),
806 symbols_mutex_(new Mutex()), 792 symbols_mutex_(new Mutex()),
807 saved_stack_limit_(0), 793 saved_stack_limit_(0),
808 deferred_interrupts_mask_(0), 794 deferred_interrupts_mask_(0),
809 deferred_interrupts_(0), 795 deferred_interrupts_(0),
810 stack_overflow_flags_(0), 796 stack_overflow_flags_(0),
811 stack_overflow_count_(0), 797 stack_overflow_count_(0),
812 message_handler_(NULL), 798 message_handler_(NULL),
(...skipping 20 matching lines...) Expand all
833 all_classes_finalized_(false), 819 all_classes_finalized_(false),
834 next_(NULL), 820 next_(NULL),
835 pause_loop_monitor_(NULL), 821 pause_loop_monitor_(NULL),
836 cha_invalidation_gen_(kInvalidGen), 822 cha_invalidation_gen_(kInvalidGen),
837 field_invalidation_gen_(kInvalidGen), 823 field_invalidation_gen_(kInvalidGen),
838 prefix_invalidation_gen_(kInvalidGen), 824 prefix_invalidation_gen_(kInvalidGen),
839 boxed_field_list_monitor_(new Monitor()), 825 boxed_field_list_monitor_(new Monitor()),
840 boxed_field_list_(GrowableObjectArray::null()), 826 boxed_field_list_(GrowableObjectArray::null()),
841 spawn_count_monitor_(new Monitor()), 827 spawn_count_monitor_(new Monitor()),
842 spawn_count_(0) { 828 spawn_count_(0) {
843 flags_.CopyFrom(api_flags); 829 NOT_IN_PRODUCT(FlagsCopyFrom(api_flags));
844 // TODO(asiva): A Thread is not available here, need to figure out 830 // TODO(asiva): A Thread is not available here, need to figure out
845 // how the vm_tag (kEmbedderTagId) can be set, these tags need to 831 // how the vm_tag (kEmbedderTagId) can be set, these tags need to
846 // move to the OSThread structure. 832 // move to the OSThread structure.
847 set_user_tag(UserTags::kDefaultUserTag); 833 set_user_tag(UserTags::kDefaultUserTag);
848 } 834 }
849 835
850 #undef REUSABLE_HANDLE_SCOPE_INIT 836 #undef REUSABLE_HANDLE_SCOPE_INIT
851 #undef REUSABLE_HANDLE_INITIALIZERS 837 #undef REUSABLE_HANDLE_INITIALIZERS
852 838
853 Isolate::~Isolate() { 839 Isolate::~Isolate() {
(...skipping 1795 matching lines...) Expand 10 before | Expand all | Expand 10 after
2649 package_config_(package_config), 2635 package_config_(package_config),
2650 library_url_(NULL), 2636 library_url_(NULL),
2651 class_name_(NULL), 2637 class_name_(NULL),
2652 function_name_(NULL), 2638 function_name_(NULL),
2653 serialized_args_(NULL), 2639 serialized_args_(NULL),
2654 serialized_args_len_(0), 2640 serialized_args_len_(0),
2655 serialized_message_(NULL), 2641 serialized_message_(NULL),
2656 serialized_message_len_(0), 2642 serialized_message_len_(0),
2657 spawn_count_monitor_(spawn_count_monitor), 2643 spawn_count_monitor_(spawn_count_monitor),
2658 spawn_count_(spawn_count), 2644 spawn_count_(spawn_count),
2659 isolate_flags_(),
2660 paused_(paused), 2645 paused_(paused),
2661 errors_are_fatal_(errors_are_fatal) { 2646 errors_are_fatal_(errors_are_fatal) {
2662 const Class& cls = Class::Handle(func.Owner()); 2647 const Class& cls = Class::Handle(func.Owner());
2663 const Library& lib = Library::Handle(cls.library()); 2648 const Library& lib = Library::Handle(cls.library());
2664 const String& lib_url = String::Handle(lib.url()); 2649 const String& lib_url = String::Handle(lib.url());
2665 library_url_ = NewConstChar(lib_url.ToCString()); 2650 library_url_ = NewConstChar(lib_url.ToCString());
2666 2651
2667 const String& func_name = String::Handle(func.name()); 2652 const String& func_name = String::Handle(func.name());
2668 function_name_ = NewConstChar(func_name.ToCString()); 2653 function_name_ = NewConstChar(func_name.ToCString());
2669 if (!cls.IsTopLevel()) { 2654 if (!cls.IsTopLevel()) {
2670 const String& class_name = String::Handle(cls.Name()); 2655 const String& class_name = String::Handle(cls.Name());
2671 class_name_ = NewConstChar(class_name.ToCString()); 2656 class_name_ = NewConstChar(class_name.ToCString());
2672 } 2657 }
2673 bool can_send_any_object = true; 2658 bool can_send_any_object = true;
2674 SerializeObject(message, 2659 SerializeObject(message,
2675 &serialized_message_, 2660 &serialized_message_,
2676 &serialized_message_len_, 2661 &serialized_message_len_,
2677 can_send_any_object); 2662 can_send_any_object);
2678 // Inherit flags from spawning isolate. 2663 // Inherit flags from spawning isolate.
2679 isolate_flags()->CopyFrom(Isolate::Current()->flags()); 2664 Isolate::Current()->FlagsCopyTo(isolate_flags());
2680 } 2665 }
2681 2666
2682 2667
2683 IsolateSpawnState::IsolateSpawnState(Dart_Port parent_port, 2668 IsolateSpawnState::IsolateSpawnState(Dart_Port parent_port,
2684 void* init_data, 2669 void* init_data,
2685 const char* script_url, 2670 const char* script_url,
2686 const char* package_root, 2671 const char* package_root,
2687 const char* package_config, 2672 const char* package_config,
2688 const Instance& args, 2673 const Instance& args,
2689 const Instance& message, 2674 const Instance& message,
(...skipping 29 matching lines...) Expand all
2719 SerializeObject(args, 2704 SerializeObject(args,
2720 &serialized_args_, 2705 &serialized_args_,
2721 &serialized_args_len_, 2706 &serialized_args_len_,
2722 can_send_any_object); 2707 can_send_any_object);
2723 SerializeObject(message, 2708 SerializeObject(message,
2724 &serialized_message_, 2709 &serialized_message_,
2725 &serialized_message_len_, 2710 &serialized_message_len_,
2726 can_send_any_object); 2711 can_send_any_object);
2727 // By default inherit flags from spawning isolate. These can be overridden 2712 // By default inherit flags from spawning isolate. These can be overridden
2728 // from the calling code. 2713 // from the calling code.
2729 isolate_flags()->CopyFrom(Isolate::Current()->flags()); 2714 Isolate::Current()->FlagsCopyTo(isolate_flags());
2730 } 2715 }
2731 2716
2732 2717
2733 IsolateSpawnState::~IsolateSpawnState() { 2718 IsolateSpawnState::~IsolateSpawnState() {
2734 delete[] script_url_; 2719 delete[] script_url_;
2735 delete[] package_root_; 2720 delete[] package_root_;
2736 delete[] package_config_; 2721 delete[] package_config_;
2737 delete[] library_url_; 2722 delete[] library_url_;
2738 delete[] class_name_; 2723 delete[] class_name_;
2739 delete[] function_name_; 2724 delete[] function_name_;
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
2824 void IsolateSpawnState::DecrementSpawnCount() { 2809 void IsolateSpawnState::DecrementSpawnCount() {
2825 ASSERT(spawn_count_monitor_ != NULL); 2810 ASSERT(spawn_count_monitor_ != NULL);
2826 ASSERT(spawn_count_ != NULL); 2811 ASSERT(spawn_count_ != NULL);
2827 MonitorLocker ml(spawn_count_monitor_); 2812 MonitorLocker ml(spawn_count_monitor_);
2828 ASSERT(*spawn_count_ > 0); 2813 ASSERT(*spawn_count_ > 0);
2829 *spawn_count_ = *spawn_count_ - 1; 2814 *spawn_count_ = *spawn_count_ - 1;
2830 ml.Notify(); 2815 ml.Notify();
2831 } 2816 }
2832 2817
2833 } // namespace dart 2818 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/isolate.h ('k') | runtime/vm/jit_optimizer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698