[vm] Update Isolate to C++11 style.
Change-Id: Iff2ea5366a99a42394e663852dcfee25ab7109d9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/100566
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
diff --git a/runtime/vm/isolate.cc b/runtime/vm/isolate.cc
index 92e2c88..117e5f9 100644
--- a/runtime/vm/isolate.cc
+++ b/runtime/vm/isolate.cc
@@ -861,60 +861,33 @@
#define REUSABLE_HANDLE_SCOPE_INIT(object)
#endif // defined(DEBUG)
-#define REUSABLE_HANDLE_INITIALIZERS(object) object##_handle_(NULL),
+#define REUSABLE_HANDLE_INITIALIZERS(object) object##_handle_(nullptr),
// TODO(srdjan): Some Isolate monitors can be shared. Replace their usage with
// that shared monitor.
Isolate::Isolate(const Dart_IsolateFlags& api_flags)
: BaseIsolate(),
- user_tag_(0),
current_tag_(UserTag::null()),
default_tag_(UserTag::null()),
ic_miss_code_(Code::null()),
- object_store_(NULL),
class_table_(),
- single_step_(false),
store_buffer_(new StoreBuffer()),
- marking_stack_(NULL),
- heap_(NULL),
- isolate_flags_(0),
- background_compiler_(NULL),
- optimizing_background_compiler_(NULL),
#if !defined(PRODUCT)
- debugger_(NULL),
last_resume_timestamp_(OS::GetCurrentTimeMillis()),
- last_allocationprofile_accumulator_reset_timestamp_(0),
- last_allocationprofile_gc_timestamp_(0),
vm_tag_counters_(),
pending_service_extension_calls_(GrowableObjectArray::null()),
registered_service_extension_handlers_(GrowableObjectArray::null()),
- metrics_list_head_(NULL),
- pause_loop_monitor_(NULL),
#define ISOLATE_METRIC_CONSTRUCTORS(type, variable, name, unit) \
metric_##variable##_(),
ISOLATE_METRIC_LIST(ISOLATE_METRIC_CONSTRUCTORS)
#undef ISOLATE_METRIC_CONSTRUCTORS
- no_reload_scope_depth_(0),
- reload_every_n_stack_overflow_checks_(FLAG_reload_every),
- reload_context_(NULL),
+ reload_every_n_stack_overflow_checks_(FLAG_reload_every),
last_reload_timestamp_(OS::GetCurrentTimeMillis()),
- object_id_ring_(NULL),
#endif // !defined(PRODUCT)
start_time_micros_(OS::GetCurrentMonotonicMicros()),
thread_registry_(new ThreadRegistry()),
safepoint_handler_(new SafepointHandler(this)),
- message_notify_callback_(NULL),
- name_(NULL),
- main_port_(0),
- origin_id_(0),
- pause_capability_(0),
- terminate_capability_(0),
- init_callback_data_(NULL),
- environment_callback_(NULL),
- library_tag_handler_(NULL),
- api_state_(NULL),
random_(),
- simulator_(NULL),
mutex_(new Mutex(NOT_IN_PRODUCT("Isolate::mutex_"))),
symbols_mutex_(new Mutex(NOT_IN_PRODUCT("Isolate::symbols_mutex_"))),
type_canonicalization_mutex_(
@@ -929,27 +902,17 @@
new Mutex(NOT_IN_PRODUCT("Isolate::kernel_data_class_cache_mutex_"))),
kernel_constants_mutex_(
new Mutex(NOT_IN_PRODUCT("Isolate::kernel_constants_mutex_"))),
- message_handler_(NULL),
- spawn_state_(NULL),
- defer_finalization_count_(0),
pending_deopts_(new MallocGrowableArray<PendingLazyDeopt>()),
- deopt_context_(NULL),
tag_table_(GrowableObjectArray::null()),
deoptimized_code_array_(GrowableObjectArray::null()),
sticky_error_(Error::null()),
reloaded_kernel_blobs_(GrowableObjectArray::null()),
- next_(NULL),
- loading_invalidation_gen_(kInvalidGen),
field_list_mutex_(
new Mutex(NOT_IN_PRODUCT("Isolate::field_list_mutex_"))),
boxed_field_list_(GrowableObjectArray::null()),
spawn_count_monitor_(new Monitor()),
- spawn_count_(0),
handler_info_cache_(),
- catch_entry_moves_cache_(),
- embedder_entry_points_(NULL),
- obfuscation_map_(NULL),
- reverse_pc_lookup_cache_(nullptr) {
+ catch_entry_moves_cache_() {
FlagsCopyFrom(api_flags);
SetErrorsFatal(true);
set_compilation_allowed(true);
@@ -986,70 +949,73 @@
if (FLAG_enable_interpreter) {
delete background_compiler_;
- background_compiler_ = NULL;
+ background_compiler_ = nullptr;
}
delete optimizing_background_compiler_;
- optimizing_background_compiler_ = NULL;
+ optimizing_background_compiler_ = nullptr;
#if !defined(PRODUCT)
delete debugger_;
- debugger_ = NULL;
+ debugger_ = nullptr;
if (FLAG_support_service) {
delete object_id_ring_;
}
- object_id_ring_ = NULL;
+ object_id_ring_ = nullptr;
delete pause_loop_monitor_;
- pause_loop_monitor_ = NULL;
+ pause_loop_monitor_ = nullptr;
#endif // !defined(PRODUCT)
free(name_);
delete store_buffer_;
delete heap_;
- ASSERT(marking_stack_ == NULL);
+ ASSERT(marking_stack_ == nullptr);
delete object_store_;
delete api_state_;
#if defined(USING_SIMULATOR)
delete simulator_;
#endif
delete mutex_;
- mutex_ = NULL; // Fail fast if interrupts are scheduled on a dead isolate.
+ mutex_ = nullptr; // Fail fast if interrupts are scheduled on a dead isolate.
delete symbols_mutex_;
- symbols_mutex_ = NULL;
+ symbols_mutex_ = nullptr;
delete type_canonicalization_mutex_;
- type_canonicalization_mutex_ = NULL;
+ type_canonicalization_mutex_ = nullptr;
delete constant_canonicalization_mutex_;
- constant_canonicalization_mutex_ = NULL;
+ constant_canonicalization_mutex_ = nullptr;
delete megamorphic_lookup_mutex_;
- megamorphic_lookup_mutex_ = NULL;
+ megamorphic_lookup_mutex_ = nullptr;
delete kernel_constants_mutex_;
kernel_constants_mutex_ = nullptr;
delete kernel_data_lib_cache_mutex_;
- kernel_data_lib_cache_mutex_ = NULL;
+ kernel_data_lib_cache_mutex_ = nullptr;
delete kernel_data_class_cache_mutex_;
- kernel_data_class_cache_mutex_ = NULL;
+ kernel_data_class_cache_mutex_ = nullptr;
delete pending_deopts_;
- pending_deopts_ = NULL;
+ pending_deopts_ = nullptr;
delete message_handler_;
- message_handler_ = NULL; // Fail fast if we send messages to a dead isolate.
- ASSERT(deopt_context_ == NULL); // No deopt in progress when isolate deleted.
+ message_handler_ =
+ nullptr; // Fail fast if we send messages to a dead isolate.
+ ASSERT(deopt_context_ ==
+ nullptr); // No deopt in progress when isolate deleted.
delete spawn_state_;
delete field_list_mutex_;
- field_list_mutex_ = NULL;
+ field_list_mutex_ = nullptr;
ASSERT(spawn_count_ == 0);
delete spawn_count_monitor_;
delete safepoint_handler_;
delete thread_registry_;
- if (obfuscation_map_ != NULL) {
- for (intptr_t i = 0; obfuscation_map_[i] != NULL; i++) {
+ if (obfuscation_map_ != nullptr) {
+ for (intptr_t i = 0; obfuscation_map_[i] != nullptr; i++) {
delete[] obfuscation_map_[i];
}
delete[] obfuscation_map_;
}
- if (embedder_entry_points_ != NULL) {
- for (intptr_t i = 0; embedder_entry_points_[i].function_name != NULL; i++) {
+ if (embedder_entry_points_ != nullptr) {
+ for (intptr_t i = 0; embedder_entry_points_[i].function_name != nullptr;
+ i++) {
free(const_cast<char*>(embedder_entry_points_[i].library_uri));
free(const_cast<char*>(embedder_entry_points_[i].class_name));
free(const_cast<char*>(embedder_entry_points_[i].function_name));
@@ -1059,11 +1025,11 @@
}
void Isolate::InitVM() {
- create_callback_ = NULL;
- if (isolates_list_monitor_ == NULL) {
+ create_callback_ = nullptr;
+ if (isolates_list_monitor_ == nullptr) {
isolates_list_monitor_ = new Monitor();
}
- ASSERT(isolates_list_monitor_ != NULL);
+ ASSERT(isolates_list_monitor_ != nullptr);
EnableIsolateCreation();
}
@@ -1071,7 +1037,7 @@
const Dart_IsolateFlags& api_flags,
bool is_vm_isolate) {
Isolate* result = new Isolate(api_flags);
- ASSERT(result != NULL);
+ ASSERT(result != nullptr);
#if !defined(PRODUCT)
// Initialize metrics.
@@ -1108,23 +1074,23 @@
// We failed to enter the isolate, it is possible the VM is shutting down,
// return back a NULL so that CreateIsolate reports back an error.
if (KernelIsolate::IsKernelIsolate(result)) {
- KernelIsolate::SetKernelIsolate(NULL);
+ KernelIsolate::SetKernelIsolate(nullptr);
}
if (ServiceIsolate::IsServiceIsolate(result)) {
- ServiceIsolate::SetServiceIsolate(NULL);
+ ServiceIsolate::SetServiceIsolate(nullptr);
}
delete result;
- return NULL;
+ return nullptr;
}
// Setup the isolate message handler.
MessageHandler* handler = new IsolateMessageHandler(result);
- ASSERT(handler != NULL);
+ ASSERT(handler != nullptr);
result->set_message_handler(handler);
// Setup the Dart API state.
ApiState* state = new ApiState();
- ASSERT(state != NULL);
+ ASSERT(state != nullptr);
result->set_api_state(state);
result->set_main_port(PortMap::CreatePort(result->message_handler()));
@@ -1142,7 +1108,7 @@
result->debugger_ = new Debugger(result);
#endif
if (FLAG_trace_isolates) {
- if (name_prefix == NULL || strcmp(name_prefix, "vm-isolate") != 0) {
+ if (name_prefix == nullptr || strcmp(name_prefix, "vm-isolate") != 0) {
OS::PrintErr(
"[+] Starting isolate:\n"
"\tisolate: %s\n",
@@ -1161,13 +1127,13 @@
result->LowLevelShutdown();
Thread::ExitIsolate();
if (KernelIsolate::IsKernelIsolate(result)) {
- KernelIsolate::SetKernelIsolate(NULL);
+ KernelIsolate::SetKernelIsolate(nullptr);
}
if (ServiceIsolate::IsServiceIsolate(result)) {
- ServiceIsolate::SetServiceIsolate(NULL);
+ ServiceIsolate::SetServiceIsolate(nullptr);
}
delete result;
- return NULL;
+ return nullptr;
}
return result;
@@ -1182,7 +1148,7 @@
}
Thread* Isolate::mutator_thread() const {
- ASSERT(thread_registry() != NULL);
+ ASSERT(thread_registry() != nullptr);
return thread_registry()->mutator_thread();
}
@@ -1212,7 +1178,7 @@
// exit the isolate while we are trying to schedule interrupts on it.
MonitorLocker ml(threads_lock());
Thread* mthread = mutator_thread();
- if (mthread != NULL) {
+ if (mthread != nullptr) {
mthread->ScheduleInterrupts(interrupt_bits);
}
}
@@ -1230,13 +1196,13 @@
#if defined(PRODUCT)
return false;
#else
- return (debugger_ != NULL) && (debugger_->PauseEvent() != NULL);
+ return (debugger_ != nullptr) && (debugger_->PauseEvent() != nullptr);
#endif // !defined(PRODUCT)
}
RawError* Isolate::PausePostRequest() {
#if !defined(PRODUCT)
- if (debugger_ == NULL) {
+ if (debugger_ == nullptr) {
return Error::null();
}
ASSERT(!IsPaused());
@@ -1254,9 +1220,9 @@
}
void Isolate::BuildName(const char* name_prefix) {
- ASSERT(name_ == NULL);
- if (name_prefix == NULL) {
- name_ = OS::SCreate(NULL, "isolate-%" Pd64 "", main_port());
+ ASSERT(name_ == nullptr);
+ if (name_prefix == nullptr) {
+ name_ = OS::SCreate(nullptr, "isolate-%" Pd64 "", main_port());
} else {
name_ = strdup(name_prefix);
}
@@ -1295,7 +1261,7 @@
SetHasAttemptedReload(true);
reload_context_ = new IsolateReloadContext(this, js);
reload_context_->Reload(force_reload, root_script_url, packages_url,
- /* kernel_buffer= */ NULL,
+ /* kernel_buffer= */ nullptr,
/* kernel_buffer_size= */ 0);
bool success = !reload_context_->reload_aborted();
if (!dont_delete_reload_context) {
@@ -1313,8 +1279,8 @@
SetHasAttemptedReload(true);
reload_context_ = new IsolateReloadContext(this, js);
reload_context_->Reload(force_reload,
- /* root_script_url= */ NULL,
- /* packages_url= */ NULL, kernel_buffer,
+ /* root_script_url= */ nullptr,
+ /* packages_url= */ nullptr, kernel_buffer,
kernel_buffer_size);
bool success = !reload_context_->reload_aborted();
if (!dont_delete_reload_context) {
@@ -1329,7 +1295,7 @@
SafepointOperationScope safepoint_scope(thread);
delete reload_context_;
- reload_context_ = NULL;
+ reload_context_ = nullptr;
}
#endif // !defined(PRODUCT) && !defined(DART_PRECOMPILED_RUNTIME)
@@ -1342,7 +1308,7 @@
}
const char* Isolate::MakeRunnable() {
- ASSERT(Isolate::Current() == NULL);
+ ASSERT(Isolate::Current() == nullptr);
MutexLocker ml(mutex_);
// Check if we are in a valid state to make the isolate runnable.
@@ -1362,15 +1328,15 @@
}
#endif // !PRODUCT
IsolateSpawnState* state = spawn_state();
- if (state != NULL) {
+ if (state != nullptr) {
ASSERT(this == state->isolate());
Run();
}
#if defined(SUPPORT_TIMELINE)
TimelineStream* stream = Timeline::GetIsolateStream();
- ASSERT(stream != NULL);
+ ASSERT(stream != nullptr);
TimelineEvent* event = stream->StartEvent();
- if (event != NULL) {
+ if (event != nullptr) {
event->Instant("Runnable");
event->Complete();
}
@@ -1392,7 +1358,7 @@
GetRunnableHeapSizeMetric()->set_value(heap_size);
}
#endif // !PRODUCT
- return NULL;
+ return nullptr;
}
bool Isolate::VerifyPauseCapability(const Object& capability) const {
@@ -1591,7 +1557,7 @@
static MessageHandler::MessageStatus RunIsolate(uword parameter) {
Isolate* isolate = reinterpret_cast<Isolate*>(parameter);
- IsolateSpawnState* state = NULL;
+ IsolateSpawnState* state = nullptr;
{
// TODO(turnidge): Is this locking required here at all anymore?
MutexLocker ml(isolate->mutex());
@@ -1803,7 +1769,7 @@
NoSafepointScope no_safepoint_scope;
// Notify exit listeners that this isolate is shutting down.
- if (object_store() != NULL) {
+ if (object_store() != nullptr) {
const Error& error = Error::Handle(thread->sticky_error());
if (error.IsNull() || !error.IsUnwindError() ||
UnwindError::Cast(error).is_user_initiated()) {
@@ -1821,7 +1787,7 @@
// Fail fast if anybody tries to post any more messages to this isolate.
delete message_handler();
- set_message_handler(NULL);
+ set_message_handler(nullptr);
#if defined(SUPPORT_TIMELINE)
// Before analyzing the isolate's timeline blocks- reclaim all cached
// blocks.
@@ -1887,13 +1853,13 @@
BackgroundCompiler::Stop(this);
if (FLAG_enable_interpreter) {
delete background_compiler_;
- background_compiler_ = NULL;
+ background_compiler_ = nullptr;
}
delete optimizing_background_compiler_;
- optimizing_background_compiler_ = NULL;
+ optimizing_background_compiler_ = nullptr;
#if defined(DEBUG)
- if (heap_ != NULL && FLAG_verify_on_transition) {
+ if (heap_ != nullptr && FLAG_verify_on_transition) {
// The VM isolate keeps all objects marked.
heap_->Verify(this == Dart::vm_isolate() ? kRequireMarked : kForbidMarked);
}
@@ -1916,7 +1882,7 @@
KernelIsolate::NotifyAboutIsolateShutdown(this);
}
- if (heap_ != NULL) {
+ if (heap_ != nullptr) {
// Wait for any concurrent GC tasks to finish before shutting down.
// TODO(rmacnak): Interrupt tasks for faster shutdown.
PageSpace* old_space = heap_->old_space();
@@ -1946,7 +1912,7 @@
#if defined(DEBUG)
// No concurrent sweeper tasks should be running at this point.
- if (heap_ != NULL) {
+ if (heap_ != nullptr) {
PageSpace* old_space = heap_->old_space();
MonitorLocker ml(old_space->tasks_lock());
ASSERT(old_space->tasks() == 0);
@@ -1958,22 +1924,22 @@
Thread::ExitIsolate();
Dart_IsolateCleanupCallback cleanup = Isolate::CleanupCallback();
- if (cleanup != NULL) {
+ if (cleanup != nullptr) {
cleanup(init_callback_data());
}
}
-Dart_IsolateCreateCallback Isolate::create_callback_ = NULL;
-Dart_IsolateShutdownCallback Isolate::shutdown_callback_ = NULL;
-Dart_IsolateCleanupCallback Isolate::cleanup_callback_ = NULL;
+Dart_IsolateCreateCallback Isolate::create_callback_ = nullptr;
+Dart_IsolateShutdownCallback Isolate::shutdown_callback_ = nullptr;
+Dart_IsolateCleanupCallback Isolate::cleanup_callback_ = nullptr;
-Monitor* Isolate::isolates_list_monitor_ = NULL;
-Isolate* Isolate::isolates_list_head_ = NULL;
+Monitor* Isolate::isolates_list_monitor_ = nullptr;
+Isolate* Isolate::isolates_list_head_ = nullptr;
bool Isolate::creation_enabled_ = false;
void Isolate::VisitObjectPointers(ObjectPointerVisitor* visitor,
ValidationPolicy validate_frames) {
- ASSERT(visitor != NULL);
+ ASSERT(visitor != nullptr);
// Visit objects in the object store.
object_store()->VisitObjectPointers(visitor);
@@ -1985,7 +1951,7 @@
StubCode::VisitObjectPointers(visitor);
// Visit the dart api state for all local and persistent handles.
- if (api_state() != NULL) {
+ if (api_state() != nullptr) {
api_state()->VisitObjectPointers(visitor);
}
@@ -2010,10 +1976,10 @@
// when at safepoint or the field_list_mutex_ lock has been taken.
visitor->VisitPointer(reinterpret_cast<RawObject**>(&boxed_field_list_));
- if (background_compiler() != NULL) {
+ if (background_compiler() != nullptr) {
background_compiler()->VisitPointers(visitor);
}
- if (optimizing_background_compiler() != NULL) {
+ if (optimizing_background_compiler() != nullptr) {
optimizing_background_compiler()->VisitPointers(visitor);
}
@@ -2022,7 +1988,7 @@
debugger()->VisitObjectPointers(visitor);
#if !defined(DART_PRECOMPILED_RUNTIME)
// Visit objects that are being used for isolate reload.
- if (reload_context() != NULL) {
+ if (reload_context() != nullptr) {
reload_context()->VisitObjectPointers(visitor);
}
#endif // !defined(DART_PRECOMPILED_RUNTIME)
@@ -2033,13 +1999,13 @@
#if !defined(DART_PRECOMPILED_RUNTIME)
// Visit objects that are being used for deoptimization.
- if (deopt_context() != NULL) {
+ if (deopt_context() != nullptr) {
deopt_context()->VisitObjectPointers(visitor);
}
#endif // !defined(DART_PRECOMPILED_RUNTIME)
#if defined(TARGET_ARCH_DBC)
- if (simulator() != NULL) {
+ if (simulator() != nullptr) {
simulator()->VisitObjectPointers(visitor);
}
#endif // defined(TARGET_ARCH_DBC)
@@ -2054,7 +2020,7 @@
}
void Isolate::VisitWeakPersistentHandles(HandleVisitor* visitor) {
- if (api_state() != NULL) {
+ if (api_state() != nullptr) {
api_state()->VisitWeakHandles(visitor);
}
}
@@ -2065,7 +2031,7 @@
void Isolate::EnableIncrementalBarrier(MarkingStack* marking_stack,
MarkingStack* deferred_marking_stack) {
- ASSERT(marking_stack_ == NULL);
+ ASSERT(marking_stack_ == nullptr);
marking_stack_ = marking_stack;
deferred_marking_stack_ = deferred_marking_stack;
thread_registry()->AcquireMarkingStacks();
@@ -2074,14 +2040,14 @@
void Isolate::DisableIncrementalBarrier() {
thread_registry()->ReleaseMarkingStacks();
- ASSERT(marking_stack_ != NULL);
- marking_stack_ = NULL;
- deferred_marking_stack_ = NULL;
+ ASSERT(marking_stack_ != nullptr);
+ marking_stack_ = nullptr;
+ deferred_marking_stack_ = nullptr;
ASSERT(!Thread::Current()->is_marking());
}
RawClass* Isolate::GetClassForHeapWalkAt(intptr_t cid) {
- RawClass* raw_class = NULL;
+ RawClass* raw_class = nullptr;
#if !defined(PRODUCT) && !defined(DART_PRECOMPILED_RUNTIME)
if (IsReloading()) {
raw_class = reload_context()->GetClassForHeapWalkAt(cid);
@@ -2091,7 +2057,7 @@
#else
raw_class = class_table()->At(cid);
#endif // !defined(PRODUCT) && !defined(DART_PRECOMPILED_RUNTIME)
- ASSERT(raw_class != NULL);
+ ASSERT(raw_class != nullptr);
ASSERT(remapping_cids() || raw_class->ptr()->id_ == cid);
return raw_class;
}
@@ -2155,7 +2121,7 @@
return "Unhandled";
default:
UNIMPLEMENTED();
- return NULL;
+ return nullptr;
}
}
@@ -2193,12 +2159,12 @@
if (!is_runnable()) {
// Isolate is not yet runnable.
- ASSERT((debugger() == NULL) || (debugger()->PauseEvent() == NULL));
+ ASSERT((debugger() == nullptr) || (debugger()->PauseEvent() == nullptr));
ServiceEvent pause_event(this, ServiceEvent::kNone);
jsobj.AddProperty("pauseEvent", &pause_event);
} else if (message_handler()->should_pause_on_start()) {
if (message_handler()->is_paused_on_start()) {
- ASSERT((debugger() == NULL) || (debugger()->PauseEvent() == NULL));
+ ASSERT((debugger() == nullptr) || (debugger()->PauseEvent() == nullptr));
ServiceEvent pause_event(this, ServiceEvent::kPauseStart);
jsobj.AddProperty("pauseEvent", &pause_event);
} else {
@@ -2208,21 +2174,22 @@
// Treat Runnable+ShouldPauseOnStart as NotRunnable so they see:
// NonRunnable -> PausedAtStart
// The should_pause_on_start flag is set to false after resume.
- ASSERT((debugger() == NULL) || (debugger()->PauseEvent() == NULL));
+ ASSERT((debugger() == nullptr) || (debugger()->PauseEvent() == nullptr));
ServiceEvent pause_event(this, ServiceEvent::kNone);
jsobj.AddProperty("pauseEvent", &pause_event);
}
} else if (message_handler()->is_paused_on_exit() &&
- ((debugger() == NULL) || (debugger()->PauseEvent() == NULL))) {
+ ((debugger() == nullptr) ||
+ (debugger()->PauseEvent() == nullptr))) {
ServiceEvent pause_event(this, ServiceEvent::kPauseExit);
jsobj.AddProperty("pauseEvent", &pause_event);
- } else if ((debugger() != NULL) && (debugger()->PauseEvent() != NULL) &&
+ } else if ((debugger() != nullptr) && (debugger()->PauseEvent() != nullptr) &&
!ResumeRequest()) {
jsobj.AddProperty("pauseEvent", debugger()->PauseEvent());
} else {
ServiceEvent pause_event(this, ServiceEvent::kResume);
- if (debugger() != NULL) {
+ if (debugger() != nullptr) {
// TODO(turnidge): Don't compute a full stack trace.
DebuggerStackTrace* stack = debugger()->StackTrace();
if (stack->Length() > 0) {
@@ -2273,18 +2240,18 @@
{
JSONArray breakpoints(&jsobj, "breakpoints");
- if (debugger() != NULL) {
+ if (debugger() != nullptr) {
debugger()->PrintBreakpointsToJSONArray(&breakpoints);
}
}
- Dart_ExceptionPauseInfo pause_info = (debugger() != NULL)
+ Dart_ExceptionPauseInfo pause_info = (debugger() != nullptr)
? debugger()->GetExceptionPauseInfo()
: kNoPauseOnExceptions;
jsobj.AddProperty("exceptionPauseMode",
ExceptionPauseInfoToServiceEnum(pause_info));
- if (debugger() != NULL) {
+ if (debugger() != nullptr) {
JSONObject settings(&jsobj, "_debuggerSettings");
debugger()->PrintSettingsToJSONObject(&settings);
}
@@ -2602,7 +2569,7 @@
// could be from our thread pool or it could be a thread from the
// embedder. Sit on the current thread handling service events
// until we are told to resume.
- if (pause_loop_monitor_ == NULL) {
+ if (pause_loop_monitor_ == nullptr) {
pause_loop_monitor_ = new Monitor();
}
Dart_EnterScope();
@@ -2612,7 +2579,7 @@
set_message_notify_callback(Isolate::WakePauseEventHandler);
#if !defined(DART_PRECOMPILED_RUNTIME)
- const bool had_isolate_reload_context = reload_context() != NULL;
+ const bool had_isolate_reload_context = reload_context() != nullptr;
const int64_t start_time_micros =
!had_isolate_reload_context ? 0 : reload_context()->start_time_micros();
#endif // !defined(DART_PRECOMPILED_RUNTIME)
@@ -2630,7 +2597,7 @@
}
#if !defined(DART_PRECOMPILED_RUNTIME)
- if (had_isolate_reload_context && (reload_context() == NULL)) {
+ if (had_isolate_reload_context && (reload_context() == nullptr)) {
if (FLAG_trace_reload) {
const int64_t reload_time_micros =
OS::GetCurrentMonotonicMicros() - start_time_micros;
@@ -2651,7 +2618,7 @@
#endif // !PRODUCT
void Isolate::VisitIsolates(IsolateVisitor* visitor) {
- if (visitor == NULL) {
+ if (visitor == nullptr) {
return;
}
// The visitor could potentially run code that could safepoint so use
@@ -2668,7 +2635,7 @@
MonitorLocker ml(isolates_list_monitor_);
intptr_t count = 0;
Isolate* current = isolates_list_head_;
- while (current != NULL) {
+ while (current != nullptr) {
count++;
current = current->next_;
}
@@ -2678,13 +2645,13 @@
Isolate* Isolate::LookupIsolateByPort(Dart_Port port) {
MonitorLocker ml(isolates_list_monitor_);
Isolate* current = isolates_list_head_;
- while (current != NULL) {
+ while (current != nullptr) {
if (current->main_port() == port) {
return current;
}
current = current->next_;
}
- return NULL;
+ return nullptr;
}
bool Isolate::AddIsolateToList(Isolate* isolate) {
@@ -2692,8 +2659,8 @@
if (!creation_enabled_) {
return false;
}
- ASSERT(isolate != NULL);
- ASSERT(isolate->next_ == NULL);
+ ASSERT(isolate != nullptr);
+ ASSERT(isolate->next_ == nullptr);
isolate->next_ = isolates_list_head_;
isolates_list_head_ = isolate;
return true;
@@ -2701,7 +2668,7 @@
void Isolate::RemoveIsolateFromList(Isolate* isolate) {
MonitorLocker ml(isolates_list_monitor_);
- ASSERT(isolate != NULL);
+ ASSERT(isolate != nullptr);
if (isolate == isolates_list_head_) {
isolates_list_head_ = isolate->next_;
if (!creation_enabled_) {
@@ -2709,11 +2676,11 @@
}
return;
}
- Isolate* previous = NULL;
+ Isolate* previous = nullptr;
Isolate* current = isolates_list_head_;
while (current) {
if (current == isolate) {
- ASSERT(previous != NULL);
+ ASSERT(previous != nullptr);
previous->next_ = current->next_;
if (!creation_enabled_) {
ml.Notify();
@@ -2779,7 +2746,7 @@
ApiMessageWriter writer;
Message* message =
writer.WriteCMessage(&kill_msg, main_port(), Message::kOOBPriority);
- ASSERT(message != NULL);
+ ASSERT(message != nullptr);
// Post the message at the given port.
bool success = PortMap::PostMessage(message);
@@ -2790,7 +2757,7 @@
class IsolateKillerVisitor : public IsolateVisitor {
public:
explicit IsolateKillerVisitor(Isolate::LibMsgId msg_id)
- : target_(NULL), msg_id_(msg_id) {}
+ : target_(nullptr), msg_id_(msg_id) {}
IsolateKillerVisitor(Isolate* isolate, Isolate::LibMsgId msg_id)
: target_(isolate), msg_id_(msg_id) {
@@ -2800,7 +2767,7 @@
virtual ~IsolateKillerVisitor() {}
void VisitIsolate(Isolate* isolate) {
- ASSERT(isolate != NULL);
+ ASSERT(isolate != nullptr);
if (ShouldKill(isolate)) {
isolate->KillLocked(msg_id_);
}
@@ -2810,8 +2777,8 @@
bool ShouldKill(Isolate* isolate) {
// If a target_ is specified, then only kill the target_.
// Otherwise, don't kill the service isolate or vm isolate.
- return (((target_ != NULL) && (isolate == target_)) ||
- ((target_ == NULL) && !IsVMInternalIsolate(isolate)));
+ return (((target_ != nullptr) && (isolate == target_)) ||
+ ((target_ == nullptr) && !IsVMInternalIsolate(isolate)));
}
Isolate* target_;
@@ -2848,9 +2815,9 @@
// Schedule the thread into the isolate by associating
// a 'Thread' structure with it (this is done while we are holding
// the thread registry lock).
- Thread* thread = NULL;
+ Thread* thread = nullptr;
OSThread* os_thread = OSThread::Current();
- if (os_thread != NULL) {
+ if (os_thread != nullptr) {
// We are about to associate the thread with an isolate and it would
// not be possible to correctly track no_safepoint_scope_depth for the
// thread in the constructor/destructor of MonitorLocker,
@@ -2859,8 +2826,8 @@
MonitorLocker ml(threads_lock(), false);
// Check to make sure we don't already have a mutator thread.
- if (is_mutator && scheduled_mutator_thread_ != NULL) {
- return NULL;
+ if (is_mutator && scheduled_mutator_thread_ != nullptr) {
+ return nullptr;
}
// If a safepoint operation is in progress wait for it
@@ -2871,13 +2838,13 @@
// Now get a free Thread structure.
thread = thread_registry()->GetFreeThreadLocked(this, is_mutator);
- ASSERT(thread != NULL);
+ ASSERT(thread != nullptr);
thread->ResetHighWatermark();
// Set up other values and set the TLS value.
thread->isolate_ = this;
- ASSERT(heap() != NULL);
+ ASSERT(heap() != nullptr);
thread->heap_ = heap();
thread->set_os_thread(os_thread);
ASSERT(thread->execution_state() == Thread::kThreadInNative);
@@ -2913,8 +2880,8 @@
sticky_error_ = thread->StealStickyError();
}
} else {
- ASSERT(thread->api_top_scope_ == NULL);
- ASSERT(thread->zone() == NULL);
+ ASSERT(thread->api_top_scope_ == nullptr);
+ ASSERT(thread->zone() == nullptr);
ASSERT(thread->sticky_error() == Error::null());
}
if (!bypass_safepoint) {
@@ -2922,12 +2889,12 @@
thread->EnterSafepoint();
}
OSThread* os_thread = thread->os_thread();
- ASSERT(os_thread != NULL);
+ ASSERT(os_thread != nullptr);
os_thread->DisableThreadInterrupts();
- os_thread->set_thread(NULL);
+ os_thread->set_thread(nullptr);
OSThread::SetCurrent(os_thread);
if (is_mutator) {
- scheduled_mutator_thread_ = NULL;
+ scheduled_mutator_thread_ = nullptr;
}
// Even if we unschedule the mutator thread, e.g. via calling
// `Dart_ExitIsolate()` inside a native, we might still have one or more Dart
@@ -2940,10 +2907,10 @@
// All other threads are not allowed to unschedule themselves and schedule
// again later on.
if (!is_mutator) {
- thread->isolate_ = NULL;
+ thread->isolate_ = nullptr;
}
- thread->heap_ = NULL;
- thread->set_os_thread(NULL);
+ thread->heap_ = nullptr;
+ thread->set_os_thread(nullptr);
thread->set_execution_state(Thread::kThreadInNative);
thread->set_safepoint_state(Thread::SetAtSafepoint(true, 0));
thread->clear_pending_functions();
@@ -2974,7 +2941,7 @@
Dart_Port on_exit_port,
Dart_Port on_error_port,
const char* debug_name)
- : isolate_(NULL),
+ : isolate_(nullptr),
parent_port_(parent_port),
origin_id_(origin_id),
init_data_(init_data),
@@ -2983,11 +2950,11 @@
script_url_(script_url),
package_root_(package_root),
package_config_(package_config),
- library_url_(NULL),
- class_name_(NULL),
- function_name_(NULL),
+ library_url_(nullptr),
+ class_name_(nullptr),
+ function_name_(nullptr),
debug_name_(debug_name),
- serialized_args_(NULL),
+ serialized_args_(nullptr),
serialized_message_(message_buffer->StealMessage()),
spawn_count_monitor_(spawn_count_monitor),
spawn_count_(spawn_count),
@@ -3025,7 +2992,7 @@
Dart_Port on_exit_port,
Dart_Port on_error_port,
const char* debug_name)
- : isolate_(NULL),
+ : isolate_(nullptr),
parent_port_(parent_port),
origin_id_(ILLEGAL_PORT),
init_data_(init_data),
@@ -3034,9 +3001,9 @@
script_url_(script_url),
package_root_(package_root),
package_config_(package_config),
- library_url_(NULL),
- class_name_(NULL),
- function_name_(NULL),
+ library_url_(nullptr),
+ class_name_(nullptr),
+ function_name_(nullptr),
debug_name_(debug_name),
serialized_args_(args_buffer->StealMessage()),
serialized_message_(message_buffer->StealMessage()),
@@ -3070,7 +3037,7 @@
const String& func_name = String::Handle(zone, String::New(function_name()));
- if (library_url() == NULL) {
+ if (library_url() == nullptr) {
// Handle spawnUri lookup rules.
// Check whether the root library defines a main function.
const Library& lib =
@@ -3106,7 +3073,7 @@
}
// Resolve the function.
- if (class_name() == NULL) {
+ if (class_name() == nullptr) {
const Function& func =
Function::Handle(zone, lib.LookupLocalFunction(func_name));
if (func.IsNull()) {
@@ -3125,7 +3092,7 @@
const String& msg = String::Handle(
zone, String::NewFormatted(
"Unable to resolve class '%s' in library '%s'.", class_name(),
- (library_url() != NULL ? library_url() : script_url())));
+ (library_url() != nullptr ? library_url() : script_url())));
return LanguageError::New(msg);
}
const Function& func =
@@ -3135,7 +3102,7 @@
zone, String::NewFormatted(
"Unable to resolve static method '%s.%s' in library '%s'.",
class_name(), function_name(),
- (library_url() != NULL ? library_url() : script_url())));
+ (library_url() != nullptr ? library_url() : script_url())));
return LanguageError::New(msg);
}
return func.raw();
@@ -3150,8 +3117,8 @@
}
void IsolateSpawnState::DecrementSpawnCount() {
- ASSERT(spawn_count_monitor_ != NULL);
- ASSERT(spawn_count_ != NULL);
+ ASSERT(spawn_count_monitor_ != nullptr);
+ ASSERT(spawn_count_ != nullptr);
MonitorLocker ml(spawn_count_monitor_);
ASSERT(*spawn_count_ > 0);
*spawn_count_ = *spawn_count_ - 1;
diff --git a/runtime/vm/isolate.h b/runtime/vm/isolate.h
index af038ff..c69042b 100644
--- a/runtime/vm/isolate.h
+++ b/runtime/vm/isolate.h
@@ -183,7 +183,7 @@
static inline Isolate* Current() {
Thread* thread = Thread::Current();
- return thread == NULL ? NULL : thread->isolate();
+ return thread == nullptr ? nullptr : thread->isolate();
}
// Register a newly introduced class.
@@ -306,14 +306,14 @@
// the caller to delete is separately if it is still needed.
bool ReloadSources(JSONStream* js,
bool force_reload,
- const char* root_script_url = NULL,
- const char* packages_url = NULL,
+ const char* root_script_url = nullptr,
+ const char* packages_url = nullptr,
bool dont_delete_reload_context = false);
// If provided, the VM takes ownership of kernel_buffer.
bool ReloadKernel(JSONStream* js,
bool force_reload,
- const uint8_t* kernel_buffer = NULL,
+ const uint8_t* kernel_buffer = nullptr,
intptr_t kernel_buffer_size = 0,
bool dont_delete_reload_context = false);
#endif // !defined(PRODUCT) && !defined(DART_PRECOMPILED_RUNTIME)
@@ -369,7 +369,7 @@
#if !defined(PRODUCT)
Debugger* debugger() const {
- ASSERT(debugger_ != NULL);
+ ASSERT(debugger_ != nullptr);
return debugger_;
}
@@ -469,10 +469,10 @@
MallocGrowableArray<PendingLazyDeopt>* pending_deopts() const {
return pending_deopts_;
}
- bool IsDeoptimizing() const { return deopt_context_ != NULL; }
+ bool IsDeoptimizing() const { return deopt_context_ != nullptr; }
DeoptContext* deopt_context() const { return deopt_context_; }
void set_deopt_context(DeoptContext* value) {
- ASSERT(value == NULL || deopt_context_ == NULL);
+ ASSERT(value == nullptr || deopt_context_ == nullptr);
deopt_context_ = value;
}
@@ -530,7 +530,7 @@
VMTagCounters* vm_tag_counters() { return &vm_tag_counters_; }
#if !defined(DART_PRECOMPILED_RUNTIME)
- bool IsReloading() const { return reload_context_ != NULL; }
+ bool IsReloading() const { return reload_context_ != nullptr; }
IsolateReloadContext* reload_context() { return reload_context_; }
@@ -784,8 +784,8 @@
static void KillAllIsolates(LibMsgId msg_id);
static void KillIfExists(Isolate* isolate, LibMsgId msg_id);
- // Lookup an isolate by its main port. Returns NULL if no matching isolate is
- // found.
+ // Lookup an isolate by its main port. Returns nullptr if no matching isolate
+ // is found.
static Isolate* LookupIsolateByPort(Dart_Port port);
static void DisableIsolateCreation();
@@ -871,19 +871,19 @@
// in SIMARM(IA32) and ARM, and the same offsets in SIMARM64(X64) and ARM64.
// We use only word-sized fields to avoid differences in struct packing on the
// different architectures. See also CheckOffsets in dart.cc.
- uword user_tag_;
+ uword user_tag_ = 0;
RawUserTag* current_tag_;
RawUserTag* default_tag_;
RawCode* ic_miss_code_;
- ObjectStore* object_store_;
+ ObjectStore* object_store_ = nullptr;
ClassTable class_table_;
- bool single_step_;
+ bool single_step_ = false;
// End accessed from generated code.
- StoreBuffer* store_buffer_;
- MarkingStack* marking_stack_;
- MarkingStack* deferred_marking_stack_;
- Heap* heap_;
+ StoreBuffer* store_buffer_ = nullptr;
+ MarkingStack* marking_stack_ = nullptr;
+ MarkingStack* deferred_marking_stack_ = nullptr;
+ Heap* heap_ = nullptr;
#define ISOLATE_FLAG_BITS(V) \
V(ErrorsFatal) \
@@ -919,23 +919,23 @@
ISOLATE_FLAG_BITS(DECLARE_BITFIELD)
#undef DECLARE_BITFIELD
- uint32_t isolate_flags_;
+ uint32_t isolate_flags_ = 0;
// Unoptimized background compilation.
- BackgroundCompiler* background_compiler_;
+ BackgroundCompiler* background_compiler_ = nullptr;
// Optimized background compilation.
- BackgroundCompiler* optimizing_background_compiler_;
+ BackgroundCompiler* optimizing_background_compiler_ = nullptr;
// Fields that aren't needed in a product build go here with boolean flags at
// the top.
#if !defined(PRODUCT)
- Debugger* debugger_;
+ Debugger* debugger_ = nullptr;
int64_t last_resume_timestamp_;
// Timestamps of last operation via service.
- int64_t last_allocationprofile_accumulator_reset_timestamp_;
- int64_t last_allocationprofile_gc_timestamp_;
+ int64_t last_allocationprofile_accumulator_reset_timestamp_ = 0;
+ int64_t last_allocationprofile_gc_timestamp_ = 0;
VMTagCounters vm_tag_counters_;
@@ -959,41 +959,42 @@
};
RawGrowableObjectArray* registered_service_extension_handlers_;
- Metric* metrics_list_head_;
+ Metric* metrics_list_head_ = nullptr;
// Used to wake the isolate when it is in the pause event loop.
- Monitor* pause_loop_monitor_;
+ Monitor* pause_loop_monitor_ = nullptr;
#define ISOLATE_METRIC_VARIABLE(type, variable, name, unit) \
type metric_##variable##_;
ISOLATE_METRIC_LIST(ISOLATE_METRIC_VARIABLE);
#undef ISOLATE_METRIC_VARIABLE
- intptr_t no_reload_scope_depth_; // we can only reload when this is 0.
+ intptr_t no_reload_scope_depth_ = 0; // we can only reload when this is 0.
// Per-isolate copy of FLAG_reload_every.
intptr_t reload_every_n_stack_overflow_checks_;
- IsolateReloadContext* reload_context_;
+ IsolateReloadContext* reload_context_ = nullptr;
int64_t last_reload_timestamp_;
// Ring buffer of objects assigned an id.
- ObjectIdRing* object_id_ring_;
+ ObjectIdRing* object_id_ring_ = nullptr;
#endif // !defined(PRODUCT)
// All other fields go here.
int64_t start_time_micros_;
ThreadRegistry* thread_registry_;
SafepointHandler* safepoint_handler_;
- Dart_MessageNotifyCallback message_notify_callback_;
- char* name_;
- Dart_Port main_port_;
- Dart_Port origin_id_; // Isolates created by spawnFunc have some origin id.
- uint64_t pause_capability_;
- uint64_t terminate_capability_;
- void* init_callback_data_;
- Dart_EnvironmentCallback environment_callback_;
- Dart_LibraryTagHandler library_tag_handler_;
- ApiState* api_state_;
+ Dart_MessageNotifyCallback message_notify_callback_ = nullptr;
+ char* name_ = nullptr;
+ Dart_Port main_port_ = 0;
+ // Isolates created by Isolate.spawn have the same origin id.
+ Dart_Port origin_id_ = 0;
+ uint64_t pause_capability_ = 0;
+ uint64_t terminate_capability_ = 0;
+ void* init_callback_data_ = nullptr;
+ Dart_EnvironmentCallback environment_callback_ = nullptr;
+ Dart_LibraryTagHandler library_tag_handler_ = nullptr;
+ ApiState* api_state_ = nullptr;
Random random_;
- Simulator* simulator_;
+ Simulator* simulator_ = nullptr;
Mutex* mutex_; // Protects compiler stats.
Mutex* symbols_mutex_; // Protects concurrent access to the symbol table.
Mutex* type_canonicalization_mutex_; // Protects type canonicalization.
@@ -1002,11 +1003,11 @@
Mutex* kernel_data_lib_cache_mutex_;
Mutex* kernel_data_class_cache_mutex_;
Mutex* kernel_constants_mutex_;
- MessageHandler* message_handler_;
- IsolateSpawnState* spawn_state_;
- intptr_t defer_finalization_count_;
+ MessageHandler* message_handler_ = nullptr;
+ IsolateSpawnState* spawn_state_ = nullptr;
+ intptr_t defer_finalization_count_ = 0;
MallocGrowableArray<PendingLazyDeopt>* pending_deopts_;
- DeoptContext* deopt_context_;
+ DeoptContext* deopt_context_ = nullptr;
RawGrowableObjectArray* tag_table_;
@@ -1021,12 +1022,12 @@
RawGrowableObjectArray* reloaded_kernel_blobs_;
// Isolate list next pointer.
- Isolate* next_;
+ Isolate* next_ = nullptr;
// Invalidation generations; used to track events occurring in parallel
// to background compilation. The counters may overflow, which is OK
// since we check for equality to detect if an event occured.
- intptr_t loading_invalidation_gen_;
+ intptr_t loading_invalidation_gen_ = kInvalidGen;
// Protect access to boxed_field_list_.
Mutex* field_list_mutex_;
@@ -1036,15 +1037,15 @@
// This guards spawn_count_. An isolate cannot complete shutdown and be
// destroyed while there are child isolates in the midst of a spawn.
Monitor* spawn_count_monitor_;
- intptr_t spawn_count_;
+ intptr_t spawn_count_ = 0;
HandlerInfoCache handler_info_cache_;
CatchEntryMovesCache catch_entry_moves_cache_;
- Dart_QualifiedFunctionName* embedder_entry_points_;
- const char** obfuscation_map_;
+ Dart_QualifiedFunctionName* embedder_entry_points_ = nullptr;
+ const char** obfuscation_map_ = nullptr;
- ReversePcLookupCache* reverse_pc_lookup_cache_;
+ ReversePcLookupCache* reverse_pc_lookup_cache_ = nullptr;
static Dart_IsolateCreateCallback create_callback_;
static Dart_IsolateShutdownCallback shutdown_callback_;
@@ -1089,14 +1090,13 @@
public:
explicit StartIsolateScope(Isolate* new_isolate)
: new_isolate_(new_isolate), saved_isolate_(Isolate::Current()) {
- // TODO(koda): Audit users; passing NULL goes against naming of this class.
- if (new_isolate_ == NULL) {
- ASSERT(Isolate::Current() == NULL);
+ if (new_isolate_ == nullptr) {
+ ASSERT(Isolate::Current() == nullptr);
// Do nothing.
return;
}
if (saved_isolate_ != new_isolate_) {
- ASSERT(Isolate::Current() == NULL);
+ ASSERT(Isolate::Current() == nullptr);
Thread::EnterIsolate(new_isolate_);
// Ensure this is not a nested 'isolate enter' with prior state.
ASSERT(Thread::Current()->saved_stack_limit() == 0);
@@ -1104,13 +1104,13 @@
}
~StartIsolateScope() {
- if (new_isolate_ == NULL) {
- ASSERT(Isolate::Current() == NULL);
+ if (new_isolate_ == nullptr) {
+ ASSERT(Isolate::Current() == nullptr);
// Do nothing.
return;
}
if (saved_isolate_ != new_isolate_) {
- ASSERT(saved_isolate_ == NULL);
+ ASSERT(saved_isolate_ == nullptr);
// ASSERT that we have bottomed out of all Dart invocations.
ASSERT(Thread::Current()->saved_stack_limit() == 0);
Thread::ExitIsolate();
@@ -1172,7 +1172,7 @@
const char* class_name() const { return class_name_; }
const char* function_name() const { return function_name_; }
const char* debug_name() const { return debug_name_; }
- bool is_spawn_uri() const { return library_url_ == NULL; }
+ bool is_spawn_uri() const { return library_url_ == nullptr; }
bool paused() const { return paused_; }
bool errors_are_fatal() const { return errors_are_fatal_; }
Dart_IsolateFlags* isolate_flags() { return &isolate_flags_; }