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

Unified Diff: runtime/vm/isolate.cc

Issue 1162033005: Fix http://dartbug.com/23578: (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Update to ToT. Created 5 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: runtime/vm/isolate.cc
diff --git a/runtime/vm/isolate.cc b/runtime/vm/isolate.cc
index 40159cf9d80a7ddcdc6b3e1e0f3850e803d53236..2432df990bfa34e8945bc702086c827c4bef13c6 100644
--- a/runtime/vm/isolate.cc
+++ b/runtime/vm/isolate.cc
@@ -54,6 +54,32 @@ DEFINE_FLAG(charp, isolate_log_filter, NULL,
"Log isolates whose name include the filter. "
"Default: service isolate log messages are suppressed.");
+// TODO(iposva): Make these isolate specific flags inaccessible using the
+// regular FLAG_xyz pattern.
+// These flags are per-isolate and only influence the defaults.
+DEFINE_FLAG(bool, enable_asserts, false, "Enable assert statements.");
+DEFINE_FLAG(bool, enable_type_checks, false, "Enable type checks.");
+DEFINE_FLAG(bool, error_on_bad_override, false,
+ "Report error for bad overrides.");
+DEFINE_FLAG(bool, error_on_bad_type, false,
+ "Report error for malformed types.");
+
+static void CheckedModeHandler(bool value) {
+ FLAG_enable_asserts = value;
+ FLAG_enable_type_checks = value;
+}
+
+// --enable-checked-mode and --checked both enable checked mode which is
+// equivalent to setting --enable-asserts and --enable-type-checks.
+DEFINE_FLAG_HANDLER(CheckedModeHandler,
+ enable_checked_mode,
+ "Enable checked mode.");
+
+DEFINE_FLAG_HANDLER(CheckedModeHandler,
+ checked,
+ "Enable checked mode.");
+
+
// Quick access to the locally defined isolate() method.
#define I (isolate())
@@ -536,6 +562,35 @@ bool IsolateMessageHandler::ProcessUnhandledException(const Error& result) {
}
+Isolate::Flags::Flags()
+ : type_checks_(FLAG_enable_type_checks),
+ asserts_(FLAG_enable_asserts),
+ error_on_bad_type_(FLAG_error_on_bad_type),
+ error_on_bad_override_(FLAG_error_on_bad_override) {}
+
+
+void Isolate::Flags::CopyFrom(const Flags& orig) {
+ type_checks_ = orig.type_checks();
+ asserts_ = orig.asserts();
+ error_on_bad_type_ = orig.error_on_bad_type();
+ error_on_bad_override_ = orig.error_on_bad_override();
+}
+
+
+void Isolate::Flags::CopyFrom(const Dart_IsolateFlags& api_flags) {
+ type_checks_ = api_flags.enable_type_checks;
+ asserts_ = api_flags.enable_asserts;
+ // Leave others at defaults.
+}
+
+
+void Isolate::Flags::CopyTo(Dart_IsolateFlags* api_flags) const {
+ api_flags->version = DART_FLAGS_CURRENT_VERSION;
+ api_flags->enable_type_checks = type_checks();
+ api_flags->enable_asserts = asserts();
+}
+
+
#if defined(DEBUG)
// static
void BaseIsolate::AssertCurrent(BaseIsolate* isolate) {
@@ -553,7 +608,7 @@ void BaseIsolate::AssertCurrent(BaseIsolate* isolate) {
#define REUSABLE_HANDLE_INITIALIZERS(object) \
object##_handle_(NULL),
-Isolate::Isolate()
+Isolate::Isolate(const Dart_IsolateFlags& api_flags)
: mutator_thread_(NULL),
vm_tag_(0),
store_buffer_(),
@@ -578,7 +633,7 @@ Isolate::Isolate()
single_step_(false),
resume_request_(false),
has_compiled_(false),
- strict_compilation_(false),
+ flags_(),
Florian Schneider 2015/06/08 11:25:49 flags_(api_flags) and remove .CopyFrom below
random_(),
simulator_(NULL),
long_jump_base_(NULL),
@@ -620,6 +675,7 @@ Isolate::Isolate()
REUSABLE_HANDLE_LIST(REUSABLE_HANDLE_INITIALIZERS)
REUSABLE_HANDLE_LIST(REUSABLE_HANDLE_SCOPE_INIT)
reusable_handles_() {
+ flags_.CopyFrom(api_flags);
set_vm_tag(VMTag::kEmbedderTagId);
set_user_tag(UserTags::kDefaultUserTag);
}
@@ -671,8 +727,10 @@ void Isolate::InitOnce() {
}
-Isolate* Isolate::Init(const char* name_prefix, bool is_vm_isolate) {
- Isolate* result = new Isolate();
+Isolate* Isolate::Init(const char* name_prefix,
+ const Dart_IsolateFlags& api_flags,
+ bool is_vm_isolate) {
+ Isolate* result = new Isolate(api_flags);
ASSERT(result != NULL);
// Initialize metrics.
@@ -1803,8 +1861,7 @@ static RawInstance* DeserializeObject(Isolate* isolate,
IsolateSpawnState::IsolateSpawnState(Dart_Port parent_port,
const Function& func,
const Instance& message,
- bool paused,
- bool checkedFlag)
+ bool paused)
: isolate_(NULL),
parent_port_(parent_port),
script_url_(NULL),
@@ -1816,8 +1873,8 @@ IsolateSpawnState::IsolateSpawnState(Dart_Port parent_port,
serialized_args_len_(0),
serialized_message_(NULL),
serialized_message_len_(0),
- paused_(paused),
- checked_(checkedFlag) {
+ isolate_flags_(),
Florian Schneider 2015/06/08 11:25:49 isolate(Isolate::Current()->flags()) and remove ->
+ paused_(paused) {
script_url_ = NULL;
const Class& cls = Class::Handle(func.Owner());
const Library& lib = Library::Handle(cls.library());
@@ -1835,6 +1892,8 @@ IsolateSpawnState::IsolateSpawnState(Dart_Port parent_port,
&serialized_message_,
&serialized_message_len_,
can_send_any_object);
+ // Inherit flags from spawning isolate.
+ isolate_flags()->CopyFrom(Isolate::Current()->flags());
}
@@ -1843,8 +1902,7 @@ IsolateSpawnState::IsolateSpawnState(Dart_Port parent_port,
const char* package_root,
const Instance& args,
const Instance& message,
- bool paused,
- bool checkedFlag)
+ bool paused)
: isolate_(NULL),
parent_port_(parent_port),
package_root_(NULL),
@@ -1855,8 +1913,8 @@ IsolateSpawnState::IsolateSpawnState(Dart_Port parent_port,
serialized_args_len_(0),
serialized_message_(NULL),
serialized_message_len_(0),
- paused_(paused),
- checked_(checkedFlag) {
+ isolate_flags_(),
Florian Schneider 2015/06/08 11:25:49 isolate_flags_(Isolate::Current()->flags()) and r
+ paused_(paused) {
script_url_ = strdup(script_url);
if (package_root != NULL) {
package_root_ = strdup(package_root);
@@ -1872,6 +1930,9 @@ IsolateSpawnState::IsolateSpawnState(Dart_Port parent_port,
&serialized_message_,
&serialized_message_len_,
can_send_any_object);
+ // By default inherit flags from spawning isolate. These can be overridden
+ // from the calling code.
+ isolate_flags()->CopyFrom(Isolate::Current()->flags());
}
« runtime/vm/isolate.h ('K') | « runtime/vm/isolate.h ('k') | runtime/vm/isolate_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698