diff --git a/runtime/vm/allocation.cc b/runtime/vm/allocation.cc index 5c3db033999..cf381d0f5bf 100644 --- a/runtime/vm/allocation.cc +++ b/runtime/vm/allocation.cc @@ -12,7 +12,7 @@ namespace dart { static void* Allocate(uword size, Zone* zone) { - ASSERT(zone != NULL); + ASSERT(zone != nullptr); if (size > static_cast(kIntptrMax)) { FATAL("ZoneAllocated object has unexpectedly large size %" Pu "", size); } @@ -28,13 +28,13 @@ void* ZoneAllocated::operator new(uword size, Zone* zone) { } StackResource::~StackResource() { - if (thread_ != NULL) { + if (thread_ != nullptr) { StackResource* top = thread_->top_resource(); ASSERT(top == this); thread_->set_top_resource(previous_); } #if defined(DEBUG) - if (thread_ != NULL) { + if (thread_ != nullptr) { ASSERT(Thread::Current() == thread_); } #endif @@ -45,11 +45,11 @@ void StackResource::Init(ThreadState* thread) { // thread and isolate. If there is no current thread, we don't need to // protect this case. // TODO(23807): Eliminate this special case. - if (thread != NULL) { + if (thread != nullptr) { ASSERT(Thread::Current() == thread); thread_ = thread; previous_ = thread_->top_resource(); - ASSERT((previous_ == NULL) || (previous_->thread_ == thread)); + ASSERT((previous_ == nullptr) || (previous_->thread_ == thread)); thread_->set_top_resource(this); } } diff --git a/runtime/vm/allocation.h b/runtime/vm/allocation.h index fd1bdfa26a4..d11f988f08d 100644 --- a/runtime/vm/allocation.h +++ b/runtime/vm/allocation.h @@ -22,7 +22,8 @@ class Zone; // to a stack frame above the frame where these objects were allocated. class StackResource { public: - explicit StackResource(ThreadState* thread) : thread_(NULL), previous_(NULL) { + explicit StackResource(ThreadState* thread) + : thread_(nullptr), previous_(nullptr) { Init(thread); } @@ -32,7 +33,7 @@ class StackResource { ThreadState* thread() const { return thread_; } // Destroy stack resources of thread until top exit frame. - static void Unwind(ThreadState* thread) { UnwindAbove(thread, NULL); } + static void Unwind(ThreadState* thread) { UnwindAbove(thread, nullptr); } // Destroy stack resources of thread above new_top, exclusive. static void UnwindAbove(ThreadState* thread, StackResource* new_top); diff --git a/runtime/vm/analyze_snapshot_api_impl.cc b/runtime/vm/analyze_snapshot_api_impl.cc index 07452727202..ccfc3534f47 100644 --- a/runtime/vm/analyze_snapshot_api_impl.cc +++ b/runtime/vm/analyze_snapshot_api_impl.cc @@ -119,7 +119,7 @@ void DumpClassTableJSON(Thread* thread, js->PrintProperty("name", name.ToCString()); // Note: Some meta info is stripped from the snapshot, it's important - // to check for NULL periodically to avoid segfaults. + // to check for nullptr periodically to avoid segfaults. const AbstractType& super_type = AbstractType::Handle(cls.super_type()); if (!super_type.IsNull()) { const String& super_name = String::Handle(super_type.Name()); diff --git a/runtime/vm/app_snapshot.cc b/runtime/vm/app_snapshot.cc index 395a31ef3e8..0dd1576b4b0 100644 --- a/runtime/vm/app_snapshot.cc +++ b/runtime/vm/app_snapshot.cc @@ -51,7 +51,7 @@ DEFINE_FLAG(bool, #if defined(DART_PRECOMPILER) DEFINE_FLAG(charp, write_v8_snapshot_profile_to, - NULL, + nullptr, "Write a snapshot profile in V8 format to a file."); DEFINE_FLAG(bool, print_array_optimization_candidates, @@ -495,7 +495,8 @@ class ClassDeserializationCluster : public DeserializationCluster { // explicitly as Array objects into the snapshot and instead utilize a different // encoding: objects in a cluster representing a canonical set are sorted // to appear in the same order they appear in the Array representing the set, -// and we additionally write out array of values describing gaps between objects. +// and we additionally write out array of values describing gaps between +// objects. // // In some situations not all canonical objects of the some type need to // be added to the resulting canonical set because they are cached in some @@ -1740,8 +1741,8 @@ class LibraryDeserializationCluster : public DeserializationCluster { LibraryPtr lib = static_cast(d.Ref(id)); Deserializer::InitializeHeader(lib, kLibraryCid, Library::InstanceSize()); d.ReadFromTo(lib); - lib->untag()->native_entry_resolver_ = NULL; - lib->untag()->native_entry_symbol_resolver_ = NULL; + lib->untag()->native_entry_resolver_ = nullptr; + lib->untag()->native_entry_symbol_resolver_ = nullptr; lib->untag()->index_ = d.Read(); lib->untag()->num_imports_ = d.Read(); lib->untag()->load_state_ = d.Read(); @@ -7159,7 +7160,7 @@ SerializationCluster* Serializer::NewClusterForClass(intptr_t cid, bool is_canonical) { #if defined(DART_PRECOMPILED_RUNTIME) UNREACHABLE(); - return NULL; + return nullptr; #else Zone* Z = zone_; if (cid >= kNumPredefinedCids || cid == kInstanceCid) { @@ -7318,9 +7319,9 @@ SerializationCluster* Serializer::NewClusterForClass(intptr_t cid, break; } - // The caller will check for NULL and provide an error with more context than - // is available here. - return NULL; + // The caller will check for nullptr and provide an error with more context + // than is available here. + return nullptr; #endif // !DART_PRECOMPILED_RUNTIME } @@ -7708,7 +7709,7 @@ uint32_t Serializer::GetDataOffset(ObjectPtr object) const { } intptr_t Serializer::GetDataSize() const { - if (image_writer_ == NULL) { + if (image_writer_ == nullptr) { return 0; } return image_writer_->data_size(); @@ -7844,13 +7845,13 @@ ObjectPtr Serializer::ParentOf(const Object& object) const { void Serializer::WriteVersionAndFeatures(bool is_vm_snapshot) { const char* expected_version = Version::SnapshotString(); - ASSERT(expected_version != NULL); + ASSERT(expected_version != nullptr); const intptr_t version_len = strlen(expected_version); WriteBytes(reinterpret_cast(expected_version), version_len); char* expected_features = Dart::FeaturesString(IsolateGroup::Current(), is_vm_snapshot, kind_); - ASSERT(expected_features != NULL); + ASSERT(expected_features != nullptr); const intptr_t features_len = strlen(expected_features); WriteBytes(reinterpret_cast(expected_features), features_len + 1); @@ -8498,7 +8499,7 @@ DeserializationCluster* Deserializer::ReadCluster() { break; } FATAL("No cluster defined for cid %" Pd, cid); - return NULL; + return nullptr; } void Deserializer::ReadDispatchTable( @@ -8607,7 +8608,7 @@ char* SnapshotHeaderReader::VerifyVersion() { // Note: New things are allocated only if we're going to return an error. const char* expected_version = Version::SnapshotString(); - ASSERT(expected_version != NULL); + ASSERT(expected_version != nullptr); const intptr_t version_len = strlen(expected_version); if (stream_.PendingBytes() < version_len) { const intptr_t kMessageBufferSize = 128; @@ -8620,7 +8621,7 @@ char* SnapshotHeaderReader::VerifyVersion() { const char* version = reinterpret_cast(stream_.AddressOfCurrentPosition()); - ASSERT(version != NULL); + ASSERT(version != nullptr); if (strncmp(version, expected_version, version_len) != 0) { const intptr_t kMessageBufferSize = 256; char message_buffer[kMessageBufferSize]; @@ -8639,8 +8640,8 @@ char* SnapshotHeaderReader::VerifyVersion() { char* SnapshotHeaderReader::VerifyFeatures(IsolateGroup* isolate_group) { const char* expected_features = - Dart::FeaturesString(isolate_group, (isolate_group == NULL), kind_); - ASSERT(expected_features != NULL); + Dart::FeaturesString(isolate_group, (isolate_group == nullptr), kind_); + ASSERT(expected_features != nullptr); const intptr_t expected_len = strlen(expected_features); const char* features = nullptr; @@ -8902,7 +8903,7 @@ void Deserializer::Deserialize(DeserializationRoots* roots) { ASSERT(section_marker == kSectionMarker); #endif - refs_ = NULL; + refs_ = nullptr; } roots->PostLoad(this, refs); @@ -8946,10 +8947,10 @@ FullSnapshotWriter::FullSnapshotWriter( isolate_snapshot_size_(0), vm_image_writer_(vm_image_writer), isolate_image_writer_(isolate_image_writer) { - ASSERT(isolate_group() != NULL); - ASSERT(heap() != NULL); + ASSERT(isolate_group() != nullptr); + ASSERT(heap() != nullptr); ObjectStore* object_store = isolate_group()->object_store(); - ASSERT(object_store != NULL); + ASSERT(object_store != nullptr); #if defined(DEBUG) isolate_group()->ValidateClassTable(); @@ -9008,7 +9009,7 @@ void FullSnapshotWriter::WriteProgramSnapshot( serializer.set_loading_units(units); serializer.set_current_loading_unit_id(LoadingUnit::kRootId); ObjectStore* object_store = isolate_group()->object_store(); - ASSERT(object_store != NULL); + ASSERT(object_store != nullptr); // These type arguments must always be retained. ASSERT(object_store->type_argument_int()->untag()->IsCanonical()); @@ -9299,10 +9300,10 @@ ApiErrorPtr FullSnapshotReader::ReadVMSnapshot() { } if (Snapshot::IncludesCode(kind_)) { - ASSERT(data_image_ != NULL); + ASSERT(data_image_ != nullptr); thread_->isolate_group()->SetupImagePage(data_image_, /* is_executable */ false); - ASSERT(instructions_image_ != NULL); + ASSERT(instructions_image_ != nullptr); thread_->isolate_group()->SetupImagePage(instructions_image_, /* is_executable */ true); } @@ -9340,10 +9341,10 @@ ApiErrorPtr FullSnapshotReader::ReadProgramSnapshot() { } if (Snapshot::IncludesCode(kind_)) { - ASSERT(data_image_ != NULL); + ASSERT(data_image_ != nullptr); thread_->isolate_group()->SetupImagePage(data_image_, /* is_executable */ false); - ASSERT(instructions_image_ != NULL); + ASSERT(instructions_image_ != nullptr); thread_->isolate_group()->SetupImagePage(instructions_image_, /* is_executable */ true); } @@ -9385,10 +9386,10 @@ ApiErrorPtr FullSnapshotReader::ReadUnitSnapshot(const LoadingUnit& unit) { } if (Snapshot::IncludesCode(kind_)) { - ASSERT(data_image_ != NULL); + ASSERT(data_image_ != nullptr); thread_->isolate_group()->SetupImagePage(data_image_, /* is_executable */ false); - ASSERT(instructions_image_ != NULL); + ASSERT(instructions_image_ != nullptr); thread_->isolate_group()->SetupImagePage(instructions_image_, /* is_executable */ true); } diff --git a/runtime/vm/benchmark_test.cc b/runtime/vm/benchmark_test.cc index e99ebd14f82..39dfc1b8003 100644 --- a/runtime/vm/benchmark_test.cc +++ b/runtime/vm/benchmark_test.cc @@ -26,14 +26,14 @@ using dart::bin::File; namespace dart { -Benchmark* Benchmark::first_ = NULL; -Benchmark* Benchmark::tail_ = NULL; -const char* Benchmark::executable_ = NULL; +Benchmark* Benchmark::first_ = nullptr; +Benchmark* Benchmark::tail_ = nullptr; +const char* Benchmark::executable_ = nullptr; void Benchmark::RunAll(const char* executable) { SetExecutable(executable); Benchmark* benchmark = first_; - while (benchmark != NULL) { + while (benchmark != nullptr) { benchmark->RunBenchmark(); benchmark = benchmark->next_; } @@ -65,24 +65,25 @@ BENCHMARK(CorelibCompileAll) { // which is depended on by run_vm_tests. static char* ComputeKernelServicePath(const char* arg) { char buffer[2048]; - char* kernel_service_path = Utils::StrDup(File::GetCanonicalPath(NULL, arg)); - EXPECT(kernel_service_path != NULL); + char* kernel_service_path = + Utils::StrDup(File::GetCanonicalPath(nullptr, arg)); + EXPECT(kernel_service_path != nullptr); const char* compiler_path = "%s%sgen%skernel_service.dill"; const char* path_separator = File::PathSeparator(); - ASSERT(path_separator != NULL && strlen(path_separator) == 1); + ASSERT(path_separator != nullptr && strlen(path_separator) == 1); char* ptr = strrchr(kernel_service_path, *path_separator); - while (ptr != NULL) { + while (ptr != nullptr) { *ptr = '\0'; Utils::SNPrint(buffer, ARRAY_SIZE(buffer), compiler_path, kernel_service_path, path_separator, path_separator); - if (File::Exists(NULL, buffer)) { + if (File::Exists(nullptr, buffer)) { break; } ptr = strrchr(kernel_service_path, *path_separator); } free(kernel_service_path); - if (ptr == NULL) { - return NULL; + if (ptr == nullptr) { + return nullptr; } return Utils::StrDup(buffer); } @@ -151,9 +152,9 @@ static void UseDartApi(Dart_NativeArguments args) { static Dart_NativeFunction bm_uda_lookup(Dart_Handle name, int argument_count, bool* auto_setup_scope) { - ASSERT(auto_setup_scope != NULL); + ASSERT(auto_setup_scope != nullptr); *auto_setup_scope = true; - const char* cstr = NULL; + const char* cstr = nullptr; Dart_Handle result = Dart_StringToCString(name, &cstr); EXPECT_VALID(result); if (strcmp(cstr, "init") == 0) { @@ -231,7 +232,7 @@ BENCHMARK(DartStringAccess) { EXPECT(!Dart_IsExternalString(internal_string)); EXPECT_VALID(external_string); EXPECT(Dart_IsExternalString(external_string)); - void* external_peer = NULL; + void* external_peer = nullptr; EXPECT_VALID(Dart_StringGetProperties(external_string, &char_size, &str_len, &external_peer)); EXPECT_EQ(1, char_size); @@ -250,7 +251,7 @@ static void vmservice_resolver(Dart_NativeArguments args) {} static Dart_NativeFunction NativeResolver(Dart_Handle name, int arg_count, bool* auto_setup_scope) { - ASSERT(auto_setup_scope != NULL); + ASSERT(auto_setup_scope != nullptr); *auto_setup_scope = false; return &vmservice_resolver; } @@ -267,8 +268,8 @@ BENCHMARK(KernelServiceCompileAll) { bin::Builtin::SetNativeResolver(bin::Builtin::kIOLibrary); bin::Builtin::SetNativeResolver(bin::Builtin::kCLILibrary); char* dill_path = ComputeKernelServicePath(Benchmark::Executable()); - File* file = File::Open(NULL, dill_path, File::kRead); - EXPECT(file != NULL); + File* file = File::Open(nullptr, dill_path, File::kRead); + EXPECT(file != nullptr); bin::RefCntReleaseScope rs(file); intptr_t kernel_buffer_size = file->Length(); uint8_t* kernel_buffer = @@ -280,7 +281,7 @@ BENCHMARK(KernelServiceCompileAll) { EXPECT_VALID(result); Dart_Handle service_lib = Dart_LookupLibrary(NewString("dart:vmservice_io")); ASSERT(!Dart_IsError(service_lib)); - Dart_SetNativeResolver(service_lib, NativeResolver, NULL); + Dart_SetNativeResolver(service_lib, NativeResolver, nullptr); result = Dart_FinalizeLoading(false); EXPECT_VALID(result); @@ -317,7 +318,7 @@ static void StackFrame_accessFrame(Dart_NativeArguments args) { StackFrameIterator frames(ValidationPolicy::kDontValidateFrames, thread, StackFrameIterator::kNoCrossThreadIteration); StackFrame* frame = frames.NextFrame(); - while (frame != NULL) { + while (frame != nullptr) { if (frame->IsStubFrame()) { code = frame->LookupDartCode(); EXPECT(code.function() == Function::null()); @@ -337,7 +338,7 @@ static void StackFrame_accessFrame(Dart_NativeArguments args) { static Dart_NativeFunction StackFrameNativeResolver(Dart_Handle name, int arg_count, bool* auto_setup_scope) { - ASSERT(auto_setup_scope != NULL); + ASSERT(auto_setup_scope != nullptr); *auto_setup_scope = false; return &StackFrame_accessFrame; } @@ -388,7 +389,7 @@ BENCHMARK(FrameLookup) { Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, StackFrameNativeResolver); Dart_Handle cls = Dart_GetClass(lib, NewString("StackFrameTest")); - Dart_Handle result = Dart_Invoke(cls, NewString("testMain"), 0, NULL); + Dart_Handle result = Dart_Invoke(cls, NewString("testMain"), 0, nullptr); EXPECT_VALID(result); int64_t elapsed_time = 0; result = Dart_IntegerToInt64(result, &elapsed_time); @@ -411,7 +412,7 @@ BENCHMARK_SIZE(CoreSnapshotSize) { // Start an Isolate, load a script and create a full snapshot. // Need to load the script into the dart: core library due to // the import of dart:_internal. - TestCase::LoadCoreTestScript(kScriptChars, NULL); + TestCase::LoadCoreTestScript(kScriptChars, nullptr); TransitionNativeToVM transition(thread); StackZone zone(thread); @@ -448,7 +449,7 @@ BENCHMARK_SIZE(StandaloneSnapshotSize) { // Start an Isolate, load a script and create a full snapshot. // Need to load the script into the dart: core library due to // the import of dart:_internal. - TestCase::LoadCoreTestScript(kScriptChars, NULL); + TestCase::LoadCoreTestScript(kScriptChars, nullptr); TransitionNativeToVM transition(thread); StackZone zone(thread); @@ -476,11 +477,11 @@ BENCHMARK(CreateMirrorSystem) { " currentMirrorSystem();\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, nullptr); Timer timer; timer.Start(); - Dart_Handle result = Dart_Invoke(lib, NewString("benchmark"), 0, NULL); + Dart_Handle result = Dart_Invoke(lib, NewString("benchmark"), 0, nullptr); EXPECT_VALID(result); timer.Stop(); int64_t elapsed_time = timer.TotalElapsedTime(); @@ -492,7 +493,7 @@ BENCHMARK(EnterExitIsolate) { "import 'dart:core';\n" "\n"; const intptr_t kLoopCount = 1000000; - TestCase::LoadTestScript(kScriptChars, NULL); + TestCase::LoadTestScript(kScriptChars, nullptr); { TransitionNativeToVM transition(thread); StackZone zone(thread); @@ -582,9 +583,9 @@ BENCHMARK(LargeMap) { " for (int i = 0; i < 100000; ++i) m[i*13+i*(i>>7)] = i;\n" " return m;\n" "}"; - Dart_Handle h_lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle h_lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(h_lib); - Dart_Handle h_result = Dart_Invoke(h_lib, NewString("makeMap"), 0, NULL); + Dart_Handle h_result = Dart_Invoke(h_lib, NewString("makeMap"), 0, nullptr); EXPECT_VALID(h_result); TransitionNativeToVM transition(thread); StackZone zone(thread); diff --git a/runtime/vm/benchmark_test.h b/runtime/vm/benchmark_test.h index b8f8528818b..0fbd4329245 100644 --- a/runtime/vm/benchmark_test.h +++ b/runtime/vm/benchmark_test.h @@ -20,7 +20,7 @@ DECLARE_FLAG(int, code_heap_size); DECLARE_FLAG(int, old_gen_growth_space_ratio); namespace bin { -// Snapshot pieces if we link in a snapshot, otherwise initialized to NULL. +// Snapshot pieces if we link in a snapshot, otherwise initialized to nullptr. extern const uint8_t* vm_snapshot_data; extern const uint8_t* vm_snapshot_instructions; extern const uint8_t* core_isolate_snapshot_data; @@ -60,9 +60,9 @@ class Benchmark { name_(name), score_kind_(score_kind), score_(0), - isolate_(NULL), - next_(NULL) { - if (first_ == NULL) { + isolate_(nullptr), + next_(nullptr) { + if (first_ == nullptr) { first_ = this; } else { tail_->next_ = this; @@ -86,7 +86,7 @@ class Benchmark { void CreateIsolate() { isolate_ = TestCase::CreateTestIsolate(); - EXPECT(isolate_ != NULL); + EXPECT(isolate_ != nullptr); } private: @@ -114,7 +114,7 @@ class BenchmarkIsolateScope { Dart_ExitScope(); // Exit the Dart API scope created for unit tests. ASSERT(benchmark_->isolate() == Isolate::Current()); Dart_ShutdownIsolate(); - benchmark_ = NULL; + benchmark_ = nullptr; } Benchmark* benchmark() const { return benchmark_; } diff --git a/runtime/vm/bootstrap.h b/runtime/vm/bootstrap.h index e9c3bd9e4c8..cd7f81db408 100644 --- a/runtime/vm/bootstrap.h +++ b/runtime/vm/bootstrap.h @@ -19,8 +19,8 @@ class Program; class Bootstrap : public AllStatic { public: // Compile the bootstrap libraries, either from sources or a Kernel program. - // If program is NULL, compile from sources or source paths linked into - // the VM. If it is non-NULL it represents the Kernel program to use for + // If program is nullptr, compile from sources or source paths linked into + // the VM. If it is non-null it represents the Kernel program to use for // bootstrapping. // The caller of this function is responsible for managing the kernel // program's memory. diff --git a/runtime/vm/bootstrap_natives.cc b/runtime/vm/bootstrap_natives.cc index 4258c9ddd2f..63d1e1689ec 100644 --- a/runtime/vm/bootstrap_natives.cc +++ b/runtime/vm/bootstrap_natives.cc @@ -47,12 +47,12 @@ Dart_NativeFunction BootstrapNatives::Lookup(Dart_Handle name, TransitionNativeToVM transition(thread); const Object& obj = Object::Handle(thread->zone(), Api::UnwrapHandle(name)); if (!obj.IsString()) { - return NULL; + return nullptr; } ASSERT(auto_setup_scope); *auto_setup_scope = false; const char* function_name = obj.ToCString(); - ASSERT(function_name != NULL); + ASSERT(function_name != nullptr); int num_entries = sizeof(BootStrapEntries) / sizeof(struct NativeEntries); for (int i = 0; i < num_entries; i++) { const struct NativeEntries* entry = &(BootStrapEntries[i]); @@ -61,7 +61,7 @@ Dart_NativeFunction BootstrapNatives::Lookup(Dart_Handle name, return reinterpret_cast(entry->function_); } } - return NULL; + return nullptr; } void* BootstrapNatives::LookupFfiNative(const char* name, @@ -85,7 +85,7 @@ const uint8_t* BootstrapNatives::Symbol(Dart_NativeFunction nf) { return reinterpret_cast(entry->name_); } } - return NULL; + return nullptr; } void Bootstrap::SetupNativeResolver() { diff --git a/runtime/vm/class_finalizer.cc b/runtime/vm/class_finalizer.cc index ba1e05205fe..f9af9305417 100644 --- a/runtime/vm/class_finalizer.cc +++ b/runtime/vm/class_finalizer.cc @@ -359,7 +359,7 @@ void ClassFinalizer::FinalizeTypeParameters(Zone* zone, void ClassFinalizer::CheckRecursiveType(const AbstractType& type, PendingTypes* pending_types) { ASSERT(!type.IsFunctionType()); - ASSERT(pending_types != NULL); + ASSERT(pending_types != nullptr); Zone* zone = Thread::Current()->zone(); if (FLAG_trace_type_finalization) { THR_Print("Checking recursive type '%s': %s\n", @@ -744,7 +744,7 @@ AbstractTypePtr ClassFinalizer::FinalizeType(const AbstractType& type, PendingTypes* pending_types) { // Only the 'root' type of the graph can be canonicalized, after all depending // types have been bound checked. - ASSERT((pending_types == NULL) || (finalization < kCanonicalize)); + ASSERT((pending_types == nullptr) || (finalization < kCanonicalize)); if (type.IsFinalized()) { // Ensure type is canonical if canonicalization is requested. if ((finalization >= kCanonicalize) && !type.IsCanonical() && @@ -845,7 +845,7 @@ AbstractTypePtr ClassFinalizer::FinalizeType(const AbstractType& type, // This type is the root type of the type graph if no pending types queue is // allocated yet. A function type is a collection of types, but not a root. - const bool is_root_type = pending_types == NULL; + const bool is_root_type = pending_types == nullptr; if (is_root_type) { pending_types = new PendingTypes(zone, 4); } @@ -1315,7 +1315,7 @@ void ClassFinalizer::PrintClassInformation(const Class& cls) { } const AbstractType& super_type = AbstractType::Handle(cls.super_type()); if (super_type.IsNull()) { - THR_Print(" Super: NULL"); + THR_Print(" Super: nullptr"); } else { const String& super_name = String::Handle(super_type.Name()); THR_Print(" Super: %s", super_name.ToCString()); diff --git a/runtime/vm/class_finalizer.h b/runtime/vm/class_finalizer.h index d62e6c91053..2dd0a7d2e9a 100644 --- a/runtime/vm/class_finalizer.h +++ b/runtime/vm/class_finalizer.h @@ -29,7 +29,7 @@ class ClassFinalizer : public AllStatic { static AbstractTypePtr FinalizeType( const AbstractType& type, FinalizationKind finalization = kCanonicalize, - PendingTypes* pending_types = NULL); + PendingTypes* pending_types = nullptr); // Return false if we still have classes pending to be finalized. static bool AllClassesFinalized(); @@ -84,14 +84,14 @@ class ClassFinalizer : public AllStatic { Zone* zone, const TypeArguments& type_args, FinalizationKind finalization = kCanonicalize, - PendingTypes* pending_types = NULL); + PendingTypes* pending_types = nullptr); // Finalize the types in the signature and the signature itself. static AbstractTypePtr FinalizeSignature( Zone* zone, const FunctionType& signature, FinalizationKind finalization = kCanonicalize, - PendingTypes* pending_types = NULL); + PendingTypes* pending_types = nullptr); static AbstractTypePtr FinalizeRecordType( Zone* zone, @@ -104,7 +104,7 @@ class ClassFinalizer : public AllStatic { const Class& cls, const FunctionType& signature, FinalizationKind finalization = kCanonicalize, - PendingTypes* pending_types = NULL); + PendingTypes* pending_types = nullptr); static intptr_t ExpandAndFinalizeTypeArguments(Zone* zone, const AbstractType& type, diff --git a/runtime/vm/class_table.cc b/runtime/vm/class_table.cc index c5b684b2de1..6454c3ac21d 100644 --- a/runtime/vm/class_table.cc +++ b/runtime/vm/class_table.cc @@ -23,7 +23,7 @@ ClassTable::ClassTable(ClassTableAllocator* allocator) : allocator_(allocator), classes_(allocator), top_level_classes_(allocator) { - if (Dart::vm_isolate() == NULL) { + if (Dart::vm_isolate() == nullptr) { classes_.SetNumCidsAndCapacity(kNumPredefinedCids, kInitialCapacity); } else { // Duplicate the class table from the VM isolate. @@ -125,7 +125,7 @@ void ClassTable::Remap(intptr_t* old_to_new_cid) { } void ClassTable::VisitObjectPointers(ObjectPointerVisitor* visitor) { - ASSERT(visitor != NULL); + ASSERT(visitor != nullptr); visitor->set_gc_root_type("class table"); const auto visit = [&](ClassPtr* table, intptr_t num_cids) { @@ -172,12 +172,12 @@ void ClassTable::UpdateClassSize(intptr_t cid, ClassPtr raw_cls) { void ClassTable::Validate() { Class& cls = Class::Handle(); for (intptr_t cid = kNumPredefinedCids; cid < classes_.num_cids(); cid++) { - // Some of the class table entries maybe NULL as we create some + // Some of the class table entries maybe nullptr as we create some // top level classes but do not add them to the list of anonymous // classes in a library if there are no top level fields or functions. // Since there are no references to these top level classes they are // not written into a full snapshot and will not be recreated when - // we read back the full snapshot. These class slots end up with NULL + // we read back the full snapshot. These class slots end up with nullptr // entries. if (HasValidClassAt(cid)) { cls = At(cid); @@ -304,10 +304,10 @@ void ClassTable::PrintToJSONObject(JSONObject* object) { void ClassTable::AllocationProfilePrintJSON(JSONStream* stream, bool internal) { Isolate* isolate = Isolate::Current(); - ASSERT(isolate != NULL); + ASSERT(isolate != nullptr); auto isolate_group = isolate->group(); Heap* heap = isolate_group->heap(); - ASSERT(heap != NULL); + ASSERT(heap != nullptr); JSONObject obj(stream); obj.AddProperty("type", "AllocationProfile"); if (isolate_group->last_allocationprofile_accumulator_reset_timestamp() != diff --git a/runtime/vm/code_descriptors.cc b/runtime/vm/code_descriptors.cc index 267386a5d2c..7e5a605a46d 100644 --- a/runtime/vm/code_descriptors.cc +++ b/runtime/vm/code_descriptors.cc @@ -133,7 +133,7 @@ ExceptionHandlersPtr ExceptionHandlerList::FinalizeExceptionHandlers( handlers.set_has_async_handler(has_async_handler_); for (intptr_t i = 0; i < num_handlers; i++) { // Assert that every element in the array has been initialized. - if (list_[i].handler_types == NULL) { + if (list_[i].handler_types == nullptr) { // Unreachable handler, entry not computed. // Initialize it to some meaningful value. const bool has_catch_all = false; @@ -173,7 +173,7 @@ class CatchEntryMovesMapBuilder::TrieNode : public ZoneAllocated { for (intptr_t i = 0; i < children_.length(); i++) { if (children_[i]->move_ == next) return children_[i]; } - return NULL; + return nullptr; } private: @@ -203,7 +203,7 @@ void CatchEntryMovesMapBuilder::EndMapping() { // Find the largest common suffix, get the last node of the path. for (intptr_t i = moves_.length() - 1; i >= 0; i--) { TrieNode* n = suffix->Follow(moves_[i]); - if (n == NULL) break; + if (n == nullptr) break; suffix_length++; suffix = n; } diff --git a/runtime/vm/code_descriptors.h b/runtime/vm/code_descriptors.h index 9a01ffccef3..cbec7edeead 100644 --- a/runtime/vm/code_descriptors.h +++ b/runtime/vm/code_descriptors.h @@ -88,7 +88,7 @@ class ExceptionHandlerList : public ZoneAllocated { data.outer_try_index = -1; data.pc_offset = ExceptionHandlers::kInvalidPcOffset; data.is_generated = true; - data.handler_types = NULL; + data.handler_types = nullptr; data.needs_stacktrace = false; list_.Add(data); } diff --git a/runtime/vm/code_descriptors_test.cc b/runtime/vm/code_descriptors_test.cc index 955e5eb6978..162732fad36 100644 --- a/runtime/vm/code_descriptors_test.cc +++ b/runtime/vm/code_descriptors_test.cc @@ -123,7 +123,7 @@ class A { ISOLATE_UNIT_TEST_CASE(DescriptorList_TokenPositions) { DescriptorList* descriptors = new DescriptorList(thread->zone()); - ASSERT(descriptors != NULL); + ASSERT(descriptors != nullptr); const int32_t token_positions[] = { kMinInt32, 5, diff --git a/runtime/vm/code_observers.cc b/runtime/vm/code_observers.cc index 859001395e3..2c5c4fdfb6e 100644 --- a/runtime/vm/code_observers.cc +++ b/runtime/vm/code_observers.cc @@ -11,9 +11,9 @@ namespace dart { #ifndef PRODUCT -Mutex* CodeObservers::mutex_ = NULL; +Mutex* CodeObservers::mutex_ = nullptr; intptr_t CodeObservers::observers_length_ = 0; -CodeObserver** CodeObservers::observers_ = NULL; +CodeObserver** CodeObservers::observers_ = nullptr; class ExternalCodeObserverAdapter : public CodeObserver { public: @@ -74,14 +74,14 @@ void CodeObservers::Cleanup() { } free(observers_); observers_length_ = 0; - observers_ = NULL; + observers_ = nullptr; } void CodeObservers::Init() { - if (mutex_ == NULL) { + if (mutex_ == nullptr) { mutex_ = new Mutex(); } - ASSERT(mutex_ != NULL); + ASSERT(mutex_ != nullptr); OS::RegisterCodeObservers(); } diff --git a/runtime/vm/code_patcher.h b/runtime/vm/code_patcher.h index 9e1e3cb9ff4..6593a29929e 100644 --- a/runtime/vm/code_patcher.h +++ b/runtime/vm/code_patcher.h @@ -46,7 +46,7 @@ class CodePatcher : public AllStatic { static CodePtr GetStaticCallTargetAt(uword return_address, const Code& code); // Get instance call information. Returns the call target and sets the output - // parameter data if non-NULL. + // parameter data if non-null. static CodePtr GetInstanceCallAt(uword return_address, const Code& caller_code, Object* data); diff --git a/runtime/vm/code_patcher_arm.cc b/runtime/vm/code_patcher_arm.cc index 11d15eabdf6..5aa488f00bc 100644 --- a/runtime/vm/code_patcher_arm.cc +++ b/runtime/vm/code_patcher_arm.cc @@ -36,7 +36,7 @@ CodePtr CodePatcher::GetInstanceCallAt(uword return_address, Object* data) { ASSERT(caller_code.ContainsInstructionAt(return_address)); ICCallPattern call(return_address, caller_code); - if (data != NULL) { + if (data != nullptr) { *data = call.Data(); } return call.TargetCode(); @@ -72,7 +72,7 @@ FunctionPtr CodePatcher::GetUnoptimizedStaticCallAt(uword return_address, ICCallPattern static_call(return_address, caller_code); ICData& ic_data = ICData::Handle(); ic_data ^= static_call.Data(); - if (ic_data_result != NULL) { + if (ic_data_result != nullptr) { *ic_data_result = ic_data.ptr(); } return ic_data.GetTargetAt(0); diff --git a/runtime/vm/code_patcher_arm64.cc b/runtime/vm/code_patcher_arm64.cc index e8217b6f510..ca27d6ab0c8 100644 --- a/runtime/vm/code_patcher_arm64.cc +++ b/runtime/vm/code_patcher_arm64.cc @@ -72,7 +72,7 @@ CodePtr CodePatcher::GetInstanceCallAt(uword return_address, Object* data) { ASSERT(caller_code.ContainsInstructionAt(return_address)); ICCallPattern call(return_address, caller_code); - if (data != NULL) { + if (data != nullptr) { *data = call.Data(); } return call.TargetCode(); @@ -108,7 +108,7 @@ FunctionPtr CodePatcher::GetUnoptimizedStaticCallAt(uword return_address, ICCallPattern static_call(return_address, code); ICData& ic_data = ICData::Handle(); ic_data ^= static_call.Data(); - if (ic_data_result != NULL) { + if (ic_data_result != nullptr) { *ic_data_result = ic_data.ptr(); } return ic_data.GetTargetAt(0); diff --git a/runtime/vm/code_patcher_ia32.cc b/runtime/vm/code_patcher_ia32.cc index 318f5ab4d5c..bb2dad1ea56 100644 --- a/runtime/vm/code_patcher_ia32.cc +++ b/runtime/vm/code_patcher_ia32.cc @@ -206,7 +206,7 @@ CodePtr CodePatcher::GetInstanceCallAt(uword return_address, Object* data) { ASSERT(caller_code.ContainsInstructionAt(return_address)); InstanceCall call(return_address, caller_code); - if (data != NULL) { + if (data != nullptr) { *data = call.data(); } return call.target(); @@ -246,7 +246,7 @@ FunctionPtr CodePatcher::GetUnoptimizedStaticCallAt(uword return_address, UnoptimizedStaticCall static_call(return_address, caller_code); ICData& ic_data = ICData::Handle(); ic_data ^= static_call.ic_data(); - if (ic_data_result != NULL) { + if (ic_data_result != nullptr) { *ic_data_result = ic_data.ptr(); } return ic_data.GetTargetAt(0); @@ -295,7 +295,7 @@ CodePtr CodePatcher::GetNativeCallAt(uword return_address, const Code& caller_code, NativeFunction* target) { UNREACHABLE(); - return NULL; + return nullptr; } } // namespace dart diff --git a/runtime/vm/code_patcher_riscv.cc b/runtime/vm/code_patcher_riscv.cc index 0af57e4deef..7f15b1cf821 100644 --- a/runtime/vm/code_patcher_riscv.cc +++ b/runtime/vm/code_patcher_riscv.cc @@ -77,7 +77,7 @@ CodePtr CodePatcher::GetInstanceCallAt(uword return_address, Object* data) { ASSERT(caller_code.ContainsInstructionAt(return_address)); ICCallPattern call(return_address, caller_code); - if (data != NULL) { + if (data != nullptr) { *data = call.Data(); } return call.TargetCode(); @@ -113,7 +113,7 @@ FunctionPtr CodePatcher::GetUnoptimizedStaticCallAt(uword return_address, ICCallPattern static_call(return_address, code); ICData& ic_data = ICData::Handle(); ic_data ^= static_call.Data(); - if (ic_data_result != NULL) { + if (ic_data_result != nullptr) { *ic_data_result = ic_data.ptr(); } return ic_data.GetTargetAt(0); diff --git a/runtime/vm/code_patcher_x64.cc b/runtime/vm/code_patcher_x64.cc index 1877688aa5c..f32a7e3bca9 100644 --- a/runtime/vm/code_patcher_x64.cc +++ b/runtime/vm/code_patcher_x64.cc @@ -422,7 +422,7 @@ CodePtr CodePatcher::GetInstanceCallAt(uword return_address, Object* data) { ASSERT(caller_code.ContainsInstructionAt(return_address)); InstanceCall call(return_address, caller_code); - if (data != NULL) { + if (data != nullptr) { *data = call.data(); } return call.target(); @@ -462,7 +462,7 @@ FunctionPtr CodePatcher::GetUnoptimizedStaticCallAt(uword return_address, UnoptimizedStaticCall static_call(return_address, caller_code); ICData& ic_data = ICData::Handle(); ic_data ^= static_call.ic_data(); - if (ic_data_result != NULL) { + if (ic_data_result != nullptr) { *ic_data_result = ic_data.ptr(); } return ic_data.GetTargetAt(0); diff --git a/runtime/vm/compiler/backend/il.h b/runtime/vm/compiler/backend/il.h index b29ff2617c1..1a1cf78bee3 100644 --- a/runtime/vm/compiler/backend/il.h +++ b/runtime/vm/compiler/backend/il.h @@ -10686,7 +10686,7 @@ class SuspendInstr : public TemplateDefinition<2, Throws> { class Environment : public ZoneAllocated { public: - // Iterate the non-nullptr values in the innermost level of an environment. + // Iterate the non-null values in the innermost level of an environment. class ShallowIterator : public ValueObject { public: explicit ShallowIterator(Environment* environment) @@ -10741,7 +10741,7 @@ class Environment : public ZoneAllocated { intptr_t index_; }; - // Iterate all non-nullptr values in an environment, including outer + // Iterate all non-null values in an environment, including outer // environments. Note that the iterator skips empty environments. class DeepIterator : public ValueObject { public: diff --git a/runtime/vm/compiler/frontend/scope_builder.h b/runtime/vm/compiler/frontend/scope_builder.h index 64845b55064..603878a657e 100644 --- a/runtime/vm/compiler/frontend/scope_builder.h +++ b/runtime/vm/compiler/frontend/scope_builder.h @@ -208,7 +208,7 @@ class ScopeBuildingResult : public ZoneAllocated { IntMap scopes; GrowableArray function_scopes; - // Only non-nullptr for factory constructor functions. + // Only non-null for factory constructor functions. LocalVariable* type_arguments_variable; // Non-nullptr when the function contains a switch statement. diff --git a/runtime/vm/compiler_test.cc b/runtime/vm/compiler_test.cc index 33265ef9c9b..a322cc69115 100644 --- a/runtime/vm/compiler_test.cc +++ b/runtime/vm/compiler_test.cc @@ -27,7 +27,7 @@ ISOLATE_UNIT_TEST_CASE(CompileFunction) { Dart_Handle library; { TransitionVMToNative transition(thread); - library = TestCase::LoadTestScript(kScriptChars, NULL); + library = TestCase::LoadTestScript(kScriptChars, nullptr); } const Library& lib = Library::Handle(Library::RawCast(Api::UnwrapHandle(library))); @@ -67,7 +67,7 @@ ISOLATE_UNIT_TEST_CASE(OptimizeCompileFunctionOnHelperThread) { Dart_Handle library; { TransitionVMToNative transition(thread); - library = TestCase::LoadTestScript(kScriptChars, NULL); + library = TestCase::LoadTestScript(kScriptChars, nullptr); } const Library& lib = Library::Handle(Library::RawCast(Api::UnwrapHandle(library))); @@ -109,7 +109,7 @@ ISOLATE_UNIT_TEST_CASE(CompileFunctionOnHelperThread) { Dart_Handle library; { TransitionVMToNative transition(thread); - library = TestCase::LoadTestScript(kScriptChars, NULL); + library = TestCase::LoadTestScript(kScriptChars, nullptr); } const Library& lib = Library::Handle(Library::RawCast(Api::UnwrapHandle(library))); @@ -140,8 +140,8 @@ ISOLATE_UNIT_TEST_CASE(RegenerateAllocStubs) { Class& cls = Class::Handle(); TransitionVMToNative transition(thread); - Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); - Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, nullptr); + Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, nullptr); EXPECT_VALID(result); { @@ -156,21 +156,21 @@ ISOLATE_UNIT_TEST_CASE(RegenerateAllocStubs) { TransitionNativeToVM transition(thread); cls.DisableAllocationStub(); } - result = Dart_Invoke(lib, NewString("main"), 0, NULL); + result = Dart_Invoke(lib, NewString("main"), 0, nullptr); EXPECT_VALID(result); { TransitionNativeToVM transition(thread); cls.DisableAllocationStub(); } - result = Dart_Invoke(lib, NewString("main"), 0, NULL); + result = Dart_Invoke(lib, NewString("main"), 0, nullptr); EXPECT_VALID(result); { TransitionNativeToVM transition(thread); cls.DisableAllocationStub(); } - result = Dart_Invoke(lib, NewString("main"), 0, NULL); + result = Dart_Invoke(lib, NewString("main"), 0, nullptr); EXPECT_VALID(result); } @@ -184,9 +184,9 @@ TEST_CASE(EvalExpression) { "} \n" "makeObj() => new A(); \n"; - Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, nullptr); Dart_Handle obj_handle = - Dart_Invoke(lib, Dart_NewStringFromCString("makeObj"), 0, NULL); + Dart_Invoke(lib, Dart_NewStringFromCString("makeObj"), 0, nullptr); EXPECT_VALID(obj_handle); TransitionNativeToVM transition(thread); const Object& obj = Object::Handle(Api::UnwrapHandle(obj_handle)); @@ -232,7 +232,7 @@ TEST_CASE(EvalExpression) { ISOLATE_UNIT_TEST_CASE(EvalExpressionWithLazyCompile) { { // Initialize an incremental compiler in DFE mode. TransitionVMToNative transition(thread); - TestCase::LoadTestScript("", NULL); + TestCase::LoadTestScript("", nullptr); } Library& lib = Library::Handle(Library::CoreLibrary()); const String& expression = String::Handle( @@ -252,7 +252,7 @@ ISOLATE_UNIT_TEST_CASE(EvalExpressionWithLazyCompile) { ISOLATE_UNIT_TEST_CASE(EvalExpressionExhaustCIDs) { { // Initialize an incremental compiler in DFE mode. TransitionVMToNative transition(thread); - TestCase::LoadTestScript("", NULL); + TestCase::LoadTestScript("", nullptr); } Library& lib = Library::Handle(Library::CoreLibrary()); const String& expression = String::Handle(String::New("3 + 4")); @@ -303,9 +303,9 @@ TEST_CASE(ManyClasses) { } buffer.Printf("}\n"); - Dart_Handle lib = TestCase::LoadTestScript(buffer.buffer(), NULL); + Dart_Handle lib = TestCase::LoadTestScript(buffer.buffer(), nullptr); EXPECT_VALID(lib); - Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL); + Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, nullptr); EXPECT_VALID(result); EXPECT(IsolateGroup::Current()->class_table()->NumCids() >= kNumClasses); diff --git a/runtime/vm/constants_riscv.h b/runtime/vm/constants_riscv.h index 8f6cb18db87..ca4361f69cf 100644 --- a/runtime/vm/constants_riscv.h +++ b/runtime/vm/constants_riscv.h @@ -69,7 +69,7 @@ enum Register { S7 = 23, // CALLEE_SAVED_TEMP2 S8 = 24, // CALLEE_SAVED_TEMP / FAR_TMP S9 = 25, // DISPATCH_TABLE_REG - S10 = 26, // NULL + S10 = 26, // nullptr S11 = 27, // WRITE_BARRIER_STATE T3 = 28, T4 = 29, diff --git a/runtime/vm/cpu_arm.cc b/runtime/vm/cpu_arm.cc index ce9a8ffbca3..90c995d701f 100644 --- a/runtime/vm/cpu_arm.cc +++ b/runtime/vm/cpu_arm.cc @@ -112,7 +112,7 @@ const char* CPU::Id() { bool HostCPUFeatures::integer_division_supported_ = false; bool HostCPUFeatures::neon_supported_ = false; bool HostCPUFeatures::hardfp_supported_ = false; -const char* HostCPUFeatures::hardware_ = NULL; +const char* HostCPUFeatures::hardware_ = nullptr; intptr_t HostCPUFeatures::store_pc_read_offset_ = 8; #if defined(DEBUG) bool HostCPUFeatures::initialized_ = false; @@ -160,15 +160,15 @@ void HostCPUFeatures::Init() { CpuInfo::FieldContains(kCpuInfoModel, "aarch64") || CpuInfo::FieldContains(kCpuInfoArchitecture, "8") || CpuInfo::FieldContains(kCpuInfoArchitecture, "AArch64") || - (ret_ == 0 && (strstr(uname_.machine, "aarch64") != NULL || - strstr(uname_.machine, "arm64") != NULL || - strstr(uname_.machine, "armv8") != NULL))) { + (ret_ == 0 && (strstr(uname_.machine, "aarch64") != nullptr || + strstr(uname_.machine, "arm64") != nullptr || + strstr(uname_.machine, "armv8") != nullptr))) { // pretend that this arm64 cpu is really an ARMv7 is_arm64 = true; } else if (!CpuInfo::FieldContains(kCpuInfoProcessor, "ARMv7") && !CpuInfo::FieldContains(kCpuInfoModel, "ARMv7") && !CpuInfo::FieldContains(kCpuInfoArchitecture, "7") && - !(ret_ == 0 && strstr(uname_.machine, "armv7") != NULL)) { + !(ret_ == 0 && strstr(uname_.machine, "armv7") != nullptr)) { FATAL("Unrecognized ARM CPU architecture."); } @@ -231,9 +231,9 @@ void HostCPUFeatures::Cleanup() { #if defined(DEBUG) initialized_ = false; #endif - ASSERT(hardware_ != NULL); + ASSERT(hardware_ != nullptr); free(const_cast(hardware_)); - hardware_ = NULL; + hardware_ = nullptr; CpuInfo::Cleanup(); } @@ -256,9 +256,9 @@ void HostCPUFeatures::Cleanup() { #if defined(DEBUG) initialized_ = false; #endif - ASSERT(hardware_ != NULL); + ASSERT(hardware_ != nullptr); free(const_cast(hardware_)); - hardware_ = NULL; + hardware_ = nullptr; CpuInfo::Cleanup(); } #endif // !defined(TARGET_HOST_MISMATCH) diff --git a/runtime/vm/cpu_arm64.cc b/runtime/vm/cpu_arm64.cc index 10827ba7c45..4d01c5f2e99 100644 --- a/runtime/vm/cpu_arm64.cc +++ b/runtime/vm/cpu_arm64.cc @@ -68,7 +68,7 @@ const char* CPU::Id() { "arm64"; } -const char* HostCPUFeatures::hardware_ = NULL; +const char* HostCPUFeatures::hardware_ = nullptr; #if defined(DEBUG) bool HostCPUFeatures::initialized_ = false; #endif @@ -87,9 +87,9 @@ void HostCPUFeatures::Cleanup() { #if defined(DEBUG) initialized_ = false; #endif - ASSERT(hardware_ != NULL); + ASSERT(hardware_ != nullptr); free(const_cast(hardware_)); - hardware_ = NULL; + hardware_ = nullptr; CpuInfo::Cleanup(); } @@ -108,9 +108,9 @@ void HostCPUFeatures::Cleanup() { #if defined(DEBUG) initialized_ = false; #endif - ASSERT(hardware_ != NULL); + ASSERT(hardware_ != nullptr); free(const_cast(hardware_)); - hardware_ = NULL; + hardware_ = nullptr; CpuInfo::Cleanup(); } #endif // !defined(USING_SIMULATOR) diff --git a/runtime/vm/cpu_ia32.cc b/runtime/vm/cpu_ia32.cc index 27ae5c549f1..72d57372117 100644 --- a/runtime/vm/cpu_ia32.cc +++ b/runtime/vm/cpu_ia32.cc @@ -58,9 +58,9 @@ void HostCPUFeatures::Cleanup() { #if defined(DEBUG) initialized_ = false; #endif - ASSERT(hardware_ != NULL); + ASSERT(hardware_ != nullptr); free(const_cast(hardware_)); - hardware_ = NULL; + hardware_ = nullptr; CpuInfo::Cleanup(); } diff --git a/runtime/vm/cpu_riscv.cc b/runtime/vm/cpu_riscv.cc index e7ab8fe083b..9d0d2a9ed21 100644 --- a/runtime/vm/cpu_riscv.cc +++ b/runtime/vm/cpu_riscv.cc @@ -66,7 +66,7 @@ const char* CPU::Id() { #endif } -const char* HostCPUFeatures::hardware_ = NULL; +const char* HostCPUFeatures::hardware_ = nullptr; #if defined(DEBUG) bool HostCPUFeatures::initialized_ = false; #endif @@ -85,9 +85,9 @@ void HostCPUFeatures::Cleanup() { #if defined(DEBUG) initialized_ = false; #endif - ASSERT(hardware_ != NULL); + ASSERT(hardware_ != nullptr); free(const_cast(hardware_)); - hardware_ = NULL; + hardware_ = nullptr; CpuInfo::Cleanup(); } @@ -106,9 +106,9 @@ void HostCPUFeatures::Cleanup() { #if defined(DEBUG) initialized_ = false; #endif - ASSERT(hardware_ != NULL); + ASSERT(hardware_ != nullptr); free(const_cast(hardware_)); - hardware_ = NULL; + hardware_ = nullptr; CpuInfo::Cleanup(); } #endif // !defined(USING_SIMULATOR) diff --git a/runtime/vm/cpu_x64.cc b/runtime/vm/cpu_x64.cc index bd78c504d03..2cb86b8002a 100644 --- a/runtime/vm/cpu_x64.cc +++ b/runtime/vm/cpu_x64.cc @@ -58,9 +58,9 @@ void HostCPUFeatures::Cleanup() { #if defined(DEBUG) initialized_ = false; #endif - ASSERT(hardware_ != NULL); + ASSERT(hardware_ != nullptr); free(const_cast(hardware_)); - hardware_ = NULL; + hardware_ = nullptr; CpuInfo::Cleanup(); } @@ -82,9 +82,9 @@ void HostCPUFeatures::Cleanup() { #if defined(DEBUG) initialized_ = false; #endif - ASSERT(hardware_ != NULL); + ASSERT(hardware_ != nullptr); free(const_cast(hardware_)); - hardware_ = NULL; + hardware_ = nullptr; CpuInfo::Cleanup(); } #endif // !defined(USING_SIMULATOR) diff --git a/runtime/vm/cpuid.cc b/runtime/vm/cpuid.cc index 7f71880c545..71273f94a6e 100644 --- a/runtime/vm/cpuid.cc +++ b/runtime/vm/cpuid.cc @@ -57,7 +57,7 @@ void CpuId::Init() { GetCpuId(0x80000001, info); CpuId::abm_ = (info[2] & (1 << 5)) != 0; - // Brand string returned by CPUID is expected to be NULL-terminated, + // Brand string returned by CPUID is expected to be nullptr-terminated, // however we have seen cases in the wild which violate this assumption. // To avoid going out of bounds when trying to print this string // we add null-terminator ourselves, just in case. @@ -72,13 +72,13 @@ void CpuId::Init() { } void CpuId::Cleanup() { - ASSERT(id_string_ != NULL); + ASSERT(id_string_ != nullptr); free(const_cast(id_string_)); - id_string_ = NULL; + id_string_ = nullptr; - ASSERT(brand_string_ != NULL); + ASSERT(brand_string_ != nullptr); free(const_cast(brand_string_)); - brand_string_ = NULL; + brand_string_ = nullptr; } const char* CpuId::id_string() { @@ -120,7 +120,7 @@ const char* CpuId::field(CpuInfoIndices idx) { } default: { UNREACHABLE(); - return NULL; + return nullptr; } } } diff --git a/runtime/vm/cpuinfo_linux.cc b/runtime/vm/cpuinfo_linux.cc index 22e86cb5242..75a084a20df 100644 --- a/runtime/vm/cpuinfo_linux.cc +++ b/runtime/vm/cpuinfo_linux.cc @@ -67,8 +67,8 @@ void CpuInfo::Cleanup() { bool CpuInfo::FieldContains(CpuInfoIndices idx, const char* search_string) { if (method_ == kCpuInfoCpuId) { const char* field = CpuId::field(idx); - if (field == NULL) return false; - bool contains = (strstr(field, search_string) != NULL); + if (field == nullptr) return false; + bool contains = (strstr(field, search_string) != nullptr); free(const_cast(field)); return contains; } else if (method_ == kCpuInfoSystem) { diff --git a/runtime/vm/cpuinfo_macos.cc b/runtime/vm/cpuinfo_macos.cc index 45968135831..9a726b14cbc 100644 --- a/runtime/vm/cpuinfo_macos.cc +++ b/runtime/vm/cpuinfo_macos.cc @@ -25,41 +25,41 @@ void CpuInfo::Init() { fields_[kCpuInfoModel] = "machdep.cpu.brand_string"; fields_[kCpuInfoHardware] = "machdep.cpu.brand_string"; fields_[kCpuInfoFeatures] = "machdep.cpu.features"; - fields_[kCpuInfoArchitecture] = NULL; + fields_[kCpuInfoArchitecture] = nullptr; } void CpuInfo::Cleanup() {} bool CpuInfo::FieldContains(CpuInfoIndices idx, const char* search_string) { ASSERT(method_ != kCpuInfoDefault); - ASSERT(search_string != NULL); + ASSERT(search_string != nullptr); const char* field = FieldName(idx); char dest[1024]; size_t dest_len = 1024; ASSERT(HasField(field)); - if (sysctlbyname(field, dest, &dest_len, NULL, 0) != 0) { + if (sysctlbyname(field, dest, &dest_len, nullptr, 0) != 0) { UNREACHABLE(); return false; } - return (strcasestr(dest, search_string) != NULL); + return (strcasestr(dest, search_string) != nullptr); } const char* CpuInfo::ExtractField(CpuInfoIndices idx) { ASSERT(method_ != kCpuInfoDefault); const char* field = FieldName(idx); - ASSERT(field != NULL); + ASSERT(field != nullptr); size_t result_len; ASSERT(HasField(field)); - if (sysctlbyname(field, NULL, &result_len, NULL, 0) != 0) { + if (sysctlbyname(field, nullptr, &result_len, nullptr, 0) != 0) { UNREACHABLE(); return 0; } char* result = reinterpret_cast(malloc(result_len)); - if (sysctlbyname(field, result, &result_len, NULL, 0) != 0) { + if (sysctlbyname(field, result, &result_len, nullptr, 0) != 0) { UNREACHABLE(); return 0; } @@ -69,8 +69,8 @@ const char* CpuInfo::ExtractField(CpuInfoIndices idx) { bool CpuInfo::HasField(const char* field) { ASSERT(method_ != kCpuInfoDefault); - ASSERT(field != NULL); - int ret = sysctlbyname(field, NULL, NULL, NULL, 0); + ASSERT(field != nullptr); + int ret = sysctlbyname(field, nullptr, nullptr, nullptr, 0); return (ret == 0); } diff --git a/runtime/vm/cpuinfo_win.cc b/runtime/vm/cpuinfo_win.cc index 2a8ad21f342..e84dd701444 100644 --- a/runtime/vm/cpuinfo_win.cc +++ b/runtime/vm/cpuinfo_win.cc @@ -29,7 +29,7 @@ void CpuInfo::Init() { fields_[kCpuInfoModel] = "Hardware"; fields_[kCpuInfoHardware] = "Hardware"; fields_[kCpuInfoFeatures] = "Features"; - fields_[kCpuInfoArchitecture] = NULL; + fields_[kCpuInfoArchitecture] = nullptr; } void CpuInfo::Cleanup() { diff --git a/runtime/vm/custom_isolate_test.cc b/runtime/vm/custom_isolate_test.cc index 5f5ac634805..ce51db403b4 100644 --- a/runtime/vm/custom_isolate_test.cc +++ b/runtime/vm/custom_isolate_test.cc @@ -82,7 +82,7 @@ static const char* kCustomIsolateScriptChars = // An entry in our event queue. class Event { protected: - explicit Event(Dart_Isolate isolate) : isolate_(isolate), next_(NULL) {} + explicit Event(Dart_Isolate isolate) : isolate_(isolate), next_(nullptr) {} public: virtual ~Event() {} @@ -99,10 +99,10 @@ class Event { // A simple event queue for our test. class EventQueue { public: - EventQueue() { head_ = NULL; } + EventQueue() { head_ = nullptr; } void Add(Event* event) { - if (head_ == NULL) { + if (head_ == nullptr) { head_ = event; tail_ = event; } else { @@ -112,14 +112,14 @@ class EventQueue { } Event* Get() { - if (head_ == NULL) { - return NULL; + if (head_ == nullptr) { + return nullptr; } Event* tmp = head_; head_ = head_->next_; - if (head_ == NULL) { + if (head_ == nullptr) { // Not necessary, but why not. - tail_ = NULL; + tail_ = nullptr; } return tmp; @@ -127,12 +127,12 @@ class EventQueue { void RemoveEventsForIsolate(Dart_Isolate isolate) { Event* cur = head_; - Event* prev = NULL; - while (cur != NULL) { + Event* prev = nullptr; + while (cur != nullptr) { Event* next = cur->next_; if (cur->isolate() == isolate) { // Remove matching event. - if (prev != NULL) { + if (prev != nullptr) { prev->next_ = next; } else { head_ = next; @@ -174,12 +174,12 @@ void StartEvent::Process() { Dart_Handle lib = Dart_LookupLibrary(NewString(TestCase::url())); EXPECT_VALID(lib); - result = Dart_Invoke(lib, NewString(main_), 0, NULL); + result = Dart_Invoke(lib, NewString(main_), 0, nullptr); EXPECT_VALID(result); free(const_cast(main_)); - main_ = NULL; + main_ = nullptr; - Dart_SetMessageNotifyCallback(NULL); + Dart_SetMessageNotifyCallback(nullptr); Dart_ExitScope(); Dart_ExitIsolate(); } @@ -205,14 +205,14 @@ void MessageEvent::Process() { if (!Dart_HasLivePorts()) { OS::PrintErr("<< Shutting down isolate(%p)\n", isolate()); event_queue->RemoveEventsForIsolate(isolate()); - Dart_SetMessageNotifyCallback(NULL); + Dart_SetMessageNotifyCallback(nullptr); Dart_ExitScope(); Dart_ShutdownIsolate(); } else { Dart_ExitScope(); Dart_ExitIsolate(); } - ASSERT(Dart_CurrentIsolate() == NULL); + ASSERT(Dart_CurrentIsolate() == nullptr); } static void NotifyMessage(Dart_Isolate dest_isolate) { @@ -224,9 +224,9 @@ static void NotifyMessage(Dart_Isolate dest_isolate) { static Dart_NativeFunction NativeLookup(Dart_Handle name, int argc, bool* auto_setup_scope) { - ASSERT(auto_setup_scope != NULL); + ASSERT(auto_setup_scope != nullptr); *auto_setup_scope = true; - const char* name_str = NULL; + const char* name_str = nullptr; EXPECT(Dart_IsString(name)); EXPECT_VALID(Dart_StringToCString(name, &name_str)); if (strcmp(name_str, "native_echo") == 0) { @@ -234,16 +234,16 @@ static Dart_NativeFunction NativeLookup(Dart_Handle name, } else if (strcmp(name_str, "CustomIsolateImpl_start") == 0) { return &CustomIsolateImpl_start; } - return NULL; + return nullptr; } -char* saved_echo = NULL; +char* saved_echo = nullptr; static void native_echo(Dart_NativeArguments args) { Dart_EnterScope(); Dart_Handle arg = Dart_GetNativeArgument(args, 0); Dart_Handle toString = Dart_ToString(arg); EXPECT_VALID(toString); - const char* c_str = NULL; + const char* c_str = nullptr; EXPECT_VALID(Dart_StringToCString(toString, &c_str)); if (saved_echo != nullptr) { free(saved_echo); @@ -263,7 +263,7 @@ static void CustomIsolateImpl_start(Dart_NativeArguments args) { Dart_Handle param = Dart_GetNativeArgument(args, 0); EXPECT_VALID(param); EXPECT(Dart_IsString(param)); - const char* isolate_main = NULL; + const char* isolate_main = nullptr; EXPECT_VALID(Dart_StringToCString(param, &isolate_main)); isolate_main = Utils::StrDup(isolate_main); @@ -273,7 +273,7 @@ static void CustomIsolateImpl_start(Dart_NativeArguments args) { // Create a new Dart_Isolate. Dart_Isolate new_isolate = TestCase::CreateTestIsolate(); - EXPECT(new_isolate != NULL); + EXPECT(new_isolate != nullptr); Dart_SetMessageNotifyCallback(&NotifyMessage); Dart_EnterScope(); // Reload all the test classes here. @@ -312,7 +312,7 @@ VM_UNIT_TEST_CASE(CustomIsolates) { event_queue = new EventQueue(); Dart_Isolate dart_isolate = TestCase::CreateTestIsolate(); - EXPECT(dart_isolate != NULL); + EXPECT(dart_isolate != nullptr); Dart_SetMessageNotifyCallback(&NotifyMessage); Dart_EnterScope(); Dart_Handle result; @@ -323,10 +323,10 @@ VM_UNIT_TEST_CASE(CustomIsolates) { EXPECT_VALID(lib); // Run main. - result = Dart_Invoke(lib, NewString("main"), 0, NULL); + result = Dart_Invoke(lib, NewString("main"), 0, nullptr); EXPECT_VALID(result); EXPECT(Dart_IsString(result)); - const char* result_str = NULL; + const char* result_str = nullptr; EXPECT_VALID(Dart_StringToCString(result, &result_str)); EXPECT_STREQ("success", result_str); @@ -345,7 +345,7 @@ VM_UNIT_TEST_CASE(CustomIsolates) { free(saved_echo); delete event_queue; - event_queue = NULL; + event_queue = nullptr; FLAG_trace_shutdown = saved_flag; } diff --git a/runtime/vm/dart.cc b/runtime/vm/dart.cc index 7e00f4badc5..b5d8c34098f 100644 --- a/runtime/vm/dart.cc +++ b/runtime/vm/dart.cc @@ -54,19 +54,19 @@ namespace dart { DECLARE_FLAG(bool, print_class_table); DEFINE_FLAG(bool, trace_shutdown, false, "Trace VM shutdown on stderr"); -Isolate* Dart::vm_isolate_ = NULL; +Isolate* Dart::vm_isolate_ = nullptr; int64_t Dart::start_time_micros_ = 0; -ThreadPool* Dart::thread_pool_ = NULL; -DebugInfo* Dart::pprof_symbol_generator_ = NULL; -ReadOnlyHandles* Dart::predefined_handles_ = NULL; +ThreadPool* Dart::thread_pool_ = nullptr; +DebugInfo* Dart::pprof_symbol_generator_ = nullptr; +ReadOnlyHandles* Dart::predefined_handles_ = nullptr; Snapshot::Kind Dart::vm_snapshot_kind_ = Snapshot::kInvalid; -Dart_ThreadStartCallback Dart::thread_start_callback_ = NULL; -Dart_ThreadExitCallback Dart::thread_exit_callback_ = NULL; -Dart_FileOpenCallback Dart::file_open_callback_ = NULL; -Dart_FileReadCallback Dart::file_read_callback_ = NULL; -Dart_FileWriteCallback Dart::file_write_callback_ = NULL; -Dart_FileCloseCallback Dart::file_close_callback_ = NULL; -Dart_EntropySource Dart::entropy_source_callback_ = NULL; +Dart_ThreadStartCallback Dart::thread_start_callback_ = nullptr; +Dart_ThreadExitCallback Dart::thread_exit_callback_ = nullptr; +Dart_FileOpenCallback Dart::file_open_callback_ = nullptr; +Dart_FileReadCallback Dart::file_read_callback_ = nullptr; +Dart_FileWriteCallback Dart::file_write_callback_ = nullptr; +Dart_FileCloseCallback Dart::file_close_callback_ = nullptr; +Dart_EntropySource Dart::entropy_source_callback_ = nullptr; Dart_DwarfStackTraceFootnoteCallback Dart::dwarf_stacktrace_footnote_callback_ = nullptr; @@ -268,7 +268,7 @@ char* Dart::DartInit(const Dart_InitializeParams* params) { if (!Flags::Initialized()) { return Utils::StrDup("VM initialization failed-VM Flags not initialized."); } - if (vm_isolate_ != NULL) { + if (vm_isolate_ != nullptr) { return Utils::StrDup("VM initialization is in an inconsistent state."); } @@ -342,13 +342,13 @@ char* Dart::DartInit(const Dart_InitializeParams* params) { Simulator::Init(); #endif // Create the read-only handles area. - ASSERT(predefined_handles_ == NULL); + ASSERT(predefined_handles_ == nullptr); predefined_handles_ = new ReadOnlyHandles(); // Create the VM isolate and finish the VM initialization. - ASSERT(thread_pool_ == NULL); + ASSERT(thread_pool_ == nullptr); thread_pool_ = new ThreadPool(); { - ASSERT(vm_isolate_ == NULL); + ASSERT(vm_isolate_ == nullptr); ASSERT(Flags::Initialized()); const bool is_vm_isolate = true; @@ -378,7 +378,7 @@ char* Dart::DartInit(const Dart_InitializeParams* params) { ASSERT(vm_isolate_ == Thread::Current()->isolate()); Thread* T = Thread::Current(); - ASSERT(T != NULL); + ASSERT(T != nullptr); StackZone zone(T); HandleScope handle_scope(T); Object::InitNullAndBool(vm_isolate_->group()); @@ -509,7 +509,7 @@ char* Dart::DartInit(const Dart_InitializeParams* params) { } #endif // DART_PRECOMPILED_RUNTIME - return NULL; + return nullptr; } char* Dart::Init(const Dart_InitializeParams* params) { @@ -520,12 +520,12 @@ char* Dart::Init(const Dart_InitializeParams* params) { "multiple threads initializing the VM."); } char* retval = DartInit(params); - if (retval != NULL) { + if (retval != nullptr) { DartInitializationState::ResetInitializing(); return retval; } DartInitializationState::SetInitialized(); - return NULL; + return nullptr; } static void DumpAliveIsolates(intptr_t num_attempts, @@ -616,11 +616,11 @@ void Dart::WaitForIsolateShutdown() { } char* Dart::Cleanup() { - ASSERT(Isolate::Current() == NULL); + ASSERT(Isolate::Current() == nullptr); if (!DartInitializationState::SetCleaningup()) { return Utils::StrDup("VM already terminated."); } - ASSERT(vm_isolate_ != NULL); + ASSERT(vm_isolate_ != nullptr); if (FLAG_trace_shutdown) { OS::PrintErr("[+%" Pd64 "ms] SHUTDOWN: Starting shutdown\n", @@ -711,7 +711,7 @@ char* Dart::Cleanup() { DartInitializationState::SetUnInitialized(); thread_pool_->Shutdown(); delete thread_pool_; - thread_pool_ = NULL; + thread_pool_ = nullptr; if (FLAG_trace_shutdown) { OS::PrintErr("[+%" Pd64 "ms] SHUTDOWN: Done deleting thread pool\n", UptimeMillis()); @@ -719,7 +719,7 @@ char* Dart::Cleanup() { Api::Cleanup(); delete predefined_handles_; - predefined_handles_ = NULL; + predefined_handles_ = nullptr; // Set the VM isolate as current isolate. if (FLAG_trace_shutdown) { @@ -750,7 +750,7 @@ char* Dart::Cleanup() { OSThread::DisableOSThreadCreation(); ShutdownIsolate(); - vm_isolate_ = NULL; + vm_isolate_ = nullptr; ASSERT(Isolate::IsolateListLength() == 0); Service::Cleanup(); PortMap::Cleanup(); @@ -779,7 +779,7 @@ char* Dart::Cleanup() { // If it is the last thread then the destructor would call // OSThread::Cleanup. OSThread* os_thread = OSThread::Current(); - OSThread::SetCurrent(NULL); + OSThread::SetCurrent(nullptr); delete os_thread; if (FLAG_trace_shutdown) { OS::PrintErr("[+%" Pd64 "ms] SHUTDOWN: Deleted os_thread\n", @@ -797,11 +797,11 @@ char* Dart::Cleanup() { } Flags::Cleanup(); #if !defined(PRODUCT) && !defined(DART_PRECOMPILED_RUNTIME) - IsolateGroupReloadContext::SetFileModifiedCallback(NULL); - Service::SetEmbedderStreamCallbacks(NULL, NULL); + IsolateGroupReloadContext::SetFileModifiedCallback(nullptr); + Service::SetEmbedderStreamCallbacks(nullptr, nullptr); #endif // !defined(PRODUCT) && !defined(DART_PRECOMPILED_RUNTIME) VirtualMemory::Cleanup(); - return NULL; + return nullptr; } bool Dart::IsInitialized() { @@ -842,7 +842,7 @@ ErrorPtr Dart::InitIsolateFromSnapshot(Thread* T, if (!error.IsNull()) { return error.ptr(); } - if ((snapshot_data != NULL) && kernel_buffer == NULL) { + if ((snapshot_data != nullptr) && kernel_buffer == nullptr) { // Read the snapshot and setup the initial state. #if defined(SUPPORT_TIMELINE) TimelineBeginEndScope tbes(T, Timeline::GetIsolateStream(), @@ -850,7 +850,7 @@ ErrorPtr Dart::InitIsolateFromSnapshot(Thread* T, #endif // defined(SUPPORT_TIMELINE) // TODO(turnidge): Remove once length is not part of the snapshot. const Snapshot* snapshot = Snapshot::SetupFromBuffer(snapshot_data); - if (snapshot == NULL) { + if (snapshot == nullptr) { const String& message = String::Handle(String::New("Invalid snapshot")); return ApiError::New(message); } @@ -889,7 +889,7 @@ ErrorPtr Dart::InitIsolateFromSnapshot(Thread* T, MegamorphicCacheTable::PrintSizes(I); } } else { - if ((vm_snapshot_kind_ != Snapshot::kNone) && kernel_buffer == NULL) { + if ((vm_snapshot_kind_ != Snapshot::kNone) && kernel_buffer == nullptr) { const String& message = String::Handle(String::New("Missing isolate snapshot")); return ApiError::New(message); @@ -955,7 +955,7 @@ ErrorPtr Dart::InitializeIsolate(const uint8_t* snapshot_data, tbes.SetNumArguments(1); tbes.CopyArgument(0, "isolateName", I->name()); #endif - ASSERT(I != NULL); + ASSERT(I != nullptr); StackZone zone(T); HandleScope handle_scope(T); bool was_child_cloned_into_existing_isolate = false; @@ -1193,21 +1193,21 @@ void Dart::RunShutdownCallback() { void* isolate_group_data = isolate->group()->embedder_data(); void* isolate_data = isolate->init_callback_data(); Dart_IsolateShutdownCallback callback = isolate->on_shutdown_callback(); - if (callback != NULL) { + if (callback != nullptr) { TransitionVMToNative transition(thread); (callback)(isolate_group_data, isolate_data); } } void Dart::ShutdownIsolate(Isolate* isolate) { - ASSERT(Isolate::Current() == NULL); + ASSERT(Isolate::Current() == nullptr); // We need to enter the isolate in order to shut it down. bool result = Thread::EnterIsolate(isolate); ASSERT(result); ShutdownIsolate(); // Since the isolate is shutdown and deleted, there is no need to // exit the isolate here. - ASSERT(Isolate::Current() == NULL); + ASSERT(Isolate::Current() == nullptr); } void Dart::ShutdownIsolate() { @@ -1215,7 +1215,7 @@ void Dart::ShutdownIsolate() { } bool Dart::VmIsolateNameEquals(const char* name) { - ASSERT(name != NULL); + ASSERT(name != nullptr); return (strcmp(name, kVmIsolateName) == 0); } @@ -1225,23 +1225,23 @@ int64_t Dart::UptimeMicros() { uword Dart::AllocateReadOnlyHandle() { ASSERT(Isolate::Current() == Dart::vm_isolate()); - ASSERT(predefined_handles_ != NULL); + ASSERT(predefined_handles_ != nullptr); return predefined_handles_->handles_.AllocateScopedHandle(); } LocalHandle* Dart::AllocateReadOnlyApiHandle() { ASSERT(Isolate::Current() == Dart::vm_isolate()); - ASSERT(predefined_handles_ != NULL); + ASSERT(predefined_handles_ != nullptr); return predefined_handles_->api_handles_.AllocateHandle(); } bool Dart::IsReadOnlyHandle(uword address) { - ASSERT(predefined_handles_ != NULL); + ASSERT(predefined_handles_ != nullptr); return predefined_handles_->handles_.IsValidScopedHandle(address); } bool Dart::IsReadOnlyApiHandle(Dart_Handle handle) { - ASSERT(predefined_handles_ != NULL); + ASSERT(predefined_handles_ != nullptr); return predefined_handles_->api_handles_.IsValidHandle(handle); } diff --git a/runtime/vm/dart.h b/runtime/vm/dart.h index 7da90d6eb22..c0b7eeeb316 100644 --- a/runtime/vm/dart.h +++ b/runtime/vm/dart.h @@ -47,7 +47,7 @@ class Dart : public AllStatic { IsolateGroup* isolate_group); // Initialize an isolate, either from a snapshot, from a Kernel binary, or - // from SDK library sources. If the snapshot_buffer is non-NULL, + // from SDK library sources. If the snapshot_buffer is non-null, // initialize from a snapshot or a Kernel binary depending on the value of // from_kernel. Otherwise, initialize from sources. static ErrorPtr InitializeIsolate(const uint8_t* snapshot_data, diff --git a/runtime/vm/dart_api_impl.cc b/runtime/vm/dart_api_impl.cc index 33a7357b757..2599838edca 100644 --- a/runtime/vm/dart_api_impl.cc +++ b/runtime/vm/dart_api_impl.cc @@ -93,12 +93,12 @@ DEFINE_FLAG(bool, } ThreadLocalKey Api::api_native_key_ = kUnsetThreadLocalKey; -Dart_Handle Api::true_handle_ = NULL; -Dart_Handle Api::false_handle_ = NULL; -Dart_Handle Api::null_handle_ = NULL; -Dart_Handle Api::empty_string_handle_ = NULL; -Dart_Handle Api::no_callbacks_error_handle_ = NULL; -Dart_Handle Api::unwind_in_progress_error_handle_ = NULL; +Dart_Handle Api::true_handle_ = nullptr; +Dart_Handle Api::false_handle_ = nullptr; +Dart_Handle Api::null_handle_ = nullptr; +Dart_Handle Api::empty_string_handle_ = nullptr; +Dart_Handle Api::no_callbacks_error_handle_ = nullptr; +Dart_Handle Api::unwind_in_progress_error_handle_ = nullptr; const char* CanonicalFunction(const char* func) { if (strncmp(func, "dart::", 6) == 0) { @@ -196,19 +196,19 @@ static bool GetNativeStringArgument(NativeArguments* arguments, int arg_index, Dart_Handle* str, void** peer) { - ASSERT(peer != NULL); + ASSERT(peer != nullptr); if (Api::StringGetPeerHelper(arguments, arg_index, peer)) { - *str = NULL; + *str = nullptr; return true; } Thread* thread = arguments->thread(); ASSERT(thread == Thread::Current()); - *peer = NULL; + *peer = nullptr; REUSABLE_OBJECT_HANDLESCOPE(thread); Object& obj = thread->ObjectHandle(); obj = arguments->NativeArgAt(arg_index); if (IsStringClassId(obj.GetClassId())) { - ASSERT(thread->api_top_scope() != NULL); + ASSERT(thread->api_top_scope() != nullptr); *str = Api::NewHandle(thread, obj.ptr()); return true; } @@ -222,14 +222,14 @@ static bool GetNativeStringArgument(NativeArguments* arguments, static bool GetNativeIntegerArgument(NativeArguments* arguments, int arg_index, int64_t* value) { - ASSERT(value != NULL); + ASSERT(value != nullptr); return Api::GetNativeIntegerArgument(arguments, arg_index, value); } static bool GetNativeUnsignedIntegerArgument(NativeArguments* arguments, int arg_index, uint64_t* value) { - ASSERT(value != NULL); + ASSERT(value != nullptr); int64_t arg_value = 0; if (Api::GetNativeIntegerArgument(arguments, arg_index, &arg_value)) { *value = static_cast(arg_value); @@ -241,7 +241,7 @@ static bool GetNativeUnsignedIntegerArgument(NativeArguments* arguments, static bool GetNativeDoubleArgument(NativeArguments* arguments, int arg_index, double* value) { - ASSERT(value != NULL); + ASSERT(value != nullptr); return Api::GetNativeDoubleArgument(arguments, arg_index, value); } @@ -250,7 +250,7 @@ static Dart_Handle GetNativeFieldsOfArgument(NativeArguments* arguments, int num_fields, intptr_t* field_values, const char* current_func) { - ASSERT(field_values != NULL); + ASSERT(field_values != nullptr); if (Api::GetNativeFieldsOfArgument(arguments, arg_index, num_fields, field_values)) { return Api::Success(); @@ -330,7 +330,7 @@ static ObjectPtr CallStatic3Args(Zone* zone, static const char* GetErrorString(Thread* thread, const Object& obj) { // This function requires an API scope to be present. if (obj.IsError()) { - ASSERT(thread->api_top_scope() != NULL); + ASSERT(thread->api_top_scope() != nullptr); const Error& error = Error::Cast(obj); const char* str = error.ToErrorCString(); intptr_t len = strlen(str) + 1; @@ -348,7 +348,7 @@ static const char* GetErrorString(Thread* thread, const Object& obj) { Dart_Handle Api::InitNewHandle(Thread* thread, ObjectPtr raw) { LocalHandles* local_handles = Api::TopScope(thread)->local_handles(); - ASSERT(local_handles != NULL); + ASSERT(local_handles != nullptr); LocalHandle* ref = local_handles->AllocateHandle(); ref->set_ptr(raw); return ref->apiHandle(); @@ -373,7 +373,7 @@ ObjectPtr Api::UnwrapHandle(Dart_Handle object) { Thread* thread = Thread::Current(); ASSERT(thread->execution_state() == Thread::kThreadInVM); ASSERT(thread->IsMutatorThread()); - ASSERT(thread->isolate() != NULL); + ASSERT(thread->isolate() != nullptr); ASSERT(FinalizablePersistentHandle::ptr_offset() == 0 && PersistentHandle::ptr_offset() == 0 && LocalHandle::ptr_offset() == 0); #endif @@ -496,9 +496,9 @@ bool Api::IsValid(Dart_Handle handle) { } ApiLocalScope* Api::TopScope(Thread* thread) { - ASSERT(thread != NULL); + ASSERT(thread != nullptr); ApiLocalScope* scope = thread->api_top_scope(); - ASSERT(scope != NULL); + ASSERT(scope != nullptr); return scope; } @@ -518,39 +518,39 @@ static Dart_Handle InitNewReadOnlyApiHandle(ObjectPtr raw) { void Api::InitHandles() { Isolate* isolate = Isolate::Current(); - ASSERT(isolate != NULL); + ASSERT(isolate != nullptr); ASSERT(isolate == Dart::vm_isolate()); ApiState* state = isolate->group()->api_state(); - ASSERT(state != NULL); + ASSERT(state != nullptr); - ASSERT(true_handle_ == NULL); + ASSERT(true_handle_ == nullptr); true_handle_ = InitNewReadOnlyApiHandle(Bool::True().ptr()); - ASSERT(false_handle_ == NULL); + ASSERT(false_handle_ == nullptr); false_handle_ = InitNewReadOnlyApiHandle(Bool::False().ptr()); - ASSERT(null_handle_ == NULL); + ASSERT(null_handle_ == nullptr); null_handle_ = InitNewReadOnlyApiHandle(Object::null()); - ASSERT(empty_string_handle_ == NULL); + ASSERT(empty_string_handle_ == nullptr); empty_string_handle_ = InitNewReadOnlyApiHandle(Symbols::Empty().ptr()); - ASSERT(no_callbacks_error_handle_ == NULL); + ASSERT(no_callbacks_error_handle_ == nullptr); no_callbacks_error_handle_ = InitNewReadOnlyApiHandle(Object::no_callbacks_error().ptr()); - ASSERT(unwind_in_progress_error_handle_ == NULL); + ASSERT(unwind_in_progress_error_handle_ == nullptr); unwind_in_progress_error_handle_ = InitNewReadOnlyApiHandle(Object::unwind_in_progress_error().ptr()); } void Api::Cleanup() { - true_handle_ = NULL; - false_handle_ = NULL; - null_handle_ = NULL; - empty_string_handle_ = NULL; - no_callbacks_error_handle_ = NULL; - unwind_in_progress_error_handle_ = NULL; + true_handle_ = nullptr; + false_handle_ = nullptr; + null_handle_ = nullptr; + empty_string_handle_ = nullptr; + no_callbacks_error_handle_ = nullptr; + unwind_in_progress_error_handle_ = nullptr; } bool Api::StringGetPeerHelper(NativeArguments* arguments, @@ -729,10 +729,10 @@ void FinalizablePersistentHandle::Finalize( return; // Free handle. } Dart_HandleFinalizer callback = handle->callback(); - ASSERT(callback != NULL); + ASSERT(callback != nullptr); void* peer = handle->peer(); ApiState* state = isolate_group->api_state(); - ASSERT(state != NULL); + ASSERT(state != nullptr); if (!handle->auto_delete()) { // Clear handle before running finalizer, finalizer can free the handle. @@ -938,7 +938,7 @@ Dart_HandleFromPersistent(Dart_PersistentHandle object) { Isolate* isolate = thread->isolate(); CHECK_ISOLATE(isolate); ApiState* state = isolate->group()->api_state(); - ASSERT(state != NULL); + ASSERT(state != nullptr); TransitionNativeToVM transition(thread); NoSafepointScope no_safepoint_scope; PersistentHandle* ref = PersistentHandle::Cast(object); @@ -951,7 +951,7 @@ Dart_HandleFromWeakPersistent(Dart_WeakPersistentHandle object) { Isolate* isolate = thread->isolate(); CHECK_ISOLATE(isolate); ApiState* state = isolate->group()->api_state(); - ASSERT(state != NULL); + ASSERT(state != nullptr); TransitionNativeToVM transition(thread); NoSafepointScope no_safepoint_scope; FinalizablePersistentHandle* weak_ref = @@ -967,7 +967,7 @@ static Dart_Handle HandleFromFinalizable(Dart_FinalizableHandle object) { Isolate* isolate = thread->isolate(); CHECK_ISOLATE(isolate); ApiState* state = isolate->group()->api_state(); - ASSERT(state != NULL); + ASSERT(state != nullptr); TransitionNativeToVM transition(thread); NoSafepointScope no_safepoint_scope; FinalizablePersistentHandle* weak_ref = @@ -979,7 +979,7 @@ DART_EXPORT Dart_PersistentHandle Dart_NewPersistentHandle(Dart_Handle object) { DARTSCOPE(Thread::Current()); Isolate* I = T->isolate(); ApiState* state = I->group()->api_state(); - ASSERT(state != NULL); + ASSERT(state != nullptr); const Object& old_ref = Object::Handle(Z, Api::UnwrapHandle(object)); PersistentHandle* new_ref = state->AllocatePersistentHandle(); new_ref->set_ptr(old_ref); @@ -991,7 +991,7 @@ DART_EXPORT void Dart_SetPersistentHandle(Dart_PersistentHandle obj1, DARTSCOPE(Thread::Current()); Isolate* I = T->isolate(); ApiState* state = I->group()->api_state(); - ASSERT(state != NULL); + ASSERT(state != nullptr); ASSERT(state->IsValidPersistentHandle(obj1)); const Object& obj2_ref = Object::Handle(Z, Api::UnwrapHandle(obj2)); PersistentHandle* obj1_ref = PersistentHandle::Cast(obj1); @@ -1026,13 +1026,13 @@ static Dart_WeakPersistentHandle AllocateWeakPersistentHandle( intptr_t external_allocation_size, Dart_HandleFinalizer callback) { if (!ref.ptr()->IsHeapObject()) { - return NULL; + return nullptr; } if (ref.IsPointer()) { - return NULL; + return nullptr; } if (IsFfiCompound(thread, ref)) { - return NULL; + return nullptr; } FinalizablePersistentHandle* finalizable_ref = @@ -1062,13 +1062,13 @@ static Dart_FinalizableHandle AllocateFinalizableHandle( intptr_t external_allocation_size, Dart_HandleFinalizer callback) { if (!ref.ptr()->IsHeapObject()) { - return NULL; + return nullptr; } if (ref.IsPointer()) { - return NULL; + return nullptr; } if (IsFfiCompound(thread, ref)) { - return NULL; + return nullptr; } FinalizablePersistentHandle* finalizable_ref = @@ -1096,8 +1096,8 @@ Dart_NewWeakPersistentHandle(Dart_Handle object, intptr_t external_allocation_size, Dart_HandleFinalizer callback) { DARTSCOPE(Thread::Current()); - if (callback == NULL) { - return NULL; + if (callback == nullptr) { + return nullptr; } return AllocateWeakPersistentHandle(T, object, peer, external_allocation_size, @@ -1125,7 +1125,7 @@ DART_EXPORT void Dart_UpdateExternalSize(Dart_WeakPersistentHandle object, CHECK_ISOLATE_GROUP(isolate_group); TransitionToVM transition(T); ApiState* state = isolate_group->api_state(); - ASSERT(state != NULL); + ASSERT(state != nullptr); ASSERT(state->IsActiveWeakPersistentHandle(object)); auto weak_ref = FinalizablePersistentHandle::Cast(object); weak_ref->UpdateExternalSize(external_size, isolate_group); @@ -1152,7 +1152,7 @@ DART_EXPORT void Dart_DeletePersistentHandle(Dart_PersistentHandle object) { CHECK_ISOLATE_GROUP(isolate_group); TransitionToVM transition(T); ApiState* state = isolate_group->api_state(); - ASSERT(state != NULL); + ASSERT(state != nullptr); ASSERT(state->IsActivePersistentHandle(object)); ASSERT(!Api::IsProtectedHandle(object)); if (!Api::IsProtectedHandle(object)) { @@ -1168,7 +1168,7 @@ DART_EXPORT void Dart_DeleteWeakPersistentHandle( CHECK_ISOLATE_GROUP(isolate_group); TransitionToVM transition(T); ApiState* state = isolate_group->api_state(); - ASSERT(state != NULL); + ASSERT(state != nullptr); ASSERT(state->IsActiveWeakPersistentHandle(object)); auto weak_ref = FinalizablePersistentHandle::Cast(object); weak_ref->EnsureFreedExternal(isolate_group); @@ -1198,7 +1198,7 @@ DART_EXPORT const char* Dart_VersionString() { } DART_EXPORT char* Dart_Initialize(Dart_InitializeParams* params) { - if (params == NULL) { + if (params == nullptr) { return Utils::StrDup( "Dart_Initialize: " "Dart_InitializeParams is null."); @@ -1242,7 +1242,7 @@ DART_API_ISOLATE_GROUP_METRIC_LIST(ISOLATE_GROUP_METRIC_API) #if !defined(PRODUCT) #define ISOLATE_METRIC_API(type, variable, name, unit) \ DART_EXPORT int64_t Dart_Isolate##variable##Metric(Dart_Isolate isolate) { \ - if (isolate == NULL) { \ + if (isolate == nullptr) { \ FATAL("%s expects argument 'isolate' to be non-null.", CURRENT_FUNC); \ } \ Isolate* iso = reinterpret_cast(isolate); \ @@ -1270,11 +1270,11 @@ static Dart_Isolate CreateIsolate(IsolateGroup* group, auto source = group->source(); Isolate* I = Dart::CreateIsolate(name, source->flags, group); - if (I == NULL) { - if (error != NULL) { + if (I == nullptr) { + if (error != nullptr) { *error = Utils::StrDup("Isolate creation failed"); } - return static_cast(NULL); + return static_cast(nullptr); } Thread* T = Thread::Current(); @@ -1297,7 +1297,7 @@ static Dart_Isolate CreateIsolate(IsolateGroup* group, } #endif // defined(DEBUG) && !defined(DART_PRECOMPILED_RUNTIME). success = true; - } else if (error != NULL) { + } else if (error != nullptr) { *error = Utils::StrDup(error_obj.ToErrorCString()); } // We exit the API scope entered above. @@ -1311,14 +1311,14 @@ static Dart_Isolate CreateIsolate(IsolateGroup* group, // outside this scope in Dart_ShutdownIsolate/Dart_ExitIsolate. T->set_execution_state(Thread::kThreadInNative); T->EnterSafepoint(); - if (error != NULL) { - *error = NULL; + if (error != nullptr) { + *error = nullptr; } return Api::CastIsolate(I); } Dart::ShutdownIsolate(); - return static_cast(NULL); + return static_cast(nullptr); } static bool IsServiceOrKernelIsolateName(const char* name) { @@ -1469,12 +1469,12 @@ DART_EXPORT void Dart_ShutdownIsolate() { // Release any remaining API scopes. ApiLocalScope* scope = T->api_top_scope(); - while (scope != NULL) { + while (scope != nullptr) { ApiLocalScope* previous = scope->previous(); delete scope; scope = previous; } - T->set_api_top_scope(NULL); + T->set_api_top_scope(nullptr); { StackZone zone(T); @@ -1501,7 +1501,7 @@ DART_EXPORT void* Dart_CurrentIsolateData() { } DART_EXPORT void* Dart_IsolateData(Dart_Isolate isolate) { - if (isolate == NULL) { + if (isolate == nullptr) { FATAL("%s expects argument 'isolate' to be non-null.", CURRENT_FUNC); } // TODO(http://dartbug.com/16615): Validate isolate parameter. @@ -1526,7 +1526,7 @@ DART_EXPORT Dart_IsolateGroupId Dart_CurrentIsolateGroupId() { } DART_EXPORT void* Dart_IsolateGroupData(Dart_Isolate isolate) { - if (isolate == NULL) { + if (isolate == nullptr) { FATAL("%s expects argument 'isolate' to be non-null.", CURRENT_FUNC); } // TODO(http://dartbug.com/16615): Validate isolate parameter. @@ -1559,13 +1559,13 @@ DART_EXPORT const char* Dart_DebugNameToCString() { } DART_EXPORT const char* Dart_IsolateServiceId(Dart_Isolate isolate) { - if (isolate == NULL) { + if (isolate == nullptr) { FATAL("%s expects argument 'isolate' to be non-null.", CURRENT_FUNC); } // TODO(http://dartbug.com/16615): Validate isolate parameter. Isolate* I = reinterpret_cast(isolate); int64_t main_port = static_cast(I->main_port()); - return OS::SCreate(NULL, "isolates/%" Pd64, main_port); + return OS::SCreate(nullptr, "isolates/%" Pd64, main_port); } DART_EXPORT void Dart_EnterIsolate(Dart_Isolate isolate) { @@ -1613,7 +1613,7 @@ DART_EXPORT void Dart_StopProfiling() { DART_EXPORT void Dart_ThreadDisableProfiling() { OSThread* os_thread = OSThread::Current(); - if (os_thread == NULL) { + if (os_thread == nullptr) { return; } os_thread->DisableThreadInterrupts(); @@ -1621,7 +1621,7 @@ DART_EXPORT void Dart_ThreadDisableProfiling() { DART_EXPORT void Dart_ThreadEnableProfiling() { OSThread* os_thread = OSThread::Current(); - if (os_thread == NULL) { + if (os_thread == nullptr) { return; } os_thread->EnableThreadInterrupts(); @@ -1639,7 +1639,7 @@ DART_EXPORT bool Dart_WriteProfileToTimeline(Dart_Port main_port, return false; #else if (!FLAG_profiler) { - if (error != NULL) { + if (error != nullptr) { *error = Utils::StrDup("The profiler is not running."); } return false; @@ -1661,7 +1661,7 @@ DART_EXPORT bool Dart_WriteProfileToTimeline(Dart_Port main_port, // clang-format on ASSERT(method_length <= kBufferLength); - char* response = NULL; + char* response = nullptr; intptr_t response_length; bool success = Dart_InvokeVMServiceMethod( reinterpret_cast(method), method_length, @@ -1970,7 +1970,7 @@ DART_EXPORT bool Dart_IsKernel(const uint8_t* buffer, intptr_t buffer_size) { DART_EXPORT char* Dart_IsolateMakeRunnable(Dart_Isolate isolate) { CHECK_NO_ISOLATE(Isolate::Current()); API_TIMELINE_DURATION(Thread::Current()); - if (isolate == NULL) { + if (isolate == nullptr) { FATAL("%s expects argument 'isolate' to be non-null.", CURRENT_FUNC); } // TODO(16615): Validate isolate parameter. @@ -2020,7 +2020,7 @@ struct RunLoopData { static void RunLoopDone(uword param) { RunLoopData* data = reinterpret_cast(param); - ASSERT(data->monitor != NULL); + ASSERT(data->monitor != nullptr); MonitorLocker ml(data->monitor); data->done = true; ml.Notify(); @@ -2046,8 +2046,8 @@ DART_EXPORT Dart_Handle Dart_RunLoop() { data.monitor = &monitor; data.done = false; result = - I->message_handler()->Run(I->group()->thread_pool(), NULL, RunLoopDone, - reinterpret_cast(&data)); + I->message_handler()->Run(I->group()->thread_pool(), nullptr, + RunLoopDone, reinterpret_cast(&data)); if (result) { while (!data.done) { ml.Wait(); @@ -2137,7 +2137,7 @@ DART_EXPORT Dart_Handle Dart_WaitForEvent(int64_t timeout_millis) { CHECK_CALLBACK_STATE(T); API_TIMELINE_BEGIN_END(T); TransitionNativeToVM transition(T); - if (I->message_notify_callback() != NULL) { + if (I->message_notify_callback() != nullptr) { return Api::NewError("waitForEventSync is not supported by this embedder"); } Object& result = @@ -2250,7 +2250,7 @@ DART_EXPORT Dart_Handle Dart_SendPortGetId(Dart_Handle port, if (send_port.IsNull()) { RETURN_TYPE_ERROR(Z, port, SendPort); } - if (port_id == NULL) { + if (port_id == nullptr) { RETURN_NULL_ERROR(port_id); } *port_id = send_port.Id(); @@ -2283,12 +2283,12 @@ DART_EXPORT void Dart_ExitScope() { DART_EXPORT uint8_t* Dart_ScopeAllocate(intptr_t size) { Zone* zone; Thread* thread = Thread::Current(); - if (thread != NULL) { + if (thread != nullptr) { ApiLocalScope* scope = thread->api_top_scope(); zone = scope->zone(); } else { ApiNativeScope* scope = ApiNativeScope::Current(); - if (scope == NULL) return NULL; + if (scope == nullptr) return nullptr; zone = scope->zone(); } return reinterpret_cast(zone->AllocUnsafe(size)); @@ -2297,7 +2297,7 @@ DART_EXPORT uint8_t* Dart_ScopeAllocate(intptr_t size) { // --- Objects ---- DART_EXPORT Dart_Handle Dart_Null() { - ASSERT(Isolate::Current() != NULL); + ASSERT(Isolate::Current() != nullptr); return Api::Null(); } @@ -2307,7 +2307,7 @@ DART_EXPORT bool Dart_IsNull(Dart_Handle object) { } DART_EXPORT Dart_Handle Dart_EmptyString() { - ASSERT(Isolate::Current() != NULL); + ASSERT(Isolate::Current() != nullptr); return Api::EmptyString(); } @@ -2625,7 +2625,7 @@ DART_EXPORT Dart_Handle Dart_FunctionOwner(Dart_Handle function) { DART_EXPORT Dart_Handle Dart_FunctionIsStatic(Dart_Handle function, bool* is_static) { DARTSCOPE(Thread::Current()); - if (is_static == NULL) { + if (is_static == nullptr) { RETURN_NULL_ERROR(is_static); } const Function& func = Api::UnwrapFunctionHandle(Z, function); @@ -2883,12 +2883,12 @@ DART_EXPORT Dart_Handle Dart_GetStaticMethodClosure(Dart_Handle library, // --- Booleans ---- DART_EXPORT Dart_Handle Dart_True() { - ASSERT(Isolate::Current() != NULL); + ASSERT(Isolate::Current() != nullptr); return Api::True(); } DART_EXPORT Dart_Handle Dart_False() { - ASSERT(Isolate::Current() != NULL); + ASSERT(Isolate::Current() != nullptr); return Api::False(); } @@ -2928,7 +2928,7 @@ DART_EXPORT Dart_Handle Dart_StringLength(Dart_Handle str, intptr_t* len) { DART_EXPORT Dart_Handle Dart_NewStringFromCString(const char* str) { DARTSCOPE(Thread::Current()); API_TIMELINE_DURATION(T); - if (str == NULL) { + if (str == nullptr) { RETURN_NULL_ERROR(str); } CHECK_CALLBACK_STATE(T); @@ -2939,7 +2939,7 @@ DART_EXPORT Dart_Handle Dart_NewStringFromUTF8(const uint8_t* utf8_array, intptr_t length) { DARTSCOPE(Thread::Current()); API_TIMELINE_DURATION(T); - if (utf8_array == NULL && length != 0) { + if (utf8_array == nullptr && length != 0) { RETURN_NULL_ERROR(utf8_array); } CHECK_LENGTH(length, String::kMaxElements); @@ -2954,7 +2954,7 @@ DART_EXPORT Dart_Handle Dart_NewStringFromUTF8(const uint8_t* utf8_array, DART_EXPORT Dart_Handle Dart_NewStringFromUTF16(const uint16_t* utf16_array, intptr_t length) { DARTSCOPE(Thread::Current()); - if (utf16_array == NULL && length != 0) { + if (utf16_array == nullptr && length != 0) { RETURN_NULL_ERROR(utf16_array); } CHECK_LENGTH(length, String::kMaxElements); @@ -2966,7 +2966,7 @@ DART_EXPORT Dart_Handle Dart_NewStringFromUTF32(const int32_t* utf32_array, intptr_t length) { DARTSCOPE(Thread::Current()); API_TIMELINE_DURATION(T); - if (utf32_array == NULL && length != 0) { + if (utf32_array == nullptr && length != 0) { RETURN_NULL_ERROR(utf32_array); } CHECK_LENGTH(length, String::kMaxElements); @@ -2982,10 +2982,10 @@ Dart_NewExternalLatin1String(const uint8_t* latin1_array, Dart_HandleFinalizer callback) { DARTSCOPE(Thread::Current()); API_TIMELINE_DURATION(T); - if (latin1_array == NULL && length != 0) { + if (latin1_array == nullptr && length != 0) { RETURN_NULL_ERROR(latin1_array); } - if (callback == NULL) { + if (callback == nullptr) { RETURN_NULL_ERROR(callback); } CHECK_LENGTH(length, String::kMaxElements); @@ -3003,10 +3003,10 @@ Dart_NewExternalUTF16String(const uint16_t* utf16_array, intptr_t external_allocation_size, Dart_HandleFinalizer callback) { DARTSCOPE(Thread::Current()); - if (utf16_array == NULL && length != 0) { + if (utf16_array == nullptr && length != 0) { RETURN_NULL_ERROR(utf16_array); } - if (callback == NULL) { + if (callback == nullptr) { RETURN_NULL_ERROR(callback); } CHECK_LENGTH(length, String::kMaxElements); @@ -3022,7 +3022,7 @@ DART_EXPORT Dart_Handle Dart_StringToCString(Dart_Handle object, const char** cstr) { DARTSCOPE(Thread::Current()); API_TIMELINE_DURATION(T); - if (cstr == NULL) { + if (cstr == nullptr) { RETURN_NULL_ERROR(cstr); } const String& str_obj = Api::UnwrapStringHandle(Z, object); @@ -3031,7 +3031,7 @@ DART_EXPORT Dart_Handle Dart_StringToCString(Dart_Handle object, } intptr_t string_length = Utf8::Length(str_obj); char* res = Api::TopScope(T)->zone()->Alloc(string_length + 1); - if (res == NULL) { + if (res == nullptr) { return Api::NewError("Unable to allocate memory"); } const char* string_value = str_obj.ToCString(); @@ -3046,10 +3046,10 @@ DART_EXPORT Dart_Handle Dart_StringToUTF8(Dart_Handle str, intptr_t* length) { DARTSCOPE(Thread::Current()); API_TIMELINE_DURATION(T); - if (utf8_array == NULL) { + if (utf8_array == nullptr) { RETURN_NULL_ERROR(utf8_array); } - if (length == NULL) { + if (length == nullptr) { RETURN_NULL_ERROR(length); } const String& str_obj = Api::UnwrapStringHandle(Z, str); @@ -3058,7 +3058,7 @@ DART_EXPORT Dart_Handle Dart_StringToUTF8(Dart_Handle str, } intptr_t str_len = Utf8::Length(str_obj); *utf8_array = Api::TopScope(T)->zone()->Alloc(str_len); - if (*utf8_array == NULL) { + if (*utf8_array == nullptr) { return Api::NewError("Unable to allocate memory"); } str_obj.ToUTF8(*utf8_array, str_len); @@ -3071,10 +3071,10 @@ DART_EXPORT Dart_Handle Dart_StringToLatin1(Dart_Handle str, intptr_t* length) { DARTSCOPE(Thread::Current()); API_TIMELINE_DURATION(T); - if (latin1_array == NULL) { + if (latin1_array == nullptr) { RETURN_NULL_ERROR(latin1_array); } - if (length == NULL) { + if (length == nullptr) { RETURN_NULL_ERROR(length); } const String& str_obj = Api::UnwrapStringHandle(Z, str); @@ -3116,7 +3116,7 @@ DART_EXPORT Dart_Handle Dart_StringStorageSize(Dart_Handle str, Thread* thread = Thread::Current(); CHECK_ISOLATE(thread->isolate()); TransitionNativeToVM transition(thread); - if (size == NULL) { + if (size == nullptr) { RETURN_NULL_ERROR(size); } { @@ -3143,7 +3143,7 @@ DART_EXPORT Dart_Handle Dart_StringGetProperties(Dart_Handle object, if (!str.IsNull()) { if (str.IsExternal()) { *peer = str.GetPeer(); - ASSERT(*peer != NULL); + ASSERT(*peer != nullptr); } else { NoSafepointScope no_safepoint_scope; *peer = thread->heap()->GetPeer(str.ptr()); @@ -3354,7 +3354,7 @@ DART_EXPORT Dart_Handle Dart_ListGetRange(Dart_Handle list, intptr_t length, Dart_Handle* result) { DARTSCOPE(Thread::Current()); - if (result == NULL) { + if (result == nullptr) { RETURN_NULL_ERROR(result); } const Object& obj = Object::Handle(Z, Api::UnwrapHandle(list)); @@ -3960,7 +3960,7 @@ static Dart_Handle NewExternalTypedDataWithFinalizer( Dart_HandleFinalizer callback, bool unmodifiable) { DARTSCOPE(Thread::Current()); - if (data == NULL && length != 0) { + if (data == nullptr && length != 0) { RETURN_NULL_ERROR(data); } CHECK_CALLBACK_STATE(T); @@ -4038,8 +4038,8 @@ static Dart_Handle NewExternalTypedDataWithFinalizer( DART_EXPORT Dart_Handle Dart_NewExternalTypedData(Dart_TypedData_Type type, void* data, intptr_t length) { - return NewExternalTypedDataWithFinalizer(type, data, length, NULL, 0, NULL, - false); + return NewExternalTypedDataWithFinalizer(type, data, length, nullptr, 0, + nullptr, false); } DART_EXPORT Dart_Handle @@ -4111,7 +4111,7 @@ DART_EXPORT Dart_Handle Dart_NewByteBuffer(Dart_Handle typed_data) { class AcquiredData { public: AcquiredData(void* data, intptr_t size_in_bytes, bool copy) - : size_in_bytes_(size_in_bytes), data_(data), data_copy_(NULL) { + : size_in_bytes_(size_in_bytes), data_(data), data_copy_(nullptr) { if (copy) { data_copy_ = malloc(size_in_bytes_); memmove(data_copy_, data_, size_in_bytes_); @@ -4119,11 +4119,11 @@ class AcquiredData { } // The pointer to hand out via the API. - void* GetData() const { return data_copy_ != NULL ? data_copy_ : data_; } + void* GetData() const { return data_copy_ != nullptr ? data_copy_ : data_; } // Writes back and deletes/zaps, if a copy was made. ~AcquiredData() { - if (data_copy_ != NULL) { + if (data_copy_ != nullptr) { memmove(data_, data_copy_, size_in_bytes_); memset(data_copy_, kZapReleasedByte, size_in_bytes_); free(data_copy_); @@ -4151,20 +4151,20 @@ DART_EXPORT Dart_Handle Dart_TypedDataAcquireData(Dart_Handle object, !IsUnmodifiableTypedDataViewClassId(class_id)) { RETURN_TYPE_ERROR(Z, object, 'TypedData'); } - if (type == NULL) { + if (type == nullptr) { RETURN_NULL_ERROR(type); } - if (data == NULL) { + if (data == nullptr) { RETURN_NULL_ERROR(data); } - if (len == NULL) { + if (len == nullptr) { RETURN_NULL_ERROR(len); } // Get the type of typed data object. *type = GetType(class_id); intptr_t length = 0; intptr_t size_in_bytes = 0; - void* data_tmp = NULL; + void* data_tmp = nullptr; bool external = false; T->IncrementNoSafepointScopeDepth(); START_NO_CALLBACK_SCOPE(T); @@ -4532,7 +4532,7 @@ Dart_AllocateWithNativeFields(Dart_Handle type, if (type_obj.IsNull()) { RETURN_TYPE_ERROR(Z, type, Type); } - if (native_fields == NULL) { + if (native_fields == nullptr) { RETURN_NULL_ERROR(native_fields); } const Class& cls = Class::Handle(Z, type_obj.type_class()); @@ -4625,7 +4625,7 @@ DART_EXPORT Dart_Handle Dart_InvokeConstructor(Dart_Handle object, const int extra_args = 1; if (!constructor.IsNull() && constructor.IsGenerativeConstructor() && constructor.AreValidArgumentCounts( - kTypeArgsLen, number_of_arguments + extra_args, 0, NULL)) { + kTypeArgsLen, number_of_arguments + extra_args, 0, nullptr)) { CHECK_ERROR_HANDLE(constructor.VerifyCallEntryPoint()); // Create the argument list. Dart_Handle result; @@ -4761,7 +4761,7 @@ DART_EXPORT Dart_Handle Dart_InvokeClosure(Dart_Handle closure, API_TIMELINE_DURATION(T); CHECK_CALLBACK_STATE(T); const Instance& closure_obj = Api::UnwrapInstanceHandle(Z, closure); - if (closure_obj.IsNull() || !closure_obj.IsCallable(NULL)) { + if (closure_obj.IsNull() || !closure_obj.IsCallable(nullptr)) { RETURN_TYPE_ERROR(Z, closure, Instance); } if (number_of_arguments < 0) { @@ -5082,7 +5082,7 @@ DART_EXPORT Dart_Handle Dart_GetNativeArguments( NativeArguments* arguments = reinterpret_cast(args); TransitionNativeToVM transition(arguments->thread()); ASSERT(arguments->thread()->isolate() == Isolate::Current()); - if (arg_values == NULL) { + if (arg_values == nullptr) { RETURN_NULL_ERROR(arg_values); } for (int i = 0; i < num_arguments; i++) { @@ -5194,7 +5194,7 @@ DART_EXPORT Dart_Handle Dart_GetNativeArguments( case Dart_NativeArgument_kInstance: { ASSERT(arguments->thread() == Thread::Current()); - ASSERT(arguments->thread()->api_top_scope() != NULL); + ASSERT(arguments->thread()->api_top_scope() != nullptr); native_value->as_instance = Api::NewHandle( arguments->thread(), arguments->NativeArgAt(arg_index)); break; @@ -5236,7 +5236,7 @@ Dart_GetNativeFieldsOfArgument(Dart_NativeArguments args, "%s: argument 'arg_index' out of range. Expected 0..%d but saw %d.", CURRENT_FUNC, arguments->NativeArgCount() - 1, arg_index); } - if (field_values == NULL) { + if (field_values == nullptr) { RETURN_NULL_ERROR(field_values); } return GetNativeFieldsOfArgument(arguments, arg_index, num_fields, @@ -5248,7 +5248,7 @@ DART_EXPORT Dart_Handle Dart_GetNativeReceiver(Dart_NativeArguments args, NativeArguments* arguments = reinterpret_cast(args); TransitionNativeToVM transition(arguments->thread()); ASSERT(arguments->thread()->isolate() == Isolate::Current()); - if (value == NULL) { + if (value == nullptr) { RETURN_NULL_ERROR(value); } if (Api::GetNativeReceiver(arguments, value)) { @@ -5358,7 +5358,7 @@ DART_EXPORT void Dart_SetWeakHandleReturnValue(Dart_NativeArguments args, #if defined(DEBUG) Isolate* isolate = arguments->thread()->isolate(); ASSERT(isolate == Isolate::Current()); - ASSERT(isolate->group()->api_state() != NULL && + ASSERT(isolate->group()->api_state() != nullptr && (isolate->group()->api_state()->IsValidWeakPersistentHandle(rval))); #endif Api::SetWeakHandleReturnValue(arguments, rval); @@ -5425,7 +5425,7 @@ StringPtr Api::GetEnvironmentValue(Thread* thread, const String& name) { StringPtr Api::CallEnvironmentCallback(Thread* thread, const String& name) { Isolate* isolate = thread->isolate(); Dart_EnvironmentCallback callback = isolate->environment_callback(); - if (callback != NULL) { + if (callback != nullptr) { Scope api_scope(thread); Dart_Handle api_name = Api::NewHandle(thread, name.ptr()); Dart_Handle api_response; @@ -5672,7 +5672,7 @@ static Dart_Handle GetTypeCommon(Dart_Handle library, intptr_t num_expected_type_arguments = cls.NumTypeParameters(); TypeArguments& type_args_obj = TypeArguments::Handle(); if (number_of_type_arguments > 0) { - if (type_arguments == NULL) { + if (type_arguments == nullptr) { RETURN_NULL_ERROR(type_arguments); } if (num_expected_type_arguments != number_of_type_arguments) { @@ -5992,7 +5992,7 @@ static Dart_Handle DeferredLoadComplete(intptr_t loading_unit_id, "ReadUnitSnapshot"); #endif // defined(SUPPORT_TIMELINE) const Snapshot* snapshot = Snapshot::SetupFromBuffer(snapshot_data); - if (snapshot == NULL) { + if (snapshot == nullptr) { return Api::NewError("Invalid snapshot"); } if (!IsSnapshotCompatible(Dart::vm_snapshot_kind(), snapshot->kind())) { @@ -6046,10 +6046,10 @@ Dart_SetNativeResolver(Dart_Handle library, DART_EXPORT Dart_Handle Dart_GetNativeResolver(Dart_Handle library, Dart_NativeEntryResolver* resolver) { - if (resolver == NULL) { + if (resolver == nullptr) { RETURN_NULL_ERROR(resolver); } - *resolver = NULL; + *resolver = nullptr; DARTSCOPE(Thread::Current()); const Library& lib = Api::UnwrapLibraryHandle(Z, library); if (lib.IsNull()) { @@ -6061,10 +6061,10 @@ Dart_GetNativeResolver(Dart_Handle library, DART_EXPORT Dart_Handle Dart_GetNativeSymbol(Dart_Handle library, Dart_NativeEntrySymbol* resolver) { - if (resolver == NULL) { + if (resolver == nullptr) { RETURN_NULL_ERROR(resolver); } - *resolver = NULL; + *resolver = nullptr; DARTSCOPE(Thread::Current()); const Library& lib = Api::UnwrapLibraryHandle(Z, library); if (lib.IsNull()) { @@ -6089,7 +6089,7 @@ Dart_SetFfiNativeResolver(Dart_Handle library, // --- Peer support --- DART_EXPORT Dart_Handle Dart_GetPeer(Dart_Handle object, void** peer) { - if (peer == NULL) { + if (peer == nullptr) { RETURN_NULL_ERROR(peer); } Thread* thread = Thread::Current(); @@ -6174,8 +6174,8 @@ Dart_CompileToKernel(const char* script_uri, result.error = Utils::StrDup("Dart_CompileToKernel is unsupported."); #else result = KernelIsolate::CompileToKernel( - script_uri, platform_kernel, platform_kernel_size, 0, NULL, - incremental_compile, snapshot_compile, package_config, NULL, NULL, + script_uri, platform_kernel, platform_kernel_size, 0, nullptr, + incremental_compile, snapshot_compile, package_config, nullptr, nullptr, verbosity); if (incremental_compile) { Dart_KernelCompilationResult ack_result = @@ -6281,38 +6281,38 @@ DART_EXPORT char* Dart_SetServiceStreamCallbacks( Dart_ServiceStreamListenCallback listen_callback, Dart_ServiceStreamCancelCallback cancel_callback) { #if defined(PRODUCT) - return NULL; + return nullptr; #else - if (listen_callback != NULL) { - if (Service::stream_listen_callback() != NULL) { + if (listen_callback != nullptr) { + if (Service::stream_listen_callback() != nullptr) { return Utils::StrDup( "Dart_SetServiceStreamCallbacks " "permits only one listen callback to be registered, please " "remove the existing callback and then add this callback"); } } else { - if (Service::stream_listen_callback() == NULL) { + if (Service::stream_listen_callback() == nullptr) { return Utils::StrDup( "Dart_SetServiceStreamCallbacks " "expects 'listen_callback' to be present in the callback set."); } } - if (cancel_callback != NULL) { - if (Service::stream_cancel_callback() != NULL) { + if (cancel_callback != nullptr) { + if (Service::stream_cancel_callback() != nullptr) { return Utils::StrDup( "Dart_SetServiceStreamCallbacks " "permits only one cancel callback to be registered, please " "remove the existing callback and then add this callback"); } } else { - if (Service::stream_cancel_callback() == NULL) { + if (Service::stream_cancel_callback() == nullptr) { return Utils::StrDup( "Dart_SetServiceStreamCallbacks " "expects 'cancel_callback' to be present in the callback set."); } } Service::SetEmbedderStreamCallbacks(listen_callback, cancel_callback); - return NULL; + return nullptr; #endif } @@ -6321,17 +6321,17 @@ DART_EXPORT char* Dart_ServiceSendDataEvent(const char* stream_id, const uint8_t* bytes, intptr_t bytes_length) { #if !defined(PRODUCT) - if (stream_id == NULL) { + if (stream_id == nullptr) { return Utils::StrDup( "Dart_ServiceSendDataEvent expects argument 'stream_id' to be " "non-null."); } - if (event_kind == NULL) { + if (event_kind == nullptr) { return Utils::StrDup( "Dart_ServiceSendDataEvent expects argument 'event_kind' to be " "non-null."); } - if (bytes == NULL) { + if (bytes == nullptr) { return Utils::StrDup( "Dart_ServiceSendDataEvent expects argument 'bytes' to be non-null."); } @@ -6340,7 +6340,7 @@ DART_EXPORT char* Dart_ServiceSendDataEvent(const char* stream_id, "Dart_ServiceSendDataEvent expects argument 'bytes_length' to be >= " "0."); } - Service::SendEmbedderEvent(Isolate::Current(), // May be NULL + Service::SendEmbedderEvent(Isolate::Current(), // May be nullptr stream_id, event_kind, bytes, bytes_length); #endif return nullptr; @@ -6355,15 +6355,15 @@ DART_EXPORT char* Dart_SetFileModifiedCallback( Dart_FileModifiedCallback file_modified_callback) { #if !defined(PRODUCT) #if !defined(DART_PRECOMPILED_RUNTIME) - if (file_modified_callback != NULL) { - if (IsolateGroupReloadContext::file_modified_callback() != NULL) { + if (file_modified_callback != nullptr) { + if (IsolateGroupReloadContext::file_modified_callback() != nullptr) { return Utils::StrDup( "Dart_SetFileModifiedCallback permits only one callback to be" " registered, please remove the existing callback and then add" " this callback"); } } else { - if (IsolateGroupReloadContext::file_modified_callback() == NULL) { + if (IsolateGroupReloadContext::file_modified_callback() == nullptr) { return Utils::StrDup( "Dart_SetFileModifiedCallback expects 'file_modified_callback' to" " be set before it is cleared."); @@ -6372,7 +6372,7 @@ DART_EXPORT char* Dart_SetFileModifiedCallback( IsolateGroupReloadContext::SetFileModifiedCallback(file_modified_callback); #endif // !defined(DART_PRECOMPILED_RUNTIME) #endif // !defined(PRODUCT) - return NULL; + return nullptr; } DART_EXPORT bool Dart_IsReloading() { @@ -6430,9 +6430,9 @@ DART_EXPORT void Dart_TimelineEvent(const char* label, return; } TimelineStream* stream = Timeline::GetEmbedderStream(); - ASSERT(stream != NULL); + ASSERT(stream != nullptr); TimelineEvent* event = stream->StartEvent(); - if (event != NULL) { + if (event != nullptr) { switch (type) { case Dart_Timeline_Event_Begin: event->Begin(label, timestamp1_or_async_id, timestamp0); @@ -6489,7 +6489,7 @@ DART_EXPORT void Dart_SetTimelineRecorderCallback( DART_EXPORT void Dart_SetThreadName(const char* name) { OSThread* thread = OSThread::Current(); - if (thread == NULL) { + if (thread == nullptr) { // VM is shutting down. return; } @@ -7038,10 +7038,10 @@ DART_EXPORT Dart_Handle Dart_GetObfuscationMap(uint8_t** buffer, DARTSCOPE(thread); auto isolate_group = thread->isolate_group(); - if (buffer == NULL) { + if (buffer == nullptr) { RETURN_NULL_ERROR(buffer); } - if (buffer_length == NULL) { + if (buffer_length == nullptr) { RETURN_NULL_ERROR(buffer_length); } diff --git a/runtime/vm/dart_api_impl.h b/runtime/vm/dart_api_impl.h index beb0921d91d..f648d25779a 100644 --- a/runtime/vm/dart_api_impl.h +++ b/runtime/vm/dart_api_impl.h @@ -28,10 +28,10 @@ const char* CanonicalFunction(const char* func); #define CURRENT_FUNC CanonicalFunction(__FUNCTION__) -// Checks that the current isolate group is not NULL. +// Checks that the current isolate group is not nullptr. #define CHECK_ISOLATE_GROUP(isolate_group) \ do { \ - if ((isolate_group) == NULL) { \ + if ((isolate_group) == nullptr) { \ FATAL( \ "%s expects there to be a current isolate group. Did you " \ "forget to call Dart_CreateIsolateGroup or Dart_EnterIsolate?", \ @@ -39,10 +39,10 @@ const char* CanonicalFunction(const char* func); } \ } while (0) -// Checks that the current isolate is not NULL. +// Checks that the current isolate is not nullptr. #define CHECK_ISOLATE(isolate) \ do { \ - if ((isolate) == NULL) { \ + if ((isolate) == nullptr) { \ FATAL( \ "%s expects there to be a current isolate. Did you " \ "forget to call Dart_CreateIsolateGroup or Dart_EnterIsolate?", \ @@ -50,10 +50,10 @@ const char* CanonicalFunction(const char* func); } \ } while (0) -// Checks that the current isolate is NULL. +// Checks that the current isolate is nullptr. #define CHECK_NO_ISOLATE(isolate) \ do { \ - if ((isolate) != NULL) { \ + if ((isolate) != nullptr) { \ FATAL( \ "%s expects there to be no current isolate. Did you " \ "forget to call Dart_ExitIsolate?", \ @@ -61,13 +61,13 @@ const char* CanonicalFunction(const char* func); } \ } while (0) -// Checks that the current isolate is not NULL and that it has an API scope. +// Checks that the current isolate is not nullptr and that it has an API scope. #define CHECK_API_SCOPE(thread) \ do { \ Thread* tmpT = (thread); \ - Isolate* tmpI = tmpT == NULL ? NULL : tmpT->isolate(); \ + Isolate* tmpI = tmpT == nullptr ? nullptr : tmpT->isolate(); \ CHECK_ISOLATE(tmpI); \ - if (tmpT->api_top_scope() == NULL) { \ + if (tmpT->api_top_scope() == nullptr) { \ FATAL( \ "%s expects to find a current scope. Did you forget to call " \ "Dart_EnterScope?", \ @@ -100,7 +100,7 @@ const char* CanonicalFunction(const char* func); CURRENT_FUNC, #parameter) #define CHECK_NULL(parameter) \ - if (parameter == NULL) { \ + if (parameter == nullptr) { \ RETURN_NULL_ERROR(parameter); \ } @@ -244,7 +244,7 @@ class Api : AllStatic { } static bool IsProtectedHandle(Dart_Handle object) { - if (object == NULL) return false; + if (object == nullptr) return false; return (object == true_handle_) || (object == false_handle_) || (object == null_handle_) || (object == empty_string_handle_) || (object == no_callbacks_error_handle_) || diff --git a/runtime/vm/dart_api_impl_test.cc b/runtime/vm/dart_api_impl_test.cc index 6df4c750e48..ec74ff94ec6 100644 --- a/runtime/vm/dart_api_impl_test.cc +++ b/runtime/vm/dart_api_impl_test.cc @@ -29,7 +29,7 @@ DECLARE_FLAG(bool, complete_timeline); #ifndef PRODUCT UNIT_TEST_CASE(DartAPI_DartInitializeAfterCleanup) { - EXPECT(Dart_SetVMFlags(TesterState::argc, TesterState::argv) == NULL); + EXPECT(Dart_SetVMFlags(TesterState::argc, TesterState::argv) == nullptr); Dart_InitializeParams params; memset(¶ms, 0, sizeof(Dart_InitializeParams)); params.version = DART_INITIALIZE_PARAMS_CURRENT_VERSION; @@ -40,26 +40,26 @@ UNIT_TEST_CASE(DartAPI_DartInitializeAfterCleanup) { params.start_kernel_isolate = true; // Reinitialize and ensure we can execute Dart code. - EXPECT(Dart_Initialize(¶ms) == NULL); + EXPECT(Dart_Initialize(¶ms) == nullptr); { TestIsolateScope scope; const char* kScriptChars = "int testMain() {\n" " return 42;\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, nullptr); EXPECT_VALID(lib); - Dart_Handle result = Dart_Invoke(lib, NewString("testMain"), 0, NULL); + Dart_Handle result = Dart_Invoke(lib, NewString("testMain"), 0, nullptr); EXPECT_VALID(result); int64_t value = 0; EXPECT_VALID(Dart_IntegerToInt64(result, &value)); EXPECT_EQ(42, value); } - EXPECT(Dart_Cleanup() == NULL); + EXPECT(Dart_Cleanup() == nullptr); } UNIT_TEST_CASE(DartAPI_DartInitializeCallsCodeObserver) { - EXPECT(Dart_SetVMFlags(TesterState::argc, TesterState::argv) == NULL); + EXPECT(Dart_SetVMFlags(TesterState::argc, TesterState::argv) == nullptr); Dart_InitializeParams params; memset(¶ms, 0, sizeof(Dart_InitializeParams)); params.version = DART_INITIALIZE_PARAMS_CURRENT_VERSION; @@ -79,14 +79,14 @@ UNIT_TEST_CASE(DartAPI_DartInitializeCallsCodeObserver) { params.code_observer = &code_observer; // Reinitialize and ensure we can execute Dart code. - EXPECT(Dart_Initialize(¶ms) == NULL); + EXPECT(Dart_Initialize(¶ms) == nullptr); // Wait for 5 seconds to let the kernel service load the snapshot, // which should trigger calls to the code observer. OS::Sleep(5); EXPECT(was_called); - EXPECT(Dart_Cleanup() == NULL); + EXPECT(Dart_Cleanup() == nullptr); } UNIT_TEST_CASE(DartAPI_DartInitializeHeapSizes) { @@ -102,16 +102,16 @@ UNIT_TEST_CASE(DartAPI_DartInitializeHeapSizes) { // Initialize with a normal heap size specification. const char* options_1[] = {"--old-gen-heap-size=3192", "--new-gen-semi-max-size=32"}; - EXPECT(Dart_SetVMFlags(2, options_1) == NULL); - EXPECT(Dart_Initialize(¶ms) == NULL); + EXPECT(Dart_SetVMFlags(2, options_1) == nullptr); + EXPECT(Dart_Initialize(¶ms) == nullptr); EXPECT(FLAG_old_gen_heap_size == 3192); EXPECT(FLAG_new_gen_semi_max_size == 32); - EXPECT(Dart_Cleanup() == NULL); + EXPECT(Dart_Cleanup() == nullptr); const char* options_2[] = {"--old-gen-heap-size=16384", "--new-gen-semi-max-size=16384"}; - EXPECT(Dart_SetVMFlags(2, options_2) == NULL); - EXPECT(Dart_Initialize(¶ms) == NULL); + EXPECT(Dart_SetVMFlags(2, options_2) == nullptr); + EXPECT(Dart_Initialize(¶ms) == nullptr); if (kMaxAddrSpaceMB == 4096) { EXPECT(FLAG_old_gen_heap_size == 0); EXPECT(FLAG_new_gen_semi_max_size == kDefaultNewGenSemiMaxSize); @@ -119,12 +119,12 @@ UNIT_TEST_CASE(DartAPI_DartInitializeHeapSizes) { EXPECT(FLAG_old_gen_heap_size == 16384); EXPECT(FLAG_new_gen_semi_max_size == 16384); } - EXPECT(Dart_Cleanup() == NULL); + EXPECT(Dart_Cleanup() == nullptr); const char* options_3[] = {"--old-gen-heap-size=30720", "--new-gen-semi-max-size=30720"}; - EXPECT(Dart_SetVMFlags(2, options_3) == NULL); - EXPECT(Dart_Initialize(¶ms) == NULL); + EXPECT(Dart_SetVMFlags(2, options_3) == nullptr); + EXPECT(Dart_Initialize(¶ms) == nullptr); if (kMaxAddrSpaceMB == 4096) { EXPECT(FLAG_old_gen_heap_size == 0); EXPECT(FLAG_new_gen_semi_max_size == kDefaultNewGenSemiMaxSize); @@ -132,7 +132,7 @@ UNIT_TEST_CASE(DartAPI_DartInitializeHeapSizes) { EXPECT(FLAG_old_gen_heap_size == 30720); EXPECT(FLAG_new_gen_semi_max_size == 30720); } - EXPECT(Dart_Cleanup() == NULL); + EXPECT(Dart_Cleanup() == nullptr); } TEST_CASE(Dart_KillIsolate) { @@ -140,16 +140,16 @@ TEST_CASE(Dart_KillIsolate) { "int testMain() {\n" " return 42;\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, nullptr); EXPECT_VALID(lib); - Dart_Handle result = Dart_Invoke(lib, NewString("testMain"), 0, NULL); + Dart_Handle result = Dart_Invoke(lib, NewString("testMain"), 0, nullptr); EXPECT_VALID(result); int64_t value = 0; EXPECT_VALID(Dart_IntegerToInt64(result, &value)); EXPECT_EQ(42, value); Dart_Isolate isolate = reinterpret_cast(Isolate::Current()); Dart_KillIsolate(isolate); - result = Dart_Invoke(lib, NewString("testMain"), 0, NULL); + result = Dart_Invoke(lib, NewString("testMain"), 0, nullptr); EXPECT(Dart_IsError(result)); EXPECT_STREQ("isolate terminated by Isolate.kill", Dart_GetError(result)); } @@ -164,14 +164,14 @@ class InfiniteLoopTask : public ThreadPool::Task { "testMain() {\n" " while(true) {};" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, nullptr); EXPECT_VALID(lib); *isolate_ = reinterpret_cast(Isolate::Current()); { MonitorLocker ml(monitor_); ml.Notify(); } - Dart_Handle result = Dart_Invoke(lib, NewString("testMain"), 0, NULL); + Dart_Handle result = Dart_Invoke(lib, NewString("testMain"), 0, nullptr); // Test should run an infinite loop and expect that to be killed. EXPECT(Dart_IsError(result)); EXPECT_STREQ("isolate terminated by Isolate.kill", Dart_GetError(result)); @@ -215,11 +215,11 @@ TEST_CASE(DartAPI_ErrorHandleBasics) { " throw new Exception(\"bad news\");\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, nullptr); Dart_Handle instance = Dart_True(); Dart_Handle error = Api::NewError("myerror"); - Dart_Handle exception = Dart_Invoke(lib, NewString("testMain"), 0, NULL); + Dart_Handle exception = Dart_Invoke(lib, NewString("testMain"), 0, nullptr); EXPECT_VALID(instance); EXPECT(Dart_IsError(error)); @@ -251,8 +251,8 @@ TEST_CASE(DartAPI_StackTraceInfo) { "foo() => bar();\n" "testMain() => foo();\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); - Dart_Handle error = Dart_Invoke(lib, NewString("testMain"), 0, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, nullptr); + Dart_Handle error = Dart_Invoke(lib, NewString("testMain"), 0, nullptr); EXPECT(Dart_IsError(error)); @@ -320,8 +320,8 @@ TEST_CASE(DartAPI_DeepStackTraceInfo) { "foo(n) => n == 1 ? throw new Error() : foo(n-1);\n" "testMain() => foo(100);\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); - Dart_Handle error = Dart_Invoke(lib, NewString("testMain"), 0, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, nullptr); + Dart_Handle error = Dart_Invoke(lib, NewString("testMain"), 0, nullptr); EXPECT(Dart_IsError(error)); @@ -398,8 +398,8 @@ void VerifyStackOverflowStackTraceInfo(const char* script, const char* entry_func_name, int expected_line_number, int expected_column_number) { - Dart_Handle lib = TestCase::LoadTestScript(script, NULL); - Dart_Handle error = Dart_Invoke(lib, NewString(entry_func_name), 0, NULL); + Dart_Handle lib = TestCase::LoadTestScript(script, nullptr); + Dart_Handle error = Dart_Invoke(lib, NewString(entry_func_name), 0, nullptr); EXPECT(Dart_IsError(error)); @@ -481,8 +481,8 @@ TEST_CASE(DartAPI_OutOfMemoryStackTraceInfo) { " new List(number_of_ints)\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); - Dart_Handle error = Dart_Invoke(lib, NewString("testMain"), 0, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, nullptr); + Dart_Handle error = Dart_Invoke(lib, NewString("testMain"), 0, nullptr); EXPECT(Dart_IsError(error)); @@ -583,7 +583,7 @@ static Dart_NativeFunction CurrentStackTraceNativeLookup( Dart_Handle name, int argument_count, bool* auto_setup_scope) { - ASSERT(auto_setup_scope != NULL); + ASSERT(auto_setup_scope != nullptr); *auto_setup_scope = true; return CurrentStackTraceNative; } @@ -598,7 +598,7 @@ testMain() => foo(100); Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, &CurrentStackTraceNativeLookup); - Dart_Handle result = Dart_Invoke(lib, NewString("testMain"), 0, NULL); + Dart_Handle result = Dart_Invoke(lib, NewString("testMain"), 0, nullptr); EXPECT_VALID(result); EXPECT(Dart_IsInteger(result)); int64_t value = 0; @@ -710,7 +710,7 @@ TEST_CASE(DartAPI_UnhandleExceptionError) { void JustPropagateErrorNative(Dart_NativeArguments args) { Dart_Handle closure = Dart_GetNativeArgument(args, 0); EXPECT(Dart_IsClosure(closure)); - Dart_Handle result = Dart_InvokeClosure(closure, 0, NULL); + Dart_Handle result = Dart_InvokeClosure(closure, 0, nullptr); EXPECT(Dart_IsError(result)); Dart_PropagateError(result); UNREACHABLE(); @@ -719,7 +719,7 @@ void JustPropagateErrorNative(Dart_NativeArguments args) { static Dart_NativeFunction JustPropagateError_lookup(Dart_Handle name, int argument_count, bool* auto_setup_scope) { - ASSERT(auto_setup_scope != NULL); + ASSERT(auto_setup_scope != nullptr); *auto_setup_scope = true; return JustPropagateErrorNative; } @@ -743,11 +743,11 @@ void Func1() { TestCase::LoadTestScript(kScriptChars, &JustPropagateError_lookup); Dart_Handle result; - result = Dart_Invoke(lib, NewString("Func1"), 0, NULL); + result = Dart_Invoke(lib, NewString("Func1"), 0, nullptr); EXPECT(Dart_IsError(result)); EXPECT_SUBSTRING("isolate terminated by Isolate.kill", Dart_GetError(result)); - result = Dart_Invoke(lib, NewString("Func1"), 0, NULL); + result = Dart_Invoke(lib, NewString("Func1"), 0, nullptr); EXPECT(Dart_IsError(result)); EXPECT_SUBSTRING("No api calls are allowed while unwind is in progress", Dart_GetError(result)); @@ -773,11 +773,11 @@ void Func1() { TestCase::LoadTestScript(kScriptChars, &JustPropagateError_lookup); Dart_Handle result; - result = Dart_Invoke(lib, NewString("Func1"), 0, NULL); + result = Dart_Invoke(lib, NewString("Func1"), 0, nullptr); EXPECT(Dart_IsError(result)); EXPECT_SUBSTRING("isolate terminated by Isolate.exit", Dart_GetError(result)); - result = Dart_Invoke(lib, NewString("Func1"), 0, NULL); + result = Dart_Invoke(lib, NewString("Func1"), 0, nullptr); EXPECT(Dart_IsError(result)); EXPECT_SUBSTRING("No api calls are allowed while unwind is in progress", Dart_GetError(result)); @@ -792,7 +792,7 @@ static bool use_throw_exception = false; void PropagateErrorNative(Dart_NativeArguments args) { Dart_Handle closure = Dart_GetNativeArgument(args, 0); EXPECT(Dart_IsClosure(closure)); - Dart_Handle result = Dart_InvokeClosure(closure, 0, NULL); + Dart_Handle result = Dart_InvokeClosure(closure, 0, nullptr); EXPECT(Dart_IsError(result)); if (use_set_return) { Dart_SetReturnValue(args, result); @@ -810,7 +810,7 @@ static Dart_NativeFunction PropagateError_native_lookup( Dart_Handle name, int argument_count, bool* auto_setup_scope) { - ASSERT(auto_setup_scope != NULL); + ASSERT(auto_setup_scope != nullptr); *auto_setup_scope = true; return PropagateErrorNative; } @@ -836,7 +836,7 @@ void Func1() { use_throw_exception = false; use_set_return = false; - result = Dart_Invoke(lib, NewString("Func1"), 0, NULL); + result = Dart_Invoke(lib, NewString("Func1"), 0, nullptr); EXPECT(Dart_IsError(result)); EXPECT_SUBSTRING("Expected ';' after this.", Dart_GetError(result)); @@ -845,7 +845,7 @@ void Func1() { use_throw_exception = false; use_set_return = true; - result = Dart_Invoke(lib, NewString("Func1"), 0, NULL); + result = Dart_Invoke(lib, NewString("Func1"), 0, nullptr); EXPECT(Dart_IsError(result)); EXPECT_SUBSTRING("Expected ';' after this.", Dart_GetError(result)); @@ -853,7 +853,7 @@ void Func1() { use_throw_exception = true; use_set_return = false; - result = Dart_Invoke(lib, NewString("Func1"), 0, NULL); + result = Dart_Invoke(lib, NewString("Func1"), 0, nullptr); EXPECT(Dart_IsError(result)); EXPECT_SUBSTRING("Expected ';' after this.", Dart_GetError(result)); } @@ -879,7 +879,7 @@ void Func2() { use_throw_exception = false; use_set_return = false; - result = Dart_Invoke(lib, NewString("Func2"), 0, NULL); + result = Dart_Invoke(lib, NewString("Func2"), 0, nullptr); EXPECT(Dart_IsError(result)); EXPECT(Dart_ErrorHasException(result)); EXPECT_SUBSTRING("myException", Dart_GetError(result)); @@ -888,7 +888,7 @@ void Func2() { use_throw_exception = false; use_set_return = true; - result = Dart_Invoke(lib, NewString("Func2"), 0, NULL); + result = Dart_Invoke(lib, NewString("Func2"), 0, nullptr); EXPECT(Dart_IsError(result)); EXPECT(Dart_ErrorHasException(result)); EXPECT_SUBSTRING("myException", Dart_GetError(result)); @@ -897,7 +897,7 @@ void Func2() { use_throw_exception = true; use_set_return = false; - result = Dart_Invoke(lib, NewString("Func2"), 0, NULL); + result = Dart_Invoke(lib, NewString("Func2"), 0, nullptr); EXPECT(Dart_IsError(result)); EXPECT(Dart_ErrorHasException(result)); EXPECT_SUBSTRING("myException", Dart_GetError(result)); @@ -1089,7 +1089,7 @@ TEST_CASE(DartAPI_InstanceGetType) { TEST_CASE(DartAPI_FunctionName) { const char* kScriptChars = "int getInt() { return 1; }\n"; // Create a test library and Load up a test script in it. - Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, nullptr); EXPECT_VALID(lib); Dart_Handle closure = Dart_GetField(lib, NewString("getInt")); @@ -1109,7 +1109,7 @@ TEST_CASE(DartAPI_FunctionName) { TEST_CASE(DartAPI_FunctionOwner) { const char* kScriptChars = "int getInt() { return 1; }\n"; // Create a test library and Load up a test script in it. - Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, nullptr); EXPECT_VALID(lib); Dart_Handle closure = Dart_GetField(lib, NewString("getInt")); @@ -1145,14 +1145,14 @@ TEST_CASE(DartAPI_IsTearOff) { " int bar() => 24;\n" "}\n" "Baz getBaz() => Baz();\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, nullptr); EXPECT_VALID(lib); // Check tear-off of top-level static method. Dart_Handle get_tear_off = Dart_GetField(lib, NewString("getTearOff")); EXPECT_VALID(get_tear_off); EXPECT(Dart_IsTearOff(get_tear_off)); - Dart_Handle tear_off = Dart_InvokeClosure(get_tear_off, 0, NULL); + Dart_Handle tear_off = Dart_InvokeClosure(get_tear_off, 0, nullptr); EXPECT_VALID(tear_off); EXPECT(Dart_IsTearOff(tear_off)); @@ -1181,9 +1181,9 @@ TEST_CASE(DartAPI_IsTearOff) { EXPECT(is_static); // Check tear-off for an instance method in a class. - Dart_Handle instance = Dart_Invoke(lib, NewString("getBaz"), 0, NULL); + Dart_Handle instance = Dart_Invoke(lib, NewString("getBaz"), 0, nullptr); EXPECT_VALID(instance); - closure = Dart_Invoke(instance, NewString("getTearOff"), 0, NULL); + closure = Dart_Invoke(instance, NewString("getTearOff"), 0, nullptr); EXPECT_VALID(closure); EXPECT(Dart_IsTearOff(closure)); } @@ -1193,7 +1193,7 @@ TEST_CASE(DartAPI_FunctionIsStatic) { "int getInt() { return 1; }\n" "class Foo { String getString() => 'foobar'; }\n"; // Create a test library and Load up a test script in it. - Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, nullptr); EXPECT_VALID(lib); Dart_Handle closure = Dart_GetField(lib, NewString("getInt")); @@ -1208,7 +1208,8 @@ TEST_CASE(DartAPI_FunctionIsStatic) { EXPECT_VALID(result); EXPECT(is_static); - Dart_Handle klass = Dart_GetNonNullableType(lib, NewString("Foo"), 0, NULL); + Dart_Handle klass = + Dart_GetNonNullableType(lib, NewString("Foo"), 0, nullptr); EXPECT_VALID(klass); Dart_Handle instance = Dart_Allocate(klass); @@ -1228,7 +1229,7 @@ TEST_CASE(DartAPI_FunctionIsStatic) { TEST_CASE(DartAPI_ClosureFunction) { const char* kScriptChars = "int getInt() { return 1; }\n"; // Create a test library and Load up a test script in it. - Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, nullptr); EXPECT_VALID(lib); Dart_Handle closure = Dart_GetField(lib, NewString("getInt")); @@ -1237,7 +1238,7 @@ TEST_CASE(DartAPI_ClosureFunction) { Dart_Handle closure_str = Dart_ToString(closure); const char* result = ""; Dart_StringToCString(closure_str, &result); - EXPECT(strstr(result, "getInt") != NULL); + EXPECT(strstr(result, "getInt") != nullptr); Dart_Handle function = Dart_ClosureFunction(closure); EXPECT_VALID(function); @@ -1258,7 +1259,7 @@ TEST_CASE(DartAPI_GetStaticMethodClosure) { " }\n" "}\n"; // Create a test library and Load up a test script in it. - Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, nullptr); EXPECT_VALID(lib); Dart_Handle foo_cls = Dart_GetClass(lib, NewString("Foo")); EXPECT_VALID(foo_cls); @@ -1303,12 +1304,12 @@ TEST_CASE(DartAPI_GetStaticMethodClosure) { TEST_CASE(DartAPI_ClassLibrary) { Dart_Handle lib = Dart_LookupLibrary(NewString("dart:core")); EXPECT_VALID(lib); - Dart_Handle type = Dart_GetNonNullableType(lib, NewString("int"), 0, NULL); + Dart_Handle type = Dart_GetNonNullableType(lib, NewString("int"), 0, nullptr); EXPECT_VALID(type); Dart_Handle result = Dart_ClassLibrary(type); EXPECT_VALID(result); Dart_Handle lib_url = Dart_LibraryUrl(result); - const char* str = NULL; + const char* str = nullptr; Dart_StringToCString(lib_url, &str); EXPECT_STREQ("dart:core", str); } @@ -1380,25 +1381,25 @@ TEST_CASE(DartAPI_NumberValues) { "getNull() { return null; }\n"; Dart_Handle result; // Create a test library and Load up a test script in it. - Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, nullptr); // Check int case. - result = Dart_Invoke(lib, NewString("getInt"), 0, NULL); + result = Dart_Invoke(lib, NewString("getInt"), 0, nullptr); EXPECT_VALID(result); EXPECT(Dart_IsNumber(result)); // Check double case. - result = Dart_Invoke(lib, NewString("getDouble"), 0, NULL); + result = Dart_Invoke(lib, NewString("getDouble"), 0, nullptr); EXPECT_VALID(result); EXPECT(Dart_IsNumber(result)); // Check bool case. - result = Dart_Invoke(lib, NewString("getBool"), 0, NULL); + result = Dart_Invoke(lib, NewString("getBool"), 0, nullptr); EXPECT_VALID(result); EXPECT(!Dart_IsNumber(result)); // Check null case. - result = Dart_Invoke(lib, NewString("getNull"), 0, NULL); + result = Dart_Invoke(lib, NewString("getNull"), 0, nullptr); EXPECT_VALID(result); EXPECT(!Dart_IsNumber(result)); } @@ -1472,7 +1473,7 @@ TEST_CASE(DartAPI_IntegerToHexCString) { for (size_t i = 0; i < kNumberOfIntTestCases; ++i) { Dart_Handle val = Dart_NewInteger(kIntTestCases[i].i); EXPECT_VALID(val); - const char* chars = NULL; + const char* chars = nullptr; Dart_Handle result = Dart_IntegerToHexCString(val, &chars); EXPECT_VALID(result); EXPECT_STREQ(kIntTestCases[i].s, chars); @@ -1597,7 +1598,6 @@ TEST_CASE(DartAPI_IsString) { Dart_Handle result = Dart_StringToLatin1(str8, latin1_array, &len); EXPECT_VALID(result); EXPECT_EQ(4, len); - EXPECT(latin1_array != NULL); for (intptr_t i = 0; i < len; i++) { EXPECT_EQ(data8[i], latin1_array[i]); } @@ -1648,7 +1648,7 @@ TEST_CASE(DartAPI_NewString) { EXPECT_VALID(ascii_str); EXPECT(Dart_IsString(ascii_str)); - const char* null = NULL; + const char* null = nullptr; Dart_Handle null_str = NewString(null); EXPECT(Dart_IsError(null_str)); @@ -1678,11 +1678,11 @@ TEST_CASE(DartAPI_MalformedStringToUTF8) { "}" "String reversed() => lowSurrogate() + highSurrogate();"; - Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); - Dart_Handle str1 = Dart_Invoke(lib, NewString("lowSurrogate"), 0, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, nullptr); + Dart_Handle str1 = Dart_Invoke(lib, NewString("lowSurrogate"), 0, nullptr); EXPECT_VALID(str1); - uint8_t* utf8_encoded = NULL; + uint8_t* utf8_encoded = nullptr; intptr_t utf8_length = 0; Dart_Handle result = Dart_StringToUTF8(str1, &utf8_encoded, &utf8_length); EXPECT_VALID(result); @@ -1695,9 +1695,9 @@ TEST_CASE(DartAPI_MalformedStringToUTF8) { Dart_Handle str2 = Dart_NewStringFromUTF8(utf8_encoded, utf8_length); EXPECT_VALID(str2); // Replacement character, but still valid - Dart_Handle reversed = Dart_Invoke(lib, NewString("reversed"), 0, NULL); + Dart_Handle reversed = Dart_Invoke(lib, NewString("reversed"), 0, nullptr); EXPECT_VALID(reversed); // This is also allowed. - uint8_t* utf8_encoded_reversed = NULL; + uint8_t* utf8_encoded_reversed = nullptr; intptr_t utf8_length_reversed = 0; result = Dart_StringToUTF8(reversed, &utf8_encoded_reversed, &utf8_length_reversed); @@ -1771,14 +1771,14 @@ TEST_CASE(DartAPI_ExternalStringPretenure) { kBig, // external size MallocFinalizer); static const uint8_t small_data8[] = {'f', 'o', 'o'}; - Dart_Handle small8 = - Dart_NewExternalLatin1String(small_data8, ARRAY_SIZE(small_data8), NULL, - sizeof(small_data8), NoopFinalizer); + Dart_Handle small8 = Dart_NewExternalLatin1String( + small_data8, ARRAY_SIZE(small_data8), nullptr, sizeof(small_data8), + NoopFinalizer); EXPECT_VALID(small8); static const uint16_t small_data16[] = {'b', 'a', 'r'}; - Dart_Handle small16 = - Dart_NewExternalUTF16String(small_data16, ARRAY_SIZE(small_data16), - NULL, sizeof(small_data16), NoopFinalizer); + Dart_Handle small16 = Dart_NewExternalUTF16String( + small_data16, ARRAY_SIZE(small_data16), nullptr, sizeof(small_data16), + NoopFinalizer); EXPECT_VALID(small16); { CHECK_API_SCOPE(thread); @@ -1843,10 +1843,10 @@ TEST_CASE(DartAPI_ListAccess) { Dart_Handle result; // Create a test library and Load up a test script in it. - Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, nullptr); // Invoke a function which returns an object of type List. - result = Dart_Invoke(lib, NewString("testMain"), 0, NULL); + result = Dart_Invoke(lib, NewString("testMain"), 0, nullptr); EXPECT_VALID(result); // First ensure that the returned object is an array. @@ -1941,7 +1941,7 @@ TEST_CASE(DartAPI_ListAccess) { EXPECT(Dart_IsError(result)); // Check if we can get a range of values. - result = Dart_ListGetRange(list_access_test_obj, 8, 4, NULL); + result = Dart_ListGetRange(list_access_test_obj, 8, 4, nullptr); EXPECT(Dart_IsError(result)); const int kRangeOffset = 1; const int kRangeLength = 2; @@ -1964,7 +1964,7 @@ TEST_CASE(DartAPI_ListAccess) { // Check that we get an exception (and not a fatal error) when // calling ListSetAt and ListSetAsBytes with an immutable list. - list_access_test_obj = Dart_Invoke(lib, NewString("immutable"), 0, NULL); + list_access_test_obj = Dart_Invoke(lib, NewString("immutable"), 0, nullptr); EXPECT_VALID(list_access_test_obj); EXPECT(Dart_IsList(list_access_test_obj)); @@ -1989,10 +1989,10 @@ TEST_CASE(DartAPI_MapAccess) { Dart_Handle result; // Create a test library and Load up a test script in it. - Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, nullptr); // Invoke a function which returns an object of type Map. - result = Dart_Invoke(lib, NewString("testMain"), 0, NULL); + result = Dart_Invoke(lib, NewString("testMain"), 0, nullptr); EXPECT_VALID(result); // First ensure that the returned object is a map. @@ -2078,10 +2078,10 @@ TEST_CASE(DartAPI_IsFuture) { Dart_Handle result; // Create a test library and Load up a test script in it. - Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, nullptr); // Invoke a function which returns an object of type Future. - result = Dart_Invoke(lib, NewString("testMain"), 0, NULL); + result = Dart_Invoke(lib, NewString("testMain"), 0, nullptr); EXPECT_VALID(result); EXPECT(Dart_IsFuture(result)); @@ -2105,7 +2105,7 @@ TEST_CASE(DartAPI_TypedDataViewListGetAsBytes) { " return view;\n" "}\n"; // Create a test library and Load up a test script in it. - Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, nullptr); // Test with a typed data view object. Dart_Handle dart_args[1]; @@ -2137,7 +2137,7 @@ TEST_CASE(DartAPI_TypedDataViewListIsTypedData) { " return view;\n" "}\n"; // Create a test library and Load up a test script in it. - Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, nullptr); // Create a typed data view object. Dart_Handle dart_args[1]; @@ -2160,7 +2160,7 @@ TEST_CASE(DartAPI_UnmodifiableTypedDataViewListIsTypedData) { " return view;\n" "}\n"; // Create a test library and Load up a test script in it. - Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, nullptr); // Create a typed data view object. Dart_Handle dart_args[1]; @@ -2302,7 +2302,7 @@ static void ByteDataNativeFunction(Dart_NativeArguments args) { static Dart_NativeFunction ByteDataNativeResolver(Dart_Handle name, int arg_count, bool* auto_setup_scope) { - ASSERT(auto_setup_scope != NULL); + ASSERT(auto_setup_scope != nullptr); *auto_setup_scope = true; return &ByteDataNativeFunction; } @@ -2333,14 +2333,14 @@ ByteData main() { } )"; // Create a test library and Load up a test script in it. - Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, nullptr); Dart_Handle result = - Dart_SetNativeResolver(lib, &ByteDataNativeResolver, NULL); + Dart_SetNativeResolver(lib, &ByteDataNativeResolver, nullptr); EXPECT_VALID(result); // Invoke 'main' function. - result = Dart_Invoke(lib, NewString("main"), 0, NULL); + result = Dart_Invoke(lib, NewString("main"), 0, nullptr); EXPECT_VALID(result); } @@ -2365,7 +2365,7 @@ static Dart_NativeFunction ExternalByteDataNativeResolver( Dart_Handle name, int arg_count, bool* auto_setup_scope) { - ASSERT(auto_setup_scope != NULL); + ASSERT(auto_setup_scope != nullptr); *auto_setup_scope = true; return &ExternalByteDataNativeFunction; } @@ -2402,14 +2402,14 @@ ByteData main() { } )"; // Create a test library and Load up a test script in it. - Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, nullptr); Dart_Handle result = - Dart_SetNativeResolver(lib, &ExternalByteDataNativeResolver, NULL); + Dart_SetNativeResolver(lib, &ExternalByteDataNativeResolver, nullptr); EXPECT_VALID(result); // Invoke 'main' function. - result = Dart_Invoke(lib, NewString("main"), 0, NULL); + result = Dart_Invoke(lib, NewString("main"), 0, nullptr); EXPECT_VALID(result); for (intptr_t i = 0; i < kExtLength; i += 2) { @@ -2437,7 +2437,7 @@ TEST_CASE(DartAPI_ExternalByteDataFinalizer) { " array = null;\n" "}\n"; // Create a test library and Load up a test script in it. - Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, nullptr); { Dart_EnterScope(); @@ -2470,7 +2470,7 @@ TEST_CASE(DartAPI_ExternalByteDataFinalizer) { EXPECT(!byte_data_finalizer_run); - Dart_Handle result = Dart_Invoke(lib, NewString("releaseArray"), 0, NULL); + Dart_Handle result = Dart_Invoke(lib, NewString("releaseArray"), 0, nullptr); EXPECT_VALID(result); { @@ -2504,7 +2504,7 @@ static Dart_NativeFunction OptExternalByteDataNativeResolver( Dart_Handle name, int arg_count, bool* auto_setup_scope) { - ASSERT(auto_setup_scope != NULL); + ASSERT(auto_setup_scope != nullptr); *auto_setup_scope = true; return &OptExternalByteDataNativeFunction; } @@ -2538,16 +2538,16 @@ ByteData main() { } )"; // Create a test library and Load up a test script in it. - Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, nullptr); Dart_Handle result = - Dart_SetNativeResolver(lib, &OptExternalByteDataNativeResolver, NULL); + Dart_SetNativeResolver(lib, &OptExternalByteDataNativeResolver, nullptr); EXPECT_VALID(result); // Invoke 'main' function. int old_oct = FLAG_optimization_counter_threshold; FLAG_optimization_counter_threshold = 5; - result = Dart_Invoke(lib, NewString("main"), 0, NULL); + result = Dart_Invoke(lib, NewString("main"), 0, nullptr); EXPECT_VALID(result); FLAG_optimization_counter_threshold = old_oct; } @@ -2559,17 +2559,17 @@ static void TestTypedDataDirectAccess() { Dart_Handle byte_array = Dart_NewTypedData(Dart_TypedData_kUint8, 10); EXPECT_VALID(byte_array); Dart_Handle result; - result = Dart_TypedDataAcquireData(byte_array, NULL, NULL, NULL); + result = Dart_TypedDataAcquireData(byte_array, nullptr, nullptr, nullptr); EXPECT_ERROR(result, "Dart_TypedDataAcquireData expects argument 'type'" " to be non-null."); Dart_TypedData_Type type; - result = Dart_TypedDataAcquireData(byte_array, &type, NULL, NULL); + result = Dart_TypedDataAcquireData(byte_array, &type, nullptr, nullptr); EXPECT_ERROR(result, "Dart_TypedDataAcquireData expects argument 'data'" " to be non-null."); void* data; - result = Dart_TypedDataAcquireData(byte_array, &type, &data, NULL); + result = Dart_TypedDataAcquireData(byte_array, &type, &data, nullptr); EXPECT_ERROR(result, "Dart_TypedDataAcquireData expects argument 'len'" " to be non-null."); @@ -2700,7 +2700,7 @@ static void TestTypedDataDirectAccess1() { " return a;" "}\n"; // Create a test library and Load up a test script in it. - Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, nullptr); Monitor monitor; bool done = false; @@ -2710,7 +2710,7 @@ static void TestTypedDataDirectAccess1() { for (intptr_t i = 0; i < 10; i++) { // Test with an regular typed data object. Dart_Handle list_access_test_obj; - list_access_test_obj = Dart_Invoke(lib, NewString("main"), 0, NULL); + list_access_test_obj = Dart_Invoke(lib, NewString("main"), 0, nullptr); EXPECT_VALID(list_access_test_obj); TestDirectAccess(lib, list_access_test_obj, Dart_TypedData_kInt8, false); @@ -2772,11 +2772,11 @@ static void TestTypedDataViewDirectAccess() { " return view;" "}\n"; // Create a test library and Load up a test script in it. - Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, nullptr); // Test with a typed data view object. Dart_Handle list_access_test_obj; - list_access_test_obj = Dart_Invoke(lib, NewString("main"), 0, NULL); + list_access_test_obj = Dart_Invoke(lib, NewString("main"), 0, nullptr); EXPECT_VALID(list_access_test_obj); TestDirectAccess(lib, list_access_test_obj, Dart_TypedData_kInt8, false); } @@ -2802,11 +2802,11 @@ static void TestUnmodifiableTypedDataViewDirectAccess() { " return new UnmodifiableInt8ListView(list);" "}\n"; // Create a test library and Load up a test script in it. - Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, nullptr); // Test with a typed data view object. Dart_Handle view_obj; - view_obj = Dart_Invoke(lib, NewString("main"), 0, NULL); + view_obj = Dart_Invoke(lib, NewString("main"), 0, nullptr); EXPECT_VALID(view_obj); const int kLength = 100; @@ -2873,11 +2873,11 @@ static void TestByteDataDirectAccess() { " return view;" "}\n"; // Create a test library and Load up a test script in it. - Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, nullptr); // Test with a typed data view object. Dart_Handle list_access_test_obj; - list_access_test_obj = Dart_Invoke(lib, NewString("main"), 0, NULL); + list_access_test_obj = Dart_Invoke(lib, NewString("main"), 0, nullptr); EXPECT_VALID(list_access_test_obj); TestDirectAccess(lib, list_access_test_obj, Dart_TypedData_kByteData, false); } @@ -2918,7 +2918,7 @@ testBytes(data) { Expect.throws(() => data.setUint8(i, 0)); } })"; - Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, nullptr); { uint8_t data[] = {0, 1, 2, 3}; @@ -3080,7 +3080,7 @@ test(original) { }; port.sendPort.send(original); })"; - Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, nullptr); uint8_t data[] = {0, 1, 2, 3}; Dart_Handle typed_data = Dart_NewUnmodifiableExternalTypedDataWithFinalizer( @@ -3111,7 +3111,7 @@ TEST_CASE(DartAPI_ExternalAllocationDuringNoCallbackScope) { EXPECT_VALID(result); Dart_WeakPersistentHandle weak = - Dart_NewWeakPersistentHandle(bytes, NULL, 100 * MB, NopCallback); + Dart_NewWeakPersistentHandle(bytes, nullptr, 100 * MB, NopCallback); EXPECT_VALID(reinterpret_cast(weak)); EXPECT_EQ(gc_count_before, @@ -3132,7 +3132,7 @@ static void ExternalTypedDataAccessTests(Dart_Handle obj, EXPECT_EQ(expected_type, Dart_GetTypeOfExternalTypedData(obj)); EXPECT(Dart_IsList(obj)); - void* raw_data = NULL; + void* raw_data = nullptr; intptr_t len; Dart_TypedData_Type type; EXPECT_VALID(Dart_TypedDataAcquireData(obj, &type, &raw_data, &len)); @@ -3219,7 +3219,7 @@ TEST_CASE(DartAPI_ExternalUint8ClampedArrayAccess) { EXPECT_VALID(obj); Dart_Handle result; // Create a test library and Load up a test script in it. - Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, nullptr); Dart_Handle args[1]; args[0] = obj; result = Dart_Invoke(lib, NewString("testClamped"), 1, args); @@ -3322,7 +3322,7 @@ TEST_CASE(DartAPI_SlowWeakPersistentHandle) { } static void CheckFloat32x4Data(Dart_Handle obj) { - void* raw_data = NULL; + void* raw_data = nullptr; intptr_t len; Dart_TypedData_Type type; EXPECT_VALID(Dart_TypedDataAcquireData(obj, &type, &raw_data, &len)); @@ -3342,9 +3342,9 @@ TEST_CASE(DartAPI_Float32x4List) { " return new Float32x4List(10);\n" "}\n"; // Create a test library and Load up a test script in it. - Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, nullptr); - Dart_Handle obj = Dart_Invoke(lib, NewString("float32x4"), 0, NULL); + Dart_Handle obj = Dart_Invoke(lib, NewString("float32x4"), 0, nullptr); EXPECT_VALID(obj); CheckFloat32x4Data(obj); @@ -3380,11 +3380,11 @@ VM_UNIT_TEST_CASE(DartAPI_EnterExitScope) { TestIsolateScope __test_isolate__; Thread* thread = Thread::Current(); - EXPECT(thread != NULL); + EXPECT(thread != nullptr); ApiLocalScope* scope = thread->api_top_scope(); Dart_EnterScope(); { - EXPECT(thread->api_top_scope() != NULL); + EXPECT(thread->api_top_scope() != nullptr); TransitionNativeToVM transition(thread); HANDLESCOPE(thread); String& str1 = String::Handle(); @@ -3405,9 +3405,9 @@ VM_UNIT_TEST_CASE(DartAPI_PersistentHandles) { TestCase::CreateTestIsolate(); Thread* thread = Thread::Current(); Isolate* isolate = thread->isolate(); - EXPECT(isolate != NULL); + EXPECT(isolate != nullptr); ApiState* state = isolate->group()->api_state(); - EXPECT(state != NULL); + EXPECT(state != nullptr); ApiLocalScope* scope = thread->api_top_scope(); const intptr_t handle_count_start = state->CountPersistentHandles(); @@ -3472,9 +3472,9 @@ VM_UNIT_TEST_CASE(DartAPI_NewPersistentHandle_FromPersistentHandle) { TestIsolateScope __test_isolate__; Isolate* isolate = Isolate::Current(); - EXPECT(isolate != NULL); + EXPECT(isolate != nullptr); ApiState* state = isolate->group()->api_state(); - EXPECT(state != NULL); + EXPECT(state != nullptr); Thread* thread = Thread::Current(); CHECK_API_SCOPE(thread); @@ -3505,9 +3505,9 @@ VM_UNIT_TEST_CASE(DartAPI_AssignToPersistentHandle) { Thread* T = Thread::Current(); CHECK_API_SCOPE(T); Isolate* isolate = T->isolate(); - EXPECT(isolate != NULL); + EXPECT(isolate != nullptr); ApiState* state = isolate->group()->api_state(); - EXPECT(state != NULL); + EXPECT(state != nullptr); // Start with a known persistent handle. Dart_Handle ref1 = Dart_NewStringFromCString(kTestString1); @@ -3800,24 +3800,24 @@ TEST_CASE(DartAPI_FinalizableHandle) { TEST_CASE(DartAPI_WeakPersistentHandleErrors) { Dart_EnterScope(); - // NULL callback. + // nullptr callback. Dart_Handle obj1 = NewString("new string"); EXPECT_VALID(obj1); Dart_WeakPersistentHandle ref1 = - Dart_NewWeakPersistentHandle(obj1, NULL, 0, NULL); - EXPECT_EQ(ref1, static_cast(NULL)); + Dart_NewWeakPersistentHandle(obj1, nullptr, 0, nullptr); + EXPECT_EQ(ref1, static_cast(nullptr)); // Immediate object. Dart_Handle obj2 = Dart_NewInteger(0); EXPECT_VALID(obj2); Dart_WeakPersistentHandle ref2 = - Dart_NewWeakPersistentHandle(obj2, NULL, 0, NopCallback); - EXPECT_EQ(ref2, static_cast(NULL)); + Dart_NewWeakPersistentHandle(obj2, nullptr, 0, NopCallback); + EXPECT_EQ(ref2, static_cast(nullptr)); // Pointer object. Dart_Handle ffi_lib = Dart_LookupLibrary(NewString("dart:ffi")); Dart_Handle pointer_type = - Dart_GetNonNullableType(ffi_lib, NewString("Pointer"), 0, NULL); + Dart_GetNonNullableType(ffi_lib, NewString("Pointer"), 0, nullptr); Dart_Handle obj3 = Dart_Allocate(pointer_type); EXPECT_VALID(obj3); Dart_WeakPersistentHandle ref3 = @@ -3836,10 +3836,10 @@ TEST_CASE(DartAPI_WeakPersistentHandleErrors) { external Pointer notEmpty; } )"; - Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, nullptr); Dart_Handle my_struct_type = - Dart_GetNonNullableType(lib, NewString("MyStruct"), 0, NULL); + Dart_GetNonNullableType(lib, NewString("MyStruct"), 0, nullptr); Dart_Handle obj4 = Dart_Allocate(my_struct_type); EXPECT_VALID(obj4); Dart_WeakPersistentHandle ref4 = @@ -3847,7 +3847,7 @@ TEST_CASE(DartAPI_WeakPersistentHandleErrors) { EXPECT_EQ(ref4, static_cast(nullptr)); Dart_Handle my_union_type = - Dart_GetNonNullableType(lib, NewString("MyUnion"), 0, NULL); + Dart_GetNonNullableType(lib, NewString("MyUnion"), 0, nullptr); Dart_Handle obj5 = Dart_Allocate(my_union_type); EXPECT_VALID(obj5); Dart_WeakPersistentHandle ref5 = @@ -3860,7 +3860,7 @@ TEST_CASE(DartAPI_WeakPersistentHandleErrors) { TEST_CASE(DartAPI_FinalizableHandleErrors) { Dart_EnterScope(); - // NULL callback. + // nullptr callback. Dart_Handle obj1 = NewString("new string"); EXPECT_VALID(obj1); Dart_FinalizableHandle ref1 = @@ -3877,7 +3877,7 @@ TEST_CASE(DartAPI_FinalizableHandleErrors) { // Pointer object. Dart_Handle ffi_lib = Dart_LookupLibrary(NewString("dart:ffi")); Dart_Handle pointer_type = - Dart_GetNonNullableType(ffi_lib, NewString("Pointer"), 0, NULL); + Dart_GetNonNullableType(ffi_lib, NewString("Pointer"), 0, nullptr); Dart_Handle obj3 = Dart_Allocate(pointer_type); EXPECT_VALID(obj3); Dart_FinalizableHandle ref3 = @@ -3896,10 +3896,10 @@ TEST_CASE(DartAPI_FinalizableHandleErrors) { external Pointer notEmpty; } )"; - Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, nullptr); Dart_Handle my_struct_type = - Dart_GetNonNullableType(lib, NewString("MyStruct"), 0, NULL); + Dart_GetNonNullableType(lib, NewString("MyStruct"), 0, nullptr); Dart_Handle obj4 = Dart_Allocate(my_struct_type); EXPECT_VALID(obj4); Dart_FinalizableHandle ref4 = @@ -3907,7 +3907,7 @@ TEST_CASE(DartAPI_FinalizableHandleErrors) { EXPECT_EQ(ref4, static_cast(nullptr)); Dart_Handle my_union_type = - Dart_GetNonNullableType(lib, NewString("MyUnion"), 0, NULL); + Dart_GetNonNullableType(lib, NewString("MyUnion"), 0, nullptr); Dart_Handle obj5 = Dart_Allocate(my_union_type); EXPECT_VALID(obj5); Dart_FinalizableHandle ref5 = @@ -4021,7 +4021,7 @@ static void WeakPersistentHandlePeerFinalizer(void* isolate_callback_data, } TEST_CASE(DartAPI_WeakPersistentHandleCallback) { - Dart_WeakPersistentHandle weak_ref = NULL; + Dart_WeakPersistentHandle weak_ref = nullptr; int peer = 0; { Dart_EnterScope(); @@ -4068,7 +4068,7 @@ TEST_CASE(DartAPI_FinalizableHandleCallback) { } TEST_CASE(DartAPI_WeakPersistentHandleNoCallback) { - Dart_WeakPersistentHandle weak_ref = NULL; + Dart_WeakPersistentHandle weak_ref = nullptr; int peer = 0; { Dart_EnterScope(); @@ -4187,26 +4187,26 @@ TEST_CASE(DartAPI_WeakPersistentHandleExternalAllocationSize) { Heap* heap = IsolateGroup::Current()->heap(); EXPECT(heap->ExternalInWords(Heap::kNew) == 0); EXPECT(heap->ExternalInWords(Heap::kOld) == 0); - Dart_WeakPersistentHandle weak1 = NULL; + Dart_WeakPersistentHandle weak1 = nullptr; static const intptr_t kWeak1ExternalSize = 1 * KB; { Dart_EnterScope(); Dart_Handle obj = NewString("weakly referenced string"); EXPECT_VALID(obj); - weak1 = Dart_NewWeakPersistentHandle(obj, NULL, kWeak1ExternalSize, + weak1 = Dart_NewWeakPersistentHandle(obj, nullptr, kWeak1ExternalSize, NopCallback); EXPECT_VALID(AsHandle(weak1)); Dart_ExitScope(); } - Dart_PersistentHandle strong_ref = NULL; - Dart_WeakPersistentHandle weak2 = NULL; + Dart_PersistentHandle strong_ref = nullptr; + Dart_WeakPersistentHandle weak2 = nullptr; static const intptr_t kWeak2ExternalSize = 2 * KB; { Dart_EnterScope(); Dart_Handle obj = NewString("strongly referenced string"); EXPECT_VALID(obj); strong_ref = Dart_NewPersistentHandle(obj); - weak2 = Dart_NewWeakPersistentHandle(obj, NULL, kWeak2ExternalSize, + weak2 = Dart_NewWeakPersistentHandle(obj, nullptr, kWeak2ExternalSize, NopCallback); EXPECT_VALID(AsHandle(strong_ref)); EXPECT_VALID(AsHandle(weak2)); @@ -4277,7 +4277,7 @@ TEST_CASE(DartAPI_FinalizableHandleExternalAllocationSize) { TEST_CASE(DartAPI_WeakPersistentHandleExternalAllocationSizeNewspaceGC) { Heap* heap = IsolateGroup::Current()->heap(); - Dart_WeakPersistentHandle weak1 = NULL; + Dart_WeakPersistentHandle weak1 = nullptr; // Large enough to exceed any new space limit. Not actually allocated. const intptr_t kWeak1ExternalSize = 500 * MB; { @@ -4285,14 +4285,14 @@ TEST_CASE(DartAPI_WeakPersistentHandleExternalAllocationSizeNewspaceGC) { Dart_Handle obj = NewString("weakly referenced string"); EXPECT_VALID(obj); // Triggers a scavenge immediately, since kWeak1ExternalSize is above limit. - weak1 = Dart_NewWeakPersistentHandle(obj, NULL, kWeak1ExternalSize, + weak1 = Dart_NewWeakPersistentHandle(obj, nullptr, kWeak1ExternalSize, NopCallback); EXPECT_VALID(AsHandle(weak1)); // ... but the object is still alive and not yet promoted, so external size // in new space is still above the limit. Thus, even the following tiny // external allocation will trigger another scavenge. Dart_WeakPersistentHandle trigger = - Dart_NewWeakPersistentHandle(obj, NULL, 1, NopCallback); + Dart_NewWeakPersistentHandle(obj, nullptr, 1, NopCallback); EXPECT_VALID(AsHandle(trigger)); Dart_DeleteWeakPersistentHandle(trigger); // After the two scavenges above, 'obj' should now be promoted, hence its @@ -4366,7 +4366,7 @@ TEST_CASE(DartAPI_WeakPersistentHandleExternalAllocationSizeOldspaceGC) { Dart_EnterScope(); Dart_Handle live = AllocateOldString("live"); EXPECT_VALID(live); - Dart_WeakPersistentHandle weak = NULL; + Dart_WeakPersistentHandle weak = nullptr; { TransitionNativeToVM transition(thread); GCTestHelper::WaitForGCTasks(); // Finalize GC for accurate live size. @@ -4377,7 +4377,7 @@ TEST_CASE(DartAPI_WeakPersistentHandleExternalAllocationSizeOldspaceGC) { Dart_EnterScope(); Dart_Handle dead = AllocateOldString("dead"); EXPECT_VALID(dead); - weak = Dart_NewWeakPersistentHandle(dead, NULL, kSmallExternalSize, + weak = Dart_NewWeakPersistentHandle(dead, nullptr, kSmallExternalSize, NopCallback); EXPECT_VALID(AsHandle(weak)); Dart_ExitScope(); @@ -4390,8 +4390,8 @@ TEST_CASE(DartAPI_WeakPersistentHandleExternalAllocationSizeOldspaceGC) { } // Large enough to trigger GC in old space. Not actually allocated. const intptr_t kHugeExternalSize = (kWordSize == 4) ? 513 * MB : 1025 * MB; - Dart_WeakPersistentHandle weak2 = - Dart_NewWeakPersistentHandle(live, NULL, kHugeExternalSize, NopCallback); + Dart_WeakPersistentHandle weak2 = Dart_NewWeakPersistentHandle( + live, nullptr, kHugeExternalSize, NopCallback); { TransitionNativeToVM transition(thread); GCTestHelper::WaitForGCTasks(); // Finalize GC for accurate live size. @@ -4442,21 +4442,21 @@ TEST_CASE(DartAPI_FinalizableHandleExternalAllocationSizeOldspaceGC) { TEST_CASE(DartAPI_WeakPersistentHandleExternalAllocationSizeOddReferents) { Heap* heap = IsolateGroup::Current()->heap(); - Dart_WeakPersistentHandle weak1 = NULL; + Dart_WeakPersistentHandle weak1 = nullptr; static const intptr_t kWeak1ExternalSize = 1 * KB; - Dart_WeakPersistentHandle weak2 = NULL; + Dart_WeakPersistentHandle weak2 = nullptr; static const intptr_t kWeak2ExternalSize = 2 * KB; EXPECT_EQ(0, heap->ExternalInWords(Heap::kOld)); { Dart_EnterScope(); Dart_Handle dart_true = Dart_True(); // VM heap object. EXPECT_VALID(dart_true); - weak1 = Dart_NewWeakPersistentHandle(dart_true, NULL, kWeak1ExternalSize, + weak1 = Dart_NewWeakPersistentHandle(dart_true, nullptr, kWeak1ExternalSize, UnreachedCallback); EXPECT_VALID(AsHandle(weak1)); Dart_Handle zero = Dart_False(); // VM heap object. EXPECT_VALID(zero); - weak2 = Dart_NewWeakPersistentHandle(zero, NULL, kWeak2ExternalSize, + weak2 = Dart_NewWeakPersistentHandle(zero, nullptr, kWeak2ExternalSize, UnreachedCallback); EXPECT_VALID(AsHandle(weak2)); // Both should be charged to old space. @@ -4629,7 +4629,7 @@ TEST_CASE(DartAPI_WeakPersistentHandleUpdateSize) { Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, ExampleResourceNativeResolver); - EXPECT_VALID(Dart_Invoke(lib, NewString("main"), 0, NULL)); + EXPECT_VALID(Dart_Invoke(lib, NewString("main"), 0, nullptr)); } void FUNCTION_NAME(SecretKeeper_KeepSecret)(Dart_NativeArguments native_args) { @@ -4716,24 +4716,24 @@ TEST_CASE(DartAPI_NativeFieldAccess_Throws) { EXPECT(Dart_IsUnhandledExceptionError(result)); } -static Dart_WeakPersistentHandle weak1 = NULL; -static Dart_WeakPersistentHandle weak2 = NULL; -static Dart_WeakPersistentHandle weak3 = NULL; +static Dart_WeakPersistentHandle weak1 = nullptr; +static Dart_WeakPersistentHandle weak2 = nullptr; +static Dart_WeakPersistentHandle weak3 = nullptr; static void ImplicitReferencesCallback(void* isolate_callback_data, void* peer) { if (peer == &weak1) { - weak1 = NULL; + weak1 = nullptr; } else if (peer == &weak2) { - weak2 = NULL; + weak2 = nullptr; } else if (peer == &weak3) { - weak3 = NULL; + weak3 = nullptr; } } TEST_CASE(DartAPI_ImplicitReferencesOldSpace) { - Dart_PersistentHandle strong = NULL; - Dart_WeakPersistentHandle strong_weak = NULL; + Dart_PersistentHandle strong = nullptr; + Dart_WeakPersistentHandle strong_weak = nullptr; Dart_EnterScope(); { @@ -4741,7 +4741,7 @@ TEST_CASE(DartAPI_ImplicitReferencesOldSpace) { Dart_Handle local = AllocateOldString("strongly reachable"); strong = Dart_NewPersistentHandle(local); - strong_weak = Dart_NewWeakPersistentHandle(local, NULL, 0, NopCallback); + strong_weak = Dart_NewWeakPersistentHandle(local, nullptr, 0, NopCallback); EXPECT(!Dart_IsNull(AsHandle(strong))); EXPECT_VALID(AsHandle(strong)); @@ -4800,8 +4800,8 @@ TEST_CASE(DartAPI_ImplicitReferencesOldSpace) { } TEST_CASE(DartAPI_ImplicitReferencesNewSpace) { - Dart_PersistentHandle strong = NULL; - Dart_WeakPersistentHandle strong_weak = NULL; + Dart_PersistentHandle strong = nullptr; + Dart_WeakPersistentHandle strong_weak = nullptr; Dart_EnterScope(); { @@ -4809,7 +4809,7 @@ TEST_CASE(DartAPI_ImplicitReferencesNewSpace) { Dart_Handle local = AllocateOldString("strongly reachable"); strong = Dart_NewPersistentHandle(local); - strong_weak = Dart_NewWeakPersistentHandle(local, NULL, 0, NopCallback); + strong_weak = Dart_NewWeakPersistentHandle(local, nullptr, 0, NopCallback); EXPECT(!Dart_IsNull(AsHandle(strong))); EXPECT_VALID(AsHandle(strong)); @@ -4873,7 +4873,7 @@ VM_UNIT_TEST_CASE(DartAPI_LocalHandles) { TestCase::CreateTestIsolate(); Thread* thread = Thread::Current(); Isolate* isolate = thread->isolate(); - EXPECT(isolate != NULL); + EXPECT(isolate != nullptr); ApiLocalScope* scope = thread->api_top_scope(); Dart_Handle handles[300]; { @@ -4944,7 +4944,7 @@ VM_UNIT_TEST_CASE(DartAPI_LocalHandles) { VM_UNIT_TEST_CASE(DartAPI_LocalZoneMemory) { TestCase::CreateTestIsolate(); Thread* thread = Thread::Current(); - EXPECT(thread != NULL); + EXPECT(thread != nullptr); ApiLocalScope* scope = thread->api_top_scope(); EXPECT_EQ(0, thread->ZoneSizeInBytes()); { @@ -5030,13 +5030,13 @@ VM_UNIT_TEST_CASE(DartAPI_CurrentIsolateData) { Dart_IsolateShutdownCallback saved_shutdown = Isolate::ShutdownCallback(); Dart_IsolateGroupCleanupCallback saved_cleanup = Isolate::GroupCleanupCallback(); - Isolate::SetShutdownCallback(NULL); - Isolate::SetGroupCleanupCallback(NULL); + Isolate::SetShutdownCallback(nullptr); + Isolate::SetGroupCleanupCallback(nullptr); intptr_t mydata = 12345; Dart_Isolate isolate = - TestCase::CreateTestIsolate(NULL, reinterpret_cast(mydata)); - EXPECT(isolate != NULL); + TestCase::CreateTestIsolate(nullptr, reinterpret_cast(mydata)); + EXPECT(isolate != nullptr); EXPECT_EQ(mydata, reinterpret_cast(Dart_CurrentIsolateGroupData())); EXPECT_EQ(mydata, reinterpret_cast(Dart_IsolateGroupData(isolate))); Dart_ShutdownIsolate(); @@ -5046,11 +5046,11 @@ VM_UNIT_TEST_CASE(DartAPI_CurrentIsolateData) { } static Dart_Handle LoadScript(const char* url_str, const char* source) { - const uint8_t* kernel_buffer = NULL; + const uint8_t* kernel_buffer = nullptr; intptr_t kernel_buffer_size = 0; char* error = TestCase::CompileTestScriptWithDFE( url_str, source, &kernel_buffer, &kernel_buffer_size); - if (error != NULL) { + if (error != nullptr) { return Dart_NewApiError(error); } TestCaseBase::AddToKernelBuffers(kernel_buffer); @@ -5066,7 +5066,7 @@ TEST_CASE(DartAPI_DebugName) { TEST_CASE(DartAPI_IsolateServiceID) { Dart_Isolate isolate = Dart_CurrentIsolate(); const char* id = Dart_IsolateServiceId(isolate); - EXPECT(id != NULL); + EXPECT(id != nullptr); int64_t main_port = Dart_GetMainPortId(); EXPECT_STREQ(ZONE_STR("isolates/%" Pd64, main_port), id); free(const_cast(id)); @@ -5084,8 +5084,8 @@ VM_UNIT_TEST_CASE(DartAPI_SetMessageCallbacks) { TEST_CASE(DartAPI_SetStickyError) { const char* kScriptChars = "main() => throw 'HI';"; - Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); - Dart_Handle retobj = Dart_Invoke(lib, NewString("main"), 0, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, nullptr); + Dart_Handle retobj = Dart_Invoke(lib, NewString("main"), 0, nullptr); EXPECT(Dart_IsError(retobj)); EXPECT(Dart_IsUnhandledExceptionError(retobj)); EXPECT(!Dart_HasStickyError()); @@ -5120,30 +5120,31 @@ TEST_CASE(DartAPI_TypeGetNonParametricTypes) { "Type getMyClass0Type() { return new MyClass0().runtimeType; }\n" "Type getMyClass1Type() { return new MyClass1().runtimeType; }\n" "Type getMyClass2Type() { return new MyClass2().runtimeType; }\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, nullptr); bool instanceOf = false; // First get the type objects of these non parameterized types. Dart_Handle type0 = - Dart_GetNonNullableType(lib, NewString("MyClass0"), 0, NULL); + Dart_GetNonNullableType(lib, NewString("MyClass0"), 0, nullptr); EXPECT_VALID(type0); Dart_Handle type1 = - Dart_GetNonNullableType(lib, NewString("MyClass1"), 0, NULL); + Dart_GetNonNullableType(lib, NewString("MyClass1"), 0, nullptr); EXPECT_VALID(type1); Dart_Handle type2 = - Dart_GetNonNullableType(lib, NewString("MyClass2"), 0, NULL); + Dart_GetNonNullableType(lib, NewString("MyClass2"), 0, nullptr); EXPECT_VALID(type2); Dart_Handle type3 = - Dart_GetNonNullableType(lib, NewString("MyInterface0"), 0, NULL); + Dart_GetNonNullableType(lib, NewString("MyInterface0"), 0, nullptr); EXPECT_VALID(type3); Dart_Handle type4 = - Dart_GetNonNullableType(lib, NewString("MyInterface1"), 0, NULL); + Dart_GetNonNullableType(lib, NewString("MyInterface1"), 0, nullptr); EXPECT_VALID(type4); // Now create objects of these non parameterized types and check // that the validity of the type of the created object. // MyClass0 type. - Dart_Handle type0_obj = Dart_Invoke(lib, NewString("getMyClass0"), 0, NULL); + Dart_Handle type0_obj = + Dart_Invoke(lib, NewString("getMyClass0"), 0, nullptr); EXPECT_VALID(type0_obj); EXPECT_VALID(Dart_ObjectIsType(type0_obj, type0, &instanceOf)); EXPECT(instanceOf); @@ -5155,12 +5156,13 @@ TEST_CASE(DartAPI_TypeGetNonParametricTypes) { EXPECT(!instanceOf); EXPECT_VALID(Dart_ObjectIsType(type0_obj, type4, &instanceOf)); EXPECT(!instanceOf); - type0_obj = Dart_Invoke(lib, NewString("getMyClass0Type"), 0, NULL); + type0_obj = Dart_Invoke(lib, NewString("getMyClass0Type"), 0, nullptr); EXPECT_VALID(type0_obj); EXPECT(Dart_IdentityEquals(type0, type0_obj)); // MyClass1 type. - Dart_Handle type1_obj = Dart_Invoke(lib, NewString("getMyClass1"), 0, NULL); + Dart_Handle type1_obj = + Dart_Invoke(lib, NewString("getMyClass1"), 0, nullptr); EXPECT_VALID(type1_obj); EXPECT_VALID(Dart_ObjectIsType(type1_obj, type1, &instanceOf)); EXPECT(instanceOf); @@ -5172,12 +5174,13 @@ TEST_CASE(DartAPI_TypeGetNonParametricTypes) { EXPECT(instanceOf); EXPECT_VALID(Dart_ObjectIsType(type1_obj, type4, &instanceOf)); EXPECT(instanceOf); - type1_obj = Dart_Invoke(lib, NewString("getMyClass1Type"), 0, NULL); + type1_obj = Dart_Invoke(lib, NewString("getMyClass1Type"), 0, nullptr); EXPECT_VALID(type1_obj); EXPECT(Dart_IdentityEquals(type1, type1_obj)); // MyClass2 type. - Dart_Handle type2_obj = Dart_Invoke(lib, NewString("getMyClass2"), 0, NULL); + Dart_Handle type2_obj = + Dart_Invoke(lib, NewString("getMyClass2"), 0, nullptr); EXPECT_VALID(type2_obj); EXPECT_VALID(Dart_ObjectIsType(type2_obj, type2, &instanceOf)); EXPECT(instanceOf); @@ -5189,7 +5192,7 @@ TEST_CASE(DartAPI_TypeGetNonParametricTypes) { EXPECT(instanceOf); EXPECT_VALID(Dart_ObjectIsType(type2_obj, type4, &instanceOf)); EXPECT(instanceOf); - type2_obj = Dart_Invoke(lib, NewString("getMyClass2Type"), 0, NULL); + type2_obj = Dart_Invoke(lib, NewString("getMyClass2Type"), 0, nullptr); EXPECT_VALID(type2_obj); EXPECT(Dart_IdentityEquals(type2, type2_obj)); } @@ -5234,16 +5237,16 @@ TEST_CASE(DartAPI_TypeGetParameterizedTypes) { Dart_Handle corelib = Dart_LookupLibrary(NewString("dart:core")); EXPECT_VALID(corelib); - Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, nullptr); // Now instantiate MyClass0 and MyClass1 types with the same type arguments // used in the code above. Dart_Handle type_args = Dart_NewList(2); - Dart_Handle int_type = Dart_Invoke(lib, NewString("getIntType"), 0, NULL); + Dart_Handle int_type = Dart_Invoke(lib, NewString("getIntType"), 0, nullptr); EXPECT_VALID(int_type); EXPECT_VALID(Dart_ListSetAt(type_args, 0, int_type)); Dart_Handle double_type = - Dart_Invoke(lib, NewString("getDoubleType"), 0, NULL); + Dart_Invoke(lib, NewString("getDoubleType"), 0, nullptr); EXPECT_VALID(double_type); EXPECT_VALID(Dart_ListSetAt(type_args, 1, double_type)); Dart_Handle myclass0_type = @@ -5254,10 +5257,11 @@ TEST_CASE(DartAPI_TypeGetParameterizedTypes) { type_args = Dart_NewList(2); Dart_Handle list_int_type = - Dart_Invoke(lib, NewString("getListIntType"), 0, NULL); + Dart_Invoke(lib, NewString("getListIntType"), 0, nullptr); EXPECT_VALID(list_int_type); EXPECT_VALID(Dart_ListSetAt(type_args, 0, list_int_type)); - Dart_Handle list_type = Dart_Invoke(lib, NewString("getListType"), 0, NULL); + Dart_Handle list_type = + Dart_Invoke(lib, NewString("getListType"), 0, nullptr); EXPECT_VALID(list_type); EXPECT_VALID(Dart_ListSetAt(type_args, 1, list_type)); Dart_Handle myclass1_type = @@ -5273,12 +5277,13 @@ TEST_CASE(DartAPI_TypeGetParameterizedTypes) { // type literals with non-literals which would fail in unsound null safety // mode. // MyClass0 type. - Dart_Handle type0_obj = Dart_Invoke(lib, NewString("getMyClass0"), 0, NULL); + Dart_Handle type0_obj = + Dart_Invoke(lib, NewString("getMyClass0"), 0, nullptr); EXPECT_VALID(type0_obj); bool instanceOf = false; EXPECT_VALID(Dart_ObjectIsType(type0_obj, myclass0_type, &instanceOf)); EXPECT(instanceOf); - type0_obj = Dart_Invoke(lib, NewString("getMyClass0Type"), 0, NULL); + type0_obj = Dart_Invoke(lib, NewString("getMyClass0Type"), 0, nullptr); EXPECT_VALID(type0_obj); bool equal = false; @@ -5286,32 +5291,33 @@ TEST_CASE(DartAPI_TypeGetParameterizedTypes) { EXPECT(equal); // MyClass1, List> type. - Dart_Handle type1_obj = Dart_Invoke(lib, NewString("getMyClass1"), 0, NULL); + Dart_Handle type1_obj = + Dart_Invoke(lib, NewString("getMyClass1"), 0, nullptr); EXPECT_VALID(type1_obj); EXPECT_VALID(Dart_ObjectIsType(type1_obj, myclass1_type, &instanceOf)); EXPECT(instanceOf); - type1_obj = Dart_Invoke(lib, NewString("getMyClass1Type"), 0, NULL); + type1_obj = Dart_Invoke(lib, NewString("getMyClass1Type"), 0, nullptr); EXPECT_VALID(type1_obj); EXPECT_VALID(Dart_ObjectEquals(type1_obj, myclass1_type, &equal)); EXPECT(equal); // MyClass0 type. - type0_obj = Dart_Invoke(lib, NewString("getMyClass0_1"), 0, NULL); + type0_obj = Dart_Invoke(lib, NewString("getMyClass0_1"), 0, nullptr); EXPECT_VALID(type0_obj); EXPECT_VALID(Dart_ObjectIsType(type0_obj, myclass0_type, &instanceOf)); EXPECT(!instanceOf); - type0_obj = Dart_Invoke(lib, NewString("getMyClass0_1Type"), 0, NULL); + type0_obj = Dart_Invoke(lib, NewString("getMyClass0_1Type"), 0, nullptr); EXPECT_VALID(type0_obj); EXPECT_VALID(Dart_ObjectEquals(type0_obj, myclass0_type, &equal)); EXPECT(!equal); // MyClass1, List> type. - type1_obj = Dart_Invoke(lib, NewString("getMyClass1_1"), 0, NULL); + type1_obj = Dart_Invoke(lib, NewString("getMyClass1_1"), 0, nullptr); EXPECT_VALID(type1_obj); EXPECT_VALID(Dart_ObjectIsType(type1_obj, myclass1_type, &instanceOf)); EXPECT(instanceOf); - type1_obj = Dart_Invoke(lib, NewString("getMyClass1_1Type"), 0, NULL); + type1_obj = Dart_Invoke(lib, NewString("getMyClass1_1Type"), 0, nullptr); EXPECT_VALID(type1_obj); EXPECT_VALID(Dart_ObjectEquals(type1_obj, myclass1_type, &equal)); EXPECT(!equal); @@ -5446,10 +5452,11 @@ TEST_CASE(DartAPI_FieldAccess) { "}\n"; // Shared setup. - Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); - Dart_Handle type = Dart_GetNonNullableType(lib, NewString("Fields"), 0, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, nullptr); + Dart_Handle type = + Dart_GetNonNullableType(lib, NewString("Fields"), 0, nullptr); EXPECT_VALID(type); - Dart_Handle instance = Dart_Invoke(lib, NewString("test"), 0, NULL); + Dart_Handle instance = Dart_Invoke(lib, NewString("test"), 0, nullptr); EXPECT_VALID(instance); Dart_Handle name; @@ -5459,7 +5466,7 @@ TEST_CASE(DartAPI_FieldAccess) { EXPECT_VALID(imported_lib); Dart_Handle result = Dart_FinalizeLoading(false); EXPECT_VALID(result); - result = Dart_Invoke(imported_lib, NewString("test2"), 0, NULL); + result = Dart_Invoke(imported_lib, NewString("test2"), 0, nullptr); EXPECT_VALID(result); // Instance field. @@ -5610,7 +5617,7 @@ TEST_CASE(DartAPI_FieldAccess) { TEST_CASE(DartAPI_SetField_FunnyValue) { const char* kScriptChars = "var top;\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, nullptr); Dart_Handle name = NewString("top"); bool value; @@ -5642,7 +5649,7 @@ TEST_CASE(DartAPI_SetField_FunnyValue) { TEST_CASE(DartAPI_SetField_BadType) { const char* kScriptChars = TestCase::IsNNBD() ? "late int foo;\n" : "int foo;\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, nullptr); Dart_Handle name = NewString("foo"); Dart_Handle result = Dart_SetField(lib, name, Dart_True()); EXPECT(Dart_IsError(result)); @@ -5657,7 +5664,7 @@ void NativeFieldLookup(Dart_NativeArguments args) { static Dart_NativeFunction native_field_lookup(Dart_Handle name, int argument_count, bool* auto_setup_scope) { - ASSERT(auto_setup_scope != NULL); + ASSERT(auto_setup_scope != nullptr); *auto_setup_scope = false; return NativeFieldLookup; } @@ -5682,11 +5689,11 @@ TEST_CASE(DartAPI_InjectNativeFields2) { Dart_Handle result; // Create a test library and Load up a test script in it. - Dart_Handle lib = - TestCase::LoadTestScript(kScriptChars.get(), NULL, USER_TEST_URI, false); + Dart_Handle lib = TestCase::LoadTestScript(kScriptChars.get(), nullptr, + USER_TEST_URI, false); // Invoke a function which returns an object of type NativeFields. - result = Dart_Invoke(lib, NewString("testMain"), 0, NULL); + result = Dart_Invoke(lib, NewString("testMain"), 0, nullptr); // We expect this to fail as class "NativeFields" extends // "NativeFieldsWrapper" and there is no definition of it either @@ -5721,7 +5728,7 @@ TEST_CASE(DartAPI_InjectNativeFields3) { TestCase::LoadTestScript(kScriptChars.get(), native_field_lookup); // Invoke a function which returns an object of type NativeFields. - result = Dart_Invoke(lib, NewString("testMain"), 0, NULL); + result = Dart_Invoke(lib, NewString("testMain"), 0, nullptr); EXPECT_VALID(result); CHECK_API_SCOPE(thread); TransitionNativeToVM transition(thread); @@ -5761,10 +5768,10 @@ TEST_CASE(DartAPI_InjectNativeFields4) { // clang-format on Dart_Handle result; // Load up a test script in the test library. - Dart_Handle lib = TestCase::LoadTestScript(kScriptChars.get(), NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScriptChars.get(), nullptr); // Invoke a function which returns an object of type NativeFields. - result = Dart_Invoke(lib, NewString("testMain"), 0, NULL); + result = Dart_Invoke(lib, NewString("testMain"), 0, nullptr); USE(result); #if 0 @@ -5816,15 +5823,15 @@ void TestNativeFieldsAccess_invalidAccess(Dart_NativeArguments args) { static Dart_NativeFunction TestNativeFieldsAccess_lookup(Dart_Handle name, int argument_count, bool* auto_scope) { - ASSERT(auto_scope != NULL); + ASSERT(auto_scope != nullptr); *auto_scope = true; TransitionNativeToVM transition(Thread::Current()); const Object& obj = Object::Handle(Api::UnwrapHandle(name)); if (!obj.IsString()) { - return NULL; + return nullptr; } const char* function_name = obj.ToCString(); - ASSERT(function_name != NULL); + ASSERT(function_name != nullptr); if (strcmp(function_name, "TestNativeFieldsAccess_init") == 0) { return TestNativeFieldsAccess_init; } else if (strcmp(function_name, "TestNativeFieldsAccess_access") == 0) { @@ -5833,7 +5840,7 @@ static Dart_NativeFunction TestNativeFieldsAccess_lookup(Dart_Handle name, 0) { return TestNativeFieldsAccess_invalidAccess; } else { - return NULL; + return nullptr; } } @@ -5877,7 +5884,7 @@ TEST_CASE(DartAPI_TestNativeFieldsAccess) { TestNativeFieldsAccess_lookup); // Invoke a function which returns an object of type NativeFields. - Dart_Handle result = Dart_Invoke(lib, NewString("testMain"), 0, NULL); + Dart_Handle result = Dart_Invoke(lib, NewString("testMain"), 0, nullptr); EXPECT_VALID(result); } @@ -5900,7 +5907,7 @@ TEST_CASE(DartAPI_InjectNativeFieldsSuperClass) { Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, native_field_lookup); // Invoke a function which returns an object of type NativeFields. - result = Dart_Invoke(lib, NewString("testMain"), 0, NULL); + result = Dart_Invoke(lib, NewString("testMain"), 0, nullptr); EXPECT_VALID(result); EXPECT(Dart_IsInteger(result)); @@ -6012,7 +6019,7 @@ TEST_CASE(DartAPI_ImplicitNativeFieldAccess) { TestCase::LoadTestScript(kScriptChars.get(), native_field_lookup); // Invoke a function which returns an object of type NativeFields. - Dart_Handle retobj = Dart_Invoke(lib, NewString("testMain"), 0, NULL); + Dart_Handle retobj = Dart_Invoke(lib, NewString("testMain"), 0, nullptr); EXPECT_VALID(retobj); // Now access and set various instance fields of the returned object. @@ -6046,10 +6053,10 @@ TEST_CASE(DartAPI_NegativeNativeFieldAccess) { CHECK_API_SCOPE(thread); // Create a test library and Load up a test script in it. - Dart_Handle lib = TestCase::LoadTestScript(kScriptChars.get(), NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScriptChars.get(), nullptr); // Invoke a function which returns an object of type NativeFields. - Dart_Handle retobj = Dart_Invoke(lib, NewString("testMain1"), 0, NULL); + Dart_Handle retobj = Dart_Invoke(lib, NewString("testMain1"), 0, nullptr); EXPECT_VALID(retobj); // Now access and set various native instance fields of the returned object. @@ -6077,7 +6084,7 @@ TEST_CASE(DartAPI_NegativeNativeFieldAccess) { EXPECT(Dart_IsError(result)); // Invoke a function which returns a closure object. - retobj = Dart_Invoke(lib, NewString("testMain2"), 0, NULL); + retobj = Dart_Invoke(lib, NewString("testMain2"), 0, nullptr); EXPECT_VALID(retobj); result = Dart_GetNativeInstanceField(retobj, kNativeFld4, &value); @@ -6106,13 +6113,13 @@ TEST_CASE(DartAPI_GetStaticField_RunsInitializer) { "}\n"; Dart_Handle result; // Create a test library and Load up a test script in it. - Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, nullptr); Dart_Handle type = - Dart_GetNonNullableType(lib, NewString("TestClass"), 0, NULL); + Dart_GetNonNullableType(lib, NewString("TestClass"), 0, nullptr); EXPECT_VALID(type); // Invoke a function which returns an object. - result = Dart_Invoke(type, NewString("testMain"), 0, NULL); + result = Dart_Invoke(type, NewString("testMain"), 0, nullptr); EXPECT_VALID(result); // For uninitialized fields, the getter is returned @@ -6149,9 +6156,9 @@ TEST_CASE(DartAPI_GetField_CheckIsolate) { int64_t value = 0; // Create a test library and Load up a test script in it. - Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, nullptr); Dart_Handle type = - Dart_GetNonNullableType(lib, NewString("TestClass"), 0, NULL); + Dart_GetNonNullableType(lib, NewString("TestClass"), 0, nullptr); EXPECT_VALID(type); result = Dart_GetField(type, NewString("fld2")); @@ -6171,9 +6178,9 @@ TEST_CASE(DartAPI_SetField_CheckIsolate) { int64_t value = 0; // Create a test library and Load up a test script in it. - Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, nullptr); Dart_Handle type = - Dart_GetNonNullableType(lib, NewString("TestClass"), 0, NULL); + Dart_GetNonNullableType(lib, NewString("TestClass"), 0, nullptr); EXPECT_VALID(type); result = Dart_SetField(type, NewString("fld2"), Dart_NewInteger(13)); @@ -6216,15 +6223,15 @@ TEST_CASE(DartAPI_New) { "}\n" "\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, nullptr); Dart_Handle type = - Dart_GetNonNullableType(lib, NewString("MyClass"), 0, NULL); + Dart_GetNonNullableType(lib, NewString("MyClass"), 0, nullptr); EXPECT_VALID(type); Dart_Handle intf = - Dart_GetNonNullableType(lib, NewString("MyInterface"), 0, NULL); + Dart_GetNonNullableType(lib, NewString("MyInterface"), 0, nullptr); EXPECT_VALID(intf); Dart_Handle private_type = - Dart_GetNonNullableType(lib, NewString("_MyClass"), 0, NULL); + Dart_GetNonNullableType(lib, NewString("_MyClass"), 0, nullptr); EXPECT_VALID(private_type); Dart_Handle args[1]; @@ -6233,7 +6240,7 @@ TEST_CASE(DartAPI_New) { bad_args[0] = Dart_NewApiError("myerror"); // Allocate and Invoke the unnamed constructor passing in Dart_Null. - Dart_Handle result = Dart_New(type, Dart_Null(), 0, NULL); + Dart_Handle result = Dart_New(type, Dart_Null(), 0, nullptr); EXPECT_VALID(result); bool instanceOf = false; EXPECT_VALID(Dart_ObjectIsType(result, type, &instanceOf)); @@ -6253,7 +6260,7 @@ TEST_CASE(DartAPI_New) { EXPECT(Dart_IsNull(foo)); // Allocate and Invoke the unnamed constructor passing in an empty string. - result = Dart_New(type, Dart_EmptyString(), 0, NULL); + result = Dart_New(type, Dart_EmptyString(), 0, nullptr); EXPECT_VALID(result); instanceOf = false; EXPECT_VALID(Dart_ObjectIsType(result, type, &instanceOf)); @@ -6270,14 +6277,14 @@ TEST_CASE(DartAPI_New) { EXPECT_VALID(Dart_ObjectIsType(obj, type, &instanceOf)); EXPECT(instanceOf); // Use the empty string to invoke the unnamed constructor. - result = Dart_InvokeConstructor(obj, Dart_EmptyString(), 0, NULL); + result = Dart_InvokeConstructor(obj, Dart_EmptyString(), 0, nullptr); EXPECT_VALID(result); int_value = 0; foo = Dart_GetField(result, NewString("foo")); EXPECT_VALID(Dart_IntegerToInt64(foo, &int_value)); EXPECT_EQ(7, int_value); // use Dart_Null to invoke the unnamed constructor. - result = Dart_InvokeConstructor(obj, Dart_Null(), 0, NULL); + result = Dart_InvokeConstructor(obj, Dart_Null(), 0, nullptr); EXPECT_VALID(result); int_value = 0; foo = Dart_GetField(result, NewString("foo")); @@ -6318,7 +6325,7 @@ TEST_CASE(DartAPI_New) { EXPECT_EQ(-11, int_value); // Invoke a hidden named constructor on a hidden type. - result = Dart_New(private_type, NewString("_"), 0, NULL); + result = Dart_New(private_type, NewString("_"), 0, nullptr); EXPECT_VALID(result); int_value = 0; foo = Dart_GetField(result, NewString("foo")); @@ -6372,7 +6379,7 @@ TEST_CASE(DartAPI_New) { "Dart_New expects argument 'number_of_arguments' to be non-negative."); // Pass the wrong arg count. - result = Dart_New(type, NewString("named"), 0, NULL); + result = Dart_New(type, NewString("named"), 0, nullptr); EXPECT_ERROR( result, "Dart_New: wrong argument count for constructor 'MyClass.named': " @@ -6398,7 +6405,7 @@ TEST_CASE(DartAPI_New) { EXPECT_ERROR(result, "ConstructorDeath"); // Invoke a constructor that is missing in the interface. - result = Dart_New(intf, Dart_Null(), 0, NULL); + result = Dart_New(intf, Dart_Null(), 0, nullptr); EXPECT_ERROR(result, "Dart_New: could not find constructor 'MyInterface.'."); // Invoke abstract constructor that is present in the interface. @@ -6436,12 +6443,12 @@ TEST_CASE(DartAPI_New_Issue42939) { "}\n" "\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, nullptr); Dart_Handle type = - Dart_GetNonNullableType(lib, NewString("MyClass"), 0, NULL); + Dart_GetNonNullableType(lib, NewString("MyClass"), 0, nullptr); EXPECT_VALID(type); Dart_Handle intf = - Dart_GetNonNullableType(lib, NewString("MyInterface"), 0, NULL); + Dart_GetNonNullableType(lib, NewString("MyInterface"), 0, nullptr); EXPECT_VALID(intf); Dart_Handle args[1]; @@ -6489,10 +6496,10 @@ TEST_CASE(DartAPI_New_Issue44205) { "Type getIntType() { return int; }\n" "\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, nullptr); EXPECT_VALID(lib); Dart_Handle int_wrapper_type = - Dart_GetNonNullableType(lib, NewString("MyIntClass"), 0, NULL); + Dart_GetNonNullableType(lib, NewString("MyIntClass"), 0, nullptr); EXPECT_VALID(int_wrapper_type); Dart_Handle args[1]; @@ -6535,10 +6542,10 @@ TEST_CASE(DartAPI_InvokeConstructor_Issue44205) { "Type getIntType() { return int; }\n" "\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, nullptr); EXPECT_VALID(lib); Dart_Handle int_wrapper_type = - Dart_GetNonNullableType(lib, NewString("MyIntClass"), 0, NULL); + Dart_GetNonNullableType(lib, NewString("MyIntClass"), 0, nullptr); EXPECT_VALID(int_wrapper_type); Dart_Handle args[1]; @@ -6584,11 +6591,11 @@ TEST_CASE(DartAPI_InvokeClosure_Issue44205) { CHECK_API_SCOPE(thread); // Create a test library and Load up a test script in it. - Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, nullptr); EXPECT_VALID(lib); // Invoke a function which returns a closure. - Dart_Handle retobj = Dart_Invoke(lib, NewString("testMain1"), 0, NULL); + Dart_Handle retobj = Dart_Invoke(lib, NewString("testMain1"), 0, nullptr); EXPECT_VALID(retobj); // Now invoke the closure and check the result. @@ -6603,7 +6610,7 @@ TEST_CASE(DartAPI_NewListOf) { "String expectListOfString(List o) => '${o.first}';\n" "String expectListOfDynamic(List o) => '${o.first}';\n" "String expectListOfInt(List o) => '${o.first}';\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, nullptr); const int kNumArgs = 1; Dart_Handle args[kNumArgs]; @@ -6657,13 +6664,13 @@ TEST_CASE(DartAPI_NewListOfType) { "void expectListOfDynamic(List _) {}\n" "void expectListOfVoid(List _) {}\n" "void expectListOfNever(List _) {}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, nullptr); Dart_Handle zxhandle_type = - Dart_GetNullableType(lib, NewString("ZXHandle"), 0, NULL); + Dart_GetNullableType(lib, NewString("ZXHandle"), 0, nullptr); EXPECT_VALID(zxhandle_type); - Dart_Handle zxhandle = Dart_New(zxhandle_type, Dart_Null(), 0, NULL); + Dart_Handle zxhandle = Dart_New(zxhandle_type, Dart_Null(), 0, nullptr); EXPECT_VALID(zxhandle); Dart_Handle zxhandle_list = Dart_NewListOfType(zxhandle_type, 1); @@ -6672,7 +6679,7 @@ TEST_CASE(DartAPI_NewListOfType) { EXPECT_VALID(Dart_ListSetAt(zxhandle_list, 0, zxhandle)); Dart_Handle readresult_type = - Dart_GetNonNullableType(lib, NewString("ChannelReadResult"), 0, NULL); + Dart_GetNonNullableType(lib, NewString("ChannelReadResult"), 0, nullptr); EXPECT_VALID(zxhandle_type); const int kNumArgs = 1; @@ -6691,7 +6698,7 @@ TEST_CASE(DartAPI_NewListOfType) { EXPECT_VALID(dart_core); Dart_Handle string_type = - Dart_GetNonNullableType(dart_core, NewString("String"), 0, NULL); + Dart_GetNonNullableType(dart_core, NewString("String"), 0, nullptr); EXPECT_VALID(string_type); Dart_Handle string_list = Dart_NewListOfType(string_type, 0); EXPECT_VALID(string_list); @@ -6730,20 +6737,20 @@ TEST_CASE(DartAPI_NewListOfTypeFilled) { " final List handles;\n" " ChannelReadResult(this.handles);\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, nullptr); Dart_Handle zxhandle_type = - Dart_GetNonNullableType(lib, NewString("ZXHandle"), 0, NULL); + Dart_GetNonNullableType(lib, NewString("ZXHandle"), 0, nullptr); EXPECT_VALID(zxhandle_type); Dart_Handle nullable_zxhandle_type = - Dart_GetNullableType(lib, NewString("ZXHandle"), 0, NULL); + Dart_GetNullableType(lib, NewString("ZXHandle"), 0, nullptr); EXPECT_VALID(nullable_zxhandle_type); Dart_Handle integer = Dart_NewInteger(42); EXPECT_VALID(integer); - Dart_Handle zxhandle = Dart_New(zxhandle_type, Dart_Null(), 0, NULL); + Dart_Handle zxhandle = Dart_New(zxhandle_type, Dart_Null(), 0, nullptr); EXPECT_VALID(zxhandle); Dart_Handle zxhandle_list = @@ -6756,7 +6763,7 @@ TEST_CASE(DartAPI_NewListOfTypeFilled) { EXPECT(Dart_IdentityEquals(result, zxhandle)); Dart_Handle readresult_type = - Dart_GetNonNullableType(lib, NewString("ChannelReadResult"), 0, NULL); + Dart_GetNonNullableType(lib, NewString("ChannelReadResult"), 0, nullptr); EXPECT_VALID(zxhandle_type); const int kNumArgs = 1; @@ -6789,7 +6796,7 @@ TEST_CASE(DartAPI_NewListOfTypeFilled) { Dart_Handle corelib = Dart_LookupLibrary(NewString("dart:core")); EXPECT_VALID(corelib); Dart_Handle string_type = - Dart_GetNonNullableType(corelib, NewString("String"), 0, NULL); + Dart_GetNonNullableType(corelib, NewString("String"), 0, nullptr); EXPECT_VALID(Dart_NewListOfTypeFilled(string_type, Dart_EmptyString(), 2)); } @@ -6824,11 +6831,11 @@ TEST_CASE(DartAPI_Invoke) { "}\n"; // Shared setup. - Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, nullptr); Dart_Handle type = - Dart_GetNonNullableType(lib, NewString("Methods"), 0, NULL); + Dart_GetNonNullableType(lib, NewString("Methods"), 0, nullptr); EXPECT_VALID(type); - Dart_Handle instance = Dart_Invoke(lib, NewString("test"), 0, NULL); + Dart_Handle instance = Dart_Invoke(lib, NewString("test"), 0, nullptr); EXPECT_VALID(instance); Dart_Handle args[1]; args[0] = NewString("!!!"); @@ -6931,9 +6938,9 @@ TEST_CASE(DartAPI_Invoke_PrivateStatic) { "\n"; // Shared setup. - Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, nullptr); Dart_Handle type = - Dart_GetNonNullableType(lib, NewString("Methods"), 0, NULL); + Dart_GetNonNullableType(lib, NewString("Methods"), 0, nullptr); Dart_Handle result; EXPECT_VALID(type); Dart_Handle name = NewString("_staticMethod"); @@ -6944,7 +6951,7 @@ TEST_CASE(DartAPI_Invoke_PrivateStatic) { result = Dart_Invoke(type, name, 1, args); EXPECT_VALID(result); - const char* str = NULL; + const char* str = nullptr; result = Dart_StringToCString(result, &str); EXPECT_STREQ("hidden static !!!", str); } @@ -6952,7 +6959,7 @@ TEST_CASE(DartAPI_Invoke_PrivateStatic) { TEST_CASE(DartAPI_Invoke_FunnyArgs) { const char* kScriptChars = "test(arg) => 'hello $arg';\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, nullptr); Dart_Handle func_name = NewString("test"); Dart_Handle args[1]; const char* str; @@ -7025,11 +7032,11 @@ TEST_CASE(DartAPI_Invoke_BadArgs) { #endif // defined(PRODUCT) // Shared setup. - Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, nullptr); Dart_Handle type = - Dart_GetNonNullableType(lib, NewString("Methods"), 0, NULL); + Dart_GetNonNullableType(lib, NewString("Methods"), 0, nullptr); EXPECT_VALID(type); - Dart_Handle instance = Dart_Invoke(lib, NewString("test"), 0, NULL); + Dart_Handle instance = Dart_Invoke(lib, NewString("test"), 0, nullptr); EXPECT_VALID(instance); Dart_Handle args[1]; args[0] = NewString("!!!"); @@ -7079,7 +7086,8 @@ TEST_CASE(DartAPI_Invoke_BadArgs) { } TEST_CASE(DartAPI_Invoke_Null) { - Dart_Handle result = Dart_Invoke(Dart_Null(), NewString("toString"), 0, NULL); + Dart_Handle result = + Dart_Invoke(Dart_Null(), NewString("toString"), 0, nullptr); EXPECT_VALID(result); EXPECT(Dart_IsString(result)); @@ -7088,7 +7096,7 @@ TEST_CASE(DartAPI_Invoke_Null) { EXPECT_STREQ("null", value); Dart_Handle function_name = NewString("NoNoNo"); - result = Dart_Invoke(Dart_Null(), function_name, 0, NULL); + result = Dart_Invoke(Dart_Null(), function_name, 0, nullptr); EXPECT(Dart_IsError(result)); EXPECT(Dart_ErrorHasException(result)); @@ -7144,13 +7152,13 @@ TEST_CASE(DartAPI_InvokeNoSuchMethod) { Dart_Handle instance; // Create a test library and Load up a test script in it. // The test library must have a dart: url so it can import dart:_internal. - Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, nullptr); Dart_Handle type = - Dart_GetNonNullableType(lib, NewString("TestClass"), 0, NULL); + Dart_GetNonNullableType(lib, NewString("TestClass"), 0, nullptr); EXPECT_VALID(type); // Invoke a function which returns an object. - instance = Dart_Invoke(type, NewString("testMain"), 0, NULL); + instance = Dart_Invoke(type, NewString("testMain"), 0, nullptr); EXPECT_VALID(instance); // Try to get a field that does not exist, should call noSuchMethod. @@ -7162,7 +7170,7 @@ TEST_CASE(DartAPI_InvokeNoSuchMethod) { EXPECT_VALID(result); // Try to invoke a method that does not exist, should call noSuchMethod. - result = Dart_Invoke(instance, NewString("method"), 0, NULL); + result = Dart_Invoke(instance, NewString("method"), 0, nullptr); EXPECT_VALID(result); result = Dart_GetField(type, NewString("fld1")); @@ -7199,10 +7207,10 @@ TEST_CASE(DartAPI_InvokeClosure) { CHECK_API_SCOPE(thread); // Create a test library and Load up a test script in it. - Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, nullptr); // Invoke a function which returns a closure. - Dart_Handle retobj = Dart_Invoke(lib, NewString("testMain1"), 0, NULL); + Dart_Handle retobj = Dart_Invoke(lib, NewString("testMain1"), 0, nullptr); EXPECT_VALID(retobj); EXPECT(Dart_IsClosure(retobj)); @@ -7219,12 +7227,12 @@ TEST_CASE(DartAPI_InvokeClosure) { EXPECT_EQ(51, value); // Invoke closure with wrong number of args, should result in exception. - result = Dart_InvokeClosure(retobj, 0, NULL); + result = Dart_InvokeClosure(retobj, 0, nullptr); EXPECT(Dart_IsError(result)); EXPECT(Dart_ErrorHasException(result)); // Invoke a function which returns a closure. - retobj = Dart_Invoke(lib, NewString("testMain2"), 0, NULL); + retobj = Dart_Invoke(lib, NewString("testMain2"), 0, nullptr); EXPECT_VALID(retobj); EXPECT(Dart_IsClosure(retobj)); @@ -7246,7 +7254,7 @@ void ExceptionNative(Dart_NativeArguments args) { static Dart_NativeFunction native_lookup(Dart_Handle name, int argument_count, bool* auto_setup_scope) { - ASSERT(auto_setup_scope != NULL); + ASSERT(auto_setup_scope != nullptr); *auto_setup_scope = true; return ExceptionNative; } @@ -7271,7 +7279,7 @@ TEST_CASE(DartAPI_ThrowException) { EXPECT(!Dart_ErrorHasException(result)); // Invoke 'test' and check for an uncaught exception. - result = Dart_Invoke(lib, NewString("test"), 0, NULL); + result = Dart_Invoke(lib, NewString("test"), 0, nullptr); EXPECT_ERROR(result, "Hello from ExceptionNative!"); EXPECT(Dart_ErrorHasException(result)); @@ -7285,7 +7293,7 @@ static intptr_t native_arg_str_peer = 100; static void NativeArgumentCreate(Dart_NativeArguments args) { Dart_Handle lib = Dart_LookupLibrary(NewString(TestCase::url())); Dart_Handle type = - Dart_GetNonNullableType(lib, NewString("MyObject"), 0, NULL); + Dart_GetNonNullableType(lib, NewString("MyObject"), 0, nullptr); EXPECT_VALID(type); // Allocate without a constructor. @@ -7307,7 +7315,7 @@ static void NativeArgumentAccess(Dart_NativeArguments args) { // Test different argument types with a valid descriptor set. { - const char* cstr = NULL; + const char* cstr = nullptr; intptr_t native_fields1[kNumNativeFields]; intptr_t native_fields2[kNumNativeFields]; const Dart_NativeArgument_Descriptor arg_descriptors[9] = { @@ -7347,9 +7355,9 @@ static void NativeArgumentAccess(Dart_NativeArguments args) { EXPECT(Dart_IsString(arg_values[5].as_string.dart_str)); EXPECT_VALID(Dart_StringToCString(arg_values[5].as_string.dart_str, &cstr)); EXPECT_STREQ("abcdefg", cstr); - EXPECT(arg_values[5].as_string.peer == NULL); + EXPECT(arg_values[5].as_string.peer == nullptr); - EXPECT(arg_values[6].as_string.dart_str == NULL); + EXPECT(arg_values[6].as_string.dart_str == nullptr); EXPECT(arg_values[6].as_string.peer == reinterpret_cast(&native_arg_str_peer)); @@ -7409,18 +7417,18 @@ static Dart_NativeFunction native_args_lookup(Dart_Handle name, TransitionNativeToVM transition(Thread::Current()); const Object& obj = Object::Handle(Api::UnwrapHandle(name)); if (!obj.IsString()) { - return NULL; + return nullptr; } - ASSERT(auto_scope_setup != NULL); + ASSERT(auto_scope_setup != nullptr); *auto_scope_setup = true; const char* function_name = obj.ToCString(); - ASSERT(function_name != NULL); + ASSERT(function_name != nullptr); if (strcmp(function_name, "NativeArgument_Create") == 0) { return NativeArgumentCreate; } else if (strcmp(function_name, "NativeArgument_Access") == 0) { return NativeArgumentAccess; } - return NULL; + return nullptr; } TEST_CASE(DartAPI_GetNativeArguments) { @@ -7477,7 +7485,7 @@ static void NativeArgumentCounter(Dart_NativeArguments args) { static Dart_NativeFunction gnac_lookup(Dart_Handle name, int argument_count, bool* auto_setup_scope) { - ASSERT(auto_setup_scope != NULL); + ASSERT(auto_setup_scope != nullptr); *auto_setup_scope = true; return NativeArgumentCounter; } @@ -7495,7 +7503,7 @@ testMain() { Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, gnac_lookup); - Dart_Handle result = Dart_Invoke(lib, NewString("testMain"), 0, NULL); + Dart_Handle result = Dart_Invoke(lib, NewString("testMain"), 0, nullptr); EXPECT_VALID(result); EXPECT(Dart_IsInteger(result)); @@ -7512,11 +7520,11 @@ TEST_CASE(DartAPI_TypeToNullability) { " static var name = 'Class';\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, nullptr); const Dart_Handle name = NewString("Class"); // Lookup the legacy type for Class. - Dart_Handle type = Dart_GetType(lib, name, 0, NULL); + Dart_Handle type = Dart_GetType(lib, name, 0, nullptr); Dart_Handle nonNullableType; Dart_Handle nullableType; if (Dart_IsError(type)) { @@ -7575,10 +7583,10 @@ TEST_CASE(DartAPI_GetNullableType) { " static var name = '_Class';\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, nullptr); // Lookup a class. - Dart_Handle type = Dart_GetNullableType(lib, NewString("Class"), 0, NULL); + Dart_Handle type = Dart_GetNullableType(lib, NewString("Class"), 0, nullptr); EXPECT_VALID(type); bool result = false; EXPECT_VALID(Dart_IsNullableType(type, &result)); @@ -7595,7 +7603,7 @@ TEST_CASE(DartAPI_GetNullableType) { EXPECT_STREQ("Class", name_cstr); // Lookup a private class. - type = Dart_GetNullableType(lib, NewString("_Class"), 0, NULL); + type = Dart_GetNullableType(lib, NewString("_Class"), 0, nullptr); EXPECT_VALID(type); result = false; EXPECT_VALID(Dart_IsNullableType(type, &result)); @@ -7607,19 +7615,19 @@ TEST_CASE(DartAPI_GetNullableType) { EXPECT_STREQ("_Class", name_cstr); // Lookup a class that does not exist. - type = Dart_GetNullableType(lib, NewString("DoesNotExist"), 0, NULL); + type = Dart_GetNullableType(lib, NewString("DoesNotExist"), 0, nullptr); EXPECT(Dart_IsError(type)); EXPECT_STREQ("Type 'DoesNotExist' not found in library 'testlib'.", Dart_GetError(type)); // Lookup a class from an error library. The error propagates. type = Dart_GetNullableType(Api::NewError("myerror"), NewString("Class"), 0, - NULL); + nullptr); EXPECT(Dart_IsError(type)); EXPECT_STREQ("myerror", Dart_GetError(type)); // Lookup a type using an error class name. The error propagates. - type = Dart_GetNullableType(lib, Api::NewError("myerror"), 0, NULL); + type = Dart_GetNullableType(lib, Api::NewError("myerror"), 0, nullptr); EXPECT(Dart_IsError(type)); EXPECT_STREQ("myerror", Dart_GetError(type)); } @@ -7635,10 +7643,11 @@ TEST_CASE(DartAPI_GetNonNullableType) { " static var name = '_Class';\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, nullptr); // Lookup a class. - Dart_Handle type = Dart_GetNonNullableType(lib, NewString("Class"), 0, NULL); + Dart_Handle type = + Dart_GetNonNullableType(lib, NewString("Class"), 0, nullptr); EXPECT_VALID(type); bool result = false; EXPECT_VALID(Dart_IsNonNullableType(type, &result)); @@ -7655,7 +7664,7 @@ TEST_CASE(DartAPI_GetNonNullableType) { EXPECT_STREQ("Class", name_cstr); // Lookup a private class. - type = Dart_GetNonNullableType(lib, NewString("_Class"), 0, NULL); + type = Dart_GetNonNullableType(lib, NewString("_Class"), 0, nullptr); EXPECT_VALID(type); result = false; EXPECT_VALID(Dart_IsNonNullableType(type, &result)); @@ -7668,19 +7677,19 @@ TEST_CASE(DartAPI_GetNonNullableType) { EXPECT_STREQ("_Class", name_cstr); // Lookup a class that does not exist. - type = Dart_GetNonNullableType(lib, NewString("DoesNotExist"), 0, NULL); + type = Dart_GetNonNullableType(lib, NewString("DoesNotExist"), 0, nullptr); EXPECT(Dart_IsError(type)); EXPECT_STREQ("Type 'DoesNotExist' not found in library 'testlib'.", Dart_GetError(type)); // Lookup a class from an error library. The error propagates. type = Dart_GetNonNullableType(Api::NewError("myerror"), NewString("Class"), - 0, NULL); + 0, nullptr); EXPECT(Dart_IsError(type)); EXPECT_STREQ("myerror", Dart_GetError(type)); // Lookup a type using an error class name. The error propagates. - type = Dart_GetNonNullableType(lib, Api::NewError("myerror"), 0, NULL); + type = Dart_GetNonNullableType(lib, Api::NewError("myerror"), 0, nullptr); EXPECT(Dart_IsError(type)); EXPECT_STREQ("myerror", Dart_GetError(type)); } @@ -7698,16 +7707,16 @@ TEST_CASE(DartAPI_InstanceOf) { "}\n"; Dart_Handle result; // Create a test library and Load up a test script in it. - Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, nullptr); // Fetch InstanceOfTest class. Dart_Handle type = - Dart_GetNonNullableType(lib, NewString("InstanceOfTest"), 0, NULL); + Dart_GetNonNullableType(lib, NewString("InstanceOfTest"), 0, nullptr); EXPECT_VALID(type); // Invoke a function which returns an object of type InstanceOf.. Dart_Handle instanceOfTestObj = - Dart_Invoke(type, NewString("testMain"), 0, NULL); + Dart_Invoke(type, NewString("testMain"), 0, nullptr); EXPECT_VALID(instanceOfTestObj); // Now check instanceOfTestObj reported as an instance of @@ -7719,7 +7728,7 @@ TEST_CASE(DartAPI_InstanceOf) { // Fetch OtherClass and check if instanceOfTestObj is instance of it. Dart_Handle otherType = - Dart_GetNonNullableType(lib, NewString("OtherClass"), 0, NULL); + Dart_GetNonNullableType(lib, NewString("OtherClass"), 0, nullptr); EXPECT_VALID(otherType); result = Dart_ObjectIsType(instanceOfTestObj, otherType, &is_instance); @@ -7740,7 +7749,8 @@ TEST_CASE(DartAPI_InstanceOf) { EXPECT(!is_instance); // Check that null is not an instance of InstanceOfTest class. - Dart_Handle null = Dart_Invoke(otherType, NewString("returnNull"), 0, NULL); + Dart_Handle null = + Dart_Invoke(otherType, NewString("returnNull"), 0, nullptr); EXPECT_VALID(null); result = Dart_ObjectIsType(null, otherType, &is_instance); @@ -7816,7 +7826,7 @@ TEST_CASE(DartAPI_LookupLibrary) { // LoadTestScript resets the LibraryTagHandler, which we don't want when // using the VM compiler, so we only use it with the Dart frontend for this // test. - result = TestCase::LoadTestScript(kScriptChars, NULL, TestCase::url()); + result = TestCase::LoadTestScript(kScriptChars, nullptr, TestCase::url()); EXPECT_VALID(result); url = NewString(kLibrary1); @@ -7863,7 +7873,7 @@ TEST_CASE(DartAPI_LibraryUrl) { result = Dart_LibraryUrl(lib); EXPECT_VALID(result); EXPECT(Dart_IsString(result)); - const char* cstr = NULL; + const char* cstr = nullptr; EXPECT_VALID(Dart_StringToCString(result, &cstr)); EXPECT_SUBSTRING("library1_url", cstr); } @@ -7883,7 +7893,7 @@ static void MyNativeFunction2(Dart_NativeArguments args) { static Dart_NativeFunction MyNativeResolver1(Dart_Handle name, int arg_count, bool* auto_setup_scope) { - ASSERT(auto_setup_scope != NULL); + ASSERT(auto_setup_scope != nullptr); *auto_setup_scope = false; return &MyNativeFunction1; } @@ -7891,7 +7901,7 @@ static Dart_NativeFunction MyNativeResolver1(Dart_Handle name, static Dart_NativeFunction MyNativeResolver2(Dart_Handle name, int arg_count, bool* auto_setup_scope) { - ASSERT(auto_setup_scope != NULL); + ASSERT(auto_setup_scope != nullptr); *auto_setup_scope = false; return &MyNativeFunction2; } @@ -7914,33 +7924,34 @@ TEST_CASE(DartAPI_SetNativeResolver) { Dart_Handle result; // Load a test script. - Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, nullptr); EXPECT_VALID(lib); result = Dart_FinalizeLoading(false); EXPECT_VALID(result); EXPECT(Dart_IsLibrary(lib)); - Dart_Handle type = Dart_GetNonNullableType(lib, NewString("Test"), 0, NULL); + Dart_Handle type = + Dart_GetNonNullableType(lib, NewString("Test"), 0, nullptr); EXPECT_VALID(type); - result = Dart_SetNativeResolver(Dart_Null(), &MyNativeResolver1, NULL); + result = Dart_SetNativeResolver(Dart_Null(), &MyNativeResolver1, nullptr); EXPECT_ERROR( result, "Dart_SetNativeResolver expects argument 'library' to be non-null."); - result = Dart_SetNativeResolver(Dart_True(), &MyNativeResolver1, NULL); + result = Dart_SetNativeResolver(Dart_True(), &MyNativeResolver1, nullptr); EXPECT_ERROR(result, "Dart_SetNativeResolver expects argument 'library' to be of " "type Library."); - result = Dart_SetNativeResolver(error, &MyNativeResolver1, NULL); + result = Dart_SetNativeResolver(error, &MyNativeResolver1, nullptr); EXPECT(Dart_IsError(result)); EXPECT_STREQ("incoming error", Dart_GetError(result)); - result = Dart_SetNativeResolver(lib, &MyNativeResolver1, NULL); + result = Dart_SetNativeResolver(lib, &MyNativeResolver1, nullptr); EXPECT_VALID(result); // Call a function and make sure native resolution works. - result = Dart_Invoke(type, NewString("foo"), 0, NULL); + result = Dart_Invoke(type, NewString("foo"), 0, nullptr); EXPECT_VALID(result); EXPECT(Dart_IsInteger(result)); int64_t value = 0; @@ -7948,11 +7959,11 @@ TEST_CASE(DartAPI_SetNativeResolver) { EXPECT_EQ(654321, value); // A second call succeeds. - result = Dart_SetNativeResolver(lib, &MyNativeResolver2, NULL); + result = Dart_SetNativeResolver(lib, &MyNativeResolver2, nullptr); EXPECT_VALID(result); // 'foo' has already been resolved so gets the old value. - result = Dart_Invoke(type, NewString("foo"), 0, NULL); + result = Dart_Invoke(type, NewString("foo"), 0, nullptr); EXPECT_VALID(result); EXPECT(Dart_IsInteger(result)); value = 0; @@ -7960,18 +7971,18 @@ TEST_CASE(DartAPI_SetNativeResolver) { EXPECT_EQ(654321, value); // 'bar' has not yet been resolved so gets the new value. - result = Dart_Invoke(type, NewString("bar"), 0, NULL); + result = Dart_Invoke(type, NewString("bar"), 0, nullptr); EXPECT_VALID(result); EXPECT(Dart_IsInteger(result)); value = 0; EXPECT_VALID(Dart_IntegerToInt64(result, &value)); EXPECT_EQ(123456, value); - // A NULL resolver is okay, but resolution will fail. - result = Dart_SetNativeResolver(lib, NULL, NULL); + // A nullptr resolver is okay, but resolution will fail. + result = Dart_SetNativeResolver(lib, nullptr, nullptr); EXPECT_VALID(result); - EXPECT_ERROR(Dart_Invoke(type, NewString("baz"), 0, NULL), + EXPECT_ERROR(Dart_Invoke(type, NewString("baz"), 0, nullptr), "native function 'SomeNativeFunction3' (0 arguments) " "cannot be found"); } @@ -8001,13 +8012,13 @@ TEST_CASE(DartAPI_ImportLibrary2) { {"file:///library2_dart", kLibrary2Chars}, }; int sourcefiles_count = sizeof(sourcefiles) / sizeof(Dart_SourceFile); - lib = TestCase::LoadTestScriptWithDFE(sourcefiles_count, sourcefiles, NULL, + lib = TestCase::LoadTestScriptWithDFE(sourcefiles_count, sourcefiles, nullptr, true); EXPECT_VALID(lib); result = Dart_FinalizeLoading(false); EXPECT_VALID(result); - result = Dart_Invoke(lib, NewString("main"), 0, NULL); + result = Dart_Invoke(lib, NewString("main"), 0, nullptr); EXPECT_VALID(result); } @@ -8035,7 +8046,7 @@ TEST_CASE(DartAPI_ImportLibrary3) { {"file:///library1_dart", kLibrary1Chars}, }; int sourcefiles_count = sizeof(sourcefiles) / sizeof(Dart_SourceFile); - lib = TestCase::LoadTestScriptWithDFE(sourcefiles_count, sourcefiles, NULL, + lib = TestCase::LoadTestScriptWithDFE(sourcefiles_count, sourcefiles, nullptr, true); EXPECT_ERROR(lib, "Compilation failed /test-lib:4:10:" @@ -8044,7 +8055,7 @@ TEST_CASE(DartAPI_ImportLibrary3) { result = Dart_FinalizeLoading(false); EXPECT_VALID(result); - result = Dart_Invoke(lib, NewString("main"), 0, NULL); + result = Dart_Invoke(lib, NewString("main"), 0, nullptr); EXPECT(Dart_IsError(result)); EXPECT_SUBSTRING("NoSuchMethodError", Dart_GetError(result)); } @@ -8072,13 +8083,13 @@ TEST_CASE(DartAPI_ImportLibrary4) { {"file:///library1_dart", kLibrary1Chars}, }; int sourcefiles_count = sizeof(sourcefiles) / sizeof(Dart_SourceFile); - lib = TestCase::LoadTestScriptWithDFE(sourcefiles_count, sourcefiles, NULL, + lib = TestCase::LoadTestScriptWithDFE(sourcefiles_count, sourcefiles, nullptr, true); EXPECT_VALID(lib); result = Dart_FinalizeLoading(false); EXPECT_VALID(result); - result = Dart_Invoke(lib, NewString("main"), 0, NULL); + result = Dart_Invoke(lib, NewString("main"), 0, nullptr); EXPECT_VALID(result); } @@ -8103,13 +8114,13 @@ TEST_CASE(DartAPI_ImportLibrary5) { {"file:///lib.dart", kLibraryChars}, }; int sourcefiles_count = sizeof(sourcefiles) / sizeof(Dart_SourceFile); - lib = TestCase::LoadTestScriptWithDFE(sourcefiles_count, sourcefiles, NULL, + lib = TestCase::LoadTestScriptWithDFE(sourcefiles_count, sourcefiles, nullptr, true); EXPECT_VALID(lib); result = Dart_FinalizeLoading(false); EXPECT_VALID(result); - result = Dart_Invoke(lib, NewString("main"), 0, NULL); + result = Dart_Invoke(lib, NewString("main"), 0, nullptr); EXPECT_VALID(result); } @@ -8128,7 +8139,7 @@ TEST_CASE(DartAPI_Multiroot_Valid) { }; int sourcefiles_count = sizeof(sourcefiles) / sizeof(Dart_SourceFile); lib = TestCase::LoadTestScriptWithDFE( - sourcefiles_count, sourcefiles, NULL, /* finalize= */ true, + sourcefiles_count, sourcefiles, nullptr, /* finalize= */ true, /* incrementally= */ true, /* allow_compile_errors= */ false, "foo:///main.dart", /* multiroot_filepaths= */ "/bar,/baz", @@ -8151,7 +8162,7 @@ TEST_CASE(DartAPI_Multiroot_Valid) { } result = Dart_FinalizeLoading(false); EXPECT_VALID(result); - result = Dart_Invoke(lib, NewString("main"), 0, NULL); + result = Dart_Invoke(lib, NewString("main"), 0, nullptr); EXPECT_VALID(result); } @@ -8169,7 +8180,7 @@ TEST_CASE(DartAPI_Multiroot_FailWhenUriIsWrong) { }; int sourcefiles_count = sizeof(sourcefiles) / sizeof(Dart_SourceFile); lib = TestCase::LoadTestScriptWithDFE( - sourcefiles_count, sourcefiles, NULL, /* finalize= */ true, + sourcefiles_count, sourcefiles, nullptr, /* finalize= */ true, /* incrementally= */ true, /* allow_compile_errors= */ false, "foo1:///main.dart", /* multiroot_filepaths= */ "/bar,/baz", @@ -8248,7 +8259,7 @@ TEST_CASE(DartAPI_PostCObject_DoesNotRunFinalizerOnFailure) { VM_UNIT_TEST_CASE(DartAPI_NewNativePort) { // Create a port with a bogus handler. - Dart_Port error_port = Dart_NewNativePort("Foo", NULL, true); + Dart_Port error_port = Dart_NewNativePort("Foo", nullptr, true); EXPECT_EQ(ILLEGAL_PORT, error_port); // Create the port w/o a current isolate, just to make sure that works. @@ -8267,7 +8278,7 @@ VM_UNIT_TEST_CASE(DartAPI_NewNativePort) { " throw new Exception(message);\n" " };\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, nullptr); Dart_EnterScope(); // Create a port w/ a current isolate, to make sure that works too. @@ -8341,7 +8352,7 @@ TEST_CASE(DartAPI_NativePortPostInteger) { " throw new Exception(message);\n" " };\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, nullptr); Dart_EnterScope(); Dart_Port port_id1 = @@ -8417,7 +8428,7 @@ TEST_CASE(DartAPI_NativePortPostTransferrableTypedData) { " port1.send(td1);\n" " port2.send([td2]);\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, nullptr); Dart_EnterScope(); Dart_Port port_id1 = @@ -8475,7 +8486,7 @@ TEST_CASE(DartAPI_NativePortPostExternalTypedData) { "void callPort(SendPort port, Uint8List data) {\n" " port.send(data);\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, nullptr); Dart_EnterScope(); Dart_Port port_id = @@ -8516,7 +8527,7 @@ TEST_CASE(DartAPI_NativePortPostUserClass) { "void callPort(SendPort port) {\n" " port.send(new ABC());\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, nullptr); Dart_EnterScope(); Dart_Port port_id = @@ -8573,7 +8584,7 @@ TEST_CASE(DartAPI_NativePortReceiveNull) { " throw new Exception(message);\n" " };\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, nullptr); Dart_EnterScope(); Dart_Port port_id1 = @@ -8625,7 +8636,7 @@ TEST_CASE(DartAPI_NativePortReceiveInteger) { " throw new Exception(message);\n" " };\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, nullptr); Dart_EnterScope(); Dart_Port port_id1 = @@ -8669,23 +8680,23 @@ static Dart_Isolate RunLoopTestCallback(const char* script_name, " rp.sendPort.send(1);\n" "}\n"; - if (Dart_CurrentIsolate() != NULL) { + if (Dart_CurrentIsolate() != nullptr) { Dart_ExitIsolate(); } Dart_Isolate isolate = TestCase::CreateTestIsolate(script_name); - ASSERT(isolate != NULL); + ASSERT(isolate != nullptr); if (Dart_IsServiceIsolate(isolate)) { return isolate; } Dart_EnterScope(); - Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, nullptr); EXPECT_VALID(lib); Dart_Handle result = Dart_FinalizeLoading(false); EXPECT_VALID(result); Dart_ExitScope(); Dart_ExitIsolate(); char* err_msg = Dart_IsolateMakeRunnable(isolate); - EXPECT(err_msg == NULL); + EXPECT(err_msg == nullptr); return isolate; } @@ -8693,8 +8704,8 @@ static Dart_Isolate RunLoopTestCallback(const char* script_name, static void RunLoopTest(bool throw_exception) { Dart_IsolateGroupCreateCallback saved = Isolate::CreateGroupCallback(); Isolate::SetCreateGroupCallback(RunLoopTestCallback); - Dart_Isolate isolate = - RunLoopTestCallback(NULL, NULL, NULL, NULL, NULL, NULL, NULL); + Dart_Isolate isolate = RunLoopTestCallback(nullptr, nullptr, nullptr, nullptr, + nullptr, nullptr, nullptr); Dart_EnterIsolate(isolate); Dart_EnterScope(); @@ -8785,7 +8796,7 @@ VM_UNIT_TEST_CASE(DartAPI_IsolateShutdownAndCleanup) { // Create an isolate. Dart_Isolate isolate = TestCase::CreateTestIsolate(nullptr, my_group_data, my_data); - EXPECT(isolate != NULL); + EXPECT(isolate != nullptr); // The shutdown callback has not been called. EXPECT(nullptr == shutdown_isolate_data); @@ -8847,19 +8858,19 @@ VM_UNIT_TEST_CASE(DartAPI_IsolateShutdownRunDartCode) { // Create an isolate. auto isolate = reinterpret_cast(TestCase::CreateTestIsolate()); - EXPECT(isolate != NULL); + EXPECT(isolate != nullptr); isolate->set_on_shutdown_callback(IsolateShutdownRunDartCodeTestCallback); { Dart_EnterScope(); - Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, nullptr); EXPECT_VALID(lib); Dart_Handle result = Dart_SetLibraryTagHandler(TestCase::library_handler); EXPECT_VALID(result); result = Dart_FinalizeLoading(false); EXPECT_VALID(result); - result = Dart_Invoke(lib, NewString("main"), 0, NULL); + result = Dart_Invoke(lib, NewString("main"), 0, nullptr); EXPECT_VALID(result); Dart_ExitScope(); } @@ -8939,12 +8950,12 @@ static void NativeFoo4(Dart_NativeArguments args) { static Dart_NativeFunction MyNativeClosureResolver(Dart_Handle name, int arg_count, bool* auto_setup_scope) { - ASSERT(auto_setup_scope != NULL); + ASSERT(auto_setup_scope != nullptr); *auto_setup_scope = false; TransitionNativeToVM transition(Thread::Current()); const Object& obj = Object::Handle(Api::UnwrapHandle(name)); if (!obj.IsString()) { - return NULL; + return nullptr; } const char* function_name = obj.ToCString(); const char* kNativeFoo1 = "NativeFoo1"; @@ -8961,7 +8972,7 @@ static Dart_NativeFunction MyNativeClosureResolver(Dart_Handle name, return &NativeFoo4; } else { UNREACHABLE(); - return NULL; + return nullptr; } } @@ -9029,15 +9040,15 @@ TEST_CASE(DartAPI_NativeFunctionClosure) { Dart_Handle result; // Load a test script. - Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, nullptr); EXPECT_VALID(lib); EXPECT(Dart_IsLibrary(lib)); - result = Dart_SetNativeResolver(lib, &MyNativeClosureResolver, NULL); + result = Dart_SetNativeResolver(lib, &MyNativeClosureResolver, nullptr); EXPECT_VALID(result); result = Dart_FinalizeLoading(false); EXPECT_VALID(result); - result = Dart_Invoke(lib, NewString("testMain"), 0, NULL); + result = Dart_Invoke(lib, NewString("testMain"), 0, nullptr); EXPECT_VALID(result); EXPECT(Dart_IsInteger(result)); int64_t value = 0; @@ -9088,12 +9099,12 @@ static Dart_NativeFunction MyStaticNativeClosureResolver( Dart_Handle name, int arg_count, bool* auto_setup_scope) { - ASSERT(auto_setup_scope != NULL); + ASSERT(auto_setup_scope != nullptr); *auto_setup_scope = false; TransitionNativeToVM transition(Thread::Current()); const Object& obj = Object::Handle(Api::UnwrapHandle(name)); if (!obj.IsString()) { - return NULL; + return nullptr; } const char* function_name = obj.ToCString(); const char* kNativeFoo1 = "StaticNativeFoo1"; @@ -9110,7 +9121,7 @@ static Dart_NativeFunction MyStaticNativeClosureResolver( return &StaticNativeFoo4; } else { UNREACHABLE(); - return NULL; + return nullptr; } } @@ -9178,15 +9189,15 @@ TEST_CASE(DartAPI_NativeStaticFunctionClosure) { Dart_Handle result; // Load a test script. - Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, nullptr); EXPECT_VALID(lib); EXPECT(Dart_IsLibrary(lib)); - result = Dart_SetNativeResolver(lib, &MyStaticNativeClosureResolver, NULL); + result = Dart_SetNativeResolver(lib, &MyStaticNativeClosureResolver, nullptr); EXPECT_VALID(result); result = Dart_FinalizeLoading(false); EXPECT_VALID(result); - result = Dart_Invoke(lib, NewString("testMain"), 0, NULL); + result = Dart_Invoke(lib, NewString("testMain"), 0, nullptr); EXPECT_VALID(result); EXPECT(Dart_IsInteger(result)); int64_t value = 0; @@ -9220,21 +9231,21 @@ TEST_CASE(DartAPI_RangeLimits) { } TEST_CASE(DartAPI_NewString_Null) { - Dart_Handle str = Dart_NewStringFromUTF8(NULL, 0); + Dart_Handle str = Dart_NewStringFromUTF8(nullptr, 0); EXPECT_VALID(str); EXPECT(Dart_IsString(str)); intptr_t len = -1; EXPECT_VALID(Dart_StringLength(str, &len)); EXPECT_EQ(0, len); - str = Dart_NewStringFromUTF16(NULL, 0); + str = Dart_NewStringFromUTF16(nullptr, 0); EXPECT_VALID(str); EXPECT(Dart_IsString(str)); len = -1; EXPECT_VALID(Dart_StringLength(str, &len)); EXPECT_EQ(0, len); - str = Dart_NewStringFromUTF32(NULL, 0); + str = Dart_NewStringFromUTF32(nullptr, 0); EXPECT_VALID(str); EXPECT(Dart_IsString(str)); len = -1; @@ -9283,17 +9294,17 @@ TEST_CASE(DartAPI_OneNewSpacePeer) { EXPECT_EQ(0, heap->PeerCount()); void* out = &out; EXPECT_VALID(Dart_GetPeer(str, &out)); - EXPECT(out == NULL); + EXPECT(out == nullptr); int peer = 1234; EXPECT_VALID(Dart_SetPeer(str, &peer)); EXPECT_EQ(1, heap->PeerCount()); out = &out; EXPECT_VALID(Dart_GetPeer(str, &out)); EXPECT(out == reinterpret_cast(&peer)); - EXPECT_VALID(Dart_SetPeer(str, NULL)); + EXPECT_VALID(Dart_SetPeer(str, nullptr)); out = &out; EXPECT_VALID(Dart_GetPeer(str, &out)); - EXPECT(out == NULL); + EXPECT(out == nullptr); EXPECT_EQ(0, heap->PeerCount()); } @@ -9311,7 +9322,7 @@ TEST_CASE(DartAPI_CollectOneNewSpacePeer) { EXPECT_EQ(0, heap->PeerCount()); void* out = &out; EXPECT_VALID(Dart_GetPeer(str, &out)); - EXPECT(out == NULL); + EXPECT(out == nullptr); int peer = 1234; EXPECT_VALID(Dart_SetPeer(str, &peer)); EXPECT_EQ(1, heap->PeerCount()); @@ -9345,7 +9356,7 @@ TEST_CASE(DartAPI_TwoNewSpacePeers) { EXPECT(Dart_IsString(s1)); void* o1 = &o1; EXPECT_VALID(Dart_GetPeer(s1, &o1)); - EXPECT(o1 == NULL); + EXPECT(o1 == nullptr); EXPECT_EQ(0, heap->PeerCount()); int p1 = 1234; EXPECT_VALID(Dart_SetPeer(s1, &p1)); @@ -9358,20 +9369,20 @@ TEST_CASE(DartAPI_TwoNewSpacePeers) { EXPECT_EQ(1, heap->PeerCount()); void* o2 = &o2; EXPECT(Dart_GetPeer(s2, &o2)); - EXPECT(o2 == NULL); + EXPECT(o2 == nullptr); int p2 = 5678; EXPECT_VALID(Dart_SetPeer(s2, &p2)); EXPECT_EQ(2, heap->PeerCount()); EXPECT_VALID(Dart_GetPeer(s2, &o2)); EXPECT(o2 == reinterpret_cast(&p2)); - EXPECT_VALID(Dart_SetPeer(s1, NULL)); + EXPECT_VALID(Dart_SetPeer(s1, nullptr)); EXPECT_EQ(1, heap->PeerCount()); EXPECT(Dart_GetPeer(s1, &o1)); - EXPECT(o1 == NULL); - EXPECT_VALID(Dart_SetPeer(s2, NULL)); + EXPECT(o1 == nullptr); + EXPECT_VALID(Dart_SetPeer(s2, nullptr)); EXPECT_EQ(0, heap->PeerCount()); EXPECT(Dart_GetPeer(s2, &o2)); - EXPECT(o2 == NULL); + EXPECT(o2 == nullptr); } // Allocates two objects in new space and assigns them a peer. Allow @@ -9388,7 +9399,7 @@ TEST_CASE(DartAPI_CollectTwoNewSpacePeers) { EXPECT_EQ(0, heap->PeerCount()); void* o1 = &o1; EXPECT(Dart_GetPeer(s1, &o1)); - EXPECT(o1 == NULL); + EXPECT(o1 == nullptr); int p1 = 1234; EXPECT_VALID(Dart_SetPeer(s1, &p1)); EXPECT_EQ(1, heap->PeerCount()); @@ -9400,7 +9411,7 @@ TEST_CASE(DartAPI_CollectTwoNewSpacePeers) { EXPECT_EQ(1, heap->PeerCount()); void* o2 = &o2; EXPECT(Dart_GetPeer(s2, &o2)); - EXPECT(o2 == NULL); + EXPECT(o2 == nullptr); int p2 = 5678; EXPECT_VALID(Dart_SetPeer(s2, &p2)); EXPECT_EQ(2, heap->PeerCount()); @@ -9427,7 +9438,7 @@ TEST_CASE(DartAPI_CopyNewSpacePeers) { EXPECT(Dart_IsString(s[i])); void* o = &o; EXPECT_VALID(Dart_GetPeer(s[i], &o)); - EXPECT(o == NULL); + EXPECT(o == nullptr); } EXPECT_EQ(0, heap->PeerCount()); int p[kPeerCount]; @@ -9459,7 +9470,7 @@ TEST_CASE(DartAPI_OnePromotedPeer) { EXPECT_EQ(0, heap->PeerCount()); void* out = &out; EXPECT(Dart_GetPeer(str, &out)); - EXPECT(out == NULL); + EXPECT(out == nullptr); int peer = 1234; EXPECT_VALID(Dart_SetPeer(str, &peer)); out = &out; @@ -9482,10 +9493,10 @@ TEST_CASE(DartAPI_OnePromotedPeer) { EXPECT_VALID(Dart_GetPeer(str, &out)); EXPECT(out == reinterpret_cast(&peer)); EXPECT_EQ(1, heap->PeerCount()); - EXPECT_VALID(Dart_SetPeer(str, NULL)); + EXPECT_VALID(Dart_SetPeer(str, nullptr)); out = &out; EXPECT_VALID(Dart_GetPeer(str, &out)); - EXPECT(out == NULL); + EXPECT(out == nullptr); EXPECT_EQ(0, heap->PeerCount()); } @@ -9500,7 +9511,7 @@ TEST_CASE(DartAPI_OneOldSpacePeer) { EXPECT_EQ(0, heap->PeerCount()); void* out = &out; EXPECT(Dart_GetPeer(str, &out)); - EXPECT(out == NULL); + EXPECT(out == nullptr); int peer = 1234; EXPECT_VALID(Dart_SetPeer(str, &peer)); EXPECT_EQ(1, heap->PeerCount()); @@ -9514,10 +9525,10 @@ TEST_CASE(DartAPI_OneOldSpacePeer) { } EXPECT_VALID(Dart_GetPeer(str, &out)); EXPECT(out == reinterpret_cast(&peer)); - EXPECT_VALID(Dart_SetPeer(str, NULL)); + EXPECT_VALID(Dart_SetPeer(str, nullptr)); out = &out; EXPECT_VALID(Dart_GetPeer(str, &out)); - EXPECT(out == NULL); + EXPECT(out == nullptr); EXPECT_EQ(0, heap->PeerCount()); } @@ -9536,7 +9547,7 @@ TEST_CASE(DartAPI_CollectOneOldSpacePeer) { EXPECT_EQ(0, heap->PeerCount()); void* out = &out; EXPECT(Dart_GetPeer(str, &out)); - EXPECT(out == NULL); + EXPECT(out == nullptr); int peer = 1234; EXPECT_VALID(Dart_SetPeer(str, &peer)); EXPECT_EQ(1, heap->PeerCount()); @@ -9570,7 +9581,7 @@ TEST_CASE(DartAPI_TwoOldSpacePeers) { EXPECT_EQ(0, heap->PeerCount()); void* o1 = &o1; EXPECT(Dart_GetPeer(s1, &o1)); - EXPECT(o1 == NULL); + EXPECT(o1 == nullptr); int p1 = 1234; EXPECT_VALID(Dart_SetPeer(s1, &p1)); EXPECT_EQ(1, heap->PeerCount()); @@ -9583,23 +9594,23 @@ TEST_CASE(DartAPI_TwoOldSpacePeers) { EXPECT_EQ(1, heap->PeerCount()); void* o2 = &o2; EXPECT(Dart_GetPeer(s2, &o2)); - EXPECT(o2 == NULL); + EXPECT(o2 == nullptr); int p2 = 5678; EXPECT_VALID(Dart_SetPeer(s2, &p2)); EXPECT_EQ(2, heap->PeerCount()); o2 = &o2; EXPECT_VALID(Dart_GetPeer(s2, &o2)); EXPECT(o2 == reinterpret_cast(&p2)); - EXPECT_VALID(Dart_SetPeer(s1, NULL)); + EXPECT_VALID(Dart_SetPeer(s1, nullptr)); EXPECT_EQ(1, heap->PeerCount()); o1 = &o1; EXPECT(Dart_GetPeer(s1, &o1)); - EXPECT(o1 == NULL); - EXPECT_VALID(Dart_SetPeer(s2, NULL)); + EXPECT(o1 == nullptr); + EXPECT_VALID(Dart_SetPeer(s2, nullptr)); EXPECT_EQ(0, heap->PeerCount()); o2 = &o2; EXPECT_VALID(Dart_GetPeer(s2, &o2)); - EXPECT(o2 == NULL); + EXPECT(o2 == nullptr); } // Allocates two objects in old space and assigns them a peer. Allows @@ -9617,7 +9628,7 @@ TEST_CASE(DartAPI_CollectTwoOldSpacePeers) { EXPECT_EQ(0, heap->PeerCount()); void* o1 = &o1; EXPECT(Dart_GetPeer(s1, &o1)); - EXPECT(o1 == NULL); + EXPECT(o1 == nullptr); int p1 = 1234; EXPECT_VALID(Dart_SetPeer(s1, &p1)); EXPECT_EQ(1, heap->PeerCount()); @@ -9630,7 +9641,7 @@ TEST_CASE(DartAPI_CollectTwoOldSpacePeers) { EXPECT_EQ(1, heap->PeerCount()); void* o2 = &o2; EXPECT(Dart_GetPeer(s2, &o2)); - EXPECT(o2 == NULL); + EXPECT(o2 == nullptr); int p2 = 5678; EXPECT_VALID(Dart_SetPeer(s2, &p2)); EXPECT_EQ(2, heap->PeerCount()); @@ -9652,7 +9663,7 @@ TEST_CASE(DartAPI_ExternalStringIndexOf) { " var str = 'Hello World';\n" " return str.indexOf(pattern);\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, nullptr); uint8_t data8[] = {'W'}; Dart_Handle ext8 = Dart_NewExternalLatin1String( @@ -9684,7 +9695,7 @@ TEST_CASE(DartAPI_StringFromExternalTypedData) { "testView16(external) {\n" " return test(external.buffer.asUint16List());\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, nullptr); { uint8_t data[64]; @@ -9757,7 +9768,7 @@ TEST_CASE(DartAPI_TimelineDuration) { stream->set_enabled(true); // Add a duration event. Dart_TimelineEvent("testDurationEvent", 500, 1500, - Dart_Timeline_Event_Duration, 0, NULL, NULL); + Dart_Timeline_Event_Duration, 0, nullptr, nullptr); // Check that it is in the output. TimelineEventRecorder* recorder = Timeline::recorder(); Timeline::ReclaimCachedBlocksFromThreads(); @@ -9779,7 +9790,7 @@ TEST_CASE(DartAPI_TimelineBegin) { stream->set_enabled(true); // Add a begin event. Dart_TimelineEvent("testBeginEvent", 1000, 1, Dart_Timeline_Event_Begin, 0, - NULL, NULL); + nullptr, nullptr); // Check that it is in the output. TimelineEventRecorder* recorder = Timeline::recorder(); Timeline::ReclaimCachedBlocksFromThreads(); @@ -9799,8 +9810,8 @@ TEST_CASE(DartAPI_TimelineEnd) { // Make sure it is enabled. stream->set_enabled(true); // Add a begin event. - Dart_TimelineEvent("testEndEvent", 1000, 1, Dart_Timeline_Event_End, 0, NULL, - NULL); + Dart_TimelineEvent("testEndEvent", 1000, 1, Dart_Timeline_Event_End, 0, + nullptr, nullptr); // Check that it is in the output. TimelineEventRecorder* recorder = Timeline::recorder(); Timeline::ReclaimCachedBlocksFromThreads(); @@ -9820,7 +9831,7 @@ TEST_CASE(DartAPI_TimelineInstant) { // Make sure it is enabled. stream->set_enabled(true); Dart_TimelineEvent("testInstantEvent", 1000, 1, Dart_Timeline_Event_Instant, - 0, NULL, NULL); + 0, nullptr, nullptr); // Check that it is in the output. TimelineEventRecorder* recorder = Timeline::recorder(); Timeline::ReclaimCachedBlocksFromThreads(); @@ -9840,7 +9851,7 @@ TEST_CASE(DartAPI_TimelineAsyncDisabled) { stream->set_enabled(false); int64_t async_id = 99; Dart_TimelineEvent("testAsyncEvent", 0, async_id, - Dart_Timeline_Event_Async_Begin, 0, NULL, NULL); + Dart_Timeline_Event_Async_Begin, 0, nullptr, nullptr); // Check that testAsync is not in the output. TimelineEventRecorder* recorder = Timeline::recorder(); Timeline::ReclaimCachedBlocksFromThreads(); @@ -9858,7 +9869,7 @@ TEST_CASE(DartAPI_TimelineAsync) { stream->set_enabled(true); int64_t async_id = 99; Dart_TimelineEvent("testAsyncEvent", 1000, async_id, - Dart_Timeline_Event_Async_Begin, 0, NULL, NULL); + Dart_Timeline_Event_Async_Begin, 0, nullptr, nullptr); // Check that it is in the output. TimelineEventRecorder* recorder = Timeline::recorder(); @@ -9991,7 +10002,7 @@ void main() { })"; Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, &NotifyIdleShort_native_lookup); - Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL); + Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, nullptr); EXPECT_VALID(result); } @@ -10024,7 +10035,7 @@ void main() { )"; Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, &NotifyIdleLong_native_lookup); - Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL); + Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, nullptr); EXPECT_VALID(result); } @@ -10057,7 +10068,7 @@ void main() { })"; Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, &NotifyDestroyed_native_lookup); - Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL); + Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, nullptr); EXPECT_VALID(result); } @@ -10078,7 +10089,7 @@ static Dart_NativeFunction SetMode_native_lookup(Dart_Handle name, } else if (strcmp(cstr, "SetPerformanceModeLatency") == 0) { return SetPerformanceModeLatency; } - return NULL; + return nullptr; } TEST_CASE(DartAPI_SetPerformanceMode) { @@ -10101,7 +10112,7 @@ void main() { )"; Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, &SetMode_native_lookup); - Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL); + Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, nullptr); EXPECT_VALID(result); } @@ -10134,7 +10145,7 @@ void main() { })"; Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, &NotifyLowMemory_native_lookup); - Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL); + Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, nullptr); EXPECT_VALID(result); } @@ -10148,7 +10159,7 @@ TEST_CASE(DartAPI_InvokeImportedFunction) { "import 'dart:math';\n" "import 'dart:developer';\n" "main() {}"; - Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, nullptr); EXPECT_VALID(lib); Dart_Handle max = Dart_NewStringFromCString("max"); @@ -10159,7 +10170,7 @@ TEST_CASE(DartAPI_InvokeImportedFunction) { "NoSuchMethodError: No top-level method 'max' declared."); Dart_Handle getCurrentTag = Dart_NewStringFromCString("getCurrentTag"); - result = Dart_Invoke(lib, getCurrentTag, 0, NULL); + result = Dart_Invoke(lib, getCurrentTag, 0, nullptr); EXPECT_ERROR( result, "NoSuchMethodError: No top-level method 'getCurrentTag' declared."); @@ -10216,7 +10227,7 @@ TEST_CASE(DartAPI_InvokeVMServiceMethod) { } )"; - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); Dart_Handle result = Dart_Invoke(lib, NewString("validateResult"), 1, &bytes); EXPECT(Dart_IsBoolean(result)); @@ -10312,22 +10323,28 @@ static void CreateTimelineEvents(uword param) { ml.Notify(); } do { - Dart_TimelineEvent("T1", 0, 1, Dart_Timeline_Event_Begin, 0, NULL, NULL); - Dart_TimelineEvent("T1", 0, 9, Dart_Timeline_Event_End, 0, NULL, NULL); - Dart_TimelineEvent("T2", 0, 1, Dart_Timeline_Event_Instant, 0, NULL, NULL); - Dart_TimelineEvent("T3", 0, 2, Dart_Timeline_Event_Duration, 0, NULL, NULL); - Dart_TimelineEvent("T4", 0, 3, Dart_Timeline_Event_Async_Begin, 0, NULL, - NULL); - Dart_TimelineEvent("T4", 9, 3, Dart_Timeline_Event_Async_End, 0, NULL, - NULL); - Dart_TimelineEvent("T5", 1, 4, Dart_Timeline_Event_Async_Instant, 0, NULL, - NULL); - Dart_TimelineEvent("T7", 1, 4, Dart_Timeline_Event_Counter, 0, NULL, NULL); - Dart_TimelineEvent("T8", 1, 4, Dart_Timeline_Event_Flow_Begin, 0, NULL, - NULL); - Dart_TimelineEvent("T8", 1, 4, Dart_Timeline_Event_Flow_Step, 0, NULL, - NULL); - Dart_TimelineEvent("T8", 1, 4, Dart_Timeline_Event_Flow_End, 0, NULL, NULL); + Dart_TimelineEvent("T1", 0, 1, Dart_Timeline_Event_Begin, 0, nullptr, + nullptr); + Dart_TimelineEvent("T1", 0, 9, Dart_Timeline_Event_End, 0, nullptr, + nullptr); + Dart_TimelineEvent("T2", 0, 1, Dart_Timeline_Event_Instant, 0, nullptr, + nullptr); + Dart_TimelineEvent("T3", 0, 2, Dart_Timeline_Event_Duration, 0, nullptr, + nullptr); + Dart_TimelineEvent("T4", 0, 3, Dart_Timeline_Event_Async_Begin, 0, nullptr, + nullptr); + Dart_TimelineEvent("T4", 9, 3, Dart_Timeline_Event_Async_End, 0, nullptr, + nullptr); + Dart_TimelineEvent("T5", 1, 4, Dart_Timeline_Event_Async_Instant, 0, + nullptr, nullptr); + Dart_TimelineEvent("T7", 1, 4, Dart_Timeline_Event_Counter, 0, nullptr, + nullptr); + Dart_TimelineEvent("T8", 1, 4, Dart_Timeline_Event_Flow_Begin, 0, nullptr, + nullptr); + Dart_TimelineEvent("T8", 1, 4, Dart_Timeline_Event_Flow_Step, 0, nullptr, + nullptr); + Dart_TimelineEvent("T8", 1, 4, Dart_Timeline_Event_Flow_End, 0, nullptr, + nullptr); } while (true); } diff --git a/runtime/vm/dart_api_state.h b/runtime/vm/dart_api_state.h index 21529e70860..e49a99cef19 100644 --- a/runtime/vm/dart_api_state.h +++ b/runtime/vm/dart_api_state.h @@ -32,9 +32,9 @@ class ApiZone { // Create an empty zone. ApiZone() : zone_() { Thread* thread = Thread::Current(); - Zone* zone = thread != NULL ? thread->zone() : NULL; + Zone* zone = thread != nullptr ? thread->zone() : nullptr; zone_.Link(zone); - if (thread != NULL) { + if (thread != nullptr) { thread->set_zone(&zone_); } if (FLAG_trace_zones) { @@ -48,12 +48,12 @@ class ApiZone { ~ApiZone() { Thread* thread = Thread::Current(); #if defined(DEBUG) - if (thread == NULL) { + if (thread == nullptr) { ASSERT(zone_.handles()->CountScopedHandles() == 0); ASSERT(zone_.handles()->CountZoneHandles() == 0); } #endif - if ((thread != NULL) && (thread->zone() == &zone_)) { + if ((thread != nullptr) && (thread->zone() == &zone_)) { thread->set_zone(zone_.previous_); } if (FLAG_trace_zones) { @@ -96,8 +96,8 @@ class ApiZone { Zone* GetZone() { return &zone_; } void Reinit(Thread* thread) { - if (thread == NULL) { - zone_.Link(NULL); + if (thread == nullptr) { + zone_.Link(nullptr); } else { zone_.Link(thread->zone()); thread->set_zone(&zone_); @@ -105,7 +105,7 @@ class ApiZone { } void Reset(Thread* thread) { - if ((thread != NULL) && (thread->zone() == &zone_)) { + if ((thread != nullptr) && (thread->zone() == &zone_)) { thread->set_zone(zone_.previous_); } zone_.Reset(); @@ -291,7 +291,7 @@ class FinalizablePersistentHandle { friend class FinalizablePersistentHandles; FinalizablePersistentHandle() - : ptr_(nullptr), peer_(NULL), external_data_(0), callback_(NULL) {} + : ptr_(nullptr), peer_(nullptr), external_data_(0), callback_(nullptr) {} ~FinalizablePersistentHandle() {} static void Finalize(IsolateGroup* isolate_group, @@ -443,14 +443,14 @@ class PersistentHandles : Handles(), - free_list_(NULL) { + free_list_(nullptr) { if (FLAG_trace_handles) { OS::PrintErr("*** Starting a new Persistent handle block 0x%" Px "\n", reinterpret_cast(this)); } } ~PersistentHandles() { - free_list_ = NULL; + free_list_ = nullptr; if (FLAG_trace_handles) { OS::PrintErr("*** Handle Counts for 0x(%" Px "):Scoped = %d\n", reinterpret_cast(this), CountHandles()); @@ -481,7 +481,7 @@ class PersistentHandles : HandlesNext(); } else { @@ -503,7 +503,7 @@ class PersistentHandles : Handles(object)) { return true; } @@ -534,8 +534,8 @@ class FinalizablePersistentHandles : Handles(), - free_list_(NULL) {} - ~FinalizablePersistentHandles() { free_list_ = NULL; } + free_list_(nullptr) {} + ~FinalizablePersistentHandles() { free_list_ = nullptr; } // Accessors. FinalizablePersistentHandle* free_list() const { return free_list_; } @@ -562,7 +562,7 @@ class FinalizablePersistentHandles // by calling FreeHandle. FinalizablePersistentHandle* AllocateHandle() { FinalizablePersistentHandle* handle; - if (free_list_ != NULL) { + if (free_list_ != nullptr) { handle = free_list_; free_list_ = handle->Next(); handle->set_ptr(Object::null()); @@ -596,7 +596,7 @@ class FinalizablePersistentHandles bool IsFreeHandle(Dart_WeakPersistentHandle object) const { FinalizablePersistentHandle* handle = free_list_; - while (handle != NULL) { + while (handle != nullptr) { if (handle == reinterpret_cast(object)) { return true; } @@ -619,7 +619,7 @@ class ApiLocalScope { public: ApiLocalScope(ApiLocalScope* previous, uword stack_marker) : previous_(previous), stack_marker_(stack_marker) {} - ~ApiLocalScope() { previous_ = NULL; } + ~ApiLocalScope() { previous_ = nullptr; } // Reinit the ApiLocalScope to new values. void Reinit(Thread* thread, ApiLocalScope* previous, uword stack_marker) { @@ -632,7 +632,7 @@ class ApiLocalScope { void Reset(Thread* thread) { local_handles_.Reset(); zone_.Reset(thread); - previous_ = NULL; + previous_ = nullptr; stack_marker_ = 0; } @@ -656,7 +656,7 @@ class ApiNativeScope { public: ApiNativeScope() { // Currently no support for nesting native scopes. - ASSERT(Current() == NULL); + ASSERT(Current() == nullptr); OSThread::SetThreadLocal(Api::api_native_key_, reinterpret_cast(this)); } diff --git a/runtime/vm/dart_entry.cc b/runtime/vm/dart_entry.cc index 068334aac85..9975813c84d 100644 --- a/runtime/vm/dart_entry.cc +++ b/runtime/vm/dart_entry.cc @@ -42,7 +42,7 @@ class ScopedIsolateStackLimits : public ValueObject { NO_SANITIZE_SAFE_STACK explicit ScopedIsolateStackLimits(Thread* thread, uword current_sp) : thread_(thread) { - ASSERT(thread != NULL); + ASSERT(thread != nullptr); // Save the Thread's current stack limit and adjust the stack limit. ASSERT(thread->isolate() == Isolate::Current()); saved_stack_limit_ = thread->saved_stack_limit(); @@ -84,11 +84,11 @@ class SuspendLongJumpScope : public ThreadStackResource { explicit SuspendLongJumpScope(Thread* thread) : ThreadStackResource(thread), saved_long_jump_base_(thread->long_jump_base()) { - thread->set_long_jump_base(NULL); + thread->set_long_jump_base(nullptr); } ~SuspendLongJumpScope() { - ASSERT(thread()->long_jump_base() == NULL); + ASSERT(thread()->long_jump_base() == nullptr); thread()->set_long_jump_base(saved_long_jump_base_); } @@ -591,7 +591,7 @@ void ArgumentsDescriptor::Init() { void ArgumentsDescriptor::Cleanup() { for (int i = 0; i < kCachedDescriptorCount; i++) { // Don't free pointers to RawArray objects managed by the VM. - cached_args_descriptors_[i] = NULL; + cached_args_descriptors_[i] = nullptr; } } diff --git a/runtime/vm/debugger.cc b/runtime/vm/debugger.cc index 01f485e05f7..dbe5447d158 100644 --- a/runtime/vm/debugger.cc +++ b/runtime/vm/debugger.cc @@ -71,8 +71,8 @@ BreakpointLocation::BreakpointLocation( line_number_(-1), // lazily computed token_pos_(token_pos), end_token_pos_(end_token_pos), - next_(NULL), - conditions_(NULL), + next_(nullptr), + conditions_(nullptr), requested_line_number_(requested_line_number), requested_column_number_(requested_column_number), code_token_pos_(TokenPosition::kNoSource) { @@ -95,8 +95,8 @@ BreakpointLocation::BreakpointLocation(Debugger* debugger, line_number_(-1), // lazily computed token_pos_(TokenPosition::kNoSource), end_token_pos_(TokenPosition::kNoSource), - next_(NULL), - conditions_(NULL), + next_(nullptr), + conditions_(nullptr), requested_line_number_(requested_line_number), requested_column_number_(requested_column_number), code_token_pos_(TokenPosition::kNoSource) { @@ -105,7 +105,7 @@ BreakpointLocation::BreakpointLocation(Debugger* debugger, BreakpointLocation::~BreakpointLocation() { Breakpoint* bpt = breakpoints(); - while (bpt != NULL) { + while (bpt != nullptr) { Breakpoint* temp = bpt; bpt = bpt->next(); delete temp; @@ -167,7 +167,7 @@ intptr_t BreakpointLocation::line_number() { void Breakpoint::set_bpt_location(BreakpointLocation* new_bpt_location) { // Only latent breakpoints can be moved. - ASSERT((new_bpt_location == NULL) || bpt_location_->IsLatent()); + ASSERT((new_bpt_location == nullptr) || bpt_location_->IsLatent()); bpt_location_ = new_bpt_location; } @@ -182,7 +182,7 @@ void BreakpointLocation::VisitObjectPointers(ObjectPointerVisitor* visitor) { visitor->VisitPointer(reinterpret_cast(&url_)); Breakpoint* bpt = conditions_; - while (bpt != NULL) { + while (bpt != nullptr) { bpt->VisitObjectPointers(visitor); bpt = bpt->next(); } @@ -401,11 +401,11 @@ void BreakpointLocation::AddBreakpoint(Breakpoint* bpt, Debugger* dbg) { Breakpoint* BreakpointLocation::AddRepeated(Debugger* dbg) { Breakpoint* bpt = breakpoints(); - while (bpt != NULL) { + while (bpt != nullptr) { if (bpt->IsRepeated()) break; bpt = bpt->next(); } - if (bpt == NULL) { + if (bpt == nullptr) { bpt = new Breakpoint(dbg->nextId(), this); bpt->SetIsRepeated(); AddBreakpoint(bpt, dbg); @@ -415,11 +415,11 @@ Breakpoint* BreakpointLocation::AddRepeated(Debugger* dbg) { Breakpoint* BreakpointLocation::AddSingleShot(Debugger* dbg) { Breakpoint* bpt = breakpoints(); - while (bpt != NULL) { + while (bpt != nullptr) { if (bpt->IsSingleShot()) break; bpt = bpt->next(); } - if (bpt == NULL) { + if (bpt == nullptr) { bpt = new Breakpoint(dbg->nextId(), this); bpt->SetIsSingleShot(); AddBreakpoint(bpt, dbg); @@ -430,18 +430,18 @@ Breakpoint* BreakpointLocation::AddSingleShot(Debugger* dbg) { Breakpoint* BreakpointLocation::AddPerClosure(Debugger* dbg, const Instance& closure, bool for_over_await) { - Breakpoint* bpt = NULL; + Breakpoint* bpt = nullptr; // Do not reuse existing breakpoints for stepping over await clauses. // A second async step-over command will set a new breakpoint before // the existing one gets deleted when first async step-over resumes. if (!for_over_await) { bpt = breakpoints(); - while (bpt != NULL) { + while (bpt != nullptr) { if (bpt->IsPerClosure() && (bpt->closure() == closure.ptr())) break; bpt = bpt->next(); } } - if (bpt == NULL) { + if (bpt == nullptr) { bpt = new Breakpoint(dbg->nextId(), this); bpt->SetIsPerClosure(closure); bpt->set_is_synthetic_async(for_over_await); @@ -502,7 +502,7 @@ bool GroupDebugger::HasCodeBreakpointInFunction(const Function& func) { auto thread = Thread::Current(); return RunUnderReadLockIfNeeded(thread, code_breakpoints_lock(), [&]() { CodeBreakpoint* cbpt = code_breakpoints_; - while (cbpt != NULL) { + while (cbpt != nullptr) { if (func.ptr() == cbpt->function()) { return true; } @@ -516,7 +516,7 @@ bool GroupDebugger::HasBreakpointInCode(const Code& code) { auto thread = Thread::Current(); return RunUnderReadLockIfNeeded(thread, code_breakpoints_lock(), [&]() { CodeBreakpoint* cbpt = code_breakpoints_; - while (cbpt != NULL) { + while (cbpt != nullptr) { if (code.ptr() == cbpt->code_) { return true; } @@ -533,9 +533,9 @@ void Debugger::PrintBreakpointsToJSONArray(JSONArray* jsarr) const { void Debugger::PrintBreakpointsListToJSONArray(BreakpointLocation* sbpt, JSONArray* jsarr) const { - while (sbpt != NULL) { + while (sbpt != nullptr) { Breakpoint* bpt = sbpt->breakpoints(); - while (bpt != NULL) { + while (bpt != nullptr) { jsarr->AddValue(bpt); bpt = bpt->next(); } @@ -687,7 +687,7 @@ void ActivationFrame::PrintDescriptorsError(const char* message) { Thread::Current(), StackFrameIterator::kNoCrossThreadIteration); StackFrame* frame = frames.NextFrame(); - while (frame != NULL) { + while (frame != nullptr) { OS::PrintErr("%s\n", frame->ToCString()); frame = frames.NextFrame(); } @@ -862,7 +862,7 @@ ActivationFrame* DebuggerStackTrace::GetHandlerFrame( return frame; } } - return NULL; + return nullptr; } void ActivationFrame::GetDescIndices() { @@ -1062,7 +1062,7 @@ void ActivationFrame::PrintContextMismatchError(intptr_t ctx_slot, StackFrameIterator::kNoCrossThreadIteration); StackFrame* frame = iterator.NextFrame(); intptr_t num = 0; - while ((frame != NULL)) { + while ((frame != nullptr)) { OS::PrintErr("#%04" Pd " %s\n", num++, frame->ToCString()); frame = iterator.NextFrame(); } @@ -1077,19 +1077,19 @@ void ActivationFrame::VariableAt(intptr_t i, GetDescIndices(); ASSERT(i < desc_indices_.length()); intptr_t desc_index = desc_indices_[i]; - ASSERT(name != NULL); + ASSERT(name != nullptr); *name = var_descriptors_.GetName(desc_index); UntaggedLocalVarDescriptors::VarInfo var_info; var_descriptors_.GetInfo(desc_index, &var_info); - ASSERT(declaration_token_pos != NULL); + ASSERT(declaration_token_pos != nullptr); *declaration_token_pos = var_info.declaration_pos; - ASSERT(visible_start_token_pos != NULL); + ASSERT(visible_start_token_pos != nullptr); *visible_start_token_pos = var_info.begin_pos; - ASSERT(visible_end_token_pos != NULL); + ASSERT(visible_end_token_pos != nullptr); *visible_end_token_pos = var_info.end_pos; - ASSERT(value != NULL); + ASSERT(value != nullptr); const int8_t kind = var_info.kind(); const auto variable_index = VariableIndex(var_info.index()); if (kind == UntaggedLocalVarDescriptors::kStackVar) { @@ -1426,7 +1426,7 @@ CodeBreakpoint::CodeBreakpoint(const Code& code, : code_(code.ptr()), pc_(pc), enabled_count_(0), - next_(NULL), + next_(nullptr), breakpoint_kind_(kind), saved_value_(Code::null()) { ASSERT(!code.IsNull()); @@ -1443,7 +1443,7 @@ CodeBreakpoint::~CodeBreakpoint() { #ifdef DEBUG code_ = Code::null(); pc_ = 0ul; - next_ = NULL; + next_ = nullptr; breakpoint_kind_ = UntaggedPcDescriptors::kOther; #endif } @@ -1513,30 +1513,30 @@ GroupDebugger::~GroupDebugger() { Debugger::Debugger(Isolate* isolate) : isolate_(isolate), next_id_(1), - latent_locations_(NULL), - breakpoint_locations_(NULL), + latent_locations_(nullptr), + breakpoint_locations_(nullptr), resume_action_(kContinue), resume_frame_index_(-1), post_deopt_frame_index_(-1), ignore_breakpoints_(false), - pause_event_(NULL), - stack_trace_(NULL), - async_causal_stack_trace_(NULL), - awaiter_stack_trace_(NULL), + pause_event_(nullptr), + stack_trace_(nullptr), + async_causal_stack_trace_(nullptr), + awaiter_stack_trace_(nullptr), stepping_fp_(0), last_stepping_fp_(0), last_stepping_pos_(TokenPosition::kNoSource), skip_next_step_(false), - synthetic_async_breakpoint_(NULL), + synthetic_async_breakpoint_(nullptr), exc_pause_info_(kNoPauseOnExceptions) {} Debugger::~Debugger() { ASSERT(!IsPaused()); - ASSERT(latent_locations_ == NULL); - ASSERT(breakpoint_locations_ == NULL); - ASSERT(stack_trace_ == NULL); - ASSERT(async_causal_stack_trace_ == NULL); - ASSERT(synthetic_async_breakpoint_ == NULL); + ASSERT(latent_locations_ == nullptr); + ASSERT(breakpoint_locations_ == nullptr); + ASSERT(stack_trace_ == nullptr); + ASSERT(async_causal_stack_trace_ == nullptr); + ASSERT(synthetic_async_breakpoint_ == nullptr); } void Debugger::Shutdown() { @@ -1595,7 +1595,7 @@ bool Debugger::SetResumeAction(ResumeAction action, intptr_t frame_index, const char** error) { if (error != nullptr) { - *error = NULL; + *error = nullptr; } resume_frame_index_ = -1; switch (action) { @@ -1741,8 +1741,8 @@ static ArrayPtr DeoptimizeToArray(Thread* thread, Isolate* isolate = thread->isolate(); // Create the DeoptContext for this deoptimization. DeoptContext* deopt_context = - new DeoptContext(frame, code, DeoptContext::kDestIsAllocated, NULL, NULL, - true, false /* deoptimizing_code */); + new DeoptContext(frame, code, DeoptContext::kDestIsAllocated, nullptr, + nullptr, true, false /* deoptimizing_code */); isolate->set_deopt_context(deopt_context); deopt_context->FillDestFrame(); @@ -1750,7 +1750,7 @@ static ArrayPtr DeoptimizeToArray(Thread* thread, const Array& dest_frame = Array::Handle(thread->zone(), deopt_context->DestFrameAsArray()); - isolate->set_deopt_context(NULL); + isolate->set_deopt_context(nullptr); delete deopt_context; return dest_frame.ptr(); @@ -1769,7 +1769,7 @@ DebuggerStackTrace* DebuggerStackTrace::Collect() { Code& inlined_code = Code::Handle(zone); Array& deopt_frame = Array::Handle(zone); - for (StackFrame* frame = iterator.NextFrame(); frame != NULL; + for (StackFrame* frame = iterator.NextFrame(); frame != nullptr; frame = iterator.NextFrame()) { ASSERT(frame->IsValid()); if (FLAG_trace_debugger_stacktrace) { @@ -2000,7 +2000,7 @@ DebuggerStackTrace* DebuggerStackTrace::CollectAwaiterReturn() { ActivationFrame* activation = CollectDartFrame( isolate, it.pc(), frame, inlined_code, deopt_frame, deopt_frame_offset, ActivationFrame::kAsyncActivation); - ASSERT(activation != NULL); + ASSERT(activation != nullptr); stack_trace->AddActivation(activation); stack_has_async_function = true; // Grab the awaiter. @@ -2062,17 +2062,18 @@ static ActivationFrame* TopDartFrame() { } DebuggerStackTrace* Debugger::StackTrace() { - return (stack_trace_ != NULL) ? stack_trace_ : DebuggerStackTrace::Collect(); + return (stack_trace_ != nullptr) ? stack_trace_ + : DebuggerStackTrace::Collect(); } DebuggerStackTrace* Debugger::AsyncCausalStackTrace() { - return (async_causal_stack_trace_ != NULL) + return (async_causal_stack_trace_ != nullptr) ? async_causal_stack_trace_ : DebuggerStackTrace::CollectAsyncCausal(); } DebuggerStackTrace* Debugger::AwaiterStackTrace() { - return (awaiter_stack_trace_ != NULL) + return (awaiter_stack_trace_ != nullptr) ? awaiter_stack_trace_ : DebuggerStackTrace::CollectAwaiterReturn(); } @@ -2192,7 +2193,7 @@ void Debugger::PauseException(const Instance& exc) { DebuggerStackTrace* awaiter_stack_trace = DebuggerStackTrace::CollectAwaiterReturn(); DebuggerStackTrace* stack_trace = DebuggerStackTrace::Collect(); - if (awaiter_stack_trace != NULL) { + if (awaiter_stack_trace != nullptr) { if (!ShouldPauseOnException(awaiter_stack_trace, exc)) { return; } @@ -2465,7 +2466,7 @@ bool BreakpointLocation::EnsureIsResolved(const Function& target_function, void GroupDebugger::MakeCodeBreakpointAt(const Function& func, BreakpointLocation* loc) { ASSERT(loc->token_pos().IsReal()); - ASSERT((loc != NULL) && loc->IsResolved()); + ASSERT((loc != nullptr) && loc->IsResolved()); ASSERT(!func.HasOptimizedCode()); ASSERT(func.HasCode()); Code& code = Code::Handle(func.unoptimized_code()); @@ -2834,13 +2835,13 @@ BreakpointLocation* Debugger::SetBreakpoint( const Script& script = scripts.At(0); if (function.IsNull()) { if (!FindBestFit(script, token_pos, last_token_pos, &func)) { - return NULL; + return nullptr; } // If func was not set (still Null), the best fit is a field. } else { func = function.ptr(); if (!func.token_pos().IsReal()) { - return NULL; // Missing source positions? + return nullptr; // Missing source positions? } } if (!func.IsNull()) { @@ -2870,7 +2871,7 @@ BreakpointLocation* Debugger::SetBreakpoint( BreakpointLocation* loc = SetCodeBreakpoints(scripts, token_pos, last_token_pos, requested_line, requested_column, exact_token_pos, code_functions); - if (loc != NULL) { + if (loc != nullptr) { return loc; } } @@ -2897,7 +2898,7 @@ BreakpointLocation* Debugger::SetBreakpoint( const String& script_url = String::Handle(script.url()); BreakpointLocation* loc = GetBreakpointLocation(script_url, token_pos, -1, requested_column); - if (loc == NULL) { + if (loc == nullptr) { loc = new BreakpointLocation(this, scripts, token_pos, last_token_pos, requested_line, requested_column); RegisterBreakpointLocation(loc); @@ -2911,7 +2912,7 @@ void GroupDebugger::SyncBreakpointLocation(BreakpointLocation* loc) { bool any_enabled = loc->AnyEnabled(); SafepointWriteRwLocker sl(Thread::Current(), code_breakpoints_lock()); CodeBreakpoint* cbpt = code_breakpoints_; - while (cbpt != NULL) { + while (cbpt != nullptr) { if (cbpt->HasBreakpointLocation(loc)) { if (any_enabled) { cbpt->Enable(); @@ -2927,14 +2928,14 @@ Breakpoint* Debugger::SetBreakpointAtEntry(const Function& target_function, bool single_shot) { ASSERT(!target_function.IsNull()); if (!target_function.is_debuggable()) { - return NULL; + return nullptr; } const Script& script = Script::Handle(target_function.script()); BreakpointLocation* bpt_location = SetBreakpoint( script, target_function.token_pos(), target_function.end_token_pos(), -1, -1 /* no requested line/col */, target_function); - if (bpt_location == NULL) { - return NULL; + if (bpt_location == nullptr) { + return nullptr; } if (single_shot) { @@ -2947,7 +2948,7 @@ Breakpoint* Debugger::SetBreakpointAtEntry(const Function& target_function, Breakpoint* Debugger::SetBreakpointAtActivation(const Instance& closure, bool for_over_await) { if (!closure.IsClosure()) { - return NULL; + return nullptr; } const Function& func = Function::Handle(Closure::Cast(closure).function()); const Script& script = Script::Handle(func.script()); @@ -2959,13 +2960,13 @@ Breakpoint* Debugger::SetBreakpointAtActivation(const Instance& closure, Breakpoint* Debugger::BreakpointAtActivation(const Instance& closure) { if (!closure.IsClosure()) { - return NULL; + return nullptr; } BreakpointLocation* loc = breakpoint_locations_; - while (loc != NULL) { + while (loc != nullptr) { Breakpoint* bpt = loc->breakpoints(); - while (bpt != NULL) { + while (bpt != nullptr) { if (bpt->IsPerClosure()) { if (closure.ptr() == bpt->closure()) { return bpt; @@ -2976,7 +2977,7 @@ Breakpoint* Debugger::BreakpointAtActivation(const Instance& closure) { loc = loc->next(); } - return NULL; + return nullptr; } void Debugger::SetBreakpointAtResumption(const Object& function_data) { @@ -3021,10 +3022,10 @@ Breakpoint* Debugger::SetBreakpointAtLine(const String& script_url, BreakpointLocation* loc = BreakpointLocationAtLineCol(script_url, line_number, -1 /* no column */); - if (loc != NULL) { + if (loc != nullptr) { return loc->AddRepeated(this); } - return NULL; + return nullptr; } Breakpoint* Debugger::SetBreakpointAtLineCol(const String& script_url, @@ -3037,10 +3038,10 @@ Breakpoint* Debugger::SetBreakpointAtLineCol(const String& script_url, BreakpointLocation* loc = BreakpointLocationAtLineCol(script_url, line_number, column_number); - if (loc != NULL) { + if (loc != nullptr) { return loc->AddRepeated(this); } - return NULL; + return nullptr; } BreakpointLocation* Debugger::BreakpointLocationAtLineCol( @@ -3091,24 +3092,24 @@ BreakpointLocation* Debugger::BreakpointLocationAtLineCol( OS::PrintErr("Script '%s' does not contain line number %" Pd "\n", script_url.ToCString(), line_number); } - return NULL; + return nullptr; } else if (!last_token_idx.IsReal()) { // Line does not contain any tokens. if (FLAG_verbose_debug) { OS::PrintErr("No executable code at line %" Pd " in '%s'\n", line_number, script_url.ToCString()); } - return NULL; + return nullptr; } - BreakpointLocation* loc = NULL; + BreakpointLocation* loc = nullptr; ASSERT(first_token_idx <= last_token_idx); - while ((loc == NULL) && (first_token_idx <= last_token_idx)) { + while ((loc == nullptr) && (first_token_idx <= last_token_idx)) { loc = SetBreakpoint(scripts, first_token_idx, last_token_idx, line_number, column_number, Function::Handle()); first_token_idx = first_token_idx.Next(); } - if ((loc == NULL) && FLAG_verbose_debug) { + if ((loc == nullptr) && FLAG_verbose_debug) { OS::PrintErr("No executable code at line %" Pd " in '%s'\n", line_number, script_url.ToCString()); } @@ -3210,7 +3211,7 @@ void GroupDebugger::NotifyCompilation(const Function& function) { location->EnsureIsResolved(function, location->token_pos()); if (FLAG_verbose_debug) { Breakpoint* bpt = location->breakpoints(); - while (bpt != NULL) { + while (bpt != nullptr) { OS::PrintErr("Setting breakpoint %" Pd " for %s '%s'\n", bpt->id(), function.IsClosureFunction() ? "closure" : "function", function.ToFullyQualifiedCString()); @@ -3232,14 +3233,14 @@ void GroupDebugger::VisitObjectPointers(ObjectPointerVisitor* visitor) { // static void Debugger::VisitObjectPointers(ObjectPointerVisitor* visitor) { - ASSERT(visitor != NULL); + ASSERT(visitor != nullptr); BreakpointLocation* loc = breakpoint_locations_; - while (loc != NULL) { + while (loc != nullptr) { loc->VisitObjectPointers(visitor); loc = loc->next(); } loc = latent_locations_; - while (loc != NULL) { + while (loc != nullptr) { loc->VisitObjectPointers(visitor); loc = loc->next(); } @@ -3307,13 +3308,13 @@ void Debugger::ResetSteppingFramePointer() { } bool Debugger::SteppedForSyntheticAsyncBreakpoint() const { - return synthetic_async_breakpoint_ != NULL; + return synthetic_async_breakpoint_ != nullptr; } void Debugger::CleanupSyntheticAsyncBreakpoint() { - if (synthetic_async_breakpoint_ != NULL) { + if (synthetic_async_breakpoint_ != nullptr) { RemoveBreakpoint(synthetic_async_breakpoint_->id()); - synthetic_async_breakpoint_ = NULL; + synthetic_async_breakpoint_ = nullptr; } } @@ -3394,7 +3395,7 @@ void Debugger::HandleSteppingRequest(DebuggerStackTrace* stack_trace, StackFrameIterator::kNoCrossThreadIteration); StackFrame* frame = iterator.NextFrame(); intptr_t num = 0; - while ((frame != NULL)) { + while ((frame != nullptr)) { OS::PrintErr("#%04" Pd " %s\n", num++, frame->ToCString()); frame = iterator.NextFrame(); } @@ -3407,18 +3408,18 @@ void Debugger::HandleSteppingRequest(DebuggerStackTrace* stack_trace, void Debugger::CacheStackTraces(DebuggerStackTrace* stack_trace, DebuggerStackTrace* async_causal_stack_trace, DebuggerStackTrace* awaiter_stack_trace) { - ASSERT(stack_trace_ == NULL); + ASSERT(stack_trace_ == nullptr); stack_trace_ = stack_trace; - ASSERT(async_causal_stack_trace_ == NULL); + ASSERT(async_causal_stack_trace_ == nullptr); async_causal_stack_trace_ = async_causal_stack_trace; - ASSERT(awaiter_stack_trace_ == NULL); + ASSERT(awaiter_stack_trace_ == nullptr); awaiter_stack_trace_ = awaiter_stack_trace; } void Debugger::ClearCachedStackTraces() { - stack_trace_ = NULL; - async_causal_stack_trace_ = NULL; - awaiter_stack_trace_ = NULL; + stack_trace_ = nullptr; + async_causal_stack_trace_ = nullptr; + awaiter_stack_trace_ = nullptr; } static intptr_t FindNextRewindFrameIndex(DebuggerStackTrace* stack, @@ -3512,7 +3513,7 @@ void Debugger::RewindToFrame(intptr_t frame_index) { Thread::Current(), StackFrameIterator::kNoCrossThreadIteration); intptr_t current_frame = 0; - for (StackFrame* frame = iterator.NextFrame(); frame != NULL; + for (StackFrame* frame = iterator.NextFrame(); frame != nullptr; frame = iterator.NextFrame()) { ASSERT(frame->IsValid()); if (frame->IsDartFrame()) { @@ -3614,7 +3615,7 @@ void Debugger::RewindPostDeopt() { StackFrameIterator::kNoCrossThreadIteration); StackFrame* frame = iterator.NextFrame(); intptr_t num = 0; - while ((frame != NULL)) { + while ((frame != nullptr)) { OS::PrintErr("#%04" Pd " %s\n", num++, frame->ToCString()); frame = iterator.NextFrame(); } @@ -3628,7 +3629,7 @@ void Debugger::RewindPostDeopt() { Thread::Current(), StackFrameIterator::kNoCrossThreadIteration); intptr_t current_frame = 0; - for (StackFrame* frame = iterator.NextFrame(); frame != NULL; + for (StackFrame* frame = iterator.NextFrame(); frame != nullptr; frame = iterator.NextFrame()) { ASSERT(frame->IsValid()); if (frame->IsDartFrame()) { @@ -3730,9 +3731,9 @@ void Debugger::SignalPausedEvent(ActivationFrame* top_frame, Breakpoint* bpt) { ResetSteppingFramePointer(); NotifySingleStepping(false); ASSERT(!IsPaused()); - if ((bpt != NULL) && bpt->IsSingleShot()) { + if ((bpt != nullptr) && bpt->IsSingleShot()) { RemoveBreakpoint(bpt->id()); - bpt = NULL; + bpt = nullptr; } ServiceEvent event(isolate_, ServiceEvent::kPauseBreakpoint); @@ -3781,7 +3782,7 @@ ErrorPtr Debugger::PauseStepping() { // in a callee of that frame. Note that we assume that the stack // grows towards lower addresses. ActivationFrame* frame = TopDartFrame(); - ASSERT(frame != NULL); + ASSERT(frame != nullptr); if (stepping_fp_ != 0) { // There is an "interesting frame" set. Only pause at appropriate @@ -3846,7 +3847,7 @@ ErrorPtr Debugger::PauseStepping() { if (SteppedForSyntheticAsyncBreakpoint()) { CleanupSyntheticAsyncBreakpoint(); } - SignalPausedEvent(frame, NULL); + SignalPausedEvent(frame, nullptr); HandleSteppingRequest(stack_trace_); ClearCachedStackTraces(); @@ -3952,7 +3953,7 @@ Breakpoint* BreakpointLocation::FindHitBreakpoint(ActivationFrame* top_frame) { // First check for a single-shot breakpoint. Breakpoint* bpt = breakpoints(); - while (bpt != NULL) { + while (bpt != nullptr) { if (bpt->IsSingleShot()) { return bpt; } @@ -3961,7 +3962,7 @@ Breakpoint* BreakpointLocation::FindHitBreakpoint(ActivationFrame* top_frame) { // Now check for a closure-specific breakpoint. bpt = breakpoints(); - while (bpt != NULL) { + while (bpt != nullptr) { if (bpt->IsPerClosure()) { Closure& closure = Closure::Handle(top_frame->GetClosure()); if (closure.ptr() == bpt->closure()) { @@ -3973,14 +3974,14 @@ Breakpoint* BreakpointLocation::FindHitBreakpoint(ActivationFrame* top_frame) { // Finally, check for a general breakpoint. bpt = breakpoints(); - while (bpt != NULL) { + while (bpt != nullptr) { if (bpt->IsRepeated()) { return bpt; } bpt = bpt->next(); } - return NULL; + return nullptr; } void Debugger::PauseDeveloper(const String& msg) { @@ -4029,7 +4030,7 @@ static TokenPosition FindExactTokenPosition(const Script& script, #endif // !defined(DART_PRECOMPILED_RUNTIME) void Debugger::NotifyDoneLoading() { - if (latent_locations_ == NULL) { + if (latent_locations_ == nullptr) { // Common, fast path. return; } @@ -4040,12 +4041,12 @@ void Debugger::NotifyDoneLoading() { Script& script = Script::Handle(zone); String& url = String::Handle(zone); BreakpointLocation* loc = latent_locations_; - BreakpointLocation* prev_loc = NULL; + BreakpointLocation* prev_loc = nullptr; const GrowableObjectArray& libs = GrowableObjectArray::Handle(isolate_group->object_store()->libraries()); GrowableHandlePtrArray scripts(zone, 1); - while (loc != NULL) { + while (loc != nullptr) { url = loc->url(); bool found_match = false; bool is_package = url.StartsWith(Symbols::PackageScheme()); @@ -4062,7 +4063,7 @@ void Debugger::NotifyDoneLoading() { found_match = true; BreakpointLocation* matched_loc = loc; loc = loc->next(); - if (prev_loc == NULL) { + if (prev_loc == nullptr) { latent_locations_ = loc; } else { prev_loc->set_next(loc); @@ -4080,7 +4081,7 @@ void Debugger::NotifyDoneLoading() { // Script does not contain the given line number or there are no // tokens on the line. Drop the breakpoint silently. Breakpoint* bpt = matched_loc->breakpoints(); - while (bpt != NULL) { + while (bpt != nullptr) { if (FLAG_verbose_debug) { OS::PrintErr("No code found at line %" Pd ": " @@ -4098,8 +4099,8 @@ void Debugger::NotifyDoneLoading() { // the latent breakpoint in release build. BreakpointLocation* existing_loc = GetBreakpointLocation(url, first_token_pos, -1, column_number); - ASSERT(existing_loc == NULL); - if (existing_loc == NULL) { + ASSERT(existing_loc == nullptr); + if (existing_loc == nullptr) { // Create and register a new source breakpoint for the // latent breakpoint. BreakpointLocation* unresolved_loc = new BreakpointLocation( @@ -4110,8 +4111,8 @@ void Debugger::NotifyDoneLoading() { // Move breakpoints over. Breakpoint* bpt = matched_loc->breakpoints(); unresolved_loc->set_breakpoints(bpt); - matched_loc->set_breakpoints(NULL); - while (bpt != NULL) { + matched_loc->set_breakpoints(nullptr); + while (bpt != nullptr) { bpt->set_bpt_location(unresolved_loc); if (FLAG_verbose_debug) { OS::PrintErr( @@ -4140,7 +4141,7 @@ void Debugger::NotifyDoneLoading() { // No matching url found in any of the libraries. if (FLAG_verbose_debug) { Breakpoint* bpt = loc->breakpoints(); - while (bpt != NULL) { + while (bpt != nullptr) { OS::PrintErr( "No match found for latent breakpoint id " "%" Pd " with url '%s'\n", @@ -4163,7 +4164,7 @@ bool GroupDebugger::HasActiveBreakpoint(uword pc) { CodeBreakpoint* GroupDebugger::GetCodeBreakpoint(uword breakpoint_address) { CodeBreakpoint* cbpt = code_breakpoints_; - while (cbpt != NULL) { + while (cbpt != nullptr) { if (cbpt->pc() == breakpoint_address) { return cbpt; } @@ -4189,7 +4190,7 @@ BreakpointLocation* GroupDebugger::GetBreakpointLocationFor( } void GroupDebugger::RegisterCodeBreakpoint(CodeBreakpoint* cbpt) { - ASSERT(cbpt->next() == NULL); + ASSERT(cbpt->next() == nullptr); DEBUG_ASSERT(code_breakpoints_lock()->IsCurrentThreadWriter()); cbpt->set_next(code_breakpoints_); code_breakpoints_ = cbpt; @@ -4198,7 +4199,7 @@ void GroupDebugger::RegisterCodeBreakpoint(CodeBreakpoint* cbpt) { CodePtr GroupDebugger::GetPatchedStubAddress(uword breakpoint_address) { SafepointReadRwLocker sl(Thread::Current(), code_breakpoints_lock()); CodeBreakpoint* cbpt = GetCodeBreakpoint(breakpoint_address); - if (cbpt != NULL) { + if (cbpt != nullptr) { return cbpt->OrigStubAddress(); } UNREACHABLE(); @@ -4236,14 +4237,14 @@ void Debugger::RemoveBreakpoint(intptr_t bp_id) { // returns false, if breakpoint was not found. bool Debugger::RemoveBreakpointFromTheList(intptr_t bp_id, BreakpointLocation** list) { - BreakpointLocation* prev_loc = NULL; + BreakpointLocation* prev_loc = nullptr; BreakpointLocation* curr_loc = *list; - while (curr_loc != NULL) { - Breakpoint* prev_bpt = NULL; + while (curr_loc != nullptr) { + Breakpoint* prev_bpt = nullptr; Breakpoint* curr_bpt = curr_loc->breakpoints(); - while (curr_bpt != NULL) { + while (curr_bpt != nullptr) { if (curr_bpt->id() == bp_id) { - if (prev_bpt == NULL) { + if (prev_bpt == nullptr) { curr_loc->set_breakpoints(curr_bpt->next()); } else { prev_bpt->set_next(curr_bpt->next()); @@ -4253,22 +4254,22 @@ bool Debugger::RemoveBreakpointFromTheList(intptr_t bp_id, // poisoned and deleted. SendBreakpointEvent(ServiceEvent::kBreakpointRemoved, curr_bpt); - curr_bpt->set_next(NULL); - curr_bpt->set_bpt_location(NULL); + curr_bpt->set_next(nullptr); + curr_bpt->set_bpt_location(nullptr); // Remove possible references to the breakpoint. - if (pause_event_ != NULL && pause_event_->breakpoint() == curr_bpt) { - pause_event_->set_breakpoint(NULL); + if (pause_event_ != nullptr && pause_event_->breakpoint() == curr_bpt) { + pause_event_->set_breakpoint(nullptr); } if (synthetic_async_breakpoint_ == curr_bpt) { - synthetic_async_breakpoint_ = NULL; + synthetic_async_breakpoint_ = nullptr; } delete curr_bpt; - curr_bpt = NULL; + curr_bpt = nullptr; // Delete the breakpoint location object if there are no more // breakpoints at that location. - if (curr_loc->breakpoints() == NULL) { - if (prev_loc == NULL) { + if (curr_loc->breakpoints() == nullptr) { + if (prev_loc == nullptr) { *list = curr_loc->next(); } else { prev_loc->set_next(curr_loc->next()); @@ -4380,7 +4381,7 @@ BreakpointLocation* Debugger::GetBreakpointLocation( TokenPosition code_token_pos) { BreakpointLocation* loc = breakpoint_locations_; String& loc_url = String::Handle(); - while (loc != NULL) { + while (loc != nullptr) { loc_url = loc->url(); if (script_url.Equals(loc_url) && (!token_pos.IsReal() || (loc->token_pos() == token_pos)) && @@ -4394,12 +4395,12 @@ BreakpointLocation* Debugger::GetBreakpointLocation( } loc = loc->next(); } - return NULL; + return nullptr; } Breakpoint* Debugger::GetBreakpointById(intptr_t id) { Breakpoint* bpt = GetBreakpointByIdInTheList(id, breakpoint_locations_); - if (bpt != NULL) { + if (bpt != nullptr) { return bpt; } return GetBreakpointByIdInTheList(id, latent_locations_); @@ -4408,9 +4409,9 @@ Breakpoint* Debugger::GetBreakpointById(intptr_t id) { Breakpoint* Debugger::GetBreakpointByIdInTheList(intptr_t id, BreakpointLocation* list) { BreakpointLocation* loc = list; - while (loc != NULL) { + while (loc != nullptr) { Breakpoint* bpt = loc->breakpoints(); - while (bpt != NULL) { + while (bpt != nullptr) { if (bpt->id() == id) { return bpt; } @@ -4418,7 +4419,7 @@ Breakpoint* Debugger::GetBreakpointByIdInTheList(intptr_t id, } loc = loc->next(); } - return NULL; + return nullptr; } void Debugger::MaybeAsyncStepInto(const Closure& async_op) { @@ -4456,7 +4457,7 @@ BreakpointLocation* Debugger::GetLatentBreakpoint(const String& url, intptr_t column) { BreakpointLocation* loc = latent_locations_; String& bpt_url = String::Handle(); - while (loc != NULL) { + while (loc != nullptr) { bpt_url = loc->url(); if (bpt_url.Equals(url) && (loc->requested_line_number() == line) && (loc->requested_column_number() == column)) { @@ -4474,7 +4475,7 @@ BreakpointLocation* Debugger::GetLatentBreakpoint(const String& url, void Debugger::RegisterBreakpointLocation(BreakpointLocation* loc) { SafepointWriteRwLocker sl(Thread::Current(), group_debugger()->breakpoint_locations_lock()); - ASSERT(loc->next() == NULL); + ASSERT(loc->next() == nullptr); loc->set_next(breakpoint_locations_); breakpoint_locations_ = loc; group_debugger()->RegisterBreakpointLocation(loc); diff --git a/runtime/vm/debugger.h b/runtime/vm/debugger.h index e9d883d91ef..1765e8ab509 100644 --- a/runtime/vm/debugger.h +++ b/runtime/vm/debugger.h @@ -48,7 +48,7 @@ class Breakpoint { Breakpoint(intptr_t id, BreakpointLocation* bpt_location) : id_(id), kind_(Breakpoint::kNone), - next_(NULL), + next_(nullptr), closure_(Instance::null()), bpt_location_(bpt_location), is_synthetic_async_(false) {} @@ -539,7 +539,7 @@ class DebuggerKeyValueTrait : public AllStatic { struct Pair { Key key; Value value; - Pair() : key(NULL), value(false) {} + Pair() : key(nullptr), value(false) {} Pair(const Key key, const Value& value) : key(key), value(value) {} Pair(const Pair& other) : key(other.key), value(other.value) {} Pair& operator=(const Pair&) = default; @@ -738,13 +738,13 @@ class Debugger { bool SetResumeAction(ResumeAction action, intptr_t frame_index = 1, - const char** error = NULL); + const char** error = nullptr); bool IsStepping() const { return resume_action_ != kContinue; } bool IsSingleStepping() const { return resume_action_ == kStepInto; } - bool IsPaused() const { return pause_event_ != NULL; } + bool IsPaused() const { return pause_event_ != nullptr; } bool ignore_breakpoints() const { return ignore_breakpoints_; } void set_ignore_breakpoints(bool ignore_breakpoints) { @@ -758,7 +758,7 @@ class Debugger { void EnterSingleStepMode(); // Indicates why the debugger is currently paused. If the debugger - // is not paused, this returns NULL. Note that the debugger can be + // is not paused, this returns nullptr. Note that the debugger can be // paused for breakpoints, isolate interruption, and (sometimes) // exceptions. const ServiceEvent* PauseEvent() const { return pause_event_; } @@ -928,7 +928,7 @@ class Debugger { bool ignore_breakpoints_; // Indicates why the debugger is currently paused. If the debugger - // is not paused, this is NULL. Note that the debugger can be + // is not paused, this is nullptr. Note that the debugger can be // paused for breakpoints, isolate interruption, and (sometimes) // exceptions. ServiceEvent* pause_event_; @@ -973,7 +973,7 @@ class DisableBreakpointsScope : public ValueObject { public: DisableBreakpointsScope(Debugger* debugger, bool disable) : debugger_(debugger) { - ASSERT(debugger_ != NULL); + ASSERT(debugger_ != nullptr); initial_state_ = debugger_->ignore_breakpoints(); debugger_->set_ignore_breakpoints(disable); } diff --git a/runtime/vm/debugger_api_impl_test.cc b/runtime/vm/debugger_api_impl_test.cc index edb14406620..0f7b5fa2bd1 100644 --- a/runtime/vm/debugger_api_impl_test.cc +++ b/runtime/vm/debugger_api_impl_test.cc @@ -39,9 +39,9 @@ namespace dart { } while (0) #define CHECK_AND_CAST(type, var, param) \ - type* var = NULL; \ + type* var = nullptr; \ do { \ - if (param == NULL) { \ + if (param == nullptr) { \ return Api::NewError("%s expects argument '%s' to be non-null.", \ CURRENT_FUNC, #param); \ } \ @@ -49,13 +49,13 @@ namespace dart { } while (0) #define CHECK_NOT_NULL(param) \ - if (param == NULL) { \ + if (param == nullptr) { \ return Api::NewError("%s expects argument '%s' to be non-null.", \ CURRENT_FUNC, #param); \ } #define CHECK_DEBUGGER(isolate) \ - if (isolate->debugger() == NULL) { \ + if (isolate->debugger() == nullptr) { \ return Api::NewError("%s requires debugger support.", CURRENT_FUNC); \ } @@ -103,7 +103,7 @@ DART_EXPORT Dart_Handle Dart_GetStackTraceFromError(Dart_Handle handle, StackTrace& dart_stacktrace = StackTrace::Handle(Z); dart_stacktrace ^= error.stacktrace(); if (dart_stacktrace.IsNull()) { - *trace = NULL; + *trace = nullptr; } else { *trace = reinterpret_cast( DebuggerStackTrace::From(dart_stacktrace)); @@ -124,16 +124,16 @@ Dart_ActivationFrameInfo(Dart_ActivationFrame activation_frame, intptr_t* column_number) { DARTSCOPE(Thread::Current()); CHECK_AND_CAST(ActivationFrame, frame, activation_frame); - if (function_name != NULL) { + if (function_name != nullptr) { *function_name = Api::NewHandle(T, frame->QualifiedFunctionName()); } - if (script_url != NULL) { + if (script_url != nullptr) { *script_url = Api::NewHandle(T, frame->SourceUrl()); } - if (line_number != NULL) { + if (line_number != nullptr) { *line_number = frame->LineNumber(); } - if (column_number != NULL) { + if (column_number != nullptr) { *column_number = frame->ColumnNumber(); } return Api::Success(); @@ -150,7 +150,7 @@ DART_EXPORT Dart_Handle Dart_SetBreakpoint(Dart_Handle script_url_in, Debugger* debugger = I->debugger(); bpt = debugger->SetBreakpointAtLineCol(script_url, line_number, -1); - if (bpt == NULL) { + if (bpt == nullptr) { return Api::NewError("%s: could not set breakpoint at line %" Pd " in '%s'", CURRENT_FUNC, line_number, script_url.ToCString()); @@ -218,7 +218,7 @@ DART_EXPORT Dart_Handle Dart_LibraryId(Dart_Handle library, if (lib.IsNull()) { RETURN_TYPE_ERROR(Z, library, Library); } - if (library_id == NULL) { + if (library_id == nullptr) { RETURN_NULL_ERROR(library_id); } *library_id = lib.index(); diff --git a/runtime/vm/debugger_api_impl_test.h b/runtime/vm/debugger_api_impl_test.h index 9b7c2a128bd..f794b507512 100644 --- a/runtime/vm/debugger_api_impl_test.h +++ b/runtime/vm/debugger_api_impl_test.h @@ -95,7 +95,7 @@ DART_EXPORT Dart_Handle Dart_SetBreakpoint(Dart_Handle script_url, intptr_t line_number); /** - * Returns in \trace the current stack trace, or NULL if the + * Returns in \trace the current stack trace, or nullptr if the * VM is not paused. * * Requires there to be a current isolate. @@ -147,7 +147,7 @@ DART_EXPORT Dart_Handle Dart_GetActivationFrame(Dart_StackTrace trace, * \col_number receives the column number in the script, or -1 if column * information is not available * - * Any or all of the out parameters above may be NULL. + * Any or all of the out parameters above may be nullptr. * * Requires there to be a current isolate. * diff --git a/runtime/vm/deferred_objects.cc b/runtime/vm/deferred_objects.cc index 339edfdf5ec..adf2adebe60 100644 --- a/runtime/vm/deferred_objects.cc +++ b/runtime/vm/deferred_objects.cc @@ -211,14 +211,14 @@ void DeferredPp::Materialize(DeoptContext* deopt_context) { } ObjectPtr DeferredObject::object() { - if (object_ == NULL) { + if (object_ == nullptr) { Create(); } return object_->ptr(); } void DeferredObject::Create() { - if (object_ != NULL) { + if (object_ != nullptr) { return; } diff --git a/runtime/vm/deferred_objects.h b/runtime/vm/deferred_objects.h index 9f2609c9c77..60738bacbc9 100644 --- a/runtime/vm/deferred_objects.h +++ b/runtime/vm/deferred_objects.h @@ -187,7 +187,7 @@ class DeferredObject { DeferredObject(intptr_t field_count, intptr_t* args) : field_count_(field_count), args_(reinterpret_cast(args)), - object_(NULL) {} + object_(nullptr) {} intptr_t ArgumentCount() const { return kFieldsStartIndex + kFieldEntrySize * field_count_; diff --git a/runtime/vm/deopt_instructions.cc b/runtime/vm/deopt_instructions.cc index 775400f8e2e..2cabea6df1b 100644 --- a/runtime/vm/deopt_instructions.cc +++ b/runtime/vm/deopt_instructions.cc @@ -37,10 +37,10 @@ DeoptContext::DeoptContext(const StackFrame* frame, object_pool_(code.GetObjectPool()), deopt_info_(TypedData::null()), dest_frame_is_allocated_(false), - dest_frame_(NULL), + dest_frame_(nullptr), dest_frame_size_(0), source_frame_is_allocated_(false), - source_frame_(NULL), + source_frame_(nullptr), source_frame_size_(0), cpu_registers_(cpu_registers), fpu_registers_(fpu_registers), @@ -49,9 +49,9 @@ DeoptContext::DeoptContext(const StackFrame* frame, deopt_flags_(0), thread_(Thread::Current()), deopt_start_micros_(0), - deferred_slots_(NULL), + deferred_slots_(nullptr), deferred_objects_count_(0), - deferred_objects_(NULL), + deferred_objects_(nullptr), is_lazy_deopt_(is_lazy_deopt), deoptimizing_code_(deoptimizing_code) { const TypedData& deopt_info = TypedData::Handle( @@ -92,7 +92,7 @@ DeoptContext::DeoptContext(const StackFrame* frame, // Work from a copy of the source frame. intptr_t* original_frame = source_frame_; source_frame_ = new intptr_t[source_frame_size_]; - ASSERT(source_frame_ != NULL); + ASSERT(source_frame_ != nullptr); for (intptr_t i = 0; i < source_frame_size_; i++) { source_frame_[i] = original_frame[i]; } @@ -104,7 +104,7 @@ DeoptContext::DeoptContext(const StackFrame* frame, if (dest_options == kDestIsAllocated) { dest_frame_ = new intptr_t[dest_frame_size_]; - ASSERT(source_frame_ != NULL); + ASSERT(source_frame_ != nullptr); for (intptr_t i = 0; i < dest_frame_size_; i++) { dest_frame_[i] = 0; } @@ -132,28 +132,28 @@ DeoptContext::~DeoptContext() { if (source_frame_is_allocated_) { delete[] source_frame_; } - source_frame_ = NULL; + source_frame_ = nullptr; delete[] fpu_registers_; delete[] cpu_registers_; - fpu_registers_ = NULL; - cpu_registers_ = NULL; + fpu_registers_ = nullptr; + cpu_registers_ = nullptr; if (dest_frame_is_allocated_) { delete[] dest_frame_; } - dest_frame_ = NULL; + dest_frame_ = nullptr; // Delete all deferred objects. for (intptr_t i = 0; i < deferred_objects_count_; i++) { delete deferred_objects_[i]; } delete[] deferred_objects_; - deferred_objects_ = NULL; + deferred_objects_ = nullptr; deferred_objects_count_ = 0; #if defined(SUPPORT_TIMELINE) if (deopt_start_micros_ != 0) { TimelineStream* compiler_stream = Timeline::GetCompilerStream(); - ASSERT(compiler_stream != NULL); + ASSERT(compiler_stream != nullptr); if (compiler_stream->enabled()) { // Allocate all Dart objects needed before calling StartEvent, // which blocks safe points until Complete is called. @@ -164,7 +164,7 @@ DeoptContext::~DeoptContext() { const char* reason = DeoptReasonToCString(deopt_reason()); const int counter = function.deoptimization_counter(); TimelineEvent* timeline_event = compiler_stream->StartEvent(); - if (timeline_event != NULL) { + if (timeline_event != nullptr) { timeline_event->Duration("Deoptimize", deopt_start_micros_, OS::GetCurrentMonotonicMicros()); timeline_event->SetNumArguments(3); @@ -343,9 +343,9 @@ const CatchEntryMoves* DeoptContext::ToCatchEntryMoves(intptr_t num_vars) { static void FillDeferredSlots(DeoptContext* deopt_context, DeferredSlot** slot_list) { DeferredSlot* slot = *slot_list; - *slot_list = NULL; + *slot_list = nullptr; - while (slot != NULL) { + while (slot != nullptr) { DeferredSlot* current = slot; slot = slot->next(); @@ -377,7 +377,7 @@ intptr_t DeoptContext::MaterializeDeferredObjects() { DartFrameIterator iterator(Thread::Current(), StackFrameIterator::kNoCrossThreadIteration); StackFrame* top_frame = iterator.NextFrame(); - ASSERT(top_frame != NULL); + ASSERT(top_frame != nullptr); const Code& code = Code::Handle(top_frame->LookupDartCode()); const Function& top_function = Function::Handle(code.function()); const Script& script = Script::Handle(top_function.script()); @@ -398,7 +398,7 @@ intptr_t DeoptContext::MaterializeDeferredObjects() { } ArrayPtr DeoptContext::DestFrameAsArray() { - ASSERT(dest_frame_ != NULL && dest_frame_is_allocated_); + ASSERT(dest_frame_ != nullptr && dest_frame_is_allocated_); const Array& dest_array = Array::Handle(zone(), Array::New(dest_frame_size_)); PassiveObject& obj = PassiveObject::Handle(zone()); for (intptr_t i = 0; i < dest_frame_size_; i++) { @@ -883,7 +883,7 @@ uword DeoptInstr::GetRetAddress(DeoptInstr* instr, Zone* zone = thread->zone(); Function& function = Function::Handle(zone); function ^= object_table.ObjectAt(ret_address_instr->object_table_index()); - ASSERT(code != NULL); + ASSERT(code != nullptr); const Error& error = Error::Handle(zone, Compiler::EnsureUnoptimizedCode(thread, function)); if (!error.IsNull()) { @@ -938,7 +938,7 @@ DeoptInstr* DeoptInstr::Create(intptr_t kind_as_int, intptr_t source_index) { return new DeoptMaterializeObjectInstr(source_index); } UNREACHABLE(); - return NULL; + return nullptr; } const char* DeoptInstr::KindToCString(Kind kind) { @@ -980,14 +980,14 @@ const char* DeoptInstr::KindToCString(Kind kind) { return "mat"; } UNREACHABLE(); - return NULL; + return nullptr; } class DeoptInfoBuilder::TrieNode : public ZoneAllocated { public: // Construct the root node representing the implicit "shared" terminator // at the end of each deopt info. - TrieNode() : instruction_(NULL), info_number_(-1), children_(16) {} + TrieNode() : instruction_(nullptr), info_number_(-1), children_(16) {} // Construct a node representing a written instruction. TrieNode(DeoptInstr* instruction, intptr_t info_number) @@ -996,7 +996,7 @@ class DeoptInfoBuilder::TrieNode : public ZoneAllocated { intptr_t info_number() const { return info_number_; } void AddChild(TrieNode* child) { - if (child != NULL) children_.Add(child); + if (child != nullptr) children_.Add(child); } TrieNode* FindChild(const DeoptInstr& instruction) { @@ -1004,7 +1004,7 @@ class DeoptInfoBuilder::TrieNode : public ZoneAllocated { TrieNode* child = children_[i]; if (child->instruction_->Equals(instruction)) return child; } - return NULL; + return nullptr; } private: @@ -1087,7 +1087,7 @@ void DeoptInfoBuilder::AddPp(const Function& function, intptr_t dest_index) { void DeoptInfoBuilder::AddCopy(Value* value, const Location& source_loc, const intptr_t dest_index) { - DeoptInstr* deopt_instr = NULL; + DeoptInstr* deopt_instr = nullptr; if (source_loc.IsConstant()) { intptr_t object_table_index = FindOrAddObjectInTable(source_loc.constant()); deopt_instr = new (zone()) DeoptConstantInstr(object_table_index); @@ -1149,7 +1149,7 @@ void DeoptInfoBuilder::AddCopy(Value* value, } } ASSERT(dest_index == FrameSize()); - ASSERT(deopt_instr != NULL); + ASSERT(deopt_instr != nullptr); instructions_.Add(deopt_instr); } @@ -1196,7 +1196,7 @@ void DeoptInfoBuilder::AddMaterialization(MaterializeObjectInstr* mat) { for (intptr_t i = 0; i < mat->InputCount(); i++) { MaterializeObjectInstr* nested_mat = mat->InputAt(i)->definition()->AsMaterializeObject(); - if (nested_mat != NULL) { + if (nested_mat != nullptr) { AddMaterialization(nested_mat); } } @@ -1242,7 +1242,7 @@ TypedDataPtr DeoptInfoBuilder::CreateDeoptInfo(const Array& deopt_table) { if (FLAG_compress_deopt_info) { for (intptr_t i = length - 1; i >= 0; --i) { TrieNode* node = suffix->FindChild(*instructions_[i]); - if (node == NULL) break; + if (node == nullptr) break; suffix = node; ++suffix_length; } @@ -1404,7 +1404,7 @@ const char* DeoptInfo::ToCString(const Array& deopt_table, // Compute the buffer size required. intptr_t len = 1; // Trailing '\0'. for (intptr_t i = 0; i < deopt_instrs.length(); i++) { - len += Utils::SNPrint(NULL, 0, FORMAT, deopt_instrs[i]->ToCString()); + len += Utils::SNPrint(nullptr, 0, FORMAT, deopt_instrs[i]->ToCString()); } // Allocate the buffer. diff --git a/runtime/vm/deopt_instructions.h b/runtime/vm/deopt_instructions.h index cbd15c21594..0ee620f175d 100644 --- a/runtime/vm/deopt_instructions.h +++ b/runtime/vm/deopt_instructions.h @@ -49,7 +49,7 @@ class DeoptContext : public MallocAllocated { intptr_t DestStackAdjustment() const; intptr_t* GetSourceFrameAddressAt(intptr_t index) const { - ASSERT(source_frame_ != NULL); + ASSERT(source_frame_ != nullptr); ASSERT((0 <= index) && (index < source_frame_size_)); // Convert FP relative index to SP relative one. index = source_frame_size_ - 1 - index; @@ -78,13 +78,13 @@ class DeoptContext : public MallocAllocated { intptr_t RegisterValue(Register reg) const { ASSERT(reg >= 0); ASSERT(reg < kNumberOfCpuRegisters); - ASSERT(cpu_registers_ != NULL); + ASSERT(cpu_registers_ != nullptr); return cpu_registers_[reg]; } double FpuRegisterValue(FpuRegister reg) const { ASSERT(FlowGraphCompiler::SupportsUnboxedDoubles()); - ASSERT(fpu_registers_ != NULL); + ASSERT(fpu_registers_ != nullptr); ASSERT(reg >= 0); ASSERT(reg < kNumberOfFpuRegisters); return *reinterpret_cast(&fpu_registers_[reg]); @@ -92,7 +92,7 @@ class DeoptContext : public MallocAllocated { simd128_value_t FpuRegisterValueAsSimd128(FpuRegister reg) const { ASSERT(FlowGraphCompiler::SupportsUnboxedSimd128()); - ASSERT(fpu_registers_ != NULL); + ASSERT(fpu_registers_ != nullptr); ASSERT(reg >= 0); ASSERT(reg < kNumberOfFpuRegisters); const float* address = reinterpret_cast(&fpu_registers_[reg]); @@ -114,7 +114,7 @@ class DeoptContext : public MallocAllocated { } void set_dest_frame(const StackFrame* frame) { - ASSERT(frame != NULL && dest_frame_ == NULL); + ASSERT(frame != nullptr && dest_frame_ == nullptr); dest_frame_ = FrameBase(frame); } @@ -208,7 +208,7 @@ class DeoptContext : public MallocAllocated { private: intptr_t* GetDestFrameAddressAt(intptr_t index) const { - ASSERT(dest_frame_ != NULL); + ASSERT(dest_frame_ != nullptr); ASSERT((0 <= index) && (index < dest_frame_size_)); return &dest_frame_[index]; } @@ -295,7 +295,7 @@ class DeoptInstr : public ZoneAllocated { virtual const char* ToCString() const { const char* args = ArgumentsToCString(); - if (args != NULL) { + if (args != nullptr) { return Thread::Current()->zone()->PrintToString( "%s(%s)", KindToCString(kind()), args); } else { @@ -335,7 +335,7 @@ class DeoptInstr : public ZoneAllocated { virtual intptr_t source_index() const = 0; - virtual const char* ArgumentsToCString() const { return NULL; } + virtual const char* ArgumentsToCString() const { return nullptr; } private: static const char* KindToCString(Kind kind); diff --git a/runtime/vm/dwarf.cc b/runtime/vm/dwarf.cc index 41b9580d2c1..e05694ec468 100644 --- a/runtime/vm/dwarf.cc +++ b/runtime/vm/dwarf.cc @@ -66,15 +66,15 @@ class InliningNode : public ZoneAllocated { position(position), start_pc_offset(start_pc_offset), end_pc_offset(-1), - children_head(NULL), - children_tail(NULL), - children_next(NULL) { + children_head(nullptr), + children_tail(nullptr), + children_next(nullptr) { ASSERT(!function.IsNull()); DEBUG_ASSERT(function.IsNotTemporaryScopedHandle()); } void AppendChild(InliningNode* child) { - if (children_tail == NULL) { + if (children_tail == nullptr) { children_head = children_tail = child; } else { children_tail->children_next = child; @@ -181,7 +181,7 @@ void Dwarf::AddCode(const Code& orig_code, intptr_t label) { intptr_t Dwarf::AddFunction(const Function& function) { RELEASE_ASSERT(!function.IsNull()); FunctionIndexPair* pair = function_to_index_.Lookup(&function); - if (pair != NULL) { + if (pair != nullptr) { return pair->index_; } intptr_t index = functions_.length(); @@ -196,7 +196,7 @@ intptr_t Dwarf::AddFunction(const Function& function) { intptr_t Dwarf::AddScript(const Script& script) { RELEASE_ASSERT(!script.IsNull()); ScriptIndexPair* pair = script_to_index_.Lookup(&script); - if (pair != NULL) { + if (pair != nullptr) { return pair->index_; } // DWARF file numbers start from 1. @@ -210,7 +210,7 @@ intptr_t Dwarf::AddScript(const Script& script) { intptr_t Dwarf::LookupFunction(const Function& function) { RELEASE_ASSERT(!function.IsNull()); FunctionIndexPair* pair = function_to_index_.Lookup(&function); - if (pair == NULL) { + if (pair == nullptr) { FATAL("Function detected too late during DWARF generation: %s", function.ToCString()); } @@ -220,7 +220,7 @@ intptr_t Dwarf::LookupFunction(const Function& function) { intptr_t Dwarf::LookupScript(const Script& script) { RELEASE_ASSERT(!script.IsNull()); ScriptIndexPair* pair = script_to_index_.Lookup(&script); - if (pair == NULL) { + if (pair == nullptr) { FATAL("Script detected too late during DWARF generation: %s", script.ToCString()); } @@ -405,8 +405,8 @@ void Dwarf::WriteConcreteFunctions(DwarfWriteStream* stream) { stream->u1(function.is_visible() ? 0 : 1); InliningNode* node = ExpandInliningTree(code); - if (node != NULL) { - for (InliningNode* child = node->children_head; child != NULL; + if (node != nullptr) { + for (InliningNode* child = node->children_head; child != nullptr; child = child->children_next) { WriteInliningNode(stream, child, label, script); } @@ -424,7 +424,7 @@ InliningNode* Dwarf::ExpandInliningTree(const Code& code) { const CodeSourceMap& map = CodeSourceMap::Handle(zone_, code.code_source_map()); if (map.IsNull()) { - return NULL; + return nullptr; } const Array& functions = Array::Handle(zone_, code.inlined_id_to_function()); const Function& root_function = Function::ZoneHandle(zone_, code.function()); @@ -521,7 +521,7 @@ void Dwarf::WriteInliningNode(DwarfWriteStream* stream, // DW_at_call_column stream->uleb128(node->position.column()); - for (InliningNode* child = node->children_head; child != NULL; + for (InliningNode* child = node->children_head; child != nullptr; child = child->children_next) { WriteInliningNode(stream, child, root_label, script); } diff --git a/runtime/vm/dwarf.h b/runtime/vm/dwarf.h index fef33e45eb4..91c677b41ff 100644 --- a/runtime/vm/dwarf.h +++ b/runtime/vm/dwarf.h @@ -41,7 +41,7 @@ struct ScriptIndexPair { DEBUG_ASSERT(s->IsNotTemporaryScopedHandle()); } - ScriptIndexPair() : script_(NULL), index_(-1) {} + ScriptIndexPair() : script_(nullptr), index_(-1) {} void Print() const; @@ -73,7 +73,7 @@ struct FunctionIndexPair { DEBUG_ASSERT(f->IsNotTemporaryScopedHandle()); } - FunctionIndexPair() : function_(NULL), index_(-1) {} + FunctionIndexPair() : function_(nullptr), index_(-1) {} void Print() const; diff --git a/runtime/vm/elf.cc b/runtime/vm/elf.cc index be284e2fdd3..a0f1d257f5d 100644 --- a/runtime/vm/elf.cc +++ b/runtime/vm/elf.cc @@ -1237,7 +1237,7 @@ class DwarfElfStream : public DwarfWriteStream { DwarfElfStream(Zone* zone, NonStreamingWriteStream* stream) : zone_(ASSERT_NOTNULL(zone)), stream_(ASSERT_NOTNULL(stream)), - relocations_(new (zone) ZoneGrowableArray()) {} + relocations_(new(zone) ZoneGrowableArray()) {} const uint8_t* buffer() const { return stream_->buffer(); } intptr_t bytes_written() const { return stream_->bytes_written(); } diff --git a/runtime/vm/exceptions.cc b/runtime/vm/exceptions.cc index 4d42b7005f4..0294c306ecb 100644 --- a/runtime/vm/exceptions.cc +++ b/runtime/vm/exceptions.cc @@ -103,9 +103,9 @@ static void BuildStackTrace(StackTraceBuilder* builder) { Thread::Current(), StackFrameIterator::kNoCrossThreadIteration); StackFrame* frame = frames.NextFrame(); - ASSERT(frame != NULL); // We expect to find a dart invocation frame. + ASSERT(frame != nullptr); // We expect to find a dart invocation frame. Code& code = Code::Handle(); - for (; frame != NULL; frame = frames.NextFrame()) { + for (; frame != nullptr; frame = frames.NextFrame()) { if (!frame->IsDartFrame()) { continue; } @@ -130,13 +130,13 @@ class ExceptionHandlerFinder : public StackResource { Thread::Current(), StackFrameIterator::kNoCrossThreadIteration); StackFrame* frame = frames.NextFrame(); - if (frame == NULL) return false; // No Dart frame. + if (frame == nullptr) return false; // No Dart frame. handler_pc_set_ = false; needs_stacktrace = false; bool is_catch_all = false; uword temp_handler_pc = kUwordMax; bool is_optimized = false; - code_ = NULL; + code_ = nullptr; catch_entry_moves_cache_ = thread_->isolate()->catch_entry_moves_cache(); while (!frame->IsEntryFrame()) { @@ -156,7 +156,7 @@ class ExceptionHandlerFinder : public StackResource { code_ = &Code::Handle(frame->LookupDartCode()); CatchEntryMovesRefPtr* cached_catch_entry_moves = catch_entry_moves_cache_->Lookup(pc_); - if (cached_catch_entry_moves != NULL) { + if (cached_catch_entry_moves != nullptr) { cached_catch_entry_moves_ = *cached_catch_entry_moves; } if (cached_catch_entry_moves_.IsEmpty()) { @@ -184,7 +184,7 @@ class ExceptionHandlerFinder : public StackResource { } } // if frame->IsDartFrame frame = frames.NextFrame(); - ASSERT(frame != NULL); + ASSERT(frame != nullptr); } // while !frame->IsEntryFrame ASSERT(frame->IsEntryFrame()); if (!handler_pc_set_) { @@ -292,7 +292,7 @@ class ExceptionHandlerFinder : public StackResource { StackFrameIterator frames(ValidationPolicy::kDontValidateFrames, thread, StackFrameIterator::kNoCrossThreadIteration); bool found = false; - for (StackFrame* frame = frames.NextFrame(); frame != NULL; + for (StackFrame* frame = frames.NextFrame(); frame != nullptr; frame = frames.NextFrame()) { if (frame->fp() == handler_fp) { ASSERT_EQUAL(frame->pc(), static_cast(pc_)); @@ -319,13 +319,13 @@ class ExceptionHandlerFinder : public StackResource { void GetCatchEntryMovesFromDeopt(intptr_t num_vars, StackFrame* frame) { Isolate* isolate = thread_->isolate(); DeoptContext* deopt_context = - new DeoptContext(frame, *code_, DeoptContext::kDestIsAllocated, NULL, - NULL, true, false /* deoptimizing_code */); + new DeoptContext(frame, *code_, DeoptContext::kDestIsAllocated, nullptr, + nullptr, true, false /* deoptimizing_code */); isolate->set_deopt_context(deopt_context); catch_entry_moves_ = deopt_context->ToCatchEntryMoves(num_vars); - isolate->set_deopt_context(NULL); + isolate->set_deopt_context(nullptr); delete deopt_context; } #endif // !defined(DART_PRECOMPILED_RUNTIME) @@ -548,10 +548,10 @@ static void FindErrorHandler(uword* handler_pc, Thread::Current(), StackFrameIterator::kNoCrossThreadIteration); StackFrame* frame = frames.NextFrame(); - ASSERT(frame != NULL); + ASSERT(frame != nullptr); while (!frame->IsEntryFrame()) { frame = frames.NextFrame(); - ASSERT(frame != NULL); + ASSERT(frame != nullptr); } ASSERT(frame->IsEntryFrame()); *handler_pc = frame->pc(); @@ -844,7 +844,7 @@ static void ThrowExceptionHelper(Thread* thread, // runtime entry. The frame iterator points to the callee. ScriptPtr Exceptions::GetCallerScript(DartFrameIterator* iterator) { StackFrame* caller_frame = iterator->NextFrame(); - ASSERT(caller_frame != NULL && caller_frame->IsDartFrame()); + ASSERT(caller_frame != nullptr && caller_frame->IsDartFrame()); const Function& caller = Function::Handle(caller_frame->LookupDartFunction()); #if defined(DART_PRECOMPILED_RUNTIME) if (caller.IsNull()) return Script::null(); @@ -863,7 +863,7 @@ InstancePtr Exceptions::NewInstance(const char* class_name) { const String& cls_name = String::Handle(zone, Symbols::New(thread, class_name)); const Library& core_lib = Library::Handle(Library::CoreLibrary()); - // No ambiguity error expected: passing NULL. + // No ambiguity error expected: passing nullptr. Class& cls = Class::Handle(core_lib.LookupClass(cls_name)); ASSERT(!cls.IsNull()); // There are no parameterized error types, so no need to set type arguments. @@ -1099,7 +1099,7 @@ void Exceptions::ThrowLateFieldAssignedDuringInitialization( ObjectPtr Exceptions::Create(ExceptionType type, const Array& arguments) { Library& library = Library::Handle(); - const String* class_name = NULL; + const String* class_name = nullptr; const String* constructor_name = &Symbols::Dot(); switch (type) { case kNone: diff --git a/runtime/vm/exceptions_test.cc b/runtime/vm/exceptions_test.cc index 7fd62c6b3a4..3528493472a 100644 --- a/runtime/vm/exceptions_test.cc +++ b/runtime/vm/exceptions_test.cc @@ -30,7 +30,7 @@ void FUNCTION_NAME(Unhandled_equals)(Dart_NativeArguments args) { void FUNCTION_NAME(Unhandled_invoke)(Dart_NativeArguments args) { // Invoke the specified entry point. Dart_Handle cls = Dart_GetClass(TestCase::lib(), NewString("Second")); - Dart_Handle result = Dart_Invoke(cls, NewString("method2"), 0, NULL); + Dart_Handle result = Dart_Invoke(cls, NewString("method2"), 0, nullptr); ASSERT(Dart_IsError(result)); ASSERT(Dart_ErrorHasException(result)); return; @@ -39,7 +39,7 @@ void FUNCTION_NAME(Unhandled_invoke)(Dart_NativeArguments args) { void FUNCTION_NAME(Unhandled_invoke2)(Dart_NativeArguments args) { // Invoke the specified entry point. Dart_Handle cls = Dart_GetClass(TestCase::lib(), NewString("Second")); - Dart_Handle result = Dart_Invoke(cls, NewString("method2"), 0, NULL); + Dart_Handle result = Dart_Invoke(cls, NewString("method2"), 0, nullptr); ASSERT(Dart_IsError(result)); ASSERT(Dart_ErrorHasException(result)); Dart_Handle exception = Dart_ErrorGetException(result); @@ -66,13 +66,13 @@ static struct NativeEntries { static Dart_NativeFunction native_lookup(Dart_Handle name, int argument_count, bool* auto_setup_scope) { - ASSERT(auto_setup_scope != NULL); + ASSERT(auto_setup_scope != nullptr); *auto_setup_scope = true; TransitionNativeToVM transition(Thread::Current()); const Object& obj = Object::Handle(Api::UnwrapHandle(name)); ASSERT(obj.IsString()); const char* function_name = obj.ToCString(); - ASSERT(function_name != NULL); + ASSERT(function_name != nullptr); int num_entries = sizeof(BuiltinEntries) / sizeof(struct NativeEntries); for (int i = 0; i < num_entries; i++) { struct NativeEntries* entry = &(BuiltinEntries[i]); @@ -81,7 +81,7 @@ static Dart_NativeFunction native_lookup(Dart_Handle name, return reinterpret_cast(entry->function_); } } - return NULL; + return nullptr; } // Unit test case to verify unhandled exceptions. @@ -122,7 +122,7 @@ TEST_CASE(UnhandledExceptions) { } )"; Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, native_lookup); - EXPECT_VALID(Dart_Invoke(lib, NewString("testMain"), 0, NULL)); + EXPECT_VALID(Dart_Invoke(lib, NewString("testMain"), 0, nullptr)); } } // namespace dart diff --git a/runtime/vm/field_table.cc b/runtime/vm/field_table.cc index dcf59104b34..79567820424 100644 --- a/runtime/vm/field_table.cc +++ b/runtime/vm/field_table.cc @@ -145,7 +145,7 @@ void FieldTable::VisitObjectPointers(ObjectPointerVisitor* visitor) { return; } - ASSERT(visitor != NULL); + ASSERT(visitor != nullptr); visitor->set_gc_root_type("static fields table"); visitor->VisitPointers(&table_[0], &table_[top_ - 1]); visitor->clear_gc_root_type(); diff --git a/runtime/vm/field_table.h b/runtime/vm/field_table.h index cd25aa98b98..fbdd56831ac 100644 --- a/runtime/vm/field_table.h +++ b/runtime/vm/field_table.h @@ -114,7 +114,7 @@ class FieldTable { // so it will get freed when its are no longer in use. MallocGrowableArray* old_tables_; - // If non-NULL, it will specify the isolate this field table belongs to. + // If non-null, it will specify the isolate this field table belongs to. // Growing the field table will keep the cached field table on the isolate's // mutator thread up-to-date. Isolate* isolate_; diff --git a/runtime/vm/fixed_cache.h b/runtime/vm/fixed_cache.h index 0b2a5825496..8a40d6ac713 100644 --- a/runtime/vm/fixed_cache.h +++ b/runtime/vm/fixed_cache.h @@ -37,7 +37,7 @@ class FixedCache { intptr_t i = LowerBound(key); if (i != length_ && pairs_[i].key == key) return &pairs_[i].value; - return NULL; + return nullptr; } void Insert(K key, V value) { diff --git a/runtime/vm/fixed_cache_test.cc b/runtime/vm/fixed_cache_test.cc index b609310c750..e2d2e4f3617 100644 --- a/runtime/vm/fixed_cache_test.cc +++ b/runtime/vm/fixed_cache_test.cc @@ -11,11 +11,11 @@ namespace dart { UNIT_TEST_CASE(FixedCacheEmpty) { FixedCache cache; - EXPECT(cache.Lookup(0) == NULL); - EXPECT(cache.Lookup(1) == NULL); + EXPECT(cache.Lookup(0) == nullptr); + EXPECT(cache.Lookup(1) == nullptr); cache.Insert(1, 2); EXPECT(*cache.Lookup(1) == 2); - EXPECT(cache.Lookup(0) == NULL); + EXPECT(cache.Lookup(0) == nullptr); } UNIT_TEST_CASE(FixedCacheHalfFull) { @@ -36,9 +36,9 @@ UNIT_TEST_CASE(FixedCacheHalfFull) { EXPECT(strcmp(*cache.Lookup(40), "c") == 0); EXPECT(strcmp(*cache.Lookup(25), "bc") == 0); // Nonexistent - front, middle, end. - EXPECT(cache.Lookup(1) == NULL); - EXPECT(cache.Lookup(35) == NULL); - EXPECT(cache.Lookup(50) == NULL); + EXPECT(cache.Lookup(1) == nullptr); + EXPECT(cache.Lookup(35) == nullptr); + EXPECT(cache.Lookup(50) == nullptr); } struct Resource { @@ -71,14 +71,14 @@ UNIT_TEST_CASE(FixedCacheFullResource) { cache.Insert(40, Resource(16)); cache.Insert(30, Resource(8)); EXPECT(cache.Lookup(40)->id == 16); - EXPECT(cache.Lookup(5) == NULL); - EXPECT(cache.Lookup(0) == NULL); + EXPECT(cache.Lookup(5) == nullptr); + EXPECT(cache.Lookup(0) == nullptr); // Insert in the front, middle. cache.Insert(5, Resource(1)); cache.Insert(15, Resource(3)); cache.Insert(25, Resource(6)); // 40 got removed by shifting. - EXPECT(cache.Lookup(40) == NULL); + EXPECT(cache.Lookup(40) == nullptr); EXPECT(cache.Lookup(5)->id == 1); EXPECT(cache.Lookup(15)->id == 3); EXPECT(cache.Lookup(25)->id == 6); @@ -86,7 +86,7 @@ UNIT_TEST_CASE(FixedCacheFullResource) { // Insert at end top - 30 gets replaced by 40. cache.Insert(40, Resource(16)); EXPECT(cache.Lookup(40)->id == 16); - EXPECT(cache.Lookup(30) == NULL); + EXPECT(cache.Lookup(30) == nullptr); } EXPECT(Resource::copies == 0); } diff --git a/runtime/vm/flags.cc b/runtime/vm/flags.cc index ac00c35cd86..57ca81888a0 100644 --- a/runtime/vm/flags.cc +++ b/runtime/vm/flags.cc @@ -75,7 +75,7 @@ FLAG_LIST(PRODUCT_FLAG_MACRO, bool Flags::initialized_ = false; // List of registered flags. -Flag** Flags::flags_ = NULL; +Flag** Flags::flags_ = nullptr; intptr_t Flags::capacity_ = 0; intptr_t Flags::num_flags_ = 0; @@ -124,7 +124,7 @@ class Flag { break; } case kString: { - if (*this->charp_ptr_ != NULL) { + if (*this->charp_ptr_ != nullptr) { OS::Print("%s: '%s' (%s)\n", name_, *this->charp_ptr_, comment_); } else { OS::Print("%s: (null) (%s)\n", name_, comment_); @@ -143,7 +143,7 @@ class Flag { } bool IsUnrecognized() const { - return (type_ == kBoolean) && (bool_ptr_ == NULL); + return (type_ == kBoolean) && (bool_ptr_ == nullptr); } const char* name_; @@ -173,13 +173,13 @@ Flag* Flags::Lookup(const char* name) { return flag; } } - return NULL; + return nullptr; } bool Flags::IsSet(const char* name) { Flag* flag = Lookup(name); - return (flag != NULL) && (flag->type_ == Flag::kBoolean) && - (flag->bool_ptr_ != NULL) && (*flag->bool_ptr_ == true); + return (flag != nullptr) && (flag->type_ == Flag::kBoolean) && + (flag->bool_ptr_ != nullptr) && (*flag->bool_ptr_ == true); } void Flags::Cleanup() { @@ -190,7 +190,7 @@ void Flags::Cleanup() { void Flags::AddFlag(Flag* flag) { ASSERT(!initialized_); if (num_flags_ == capacity_) { - if (flags_ == NULL) { + if (flags_ == nullptr) { capacity_ = 256; flags_ = new Flag*[capacity_]; } else { @@ -212,7 +212,7 @@ bool Flags::Register_bool(bool* addr, bool default_value, const char* comment) { Flag* flag = Lookup(name); - if (flag != NULL) { + if (flag != nullptr) { ASSERT(flag->IsUnrecognized()); return default_value; } @@ -225,7 +225,7 @@ int Flags::Register_int(int* addr, const char* name, int default_value, const char* comment) { - ASSERT(Lookup(name) == NULL); + ASSERT(Lookup(name) == nullptr); Flag* flag = new Flag(name, comment, addr, Flag::kInteger); AddFlag(flag); @@ -237,7 +237,7 @@ uint64_t Flags::Register_uint64_t(uint64_t* addr, const char* name, uint64_t default_value, const char* comment) { - ASSERT(Lookup(name) == NULL); + ASSERT(Lookup(name) == nullptr); Flag* flag = new Flag(name, comment, addr, Flag::kUint64); AddFlag(flag); @@ -249,7 +249,7 @@ const char* Flags::Register_charp(charp* addr, const char* name, const char* default_value, const char* comment) { - ASSERT(Lookup(name) == NULL); + ASSERT(Lookup(name) == nullptr); Flag* flag = new Flag(name, comment, addr, Flag::kString); AddFlag(flag); return default_value; @@ -258,7 +258,7 @@ const char* Flags::Register_charp(charp* addr, bool Flags::RegisterFlagHandler(FlagHandler handler, const char* name, const char* comment) { - ASSERT(Lookup(name) == NULL); + ASSERT(Lookup(name) == nullptr); Flag* flag = new Flag(name, comment, handler); AddFlag(flag); return false; @@ -267,7 +267,7 @@ bool Flags::RegisterFlagHandler(FlagHandler handler, bool Flags::RegisterOptionHandler(OptionHandler handler, const char* name, const char* comment) { - ASSERT(Lookup(name) == NULL); + ASSERT(Lookup(name) == nullptr); Flag* flag = new Flag(name, comment, handler); AddFlag(flag); return false; @@ -302,7 +302,7 @@ bool Flags::SetFlagFromString(Flag* flag, const char* argument) { break; } case Flag::kInteger: { - char* endptr = NULL; + char* endptr = nullptr; const intptr_t len = strlen(argument); int base = 10; if ((len > 2) && (argument[0] == '0') && (argument[1] == 'x')) { @@ -317,7 +317,7 @@ bool Flags::SetFlagFromString(Flag* flag, const char* argument) { break; } case Flag::kUint64: { - char* endptr = NULL; + char* endptr = nullptr; const intptr_t len = strlen(argument); int base = 10; if ((len > 2) && (argument[0] == '0') && (argument[1] == 'x')) { @@ -363,7 +363,7 @@ void Flags::Parse(const char* option) { equals++; } - const char* argument = NULL; + const char* argument = nullptr; // Determine if this is an option argument. if (*equals != '=') { @@ -395,12 +395,12 @@ void Flags::Parse(const char* option) { Normalize(name); Flag* flag = Flags::Lookup(name); - if (flag == NULL) { + if (flag == nullptr) { // Collect unrecognized flags. char* new_flag = new char[name_len + 1]; strncpy(new_flag, option, name_len); new_flag[name_len] = '\0'; - Flags::Register_bool(NULL, new_flag, true, NULL); + Flags::Register_bool(nullptr, new_flag, true, nullptr); } else { // Only set values for recognized flags, skip collected // unrecognized flags. @@ -471,12 +471,12 @@ char* Flags::ProcessCommandLineFlags(int number_of_vm_flags, } initialized_ = true; - return NULL; + return nullptr; } bool Flags::SetFlag(const char* name, const char* value, const char** error) { Flag* flag = Lookup(name); - if (flag == NULL) { + if (flag == nullptr) { *error = "Cannot set flag: flag not found"; return false; } @@ -522,10 +522,10 @@ void Flags::PrintFlagToJSONArray(JSONArray* jsarr, const Flag* flag) { } case Flag::kString: { jsflag.AddProperty("_flagType", "String"); - if (flag->charp_ptr_ != NULL) { + if (flag->charp_ptr_ != nullptr) { jsflag.AddPropertyF("valueAsString", "%s", *flag->charp_ptr_); } else { - // valueAsString missing means NULL. + // valueAsString missing means nullptr. } break; } @@ -540,7 +540,7 @@ void Flags::PrintFlagToJSONArray(JSONArray* jsarr, const Flag* flag) { if (flag->string_value_ != nullptr) { jsflag.AddProperty("valueAsString", flag->string_value_.get()); } else { - // valueAsString missing means NULL. + // valueAsString missing means nullptr. } break; } diff --git a/runtime/vm/flags_test.cc b/runtime/vm/flags_test.cc index fdced0e459d..3ec41192a99 100644 --- a/runtime/vm/flags_test.cc +++ b/runtime/vm/flags_test.cc @@ -20,7 +20,7 @@ VM_UNIT_TEST_CASE(BasicFlags) { } DEFINE_FLAG(bool, parse_flag_bool_test, true, "Flags::Parse (bool) testing"); -DEFINE_FLAG(charp, string_opt_test, NULL, "Testing: string option."); +DEFINE_FLAG(charp, string_opt_test, nullptr, "Testing: string option."); DEFINE_FLAG(charp, entrypoint_test, "main", "Testing: entrypoint"); DEFINE_FLAG(int, counter, 100, "Testing: int flag"); @@ -35,16 +35,16 @@ VM_UNIT_TEST_CASE(ParseFlags) { Flags::Parse("parse_flag_bool_test=true"); EXPECT_EQ(true, FLAG_parse_flag_bool_test); - EXPECT_EQ(true, FLAG_string_opt_test == NULL); + EXPECT_EQ(true, FLAG_string_opt_test == nullptr); Flags::Parse("string_opt_test=doobidoo"); - EXPECT_EQ(true, FLAG_string_opt_test != NULL); + EXPECT_EQ(true, FLAG_string_opt_test != nullptr); EXPECT_EQ(0, strcmp(FLAG_string_opt_test, "doobidoo")); FLAG_string_opt_test = reinterpret_cast(0xDEADBEEF); Flags::Parse("string_opt_test=foofoo"); - EXPECT_EQ(true, FLAG_string_opt_test != NULL); + EXPECT_EQ(true, FLAG_string_opt_test != nullptr); EXPECT_EQ(0, strcmp(FLAG_string_opt_test, "foofoo")); - EXPECT_EQ(true, FLAG_entrypoint_test != NULL); + EXPECT_EQ(true, FLAG_entrypoint_test != nullptr); EXPECT_EQ(0, strcmp(FLAG_entrypoint_test, "main")); EXPECT_EQ(100, FLAG_counter); diff --git a/runtime/vm/globals.h b/runtime/vm/globals.h index a13f054112e..bcee6518127 100644 --- a/runtime/vm/globals.h +++ b/runtime/vm/globals.h @@ -129,7 +129,7 @@ const intptr_t kDefaultNewGenSemiMaxSize = (kWordSize <= 4) ? 8 : 16; // The expression OFFSET_OF_RETURNED_VALUE(type, accessor) computes the // byte-offset of the return value of the accessor to the containing type. // -// None of these use 0 or NULL, which causes a problem with the compiler +// None of these use 0 or nullptr, which causes a problem with the compiler // warnings we have enabled (which is also why 'offsetof' doesn't seem to work). // The workaround is to use the non-zero value kOffsetOfPtr. const intptr_t kOffsetOfPtr = 32; diff --git a/runtime/vm/guard_field_test.cc b/runtime/vm/guard_field_test.cc index 7645e46a8e3..fbaaec79fd9 100644 --- a/runtime/vm/guard_field_test.cc +++ b/runtime/vm/guard_field_test.cc @@ -61,8 +61,8 @@ TEST_CASE(GuardFieldSimpleTest) { " runBar();\n" " }\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(script_chars, NULL); - Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL); + Dart_Handle lib = TestCase::LoadTestScript(script_chars, nullptr); + Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, nullptr); EXPECT_VALID(result); TransitionNativeToVM transition(thread); Field& f1 = Field::ZoneHandle(LookupField(lib, "A", "f1")); @@ -112,8 +112,8 @@ TEST_CASE(GuardFieldFinalListTest) { " runBar();\n" " }\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(script_chars, NULL); - Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL); + Dart_Handle lib = TestCase::LoadTestScript(script_chars, nullptr); + Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, nullptr); EXPECT_VALID(result); TransitionNativeToVM transition(thread); Field& f1 = Field::ZoneHandle(LookupField(lib, "A", "f1")); @@ -165,8 +165,8 @@ TEST_CASE(GuardFieldFinalVariableLengthListTest) { " runBar();\n" " }\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(script_chars, NULL); - Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL); + Dart_Handle lib = TestCase::LoadTestScript(script_chars, nullptr); + Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, nullptr); EXPECT_VALID(result); TransitionNativeToVM transition(thread); Field& f1 = Field::ZoneHandle(LookupField(lib, "A", "f1")); @@ -222,8 +222,8 @@ TEST_CASE(GuardFieldConstructorTest) { " runBar();\n" " }\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(script_chars, NULL); - Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL); + Dart_Handle lib = TestCase::LoadTestScript(script_chars, nullptr); + Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, nullptr); EXPECT_VALID(result); TransitionNativeToVM transition(thread); Field& f1 = Field::ZoneHandle(LookupField(lib, "A", "f1")); @@ -271,8 +271,8 @@ TEST_CASE(GuardFieldConstructor2Test) { " runBar();\n" " }\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(script_chars, NULL); - Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL); + Dart_Handle lib = TestCase::LoadTestScript(script_chars, nullptr); + Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, nullptr); EXPECT_VALID(result); TransitionNativeToVM transition(thread); Field& f3 = Field::ZoneHandle(LookupField(lib, "A", "f3")); diff --git a/runtime/vm/handles.cc b/runtime/vm/handles.cc index 1a5984ad1e5..a5a58144f18 100644 --- a/runtime/vm/handles.cc +++ b/runtime/vm/handles.cc @@ -25,7 +25,7 @@ void VMHandles::VisitObjectPointers(ObjectPointerVisitor* visitor) { #if defined(DEBUG) static bool IsCurrentApiNativeScope(Zone* zone) { ApiNativeScope* scope = ApiNativeScope::Current(); - return (scope != NULL) && (scope->zone() == zone); + return (scope != nullptr) && (scope->zone() == zone); } #endif // DEBUG @@ -58,14 +58,14 @@ bool VMHandles::IsZoneHandle(uword handle) { int VMHandles::ScopedHandleCount() { Thread* thread = Thread::Current(); - ASSERT(thread->zone() != NULL); + ASSERT(thread->zone() != nullptr); VMHandles* handles = thread->zone()->handles(); return handles->CountScopedHandles(); } int VMHandles::ZoneHandleCount() { Thread* thread = Thread::Current(); - ASSERT(thread->zone() != NULL); + ASSERT(thread->zone() != nullptr); VMHandles* handles = thread->zone()->handles(); return handles->CountZoneHandles(); } @@ -73,7 +73,7 @@ int VMHandles::ZoneHandleCount() { void HandleScope::Initialize() { ASSERT(thread()->MayAllocateHandles()); VMHandles* handles = thread()->zone()->handles(); - ASSERT(handles != NULL); + ASSERT(handles != nullptr); saved_handle_block_ = handles->scoped_blocks_; saved_handle_slot_ = handles->scoped_blocks_->next_handle_slot(); #if defined(DEBUG) @@ -87,9 +87,9 @@ HandleScope::HandleScope(ThreadState* thread) : StackResource(thread) { } HandleScope::~HandleScope() { - ASSERT(thread()->zone() != NULL); + ASSERT(thread()->zone() != nullptr); VMHandles* handles = thread()->zone()->handles(); - ASSERT(handles != NULL); + ASSERT(handles != nullptr); #if defined(DEBUG) VMHandles::HandlesBlock* last = handles->scoped_blocks_; #endif diff --git a/runtime/vm/handles.h b/runtime/vm/handles.h index 9cb28f20e2c..a8a5b57b8e8 100644 --- a/runtime/vm/handles.h +++ b/runtime/vm/handles.h @@ -54,8 +54,8 @@ template class Handles { public: Handles() - : zone_blocks_(NULL), - first_scoped_block_(NULL), + : zone_blocks_(nullptr), + first_scoped_block_(nullptr), scoped_blocks_(&first_scoped_block_) {} ~Handles() { DeleteAll(); } @@ -209,7 +209,7 @@ class Handles { // Allocates space for a zone handle. uword AllocateHandleInZone() { - if (zone_blocks_ == NULL || zone_blocks_->IsFull()) { + if (zone_blocks_ == nullptr || zone_blocks_->IsFull()) { SetupNextZoneBlock(); } return zone_blocks_->AllocateHandle(); diff --git a/runtime/vm/handles_impl.h b/runtime/vm/handles_impl.h index d43e0e8a4cb..1f2ffee82cd 100644 --- a/runtime/vm/handles_impl.h +++ b/runtime/vm/handles_impl.h @@ -16,7 +16,7 @@ void Handles:: VisitObjectPointers(ObjectPointerVisitor* visitor) { // Visit all zone handles. HandlesBlock* block = zone_blocks_; - while (block != NULL) { + while (block != nullptr) { block->VisitObjectPointers(visitor); block = block->next_block(); } @@ -35,7 +35,7 @@ void Handles:: return; } block = block->next_block(); - } while (block != NULL); + } while (block != nullptr); UNREACHABLE(); } @@ -44,7 +44,7 @@ void Handles::Visit( HandleVisitor* visitor) { // Visit all zone handles. HandlesBlock* block = zone_blocks_; - while (block != NULL) { + while (block != nullptr) { block->Visit(visitor); block = block->next_block(); } @@ -54,14 +54,14 @@ void Handles::Visit( do { block->Visit(visitor); block = block->next_block(); - } while (block != NULL); + } while (block != nullptr); } template void Handles::Reset() { // Delete all the extra zone handle blocks allocated and reinit the first // zone block. - if (zone_blocks_ != NULL) { + if (zone_blocks_ != nullptr) { DeleteHandleBlocks(zone_blocks_->next_block()); zone_blocks_->ReInit(); } @@ -84,7 +84,7 @@ uword Handles:: ASSERT(thread->MayAllocateHandles()); #endif // DEBUG Handles* handles = zone->handles(); - ASSERT(handles != NULL); + ASSERT(handles != nullptr); return handles->AllocateScopedHandle(); } @@ -99,7 +99,7 @@ uword Handles:: ASSERT(thread->MayAllocateHandles()); #endif // DEBUG Handles* handles = zone->handles(); - ASSERT(handles != NULL); + ASSERT(handles != nullptr); uword address = handles->AllocateHandleInZone(); return address; } @@ -113,10 +113,10 @@ bool Handles:: // TODO(5411412): Accessing the current thread is a performance problem, // consider passing it down as a parameter. Thread* thread = Thread::Current(); - ASSERT(thread != NULL); - ASSERT(thread->zone() != NULL); + ASSERT(thread != nullptr); + ASSERT(thread->zone() != nullptr); Handles* handles = thread->zone()->handles(); - ASSERT(handles != NULL); + ASSERT(handles != nullptr); return handles->IsValidZoneHandle(handle); } #endif @@ -129,7 +129,7 @@ void Handles:: // since the individual zone deletions will be caught // by instrumentation in the BaseZone destructor. DeleteHandleBlocks(zone_blocks_); - zone_blocks_ = NULL; + zone_blocks_ = nullptr; // Delete all the scoped handle blocks. scoped_blocks_ = first_scoped_block_.next_block(); @@ -141,7 +141,7 @@ void Handles:: template void Handles:: DeleteHandleBlocks(HandlesBlock* blocks) { - while (blocks != NULL) { + while (blocks != nullptr) { HandlesBlock* block = blocks; blocks = blocks->next_block(); delete block; @@ -156,8 +156,8 @@ void Handles:: reinterpret_cast(this), CountZoneHandles(), CountScopedHandles()); } - if (scoped_blocks_->next_block() == NULL) { - HandlesBlock* block = new HandlesBlock(NULL); + if (scoped_blocks_->next_block() == nullptr) { + HandlesBlock* block = new HandlesBlock(nullptr); scoped_blocks_->set_next_block(block); } scoped_blocks_ = scoped_blocks_->next_block(); @@ -174,7 +174,7 @@ template bool Handles:: IsValidScopedHandle(uword handle) const { const HandlesBlock* iterator = &first_scoped_block_; - while (iterator != NULL) { + while (iterator != nullptr) { if (iterator->IsValidHandle(handle)) { return true; } @@ -187,7 +187,7 @@ template bool Handles:: IsValidZoneHandle(uword handle) const { const HandlesBlock* iterator = zone_blocks_; - while (iterator != NULL) { + while (iterator != nullptr) { if (iterator->IsValidHandle(handle)) { return true; } @@ -218,7 +218,7 @@ int Handles:: return count; } block = block->next_block(); - } while (block != NULL); + } while (block != nullptr); UNREACHABLE(); return 0; } @@ -228,7 +228,7 @@ int Handles:: CountZoneHandles() const { int count = 0; const HandlesBlock* block = zone_blocks_; - while (block != NULL) { + while (block != nullptr) { count += block->HandleCount(); block = block->next_block(); } @@ -247,7 +247,7 @@ template void Handles:: HandlesBlock::ReInit() { next_handle_slot_ = 0; - next_block_ = NULL; + next_block_ = nullptr; #if defined(DEBUG) ZapFreeHandles(); #endif @@ -256,7 +256,7 @@ void Handles:: template void Handles:: HandlesBlock::VisitObjectPointers(ObjectPointerVisitor* visitor) { - ASSERT(visitor != NULL); + ASSERT(visitor != nullptr); for (intptr_t i = 0; i < next_handle_slot_; i += kHandleSizeInWords) { visitor->VisitPointer( reinterpret_cast(&data_[i + kOffsetOfRawPtr / kWordSize])); @@ -266,7 +266,7 @@ void Handles:: template void Handles:: HandlesBlock::Visit(HandleVisitor* visitor) { - ASSERT(visitor != NULL); + ASSERT(visitor != nullptr); for (intptr_t i = 0; i < next_handle_slot_; i += kHandleSizeInWords) { visitor->VisitHandle(reinterpret_cast(&data_[i])); } diff --git a/runtime/vm/handles_test.cc b/runtime/vm/handles_test.cc index 32670898b7a..aef41d9a29a 100644 --- a/runtime/vm/handles_test.cc +++ b/runtime/vm/handles_test.cc @@ -84,7 +84,7 @@ TEST_CASE(CheckHandleValidity) { #if defined(DEBUG) FLAG_trace_handles = true; #endif - Dart_Handle handle = NULL; + Dart_Handle handle = nullptr; // Check validity using zone handles. { TransitionNativeToVM transition(thread); @@ -128,7 +128,7 @@ TEST_CASE(CheckHandleValidity) { // Check validity using weak persistent handle. handle = reinterpret_cast(Dart_NewWeakPersistentHandle( - Dart_NewStringFromCString("foo"), NULL, 0, NoopCallback)); + Dart_NewStringFromCString("foo"), nullptr, 0, NoopCallback)); EXPECT_NOTNULL(handle); EXPECT_VALID(handle); diff --git a/runtime/vm/hash_map_test.cc b/runtime/vm/hash_map_test.cc index 30ed7d1d076..6e31d50d9f1 100644 --- a/runtime/vm/hash_map_test.cc +++ b/runtime/vm/hash_map_test.cc @@ -33,7 +33,7 @@ TEST_CASE(DirectChainedHashMap) { EXPECT(map.LookupValue(&v2) == &v2); EXPECT(map.LookupValue(&v3) == &v1); EXPECT(map.Remove(&v1)); - EXPECT(map.Lookup(&v1) == NULL); + EXPECT(map.Lookup(&v1) == nullptr); map.Insert(&v1); DirectChainedHashMap> map2(map); EXPECT(map2.LookupValue(&v1) == &v1); @@ -52,7 +52,7 @@ TEST_CASE(DirectChainedHashMapInsertRemove) { map.Insert(&v1); EXPECT(map.LookupValue(&v1) == &v1); EXPECT(map.Remove(&v1)); - EXPECT(map.Lookup(&v1) == NULL); + EXPECT(map.Lookup(&v1) == nullptr); // Inserting v2 first should put it at the head of the list. map.Insert(&v2); @@ -62,7 +62,7 @@ TEST_CASE(DirectChainedHashMapInsertRemove) { // Check to see if removing the head of the list causes issues. EXPECT(map.Remove(&v2)); - EXPECT(map.Lookup(&v2) == NULL); + EXPECT(map.Lookup(&v2) == nullptr); EXPECT(map.LookupValue(&v1) == &v1); // Reinsert v2, which will place it at the back of the hash map list. @@ -71,9 +71,9 @@ TEST_CASE(DirectChainedHashMapInsertRemove) { // Remove from the back of the hash map list. EXPECT(map.Remove(&v2)); - EXPECT(map.Lookup(&v2) == NULL); + EXPECT(map.Lookup(&v2) == nullptr); EXPECT(map.Remove(&v1)); - EXPECT(map.Lookup(&v1) == NULL); + EXPECT(map.Lookup(&v1) == nullptr); // Check to see that removing an invalid element returns false. EXPECT(!map.Remove(&v1)); @@ -89,7 +89,7 @@ TEST_CASE(DirectChainedHashMapInsertRemove) { EXPECT(map.Remove(&v2)); EXPECT(map.LookupValue(&v1) == &v1); - EXPECT(map.Lookup(&v2) == NULL); + EXPECT(map.Lookup(&v2) == nullptr); EXPECT(map.LookupValue(&v3) == &v3); EXPECT(map.Remove(&v1)); @@ -164,7 +164,7 @@ TEST_CASE(DirectChainedHashMapIterator) { EXPECT(map.IsEmpty()); DirectChainedHashMap >::Iterator it = map.GetIterator(); - EXPECT(it.Next() == NULL); + EXPECT(it.Next() == nullptr); it.Reset(); map.Insert(p1); @@ -179,7 +179,7 @@ TEST_CASE(DirectChainedHashMapIterator) { intptr_t sum = 0; while (true) { IntptrPair* p = it.Next(); - if (p == NULL) { + if (p == nullptr) { break; } count++; diff --git a/runtime/vm/hash_table.h b/runtime/vm/hash_table.h index a8fc29f8b5a..4d84c7fb484 100644 --- a/runtime/vm/hash_table.h +++ b/runtime/vm/hash_table.h @@ -181,30 +181,30 @@ class HashTable : public HashTableBase { : key_handle_(key), smi_handle_(index), data_(data), - released_data_(NULL) {} + released_data_(nullptr) {} // Uses 'zone' for handle allocation. 'Release' must be called at the end // to obtain the final table after potential growth/shrinkage. HashTable(Zone* zone, typename StorageTraits::ArrayPtr data) : key_handle_(&Object::Handle(zone)), smi_handle_(&Smi::Handle(zone)), data_(&StorageTraits::PtrToHandle(data)), - released_data_(NULL) {} + released_data_(nullptr) {} // Returns the final table. The handle is cleared when this HashTable is // destroyed. typename StorageTraits::ArrayHandle& Release() { - ASSERT(data_ != NULL); - ASSERT(released_data_ == NULL); + ASSERT(data_ != nullptr); + ASSERT(released_data_ == nullptr); // Ensure that no methods are called after 'Release'. released_data_ = data_; - data_ = NULL; + data_ = nullptr; return *released_data_; } ~HashTable() { // In DEBUG mode, calling 'Release' is mandatory. - ASSERT(data_ == NULL); - if (released_data_ != NULL) { + ASSERT(data_ == nullptr); + if (released_data_ != nullptr) { StorageTraits::ClearHandle(*released_data_); } } @@ -285,7 +285,7 @@ class HashTable : public HashTableBase { template bool FindKeyOrDeletedOrUnused(const Key& key, intptr_t* entry) const { const intptr_t num_entries = NumEntries(); - ASSERT(entry != NULL); + ASSERT(entry != nullptr); NOT_IN_PRODUCT(intptr_t collisions = 0;) uword hash = KeyTraits::Hash(key); ASSERT(Utils::IsPowerOfTwo(num_entries)); @@ -513,7 +513,7 @@ class HashTable : public HashTableBase { Object* key_handle_; Smi* smi_handle_; - // Exactly one of these is non-NULL, depending on whether Release was called. + // Exactly one of these is non-null, depending on whether Release was called. typename StorageTraits::ArrayHandle* data_; typename StorageTraits::ArrayHandle* released_data_; @@ -697,9 +697,9 @@ class HashMap : public BaseIterTable { HashMap(Object* key, Smi* value, Array* data) : BaseIterTable(key, value, data) {} template - ObjectPtr GetOrNull(const Key& key, bool* present = NULL) const { + ObjectPtr GetOrNull(const Key& key, bool* present = nullptr) const { intptr_t entry = BaseIterTable::FindKey(key); - if (present != NULL) { + if (present != nullptr) { *present = (entry != -1); } return (entry == -1) ? Object::null() : BaseIterTable::GetPayload(entry, 0); @@ -837,9 +837,9 @@ class HashSet : public BaseIterTable { } template - ObjectPtr GetOrNull(const Key& key, bool* present = NULL) const { + ObjectPtr GetOrNull(const Key& key, bool* present = nullptr) const { intptr_t entry = BaseIterTable::FindKey(key); - if (present != NULL) { + if (present != nullptr) { *present = (entry != -1); } return (entry == -1) ? Object::null() : BaseIterTable::GetKey(entry); diff --git a/runtime/vm/image_snapshot.h b/runtime/vm/image_snapshot.h index a959f597483..8162763db3f 100644 --- a/runtime/vm/image_snapshot.h +++ b/runtime/vm/image_snapshot.h @@ -169,7 +169,7 @@ class ImageReader : public ZoneAllocated { struct ObjectOffsetPair { public: - ObjectOffsetPair() : ObjectOffsetPair(NULL, 0) {} + ObjectOffsetPair() : ObjectOffsetPair(nullptr, 0) {} ObjectOffsetPair(ObjectPtr obj, int32_t off) : object(obj), offset(off) {} ObjectPtr object; diff --git a/runtime/vm/instructions_ia32.h b/runtime/vm/instructions_ia32.h index ae82c3c44f7..ff1db5e5f76 100644 --- a/runtime/vm/instructions_ia32.h +++ b/runtime/vm/instructions_ia32.h @@ -38,7 +38,7 @@ class InstructionPattern : public ValueObject { // array of integers 'data'. 'data' elements are either a byte or -1, which // represents any byte. bool TestBytesWith(const int* data, int num_bytes) const { - ASSERT(data != NULL); + ASSERT(data != nullptr); const uint8_t* byte_array = reinterpret_cast(start_); for (int i = 0; i < num_bytes; i++) { // Skip comparison for data[i] < 0. diff --git a/runtime/vm/instructions_x64.h b/runtime/vm/instructions_x64.h index b7ed4f26cea..171daed283c 100644 --- a/runtime/vm/instructions_x64.h +++ b/runtime/vm/instructions_x64.h @@ -43,7 +43,7 @@ class InstructionPattern : public ValueObject { // array of integers 'data'. 'data' elements are either a byte or -1, which // represents any byte. bool TestBytesWith(const int* data, int num_bytes) const { - ASSERT(data != NULL); + ASSERT(data != nullptr); const uint8_t* byte_array = reinterpret_cast(start_); for (int i = 0; i < num_bytes; i++) { // Skip comparison for data[i] < 0. diff --git a/runtime/vm/isolate.cc b/runtime/vm/isolate.cc index 348a7e2e29b..2818dc6fe69 100644 --- a/runtime/vm/isolate.cc +++ b/runtime/vm/isolate.cc @@ -1215,7 +1215,7 @@ ErrorPtr IsolateMessageHandler::HandleLibMessage(const Array& message) { #if !defined(PRODUCT) // If we are already paused, don't pause again. - if (I->debugger()->PauseEvent() == NULL) { + if (I->debugger()->PauseEvent() == nullptr) { return I->debugger()->PauseInterrupted(); } #endif @@ -1757,7 +1757,7 @@ Isolate::Isolate(IsolateGroup* isolate_group, Isolate::~Isolate() { #if !defined(PRODUCT) && !defined(DART_PRECOMPILED_RUNTIME) // TODO(32796): Re-enable assertion. - // RELEASE_ASSERT(program_reload_context_ == NULL); + // RELEASE_ASSERT(program_reload_context_ == nullptr); #endif // !defined(PRODUCT) && !defined(DART_PRECOMPILED_RUNTIME) #if !defined(PRODUCT) @@ -1824,7 +1824,8 @@ Isolate* Isolate::InitIsolate(const char* name_prefix, #if !defined(PRODUCT) // Initialize metrics. #define ISOLATE_METRIC_INIT(type, variable, name, unit) \ - result->metric_##variable##_.InitInstance(result, name, NULL, Metric::unit); + result->metric_##variable##_.InitInstance(result, name, nullptr, \ + Metric::unit); ISOLATE_METRIC_LIST(ISOLATE_METRIC_INIT); #undef ISOLATE_METRIC_INIT #endif // !defined(PRODUCT) @@ -2346,7 +2347,7 @@ bool Isolate::NotifyErrorListeners(const char* message, msg.value.as_string = const_cast(message); arr_values[0] = &msg; Dart_CObject stack; - if (stacktrace == NULL) { + if (stacktrace == nullptr) { stack.type = Dart_CObject_kNull; } else { stack.type = Dart_CObject_kString; @@ -3644,7 +3645,7 @@ void Isolate::DecrementSpawnCount() { void Isolate::WaitForOutstandingSpawns() { Thread* thread = Thread::Current(); - ASSERT(thread != NULL); + ASSERT(thread != nullptr); MonitorLocker ml(&spawn_count_monitor_); while (spawn_count_ > 0) { ml.WaitWithSafepointCheck(thread); diff --git a/runtime/vm/isolate_reload.cc b/runtime/vm/isolate_reload.cc index 225113af4e4..af15f189e8e 100644 --- a/runtime/vm/isolate_reload.cc +++ b/runtime/vm/isolate_reload.cc @@ -76,7 +76,7 @@ class ObjectLocator : public ObjectVisitor { void VisitObject(ObjectPtr obj) { InstanceMorpher* morpher = context_->instance_morpher_by_cid_.LookupValue(obj->GetClassId()); - if (morpher != NULL) { + if (morpher != nullptr) { morpher->AddObject(obj); count_++; } @@ -522,7 +522,7 @@ ErrorPtr ReasonForCancelling::ToError() { StringPtr ReasonForCancelling::ToString() { UNREACHABLE(); - return NULL; + return nullptr; } void ReasonForCancelling::AppendTo(JSONArray* array) { @@ -673,7 +673,7 @@ ProgramReloadContext::ProgramReloadContext( // NOTE: DO NOT ALLOCATE ANY RAW OBJECTS HERE. The ProgramReloadContext is not // associated with the isolate yet and if a GC is triggered here the raw // objects will not be properly accounted for. - ASSERT(zone_ != NULL); + ASSERT(zone_ != nullptr); } ProgramReloadContext::~ProgramReloadContext() { @@ -813,7 +813,7 @@ bool IsolateGroupReloadContext::Reload(bool force_reload, // ReadKernelFromFile checks to see if the file at // root_script_url is a valid .dill file. If that's the case, a Program* // is returned. Otherwise, this is likely a source file that needs to be - // compiled, so ReadKernelFromFile returns NULL. + // compiled, so ReadKernelFromFile returns nullptr. kernel_program = kernel::Program::ReadFromFile(root_script_url); if (kernel_program != nullptr) { num_received_libs_ = kernel_program->library_count(); @@ -821,7 +821,7 @@ bool IsolateGroupReloadContext::Reload(bool force_reload, p_num_received_classes = &num_received_classes_; p_num_received_procedures = &num_received_procedures_; } else { - if (kernel_buffer == NULL || kernel_buffer_size == 0) { + if (kernel_buffer == nullptr || kernel_buffer_size == 0) { char* error = CompileToKernel(force_reload, packages_url, &kernel_buffer, &kernel_buffer_size); did_kernel_compilation = true; @@ -1532,7 +1532,7 @@ Dart_FileModifiedCallback IsolateGroupReloadContext::file_modified_callback_ = bool IsolateGroupReloadContext::ScriptModifiedSince(const Script& script, int64_t since) { - if (IsolateGroupReloadContext::file_modified_callback_ == NULL) { + if (IsolateGroupReloadContext::file_modified_callback_ == nullptr) { return true; } // We use the resolved url to determine if the script has been modified. @@ -1600,8 +1600,8 @@ void IsolateGroupReloadContext::FindModifiedSources( // In addition to all sources, we need to check if the .packages file // contents have been modified. - if (packages_url != NULL) { - if (IsolateGroupReloadContext::file_modified_callback_ == NULL || + if (packages_url != nullptr) { + if (IsolateGroupReloadContext::file_modified_callback_ == nullptr || (*IsolateGroupReloadContext::file_modified_callback_)(packages_url, last_reload)) { modified_sources_uris.Add(packages_url); @@ -1616,7 +1616,7 @@ void IsolateGroupReloadContext::FindModifiedSources( *modified_sources = Z->Alloc(*count); for (intptr_t i = 0; i < *count; ++i) { (*modified_sources)[i].uri = modified_sources_uris[i]; - (*modified_sources)[i].source = NULL; + (*modified_sources)[i].source = nullptr; } } diff --git a/runtime/vm/isolate_reload.h b/runtime/vm/isolate_reload.h index 3ae35d93412..25914cf4747 100644 --- a/runtime/vm/isolate_reload.h +++ b/runtime/vm/isolate_reload.h @@ -145,9 +145,9 @@ class IsolateGroupReloadContext { // If kernel_buffer is provided, the VM takes ownership when Reload is called. bool Reload(bool force_reload, - const char* root_script_url = NULL, - const char* packages_url = NULL, - const uint8_t* kernel_buffer = NULL, + const char* root_script_url = nullptr, + const char* packages_url = nullptr, + const uint8_t* kernel_buffer = nullptr, intptr_t kernel_buffer_size = 0); // All zone allocated objects must be allocated from this zone. diff --git a/runtime/vm/isolate_reload_test.cc b/runtime/vm/isolate_reload_test.cc index 645f8317575..6687e751599 100644 --- a/runtime/vm/isolate_reload_test.cc +++ b/runtime/vm/isolate_reload_test.cc @@ -21,7 +21,7 @@ namespace dart { #if !defined(PRODUCT) && !defined(DART_PRECOMPILED_RUNTIME) int64_t SimpleInvoke(Dart_Handle lib, const char* method) { - Dart_Handle result = Dart_Invoke(lib, NewString(method), 0, NULL); + Dart_Handle result = Dart_Invoke(lib, NewString(method), 0, nullptr); EXPECT_VALID(result); EXPECT(Dart_IsInteger(result)); int64_t integer_result = 0; @@ -31,15 +31,15 @@ int64_t SimpleInvoke(Dart_Handle lib, const char* method) { } const char* SimpleInvokeStr(Dart_Handle lib, const char* method) { - Dart_Handle result = Dart_Invoke(lib, NewString(method), 0, NULL); - const char* result_str = NULL; + Dart_Handle result = Dart_Invoke(lib, NewString(method), 0, nullptr); + const char* result_str = nullptr; EXPECT(Dart_IsString(result)); EXPECT_VALID(Dart_StringToCString(result, &result_str)); return result_str; } Dart_Handle SimpleInvokeError(Dart_Handle lib, const char* method) { - Dart_Handle result = Dart_Invoke(lib, NewString(method), 0, NULL); + Dart_Handle result = Dart_Invoke(lib, NewString(method), 0, nullptr); EXPECT(Dart_IsError(result)); return result; } @@ -50,7 +50,7 @@ TEST_CASE(IsolateReload_FunctionReplacement) { " return 4;\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); EXPECT_EQ(4, SimpleInvoke(lib, "main")); @@ -71,9 +71,9 @@ TEST_CASE(IsolateReload_IncrementalCompile) { "main() {\n" " return 42;\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, nullptr); EXPECT_VALID(lib); - Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL); + Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, nullptr); int64_t value = 0; result = Dart_IntegerToInt64(result, &value); EXPECT_VALID(result); @@ -86,7 +86,7 @@ TEST_CASE(IsolateReload_IncrementalCompile) { ""; lib = TestCase::ReloadTestScript(kUpdatedScriptChars); EXPECT_VALID(lib); - result = Dart_Invoke(lib, NewString("main"), 0, NULL); + result = Dart_Invoke(lib, NewString("main"), 0, nullptr); result = Dart_IntegerToInt64(result, &value); EXPECT_VALID(result); EXPECT_EQ(24, value); @@ -105,8 +105,8 @@ TEST_CASE(IsolateReload_KernelIncrementalCompile) { Dart_Handle lib = TestCase::LoadTestScriptWithDFE( sizeof(sourcefiles) / sizeof(Dart_SourceFile), sourcefiles, - NULL /* resolver */, true /* finalize */, true /* incrementally */); - Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL); + nullptr /* resolver */, true /* finalize */, true /* incrementally */); + Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, nullptr); int64_t value = 0; result = Dart_IntegerToInt64(result, &value); EXPECT_VALID(result); @@ -123,20 +123,20 @@ TEST_CASE(IsolateReload_KernelIncrementalCompile) { }}; // clang-format on { - const uint8_t* kernel_buffer = NULL; + const uint8_t* kernel_buffer = nullptr; intptr_t kernel_buffer_size = 0; char* error = TestCase::CompileTestScriptWithDFE( "file:///test-app", sizeof(updated_sourcefiles) / sizeof(Dart_SourceFile), updated_sourcefiles, &kernel_buffer, &kernel_buffer_size, true /* incrementally */); - EXPECT(error == NULL); + EXPECT(error == nullptr); EXPECT_NOTNULL(kernel_buffer); lib = TestCase::ReloadTestKernel(kernel_buffer, kernel_buffer_size); EXPECT_VALID(lib); } - result = Dart_Invoke(lib, NewString("main"), 0, NULL); + result = Dart_Invoke(lib, NewString("main"), 0, nullptr); result = Dart_IntegerToInt64(result, &value); EXPECT_VALID(result); EXPECT_EQ(24, value); @@ -162,9 +162,9 @@ TEST_CASE(IsolateReload_KernelIncrementalCompileAppAndLib) { Dart_Handle lib = TestCase::LoadTestScriptWithDFE( sizeof(sourcefiles) / sizeof(Dart_SourceFile), sourcefiles, - NULL /* resolver */, true /* finalize */, true /* incrementally */); + nullptr /* resolver */, true /* finalize */, true /* incrementally */); EXPECT_VALID(lib); - Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL); + Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, nullptr); int64_t value = 0; result = Dart_IntegerToInt64(result, &value); EXPECT_VALID(result); @@ -182,20 +182,20 @@ TEST_CASE(IsolateReload_KernelIncrementalCompileAppAndLib) { // clang-format on { - const uint8_t* kernel_buffer = NULL; + const uint8_t* kernel_buffer = nullptr; intptr_t kernel_buffer_size = 0; char* error = TestCase::CompileTestScriptWithDFE( "file:///test-app.dart", sizeof(updated_sourcefiles) / sizeof(Dart_SourceFile), updated_sourcefiles, &kernel_buffer, &kernel_buffer_size, true /* incrementally */); - EXPECT(error == NULL); + EXPECT(error == nullptr); EXPECT_NOTNULL(kernel_buffer); lib = TestCase::ReloadTestKernel(kernel_buffer, kernel_buffer_size); EXPECT_VALID(lib); } - result = Dart_Invoke(lib, NewString("main"), 0, NULL); + result = Dart_Invoke(lib, NewString("main"), 0, nullptr); result = Dart_IntegerToInt64(result, &value); EXPECT_VALID(result); EXPECT_EQ(24, value); @@ -230,9 +230,9 @@ TEST_CASE(IsolateReload_KernelIncrementalCompileGenerics) { Dart_Handle lib = TestCase::LoadTestScriptWithDFE( sizeof(sourcefiles) / sizeof(Dart_SourceFile), sourcefiles, - NULL /* resolver */, true /* finalize */, true /* incrementally */); + nullptr /* resolver */, true /* finalize */, true /* incrementally */); EXPECT_VALID(lib); - Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL); + Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, nullptr); int64_t value = 0; result = Dart_IntegerToInt64(result, &value); EXPECT_VALID(result); @@ -256,20 +256,20 @@ TEST_CASE(IsolateReload_KernelIncrementalCompileGenerics) { }}; // clang-format on { - const uint8_t* kernel_buffer = NULL; + const uint8_t* kernel_buffer = nullptr; intptr_t kernel_buffer_size = 0; char* error = TestCase::CompileTestScriptWithDFE( "file:///test-app.dart", sizeof(updated_sourcefiles) / sizeof(Dart_SourceFile), updated_sourcefiles, &kernel_buffer, &kernel_buffer_size, true /* incrementally */); - EXPECT(error == NULL); + EXPECT(error == nullptr); EXPECT_NOTNULL(kernel_buffer); lib = TestCase::ReloadTestKernel(kernel_buffer, kernel_buffer_size); EXPECT_VALID(lib); } - result = Dart_Invoke(lib, NewString("main"), 0, NULL); + result = Dart_Invoke(lib, NewString("main"), 0, nullptr); result = Dart_IntegerToInt64(result, &value); EXPECT_VALID(result); EXPECT_EQ(24, value); @@ -317,9 +317,9 @@ TEST_CASE(IsolateReload_KernelIncrementalCompileBaseClass) { Dart_Handle lib = TestCase::LoadTestScriptWithDFE( sizeof(sourcefiles) / sizeof(Dart_SourceFile), sourcefiles, - NULL /* resolver */, true /* finalize */, true /* incrementally */); + nullptr /* resolver */, true /* finalize */, true /* incrementally */); EXPECT_VALID(lib); - Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL); + Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, nullptr); int64_t value = 0; result = Dart_IntegerToInt64(result, &value); EXPECT_VALID(result); @@ -342,20 +342,20 @@ TEST_CASE(IsolateReload_KernelIncrementalCompileBaseClass) { kUpdatedSourceFile.get(), }}; { - const uint8_t* kernel_buffer = NULL; + const uint8_t* kernel_buffer = nullptr; intptr_t kernel_buffer_size = 0; char* error = TestCase::CompileTestScriptWithDFE( "file:///test-app.dart", sizeof(updated_sourcefiles) / sizeof(Dart_SourceFile), updated_sourcefiles, &kernel_buffer, &kernel_buffer_size, true /* incrementally */); - EXPECT(error == NULL); + EXPECT(error == nullptr); EXPECT_NOTNULL(kernel_buffer); lib = TestCase::ReloadTestKernel(kernel_buffer, kernel_buffer_size); EXPECT_VALID(lib); } - result = Dart_Invoke(lib, NewString("main"), 0, NULL); + result = Dart_Invoke(lib, NewString("main"), 0, nullptr); result = Dart_IntegerToInt64(result, &value); EXPECT_VALID(result); EXPECT_EQ(-1, value); @@ -372,7 +372,7 @@ TEST_CASE(IsolateReload_BadClass) { " return 4;\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); EXPECT_EQ(4, SimpleInvoke(lib, "main")); @@ -400,7 +400,7 @@ TEST_CASE(IsolateReload_StaticValuePreserved) { " return 'init()=${init()},value=${value}';\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); EXPECT_STREQ("init()=old value,value=old value", SimpleInvokeStr(lib, "main")); @@ -432,7 +432,7 @@ TEST_CASE(IsolateReload_SavedClosure) { " return closure();\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); EXPECT_STREQ("antediluvian!", SimpleInvokeStr(lib, "main")); @@ -460,7 +460,7 @@ TEST_CASE(IsolateReload_TopLevelFieldAdded) { " return 'value1=${value1}';\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); EXPECT_STREQ("value1=10", SimpleInvokeStr(lib, "main")); @@ -486,7 +486,7 @@ TEST_CASE(IsolateReload_ClassFieldAdded) { " return 44;\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); EXPECT_EQ(44, SimpleInvoke(lib, "main")); @@ -516,7 +516,7 @@ TEST_CASE(IsolateReload_ClassFieldAdded2) { " return 44;\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); EXPECT_EQ(44, SimpleInvoke(lib, "main")); @@ -547,7 +547,7 @@ TEST_CASE(IsolateReload_ClassFieldRemoved) { " return 44;\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); EXPECT_EQ(44, SimpleInvoke(lib, "main")); @@ -571,7 +571,7 @@ TEST_CASE(IsolateReload_ClassAdded) { " return 'hello';\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); EXPECT_STREQ("hello", SimpleInvokeStr(lib, "main")); @@ -600,7 +600,7 @@ TEST_CASE(IsolateReload_ClassRemoved) { " return list[0].toString();\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); EXPECT_STREQ("hello from A", SimpleInvokeStr(lib, "main")); @@ -643,7 +643,7 @@ TEST_CASE(IsolateReload_LibraryImportRemoved) { " return max(3, 4);\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); EXPECT_EQ(4, SimpleInvoke(lib, "main")); @@ -662,7 +662,7 @@ TEST_CASE(IsolateReload_LibraryDebuggable) { " return 1;\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); // The library is by default debuggable. Make it not debuggable. @@ -708,7 +708,7 @@ TEST_CASE(IsolateReload_ImplicitConstructorChanged) { " return 'saved:${savedA.field} new:${newA.field}';\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); EXPECT_STREQ("saved:20 new:20", SimpleInvokeStr(lib, "main")); @@ -745,7 +745,7 @@ TEST_CASE(IsolateReload_ConstructorChanged) { std::free); // clang-format on - Dart_Handle lib = TestCase::LoadTestScript(kScript.get(), NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript.get(), nullptr); EXPECT_VALID(lib); EXPECT_STREQ("saved:20 new:20", SimpleInvokeStr(lib, "main")); @@ -782,7 +782,7 @@ TEST_CASE(IsolateReload_SuperClassChanged) { " return (list.map((x) => '${x is A}/${x is B}')).toString();\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); EXPECT_STREQ("(true/false, true/true)", SimpleInvokeStr(lib, "main")); @@ -815,7 +815,7 @@ TEST_CASE(IsolateReload_Generics) { " return new B().toString();\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); EXPECT_STREQ("Instance of 'B'", SimpleInvokeStr(lib, "main")); @@ -845,7 +845,7 @@ TEST_CASE(IsolateReload_TypeIdentity) { " return identical(oldType, newType).toString();\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); const char* kReloadScript = @@ -876,7 +876,7 @@ TEST_CASE(IsolateReload_TypeIdentityGeneric) { " return identical(oldType, newType).toString();\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); const char* kReloadScript = @@ -908,7 +908,7 @@ TEST_CASE(IsolateReload_TypeIdentityParameter) { " return (oldType == newType).toString();\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); const char* kReloadScript = @@ -941,7 +941,7 @@ TEST_CASE(IsolateReload_MixinChanged) { " return 'saved:field=${saved.field},func=${saved.func()}';\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); EXPECT_STREQ("saved:field=mixin1,func=mixin1", SimpleInvokeStr(lib, "main")); @@ -989,7 +989,7 @@ TEST_CASE(IsolateReload_ComplexInheritanceChange) { " })).toString();\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); EXPECT_STREQ( "(a is A(true)/ B(false)/ C(false)," @@ -1070,7 +1070,7 @@ TEST_CASE(IsolateReload_LiveStack) { " return bar();\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); const char* kReloadScript = @@ -1101,7 +1101,7 @@ TEST_CASE(IsolateReload_LibraryLookup) { " return 'b';\n" "}\n"; Dart_Handle result; - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); EXPECT_STREQ("b", SimpleInvokeStr(lib, "main")); @@ -1219,7 +1219,7 @@ TEST_CASE(IsolateReload_SmiFastPathStubs) { " return x + y;\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); // Identity reload. @@ -1246,7 +1246,7 @@ TEST_CASE(IsolateReload_ImportedMixinFunction) { " return func();\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); EXPECT_STREQ("mixin", SimpleInvokeStr(lib, "main")); @@ -1271,7 +1271,7 @@ TEST_CASE(IsolateReload_TopLevelParseError) { " return 4;\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); EXPECT_EQ(4, SimpleInvoke(lib, "main")); @@ -1301,7 +1301,7 @@ TEST_CASE(IsolateReload_PendingUnqualifiedCall_StaticToInstance) { " return new C().test();\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); const char* kReloadScript = @@ -1324,7 +1324,7 @@ TEST_CASE(IsolateReload_PendingUnqualifiedCall_StaticToInstance) { EXPECT_STREQ(expected, result); // Bail out if we've already failed so we don't crash in the tag handler. - if ((result == NULL) || (strcmp(expected, result) != 0)) { + if ((result == nullptr) || (strcmp(expected, result) != 0)) { return; } @@ -1347,7 +1347,7 @@ TEST_CASE(IsolateReload_PendingUnqualifiedCall_InstanceToStatic) { " return new C().test();\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); const char* kReloadScript = @@ -1368,7 +1368,7 @@ TEST_CASE(IsolateReload_PendingUnqualifiedCall_InstanceToStatic) { const char* result = SimpleInvokeStr(lib, "main"); EXPECT_NOTNULL(result); // Bail out if we've already failed so we don't crash in StringEquals. - if (result == NULL) { + if (result == nullptr) { return; } EXPECT_STREQ(expected, result); @@ -1396,7 +1396,7 @@ TEST_CASE(IsolateReload_PendingConstructorCall_AbstractToConcrete) { " }\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); const char* kReloadScript = @@ -1424,7 +1424,7 @@ TEST_CASE(IsolateReload_PendingConstructorCall_AbstractToConcrete) { EXPECT_STREQ(expected, result); // Bail out if we've already failed so we don't crash in the tag handler. - if ((result == NULL) || (strcmp(expected, result) != 0)) { + if ((result == nullptr) || (strcmp(expected, result) != 0)) { return; } @@ -1452,7 +1452,7 @@ TEST_CASE(IsolateReload_PendingConstructorCall_ConcreteToAbstract) { " }\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); const char* kReloadScript = @@ -1495,7 +1495,7 @@ TEST_CASE(IsolateReload_PendingStaticCall_DefinedToNSM) { " }\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); const char* kReloadScript = @@ -1520,7 +1520,7 @@ TEST_CASE(IsolateReload_PendingStaticCall_DefinedToNSM) { EXPECT_NOTNULL(result); // Bail out if we've already failed so we don't crash in StringEquals. - if (result == NULL) { + if (result == nullptr) { return; } EXPECT_STREQ(expected, result); @@ -1547,7 +1547,7 @@ TEST_CASE(IsolateReload_PendingStaticCall_NSMToDefined) { " }\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); const char* kReloadScript = @@ -1573,7 +1573,7 @@ TEST_CASE(IsolateReload_PendingStaticCall_NSMToDefined) { const char* result = SimpleInvokeStr(lib, "main"); // Bail out if we've already failed so we don't crash in the tag handler. - if (result == NULL) { + if (result == nullptr) { return; } EXPECT_STREQ(expected, result); @@ -1601,7 +1601,7 @@ TEST_CASE(IsolateReload_PendingSuperCall) { " return new C().test();\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); const char* kReloadScript = @@ -1640,7 +1640,7 @@ TEST_CASE(IsolateReload_TearOff_Instance_Equality) { " return '${f1()} ${f2()} ${f1 == f2} ${identical(f1, f2)}';\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); const char* kReloadScript = @@ -1676,7 +1676,7 @@ TEST_CASE(IsolateReload_TearOff_Parameter_Count_Mismatch) { " return f1();\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); const char* kReloadScript = @@ -1715,7 +1715,7 @@ TEST_CASE(IsolateReload_TearOff_Remove) { " } catch(e) { return '$e'; }\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); const char* kReloadScript = @@ -1754,7 +1754,7 @@ TEST_CASE(IsolateReload_TearOff_Class_Identity) { " return '${f1()} ${f2()} ${f1 == f2} ${identical(f1, f2)}';\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); const char* kReloadScript = @@ -1790,7 +1790,7 @@ TEST_CASE(IsolateReload_TearOff_Library_Identity) { " return '${f1()} ${f2()} ${f1 == f2} ${identical(f1, f2)}';\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); const char* kReloadScript = @@ -1838,7 +1838,7 @@ TEST_CASE(IsolateReload_TearOff_List_Set) { " '${set.remove(c.foo)}';\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); const char* kReloadScript = @@ -1897,7 +1897,7 @@ TEST_CASE(IsolateReload_TearOff_AddArguments) { " return '$r1 $r2';\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); const char* kReloadScript = @@ -1953,7 +1953,7 @@ TEST_CASE(IsolateReload_TearOff_AddArguments2) { " return '$r1 $r2';\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); const char* kReloadScript = @@ -1999,7 +1999,7 @@ TEST_CASE(IsolateReload_EnumEquality) { " return Fruit.Apple.toString();\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); EXPECT_STREQ("Fruit.Apple", SimpleInvokeStr(lib, "main")); @@ -2035,7 +2035,7 @@ TEST_CASE(IsolateReload_EnumIdentical) { " return Fruit.Apple.toString();\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); EXPECT_STREQ("Fruit.Apple", SimpleInvokeStr(lib, "main")); @@ -2070,7 +2070,7 @@ TEST_CASE(IsolateReload_EnumReorderIdentical) { " return Fruit.Apple.toString();\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); EXPECT_STREQ("Fruit.Apple", SimpleInvokeStr(lib, "main")); @@ -2104,7 +2104,7 @@ TEST_CASE(IsolateReload_EnumAddition) { " return Fruit.Apple.toString();\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); EXPECT_STREQ("Fruit.Apple", SimpleInvokeStr(lib, "main")); @@ -2137,7 +2137,7 @@ TEST_CASE(IsolateReload_EnumToNotEnum) { " return Fruit.Apple.toString();\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); EXPECT_STREQ("Fruit.Apple", SimpleInvokeStr(lib, "main")); @@ -2162,7 +2162,7 @@ TEST_CASE(IsolateReload_NotEnumToEnum) { " return new Fruit().zero.toString();\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); EXPECT_STREQ("0", SimpleInvokeStr(lib, "main")); @@ -2191,7 +2191,7 @@ TEST_CASE(IsolateReload_EnumDelete) { " return Fruit.Apple.toString();\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); EXPECT_STREQ("Fruit.Apple", SimpleInvokeStr(lib, "main")); @@ -2236,7 +2236,7 @@ TEST_CASE(IsolateReload_EnumIdentityReload) { " return Fruit.Apple.toString();\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); EXPECT_STREQ("Fruit.Apple", SimpleInvokeStr(lib, "main")); @@ -2282,7 +2282,7 @@ TEST_CASE(IsolateReload_EnumShapeChange) { " return retained.toString();\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); EXPECT_STREQ("Fruit.Apple", SimpleInvokeStr(lib, "main")); @@ -2313,7 +2313,7 @@ TEST_CASE(IsolateReload_EnumShapeChangeAdd) { " return retained.toString();\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); EXPECT_STREQ("Fruit.Apple", SimpleInvokeStr(lib, "main")); @@ -2345,7 +2345,7 @@ TEST_CASE(IsolateReload_EnumShapeChangeRemove) { " return retained.toString();\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); EXPECT_STREQ("Fruit.Banana", SimpleInvokeStr(lib, "main")); @@ -2376,7 +2376,7 @@ TEST_CASE(IsolateReload_EnumShapeChangeValues) { " return retained.toString();\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); EXPECT_STREQ("[Fruit.Apple, Fruit.Banana]", SimpleInvokeStr(lib, "main")); @@ -2413,7 +2413,7 @@ TEST_CASE(IsolateReload_ConstantIdentical) { " return x.toString();\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); EXPECT_STREQ("Pear", SimpleInvokeStr(lib, "main")); @@ -3355,7 +3355,7 @@ TEST_CASE(IsolateReload_EnumValuesToString) { " return r;\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); EXPECT_STREQ("Fruit.Apple Fruit.Banana", SimpleInvokeStr(lib, "main")); @@ -3409,7 +3409,7 @@ ISOLATE_UNIT_TEST_CASE(IsolateReload_DirectSubclasses_Success) { { TransitionVMToNative transition(thread); - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); EXPECT_EQ(1, SimpleInvoke(lib, "main")); } @@ -3476,7 +3476,7 @@ ISOLATE_UNIT_TEST_CASE(IsolateReload_DirectSubclasses_GhostSubclass) { { TransitionVMToNative transition(thread); - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); EXPECT_EQ(1, SimpleInvoke(lib, "main")); } @@ -3550,7 +3550,7 @@ ISOLATE_UNIT_TEST_CASE(IsolateReload_DirectSubclasses_Failure) { { TransitionVMToNative transition(thread); - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); EXPECT_EQ(1, SimpleInvoke(lib, "main")); } @@ -3614,7 +3614,7 @@ TEST_CASE(IsolateReload_ChangeInstanceFormat0) { " return f.c;\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); EXPECT_EQ(42, SimpleInvoke(lib, "main")); @@ -3645,7 +3645,7 @@ TEST_CASE(IsolateReload_ChangeInstanceFormat1) { " return 42;\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); EXPECT_EQ(42, SimpleInvoke(lib, "main")); @@ -3678,7 +3678,7 @@ TEST_CASE(IsolateReload_ChangeInstanceFormat2) { " return f.c;\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); EXPECT_EQ(42, SimpleInvoke(lib, "main")); @@ -3720,7 +3720,7 @@ TEST_CASE(IsolateReload_ChangeInstanceFormat3) { " return f.c;\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); EXPECT_EQ(3, SimpleInvoke(lib, "main")); @@ -3758,7 +3758,7 @@ TEST_CASE(IsolateReload_ChangeInstanceFormat4) { " return f.c;\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); EXPECT_EQ(44, SimpleInvoke(lib, "main")); @@ -3795,7 +3795,7 @@ TEST_CASE(IsolateReload_ChangeInstanceFormat5) { " return f.c;\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); EXPECT_EQ(44, SimpleInvoke(lib, "main")); @@ -3829,7 +3829,7 @@ TEST_CASE(IsolateReload_ChangeInstanceFormat6) { " return 43;\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); EXPECT_EQ(43, SimpleInvoke(lib, "main")); @@ -3852,7 +3852,7 @@ TEST_CASE(IsolateReload_ChangeInstanceFormat7) { " var b;\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); const char* kReloadScript = @@ -3880,7 +3880,7 @@ TEST_CASE(IsolateReload_ChangeInstanceFormat8) { " return '$a $b';\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); EXPECT_STREQ("Instance of 'A' Instance of 'B'", SimpleInvokeStr(lib, "main")); @@ -3916,7 +3916,7 @@ TEST_CASE(IsolateReload_ChangeInstanceFormat9) { " return 43;\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); EXPECT_EQ(43, SimpleInvoke(lib, "main")); @@ -3946,7 +3946,7 @@ TEST_CASE(IsolateReload_ShapeChangeRetainsHash) { " return 'okay';\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); EXPECT_STREQ("okay", SimpleInvokeStr(lib, "main")); @@ -3978,7 +3978,7 @@ TEST_CASE(IsolateReload_ShapeChangeRetainsHash_Const) { " return 'okay';\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); EXPECT_STREQ("okay", SimpleInvokeStr(lib, "main")); @@ -4020,7 +4020,7 @@ TEST_CASE(IsolateReload_ShapeChange_Const_AddSlot) { } )"; - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); EXPECT_STREQ("okay", SimpleInvokeStr(lib, "main")); @@ -4076,7 +4076,7 @@ TEST_CASE(IsolateReload_ShapeChange_Const_RemoveSlot) { } )"; - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); EXPECT_STREQ("okay", SimpleInvokeStr(lib, "main")); @@ -4133,7 +4133,7 @@ TEST_CASE(IsolateReload_ConstToNonConstClass) { } )"; - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); EXPECT_STREQ("okay", SimpleInvokeStr(lib, "main")); @@ -4166,7 +4166,7 @@ TEST_CASE(IsolateReload_ConstToNonConstClass_Empty) { } )"; - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); EXPECT_STREQ("okay", SimpleInvokeStr(lib, "main")); @@ -4196,7 +4196,7 @@ TEST_CASE(IsolateReload_StaticTearOffRetainsHash) { " return 'okay';\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); EXPECT_STREQ("okay", SimpleInvokeStr(lib, "main")); @@ -4227,7 +4227,7 @@ TEST_CASE(IsolateReload_NoLibsModified) { " return importedFunc() + ' feast';\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); EXPECT_STREQ("fancy feast", SimpleInvokeStr(lib, "main")); @@ -4243,7 +4243,7 @@ TEST_CASE(IsolateReload_NoLibsModified) { Dart_SetFileModifiedCallback(&NothingModifiedCallback); lib = TestCase::ReloadTestScript(kReloadScript); EXPECT_VALID(lib); - Dart_SetFileModifiedCallback(NULL); + Dart_SetFileModifiedCallback(nullptr); // No reload occurred because no files were "modified". EXPECT_STREQ("fancy feast", SimpleInvokeStr(lib, "main")); @@ -4267,7 +4267,7 @@ TEST_CASE(IsolateReload_MainLibModified) { " return importedFunc() + ' feast';\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); EXPECT_STREQ("fancy feast", SimpleInvokeStr(lib, "main")); @@ -4283,7 +4283,7 @@ TEST_CASE(IsolateReload_MainLibModified) { Dart_SetFileModifiedCallback(&MainModifiedCallback); lib = TestCase::ReloadTestScript(kReloadScript); EXPECT_VALID(lib); - Dart_SetFileModifiedCallback(NULL); + Dart_SetFileModifiedCallback(nullptr); // Imported library is not reloaded. EXPECT_STREQ("fancy pants", SimpleInvokeStr(lib, "main")); @@ -4306,7 +4306,7 @@ TEST_CASE(IsolateReload_ImportedLibModified) { " return importedFunc() + ' feast';\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); EXPECT_STREQ("fancy feast", SimpleInvokeStr(lib, "main")); @@ -4322,7 +4322,7 @@ TEST_CASE(IsolateReload_ImportedLibModified) { Dart_SetFileModifiedCallback(&ImportModifiedCallback); lib = TestCase::ReloadTestScript(kReloadScript); EXPECT_VALID(lib); - Dart_SetFileModifiedCallback(NULL); + Dart_SetFileModifiedCallback(nullptr); // Modification of an imported library propagates to the importing library. EXPECT_STREQ("bossy pants", SimpleInvokeStr(lib, "main")); @@ -4338,7 +4338,7 @@ TEST_CASE(IsolateReload_PrefixImportedLibModified) { " return cobra.importedFunc() + ' feast';\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); EXPECT_STREQ("fancy feast", SimpleInvokeStr(lib, "main")); @@ -4354,7 +4354,7 @@ TEST_CASE(IsolateReload_PrefixImportedLibModified) { Dart_SetFileModifiedCallback(&ImportModifiedCallback); lib = TestCase::ReloadTestScript(kReloadScript); EXPECT_VALID(lib); - Dart_SetFileModifiedCallback(NULL); + Dart_SetFileModifiedCallback(nullptr); // Modification of an prefix-imported library propagates to the // importing library. @@ -4381,7 +4381,7 @@ TEST_CASE(IsolateReload_ExportedLibModified) { " return exportedFunc() + ' feast';\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); EXPECT_STREQ("fancy feast", SimpleInvokeStr(lib, "main")); @@ -4397,7 +4397,7 @@ TEST_CASE(IsolateReload_ExportedLibModified) { Dart_SetFileModifiedCallback(&ExportModifiedCallback); lib = TestCase::ReloadTestScript(kReloadScript); EXPECT_VALID(lib); - Dart_SetFileModifiedCallback(NULL); + Dart_SetFileModifiedCallback(nullptr); // Modification of an exported library propagates. EXPECT_STREQ("bossy pants", SimpleInvokeStr(lib, "main")); @@ -4410,7 +4410,7 @@ TEST_CASE(IsolateReload_SimpleConstFieldUpdate) { " return 'value=${value}';\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); EXPECT_STREQ("value=a", SimpleInvokeStr(lib, "main")); @@ -4432,7 +4432,7 @@ TEST_CASE(IsolateReload_ConstFieldUpdate) { " return 'value=${value}';\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); EXPECT_STREQ("value=0:00:01.000000", SimpleInvokeStr(lib, "main")); @@ -4463,7 +4463,7 @@ TEST_CASE(IsolateReload_RunNewFieldInitializers) { std::free); // clang-format on - Dart_Handle lib = TestCase::LoadTestScript(kScript.get(), NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript.get(), nullptr); EXPECT_VALID(lib); EXPECT_EQ(4, SimpleInvoke(lib, "main")); @@ -4506,7 +4506,7 @@ TEST_CASE(IsolateReload_RunNewFieldInitializersReferenceStaticField) { std::free); // clang-format on - Dart_Handle lib = TestCase::LoadTestScript(kScript.get(), NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript.get(), nullptr); EXPECT_VALID(lib); EXPECT_EQ(4, SimpleInvoke(lib, "main")); @@ -4553,7 +4553,7 @@ TEST_CASE(IsolateReload_RunNewFieldInitializersLazy) { std::free); // clang-format on - Dart_Handle lib = TestCase::LoadTestScript(kScript.get(), NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript.get(), nullptr); EXPECT_VALID(lib); EXPECT_EQ(4, SimpleInvoke(lib, "main")); @@ -4598,7 +4598,7 @@ TEST_CASE(IsolateReload_RunNewFieldInitializersLazyConst) { std::free); // clang-format on - Dart_Handle lib = TestCase::LoadTestScript(kScript.get(), NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript.get(), nullptr); EXPECT_VALID(lib); EXPECT_EQ(4, SimpleInvoke(lib, "main")); @@ -4663,7 +4663,7 @@ TEST_CASE(IsolateReload_RunNewFieldInitializersLazyTransitive) { std::free); // clang-format on - Dart_Handle lib = TestCase::LoadTestScript(kScript.get(), NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript.get(), nullptr); EXPECT_VALID(lib); EXPECT_EQ(4, SimpleInvoke(lib, "main")); @@ -4731,7 +4731,7 @@ TEST_CASE(IsolateReload_RunNewFieldInitializersThrows) { std::free); // clang-format on - Dart_Handle lib = TestCase::LoadTestScript(kScript.get(), NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript.get(), nullptr); EXPECT_VALID(lib); EXPECT_EQ(4, SimpleInvoke(lib, "main")); @@ -4777,7 +4777,7 @@ TEST_CASE(IsolateReload_RunNewFieldInitializersCyclicInitialization) { std::free); // clang-format on - Dart_Handle lib = TestCase::LoadTestScript(kScript.get(), NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript.get(), nullptr); EXPECT_VALID(lib); EXPECT_EQ(4, SimpleInvoke(lib, "main")); @@ -4823,7 +4823,7 @@ TEST_CASE(IsolateReload_RunNewFieldInitializersSyntaxError) { std::free); // clang-format on - Dart_Handle lib = TestCase::LoadTestScript(kScript.get(), NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript.get(), nullptr); EXPECT_VALID(lib); EXPECT_EQ(4, SimpleInvoke(lib, "main")); @@ -4869,7 +4869,7 @@ TEST_CASE(IsolateReload_RunNewFieldInitializersSyntaxError2) { std::free); // clang-format on - Dart_Handle lib = TestCase::LoadTestScript(kScript.get(), NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript.get(), nullptr); EXPECT_VALID(lib); EXPECT_EQ(4, SimpleInvoke(lib, "main")); @@ -4916,7 +4916,7 @@ TEST_CASE(IsolateReload_RunNewFieldInitializersSyntaxError3) { std::free); // clang-format on - Dart_Handle lib = TestCase::LoadTestScript(kScript.get(), NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript.get(), nullptr); EXPECT_VALID(lib); EXPECT_EQ(4, SimpleInvoke(lib, "main")); @@ -4965,7 +4965,7 @@ TEST_CASE(IsolateReload_RunNewFieldInitializersSuperClass) { std::free); // clang-format on - Dart_Handle lib = TestCase::LoadTestScript(kScript.get(), NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript.get(), nullptr); EXPECT_VALID(lib); EXPECT_EQ(0, SimpleInvoke(lib, "main")); @@ -5080,7 +5080,7 @@ TEST_CASE(IsolateReload_RunNewFieldInitializersWithGenerics) { std::free); // clang-format on - Dart_Handle lib = TestCase::LoadTestScript(kScript.get(), NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript.get(), nullptr); EXPECT_VALID(lib); EXPECT_STREQ("Okay", SimpleInvokeStr(lib, "main")); @@ -5118,7 +5118,7 @@ TEST_CASE(IsolateReload_AddNewStaticField) { " return 'Okay';\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); EXPECT_STREQ("Okay", SimpleInvokeStr(lib, "main")); @@ -5144,7 +5144,7 @@ TEST_CASE(IsolateReload_StaticFieldInitialValueDoesnotChange) { " return '${C.x}';\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); EXPECT_STREQ("42", SimpleInvokeStr(lib, "main")); @@ -5190,12 +5190,12 @@ TEST_CASE(IsolateReload_DeleteStaticField) { " return Foo.x;\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); intptr_t cid = 1118; { Dart_EnterScope(); - Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL); + Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, nullptr); EXPECT_VALID(result); { TransitionNativeToVM transition(thread); @@ -5215,7 +5215,7 @@ TEST_CASE(IsolateReload_DeleteStaticField) { lib = TestCase::ReloadTestScript(kReloadScript); EXPECT_VALID(lib); - Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL); + Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, nullptr); EXPECT_VALID(result); { TransitionNativeToVM transition(thread); @@ -5274,7 +5274,7 @@ static void TestReloadWithFieldChange(const char* prefix, verify), std::free); // clang-format on - Dart_Handle lib = TestCase::LoadTestScript(kScript.get(), NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript.get(), nullptr); EXPECT_VALID(lib); EXPECT_STREQ("Okay", SimpleInvokeStr(lib, "main")); @@ -5375,7 +5375,7 @@ TEST_CASE(IsolateReload_ExistingStaticFieldChangesType) { } )"; - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); EXPECT_STREQ("42", SimpleInvokeStr(lib, "main")); @@ -5416,7 +5416,7 @@ TEST_CASE(IsolateReload_ExistingFieldChangesTypeIndirect) { )", late_tag), std::free); // clang-format on - Dart_Handle lib = TestCase::LoadTestScript(kScript.get(), NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript.get(), nullptr); EXPECT_VALID(lib); EXPECT_STREQ("Okay", SimpleInvokeStr(lib, "main")); @@ -5457,7 +5457,7 @@ TEST_CASE(IsolateReload_ExistingStaticFieldChangesTypeIndirect) { } )"; - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); EXPECT_STREQ("Instance of 'B'", SimpleInvokeStr(lib, "main")); @@ -5500,7 +5500,7 @@ TEST_CASE(IsolateReload_ExistingFieldChangesTypeIndirectGeneric) { )", late_tag), std::free); // clang-format on - Dart_Handle lib = TestCase::LoadTestScript(kScript.get(), NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript.get(), nullptr); EXPECT_VALID(lib); EXPECT_STREQ("Okay", SimpleInvokeStr(lib, "main")); @@ -5542,7 +5542,7 @@ TEST_CASE(IsolateReload_ExistingStaticFieldChangesTypeIndirectGeneric) { } )"; - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); EXPECT_STREQ("[]", SimpleInvokeStr(lib, "main")); @@ -5587,7 +5587,7 @@ TEST_CASE(IsolateReload_ExistingFieldChangesTypeIndirectFunction) { )", late_tag), std::free); // clang-format on - Dart_Handle lib = TestCase::LoadTestScript(kScript.get(), NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript.get(), nullptr); EXPECT_VALID(lib); EXPECT_STREQ("Okay", SimpleInvokeStr(lib, "main")); @@ -5632,7 +5632,7 @@ TEST_CASE(IsolateReload_ExistingStaticFieldChangesTypeIndirectFunction) { } )"; - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); EXPECT_STREQ("Closure: (A) => bool", SimpleInvokeStr(lib, "main")); @@ -5670,7 +5670,7 @@ TEST_CASE(IsolateReload_TypedefToNotTypedef) { " return (42 is Predicate).toString();\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); EXPECT_STREQ("false", SimpleInvokeStr(lib, "main")); @@ -5695,7 +5695,7 @@ TEST_CASE(IsolateReload_NotTypedefToTypedef) { " return (42 is Predicate).toString();\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); EXPECT_STREQ("false", SimpleInvokeStr(lib, "main")); @@ -5720,7 +5720,7 @@ TEST_CASE(IsolateReload_TypedefAddParameter) { " return (foo is Predicate).toString();\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); EXPECT_STREQ("true", SimpleInvokeStr(lib, "main")); @@ -5744,7 +5744,7 @@ TEST_CASE(IsolateReload_PatchStaticInitializerWithClosure) { " return f('b');\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); EXPECT_STREQ("ab", SimpleInvokeStr(lib, "main")); @@ -5777,7 +5777,7 @@ TEST_CASE(IsolateReload_StaticTargetArityChange) { } )"; - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); EXPECT_STREQ("okay", SimpleInvokeStr(lib, "main")); @@ -5827,7 +5827,7 @@ TEST_CASE(IsolateReload_SuperGetterReboundToMethod) { } )"; - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); const char* kReloadScript = R"( @@ -5874,7 +5874,7 @@ static void CompileToKernel(Dart_SourceFile source, sources[0].uri, ARRAY_SIZE(sources), sources, kernel_buffer, kernel_buffer_size, /*incrementally=*/false); - EXPECT(error == NULL); + EXPECT(error == nullptr); EXPECT_NOTNULL(kernel_buffer); } @@ -6033,7 +6033,7 @@ TEST_CASE(IsolateReload_GenericConstructorTearOff) { } )"; - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); EXPECT_STREQ("okay", SimpleInvokeStr(lib, "main")); @@ -6108,7 +6108,7 @@ TEST_CASE(IsolateReload_EnumInMainLibraryModified) { " return Foo().toString();\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); EXPECT_VALID(Dart_FinalizeAllClasses()); EXPECT_STREQ("foo", SimpleInvokeStr(lib, "main")); @@ -6122,7 +6122,7 @@ TEST_CASE(IsolateReload_EnumInMainLibraryModified) { lib = TestCase::ReloadTestScript(kReloadScript); EXPECT_VALID(lib); - Dart_SetFileModifiedCallback(NULL); + Dart_SetFileModifiedCallback(nullptr); // Modification of an imported library propagates to the importing library. EXPECT_STREQ("foo", SimpleInvokeStr(lib, "main")); diff --git a/runtime/vm/isolate_test.cc b/runtime/vm/isolate_test.cc index 5a63cc75880..e620dadc70f 100644 --- a/runtime/vm/isolate_test.cc +++ b/runtime/vm/isolate_test.cc @@ -17,7 +17,7 @@ VM_UNIT_TEST_CASE(IsolateCurrent) { Dart_Isolate isolate = TestCase::CreateTestIsolate(); EXPECT_EQ(isolate, Dart_CurrentIsolate()); Dart_ShutdownIsolate(); - EXPECT_EQ(static_cast(NULL), Dart_CurrentIsolate()); + EXPECT_EQ(static_cast(nullptr), Dart_CurrentIsolate()); } // Test to ensure that an exception is thrown if no isolate creation @@ -40,7 +40,7 @@ void IsolateSpawn(const char* platform_script_value) { "}\n", platform_script_value); - Dart_Handle test_lib = TestCase::LoadTestScript(scriptChars, NULL); + Dart_Handle test_lib = TestCase::LoadTestScript(scriptChars, nullptr); free(scriptChars); @@ -72,8 +72,9 @@ void IsolateSpawn(const char* platform_script_value) { EXPECT_VALID(url); Dart_Handle isolate_lib = Dart_LookupLibrary(url); EXPECT_VALID(isolate_lib); - Dart_Handle schedule_immediate_closure = Dart_Invoke( - isolate_lib, NewString("_getIsolateScheduleImmediateClosure"), 0, NULL); + Dart_Handle schedule_immediate_closure = + Dart_Invoke(isolate_lib, NewString("_getIsolateScheduleImmediateClosure"), + 0, nullptr); Dart_Handle args[1]; args[0] = schedule_immediate_closure; url = NewString("dart:async"); @@ -83,7 +84,7 @@ void IsolateSpawn(const char* platform_script_value) { EXPECT_VALID(Dart_Invoke(async_lib, NewString("_setScheduleImmediateClosure"), 1, args)); - result = Dart_Invoke(test_lib, NewString("testMain"), 0, NULL); + result = Dart_Invoke(test_lib, NewString("testMain"), 0, nullptr); EXPECT_VALID(result); // Run until all ports to isolate are closed. result = Dart_RunLoop(); diff --git a/runtime/vm/json_stream.cc b/runtime/vm/json_stream.cc index 5e3fe1e1a50..86ed8491c1a 100644 --- a/runtime/vm/json_stream.cc +++ b/runtime/vm/json_stream.cc @@ -29,20 +29,20 @@ JSONStream::JSONStream(intptr_t buf_size) default_id_zone_(), id_zone_(&default_id_zone_), reply_port_(ILLEGAL_PORT), - seq_(NULL), - parameter_keys_(NULL), - parameter_values_(NULL), + seq_(nullptr), + parameter_keys_(nullptr), + parameter_values_(nullptr), method_(""), - param_keys_(NULL), - param_values_(NULL), + param_keys_(nullptr), + param_values_(nullptr), num_params_(0), offset_(0), count_(-1), include_private_members_(true), ignore_object_depth_(0) { - ObjectIdRing* ring = NULL; + ObjectIdRing* ring = nullptr; Isolate* isolate = Isolate::Current(); - if (isolate != NULL) { + if (isolate != nullptr) { ring = isolate->EnsureObjectIdRing(); } default_id_zone_.Init(ring, ObjectIdRing::kAllocateId); @@ -83,7 +83,7 @@ void JSONStream::Setup(Zone* zone, if (FLAG_trace_service) { Isolate* isolate = Isolate::Current(); - ASSERT(isolate != NULL); + ASSERT(isolate != nullptr); int64_t main_port = static_cast(isolate->main_port()); const char* isolate_name = isolate->name(); setup_time_micros_ = OS::GetCurrentTimeMicros(); @@ -169,10 +169,10 @@ void JSONStream::PrintError(intptr_t code, const char* details_format, ...) { { JSONObject data(&jsobj, "data"); PrintRequest(&data, this); - if (details_format != NULL) { + if (details_format != nullptr) { va_list measure_args; va_start(measure_args, details_format); - intptr_t len = Utils::VSNPrint(NULL, 0, details_format, measure_args); + intptr_t len = Utils::VSNPrint(nullptr, 0, details_format, measure_args); va_end(measure_args); char* buffer = Thread::Current()->zone()->Alloc(len + 1); @@ -195,7 +195,7 @@ static void Finalizer(void* isolate_callback_data, void* buffer) { } void JSONStream::PostReply() { - ASSERT(seq_ != NULL); + ASSERT(seq_ != nullptr); Dart_Port port = reply_port(); set_reply_port(ILLEGAL_PORT); // Prevent double replies. if (seq_->IsString()) { @@ -253,7 +253,7 @@ void JSONStream::PostReply() { if (FLAG_trace_service) { Isolate* isolate = Isolate::Current(); - ASSERT(isolate != NULL); + ASSERT(isolate != nullptr); int64_t main_port = static_cast(isolate->main_port()); const char* isolate_name = isolate->name(); int64_t total_time = OS::GetCurrentTimeMicros() - setup_time_micros_; @@ -277,19 +277,19 @@ const char* JSONStream::LookupParam(const char* key) const { return param_values_[i]; } } - return NULL; + return nullptr; } bool JSONStream::HasParam(const char* key) const { ASSERT(key); - return LookupParam(key) != NULL; + return LookupParam(key) != nullptr; } bool JSONStream::ParamIs(const char* key, const char* value) const { ASSERT(key); ASSERT(value); const char* key_value = LookupParam(key); - return (key_value != NULL) && (strcmp(key_value, value) == 0); + return (key_value != nullptr) && (strcmp(key_value, value) == 0); } void JSONStream::ComputeOffsetAndCount(intptr_t length, @@ -370,7 +370,7 @@ void JSONStream::PrintValueVM(bool ref) { } void JSONStream::PrintServiceId(const Object& o) { - ASSERT(id_zone_ != NULL); + ASSERT(id_zone_ != nullptr); PrintProperty("id", id_zone_->GetServiceId(o)); } @@ -440,11 +440,11 @@ void JSONStream::set_reply_port(Dart_Port port) { } intptr_t JSONStream::NumObjectParameters() const { - if (parameter_keys_ == NULL) { + if (parameter_keys_ == nullptr) { return 0; } - ASSERT(parameter_keys_ != NULL); - ASSERT(parameter_values_ != NULL); + ASSERT(parameter_keys_ != nullptr); + ASSERT(parameter_values_ != nullptr); return parameter_keys_->Length(); } diff --git a/runtime/vm/json_stream.h b/runtime/vm/json_stream.h index 21e00648e2d..0cb325da82c 100644 --- a/runtime/vm/json_stream.h +++ b/runtime/vm/json_stream.h @@ -180,7 +180,7 @@ class JSONStream : ValueObject { void PostNullReply(Dart_Port port); - void OpenObject(const char* property_name = NULL) { + void OpenObject(const char* property_name = nullptr) { if (ignore_object_depth_ > 0 || (property_name != nullptr && !IsAllowableKey(property_name))) { ignore_object_depth_++; @@ -201,7 +201,7 @@ class JSONStream : ValueObject { writer_.UncloseObject(); } - void OpenArray(const char* property_name = NULL) { + void OpenArray(const char* property_name = nullptr) { if (ignore_object_depth_ > 0 || (property_name != nullptr && !IsAllowableKey(property_name))) { ignore_object_depth_++; diff --git a/runtime/vm/json_test.cc b/runtime/vm/json_test.cc index 283ab38b7ec..e8eb16838bc 100644 --- a/runtime/vm/json_test.cc +++ b/runtime/vm/json_test.cc @@ -219,7 +219,7 @@ TEST_CASE(JSON_JSONStream_DartString) { "var wrongEncoding = '\\u{1D11E}' + surrogates[0] + '\\u{1D11E}';" "var nullInMiddle = 'This has\\u0000 four words.';"; - Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, nullptr); EXPECT_VALID(lib); Dart_Handle result; diff --git a/runtime/vm/json_writer.cc b/runtime/vm/json_writer.cc index c420a7c8bf6..39447c61b52 100644 --- a/runtime/vm/json_writer.cc +++ b/runtime/vm/json_writer.cc @@ -60,7 +60,7 @@ void JSONWriter::Clear() { void JSONWriter::OpenObject(const char* property_name) { PrintCommaIfNeeded(); open_objects_++; - if (property_name != NULL) { + if (property_name != nullptr) { PrintPropertyName(property_name); } buffer_.AddChar('{'); @@ -82,7 +82,7 @@ void JSONWriter::CloseObject() { void JSONWriter::OpenArray(const char* property_name) { PrintCommaIfNeeded(); - if (property_name != NULL) { + if (property_name != nullptr) { PrintPropertyName(property_name); } open_objects_++; @@ -195,7 +195,7 @@ void JSONWriter::VPrintfValue(const char* format, va_list args) { va_list measure_args; va_copy(measure_args, args); - intptr_t len = Utils::VSNPrint(NULL, 0, format, measure_args); + intptr_t len = Utils::VSNPrint(nullptr, 0, format, measure_args); va_end(measure_args); MaybeOnStackBuffer mosb(len + 1); @@ -271,7 +271,7 @@ void JSONWriter::VPrintfProperty(const char* name, va_list measure_args; va_copy(measure_args, args); - intptr_t len = Utils::VSNPrint(NULL, 0, format, measure_args); + intptr_t len = Utils::VSNPrint(nullptr, 0, format, measure_args); va_end(measure_args); MaybeOnStackBuffer mosb(len + 1); @@ -289,14 +289,14 @@ void JSONWriter::VPrintfProperty(const char* name, } void JSONWriter::Steal(char** buffer, intptr_t* buffer_length) { - ASSERT(buffer != NULL); - ASSERT(buffer_length != NULL); + ASSERT(buffer != nullptr); + ASSERT(buffer_length != nullptr); *buffer_length = buffer_.length(); *buffer = buffer_.Steal(); } void JSONWriter::PrintPropertyName(const char* name) { - ASSERT(name != NULL); + ASSERT(name != nullptr); PrintCommaIfNeeded(); buffer_.AddChar('"'); AddEscapedUTF8String(name); @@ -337,7 +337,7 @@ void JSONWriter::EnsureIntegerIsRepresentableInJavaScript(int64_t i) { } void JSONWriter::AddEscapedUTF8String(const char* s) { - if (s == NULL) { + if (s == nullptr) { return; } intptr_t len = strlen(s); @@ -345,7 +345,7 @@ void JSONWriter::AddEscapedUTF8String(const char* s) { } void JSONWriter::AddEscapedUTF8String(const char* s, intptr_t len) { - if (s == NULL) { + if (s == nullptr) { return; } buffer_.AddEscapedUTF8(s, len); diff --git a/runtime/vm/json_writer.h b/runtime/vm/json_writer.h index 311e4760c63..0a2d9e9690d 100644 --- a/runtime/vm/json_writer.h +++ b/runtime/vm/json_writer.h @@ -33,11 +33,11 @@ class JSONWriter : ValueObject { void AppendSerializedObject(const char* property_name, const char* serialized_object); - void OpenObject(const char* property_name = NULL); + void OpenObject(const char* property_name = nullptr); void CloseObject(); void UncloseObject(); - void OpenArray(const char* property_name = NULL); + void OpenArray(const char* property_name = nullptr); void CloseArray(); void Clear(); diff --git a/runtime/vm/kernel.cc b/runtime/vm/kernel.cc index 37176c6dd75..ea87bea4ef8 100644 --- a/runtime/vm/kernel.cc +++ b/runtime/vm/kernel.cc @@ -162,7 +162,7 @@ void KernelTokenPositionCollector::CollectTokenPositions( void KernelTokenPositionCollector::RecordTokenPosition(TokenPosition position) { if (record_for_script_id_ == current_script_id_ && - record_token_positions_into_ != NULL && position.IsReal()) { + record_token_positions_into_ != nullptr && position.IsReal()) { record_token_positions_into_->Add(position.Serialize()); } } diff --git a/runtime/vm/kernel_binary.cc b/runtime/vm/kernel_binary.cc index 2b31883185d..48b9c9f5d50 100644 --- a/runtime/vm/kernel_binary.cc +++ b/runtime/vm/kernel_binary.cc @@ -183,7 +183,7 @@ std::unique_ptr Program::ReadFromFile( const char* script_uri, const char** error /* = nullptr */) { Thread* thread = Thread::Current(); auto isolate_group = thread->isolate_group(); - if (script_uri == NULL) { + if (script_uri == nullptr) { return nullptr; } if (!isolate_group->HasTagHandler()) { diff --git a/runtime/vm/kernel_binary.h b/runtime/vm/kernel_binary.h index e7e43e18022..b774d81eb1a 100644 --- a/runtime/vm/kernel_binary.h +++ b/runtime/vm/kernel_binary.h @@ -282,7 +282,7 @@ class Reader : public ValueObject { explicit Reader(const ExternalTypedData& typed_data) : thread_(Thread::Current()), - raw_buffer_(NULL), + raw_buffer_(nullptr), typed_data_(&typed_data), size_(typed_data.IsNull() ? 0 : typed_data.Length()) {} @@ -300,7 +300,7 @@ class Reader : public ValueObject { uint32_t ReadUInt32At(intptr_t offset) const { ASSERT((size_ >= 4) && (offset >= 0) && (offset <= size_ - 4)); uint32_t value; - if (raw_buffer_ != NULL) { + if (raw_buffer_ != nullptr) { value = LoadUnaligned( reinterpret_cast(raw_buffer_ + offset)); } else { @@ -401,12 +401,12 @@ class Reader : public ValueObject { static const char* TagName(Tag tag); - Tag ReadTag(uint8_t* payload = NULL) { + Tag ReadTag(uint8_t* payload = nullptr) { uint8_t byte = ReadByte(); bool has_payload = (byte & kSpecializedTagHighBits) == kSpecializedTagHighBits; if (has_payload) { - if (payload != NULL) { + if (payload != nullptr) { *payload = byte & kSpecializedPayloadMask; } return static_cast(byte & kSpecializedTagMask); @@ -415,12 +415,12 @@ class Reader : public ValueObject { } } - Tag PeekTag(uint8_t* payload = NULL) { + Tag PeekTag(uint8_t* payload = nullptr) { uint8_t byte = PeekByte(); bool has_payload = (byte & kSpecializedTagHighBits) == kSpecializedTagHighBits; if (has_payload) { - if (payload != NULL) { + if (payload != nullptr) { *payload = byte & kSpecializedPayloadMask; } return static_cast(byte & kSpecializedTagMask); @@ -503,10 +503,13 @@ class Reader : public ValueObject { private: Reader(const uint8_t* buffer, intptr_t size) - : thread_(NULL), raw_buffer_(buffer), typed_data_(NULL), size_(size) {} + : thread_(nullptr), + raw_buffer_(buffer), + typed_data_(nullptr), + size_(size) {} const uint8_t* buffer() const { - if (raw_buffer_ != NULL) { + if (raw_buffer_ != nullptr) { return raw_buffer_; } NoSafepointScope no_safepoint(thread_); diff --git a/runtime/vm/kernel_isolate.cc b/runtime/vm/kernel_isolate.cc index bb3854aa730..da81f00cb0e 100644 --- a/runtime/vm/kernel_isolate.cc +++ b/runtime/vm/kernel_isolate.cc @@ -33,12 +33,12 @@ namespace dart { DEFINE_FLAG(bool, trace_kernel, false, "Trace Kernel service requests."); DEFINE_FLAG(charp, kernel_multiroot_filepaths, - NULL, + nullptr, "Comma-separated list of file paths that should be treated as roots" " by frontend compiler."); DEFINE_FLAG(charp, kernel_multiroot_scheme, - NULL, + nullptr, "URI scheme that replaces filepaths prefixes specified" " by kernel_multiroot_filepaths option"); @@ -63,25 +63,25 @@ const int KernelIsolate::kNotifyIsolateShutdown = 6; const int KernelIsolate::kRejectTag = 7; const char* KernelIsolate::kName = DART_KERNEL_ISOLATE_NAME; -Dart_IsolateGroupCreateCallback KernelIsolate::create_group_callback_ = NULL; +Dart_IsolateGroupCreateCallback KernelIsolate::create_group_callback_ = nullptr; Monitor* KernelIsolate::monitor_ = new Monitor(); KernelIsolate::State KernelIsolate::state_ = KernelIsolate::kNotStarted; -Isolate* KernelIsolate::isolate_ = NULL; +Isolate* KernelIsolate::isolate_ = nullptr; Dart_Port KernelIsolate::kernel_port_ = ILLEGAL_PORT; class RunKernelTask : public ThreadPool::Task { public: virtual void Run() { - ASSERT(Isolate::Current() == NULL); + ASSERT(Isolate::Current() == nullptr); #ifdef SUPPORT_TIMELINE TimelineBeginEndScope tbes(Timeline::GetVMStream(), "KernelIsolateStartup"); #endif // SUPPORT_TIMELINE - char* error = NULL; - Isolate* isolate = NULL; + char* error = nullptr; + Isolate* isolate = nullptr; Dart_IsolateGroupCreateCallback create_group_callback = KernelIsolate::create_group_callback(); - ASSERT(create_group_callback != NULL); + ASSERT(create_group_callback != nullptr); // Note: these flags must match those passed to the VM during // the app-jit training run (see //utils/kernel-service/BUILD.gn). @@ -98,23 +98,23 @@ class RunKernelTask : public ThreadPool::Task { #endif isolate = reinterpret_cast( - create_group_callback(KernelIsolate::kName, KernelIsolate::kName, NULL, - NULL, &api_flags, NULL, &error)); - if (isolate == NULL) { + create_group_callback(KernelIsolate::kName, KernelIsolate::kName, + nullptr, nullptr, &api_flags, nullptr, &error)); + if (isolate == nullptr) { if (FLAG_trace_kernel) { OS::PrintErr(DART_KERNEL_ISOLATE_NAME ": Isolate creation error: %s\n", error); } free(error); error = nullptr; - KernelIsolate::SetKernelIsolate(NULL); + KernelIsolate::SetKernelIsolate(nullptr); KernelIsolate::InitializingFailed(); return; } bool got_unwind; { - ASSERT(Isolate::Current() == NULL); + ASSERT(Isolate::Current() == nullptr); StartIsolateScope start_scope(isolate); got_unwind = RunMain(isolate); } @@ -128,7 +128,7 @@ class RunKernelTask : public ThreadPool::Task { // isolate_ was set as side effect of create callback. ASSERT(KernelIsolate::IsKernelIsolate(isolate)); - isolate->message_handler()->Run(isolate->group()->thread_pool(), NULL, + isolate->message_handler()->Run(isolate->group()->thread_pool(), nullptr, ShutdownIsolate, reinterpret_cast(isolate)); } @@ -225,7 +225,7 @@ void KernelIsolate::InitializeState() { OS::PrintErr(DART_KERNEL_ISOLATE_NAME ": InitializeState\n"); } create_group_callback_ = Isolate::CreateGroupCallback(); - if (create_group_callback_ == NULL) { + if (create_group_callback_ == nullptr) { KernelIsolate::InitializingFailed(); return; } @@ -280,7 +280,7 @@ void KernelIsolate::Shutdown() { void KernelIsolate::InitCallback(Isolate* I) { Thread* T = Thread::Current(); ASSERT(I == T->isolate()); - ASSERT(I != NULL); + ASSERT(I != nullptr); if (!NameEquals(I->name())) { // Not kernel isolate. return; @@ -300,17 +300,17 @@ bool KernelIsolate::IsKernelIsolate(const Isolate* isolate) { bool KernelIsolate::IsRunning() { MonitorLocker ml(monitor_); - return (kernel_port_ != ILLEGAL_PORT) && (isolate_ != NULL); + return (kernel_port_ != ILLEGAL_PORT) && (isolate_ != nullptr); } bool KernelIsolate::NameEquals(const char* name) { - ASSERT(name != NULL); + ASSERT(name != nullptr); return (strcmp(name, DART_KERNEL_ISOLATE_NAME) == 0); } bool KernelIsolate::Exists() { MonitorLocker ml(monitor_); - return isolate_ != NULL; + return isolate_ != nullptr; } void KernelIsolate::SetKernelIsolate(Isolate* isolate) { @@ -372,7 +372,7 @@ static Dart_CObject BuildFilesPairs(int source_files_count, fileNamePairs[i * 2] = source_uri; Dart_CObject* source_code = new Dart_CObject(); - if (source_files[i].source != NULL) { + if (source_files[i].source != nullptr) { source_code->type = Dart_CObject_kTypedData; source_code->value.as_typed_data.type = Dart_TypedData_kUint8; source_code->value.as_typed_data.length = strlen(source_files[i].source); @@ -403,9 +403,9 @@ void KernelIsolate::AddExperimentalFlag(const char* value) { char* save_ptr; // Needed for strtok_r. char* temp = Utils::StrDup(value); char* token = strtok_r(temp, ",", &save_ptr); - while (token != NULL) { + while (token != nullptr) { experimental_flags_->Add(Utils::StrDup(token)); - token = strtok_r(NULL, ",", &save_ptr); + token = strtok_r(nullptr, ",", &save_ptr); } free(temp); } @@ -433,12 +433,12 @@ class KernelCompilationRequest : public ValueObject { port_(Dart_NewNativePort("kernel-compilation-port", &HandleResponse, false)), - next_(NULL), - prev_(NULL) { + next_(nullptr), + prev_(nullptr) { RegisterRequest(this); result_.status = Dart_KernelCompilationStatus_Unknown; - result_.error = NULL; - result_.kernel = NULL; + result_.error = nullptr; + result_.kernel = nullptr; result_.kernel_size = 0; } @@ -504,7 +504,7 @@ class KernelCompilationRequest : public ValueObject { send_port.value.as_send_port.origin_id = ILLEGAL_PORT; Dart_CObject dart_platform_kernel; - if (platform_kernel != NULL) { + if (platform_kernel != nullptr) { dart_platform_kernel.type = Dart_CObject_kExternalTypedData; dart_platform_kernel.value.as_external_typed_data.type = Dart_TypedData_kUint8; @@ -517,7 +517,7 @@ class KernelCompilationRequest : public ValueObject { dart_platform_kernel.value.as_external_typed_data.callback = PassThroughFinalizer; } else { - // If NULL, the kernel service looks up the platform dill file + // If nullptr, the kernel service looks up the platform dill file // next to the executable. dart_platform_kernel.type = Dart_CObject_kNull; } @@ -606,7 +606,7 @@ class KernelCompilationRequest : public ValueObject { library_uri_object.value.as_string = const_cast(library_uri); Dart_CObject class_object; - if (klass != NULL) { + if (klass != nullptr) { class_object.type = Dart_CObject_kString; class_object.value.as_string = const_cast(klass); } else { @@ -614,7 +614,7 @@ class KernelCompilationRequest : public ValueObject { } Dart_CObject method_object; - if (method != NULL) { + if (method != nullptr) { method_object.type = Dart_CObject_kString; method_object.value.as_string = const_cast(method); } else { @@ -814,7 +814,7 @@ class KernelCompilationRequest : public ValueObject { send_port.value.as_send_port.origin_id = ILLEGAL_PORT; Dart_CObject uri; - if (script_uri != NULL) { + if (script_uri != nullptr) { uri.type = Dart_CObject_kString; uri.value.as_string = const_cast(script_uri); } else { @@ -822,7 +822,7 @@ class KernelCompilationRequest : public ValueObject { } Dart_CObject dart_platform_kernel; - if (platform_kernel != NULL) { + if (platform_kernel != nullptr) { dart_platform_kernel.type = Dart_CObject_kExternalTypedData; dart_platform_kernel.value.as_external_typed_data.type = Dart_TypedData_kUint8; @@ -835,7 +835,7 @@ class KernelCompilationRequest : public ValueObject { dart_platform_kernel.value.as_external_typed_data.callback = PassThroughFinalizer; } else { - // If NULL, the kernel service looks up the platform dill file + // If nullptr, the kernel service looks up the platform dill file // next to the executable. dart_platform_kernel.type = Dart_CObject_kNull; } @@ -894,7 +894,7 @@ class KernelCompilationRequest : public ValueObject { experimental_flags_object.value.as_array.length = num_experimental_flags; Dart_CObject package_config_uri; - if (package_config != NULL) { + if (package_config != nullptr) { package_config_uri.type = Dart_CObject_kString; package_config_uri.value.as_string = const_cast(package_config); } else { @@ -903,10 +903,10 @@ class KernelCompilationRequest : public ValueObject { Dart_CObject multiroot_filepaths_object; { - const char* filepaths = multiroot_filepaths != NULL + const char* filepaths = multiroot_filepaths != nullptr ? multiroot_filepaths : FLAG_kernel_multiroot_filepaths; - if (filepaths != NULL) { + if (filepaths != nullptr) { multiroot_filepaths_object.type = Dart_CObject_kString; multiroot_filepaths_object.value.as_string = const_cast(filepaths); @@ -917,10 +917,10 @@ class KernelCompilationRequest : public ValueObject { Dart_CObject multiroot_scheme_object; { - const char* scheme = multiroot_scheme != NULL + const char* scheme = multiroot_scheme != nullptr ? multiroot_scheme : FLAG_kernel_multiroot_scheme; - if (scheme != NULL) { + if (scheme != nullptr) { multiroot_scheme_object.type = Dart_CObject_kString; multiroot_scheme_object.value.as_string = const_cast(scheme); } else { @@ -930,7 +930,7 @@ class KernelCompilationRequest : public ValueObject { Dart_CObject original_working_directory_object; { - if (original_working_directory != NULL) { + if (original_working_directory != nullptr) { original_working_directory_object.type = Dart_CObject_kString; original_working_directory_object.value.as_string = const_cast(original_working_directory); @@ -1042,7 +1042,7 @@ class KernelCompilationRequest : public ValueObject { static void HandleResponse(Dart_Port port, Dart_CObject* message) { MonitorLocker locker(requests_monitor_); KernelCompilationRequest* rq = FindRequestLocked(port); - if (rq == NULL) { + if (rq == nullptr) { return; } rq->HandleResponseImpl(message); @@ -1051,7 +1051,7 @@ class KernelCompilationRequest : public ValueObject { static void RegisterRequest(KernelCompilationRequest* rq) { MonitorLocker locker(requests_monitor_); rq->next_ = requests_; - if (requests_ != NULL) { + if (requests_ != nullptr) { requests_->prev_ = rq; } requests_ = rq; @@ -1059,10 +1059,10 @@ class KernelCompilationRequest : public ValueObject { static void UnregisterRequest(KernelCompilationRequest* rq) { MonitorLocker locker(requests_monitor_); - if (rq->next_ != NULL) { + if (rq->next_ != nullptr) { rq->next_->prev_ = rq->prev_; } - if (rq->prev_ != NULL) { + if (rq->prev_ != nullptr) { rq->prev_->next_ = rq->next_; } else { requests_ = rq->next_; @@ -1071,12 +1071,13 @@ class KernelCompilationRequest : public ValueObject { // Note: Caller must hold requests_monitor_. static KernelCompilationRequest* FindRequestLocked(Dart_Port port) { - for (KernelCompilationRequest* rq = requests_; rq != NULL; rq = rq->next_) { + for (KernelCompilationRequest* rq = requests_; rq != nullptr; + rq = rq->next_) { if (rq->port_ == port) { return rq; } } - return NULL; + return nullptr; } static const char* KernelCompilationVerbosityLevelToString( @@ -1113,7 +1114,7 @@ class KernelCompilationRequest : public ValueObject { }; Monitor* KernelCompilationRequest::requests_monitor_ = new Monitor(); -KernelCompilationRequest* KernelCompilationRequest::requests_ = NULL; +KernelCompilationRequest* KernelCompilationRequest::requests_ = nullptr; Dart_KernelCompilationResult KernelIsolate::CompileToKernel( const char* script_uri, @@ -1150,7 +1151,7 @@ Dart_KernelCompilationResult KernelIsolate::CompileToKernel( kCompileTag, kernel_port, script_uri, platform_kernel, platform_kernel_size, source_file_count, source_files, incremental_compile, snapshot_compile, package_config, - multiroot_filepaths, multiroot_scheme, experimental_flags_, NULL, + multiroot_filepaths, multiroot_scheme, experimental_flags_, nullptr, verbosity); } @@ -1165,8 +1166,8 @@ Dart_KernelCompilationResult KernelIsolate::ListDependencies() { KernelCompilationRequest request; return request.SendAndWaitForResponse( - kListDependenciesTag, kernel_port, NULL, NULL, 0, 0, NULL, false, false, - NULL, NULL, NULL, experimental_flags_, NULL, + kListDependenciesTag, kernel_port, nullptr, nullptr, 0, 0, nullptr, false, + false, nullptr, nullptr, nullptr, experimental_flags_, nullptr, Dart_KernelCompilationVerbosityLevel_Error); } @@ -1183,8 +1184,8 @@ Dart_KernelCompilationResult KernelIsolate::AcceptCompilation() { KernelCompilationRequest request; return request.SendAndWaitForResponse( - kAcceptTag, kernel_port, NULL, NULL, 0, 0, NULL, true, false, NULL, NULL, - NULL, experimental_flags_, NULL, + kAcceptTag, kernel_port, nullptr, nullptr, 0, 0, nullptr, true, false, + nullptr, nullptr, nullptr, experimental_flags_, nullptr, Dart_KernelCompilationVerbosityLevel_Error); } @@ -1201,8 +1202,8 @@ Dart_KernelCompilationResult KernelIsolate::RejectCompilation() { KernelCompilationRequest request; return request.SendAndWaitForResponse( - kRejectTag, kernel_port, NULL, NULL, 0, 0, NULL, true, false, NULL, NULL, - NULL, experimental_flags_, NULL, + kRejectTag, kernel_port, nullptr, nullptr, 0, 0, nullptr, true, false, + nullptr, nullptr, nullptr, experimental_flags_, nullptr, Dart_KernelCompilationVerbosityLevel_Error); } @@ -1252,9 +1253,9 @@ Dart_KernelCompilationResult KernelIsolate::UpdateInMemorySources( KernelCompilationRequest request; return request.SendAndWaitForResponse( - kUpdateSourcesTag, kernel_port, NULL, NULL, 0, source_files_count, - source_files, true, false, NULL, NULL, NULL, experimental_flags_, NULL, - Dart_KernelCompilationVerbosityLevel_Error); + kUpdateSourcesTag, kernel_port, nullptr, nullptr, 0, source_files_count, + source_files, true, false, nullptr, nullptr, nullptr, experimental_flags_, + nullptr, Dart_KernelCompilationVerbosityLevel_Error); } void KernelIsolate::NotifyAboutIsolateGroupShutdown( diff --git a/runtime/vm/kernel_isolate.h b/runtime/vm/kernel_isolate.h index 976f85bd66a..c77984e6fff 100644 --- a/runtime/vm/kernel_isolate.h +++ b/runtime/vm/kernel_isolate.h @@ -49,12 +49,12 @@ class KernelIsolate : public AllStatic { const uint8_t* platform_kernel, intptr_t platform_kernel_size, int source_files_count = 0, - Dart_SourceFile source_files[] = NULL, + Dart_SourceFile source_files[] = nullptr, bool incremental_compile = true, bool snapshot_compile = false, - const char* package_config = NULL, - const char* multiroot_filepaths = NULL, - const char* multiroot_scheme = NULL, + const char* package_config = nullptr, + const char* multiroot_filepaths = nullptr, + const char* multiroot_scheme = nullptr, Dart_KernelCompilationVerbosityLevel verbosity = Dart_KernelCompilationVerbosityLevel_All); diff --git a/runtime/vm/kernel_loader.cc b/runtime/vm/kernel_loader.cc index 4dbd5572f50..2fe53f2ccad 100644 --- a/runtime/vm/kernel_loader.cc +++ b/runtime/vm/kernel_loader.cc @@ -41,7 +41,7 @@ class SimpleExpressionConverter { KernelReaderHelper* reader_helper) : translation_helper_(*translation_helper), zone_(translation_helper_.zone()), - simple_value_(NULL), + simple_value_(nullptr), helper_(reader_helper) {} bool IsSimple(intptr_t kernel_offset) { @@ -274,7 +274,7 @@ Object& KernelLoader::LoadEntireProgram(Program* program, const String& script_source = helper_.GetSourceFor(index); wrapper.uri = &uri_string; UriToSourceTableEntry* pair = uri_to_source_table.LookupValue(&wrapper); - if (pair != NULL) { + if (pair != nullptr) { // At least two entries with content. Unless the content is the same // that's not valid. const bool src_differ = pair->sources->CompareTo(script_source) != 0; @@ -455,7 +455,7 @@ void KernelLoader::InitializeFields(UriToSourceTable* uri_to_source_table) { KernelLoader::KernelLoader(const Script& script, const ExternalTypedData& kernel_data, intptr_t data_program_offset) - : program_(NULL), + : program_(nullptr), thread_(Thread::Current()), zone_(thread_->zone()), no_active_isolate_scope_(), @@ -1035,7 +1035,7 @@ void KernelLoader::FinishTopLevelClassLoading( const intptr_t field_count = helper_.ReadListLength(); // read list length. for (intptr_t i = 0; i < field_count; ++i) { intptr_t field_offset = helper_.ReaderOffset() - correction_offset_; - ActiveMemberScope active_member_scope(&active_class_, NULL); + ActiveMemberScope active_member_scope(&active_class_, nullptr); FieldHelper field_helper(&helper_); field_helper.ReadUntilExcluding(FieldHelper::kName); @@ -1429,7 +1429,7 @@ void KernelLoader::FinishClassLoading(const Class& klass, int field_count = helper_.ReadListLength(); // read list length. for (intptr_t i = 0; i < field_count; ++i) { intptr_t field_offset = helper_.ReaderOffset() - correction_offset_; - ActiveMemberScope active_member(&active_class_, NULL); + ActiveMemberScope active_member(&active_class_, nullptr); FieldHelper field_helper(&helper_); field_helper.ReadUntilIncluding(FieldHelper::kSourceUriIndex); @@ -1565,7 +1565,7 @@ void KernelLoader::FinishClassLoading(const Class& klass, int constructor_count = helper_.ReadListLength(); // read list length. for (intptr_t i = 0; i < constructor_count; ++i) { intptr_t constructor_offset = helper_.ReaderOffset() - correction_offset_; - ActiveMemberScope active_member_scope(&active_class_, NULL); + ActiveMemberScope active_member_scope(&active_class_, nullptr); ConstructorHelper constructor_helper(&helper_); constructor_helper.ReadUntilExcluding(ConstructorHelper::kAnnotations); intptr_t annotation_count = helper_.ReadListLength(); diff --git a/runtime/vm/kernel_loader.h b/runtime/vm/kernel_loader.h index 76229658bdc..6d7c6ac3097 100644 --- a/runtime/vm/kernel_loader.h +++ b/runtime/vm/kernel_loader.h @@ -65,7 +65,7 @@ class Mapping { public: bool Lookup(intptr_t canonical_name, VmType** handle) { typename MapType::Pair* pair = map_.LookupPair(canonical_name); - if (pair != NULL) { + if (pair != nullptr) { *handle = pair->value; return true; } diff --git a/runtime/vm/lockers.cc b/runtime/vm/lockers.cc index 6cee868fdcd..ea6d26aa1a6 100644 --- a/runtime/vm/lockers.cc +++ b/runtime/vm/lockers.cc @@ -41,12 +41,12 @@ Monitor::WaitResult MonitorLocker::WaitWithSafepointCheck(Thread* thread, SafepointMutexLocker::SafepointMutexLocker(ThreadState* thread, Mutex* mutex) : StackResource(thread), mutex_(mutex) { - ASSERT(mutex != NULL); + ASSERT(mutex != nullptr); if (!mutex_->TryLock()) { // We did not get the lock and could potentially block, so transition // accordingly. Thread* thread = Thread::Current(); - if (thread != NULL) { + if (thread != nullptr) { TransitionVMToBlocked transition(thread); mutex->Lock(); } else { @@ -56,12 +56,12 @@ SafepointMutexLocker::SafepointMutexLocker(ThreadState* thread, Mutex* mutex) } void SafepointMonitorLocker::AcquireLock() { - ASSERT(monitor_ != NULL); + ASSERT(monitor_ != nullptr); if (!monitor_->TryEnter()) { // We did not get the lock and could potentially block, so transition // accordingly. Thread* thread = Thread::Current(); - if (thread != NULL) { + if (thread != nullptr) { TransitionVMToBlocked transition(thread); monitor_->Enter(); } else { @@ -76,7 +76,7 @@ void SafepointMonitorLocker::ReleaseLock() { Monitor::WaitResult SafepointMonitorLocker::Wait(int64_t millis) { Thread* thread = Thread::Current(); - if (thread != NULL) { + if (thread != nullptr) { Monitor::WaitResult result; { TransitionVMToBlocked transition(thread); diff --git a/runtime/vm/lockers.h b/runtime/vm/lockers.h index b4557ae7c63..ba4bca66834 100644 --- a/runtime/vm/lockers.h +++ b/runtime/vm/lockers.h @@ -129,11 +129,11 @@ class MonitorLocker : public ValueObject { public: explicit MonitorLocker(Monitor* monitor, bool no_safepoint_scope = true) : monitor_(monitor), no_safepoint_scope_(no_safepoint_scope) { - ASSERT(monitor != NULL); + ASSERT(monitor != nullptr); #if defined(DEBUG) if (no_safepoint_scope_) { Thread* thread = Thread::Current(); - if (thread != NULL) { + if (thread != nullptr) { thread->IncrementNoSafepointScopeDepth(); } else { no_safepoint_scope_ = false; diff --git a/runtime/vm/log_test.cc b/runtime/vm/log_test.cc index 0d353122c78..93a53e51abe 100644 --- a/runtime/vm/log_test.cc +++ b/runtime/vm/log_test.cc @@ -17,12 +17,12 @@ namespace dart { -static const char* test_output_ = NULL; +static const char* test_output_ = nullptr; static void TestPrinter(const char* buffer) { - if (test_output_ != NULL) { + if (test_output_ != nullptr) { free(const_cast(test_output_)); - test_output_ = NULL; + test_output_ = nullptr; } test_output_ = Utils::StrDup(buffer); @@ -33,21 +33,21 @@ static void TestPrinter(const char* buffer) { class LogTestHelper : public AllStatic { public: static void SetPrinter(Log* log, LogPrinter printer) { - ASSERT(log != NULL); - ASSERT(printer != NULL); + ASSERT(log != nullptr); + ASSERT(printer != nullptr); log->printer_ = printer; } static void FreeTestOutput() { - if (test_output_ != NULL) { + if (test_output_ != nullptr) { free(const_cast(test_output_)); - test_output_ = NULL; + test_output_ = nullptr; } } }; TEST_CASE(Log_Macro) { - test_output_ = NULL; + test_output_ = nullptr; Log* log = Log::Current(); LogTestHelper::SetPrinter(log, TestPrinter); @@ -59,10 +59,10 @@ TEST_CASE(Log_Macro) { } TEST_CASE(Log_Basic) { - test_output_ = NULL; + test_output_ = nullptr; Log* log = new Log(TestPrinter); - EXPECT_EQ(static_cast(NULL), test_output_); + EXPECT_EQ(static_cast(nullptr), test_output_); log->Print("Hello %s", "World"); EXPECT_STREQ("Hello World", test_output_); @@ -71,26 +71,26 @@ TEST_CASE(Log_Basic) { } TEST_CASE(Log_Block) { - test_output_ = NULL; + test_output_ = nullptr; Log* log = new Log(TestPrinter); - EXPECT_EQ(static_cast(NULL), test_output_); + EXPECT_EQ(static_cast(nullptr), test_output_); { LogBlock ba(thread, log); log->Print("APPLE"); - EXPECT_EQ(static_cast(NULL), test_output_); + EXPECT_EQ(static_cast(nullptr), test_output_); { LogBlock ba(thread, log); log->Print("BANANA"); - EXPECT_EQ(static_cast(NULL), test_output_); + EXPECT_EQ(static_cast(nullptr), test_output_); } - EXPECT_EQ(static_cast(NULL), test_output_); + EXPECT_EQ(static_cast(nullptr), test_output_); { LogBlock ba(thread, log); log->Print("PEAR"); - EXPECT_EQ(static_cast(NULL), test_output_); + EXPECT_EQ(static_cast(nullptr), test_output_); } - EXPECT_EQ(static_cast(NULL), test_output_); + EXPECT_EQ(static_cast(nullptr), test_output_); } EXPECT_STREQ("APPLEBANANAPEAR", test_output_); delete log; diff --git a/runtime/vm/longjump.cc b/runtime/vm/longjump.cc index e789ecf14c7..28a8e47a14b 100644 --- a/runtime/vm/longjump.cc +++ b/runtime/vm/longjump.cc @@ -14,7 +14,7 @@ namespace dart { jmp_buf* LongJumpScope::Set() { - ASSERT(top_ == NULL); + ASSERT(top_ == nullptr); top_ = Thread::Current()->top_resource(); return &environment_; } diff --git a/runtime/vm/memory_region.cc b/runtime/vm/memory_region.cc index 0b4603d553c..53e1cb7df3f 100644 --- a/runtime/vm/memory_region.cc +++ b/runtime/vm/memory_region.cc @@ -7,7 +7,7 @@ namespace dart { void MemoryRegion::CopyFrom(uword offset, const MemoryRegion& from) const { - ASSERT(from.pointer() != NULL && from.size() > 0); + ASSERT(from.pointer() != nullptr && from.size() > 0); ASSERT(this->size() >= from.size()); ASSERT(offset <= this->size() - from.size()); memmove(reinterpret_cast(start() + offset), from.pointer(), diff --git a/runtime/vm/memory_region.h b/runtime/vm/memory_region.h index 3432f6faf16..885243fdf26 100644 --- a/runtime/vm/memory_region.h +++ b/runtime/vm/memory_region.h @@ -17,7 +17,7 @@ namespace dart { // of the region. class MemoryRegion : public ValueObject { public: - MemoryRegion() : pointer_(NULL), size_(0) {} + MemoryRegion() : pointer_(nullptr), size_(0) {} MemoryRegion(void* pointer, uword size) : pointer_(pointer), size_(size) {} MemoryRegion(const MemoryRegion& other) : ValueObject() { *this = other; } MemoryRegion& operator=(const MemoryRegion& other) { diff --git a/runtime/vm/memory_region_test.cc b/runtime/vm/memory_region_test.cc index 3bfc7aff29c..0dd877acd55 100644 --- a/runtime/vm/memory_region_test.cc +++ b/runtime/vm/memory_region_test.cc @@ -19,8 +19,8 @@ static void DeleteRegion(const MemoryRegion& region) { VM_UNIT_TEST_CASE(NullRegion) { static const uword kSize = 512; - MemoryRegion region(NULL, kSize); - EXPECT(region.pointer() == NULL); + MemoryRegion region(nullptr, kSize); + EXPECT(region.pointer() == nullptr); EXPECT_EQ(kSize, region.size()); } @@ -28,7 +28,7 @@ VM_UNIT_TEST_CASE(NewRegion) { static const uword kSize = 1024; MemoryRegion region(NewRegion(kSize), kSize); EXPECT_EQ(kSize, region.size()); - EXPECT(region.pointer() != NULL); + EXPECT(region.pointer() != nullptr); region.Store(0, 42); EXPECT_EQ(42, region.Load(0)); @@ -44,7 +44,7 @@ VM_UNIT_TEST_CASE(Subregion) { MemoryRegion sub_region; sub_region.Subregion(region, kSubOffset, kSubSize); EXPECT_EQ(kSubSize, sub_region.size()); - EXPECT(sub_region.pointer() != NULL); + EXPECT(sub_region.pointer() != nullptr); EXPECT(sub_region.start() == region.start() + kSubOffset); region.Store(0, 42); diff --git a/runtime/vm/message.cc b/runtime/vm/message.cc index d9d06801af9..45f710e021a 100644 --- a/runtime/vm/message.cc +++ b/runtime/vm/message.cc @@ -80,19 +80,19 @@ const char* Message::PriorityAsString(Priority priority) { break; default: UNIMPLEMENTED(); - return NULL; + return nullptr; } } MessageQueue::MessageQueue() { - head_ = NULL; - tail_ = NULL; + head_ = nullptr; + tail_ = nullptr; } MessageQueue::~MessageQueue() { // Ensure that all pending messages have been released. Clear(); - ASSERT(head_ == NULL); + ASSERT(head_ == nullptr); } void MessageQueue::Enqueue(std::unique_ptr msg0, bool before_events) { @@ -100,14 +100,14 @@ void MessageQueue::Enqueue(std::unique_ptr msg0, bool before_events) { Message* msg = msg0.release(); // Make sure messages are not reused. - ASSERT(msg->next_ == NULL); - if (head_ == NULL) { + ASSERT(msg->next_ == nullptr); + if (head_ == nullptr) { // Only element in the queue. - ASSERT(tail_ == NULL); + ASSERT(tail_ == nullptr); head_ = msg; tail_ = msg; } else { - ASSERT(tail_ != NULL); + ASSERT(tail_ != nullptr); if (!before_events) { // Append at the tail. tail_->next_ = msg; @@ -119,7 +119,7 @@ void MessageQueue::Enqueue(std::unique_ptr msg0, bool before_events) { head_ = msg; } else { Message* cur = head_; - while (cur->next_ != NULL) { + while (cur->next_ != nullptr) { if (cur->next_->dest_port() != Message::kIllegalPort) { // Splice in the new message at the break. msg->next_ = cur->next_; @@ -165,20 +165,20 @@ void MessageQueue::Clear() { } } -MessageQueue::Iterator::Iterator(const MessageQueue* queue) : next_(NULL) { +MessageQueue::Iterator::Iterator(const MessageQueue* queue) : next_(nullptr) { Reset(queue); } MessageQueue::Iterator::~Iterator() {} void MessageQueue::Iterator::Reset(const MessageQueue* queue) { - ASSERT(queue != NULL); + ASSERT(queue != nullptr); next_ = queue->head_; } // returns false when there are no more messages left. bool MessageQueue::Iterator::HasNext() { - return next_ != NULL; + return next_ != nullptr; } // Returns the current message and moves forward. @@ -202,12 +202,12 @@ Message* MessageQueue::FindMessageById(intptr_t id) { MessageQueue::Iterator it(this); while (it.HasNext()) { Message* current = it.Next(); - ASSERT(current != NULL); + ASSERT(current != nullptr); if (current->Id() == id) { return current; } } - return NULL; + return nullptr; } void MessageQueue::PrintJSON(JSONStream* stream) { diff --git a/runtime/vm/message.h b/runtime/vm/message.h index 31bdb4a95d9..02bf5ec5f7c 100644 --- a/runtime/vm/message.h +++ b/runtime/vm/message.h @@ -85,7 +85,7 @@ class Message { intptr_t Size() const { intptr_t size = snapshot_length_; - if (finalizable_data_ != NULL) { + if (finalizable_data_ != nullptr) { size += finalizable_data_->external_size(); } return size; @@ -163,11 +163,11 @@ class MessageQueue { void Enqueue(std::unique_ptr msg, bool before_events); - // Gets the next message from the message queue or NULL if no + // Gets the next message from the message queue or nullptr if no // message is available. This function will not block. std::unique_ptr Dequeue(); - bool IsEmpty() { return head_ == NULL; } + bool IsEmpty() { return head_ == nullptr; } // Clear all messages from the message queue. void Clear(); @@ -192,7 +192,7 @@ class MessageQueue { intptr_t Length() const; - // Returns the message with id or NULL. + // Returns the message with id or nullptr. Message* FindMessageById(intptr_t id); void PrintJSON(JSONStream* stream); diff --git a/runtime/vm/message_handler.cc b/runtime/vm/message_handler.cc index 3194de15b82..363686977d5 100644 --- a/runtime/vm/message_handler.cc +++ b/runtime/vm/message_handler.cc @@ -23,11 +23,11 @@ DECLARE_FLAG(bool, trace_service_pause_events); class MessageHandlerTask : public ThreadPool::Task { public: explicit MessageHandlerTask(MessageHandler* handler) : handler_(handler) { - ASSERT(handler != NULL); + ASSERT(handler != nullptr); } virtual void Run() { - ASSERT(handler_ != NULL); + ASSERT(handler_ != nullptr); handler_->TaskCallback(); } @@ -69,20 +69,20 @@ MessageHandler::MessageHandler() #endif task_running_(false), delete_me_(false), - pool_(NULL), - start_callback_(NULL), - end_callback_(NULL), + pool_(nullptr), + start_callback_(nullptr), + end_callback_(nullptr), callback_data_(0) { - ASSERT(queue_ != NULL); - ASSERT(oob_queue_ != NULL); + ASSERT(queue_ != nullptr); + ASSERT(oob_queue_ != nullptr); } MessageHandler::~MessageHandler() { delete queue_; delete oob_queue_; - queue_ = NULL; - oob_queue_ = NULL; - pool_ = NULL; + queue_ = nullptr; + oob_queue_ = nullptr; + pool_ = nullptr; } const char* MessageHandler::name() const { @@ -110,7 +110,7 @@ bool MessageHandler::Run(ThreadPool* pool, "\thandler: %s\n", name()); } - ASSERT(pool_ == NULL); + ASSERT(pool_ == nullptr); ASSERT(!delete_me_); pool_ = pool; start_callback_ = start_callback; @@ -292,7 +292,7 @@ MessageHandler::MessageStatus MessageHandler::HandleNextMessage() { // We can only call HandleNextMessage when this handler is not // assigned to a thread pool. MonitorLocker ml(&monitor_); - ASSERT(pool_ == NULL); + ASSERT(pool_ == nullptr); ASSERT(!delete_me_); #if defined(DEBUG) CheckAccess(); @@ -351,7 +351,7 @@ MessageHandler::MessageStatus MessageHandler::HandleOOBMessages() { #if !defined(PRODUCT) bool MessageHandler::ShouldPauseOnStart(MessageStatus status) const { Isolate* owning_isolate = isolate(); - if (owning_isolate == NULL) { + if (owning_isolate == nullptr) { return false; } // If we are restarting or shutting down, we do not want to honor @@ -362,7 +362,7 @@ bool MessageHandler::ShouldPauseOnStart(MessageStatus status) const { bool MessageHandler::ShouldPauseOnExit(MessageStatus status) const { Isolate* owning_isolate = isolate(); - if (owning_isolate == NULL) { + if (owning_isolate == nullptr) { return false; } return (status != MessageHandler::kShutdown) && should_pause_on_exit() && @@ -381,11 +381,11 @@ bool MessageHandler::HasMessages() { } void MessageHandler::TaskCallback() { - ASSERT(Isolate::Current() == NULL); + ASSERT(Isolate::Current() == nullptr); MessageStatus status = kOK; bool run_end_callback = false; bool delete_me = false; - EndCallback end_callback = NULL; + EndCallback end_callback = nullptr; CallbackData callback_data = 0; { // We will occasionally release and reacquire this monitor in this @@ -440,8 +440,8 @@ void MessageHandler::TaskCallback() { // Release the monitor_ temporarily while we call the start callback. ml.Exit(); status = start_callback_(callback_data_); - ASSERT(Isolate::Current() == NULL); - start_callback_ = NULL; + ASSERT(Isolate::Current() == nullptr); + start_callback_ = nullptr; ml.Enter(); } @@ -478,7 +478,7 @@ void MessageHandler::TaskCallback() { } #endif // !defined(PRODUCT) if (FLAG_trace_isolates) { - if (status != kOK && thread() != NULL) { + if (status != kOK && thread() != nullptr) { const Error& error = Error::Handle(thread()->sticky_error()); OS::PrintErr( "[-] Stopping message handler (%s):\n" @@ -492,11 +492,11 @@ void MessageHandler::TaskCallback() { MessageStatusString(status), name()); } } - pool_ = NULL; + pool_ = nullptr; // Decide if we have a callback before releasing the monitor. end_callback = end_callback_; callback_data = callback_data_; - run_end_callback = end_callback_ != NULL; + run_end_callback = end_callback_ != nullptr; delete_me = delete_me_; } @@ -513,7 +513,7 @@ void MessageHandler::TaskCallback() { ASSERT(!delete_me || !run_end_callback); if (run_end_callback) { - ASSERT(end_callback != NULL); + ASSERT(end_callback != nullptr); end_callback(callback_data); // The handler may have been deleted after this point. } @@ -607,7 +607,7 @@ void MessageHandler::PausedOnStartLocked(MonitorLocker* ml, bool paused) { paused_timestamp_ = -1; // Resumed. Clear the resume request of the owning isolate. Isolate* owning_isolate = isolate(); - if (owning_isolate != NULL) { + if (owning_isolate != nullptr) { owning_isolate->GetAndClearResumeRequest(); } is_paused_on_start_ = false; @@ -638,7 +638,7 @@ void MessageHandler::PausedOnExitLocked(MonitorLocker* ml, bool paused) { paused_timestamp_ = -1; // Resumed. Clear the resume request of the owning isolate. Isolate* owning_isolate = isolate(); - if (owning_isolate != NULL) { + if (owning_isolate != nullptr) { owning_isolate->GetAndClearResumeRequest(); } is_paused_on_exit_ = false; @@ -648,12 +648,12 @@ void MessageHandler::PausedOnExitLocked(MonitorLocker* ml, bool paused) { MessageHandler::AcquiredQueues::AcquiredQueues(MessageHandler* handler) : handler_(handler), ml_(&handler->monitor_) { - ASSERT(handler != NULL); + ASSERT(handler != nullptr); handler_->oob_message_handling_allowed_ = false; } MessageHandler::AcquiredQueues::~AcquiredQueues() { - ASSERT(handler_ != NULL); + ASSERT(handler_ != nullptr); handler_->oob_message_handling_allowed_ = true; } diff --git a/runtime/vm/message_handler.h b/runtime/vm/message_handler.h index 5c4f7a53ac6..2e998382c26 100644 --- a/runtime/vm/message_handler.h +++ b/runtime/vm/message_handler.h @@ -131,15 +131,15 @@ class MessageHandler { ~AcquiredQueues(); MessageQueue* queue() { - if (handler_ == NULL) { - return NULL; + if (handler_ == nullptr) { + return nullptr; } return handler_->queue_; } MessageQueue* oob_queue() { - if (handler_ == NULL) { - return NULL; + if (handler_ == nullptr) { + return nullptr; } return handler_->oob_queue_; } @@ -168,7 +168,7 @@ class MessageHandler { virtual bool IsCurrentIsolate() const { return false; } // Return Isolate to which this message handler corresponds to. - virtual Isolate* isolate() const { return NULL; } + virtual Isolate* isolate() const { return nullptr; } // Posts a message on this handler's message queue. // If before_events is true, then the message is enqueued before any pending diff --git a/runtime/vm/message_handler_test.cc b/runtime/vm/message_handler_test.cc index aabd5c41a8c..c85f3c938c0 100644 --- a/runtime/vm/message_handler_test.cc +++ b/runtime/vm/message_handler_test.cc @@ -36,13 +36,13 @@ class MessageHandlerTestPeer { class TestMessageHandler : public MessageHandler { public: TestMessageHandler() - : port_buffer_(NULL), + : port_buffer_(nullptr), port_buffer_size_(0), notify_count_(0), message_count_(0), start_called_(false), end_called_(false), - results_(NULL), + results_(nullptr), monitor_() {} ~TestMessageHandler() { @@ -63,7 +63,7 @@ class TestMessageHandler : public MessageHandler { AddPortToBuffer(message->dest_port()); message_count_++; MessageStatus status = kOK; - if (results_ != NULL) { + if (results_ != nullptr) { status = results_[0]; results_++; } @@ -95,7 +95,7 @@ class TestMessageHandler : public MessageHandler { private: void AddPortToBuffer(Dart_Port port) { - if (port_buffer_ == NULL) { + if (port_buffer_ == nullptr) { port_buffer_ = new Dart_Port[10]; port_buffer_size_ = 10; } else if (message_count_ == port_buffer_size_) { diff --git a/runtime/vm/message_snapshot.cc b/runtime/vm/message_snapshot.cc index 8f0b2267351..ceccaf9db82 100644 --- a/runtime/vm/message_snapshot.cc +++ b/runtime/vm/message_snapshot.cc @@ -1204,7 +1204,7 @@ class GrowableObjectArrayMessageDeserializationCluster array->value.as_array.values = d->zone()->Alloc(length); } else { ASSERT(length == 0); - array->value.as_array.values = NULL; + array->value.as_array.values = nullptr; } d->AssignRef(array); } @@ -1352,7 +1352,7 @@ class TypedDataMessageDeserializationCluster data->value.as_typed_data.type = type; data->value.as_typed_data.length = length; if (length == 0) { - data->value.as_typed_data.values = NULL; + data->value.as_typed_data.values = nullptr; } else { data->value.as_typed_data.values = d->CurrentBufferAddress(); d->Advance(length * element_size); @@ -2503,7 +2503,7 @@ class ArrayMessageDeserializationCluster intptr_t length = d->ReadUnsigned(); array->value.as_array.length = length; if (length == 0) { - array->value.as_array.values = NULL; + array->value.as_array.values = nullptr; } else { array->value.as_array.values = d->zone()->Alloc(length); } @@ -2904,7 +2904,7 @@ bool ApiMessageSerializer::Trace(Dart_CObject* object) { cid = kDoubleCid; break; case Dart_CObject_kString: { - RELEASE_ASSERT(object->value.as_string != NULL); + RELEASE_ASSERT(object->value.as_string != nullptr); const uint8_t* utf8_str = reinterpret_cast(object->value.as_string); intptr_t utf8_len = strlen(object->value.as_string); diff --git a/runtime/vm/message_test.cc b/runtime/vm/message_test.cc index 2c11a28119d..d25e8ebc400 100644 --- a/runtime/vm/message_test.cc +++ b/runtime/vm/message_test.cc @@ -59,7 +59,7 @@ TEST_CASE(MessageQueue_BasicOperations) { EXPECT(queue.FindMessageById(reinterpret_cast(msg2)) == msg2); // Lookup bad id. - EXPECT(queue.FindMessageById(0x1) == NULL); + EXPECT(queue.FindMessageById(0x1) == nullptr); // Remove message 1 msg = queue.Dequeue(); diff --git a/runtime/vm/metrics.cc b/runtime/vm/metrics.cc index 8a892665484..1fa5a80b416 100644 --- a/runtime/vm/metrics.cc +++ b/runtime/vm/metrics.cc @@ -18,7 +18,7 @@ DEFINE_FLAG(bool, false, "Print metrics when isolates (and the VM) are shutdown."); -Metric* Metric::vm_list_head_ = NULL; +Metric* Metric::vm_list_head_ = nullptr; Metric::Metric() : unit_(kCounter), value_(0) {} Metric::~Metric() {} @@ -28,7 +28,7 @@ void Metric::InitInstance(IsolateGroup* isolate_group, const char* description, Unit unit) { // Only called once. - ASSERT(name != NULL); + ASSERT(name != nullptr); isolate_group_ = isolate_group; name_ = name; description_ = description; @@ -41,7 +41,7 @@ void Metric::InitInstance(Isolate* isolate, const char* description, Unit unit) { // Only called once. - ASSERT(name != NULL); + ASSERT(name != nullptr); isolate_ = isolate; name_ = name; description_ = description; @@ -52,7 +52,7 @@ void Metric::InitInstance(const char* name, const char* description, Unit unit) { // Only called once. - ASSERT(name != NULL); + ASSERT(name != nullptr); name_ = name; description_ = description; unit_ = unit; @@ -70,7 +70,7 @@ static const char* UnitString(intptr_t unit) { UNREACHABLE(); } UNREACHABLE(); - return NULL; + return nullptr; } void Metric::PrintJSON(JSONStream* stream) { @@ -92,9 +92,9 @@ void Metric::PrintJSON(JSONStream* stream) { char* Metric::ValueToString(int64_t value, Unit unit) { Thread* thread = Thread::Current(); - ASSERT(thread != NULL); + ASSERT(thread != nullptr); Zone* zone = thread->zone(); - ASSERT(zone != NULL); + ASSERT(zone != nullptr); switch (unit) { case kCounter: return zone->PrintToString("%" Pd64 "", value); @@ -129,15 +129,15 @@ char* Metric::ValueToString(int64_t value, Unit unit) { } default: UNREACHABLE(); - return NULL; + return nullptr; } } char* Metric::ToString() { Thread* thread = Thread::Current(); - ASSERT(thread != NULL); + ASSERT(thread != nullptr); Zone* zone = thread->zone(); - ASSERT(zone != NULL); + ASSERT(zone != nullptr); return zone->PrintToString("%s %s", name(), ValueToString(Value(), unit())); } diff --git a/runtime/vm/mixin_test.cc b/runtime/vm/mixin_test.cc index ef361c2f092..51dd5099c4e 100644 --- a/runtime/vm/mixin_test.cc +++ b/runtime/vm/mixin_test.cc @@ -34,9 +34,9 @@ TEST_CASE(Mixin_PrivateSuperResolution) { Dart_Handle lib = TestCase::LoadTestScriptWithDFE( sizeof(sourcefiles) / sizeof(Dart_SourceFile), sourcefiles, - /* resolver= */ NULL, /* finalize= */ true, /* incrementally= */ true); + /* resolver= */ nullptr, /* finalize= */ true, /* incrementally= */ true); EXPECT_VALID(lib); - Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL); + Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, nullptr); int64_t value = 0; result = Dart_IntegerToInt64(result, &value); EXPECT_VALID(result); @@ -83,7 +83,7 @@ TEST_CASE(Mixin_PrivateSuperResolutionCrossLibraryShouldFail) { Dart_Handle lib = TestCase::LoadTestScriptWithDFE( sizeof(sourcefiles) / sizeof(Dart_SourceFile), sourcefiles, - /* resolver= */ NULL, /* finalize= */ true, /* incrementally= */ true); + /* resolver= */ nullptr, /* finalize= */ true, /* incrementally= */ true); EXPECT_ERROR(lib, "Error: Superclass has no method named '_bar'."); } #endif // !defined(PRODUCT) && !defined(DART_PRECOMPILED_RUNTIME) diff --git a/runtime/vm/native_api_impl.cc b/runtime/vm/native_api_impl.cc index abaeb8b163e..0248c578ece 100644 --- a/runtime/vm/native_api_impl.cc +++ b/runtime/vm/native_api_impl.cc @@ -25,13 +25,13 @@ class IsolateLeaveScope { public: explicit IsolateLeaveScope(Isolate* current_isolate) : saved_isolate_(current_isolate) { - if (current_isolate != NULL) { + if (current_isolate != nullptr) { ASSERT(current_isolate == Isolate::Current()); Dart_ExitIsolate(); } } ~IsolateLeaveScope() { - if (saved_isolate_ != NULL) { + if (saved_isolate_ != nullptr) { Dart_Isolate I = reinterpret_cast(saved_isolate_); Dart_EnterIsolate(I); } @@ -74,10 +74,10 @@ DART_EXPORT bool Dart_PostInteger(Dart_Port port_id, int64_t message) { DART_EXPORT Dart_Port Dart_NewNativePort(const char* name, Dart_NativeMessageHandler handler, bool handle_concurrently) { - if (name == NULL) { + if (name == nullptr) { name = ""; } - if (handler == NULL) { + if (handler == nullptr) { OS::PrintErr("%s expects argument 'handler' to be non-null.\n", CURRENT_FUNC); return ILLEGAL_PORT; @@ -92,7 +92,7 @@ DART_EXPORT Dart_Port Dart_NewNativePort(const char* name, Dart_Port port_id = PortMap::CreatePort(nmh); if (port_id != ILLEGAL_PORT) { PortMap::SetPortState(port_id, PortMap::kLivePort); - if (!nmh->Run(Dart::thread_pool(), NULL, NULL, 0)) { + if (!nmh->Run(Dart::thread_pool(), nullptr, nullptr, 0)) { PortMap::ClosePort(port_id); port_id = ILLEGAL_PORT; } @@ -262,7 +262,7 @@ struct RunInSafepointAndRWCodeArgs { DART_EXPORT void* Dart_ExecuteInternalCommand(const char* command, void* arg) { if (strcmp(command, "gc-on-nth-allocation") == 0) { Thread* const thread = Thread::Current(); - Isolate* isolate = (thread == NULL) ? NULL : thread->isolate(); + Isolate* isolate = (thread == nullptr) ? nullptr : thread->isolate(); CHECK_ISOLATE(isolate); TransitionNativeToVM _(thread); intptr_t argument = reinterpret_cast(arg); @@ -273,7 +273,7 @@ DART_EXPORT void* Dart_ExecuteInternalCommand(const char* command, void* arg) { } else if (strcmp(command, "gc-now") == 0) { ASSERT(arg == nullptr); // Don't pass an argument to this command. Thread* const thread = Thread::Current(); - Isolate* isolate = (thread == NULL) ? NULL : thread->isolate(); + Isolate* isolate = (thread == nullptr) ? nullptr : thread->isolate(); CHECK_ISOLATE(isolate); TransitionNativeToVM _(thread); IsolateGroup::Current()->heap()->CollectAllGarbage(GCReason::kDebugging); diff --git a/runtime/vm/native_entry.cc b/runtime/vm/native_entry.cc index 9438a94b8ae..9cb4c0648c8 100644 --- a/runtime/vm/native_entry.cc +++ b/runtime/vm/native_entry.cc @@ -39,12 +39,12 @@ NativeFunction NativeEntry::ResolveNative(const Library& library, int number_of_arguments, bool* auto_setup_scope) { // Now resolve the native function to the corresponding native entrypoint. - if (library.native_entry_resolver() == NULL) { + if (library.native_entry_resolver() == nullptr) { // Native methods are not allowed in the library to which this // class belongs in. - return NULL; + return nullptr; } - Dart_NativeFunction native_function = NULL; + Dart_NativeFunction native_function = nullptr; { Thread* T = Thread::Current(); Api::Scope api_scope(T); @@ -63,9 +63,9 @@ const uint8_t* NativeEntry::ResolveSymbolInLibrary(const Library& library, uword pc) { Dart_NativeEntrySymbol symbol_resolver = library.native_entry_symbol_resolver(); - if (symbol_resolver == NULL) { + if (symbol_resolver == nullptr) { // Cannot reverse lookup native entries. - return NULL; + return nullptr; } return symbol_resolver(reinterpret_cast(pc)); } @@ -83,11 +83,11 @@ const uint8_t* NativeEntry::ResolveSymbol(uword pc) { lib ^= libs.At(i); ASSERT(!lib.IsNull()); const uint8_t* r = ResolveSymbolInLibrary(lib, pc); - if (r != NULL) { + if (r != nullptr) { return r; } } - return NULL; + return nullptr; } bool NativeEntry::ReturnValueIsError(NativeArguments* arguments) { @@ -209,7 +209,7 @@ void NativeEntry::AutoScopeNativeCallWrapperNoStackCheck( { Isolate* isolate = thread->isolate(); ApiState* state = isolate->group()->api_state(); - ASSERT(state != NULL); + ASSERT(state != nullptr); TRACE_NATIVE_CALL("0x%" Px "", reinterpret_cast(func)); thread->EnterApiScope(); { @@ -241,7 +241,7 @@ static NativeFunction ResolveNativeFunction(Zone* zone, const int num_params = NativeArguments::ParameterCountForResolution(func); NativeFunction native_function = NativeEntry::ResolveNative( library, native_name, num_params, is_auto_scope); - if (native_function == NULL) { + if (native_function == nullptr) { FATAL("Failed to resolve native function '%s' in '%s'\n", native_name.ToCString(), func.ToQualifiedCString()); } @@ -260,7 +260,7 @@ void NativeEntry::LinkNativeCall(Dart_NativeArguments args) { MSAN_UNPOISON(arguments, sizeof(*arguments)); TRACE_NATIVE_CALL("%s", "LinkNative"); - NativeFunction target_function = NULL; + NativeFunction target_function = nullptr; bool is_bootstrap_native = false; bool is_auto_scope = true; @@ -283,10 +283,10 @@ void NativeEntry::LinkNativeCall(Dart_NativeArguments args) { target_function = ResolveNativeFunction(arguments->thread()->zone(), func, &is_bootstrap_native, &is_auto_scope); - ASSERT(target_function != NULL); + ASSERT(target_function != nullptr); #if defined(DEBUG) - NativeFunction current_function = NULL; + NativeFunction current_function = nullptr; const Code& current_trampoline = Code::Handle(zone, CodePatcher::GetNativeCallAt( caller_frame->pc(), code, ¤t_function)); diff --git a/runtime/vm/native_message_handler.cc b/runtime/vm/native_message_handler.cc index 31639e9ab3b..22371adb7ca 100644 --- a/runtime/vm/native_message_handler.cc +++ b/runtime/vm/native_message_handler.cc @@ -24,7 +24,7 @@ NativeMessageHandler::~NativeMessageHandler() { #if defined(DEBUG) void NativeMessageHandler::CheckAccess() { - ASSERT(Isolate::Current() == NULL); + ASSERT(Isolate::Current() == nullptr); } #endif diff --git a/runtime/vm/native_symbol_android.cc b/runtime/vm/native_symbol_android.cc index d7837e3c990..faff281f99e 100644 --- a/runtime/vm/native_symbol_android.cc +++ b/runtime/vm/native_symbol_android.cc @@ -21,17 +21,17 @@ char* NativeSymbolResolver::LookupSymbolName(uword pc, uword* start) { Dl_info info; int r = dladdr(reinterpret_cast(pc), &info); if (r == 0) { - return NULL; + return nullptr; } - if (info.dli_sname == NULL) { - return NULL; + if (info.dli_sname == nullptr) { + return nullptr; } - if (start != NULL) { + if (start != nullptr) { *start = reinterpret_cast(info.dli_saddr); } int status = 0; size_t len = 0; - char* demangled = abi::__cxa_demangle(info.dli_sname, NULL, &len, &status); + char* demangled = abi::__cxa_demangle(info.dli_sname, nullptr, &len, &status); MSAN_UNPOISON(demangled, len); if (status == 0) { return demangled; diff --git a/runtime/vm/native_symbol_fuchsia.cc b/runtime/vm/native_symbol_fuchsia.cc index 1cb72a83f74..021c2a6f00b 100644 --- a/runtime/vm/native_symbol_fuchsia.cc +++ b/runtime/vm/native_symbol_fuchsia.cc @@ -31,7 +31,7 @@ namespace dart { class NativeSymbols { public: NativeSymbols(const char* dso_name, void* buffer, size_t size) - : next_(NULL), dso_name_(dso_name) { + : next_(nullptr), dso_name_(dso_name) { num_entries_ = *reinterpret_cast(buffer); entries_ = reinterpret_cast(reinterpret_cast(buffer) + 1); @@ -86,14 +86,14 @@ class NativeSymbols { DISALLOW_COPY_AND_ASSIGN(NativeSymbols); }; -static NativeSymbols* symbols_ = NULL; +static NativeSymbols* symbols_ = nullptr; void NativeSymbolResolver::Init() {} void NativeSymbolResolver::Cleanup() { NativeSymbols* symbols = symbols_; - symbols_ = NULL; - while (symbols != NULL) { + symbols_ = nullptr; + while (symbols != nullptr) { NativeSymbols* next = symbols->next(); delete symbols; symbols = next; @@ -104,27 +104,27 @@ char* NativeSymbolResolver::LookupSymbolName(uword pc, uword* start) { Dl_info info; int r = dladdr(reinterpret_cast(pc), &info); if (r == 0) { - return NULL; + return nullptr; } auto const dso_name = info.dli_fname; const auto dso_base = reinterpret_cast(info.dli_fbase); const auto dso_offset = pc - dso_base; - for (NativeSymbols* symbols = symbols_; symbols != NULL; + for (NativeSymbols* symbols = symbols_; symbols != nullptr; symbols = symbols->next()) { uword symbol_start_offset; const char* symbol_name; if (symbols->Lookup(dso_name, dso_offset, &symbol_start_offset, &symbol_name)) { - if (start != NULL) { + if (start != nullptr) { *start = symbol_start_offset + dso_base; } return strdup(symbol_name); } } - return NULL; + return nullptr; } void NativeSymbolResolver::FreeSymbolName(char* name) { diff --git a/runtime/vm/native_symbol_linux.cc b/runtime/vm/native_symbol_linux.cc index 75578905df4..2fe49385271 100644 --- a/runtime/vm/native_symbol_linux.cc +++ b/runtime/vm/native_symbol_linux.cc @@ -22,17 +22,17 @@ char* NativeSymbolResolver::LookupSymbolName(uword pc, uword* start) { Dl_info info; int r = dladdr(reinterpret_cast(pc), &info); if (r == 0) { - return NULL; + return nullptr; } - if (info.dli_sname == NULL) { - return NULL; + if (info.dli_sname == nullptr) { + return nullptr; } - if (start != NULL) { + if (start != nullptr) { *start = reinterpret_cast(info.dli_saddr); } int status = 0; size_t len = 0; - char* demangled = abi::__cxa_demangle(info.dli_sname, NULL, &len, &status); + char* demangled = abi::__cxa_demangle(info.dli_sname, nullptr, &len, &status); MSAN_UNPOISON(demangled, len); if (status == 0) { return demangled; diff --git a/runtime/vm/native_symbol_macos.cc b/runtime/vm/native_symbol_macos.cc index aa1fc6c7d91..89593ec141e 100644 --- a/runtime/vm/native_symbol_macos.cc +++ b/runtime/vm/native_symbol_macos.cc @@ -21,16 +21,17 @@ char* NativeSymbolResolver::LookupSymbolName(uword pc, uword* start) { Dl_info info; int r = dladdr(reinterpret_cast(pc), &info); if (r == 0) { - return NULL; + return nullptr; } - if (info.dli_sname == NULL) { - return NULL; + if (info.dli_sname == nullptr) { + return nullptr; } - if (start != NULL) { + if (start != nullptr) { *start = reinterpret_cast(info.dli_saddr); } int status; - char* demangled = abi::__cxa_demangle(info.dli_sname, NULL, NULL, &status); + char* demangled = + abi::__cxa_demangle(info.dli_sname, nullptr, nullptr, &status); if (status == 0) { return demangled; } diff --git a/runtime/vm/native_symbol_win.cc b/runtime/vm/native_symbol_win.cc index db48485a094..34ce7a836aa 100644 --- a/runtime/vm/native_symbol_win.cc +++ b/runtime/vm/native_symbol_win.cc @@ -15,11 +15,11 @@ namespace dart { static bool running_ = false; -static Mutex* lock_ = NULL; +static Mutex* lock_ = nullptr; void NativeSymbolResolver::Init() { ASSERT(running_ == false); - if (lock_ == NULL) { + if (lock_ == nullptr) { lock_ = new Mutex(); } running_ = true; @@ -29,7 +29,7 @@ void NativeSymbolResolver::Init() { #ifndef DART_TARGET_OS_WINDOWS_UWP SymSetOptions(SYMOPT_UNDNAME | SYMOPT_DEFERRED_LOADS); HANDLE hProcess = GetCurrentProcess(); - if (!SymInitialize(hProcess, NULL, TRUE)) { + if (!SymInitialize(hProcess, nullptr, TRUE)) { DWORD error = GetLastError(); OS::PrintErr("Failed to init NativeSymbolResolver (SymInitialize %" Pu32 ")\n", @@ -58,7 +58,7 @@ void NativeSymbolResolver::Cleanup() { char* NativeSymbolResolver::LookupSymbolName(uword pc, uword* start) { #ifdef DART_TARGET_OS_WINDOWS_UWP - return NULL; + return nullptr; #else static const intptr_t kMaxNameLength = 2048; static const intptr_t kSymbolInfoSize = sizeof(SYMBOL_INFO); // NOLINT. @@ -66,10 +66,10 @@ char* NativeSymbolResolver::LookupSymbolName(uword pc, uword* start) { static char name_buffer[kMaxNameLength]; MutexLocker lock(lock_); if (!running_) { - return NULL; + return nullptr; } - if (start != NULL) { - *start = NULL; + if (start != nullptr) { + *start = 0; } memset(&buffer[0], 0, sizeof(buffer)); HANDLE hProcess = GetCurrentProcess(); @@ -80,9 +80,9 @@ char* NativeSymbolResolver::LookupSymbolName(uword pc, uword* start) { DWORD64 displacement; BOOL r = SymFromAddr(hProcess, address, &displacement, pSymbol); if (r == FALSE) { - return NULL; + return nullptr; } - if (start != NULL) { + if (start != nullptr) { *start = pc - displacement; } return Utils::StrDup(pSymbol->Name); diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc index c433149f189..d92715f906a 100644 --- a/runtime/vm/object.cc +++ b/runtime/vm/object.cc @@ -321,7 +321,7 @@ const char* String::ScrubName(const String& name, bool is_extension) { } } - const char* unmangled_name = NULL; + const char* unmangled_name = nullptr; if (start_pos == 0) { // No name unmangling needed, reuse the name that was passed in. unmangled_name = cname; @@ -332,7 +332,7 @@ const char* String::ScrubName(const String& name, bool is_extension) { sum_segment_len += segment_len; AppendSubString(&printer, cname, start_pos, segment_len); } - if (unmangled_name == NULL) { + if (unmangled_name == nullptr) { // Merge unmangled_segments. unmangled_name = printer.buffer(); } @@ -1702,8 +1702,8 @@ void Object::RegisterPrivateClass(const Class& cls, // 2. There is no vm snapshot. This function will bootstrap from source. // 3. There is a vm snapshot. The caller should initialize from the snapshot. // -// A non-NULL kernel argument indicates (1). -// A NULL kernel indicates (2) or (3). +// A non-null kernel argument indicates (1). +// A nullptr kernel indicates (2) or (3). ErrorPtr Object::Init(IsolateGroup* isolate_group, const uint8_t* kernel_buffer, intptr_t kernel_buffer_size) { @@ -1715,7 +1715,7 @@ ErrorPtr Object::Init(IsolateGroup* isolate_group, #if defined(DART_PRECOMPILED_RUNTIME) const bool bootstrapping = false; #else - const bool is_kernel = (kernel_buffer != NULL); + const bool is_kernel = (kernel_buffer != nullptr); const bool bootstrapping = (Dart::vm_snapshot_kind() == Snapshot::kNone) || is_kernel; #endif // defined(DART_PRECOMPILED_RUNTIME). @@ -4712,12 +4712,12 @@ ErrorPtr Class::EnsureIsFinalized(Thread* thread) const { return Error::null(); } LeaveCompilerScope ncs(thread); - ASSERT(thread != NULL); + ASSERT(thread != nullptr); const Error& error = Error::Handle(thread->zone(), ClassFinalizer::LoadClassMembers(*this)); if (!error.IsNull()) { ASSERT(thread == Thread::Current()); - if (thread->long_jump_base() != NULL) { + if (thread->long_jump_base() != nullptr) { Report::LongJump(error); UNREACHABLE(); } @@ -4737,11 +4737,11 @@ ErrorPtr Class::EnsureIsAllocateFinalized(Thread* thread) const { if (is_allocate_finalized()) { return Error::null(); } - ASSERT(thread != NULL); + ASSERT(thread != nullptr); Error& error = Error::Handle(thread->zone(), EnsureIsFinalized(thread)); if (!error.IsNull()) { ASSERT(thread == Thread::Current()); - if (thread->long_jump_base() != NULL) { + if (thread->long_jump_base() != nullptr) { Report::LongJump(error); UNREACHABLE(); } @@ -8790,7 +8790,7 @@ bool Function::AreValidArgumentCounts(intptr_t num_type_arguments, String* error_message) const { if ((num_type_arguments != 0) && (num_type_arguments != NumTypeParameters())) { - if (error_message != NULL) { + if (error_message != nullptr) { const intptr_t kMessageBufferSize = 64; char message_buffer[kMessageBufferSize]; Utils::SNPrint(message_buffer, kMessageBufferSize, @@ -8803,7 +8803,7 @@ bool Function::AreValidArgumentCounts(intptr_t num_type_arguments, return false; // Too many type arguments. } if (num_named_arguments > NumOptionalNamedParameters()) { - if (error_message != NULL) { + if (error_message != nullptr) { const intptr_t kMessageBufferSize = 64; char message_buffer[kMessageBufferSize]; Utils::SNPrint(message_buffer, kMessageBufferSize, @@ -8819,7 +8819,7 @@ bool Function::AreValidArgumentCounts(intptr_t num_type_arguments, const intptr_t num_opt_pos_params = NumOptionalPositionalParameters(); const intptr_t num_pos_params = num_fixed_parameters() + num_opt_pos_params; if (num_pos_args > num_pos_params) { - if (error_message != NULL) { + if (error_message != nullptr) { const intptr_t kMessageBufferSize = 64; char message_buffer[kMessageBufferSize]; // Hide implicit parameters to the user. @@ -8837,7 +8837,7 @@ bool Function::AreValidArgumentCounts(intptr_t num_type_arguments, return false; // Too many fixed and/or positional arguments. } if (num_pos_args < num_fixed_parameters()) { - if (error_message != NULL) { + if (error_message != nullptr) { const intptr_t kMessageBufferSize = 64; char message_buffer[kMessageBufferSize]; // Hide implicit parameters to the user. @@ -9248,7 +9248,7 @@ static intptr_t ConstructFunctionFullyQualifiedCString( Zone* zone = Thread::Current()->zone(); const char* name = String::Handle(zone, function.name()).ToCString(); const char* function_format = (reserve_len == 0) ? "%s" : "%s_"; - reserve_len += Utils::SNPrint(NULL, 0, function_format, name); + reserve_len += Utils::SNPrint(nullptr, 0, function_format, name); const Function& parent = Function::Handle(zone, function.parent_function()); intptr_t written = 0; if (parent.IsNull()) { @@ -9256,9 +9256,9 @@ static intptr_t ConstructFunctionFullyQualifiedCString( ASSERT(!function_class.IsNull()); const char* class_name = String::Handle(zone, function_class.Name()).ToCString(); - ASSERT(class_name != NULL); - const char* library_name = NULL; - const char* lib_class_format = NULL; + ASSERT(class_name != nullptr); + const char* library_name = nullptr; + const char* lib_class_format = nullptr; if (with_lib) { const Library& library = Library::Handle(zone, function_class.library()); ASSERT(!library.IsNull()); @@ -9272,15 +9272,15 @@ static intptr_t ConstructFunctionFullyQualifiedCString( default: UNREACHABLE(); } - ASSERT(library_name != NULL); + ASSERT(library_name != nullptr); lib_class_format = (library_name[0] == '\0') ? "%s%s_" : "%s_%s_"; } else { library_name = ""; lib_class_format = "%s%s."; } reserve_len += - Utils::SNPrint(NULL, 0, lib_class_format, library_name, class_name); - ASSERT(chars != NULL); + Utils::SNPrint(nullptr, 0, lib_class_format, library_name, class_name); + ASSERT(chars != nullptr); *chars = zone->Alloc(reserve_len + 1); written = Utils::SNPrint(*chars, reserve_len + 1, lib_class_format, library_name, class_name); @@ -9288,34 +9288,34 @@ static intptr_t ConstructFunctionFullyQualifiedCString( written = ConstructFunctionFullyQualifiedCString(parent, chars, reserve_len, with_lib, lib_kind); } - ASSERT(*chars != NULL); + ASSERT(*chars != nullptr); char* next = *chars + written; written += Utils::SNPrint(next, reserve_len + 1, function_format, name); // Replace ":" with "_". while (true) { next = strchr(next, ':'); - if (next == NULL) break; + if (next == nullptr) break; *next = '_'; } return written; } const char* Function::ToFullyQualifiedCString() const { - char* chars = NULL; + char* chars = nullptr; ConstructFunctionFullyQualifiedCString(*this, &chars, 0, true, kQualifiedFunctionLibKindLibUrl); return chars; } const char* Function::ToLibNamePrefixedQualifiedCString() const { - char* chars = NULL; + char* chars = nullptr; ConstructFunctionFullyQualifiedCString(*this, &chars, 0, true, kQualifiedFunctionLibKindLibName); return chars; } const char* Function::ToQualifiedCString() const { - char* chars = NULL; + char* chars = nullptr; ConstructFunctionFullyQualifiedCString(*this, &chars, 0, false, kQualifiedFunctionLibKindLibUrl); return chars; @@ -10632,7 +10632,7 @@ void Function::SaveICDataMap( // Compute number of ICData objects to save. intptr_t count = 0; for (intptr_t i = 0; i < deopt_id_to_ic_data.length(); i++) { - if (deopt_id_to_ic_data[i] != NULL) { + if (deopt_id_to_ic_data[i] != nullptr) { count++; } } @@ -10643,7 +10643,7 @@ void Function::SaveICDataMap( Array::New(ICDataArrayIndices::kFirstICData + count, Heap::kOld)); for (intptr_t i = 0, pos = ICDataArrayIndices::kFirstICData; i < deopt_id_to_ic_data.length(); i++) { - if (deopt_id_to_ic_data[i] != NULL) { + if (deopt_id_to_ic_data[i] != nullptr) { ASSERT(i == deopt_id_to_ic_data[i]->deopt_id()); array.SetAt(pos++, *deopt_id_to_ic_data[i]); } @@ -10681,7 +10681,7 @@ void Function::RestoreICDataMap( 1; deopt_id_to_ic_data->SetLength(restored_length); for (intptr_t i = 0; i < restored_length; i++) { - (*deopt_id_to_ic_data)[i] = NULL; + (*deopt_id_to_ic_data)[i] = nullptr; } for (intptr_t i = ICDataArrayIndices::kFirstICData; i < saved_length; i++) { ICData& ic_data = ICData::ZoneHandle(zone); @@ -13427,7 +13427,7 @@ ObjectPtr Library::LookupReExport(const String& name, return Object::null(); } - if (trail == NULL) { + if (trail == nullptr) { trail = new ZoneGrowableArray(); } Object& obj = Object::Handle(); @@ -14000,8 +14000,8 @@ LibraryPtr Library::NewLibraryHelper(const String& url, bool import_core_lib) { result.untag()->set_imports(Object::empty_array().ptr()); result.untag()->set_exports(Object::empty_array().ptr()); result.untag()->set_loaded_scripts(Array::null()); - result.set_native_entry_resolver(NULL); - result.set_native_entry_symbol_resolver(NULL); + result.set_native_entry_resolver(nullptr); + result.set_native_entry_symbol_resolver(nullptr); result.set_ffi_native_resolver(nullptr); result.set_flags(0); result.set_is_in_fullsnapshot(false); @@ -14369,7 +14369,7 @@ static ObjectPtr EvaluateCompiledExpressionHelper( std::unique_ptr kernel_pgm = kernel::Program::ReadFromTypedData(kernel_buffer); - if (kernel_pgm == NULL) { + if (kernel_pgm == nullptr) { return ApiError::New(String::Handle( zone, String::New("Kernel isolate returned ill-formed kernel."))); } @@ -14410,7 +14410,7 @@ static ObjectPtr EvaluateCompiledExpressionHelper( #endif } -// Returns library with given url in current isolate, or NULL. +// Returns library with given url in current isolate, or nullptr. LibraryPtr Library::LookupLibrary(Thread* thread, const String& url) { Zone* zone = thread->zone(); ObjectStore* object_store = thread->isolate_group()->object_store(); @@ -14520,7 +14520,7 @@ StringPtr Library::PrivateName(const String& name) const { Thread* thread = Thread::Current(); Zone* zone = thread->zone(); ASSERT(IsPrivate(name)); - // ASSERT(strchr(name, '@') == NULL); + // ASSERT(strchr(name, '@') == nullptr); String& str = String::Handle(zone); str = name.ptr(); str = Symbols::FromConcat(thread, str, @@ -14784,7 +14784,7 @@ ObjectPtr Namespace::Lookup(const String& name, Zone* zone = Thread::Current()->zone(); const Library& lib = Library::Handle(zone, target()); - if (trail != NULL) { + if (trail != nullptr) { // Look for cycle in reexport graph. for (int i = 0; i < trail->length(); i++) { if (trail->At(i) == lib.index()) { @@ -15548,7 +15548,7 @@ void ObjectPool::DebugPrint() const { uword pc = RawValueAt(i); uintptr_t start = 0; char* name = NativeSymbolResolver::LookupSymbolName(pc, &start); - if (name != NULL) { + if (name != nullptr) { THR_Print("%s (native function)\n", name); NativeSymbolResolver::FreeSymbolName(name); } else { @@ -15658,7 +15658,7 @@ const char* PcDescriptors::ToCString() const { { Iterator iter(*this, UntaggedPcDescriptors::kAnyKind); while (iter.MoveNext()) { - len += Utils::SNPrint(NULL, 0, FORMAT, addr_width, iter.PcOffset(), + len += Utils::SNPrint(nullptr, 0, FORMAT, addr_width, iter.PcOffset(), KindAsStr(iter.Kind()), iter.DeoptId(), iter.TokenPos().ToCString(), iter.TryIndex(), iter.YieldIndex()); @@ -15908,7 +15908,7 @@ const char* LocalVarDescriptors::ToCString() const { UntaggedLocalVarDescriptors::VarInfo info; var_name = GetName(i); GetInfo(i, &info); - len += PrintVarInfo(NULL, 0, i, var_name, info); + len += PrintVarInfo(nullptr, 0, i, var_name, info); } char* buffer = Thread::Current()->zone()->Alloc(len + 1); buffer[0] = '\0'; @@ -15936,7 +15936,7 @@ const char* LocalVarDescriptors::KindToCString( return "CurrentCtx"; default: UNIMPLEMENTED(); - return NULL; + return nullptr; } } @@ -16005,7 +16005,7 @@ void ExceptionHandlers::SetHandlerInfo(intptr_t try_index, void ExceptionHandlers::GetHandlerInfo(intptr_t try_index, ExceptionHandlerInfo* info) const { ASSERT((try_index >= 0) && (try_index < num_entries())); - ASSERT(info != NULL); + ASSERT(info != nullptr); *info = untag()->data()[try_index]; } @@ -16126,18 +16126,18 @@ const char* ExceptionHandlers::ToCString() const { const intptr_t num_types = handled_types.IsNull() ? 0 : handled_types.Length(); len += Utils::SNPrint( - NULL, 0, FORMAT1, i, info.handler_pc_offset, num_types, + nullptr, 0, FORMAT1, i, info.handler_pc_offset, num_types, info.outer_try_index, ((info.needs_stacktrace != 0) ? " (needs stack trace)" : ""), ((info.is_generated != 0) ? " (generated)" : "")); for (int k = 0; k < num_types; k++) { type ^= handled_types.At(k); ASSERT(!type.IsNull()); - len += Utils::SNPrint(NULL, 0, FORMAT2, k, type.ToCString()); + len += Utils::SNPrint(nullptr, 0, FORMAT2, k, type.ToCString()); } } if (has_async_handler()) { - len += Utils::SNPrint(NULL, 0, FORMAT3); + len += Utils::SNPrint(nullptr, 0, FORMAT3); } // Allocate the buffer. char* buffer = Thread::Current()->zone()->Alloc(len); @@ -16834,8 +16834,8 @@ void ICData::GetCheckAt(intptr_t index, GrowableArray* class_ids, Function* target) const { ASSERT(index < NumberOfChecks()); - ASSERT(class_ids != NULL); - ASSERT(target != NULL); + ASSERT(class_ids != nullptr); + ASSERT(target != nullptr); class_ids->Clear(); Thread* thread = Thread::Current(); REUSABLE_ARRAY_HANDLESCOPE(thread); @@ -16851,7 +16851,7 @@ void ICData::GetCheckAt(intptr_t index, void ICData::GetClassIdsAt(intptr_t index, GrowableArray* class_ids) const { ASSERT(index < Length()); - ASSERT(class_ids != NULL); + ASSERT(class_ids != nullptr); ASSERT(IsValidEntryIndex(index)); class_ids->Clear(); Thread* thread = Thread::Current(); @@ -16867,8 +16867,8 @@ void ICData::GetClassIdsAt(intptr_t index, void ICData::GetOneClassCheckAt(intptr_t index, intptr_t* class_id, Function* target) const { - ASSERT(class_id != NULL); - ASSERT(target != NULL); + ASSERT(class_id != nullptr); + ASSERT(target != nullptr); ASSERT(NumArgsTested() == 1); Thread* thread = Thread::Current(); REUSABLE_ARRAY_HANDLESCOPE(thread); @@ -17136,7 +17136,7 @@ void ICData::Init() { void ICData::Cleanup() { for (int i = 0; i < kCachedICDataArrayCount; ++i) { - cached_icdata_arrays_[i] = NULL; + cached_icdata_arrays_[i] = nullptr; } } @@ -17755,7 +17755,7 @@ void Code::Disassemble(DisassemblyFormatter* formatter) const { return; } const uword start = PayloadStart(); - if (formatter == NULL) { + if (formatter == nullptr) { Disassembler::Disassemble(start, start + Size(), *this); } else { Disassembler::Disassemble(start, start + Size(), formatter, *this); @@ -17928,7 +17928,7 @@ CodePtr Code::FinalizeCode(FlowGraphCompiler* compiler, auto thread = Thread::Current(); ASSERT(thread->isolate_group()->program_lock()->IsCurrentThreadWriter()); - ASSERT(assembler != NULL); + ASSERT(assembler != nullptr); ObjectPool& object_pool = ObjectPool::Handle(); if (pool_attachment == PoolAttachment::kAttachPool) { @@ -18115,7 +18115,7 @@ bool Code::SlowFindRawCodeVisitor::FindObject(ObjectPtr raw_obj) const { CodePtr Code::LookupCodeInIsolateGroup(IsolateGroup* isolate_group, uword pc) { ASSERT((isolate_group == IsolateGroup::Current()) || (isolate_group == Dart::vm_isolate_group())); - if (isolate_group->heap() == NULL) { + if (isolate_group->heap() == nullptr) { return Code::null(); } HeapIterationScope heap_iteration_scope(Thread::Current()); @@ -18220,7 +18220,7 @@ const char* Code::Name() const { if (IsStubCode()) { // Regular stub. const char* name = StubCode::NameOfStub(EntryPoint()); - if (name == NULL) { + if (name == nullptr) { return "[unknown stub]"; // Not yet recorded. } return OS::SCreate(zone, "[Stub] %s", name); @@ -18883,7 +18883,7 @@ void SubtypeTestCache::Init() { } void SubtypeTestCache::Cleanup() { - cached_array_ = NULL; + cached_array_ = nullptr; } SubtypeTestCachePtr SubtypeTestCache::New() { @@ -20495,7 +20495,7 @@ intptr_t* Instance::NativeFieldsDataAddr() const { TypedDataPtr native_fields = static_cast( NativeFieldsAddr()->Decompress(untag()->heap_base())); if (native_fields == TypedData::null()) { - return NULL; + return nullptr; } return reinterpret_cast(native_fields->untag()->data()); } @@ -20516,7 +20516,7 @@ void Instance::SetNativeField(int index, intptr_t value) const { void Instance::SetNativeFields(uint16_t num_native_fields, const intptr_t* field_values) const { ASSERT(num_native_fields == NumNativeFields()); - ASSERT(field_values != NULL); + ASSERT(field_values != nullptr); Object& native_fields = Object::Handle(NativeFieldsAddr()->Decompress(untag()->heap_base())); if (native_fields.IsNull()) { @@ -20672,7 +20672,7 @@ TypeArgumentsPtr AbstractType::arguments() const { ASSERT(IsNull()); // AbstractType is an abstract class. UNREACHABLE(); - return NULL; + return nullptr; } void AbstractType::set_arguments(const TypeArguments& value) const { @@ -20905,7 +20905,7 @@ AbstractTypePtr AbstractType::InstantiateFrom( ASSERT(IsNull()); // AbstractType is an abstract class. UNREACHABLE(); - return NULL; + return nullptr; } AbstractTypePtr AbstractType::UpdateParentFunctionType( @@ -20914,7 +20914,7 @@ AbstractTypePtr AbstractType::UpdateParentFunctionType( Heap::Space space, TrailPtr trail) const { UNREACHABLE(); - return NULL; + return nullptr; } AbstractTypePtr AbstractType::Canonicalize(Thread* thread, @@ -20924,7 +20924,7 @@ AbstractTypePtr AbstractType::Canonicalize(Thread* thread, ASSERT(IsNull()); // AbstractType is an abstract class. UNREACHABLE(); - return NULL; + return nullptr; } void AbstractType::EnumerateURIs(URIs* uris) const { @@ -20936,7 +20936,7 @@ void AbstractType::EnumerateURIs(URIs* uris) const { } AbstractTypePtr AbstractType::OnlyBuddyInTrail(TrailPtr trail) const { - if (trail == NULL) { + if (trail == nullptr) { return AbstractType::null(); } const intptr_t len = trail->length(); @@ -20954,7 +20954,7 @@ AbstractTypePtr AbstractType::OnlyBuddyInTrail(TrailPtr trail) const { void AbstractType::AddOnlyBuddyToTrail(TrailPtr* trail, const AbstractType& buddy) const { - if (*trail == NULL) { + if (*trail == nullptr) { *trail = new Trail(Thread::Current()->zone(), 4); } else { ASSERT(OnlyBuddyInTrail(*trail) == AbstractType::null()); @@ -20964,7 +20964,7 @@ void AbstractType::AddOnlyBuddyToTrail(TrailPtr* trail, } bool AbstractType::TestAndAddToTrail(TrailPtr* trail) const { - if (*trail == NULL) { + if (*trail == nullptr) { *trail = new Trail(Thread::Current()->zone(), 4); } else { const intptr_t len = (*trail)->length(); @@ -20980,7 +20980,7 @@ bool AbstractType::TestAndAddToTrail(TrailPtr* trail) const { bool AbstractType::TestAndAddBuddyToTrail(TrailPtr* trail, const AbstractType& buddy) const { - if (*trail == NULL) { + if (*trail == nullptr) { *trail = new Trail(Thread::Current()->zone(), 4); } else { const intptr_t len = (*trail)->length(); @@ -20998,7 +20998,7 @@ bool AbstractType::TestAndAddBuddyToTrail(TrailPtr* trail, } void AbstractType::AddURI(URIs* uris, const String& name, const String& uri) { - ASSERT(uris != NULL); + ASSERT(uris != nullptr); const intptr_t len = uris->length(); ASSERT((len % 3) == 0); bool print_uri = false; @@ -21024,7 +21024,7 @@ void AbstractType::AddURI(URIs* uris, const String& name, const String& uri) { } StringPtr AbstractType::PrintURIs(URIs* uris) { - ASSERT(uris != NULL); + ASSERT(uris != nullptr); Thread* thread = Thread::Current(); Zone* zone = thread->zone(); const intptr_t len = uris->length(); @@ -23279,7 +23279,7 @@ const char* Number::ToCString() const { const char* Integer::ToCString() const { // Integer is an interface. No instances of Integer should exist except null. ASSERT(IsNull()); - return "NULL Integer"; + return "nullptr Integer"; } IntegerPtr Integer::New(const String& str, Heap::Space space) { @@ -23907,7 +23907,7 @@ bool String::Equals(const String& str, } bool String::Equals(const char* cstr) const { - ASSERT(cstr != NULL); + ASSERT(cstr != nullptr); CodePointIterator it(*this); intptr_t len = strlen(cstr); while (it.Next()) { @@ -24048,7 +24048,7 @@ bool String::CheckIsCanonical(Thread* thread) const { #endif // DEBUG StringPtr String::New(const char* cstr, Heap::Space space) { - ASSERT(cstr != NULL); + ASSERT(cstr != nullptr); intptr_t array_len = strlen(cstr); const uint8_t* utf8_array = reinterpret_cast(cstr); return String::FromUTF8(utf8_array, array_len, space); @@ -24418,7 +24418,7 @@ StringPtr String::NewFormattedV(const char* format, Heap::Space space) { va_list args_copy; va_copy(args_copy, args); - intptr_t len = Utils::VSNPrint(NULL, 0, format, args_copy); + intptr_t len = Utils::VSNPrint(nullptr, 0, format, args_copy); va_end(args_copy); Zone* zone = Thread::Current()->zone(); @@ -24810,7 +24810,7 @@ OneByteStringPtr ExternalOneByteString::EscapeSpecialCharacters( OneByteStringPtr OneByteString::New(intptr_t len, Heap::Space space) { ASSERT((IsolateGroup::Current() == Dart::vm_isolate_group()) || - ((IsolateGroup::Current()->object_store() != NULL) && + ((IsolateGroup::Current()->object_store() != nullptr) && (IsolateGroup::Current()->object_store()->one_byte_string_class() != Class::null()))); if (len < 0 || len > kMaxElements) { @@ -25386,7 +25386,7 @@ void Array::MakeImmutable() const { const char* Array::ToCString() const { if (IsNull()) { - return IsImmutable() ? "_ImmutableList NULL" : "_List NULL"; + return IsImmutable() ? "_ImmutableList nullptr" : "_List nullptr"; } Zone* zone = Thread::Current()->zone(); const char* format = @@ -27501,7 +27501,7 @@ const char* MirrorReference::ToCString() const { UserTagPtr UserTag::MakeActive() const { Isolate* isolate = Isolate::Current(); - ASSERT(isolate != NULL); + ASSERT(isolate != nullptr); UserTag& old = UserTag::Handle(isolate->current_tag()); isolate->set_current_tag(*this); @@ -27555,7 +27555,7 @@ UserTagPtr UserTag::DefaultTag() { Thread* thread = Thread::Current(); Zone* zone = thread->zone(); Isolate* isolate = thread->isolate(); - ASSERT(isolate != NULL); + ASSERT(isolate != nullptr); if (isolate->default_tag() != UserTag::null()) { // Already created. return isolate->default_tag(); diff --git a/runtime/vm/object.h b/runtime/vm/object.h index 980bef1a611..364c2dd1ed6 100644 --- a/runtime/vm/object.h +++ b/runtime/vm/object.h @@ -798,7 +798,7 @@ class Object { } \ type##Ptr* UnsafeMutableNonPointer(type##Ptr const* addr) const { \ UnimplementedMethod(); \ - return NULL; \ + return nullptr; \ } CLASS_LIST(STORE_NON_POINTER_ILLEGAL_TYPE); @@ -3397,7 +3397,8 @@ class Function : public Object { bool HasOptimizedCode() const; // Returns true if the argument counts are valid for calling this function. - // Otherwise, it returns false and the reason (if error_message is not NULL). + // Otherwise, it returns false and the reason (if error_message is not + // nullptr). bool AreValidArgumentCounts(intptr_t num_type_arguments, intptr_t num_arguments, intptr_t num_named_arguments, @@ -3452,7 +3453,8 @@ class Function : public Object { // Returns true if the type argument count, total argument count and the names // of optional arguments are valid for calling this function. - // Otherwise, it returns false and the reason (if error_message is not NULL). + // Otherwise, it returns false and the reason (if error_message is not + // nullptr). bool AreValidArguments(intptr_t num_type_arguments, intptr_t num_arguments, const Array& argument_names, @@ -4887,8 +4889,9 @@ class Library : public Object { // more regular. void AddClass(const Class& cls) const; void AddObject(const Object& obj, const String& name) const; - ObjectPtr LookupReExport(const String& name, - ZoneGrowableArray* visited = NULL) const; + ObjectPtr LookupReExport( + const String& name, + ZoneGrowableArray* visited = nullptr) const; ObjectPtr LookupObjectAllowPrivate(const String& name) const; ObjectPtr LookupLocalOrReExportObject(const String& name) const; ObjectPtr LookupImportedObject(const String& name) const; @@ -6477,7 +6480,7 @@ class Code : public Object { InstructionsPtr active_instructions() const { #if defined(DART_PRECOMPILED_RUNTIME) UNREACHABLE(); - return NULL; + return nullptr; #else return untag()->active_instructions(); #endif @@ -6656,7 +6659,7 @@ class Code : public Object { ArrayPtr deopt_info_array() const { #if defined(DART_PRECOMPILED_RUNTIME) UNREACHABLE(); - return NULL; + return nullptr; #else return untag()->deopt_info_array(); #endif @@ -6712,7 +6715,7 @@ class Code : public Object { ArrayPtr static_calls_target_table() const { #if defined(DART_PRECOMPILED_RUNTIME) UNREACHABLE(); - return NULL; + return nullptr; #else return untag()->static_calls_target_table(); #endif @@ -6728,7 +6731,7 @@ class Code : public Object { void SetStaticCallTargetCodeAt(uword pc, const Code& code) const; void SetStubCallTargetCodeAt(uword pc, const Code& code) const; - void Disassemble(DisassemblyFormatter* formatter = NULL) const; + void Disassemble(DisassemblyFormatter* formatter = nullptr) const; #if defined(INCLUDE_IL_PRINTER) class Comments : public ZoneAllocated, public CodeComments { @@ -6766,7 +6769,7 @@ class Code : public Object { ObjectPtr return_address_metadata() const { #if defined(PRODUCT) UNREACHABLE(); - return NULL; + return nullptr; #else return untag()->return_address_metadata(); #endif @@ -6807,7 +6810,7 @@ class Code : public Object { LocalVarDescriptorsPtr var_descriptors() const { #if defined(PRODUCT) UNREACHABLE(); - return NULL; + return nullptr; #else return untag()->var_descriptors(); #endif @@ -7791,7 +7794,7 @@ class Instance : public Object { // If the instance is a callable object, i.e. a closure or the instance of a // class implementing a 'call' method, return true and set the function - // (if not NULL) to call. + // (if not nullptr) to call. bool IsCallable(Function* function) const; ObjectPtr Invoke(const String& selector, @@ -13074,7 +13077,7 @@ void Instance::GetNativeFields(uint16_t num_fields, intptr_t* field_values) const { NoSafepointScope no_safepoint; ASSERT(num_fields == NumNativeFields()); - ASSERT(field_values != NULL); + ASSERT(field_values != nullptr); TypedDataPtr native_fields = static_cast( NativeFieldsAddr()->Decompress(untag()->heap_base())); if (native_fields == TypedData::null()) { diff --git a/runtime/vm/object_graph.cc b/runtime/vm/object_graph.cc index e3ead87fd07..026c2a80591 100644 --- a/runtime/vm/object_graph.cc +++ b/runtime/vm/object_graph.cc @@ -285,7 +285,7 @@ class ObjectGraph::Stack : public ObjectPointerVisitor { DISALLOW_COPY_AND_ASSIGN(Stack); }; -ObjectPtr* const ObjectGraph::Stack::kSentinel = NULL; +ObjectPtr* const ObjectGraph::Stack::kSentinel = nullptr; ObjectPtr ObjectGraph::StackIterator::Get() const { return stack_->data_[index_].obj; @@ -818,7 +818,7 @@ void HeapSnapshotWriter::SetupCountingPages() { intptr_t next_offset = 0; Page* image_page = Dart::vm_isolate_group()->heap()->old_space()->image_pages_; - while (image_page != NULL) { + while (image_page != nullptr) { RELEASE_ASSERT(next_offset <= kMaxImagePages); image_page_ranges_[next_offset].base = image_page->object_start(); image_page_ranges_[next_offset].size = @@ -827,7 +827,7 @@ void HeapSnapshotWriter::SetupCountingPages() { next_offset++; } image_page = isolate_group()->heap()->old_space()->image_pages_; - while (image_page != NULL) { + while (image_page != nullptr) { RELEASE_ASSERT(next_offset <= kMaxImagePages); image_page_ranges_[next_offset].base = image_page->object_start(); image_page_ranges_[next_offset].size = @@ -837,11 +837,11 @@ void HeapSnapshotWriter::SetupCountingPages() { } Page* page = isolate_group()->heap()->old_space()->pages_; - while (page != NULL) { + while (page != nullptr) { page->forwarding_page(); CountingPage* counting_page = reinterpret_cast(page->forwarding_page()); - ASSERT(counting_page != NULL); + ASSERT(counting_page != nullptr); counting_page->Clear(); page = page->next(); } diff --git a/runtime/vm/object_graph.h b/runtime/vm/object_graph.h index eca50bd1c55..5e226371846 100644 --- a/runtime/vm/object_graph.h +++ b/runtime/vm/object_graph.h @@ -62,7 +62,7 @@ class ObjectGraph : public ThreadStackResource { virtual bool visit_weak_persistent_handles() const { return false; } - const char* gc_root_type = NULL; + const char* gc_root_type = nullptr; bool is_traversing = false; }; diff --git a/runtime/vm/object_graph_test.cc b/runtime/vm/object_graph_test.cc index 8294897e521..1ddf7cc6bf3 100644 --- a/runtime/vm/object_graph_test.cc +++ b/runtime/vm/object_graph_test.cc @@ -175,7 +175,7 @@ ISOLATE_UNIT_TEST_CASE(RetainingPathGCRoot) { { TransitionVMToNative transition(thread); Dart_DeletePersistentHandle(persistent_handle); - persistent_handle = NULL; + persistent_handle = nullptr; } result = graph.RetainingPath(&path, path); EXPECT_STREQ(result.gc_root_type, "weak persistent handle"); @@ -184,7 +184,7 @@ ISOLATE_UNIT_TEST_CASE(RetainingPathGCRoot) { { TransitionVMToNative transition(thread); Dart_DeleteWeakPersistentHandle(weak_persistent_handle); - weak_persistent_handle = NULL; + weak_persistent_handle = nullptr; } result = graph.RetainingPath(&path, path); EXPECT_STREQ(result.gc_root_type, "local handle"); diff --git a/runtime/vm/object_id_ring.cc b/runtime/vm/object_id_ring.cc index 4e60ce056db..8fb39e8a32f 100644 --- a/runtime/vm/object_id_ring.cc +++ b/runtime/vm/object_id_ring.cc @@ -13,9 +13,9 @@ namespace dart { #ifndef PRODUCT ObjectIdRing::~ObjectIdRing() { - ASSERT(table_ != NULL); + ASSERT(table_ != nullptr); free(table_); - table_ = NULL; + table_ = nullptr; } int32_t ObjectIdRing::GetIdForObject(ObjectPtr object, IdPolicy policy) { @@ -61,14 +61,14 @@ ObjectPtr ObjectIdRing::GetObjectForId(int32_t id, LookupResult* kind) { } void ObjectIdRing::VisitPointers(ObjectPointerVisitor* visitor) { - ASSERT(table_ != NULL); + ASSERT(table_ != nullptr); visitor->VisitPointers(table_, capacity_); } void ObjectIdRing::PrintJSON(JSONStream* js) { Thread* thread = Thread::Current(); Zone* zone = thread->zone(); - ASSERT(zone != NULL); + ASSERT(zone != nullptr); JSONObject jsobj(js); jsobj.AddProperty("type", "_IdZone"); jsobj.AddProperty("name", "default"); @@ -89,7 +89,7 @@ void ObjectIdRing::PrintJSON(JSONStream* js) { ObjectIdRing::ObjectIdRing() { serial_num_ = 0; wrapped_ = false; - table_ = NULL; + table_ = nullptr; SetCapacityAndMaxSerial(kDefaultCapacity, kMaxId); } @@ -98,7 +98,7 @@ void ObjectIdRing::SetCapacityAndMaxSerial(int32_t capacity, ASSERT(capacity > 0); ASSERT(max_serial <= kMaxId); capacity_ = capacity; - if (table_ != NULL) { + if (table_ != nullptr) { free(table_); } table_ = reinterpret_cast(calloc(capacity_, kWordSize)); diff --git a/runtime/vm/object_id_ring_test.cc b/runtime/vm/object_id_ring_test.cc index e1e6cf03ae9..8ece9933a05 100644 --- a/runtime/vm/object_id_ring_test.cc +++ b/runtime/vm/object_id_ring_test.cc @@ -126,8 +126,8 @@ TEST_CASE(ObjectIdRingScavengeMoveTest) { "main() {\n" " return [1, 2, 3];\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); - Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, nullptr); + Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, nullptr); Dart_Handle moved_handle; intptr_t list_length = 0; EXPECT_VALID(result); diff --git a/runtime/vm/object_reload.cc b/runtime/vm/object_reload.cc index ea79b675629..3af8dfa74c6 100644 --- a/runtime/vm/object_reload.cc +++ b/runtime/vm/object_reload.cc @@ -790,7 +790,7 @@ void CallSiteResetter::Reset(const ICData& ic) { } else if (rule == ICData::kStatic || rule == ICData::kSuper) { old_target_ = ic.GetTargetAt(0); if (old_target_.IsNull()) { - FATAL("old_target is NULL.\n"); + FATAL("old_target is nullptr.\n"); } name_ = old_target_.name(); @@ -815,7 +815,7 @@ void CallSiteResetter::Reset(const ICData& ic) { args_desc_array_ = ic.arguments_descriptor(); ArgumentsDescriptor args_desc(args_desc_array_); if (new_target_.IsNull() || - !new_target_.AreValidArguments(args_desc, NULL)) { + !new_target_.AreValidArguments(args_desc, nullptr)) { // TODO(rmacnak): Patch to a NSME stub. VTIR_Print("Cannot rebind static call to %s from %s\n", old_target_.ToCString(), diff --git a/runtime/vm/object_service.cc b/runtime/vm/object_service.cc index 5554ddc16e7..323352f3d24 100644 --- a/runtime/vm/object_service.cc +++ b/runtime/vm/object_service.cc @@ -279,7 +279,7 @@ void Function::AddFunctionServiceId(const JSONObject& jsobj) const { Class& cls = Class::Handle(Owner()); // Special kinds of functions use indices in their respective lists. intptr_t id = -1; - const char* selector = NULL; + const char* selector = nullptr; // Regular functions known to their owner use their name (percent-encoded). String& name = String::Handle(this->name()); @@ -307,7 +307,7 @@ void Function::AddFunctionServiceId(const JSONObject& jsobj) const { return; } if (id != -1) { - ASSERT(selector != NULL); + ASSERT(selector != nullptr); if (cls.IsTopLevel()) { const auto& library = Library::Handle(cls.library()); const auto& private_key = String::Handle(library.private_key()); diff --git a/runtime/vm/object_store.cc b/runtime/vm/object_store.cc index 4ad5bc76283..a4656556c4c 100644 --- a/runtime/vm/object_store.cc +++ b/runtime/vm/object_store.cc @@ -17,7 +17,7 @@ namespace dart { void IsolateObjectStore::VisitObjectPointers(ObjectPointerVisitor* visitor) { - ASSERT(visitor != NULL); + ASSERT(visitor != nullptr); visitor->set_gc_root_type("isolate_object store"); visitor->VisitPointers(from(), to()); visitor->clear_gc_root_type(); @@ -73,7 +73,7 @@ ErrorPtr IsolateObjectStore::PreallocateObjects(const Object& out_of_memory) { Thread* thread = Thread::Current(); Isolate* isolate = thread->isolate(); Zone* zone = thread->zone(); - ASSERT(isolate != NULL && isolate->isolate_object_store() == this); + ASSERT(isolate != nullptr && isolate->isolate_object_store() == this); ASSERT(preallocated_stack_trace() == StackTrace::null()); resume_capabilities_ = GrowableObjectArray::New(); exit_listeners_ = GrowableObjectArray::New(); @@ -120,7 +120,7 @@ ObjectStore::ObjectStore() ObjectStore::~ObjectStore() {} void ObjectStore::VisitObjectPointers(ObjectPointerVisitor* visitor) { - ASSERT(visitor != NULL); + ASSERT(visitor != nullptr); visitor->set_gc_root_type("object store"); visitor->VisitPointers(from(), to()); visitor->clear_gc_root_type(); diff --git a/runtime/vm/object_store.h b/runtime/vm/object_store.h index ce36da8d4dc..f7e9040ebf1 100644 --- a/runtime/vm/object_store.h +++ b/runtime/vm/object_store.h @@ -614,7 +614,7 @@ class ObjectStore { break; } UNREACHABLE(); - return NULL; + return nullptr; } uword unused_field_; diff --git a/runtime/vm/object_test.cc b/runtime/vm/object_test.cc index b60a0fc6803..d4cf3e12203 100644 --- a/runtime/vm/object_test.cc +++ b/runtime/vm/object_test.cc @@ -291,7 +291,7 @@ TEST_CASE(Class_EndTokenPos) { " // }\n" " var bar = '\\'}';\n" "}\n"; - Dart_Handle lib_h = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib_h = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib_h); TransitionNativeToVM transition(thread); Library& lib = Library::Handle(); @@ -1648,7 +1648,7 @@ ISOLATE_UNIT_TEST_CASE(ExternalOneByteString) { intptr_t len = ARRAY_SIZE(characters); const String& str = String::Handle(ExternalOneByteString::New( - characters, len, NULL, 0, NoopFinalizer, Heap::kNew)); + characters, len, nullptr, 0, NoopFinalizer, Heap::kNew)); EXPECT(!str.IsOneByteString()); EXPECT(str.IsExternalOneByteString()); EXPECT_EQ(str.Length(), len); @@ -1698,7 +1698,7 @@ ISOLATE_UNIT_TEST_CASE(EscapeSpecialCharactersExternalOneByteString) { intptr_t len = ARRAY_SIZE(characters); const String& str = String::Handle(ExternalOneByteString::New( - characters, len, NULL, 0, NoopFinalizer, Heap::kNew)); + characters, len, nullptr, 0, NoopFinalizer, Heap::kNew)); EXPECT(!str.IsOneByteString()); EXPECT(str.IsExternalOneByteString()); EXPECT_EQ(str.Length(), len); @@ -1708,7 +1708,7 @@ ISOLATE_UNIT_TEST_CASE(EscapeSpecialCharactersExternalOneByteString) { EXPECT(escaped_str.Equals("a\\n\\f\\b\\t\\v\\r\\\\\\$z")); const String& empty_str = String::Handle(ExternalOneByteString::New( - characters, 0, NULL, 0, NoopFinalizer, Heap::kNew)); + characters, 0, nullptr, 0, NoopFinalizer, Heap::kNew)); const String& escaped_empty_str = String::Handle(String::EscapeSpecialCharacters(empty_str)); EXPECT_EQ(empty_str.Length(), 0); @@ -1743,7 +1743,7 @@ ISOLATE_UNIT_TEST_CASE(EscapeSpecialCharactersExternalTwoByteString) { intptr_t len = ARRAY_SIZE(characters); const String& str = String::Handle(ExternalTwoByteString::New( - characters, len, NULL, 0, NoopFinalizer, Heap::kNew)); + characters, len, nullptr, 0, NoopFinalizer, Heap::kNew)); EXPECT(str.IsExternalTwoByteString()); EXPECT_EQ(str.Length(), len); EXPECT(str.Equals("a\n\f\b\t\v\r\\$z")); @@ -1752,7 +1752,7 @@ ISOLATE_UNIT_TEST_CASE(EscapeSpecialCharactersExternalTwoByteString) { EXPECT(escaped_str.Equals("a\\n\\f\\b\\t\\v\\r\\\\\\$z")); const String& empty_str = String::Handle(ExternalTwoByteString::New( - characters, 0, NULL, 0, NoopFinalizer, Heap::kNew)); + characters, 0, nullptr, 0, NoopFinalizer, Heap::kNew)); const String& escaped_empty_str = String::Handle(String::EscapeSpecialCharacters(empty_str)); EXPECT_EQ(empty_str.Length(), 0); @@ -1764,7 +1764,7 @@ ISOLATE_UNIT_TEST_CASE(ExternalTwoByteString) { intptr_t len = ARRAY_SIZE(characters); const String& str = String::Handle(ExternalTwoByteString::New( - characters, len, NULL, 0, NoopFinalizer, Heap::kNew)); + characters, len, nullptr, 0, NoopFinalizer, Heap::kNew)); EXPECT(!str.IsTwoByteString()); EXPECT(str.IsExternalTwoByteString()); EXPECT_EQ(str.Length(), len); @@ -1977,9 +1977,9 @@ static void TestIllegalArrayLength(intptr_t length) { ", null);\n" "}\n", length); - Dart_Handle lib = TestCase::LoadTestScript(buffer, NULL); + Dart_Handle lib = TestCase::LoadTestScript(buffer, nullptr); EXPECT_VALID(lib); - Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL); + Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, nullptr); Utils::SNPrint(buffer, sizeof(buffer), "Unhandled exception:\n" "RangeError (length): Invalid value: " @@ -2006,9 +2006,9 @@ TEST_CASE(ArrayLengthOneTooMany) { ", null);\n" "}\n", kOneTooMany); - Dart_Handle lib = TestCase::LoadTestScript(buffer, NULL); + Dart_Handle lib = TestCase::LoadTestScript(buffer, nullptr); EXPECT_VALID(lib); - Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL); + Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, nullptr); EXPECT_ERROR(result, "Out of Memory"); } @@ -2020,9 +2020,9 @@ TEST_CASE(ArrayLengthMaxElements) { ", null);\n" "}\n", Array::kMaxElements); - Dart_Handle lib = TestCase::LoadTestScript(buffer, NULL); + Dart_Handle lib = TestCase::LoadTestScript(buffer, nullptr); EXPECT_VALID(lib); - Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL); + Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, nullptr); if (Dart_IsError(result)) { EXPECT_ERROR(result, "Out of Memory"); } else { @@ -2043,9 +2043,9 @@ static void TestIllegalTypedDataLength(const char* class_name, ");\n" "}\n", class_name, length); - Dart_Handle lib = TestCase::LoadTestScript(buffer, NULL); + Dart_Handle lib = TestCase::LoadTestScript(buffer, nullptr); EXPECT_VALID(lib); - Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL); + Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, nullptr); Utils::SNPrint(buffer, sizeof(buffer), "%" Pd, length); EXPECT_ERROR(result, "RangeError (length): Invalid value"); EXPECT_ERROR(result, buffer); @@ -2070,9 +2070,9 @@ TEST_CASE(Int8ListLengthOneTooMany) { ");\n" "}\n", kOneTooMany); - Dart_Handle lib = TestCase::LoadTestScript(buffer, NULL); + Dart_Handle lib = TestCase::LoadTestScript(buffer, nullptr); EXPECT_VALID(lib); - Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL); + Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, nullptr); EXPECT_ERROR(result, "Out of Memory"); } @@ -2086,9 +2086,9 @@ TEST_CASE(Int8ListLengthMaxElements) { ");\n" "}\n", max_elements); - Dart_Handle lib = TestCase::LoadTestScript(buffer, NULL); + Dart_Handle lib = TestCase::LoadTestScript(buffer, nullptr); EXPECT_VALID(lib); - Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL); + Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, nullptr); if (Dart_IsError(result)) { EXPECT_ERROR(result, "Out of Memory"); } else { @@ -2514,9 +2514,9 @@ ISOLATE_UNIT_TEST_CASE(Script) { TransitionVMToNative transition(thread); const char* kScript = "main() {}"; - Dart_Handle h_lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle h_lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(h_lib); - Dart_Handle result = Dart_Invoke(h_lib, NewString("main"), 0, NULL); + Dart_Handle result = Dart_Invoke(h_lib, NewString("main"), 0, nullptr); EXPECT_VALID(result); } @@ -2550,7 +2550,7 @@ ISOLATE_UNIT_TEST_CASE(ContextScope) { const intptr_t parent_scope_function_level = 0; LocalScope* parent_scope = - new LocalScope(NULL, parent_scope_function_level, 0); + new LocalScope(nullptr, parent_scope_function_level, 0); const intptr_t local_scope_function_level = 1; LocalScope* local_scope = @@ -2606,7 +2606,7 @@ ISOLATE_UNIT_TEST_CASE(ContextScope) { EXPECT_EQ(parent_scope_function_level, var_c->owner()->function_level()); // c is not in local_scope. EXPECT(local_scope->LocalLookupVariable(c, LocalVariable::kNoKernelOffset) == - NULL); + nullptr); test_only = false; // Please, insert alias. var_c = @@ -2622,7 +2622,7 @@ ISOLATE_UNIT_TEST_CASE(ContextScope) { bool found_captured_vars = false; VariableIndex next_index = parent_scope->AllocateVariables( Function::null_function(), first_parameter_index, num_parameters, - first_local_index, NULL, &found_captured_vars); + first_local_index, nullptr, &found_captured_vars); // Variables a, c and var_ta are captured, therefore are not allocated in // frame. EXPECT_EQ(0, next_index.value() - @@ -2651,7 +2651,7 @@ ISOLATE_UNIT_TEST_CASE(ContextScope) { // var b was not captured. EXPECT(outer_scope->LocalLookupVariable(b, LocalVariable::kNoKernelOffset) == - NULL); + nullptr); var_c = outer_scope->LocalLookupVariable(c, LocalVariable::kNoKernelOffset); EXPECT(var_c->is_captured()); @@ -3482,15 +3482,15 @@ ISOLATE_UNIT_TEST_CASE(EqualsIgnoringPrivate) { mangled_name = OneByteString::New("foo@12345.name@12345"); ext_mangled_name = ExternalOneByteString::New( reinterpret_cast(ext_mangled_str), - strlen(ext_mangled_str), NULL, 0, NoopFinalizer, Heap::kNew); + strlen(ext_mangled_str), nullptr, 0, NoopFinalizer, Heap::kNew); EXPECT(ext_mangled_name.IsExternalOneByteString()); ext_bare_name = ExternalOneByteString::New( reinterpret_cast(ext_bare_str), strlen(ext_bare_str), - NULL, 0, NoopFinalizer, Heap::kNew); + nullptr, 0, NoopFinalizer, Heap::kNew); EXPECT(ext_bare_name.IsExternalOneByteString()); ext_bad_bare_name = ExternalOneByteString::New( reinterpret_cast(ext_bad_bare_str), - strlen(ext_bad_bare_str), NULL, 0, NoopFinalizer, Heap::kNew); + strlen(ext_bad_bare_str), nullptr, 0, NoopFinalizer, Heap::kNew); EXPECT(ext_bad_bare_name.IsExternalOneByteString()); // str1 - OneByteString, str2 - ExternalOneByteString. @@ -3550,9 +3550,9 @@ TEST_CASE(StackTraceFormat) { "main() {\n" " (() => new MyClass())();\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, nullptr); EXPECT_VALID(lib); - Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL); + Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, nullptr); const char* lib_url = "file:///test-lib"; const size_t kBufferSize = 1024; @@ -5506,9 +5506,9 @@ main() { new FImplementation2(); } )"; - Dart_Handle h_lib = TestCase::LoadTestScript(kScriptChars, NULL); + Dart_Handle h_lib = TestCase::LoadTestScript(kScriptChars, nullptr); EXPECT_VALID(h_lib); - Dart_Handle result = Dart_Invoke(h_lib, NewString("main"), 0, NULL); + Dart_Handle result = Dart_Invoke(h_lib, NewString("main"), 0, nullptr); EXPECT_VALID(result); TransitionNativeToVM transition(thread); @@ -5763,9 +5763,9 @@ TEST_CASE(Metadata) { TestCase::NullableTag()), std::free); // clang-format on - Dart_Handle h_lib = TestCase::LoadTestScript(kScriptChars.get(), NULL); + Dart_Handle h_lib = TestCase::LoadTestScript(kScriptChars.get(), nullptr); EXPECT_VALID(h_lib); - Dart_Handle result = Dart_Invoke(h_lib, NewString("main"), 0, NULL); + Dart_Handle result = Dart_Invoke(h_lib, NewString("main"), 0, nullptr); EXPECT_VALID(result); TransitionNativeToVM transition(thread); Library& lib = Library::Handle(); @@ -5842,7 +5842,7 @@ TEST_CASE(FunctionSourceFingerprint) { " return a > 1 ? a + 1 : a;\n" " }\n" "}"; - TestCase::LoadTestScript(kScriptChars, NULL); + TestCase::LoadTestScript(kScriptChars, nullptr); TransitionNativeToVM transition(thread); EXPECT(ClassFinalizer::ProcessPendingClasses()); const String& name = String::Handle(String::New(TestCase::url())); @@ -5898,11 +5898,11 @@ TEST_CASE(FunctionWithBreakpointNotInlined) { " new A().b();\n" "}"; const int kBreakpointLine = 5; - Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, nullptr); EXPECT_VALID(lib); // Run function A.b one time. - Dart_Handle result = Dart_Invoke(lib, NewString("test"), 0, NULL); + Dart_Handle result = Dart_Invoke(lib, NewString("test"), 0, nullptr); EXPECT_VALID(result); // With no breakpoint, function A.b is inlineable. @@ -6516,9 +6516,9 @@ TEST_CASE(InstanceEquality) { " A a = new A();\n" "}"; - Dart_Handle h_lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle h_lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(h_lib); - Dart_Handle result = Dart_Invoke(h_lib, NewString("main"), 0, NULL); + Dart_Handle result = Dart_Invoke(h_lib, NewString("main"), 0, nullptr); EXPECT_VALID(result); TransitionNativeToVM transition(thread); @@ -6542,9 +6542,9 @@ TEST_CASE(HashCode) { " return \"foo\".hashCode;\n" "}"; - Dart_Handle h_lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle h_lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(h_lib); - Dart_Handle h_result = Dart_Invoke(h_lib, NewString("foo"), 0, NULL); + Dart_Handle h_result = Dart_Invoke(h_lib, NewString("foo"), 0, nullptr); EXPECT_VALID(h_result); TransitionNativeToVM transition(thread); @@ -6736,9 +6736,9 @@ TEST_CASE(Map_iteration) { " map.remove('w');\n" " return map;\n" "}"; - Dart_Handle h_lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle h_lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(h_lib); - Dart_Handle h_result = Dart_Invoke(h_lib, NewString("makeMap"), 0, NULL); + Dart_Handle h_result = Dart_Invoke(h_lib, NewString("makeMap"), 0, nullptr); EXPECT_VALID(h_result); TransitionNativeToVM transition(thread); @@ -6942,19 +6942,19 @@ bool lookupSpreadCollections(Map map) => bool? lookupNull(Map map) => map[null]; )"; - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); Dart_Handle non_const_result = - Dart_Invoke(lib, NewString("makeNonConstMap"), 0, NULL); + Dart_Invoke(lib, NewString("makeNonConstMap"), 0, nullptr); EXPECT_VALID(non_const_result); Dart_Handle first_key_result = - Dart_Invoke(lib, NewString("firstKey"), 0, NULL); + Dart_Invoke(lib, NewString("firstKey"), 0, nullptr); EXPECT_VALID(first_key_result); Dart_Handle first_key_hashcode_result = - Dart_Invoke(lib, NewString("firstKeyHashCode"), 0, NULL); + Dart_Invoke(lib, NewString("firstKeyHashCode"), 0, nullptr); EXPECT_VALID(first_key_hashcode_result); Dart_Handle first_key_identity_hashcode_result = - Dart_Invoke(lib, NewString("firstKeyIdentityHashCode"), 0, NULL); + Dart_Invoke(lib, NewString("firstKeyIdentityHashCode"), 0, nullptr); EXPECT_VALID(first_key_identity_hashcode_result); Dart_Handle const_argument; @@ -7015,14 +7015,15 @@ static bool IsLinkedHashBase(const Object& object) { template static void HashBaseNonConstEqualsConst(const char* script, bool check_data = true) { - Dart_Handle lib = TestCase::LoadTestScript(script, NULL); + Dart_Handle lib = TestCase::LoadTestScript(script, nullptr); EXPECT_VALID(lib); - Dart_Handle init_result = Dart_Invoke(lib, NewString("init"), 0, NULL); + Dart_Handle init_result = Dart_Invoke(lib, NewString("init"), 0, nullptr); EXPECT_VALID(init_result); Dart_Handle non_const_result = - Dart_Invoke(lib, NewString("nonConstValue"), 0, NULL); + Dart_Invoke(lib, NewString("nonConstValue"), 0, nullptr); EXPECT_VALID(non_const_result); - Dart_Handle const_result = Dart_Invoke(lib, NewString("constValue"), 0, NULL); + Dart_Handle const_result = + Dart_Invoke(lib, NewString("constValue"), 0, nullptr); EXPECT_VALID(const_result); TransitionNativeToVM transition(Thread::Current()); @@ -7221,9 +7222,9 @@ makeSet() { return set; } )"; - Dart_Handle h_lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle h_lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(h_lib); - Dart_Handle h_result = Dart_Invoke(h_lib, NewString("makeSet"), 0, NULL); + Dart_Handle h_result = Dart_Invoke(h_lib, NewString("makeSet"), 0, nullptr); EXPECT_VALID(h_result); TransitionNativeToVM transition(thread); @@ -7276,10 +7277,10 @@ makeNonConstSet() { bool containsFive(Set set) => set.contains(5); )"; - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); Dart_Handle non_const_result = - Dart_Invoke(lib, NewString("makeNonConstSet"), 0, NULL); + Dart_Invoke(lib, NewString("makeNonConstSet"), 0, nullptr); EXPECT_VALID(non_const_result); Dart_Handle const_argument; @@ -7413,10 +7414,10 @@ makeInternalString() { bool equalsAB(String a, String b) => !identical(a, b) && (a == b); bool equalsBA(String a, String b) => !identical(b, a) && (b == a); )"; - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); Dart_Handle internal_string = - Dart_Invoke(lib, NewString("makeInternalString"), 0, NULL); + Dart_Invoke(lib, NewString("makeInternalString"), 0, nullptr); EXPECT_VALID(internal_string); Dart_Handle external_string; @@ -7427,7 +7428,7 @@ bool equalsBA(String a, String b) => !identical(b, a) && (b == a); TransitionNativeToVM transition(thread); const String& str = String::Handle(ExternalOneByteString::New( - characters, len, NULL, 0, NoopFinalizer, Heap::kNew)); + characters, len, nullptr, 0, NoopFinalizer, Heap::kNew)); EXPECT(!str.IsOneByteString()); EXPECT(str.IsExternalOneByteString()); @@ -7483,7 +7484,7 @@ ISOLATE_UNIT_TEST_CASE(Symbols_FromConcatAll) { intptr_t len = ARRAY_SIZE(characters); const String& str = String::Handle(ExternalOneByteString::New( - characters, len, NULL, 0, NoopFinalizer, Heap::kNew)); + characters, len, nullptr, 0, NoopFinalizer, Heap::kNew)); const String* data[3] = {&str, &Symbols::Dot(), &str}; CheckConcatAll(data, 3); } @@ -7494,7 +7495,7 @@ ISOLATE_UNIT_TEST_CASE(Symbols_FromConcatAll) { intptr_t len = ARRAY_SIZE(characters); const String& str = String::Handle(ExternalTwoByteString::New( - characters, len, NULL, 0, NoopFinalizer, Heap::kNew)); + characters, len, nullptr, 0, NoopFinalizer, Heap::kNew)); const String* data[3] = {&str, &Symbols::Dot(), &str}; CheckConcatAll(data, 3); } @@ -7504,14 +7505,14 @@ ISOLATE_UNIT_TEST_CASE(Symbols_FromConcatAll) { intptr_t len1 = ARRAY_SIZE(characters1); const String& str1 = String::Handle(ExternalOneByteString::New( - characters1, len1, NULL, 0, NoopFinalizer, Heap::kNew)); + characters1, len1, nullptr, 0, NoopFinalizer, Heap::kNew)); uint16_t characters2[] = {'a', '\n', '\f', '\b', '\t', '\v', '\r', '\\', '$', 'z'}; intptr_t len2 = ARRAY_SIZE(characters2); const String& str2 = String::Handle(ExternalTwoByteString::New( - characters2, len2, NULL, 0, NoopFinalizer, Heap::kNew)); + characters2, len2, nullptr, 0, NoopFinalizer, Heap::kNew)); const String* data[3] = {&str1, &Symbols::Dot(), &str2}; CheckConcatAll(data, 3); } @@ -7575,7 +7576,7 @@ TEST_CASE(TypeParameterTypeRef) { "void bar>(M x) {}\n" "abstract class C {}\n" "abstract class U extends C {}\n"; - TestCase::LoadTestScript(kScriptChars, NULL); + TestCase::LoadTestScript(kScriptChars, nullptr); TransitionNativeToVM transition(thread); EXPECT(ClassFinalizer::ProcessPendingClasses()); const String& name = String::Handle(String::New(TestCase::url())); @@ -8235,9 +8236,9 @@ static void TypeArgumentsHashCacheTest(Thread* thread, intptr_t num_classes) { } buffer.AddString("}\n"); - Dart_Handle api_lib = TestCase::LoadTestScript(buffer.buffer(), NULL); + Dart_Handle api_lib = TestCase::LoadTestScript(buffer.buffer(), nullptr); EXPECT_VALID(api_lib); - Dart_Handle result = Dart_Invoke(api_lib, NewString("main"), 0, NULL); + Dart_Handle result = Dart_Invoke(api_lib, NewString("main"), 0, nullptr); EXPECT_VALID(result); // D + C0...CN, where N = kNumClasses - 1 diff --git a/runtime/vm/os_android.cc b/runtime/vm/os_android.cc index 564e68ec5ec..783ca0342b8 100644 --- a/runtime/vm/os_android.cc +++ b/runtime/vm/os_android.cc @@ -43,27 +43,27 @@ DEFINE_FLAG(bool, class PerfCodeObserver : public CodeObserver { public: - PerfCodeObserver() : out_file_(NULL) { + PerfCodeObserver() : out_file_(nullptr) { Dart_FileOpenCallback file_open = Dart::file_open_callback(); - if (file_open == NULL) { + if (file_open == nullptr) { return; } intptr_t pid = getpid(); - char* filename = OS::SCreate(NULL, "/tmp/perf-%" Pd ".map", pid); + char* filename = OS::SCreate(nullptr, "/tmp/perf-%" Pd ".map", pid); out_file_ = (*file_open)(filename, true); free(filename); } ~PerfCodeObserver() { Dart_FileCloseCallback file_close = Dart::file_close_callback(); - if ((file_close == NULL) || (out_file_ == NULL)) { + if ((file_close == nullptr) || (out_file_ == nullptr)) { return; } (*file_close)(out_file_); } virtual bool IsActive() const { - return FLAG_generate_perf_events_symbols && (out_file_ != NULL); + return FLAG_generate_perf_events_symbols && (out_file_ != nullptr); } virtual void Notify(const char* name, @@ -73,7 +73,7 @@ class PerfCodeObserver : public CodeObserver { bool optimized, const CodeComments* comments) { Dart_FileWriteCallback file_write = Dart::file_write_callback(); - if ((file_write == NULL) || (out_file_ == NULL)) { + if ((file_write == nullptr) || (out_file_ == nullptr)) { return; } const char* marker = optimized ? "*" : ""; @@ -99,14 +99,15 @@ static bool LocalTime(int64_t seconds_since_epoch, tm* tm_result) { time_t seconds = static_cast(seconds_since_epoch); if (seconds != seconds_since_epoch) return false; struct tm* error_code = localtime_r(&seconds, tm_result); - return error_code != NULL; + return error_code != nullptr; } const char* OS::GetTimeZoneName(int64_t seconds_since_epoch) { tm decomposed; bool succeeded = LocalTime(seconds_since_epoch, &decomposed); // If unsuccessful, return an empty string like V8 does. - return (succeeded && (decomposed.tm_zone != NULL)) ? decomposed.tm_zone : ""; + return (succeeded && (decomposed.tm_zone != nullptr)) ? decomposed.tm_zone + : ""; } int OS::GetTimeZoneOffsetInSeconds(int64_t seconds_since_epoch) { @@ -124,7 +125,7 @@ int64_t OS::GetCurrentTimeMillis() { int64_t OS::GetCurrentTimeMicros() { // gettimeofday has microsecond resolution. struct timeval tv; - if (gettimeofday(&tv, NULL) < 0) { + if (gettimeofday(&tv, nullptr) < 0) { UNREACHABLE(); return 0; } @@ -262,7 +263,7 @@ char* OS::VSCreate(Zone* zone, const char* format, va_list args) { // Measure. va_list measure_args; va_copy(measure_args, args); - intptr_t len = Utils::VSNPrint(NULL, 0, format, measure_args); + intptr_t len = Utils::VSNPrint(nullptr, 0, format, measure_args); va_end(measure_args); char* buffer; @@ -271,7 +272,7 @@ char* OS::VSCreate(Zone* zone, const char* format, va_list args) { } else { buffer = reinterpret_cast(malloc(len + 1)); } - ASSERT(buffer != NULL); + ASSERT(buffer != nullptr); // Print. va_list print_args; @@ -282,7 +283,7 @@ char* OS::VSCreate(Zone* zone, const char* format, va_list args) { } bool OS::StringToInt64(const char* str, int64_t* value) { - ASSERT(str != NULL && strlen(str) > 0 && value != NULL); + ASSERT(str != nullptr && strlen(str) > 0 && value != nullptr); int32_t base = 10; char* endptr; int i = 0; diff --git a/runtime/vm/os_fuchsia.cc b/runtime/vm/os_fuchsia.cc index f5b7eff989a..1616a4a5dd9 100644 --- a/runtime/vm/os_fuchsia.cc +++ b/runtime/vm/os_fuchsia.cc @@ -514,7 +514,7 @@ char* OS::VSCreate(Zone* zone, const char* format, va_list args) { // Measure. va_list measure_args; va_copy(measure_args, args); - intptr_t len = Utils::VSNPrint(NULL, 0, format, measure_args); + intptr_t len = Utils::VSNPrint(nullptr, 0, format, measure_args); va_end(measure_args); char* buffer; @@ -523,7 +523,7 @@ char* OS::VSCreate(Zone* zone, const char* format, va_list args) { } else { buffer = reinterpret_cast(malloc(len + 1)); } - ASSERT(buffer != NULL); + ASSERT(buffer != nullptr); // Print. va_list print_args; @@ -534,7 +534,7 @@ char* OS::VSCreate(Zone* zone, const char* format, va_list args) { } bool OS::StringToInt64(const char* str, int64_t* value) { - ASSERT(str != NULL && strlen(str) > 0 && value != NULL); + ASSERT(str != nullptr && strlen(str) > 0 && value != nullptr); int32_t base = 10; char* endptr; int i = 0; diff --git a/runtime/vm/os_linux.cc b/runtime/vm/os_linux.cc index ff590cee58a..a2a7a2a5640 100644 --- a/runtime/vm/os_linux.cc +++ b/runtime/vm/os_linux.cc @@ -64,27 +64,27 @@ DECLARE_FLAG(bool, code_comments); // invoke perf-report. class PerfCodeObserver : public CodeObserver { public: - PerfCodeObserver() : out_file_(NULL) { + PerfCodeObserver() : out_file_(nullptr) { Dart_FileOpenCallback file_open = Dart::file_open_callback(); - if (file_open == NULL) { + if (file_open == nullptr) { return; } intptr_t pid = getpid(); - char* filename = OS::SCreate(NULL, "/tmp/perf-%" Pd ".map", pid); + char* filename = OS::SCreate(nullptr, "/tmp/perf-%" Pd ".map", pid); out_file_ = (*file_open)(filename, true); free(filename); } ~PerfCodeObserver() { Dart_FileCloseCallback file_close = Dart::file_close_callback(); - if ((file_close == NULL) || (out_file_ == NULL)) { + if ((file_close == nullptr) || (out_file_ == nullptr)) { return; } (*file_close)(out_file_); } virtual bool IsActive() const { - return FLAG_generate_perf_events_symbols && (out_file_ != NULL); + return FLAG_generate_perf_events_symbols && (out_file_ != nullptr); } virtual void Notify(const char* name, @@ -94,7 +94,7 @@ class PerfCodeObserver : public CodeObserver { bool optimized, const CodeComments* comments) { Dart_FileWriteCallback file_write = Dart::file_write_callback(); - if ((file_write == NULL) || (out_file_ == NULL)) { + if ((file_write == nullptr) || (out_file_ == nullptr)) { return; } const char* marker = optimized ? "*" : ""; @@ -418,14 +418,15 @@ static bool LocalTime(int64_t seconds_since_epoch, tm* tm_result) { time_t seconds = static_cast(seconds_since_epoch); if (seconds != seconds_since_epoch) return false; struct tm* error_code = localtime_r(&seconds, tm_result); - return error_code != NULL; + return error_code != nullptr; } const char* OS::GetTimeZoneName(int64_t seconds_since_epoch) { tm decomposed; bool succeeded = LocalTime(seconds_since_epoch, &decomposed); // If unsuccessful, return an empty string like V8 does. - return (succeeded && (decomposed.tm_zone != NULL)) ? decomposed.tm_zone : ""; + return (succeeded && (decomposed.tm_zone != nullptr)) ? decomposed.tm_zone + : ""; } int OS::GetTimeZoneOffsetInSeconds(int64_t seconds_since_epoch) { @@ -443,7 +444,7 @@ int64_t OS::GetCurrentTimeMillis() { int64_t OS::GetCurrentTimeMicros() { // gettimeofday has microsecond resolution. struct timeval tv; - if (gettimeofday(&tv, NULL) < 0) { + if (gettimeofday(&tv, nullptr) < 0) { UNREACHABLE(); return 0; } @@ -578,7 +579,7 @@ char* OS::VSCreate(Zone* zone, const char* format, va_list args) { // Measure. va_list measure_args; va_copy(measure_args, args); - intptr_t len = Utils::VSNPrint(NULL, 0, format, measure_args); + intptr_t len = Utils::VSNPrint(nullptr, 0, format, measure_args); va_end(measure_args); char* buffer; @@ -587,7 +588,7 @@ char* OS::VSCreate(Zone* zone, const char* format, va_list args) { } else { buffer = reinterpret_cast(malloc(len + 1)); } - ASSERT(buffer != NULL); + ASSERT(buffer != nullptr); // Print. va_list print_args; @@ -598,7 +599,7 @@ char* OS::VSCreate(Zone* zone, const char* format, va_list args) { } bool OS::StringToInt64(const char* str, int64_t* value) { - ASSERT(str != NULL && strlen(str) > 0 && value != NULL); + ASSERT(str != nullptr && strlen(str) > 0 && value != nullptr); int32_t base = 10; char* endptr; int i = 0; diff --git a/runtime/vm/os_macos.cc b/runtime/vm/os_macos.cc index 17d4c261b61..59977a0a789 100644 --- a/runtime/vm/os_macos.cc +++ b/runtime/vm/os_macos.cc @@ -34,14 +34,15 @@ static bool LocalTime(int64_t seconds_since_epoch, tm* tm_result) { time_t seconds = static_cast(seconds_since_epoch); if (seconds != seconds_since_epoch) return false; struct tm* error_code = localtime_r(&seconds, tm_result); - return error_code != NULL; + return error_code != nullptr; } const char* OS::GetTimeZoneName(int64_t seconds_since_epoch) { tm decomposed; bool succeeded = LocalTime(seconds_since_epoch, &decomposed); // If unsuccessful, return an empty string like V8 does. - return (succeeded && (decomposed.tm_zone != NULL)) ? decomposed.tm_zone : ""; + return (succeeded && (decomposed.tm_zone != nullptr)) ? decomposed.tm_zone + : ""; } int OS::GetTimeZoneOffsetInSeconds(int64_t seconds_since_epoch) { @@ -59,7 +60,7 @@ int64_t OS::GetCurrentTimeMillis() { int64_t OS::GetCurrentTimeMicros() { // gettimeofday has microsecond resolution. struct timeval tv; - if (gettimeofday(&tv, NULL) < 0) { + if (gettimeofday(&tv, nullptr) < 0) { UNREACHABLE(); return 0; } @@ -216,7 +217,7 @@ char* OS::VSCreate(Zone* zone, const char* format, va_list args) { // Measure. va_list measure_args; va_copy(measure_args, args); - intptr_t len = Utils::VSNPrint(NULL, 0, format, measure_args); + intptr_t len = Utils::VSNPrint(nullptr, 0, format, measure_args); va_end(measure_args); char* buffer; @@ -225,7 +226,7 @@ char* OS::VSCreate(Zone* zone, const char* format, va_list args) { } else { buffer = reinterpret_cast(malloc(len + 1)); } - ASSERT(buffer != NULL); + ASSERT(buffer != nullptr); // Print. va_list print_args; @@ -236,7 +237,7 @@ char* OS::VSCreate(Zone* zone, const char* format, va_list args) { } bool OS::StringToInt64(const char* str, int64_t* value) { - ASSERT(str != NULL && strlen(str) > 0 && value != NULL); + ASSERT(str != nullptr && strlen(str) > 0 && value != nullptr); int32_t base = 10; char* endptr; int i = 0; @@ -281,13 +282,13 @@ void OS::Init() { // This is a workaround for a macos bug, we eagerly call localtime_r so that // libnotify is initialized early before any fork happens. struct timeval tv; - if (gettimeofday(&tv, NULL) < 0) { + if (gettimeofday(&tv, nullptr) < 0) { FATAL("gettimeofday returned an error (%s)\n", strerror(errno)); return; } tm decomposed; struct tm* error_code = localtime_r(&(tv.tv_sec), &decomposed); - if (error_code == NULL) { + if (error_code == nullptr) { FATAL("localtime_r returned an error (%s)\n", strerror(errno)); return; } diff --git a/runtime/vm/os_test.cc b/runtime/vm/os_test.cc index d1b7791c414..f0cec9819f4 100644 --- a/runtime/vm/os_test.cc +++ b/runtime/vm/os_test.cc @@ -22,7 +22,7 @@ VM_UNIT_TEST_CASE(SNPrint) { length = Utils::SNPrint(buffer, 256, "%s%c%d", "foo", 'Z', 42); EXPECT_EQ(6, length); EXPECT_STREQ("fooZ42", buffer); - length = Utils::SNPrint(NULL, 0, "foo"); + length = Utils::SNPrint(nullptr, 0, "foo"); EXPECT_EQ(3, length); } diff --git a/runtime/vm/os_thread.cc b/runtime/vm/os_thread.cc index 9bc6f61c358..6ee3aee0e42 100644 --- a/runtime/vm/os_thread.cc +++ b/runtime/vm/os_thread.cc @@ -16,8 +16,8 @@ namespace dart { // The single thread local key which stores all the thread local data // for a thread. ThreadLocalKey OSThread::thread_key_ = kUnsetThreadLocalKey; -OSThread* OSThread::thread_list_head_ = NULL; -Mutex* OSThread::thread_list_lock_ = NULL; +OSThread* OSThread::thread_list_head_ = nullptr; +Mutex* OSThread::thread_list_lock_ = nullptr; bool OSThread::creation_enabled_ = false; #if defined(SUPPORT_TIMELINE) @@ -46,14 +46,14 @@ OSThread::OSThread() #endif name_(OSThread::GetCurrentThreadName()), timeline_block_lock_(), - timeline_block_(NULL), - thread_list_next_(NULL), + timeline_block_(nullptr), + thread_list_next_(nullptr), thread_interrupt_disabled_(1), // Thread interrupts disabled by default. log_(new class Log()), stack_base_(0), stack_limit_(0), stack_headroom_(0), - thread_(NULL) { + thread_(nullptr) { // Try to get accurate stack bounds from pthreads, etc. if (!GetCurrentStackBounds(&stack_limit_, &stack_base_)) { FATAL("Failed to retrieve stack bounds"); @@ -74,10 +74,10 @@ OSThread::OSThread() } OSThread* OSThread::CreateOSThread() { - ASSERT(thread_list_lock_ != NULL); + ASSERT(thread_list_lock_ != nullptr); MutexLocker ml(thread_list_lock_); if (!creation_enabled_) { - return NULL; + return nullptr; } OSThread* os_thread = new OSThread(); AddThreadToListLocked(os_thread); @@ -93,22 +93,22 @@ OSThread::~OSThread() { } RemoveThreadFromList(this); delete log_; - log_ = NULL; + log_ = nullptr; #if defined(SUPPORT_TIMELINE) - if (Timeline::recorder() != NULL) { + if (Timeline::recorder() != nullptr) { Timeline::recorder()->FinishBlock(timeline_block_); } #endif - timeline_block_ = NULL; + timeline_block_ = nullptr; free(name_); } void OSThread::SetName(const char* name) { MutexLocker ml(thread_list_lock_); // Clear the old thread name. - if (name_ != NULL) { + if (name_ != nullptr) { free(name_); - name_ = NULL; + name_ = nullptr; } ASSERT(OSThread::Current() == this); ASSERT(name != nullptr); @@ -162,10 +162,10 @@ static void DeleteThread(void* thread) { void OSThread::Init() { // Allocate the global OSThread lock. - if (thread_list_lock_ == NULL) { + if (thread_list_lock_ == nullptr) { thread_list_lock_ = new Mutex(); } - ASSERT(thread_list_lock_ != NULL); + ASSERT(thread_list_lock_ != nullptr); // Create the thread local key. if (thread_key_ == kUnsetThreadLocalKey) { @@ -178,7 +178,7 @@ void OSThread::Init() { // Create a new OSThread structure and set it as the TLS. OSThread* os_thread = CreateOSThread(); - ASSERT(os_thread != NULL); + ASSERT(os_thread != nullptr); OSThread::SetCurrent(os_thread); os_thread->SetName("Dart_Initialize"); } @@ -187,24 +187,24 @@ void OSThread::Cleanup() { // We cannot delete the thread local key and thread list lock, yet. // See the note on thread_list_lock_ in os_thread.h. #if 0 - if (thread_list_lock_ != NULL) { + if (thread_list_lock_ != nullptr) { // Delete the thread local key. ASSERT(thread_key_ != kUnsetThreadLocalKey); DeleteThreadLocal(thread_key_); thread_key_ = kUnsetThreadLocalKey; // Delete the global OSThread lock. - ASSERT(thread_list_lock_ != NULL); + ASSERT(thread_list_lock_ != nullptr); delete thread_list_lock_; - thread_list_lock_ = NULL; + thread_list_lock_ = nullptr; } #endif } OSThread* OSThread::CreateAndSetUnknownThread() { - ASSERT(OSThread::GetCurrentTLS() == NULL); + ASSERT(OSThread::GetCurrentTLS() == nullptr); OSThread* os_thread = CreateOSThread(); - if (os_thread != NULL) { + if (os_thread != nullptr) { OSThread::SetCurrent(os_thread); if (os_thread->name() == nullptr) { os_thread->SetName("Unknown"); @@ -241,22 +241,22 @@ void OSThread::EnableOSThreadCreation() { } OSThread* OSThread::GetOSThreadFromThread(ThreadState* thread) { - ASSERT(thread->os_thread() != NULL); + ASSERT(thread->os_thread() != nullptr); return thread->os_thread(); } void OSThread::AddThreadToListLocked(OSThread* thread) { - ASSERT(thread != NULL); - ASSERT(thread_list_lock_ != NULL); + ASSERT(thread != nullptr); + ASSERT(thread_list_lock_ != nullptr); ASSERT(OSThread::thread_list_lock_->IsOwnedByCurrentThread()); ASSERT(creation_enabled_); - ASSERT(thread->thread_list_next_ == NULL); + ASSERT(thread->thread_list_next_ == nullptr); #if defined(DEBUG) { // Ensure that we aren't already in the list. OSThread* current = thread_list_head_; - while (current != NULL) { + while (current != nullptr) { ASSERT(current != thread); current = current->thread_list_next_; } @@ -271,23 +271,23 @@ void OSThread::AddThreadToListLocked(OSThread* thread) { void OSThread::RemoveThreadFromList(OSThread* thread) { bool final_thread = false; { - ASSERT(thread != NULL); - ASSERT(thread_list_lock_ != NULL); + ASSERT(thread != nullptr); + ASSERT(thread_list_lock_ != nullptr); MutexLocker ml(thread_list_lock_); OSThread* current = thread_list_head_; - OSThread* previous = NULL; + OSThread* previous = nullptr; // Scan across list and remove |thread|. - while (current != NULL) { + while (current != nullptr) { if (current == thread) { // We found |thread|, remove from list. - if (previous == NULL) { + if (previous == nullptr) { thread_list_head_ = thread->thread_list_next_; } else { previous->thread_list_next_ = current->thread_list_next_; } - thread->thread_list_next_ = NULL; - final_thread = !creation_enabled_ && (thread_list_head_ == NULL); + thread->thread_list_next_ = nullptr; + final_thread = !creation_enabled_ && (thread_list_head_ == nullptr); break; } previous = current; @@ -306,34 +306,34 @@ void OSThread::SetCurrentTLS(BaseThread* value) { SetThreadLocal(thread_key_, reinterpret_cast(value)); // Allows the C compiler more freedom to optimize. - if ((value != NULL) && !value->is_os_thread()) { + if ((value != nullptr) && !value->is_os_thread()) { current_vm_thread_ = static_cast(value); } else { - current_vm_thread_ = NULL; + current_vm_thread_ = nullptr; } } OSThreadIterator::OSThreadIterator() { - ASSERT(OSThread::thread_list_lock_ != NULL); + ASSERT(OSThread::thread_list_lock_ != nullptr); // Lock the thread list while iterating. OSThread::thread_list_lock_->Lock(); next_ = OSThread::thread_list_head_; } OSThreadIterator::~OSThreadIterator() { - ASSERT(OSThread::thread_list_lock_ != NULL); + ASSERT(OSThread::thread_list_lock_ != nullptr); // Unlock the thread list when done. OSThread::thread_list_lock_->Unlock(); } bool OSThreadIterator::HasNext() const { - ASSERT(OSThread::thread_list_lock_ != NULL); + ASSERT(OSThread::thread_list_lock_ != nullptr); ASSERT(OSThread::thread_list_lock_->IsOwnedByCurrentThread()); - return next_ != NULL; + return next_ != nullptr; } OSThread* OSThreadIterator::Next() { - ASSERT(OSThread::thread_list_lock_ != NULL); + ASSERT(OSThread::thread_list_lock_ != nullptr); ASSERT(OSThread::thread_list_lock_->IsOwnedByCurrentThread()); OSThread* current = next_; next_ = next_->thread_list_next_; diff --git a/runtime/vm/os_thread.h b/runtime/vm/os_thread.h index 5940cd7e11d..c27b7a940a4 100644 --- a/runtime/vm/os_thread.h +++ b/runtime/vm/os_thread.h @@ -86,7 +86,7 @@ class OSThread : public BaseThread { public: // The constructor of OSThread is never called directly, instead we call // this factory style method 'CreateOSThread' to create OSThread structures. - // The method can return a NULL if the Dart VM is in shutdown mode. + // The method can return a nullptr if the Dart VM is in shutdown mode. static OSThread* CreateOSThread(); ~OSThread(); @@ -146,11 +146,11 @@ class OSThread : public BaseThread { void EnableThreadInterrupts(); bool ThreadInterruptsEnabled(); - // The currently executing thread, or NULL if not yet initialized. + // The currently executing thread, or nullptr if not yet initialized. static OSThread* TryCurrent() { BaseThread* thread = GetCurrentTLS(); - OSThread* os_thread = NULL; - if (thread != NULL) { + OSThread* os_thread = nullptr; + if (thread != nullptr) { if (thread->is_os_thread()) { os_thread = reinterpret_cast(thread); } else { @@ -165,7 +165,7 @@ class OSThread : public BaseThread { // a new OSThread is created and returned. static OSThread* Current() { OSThread* os_thread = TryCurrent(); - if (os_thread == NULL) { + if (os_thread == nullptr) { os_thread = CreateAndSetUnknownThread(); } return os_thread; @@ -203,7 +203,8 @@ class OSThread : public BaseThread { ThreadStartFunction function, uword parameter); - static ThreadLocalKey CreateThreadLocal(ThreadDestructor destructor = NULL); + static ThreadLocalKey CreateThreadLocal( + ThreadDestructor destructor = nullptr); static void DeleteThreadLocal(ThreadLocalKey key); static uword GetThreadLocal(ThreadLocalKey key) { return ThreadInlineImpl::GetThreadLocal(key); diff --git a/runtime/vm/os_thread_absl.cc b/runtime/vm/os_thread_absl.cc index 8968b07edab..8c4e7e2aecd 100644 --- a/runtime/vm/os_thread_absl.cc +++ b/runtime/vm/os_thread_absl.cc @@ -100,7 +100,7 @@ static void UnblockSIGPROF() { sigset_t set; sigemptyset(&set); sigaddset(&set, SIGPROF); - int r = pthread_sigmask(SIG_UNBLOCK, &set, NULL); + int r = pthread_sigmask(SIG_UNBLOCK, &set, nullptr); USE(r); ASSERT(r == 0); ASSERT(!CHECK_IS_BLOCKING(SIGPROF)); @@ -154,7 +154,7 @@ static void* ThreadStart(void* data_ptr) { // Create new OSThread object and set as TLS for new thread. OSThread* thread = OSThread::CreateOSThread(); - if (thread != NULL) { + if (thread != nullptr) { OSThread::SetCurrent(thread); thread->SetName(name); UnblockSIGPROF(); @@ -162,7 +162,7 @@ static void* ThreadStart(void* data_ptr) { function(parameter); } - return NULL; + return nullptr; } int OSThread::Start(const char* name, @@ -246,7 +246,7 @@ char* OSThread::GetCurrentThreadName() { } ThreadJoinId OSThread::GetCurrentThreadJoinId(OSThread* thread) { - ASSERT(thread != NULL); + ASSERT(thread != nullptr); // Make sure we're filling in the join id for the current thread. ASSERT(thread->id() == GetCurrentThreadId()); // Make sure the join_id_ hasn't been set, yet. @@ -259,7 +259,7 @@ ThreadJoinId OSThread::GetCurrentThreadJoinId(OSThread* thread) { } void OSThread::Join(ThreadJoinId id) { - int result = pthread_join(id, NULL); + int result = pthread_join(id, nullptr); ASSERT(result == 0); } diff --git a/runtime/vm/os_thread_android.cc b/runtime/vm/os_thread_android.cc index 176c25f03b8..d4ad65acb45 100644 --- a/runtime/vm/os_thread_android.cc +++ b/runtime/vm/os_thread_android.cc @@ -75,7 +75,7 @@ static void ComputeTimeSpecMicros(struct timespec* ts, int64_t micros) { struct timeval tv; int64_t secs = micros / kMicrosecondsPerSecond; int64_t remaining_micros = (micros - (secs * kMicrosecondsPerSecond)); - int result = gettimeofday(&tv, NULL); + int result = gettimeofday(&tv, nullptr); ASSERT(result == 0); ts->tv_sec = tv.tv_sec + secs; ts->tv_nsec = (tv.tv_usec + remaining_micros) * kNanosecondsPerMicrosecond; @@ -113,7 +113,7 @@ static void UnblockSIGPROF() { sigset_t set; sigemptyset(&set); sigaddset(&set, SIGPROF); - int r = pthread_sigmask(SIG_UNBLOCK, &set, NULL); + int r = pthread_sigmask(SIG_UNBLOCK, &set, nullptr); USE(r); ASSERT(r == 0); ASSERT(!CHECK_IS_BLOCKING(SIGPROF)); @@ -146,7 +146,7 @@ static void* ThreadStart(void* data_ptr) { // Create new OSThread object and set as TLS for new thread. OSThread* thread = OSThread::CreateOSThread(); - if (thread != NULL) { + if (thread != nullptr) { OSThread::SetCurrent(thread); thread->SetName(name); UnblockSIGPROF(); @@ -154,7 +154,7 @@ static void* ThreadStart(void* data_ptr) { function(parameter); } - return NULL; + return nullptr; } int OSThread::Start(const char* name, @@ -226,7 +226,7 @@ char* OSThread::GetCurrentThreadName() { } ThreadJoinId OSThread::GetCurrentThreadJoinId(OSThread* thread) { - ASSERT(thread != NULL); + ASSERT(thread != nullptr); // Make sure we're filling in the join id for the current thread. ASSERT(thread->id() == GetCurrentThreadId()); // Make sure the join_id_ hasn't been set, yet. @@ -239,7 +239,7 @@ ThreadJoinId OSThread::GetCurrentThreadJoinId(OSThread* thread) { } void OSThread::Join(ThreadJoinId id) { - int result = pthread_join(id, NULL); + int result = pthread_join(id, nullptr); ASSERT(result == 0); } diff --git a/runtime/vm/os_thread_fuchsia.cc b/runtime/vm/os_thread_fuchsia.cc index 2cd616ca655..4546b88f7fd 100644 --- a/runtime/vm/os_thread_fuchsia.cc +++ b/runtime/vm/os_thread_fuchsia.cc @@ -104,14 +104,14 @@ static void* ThreadStart(void* data_ptr) { // Create new OSThread object and set as TLS for new thread. OSThread* thread = OSThread::CreateOSThread(); - if (thread != NULL) { + if (thread != nullptr) { OSThread::SetCurrent(thread); thread->SetName(name); // Call the supplied thread start function handing it its parameters. function(parameter); } - return NULL; + return nullptr; } int OSThread::Start(const char* name, @@ -183,7 +183,7 @@ char* OSThread::GetCurrentThreadName() { } ThreadJoinId OSThread::GetCurrentThreadJoinId(OSThread* thread) { - ASSERT(thread != NULL); + ASSERT(thread != nullptr); // Make sure we're filling in the join id for the current thread. ASSERT(thread->id() == GetCurrentThreadId()); // Make sure the join_id_ hasn't been set, yet. @@ -196,7 +196,7 @@ ThreadJoinId OSThread::GetCurrentThreadJoinId(OSThread* thread) { } void OSThread::Join(ThreadJoinId id) { - int result = pthread_join(id, NULL); + int result = pthread_join(id, nullptr); ASSERT(result == 0); } diff --git a/runtime/vm/os_thread_linux.cc b/runtime/vm/os_thread_linux.cc index 63d077e5c92..3543aaa1421 100644 --- a/runtime/vm/os_thread_linux.cc +++ b/runtime/vm/os_thread_linux.cc @@ -113,7 +113,7 @@ static void UnblockSIGPROF() { sigset_t set; sigemptyset(&set); sigaddset(&set, SIGPROF); - int r = pthread_sigmask(SIG_UNBLOCK, &set, NULL); + int r = pthread_sigmask(SIG_UNBLOCK, &set, nullptr); USE(r); ASSERT(r == 0); ASSERT(!CHECK_IS_BLOCKING(SIGPROF)); @@ -146,7 +146,7 @@ static void* ThreadStart(void* data_ptr) { // Create new OSThread object and set as TLS for new thread. OSThread* thread = OSThread::CreateOSThread(); - if (thread != NULL) { + if (thread != nullptr) { OSThread::SetCurrent(thread); thread->SetName(name); UnblockSIGPROF(); @@ -154,7 +154,7 @@ static void* ThreadStart(void* data_ptr) { function(parameter); } - return NULL; + return nullptr; } int OSThread::Start(const char* name, @@ -226,7 +226,7 @@ char* OSThread::GetCurrentThreadName() { } ThreadJoinId OSThread::GetCurrentThreadJoinId(OSThread* thread) { - ASSERT(thread != NULL); + ASSERT(thread != nullptr); // Make sure we're filling in the join id for the current thread. ASSERT(thread->id() == GetCurrentThreadId()); // Make sure the join_id_ hasn't been set, yet. @@ -239,7 +239,7 @@ ThreadJoinId OSThread::GetCurrentThreadJoinId(OSThread* thread) { } void OSThread::Join(ThreadJoinId id) { - int result = pthread_join(id, NULL); + int result = pthread_join(id, nullptr); ASSERT(result == 0); } diff --git a/runtime/vm/os_thread_macos.cc b/runtime/vm/os_thread_macos.cc index a62dab1c504..0d9c8de7b1a 100644 --- a/runtime/vm/os_thread_macos.cc +++ b/runtime/vm/os_thread_macos.cc @@ -129,14 +129,14 @@ static void* ThreadStart(void* data_ptr) { // Create new OSThread object and set as TLS for new thread. OSThread* thread = OSThread::CreateOSThread(); - if (thread != NULL) { + if (thread != nullptr) { OSThread::SetCurrent(thread); thread->SetName(name); // Call the supplied thread start function handing it its parameters. function(parameter); } - return NULL; + return nullptr; } int OSThread::Start(const char* name, @@ -161,9 +161,9 @@ int OSThread::Start(const char* name, return 0; } -const ThreadId OSThread::kInvalidThreadId = static_cast(NULL); +const ThreadId OSThread::kInvalidThreadId = static_cast(nullptr); const ThreadJoinId OSThread::kInvalidThreadJoinId = - static_cast(NULL); + static_cast(nullptr); ThreadLocalKey OSThread::CreateThreadLocal(ThreadDestructor destructor) { pthread_key_t key = kUnsetThreadLocalKey; @@ -208,7 +208,7 @@ char* OSThread::GetCurrentThreadName() { } ThreadJoinId OSThread::GetCurrentThreadJoinId(OSThread* thread) { - ASSERT(thread != NULL); + ASSERT(thread != nullptr); // Make sure we're filling in the join id for the current thread. ASSERT(thread->id() == GetCurrentThreadId()); // Make sure the join_id_ hasn't been set, yet. @@ -221,7 +221,7 @@ ThreadJoinId OSThread::GetCurrentThreadJoinId(OSThread* thread) { } void OSThread::Join(ThreadJoinId id) { - int result = pthread_join(id, NULL); + int result = pthread_join(id, nullptr); ASSERT(result == 0); } @@ -354,7 +354,7 @@ Monitor::Monitor() { result = pthread_mutexattr_destroy(&attr); VALIDATE_PTHREAD_RESULT(result); - result = pthread_cond_init(data_.cond(), NULL); + result = pthread_cond_init(data_.cond(), nullptr); VALIDATE_PTHREAD_RESULT(result); #if defined(DEBUG) diff --git a/runtime/vm/os_thread_win.cc b/runtime/vm/os_thread_win.cc index 4e3473ef4d4..b884c60d79f 100644 --- a/runtime/vm/os_thread_win.cc +++ b/runtime/vm/os_thread_win.cc @@ -68,7 +68,7 @@ static unsigned int __stdcall ThreadEntry(void* data_ptr) { // Create new OSThread object and set as TLS for new thread. OSThread* thread = OSThread::CreateOSThread(); - if (thread != NULL) { + if (thread != nullptr) { OSThread::SetCurrent(thread); thread->SetName(name); @@ -84,7 +84,7 @@ int OSThread::Start(const char* name, uword parameter) { ThreadStartData* start_data = new ThreadStartData(name, function, parameter); uint32_t tid; - uintptr_t thread = _beginthreadex(NULL, OSThread::GetMaxStackSize(), + uintptr_t thread = _beginthreadex(nullptr, OSThread::GetMaxStackSize(), ThreadEntry, start_data, 0, &tid); if (thread == -1L || thread == 0) { #ifdef DEBUG @@ -100,7 +100,7 @@ int OSThread::Start(const char* name, } const ThreadId OSThread::kInvalidThreadId = 0; -const ThreadJoinId OSThread::kInvalidThreadJoinId = NULL; +const ThreadJoinId OSThread::kInvalidThreadJoinId = nullptr; ThreadLocalKey OSThread::CreateThreadLocal(ThreadDestructor destructor) { ThreadLocalKey key = TlsAlloc(); @@ -142,14 +142,14 @@ char* OSThread::GetCurrentThreadName() { } ThreadJoinId OSThread::GetCurrentThreadJoinId(OSThread* thread) { - ASSERT(thread != NULL); + ASSERT(thread != nullptr); // Make sure we're filling in the join id for the current thread. ThreadId id = GetCurrentThreadId(); ASSERT(thread->id() == id); // Make sure the join_id_ hasn't been set, yet. DEBUG_ASSERT(thread->join_id_ == kInvalidThreadJoinId); HANDLE handle = OpenThread(SYNCHRONIZE, false, id); - ASSERT(handle != NULL); + ASSERT(handle != nullptr); #if defined(DEBUG) thread->join_id_ = handle; #endif @@ -158,7 +158,7 @@ ThreadJoinId OSThread::GetCurrentThreadJoinId(OSThread* thread) { void OSThread::Join(ThreadJoinId id) { HANDLE handle = static_cast(id); - ASSERT(handle != NULL); + ASSERT(handle != nullptr); DWORD res = WaitForSingleObject(handle, INFINITE); CloseHandle(handle); ASSERT(res == WAIT_OBJECT_0); @@ -386,8 +386,8 @@ void Monitor::NotifyAll() { void ThreadLocalData::AddThreadLocal(ThreadLocalKey key, ThreadDestructor destructor) { - ASSERT(thread_locals_ != NULL); - if (destructor == NULL) { + ASSERT(thread_locals_ != nullptr); + if (destructor == nullptr) { // We only care about thread locals with destructors. return; } @@ -404,7 +404,7 @@ void ThreadLocalData::AddThreadLocal(ThreadLocalKey key, } void ThreadLocalData::RemoveThreadLocal(ThreadLocalKey key) { - ASSERT(thread_locals_ != NULL); + ASSERT(thread_locals_ != nullptr); MutexLocker ml(mutex_); intptr_t i = 0; for (; i < thread_locals_->length(); i++) { @@ -426,10 +426,10 @@ void ThreadLocalData::RunDestructors() { // If an OS thread is created but ThreadLocalData::Init has not yet been // called, this method still runs. If this happens, there's nothing to clean // up here. See issue 33826. - if (thread_locals_ == NULL) { + if (thread_locals_ == nullptr) { return; } - ASSERT(mutex_ != NULL); + ASSERT(mutex_ != nullptr); MutexLocker ml(mutex_); for (intptr_t i = 0; i < thread_locals_->length(); i++) { const ThreadLocalEntry& entry = thread_locals_->At(i); @@ -440,8 +440,9 @@ void ThreadLocalData::RunDestructors() { } } -Mutex* ThreadLocalData::mutex_ = NULL; -MallocGrowableArray* ThreadLocalData::thread_locals_ = NULL; +Mutex* ThreadLocalData::mutex_ = nullptr; +MallocGrowableArray* ThreadLocalData::thread_locals_ = + nullptr; void ThreadLocalData::Init() { mutex_ = new Mutex(); @@ -449,13 +450,13 @@ void ThreadLocalData::Init() { } void ThreadLocalData::Cleanup() { - if (mutex_ != NULL) { + if (mutex_ != nullptr) { delete mutex_; - mutex_ = NULL; + mutex_ = nullptr; } - if (thread_locals_ != NULL) { + if (thread_locals_ != nullptr) { delete thread_locals_; - thread_locals_ = NULL; + thread_locals_ = nullptr; } } diff --git a/runtime/vm/os_win.cc b/runtime/vm/os_win.cc index 9756d91af5a..4de8c339113 100644 --- a/runtime/vm/os_win.cc +++ b/runtime/vm/os_win.cc @@ -73,10 +73,11 @@ const char* OS::GetTimeZoneName(int64_t seconds_since_epoch) { // Convert the wchar string to a null-terminated utf8 string. wchar_t* wchar_name = daylight_savings ? zone_information.DaylightName : zone_information.StandardName; - intptr_t utf8_len = - WideCharToMultiByte(CP_UTF8, 0, wchar_name, -1, NULL, 0, NULL, NULL); + intptr_t utf8_len = WideCharToMultiByte(CP_UTF8, 0, wchar_name, -1, nullptr, + 0, nullptr, nullptr); char* name = ThreadState::Current()->zone()->Alloc(utf8_len + 1); - WideCharToMultiByte(CP_UTF8, 0, wchar_name, -1, name, utf8_len, NULL, NULL); + WideCharToMultiByte(CP_UTF8, 0, wchar_name, -1, name, utf8_len, nullptr, + nullptr); name[utf8_len] = '\0'; return name; } @@ -246,7 +247,7 @@ char* OS::VSCreate(Zone* zone, const char* format, va_list args) { // Measure. va_list measure_args; va_copy(measure_args, args); - intptr_t len = Utils::VSNPrint(NULL, 0, format, measure_args); + intptr_t len = Utils::VSNPrint(nullptr, 0, format, measure_args); va_end(measure_args); char* buffer; @@ -255,7 +256,7 @@ char* OS::VSCreate(Zone* zone, const char* format, va_list args) { } else { buffer = reinterpret_cast(malloc(len + 1)); } - ASSERT(buffer != NULL); + ASSERT(buffer != nullptr); // Print. va_list print_args; @@ -266,7 +267,7 @@ char* OS::VSCreate(Zone* zone, const char* format, va_list args) { } bool OS::StringToInt64(const char* str, int64_t* value) { - ASSERT(str != NULL && strlen(str) > 0 && value != NULL); + ASSERT(str != nullptr && strlen(str) > 0 && value != nullptr); int32_t base = 10; char* endptr; int i = 0; diff --git a/runtime/vm/parser.cc b/runtime/vm/parser.cc index d507be9157d..f2ef5b9abb1 100644 --- a/runtime/vm/parser.cc +++ b/runtime/vm/parser.cc @@ -50,23 +50,23 @@ ParsedFunction::ParsedFunction(Thread* thread, const Function& function) : thread_(thread), function_(function), code_(Code::Handle(zone(), function.unoptimized_code())), - scope_(NULL), - regexp_compile_data_(NULL), - function_type_arguments_(NULL), - parent_type_arguments_(NULL), - current_context_var_(NULL), - arg_desc_var_(NULL), - expression_temp_var_(NULL), - entry_points_temp_var_(NULL), - finally_return_temp_var_(NULL), + scope_(nullptr), + regexp_compile_data_(nullptr), + function_type_arguments_(nullptr), + parent_type_arguments_(nullptr), + current_context_var_(nullptr), + arg_desc_var_(nullptr), + expression_temp_var_(nullptr), + entry_points_temp_var_(nullptr), + finally_return_temp_var_(nullptr), dynamic_closure_call_vars_(nullptr), guarded_fields_(), - default_parameter_values_(NULL), - raw_type_arguments_var_(NULL), + default_parameter_values_(nullptr), + raw_type_arguments_var_(nullptr), first_parameter_index_(), num_stack_locals_(0), have_seen_await_expr_(false), - kernel_scopes_(NULL) { + kernel_scopes_(nullptr) { DEBUG_ASSERT(function.IsNotTemporaryScopedHandle()); // Every function has a local variable for the current context. LocalVariable* temp = new (zone()) @@ -126,7 +126,7 @@ void ParsedFunction::Bailout(const char* origin, const char* reason) const { } kernel::ScopeBuildingResult* ParsedFunction::EnsureKernelScopes() { - if (kernel_scopes_ == NULL) { + if (kernel_scopes_ == nullptr) { kernel::ScopeBuilder builder(this); kernel_scopes_ = builder.BuildScopes(); } @@ -138,7 +138,7 @@ LocalVariable* ParsedFunction::EnsureExpressionTemp() { LocalVariable* temp = new (Z) LocalVariable(function_.token_pos(), function_.token_pos(), Symbols::ExprTemp(), Object::dynamic_type()); - ASSERT(temp != NULL); + ASSERT(temp != nullptr); set_expression_temp_var(temp); } ASSERT(has_expression_temp_var()); @@ -150,7 +150,7 @@ LocalVariable* ParsedFunction::EnsureEntryPointsTemp() { LocalVariable* temp = new (Z) LocalVariable(function_.token_pos(), function_.token_pos(), Symbols::EntryPointsTemp(), Object::dynamic_type()); - ASSERT(temp != NULL); + ASSERT(temp != nullptr); set_entry_points_temp_var(temp); } ASSERT(has_entry_points_temp_var()); @@ -162,7 +162,7 @@ void ParsedFunction::EnsureFinallyReturnTemp(bool is_async) { LocalVariable* temp = new (Z) LocalVariable(function_.token_pos(), function_.token_pos(), Symbols::FinallyRetVal(), Object::dynamic_type()); - ASSERT(temp != NULL); + ASSERT(temp != nullptr); temp->set_is_final(); if (is_async) { temp->set_is_captured(); @@ -174,8 +174,8 @@ void ParsedFunction::EnsureFinallyReturnTemp(bool is_async) { void ParsedFunction::SetRegExpCompileData( RegExpCompileData* regexp_compile_data) { - ASSERT(regexp_compile_data_ == NULL); - ASSERT(regexp_compile_data != NULL); + ASSERT(regexp_compile_data_ == nullptr); + ASSERT(regexp_compile_data != nullptr); regexp_compile_data_ = regexp_compile_data; } @@ -241,7 +241,7 @@ void ParsedFunction::AllocateVariables() { } raw_parameters_->Add(raw_parameter); } - if (function_type_arguments_ != NULL) { + if (function_type_arguments_ != nullptr) { LocalVariable* raw_type_args_parameter = function_type_arguments_; if (function_type_arguments_->is_captured()) { String& tmp = String::ZoneHandle(Z); @@ -286,8 +286,8 @@ void ParsedFunction::AllocateVariables() { // in the context(s). bool found_captured_variables = false; VariableIndex next_free_index = scope->AllocateVariables( - function(), first_parameter_index_, num_params, first_local_index, NULL, - &found_captured_variables); + function(), first_parameter_index_, num_params, first_local_index, + nullptr, &found_captured_variables); num_stack_locals_ = -next_free_index.value(); } diff --git a/runtime/vm/parser.h b/runtime/vm/parser.h index 66a4b39fc9d..a801ae60b20 100644 --- a/runtime/vm/parser.h +++ b/runtime/vm/parser.h @@ -89,14 +89,14 @@ class ParsedFunction : public ZoneAllocated { return function_type_arguments_; } void set_function_type_arguments(LocalVariable* function_type_arguments) { - ASSERT(function_type_arguments != NULL); + ASSERT(function_type_arguments != nullptr); function_type_arguments_ = function_type_arguments; } LocalVariable* parent_type_arguments() const { return parent_type_arguments_; } void set_parent_type_arguments(LocalVariable* parent_type_arguments) { - ASSERT(parent_type_arguments != NULL); + ASSERT(parent_type_arguments != nullptr); parent_type_arguments_ = parent_type_arguments; } @@ -109,7 +109,7 @@ class ParsedFunction : public ZoneAllocated { void set_default_parameter_values(ZoneGrowableArray* list) { default_parameter_values_ = list; #if defined(DEBUG) - if (list == NULL) return; + if (list == nullptr) return; for (intptr_t i = 0; i < list->length(); i++) { DEBUG_ASSERT(list->At(i)->IsNotTemporaryScopedHandle()); } @@ -117,7 +117,7 @@ class ParsedFunction : public ZoneAllocated { } const Instance& DefaultParameterValueAt(intptr_t i) const { - ASSERT(default_parameter_values_ != NULL); + ASSERT(default_parameter_values_ != nullptr); return *default_parameter_values_->At(i); } @@ -127,7 +127,7 @@ class ParsedFunction : public ZoneAllocated { LocalVariable* current_context_var() const { return current_context_var_; } - bool has_arg_desc_var() const { return arg_desc_var_ != NULL; } + bool has_arg_desc_var() const { return arg_desc_var_ != nullptr; } LocalVariable* arg_desc_var() const { return arg_desc_var_; } LocalVariable* receiver_var() const { @@ -149,7 +149,9 @@ class ParsedFunction : public ZoneAllocated { ASSERT(!has_expression_temp_var()); expression_temp_var_ = value; } - bool has_expression_temp_var() const { return expression_temp_var_ != NULL; } + bool has_expression_temp_var() const { + return expression_temp_var_ != nullptr; + } LocalVariable* entry_points_temp_var() const { ASSERT(has_entry_points_temp_var()); @@ -160,7 +162,7 @@ class ParsedFunction : public ZoneAllocated { entry_points_temp_var_ = value; } bool has_entry_points_temp_var() const { - return entry_points_temp_var_ != NULL; + return entry_points_temp_var_ != nullptr; } LocalVariable* finally_return_temp_var() const { @@ -172,7 +174,7 @@ class ParsedFunction : public ZoneAllocated { finally_return_temp_var_ = value; } bool has_finally_return_temp_var() const { - return finally_return_temp_var_ != NULL; + return finally_return_temp_var_ != nullptr; } void EnsureFinallyReturnTemp(bool is_async); diff --git a/runtime/vm/port.cc b/runtime/vm/port.cc index ee8b1297c16..880ba1291bb 100644 --- a/runtime/vm/port.cc +++ b/runtime/vm/port.cc @@ -17,10 +17,10 @@ namespace dart { -Mutex* PortMap::mutex_ = NULL; -PortSet* PortMap::ports_ = NULL; +Mutex* PortMap::mutex_ = nullptr; +PortSet* PortMap::ports_ = nullptr; MessageHandler* PortMap::deleted_entry_ = reinterpret_cast(1); -Random* PortMap::prng_ = NULL; +Random* PortMap::prng_ = nullptr; const char* PortMap::PortStateString(PortState kind) { switch (kind) { @@ -97,7 +97,7 @@ void PortMap::SetPortState(Dart_Port port, PortState state) { } Dart_Port PortMap::CreatePort(MessageHandler* handler) { - ASSERT(handler != NULL); + ASSERT(handler != nullptr); MutexLocker ml(mutex_); if (ports_ == nullptr) { return ILLEGAL_PORT; @@ -133,7 +133,7 @@ Dart_Port PortMap::CreatePort(MessageHandler* handler) { } bool PortMap::ClosePort(Dart_Port port) { - MessageHandler* handler = NULL; + MessageHandler* handler = nullptr; { MutexLocker ml(mutex_); if (ports_ == nullptr) { @@ -307,10 +307,10 @@ bool PortMap::IsReceiverInThisIsolateGroupOrClosed(Dart_Port receiver, } void PortMap::Init() { - if (mutex_ == NULL) { + if (mutex_ == nullptr) { mutex_ = new Mutex(); } - ASSERT(mutex_ != NULL); + ASSERT(mutex_ != nullptr); if (prng_ == nullptr) { prng_ = new Random(); } @@ -321,7 +321,7 @@ void PortMap::Init() { void PortMap::Cleanup() { ASSERT(ports_ != nullptr); - ASSERT(prng_ != NULL); + ASSERT(prng_ != nullptr); for (auto it = ports_->begin(); it != ports_->end(); ++it) { const auto& entry = *it; ASSERT(entry.handler != nullptr); @@ -336,7 +336,7 @@ void PortMap::Cleanup() { // Grab the mutex and delete the port set. MutexLocker ml(mutex_); delete prng_; - prng_ = NULL; + prng_ = nullptr; delete ports_; ports_ = nullptr; } diff --git a/runtime/vm/proccpuinfo.cc b/runtime/vm/proccpuinfo.cc index 066e3f7a5f6..a6c1c250d1b 100644 --- a/runtime/vm/proccpuinfo.cc +++ b/runtime/vm/proccpuinfo.cc @@ -14,7 +14,7 @@ namespace dart { -char* ProcCpuInfo::data_ = NULL; +char* ProcCpuInfo::data_ = nullptr; intptr_t ProcCpuInfo::datalen_ = 0; void ProcCpuInfo::Init() { @@ -23,7 +23,7 @@ void ProcCpuInfo::Init() { // when using fseek(0, SEEK_END) + ftell(). Nor can they be mmap()-ed. static const char PATHNAME[] = "/proc/cpuinfo"; FILE* fp = fopen(PATHNAME, "r"); - if (fp != NULL) { + if (fp != nullptr) { for (;;) { char buffer[256]; size_t n = fread(buffer, 1, sizeof(buffer), fp); @@ -38,7 +38,7 @@ void ProcCpuInfo::Init() { // Read the contents of the cpuinfo file. data_ = reinterpret_cast(malloc(datalen_ + 1)); fp = fopen(PATHNAME, "r"); - if (fp != NULL) { + if (fp != nullptr) { for (intptr_t offset = 0; offset < datalen_;) { size_t n = fread(data_ + offset, 1, datalen_ - offset, fp); if (n == 0) { @@ -56,7 +56,7 @@ void ProcCpuInfo::Init() { void ProcCpuInfo::Cleanup() { ASSERT(data_); free(data_); - data_ = NULL; + data_ = nullptr; } char* ProcCpuInfo::FieldStart(const char* field) { @@ -65,8 +65,8 @@ char* ProcCpuInfo::FieldStart(const char* field) { char* p = data_; for (;;) { p = strstr(p, field); - if (p == NULL) { - return NULL; + if (p == nullptr) { + return nullptr; } if (p == data_ || p[-1] == '\n') { break; @@ -76,8 +76,8 @@ char* ProcCpuInfo::FieldStart(const char* field) { // Skip to the first colon followed by a space. p = strchr(p + fieldlen, ':'); - if (p == NULL || (isspace(p[1]) == 0)) { - return NULL; + if (p == nullptr || (isspace(p[1]) == 0)) { + return nullptr; } p += 2; @@ -85,23 +85,23 @@ char* ProcCpuInfo::FieldStart(const char* field) { } bool ProcCpuInfo::FieldContains(const char* field, const char* search_string) { - ASSERT(data_ != NULL); - ASSERT(search_string != NULL); + ASSERT(data_ != nullptr); + ASSERT(search_string != nullptr); char* p = FieldStart(field); - if (p == NULL) { + if (p == nullptr) { return false; } // Find the end of the line. char* q = strchr(p, '\n'); - if (q == NULL) { + if (q == nullptr) { q = data_ + datalen_; } char saved_end = *q; *q = '\0'; - bool ret = (strcasestr(p, search_string) != NULL); + bool ret = (strcasestr(p, search_string) != nullptr); *q = saved_end; return ret; @@ -110,19 +110,19 @@ bool ProcCpuInfo::FieldContains(const char* field, const char* search_string) { // Extract the content of a the first occurrence of a given field in // the content of the cpuinfo file and return it as a heap-allocated // string that must be freed by the caller using free. -// Return NULL if not found. +// Return nullptr if not found. const char* ProcCpuInfo::ExtractField(const char* field) { - ASSERT(field != NULL); - ASSERT(data_ != NULL); + ASSERT(field != nullptr); + ASSERT(data_ != nullptr); char* p = FieldStart(field); - if (p == NULL) { - return NULL; + if (p == nullptr) { + return nullptr; } // Find the end of the line. char* q = strchr(p, '\n'); - if (q == NULL) { + if (q == nullptr) { q = data_ + datalen_; } @@ -139,9 +139,9 @@ const char* ProcCpuInfo::ExtractField(const char* field) { } bool ProcCpuInfo::HasField(const char* field) { - ASSERT(field != NULL); - ASSERT(data_ != NULL); - return (FieldStart(field) != NULL); + ASSERT(field != nullptr); + ASSERT(data_ != nullptr); + return (FieldStart(field) != nullptr); } } // namespace dart diff --git a/runtime/vm/profiler.cc b/runtime/vm/profiler.cc index 2749576f608..da542ed5aca 100644 --- a/runtime/vm/profiler.cc +++ b/runtime/vm/profiler.cc @@ -105,10 +105,10 @@ class ProfilerStackWalker : public ValueObject { frames_skipped_(0), frame_index_(0), total_frames_(0) { - if (sample_ == NULL) { - ASSERT(sample_buffer_ == NULL); + if (sample_ == nullptr) { + ASSERT(sample_buffer_ == nullptr); } else { - ASSERT(sample_buffer_ != NULL); + ASSERT(sample_buffer_ != nullptr); ASSERT(sample_->head_sample()); } } @@ -119,7 +119,7 @@ class ProfilerStackWalker : public ValueObject { return true; } - if (sample_ == NULL) { + if (sample_ == nullptr) { DumpStackFrame(frame_index_, pc, fp); frame_index_++; total_frames_++; @@ -129,10 +129,10 @@ class ProfilerStackWalker : public ValueObject { sample_->set_truncated_trace(true); return false; } - ASSERT(sample_ != NULL); + ASSERT(sample_ != nullptr); if (frame_index_ == Sample::kPCArraySizeInWords) { Sample* new_sample = sample_buffer_->ReserveSampleAndLink(sample_); - if (new_sample == NULL) { + if (new_sample == nullptr) { // Could not reserve new sample- mark this as truncated. sample_->set_truncated_trace(true); return false; @@ -232,7 +232,7 @@ class ProfilerNativeStackWalker : public ProfilerStackWalker { previous_fp = fp; fp = CallerFP(fp); - if (fp == NULL) { + if (fp == nullptr) { return; } @@ -277,7 +277,7 @@ class ProfilerNativeStackWalker : public ProfilerStackWalker { private: uword* CallerPC(uword* fp) const { - ASSERT(fp != NULL); + ASSERT(fp != nullptr); uword* caller_pc_ptr = fp + kHostSavedCallerPcSlotFromFp; // This may actually be uninitialized, by design (see class comment above). MSAN_UNPOISON(caller_pc_ptr, kWordSize); @@ -286,7 +286,7 @@ class ProfilerNativeStackWalker : public ProfilerStackWalker { } uword* CallerFP(uword* fp) const { - ASSERT(fp != NULL); + ASSERT(fp != nullptr); uword* caller_fp_ptr = fp + kHostSavedCallerFpSlotFromFp; // This may actually be uninitialized, by design (see class comment above). MSAN_UNPOISON(caller_fp_ptr, kWordSize); @@ -295,7 +295,7 @@ class ProfilerNativeStackWalker : public ProfilerStackWalker { } bool ValidFramePointer(uword* fp) const { - if (fp == NULL) { + if (fp == nullptr) { return false; } uword cursor = reinterpret_cast(fp); @@ -342,16 +342,16 @@ static bool GetAndValidateThreadStackBounds(OSThread* os_thread, uintptr_t sp, uword* stack_lower, uword* stack_upper) { - ASSERT(os_thread != NULL); - ASSERT(stack_lower != NULL); - ASSERT(stack_upper != NULL); + ASSERT(os_thread != nullptr); + ASSERT(stack_lower != nullptr); + ASSERT(stack_upper != nullptr); #if defined(USING_SIMULATOR) const bool use_simulator_stack_bounds = - thread != NULL && thread->IsExecutingDartCode(); + thread != nullptr && thread->IsExecutingDartCode(); if (use_simulator_stack_bounds) { Isolate* isolate = thread->isolate(); - ASSERT(isolate != NULL); + ASSERT(isolate != nullptr); Simulator* simulator = isolate->simulator(); *stack_lower = simulator->stack_limit(); *stack_upper = simulator->stack_base(); @@ -378,7 +378,7 @@ static bool GetAndValidateThreadStackBounds(OSThread* os_thread, } void Profiler::DumpStackTrace(void* context) { - if (context == NULL) { + if (context == nullptr) { DumpStackTrace(/*for_crash=*/true); return; } @@ -450,7 +450,7 @@ void Profiler::DumpStackTrace(uword sp, uword fp, uword pc, bool for_crash) { auto os_thread = OSThread::Current(); ASSERT(os_thread != nullptr); - auto thread = Thread::Current(); // NULL if no current isolate. + auto thread = Thread::Current(); // nullptr if no current isolate. auto isolate = thread == nullptr ? nullptr : thread->isolate(); auto isolate_group = thread == nullptr ? nullptr : thread->isolate_group(); auto source = isolate_group == nullptr ? nullptr : isolate_group->source(); @@ -504,9 +504,9 @@ void Profiler::DumpStackTrace(uword sp, uword fp, uword pc, bool for_crash) { return; } - ProfilerNativeStackWalker native_stack_walker(&counters_, ILLEGAL_PORT, NULL, - NULL, stack_lower, stack_upper, - pc, fp, sp, + ProfilerNativeStackWalker native_stack_walker(&counters_, ILLEGAL_PORT, + nullptr, nullptr, stack_lower, + stack_upper, pc, fp, sp, /*skip_count=*/0); native_stack_walker.walk(); OS::PrintErr("-- End of DumpStackTrace\n"); @@ -641,7 +641,7 @@ SampleBlockBuffer::SampleBlockBuffer(intptr_t blocks, const bool compressed = false; memory_ = VirtualMemory::Allocate(size, executable, compressed, "dart-profiler"); - if (memory_ == NULL) { + if (memory_ == nullptr) { OUT_OF_MEMORY(); } sample_buffer_ = reinterpret_cast(memory_->address()); @@ -872,7 +872,7 @@ class ReturnAddressLocator : public ValueObject { #if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64) bool ReturnAddressLocator::LocateReturnAddress(uword* return_address) { - ASSERT(return_address != NULL); + ASSERT(return_address != nullptr); const intptr_t offset = RelativePC(); ASSERT(offset >= 0); const intptr_t size = code_.Size(); @@ -922,7 +922,7 @@ bool ReturnAddressLocator::LocateReturnAddress(uword* return_address) { #elif defined(TARGET_ARCH_ARM) || defined(TARGET_ARCH_ARM64) || \ defined(TARGET_ARCH_RISCV32) || defined(TARGET_ARCH_RISCV64) bool ReturnAddressLocator::LocateReturnAddress(uword* return_address) { - ASSERT(return_address != NULL); + ASSERT(return_address != nullptr); return false; } #else @@ -966,7 +966,7 @@ class ProfilerDartStackWalker : public ProfilerStackWalker { uword lr, bool allocation_sample, intptr_t skip_count = 0) - : ProfilerStackWalker((thread->isolate() != NULL) + : ProfilerStackWalker((thread->isolate() != nullptr) ? thread->isolate()->main_port() : ILLEGAL_PORT, sample, @@ -1055,7 +1055,7 @@ class ProfilerDartStackWalker : public ProfilerStackWalker { private: uword* CallerPC() const { - ASSERT(fp_ != NULL); + ASSERT(fp_ != nullptr); uword* caller_pc_ptr = fp_ + kSavedCallerPcSlotFromFp; // MSan/ASan are unaware of frames initialized by generated code. MSAN_UNPOISON(caller_pc_ptr, kWordSize); @@ -1064,7 +1064,7 @@ class ProfilerDartStackWalker : public ProfilerStackWalker { } uword* CallerFP() const { - ASSERT(fp_ != NULL); + ASSERT(fp_ != nullptr); uword* caller_fp_ptr = fp_ + kSavedCallerFpSlotFromFp; // MSan/ASan are unaware of frames initialized by generated code. MSAN_UNPOISON(caller_fp_ptr, kWordSize); @@ -1073,7 +1073,7 @@ class ProfilerDartStackWalker : public ProfilerStackWalker { } uword* ExitLink() const { - ASSERT(fp_ != NULL); + ASSERT(fp_ != nullptr); uword* exit_link_ptr = fp_ + kExitLinkSlotFromEntryFp; // MSan/ASan are unaware of frames initialized by generated code. MSAN_UNPOISON(exit_link_ptr, kWordSize); @@ -1082,7 +1082,7 @@ class ProfilerDartStackWalker : public ProfilerStackWalker { } uword Stack(intptr_t index) const { - ASSERT(sp_ != NULL); + ASSERT(sp_ != nullptr); uword* stack_ptr = sp_ + index; // MSan/ASan are unaware of frames initialized by generated code. MSAN_UNPOISON(stack_ptr, kWordSize); @@ -1098,10 +1098,10 @@ class ProfilerDartStackWalker : public ProfilerStackWalker { }; static void CopyStackBuffer(Sample* sample, uword sp_addr) { - ASSERT(sample != NULL); + ASSERT(sample != nullptr); uword* sp = reinterpret_cast(sp_addr); uword* buffer = sample->GetStackBuffer(); - if (sp != NULL) { + if (sp != nullptr) { for (intptr_t i = 0; i < Sample::kStackBufferSizeInWords; i++) { MSAN_UNPOISON(sp, kWordSize); ASAN_UNPOISON(sp, kWordSize); @@ -1139,7 +1139,7 @@ static void CollectSample(Isolate* isolate, uword fp, uword sp, ProfilerCounters* counters) { - ASSERT(counters != NULL); + ASSERT(counters != nullptr); #if defined(DART_HOST_OS_WINDOWS) // Use structured exception handling to trap guard page access on Windows. __try { @@ -1192,7 +1192,7 @@ static void CollectSample(Isolate* isolate, static Sample* SetupSample(Thread* thread, bool allocation_sample, ThreadId tid) { - ASSERT(thread != NULL); + ASSERT(thread != nullptr); Isolate* isolate = thread->isolate(); SampleBlockBuffer* buffer = Profiler::sample_block_buffer(); Sample* sample = allocation_sample ? buffer->ReserveAllocationSample(isolate) @@ -1218,7 +1218,7 @@ static Sample* SetupSample(Thread* thread, } static bool CheckIsolate(Isolate* isolate) { - if ((isolate == NULL) || (Dart::vm_isolate() == NULL)) { + if ((isolate == nullptr) || (Dart::vm_isolate() == nullptr)) { // No isolate. return false; } @@ -1228,9 +1228,9 @@ static bool CheckIsolate(Isolate* isolate) { void Profiler::SampleAllocation(Thread* thread, intptr_t cid, uint32_t identity_hash) { - ASSERT(thread != NULL); + ASSERT(thread != nullptr); OSThread* os_thread = thread->os_thread(); - ASSERT(os_thread != NULL); + ASSERT(os_thread != nullptr); Isolate* isolate = thread->isolate(); if (!CheckIsolate(isolate)) { return; @@ -1271,7 +1271,7 @@ void Profiler::SampleAllocation(Thread* thread, if (FLAG_profile_vm_allocation) { ProfilerNativeStackWalker native_stack_walker( - &counters_, (isolate != NULL) ? isolate->main_port() : ILLEGAL_PORT, + &counters_, (isolate != nullptr) ? isolate->main_port() : ILLEGAL_PORT, sample, isolate->current_allocation_sample_block(), stack_lower, stack_upper, pc, fp, sp); native_stack_walker.walk(); @@ -1290,16 +1290,16 @@ void Profiler::SampleAllocation(Thread* thread, void Profiler::SampleThreadSingleFrame(Thread* thread, Sample* sample, uintptr_t pc) { - ASSERT(thread != NULL); + ASSERT(thread != nullptr); OSThread* os_thread = thread->os_thread(); - ASSERT(os_thread != NULL); + ASSERT(os_thread != nullptr); Isolate* isolate = thread->isolate(); ASSERT(Profiler::sample_block_buffer() != nullptr); // Increment counter for vm tag. VMTagCounters* counters = isolate->vm_tag_counters(); - ASSERT(counters != NULL); + ASSERT(counters != nullptr); if (thread->IsMutatorThread()) { counters->Increment(sample->vm_tag()); } @@ -1310,9 +1310,9 @@ void Profiler::SampleThreadSingleFrame(Thread* thread, void Profiler::SampleThread(Thread* thread, const InterruptedThreadState& state) { - ASSERT(thread != NULL); + ASSERT(thread != nullptr); OSThread* os_thread = thread->os_thread(); - ASSERT(os_thread != NULL); + ASSERT(os_thread != nullptr); Isolate* isolate = thread->isolate(); // Thread is not doing VM work. @@ -1336,7 +1336,7 @@ void Profiler::SampleThread(Thread* thread, uintptr_t pc = state.pc; uintptr_t lr = state.lr; #if defined(USING_SIMULATOR) - Simulator* simulator = NULL; + Simulator* simulator = nullptr; #endif if (in_dart_code) { @@ -1398,13 +1398,13 @@ void Profiler::SampleThread(Thread* thread, // Increment counter for vm tag. VMTagCounters* counters = isolate->vm_tag_counters(); - ASSERT(counters != NULL); + ASSERT(counters != nullptr); if (thread->IsMutatorThread()) { counters->Increment(sample->vm_tag()); } ProfilerNativeStackWalker native_stack_walker( - &counters_, (isolate != NULL) ? isolate->main_port() : ILLEGAL_PORT, + &counters_, (isolate != nullptr) ? isolate->main_port() : ILLEGAL_PORT, sample, isolate->current_sample_block(), stack_lower, stack_upper, pc, fp, sp); const bool exited_dart_code = thread->HasExitedDartCode(); @@ -1439,7 +1439,7 @@ CodeLookupTable::CodeLookupTable(Thread* thread) { class CodeLookupTableBuilder : public ObjectVisitor { public: explicit CodeLookupTableBuilder(CodeLookupTable* table) : table_(table) { - ASSERT(table_ != NULL); + ASSERT(table_ != nullptr); } ~CodeLookupTableBuilder() {} @@ -1455,11 +1455,11 @@ class CodeLookupTableBuilder : public ObjectVisitor { }; void CodeLookupTable::Build(Thread* thread) { - ASSERT(thread != NULL); + ASSERT(thread != nullptr); Isolate* isolate = thread->isolate(); - ASSERT(isolate != NULL); + ASSERT(isolate != nullptr); Isolate* vm_isolate = Dart::vm_isolate(); - ASSERT(vm_isolate != NULL); + ASSERT(vm_isolate != nullptr); // Clear. code_objects_.Clear(); @@ -1483,8 +1483,8 @@ void CodeLookupTable::Build(Thread* thread) { if (length() <= 1) { return; } - ASSERT(FindCode(0) == NULL); - ASSERT(FindCode(~0) == NULL); + ASSERT(FindCode(0) == nullptr); + ASSERT(FindCode(~0) == nullptr); // Sanity check that we don't have duplicate entries and that the entries // are sorted. for (intptr_t i = 0; i < length() - 1; i++) { @@ -1524,7 +1524,7 @@ const CodeDescriptor* CodeLookupTable::FindCode(uword pc) const { // First points to the first code object whose entry is greater than PC. // That means the code object we need to check is first - 1. if (first == 0) { - return NULL; + return nullptr; } first--; ASSERT(first >= 0); @@ -1533,7 +1533,7 @@ const CodeDescriptor* CodeLookupTable::FindCode(uword pc) const { if (cd->Contains(pc)) { return cd; } - return NULL; + return nullptr; } ProcessedSampleBuffer* SampleBuffer::BuildProcessedSampleBuffer( @@ -1614,7 +1614,7 @@ ProcessedSample* SampleBuffer::BuildProcessedSample( // Copy stack trace from sample(s). bool truncated = false; Sample* current = sample; - while (current != NULL) { + while (current != nullptr) { for (intptr_t i = 0; i < Sample::kPCArraySizeInWords; i++) { if (current->At(i) == 0) { break; @@ -1636,19 +1636,19 @@ ProcessedSample* SampleBuffer::BuildProcessedSample( } Sample* SampleBuffer::Next(Sample* sample) { - if (!sample->is_continuation_sample()) return NULL; + if (!sample->is_continuation_sample()) return nullptr; Sample* next_sample = sample->continuation_sample(); // Sanity check. ASSERT(sample != next_sample); // Detect invalid chaining. if (sample->port() != next_sample->port()) { - return NULL; + return nullptr; } if (sample->timestamp() != next_sample->timestamp()) { - return NULL; + return nullptr; } if (sample->tid() != next_sample->tid()) { - return NULL; + return nullptr; } return next_sample; } @@ -1666,7 +1666,7 @@ void ProcessedSample::FixupCaller(const CodeLookupTable& clt, uword pc_marker, uword* stack_buffer) { const CodeDescriptor* cd = clt.FindCode(At(0)); - if (cd == NULL) { + if (cd == nullptr) { // No Dart code. return; } @@ -1681,7 +1681,7 @@ void ProcessedSample::CheckForMissingDartFrame(const CodeLookupTable& clt, const CodeDescriptor* cd, uword pc_marker, uword* stack_buffer) { - ASSERT(cd != NULL); + ASSERT(cd != nullptr); const Code& code = Code::Handle(Code::RawCast(cd->code().ptr())); ASSERT(!code.IsNull()); // Some stubs (and intrinsics) do not push a frame onto the stack leaving @@ -1721,7 +1721,7 @@ void ProcessedSample::CheckForMissingDartFrame(const CodeLookupTable& clt, } } - if (clt.FindCode(return_address) == NULL) { + if (clt.FindCode(return_address) == nullptr) { // Return address is not from a Dart code object. Do not insert. return; } @@ -1733,7 +1733,7 @@ void ProcessedSample::CheckForMissingDartFrame(const CodeLookupTable& clt, ProcessedSampleBuffer::ProcessedSampleBuffer() : code_lookup_table_(new CodeLookupTable(Thread::Current())) { - ASSERT(code_lookup_table_ != NULL); + ASSERT(code_lookup_table_ != nullptr); } void SampleBlockProcessor::Init() { @@ -1832,7 +1832,7 @@ void SampleBlockProcessor::ThreadMain(uword parameters) { // Signal to main thread we are ready. MonitorLocker startup_ml(monitor_); OSThread* os_thread = OSThread::Current(); - ASSERT(os_thread != NULL); + ASSERT(os_thread != nullptr); processor_thread_id_ = OSThread::GetCurrentThreadJoinId(os_thread); thread_running_ = true; startup_ml.Notify(); diff --git a/runtime/vm/profiler.h b/runtime/vm/profiler.h index 71d8a846816..c00d381cf01 100644 --- a/runtime/vm/profiler.h +++ b/runtime/vm/profiler.h @@ -253,7 +253,7 @@ class Sample { uword pc = At(i); char* native_symbol_name = NativeSymbolResolver::LookupSymbolName(pc, &start); - if (native_symbol_name == NULL) { + if (native_symbol_name == nullptr) { OS::PrintErr(" [0x%" Pp "] Unknown symbol\n", pc); } else { OS::PrintErr(" [0x%" Pp "] %s\n", pc, native_symbol_name); @@ -522,8 +522,8 @@ class CodeDescriptor : public ZoneAllocated { } static int Compare(CodeDescriptor* const* a, CodeDescriptor* const* b) { - ASSERT(a != NULL); - ASSERT(b != NULL); + ASSERT(a != nullptr); + ASSERT(b != nullptr); uword a_start = (*a)->Start(); uword b_start = (*b)->Start(); @@ -591,7 +591,7 @@ class SampleBuffer : public ProcessedSampleBufferBuilder { } void VisitSamples(SampleVisitor* visitor) { - ASSERT(visitor != NULL); + ASSERT(visitor != nullptr); const intptr_t length = capacity(); for (intptr_t i = 0; i < length; i++) { Sample* sample = At(i); @@ -756,7 +756,7 @@ class SampleBlockBuffer : public ProcessedSampleBufferBuilder { virtual ~SampleBlockBuffer(); void VisitSamples(SampleVisitor* visitor) { - ASSERT(visitor != NULL); + ASSERT(visitor != nullptr); for (intptr_t i = 0; i < capacity_; ++i) { blocks_[i].VisitSamples(visitor); } diff --git a/runtime/vm/profiler_service.cc b/runtime/vm/profiler_service.cc index 52e7c8c3d0d..3ae07440467 100644 --- a/runtime/vm/profiler_service.cc +++ b/runtime/vm/profiler_service.cc @@ -58,7 +58,7 @@ ProfileFunction::ProfileFunction(Kind kind, } const char* ProfileFunction::Name() const { - if (name_ != NULL) { + if (name_ != nullptr) { return name_; } ASSERT(!function_.IsNull()); @@ -69,15 +69,15 @@ const char* ProfileFunction::Name() const { const char* ProfileFunction::ResolvedScriptUrl() const { if (function_.IsNull()) { - return NULL; + return nullptr; } const Script& script = Script::Handle(function_.script()); if (script.IsNull()) { - return NULL; + return nullptr; } const String& uri = String::Handle(script.resolved_url()); if (uri.IsNull()) { - return NULL; + return nullptr; } return uri.ToCString(); } @@ -214,7 +214,7 @@ void ProfileFunction::AddProfileCode(intptr_t code_table_index) { } bool ProfileFunction::GetSinglePosition(ProfileFunctionSourcePosition* pfsp) { - if (pfsp == NULL) { + if (pfsp == nullptr) { return false; } if (source_position_ticks_.length() != 1) { @@ -247,9 +247,9 @@ ProfileCode::ProfileCode(Kind kind, inclusive_ticks_(0), inclusive_serial_(-1), code_(code), - name_(NULL), + name_(nullptr), compile_timestamp_(0), - function_(NULL), + function_(nullptr), code_table_index_(-1), address_ticks_(0) { ASSERT(start_ < end_); @@ -284,7 +284,7 @@ void ProfileCode::ExpandUpper(uword end) { } bool ProfileCode::Overlaps(const ProfileCode* other) const { - ASSERT(other != NULL); + ASSERT(other != nullptr); return other->Contains(start_) || other->Contains(end_ - 1) || Contains(other->start()) || Contains(other->end() - 1); } @@ -294,8 +294,8 @@ bool ProfileCode::IsOptimizedDart() const { } void ProfileCode::SetName(const char* name) { - if (name == NULL) { - name_ = NULL; + if (name == nullptr) { + name_ = nullptr; } intptr_t len = strlen(name) + 1; name_ = Thread::Current()->zone()->Alloc(len); @@ -368,7 +368,7 @@ void ProfileCode::PrintNativeCode(JSONObject* profile_code_obj) { { // Generate a fake function entry. JSONObject func(&obj, "function"); - ASSERT(function_ != NULL); + ASSERT(function_ != nullptr); function_->PrintToJSONObject(&func); } } @@ -385,7 +385,7 @@ void ProfileCode::PrintCollectedCode(JSONObject* profile_code_obj) { { // Generate a fake function entry. JSONObject func(&obj, "function"); - ASSERT(function_ != NULL); + ASSERT(function_ != nullptr); function_->PrintToJSONObject(&func); } } @@ -402,7 +402,7 @@ void ProfileCode::PrintOverwrittenCode(JSONObject* profile_code_obj) { { // Generate a fake function entry. JSONObject func(&obj, "function"); - ASSERT(function_ != NULL); + ASSERT(function_ != nullptr); function_->PrintToJSONObject(&func); } } @@ -419,7 +419,7 @@ void ProfileCode::PrintTagCode(JSONObject* profile_code_obj) { { // Generate a fake function entry. JSONObject func(&obj, "function"); - ASSERT(function_ != NULL); + ASSERT(function_ != nullptr); function_->PrintToJSONObject(&func); } } @@ -438,7 +438,7 @@ const char* ProfileCode::KindToCString(Kind kind) { return "Tag"; } UNREACHABLE(); - return NULL; + return nullptr; } void ProfileCode::PrintToJSONArray(JSONArray* codes) { @@ -474,7 +474,7 @@ class ProfileFunctionTable : public ZoneAllocated { public: ProfileFunctionTable() : null_function_(Function::ZoneHandle()), - unknown_function_(NULL), + unknown_function_(nullptr), table_(8) { unknown_function_ = Add(ProfileFunction::kUnknownFunction, ""); @@ -483,7 +483,7 @@ class ProfileFunctionTable : public ZoneAllocated { ProfileFunction* LookupOrAdd(const Function& function) { ASSERT(!function.IsNull()); ProfileFunction* profile_function = Lookup(function); - if (profile_function != NULL) { + if (profile_function != nullptr) { return profile_function; } return Add(function); @@ -495,7 +495,7 @@ class ProfileFunctionTable : public ZoneAllocated { } ProfileFunction* GetUnknown() { - ASSERT(unknown_function_ != NULL); + ASSERT(unknown_function_ != nullptr); return unknown_function_; } @@ -528,7 +528,7 @@ class ProfileFunctionTable : public ZoneAllocated { private: ProfileFunction* Add(ProfileFunction::Kind kind, const char* name) { ASSERT(kind != ProfileFunction::kDartFunction); - ASSERT(name != NULL); + ASSERT(name != nullptr); ProfileFunction* profile_function = new ProfileFunction(kind, name, null_function_, table_.length()); table_.Add(profile_function); @@ -536,9 +536,9 @@ class ProfileFunctionTable : public ZoneAllocated { } ProfileFunction* Add(const Function& function) { - ASSERT(Lookup(function) == NULL); + ASSERT(Lookup(function) == nullptr); ProfileFunction* profile_function = new ProfileFunction( - ProfileFunction::kDartFunction, NULL, function, table_.length()); + ProfileFunction::kDartFunction, nullptr, function, table_.length()); table_.Add(profile_function); function_hash_.Insert(profile_function); return profile_function; @@ -568,11 +568,11 @@ class ProfileFunctionTable : public ZoneAllocated { }; ProfileFunction* ProfileCode::SetFunctionAndName(ProfileFunctionTable* table) { - ASSERT(function_ == NULL); + ASSERT(function_ == nullptr); - ProfileFunction* function = NULL; + ProfileFunction* function = nullptr; if ((kind() == kReusedCode) || (kind() == kCollectedCode)) { - if (name() == NULL) { + if (name() == nullptr) { // Lazily set generated name. GenerateAndSetSymbolName("[Collected]"); } @@ -590,7 +590,7 @@ ProfileFunction* ProfileCode::SetFunctionAndName(ProfileFunctionTable* table) { } SetName(name); } else if (kind() == kNativeCode) { - if (name() == NULL) { + if (name() == nullptr) { // Lazily set generated name. const intptr_t kBuffSize = 512; char buff[kBuffSize]; @@ -609,15 +609,15 @@ ProfileFunction* ProfileCode::SetFunctionAndName(ProfileFunctionTable* table) { } function = table->AddNative(start(), name()); } else if (kind() == kTagCode) { - if (name() == NULL) { + if (name() == nullptr) { if (UserTags::IsUserTag(start())) { const char* tag_name = UserTags::TagName(start()); - ASSERT(tag_name != NULL); + ASSERT(tag_name != nullptr); SetName(tag_name); } else if (VMTag::IsVMTag(start()) || VMTag::IsRuntimeEntryTag(start()) || VMTag::IsNativeEntryTag(start())) { const char* tag_name = VMTag::TagName(start()); - ASSERT(tag_name != NULL); + ASSERT(tag_name != nullptr); SetName(tag_name); } else { switch (start()) { @@ -655,7 +655,7 @@ ProfileFunction* ProfileCode::SetFunctionAndName(ProfileFunctionTable* table) { } else { UNREACHABLE(); } - ASSERT(function != NULL); + ASSERT(function != nullptr); function->AddProfileCode(code_table_index()); @@ -696,11 +696,11 @@ intptr_t ProfileCodeTable::InsertCode(ProfileCode* new_code) { // Determine the correct place to insert or merge |new_code| into table. intptr_t lo = -1; intptr_t hi = -1; - ProfileCode* lo_code = NULL; - ProfileCode* hi_code = NULL; + ProfileCode* lo_code = nullptr; + ProfileCode* hi_code = nullptr; const uword pc = new_code->end() - 1; FindNeighbors(pc, &lo, &hi, &lo_code, &hi_code); - ASSERT((lo_code != NULL) || (hi_code != NULL)); + ASSERT((lo_code != nullptr) || (hi_code != nullptr)); if (lo != -1) { // Has left neighbor. @@ -757,7 +757,7 @@ void ProfileCodeTable::FindNeighbors(uword pc, if (pc < At(0)->start()) { // Lower than any existing code. *lo = -1; - *lo_code = NULL; + *lo_code = nullptr; *hi = 0; *hi_code = At(*hi); return; @@ -768,7 +768,7 @@ void ProfileCodeTable::FindNeighbors(uword pc, *lo = length - 1; *lo_code = At(*lo); *hi = -1; - *hi_code = NULL; + *hi_code = nullptr; return; } @@ -849,8 +849,8 @@ bool ProfileCodeInlinedFunctionsCache::FindInCache( if ((cache_[index].pc == pc) && (cache_[index].offset == offset)) { // Hit. if (cache_[index].inlined_functions.length() == 0) { - *inlined_functions = NULL; - *inlined_token_positions = NULL; + *inlined_functions = nullptr; + *inlined_token_positions = nullptr; } else { *inlined_functions = &cache_[index].inlined_functions; *inlined_token_positions = &cache_[index].inlined_token_positions; @@ -884,8 +884,8 @@ void ProfileCodeInlinedFunctionsCache::Add( offset, &(cache_entry->inlined_functions), &(cache_entry->inlined_token_positions)); if (cache_entry->inlined_functions.length() == 0) { - *inlined_functions = NULL; - *inlined_token_positions = NULL; + *inlined_functions = nullptr; + *inlined_token_positions = nullptr; *token_position = cache_entry->token_position = TokenPosition::kNoSource; return; } @@ -944,9 +944,9 @@ class ProfileBuilder : public ValueObject { null_function_(Function::ZoneHandle()), inclusive_tree_(false), inlined_functions_cache_(new ProfileCodeInlinedFunctionsCache()), - samples_(NULL), + samples_(nullptr), info_kind_(kNone) { - ASSERT(profile_ != NULL); + ASSERT(profile_ != nullptr); } void Build() { @@ -1014,14 +1014,14 @@ class ProfileBuilder : public ValueObject { ScopeTimer sw("ProfileBuilder::BuildCodeTable", FLAG_trace_profiler); Isolate* isolate = thread_->isolate(); - ASSERT(isolate != NULL); + ASSERT(isolate != nullptr); // Build the live code table eagerly by populating it with code objects // from the processed sample buffer. const CodeLookupTable& code_lookup_table = samples_->code_lookup_table(); for (intptr_t i = 0; i < code_lookup_table.length(); i++) { const CodeDescriptor* descriptor = code_lookup_table.At(i); - ASSERT(descriptor != NULL); + ASSERT(descriptor != nullptr); const AbstractCode code = descriptor->code(); RegisterLiveProfileCode(new ProfileCode( ProfileCode::kDartCode, code.PayloadStart(), @@ -1056,7 +1056,7 @@ class ProfileBuilder : public ValueObject { const uword pc = sample->At(frame_index); ASSERT(pc != 0); ProfileCode* code = FindOrRegisterProfileCode(pc, timestamp); - ASSERT(code != NULL); + ASSERT(code != nullptr); code->Tick(pc, IsExecutingFrame(sample, frame_index), sample_index); } @@ -1080,21 +1080,21 @@ class ProfileBuilder : public ValueObject { for (intptr_t i = 0; i < live_table->length(); i++) { const intptr_t index = i; ProfileCode* code = live_table->At(i); - ASSERT(code != NULL); + ASSERT(code != nullptr); code->set_code_table_index(index); } for (intptr_t i = 0; i < dead_table->length(); i++) { const intptr_t index = dead_code_index_offset + i; ProfileCode* code = dead_table->At(i); - ASSERT(code != NULL); + ASSERT(code != nullptr); code->set_code_table_index(index); } for (intptr_t i = 0; i < tag_table->length(); i++) { const intptr_t index = tag_code_index_offset + i; ProfileCode* code = tag_table->At(i); - ASSERT(code != NULL); + ASSERT(code != nullptr); code->set_code_table_index(index); } } @@ -1107,21 +1107,21 @@ class ProfileBuilder : public ValueObject { ProfileFunctionTable* function_table = profile_->functions_; for (intptr_t i = 0; i < live_table->length(); i++) { ProfileCode* code = live_table->At(i); - ASSERT(code != NULL); + ASSERT(code != nullptr); code->SetFunctionAndName(function_table); thread_->CheckForSafepoint(); } for (intptr_t i = 0; i < dead_table->length(); i++) { ProfileCode* code = dead_table->At(i); - ASSERT(code != NULL); + ASSERT(code != nullptr); code->SetFunctionAndName(function_table); thread_->CheckForSafepoint(); } for (intptr_t i = 0; i < tag_table->length(); i++) { ProfileCode* code = tag_table->At(i); - ASSERT(code != NULL); + ASSERT(code != nullptr); code->SetFunctionAndName(function_table); thread_->CheckForSafepoint(); } @@ -1151,12 +1151,12 @@ class ProfileBuilder : public ValueObject { const uword pc = sample->At(frame_index); ProfileCode* profile_code = GetProfileCode(pc, sample->timestamp()); ProfileFunction* function = profile_code->function(); - ASSERT(function != NULL); + ASSERT(function != nullptr); const intptr_t code_index = profile_code->code_table_index(); - ASSERT(profile_code != NULL); + ASSERT(profile_code != nullptr); - GrowableArray* inlined_functions = NULL; - GrowableArray* inlined_token_positions = NULL; + GrowableArray* inlined_functions = nullptr; + GrowableArray* inlined_token_positions = nullptr; TokenPosition token_position = TokenPosition::kNoSource; Code& code = Code::ZoneHandle(); if (profile_code->code().IsCode()) { @@ -1164,7 +1164,7 @@ class ProfileBuilder : public ValueObject { inlined_functions_cache_->Get(pc, code, sample, frame_index, &inlined_functions, &inlined_token_positions, &token_position); - if (FLAG_trace_profiler_verbose && (inlined_functions != NULL)) { + if (FLAG_trace_profiler_verbose && (inlined_functions != nullptr)) { for (intptr_t i = 0; i < inlined_functions->length(); i++) { const String& name = String::Handle((*inlined_functions)[i]->QualifiedScrubbedName()); @@ -1175,7 +1175,7 @@ class ProfileBuilder : public ValueObject { } } - if (code.IsNull() || (inlined_functions == NULL) || + if (code.IsNull() || (inlined_functions == nullptr) || (inlined_functions->length() <= 1)) { ProcessFunction(sample_index, sample, frame_index, function, token_position, code_index); @@ -1198,7 +1198,7 @@ class ProfileBuilder : public ValueObject { // Append the inlined children. for (intptr_t i = inlined_functions->length() - 1; i >= 0; i--) { const Function* inlined_function = (*inlined_functions)[i]; - ASSERT(inlined_function != NULL); + ASSERT(inlined_function != nullptr); ASSERT(!inlined_function->IsNull()); TokenPosition inlined_token_position = (*inlined_token_positions)[i]; ProcessInlinedFunction(sample_index, sample, frame_index + i, @@ -1215,7 +1215,7 @@ class ProfileBuilder : public ValueObject { intptr_t code_index) { ProfileFunctionTable* function_table = profile_->functions_; ProfileFunction* function = function_table->LookupOrAdd(*inlined_function); - ASSERT(function != NULL); + ASSERT(function != nullptr); ProcessFunction(sample_index, sample, frame_index, function, inlined_token_position, code_index); } @@ -1254,7 +1254,7 @@ class ProfileBuilder : public ValueObject { ASSERT(index >= 0); ProfileCode* code = tag_table->At(index); code->IncInclusiveTicks(); - ASSERT(code != NULL); + ASSERT(code != nullptr); ProfileFunction* function = code->function(); function->IncInclusiveTicks(); } @@ -1288,7 +1288,7 @@ class ProfileBuilder : public ValueObject { } ProfileCodeTable* tag_table = profile_->tag_code_; ProfileCode* code = tag_table->FindCodeForPC(vm_tag); - ASSERT(code != NULL); + ASSERT(code != nullptr); code->Tick(vm_tag, true, serial); } @@ -1301,9 +1301,9 @@ class ProfileBuilder : public ValueObject { } ProfileCodeTable* tag_table = profile_->tag_code_; ProfileCode* code = tag_table->FindCodeForPC(vm_tag); - ASSERT(code != NULL); + ASSERT(code != nullptr); ProfileFunction* function = code->function(); - ASSERT(function != NULL); + ASSERT(function != nullptr); function->Tick(true, serial, TokenPosition::kNoSource); } @@ -1312,7 +1312,7 @@ class ProfileBuilder : public ValueObject { intptr_t index = tag_table->FindCodeIndexForPC(tag); ASSERT(index >= 0); ProfileCode* code = tag_table->At(index); - ASSERT(code != NULL); + ASSERT(code != nullptr); return code->code_table_index(); } @@ -1321,9 +1321,9 @@ class ProfileBuilder : public ValueObject { intptr_t index = tag_table->FindCodeIndexForPC(tag); ASSERT(index >= 0); ProfileCode* code = tag_table->At(index); - ASSERT(code != NULL); + ASSERT(code != nullptr); ProfileFunction* function = code->function(); - ASSERT(function != NULL); + ASSERT(function != nullptr); return function->table_index(); } @@ -1367,7 +1367,7 @@ class ProfileBuilder : public ValueObject { // Check if |pc| is already known in the live code table. ProfileCodeTable* live_table = profile_->live_code_; ProfileCode* profile_code = live_table->FindCodeForPC(pc); - if (profile_code != NULL) { + if (profile_code != nullptr) { return profile_code; } @@ -1377,7 +1377,7 @@ class ProfileBuilder : public ValueObject { uword native_start = 0; char* native_name = NativeSymbolResolver::LookupSymbolName(pc, &native_start); - if (native_name == NULL) { + if (native_name == nullptr) { // Failed to find a native symbol for pc. native_start = pc; } @@ -1390,18 +1390,18 @@ class ProfileBuilder : public ValueObject { if (native_start > pc) { // Bogus lookup result. - if (native_name != NULL) { + if (native_name != nullptr) { NativeSymbolResolver::FreeSymbolName(native_name); - native_name = NULL; + native_name = nullptr; } native_start = pc; } if ((pc - native_start) > (32 * KB)) { // Suspect lookup result. More likely dladdr going off the rails than a // jumbo function. - if (native_name != NULL) { + if (native_name != nullptr) { NativeSymbolResolver::FreeSymbolName(native_name); - native_name = NULL; + native_name = nullptr; } native_start = pc; } @@ -1410,7 +1410,7 @@ class ProfileBuilder : public ValueObject { ASSERT(pc < (pc + 1)); // Should not overflow. profile_code = new ProfileCode(ProfileCode::kNativeCode, native_start, pc + 1, 0, null_code_); - if (native_name != NULL) { + if (native_name != nullptr) { profile_code->SetName(native_name); NativeSymbolResolver::FreeSymbolName(native_name); } @@ -1429,7 +1429,7 @@ class ProfileBuilder : public ValueObject { ProfileCodeTable* dead_table = profile_->dead_code_; ProfileCode* code = dead_table->FindCodeForPC(pc); - if (code != NULL) { + if (code != nullptr) { return code; } @@ -1442,11 +1442,11 @@ class ProfileBuilder : public ValueObject { ProfileCode* FindOrRegisterProfileCode(uword pc, int64_t timestamp) { ProfileCodeTable* live_table = profile_->live_code_; ProfileCode* code = live_table->FindCodeForPC(pc); - if ((code != NULL) && (code->compile_timestamp() <= timestamp)) { + if ((code != nullptr) && (code->compile_timestamp() <= timestamp)) { // Code was compiled before sample was taken. return code; } - if ((code == NULL) && !IsPCInDartHeap(pc)) { + if ((code == nullptr) && !IsPCInDartHeap(pc)) { // Not a PC from Dart code. Check with native code. return FindOrRegisterNativeProfileCode(pc); } @@ -1469,11 +1469,11 @@ class ProfileBuilder : public ValueObject { Profile::Profile() : zone_(Thread::Current()->zone()), - samples_(NULL), - live_code_(NULL), - dead_code_(NULL), - tag_code_(NULL), - functions_(NULL), + samples_(nullptr), + live_code_(nullptr), + dead_code_(nullptr), + tag_code_(nullptr), + functions_(nullptr), dead_code_index_offset_(-1), tag_code_index_offset_(-1), min_time_(kMaxInt64), @@ -1500,14 +1500,14 @@ intptr_t Profile::NumFunctions() const { } ProfileFunction* Profile::GetFunction(intptr_t index) { - ASSERT(functions_ != NULL); + ASSERT(functions_ != nullptr); return functions_->At(index); } ProfileCode* Profile::GetCode(intptr_t index) { - ASSERT(live_code_ != NULL); - ASSERT(dead_code_ != NULL); - ASSERT(tag_code_ != NULL); + ASSERT(live_code_ != nullptr); + ASSERT(dead_code_ != nullptr); + ASSERT(tag_code_ != nullptr); ASSERT(dead_code_index_offset_ >= 0); ASSERT(tag_code_index_offset_ >= 0); @@ -1531,14 +1531,14 @@ ProfileCode* Profile::GetCode(intptr_t index) { ProfileCode* Profile::GetCodeFromPC(uword pc, int64_t timestamp) { intptr_t index = live_code_->FindCodeIndexForPC(pc); - ProfileCode* code = NULL; + ProfileCode* code = nullptr; if (index < 0) { index = dead_code_->FindCodeIndexForPC(pc); ASSERT(index >= 0); code = dead_code_->At(index); } else { code = live_code_->At(index); - ASSERT(code != NULL); + ASSERT(code != nullptr); if (code->compile_timestamp() > timestamp) { // Code is newer than sample. Fall back to dead code table. index = dead_code_->FindCodeIndexForPC(pc); @@ -1547,7 +1547,7 @@ ProfileCode* Profile::GetCodeFromPC(uword pc, int64_t timestamp) { } } - ASSERT(code != NULL); + ASSERT(code != nullptr); ASSERT(code->Contains(pc)); ASSERT(code->compile_timestamp() <= timestamp); return code; @@ -1591,9 +1591,9 @@ void Profile::ProcessSampleFrameJSON(JSONArray* stack, intptr_t frame_index) { const uword pc = sample->At(frame_index); ProfileCode* profile_code = GetCodeFromPC(pc, sample->timestamp()); - ASSERT(profile_code != NULL); + ASSERT(profile_code != nullptr); ProfileFunction* function = profile_code->function(); - ASSERT(function != NULL); + ASSERT(function != nullptr); // Don't show stubs in stack traces. if (!function->is_visible() || @@ -1601,8 +1601,8 @@ void Profile::ProcessSampleFrameJSON(JSONArray* stack, return; } - GrowableArray* inlined_functions = NULL; - GrowableArray* inlined_token_positions = NULL; + GrowableArray* inlined_functions = nullptr; + GrowableArray* inlined_token_positions = nullptr; TokenPosition token_position = TokenPosition::kNoSource; Code& code = Code::ZoneHandle(); @@ -1610,7 +1610,7 @@ void Profile::ProcessSampleFrameJSON(JSONArray* stack, code ^= profile_code->code().ptr(); cache_->Get(pc, code, sample, frame_index, &inlined_functions, &inlined_token_positions, &token_position); - if (FLAG_trace_profiler_verbose && (inlined_functions != NULL)) { + if (FLAG_trace_profiler_verbose && (inlined_functions != nullptr)) { for (intptr_t i = 0; i < inlined_functions->length(); i++) { const String& name = String::Handle((*inlined_functions)[i]->QualifiedScrubbedName()); @@ -1620,7 +1620,7 @@ void Profile::ProcessSampleFrameJSON(JSONArray* stack, } } - if (code.IsNull() || (inlined_functions == NULL) || + if (code.IsNull() || (inlined_functions == nullptr) || (inlined_functions->length() <= 1)) { PrintFunctionFrameIndexJSON(stack, function); return; @@ -1641,7 +1641,7 @@ void Profile::ProcessSampleFrameJSON(JSONArray* stack, for (intptr_t i = inlined_functions->length() - 1; i >= 0; i--) { const Function* inlined_function = (*inlined_functions)[i]; - ASSERT(inlined_function != NULL); + ASSERT(inlined_function != nullptr); ASSERT(!inlined_function->IsNull()); ProcessInlinedFunctionFrameJSON(stack, inlined_function); } @@ -1651,7 +1651,7 @@ void Profile::ProcessInlinedFunctionFrameJSON( JSONArray* stack, const Function* inlined_function) { ProfileFunction* function = functions_->LookupOrAdd(*inlined_function); - ASSERT(function != NULL); + ASSERT(function != nullptr); PrintFunctionFrameIndexJSON(stack, function); } @@ -1723,7 +1723,7 @@ void Profile::PrintSamplesJSON(JSONObject* obj, bool code_samples) { } ProfileFunction* Profile::FindFunction(const Function& function) { - return (functions_ != NULL) ? functions_->Lookup(function) : NULL; + return (functions_ != nullptr) ? functions_->Lookup(function) : nullptr; } void Profile::PrintProfileJSON(JSONStream* stream, bool include_code_samples) { @@ -1746,19 +1746,19 @@ void Profile::PrintProfileJSON(JSONObject* obj, JSONArray codes(obj, "_codes"); for (intptr_t i = 0; i < live_code_->length(); i++) { ProfileCode* code = live_code_->At(i); - ASSERT(code != NULL); + ASSERT(code != nullptr); code->PrintToJSONArray(&codes); thread->CheckForSafepoint(); } for (intptr_t i = 0; i < dead_code_->length(); i++) { ProfileCode* code = dead_code_->At(i); - ASSERT(code != NULL); + ASSERT(code != nullptr); code->PrintToJSONArray(&codes); thread->CheckForSafepoint(); } for (intptr_t i = 0; i < tag_code_->length(); i++) { ProfileCode* code = tag_code_->At(i); - ASSERT(code != NULL); + ASSERT(code != nullptr); code->PrintToJSONArray(&codes); thread->CheckForSafepoint(); } @@ -1768,7 +1768,7 @@ void Profile::PrintProfileJSON(JSONObject* obj, JSONArray functions(obj, "functions"); for (intptr_t i = 0; i < functions_->length(); i++) { ProfileFunction* function = functions_->At(i); - ASSERT(function != NULL); + ASSERT(function != nullptr); function->PrintToJSONArray(&functions, is_event); thread->CheckForSafepoint(); } diff --git a/runtime/vm/profiler_service.h b/runtime/vm/profiler_service.h index da120252c9a..d39125bdf2c 100644 --- a/runtime/vm/profiler_service.h +++ b/runtime/vm/profiler_service.h @@ -143,7 +143,7 @@ class ProfileFunction : public ZoneAllocated { const intptr_t table_index); const char* name() const { - ASSERT(name_ != NULL); + ASSERT(name_ != nullptr); return name_; } @@ -337,7 +337,7 @@ class ProfileCodeTable : public ZoneAllocated { ProfileCode* FindCodeForPC(uword pc) const { intptr_t index = FindCodeIndexForPC(pc); if (index < 0) { - return NULL; + return nullptr; } return At(index); } diff --git a/runtime/vm/profiler_test.cc b/runtime/vm/profiler_test.cc index 7cf5e0125e2..9383709e263 100644 --- a/runtime/vm/profiler_test.cc +++ b/runtime/vm/profiler_test.cc @@ -211,7 +211,7 @@ static LibraryPtr LoadTestScript(const char* script) { Dart_Handle api_lib; { TransitionVMToNative transition(Thread::Current()); - api_lib = TestCase::LoadTestScript(script, NULL); + api_lib = TestCase::LoadTestScript(script, nullptr); EXPECT_VALID(api_lib); } Library& lib = Library::Handle(); @@ -238,7 +238,7 @@ static FunctionPtr GetFunction(const Library& lib, const char* name) { static void Invoke(const Library& lib, const char* name, intptr_t argc = 0, - Dart_Handle* argv = NULL) { + Dart_Handle* argv = nullptr) { Thread* thread = Thread::Current(); Dart_Handle api_lib = Api::NewHandle(thread, lib.ptr()); TransitionVMToNative transition(thread); @@ -303,11 +303,11 @@ class ProfileStackWalker { const char* CurrentName() { if (as_functions_) { ProfileFunction* func = GetFunction(); - EXPECT(func != NULL); + EXPECT(func != nullptr); return func->Name(); } else { ProfileCode* code = GetCode(); - EXPECT(code != NULL); + EXPECT(code != nullptr); return code->name(); } } @@ -349,11 +349,11 @@ class ProfileStackWalker { intptr_t CurrentInclusiveTicks() { if (as_functions_) { ProfileFunction* func = GetFunction(); - EXPECT(func != NULL); + EXPECT(func != nullptr); return func->inclusive_ticks(); } else { ProfileCode* code = GetCode(); - ASSERT(code != NULL); + ASSERT(code != nullptr); return code->inclusive_ticks(); } } @@ -361,11 +361,11 @@ class ProfileStackWalker { intptr_t CurrentExclusiveTicks() { if (as_functions_) { ProfileFunction* func = GetFunction(); - EXPECT(func != NULL); + EXPECT(func != nullptr); return func->exclusive_ticks(); } else { ProfileCode* code = GetCode(); - ASSERT(code != NULL); + ASSERT(code != nullptr); return code->exclusive_ticks(); } } @@ -395,24 +395,24 @@ class ProfileStackWalker { void ClearInliningData() { inlined_index_ = kInvalidInlinedIndex; - inlined_functions_ = NULL; - inlined_token_positions_ = NULL; + inlined_functions_ = nullptr; + inlined_token_positions_ = nullptr; } ProfileFunction* GetFunction() { // Check to see if we're currently processing inlined functions. If so, // return the next inlined function. ProfileFunction* function = GetInlinedFunction(); - if (function != NULL) { + if (function != nullptr) { return function; } const uword pc = sample_->At(index_); ProfileCode* profile_code = profile_->GetCodeFromPC(pc, sample_->timestamp()); - ASSERT(profile_code != NULL); + ASSERT(profile_code != nullptr); function = profile_code->function(); - ASSERT(function != NULL); + ASSERT(function != nullptr); TokenPosition token_position = TokenPosition::kNoSource; Code& code = Code::ZoneHandle(); @@ -423,7 +423,7 @@ class ProfileStackWalker { &inlined_token_positions_, &token_position); } - if (code.IsNull() || (inlined_functions_ == NULL) || + if (code.IsNull() || (inlined_functions_ == nullptr) || (inlined_functions_->length() <= 1)) { ClearInliningData(); // No inlined functions. @@ -433,7 +433,7 @@ class ProfileStackWalker { ASSERT(code.is_optimized()); inlined_index_ = inlined_functions_->length() - 1; function = GetInlinedFunction(); - ASSERT(function != NULL); + ASSERT(function != nullptr); return function; } @@ -442,7 +442,7 @@ class ProfileStackWalker { (inlined_index_ < inlined_functions_->length())) { return profile_->FindFunction(*(*inlined_functions_)[inlined_index_]); } - return NULL; + return nullptr; } Profile* profile_; @@ -2168,7 +2168,7 @@ static void InsertFakeSample(uword* pc_offsets) { Isolate* isolate = Isolate::Current(); ASSERT(Profiler::sample_block_buffer() != nullptr); Sample* sample = Profiler::sample_block_buffer()->ReserveCPUSample(isolate); - ASSERT(sample != NULL); + ASSERT(sample != nullptr); sample->Init(isolate->main_port(), OS::GetCurrentMonotonicMicros(), OSThread::Current()->trace_id()); sample->set_thread_task(Thread::kMutatorTask); @@ -2330,7 +2330,7 @@ ISOLATE_UNIT_TEST_CASE(Profiler_ProfileCodeTableTest) { ProfileCodeTable* table = new (Z) ProfileCodeTable(); EXPECT_EQ(table->length(), 0); - EXPECT_EQ(table->FindCodeForPC(42), static_cast(NULL)); + EXPECT_EQ(table->FindCodeForPC(42), static_cast(nullptr)); int64_t timestamp = 0; const AbstractCode null_code(Code::null()); @@ -2338,69 +2338,69 @@ ISOLATE_UNIT_TEST_CASE(Profiler_ProfileCodeTableTest) { ProfileCode* code1 = new (Z) ProfileCode(ProfileCode::kNativeCode, 50, 60, timestamp, null_code); EXPECT_EQ(table->InsertCode(code1), 0); - EXPECT_EQ(table->FindCodeForPC(0), static_cast(NULL)); - EXPECT_EQ(table->FindCodeForPC(100), static_cast(NULL)); + EXPECT_EQ(table->FindCodeForPC(0), static_cast(nullptr)); + EXPECT_EQ(table->FindCodeForPC(100), static_cast(nullptr)); EXPECT_EQ(table->FindCodeForPC(50), code1); EXPECT_EQ(table->FindCodeForPC(55), code1); EXPECT_EQ(table->FindCodeForPC(59), code1); - EXPECT_EQ(table->FindCodeForPC(60), static_cast(NULL)); + EXPECT_EQ(table->FindCodeForPC(60), static_cast(nullptr)); // Insert below all. ProfileCode* code2 = new (Z) ProfileCode(ProfileCode::kNativeCode, 10, 20, timestamp, null_code); EXPECT_EQ(table->InsertCode(code2), 0); - EXPECT_EQ(table->FindCodeForPC(0), static_cast(NULL)); - EXPECT_EQ(table->FindCodeForPC(100), static_cast(NULL)); + EXPECT_EQ(table->FindCodeForPC(0), static_cast(nullptr)); + EXPECT_EQ(table->FindCodeForPC(100), static_cast(nullptr)); EXPECT_EQ(table->FindCodeForPC(50), code1); EXPECT_EQ(table->FindCodeForPC(10), code2); EXPECT_EQ(table->FindCodeForPC(19), code2); - EXPECT_EQ(table->FindCodeForPC(20), static_cast(NULL)); + EXPECT_EQ(table->FindCodeForPC(20), static_cast(nullptr)); // Insert above all. ProfileCode* code3 = new (Z) ProfileCode(ProfileCode::kNativeCode, 80, 90, timestamp, null_code); EXPECT_EQ(table->InsertCode(code3), 2); - EXPECT_EQ(table->FindCodeForPC(0), static_cast(NULL)); - EXPECT_EQ(table->FindCodeForPC(100), static_cast(NULL)); + EXPECT_EQ(table->FindCodeForPC(0), static_cast(nullptr)); + EXPECT_EQ(table->FindCodeForPC(100), static_cast(nullptr)); EXPECT_EQ(table->FindCodeForPC(50), code1); EXPECT_EQ(table->FindCodeForPC(10), code2); EXPECT_EQ(table->FindCodeForPC(80), code3); EXPECT_EQ(table->FindCodeForPC(89), code3); - EXPECT_EQ(table->FindCodeForPC(90), static_cast(NULL)); + EXPECT_EQ(table->FindCodeForPC(90), static_cast(nullptr)); // Insert between. ProfileCode* code4 = new (Z) ProfileCode(ProfileCode::kNativeCode, 65, 75, timestamp, null_code); EXPECT_EQ(table->InsertCode(code4), 2); - EXPECT_EQ(table->FindCodeForPC(0), static_cast(NULL)); - EXPECT_EQ(table->FindCodeForPC(100), static_cast(NULL)); + EXPECT_EQ(table->FindCodeForPC(0), static_cast(nullptr)); + EXPECT_EQ(table->FindCodeForPC(100), static_cast(nullptr)); EXPECT_EQ(table->FindCodeForPC(50), code1); EXPECT_EQ(table->FindCodeForPC(10), code2); EXPECT_EQ(table->FindCodeForPC(80), code3); EXPECT_EQ(table->FindCodeForPC(65), code4); EXPECT_EQ(table->FindCodeForPC(74), code4); - EXPECT_EQ(table->FindCodeForPC(75), static_cast(NULL)); + EXPECT_EQ(table->FindCodeForPC(75), static_cast(nullptr)); // Insert overlapping left. ProfileCode* code5 = new (Z) ProfileCode(ProfileCode::kNativeCode, 15, 25, timestamp, null_code); EXPECT_EQ(table->InsertCode(code5), 0); - EXPECT_EQ(table->FindCodeForPC(0), static_cast(NULL)); - EXPECT_EQ(table->FindCodeForPC(100), static_cast(NULL)); + EXPECT_EQ(table->FindCodeForPC(0), static_cast(nullptr)); + EXPECT_EQ(table->FindCodeForPC(100), static_cast(nullptr)); EXPECT_EQ(table->FindCodeForPC(50), code1); EXPECT_EQ(table->FindCodeForPC(10), code2); EXPECT_EQ(table->FindCodeForPC(80), code3); EXPECT_EQ(table->FindCodeForPC(65), code4); EXPECT_EQ(table->FindCodeForPC(15), code2); // Merged left. EXPECT_EQ(table->FindCodeForPC(24), code2); // Merged left. - EXPECT_EQ(table->FindCodeForPC(25), static_cast(NULL)); + EXPECT_EQ(table->FindCodeForPC(25), static_cast(nullptr)); // Insert overlapping right. ProfileCode* code6 = new (Z) ProfileCode(ProfileCode::kNativeCode, 45, 55, timestamp, null_code); EXPECT_EQ(table->InsertCode(code6), 1); - EXPECT_EQ(table->FindCodeForPC(0), static_cast(NULL)); - EXPECT_EQ(table->FindCodeForPC(100), static_cast(NULL)); + EXPECT_EQ(table->FindCodeForPC(0), static_cast(nullptr)); + EXPECT_EQ(table->FindCodeForPC(100), static_cast(nullptr)); EXPECT_EQ(table->FindCodeForPC(50), code1); EXPECT_EQ(table->FindCodeForPC(10), code2); EXPECT_EQ(table->FindCodeForPC(80), code3); @@ -2415,8 +2415,8 @@ ISOLATE_UNIT_TEST_CASE(Profiler_ProfileCodeTableTest) { ProfileCode* code7 = new (Z) ProfileCode(ProfileCode::kNativeCode, 20, 50, timestamp, null_code); EXPECT_EQ(table->InsertCode(code7), 0); - EXPECT_EQ(table->FindCodeForPC(0), static_cast(NULL)); - EXPECT_EQ(table->FindCodeForPC(100), static_cast(NULL)); + EXPECT_EQ(table->FindCodeForPC(0), static_cast(nullptr)); + EXPECT_EQ(table->FindCodeForPC(100), static_cast(nullptr)); EXPECT_EQ(table->FindCodeForPC(50), code1); EXPECT_EQ(table->FindCodeForPC(10), code2); EXPECT_EQ(table->FindCodeForPC(80), code3); diff --git a/runtime/vm/random.cc b/runtime/vm/random.cc index 752f1c0898d..69f55c1917d 100644 --- a/runtime/vm/random.cc +++ b/runtime/vm/random.cc @@ -18,7 +18,7 @@ Random::Random() { uint64_t seed = FLAG_random_seed; if (seed == 0) { Dart_EntropySource callback = Dart::entropy_source_callback(); - if (callback != NULL) { + if (callback != nullptr) { if (!callback(reinterpret_cast(&seed), sizeof(seed))) { // Callback failed. Reset the seed to 0. seed = 0; diff --git a/runtime/vm/raw_object.cc b/runtime/vm/raw_object.cc index f13b520e9b7..bec37dae48a 100644 --- a/runtime/vm/raw_object.cc +++ b/runtime/vm/raw_object.cc @@ -417,7 +417,7 @@ void UntaggedObject::VisitPointersPrecise(ObjectPointerVisitor* visitor) { } bool UntaggedObject::FindObject(FindObjectVisitor* visitor) { - ASSERT(visitor != NULL); + ASSERT(visitor != nullptr); return visitor->FindObject(static_cast(this)); } diff --git a/runtime/vm/raw_object.h b/runtime/vm/raw_object.h index a3d0389db46..4e9df320367 100644 --- a/runtime/vm/raw_object.h +++ b/runtime/vm/raw_object.h @@ -1048,7 +1048,7 @@ class UntaggedClass : public UntaggedObject { break; } UNREACHABLE(); - return NULL; + return nullptr; } NOT_IN_PRECOMPILED(TokenPosition token_pos_); @@ -1122,7 +1122,7 @@ class UntaggedPatchClass : public UntaggedObject { break; } UNREACHABLE(); - return NULL; + return nullptr; } NOT_IN_PRECOMPILED(intptr_t library_kernel_offset_); @@ -1312,7 +1312,7 @@ class UntaggedFunction : public UntaggedObject { break; } UNREACHABLE(); - return NULL; + return nullptr; } // ICData of unoptimized code. COMPRESSED_POINTER_FIELD(ArrayPtr, ic_data_array); @@ -1463,7 +1463,7 @@ class UntaggedField : public UntaggedObject { break; } UNREACHABLE(); - return NULL; + return nullptr; } #if defined(DART_PRECOMPILED_RUNTIME) VISIT_TO(dependent_code); @@ -1536,7 +1536,7 @@ class alignas(8) UntaggedScript : public UntaggedObject { break; } UNREACHABLE(); - return NULL; + return nullptr; } #if !defined(PRODUCT) && !defined(DART_PRECOMPILED_RUNTIME) @@ -1627,7 +1627,7 @@ class UntaggedLibrary : public UntaggedObject { break; } UNREACHABLE(); - return NULL; + return nullptr; } // Cache of resolved names in library scope. COMPRESSED_POINTER_FIELD(ArrayPtr, resolved_names); @@ -1679,7 +1679,7 @@ class UntaggedNamespace : public UntaggedObject { break; } UNREACHABLE(); - return NULL; + return nullptr; } }; @@ -2470,7 +2470,7 @@ class UntaggedICData : public UntaggedCallSiteData { break; } UNREACHABLE(); - return NULL; + return nullptr; } NOT_IN_PRECOMPILED(int32_t deopt_id_); // Number of arguments tested in IC, deopt reasons. @@ -2592,7 +2592,7 @@ class UntaggedLibraryPrefix : public UntaggedInstance { break; } UNREACHABLE(); - return NULL; + return nullptr; } uint16_t num_imports_; // Number of library entries in libraries_. bool is_deferred_load_; diff --git a/runtime/vm/regexp.cc b/runtime/vm/regexp.cc index 5134d430e27..576e647bfb7 100644 --- a/runtime/vm/regexp.cc +++ b/runtime/vm/regexp.cc @@ -391,7 +391,7 @@ RegExpCompiler::RegExpCompiler(intptr_t capture_count, bool is_one_byte) : next_register_(2 * (capture_count + 1)), unicode_lookaround_stack_register_(kNoRegister), unicode_lookaround_position_register_(kNoRegister), - work_list_(NULL), + work_list_(nullptr), recursion_depth_(0), is_one_byte_(is_one_byte), reg_exp_too_big_(false), @@ -468,7 +468,7 @@ bool Trace::DeferredAction::Mentions(intptr_t that) { } bool Trace::mentions_reg(intptr_t reg) { - for (DeferredAction* action = actions_; action != NULL; + for (DeferredAction* action = actions_; action != nullptr; action = action->next()) { if (action->Mentions(reg)) return true; } @@ -477,7 +477,7 @@ bool Trace::mentions_reg(intptr_t reg) { bool Trace::GetStoredPosition(intptr_t reg, intptr_t* cp_offset) { ASSERT(*cp_offset == 0); - for (DeferredAction* action = actions_; action != NULL; + for (DeferredAction* action = actions_; action != nullptr; action = action->next()) { if (action->Mentions(reg)) { if (action->action_type() == ActionNode::STORE_POSITION) { @@ -496,7 +496,7 @@ bool Trace::GetStoredPosition(intptr_t reg, intptr_t* cp_offset) { // generate generic code. intptr_t Trace::FindAffectedRegisters(OutSet* affected_registers, Zone* zone) { intptr_t max_register = RegExpCompiler::kNoRegister; - for (DeferredAction* action = actions_; action != NULL; + for (DeferredAction* action = actions_; action != nullptr; action = action->next()) { if (action->action_type() == ActionNode::CLEAR_CAPTURES) { Interval range = static_cast(action)->range(); @@ -552,7 +552,7 @@ void Trace::PerformDeferredActions(RegExpMacroAssembler* assembler, intptr_t store_position = kNoStore; // This is a little tricky because we are scanning the actions in reverse // historical order (newest first). - for (DeferredAction* action = actions_; action != NULL; + for (DeferredAction* action = actions_; action != nullptr; action = action->next()) { if (action->Mentions(reg)) { switch (action->action_type()) { @@ -651,7 +651,7 @@ void Trace::Flush(RegExpCompiler* compiler, RegExpNode* successor) { ASSERT(!is_trivial()); - if (actions_ == NULL && backtrack() == NULL) { + if (actions_ == nullptr && backtrack() == nullptr) { // Here we just have some deferred cp advances to fix and we are back to // a normal situation. We may also have to forget some information gained // through a quick check that was already performed. @@ -665,7 +665,7 @@ void Trace::Flush(RegExpCompiler* compiler, RegExpNode* successor) { // Generate deferred actions here along with code to undo them again. OutSet affected_registers; - if (backtrack() != NULL) { + if (backtrack() != nullptr) { // Here we have a concrete backtrack location. These are set up by choice // nodes and so they indicate that we have a deferred save of the current // position which we may need to emit here. @@ -691,7 +691,7 @@ void Trace::Flush(RegExpCompiler* compiler, RegExpNode* successor) { assembler->BindBlock(&undo); RestoreAffectedRegisters(assembler, max_register, registers_to_pop, registers_to_clear); - if (backtrack() == NULL) { + if (backtrack() == nullptr) { assembler->Backtrack(); } else { assembler->PopCurrentPosition(); @@ -749,7 +749,7 @@ void EndNode::Emit(RegExpCompiler* compiler, Trace* trace) { } void GuardedAlternative::AddGuard(Guard* guard, Zone* zone) { - if (guards_ == NULL) guards_ = new (zone) ZoneGrowableArray(1); + if (guards_ == nullptr) guards_ = new (zone) ZoneGrowableArray(1); guards_->Add(guard); } @@ -1210,7 +1210,7 @@ static void SplitSearchSpace(ZoneGrowableArray* ranges, // character is in the range between an even and an odd boundary (counting from // start_index) then go to even_label, otherwise go to odd_label. We already // know that the character is in the range of min_char to max_char inclusive. -// Either label can be NULL indicating backtracking. Either label can also be +// Either label can be null indicating backtracking. Either label can also be // equal to the fall_through label. static void GenerateBranches(RegExpMacroAssembler* masm, ZoneGrowableArray* ranges, @@ -1429,7 +1429,7 @@ RegExpNode::~RegExpNode() {} RegExpNode::LimitResult RegExpNode::LimitVersions(RegExpCompiler* compiler, Trace* trace) { // If we are generating a greedy loop then don't stop and don't reuse code. - if (trace->stop_node() != NULL) { + if (trace->stop_node() != nullptr) { return CONTINUE; } @@ -1580,7 +1580,7 @@ intptr_t LoopChoiceNode::EatsAtLeast(intptr_t still_to_find, intptr_t ChoiceNode::EatsAtLeast(intptr_t still_to_find, intptr_t budget, bool not_at_start) { - return EatsAtLeastHelper(still_to_find, budget, NULL, not_at_start); + return EatsAtLeastHelper(still_to_find, budget, nullptr, not_at_start); } // Takes the left-most 1-bit and smears it out, setting all bits to its right. @@ -1936,7 +1936,7 @@ RegExpNode* SeqRegExpNode::FilterOneByte(intptr_t depth) { RegExpNode* SeqRegExpNode::FilterSuccessor(intptr_t depth) { RegExpNode* next = on_success_->FilterOneByte(depth - 1); - if (next == NULL) return set_replacement(NULL); + if (next == nullptr) return set_replacement(nullptr); on_success_ = next; return set_replacement(this); } @@ -1985,12 +1985,12 @@ RegExpNode* TextNode::FilterOneByte(intptr_t depth) { for (intptr_t j = 0; j < quarks->length(); j++) { uint16_t c = quarks->At(j); if (c <= Symbols::kMaxOneCharCodeSymbol) continue; - if (!elm.atom()->ignore_case()) return set_replacement(NULL); + if (!elm.atom()->ignore_case()) return set_replacement(nullptr); // Here, we need to check for characters whose upper and lower cases // are outside the Latin-1 range. uint16_t converted = ConvertNonLatin1ToLatin1(c); // Character is outside Latin-1 completely - if (converted == 0) return set_replacement(NULL); + if (converted == 0) return set_replacement(nullptr); // Convert quark to Latin-1 in place. (*quarks)[0] = converted; } @@ -2011,7 +2011,7 @@ RegExpNode* TextNode::FilterOneByte(intptr_t depth) { RangesContainLatin1Equivalents(ranges)) { continue; } - return set_replacement(NULL); + return set_replacement(nullptr); } } else { if (range_count == 0 || @@ -2020,7 +2020,7 @@ RegExpNode* TextNode::FilterOneByte(intptr_t depth) { if (cc->flags().IgnoreCase() && RangesContainLatin1Equivalents(ranges)) continue; - return set_replacement(NULL); + return set_replacement(nullptr); } } } @@ -2038,7 +2038,7 @@ RegExpNode* LoopChoiceNode::FilterOneByte(intptr_t depth) { RegExpNode* continue_replacement = continue_node_->FilterOneByte(depth - 1); // If we can't continue after the loop then there is no sense in doing the // loop. - if (continue_replacement == NULL) return set_replacement(NULL); + if (continue_replacement == nullptr) return set_replacement(nullptr); } return ChoiceNode::FilterOneByte(depth - 1); @@ -2053,19 +2053,20 @@ RegExpNode* ChoiceNode::FilterOneByte(intptr_t depth) { for (intptr_t i = 0; i < choice_count; i++) { GuardedAlternative alternative = alternatives_->At(i); - if (alternative.guards() != NULL && alternative.guards()->length() != 0) { + if (alternative.guards() != nullptr && + alternative.guards()->length() != 0) { set_replacement(this); return this; } } intptr_t surviving = 0; - RegExpNode* survivor = NULL; + RegExpNode* survivor = nullptr; for (intptr_t i = 0; i < choice_count; i++) { GuardedAlternative alternative = alternatives_->At(i); RegExpNode* replacement = alternative.node()->FilterOneByte(depth - 1); ASSERT(replacement != this); // No missing EMPTY_MATCH_CHECK. - if (replacement != NULL) { + if (replacement != nullptr) { (*alternatives_)[i].set_node(replacement); surviving++; survivor = replacement; @@ -2084,7 +2085,7 @@ RegExpNode* ChoiceNode::FilterOneByte(intptr_t depth) { for (intptr_t i = 0; i < choice_count; i++) { RegExpNode* replacement = (*alternatives_)[i].node()->FilterOneByte(depth - 1); - if (replacement != NULL) { + if (replacement != nullptr) { (*alternatives_)[i].set_node(replacement); new_alternatives->Add((*alternatives_)[i]); } @@ -2102,14 +2103,14 @@ RegExpNode* NegativeLookaroundChoiceNode::FilterOneByte(intptr_t depth) { // afterwards. RegExpNode* node = (*alternatives_)[1].node(); RegExpNode* replacement = node->FilterOneByte(depth - 1); - if (replacement == NULL) return set_replacement(NULL); + if (replacement == nullptr) return set_replacement(nullptr); (*alternatives_)[1].set_node(replacement); RegExpNode* neg_node = (*alternatives_)[0].node(); RegExpNode* neg_replacement = neg_node->FilterOneByte(depth - 1); // If the negative lookahead is always going to fail then // we don't need to check it. - if (neg_replacement == NULL) return set_replacement(replacement); + if (neg_replacement == nullptr) return set_replacement(replacement); (*alternatives_)[0].set_node(neg_replacement); return set_replacement(this); } @@ -2219,7 +2220,7 @@ void AssertionNode::EmitBoundaryCheck(RegExpCompiler* compiler, Trace* trace) { Trace::TriBool next_is_word_character = Trace::UNKNOWN; bool not_at_start = (trace->at_start() == Trace::FALSE_VALUE); BoyerMooreLookahead* lookahead = bm_info(not_at_start); - if (lookahead == NULL) { + if (lookahead == nullptr) { intptr_t eats_at_least = Utils::Minimum(kMaxLookaheadForBoyerMoore, EatsAtLeast(kMaxLookaheadForBoyerMoore, kRecursionBudget, @@ -2346,7 +2347,7 @@ void AssertionNode::Emit(RegExpCompiler* compiler, Trace* trace) { } static bool DeterminedAlready(QuickCheckDetails* quick_check, intptr_t offset) { - if (quick_check == NULL) return false; + if (quick_check == nullptr) return false; if (offset >= quick_check->characters()) return false; return quick_check->positions(offset)->determines_perfectly; } @@ -2407,7 +2408,7 @@ void TextNode::TextEmitPass(RegExpCompiler* compiler, if (SkipPass(pass, elm.atom()->ignore_case())) continue; if (first_element_checked && i == 0 && j == 0) continue; if (DeterminedAlready(quick_check, elm.cp_offset() + j)) continue; - EmitCharacterFunction* emit_function = NULL; + EmitCharacterFunction* emit_function = nullptr; uint16_t quark = quarks->At(j); if (elm.atom()->ignore_case()) { // Everywhere else we assume that a non-Latin-1 character cannot match @@ -2435,7 +2436,7 @@ void TextNode::TextEmitPass(RegExpCompiler* compiler, default: break; } - if (emit_function != NULL) { + if (emit_function != nullptr) { const bool bounds_check = *checked_up_to < (cp_offset + j) || read_backward(); bool bound_checked = @@ -2601,25 +2602,25 @@ intptr_t TextNode::GreedyLoopTextLength() { RegExpNode* TextNode::GetSuccessorOfOmnivorousTextNode( RegExpCompiler* compiler) { if (read_backward()) return nullptr; - if (elms_->length() != 1) return NULL; + if (elms_->length() != 1) return nullptr; TextElement elm = elms_->At(0); - if (elm.text_type() != TextElement::CHAR_CLASS) return NULL; + if (elm.text_type() != TextElement::CHAR_CLASS) return nullptr; RegExpCharacterClass* node = elm.char_class(); ZoneGrowableArray* ranges = node->ranges(); if (!CharacterRange::IsCanonical(ranges)) { CharacterRange::Canonicalize(ranges); } if (node->is_negated()) { - return ranges->length() == 0 ? on_success() : NULL; + return ranges->length() == 0 ? on_success() : nullptr; } - if (ranges->length() != 1) return NULL; + if (ranges->length() != 1) return nullptr; uint32_t max_char; if (compiler->one_byte()) { max_char = Symbols::kMaxOneCharCodeSymbol; } else { max_char = Utf16::kMaxCodeUnit; } - return ranges->At(0).IsEverything(max_char) ? on_success() : NULL; + return ranges->At(0).IsEverything(max_char) ? on_success() : nullptr; } // Finds the fixed match length of a sequence of nodes that goes from @@ -2649,13 +2650,13 @@ intptr_t ChoiceNode::GreedyLoopTextLengthForAlternative( } void LoopChoiceNode::AddLoopAlternative(GuardedAlternative alt) { - ASSERT(loop_node_ == NULL); + ASSERT(loop_node_ == nullptr); AddAlternative(alt); loop_node_ = alt.node(); } void LoopChoiceNode::AddContinueAlternative(GuardedAlternative alt) { - ASSERT(continue_node_ == NULL); + ASSERT(continue_node_ == nullptr); AddAlternative(alt); continue_node_ = alt.node(); } @@ -2674,7 +2675,7 @@ void LoopChoiceNode::Emit(RegExpCompiler* compiler, Trace* trace) { macro_assembler->GoTo(trace->loop_label()); return; } - ASSERT(trace->stop_node() == NULL); + ASSERT(trace->stop_node() == nullptr); if (!trace->is_trivial()) { trace->Flush(compiler, this); return; @@ -3096,7 +3097,7 @@ void ChoiceNode::AssertGuardsMentionRegisters(Trace* trace) { for (intptr_t i = 0; i < choice_count - 1; i++) { GuardedAlternative alternative = alternatives_->At(i); ZoneGrowableArray* guards = alternative.guards(); - intptr_t guard_count = (guards == NULL) ? 0 : guards->length(); + intptr_t guard_count = (guards == nullptr) ? 0 : guards->length(); for (intptr_t j = 0; j < guard_count; j++) { ASSERT(!trace->mentions_reg(guards->At(j)->reg())); } @@ -3137,7 +3138,7 @@ void ChoiceNode::Emit(RegExpCompiler* compiler, Trace* trace) { // For loop nodes we already flushed (see LoopChoiceNode::Emit), but for // other choice nodes we only flush if we are out of code size budget. - if (trace->flush_budget() == 0 && trace->actions() != NULL) { + if (trace->flush_budget() == 0 && trace->actions() != nullptr) { trace->Flush(compiler, this); return; } @@ -3176,7 +3177,7 @@ void ChoiceNode::Emit(RegExpCompiler* compiler, Trace* trace) { // If there are actions to be flushed we have to limit how many times // they are flushed. Take the budget of the parent trace and distribute // it fairly amongst the children. - if (new_trace.actions() != NULL) { + if (new_trace.actions() != nullptr) { new_trace.set_flush_budget(new_flush_budget); } bool next_expects_preload = @@ -3201,7 +3202,7 @@ Trace* ChoiceNode::EmitGreedyLoop(RegExpCompiler* compiler, // and check it against the pushed value. This avoids pushing backtrack // information for each iteration of the loop, which could take up a lot of // space. - ASSERT(trace->stop_node() == NULL); + ASSERT(trace->stop_node() == nullptr); macro_assembler->PushCurrentPosition(); BlockLabel greedy_match_failed; Trace greedy_match_trace; @@ -3237,7 +3238,7 @@ intptr_t ChoiceNode::EmitOptimizedUnanchoredSearch(RegExpCompiler* compiler, if (alternatives_->length() != 2) return eats_at_least; GuardedAlternative alt1 = alternatives_->At(1); - if (alt1.guards() != NULL && alt1.guards()->length() != 0) { + if (alt1.guards() != nullptr && alt1.guards()->length() != 0) { return eats_at_least; } RegExpNode* eats_anything_node = alt1.node(); @@ -3262,7 +3263,7 @@ intptr_t ChoiceNode::EmitOptimizedUnanchoredSearch(RegExpCompiler* compiler, // not be atoms, they can be any reasonably limited character class or // small alternation. BoyerMooreLookahead* bm = bm_info(false); - if (bm == NULL) { + if (bm == nullptr) { eats_at_least = Utils::Minimum( kMaxLookaheadForBoyerMoore, EatsAtLeast(kMaxLookaheadForBoyerMoore, kRecursionBudget, false)); @@ -3272,7 +3273,7 @@ intptr_t ChoiceNode::EmitOptimizedUnanchoredSearch(RegExpCompiler* compiler, alt0.node()->FillInBMInfo(0, kRecursionBudget, bm, false); } } - if (bm != NULL) { + if (bm != nullptr) { bm->EmitSkipInstructions(macro_assembler); } return eats_at_least; @@ -3299,7 +3300,7 @@ void ChoiceNode::EmitChoices(RegExpCompiler* compiler, AlternativeGeneration* alt_gen = alt_gens->at(i); alt_gen->quick_check_details.set_characters(preload->preload_characters_); ZoneGrowableArray* guards = alternative.guards(); - intptr_t guard_count = (guards == NULL) ? 0 : guards->length(); + intptr_t guard_count = (guards == nullptr) ? 0 : guards->length(); Trace new_trace(*trace); new_trace.set_characters_preloaded( preload->preload_is_current_ ? preload->preload_characters_ : 0); @@ -3349,7 +3350,7 @@ void ChoiceNode::EmitChoices(RegExpCompiler* compiler, generate_full_check_inline = true; } if (generate_full_check_inline) { - if (new_trace.actions() != NULL) { + if (new_trace.actions() != nullptr) { new_trace.set_flush_budget(new_flush_budget); } for (intptr_t j = 0; j < guard_count; j++) { @@ -3377,7 +3378,7 @@ void ChoiceNode::EmitOutOfLineContinuation(RegExpCompiler* compiler, out_of_line_trace.set_quick_check_performed(&alt_gen->quick_check_details); if (not_at_start_) out_of_line_trace.set_at_start(Trace::FALSE_VALUE); ZoneGrowableArray* guards = alternative.guards(); - intptr_t guard_count = (guards == NULL) ? 0 : guards->length(); + intptr_t guard_count = (guards == nullptr) ? 0 : guards->length(); if (next_expects_preload) { BlockLabel reload_current_char; out_of_line_trace.set_backtrack(&reload_current_char); @@ -3389,7 +3390,7 @@ void ChoiceNode::EmitOutOfLineContinuation(RegExpCompiler* compiler, // Reload the current character, since the next quick check expects that. // We don't need to check bounds here because we only get into this // code through a quick check which already did the checked load. - macro_assembler->LoadCurrentCharacter(trace->cp_offset(), NULL, false, + macro_assembler->LoadCurrentCharacter(trace->cp_offset(), nullptr, false, preload_characters); macro_assembler->GoTo(&(alt_gen->after)); } else { @@ -3512,7 +3513,7 @@ void ActionNode::Emit(RegExpCompiler* compiler, Trace* trace) { clear_registers_from + clear_register_count - 1; assembler->ClearRegisters(clear_registers_from, clear_registers_to); - ASSERT(trace->backtrack() == NULL); + ASSERT(trace->backtrack() == nullptr); assembler->Backtrack(); return; } @@ -4767,7 +4768,7 @@ void CharacterRange::AddCaseEquivalents( } bool CharacterRange::IsCanonical(ZoneGrowableArray* ranges) { - ASSERT(ranges != NULL); + ASSERT(ranges != nullptr); intptr_t n = ranges->length(); if (n <= 1) return true; intptr_t max = ranges->At(0).to(); @@ -4780,7 +4781,7 @@ bool CharacterRange::IsCanonical(ZoneGrowableArray* ranges) { } ZoneGrowableArray* CharacterSet::ranges() { - if (ranges_ == NULL) { + if (ranges_ == nullptr) { ranges_ = new ZoneGrowableArray(2); CharacterRange::AddClassEscape(standard_set_type_, ranges_); } @@ -4866,7 +4867,7 @@ static intptr_t InsertRangeInCanonicalList( void CharacterSet::Canonicalize() { // Special/default classes are always considered canonical. The result // of calling ranges() will be sorted. - if (ranges_ == NULL) return; + if (ranges_ == nullptr) return; CharacterRange::Canonicalize(ranges_); } @@ -4961,7 +4962,7 @@ void OutSet::Set(unsigned value, Zone* zone) { if (value < kFirstLimit) { first_ |= (1 << value); } else { - if (remaining_ == NULL) + if (remaining_ == nullptr) remaining_ = new (zone) ZoneGrowableArray(1); bool remaining_contains_value = ArrayContains(remaining_, value); @@ -4974,7 +4975,7 @@ void OutSet::Set(unsigned value, Zone* zone) { bool OutSet::Get(unsigned value) const { if (value < kFirstLimit) { return (first_ & (1 << value)) != 0; - } else if (remaining_ == NULL) { + } else if (remaining_ == nullptr) { return false; } else { return ArrayContains(remaining_, value); @@ -5187,7 +5188,7 @@ void ChoiceNode::FillInBMInfo(intptr_t offset, budget = (budget - 1) / alts->length(); for (intptr_t i = 0; i < alts->length(); i++) { GuardedAlternative& alt = (*alts)[i]; - if (alt.guards() != NULL && alt.guards()->length() != 0) { + if (alt.guards() != nullptr && alt.guards()->length() != 0) { bm->SetRest(offset); // Give up trying to fill in info. SaveBMInfo(bm, not_at_start, offset); return; @@ -5358,14 +5359,14 @@ RegExpEngine::CompilationResult RegExpEngine::CompileIR( node = node->FilterOneByte(RegExpCompiler::kMaxRecursion); // Do it again to propagate the new nodes to places where they were not // put because they had not been calculated yet. - if (node != NULL) { + if (node != nullptr) { node = node->FilterOneByte(RegExpCompiler::kMaxRecursion); } } else if (is_unicode && (is_global || is_sticky)) { node = OptionallyStepBackToLeadSurrogate(&compiler, node, regexp.flags()); } - if (node == NULL) node = new (zone) EndNode(EndNode::BACKTRACK, zone); + if (node == nullptr) node = new (zone) EndNode(EndNode::BACKTRACK, zone); data->node = node; Analysis analysis(is_one_byte); analysis.EnsureAnalyzed(node); @@ -5468,14 +5469,14 @@ RegExpEngine::CompilationResult RegExpEngine::CompileBytecode( node = node->FilterOneByte(RegExpCompiler::kMaxRecursion); // Do it again to propagate the new nodes to places where they were not // put because they had not been calculated yet. - if (node != NULL) { + if (node != nullptr) { node = node->FilterOneByte(RegExpCompiler::kMaxRecursion); } } else if (is_unicode && (is_global || is_sticky)) { node = OptionallyStepBackToLeadSurrogate(&compiler, node, regexp.flags()); } - if (node == NULL) node = new (zone) EndNode(EndNode::BACKTRACK, zone); + if (node == nullptr) node = new (zone) EndNode(EndNode::BACKTRACK, zone); data->node = node; Analysis analysis(is_one_byte); analysis.EnsureAnalyzed(node); diff --git a/runtime/vm/regexp.h b/runtime/vm/regexp.h index 9c2b8e95ff6..527058dcdc7 100644 --- a/runtime/vm/regexp.h +++ b/runtime/vm/regexp.h @@ -91,7 +91,7 @@ class CharacterRange { // integers (< 32). May do zone-allocation. class OutSet : public ZoneAllocated { public: - OutSet() : first_(0), remaining_(NULL), successors_(NULL) {} + OutSet() : first_(0), remaining_(nullptr), successors_(nullptr) {} OutSet* Extend(unsigned value, Zone* zone); bool Get(unsigned value) const; static const unsigned kFirstLimit = 32; @@ -108,7 +108,7 @@ class OutSet : public ZoneAllocated { ZoneGrowableArray* successors() { return successors_; } OutSet(uint32_t first, ZoneGrowableArray* remaining) - : first_(first), remaining_(remaining), successors_(NULL) {} + : first_(first), remaining_(remaining), successors_(nullptr) {} uint32_t first_; ZoneGrowableArray* remaining_; ZoneGrowableArray* successors_; @@ -384,8 +384,8 @@ class QuickCheckDetails { class RegExpNode : public ZoneAllocated { public: explicit RegExpNode(Zone* zone) - : replacement_(NULL), trace_count_(0), zone_(zone) { - bm_info_[0] = bm_info_[1] = NULL; + : replacement_(nullptr), trace_count_(0), zone_(zone) { + bm_info_[0] = bm_info_[1] = nullptr; } virtual ~RegExpNode(); virtual void Accept(NodeVisitor* visitor) = 0; @@ -427,7 +427,7 @@ class RegExpNode : public ZoneAllocated { // character and that has no guards on it. virtual RegExpNode* GetSuccessorOfOmnivorousTextNode( RegExpCompiler* compiler) { - return NULL; + return nullptr; } // Collects information on the possible code units (mod 128) that can match if @@ -445,7 +445,7 @@ class RegExpNode : public ZoneAllocated { // If we know that the input is one-byte then there are some nodes that can // never match. This method returns a node that can be substituted for - // itself, or NULL if the node can never match. + // itself, or nullptr if the node can never match. virtual RegExpNode* FilterOneByte(intptr_t depth) { return this; } // Helper for FilterOneByte. RegExpNode* replacement() { @@ -875,7 +875,8 @@ class Guard : public ZoneAllocated { class GuardedAlternative { public: - explicit GuardedAlternative(RegExpNode* node) : node_(node), guards_(NULL) {} + explicit GuardedAlternative(RegExpNode* node) + : node_(node), guards_(nullptr) {} void AddGuard(Guard* guard, Zone* zone); RegExpNode* node() const { return node_; } void set_node(RegExpNode* node) { node_ = node; } @@ -1012,8 +1013,8 @@ class LoopChoiceNode : public ChoiceNode { bool read_backward, Zone* zone) : ChoiceNode(2, zone), - loop_node_(NULL), - continue_node_(NULL), + loop_node_(nullptr), + continue_node_(nullptr), body_can_be_zero_length_(body_can_be_zero_length), read_backward_(read_backward) {} void AddLoopAlternative(GuardedAlternative alt); @@ -1207,7 +1208,7 @@ class Trace { class DeferredAction { public: DeferredAction(ActionNode::ActionType action_type, intptr_t reg) - : action_type_(action_type), reg_(reg), next_(NULL) {} + : action_type_(action_type), reg_(reg), next_(nullptr) {} DeferredAction* next() { return next_; } bool Mentions(intptr_t reg); intptr_t reg() { return reg_; } @@ -1265,10 +1266,10 @@ class Trace { Trace() : cp_offset_(0), - actions_(NULL), - backtrack_(NULL), - stop_node_(NULL), - loop_label_(NULL), + actions_(nullptr), + backtrack_(nullptr), + stop_node_(nullptr), + loop_label_(nullptr), characters_preloaded_(0), bound_checked_up_to_(0), flush_budget_(100), @@ -1292,7 +1293,7 @@ class Trace { // a trivial trace is recorded in a label in the node so that gotos can be // generated to that code. bool is_trivial() { - return backtrack_ == NULL && actions_ == NULL && cp_offset_ == 0 && + return backtrack_ == nullptr && actions_ == nullptr && cp_offset_ == 0 && characters_preloaded_ == 0 && bound_checked_up_to_ == 0 && quick_check_performed_.characters() == 0 && at_start_ == UNKNOWN; } @@ -1313,7 +1314,7 @@ class Trace { // These set methods and AdvanceCurrentPositionInTrace should be used only on // new traces - the intention is that traces are immutable after creation. void add_action(DeferredAction* new_action) { - ASSERT(new_action->next_ == NULL); + ASSERT(new_action->next_ == nullptr); new_action->next_ = actions_; actions_ = new_action; } @@ -1404,7 +1405,7 @@ class NodeVisitor : public ValueObject { class Analysis : public NodeVisitor { public: explicit Analysis(bool is_one_byte) - : is_one_byte_(is_one_byte), error_message_(NULL) {} + : is_one_byte_(is_one_byte), error_message_(nullptr) {} void EnsureAnalyzed(RegExpNode* node); #define DECLARE_VISIT(Type) virtual void Visit##Type(Type##Node* that); @@ -1412,9 +1413,9 @@ class Analysis : public NodeVisitor { #undef DECLARE_VISIT virtual void VisitLoopChoice(LoopChoiceNode* that); - bool has_failed() { return error_message_ != NULL; } + bool has_failed() { return error_message_ != nullptr; } const char* error_message() { - ASSERT(error_message_ != NULL); + ASSERT(error_message_ != nullptr); return error_message_; } void fail(const char* error_message) { error_message_ = error_message; } @@ -1428,8 +1429,8 @@ class Analysis : public NodeVisitor { struct RegExpCompileData : public ZoneAllocated { RegExpCompileData() - : tree(NULL), - node(NULL), + : tree(nullptr), + node(nullptr), simple(true), contains_anchor(false), capture_name_map(Array::Handle(Array::null())), @@ -1450,20 +1451,20 @@ class RegExpEngine : public AllStatic { explicit CompilationResult(const char* error_message) : error_message(error_message), #if !defined(DART_PRECOMPILED_RUNTIME) - backtrack_goto(NULL), - graph_entry(NULL), + backtrack_goto(nullptr), + graph_entry(nullptr), num_blocks(-1), num_stack_locals(-1), #endif - bytecode(NULL), + bytecode(nullptr), num_registers(-1) { } CompilationResult(TypedData* bytecode, intptr_t num_registers) - : error_message(NULL), + : error_message(nullptr), #if !defined(DART_PRECOMPILED_RUNTIME) - backtrack_goto(NULL), - graph_entry(NULL), + backtrack_goto(nullptr), + graph_entry(nullptr), num_blocks(-1), num_stack_locals(-1), #endif @@ -1477,12 +1478,12 @@ class RegExpEngine : public AllStatic { intptr_t num_blocks, intptr_t num_stack_locals, intptr_t num_registers) - : error_message(NULL), + : error_message(nullptr), backtrack_goto(backtrack_goto), graph_entry(graph_entry), num_blocks(num_blocks), num_stack_locals(num_stack_locals), - bytecode(NULL) {} + bytecode(nullptr) {} #endif const char* error_message; diff --git a/runtime/vm/regexp_assembler.h b/runtime/vm/regexp_assembler.h index d858c485323..0f5d42805d2 100644 --- a/runtime/vm/regexp_assembler.h +++ b/runtime/vm/regexp_assembler.h @@ -149,7 +149,7 @@ class RegExpMacroAssembler : public ZoneAllocated { BlockLabel* on_no_match) = 0; // Check the current character for a match with a literal character. If we // fail to match then goto the on_failure label. End of input always - // matches. If the label is NULL then we should pop a backtrack address off + // matches. If the label is null then we should pop a backtrack address off // the stack and go to that. virtual void CheckNotCharacter(unsigned c, BlockLabel* on_not_equal) = 0; virtual void CheckNotCharacterAfterAnd(unsigned c, @@ -191,12 +191,12 @@ class RegExpMacroAssembler : public ZoneAllocated { } virtual void Fail() = 0; // Check whether a register is >= a given constant and go to a label if it - // is. Backtracks instead if the label is NULL. + // is. Backtracks instead if the label is nullptr. virtual void IfRegisterGE(intptr_t reg, intptr_t comparand, BlockLabel* if_ge) = 0; // Check whether a register is < a given constant and go to a label if it is. - // Backtracks instead if the label is NULL. + // Backtracks instead if the label is nullptr. virtual void IfRegisterLT(intptr_t reg, intptr_t comparand, BlockLabel* if_lt) = 0; diff --git a/runtime/vm/regexp_assembler_bytecode.cc b/runtime/vm/regexp_assembler_bytecode.cc index dd8bd53dd4c..863227ee50e 100644 --- a/runtime/vm/regexp_assembler_bytecode.cc +++ b/runtime/vm/regexp_assembler_bytecode.cc @@ -48,7 +48,7 @@ void BytecodeRegExpMacroAssembler::BindBlock(BlockLabel* l) { } void BytecodeRegExpMacroAssembler::EmitOrLink(BlockLabel* l) { - if (l == NULL) l = &backtrack_; + if (l == nullptr) l = &backtrack_; if (l->is_bound()) { Emit32(l->pos()); } else { @@ -455,7 +455,7 @@ static intptr_t Prepare(const RegExp& regexp, if (result.error_message != nullptr) { Exceptions::ThrowUnsupportedError(result.error_message); } - ASSERT(result.bytecode != NULL); + ASSERT(result.bytecode != nullptr); ASSERT(regexp.num_registers(is_one_byte) == -1 || regexp.num_registers(is_one_byte) == result.num_registers); regexp.set_num_registers(is_one_byte, result.num_registers); diff --git a/runtime/vm/regexp_assembler_bytecode.h b/runtime/vm/regexp_assembler_bytecode.h index 6bb8f94b983..c99faa7b4e5 100644 --- a/runtime/vm/regexp_assembler_bytecode.h +++ b/runtime/vm/regexp_assembler_bytecode.h @@ -17,11 +17,11 @@ class BytecodeRegExpMacroAssembler : public RegExpMacroAssembler { // relocation information starting from the end of the buffer. See CodeDesc // for a detailed comment on the layout (globals.h). // - // If the provided buffer is NULL, the assembler allocates and grows its own + // If the provided buffer is null, the assembler allocates and grows its own // buffer, and buffer_size determines the initial buffer size. The buffer is // owned by the assembler and deallocated upon destruction of the assembler. // - // If the provided buffer is not NULL, the assembler uses the provided buffer + // If the provided buffer is not null, the assembler uses the provided buffer // for code generation and assumes its size to be buffer_size. If the buffer // is too small, a fatal error occurs. No deallocation of the buffer is done // upon destruction of the assembler. diff --git a/runtime/vm/regexp_assembler_ir.cc b/runtime/vm/regexp_assembler_ir.cc index 56ef339974a..cb45f027bbc 100644 --- a/runtime/vm/regexp_assembler_ir.cc +++ b/runtime/vm/regexp_assembler_ir.cc @@ -75,14 +75,14 @@ IRRegExpMacroAssembler::IRRegExpMacroAssembler( specialization_cid_(specialization_cid), parsed_function_(parsed_function), ic_data_array_(ic_data_array), - current_instruction_(NULL), - stack_(NULL), - stack_pointer_(NULL), - current_character_(NULL), - current_position_(NULL), - string_param_(NULL), - string_param_length_(NULL), - start_index_param_(NULL), + current_instruction_(nullptr), + stack_(nullptr), + stack_pointer_(nullptr), + current_character_(nullptr), + current_position_(nullptr), + string_param_(nullptr), + string_param_length_(nullptr), + start_index_param_(nullptr), registers_count_(0), saved_registers_count_((capture_count + 1) * 2), // B0 is taken by GraphEntry thus block ids must start at 1. @@ -552,7 +552,7 @@ Value* IRRegExpMacroAssembler::BindLoadLocal(const LocalVariable& local) { // to append to a block following a jmp. In such cases, assume that we are doing // the correct thing, but output a warning when tracing. #define HANDLE_DEAD_CODE_EMISSION() \ - if (current_instruction_ == NULL) { \ + if (current_instruction_ == nullptr) { \ if (FLAG_trace_irregexp) { \ OS::PrintErr( \ "WARNING: Attempting to append to a closed assembler. " \ @@ -566,8 +566,8 @@ Value* IRRegExpMacroAssembler::BindLoadLocal(const LocalVariable& local) { void IRRegExpMacroAssembler::AppendInstruction(Instruction* instruction) { HANDLE_DEAD_CODE_EMISSION(); - ASSERT(current_instruction_ != NULL); - ASSERT(current_instruction_->next() == NULL); + ASSERT(current_instruction_ != nullptr); + ASSERT(current_instruction_->next() == nullptr); temp_id_.Dealloc(instruction->InputCount()); @@ -578,17 +578,17 @@ void IRRegExpMacroAssembler::AppendInstruction(Instruction* instruction) { void IRRegExpMacroAssembler::CloseBlockWith(Instruction* instruction) { HANDLE_DEAD_CODE_EMISSION(); - ASSERT(current_instruction_ != NULL); - ASSERT(current_instruction_->next() == NULL); + ASSERT(current_instruction_ != nullptr); + ASSERT(current_instruction_->next() == nullptr); temp_id_.Dealloc(instruction->InputCount()); current_instruction_->LinkTo(instruction); - set_current_instruction(NULL); + set_current_instruction(nullptr); } void IRRegExpMacroAssembler::GoTo(BlockLabel* to) { - if (to == NULL) { + if (to == nullptr) { Backtrack(); } else { to->SetLinked(); @@ -601,10 +601,10 @@ void IRRegExpMacroAssembler::GoTo(BlockLabel* to) { void IRRegExpMacroAssembler::GoTo(JoinEntryInstr* to) { HANDLE_DEAD_CODE_EMISSION(); - ASSERT(current_instruction_ != NULL); - ASSERT(current_instruction_->next() == NULL); + ASSERT(current_instruction_ != nullptr); + ASSERT(current_instruction_->next() == nullptr); current_instruction_->Goto(to); - set_current_instruction(NULL); + set_current_instruction(nullptr); } Value* IRRegExpMacroAssembler::PushLocal(LocalVariable* local) { @@ -669,12 +669,12 @@ void IRRegExpMacroAssembler::Backtrack() { // If there is a current instruction, append a goto to the bound block. void IRRegExpMacroAssembler::BindBlock(BlockLabel* label) { ASSERT(!label->is_bound()); - ASSERT(label->block()->next() == NULL); + ASSERT(label->block()->next() == nullptr); label->BindTo(block_id_.Alloc()); blocks_.Add(label->block()); - if (current_instruction_ != NULL) { + if (current_instruction_ != nullptr) { GoTo(label); } set_current_instruction(label->block()); @@ -780,7 +780,7 @@ void IRRegExpMacroAssembler::CheckGreedyLoop(BlockLabel* on_equal) { // Pop, throwing away the value. Do(PopStack()); - BranchOrBacktrack(NULL, on_equal); + BranchOrBacktrack(nullptr, on_equal); BindBlock(&fallthrough); } @@ -1147,7 +1147,7 @@ void IRRegExpMacroAssembler::CheckCharacterInRange(uint16_t from, BranchOrBacktrack( Comparison(kGT, LoadLocal(current_character_), Uint64Constant(to)), &on_not_in_range); - BranchOrBacktrack(NULL, on_in_range); + BranchOrBacktrack(nullptr, on_in_range); BindBlock(&on_not_in_range); } @@ -1313,7 +1313,7 @@ bool IRRegExpMacroAssembler::CheckSpecialCharacterClass( Uint64Constant(0x2029)), &success); } - BranchOrBacktrack(NULL, on_no_match); + BranchOrBacktrack(nullptr, on_no_match); BindBlock(&success); return true; } @@ -1616,8 +1616,8 @@ void IRRegExpMacroAssembler::CheckPosition(intptr_t cp_offset, void IRRegExpMacroAssembler::BranchOrBacktrack(ComparisonInstr* comparison, BlockLabel* true_successor) { - if (comparison == NULL) { // No condition - if (true_successor == NULL) { + if (comparison == nullptr) { // No condition + if (true_successor == nullptr) { Backtrack(); return; } @@ -1627,11 +1627,11 @@ void IRRegExpMacroAssembler::BranchOrBacktrack(ComparisonInstr* comparison, // If no successor block has been passed in, backtrack. JoinEntryInstr* true_successor_block = backtrack_block_; - if (true_successor != NULL) { + if (true_successor != nullptr) { true_successor->SetLinked(); true_successor_block = true_successor->block(); } - ASSERT(true_successor_block != NULL); + ASSERT(true_successor_block != nullptr); // If the condition is not true, fall through to a new block. BlockLabel fallthrough; diff --git a/runtime/vm/regexp_assembler_ir.h b/runtime/vm/regexp_assembler_ir.h index 7c0811f72cd..b65dba2d06f 100644 --- a/runtime/vm/regexp_assembler_ir.h +++ b/runtime/vm/regexp_assembler_ir.h @@ -44,7 +44,7 @@ class IRRegExpMacroAssembler : public RegExpMacroAssembler { bool sticky, Zone* zone); - virtual bool IsClosed() const { return (current_instruction_ == NULL); } + virtual bool IsClosed() const { return (current_instruction_ == nullptr); } virtual intptr_t stack_limit_slack(); virtual void AdvanceCurrentPosition(intptr_t by); @@ -297,7 +297,7 @@ class IRRegExpMacroAssembler : public RegExpMacroAssembler { inline intptr_t char_size() { return static_cast(mode_); } // Equivalent to a conditional branch to the label, unless the label - // is NULL, in which case it is a conditional Backtrack. + // is nullptr, in which case it is a conditional Backtrack. void BranchOrBacktrack(ComparisonInstr* comparison, BlockLabel* true_successor); @@ -324,7 +324,7 @@ class IRRegExpMacroAssembler : public RegExpMacroAssembler { // bookkeeping. void AppendInstruction(Instruction* instruction); // Similar to AppendInstruction, but closes the current block by - // setting current_instruction_ to NULL. + // setting current_instruction_ to nullptr. void CloseBlockWith(Instruction* instruction); // Appends definition and allocates a temp index for the result. Value* Bind(Definition* definition); diff --git a/runtime/vm/regexp_ast.cc b/runtime/vm/regexp_ast.cc index e096e2b592c..acbc9870e9b 100644 --- a/runtime/vm/regexp_ast.cc +++ b/runtime/vm/regexp_ast.cc @@ -17,8 +17,12 @@ FOR_EACH_REG_EXP_TREE_TYPE(MAKE_ACCEPT) #undef MAKE_ACCEPT #define MAKE_TYPE_CASE(Name) \ - RegExp##Name* RegExpTree::As##Name() { return NULL; } \ - bool RegExpTree::Is##Name() const { return false; } + RegExp##Name* RegExpTree::As##Name() { \ + return nullptr; \ + } \ + bool RegExpTree::Is##Name() const { \ + return false; \ + } FOR_EACH_REG_EXP_TREE_TYPE(MAKE_TYPE_CASE) #undef MAKE_TYPE_CASE @@ -140,7 +144,7 @@ void* RegExpUnparser::VisitDisjunction(RegExpDisjunction* that, void* data) { (*that->alternatives())[i]->Accept(this, data); } OS::PrintErr(")"); - return NULL; + return nullptr; } void* RegExpUnparser::VisitAlternative(RegExpAlternative* that, void* data) { @@ -150,7 +154,7 @@ void* RegExpUnparser::VisitAlternative(RegExpAlternative* that, void* data) { (*that->nodes())[i]->Accept(this, data); } OS::PrintErr(")"); - return NULL; + return nullptr; } void RegExpUnparser::VisitCharacterRange(CharacterRange that) { @@ -170,7 +174,7 @@ void* RegExpUnparser::VisitCharacterClass(RegExpCharacterClass* that, VisitCharacterRange((*that->ranges())[i]); } OS::PrintErr("]"); - return NULL; + return nullptr; } void* RegExpUnparser::VisitAssertion(RegExpAssertion* that, void* data) { @@ -194,7 +198,7 @@ void* RegExpUnparser::VisitAssertion(RegExpAssertion* that, void* data) { OS::PrintErr("@B"); break; } - return NULL; + return nullptr; } void* RegExpUnparser::VisitAtom(RegExpAtom* that, void* data) { @@ -204,7 +208,7 @@ void* RegExpUnparser::VisitAtom(RegExpAtom* that, void* data) { PrintUtf16(chardata->At(i)); } OS::PrintErr("'"); - return NULL; + return nullptr; } void* RegExpUnparser::VisitText(RegExpText* that, void* data) { @@ -218,7 +222,7 @@ void* RegExpUnparser::VisitText(RegExpText* that, void* data) { } OS::PrintErr(")"); } - return NULL; + return nullptr; } void* RegExpUnparser::VisitQuantifier(RegExpQuantifier* that, void* data) { @@ -231,14 +235,14 @@ void* RegExpUnparser::VisitQuantifier(RegExpQuantifier* that, void* data) { OS::PrintErr(that->is_greedy() ? "g " : that->is_possessive() ? "p " : "n "); that->body()->Accept(this, data); OS::PrintErr(")"); - return NULL; + return nullptr; } void* RegExpUnparser::VisitCapture(RegExpCapture* that, void* data) { OS::PrintErr("(^ "); that->body()->Accept(this, data); OS::PrintErr(")"); - return NULL; + return nullptr; } void* RegExpUnparser::VisitLookaround(RegExpLookaround* that, void* data) { @@ -248,22 +252,22 @@ void* RegExpUnparser::VisitLookaround(RegExpLookaround* that, void* data) { (that->is_positive() ? "+ " : "- ")); that->body()->Accept(this, data); OS::PrintErr(")"); - return NULL; + return nullptr; } void* RegExpUnparser::VisitBackReference(RegExpBackReference* that, void*) { OS::PrintErr("(<- %" Pd ")", that->index()); - return NULL; + return nullptr; } void* RegExpUnparser::VisitEmpty(RegExpEmpty*, void*) { OS::PrintErr("%%"); - return NULL; + return nullptr; } void RegExpTree::Print() { RegExpUnparser unparser; - Accept(&unparser, NULL); + Accept(&unparser, nullptr); } RegExpDisjunction::RegExpDisjunction( diff --git a/runtime/vm/regexp_ast.h b/runtime/vm/regexp_ast.h index 6301d4de359..d846998d353 100644 --- a/runtime/vm/regexp_ast.h +++ b/runtime/vm/regexp_ast.h @@ -128,7 +128,7 @@ class RegExpAssertion : public RegExpTree { class CharacterSet : public ValueObject { public: explicit CharacterSet(uint16_t standard_set_type) - : ranges_(NULL), standard_set_type_(standard_set_type) {} + : ranges_(nullptr), standard_set_type_(standard_set_type) {} explicit CharacterSet(ZoneGrowableArray* ranges) : ranges_(ranges), standard_set_type_(0) {} CharacterSet(const CharacterSet& that) diff --git a/runtime/vm/regexp_parser.cc b/runtime/vm/regexp_parser.cc index 4b4d12b77ec..bc0bf7182e3 100644 --- a/runtime/vm/regexp_parser.cc +++ b/runtime/vm/regexp_parser.cc @@ -23,7 +23,7 @@ RegExpBuilder::RegExpBuilder(RegExpFlags flags) : zone_(Thread::Current()->zone()), pending_empty_(false), flags_(flags), - characters_(NULL), + characters_(nullptr), pending_surrogate_(kNoPendingSurrogate), terms_(), text_(), @@ -76,9 +76,9 @@ void RegExpBuilder::FlushPendingSurrogate() { void RegExpBuilder::FlushCharacters() { FlushPendingSurrogate(); pending_empty_ = false; - if (characters_ != NULL) { + if (characters_ != nullptr) { RegExpTree* atom = new (Z) RegExpAtom(characters_, flags_); - characters_ = NULL; + characters_ = nullptr; text_.Add(atom); LAST(ADD_ATOM); } @@ -106,7 +106,7 @@ void RegExpBuilder::AddCharacter(uint16_t c) { if (NeedsDesugaringForIgnoreCase(c)) { AddCharacterClassForDesugaring(c); } else { - if (characters_ == NULL) { + if (characters_ == nullptr) { characters_ = new (Z) ZoneGrowableArray(4); } characters_->Add(c); @@ -266,7 +266,7 @@ bool RegExpBuilder::AddQuantifierToAtom( return true; } RegExpTree* atom; - if (characters_ != NULL) { + if (characters_ != nullptr) { DEBUG_ASSERT(last_added_ == ADD_CHAR); // Last atom was character. @@ -285,7 +285,7 @@ bool RegExpBuilder::AddQuantifierToAtom( tail->Add(char_vector->At(num_chars - 1)); char_vector = tail; } - characters_ = NULL; + characters_ = nullptr; atom = new (Z) RegExpAtom(char_vector, flags_); FlushText(); } else if (text_.length() > 0) { @@ -1957,11 +1957,11 @@ RegExpTree* RegExpParser::ParseCharacterClass(const RegExpBuilder* builder) { void RegExpParser::ParseRegExp(const String& input, RegExpFlags flags, RegExpCompileData* result) { - ASSERT(result != NULL); + ASSERT(result != nullptr); RegExpParser parser(input, &result->error, flags); // Throws an exception if 'input' is not valid. RegExpTree* tree = parser.ParsePattern(); - ASSERT(tree != NULL); + ASSERT(tree != nullptr); ASSERT(result->error.IsNull()); result->tree = tree; intptr_t capture_count = parser.captures_started(); diff --git a/runtime/vm/regexp_parser.h b/runtime/vm/regexp_parser.h index fd456ba5e65..1aed648693b 100644 --- a/runtime/vm/regexp_parser.h +++ b/runtime/vm/regexp_parser.h @@ -171,7 +171,7 @@ class RegExpParser : public ValueObject { capture_name_(capture_name) {} // Parser state of containing expression, if any. RegExpParserState* previous_state() { return previous_state_; } - bool IsSubexpression() { return previous_state_ != NULL; } + bool IsSubexpression() { return previous_state_ != nullptr; } // RegExpBuilder building this regexp's AST. RegExpBuilder* builder() { return builder_; } // Type of regexp being parsed (parenthesized group or entire regexp). diff --git a/runtime/vm/regexp_test.cc b/runtime/vm/regexp_test.cc index 56bd9429cd8..2ebfd80bb37 100644 --- a/runtime/vm/regexp_test.cc +++ b/runtime/vm/regexp_test.cc @@ -72,7 +72,7 @@ ISOLATE_UNIT_TEST_CASE(RegExp_ExternalOneByteString) { uint8_t chars[] = {'a', 'b', 'c', 'b', 'a'}; intptr_t len = ARRAY_SIZE(chars); const String& str = String::Handle(ExternalOneByteString::New( - chars, len, NULL, 0, NoopFinalizer, Heap::kNew)); + chars, len, nullptr, 0, NoopFinalizer, Heap::kNew)); const String& pat = String::Handle(Symbols::New(thread, String::Handle(String::New("bc")))); @@ -94,7 +94,7 @@ ISOLATE_UNIT_TEST_CASE(RegExp_ExternalTwoByteString) { uint16_t chars[] = {'a', 'b', 'c', 'b', 'a'}; intptr_t len = ARRAY_SIZE(chars); const String& str = String::Handle(ExternalTwoByteString::New( - chars, len, NULL, 0, NoopFinalizer, Heap::kNew)); + chars, len, nullptr, 0, NoopFinalizer, Heap::kNew)); const String& pat = String::Handle(Symbols::New(thread, String::Handle(String::New("bc")))); diff --git a/runtime/vm/resolver.cc b/runtime/vm/resolver.cc index 65b20c9e27c..5c1ead983d0 100644 --- a/runtime/vm/resolver.cc +++ b/runtime/vm/resolver.cc @@ -139,7 +139,7 @@ static FunctionPtr ResolveDynamicForReceiverClassWithCustomLookup( } #endif - if (function.IsNull() || !function.AreValidArguments(args_desc, NULL)) { + if (function.IsNull() || !function.AreValidArguments(args_desc, nullptr)) { // Return a null function to signal to the upper levels to dispatch to // "noSuchMethod" function. if (FLAG_trace_resolving) { @@ -228,7 +228,7 @@ FunctionPtr Resolver::ResolveStatic(const Library& library, if (!object.IsNull() && object.IsFunction()) { function ^= object.ptr(); if (!function.AreValidArguments(type_args_len, num_arguments, - argument_names, NULL)) { + argument_names, nullptr)) { if (FLAG_trace_resolving) { String& error_message = String::Handle(); // Obtain more detailed error message. @@ -248,7 +248,7 @@ FunctionPtr Resolver::ResolveStatic(const Library& library, } else { // Lookup class_name in the library's class dictionary to get at // the dart class object. If class_name is not found in the dictionary - // ResolveStatic will return a NULL function object. + // ResolveStatic will return a nullptr function object. const Class& cls = Class::Handle(library.LookupClass(class_name)); if (!cls.IsNull()) { function = ResolveStatic(cls, function_name, type_args_len, num_arguments, @@ -275,7 +275,7 @@ FunctionPtr Resolver::ResolveStatic(const Class& cls, Function::Handle(cls.LookupStaticFunction(function_name)); if (function.IsNull() || !function.AreValidArguments(type_args_len, num_arguments, argument_names, - NULL)) { + nullptr)) { // Return a null function to signal to the upper levels to throw a // resolution error or maybe throw the error right here. if (FLAG_trace_resolving) { diff --git a/runtime/vm/reusable_handles.h b/runtime/vm/reusable_handles.h index 7d4a09e9c64..0c03f20f4dc 100644 --- a/runtime/vm/reusable_handles.h +++ b/runtime/vm/reusable_handles.h @@ -45,7 +45,7 @@ namespace dart { Handle().ptr_ = name::null(); \ } \ name& Handle() const { \ - ASSERT(thread_->name##_handle_ != NULL); \ + ASSERT(thread_->name##_handle_ != nullptr); \ return *thread_->name##_handle_; \ } \ \ @@ -59,9 +59,11 @@ namespace dart { public: \ explicit Reusable##name##HandleScope(Thread* thread = Thread::Current()) \ : handle_(thread->name##_handle_) {} \ - ~Reusable##name##HandleScope() { handle_->ptr_ = name::null(); } \ + ~Reusable##name##HandleScope() { \ + handle_->ptr_ = name::null(); \ + } \ name& Handle() const { \ - ASSERT(handle_ != NULL); \ + ASSERT(handle_ != nullptr); \ return *handle_; \ } \ \ diff --git a/runtime/vm/runtime_entry.cc b/runtime/vm/runtime_entry.cc index 1de3f71c8c4..4ea8364316e 100644 --- a/runtime/vm/runtime_entry.cc +++ b/runtime/vm/runtime_entry.cc @@ -77,15 +77,15 @@ DEFINE_FLAG(int, "Compute debugger stacktrace on every N stack overflow checks"); DEFINE_FLAG(charp, stacktrace_filter, - NULL, + nullptr, "Compute stacktrace in named function on stack overflow checks"); DEFINE_FLAG(charp, deoptimize_filter, - NULL, + nullptr, "Deoptimize in named function on stack overflow checks"); DEFINE_FLAG(charp, deoptimize_on_runtime_call_name_filter, - NULL, + nullptr, "Runtime call name filter for --deoptimize-on-runtime-call-every."); DEFINE_FLAG(bool, @@ -453,7 +453,7 @@ static TokenPosition GetCallerLocation() { DartFrameIterator iterator(Thread::Current(), StackFrameIterator::kNoCrossThreadIteration); StackFrame* caller_frame = iterator.NextFrame(); - ASSERT(caller_frame != NULL); + ASSERT(caller_frame != nullptr); return caller_frame->GetTokenPos(); } @@ -605,7 +605,7 @@ static void PrintSubtypeCheck(const AbstractType& subtype, DartFrameIterator iterator(Thread::Current(), StackFrameIterator::kNoCrossThreadIteration); StackFrame* caller_frame = iterator.NextFrame(); - ASSERT(caller_frame != NULL); + ASSERT(caller_frame != nullptr); LogBlock lb; THR_Print("SubtypeCheck: '%s' %d %s '%s' %d (pc: %#" Px ").\n", @@ -814,7 +814,7 @@ static void PrintTypeCheck(const char* message, DartFrameIterator iterator(Thread::Current(), StackFrameIterator::kNoCrossThreadIteration); StackFrame* caller_frame = iterator.NextFrame(); - ASSERT(caller_frame != NULL); + ASSERT(caller_frame != nullptr); const AbstractType& instance_type = AbstractType::Handle(instance.GetType(Heap::kNew)); @@ -1335,7 +1335,7 @@ DEFINE_RUNTIME_ENTRY(PatchStaticCall, 0) { DartFrameIterator iterator(thread, StackFrameIterator::kNoCrossThreadIteration); StackFrame* caller_frame = iterator.NextFrame(); - ASSERT(caller_frame != NULL); + ASSERT(caller_frame != nullptr); const Code& caller_code = Code::Handle(zone, caller_frame->LookupDartCode()); ASSERT(!caller_code.IsNull()); ASSERT(caller_code.is_optimized()); @@ -1380,7 +1380,7 @@ DEFINE_RUNTIME_ENTRY(BreakpointRuntimeHandler, 0) { DartFrameIterator iterator(thread, StackFrameIterator::kNoCrossThreadIteration); StackFrame* caller_frame = iterator.NextFrame(); - ASSERT(caller_frame != NULL); + ASSERT(caller_frame != nullptr); Code& orig_stub = Code::Handle(zone); orig_stub = isolate->group()->debugger()->GetPatchedStubAddress(caller_frame->pc()); @@ -1627,7 +1627,7 @@ DEFINE_RUNTIME_ENTRY(StaticCallMissHandlerOneArg, 2) { DartFrameIterator iterator(thread, StackFrameIterator::kNoCrossThreadIteration); StackFrame* caller_frame = iterator.NextFrame(); - ASSERT(caller_frame != NULL); + ASSERT(caller_frame != nullptr); OS::PrintErr("StaticCallMissHandler at %#" Px " target %s (%" Pd ")\n", caller_frame->pc(), target.ToCString(), arg.GetClassId()); } @@ -1655,7 +1655,7 @@ DEFINE_RUNTIME_ENTRY(StaticCallMissHandlerTwoArgs, 3) { DartFrameIterator iterator(thread, StackFrameIterator::kNoCrossThreadIteration); StackFrame* caller_frame = iterator.NextFrame(); - ASSERT(caller_frame != NULL); + ASSERT(caller_frame != nullptr); OS::PrintErr("StaticCallMissHandler at %#" Px " target %s (%" Pd ", %" Pd ")\n", caller_frame->pc(), target.ToCString(), cids[0], cids[1]); @@ -2677,14 +2677,14 @@ static ObjectPtr InvokeCallThroughGetterOrNoSuchMethod( function = Resolver::ResolveDynamicFunction(zone, cls, target_name); } if (!function.IsNull()) { - ASSERT(!function.AreValidArguments(args_desc, NULL)); + ASSERT(!function.AreValidArguments(args_desc, nullptr)); break; // mismatch, invoke noSuchMethod } if (is_dynamic_call) { function = Resolver::ResolveDynamicFunction(zone, cls, demangled_target_name); if (!function.IsNull()) { - ASSERT(!function.AreValidArguments(args_desc, NULL)); + ASSERT(!function.AreValidArguments(args_desc, nullptr)); break; // mismatch, invoke noSuchMethod } } @@ -2927,7 +2927,7 @@ static void HandleOSRRequest(Thread* thread) { DartFrameIterator iterator(thread, StackFrameIterator::kNoCrossThreadIteration); StackFrame* frame = iterator.NextFrame(); - ASSERT(frame != NULL); + ASSERT(frame != nullptr); const Code& code = Code::ZoneHandle(frame->LookupDartCode()); ASSERT(!code.IsNull()); ASSERT(!code.is_optimized()); @@ -3009,7 +3009,7 @@ DEFINE_RUNTIME_ENTRY(InterruptOrStackOverflow, 0) { StackFrameIterator::kNoCrossThreadIteration); uword fp = stack_pos; StackFrame* frame = frames.NextFrame(); - while (frame != NULL) { + while (frame != nullptr) { uword delta = (frame->fp() - fp); fp = frame->fp(); OS::PrintErr("%4" Pd " %s\n", delta, frame->ToCString()); @@ -3050,7 +3050,7 @@ DEFINE_RUNTIME_ENTRY(TraceICCall, 2) { DartFrameIterator iterator(thread, StackFrameIterator::kNoCrossThreadIteration); StackFrame* frame = iterator.NextFrame(); - ASSERT(frame != NULL); + ASSERT(frame != nullptr); OS::PrintErr( "IC call @%#" Px ": ICData: %#" Px " cnt:%" Pd " nchecks: %" Pd " %s\n", frame->pc(), static_cast(ic_data.ptr()), function.usage_counter(), @@ -3107,10 +3107,10 @@ DEFINE_RUNTIME_ENTRY(FixCallersTarget, 0) { StackFrameIterator iterator(ValidationPolicy::kDontValidateFrames, thread, StackFrameIterator::kNoCrossThreadIteration); StackFrame* frame = iterator.NextFrame(); - ASSERT(frame != NULL); + ASSERT(frame != nullptr); while (frame->IsStubFrame() || frame->IsExitFrame()) { frame = iterator.NextFrame(); - ASSERT(frame != NULL); + ASSERT(frame != nullptr); } if (frame->IsEntryFrame()) { // Since function's current code is always unpatched, the entry frame always @@ -3175,10 +3175,10 @@ DEFINE_RUNTIME_ENTRY(FixAllocationStubTarget, 0) { StackFrameIterator iterator(ValidationPolicy::kDontValidateFrames, thread, StackFrameIterator::kNoCrossThreadIteration); StackFrame* frame = iterator.NextFrame(); - ASSERT(frame != NULL); + ASSERT(frame != nullptr); while (frame->IsStubFrame() || frame->IsExitFrame()) { frame = iterator.NextFrame(); - ASSERT(frame != NULL); + ASSERT(frame != nullptr); } if (frame->IsEntryFrame()) { // There must be a valid Dart frame. @@ -3364,7 +3364,7 @@ static void CopySavedRegisters(uword saved_registers_address, ASSERT(sizeof(fpu_register_t) == kFpuRegisterSize); fpu_register_t* fpu_registers_copy = new fpu_register_t[kNumberOfSavedFpuRegisters]; - ASSERT(fpu_registers_copy != NULL); + ASSERT(fpu_registers_copy != nullptr); for (intptr_t i = 0; i < kNumberOfSavedFpuRegisters; i++) { fpu_registers_copy[i] = *reinterpret_cast(saved_registers_address); @@ -3374,7 +3374,7 @@ static void CopySavedRegisters(uword saved_registers_address, ASSERT(sizeof(intptr_t) == kWordSize); intptr_t* cpu_registers_copy = new intptr_t[kNumberOfSavedCpuRegisters]; - ASSERT(cpu_registers_copy != NULL); + ASSERT(cpu_registers_copy != nullptr); for (intptr_t i = 0; i < kNumberOfSavedCpuRegisters; i++) { cpu_registers_copy[i] = *reinterpret_cast(saved_registers_address); @@ -3422,7 +3422,7 @@ DEFINE_LEAF_RUNTIME_ENTRY(intptr_t, StackFrameIterator::kNoCrossThreadIteration); StackFrame* caller_frame = iterator.NextFrame(); - ASSERT(caller_frame != NULL); + ASSERT(caller_frame != nullptr); const Code& optimized_code = Code::Handle(caller_frame->LookupDartCode()); ASSERT(optimized_code.is_optimized()); const Function& top_function = @@ -3486,7 +3486,7 @@ DEFINE_LEAF_RUNTIME_ENTRY(void, DeoptimizeFillFrame, 1, uword last_fp) { DartFrameIterator iterator(last_fp, thread, StackFrameIterator::kNoCrossThreadIteration); StackFrame* caller_frame = iterator.NextFrame(); - ASSERT(caller_frame != NULL); + ASSERT(caller_frame != nullptr); #if defined(DEBUG) { @@ -3531,7 +3531,7 @@ DEFINE_RUNTIME_ENTRY(DeoptimizeMaterialize, 0) { #endif DeoptContext* deopt_context = isolate->deopt_context(); intptr_t deopt_arg_count = deopt_context->MaterializeDeferredObjects(); - isolate->set_deopt_context(NULL); + isolate->set_deopt_context(nullptr); delete deopt_context; // Return value tells deoptimization stub to remove the given number of bytes diff --git a/runtime/vm/scopes.cc b/runtime/vm/scopes.cc index b826a34115b..29e3f4d34b5 100644 --- a/runtime/vm/scopes.cc +++ b/runtime/vm/scopes.cc @@ -23,8 +23,8 @@ DEFINE_FLAG(bool, LocalScope::LocalScope(LocalScope* parent, int function_level, int loop_level) : parent_(parent), - child_(NULL), - sibling_(NULL), + child_(nullptr), + sibling_(nullptr), function_level_(function_level), loop_level_(loop_level), context_level_(LocalScope::kUninitializedContextLevel), @@ -32,12 +32,12 @@ LocalScope::LocalScope(LocalScope* parent, int function_level, int loop_level) end_token_pos_(TokenPosition::kNoSource), variables_(), context_variables_(), - context_slots_(new (Thread::Current()->zone()) + context_slots_(new(Thread::Current()->zone()) ZoneGrowableArray()) { // Hook this node into the children of the parent, unless the parent has a // different function_level, since the local scope of a nested function can // be discarded after it has been parsed. - if ((parent != NULL) && (parent->function_level() == function_level)) { + if ((parent != nullptr) && (parent->function_level() == function_level)) { sibling_ = parent->child_; parent->child_ = this; } @@ -45,7 +45,7 @@ LocalScope::LocalScope(LocalScope* parent, int function_level, int loop_level) bool LocalScope::IsNestedWithin(LocalScope* scope) const { const LocalScope* current_scope = this; - while (current_scope != NULL) { + while (current_scope != nullptr) { if (current_scope == scope) { return true; } @@ -55,13 +55,13 @@ bool LocalScope::IsNestedWithin(LocalScope* scope) const { } bool LocalScope::AddVariable(LocalVariable* variable) { - ASSERT(variable != NULL); + ASSERT(variable != nullptr); if (LocalLookupVariable(variable->name(), variable->kernel_offset()) != nullptr) { return false; } variables_.Add(variable); - if (variable->owner() == NULL) { + if (variable->owner() == nullptr) { // Variables must be added to their owner scope first. Subsequent calls // to 'add' treat the variable as an alias. variable->set_owner(this); @@ -70,14 +70,14 @@ bool LocalScope::AddVariable(LocalVariable* variable) { } bool LocalScope::InsertParameterAt(intptr_t pos, LocalVariable* parameter) { - ASSERT(parameter != NULL); + ASSERT(parameter != nullptr); if (LocalLookupVariable(parameter->name(), parameter->kernel_offset()) != nullptr) { return false; } variables_.InsertAt(pos, parameter); // InsertParameterAt is not used to add aliases of parameters. - ASSERT(parameter->owner() == NULL); + ASSERT(parameter->owner() == nullptr); parameter->set_owner(this); return true; } @@ -89,7 +89,7 @@ void LocalScope::AllocateContextVariable(LocalVariable* variable, // The context level in the owner scope of a captured variable indicates at // code generation time how far to walk up the context chain in order to // access the variable from the current context level. - if ((*context_owner) == NULL) { + if ((*context_owner) == nullptr) { ASSERT(num_context_variables() == 0); // This scope becomes the current context owner. set_context_level(1); @@ -241,7 +241,7 @@ VariableIndex LocalScope::AllocateVariables(const Function& function, // Allocate variables of all children. VariableIndex min_index = next_index; LocalScope* child = this->child(); - while (child != NULL) { + while (child != nullptr) { // Ignored, since no parameters. const VariableIndex dummy_parameter_index(0); @@ -333,7 +333,7 @@ void LocalScope::CollectLocalVariables(LocalVarDescriptorsBuilder* vars, desc.name = &var->name(); if (var->is_captured()) { desc.info.set_kind(UntaggedLocalVarDescriptors::kContextVar); - ASSERT(var->owner() != NULL); + ASSERT(var->owner() != nullptr); ASSERT(var->owner()->context_level() >= 0); desc.info.scope_id = var->owner()->context_level(); } else { @@ -349,7 +349,7 @@ void LocalScope::CollectLocalVariables(LocalVarDescriptorsBuilder* vars, } } LocalScope* child = this->child(); - while (child != NULL) { + while (child != nullptr) { child->CollectLocalVariables(vars, scope_id); child = child->sibling(); } @@ -366,18 +366,18 @@ LocalVariable* LocalScope::LocalLookupVariable(const String& name, return var; } } - return NULL; + return nullptr; } LocalVariable* LocalScope::LookupVariable(const String& name, intptr_t kernel_offset, bool test_only) { LocalScope* current_scope = this; - while (current_scope != NULL) { + while (current_scope != nullptr) { LocalVariable* var = current_scope->LocalLookupVariable(name, kernel_offset); // If testing only, return the variable even if invisible. - if ((var != NULL) && (!var->is_invisible_ || test_only)) { + if ((var != nullptr) && (!var->is_invisible_ || test_only)) { if (!test_only && (var->owner()->function_level() != function_level())) { CaptureVariable(var); } @@ -385,7 +385,7 @@ LocalVariable* LocalScope::LookupVariable(const String& name, } current_scope = current_scope->parent(); } - return NULL; + return nullptr; } LocalVariable* LocalScope::LookupVariableByName(const String& name) { @@ -403,7 +403,7 @@ LocalVariable* LocalScope::LookupVariableByName(const String& name) { } void LocalScope::CaptureVariable(LocalVariable* variable) { - ASSERT(variable != NULL); + ASSERT(variable != nullptr); // The variable must exist in an enclosing scope, not necessarily in this one. variable->set_is_captured(); @@ -413,7 +413,7 @@ void LocalScope::CaptureVariable(LocalVariable* variable) { // Insert an alias of the variable in the top scope of each function // level so that the variable is found in the context. LocalScope* parent_scope = scope->parent(); - while ((parent_scope != NULL) && + while ((parent_scope != nullptr) && (parent_scope->function_level() == scope->function_level())) { scope = parent_scope; parent_scope = scope->parent(); @@ -508,7 +508,7 @@ ContextScopePtr LocalScope::PreserveOuterScope( LocalScope* LocalScope::RestoreOuterScope(const ContextScope& context_scope) { // The function level of the outer scope is one less than the function level // of the current function, which is 0. - LocalScope* outer_scope = new LocalScope(NULL, -1, 0); + LocalScope* outer_scope = new LocalScope(nullptr, -1, 0); // Add all variables as aliases to the outer scope. for (int i = 0; i < context_scope.num_variables(); i++) { LocalVariable* variable; @@ -543,7 +543,7 @@ LocalScope* LocalScope::RestoreOuterScope(const ContextScope& context_scope) { // Create a fake owner scope describing the index and context level of the // variable. Function level and loop level are unused (set to 0), since // context level has already been assigned. - LocalScope* owner_scope = new LocalScope(NULL, 0, 0); + LocalScope* owner_scope = new LocalScope(nullptr, 0, 0); owner_scope->set_context_level(context_scope.ContextLevelAt(i)); owner_scope->AddVariable(variable); outer_scope->AddVariable(variable); // As alias. diff --git a/runtime/vm/scopes.h b/runtime/vm/scopes.h index 46afd1fda49..afebc62b6ba 100644 --- a/runtime/vm/scopes.h +++ b/runtime/vm/scopes.h @@ -85,11 +85,11 @@ class LocalVariable : public ZoneAllocated { token_pos_(token_pos), name_(name), kernel_offset_(kernel_offset), - owner_(NULL), + owner_(nullptr), type_(type), parameter_type_(parameter_type), parameter_value_(parameter_value), - const_value_(NULL), + const_value_(nullptr), is_final_(false), is_captured_(false), is_invisible_(false), @@ -115,7 +115,7 @@ class LocalVariable : public ZoneAllocated { intptr_t kernel_offset() const { return kernel_offset_; } LocalScope* owner() const { return owner_; } void set_owner(LocalScope* owner) { - ASSERT(owner_ == NULL); + ASSERT(owner_ == nullptr); owner_ = owner; } @@ -201,7 +201,7 @@ class LocalVariable : public ZoneAllocated { bool is_captured_parameter() const { return is_captured_parameter_; } void set_is_captured_parameter(bool value) { is_captured_parameter_ = value; } - bool IsConst() const { return const_value_ != NULL; } + bool IsConst() const { return const_value_ != nullptr; } void SetConstValue(const Instance& value) { DEBUG_ASSERT(value.IsNotTemporaryScopedHandle()); @@ -234,10 +234,10 @@ class LocalVariable : public ZoneAllocated { const AbstractType& type_; // Declaration type of local variable. - CompileType* const parameter_type_; // NULL or incoming parameter type. - const Object* parameter_value_; // NULL or incoming parameter value. + CompileType* const parameter_type_; // nullptr or incoming parameter type. + const Object* parameter_value_; // nullptr or incoming parameter value. - const Instance* const_value_; // NULL or compile-time const value. + const Instance* const_value_; // nullptr or compile-time const value. bool is_final_; // If true, this variable is readonly. bool is_captured_; // If true, this variable lives in the context, otherwise diff --git a/runtime/vm/scopes_test.cc b/runtime/vm/scopes_test.cc index 03b5b62f6f8..2d78ae0b55c 100644 --- a/runtime/vm/scopes_test.cc +++ b/runtime/vm/scopes_test.cc @@ -23,17 +23,17 @@ ISOLATE_UNIT_TEST_CASE(LocalScope) { LocalVariable* var_c = new LocalVariable( TokenPosition::kNoSource, TokenPosition::kNoSource, c, dynamic_type); - LocalScope* outer_scope = new LocalScope(NULL, 0, 0); + LocalScope* outer_scope = new LocalScope(nullptr, 0, 0); LocalScope* inner_scope1 = new LocalScope(outer_scope, 0, 0); LocalScope* inner_scope2 = new LocalScope(outer_scope, 0, 0); - EXPECT(outer_scope->parent() == NULL); + EXPECT(outer_scope->parent() == nullptr); EXPECT_EQ(outer_scope, inner_scope1->parent()); EXPECT_EQ(outer_scope, inner_scope2->parent()); EXPECT_EQ(inner_scope2, outer_scope->child()); EXPECT_EQ(inner_scope1, inner_scope2->sibling()); - EXPECT(inner_scope1->child() == NULL); - EXPECT(inner_scope2->child() == NULL); + EXPECT(inner_scope1->child() == nullptr); + EXPECT(inner_scope2->child() == nullptr); // Populate the local scopes as follows: // { // outer_scope @@ -56,9 +56,9 @@ ISOLATE_UNIT_TEST_CASE(LocalScope) { EXPECT_EQ(var_a, inner_scope1->LookupVariable( a, LocalVariable::kNoKernelOffset, true)); EXPECT(outer_scope->LocalLookupVariable(b, LocalVariable::kNoKernelOffset) == - NULL); + nullptr); EXPECT(inner_scope1->LocalLookupVariable(c, LocalVariable::kNoKernelOffset) == - NULL); + nullptr); // Modify the local scopes to contain shadowing: // { // outer_scope @@ -91,7 +91,7 @@ ISOLATE_UNIT_TEST_CASE(LocalScope) { // } // } EXPECT(inner_scope2->LocalLookupVariable(a, LocalVariable::kNoKernelOffset) == - NULL); + nullptr); EXPECT(inner_scope2->AddVariable(var_a)); EXPECT_EQ(var_a, inner_scope2->LocalLookupVariable( a, LocalVariable::kNoKernelOffset)); diff --git a/runtime/vm/service.cc b/runtime/vm/service.cc index 21701173300..4aeda83eafa 100644 --- a/runtime/vm/service.cc +++ b/runtime/vm/service.cc @@ -165,7 +165,7 @@ class NoSuchParameter : public MethodParameter { public: explicit NoSuchParameter(const char* name) : MethodParameter(name, false) {} - virtual bool Validate(const char* value) const { return (value == NULL); } + virtual bool Validate(const char* value) const { return (value == nullptr); } virtual bool ValidateObject(const Object& value) const { return value.IsNull(); @@ -197,10 +197,10 @@ class EnumListParameter : public MethodParameter { } intptr_t element_pos = 0; - // Allocate our element array. +1 for NULL terminator. + // Allocate our element array. +1 for nullptr terminator. // The caller is responsible for deleting this memory. char** elements = new char*[element_count + 1]; - elements[element_count] = NULL; + elements[element_count] = nullptr; // Parse the string destructively. Build the list of elements. while (element_pos < element_count) { @@ -228,7 +228,7 @@ class EnumListParameter : public MethodParameter { // Returns number of elements in the list. -1 on parse error. intptr_t ElementCount(const char* value) const { const char* kJsonWhitespaceChars = " \t\r\n"; - if (value == NULL) { + if (value == nullptr) { return -1; } const char* cp = value; @@ -271,8 +271,8 @@ class EnumListParameter : public MethodParameter { return -1; } intptr_t id_len = cp - id_start; - if (enums_ != NULL) { - for (intptr_t i = 0; enums_[i] != NULL; i++) { + if (enums_ != nullptr) { + for (intptr_t i = 0; enums_[i] != nullptr; i++) { intptr_t len = strlen(enums_[i]); if (len == id_len && strncmp(id_start, enums_[i], len) == 0) { element_count++; @@ -299,20 +299,20 @@ static const char* const timeline_streams_enum_names[] = { #define DEFINE_NAME(name, ...) #name, TIMELINE_STREAM_LIST(DEFINE_NAME) #undef DEFINE_NAME - NULL}; + nullptr}; static const MethodParameter* const set_vm_timeline_flags_params[] = { NO_ISOLATE_PARAMETER, new EnumListParameter("recordedStreams", false, timeline_streams_enum_names), - NULL, + nullptr, }; static bool HasStream(const char** recorded_streams, const char* stream) { - while (*recorded_streams != NULL) { - if ((strstr(*recorded_streams, "all") != NULL) || - (strstr(*recorded_streams, stream) != NULL)) { + while (*recorded_streams != nullptr) { + if ((strstr(*recorded_streams, "all") != nullptr) || + (strstr(*recorded_streams, stream) != nullptr)) { return true; } recorded_streams++; @@ -349,10 +349,10 @@ bool Service::EnableTimelineStreams(char* categories_list) { #ifndef PRODUCT // The name of this of this vm as reported by the VM service protocol. -static char* vm_name = NULL; +static char* vm_name = nullptr; static const char* GetVMName() { - if (vm_name == NULL) { + if (vm_name == nullptr) { return FLAG_vm_name; } return vm_name; @@ -363,7 +363,7 @@ ServiceIdZone::ServiceIdZone() {} ServiceIdZone::~ServiceIdZone() {} RingServiceIdZone::RingServiceIdZone() - : ring_(NULL), policy_(ObjectIdRing::kAllocateId) {} + : ring_(nullptr), policy_(ObjectIdRing::kAllocateId) {} RingServiceIdZone::~RingServiceIdZone() {} @@ -374,25 +374,26 @@ void RingServiceIdZone::Init(ObjectIdRing* ring, } char* RingServiceIdZone::GetServiceId(const Object& obj) { - ASSERT(ring_ != NULL); + ASSERT(ring_ != nullptr); Thread* thread = Thread::Current(); Zone* zone = thread->zone(); - ASSERT(zone != NULL); + ASSERT(zone != nullptr); const intptr_t id = ring_->GetIdForObject(obj.ptr(), policy_); return zone->PrintToString("objects/%" Pd "", id); } // TODO(johnmccutchan): Unify embedder service handler lists and their APIs. -EmbedderServiceHandler* Service::isolate_service_handler_head_ = NULL; -EmbedderServiceHandler* Service::root_service_handler_head_ = NULL; +EmbedderServiceHandler* Service::isolate_service_handler_head_ = nullptr; +EmbedderServiceHandler* Service::root_service_handler_head_ = nullptr; struct ServiceMethodDescriptor; const ServiceMethodDescriptor* FindMethod(const char* method_name); // Support for streams defined in embedders. -Dart_ServiceStreamListenCallback Service::stream_listen_callback_ = NULL; -Dart_ServiceStreamCancelCallback Service::stream_cancel_callback_ = NULL; -Dart_GetVMServiceAssetsArchive Service::get_service_assets_callback_ = NULL; -Dart_EmbedderInformationCallback Service::embedder_information_callback_ = NULL; +Dart_ServiceStreamListenCallback Service::stream_listen_callback_ = nullptr; +Dart_ServiceStreamCancelCallback Service::stream_cancel_callback_ = nullptr; +Dart_GetVMServiceAssetsArchive Service::get_service_assets_callback_ = nullptr; +Dart_EmbedderInformationCallback Service::embedder_information_callback_ = + nullptr; // These are the set of streams known to the core VM. StreamInfo Service::vm_stream("VM"); @@ -406,7 +407,7 @@ StreamInfo Service::extension_stream("Extension"); StreamInfo Service::timeline_stream("Timeline"); StreamInfo Service::profiler_stream("Profiler"); -const uint8_t* Service::dart_library_kernel_ = NULL; +const uint8_t* Service::dart_library_kernel_ = nullptr; intptr_t Service::dart_library_kernel_len_ = 0; // Keep streams_ in sync with the protected streams in @@ -466,7 +467,7 @@ ObjectPtr Service::RequestAssets() { Dart_Handle handle; { TransitionVMToNative transition(T); - if (get_service_assets_callback_ == NULL) { + if (get_service_assets_callback_ == nullptr) { return Object::null(); } handle = get_service_assets_callback_(); @@ -509,7 +510,7 @@ static bool CheckDebuggerDisabled(Thread* thread, JSONStream* js) { js->PrintError(kFeatureDisabled, "Debugger is disabled in AOT mode."); return true; #else - if (thread->isolate()->debugger() == NULL) { + if (thread->isolate()->debugger() == nullptr) { js->PrintError(kFeatureDisabled, "Debugger is disabled."); return true; } @@ -535,16 +536,16 @@ static bool CheckProfilerDisabled(Thread* thread, JSONStream* js) { } static bool GetIntegerId(const char* s, intptr_t* id, int base = 10) { - if ((s == NULL) || (*s == '\0')) { + if ((s == nullptr) || (*s == '\0')) { // Empty string. return false; } - if (id == NULL) { + if (id == nullptr) { // No id pointer. return false; } intptr_t r = 0; - char* end_ptr = NULL; + char* end_ptr = nullptr; #if defined(ARCH_IS_32_BIT) r = strtol(s, &end_ptr, base); #else @@ -559,16 +560,16 @@ static bool GetIntegerId(const char* s, intptr_t* id, int base = 10) { } static bool GetUnsignedIntegerId(const char* s, uintptr_t* id, int base = 10) { - if ((s == NULL) || (*s == '\0')) { + if ((s == nullptr) || (*s == '\0')) { // Empty string. return false; } - if (id == NULL) { + if (id == nullptr) { // No id pointer. return false; } uintptr_t r = 0; - char* end_ptr = NULL; + char* end_ptr = nullptr; #if defined(ARCH_IS_32_BIT) r = strtoul(s, &end_ptr, base); #else @@ -583,16 +584,16 @@ static bool GetUnsignedIntegerId(const char* s, uintptr_t* id, int base = 10) { } static bool GetInteger64Id(const char* s, int64_t* id, int base = 10) { - if ((s == NULL) || (*s == '\0')) { + if ((s == nullptr) || (*s == '\0')) { // Empty string. return false; } - if (id == NULL) { + if (id == nullptr) { // No id pointer. return false; } int64_t r = 0; - char* end_ptr = NULL; + char* end_ptr = nullptr; r = strtoll(s, &end_ptr, base); if (end_ptr == s) { // String was not advanced at all, cannot be valid. @@ -603,11 +604,11 @@ static bool GetInteger64Id(const char* s, int64_t* id, int base = 10) { } // Scans the string until the '-' character. Returns pointer to string -// at '-' character. Returns NULL if not found. +// at '-' character. Returns nullptr if not found. static const char* ScanUntilDash(const char* s) { - if ((s == NULL) || (*s == '\0')) { + if ((s == nullptr) || (*s == '\0')) { // Empty string. - return NULL; + return nullptr; } while (*s != '\0') { if (*s == '-') { @@ -615,15 +616,15 @@ static const char* ScanUntilDash(const char* s) { } s++; } - return NULL; + return nullptr; } static bool GetCodeId(const char* s, int64_t* timestamp, uword* address) { - if ((s == NULL) || (*s == '\0')) { + if ((s == nullptr) || (*s == '\0')) { // Empty string. return false; } - if ((timestamp == NULL) || (address == NULL)) { + if ((timestamp == nullptr) || (address == nullptr)) { // Bad arguments. return false; } @@ -632,7 +633,7 @@ static bool GetCodeId(const char* s, int64_t* timestamp, uword* address) { return false; } s = ScanUntilDash(s); - if (s == NULL) { + if (s == nullptr) { return false; } // Skip the dash. @@ -649,10 +650,10 @@ static bool GetCodeId(const char* s, int64_t* timestamp, uword* address) { static bool GetPrefixedIntegerId(const char* s, const char* prefix, intptr_t* service_id) { - if (s == NULL) { + if (s == nullptr) { return false; } - ASSERT(prefix != NULL); + ASSERT(prefix != nullptr); const intptr_t kInputLen = strlen(s); const intptr_t kPrefixLen = strlen(prefix); ASSERT(kPrefixLen > 0); @@ -669,17 +670,17 @@ static bool GetPrefixedIntegerId(const char* s, } static bool IsValidClassId(Isolate* isolate, intptr_t cid) { - ASSERT(isolate != NULL); + ASSERT(isolate != nullptr); ClassTable* class_table = isolate->group()->class_table(); - ASSERT(class_table != NULL); + ASSERT(class_table != nullptr); return class_table->IsValidIndex(cid) && class_table->HasValidClassAt(cid); } static ClassPtr GetClassForId(Isolate* isolate, intptr_t cid) { ASSERT(isolate == Isolate::Current()); - ASSERT(isolate != NULL); + ASSERT(isolate != nullptr); ClassTable* class_table = isolate->group()->class_table(); - ASSERT(class_table != NULL); + ASSERT(class_table != nullptr); return class_table->At(cid); } @@ -709,14 +710,14 @@ class BoolParameter : public MethodParameter { : MethodParameter(name, required) {} virtual bool Validate(const char* value) const { - if (value == NULL) { + if (value == nullptr) { return false; } return (strcmp("true", value) == 0) || (strcmp("false", value) == 0); } static bool Parse(const char* value, bool default_value = false) { - if (value == NULL) { + if (value == nullptr) { return default_value; } return strcmp("true", value) == 0; @@ -729,7 +730,7 @@ class UIntParameter : public MethodParameter { : MethodParameter(name, required) {} virtual bool Validate(const char* value) const { - if (value == NULL) { + if (value == nullptr) { return false; } for (const char* cp = value; *cp != '\0'; cp++) { @@ -741,10 +742,10 @@ class UIntParameter : public MethodParameter { } static uintptr_t Parse(const char* value) { - if (value == NULL) { + if (value == nullptr) { return -1; } - char* end_ptr = NULL; + char* end_ptr = nullptr; uintptr_t result = strtoul(value, &end_ptr, 10); ASSERT(*end_ptr == '\0'); // Parsed full string return result; @@ -757,7 +758,7 @@ class Int64Parameter : public MethodParameter { : MethodParameter(name, required) {} virtual bool Validate(const char* value) const { - if (value == NULL) { + if (value == nullptr) { return false; } for (const char* cp = value; *cp != '\0'; cp++) { @@ -769,10 +770,10 @@ class Int64Parameter : public MethodParameter { } static int64_t Parse(const char* value, int64_t default_value = -1) { - if ((value == NULL) || (*value == '\0')) { + if ((value == nullptr) || (*value == '\0')) { return default_value; } - char* end_ptr = NULL; + char* end_ptr = nullptr; int64_t result = strtoll(value, &end_ptr, 10); ASSERT(*end_ptr == '\0'); // Parsed full string return result; @@ -785,7 +786,7 @@ class UInt64Parameter : public MethodParameter { : MethodParameter(name, required) {} virtual bool Validate(const char* value) const { - if (value == NULL) { + if (value == nullptr) { return false; } for (const char* cp = value; *cp != '\0'; cp++) { @@ -797,10 +798,10 @@ class UInt64Parameter : public MethodParameter { } static uint64_t Parse(const char* value, uint64_t default_value = 0) { - if ((value == NULL) || (*value == '\0')) { + if ((value == nullptr) || (*value == '\0')) { return default_value; } - char* end_ptr = NULL; + char* end_ptr = nullptr; uint64_t result = strtoull(value, &end_ptr, 10); ASSERT(*end_ptr == '\0'); // Parsed full string return result; @@ -812,7 +813,7 @@ class IdParameter : public MethodParameter { IdParameter(const char* name, bool required) : MethodParameter(name, required) {} - virtual bool Validate(const char* value) const { return (value != NULL); } + virtual bool Validate(const char* value) const { return (value != nullptr); } }; class StringParameter : public MethodParameter { @@ -820,7 +821,7 @@ class StringParameter : public MethodParameter { StringParameter(const char* name, bool required) : MethodParameter(name, required) {} - virtual bool Validate(const char* value) const { return (value != NULL); } + virtual bool Validate(const char* value) const { return (value != nullptr); } }; class RunnableIsolateParameter : public MethodParameter { @@ -830,7 +831,8 @@ class RunnableIsolateParameter : public MethodParameter { virtual bool Validate(const char* value) const { Isolate* isolate = Isolate::Current(); - return (value != NULL) && (isolate != NULL) && (isolate->is_runnable()); + return (value != nullptr) && (isolate != nullptr) && + (isolate->is_runnable()); } virtual void PrintError(const char* name, @@ -847,10 +849,10 @@ class EnumParameter : public MethodParameter { : MethodParameter(name, required), enums_(enums) {} virtual bool Validate(const char* value) const { - if (value == NULL) { + if (value == nullptr) { return true; } - for (intptr_t i = 0; enums_[i] != NULL; i++) { + for (intptr_t i = 0; enums_[i] != nullptr; i++) { if (strcmp(value, enums_[i]) == 0) { return true; } @@ -866,9 +868,9 @@ class EnumParameter : public MethodParameter { // values array. This can be used to encode the default value. template T EnumMapper(const char* value, const char* const* enums, T* values) { - ASSERT(value != NULL); + ASSERT(value != nullptr); intptr_t i = 0; - for (i = 0; enums[i] != NULL; i++) { + for (i = 0; enums[i] != nullptr; i++) { if (strcmp(value, enums[i]) == 0) { return values[i]; } @@ -891,18 +893,18 @@ static void PrintMissingParamError(JSONStream* js, const char* param) { } static void PrintUnrecognizedMethodError(JSONStream* js) { - js->PrintError(kMethodNotFound, NULL); + js->PrintError(kMethodNotFound, nullptr); } // TODO(johnmccutchan): Do we reject unexpected parameters? static bool ValidateParameters(const MethodParameter* const* parameters, JSONStream* js) { - if (parameters == NULL) { + if (parameters == nullptr) { return true; } if (js->NumObjectParameters() > 0) { Object& value = Object::Handle(); - for (intptr_t i = 0; parameters[i] != NULL; i++) { + for (intptr_t i = 0; parameters[i] != nullptr; i++) { const MethodParameter* parameter = parameters[i]; const char* name = parameter->name(); const bool required = parameter->required(); @@ -918,12 +920,12 @@ static bool ValidateParameters(const MethodParameter* const* parameters, } } } else { - for (intptr_t i = 0; parameters[i] != NULL; i++) { + for (intptr_t i = 0; parameters[i] != nullptr; i++) { const MethodParameter* parameter = parameters[i]; const char* name = parameter->name(); const bool required = parameter->required(); const char* value = js->LookupParam(name); - const bool has_parameter = (value != NULL); + const bool has_parameter = (value != nullptr); if (required && !has_parameter) { PrintMissingParamError(js, name); return false; @@ -958,7 +960,7 @@ ErrorPtr Service::InvokeMethod(Isolate* I, bool parameters_are_dart_objects) { Thread* T = Thread::Current(); ASSERT(I == T->isolate()); - ASSERT(I != NULL); + ASSERT(I != nullptr); ASSERT(T->execution_state() == Thread::kThreadInVM); ASSERT(!msg.IsNull()); ASSERT(msg.Length() == 6); @@ -999,7 +1001,7 @@ ErrorPtr Service::InvokeMethod(Isolate* I, // RPC came in with a custom service id zone. const char* id_zone_param = js.LookupParam("_idZone"); - if (id_zone_param != NULL) { + if (id_zone_param != nullptr) { // Override id zone. if (strcmp("default", id_zone_param) == 0) { // Ring with eager id allocation. This is the default ring and default @@ -1022,7 +1024,7 @@ ErrorPtr Service::InvokeMethod(Isolate* I, const char* c_method_name = method_name.ToCString(); const ServiceMethodDescriptor* method = FindMethod(c_method_name); - if (method != NULL) { + if (method != nullptr) { if (!ValidateParameters(method->parameters, &js)) { js.PostReply(); return T->StealStickyError(); @@ -1034,11 +1036,11 @@ ErrorPtr Service::InvokeMethod(Isolate* I, } EmbedderServiceHandler* handler = FindIsolateEmbedderHandler(c_method_name); - if (handler == NULL) { + if (handler == nullptr) { handler = FindRootEmbedderHandler(c_method_name); } - if (handler != NULL) { + if (handler != nullptr) { EmbedderHandleMessage(handler, &js); return T->StealStickyError(); } @@ -1070,7 +1072,7 @@ ErrorPtr Service::HandleObjectRootMessage(const Array& msg_instance) { } ErrorPtr Service::HandleIsolateMessage(Isolate* isolate, const Array& msg) { - ASSERT(isolate != NULL); + ASSERT(isolate != nullptr); const Error& error = Error::Handle(InvokeMethod(isolate, msg)); return MaybePause(isolate, error); } @@ -1085,7 +1087,7 @@ void Service::SendEvent(const char* stream_id, intptr_t bytes_length) { Thread* thread = Thread::Current(); Isolate* isolate = thread->isolate(); - ASSERT(isolate != NULL); + ASSERT(isolate != nullptr); if (FLAG_trace_service) { OS::PrintErr( @@ -1194,7 +1196,7 @@ static void ReportPauseOnConsole(ServiceEvent* event) { } if (!ServiceIsolate::IsRunning()) { OS::PrintErr(" Start the vm-service to debug.\n"); - } else if (ServiceIsolate::server_address() == NULL) { + } else if (ServiceIsolate::server_address() == nullptr) { OS::PrintErr(" Connect to the Dart VM service to debug.\n"); } else { OS::PrintErr(" Connect to the Dart VM service at %s to debug.\n", @@ -1315,8 +1317,11 @@ void Service::PostEventImpl(Isolate* isolate, class EmbedderServiceHandler { public: explicit EmbedderServiceHandler(const char* name) - : name_(NULL), callback_(NULL), user_data_(NULL), next_(NULL) { - ASSERT(name != NULL); + : name_(nullptr), + callback_(nullptr), + user_data_(nullptr), + next_(nullptr) { + ASSERT(name != nullptr); name_ = Utils::StrDup(name); } @@ -1344,17 +1349,17 @@ class EmbedderServiceHandler { void Service::EmbedderHandleMessage(EmbedderServiceHandler* handler, JSONStream* js) { - ASSERT(handler != NULL); + ASSERT(handler != nullptr); Dart_ServiceRequestCallback callback = handler->callback(); - ASSERT(callback != NULL); - const char* response = NULL; + ASSERT(callback != nullptr); + const char* response = nullptr; bool success; { TransitionVMToNative transition(Thread::Current()); success = callback(js->method(), js->param_keys(), js->param_values(), js->num_params(), handler->user_data(), &response); } - ASSERT(response != NULL); + ASSERT(response != nullptr); if (!success) { js->SetupError(); } @@ -1367,11 +1372,11 @@ void Service::RegisterIsolateEmbedderCallback( const char* name, Dart_ServiceRequestCallback callback, void* user_data) { - if (name == NULL) { + if (name == nullptr) { return; } EmbedderServiceHandler* handler = FindIsolateEmbedderHandler(name); - if (handler != NULL) { + if (handler != nullptr) { // Update existing handler entry. handler->set_callback(callback); handler->set_user_data(user_data); @@ -1389,23 +1394,23 @@ void Service::RegisterIsolateEmbedderCallback( EmbedderServiceHandler* Service::FindIsolateEmbedderHandler(const char* name) { EmbedderServiceHandler* current = isolate_service_handler_head_; - while (current != NULL) { + while (current != nullptr) { if (strcmp(name, current->name()) == 0) { return current; } current = current->next(); } - return NULL; + return nullptr; } void Service::RegisterRootEmbedderCallback(const char* name, Dart_ServiceRequestCallback callback, void* user_data) { - if (name == NULL) { + if (name == nullptr) { return; } EmbedderServiceHandler* handler = FindRootEmbedderHandler(name); - if (handler != NULL) { + if (handler != nullptr) { // Update existing handler entry. handler->set_callback(callback); handler->set_user_data(user_data); @@ -1439,14 +1444,14 @@ void Service::SetEmbedderInformationCallback( } int64_t Service::CurrentRSS() { - if (embedder_information_callback_ == NULL) { + if (embedder_information_callback_ == nullptr) { return -1; } Dart_EmbedderInformation info = { - 0, // version - NULL, // name - 0, // max_rss - 0 // current_rss + 0, // version + nullptr, // name + 0, // max_rss + 0 // current_rss }; embedder_information_callback_(&info); ASSERT(info.version == DART_EMBEDDER_INFORMATION_CURRENT_VERSION); @@ -1454,14 +1459,14 @@ int64_t Service::CurrentRSS() { } int64_t Service::MaxRSS() { - if (embedder_information_callback_ == NULL) { + if (embedder_information_callback_ == nullptr) { return -1; } Dart_EmbedderInformation info = { - 0, // version - NULL, // name - 0, // max_rss - 0 // current_rss + 0, // version + nullptr, // name + 0, // max_rss + 0 // current_rss }; embedder_information_callback_(&info); ASSERT(info.version == DART_EMBEDDER_INFORMATION_CURRENT_VERSION); @@ -1476,13 +1481,13 @@ void Service::SetDartLibraryKernelForSources(const uint8_t* kernel_bytes, EmbedderServiceHandler* Service::FindRootEmbedderHandler(const char* name) { EmbedderServiceHandler* current = root_service_handler_head_; - while (current != NULL) { + while (current != nullptr) { if (strcmp(name, current->name()) == 0) { return current; } current = current->next(); } - return NULL; + return nullptr; } void Service::ScheduleExtensionHandler(const Instance& handler, @@ -1497,14 +1502,14 @@ void Service::ScheduleExtensionHandler(const Instance& handler, ASSERT(!parameter_values.IsNull()); ASSERT(!reply_port.IsNull()); Isolate* isolate = Isolate::Current(); - ASSERT(isolate != NULL); + ASSERT(isolate != nullptr); isolate->AppendServiceExtensionCall(handler, method_name, parameter_keys, parameter_values, reply_port, id); } static const MethodParameter* const get_isolate_params[] = { ISOLATE_PARAMETER, - NULL, + nullptr, }; static void GetIsolate(Thread* thread, JSONStream* js) { @@ -1513,7 +1518,7 @@ static void GetIsolate(Thread* thread, JSONStream* js) { static const MethodParameter* const get_isolate_group_params[] = { ISOLATE_GROUP_PARAMETER, - NULL, + nullptr, }; enum SentinelType { @@ -1596,7 +1601,7 @@ static void GetIsolateGroup(Thread* thread, JSONStream* js) { static const MethodParameter* const get_memory_usage_params[] = { ISOLATE_PARAMETER, - NULL, + nullptr, }; static void GetMemoryUsage(Thread* thread, JSONStream* js) { @@ -1605,7 +1610,7 @@ static void GetMemoryUsage(Thread* thread, JSONStream* js) { static const MethodParameter* const get_isolate_group_memory_usage_params[] = { ISOLATE_GROUP_PARAMETER, - NULL, + nullptr, }; static void GetIsolateGroupMemoryUsage(Thread* thread, JSONStream* js) { @@ -1616,7 +1621,7 @@ static void GetIsolateGroupMemoryUsage(Thread* thread, JSONStream* js) { static const MethodParameter* const get_scripts_params[] = { RUNNABLE_ISOLATE_PARAMETER, - NULL, + nullptr, }; static void GetScripts(Thread* thread, JSONStream* js) { @@ -1651,7 +1656,7 @@ static void GetScripts(Thread* thread, JSONStream* js) { static const MethodParameter* const get_stack_params[] = { RUNNABLE_ISOLATE_PARAMETER, new UIntParameter("limit", false), - NULL, + nullptr, }; static void GetStack(Thread* thread, JSONStream* js) { @@ -1690,7 +1695,7 @@ static void GetStack(Thread* thread, JSONStream* js) { } } - if (async_causal_stack != NULL) { + if (async_causal_stack != nullptr) { JSONArray jsarr(&jsobj, "asyncCausalFrames"); intptr_t num_frames = has_limit ? Utils::Minimum(async_causal_stack->Length(), limit) @@ -1703,7 +1708,7 @@ static void GetStack(Thread* thread, JSONStream* js) { } } - if (awaiter_stack != NULL) { + if (awaiter_stack != nullptr) { JSONArray jsarr(&jsobj, "awaiterFrames"); intptr_t num_frames = has_limit ? Utils::Minimum(awaiter_stack->Length(), limit) @@ -1751,7 +1756,7 @@ void Service::SendEchoEvent(Isolate* isolate, const char* text) { event.AddProperty("type", "Event"); event.AddProperty("kind", "_Echo"); event.AddProperty("isolate", isolate); - if (text != NULL) { + if (text != nullptr) { event.AddProperty("text", text); } event.AddPropertyTimeMillis("timestamp", OS::GetCurrentTimeMillis()); @@ -2159,7 +2164,7 @@ static ObjectPtr LookupHeapObjectMessage(Thread* thread, } MessageHandler::AcquiredQueues aq(thread->isolate()->message_handler()); Message* message = aq.queue()->FindMessageById(message_id); - if (message == NULL) { + if (message == nullptr) { // The user may try to load an expired message. return Object::sentinel().ptr(); } @@ -2197,7 +2202,7 @@ static ObjectPtr LookupHeapObject(Thread* thread, parts[num_parts++] = &id[start_pos]; } - if (result != NULL) { + if (result != nullptr) { *result = ObjectIdRing::kValid; } @@ -2208,7 +2213,7 @@ static ObjectPtr LookupHeapObject(Thread* thread, ObjectIdRing::LookupResult lookup_result; obj = LookupObjectId(thread, parts[1], &lookup_result); if (lookup_result != ObjectIdRing::kValid) { - if (result != NULL) { + if (result != nullptr) { *result = lookup_result; } return Object::sentinel().ptr(); @@ -2237,12 +2242,12 @@ static Breakpoint* LookupBreakpoint(Isolate* isolate, *result = ObjectIdRing::kInvalid; size_t end_pos = strcspn(id, "/"); if (end_pos == strlen(id)) { - return NULL; + return nullptr; } const char* rest = id + end_pos + 1; // +1 for '/'. if (strncmp("breakpoints", id, end_pos) == 0) { intptr_t bpt_id = 0; - Breakpoint* bpt = NULL; + Breakpoint* bpt = nullptr; if (GetIntegerId(rest, &bpt_id)) { bpt = isolate->debugger()->GetBreakpointById(bpt_id); if (bpt != nullptr) { @@ -2251,11 +2256,11 @@ static Breakpoint* LookupBreakpoint(Isolate* isolate, } if (bpt_id < isolate->debugger()->limitBreakpointId()) { *result = ObjectIdRing::kCollected; - return NULL; + return nullptr; } } } - return NULL; + return nullptr; } static inline void AddParentFieldToResponseBasedOnRecord( @@ -2358,17 +2363,17 @@ static void PrintInboundReferences(Thread* thread, static const MethodParameter* const get_inbound_references_params[] = { RUNNABLE_ISOLATE_PARAMETER, - NULL, + nullptr, }; static void GetInboundReferences(Thread* thread, JSONStream* js) { const char* target_id = js->LookupParam("targetId"); - if (target_id == NULL) { + if (target_id == nullptr) { PrintMissingParamError(js, "targetId"); return; } const char* limit_cstr = js->LookupParam("limit"); - if (limit_cstr == NULL) { + if (limit_cstr == nullptr) { PrintMissingParamError(js, "limit"); return; } @@ -2500,17 +2505,17 @@ static void PrintRetainingPath(Thread* thread, static const MethodParameter* const get_retaining_path_params[] = { RUNNABLE_ISOLATE_PARAMETER, - NULL, + nullptr, }; static void GetRetainingPath(Thread* thread, JSONStream* js) { const char* target_id = js->LookupParam("targetId"); - if (target_id == NULL) { + if (target_id == nullptr) { PrintMissingParamError(js, "targetId"); return; } const char* limit_cstr = js->LookupParam("limit"); - if (limit_cstr == NULL) { + if (limit_cstr == nullptr) { PrintMissingParamError(js, "limit"); return; } @@ -2542,12 +2547,12 @@ static void GetRetainingPath(Thread* thread, JSONStream* js) { static const MethodParameter* const get_retained_size_params[] = { RUNNABLE_ISOLATE_PARAMETER, new IdParameter("targetId", true), - NULL, + nullptr, }; static void GetRetainedSize(Thread* thread, JSONStream* js) { const char* target_id = js->LookupParam("targetId"); - ASSERT(target_id != NULL); + ASSERT(target_id != nullptr); ObjectIdRing::LookupResult lookup_result; Object& obj = Object::Handle(LookupHeapObject(thread, target_id, &lookup_result)); @@ -2581,12 +2586,12 @@ static void GetRetainedSize(Thread* thread, JSONStream* js) { static const MethodParameter* const get_reachable_size_params[] = { RUNNABLE_ISOLATE_PARAMETER, new IdParameter("targetId", true), - NULL, + nullptr, }; static void GetReachableSize(Thread* thread, JSONStream* js) { const char* target_id = js->LookupParam("targetId"); - ASSERT(target_id != NULL); + ASSERT(target_id != nullptr); ObjectIdRing::LookupResult lookup_result; Object& obj = Object::Handle(LookupHeapObject(thread, target_id, &lookup_result)); @@ -2619,22 +2624,22 @@ static void GetReachableSize(Thread* thread, JSONStream* js) { static const MethodParameter* const invoke_params[] = { RUNNABLE_ISOLATE_PARAMETER, - NULL, + nullptr, }; static void Invoke(Thread* thread, JSONStream* js) { const char* receiver_id = js->LookupParam("targetId"); - if (receiver_id == NULL) { + if (receiver_id == nullptr) { PrintMissingParamError(js, "targetId"); return; } const char* selector_cstr = js->LookupParam("selector"); - if (selector_cstr == NULL) { + if (selector_cstr == nullptr) { PrintMissingParamError(js, "selector"); return; } const char* argument_ids = js->LookupParam("argumentIds"); - if (argument_ids == NULL) { + if (argument_ids == nullptr) { PrintMissingParamError(js, "argumentIds"); return; } @@ -2752,7 +2757,7 @@ static void Invoke(Thread* thread, JSONStream* js) { static const MethodParameter* const evaluate_params[] = { RUNNABLE_ISOLATE_PARAMETER, - NULL, + nullptr, }; static bool IsAlpha(char c) { @@ -2830,7 +2835,7 @@ static bool BuildScope(Thread* thread, const char* scope = js->LookupParam("scope"); GrowableArray cnames; GrowableArray cids; - if (scope != NULL) { + if (scope != nullptr) { if (!ParseScope(scope, &cnames, &cids)) { PrintInvalidParamError(js, "scope"); return true; @@ -2879,7 +2884,7 @@ static const MethodParameter* const build_expression_evaluation_scope_params[] = RUNNABLE_ISOLATE_PARAMETER, new IdParameter("frameIndex", false), new IdParameter("targetId", false), - NULL, + nullptr, }; static void CollectStringifiedType(Zone* zone, @@ -3185,7 +3190,7 @@ static const MethodParameter* const compile_expression_params[] = { new StringParameter("klass", false), new BoolParameter("isStatic", false), new StringParameter("method", false), - NULL, + nullptr, }; static void CompileExpression(Thread* thread, JSONStream* js) { @@ -3262,7 +3267,7 @@ static void CompileExpression(Thread* thread, JSONStream* js) { const uint8_t* kernel_bytes = compilation_result.kernel; intptr_t kernel_length = compilation_result.kernel_size; - ASSERT(kernel_bytes != NULL); + ASSERT(kernel_bytes != nullptr); JSONObject report(js); report.AddPropertyBase64("kernelBytes", kernel_bytes, kernel_length); @@ -3274,7 +3279,7 @@ static const MethodParameter* const evaluate_compiled_expression_params[] = { new UIntParameter("frameIndex", false), new IdParameter("targetId", false), new StringParameter("kernelBytes", true), - NULL, + nullptr, }; ExternalTypedDataPtr DecodeKernelBuffer(const char* kernel_buffer_base64) { @@ -3412,7 +3417,7 @@ static const MethodParameter* const evaluate_in_frame_params[] = { RUNNABLE_ISOLATE_PARAMETER, new UIntParameter("frameIndex", true), new MethodParameter("expression", true), - NULL, + nullptr, }; static void EvaluateInFrame(Thread* thread, JSONStream* js) { @@ -3524,7 +3529,8 @@ static void GetInstances(Thread* thread, JSONStream* js) { const bool include_implementers = BoolParameter::Parse(js->LookupParam("includeImplementers"), false); - const Object& obj = Object::Handle(LookupHeapObject(thread, object_id, NULL)); + const Object& obj = + Object::Handle(LookupHeapObject(thread, object_id, nullptr)); if (obj.ptr() == Object::sentinel().ptr() || !obj.IsClass()) { PrintInvalidParamError(js, "objectId"); return; @@ -3570,7 +3576,8 @@ static void GetInstancesAsList(Thread* thread, JSONStream* js) { bool include_implementers = BoolParameter::Parse(js->LookupParam("includeImplementers"), false); - const Object& obj = Object::Handle(LookupHeapObject(thread, object_id, NULL)); + const Object& obj = + Object::Handle(LookupHeapObject(thread, object_id, nullptr)); if (obj.ptr() == Object::sentinel().ptr() || !obj.IsClass()) { PrintInvalidParamError(js, "objectId"); return; @@ -3632,7 +3639,7 @@ static intptr_t ParseJSONArray(Thread* thread, static const MethodParameter* const get_ports_params[] = { RUNNABLE_ISOLATE_PARAMETER, - NULL, + nullptr, }; static void GetPorts(Thread* thread, JSONStream* js) { @@ -3659,7 +3666,7 @@ static void GetPorts(Thread* thread, JSONStream* js) { static const char* const report_enum_names[] = { SourceReport::kCallSitesStr, SourceReport::kCoverageStr, SourceReport::kPossibleBreakpointsStr, SourceReport::kProfileStr, - SourceReport::kBranchCoverageStr, NULL, + SourceReport::kBranchCoverageStr, nullptr, }; #endif @@ -3672,7 +3679,7 @@ static const MethodParameter* const get_source_report_params[] = { new UIntParameter("endTokenPos", false), new BoolParameter("forceCompile", false), #endif - NULL, + nullptr, }; static void GetSourceReport(Thread* thread, JSONStream* js) { @@ -3689,7 +3696,7 @@ static void GetSourceReport(Thread* thread, JSONStream* js) { const char** reports = reports_parameter->Parse(reports_str); const char** riter = reports; intptr_t report_set = 0; - while (*riter != NULL) { + while (*riter != nullptr) { if (strcmp(*riter, SourceReport::kCallSitesStr) == 0) { report_set |= SourceReport::kCallSites; } else if (strcmp(*riter, SourceReport::kCoverageStr) == 0) { @@ -3724,7 +3731,7 @@ static void GetSourceReport(Thread* thread, JSONStream* js) { // Get the target script. const char* script_id_param = js->LookupParam("scriptId"); const Object& obj = - Object::Handle(LookupHeapObject(thread, script_id_param, NULL)); + Object::Handle(LookupHeapObject(thread, script_id_param, nullptr)); if (obj.ptr() == Object::sentinel().ptr() || !obj.IsScript()) { PrintInvalidParamError(js, "scriptId"); return; @@ -3771,7 +3778,7 @@ static const MethodParameter* const reload_sources_params[] = { new BoolParameter("pause", false), new StringParameter("rootLibUri", false), new StringParameter("packagesUri", false), - NULL, + nullptr, }; static void ReloadSources(Thread* thread, JSONStream* js) { @@ -3851,7 +3858,7 @@ static void AddBreakpointCommon(Thread* thread, intptr_t line = UIntParameter::Parse(line_param); const char* col_param = js->LookupParam("column"); intptr_t col = -1; - if (col_param != NULL) { + if (col_param != nullptr) { col = UIntParameter::Parse(col_param); if (col == 0) { // Column number is 1-based. @@ -3860,10 +3867,10 @@ static void AddBreakpointCommon(Thread* thread, } } ASSERT(!script_uri.IsNull()); - Breakpoint* bpt = NULL; + Breakpoint* bpt = nullptr; bpt = thread->isolate()->debugger()->SetBreakpointAtLineCol(script_uri, line, col); - if (bpt == NULL) { + if (bpt == nullptr) { js->PrintError(kCannotAddBreakpoint, "%s: Cannot add breakpoint at line '%s'", js->method(), line_param); @@ -3877,7 +3884,7 @@ static const MethodParameter* const add_breakpoint_params[] = { new IdParameter("scriptId", true), new UIntParameter("line", true), new UIntParameter("column", false), - NULL, + nullptr, }; static void AddBreakpoint(Thread* thread, JSONStream* js) { @@ -3886,7 +3893,8 @@ static void AddBreakpoint(Thread* thread, JSONStream* js) { } const char* script_id_param = js->LookupParam("scriptId"); - Object& obj = Object::Handle(LookupHeapObject(thread, script_id_param, NULL)); + Object& obj = + Object::Handle(LookupHeapObject(thread, script_id_param, nullptr)); if (obj.ptr() == Object::sentinel().ptr() || !obj.IsScript()) { PrintInvalidParamError(js, "scriptId"); return; @@ -3902,7 +3910,7 @@ static const MethodParameter* const add_breakpoint_with_script_uri_params[] = { new IdParameter("scriptUri", true), new UIntParameter("line", true), new UIntParameter("column", false), - NULL, + nullptr, }; static void AddBreakpointWithScriptUri(Thread* thread, JSONStream* js) { @@ -3918,7 +3926,7 @@ static void AddBreakpointWithScriptUri(Thread* thread, JSONStream* js) { static const MethodParameter* const add_breakpoint_at_entry_params[] = { RUNNABLE_ISOLATE_PARAMETER, new IdParameter("functionId", true), - NULL, + nullptr, }; static void AddBreakpointAtEntry(Thread* thread, JSONStream* js) { @@ -3927,7 +3935,7 @@ static void AddBreakpointAtEntry(Thread* thread, JSONStream* js) { } const char* function_id = js->LookupParam("functionId"); - Object& obj = Object::Handle(LookupHeapObject(thread, function_id, NULL)); + Object& obj = Object::Handle(LookupHeapObject(thread, function_id, nullptr)); if (obj.ptr() == Object::sentinel().ptr() || !obj.IsFunction()) { PrintInvalidParamError(js, "functionId"); return; @@ -3935,7 +3943,7 @@ static void AddBreakpointAtEntry(Thread* thread, JSONStream* js) { const Function& function = Function::Cast(obj); Breakpoint* bpt = thread->isolate()->debugger()->SetBreakpointAtEntry(function, false); - if (bpt == NULL) { + if (bpt == nullptr) { js->PrintError(kCannotAddBreakpoint, "%s: Cannot add breakpoint at function '%s'", js->method(), function.ToCString()); @@ -3947,7 +3955,7 @@ static void AddBreakpointAtEntry(Thread* thread, JSONStream* js) { static const MethodParameter* const add_breakpoint_at_activation_params[] = { RUNNABLE_ISOLATE_PARAMETER, new IdParameter("objectId", true), - NULL, + nullptr, }; static void AddBreakpointAtActivation(Thread* thread, JSONStream* js) { @@ -3956,7 +3964,7 @@ static void AddBreakpointAtActivation(Thread* thread, JSONStream* js) { } const char* object_id = js->LookupParam("objectId"); - Object& obj = Object::Handle(LookupHeapObject(thread, object_id, NULL)); + Object& obj = Object::Handle(LookupHeapObject(thread, object_id, nullptr)); if (obj.ptr() == Object::sentinel().ptr() || !obj.IsInstance()) { PrintInvalidParamError(js, "objectId"); return; @@ -3964,7 +3972,7 @@ static void AddBreakpointAtActivation(Thread* thread, JSONStream* js) { const Instance& closure = Instance::Cast(obj); Breakpoint* bpt = thread->isolate()->debugger()->SetBreakpointAtActivation(closure, false); - if (bpt == NULL) { + if (bpt == nullptr) { js->PrintError(kCannotAddBreakpoint, "%s: Cannot add breakpoint at activation", js->method()); return; @@ -3974,7 +3982,7 @@ static void AddBreakpointAtActivation(Thread* thread, JSONStream* js) { static const MethodParameter* const remove_breakpoint_params[] = { RUNNABLE_ISOLATE_PARAMETER, - NULL, + nullptr, }; static void RemoveBreakpoint(Thread* thread, JSONStream* js) { @@ -3992,7 +4000,7 @@ static void RemoveBreakpoint(Thread* thread, JSONStream* js) { Breakpoint* bpt = LookupBreakpoint(isolate, bpt_id, &lookup_result); // TODO(turnidge): Should we return a different error for bpts which // have been already removed? - if (bpt == NULL) { + if (bpt == nullptr) { PrintInvalidParamError(js, "breakpointId"); return; } @@ -4044,7 +4052,7 @@ static void HandleNativeMetric(Thread* thread, JSONStream* js, const char* id) { static const MethodParameter* const get_isolate_metric_list_params[] = { RUNNABLE_ISOLATE_PARAMETER, - NULL, + nullptr, }; static void GetIsolateMetricList(Thread* thread, JSONStream* js) { @@ -4062,12 +4070,12 @@ static void GetIsolateMetricList(Thread* thread, JSONStream* js) { static const MethodParameter* const get_isolate_metric_params[] = { RUNNABLE_ISOLATE_PARAMETER, - NULL, + nullptr, }; static void GetIsolateMetric(Thread* thread, JSONStream* js) { const char* metric_id = js->LookupParam("metricId"); - if (metric_id == NULL) { + if (metric_id == nullptr) { PrintMissingParamError(js, "metricId"); return; } @@ -4088,7 +4096,7 @@ static void SetVMTimelineFlags(Thread* thread, JSONStream* js) { PrintSuccess(js); #else Isolate* isolate = thread->isolate(); - ASSERT(isolate != NULL); + ASSERT(isolate != nullptr); StackZone zone(thread); char* recorded_streams = Utils::StrDup(js->LookupParam("recordedStreams")); @@ -4101,7 +4109,7 @@ static void SetVMTimelineFlags(Thread* thread, JSONStream* js) { static const MethodParameter* const get_vm_timeline_flags_params[] = { NO_ISOLATE_PARAMETER, - NULL, + nullptr, }; static void GetVMTimelineFlags(Thread* thread, JSONStream* js) { @@ -4110,7 +4118,7 @@ static void GetVMTimelineFlags(Thread* thread, JSONStream* js) { obj.AddProperty("type", "TimelineFlags"); #else Isolate* isolate = thread->isolate(); - ASSERT(isolate != NULL); + ASSERT(isolate != nullptr); StackZone zone(thread); Timeline::PrintFlagsToJSON(js); #endif @@ -4118,7 +4126,7 @@ static void GetVMTimelineFlags(Thread* thread, JSONStream* js) { static const MethodParameter* const get_vm_timeline_micros_params[] = { NO_ISOLATE_PARAMETER, - NULL, + nullptr, }; static void GetVMTimelineMicros(Thread* thread, JSONStream* js) { @@ -4129,12 +4137,12 @@ static void GetVMTimelineMicros(Thread* thread, JSONStream* js) { static const MethodParameter* const clear_vm_timeline_params[] = { NO_ISOLATE_PARAMETER, - NULL, + nullptr, }; static void ClearVMTimeline(Thread* thread, JSONStream* js) { Isolate* isolate = thread->isolate(); - ASSERT(isolate != NULL); + ASSERT(isolate != nullptr); StackZone zone(thread); Timeline::Clear(); @@ -4146,12 +4154,12 @@ static const MethodParameter* const get_vm_timeline_params[] = { NO_ISOLATE_PARAMETER, new Int64Parameter("timeOriginMicros", false), new Int64Parameter("timeExtentMicros", false), - NULL, + nullptr, }; static void GetVMTimeline(Thread* thread, JSONStream* js) { Isolate* isolate = thread->isolate(); - ASSERT(isolate != NULL); + ASSERT(isolate != nullptr); StackZone zone(thread); Timeline::ReclaimCachedBlocksFromThreads(); TimelineEventRecorder* timeline_recorder = Timeline::recorder(); @@ -4192,7 +4200,7 @@ static void GetVMTimeline(Thread* thread, JSONStream* js) { } static const char* const step_enum_names[] = { - "None", "Into", "Over", "Out", "Rewind", "OverAsyncSuspension", NULL, + "None", "Into", "Over", "Out", "Rewind", "OverAsyncSuspension", nullptr, }; static const Debugger::ResumeAction step_enum_values[] = { @@ -4206,18 +4214,18 @@ static const MethodParameter* const resume_params[] = { RUNNABLE_ISOLATE_PARAMETER, new EnumParameter("step", false, step_enum_names), new UIntParameter("frameIndex", false), - NULL, + nullptr, }; static void Resume(Thread* thread, JSONStream* js) { const char* step_param = js->LookupParam("step"); Debugger::ResumeAction step = Debugger::kContinue; - if (step_param != NULL) { + if (step_param != nullptr) { step = EnumMapper(step_param, step_enum_names, step_enum_values); } intptr_t frame_index = 1; const char* frame_index_param = js->LookupParam("frameIndex"); - if (frame_index_param != NULL) { + if (frame_index_param != nullptr) { if (step != Debugger::kStepRewind) { // Only rewind supports the frameIndex parameter. js->PrintError( @@ -4261,12 +4269,12 @@ static void Resume(Thread* thread, JSONStream* js) { PrintSuccess(js); return; } - if (isolate->debugger()->PauseEvent() == NULL) { - js->PrintError(kIsolateMustBePaused, NULL); + if (isolate->debugger()->PauseEvent() == nullptr) { + js->PrintError(kIsolateMustBePaused, nullptr); return; } - const char* error = NULL; + const char* error = nullptr; if (!isolate->debugger()->SetResumeAction(step, frame_index, &error)) { js->PrintError(kCannotResume, "%s", error); return; @@ -4277,7 +4285,7 @@ static void Resume(Thread* thread, JSONStream* js) { static const MethodParameter* const kill_params[] = { RUNNABLE_ISOLATE_PARAMETER, - NULL, + nullptr, }; static void Kill(Thread* thread, JSONStream* js) { @@ -4291,7 +4299,7 @@ static void Kill(Thread* thread, JSONStream* js) { static const MethodParameter* const pause_params[] = { RUNNABLE_ISOLATE_PARAMETER, - NULL, + nullptr, }; static void Pause(Thread* thread, JSONStream* js) { @@ -4306,7 +4314,7 @@ static void Pause(Thread* thread, JSONStream* js) { } static const MethodParameter* const enable_profiler_params[] = { - NULL, + nullptr, }; static void EnableProfiler(Thread* thread, JSONStream* js) { @@ -4319,7 +4327,7 @@ static void EnableProfiler(Thread* thread, JSONStream* js) { static const MethodParameter* const get_tag_profile_params[] = { RUNNABLE_ISOLATE_PARAMETER, - NULL, + nullptr, }; static void GetTagProfile(Thread* thread, JSONStream* js) { @@ -4332,7 +4340,7 @@ static const MethodParameter* const get_cpu_samples_params[] = { RUNNABLE_ISOLATE_PARAMETER, new Int64Parameter("timeOriginMicros", false), new Int64Parameter("timeExtentMicros", false), - NULL, + nullptr, }; static void GetCpuSamples(Thread* thread, JSONStream* js) { @@ -4354,7 +4362,7 @@ static const MethodParameter* const get_allocation_traces_params[] = { new IdParameter("classId", false), new Int64Parameter("timeOriginMicros", false), new Int64Parameter("timeExtentMicros", false), - NULL, + nullptr, }; static void GetAllocationTraces(Thread* thread, JSONStream* js) { @@ -4391,7 +4399,7 @@ static void GetAllocationTraces(Thread* thread, JSONStream* js) { static const MethodParameter* const clear_cpu_samples_params[] = { RUNNABLE_ISOLATE_PARAMETER, - NULL, + nullptr, }; static void ClearCpuSamples(Thread* thread, JSONStream* js) { @@ -4433,7 +4441,7 @@ static void GetAllocationProfileImpl(Thread* thread, static const MethodParameter* const get_allocation_profile_params[] = { RUNNABLE_ISOLATE_PARAMETER, - NULL, + nullptr, }; static void GetAllocationProfilePublic(Thread* thread, JSONStream* js) { @@ -4446,7 +4454,7 @@ static void GetAllocationProfile(Thread* thread, JSONStream* js) { static const MethodParameter* const collect_all_garbage_params[] = { RUNNABLE_ISOLATE_PARAMETER, - NULL, + nullptr, }; static void CollectAllGarbage(Thread* thread, JSONStream* js) { @@ -4457,7 +4465,7 @@ static void CollectAllGarbage(Thread* thread, JSONStream* js) { static const MethodParameter* const get_heap_map_params[] = { RUNNABLE_ISOLATE_PARAMETER, - NULL, + nullptr, }; static void GetHeapMap(Thread* thread, JSONStream* js) { @@ -4482,7 +4490,7 @@ static void GetHeapMap(Thread* thread, JSONStream* js) { static const MethodParameter* const request_heap_snapshot_params[] = { RUNNABLE_ISOLATE_PARAMETER, - NULL, + nullptr, }; static void RequestHeapSnapshot(Thread* thread, JSONStream* js) { @@ -4674,7 +4682,7 @@ static intptr_t GetProcessMemoryUsageHelper(JSONStream* js) { } static const MethodParameter* const get_process_memory_usage_params[] = { - NULL, + nullptr, }; static void GetProcessMemoryUsage(Thread* thread, JSONStream* js) { @@ -4744,7 +4752,7 @@ void Service::SendExtensionEvent(Isolate* isolate, static const MethodParameter* const get_persistent_handles_params[] = { ISOLATE_PARAMETER, - NULL, + nullptr, }; template @@ -4752,7 +4760,7 @@ class PersistentHandleVisitor : public HandleVisitor { public: PersistentHandleVisitor(Thread* thread, JSONArray* handles) : HandleVisitor(thread), handles_(handles) { - ASSERT(handles_ != NULL); + ASSERT(handles_ != nullptr); } void Append(PersistentHandle* persistent_handle) { @@ -4799,10 +4807,10 @@ class PersistentHandleVisitor : public HandleVisitor { static void GetPersistentHandles(Thread* thread, JSONStream* js) { Isolate* isolate = thread->isolate(); - ASSERT(isolate != NULL); + ASSERT(isolate != nullptr); ApiState* api_state = isolate->group()->api_state(); - ASSERT(api_state != NULL); + ASSERT(api_state != nullptr); { JSONObject obj(js); @@ -4832,7 +4840,7 @@ static void GetPersistentHandles(Thread* thread, JSONStream* js) { static const MethodParameter* const get_ports_private_params[] = { RUNNABLE_ISOLATE_PARAMETER, - NULL, + nullptr, }; static void GetPortsPrivate(Thread* thread, JSONStream* js) { @@ -4896,12 +4904,12 @@ static const MethodParameter* const get_object_params[] = { RUNNABLE_ISOLATE_PARAMETER, new UIntParameter("offset", false), new UIntParameter("count", false), - NULL, + nullptr, }; static void GetObject(Thread* thread, JSONStream* js) { const char* id = js->LookupParam("objectId"); - if (id == NULL) { + if (id == nullptr) { PrintMissingParamError(js, "objectId"); return; } @@ -4938,7 +4946,7 @@ static void GetObject(Thread* thread, JSONStream* js) { // Handle non-heap objects. Breakpoint* bpt = LookupBreakpoint(thread->isolate(), id, &lookup_result); - if (bpt != NULL) { + if (bpt != nullptr) { bpt->PrintJSON(js); return; } else if (lookup_result == ObjectIdRing::kCollected) { @@ -4989,7 +4997,7 @@ static void GetImplementationFields(Thread* thread, JSONStream* js) { static const MethodParameter* const get_object_store_params[] = { RUNNABLE_ISOLATE_PARAMETER, - NULL, + nullptr, }; static void GetObjectStore(Thread* thread, JSONStream* js) { @@ -4999,7 +5007,7 @@ static void GetObjectStore(Thread* thread, JSONStream* js) { static const MethodParameter* const get_isolate_object_store_params[] = { RUNNABLE_ISOLATE_PARAMETER, - NULL, + nullptr, }; static void GetIsolateObjectStore(Thread* thread, JSONStream* js) { @@ -5009,7 +5017,7 @@ static void GetIsolateObjectStore(Thread* thread, JSONStream* js) { static const MethodParameter* const get_class_list_params[] = { RUNNABLE_ISOLATE_PARAMETER, - NULL, + nullptr, }; static void GetClassList(Thread* thread, JSONStream* js) { @@ -5020,7 +5028,7 @@ static void GetClassList(Thread* thread, JSONStream* js) { static const MethodParameter* const get_type_arguments_list_params[] = { RUNNABLE_ISOLATE_PARAMETER, - NULL, + nullptr, }; static void GetTypeArgumentsList(Thread* thread, JSONStream* js) { @@ -5056,7 +5064,7 @@ static void GetTypeArgumentsList(Thread* thread, JSONStream* js) { static const MethodParameter* const get_version_params[] = { NO_ISOLATE_PARAMETER, - NULL, + nullptr, }; static void GetVersion(Thread* thread, JSONStream* js) { @@ -5103,20 +5111,20 @@ class SystemServiceIsolateVisitor : public IsolateVisitor { static const MethodParameter* const get_vm_params[] = { NO_ISOLATE_PARAMETER, - NULL, + nullptr, }; void Service::PrintJSONForEmbedderInformation(JSONObject* jsobj) { - if (embedder_information_callback_ != NULL) { + if (embedder_information_callback_ != nullptr) { Dart_EmbedderInformation info = { - 0, // version - NULL, // name - -1, // max_rss - -1 // current_rss + 0, // version + nullptr, // name + -1, // max_rss + -1 // current_rss }; embedder_information_callback_(&info); ASSERT(info.version == DART_EMBEDDER_INFORMATION_CURRENT_VERSION); - if (info.name != NULL) { + if (info.name != nullptr) { jsobj->AddProperty("_embedder", info.name); } if (info.max_rss >= 0) { @@ -5343,7 +5351,7 @@ static const char* const exception_pause_mode_names[] = { "All", "None", "Unhandled", - NULL, + nullptr, }; static Dart_ExceptionPauseInfo exception_pause_mode_values[] = { @@ -5356,12 +5364,12 @@ static Dart_ExceptionPauseInfo exception_pause_mode_values[] = { static const MethodParameter* const set_exception_pause_mode_params[] = { ISOLATE_PARAMETER, new EnumParameter("mode", true, exception_pause_mode_names), - NULL, + nullptr, }; static void SetExceptionPauseMode(Thread* thread, JSONStream* js) { const char* mode = js->LookupParam("mode"); - if (mode == NULL) { + if (mode == nullptr) { PrintMissingParamError(js, "mode"); return; } @@ -5449,7 +5457,7 @@ static void SetBreakpointState(Thread* thread, JSONStream* js) { static const MethodParameter* const get_flag_list_params[] = { NO_ISOLATE_PARAMETER, - NULL, + nullptr, }; static void GetFlagList(Thread* thread, JSONStream* js) { @@ -5458,22 +5466,22 @@ static void GetFlagList(Thread* thread, JSONStream* js) { static const MethodParameter* const set_flags_params[] = { NO_ISOLATE_PARAMETER, - NULL, + nullptr, }; static void SetFlag(Thread* thread, JSONStream* js) { const char* flag_name = js->LookupParam("name"); - if (flag_name == NULL) { + if (flag_name == nullptr) { PrintMissingParamError(js, "name"); return; } const char* flag_value = js->LookupParam("value"); - if (flag_value == NULL) { + if (flag_value == nullptr) { PrintMissingParamError(js, "value"); return; } - if (Flags::Lookup(flag_name) == NULL) { + if (Flags::Lookup(flag_name) == nullptr) { JSONObject jsobj(js); jsobj.AddProperty("type", "Error"); jsobj.AddProperty("message", "Cannot set flag: flag not found"); @@ -5511,7 +5519,7 @@ static void SetFlag(Thread* thread, JSONStream* js) { return; } - const char* error = NULL; + const char* error = nullptr; if (Flags::SetFlag(flag_name, flag_value, &error)) { PrintSuccess(js); if (profile_period) { @@ -5539,7 +5547,7 @@ static const MethodParameter* const set_library_debuggable_params[] = { RUNNABLE_ISOLATE_PARAMETER, new IdParameter("libraryId", true), new BoolParameter("isDebuggable", true), - NULL, + nullptr, }; static void SetLibraryDebuggable(Thread* thread, JSONStream* js) { @@ -5561,7 +5569,7 @@ static void SetLibraryDebuggable(Thread* thread, JSONStream* js) { static const MethodParameter* const set_name_params[] = { ISOLATE_PARAMETER, new MethodParameter("name", true), - NULL, + nullptr, }; static void SetName(Thread* thread, JSONStream* js) { @@ -5578,7 +5586,7 @@ static void SetName(Thread* thread, JSONStream* js) { static const MethodParameter* const set_vm_name_params[] = { NO_ISOLATE_PARAMETER, new MethodParameter("name", true), - NULL, + nullptr, }; static void SetVMName(Thread* thread, JSONStream* js) { @@ -5597,7 +5605,7 @@ static const MethodParameter* const set_trace_class_allocation_params[] = { RUNNABLE_ISOLATE_PARAMETER, new IdParameter("classId", true), new BoolParameter("enable", true), - NULL, + nullptr, }; static void SetTraceClassAllocation(Thread* thread, JSONStream* js) { @@ -5622,7 +5630,7 @@ static void SetTraceClassAllocation(Thread* thread, JSONStream* js) { static const MethodParameter* const get_default_classes_aliases_params[] = { NO_ISOLATE_PARAMETER, - NULL, + nullptr, }; static void GetDefaultClassesAliases(Thread* thread, JSONStream* js) { @@ -5709,13 +5717,13 @@ static void GetDefaultClassesAliases(Thread* thread, JSONStream* js) { // clang-format off static const ServiceMethodDescriptor service_methods_[] = { { "_echo", Echo, - NULL }, + nullptr }, { "_respondWithMalformedJson", RespondWithMalformedJson, - NULL }, + nullptr }, { "_respondWithMalformedObject", RespondWithMalformedObject, - NULL }, + nullptr }, { "_triggerEchoEvent", TriggerEchoEvent, - NULL }, + nullptr }, { "addBreakpoint", AddBreakpoint, add_breakpoint_params }, { "addBreakpointWithScriptUri", AddBreakpointWithScriptUri, @@ -5866,7 +5874,7 @@ const ServiceMethodDescriptor* FindMethod(const char* method_name) { return &method; } } - return NULL; + return nullptr; } #endif // !PRODUCT diff --git a/runtime/vm/service.h b/runtime/vm/service.h index c92cf6bbbe0..def031d79e7 100644 --- a/runtime/vm/service.h +++ b/runtime/vm/service.h @@ -209,7 +209,7 @@ class Service : public AllStatic { static void SetDartLibraryKernelForSources(const uint8_t* kernel_bytes, intptr_t kernel_length); static bool HasDartLibraryKernelForSources() { - return (dart_library_kernel_ != NULL); + return (dart_library_kernel_ != nullptr); } static const uint8_t* dart_library_kernel() { return dart_library_kernel_; } diff --git a/runtime/vm/service/service.md b/runtime/vm/service/service.md index 04f5932a803..7dec2596f94 100644 --- a/runtime/vm/service/service.md +++ b/runtime/vm/service/service.md @@ -2609,7 +2609,7 @@ class Flag { // The value of this flag as a string. // - // If this property is absent, then the value of the flag was NULL. + // If this property is absent, then the value of the flag was nullptr. string valueAsString [optional]; } ``` diff --git a/runtime/vm/service_event.cc b/runtime/vm/service_event.cc index b0e3fcf83ad..7c703edba57 100644 --- a/runtime/vm/service_event.cc +++ b/runtime/vm/service_event.cc @@ -60,7 +60,7 @@ ServiceEvent::ServiceEvent(IsolateGroup* isolate_group, // and none events for this purpose. The resume event represents a running // isolate and the none event is returned for an isolate that has not yet // been marked as runnable (see "pauseEvent" in Isolate::PrintJSON). - ASSERT(isolate == NULL || !Isolate::IsVMInternalIsolate(isolate) || + ASSERT(isolate == nullptr || !Isolate::IsVMInternalIsolate(isolate) || (Isolate::IsVMInternalIsolate(isolate) && (event_kind == ServiceEvent::kResume || event_kind == ServiceEvent::kNone || @@ -210,7 +210,7 @@ const StreamInfo* ServiceEvent::stream_info() const { const char* ServiceEvent::stream_id() const { const StreamInfo* stream = stream_info(); - if (stream == NULL) { + if (stream == nullptr) { ASSERT(kind() == kEmbedder); return embedder_stream_id_; } else { @@ -231,7 +231,7 @@ void ServiceEvent::PrintJSON(JSONStream* js) const { jsobj.AddProperty("updatedTag", updated_tag()); } if (kind() == kIsolateReload) { - if (reload_error_ == NULL) { + if (reload_error_ == nullptr) { jsobj.AddProperty("status", "success"); } else { jsobj.AddProperty("status", "failure"); @@ -239,18 +239,18 @@ void ServiceEvent::PrintJSON(JSONStream* js) const { } } if (kind() == kServiceExtensionAdded) { - ASSERT(extension_rpc_ != NULL); + ASSERT(extension_rpc_ != nullptr); jsobj.AddProperty("extensionRPC", extension_rpc_->ToCString()); } if (kind() == kPauseBreakpoint) { JSONArray jsarr(&jsobj, "pauseBreakpoints"); // TODO(rmacnak): If we are paused at more than one breakpoint, // provide it here. - if (breakpoint() != NULL) { + if (breakpoint() != nullptr) { jsarr.AddValue(breakpoint()); } } else { - if (breakpoint() != NULL) { + if (breakpoint() != nullptr) { jsobj.AddProperty("breakpoint", breakpoint()); } } @@ -273,22 +273,22 @@ void ServiceEvent::PrintJSON(JSONStream* js) const { jsFrame.AddProperty("index", index); } #endif - if (exception() != NULL) { + if (exception() != nullptr) { jsobj.AddProperty("exception", *(exception())); } if (at_async_jump()) { jsobj.AddProperty("atAsyncSuspension", true); } - if (inspectee() != NULL) { + if (inspectee() != nullptr) { jsobj.AddProperty("inspectee", *(inspectee())); } - if (gc_stats() != NULL) { + if (gc_stats() != nullptr) { jsobj.AddProperty("reason", Heap::GCReasonToString(gc_stats()->reason_)); jsobj.AddProperty("gcType", Heap::GCTypeToString(gc_stats()->type_)); isolate_group()->heap()->PrintToJSONObject(Heap::kNew, &jsobj); isolate_group()->heap()->PrintToJSONObject(Heap::kOld, &jsobj); } - if (bytes() != NULL) { + if (bytes() != nullptr) { jsobj.AddPropertyBase64("bytes", bytes(), bytes_length()); } if (kind() == kLogging) { @@ -316,15 +316,15 @@ void ServiceEvent::PrintJSON(JSONStream* js) const { } void ServiceEvent::PrintJSONHeader(JSONObject* jsobj) const { - ASSERT(jsobj != NULL); + ASSERT(jsobj != nullptr); jsobj->AddProperty("type", "Event"); jsobj->AddProperty("kind", KindAsCString()); if (kind() == kExtension) { - ASSERT(extension_event_.event_kind != NULL); + ASSERT(extension_event_.event_kind != nullptr); jsobj->AddProperty("extensionKind", extension_event_.event_kind->ToCString()); } - if (isolate() == NULL) { + if (isolate() == nullptr) { jsobj->AddPropertyVM("vm"); } else { jsobj->AddProperty("isolate", isolate()); diff --git a/runtime/vm/service_isolate.cc b/runtime/vm/service_isolate.cc index 67f1b0e246e..66f05e87286 100644 --- a/runtime/vm/service_isolate.cc +++ b/runtime/vm/service_isolate.cc @@ -99,13 +99,14 @@ static ArrayPtr MakeServerControlMessage(const SendPort& sp, } const char* ServiceIsolate::kName = DART_VM_SERVICE_ISOLATE_NAME; -Dart_IsolateGroupCreateCallback ServiceIsolate::create_group_callback_ = NULL; +Dart_IsolateGroupCreateCallback ServiceIsolate::create_group_callback_ = + nullptr; Monitor* ServiceIsolate::monitor_ = new Monitor(); ServiceIsolate::State ServiceIsolate::state_ = ServiceIsolate::kStopped; -Isolate* ServiceIsolate::isolate_ = NULL; +Isolate* ServiceIsolate::isolate_ = nullptr; Dart_Port ServiceIsolate::port_ = ILLEGAL_PORT; Dart_Port ServiceIsolate::origin_ = ILLEGAL_PORT; -char* ServiceIsolate::server_address_ = NULL; +char* ServiceIsolate::server_address_ = nullptr; char* ServiceIsolate::startup_failure_reason_ = nullptr; void ServiceIsolate::RequestServerInfo(const SendPort& sp) { @@ -128,29 +129,29 @@ void ServiceIsolate::ControlWebServer(const SendPort& sp, } void ServiceIsolate::SetServerAddress(const char* address) { - if (server_address_ != NULL) { + if (server_address_ != nullptr) { free(server_address_); - server_address_ = NULL; + server_address_ = nullptr; } - if (address == NULL) { + if (address == nullptr) { return; } server_address_ = Utils::StrDup(address); } bool ServiceIsolate::NameEquals(const char* name) { - ASSERT(name != NULL); + ASSERT(name != nullptr); return strcmp(name, kName) == 0; } bool ServiceIsolate::Exists() { MonitorLocker ml(monitor_); - return isolate_ != NULL; + return isolate_ != nullptr; } bool ServiceIsolate::IsRunning() { MonitorLocker ml(monitor_); - return (port_ != ILLEGAL_PORT) && (isolate_ != NULL); + return (port_ != ILLEGAL_PORT) && (isolate_ != nullptr); } bool ServiceIsolate::IsServiceIsolate(const Isolate* isolate) { @@ -304,7 +305,7 @@ void ServiceIsolate::SetServicePort(Dart_Port port) { void ServiceIsolate::SetServiceIsolate(Isolate* isolate) { MonitorLocker ml(monitor_); isolate_ = isolate; - if (isolate_ != NULL) { + if (isolate_ != nullptr) { isolate_->set_is_service_isolate(true); origin_ = isolate_->origin_id(); } @@ -313,8 +314,8 @@ void ServiceIsolate::SetServiceIsolate(Isolate* isolate) { void ServiceIsolate::MaybeMakeServiceIsolate(Isolate* I) { Thread* T = Thread::Current(); ASSERT(I == T->isolate()); - ASSERT(I != NULL); - ASSERT(I->name() != NULL); + ASSERT(I != nullptr); + ASSERT(I->name() != nullptr); if (!ServiceIsolate::NameEquals(I->name())) { // Not service isolate. return; @@ -354,24 +355,24 @@ void ServiceIsolate::InitializingFailed(char* error) { class RunServiceTask : public ThreadPool::Task { public: virtual void Run() { - ASSERT(Isolate::Current() == NULL); + ASSERT(Isolate::Current() == nullptr); #if defined(SUPPORT_TIMELINE) TimelineBeginEndScope tbes(Timeline::GetVMStream(), "ServiceIsolateStartup"); #endif // SUPPORT_TIMELINE - char* error = NULL; - Isolate* isolate = NULL; + char* error = nullptr; + Isolate* isolate = nullptr; const auto create_group_callback = ServiceIsolate::create_group_callback(); - ASSERT(create_group_callback != NULL); + ASSERT(create_group_callback != nullptr); Dart_IsolateFlags api_flags; Isolate::FlagsInitialize(&api_flags); api_flags.is_system_isolate = true; isolate = reinterpret_cast( create_group_callback(ServiceIsolate::kName, ServiceIsolate::kName, - NULL, NULL, &api_flags, NULL, &error)); - if (isolate == NULL) { + nullptr, nullptr, &api_flags, nullptr, &error)); + if (isolate == nullptr) { if (FLAG_trace_service) { OS::PrintErr(DART_VM_SERVICE_ISOLATE_NAME ": Isolate creation error: %s\n", @@ -390,7 +391,7 @@ class RunServiceTask : public ThreadPool::Task { bool got_unwind; { - ASSERT(Isolate::Current() == NULL); + ASSERT(Isolate::Current() == nullptr); StartIsolateScope start_scope(isolate); got_unwind = RunMain(isolate); } @@ -405,7 +406,7 @@ class RunServiceTask : public ThreadPool::Task { return; } - isolate->message_handler()->Run(isolate->group()->thread_pool(), NULL, + isolate->message_handler()->Run(isolate->group()->thread_pool(), nullptr, ShutdownIsolate, reinterpret_cast(isolate)); } @@ -504,7 +505,7 @@ void ServiceIsolate::Run() { // Grab the isolate create callback here to avoid race conditions with tests // that change this after Dart_Initialize returns. create_group_callback_ = Isolate::CreateGroupCallback(); - if (create_group_callback_ == NULL) { + if (create_group_callback_ == nullptr) { ServiceIsolate::InitializingFailed( Utils::StrDup("The 'create_group' callback was not provided")); return; @@ -557,7 +558,7 @@ void ServiceIsolate::Shutdown() { ASSERT(state_ == kStopped); } } else { - if (isolate_ != NULL) { + if (isolate_ != nullptr) { // TODO(johnmccutchan,turnidge) When it is possible to properly create // the VMService object and set up its shutdown handler in the service // isolate's main() function, this case will no longer be possible and @@ -565,9 +566,9 @@ void ServiceIsolate::Shutdown() { KillServiceIsolate(); } } - if (server_address_ != NULL) { + if (server_address_ != nullptr) { free(server_address_); - server_address_ = NULL; + server_address_ = nullptr; } if (startup_failure_reason_ != nullptr) { diff --git a/runtime/vm/service_isolate.h b/runtime/vm/service_isolate.h index 274dc605ea2..e11402322ca 100644 --- a/runtime/vm/service_isolate.h +++ b/runtime/vm/service_isolate.h @@ -65,7 +65,7 @@ class ServiceIsolate : public AllStatic { static void SetServerAddress(const char* address); - // Returns the server's web address or NULL if none is running. + // Returns the server's web address or nullptr if none is running. static const char* server_address() { return server_address_; } static void VisitObjectPointers(ObjectPointerVisitor* visitor); diff --git a/runtime/vm/service_test.cc b/runtime/vm/service_test.cc index b1db023333d..6c7e4cc26a8 100644 --- a/runtime/vm/service_test.cc +++ b/runtime/vm/service_test.cc @@ -32,7 +32,7 @@ DEFINE_FLAG(bool, service_testing_flag, false, "Comment"); class ServiceTestMessageHandler : public MessageHandler { public: - ServiceTestMessageHandler() : _msg(NULL) {} + ServiceTestMessageHandler() : _msg(nullptr) {} ~ServiceTestMessageHandler() { PortMap::ClosePorts(this); @@ -40,9 +40,9 @@ class ServiceTestMessageHandler : public MessageHandler { } MessageStatus HandleMessage(std::unique_ptr message) { - if (_msg != NULL) { + if (_msg != nullptr) { free(_msg); - _msg = NULL; + _msg = nullptr; } // Parse the message. @@ -107,7 +107,7 @@ static ArrayPtr Eval(Dart_Handle lib, const char* expr) { static ArrayPtr EvalF(Dart_Handle lib, const char* fmt, ...) { va_list measure_args; va_start(measure_args, fmt); - intptr_t len = Utils::VSNPrint(NULL, 0, fmt, measure_args); + intptr_t len = Utils::VSNPrint(nullptr, 0, fmt, measure_args); va_end(measure_args); char* buffer = Thread::Current()->zone()->Alloc(len + 1); @@ -149,9 +149,9 @@ ISOLATE_UNIT_TEST_CASE(Service_IsolateStickyError) { Dart_Handle result; { TransitionVMToNative transition(thread); - Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); - result = Dart_Invoke(lib, NewString("main"), 0, NULL); + result = Dart_Invoke(lib, NewString("main"), 0, nullptr); EXPECT(Dart_IsUnhandledExceptionError(result)); EXPECT(!Dart_HasStickyError()); } @@ -242,10 +242,10 @@ ISOLATE_UNIT_TEST_CASE(Service_Code) { Library& vmlib = Library::Handle(); { TransitionVMToNative transition(thread); - lib = TestCase::LoadTestScript(kScript, NULL); + lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); EXPECT(!Dart_IsNull(lib)); - Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL); + Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, nullptr); EXPECT_VALID(result); } vmlib ^= Api::UnwrapHandle(lib); @@ -367,10 +367,10 @@ ISOLATE_UNIT_TEST_CASE(Service_PcDescriptors) { Library& vmlib = Library::Handle(); { TransitionVMToNative transition(thread); - lib = TestCase::LoadTestScript(kScript, NULL); + lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); EXPECT(!Dart_IsNull(lib)); - Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL); + Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, nullptr); EXPECT_VALID(result); } vmlib ^= Api::UnwrapHandle(lib); @@ -438,10 +438,10 @@ ISOLATE_UNIT_TEST_CASE(Service_LocalVarDescriptors) { Library& vmlib = Library::Handle(); { TransitionVMToNative transition(thread); - lib = TestCase::LoadTestScript(kScript, NULL); + lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); EXPECT(!Dart_IsNull(lib)); - Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL); + Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, nullptr); EXPECT_VALID(result); } vmlib ^= Api::UnwrapHandle(lib); @@ -507,9 +507,9 @@ ISOLATE_UNIT_TEST_CASE(Service_PersistentHandles) { Dart_WeakPersistentHandle weak_persistent_handle; { TransitionVMToNative transition(thread); - lib = TestCase::LoadTestScript(kScript, NULL); + lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); - Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL); + Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, nullptr); EXPECT_VALID(result); // Create a persistent handle to global. @@ -594,12 +594,12 @@ ISOLATE_UNIT_TEST_CASE(Service_EmbedderRootHandler) { { TransitionVMToNative transition(thread); - Dart_RegisterRootServiceRequestCallback("alpha", alpha_callback, NULL); - Dart_RegisterRootServiceRequestCallback("beta", beta_callback, NULL); + Dart_RegisterRootServiceRequestCallback("alpha", alpha_callback, nullptr); + Dart_RegisterRootServiceRequestCallback("beta", beta_callback, nullptr); - lib = TestCase::LoadTestScript(kScript, NULL); + lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); - Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL); + Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, nullptr); EXPECT_VALID(result); } @@ -639,12 +639,13 @@ ISOLATE_UNIT_TEST_CASE(Service_EmbedderIsolateHandler) { { TransitionVMToNative transition(thread); - Dart_RegisterIsolateServiceRequestCallback("alpha", alpha_callback, NULL); - Dart_RegisterIsolateServiceRequestCallback("beta", beta_callback, NULL); + Dart_RegisterIsolateServiceRequestCallback("alpha", alpha_callback, + nullptr); + Dart_RegisterIsolateServiceRequestCallback("beta", beta_callback, nullptr); - lib = TestCase::LoadTestScript(kScript, NULL); + lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); - Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL); + Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, nullptr); EXPECT_VALID(result); } @@ -699,9 +700,9 @@ ISOLATE_UNIT_TEST_CASE(Service_Profile) { { TransitionVMToNative transition(thread); - lib = TestCase::LoadTestScript(kScript, NULL); + lib = TestCase::LoadTestScript(kScript, nullptr); EXPECT_VALID(lib); - Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL); + Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, nullptr); EXPECT_VALID(result); } diff --git a/runtime/vm/signal_handler_android.cc b/runtime/vm/signal_handler_android.cc index 2fba54ac655..99787afc48b 100644 --- a/runtime/vm/signal_handler_android.cc +++ b/runtime/vm/signal_handler_android.cc @@ -108,14 +108,14 @@ void SignalHandler::Install(SignalAction action) { ss.ss_size = SIGSTKSZ; ss.ss_sp = malloc(ss.ss_size); ss.ss_flags = 0; - int r = sigaltstack(&ss, NULL); + int r = sigaltstack(&ss, nullptr); ASSERT(r == 0); struct sigaction act = {}; act.sa_sigaction = action; sigemptyset(&act.sa_mask); act.sa_flags = SA_RESTART | SA_SIGINFO | SA_ONSTACK; - r = sigaction(SIGPROF, &act, NULL); + r = sigaction(SIGPROF, &act, nullptr); ASSERT(r == 0); } @@ -125,7 +125,7 @@ void SignalHandler::Remove() { struct sigaction act = {}; act.sa_handler = SIG_IGN; sigemptyset(&act.sa_mask); - int r = sigaction(SIGPROF, &act, NULL); + int r = sigaction(SIGPROF, &act, nullptr); ASSERT(r == 0); // Disable and delete alternative signal stack. diff --git a/runtime/vm/signal_handler_linux.cc b/runtime/vm/signal_handler_linux.cc index a0127e95838..1b4830d5514 100644 --- a/runtime/vm/signal_handler_linux.cc +++ b/runtime/vm/signal_handler_linux.cc @@ -112,11 +112,11 @@ uintptr_t SignalHandler::GetLinkRegister(const mcontext_t& mcontext) { void SignalHandler::Install(SignalAction action) { struct sigaction act = {}; - act.sa_handler = NULL; + act.sa_handler = nullptr; act.sa_sigaction = action; sigemptyset(&act.sa_mask); act.sa_flags = SA_RESTART | SA_SIGINFO; - int r = sigaction(SIGPROF, &act, NULL); + int r = sigaction(SIGPROF, &act, nullptr); ASSERT(r == 0); } @@ -127,7 +127,7 @@ void SignalHandler::Remove() { act.sa_handler = SIG_IGN; sigemptyset(&act.sa_mask); act.sa_flags = 0; - int r = sigaction(SIGPROF, &act, NULL); + int r = sigaction(SIGPROF, &act, nullptr); ASSERT(r == 0); } diff --git a/runtime/vm/simulator_arm.cc b/runtime/vm/simulator_arm.cc index b714100b724..9fbd5b67eae 100644 --- a/runtime/vm/simulator_arm.cc +++ b/runtime/vm/simulator_arm.cc @@ -321,12 +321,12 @@ void SimulatorDebugger::PrintBacktrace() { ValidationPolicy::kDontValidateFrames, T, StackFrameIterator::kNoCrossThreadIteration); StackFrame* frame = frames.NextFrame(); - ASSERT(frame != NULL); + ASSERT(frame != nullptr); Function& function = Function::Handle(Z); Function& inlined_function = Function::Handle(Z); Code& code = Code::Handle(Z); Code& unoptimized_code = Code::Handle(Z); - while (frame != NULL) { + while (frame != nullptr) { if (frame->IsDartFrame()) { code = frame->LookupDartCode(); function = code.function(); @@ -377,7 +377,7 @@ void SimulatorDebugger::PrintBacktrace() { bool SimulatorDebugger::SetBreakpoint(Instr* breakpc) { // Check if a breakpoint can be set. If not return without any side-effects. - if (sim_->break_pc_ != NULL) { + if (sim_->break_pc_ != nullptr) { return false; } @@ -390,23 +390,23 @@ bool SimulatorDebugger::SetBreakpoint(Instr* breakpc) { } bool SimulatorDebugger::DeleteBreakpoint(Instr* breakpc) { - if (sim_->break_pc_ != NULL) { + if (sim_->break_pc_ != nullptr) { sim_->break_pc_->SetInstructionBits(sim_->break_instr_); } - sim_->break_pc_ = NULL; + sim_->break_pc_ = nullptr; sim_->break_instr_ = 0; return true; } void SimulatorDebugger::UndoBreakpoints() { - if (sim_->break_pc_ != NULL) { + if (sim_->break_pc_ != nullptr) { sim_->break_pc_->SetInstructionBits(sim_->break_instr_); } } void SimulatorDebugger::RedoBreakpoints() { - if (sim_->break_pc_ != NULL) { + if (sim_->break_pc_ != nullptr) { sim_->break_pc_->SetInstructionBits(Instr::kSimulatorBreakpointInstruction); } } @@ -448,7 +448,7 @@ void SimulatorDebugger::Debug() { } } char* line = ReadLine("sim> "); - if (line == NULL) { + if (line == nullptr) { FATAL("ReadLine failed"); } else { // Use sscanf to parse the individual parts of the command line. At the @@ -611,7 +611,7 @@ void SimulatorDebugger::Debug() { OS::PrintErr("break \n"); } } else if (strcmp(cmd, "del") == 0) { - if (!DeleteBreakpoint(NULL)) { + if (!DeleteBreakpoint(nullptr)) { OS::PrintErr("deleting breakpoint failed\n"); } } else if (strcmp(cmd, "flags") == 0) { @@ -665,18 +665,18 @@ void SimulatorDebugger::Debug() { } char* SimulatorDebugger::ReadLine(const char* prompt) { - char* result = NULL; + char* result = nullptr; char line_buf[256]; intptr_t offset = 0; bool keep_going = true; OS::PrintErr("%s", prompt); while (keep_going) { - if (fgets(line_buf, sizeof(line_buf), stdin) == NULL) { + if (fgets(line_buf, sizeof(line_buf), stdin) == nullptr) { // fgets got an error. Just give up. - if (result != NULL) { + if (result != nullptr) { delete[] result; } - return NULL; + return nullptr; } intptr_t len = strlen(line_buf); if (len > 1 && line_buf[len - 2] == '\\' && line_buf[len - 1] == '\n') { @@ -690,21 +690,21 @@ char* SimulatorDebugger::ReadLine(const char* prompt) { // will exit the loop after copying this buffer into the result. keep_going = false; } - if (result == NULL) { + if (result == nullptr) { // Allocate the initial result and make room for the terminating '\0' result = new char[len + 1]; - if (result == NULL) { + if (result == nullptr) { // OOM, so cannot readline anymore. - return NULL; + return nullptr; } } else { // Allocate a new result with enough room for the new addition. intptr_t new_len = offset + len + 1; char* new_result = new char[new_len]; - if (new_result == NULL) { - // OOM, free the buffer allocated so far and return NULL. + if (new_result == nullptr) { + // OOM, free the buffer allocated so far and return nullptr. delete[] result; - return NULL; + return nullptr; } else { // Copy the existing input into the new array and set the new // array as the result. @@ -717,7 +717,7 @@ char* SimulatorDebugger::ReadLine(const char* prompt) { memmove(result + offset, line_buf, len); offset += len; } - ASSERT(result != NULL); + ASSERT(result != nullptr); result[offset] = '\0'; return result; } @@ -743,9 +743,9 @@ Simulator::Simulator() : exclusive_access_addr_(0), exclusive_access_value_(0) { pc_modified_ = false; icount_ = 0; - break_pc_ = NULL; + break_pc_ = nullptr; break_instr_ = 0; - last_setjmp_buffer_ = NULL; + last_setjmp_buffer_ = nullptr; // Setup architecture state. // All registers are initialized to zero to start with. @@ -784,8 +784,8 @@ Simulator::Simulator() : exclusive_access_addr_(0), exclusive_access_value_(0) { Simulator::~Simulator() { delete[] stack_; Isolate* isolate = Isolate::Current(); - if (isolate != NULL) { - isolate->set_simulator(NULL); + if (isolate != nullptr) { + isolate->set_simulator(nullptr); } } @@ -860,7 +860,7 @@ class Redirection { call_kind_(call_kind), argument_count_(argument_count), svc_instruction_(Instr::kSimulatorRedirectInstruction), - next_(NULL) {} + next_(nullptr) {} uword external_function_; Simulator::CallKind call_kind_; @@ -890,7 +890,7 @@ uword Simulator::FunctionForRedirect(uword redirect) { Simulator* Simulator::Current() { Isolate* isolate = Isolate::Current(); Simulator* simulator = isolate->simulator(); - if (simulator == NULL) { + if (simulator == nullptr) { NoSafepointScope no_safepoint; simulator = new Simulator(); isolate->set_simulator(simulator); @@ -3672,10 +3672,10 @@ void Simulator::JumpToFrame(uword pc, uword sp, uword fp, Thread* thread) { // Walk over all setjmp buffers (simulated --> C++ transitions) // and try to find the setjmp associated with the simulated stack pointer. SimulatorSetjmpBuffer* buf = last_setjmp_buffer(); - while (buf->link() != NULL && buf->link()->sp() <= sp) { + while (buf->link() != nullptr && buf->link()->sp() <= sp) { buf = buf->link(); } - ASSERT(buf != NULL); + ASSERT(buf != nullptr); // The C++ caller has not cleaned up the stack memory of C++ frames. // Prepare for unwinding frames by destroying all the stack resources diff --git a/runtime/vm/simulator_arm64.cc b/runtime/vm/simulator_arm64.cc index c33e65bc507..222862a23e9 100644 --- a/runtime/vm/simulator_arm64.cc +++ b/runtime/vm/simulator_arm64.cc @@ -348,12 +348,12 @@ void SimulatorDebugger::PrintBacktrace() { ValidationPolicy::kDontValidateFrames, T, StackFrameIterator::kNoCrossThreadIteration); StackFrame* frame = frames.NextFrame(); - ASSERT(frame != NULL); + ASSERT(frame != nullptr); Function& function = Function::Handle(Z); Function& inlined_function = Function::Handle(Z); Code& code = Code::Handle(Z); Code& unoptimized_code = Code::Handle(Z); - while (frame != NULL) { + while (frame != nullptr) { if (frame->IsDartFrame()) { code = frame->LookupDartCode(); function = code.function(); @@ -404,7 +404,7 @@ void SimulatorDebugger::PrintBacktrace() { bool SimulatorDebugger::SetBreakpoint(Instr* breakpc) { // Check if a breakpoint can be set. If not return without any side-effects. - if (sim_->break_pc_ != NULL) { + if (sim_->break_pc_ != nullptr) { return false; } @@ -417,23 +417,23 @@ bool SimulatorDebugger::SetBreakpoint(Instr* breakpc) { } bool SimulatorDebugger::DeleteBreakpoint(Instr* breakpc) { - if (sim_->break_pc_ != NULL) { + if (sim_->break_pc_ != nullptr) { sim_->break_pc_->SetInstructionBits(sim_->break_instr_); } - sim_->break_pc_ = NULL; + sim_->break_pc_ = nullptr; sim_->break_instr_ = 0; return true; } void SimulatorDebugger::UndoBreakpoints() { - if (sim_->break_pc_ != NULL) { + if (sim_->break_pc_ != nullptr) { sim_->break_pc_->SetInstructionBits(sim_->break_instr_); } } void SimulatorDebugger::RedoBreakpoints() { - if (sim_->break_pc_ != NULL) { + if (sim_->break_pc_ != nullptr) { sim_->break_pc_->SetInstructionBits(Instr::kSimulatorBreakpointInstruction); } } @@ -475,7 +475,7 @@ void SimulatorDebugger::Debug() { } } char* line = ReadLine("sim> "); - if (line == NULL) { + if (line == nullptr) { FATAL("ReadLine failed"); } else { // Use sscanf to parse the individual parts of the command line. At the @@ -671,7 +671,7 @@ void SimulatorDebugger::Debug() { OS::PrintErr("break \n"); } } else if (strcmp(cmd, "del") == 0) { - if (!DeleteBreakpoint(NULL)) { + if (!DeleteBreakpoint(nullptr)) { OS::PrintErr("deleting breakpoint failed\n"); } } else if (strcmp(cmd, "flags") == 0) { @@ -720,18 +720,18 @@ void SimulatorDebugger::Debug() { } char* SimulatorDebugger::ReadLine(const char* prompt) { - char* result = NULL; + char* result = nullptr; char line_buf[256]; intptr_t offset = 0; bool keep_going = true; OS::PrintErr("%s", prompt); while (keep_going) { - if (fgets(line_buf, sizeof(line_buf), stdin) == NULL) { + if (fgets(line_buf, sizeof(line_buf), stdin) == nullptr) { // fgets got an error. Just give up. - if (result != NULL) { + if (result != nullptr) { delete[] result; } - return NULL; + return nullptr; } intptr_t len = strlen(line_buf); if (len > 1 && line_buf[len - 2] == '\\' && line_buf[len - 1] == '\n') { @@ -745,21 +745,21 @@ char* SimulatorDebugger::ReadLine(const char* prompt) { // will exit the loop after copying this buffer into the result. keep_going = false; } - if (result == NULL) { + if (result == nullptr) { // Allocate the initial result and make room for the terminating '\0' result = new char[len + 1]; - if (result == NULL) { + if (result == nullptr) { // OOM, so cannot readline anymore. - return NULL; + return nullptr; } } else { // Allocate a new result with enough room for the new addition. intptr_t new_len = offset + len + 1; char* new_result = new char[new_len]; - if (new_result == NULL) { - // OOM, free the buffer allocated so far and return NULL. + if (new_result == nullptr) { + // OOM, free the buffer allocated so far and return nullptr. delete[] result; - return NULL; + return nullptr; } else { // Copy the existing input into the new array and set the new // array as the result. @@ -772,7 +772,7 @@ char* SimulatorDebugger::ReadLine(const char* prompt) { memmove(result + offset, line_buf, len); offset += len; } - ASSERT(result != NULL); + ASSERT(result != nullptr); result[offset] = '\0'; return result; } @@ -798,9 +798,9 @@ Simulator::Simulator() : exclusive_access_addr_(0), exclusive_access_value_(0) { pc_modified_ = false; icount_ = 0; - break_pc_ = NULL; + break_pc_ = nullptr; break_instr_ = 0; - last_setjmp_buffer_ = NULL; + last_setjmp_buffer_ = nullptr; // Setup architecture state. // All registers are initialized to zero to start with. @@ -829,8 +829,8 @@ Simulator::Simulator() : exclusive_access_addr_(0), exclusive_access_value_(0) { Simulator::~Simulator() { delete[] stack_; Isolate* isolate = Isolate::Current(); - if (isolate != NULL) { - isolate->set_simulator(NULL); + if (isolate != nullptr) { + isolate->set_simulator(nullptr); } } @@ -905,7 +905,7 @@ class Redirection { call_kind_(call_kind), argument_count_(argument_count), hlt_instruction_(Instr::kSimulatorRedirectInstruction), - next_(NULL) {} + next_(nullptr) {} uword external_function_; Simulator::CallKind call_kind_; @@ -935,7 +935,7 @@ uword Simulator::FunctionForRedirect(uword redirect) { Simulator* Simulator::Current() { Isolate* isolate = Isolate::Current(); Simulator* simulator = isolate->simulator(); - if (simulator == NULL) { + if (simulator == nullptr) { NoSafepointScope no_safepoint; simulator = new Simulator(); isolate->set_simulator(simulator); @@ -951,7 +951,7 @@ void Simulator::set_register(Instr* instr, // Register is in range. ASSERT((reg >= 0) && (reg < kNumberOfCpuRegisters)); #if !defined(DART_TARGET_OS_FUCHSIA) - ASSERT(instr == NULL || reg != R18); // R18 is globally reserved on iOS. + ASSERT(instr == nullptr || reg != R18); // R18 is globally reserved on iOS. #endif if ((reg != R31) || (r31t != R31IsZR)) { @@ -963,7 +963,7 @@ void Simulator::set_register(Instr* instr, // useful to find the program locations where CSP is set to a bad value, // than to find only the resulting loads/stores that would cause a fault on // hardware. - if ((instr != NULL) && (reg == R31) && !Utils::IsAligned(value, 16)) { + if ((instr != nullptr) && (reg == R31) && !Utils::IsAligned(value, 16)) { UnalignedAccess("CSP set", value, instr); } @@ -973,10 +973,10 @@ void Simulator::set_register(Instr* instr, // signal handler. Simulate this to ensure we're keeping CSP far enough // ahead of SP to prevent Dart frames from being trashed. uword csp = registers_[R31]; - WriteX(csp - 1 * kWordSize, icount_, NULL); - WriteX(csp - 2 * kWordSize, icount_, NULL); - WriteX(csp - 3 * kWordSize, icount_, NULL); - WriteX(csp - 4 * kWordSize, icount_, NULL); + WriteX(csp - 1 * kWordSize, icount_, nullptr); + WriteX(csp - 2 * kWordSize, icount_, nullptr); + WriteX(csp - 3 * kWordSize, icount_, nullptr); + WriteX(csp - 4 * kWordSize, icount_, nullptr); } #endif } @@ -3797,10 +3797,10 @@ int64_t Simulator::Call(int64_t entry, set_vregisterd(V3, 0, parameter3); set_vregisterd(V3, 1, 0); } else { - set_register(NULL, R0, parameter0); - set_register(NULL, R1, parameter1); - set_register(NULL, R2, parameter2); - set_register(NULL, R3, parameter3); + set_register(nullptr, R0, parameter0); + set_register(nullptr, R1, parameter1); + set_register(nullptr, R2, parameter2); + set_register(nullptr, R3, parameter3); } // Make sure the activation frames are properly aligned. @@ -3809,14 +3809,14 @@ int64_t Simulator::Call(int64_t entry, stack_pointer = Utils::RoundDown(stack_pointer, OS::ActivationFrameAlignment()); } - set_register(NULL, R31, stack_pointer, R31IsSP); + set_register(nullptr, R31, stack_pointer, R31IsSP); // Prepare to execute the code at entry. set_pc(entry); // Put down marker for end of simulation. The simulator will stop simulation // when the PC reaches this value. By saving the "end simulation" value into // the LR the simulation stops when returning to this call point. - set_register(NULL, LR, kEndSimulatingPC); + set_register(nullptr, LR, kEndSimulatingPC); // Remember the values of callee-saved registers, and set them up with a // known value so that we are able to check that they are preserved @@ -3827,7 +3827,7 @@ int64_t Simulator::Call(int64_t entry, for (int i = kAbiFirstPreservedCpuReg; i <= kAbiLastPreservedCpuReg; i++) { const Register r = static_cast(i); preserved_vals[i - kAbiFirstPreservedCpuReg] = get_register(r); - set_register(NULL, r, callee_saved_value); + set_register(nullptr, r, callee_saved_value); } // Only the bottom half of the V registers must be preserved. @@ -3847,7 +3847,7 @@ int64_t Simulator::Call(int64_t entry, for (int i = kAbiFirstPreservedCpuReg; i <= kAbiLastPreservedCpuReg; i++) { const Register r = static_cast(i); ASSERT(callee_saved_value == get_register(r)); - set_register(NULL, r, preserved_vals[i - kAbiFirstPreservedCpuReg]); + set_register(nullptr, r, preserved_vals[i - kAbiFirstPreservedCpuReg]); } for (int i = kAbiFirstPreservedFpuReg; i <= kAbiLastPreservedFpuReg; i++) { @@ -3858,7 +3858,7 @@ int64_t Simulator::Call(int64_t entry, } // Restore the SP register and return R0. - set_register(NULL, R31, sp_before_call, R31IsSP); + set_register(nullptr, R31, sp_before_call, R31IsSP); int64_t return_value; if (fp_return) { return_value = get_vregisterd(V0, 0); @@ -3872,10 +3872,10 @@ void Simulator::JumpToFrame(uword pc, uword sp, uword fp, Thread* thread) { // Walk over all setjmp buffers (simulated --> C++ transitions) // and try to find the setjmp associated with the simulated stack pointer. SimulatorSetjmpBuffer* buf = last_setjmp_buffer(); - while (buf->link() != NULL && buf->link()->sp() <= sp) { + while (buf->link() != nullptr && buf->link()->sp() <= sp) { buf = buf->link(); } - ASSERT(buf != NULL); + ASSERT(buf != nullptr); // The C++ caller has not cleaned up the stack memory of C++ frames. // Prepare for unwinding frames by destroying all the stack resources @@ -3886,10 +3886,10 @@ void Simulator::JumpToFrame(uword pc, uword sp, uword fp, Thread* thread) { // Unwind the C++ stack and continue simulation in the target frame. set_pc(static_cast(pc)); - set_register(NULL, SP, static_cast(sp)); - set_register(NULL, FP, static_cast(fp)); - set_register(NULL, THR, reinterpret_cast(thread)); - set_register(NULL, R31, thread->saved_stack_limit() - 4096); + set_register(nullptr, SP, static_cast(sp)); + set_register(nullptr, FP, static_cast(fp)); + set_register(nullptr, THR, reinterpret_cast(thread)); + set_register(nullptr, R31, thread->saved_stack_limit() - 4096); // Set the tag. thread->set_vm_tag(VMTag::kDartTagId); // Clear top exit frame. @@ -3902,14 +3902,14 @@ void Simulator::JumpToFrame(uword pc, uword sp, uword fp, Thread* thread) { : *reinterpret_cast( code + Code::object_pool_offset() - kHeapObjectTag); pp -= kHeapObjectTag; // In the PP register, the pool pointer is untagged. - set_register(NULL, CODE_REG, code); - set_register(NULL, PP, pp); + set_register(nullptr, CODE_REG, code); + set_register(nullptr, PP, pp); set_register( - NULL, HEAP_BITS, + nullptr, HEAP_BITS, (thread->write_barrier_mask() << 32) | (thread->heap_base() >> 32)); - set_register(NULL, NULL_REG, static_cast(Object::null())); + set_register(nullptr, NULL_REG, static_cast(Object::null())); if (FLAG_precompiled_mode) { - set_register(NULL, DISPATCH_TABLE_REG, + set_register(nullptr, DISPATCH_TABLE_REG, reinterpret_cast(thread->dispatch_table_array())); } diff --git a/runtime/vm/simulator_riscv.cc b/runtime/vm/simulator_riscv.cc index 19c250367b1..95474e97fa4 100644 --- a/runtime/vm/simulator_riscv.cc +++ b/runtime/vm/simulator_riscv.cc @@ -140,7 +140,7 @@ class Redirection { call_kind_(call_kind), argument_count_(argument_count), ecall_instruction_(Instr::kSimulatorRedirectInstruction), - next_(NULL) {} + next_(nullptr) {} uword external_function_; Simulator::CallKind call_kind_; @@ -170,7 +170,7 @@ uword Simulator::FunctionForRedirect(uword redirect) { Simulator* Simulator::Current() { Isolate* isolate = Isolate::Current(); Simulator* simulator = isolate->simulator(); - if (simulator == NULL) { + if (simulator == nullptr) { NoSafepointScope no_safepoint; simulator = new Simulator(); isolate->set_simulator(simulator); @@ -187,7 +187,7 @@ Simulator::Simulator() reserved_value_(0), fcsr_(0), random_(), - last_setjmp_buffer_(NULL) { + last_setjmp_buffer_(nullptr) { // Setup simulator support first. Some of this information is needed to // setup the architecture state. // We allocate the stack here, the size is computed as the sum of @@ -229,8 +229,8 @@ Simulator::Simulator() Simulator::~Simulator() { delete[] stack_; Isolate* isolate = Isolate::Current(); - if (isolate != NULL) { - isolate->set_simulator(NULL); + if (isolate != nullptr) { + isolate->set_simulator(nullptr); } } @@ -432,10 +432,10 @@ void Simulator::JumpToFrame(uword pc, uword sp, uword fp, Thread* thread) { // Walk over all setjmp buffers (simulated --> C++ transitions) // and try to find the setjmp associated with the simulated stack pointer. SimulatorSetjmpBuffer* buf = last_setjmp_buffer(); - while (buf->link() != NULL && buf->link()->sp() <= sp) { + while (buf->link() != nullptr && buf->link()->sp() <= sp) { buf = buf->link(); } - ASSERT(buf != NULL); + ASSERT(buf != nullptr); // The C++ caller has not cleaned up the stack memory of C++ frames. // Prepare for unwinding frames by destroying all the stack resources diff --git a/runtime/vm/simulator_x64.cc b/runtime/vm/simulator_x64.cc index 936427170a8..db5015b4e8b 100644 --- a/runtime/vm/simulator_x64.cc +++ b/runtime/vm/simulator_x64.cc @@ -22,7 +22,7 @@ namespace dart { Simulator* Simulator::Current() { Isolate* isolate = Isolate::Current(); Simulator* simulator = isolate->simulator(); - if (simulator == NULL) { + if (simulator == nullptr) { NoSafepointScope no_safepoint; simulator = new Simulator(); isolate->set_simulator(simulator); @@ -36,8 +36,8 @@ Simulator::Simulator() {} Simulator::~Simulator() { Isolate* isolate = Isolate::Current(); - if (isolate != NULL) { - isolate->set_simulator(NULL); + if (isolate != nullptr) { + isolate->set_simulator(nullptr); } } diff --git a/runtime/vm/snapshot.cc b/runtime/vm/snapshot.cc index 211d7e1f602..36d8b38650e 100644 --- a/runtime/vm/snapshot.cc +++ b/runtime/vm/snapshot.cc @@ -28,16 +28,16 @@ const char* Snapshot::KindToCString(Kind kind) { } const Snapshot* Snapshot::SetupFromBuffer(const void* raw_memory) { - ASSERT(raw_memory != NULL); + ASSERT(raw_memory != nullptr); const Snapshot* snapshot = reinterpret_cast(raw_memory); if (!snapshot->check_magic()) { - return NULL; + return nullptr; } // If the raw length is negative or greater than what the local machine can // handle, then signal an error. int64_t length = snapshot->large_length(); if ((length < 0) || (length > kIntptrMax)) { - return NULL; + return nullptr; } return snapshot; } diff --git a/runtime/vm/snapshot.h b/runtime/vm/snapshot.h index 351c52fa722..6499742d4b6 100644 --- a/runtime/vm/snapshot.h +++ b/runtime/vm/snapshot.h @@ -81,7 +81,7 @@ class Snapshot { const uint8_t* DataImage() const { if (!IncludesCode(kind())) { - return NULL; + return nullptr; } uword offset = Utils::RoundUp(length(), kObjectStartAlignment); return Addr() + offset; diff --git a/runtime/vm/snapshot_test.cc b/runtime/vm/snapshot_test.cc index ddf602bcdcc..2d2f77a1dc4 100644 --- a/runtime/vm/snapshot_test.cc +++ b/runtime/vm/snapshot_test.cc @@ -473,7 +473,7 @@ TEST_CASE(FailSerializeLargeArray) { Dart_CObject root; root.type = Dart_CObject_kArray; root.value.as_array.length = Array::kMaxElements + 1; - root.value.as_array.values = NULL; + root.value.as_array.values = nullptr; ApiNativeScope scope; ExpectEncodeFail(scope.zone(), &root); } @@ -549,7 +549,7 @@ ISOLATE_UNIT_TEST_CASE(SerializeEmptyArray) { Dart_CObject* root = ReadApiMessage(scope.zone(), message.get()); EXPECT_EQ(Dart_CObject_kArray, root->type); EXPECT_EQ(kArrayLength, root->value.as_array.length); - EXPECT(root->value.as_array.values == NULL); + EXPECT(root->value.as_array.values == nullptr); CheckEncodeDecodeMessage(scope.zone(), root); } @@ -702,7 +702,7 @@ ISOLATE_UNIT_TEST_CASE(SerializeEmptyByteArray) { EXPECT_EQ(Dart_CObject_kTypedData, root->type); EXPECT_EQ(Dart_TypedData_kUint8, root->value.as_typed_data.type); EXPECT_EQ(kTypedDataLength, root->value.as_typed_data.length); - EXPECT(root->value.as_typed_data.values == NULL); + EXPECT(root->value.as_typed_data.values == nullptr); CheckEncodeDecodeMessage(scope.zone(), root); } @@ -747,7 +747,7 @@ VM_UNIT_TEST_CASE(FullSnapshot) { TestIsolateScope __test_isolate__; // Create a test library and Load up a test script in it. - TestCase::LoadTestScript(kScriptChars.get(), NULL); + TestCase::LoadTestScript(kScriptChars.get(), nullptr); Thread* thread = Thread::Current(); TransitionNativeToVM transition(thread); @@ -785,7 +785,7 @@ VM_UNIT_TEST_CASE(FullSnapshot) { // Invoke a function which returns an object. Dart_Handle cls = Dart_GetClass(TestCase::lib(), NewString("FieldsTest")); - result = Dart_Invoke(cls, NewString("testMain"), 0, NULL); + result = Dart_Invoke(cls, NewString("testMain"), 0, nullptr); EXPECT_VALID(result); Dart_ExitScope(); } @@ -799,7 +799,7 @@ static std::unique_ptr GetSerialized(Dart_Handle lib, Dart_Handle result; { TransitionVMToNative transition(Thread::Current()); - result = Dart_Invoke(lib, NewString(dart_function), 0, NULL); + result = Dart_Invoke(lib, NewString(dart_function), 0, nullptr); EXPECT_VALID(result); } Object& obj = Object::Handle(Api::UnwrapHandle(result)); @@ -872,53 +872,55 @@ VM_UNIT_TEST_CASE(DartGeneratedMessages) { TestCase::CreateTestIsolate(); Isolate* isolate = Isolate::Current(); - EXPECT(isolate != NULL); + EXPECT(isolate != nullptr); Dart_EnterScope(); - Dart_Handle lib = TestCase::LoadTestScript(kCustomIsolateScriptChars, NULL); + Dart_Handle lib = + TestCase::LoadTestScript(kCustomIsolateScriptChars, nullptr); EXPECT_VALID(lib); Dart_Handle smi_result; - smi_result = Dart_Invoke(lib, NewString("getSmi"), 0, NULL); + smi_result = Dart_Invoke(lib, NewString("getSmi"), 0, nullptr); EXPECT_VALID(smi_result); Dart_Handle ascii_string_result; - ascii_string_result = Dart_Invoke(lib, NewString("getAsciiString"), 0, NULL); + ascii_string_result = + Dart_Invoke(lib, NewString("getAsciiString"), 0, nullptr); EXPECT_VALID(ascii_string_result); EXPECT(Dart_IsString(ascii_string_result)); Dart_Handle non_ascii_string_result; non_ascii_string_result = - Dart_Invoke(lib, NewString("getNonAsciiString"), 0, NULL); + Dart_Invoke(lib, NewString("getNonAsciiString"), 0, nullptr); EXPECT_VALID(non_ascii_string_result); EXPECT(Dart_IsString(non_ascii_string_result)); Dart_Handle non_bmp_string_result; non_bmp_string_result = - Dart_Invoke(lib, NewString("getNonBMPString"), 0, NULL); + Dart_Invoke(lib, NewString("getNonBMPString"), 0, nullptr); EXPECT_VALID(non_bmp_string_result); EXPECT(Dart_IsString(non_bmp_string_result)); Dart_Handle lead_surrogate_string_result; lead_surrogate_string_result = - Dart_Invoke(lib, NewString("getLeadSurrogateString"), 0, NULL); + Dart_Invoke(lib, NewString("getLeadSurrogateString"), 0, nullptr); EXPECT_VALID(lead_surrogate_string_result); EXPECT(Dart_IsString(lead_surrogate_string_result)); Dart_Handle trail_surrogate_string_result; trail_surrogate_string_result = - Dart_Invoke(lib, NewString("getTrailSurrogateString"), 0, NULL); + Dart_Invoke(lib, NewString("getTrailSurrogateString"), 0, nullptr); EXPECT_VALID(trail_surrogate_string_result); EXPECT(Dart_IsString(trail_surrogate_string_result)); Dart_Handle surrogates_string_result; surrogates_string_result = - Dart_Invoke(lib, NewString("getSurrogatesString"), 0, NULL); + Dart_Invoke(lib, NewString("getSurrogatesString"), 0, nullptr); EXPECT_VALID(surrogates_string_result); EXPECT(Dart_IsString(surrogates_string_result)); Dart_Handle crappy_string_result; crappy_string_result = - Dart_Invoke(lib, NewString("getCrappyString"), 0, NULL); + Dart_Invoke(lib, NewString("getCrappyString"), 0, nullptr); EXPECT_VALID(crappy_string_result); EXPECT(Dart_IsString(crappy_string_result)); @@ -987,10 +989,10 @@ VM_UNIT_TEST_CASE(DartGeneratedListMessages) { TestCase::CreateTestIsolate(); Thread* thread = Thread::Current(); - EXPECT(thread->isolate() != NULL); + EXPECT(thread->isolate() != nullptr); Dart_EnterScope(); - Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, nullptr); EXPECT_VALID(lib); { @@ -1111,10 +1113,10 @@ VM_UNIT_TEST_CASE(DartGeneratedArrayLiteralMessages) { TestCase::CreateTestIsolate(); Thread* thread = Thread::Current(); - EXPECT(thread->isolate() != NULL); + EXPECT(thread->isolate() != nullptr); Dart_EnterScope(); - Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, nullptr); EXPECT_VALID(lib); { @@ -1344,10 +1346,10 @@ VM_UNIT_TEST_CASE(DartGeneratedListMessagesWithBackref) { TestCase::CreateTestIsolate(); Thread* thread = Thread::Current(); - EXPECT(thread->isolate() != NULL); + EXPECT(thread->isolate() != nullptr); Dart_EnterScope(); - Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, nullptr); EXPECT_VALID(lib); { @@ -1543,10 +1545,10 @@ VM_UNIT_TEST_CASE(DartGeneratedArrayLiteralMessagesWithBackref) { TestCase::CreateTestIsolate(); Thread* thread = Thread::Current(); - EXPECT(thread->isolate() != NULL); + EXPECT(thread->isolate() != nullptr); Dart_EnterScope(); - Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, nullptr); EXPECT_VALID(lib); { @@ -1784,10 +1786,10 @@ VM_UNIT_TEST_CASE(DartGeneratedListMessagesWithTypedData) { TestCase::CreateTestIsolate(); Thread* thread = Thread::Current(); - EXPECT(thread->isolate() != NULL); + EXPECT(thread->isolate() != nullptr); Dart_EnterScope(); - Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, nullptr); EXPECT_VALID(lib); { @@ -1936,10 +1938,10 @@ VM_UNIT_TEST_CASE(PostCObject) { " };\n" " return sendPort;\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, nullptr); Dart_EnterScope(); - Dart_Handle send_port = Dart_Invoke(lib, NewString("main"), 0, NULL); + Dart_Handle send_port = Dart_Invoke(lib, NewString("main"), 0, nullptr); EXPECT_VALID(send_port); Dart_Port port_id; Dart_Handle result = Dart_SendPortGetId(send_port, &port_id); @@ -2038,7 +2040,7 @@ VM_UNIT_TEST_CASE(PostCObject) { } TEST_CASE(IsKernelNegative) { - EXPECT(!Dart_IsKernel(NULL, 0)); + EXPECT(!Dart_IsKernel(nullptr, 0)); uint8_t buffer[4] = {0, 0, 0, 0}; EXPECT(!Dart_IsKernel(buffer, ARRAY_SIZE(buffer))); @@ -2058,7 +2060,7 @@ VM_UNIT_TEST_CASE(LegacyErasureDetectionInFullSnapshot) { TestIsolateScope __test_isolate__; // Create a test library and Load up a test script in it. - Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, nullptr); EXPECT_VALID(lib); Thread* thread = Thread::Current(); @@ -2076,7 +2078,7 @@ VM_UNIT_TEST_CASE(LegacyErasureDetectionInFullSnapshot) { // Invoke a function so that the constant is evaluated. cls = Dart_GetClass(TestCase::lib(), NewString("Generic")); - result = Dart_Invoke(cls, NewString("testMain"), 0, NULL); + result = Dart_Invoke(cls, NewString("testMain"), 0, nullptr); EXPECT_VALID(result); } // Verify that legacy erasure is required in strong mode. diff --git a/runtime/vm/source_report.cc b/runtime/vm/source_report.cc index 737a9a8042b..f5e243bf7ef 100644 --- a/runtime/vm/source_report.cc +++ b/runtime/vm/source_report.cc @@ -30,8 +30,8 @@ SourceReport::SourceReport(intptr_t report_set, compile_mode_(compile_mode), report_lines_(report_lines), library_filters_(GrowableObjectArray::Handle()), - thread_(NULL), - script_(NULL), + thread_(nullptr), + script_(nullptr), start_pos_(TokenPosition::kMinSource), end_pos_(TokenPosition::kMaxSource), next_script_index_(0) {} @@ -44,8 +44,8 @@ SourceReport::SourceReport(intptr_t report_set, compile_mode_(compile_mode), report_lines_(report_lines), library_filters_(library_filters), - thread_(NULL), - script_(NULL), + thread_(nullptr), + script_(nullptr), start_pos_(TokenPosition::kMinSource), end_pos_(TokenPosition::kMaxSource), next_script_index_(0) {} @@ -65,7 +65,7 @@ void SourceReport::ClearScriptTable() { script_table_.Clear(); for (intptr_t i = 0; i < script_table_entries_.length(); i++) { - script_table_entries_[i] = NULL; + script_table_entries_[i] = nullptr; } script_table_entries_.Clear(); @@ -101,7 +101,7 @@ bool SourceReport::ShouldSkipFunction(const Function& func) { return true; } - if (script_ != NULL && !script_->IsNull()) { + if (script_ != nullptr && !script_->IsNull()) { if (func.script() != script_->ptr()) { // The function is from the wrong script. return true; @@ -186,7 +186,7 @@ bool SourceReport::ShouldSkipField(const Field& field) { return true; } - if (script_ != NULL && !script_->IsNull()) { + if (script_ != nullptr && !script_->IsNull()) { if (field.Script() != script_->ptr()) { // The field is from the wrong script. return true; @@ -227,7 +227,7 @@ intptr_t SourceReport::GetScriptIndex(const Script& script) { wrapper.key = &url; wrapper.script = &Script::Handle(zone(), script.ptr()); ScriptTableEntry* pair = script_table_.LookupValue(&wrapper); - if (pair != NULL) { + if (pair != nullptr) { return pair->index; } ScriptTableEntry* tmp = new ScriptTableEntry(); @@ -297,7 +297,7 @@ void SourceReport::PrintCallSitesData(JSONObject* jsobj, HANDLESCOPE(thread()); ASSERT(iter.DeoptId() < ic_data_array->length()); const ICData* ic_data = (*ic_data_array)[iter.DeoptId()]; - if (ic_data != NULL) { + if (ic_data != nullptr) { const TokenPosition& token_pos = iter.TokenPos(); if (!token_pos.IsWithin(begin_pos, end_pos)) { // Does not correspond to a valid source position. @@ -320,7 +320,7 @@ intptr_t SourceReport::GetTokenPosOrLine(const Script& script, } bool SourceReport::ShouldCoverageSkipCallSite(const ICData* ic_data) { - if (ic_data == NULL) return true; + if (ic_data == nullptr) return true; if (!ic_data->is_static_call()) return false; Function& func = Function::Handle(ic_data->GetTargetAt(0)); @@ -485,7 +485,7 @@ void SourceReport::PrintPossibleBreakpointsData(JSONObject* jsobj, void SourceReport::PrintProfileData(JSONObject* jsobj, ProfileFunction* profile_function) { - ASSERT(profile_function != NULL); + ASSERT(profile_function != nullptr); ASSERT(profile_function->NumSourcePositions() > 0); { @@ -602,7 +602,7 @@ void SourceReport::VisitFunction(JSONArray* jsarr, const Function& func) { } if (IsReportRequested(kProfile)) { ProfileFunction* profile_function = profile_.FindFunction(func); - if ((profile_function != NULL) && + if ((profile_function != nullptr) && (profile_function->NumSourcePositions() > 0)) { PrintProfileData(&range, profile_function); } @@ -751,7 +751,7 @@ void SourceReport::CollectAllScripts( wrapper.key = &url; wrapper.script = &Script::Handle(zone(), scriptRef.ptr()); ScriptTableEntry* pair = local_script_table->LookupValue(&wrapper); - if (pair != NULL) { + if (pair != nullptr) { // Existing one. continue; } @@ -771,7 +771,7 @@ void SourceReport::CleanupCollectedScripts( GrowableArray* local_script_table_entries) { for (intptr_t i = 0; i < local_script_table_entries->length(); i++) { delete local_script_table_entries->operator[](i); - local_script_table_entries->operator[](i) = NULL; + local_script_table_entries->operator[](i) = nullptr; } local_script_table_entries->Clear(); local_script_table->Clear(); diff --git a/runtime/vm/source_report.h b/runtime/vm/source_report.h index 0904aee1c56..269f3ce5004 100644 --- a/runtime/vm/source_report.h +++ b/runtime/vm/source_report.h @@ -105,7 +105,7 @@ class SourceReport { void VisitClosures(JSONArray* jsarr); // An entry in the script table. struct ScriptTableEntry { - ScriptTableEntry() : key(NULL), index(-1), script(NULL) {} + ScriptTableEntry() : key(nullptr), index(-1), script(nullptr) {} const String* key; intptr_t index; diff --git a/runtime/vm/source_report_test.cc b/runtime/vm/source_report_test.cc index 22ef9de090a..b8f2fdbfd82 100644 --- a/runtime/vm/source_report_test.cc +++ b/runtime/vm/source_report_test.cc @@ -15,12 +15,12 @@ static ObjectPtr ExecuteScript(const char* script, bool allow_errors = false) { { TransitionVMToNative transition(Thread::Current()); if (allow_errors) { - lib = TestCase::LoadTestScriptWithErrors(script, NULL); + lib = TestCase::LoadTestScriptWithErrors(script, nullptr); } else { - lib = TestCase::LoadTestScript(script, NULL); + lib = TestCase::LoadTestScript(script, nullptr); } EXPECT_VALID(lib); - Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL); + Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, nullptr); EXPECT_VALID(result); } return Api::UnwrapHandle(lib); diff --git a/runtime/vm/stack_frame.cc b/runtime/vm/stack_frame.cc index 5fdd616ae33..145e63cbdf7 100644 --- a/runtime/vm/stack_frame.cc +++ b/runtime/vm/stack_frame.cc @@ -154,7 +154,7 @@ bool StackFrame::IsStubFrame() const { ASSERT(!(IsEntryFrame() || IsExitFrame())); #if !defined(DART_HOST_OS_WINDOWS) && !defined(DART_HOST_OS_FUCHSIA) // On Windows and Fuchsia, the profiler calls this from a separate thread - // where Thread::Current() is NULL, so we cannot create a NoSafepointScope. + // where Thread::Current() is nullptr, so we cannot create a NoSafepointScope. NoSafepointScope no_safepoint; #endif @@ -178,7 +178,7 @@ const char* StackFrame::ToCString() const { } void ExitFrame::VisitObjectPointers(ObjectPointerVisitor* visitor) { - ASSERT(visitor != NULL); + ASSERT(visitor != nullptr); // Visit pc marker and saved pool pointer. ObjectPtr* last_fixed = reinterpret_cast(fp()) + runtime_frame_layout.first_object_from_fp; @@ -193,7 +193,7 @@ void ExitFrame::VisitObjectPointers(ObjectPointerVisitor* visitor) { } void EntryFrame::VisitObjectPointers(ObjectPointerVisitor* visitor) { - ASSERT(visitor != NULL); + ASSERT(visitor != nullptr); // Visit objects between SP and (FP - callee_save_area). ObjectPtr* first = reinterpret_cast(sp()); ObjectPtr* last = @@ -203,7 +203,7 @@ void EntryFrame::VisitObjectPointers(ObjectPointerVisitor* visitor) { } void StackFrame::VisitObjectPointers(ObjectPointerVisitor* visitor) { - ASSERT(visitor != NULL); + ASSERT(visitor != nullptr); // NOTE: This code runs while GC is in progress and runs within // a NoHandleScope block. Hence it is not ok to use regular Zone or // Scope handles. We use direct stack handles, the raw pointers in @@ -338,7 +338,7 @@ CodePtr StackFrame::LookupDartCode() const { // that the code is called while a GC is in progress, that is ok. #if !defined(DART_HOST_OS_WINDOWS) && !defined(DART_HOST_OS_FUCHSIA) // On Windows and Fuchsia, the profiler calls this from a separate thread - // where Thread::Current() is NULL, so we cannot create a NoSafepointScope. + // where Thread::Current() is nullptr, so we cannot create a NoSafepointScope. NoSafepointScope no_safepoint; #endif CodePtr code = GetCodeObject(); @@ -388,7 +388,7 @@ bool StackFrame::FindExceptionHandler(Thread* thread, *is_optimized = code.is_optimized(); HandlerInfoCache* cache = thread->isolate()->handler_info_cache(); ExceptionHandlerInfo* info = cache->Lookup(pc()); - if (info != NULL) { + if (info != nullptr) { *handler_pc = start + info->handler_pc_offset; *needs_stacktrace = (info->needs_stacktrace != 0); *has_catch_all = (info->has_catch_all != 0); @@ -462,7 +462,7 @@ void StackFrame::DumpCurrentTrace() { } void StackFrameIterator::SetupLastExitFrameData() { - ASSERT(thread_ != NULL); + ASSERT(thread_ != nullptr); uword exit_marker = thread_->top_exit_frame_info(); frames_.fp_ = exit_marker; frames_.sp_ = 0; @@ -487,7 +487,7 @@ StackFrameIterator::StackFrameIterator(ValidationPolicy validation_policy, entry_(thread), exit_(thread), frames_(thread), - current_frame_(NULL), + current_frame_(nullptr), thread_(thread) { ASSERT(cross_thread_policy == kAllowCrossThreadIteration || thread_ == Thread::Current()); @@ -502,7 +502,7 @@ StackFrameIterator::StackFrameIterator(uword last_fp, entry_(thread), exit_(thread), frames_(thread), - current_frame_(NULL), + current_frame_(nullptr), thread_(thread) { ASSERT(cross_thread_policy == kAllowCrossThreadIteration || thread_ == Thread::Current()); @@ -522,7 +522,7 @@ StackFrameIterator::StackFrameIterator(uword fp, entry_(thread), exit_(thread), frames_(thread), - current_frame_(NULL), + current_frame_(nullptr), thread_(thread) { ASSERT(cross_thread_policy == kAllowCrossThreadIteration || thread_ == Thread::Current()); @@ -547,20 +547,20 @@ StackFrameIterator::StackFrameIterator(const StackFrameIterator& orig) StackFrame* StackFrameIterator::NextFrame() { // When we are at the start of iteration after having created an - // iterator object, current_frame_ will be NULL as we haven't seen + // iterator object, current_frame_ will be nullptr as we haven't seen // any frames yet (unless we start iterating in the simulator from a given // triplet of fp, sp, and pc). At this point, if NextFrame is called, it tries // to set up the next exit frame by reading the top_exit_frame_info // from the isolate. If we do not have any dart invocations yet, - // top_exit_frame_info will be 0 and so we would return NULL. + // top_exit_frame_info will be 0 and so we would return nullptr. - // current_frame_ will also be NULL, when we are at the end of having + // current_frame_ will also be nullptr, when we are at the end of having // iterated through all the frames. If NextFrame is called at this // point, we will try and set up the next exit frame, but since we are - // at the end of the iteration, fp_ will be 0 and we would return NULL. - if (current_frame_ == NULL) { + // at the end of the iteration, fp_ will be 0 and we would return nullptr. + if (current_frame_ == nullptr) { if (!HasNextFrame()) { - return NULL; + return nullptr; } if (frames_.pc_ == 0) { // Iteration starts from an exit frame given by its fp. @@ -582,7 +582,7 @@ StackFrame* StackFrameIterator::NextFrame() { current_frame_ = NextExitFrame(); return current_frame_; } - current_frame_ = NULL; // No more frames. + current_frame_ = nullptr; // No more frames. return current_frame_; } ASSERT(!validate_ || current_frame_->IsExitFrame() || @@ -747,7 +747,7 @@ void ValidateFrames() { Thread::Current(), StackFrameIterator::kNoCrossThreadIteration); StackFrame* frame = frames.NextFrame(); - while (frame != NULL) { + while (frame != nullptr) { frame = frames.NextFrame(); } } diff --git a/runtime/vm/stack_frame.h b/runtime/vm/stack_frame.h index e4cde303b7d..56a95100f2d 100644 --- a/runtime/vm/stack_frame.h +++ b/runtime/vm/stack_frame.h @@ -351,7 +351,7 @@ class DartFrameIterator { // Get next dart frame. StackFrame* NextFrame() { StackFrame* frame = frames_.NextFrame(); - while (frame != NULL && !frame->IsDartFrame(frames_.validate())) { + while (frame != nullptr && !frame->IsDartFrame(frames_.validate())) { frame = frames_.NextFrame(); } return frame; diff --git a/runtime/vm/stack_frame_test.cc b/runtime/vm/stack_frame_test.cc index f53745801d5..42285132416 100644 --- a/runtime/vm/stack_frame_test.cc +++ b/runtime/vm/stack_frame_test.cc @@ -22,7 +22,7 @@ ISOLATE_UNIT_TEST_CASE(EmptyStackFrameIteration) { Thread::Current(), StackFrameIterator::kNoCrossThreadIteration); EXPECT(!iterator.HasNextFrame()); - EXPECT(iterator.NextFrame() == NULL); + EXPECT(iterator.NextFrame() == nullptr); VerifyPointersVisitor::VerifyPointers(); } @@ -30,7 +30,7 @@ ISOLATE_UNIT_TEST_CASE(EmptyStackFrameIteration) { ISOLATE_UNIT_TEST_CASE(EmptyDartStackFrameIteration) { DartFrameIterator iterator(Thread::Current(), StackFrameIterator::kNoCrossThreadIteration); - EXPECT(iterator.NextFrame() == NULL); + EXPECT(iterator.NextFrame() == nullptr); VerifyPointersVisitor::VerifyPointers(); } @@ -59,7 +59,7 @@ void FUNCTION_NAME(StackFrame_frameCount)(Dart_NativeArguments args) { StackFrameIterator frames(ValidationPolicy::kValidateFrames, arguments->thread(), StackFrameIterator::kNoCrossThreadIteration); - while (frames.NextFrame() != NULL) { + while (frames.NextFrame() != nullptr) { count += 1; // Count the frame. } VerifyPointersVisitor::VerifyPointers(); @@ -71,7 +71,7 @@ void FUNCTION_NAME(StackFrame_dartFrameCount)(Dart_NativeArguments args) { int count = 0; DartFrameIterator frames(Thread::Current(), StackFrameIterator::kNoCrossThreadIteration); - while (frames.NextFrame() != NULL) { + while (frames.NextFrame() != nullptr) { count += 1; // Count the dart frame. } VerifyPointersVisitor::VerifyPointers(); @@ -95,7 +95,7 @@ void FUNCTION_NAME(StackFrame_validateFrame)(Dart_NativeArguments args) { int count = 0; DartFrameIterator frames(thread, StackFrameIterator::kNoCrossThreadIteration); StackFrame* frame = frames.NextFrame(); - while (frame != NULL) { + while (frame != nullptr) { if (count == frame_index) { // Find the function corresponding to this frame and check if it // matches the function name passed in. @@ -139,13 +139,13 @@ static struct NativeEntries { static Dart_NativeFunction native_lookup(Dart_Handle name, int argument_count, bool* auto_setup_scope) { - ASSERT(auto_setup_scope != NULL); + ASSERT(auto_setup_scope != nullptr); *auto_setup_scope = false; TransitionNativeToVM transition(Thread::Current()); const Object& obj = Object::Handle(Api::UnwrapHandle(name)); ASSERT(obj.IsString()); const char* function_name = obj.ToCString(); - ASSERT(function_name != NULL); + ASSERT(function_name != nullptr); int num_entries = sizeof(BuiltinEntries) / sizeof(struct NativeEntries); for (int i = 0; i < num_entries; i++) { struct NativeEntries* entry = &(BuiltinEntries[i]); @@ -154,7 +154,7 @@ static Dart_NativeFunction native_lookup(Dart_Handle name, return reinterpret_cast(entry->function_); } } - return NULL; + return nullptr; } // Unit test case to verify stack frame iteration. @@ -252,7 +252,7 @@ TEST_CASE(ValidateStackFrameIteration) { kScriptChars.get(), reinterpret_cast(native_lookup)); Dart_Handle cls = Dart_GetClass(lib, NewString("StackFrameTest")); - EXPECT_VALID(Dart_Invoke(cls, NewString("testMain"), 0, NULL)); + EXPECT_VALID(Dart_Invoke(cls, NewString("testMain"), 0, nullptr)); } // Unit test case to verify stack frame iteration. @@ -343,7 +343,7 @@ TEST_CASE(ValidateNoSuchMethodStackFrameIteration) { Dart_Handle lib = TestCase::LoadTestScript( kScriptChars, reinterpret_cast(native_lookup)); Dart_Handle cls = Dart_GetClass(lib, NewString("StackFrame2Test")); - EXPECT_VALID(Dart_Invoke(cls, NewString("testMain"), 0, NULL)); + EXPECT_VALID(Dart_Invoke(cls, NewString("testMain"), 0, nullptr)); } } // namespace dart diff --git a/runtime/vm/stack_trace.h b/runtime/vm/stack_trace.h index 6242f72ca26..9e11620471f 100644 --- a/runtime/vm/stack_trace.h +++ b/runtime/vm/stack_trace.h @@ -129,7 +129,7 @@ class StackTraceUtils : public AllStatic { /// From there on finds the closure of the async/async* frame and starts /// traversing the listeners. /// - /// If [on_sync_frames] is non-nullptr, it will be called for every + /// If [on_sync_frames] is non-null, it will be called for every /// synchronous frame which is collected. static void CollectFrames( Thread* thread, diff --git a/runtime/vm/stub_code.cc b/runtime/vm/stub_code.cc index 95c26177d1b..f70ddfac5a0 100644 --- a/runtime/vm/stub_code.cc +++ b/runtime/vm/stub_code.cc @@ -201,8 +201,8 @@ CodePtr StubCode::GetAllocationStubForClass(const Class& cls) { Precompiler* precompiler = Precompiler::Instance(); compiler::ObjectPoolBuilder* wrapper = - precompiler != NULL ? precompiler->global_object_pool_builder() - : &object_pool_builder; + precompiler != nullptr ? precompiler->global_object_pool_builder() + : &object_pool_builder; const auto pool_attachment = FLAG_precompiled_mode ? Code::PoolAttachment::kNotAttachPool diff --git a/runtime/vm/stub_code.h b/runtime/vm/stub_code.h index ab7eb15f7e2..0a9e1898cbd 100644 --- a/runtime/vm/stub_code.h +++ b/runtime/vm/stub_code.h @@ -52,7 +52,7 @@ class StubCode : public AllStatic { // Check if the specified pc is in the jump to frame stub. static bool InJumpToFrameStub(uword pc); - // Returns NULL if no stub found. + // Returns nullptr if no stub found. static const char* NameOfStub(uword entry_point); // Define the shared stub code accessors. diff --git a/runtime/vm/symbols.cc b/runtime/vm/symbols.cc index 78a709319f3..e17cd8b3e53 100644 --- a/runtime/vm/symbols.cc +++ b/runtime/vm/symbols.cc @@ -23,7 +23,7 @@ String* Symbols::symbol_handles_[Symbols::kMaxPredefinedId]; static const char* const names[] = { // clang-format off - NULL, + nullptr, #define DEFINE_SYMBOL_LITERAL(symbol, literal) literal, PREDEFINED_SYMBOLS_LIST(DEFINE_SYMBOL_LITERAL) #undef DEFINE_SYMBOL_LITERAL @@ -74,7 +74,7 @@ const String& Symbols::Token(Token::Kind token) { ASSERT((0 <= tok_index) && (tok_index < Token::kNumTokens)); // First keyword symbol is in symbol_handles_[kTokenTableStart + 1]. const intptr_t token_id = Symbols::kTokenTableStart + 1 + tok_index; - ASSERT(symbol_handles_[token_id] != NULL); + ASSERT(symbol_handles_[token_id] != nullptr); return *symbol_handles_[token_id]; } @@ -189,7 +189,7 @@ void Symbols::GetStats(IsolateGroup* isolate_group, } StringPtr Symbols::New(Thread* thread, const char* cstr, intptr_t len) { - ASSERT((cstr != NULL) && (len >= 0)); + ASSERT((cstr != nullptr) && (len >= 0)); const uint8_t* utf8_array = reinterpret_cast(cstr); return Symbols::FromUTF8(thread, utf8_array, len); } @@ -197,8 +197,8 @@ StringPtr Symbols::New(Thread* thread, const char* cstr, intptr_t len) { StringPtr Symbols::FromUTF8(Thread* thread, const uint8_t* utf8_array, intptr_t array_len) { - if (array_len == 0 || utf8_array == NULL) { - return FromLatin1(thread, static_cast(NULL), 0); + if (array_len == 0 || utf8_array == nullptr) { + return FromLatin1(thread, static_cast(nullptr), 0); } Utf8::Type type; intptr_t len = Utf8::CodeUnitCount(utf8_array, array_len, &type); @@ -469,7 +469,7 @@ StringPtr Symbols::NewFormattedV(Thread* thread, va_list args) { va_list args_copy; va_copy(args_copy, args); - intptr_t len = Utils::VSNPrint(NULL, 0, format, args_copy); + intptr_t len = Utils::VSNPrint(nullptr, 0, format, args_copy); va_end(args_copy); Zone* zone = Thread::Current()->zone(); diff --git a/runtime/vm/tagged_pointer.h b/runtime/vm/tagged_pointer.h index c0327529104..13e12d7b295 100644 --- a/runtime/vm/tagged_pointer.h +++ b/runtime/vm/tagged_pointer.h @@ -321,8 +321,12 @@ struct base_ptr_type< class Untagged##klass; \ class klass##Ptr : public base##Ptr { \ public: \ - klass##Ptr* operator->() { return this; } \ - const klass##Ptr* operator->() const { return this; } \ + klass##Ptr* operator->() { \ + return this; \ + } \ + const klass##Ptr* operator->() const { \ + return this; \ + } \ Untagged##klass* untag() { \ return reinterpret_cast(untagged_pointer()); \ } \ @@ -340,7 +344,9 @@ struct base_ptr_type< constexpr klass##Ptr(std::nullptr_t) : base##Ptr(nullptr) {} /* NOLINT */ \ explicit klass##Ptr(const UntaggedObject* untagged) \ : base##Ptr(reinterpret_cast(untagged) + kHeapObjectTag) {} \ - klass##Ptr Decompress(uword heap_base) const { return *this; } \ + klass##Ptr Decompress(uword heap_base) const { \ + return *this; \ + } \ }; \ DEFINE_COMPRESSED_POINTER(klass, base) diff --git a/runtime/vm/tags.cc b/runtime/vm/tags.cc index acf76271cdc..fb0b2727dc5 100644 --- a/runtime/vm/tags.cc +++ b/runtime/vm/tags.cc @@ -19,13 +19,13 @@ Mutex* UserTags::subscribed_tags_lock_ = nullptr; const char* VMTag::TagName(uword tag) { if (IsNativeEntryTag(tag)) { const uint8_t* native_reverse_lookup = NativeEntry::ResolveSymbol(tag); - if (native_reverse_lookup != NULL) { + if (native_reverse_lookup != nullptr) { return reinterpret_cast(native_reverse_lookup); } return "Unknown native entry"; } else if (IsRuntimeEntryTag(tag)) { const char* runtime_entry_name = RuntimeEntryTagName(tag); - ASSERT(runtime_entry_name != NULL); + ASSERT(runtime_entry_name != nullptr); return runtime_entry_name; } ASSERT(tag != kInvalidTagId); @@ -79,8 +79,8 @@ const VMTag::TagEntry VMTag::entries_[] = { VMTagScope::VMTagScope(Thread* thread, uword tag, bool conditional_set) : ThreadStackResource(thread) { - if (thread != NULL) { - ASSERT(isolate_group() != NULL); + if (thread != nullptr) { + ASSERT(isolate_group() != nullptr); previous_tag_ = thread->vm_tag(); if (conditional_set) { thread->set_vm_tag(tag); @@ -89,8 +89,8 @@ VMTagScope::VMTagScope(Thread* thread, uword tag, bool conditional_set) } VMTagScope::~VMTagScope() { - if (thread() != NULL) { - ASSERT(isolate_group() != NULL); + if (thread() != nullptr) { + ASSERT(isolate_group() != nullptr); thread()->set_vm_tag(previous_tag_); } } diff --git a/runtime/vm/thread.h b/runtime/vm/thread.h index cce937edeb5..e7a4c7c8eae 100644 --- a/runtime/vm/thread.h +++ b/runtime/vm/thread.h @@ -245,7 +245,7 @@ class Thread; V(uword, auto_scope_native_wrapper_entry_point_, \ NativeEntry::AutoScopeNativeCallWrapperEntry(), 0) \ V(StringPtr*, predefined_symbols_address_, Symbols::PredefinedAddress(), \ - NULL) \ + nullptr) \ V(uword, double_nan_address_, reinterpret_cast(&double_nan_constant), \ 0) \ V(uword, double_negate_address_, \ @@ -349,7 +349,7 @@ class Thread : public ThreadState { ~Thread(); - // The currently executing thread, or NULL if not yet initialized. + // The currently executing thread, or nullptr if not yet initialized. static Thread* Current() { return static_cast(OSThread::CurrentVMThread()); } @@ -499,7 +499,7 @@ class Thread : public ThreadState { // The reusable api local scope for this thread. ApiLocalScope* api_reusable_scope() const { return api_reusable_scope_; } void set_api_reusable_scope(ApiLocalScope* value) { - ASSERT(value == NULL || api_reusable_scope_ == NULL); + ASSERT(value == nullptr || api_reusable_scope_ == nullptr); api_reusable_scope_ = value; } @@ -651,7 +651,7 @@ class Thread : public ThreadState { return OFFSET_OF(Thread, store_buffer_block_); } - bool is_marking() const { return marking_stack_block_ != NULL; } + bool is_marking() const { return marking_stack_block_ != nullptr; } void MarkingStackAddObject(ObjectPtr obj); void DeferredMarkingStackAddObject(ObjectPtr obj); void MarkingStackBlockProcess(); diff --git a/runtime/vm/thread_interrupter.cc b/runtime/vm/thread_interrupter.cc index aa770abaac3..a1b0cdb5df2 100644 --- a/runtime/vm/thread_interrupter.cc +++ b/runtime/vm/thread_interrupter.cc @@ -45,16 +45,16 @@ bool ThreadInterrupter::thread_running_ = false; bool ThreadInterrupter::woken_up_ = false; ThreadJoinId ThreadInterrupter::interrupter_thread_id_ = OSThread::kInvalidThreadJoinId; -Monitor* ThreadInterrupter::monitor_ = NULL; +Monitor* ThreadInterrupter::monitor_ = nullptr; intptr_t ThreadInterrupter::interrupt_period_ = 1000; intptr_t ThreadInterrupter::current_wait_time_ = Monitor::kNoTimeout; void ThreadInterrupter::Init() { ASSERT(!initialized_); - if (monitor_ == NULL) { + if (monitor_ == nullptr) { monitor_ = new Monitor(); } - ASSERT(monitor_ != NULL); + ASSERT(monitor_ != nullptr); initialized_ = true; shutdown_ = false; } @@ -121,7 +121,7 @@ void ThreadInterrupter::SetInterruptPeriod(intptr_t period) { } void ThreadInterrupter::WakeUp() { - if (monitor_ == NULL) { + if (monitor_ == nullptr) { // Early call. return; } @@ -155,7 +155,7 @@ void ThreadInterrupter::ThreadMain(uword parameters) { // Signal to main thread we are ready. MonitorLocker startup_ml(monitor_); OSThread* os_thread = OSThread::Current(); - ASSERT(os_thread != NULL); + ASSERT(os_thread != nullptr); interrupter_thread_id_ = OSThread::GetCurrentThreadJoinId(os_thread); thread_running_ = true; startup_ml.Notify(); diff --git a/runtime/vm/thread_interrupter_android.cc b/runtime/vm/thread_interrupter_android.cc index 146515c1bf8..c1a3045f2af 100644 --- a/runtime/vm/thread_interrupter_android.cc +++ b/runtime/vm/thread_interrupter_android.cc @@ -38,7 +38,7 @@ void ThreadInterruptSignalHandler(int signal, siginfo_t* info, void* context_) { return; } Thread* thread = Thread::Current(); - if (thread == NULL) { + if (thread == nullptr) { return; } ThreadInterruptScope signal_handler_scope; diff --git a/runtime/vm/thread_interrupter_fuchsia.cc b/runtime/vm/thread_interrupter_fuchsia.cc index 4cefbeb1da5..97dd40b67ef 100644 --- a/runtime/vm/thread_interrupter_fuchsia.cc +++ b/runtime/vm/thread_interrupter_fuchsia.cc @@ -154,7 +154,7 @@ class ThreadInterrupterFuchsia : public AllStatic { // with an isolate. It is safe to call 'os_thread->thread()' // here as the thread which is being queried is suspended. Thread* thread = static_cast(os_thread->thread()); - if (thread != NULL) { + if (thread != nullptr) { ThreadInterruptScope signal_handler_scope; Profiler::SampleThread(thread, its); } @@ -192,7 +192,7 @@ class ThreadInterrupterFuchsia : public AllStatic { zx_info_thread_t thread_info; zx_status_t status = zx_object_get_info(thread_handle, ZX_INFO_THREAD, &thread_info, - sizeof(thread_info), NULL, NULL); + sizeof(thread_info), nullptr, nullptr); poll_tries++; if (status != ZX_OK) { if (FLAG_trace_thread_interrupter) { diff --git a/runtime/vm/thread_interrupter_linux.cc b/runtime/vm/thread_interrupter_linux.cc index 7da18f24a72..d88c21b65e1 100644 --- a/runtime/vm/thread_interrupter_linux.cc +++ b/runtime/vm/thread_interrupter_linux.cc @@ -28,7 +28,7 @@ class ThreadInterrupterLinux : public AllStatic { return; } Thread* thread = Thread::Current(); - if (thread == NULL) { + if (thread == nullptr) { return; } ThreadInterruptScope signal_handler_scope; diff --git a/runtime/vm/thread_interrupter_win.cc b/runtime/vm/thread_interrupter_win.cc index aa13c6796e1..f78f22fc018 100644 --- a/runtime/vm/thread_interrupter_win.cc +++ b/runtime/vm/thread_interrupter_win.cc @@ -68,7 +68,7 @@ class ThreadInterrupterWin : public AllStatic { HANDLE handle = OpenThread( THREAD_GET_CONTEXT | THREAD_QUERY_INFORMATION | THREAD_SUSPEND_RESUME, false, os_thread->id()); - ASSERT(handle != NULL); + ASSERT(handle != nullptr); DWORD result = SuspendThread(handle); if (result == kThreadError) { if (FLAG_trace_thread_interrupter) { @@ -93,7 +93,7 @@ class ThreadInterrupterWin : public AllStatic { // with an isolate. It is safe to call 'os_thread->thread()' // here as the thread which is being queried is suspended. Thread* thread = static_cast(os_thread->thread()); - if (thread != NULL) { + if (thread != nullptr) { ThreadInterruptScope signal_handler_scope; Profiler::SampleThread(thread, its); } diff --git a/runtime/vm/thread_pool_test.cc b/runtime/vm/thread_pool_test.cc index 1dcf3dfde98..7a6effdc48b 100644 --- a/runtime/vm/thread_pool_test.cc +++ b/runtime/vm/thread_pool_test.cc @@ -154,7 +154,7 @@ THREAD_POOL_UNIT_TEST_CASE(ThreadPool_WorkerShutdown) { // Kill the thread pool while the workers are sleeping. delete thread_pool; - thread_pool = NULL; + thread_pool = nullptr; int final_count = 0; { diff --git a/runtime/vm/thread_registry.cc b/runtime/vm/thread_registry.cc index b61b52a0d3d..55a651f029e 100644 --- a/runtime/vm/thread_registry.cc +++ b/runtime/vm/thread_registry.cc @@ -14,10 +14,10 @@ ThreadRegistry::~ThreadRegistry() { { MonitorLocker ml(threads_lock()); // At this point the active list should be empty. - ASSERT(active_list_ == NULL); + ASSERT(active_list_ == nullptr); // Now delete all the threads in the free list. - while (free_list_ != NULL) { + while (free_list_ != nullptr) { Thread* thread = free_list_; free_list_ = thread->next_; delete thread; @@ -28,7 +28,7 @@ ThreadRegistry::~ThreadRegistry() { Thread* ThreadRegistry::GetFreeThreadLocked(bool is_vm_isolate) { ASSERT(threads_lock()->IsOwnedByCurrentThread()); Thread* thread = GetFromFreelistLocked(is_vm_isolate); - ASSERT(thread->api_top_scope() == NULL); + ASSERT(thread->api_top_scope() == nullptr); // Now add this Thread to the active list for the isolate. AddToActiveListLocked(thread); return thread; @@ -47,7 +47,7 @@ void ThreadRegistry::VisitObjectPointers( ValidationPolicy validate_frames) { MonitorLocker ml(threads_lock()); Thread* thread = active_list_; - while (thread != NULL) { + while (thread != nullptr) { if (thread->isolate_group() == isolate_group_of_interest) { // The mutator thread is visited by the isolate itself (see // [IsolateGroup::VisitStackPointers]). @@ -72,7 +72,7 @@ void ThreadRegistry::ForEachThread( void ThreadRegistry::ReleaseStoreBuffers() { MonitorLocker ml(threads_lock()); Thread* thread = active_list_; - while (thread != NULL) { + while (thread != nullptr) { if (!thread->BypassSafepoints()) { thread->ReleaseStoreBuffer(); } @@ -83,7 +83,7 @@ void ThreadRegistry::ReleaseStoreBuffers() { void ThreadRegistry::AcquireMarkingStacks() { MonitorLocker ml(threads_lock()); Thread* thread = active_list_; - while (thread != NULL) { + while (thread != nullptr) { if (!thread->BypassSafepoints()) { thread->MarkingStackAcquire(); thread->DeferredMarkingStackAcquire(); @@ -95,7 +95,7 @@ void ThreadRegistry::AcquireMarkingStacks() { void ThreadRegistry::ReleaseMarkingStacks() { MonitorLocker ml(threads_lock()); Thread* thread = active_list_; - while (thread != NULL) { + while (thread != nullptr) { if (!thread->BypassSafepoints()) { thread->MarkingStackRelease(); thread->DeferredMarkingStackRelease(); @@ -106,20 +106,20 @@ void ThreadRegistry::ReleaseMarkingStacks() { } void ThreadRegistry::AddToActiveListLocked(Thread* thread) { - ASSERT(thread != NULL); + ASSERT(thread != nullptr); ASSERT(threads_lock()->IsOwnedByCurrentThread()); thread->next_ = active_list_; active_list_ = thread; } void ThreadRegistry::RemoveFromActiveListLocked(Thread* thread) { - ASSERT(thread != NULL); + ASSERT(thread != nullptr); ASSERT(threads_lock()->IsOwnedByCurrentThread()); - Thread* prev = NULL; + Thread* prev = nullptr; Thread* current = active_list_; - while (current != NULL) { + while (current != nullptr) { if (current == thread) { - if (prev == NULL) { + if (prev == nullptr) { active_list_ = current->next_; } else { prev->next_ = current->next_; @@ -133,9 +133,9 @@ void ThreadRegistry::RemoveFromActiveListLocked(Thread* thread) { Thread* ThreadRegistry::GetFromFreelistLocked(bool is_vm_isolate) { ASSERT(threads_lock()->IsOwnedByCurrentThread()); - Thread* thread = NULL; + Thread* thread = nullptr; // Get thread structure from free list or create a new one. - if (free_list_ == NULL) { + if (free_list_ == nullptr) { thread = new Thread(is_vm_isolate); } else { thread = free_list_; @@ -145,10 +145,10 @@ Thread* ThreadRegistry::GetFromFreelistLocked(bool is_vm_isolate) { } void ThreadRegistry::ReturnToFreelistLocked(Thread* thread) { - ASSERT(thread != NULL); - ASSERT(thread->os_thread() == NULL); - ASSERT(thread->isolate_ == NULL); - ASSERT(thread->heap_ == NULL); + ASSERT(thread != nullptr); + ASSERT(thread->os_thread() == nullptr); + ASSERT(thread->isolate_ == nullptr); + ASSERT(thread->heap_ == nullptr); ASSERT(threads_lock()->IsOwnedByCurrentThread()); // Add thread to the free list. thread->next_ = free_list_; diff --git a/runtime/vm/thread_registry.h b/runtime/vm/thread_registry.h index 07493983ca3..c167c0fc0eb 100644 --- a/runtime/vm/thread_registry.h +++ b/runtime/vm/thread_registry.h @@ -22,7 +22,8 @@ class JSONArray; // Unordered collection of threads relating to a particular isolate. class ThreadRegistry { public: - ThreadRegistry() : threads_lock_(), active_list_(NULL), free_list_(NULL) {} + ThreadRegistry() + : threads_lock_(), active_list_(nullptr), free_list_(nullptr) {} ~ThreadRegistry(); void VisitObjectPointers(IsolateGroup* isolate_group_of_interest, diff --git a/runtime/vm/thread_state.cc b/runtime/vm/thread_state.cc index c3bae0cd84b..b04882b05cf 100644 --- a/runtime/vm/thread_state.cc +++ b/runtime/vm/thread_state.cc @@ -27,7 +27,7 @@ bool ThreadState::ZoneIsOwnedByThread(Zone* zone) const { bool ThreadState::IsValidZoneHandle(Dart_Handle object) const { Zone* zone = this->zone(); - while (zone != NULL) { + while (zone != nullptr) { if (zone->handles()->IsValidZoneHandle(reinterpret_cast(object))) { return true; } @@ -39,7 +39,7 @@ bool ThreadState::IsValidZoneHandle(Dart_Handle object) const { intptr_t ThreadState::CountZoneHandles() const { intptr_t count = 0; Zone* zone = this->zone(); - while (zone != NULL) { + while (zone != nullptr) { count += zone->handles()->CountZoneHandles(); zone = zone->previous(); } @@ -49,7 +49,7 @@ intptr_t ThreadState::CountZoneHandles() const { bool ThreadState::IsValidScopedHandle(Dart_Handle object) const { Zone* zone = this->zone(); - while (zone != NULL) { + while (zone != nullptr) { if (zone->handles()->IsValidScopedHandle(reinterpret_cast(object))) { return true; } @@ -61,7 +61,7 @@ bool ThreadState::IsValidScopedHandle(Dart_Handle object) const { intptr_t ThreadState::CountScopedHandles() const { intptr_t count = 0; Zone* zone = this->zone(); - while (zone != NULL) { + while (zone != nullptr) { count += zone->handles()->CountScopedHandles(); zone = zone->previous(); } diff --git a/runtime/vm/thread_state.h b/runtime/vm/thread_state.h index 61c46c33f9c..f3a3d3fcba2 100644 --- a/runtime/vm/thread_state.h +++ b/runtime/vm/thread_state.h @@ -23,7 +23,7 @@ class Zone; // restrictions. class ThreadState : public BaseThread { public: - // The currently executing thread, or NULL if not yet initialized. + // The currently executing thread, or nullptr if not yet initialized. static ThreadState* Current() { return OSThread::CurrentVMThread(); } diff --git a/runtime/vm/thread_test.cc b/runtime/vm/thread_test.cc index c8d918e0bdc..a69d25840a0 100644 --- a/runtime/vm/thread_test.cc +++ b/runtime/vm/thread_test.cc @@ -628,9 +628,9 @@ TEST_CASE(SafepointTestDart) { " }\n" "}\n", kLoopCount); - Dart_Handle lib = TestCase::LoadTestScript(buffer, NULL); + Dart_Handle lib = TestCase::LoadTestScript(buffer, nullptr); EXPECT_VALID(lib); - Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL); + Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, nullptr); EXPECT_VALID(result); // Ensure we looped long enough to allow all helpers to succeed and exit. { @@ -693,7 +693,7 @@ ISOLATE_UNIT_TEST_CASE(ThreadIterator_Count) { OSThreadIterator ti; while (ti.HasNext()) { OSThread* thread = ti.Next(); - EXPECT(thread != NULL); + EXPECT(thread != nullptr); thread_count_0++; } } @@ -702,7 +702,7 @@ ISOLATE_UNIT_TEST_CASE(ThreadIterator_Count) { OSThreadIterator ti; while (ti.HasNext()) { OSThread* thread = ti.Next(); - EXPECT(thread != NULL); + EXPECT(thread != nullptr); thread_count_1++; } } @@ -727,7 +727,7 @@ void ThreadIteratorTestMain(uword parameter) { ThreadIteratorTestParams* params = reinterpret_cast(parameter); OSThread* thread = OSThread::Current(); - EXPECT(thread != NULL); + EXPECT(thread != nullptr); MonitorLocker ml(params->monitor); params->spawned_thread_id = thread->id(); diff --git a/runtime/vm/timeline.cc b/runtime/vm/timeline.cc index dfe58fd14be..9cd59129d66 100644 --- a/runtime/vm/timeline.cc +++ b/runtime/vm/timeline.cc @@ -46,12 +46,12 @@ DEFINE_FLAG(bool, trace_timeline, false, "Trace timeline backend"); DEFINE_FLAG( charp, timeline_dir, - NULL, + nullptr, "Enable all timeline trace streams and output VM global trace " "into specified directory. This flag is ignored by the file recorder."); DEFINE_FLAG(charp, timeline_streams, - NULL, + nullptr, "Comma separated list of timeline streams to record. " "Valid values: all, API, Compiler, CompilerVerbose, Dart, " "Debugger, Embedder, GC, Isolate, and VM."); @@ -190,7 +190,7 @@ static TimelineEventRecorder* CreateTimelineRecorder() { // Returns a caller freed array of stream names in FLAG_timeline_streams. static MallocGrowableArray* GetEnabledByDefaultTimelineStreams() { MallocGrowableArray* result = new MallocGrowableArray(); - if (FLAG_timeline_streams == NULL) { + if (FLAG_timeline_streams == nullptr) { // Nothing set. return result; } @@ -198,9 +198,9 @@ static MallocGrowableArray* GetEnabledByDefaultTimelineStreams() { // strtok modifies arg 1 so we make a copy of it. char* streams = Utils::StrDup(FLAG_timeline_streams); char* token = strtok_r(streams, ",", &save_ptr); - while (token != NULL) { + while (token != nullptr) { result->Add(Utils::StrDup(token)); - token = strtok_r(NULL, ",", &save_ptr); + token = strtok_r(nullptr, ",", &save_ptr); } free(streams); return result; @@ -209,7 +209,7 @@ static MallocGrowableArray* GetEnabledByDefaultTimelineStreams() { // Frees the result of |GetEnabledByDefaultTimelineStreams|. static void FreeEnabledByDefaultTimelineStreams( MallocGrowableArray* streams) { - if (streams == NULL) { + if (streams == nullptr) { return; } for (intptr_t i = 0; i < streams->length(); i++) { @@ -220,14 +220,14 @@ static void FreeEnabledByDefaultTimelineStreams( // Returns true if |streams| contains |stream| or "all". Not case sensitive. static bool HasStream(MallocGrowableArray* streams, const char* stream) { - if ((FLAG_timeline_dir != NULL) || FLAG_complete_timeline || + if ((FLAG_timeline_dir != nullptr) || FLAG_complete_timeline || FLAG_startup_timeline) { return true; } for (intptr_t i = 0; i < streams->length(); i++) { const char* checked_stream = (*streams)[i]; - if ((strstr(checked_stream, "all") != NULL) || - (strstr(checked_stream, stream) != NULL)) { + if ((strstr(checked_stream, "all") != nullptr) || + (strstr(checked_stream, stream) != nullptr)) { return true; } } @@ -235,7 +235,7 @@ static bool HasStream(MallocGrowableArray* streams, const char* stream) { } void Timeline::Init() { - ASSERT(recorder_ == NULL); + ASSERT(recorder_ == nullptr); recorder_ = CreateTimelineRecorder(); RecorderSynchronizationLock::Init(); @@ -252,7 +252,7 @@ void Timeline::Init() { if (FLAG_trace_timeline) { OS::PrintErr("Using the %s timeline recorder.\n", recorder_->name()); } - ASSERT(recorder_ != NULL); + ASSERT(recorder_ != nullptr); enabled_streams_ = GetEnabledByDefaultTimelineStreams(); // Global overrides. #define TIMELINE_STREAM_FLAG_DEFAULT(name, ...) \ @@ -262,10 +262,10 @@ void Timeline::Init() { } void Timeline::Cleanup() { - ASSERT(recorder_ != NULL); + ASSERT(recorder_ != nullptr); #ifndef PRODUCT - if (FLAG_timeline_dir != NULL) { + if (FLAG_timeline_dir != nullptr) { recorder_->WriteTo(FLAG_timeline_dir); } #endif @@ -282,17 +282,17 @@ void Timeline::Cleanup() { // without explicitly grabbing a recorder lock. Timeline::ClearUnsafe(); delete recorder_; - recorder_ = NULL; - if (enabled_streams_ != NULL) { + recorder_ = nullptr; + if (enabled_streams_ != nullptr) { FreeEnabledByDefaultTimelineStreams(enabled_streams_); - enabled_streams_ = NULL; + enabled_streams_ = nullptr; } } void Timeline::ReclaimCachedBlocksFromThreads() { RecorderSynchronizationLockScope ls; TimelineEventRecorder* recorder = Timeline::recorder(); - if (recorder == NULL || !ls.IsActive()) { + if (recorder == nullptr || !ls.IsActive()) { return; } ReclaimCachedBlocksFromThreadsUnsafe(); @@ -331,7 +331,7 @@ void Timeline::PrintFlagsToJSON(JSONStream* js) { obj.AddProperty("type", "TimelineFlags"); RecorderSynchronizationLockScope ls; TimelineEventRecorder* recorder = Timeline::recorder(); - if (recorder == NULL || !ls.IsActive()) { + if (recorder == nullptr || !ls.IsActive()) { obj.AddProperty("recorderName", "null"); } else { obj.AddProperty("recorderName", recorder->name()); @@ -378,7 +378,7 @@ void TimelineEventArguments::SetNumArguments(intptr_t length) { Free(); return; } - if (buffer_ == NULL) { + if (buffer_ == nullptr) { // calloc already nullifies buffer_ = reinterpret_cast( calloc(sizeof(TimelineEventArgument), length)); @@ -419,7 +419,7 @@ void TimelineEventArguments::FormatArgument(intptr_t i, ASSERT(i < length_); va_list measure_args; va_copy(measure_args, args); - intptr_t len = Utils::VSNPrint(NULL, 0, fmt, measure_args); + intptr_t len = Utils::VSNPrint(nullptr, 0, fmt, measure_args); va_end(measure_args); char* buffer = reinterpret_cast(malloc(len + 1)); @@ -436,24 +436,24 @@ void TimelineEventArguments::StealArguments(TimelineEventArguments* arguments) { length_ = arguments->length_; buffer_ = arguments->buffer_; arguments->length_ = 0; - arguments->buffer_ = NULL; + arguments->buffer_ = nullptr; } void TimelineEventArguments::Free() { - if (buffer_ == NULL) { + if (buffer_ == nullptr) { return; } for (intptr_t i = 0; i < length_; i++) { free(buffer_[i].value); } free(buffer_); - buffer_ = NULL; + buffer_ = nullptr; length_ = 0; } -TimelineEventRecorder* Timeline::recorder_ = NULL; -Dart_TimelineRecorderCallback Timeline::callback_ = NULL; -MallocGrowableArray* Timeline::enabled_streams_ = NULL; +TimelineEventRecorder* Timeline::recorder_ = nullptr; +Dart_TimelineRecorderCallback Timeline::callback_ = nullptr; +MallocGrowableArray* Timeline::enabled_streams_ = nullptr; bool Timeline::recorder_discards_clock_values_ = false; #define TIMELINE_STREAM_DEFINE(name, fuchsia_name, static_labels) \ @@ -466,8 +466,8 @@ TimelineEvent::TimelineEvent() : timestamp0_(0), timestamp1_(0), state_(0), - label_(NULL), - stream_(NULL), + label_(nullptr), + stream_(nullptr), thread_(OSThread::kInvalidThreadId), isolate_id_(ILLEGAL_ISOLATE_ID), isolate_group_id_(ILLEGAL_ISOLATE_GROUP_ID) {} @@ -477,15 +477,15 @@ TimelineEvent::~TimelineEvent() { } void TimelineEvent::Reset() { - if (owns_label() && label_ != NULL) { + if (owns_label() && label_ != nullptr) { free(const_cast(label_)); } state_ = 0; thread_ = OSThread::kInvalidThreadId; isolate_id_ = ILLEGAL_PORT; isolate_group_id_ = 0; - stream_ = NULL; - label_ = NULL; + stream_ = nullptr; + label_ = nullptr; arguments_.Free(); set_event_type(kNone); set_pre_serialized_args(false); @@ -619,12 +619,12 @@ void TimelineEvent::Complete() { } void TimelineEvent::Init(EventType event_type, const char* label) { - ASSERT(label != NULL); + ASSERT(label != nullptr); state_ = 0; timestamp0_ = 0; timestamp1_ = 0; OSThread* os_thread = OSThread::Current(); - ASSERT(os_thread != NULL); + ASSERT(os_thread != nullptr); thread_ = os_thread->trace_id(); auto thread = Thread::Current(); auto isolate = thread != nullptr ? thread->isolate() : nullptr; @@ -670,7 +670,7 @@ void TimelineEvent::PrintJSON(JSONWriter* writer) const { int64_t pid = OS::ProcessId(); int64_t tid = OSThread::ThreadIdToIntPtr(thread_); writer->PrintProperty("name", label_); - writer->PrintProperty("cat", stream_ != NULL ? stream_->name() : NULL); + writer->PrintProperty("cat", stream_ != nullptr ? stream_->name() : nullptr); writer->PrintProperty64("tid", tid); writer->PrintProperty64("pid", pid); writer->PrintProperty64("ts", TimeOrigin()); @@ -886,7 +886,7 @@ TimelineEvent* TimelineStream::StartEvent() { TimelineEventScope::TimelineEventScope(TimelineStream* stream, const char* label) - : StackResource(static_cast(NULL)), + : StackResource(static_cast(nullptr)), stream_(stream), label_(label), enabled_(false) { @@ -904,15 +904,15 @@ TimelineEventScope::~TimelineEventScope() {} void TimelineEventScope::Init() { ASSERT(enabled_ == false); - ASSERT(label_ != NULL); - ASSERT(stream_ != NULL); + ASSERT(label_ != nullptr); + ASSERT(stream_ != nullptr); if (!stream_->enabled()) { // Stream is not enabled, do nothing. return; } enabled_ = true; Thread* thread = static_cast(this->thread()); - if (thread != NULL) { + if (thread != nullptr) { id_ = thread->GetNextTaskId(); } else { static RelaxedAtomic next_bootstrap_task_id = {0}; @@ -961,7 +961,7 @@ void TimelineEventScope::FormatArgument(intptr_t i, } void TimelineEventScope::StealArguments(TimelineEvent* event) { - if (event == NULL) { + if (event == nullptr) { return; } event->StealArguments(&arguments_); @@ -989,12 +989,12 @@ void TimelineBeginEndScope::EmitBegin() { return; } TimelineEvent* event = stream()->StartEvent(); - if (event == NULL) { + if (event == nullptr) { // Stream is now disabled. set_enabled(false); return; } - ASSERT(event != NULL); + ASSERT(event != nullptr); // Emit a begin event. event->Begin(label(), id()); event->Complete(); @@ -1005,12 +1005,12 @@ void TimelineBeginEndScope::EmitEnd() { return; } TimelineEvent* event = stream()->StartEvent(); - if (event == NULL) { + if (event == nullptr) { // Stream is now disabled. set_enabled(false); return; } - ASSERT(event != NULL); + ASSERT(event != nullptr); // Emit an end event. event->End(label(), id()); StealArguments(event); @@ -1066,22 +1066,22 @@ void TimelineEventRecorder::PrintJSONMeta(const JSONArray& jsarr_events) { TimelineEvent* TimelineEventRecorder::ThreadBlockStartEvent() { // Grab the current thread. OSThread* thread = OSThread::Current(); - ASSERT(thread != NULL); + ASSERT(thread != nullptr); Mutex* thread_block_lock = thread->timeline_block_lock(); - ASSERT(thread_block_lock != NULL); + ASSERT(thread_block_lock != nullptr); // We are accessing the thread's timeline block- so take the lock here. // This lock will be held until the call to |CompleteEvent| is made. thread_block_lock->Lock(); #if defined(DEBUG) Thread* T = Thread::Current(); - if (T != NULL) { + if (T != nullptr) { T->IncrementNoSafepointScopeDepth(); } #endif // defined(DEBUG) TimelineEventBlock* thread_block = thread->timeline_block(); - if ((thread_block != NULL) && thread_block->IsFull()) { + if ((thread_block != nullptr) && thread_block->IsFull()) { MutexLocker ml(&lock_); // Thread has a block and it is full: // 1) Mark it as finished. @@ -1089,13 +1089,13 @@ TimelineEvent* TimelineEventRecorder::ThreadBlockStartEvent() { // 2) Allocate a new block. thread_block = GetNewBlockLocked(); thread->set_timeline_block(thread_block); - } else if (thread_block == NULL) { + } else if (thread_block == nullptr) { MutexLocker ml(&lock_); // Thread has no block. Attempt to allocate one. thread_block = GetNewBlockLocked(); thread->set_timeline_block(thread_block); } - if (thread_block != NULL) { + if (thread_block != nullptr) { // NOTE: We are exiting this function with the thread's block lock held. ASSERT(!thread_block->IsFull()); TimelineEvent* event = thread_block->StartEvent(); @@ -1103,12 +1103,12 @@ TimelineEvent* TimelineEventRecorder::ThreadBlockStartEvent() { } // Drop lock here as no event is being handed out. #if defined(DEBUG) - if (T != NULL) { + if (T != nullptr) { T->DecrementNoSafepointScopeDepth(); } #endif // defined(DEBUG) thread_block_lock->Unlock(); - return NULL; + return nullptr; } void TimelineEventRecorder::ResetTimeTracking() { @@ -1140,18 +1140,18 @@ int64_t TimelineEventRecorder::TimeExtentMicros() const { } void TimelineEventRecorder::ThreadBlockCompleteEvent(TimelineEvent* event) { - if (event == NULL) { + if (event == nullptr) { return; } // Grab the current thread. OSThread* thread = OSThread::Current(); - ASSERT(thread != NULL); + ASSERT(thread != nullptr); // Unlock the thread's block lock. Mutex* thread_block_lock = thread->timeline_block_lock(); - ASSERT(thread_block_lock != NULL); + ASSERT(thread_block_lock != nullptr); #if defined(DEBUG) Thread* T = Thread::Current(); - if (T != NULL) { + if (T != nullptr) { T->DecrementNoSafepointScopeDepth(); } #endif // defined(DEBUG) @@ -1163,7 +1163,8 @@ void TimelineEventRecorder::WriteTo(const char* directory) { Dart_FileOpenCallback file_open = Dart::file_open_callback(); Dart_FileWriteCallback file_write = Dart::file_write_callback(); Dart_FileCloseCallback file_close = Dart::file_close_callback(); - if ((file_open == NULL) || (file_write == NULL) || (file_close == NULL)) { + if ((file_open == nullptr) || (file_write == nullptr) || + (file_close == nullptr)) { OS::PrintErr("warning: Could not access file callbacks."); return; } @@ -1172,9 +1173,9 @@ void TimelineEventRecorder::WriteTo(const char* directory) { intptr_t pid = OS::ProcessId(); char* filename = - OS::SCreate(NULL, "%s/dart-timeline-%" Pd ".json", directory, pid); + OS::SCreate(nullptr, "%s/dart-timeline-%" Pd ".json", directory, pid); void* file = (*file_open)(filename, true); - if (file == NULL) { + if (file == nullptr) { OS::PrintErr("warning: Failed to write timeline file: %s\n", filename); free(filename); return; @@ -1185,7 +1186,7 @@ void TimelineEventRecorder::WriteTo(const char* directory) { TimelineEventFilter filter; PrintTraceEvent(&js, &filter); // Steal output from JSONStream. - char* output = NULL; + char* output = nullptr; intptr_t output_length = 0; js.Steal(&output, &output_length); (*file_write)(output, output_length, file); @@ -1198,7 +1199,7 @@ void TimelineEventRecorder::WriteTo(const char* directory) { #endif void TimelineEventRecorder::FinishBlock(TimelineEventBlock* block) { - if (block == NULL) { + if (block == nullptr) { return; } MutexLocker ml(&lock_); @@ -1242,8 +1243,8 @@ void TimelineEventRecorder::AddTrackMetadataBasedOnThread( TimelineEventFixedBufferRecorder::TimelineEventFixedBufferRecorder( intptr_t capacity) - : memory_(NULL), - blocks_(NULL), + : memory_(nullptr), + blocks_(nullptr), capacity_(capacity), num_blocks_(0), block_cursor_(0) { @@ -1258,7 +1259,7 @@ TimelineEventFixedBufferRecorder::TimelineEventFixedBufferRecorder( const bool compressed = false; memory_ = VirtualMemory::Allocate(size, executable, compressed, "dart-timeline"); - if (memory_ == NULL) { + if (memory_ == nullptr) { OUT_OF_MEMORY(); } blocks_ = reinterpret_cast(memory_->address()); @@ -1363,7 +1364,7 @@ TimelineEvent* TimelineEventFixedBufferRecorder::StartEvent() { } void TimelineEventFixedBufferRecorder::CompleteEvent(TimelineEvent* event) { - if (event == NULL) { + if (event == nullptr) { return; } ThreadBlockCompleteEvent(event); @@ -1383,7 +1384,7 @@ TimelineEventBlock* TimelineEventRingRecorder::GetNewBlockLocked() { TimelineEventBlock* TimelineEventStartupRecorder::GetNewBlockLocked() { if (block_cursor_ == num_blocks_) { - return NULL; + return nullptr; } TimelineEventBlock* block = &blocks_[block_cursor_++]; block->Reset(); @@ -1420,7 +1421,7 @@ void TimelineEventCallbackRecorder::CompleteEvent(TimelineEvent* event) { void TimelineEventEmbedderCallbackRecorder::OnEvent(TimelineEvent* event) { Dart_TimelineRecorderCallback callback = Timeline::callback(); - if (callback == NULL) { + if (callback == nullptr) { return; } @@ -1656,7 +1657,7 @@ void TimelineEventFileRecorder::DrainImpl(const TimelineEvent& event) { writer.buffer()->AddChar(','); } event.PrintJSON(&writer); - char* output = NULL; + char* output = nullptr; intptr_t output_length = 0; writer.Steal(&output, &output_length); Write(output, output_length); @@ -1700,7 +1701,7 @@ TimelineEvent* TimelineEventEndlessRecorder::StartEvent() { } void TimelineEventEndlessRecorder::CompleteEvent(TimelineEvent* event) { - if (event == NULL) { + if (event == nullptr) { return; } ThreadBlockCompleteEvent(event); @@ -1750,18 +1751,18 @@ void TimelineEventEndlessRecorder::PrintJSONEvents( void TimelineEventEndlessRecorder::Clear() { MutexLocker ml(&lock_); TimelineEventBlock* current = head_; - while (current != NULL) { + while (current != nullptr) { TimelineEventBlock* next = current->next(); delete current; current = next; } - head_ = NULL; - tail_ = NULL; + head_ = nullptr; + tail_ = nullptr; block_index_ = 0; } TimelineEventBlock::TimelineEventBlock(intptr_t block_index) - : next_(NULL), + : next_(nullptr), length_(0), block_index_(block_index), thread_id_(OSThread::kInvalidThreadId), @@ -1788,7 +1789,7 @@ TimelineEvent* TimelineEventBlock::StartEvent() { ASSERT(!IsFull()); if (FLAG_trace_timeline) { OSThread* os_thread = OSThread::Current(); - ASSERT(os_thread != NULL); + ASSERT(os_thread != nullptr); intptr_t tid = OSThread::ThreadIdToIntPtr(os_thread->id()); OS::PrintErr("StartEvent in block %p for thread %" Pd "\n", this, tid); } @@ -1838,7 +1839,7 @@ void TimelineEventBlock::Reset() { void TimelineEventBlock::Open() { OSThread* os_thread = OSThread::Current(); - ASSERT(os_thread != NULL); + ASSERT(os_thread != nullptr); thread_id_ = os_thread->trace_id(); in_use_ = true; } diff --git a/runtime/vm/timeline.h b/runtime/vm/timeline.h index 2ea818b91a5..1cbfa1b4f2b 100644 --- a/runtime/vm/timeline.h +++ b/runtime/vm/timeline.h @@ -96,7 +96,7 @@ class TimelineStream { void set_enabled(bool enabled) { enabled_ = enabled ? 1 : 0; } - // Records an event. Will return |NULL| if not enabled. The returned + // Records an event. Will return |nullptr| if not enabled. The returned // |TimelineEvent| is in an undefined state and must be initialized. // NOTE: It is not allowed to call StartEvent again without completing // the first event. @@ -258,7 +258,7 @@ struct TimelineEventArgument { class TimelineEventArguments { public: - TimelineEventArguments() : buffer_(NULL), length_(0) {} + TimelineEventArguments() : buffer_(nullptr), length_(0) {} ~TimelineEventArguments() { Free(); } // Get/Set the number of arguments in the event. void SetNumArguments(intptr_t length); @@ -766,7 +766,7 @@ class TimelineEventFilter : public ValueObject { virtual ~TimelineEventFilter(); virtual bool IncludeBlock(TimelineEventBlock* block) { - if (block == NULL) { + if (block == nullptr) { return false; } // Not empty and not in use. @@ -774,7 +774,7 @@ class TimelineEventFilter : public ValueObject { } virtual bool IncludeEvent(TimelineEvent* event) { - if (event == NULL) { + if (event == nullptr) { return false; } return event->IsValid(); @@ -796,7 +796,7 @@ class IsolateTimelineEventFilter : public TimelineEventFilter { int64_t time_extent_micros = -1); bool IncludeBlock(TimelineEventBlock* block) { - if (block == NULL) { + if (block == nullptr) { return false; } // Not empty, not in use, and isolate match. @@ -955,8 +955,8 @@ class TimelineEventCallbackRecorder : public TimelineEventRecorder { } protected: - TimelineEventBlock* GetNewBlockLocked() { return NULL; } - TimelineEventBlock* GetHeadBlockLocked() { return NULL; } + TimelineEventBlock* GetNewBlockLocked() { return nullptr; } + TimelineEventBlock* GetHeadBlockLocked() { return nullptr; } void Clear() {} TimelineEvent* StartEvent(); void CompleteEvent(TimelineEvent* event); @@ -1036,8 +1036,8 @@ class TimelineEventPlatformRecorder : public TimelineEventRecorder { virtual const char* name() const = 0; protected: - TimelineEventBlock* GetNewBlockLocked() { return NULL; } - TimelineEventBlock* GetHeadBlockLocked() { return NULL; } + TimelineEventBlock* GetNewBlockLocked() { return nullptr; } + TimelineEventBlock* GetHeadBlockLocked() { return nullptr; } void Clear() {} TimelineEvent* StartEvent(); void CompleteEvent(TimelineEvent* event); diff --git a/runtime/vm/timeline_android.cc b/runtime/vm/timeline_android.cc index 37844f7c4f4..6b43cd539d9 100644 --- a/runtime/vm/timeline_android.cc +++ b/runtime/vm/timeline_android.cc @@ -54,7 +54,7 @@ TimelineEventSystraceRecorder::~TimelineEventSystraceRecorder() { intptr_t TimelineEventSystraceRecorder::PrintSystrace(TimelineEvent* event, char* buffer, intptr_t buffer_size) { - ASSERT(buffer != NULL); + ASSERT(buffer != nullptr); ASSERT(buffer_size > 0); buffer[0] = '\0'; intptr_t length = 0; @@ -95,7 +95,7 @@ intptr_t TimelineEventSystraceRecorder::PrintSystrace(TimelineEvent* event, } void TimelineEventSystraceRecorder::OnEvent(TimelineEvent* event) { - if (event == NULL) { + if (event == nullptr) { return; } if (systrace_fd_ < 0) { diff --git a/runtime/vm/timeline_fuchsia.cc b/runtime/vm/timeline_fuchsia.cc index 6dd671a7c8e..09fdf0e8252 100644 --- a/runtime/vm/timeline_fuchsia.cc +++ b/runtime/vm/timeline_fuchsia.cc @@ -15,14 +15,14 @@ namespace dart { void TimelineEventFuchsiaRecorder::OnEvent(TimelineEvent* event) { - if (event == NULL) { + if (event == nullptr) { return; } TimelineStream* stream = event->stream_; trace_string_ref_t category; trace_context_t* context = trace_acquire_context_for_category_cached( stream->fuchsia_name(), stream->trace_site(), &category); - if (context == NULL) { + if (context == nullptr) { return; } diff --git a/runtime/vm/timeline_linux.cc b/runtime/vm/timeline_linux.cc index 407a790bd9a..70d31bda348 100644 --- a/runtime/vm/timeline_linux.cc +++ b/runtime/vm/timeline_linux.cc @@ -54,7 +54,7 @@ TimelineEventSystraceRecorder::~TimelineEventSystraceRecorder() { intptr_t TimelineEventSystraceRecorder::PrintSystrace(TimelineEvent* event, char* buffer, intptr_t buffer_size) { - ASSERT(buffer != NULL); + ASSERT(buffer != nullptr); ASSERT(buffer_size > 0); buffer[0] = '\0'; intptr_t length = 0; @@ -95,7 +95,7 @@ intptr_t TimelineEventSystraceRecorder::PrintSystrace(TimelineEvent* event, } void TimelineEventSystraceRecorder::OnEvent(TimelineEvent* event) { - if (event == NULL) { + if (event == nullptr) { return; } if (systrace_fd_ < 0) { diff --git a/runtime/vm/timeline_macos.cc b/runtime/vm/timeline_macos.cc index 55e0b2435ea..6301aed421f 100644 --- a/runtime/vm/timeline_macos.cc +++ b/runtime/vm/timeline_macos.cc @@ -19,7 +19,7 @@ TimelineEventMacosRecorder::TimelineEventMacosRecorder() TimelineEventMacosRecorder::~TimelineEventMacosRecorder() {} void TimelineEventMacosRecorder::OnEvent(TimelineEvent* event) { - if (event == NULL) { + if (event == nullptr) { return; } diff --git a/runtime/vm/timeline_test.cc b/runtime/vm/timeline_test.cc index 8863dd325de..521d3955896 100644 --- a/runtime/vm/timeline_test.cc +++ b/runtime/vm/timeline_test.cc @@ -50,12 +50,12 @@ class TimelineTestHelper : public AllStatic { static void FakeThreadEvent(TimelineEventBlock* block, intptr_t ftid, const char* label = "fake", - TimelineStream* stream = NULL) { + TimelineStream* stream = nullptr) { TimelineEvent* event = block->StartEvent(); - ASSERT(event != NULL); + ASSERT(event != nullptr); event->DurationBegin(label); event->thread_ = OSThread::ThreadIdFromIntPtr(ftid); - if (stream != NULL) { + if (stream != nullptr) { event->StreamInit(stream); } } @@ -68,11 +68,11 @@ class TimelineTestHelper : public AllStatic { const char* label, int64_t start, int64_t end) { - ASSERT(recorder != NULL); + ASSERT(recorder != nullptr); ASSERT(start < end); - ASSERT(label != NULL); + ASSERT(label != nullptr); TimelineEvent* event = recorder->StartEvent(); - ASSERT(event != NULL); + ASSERT(event != nullptr); event->Duration(label, start, end); event->Complete(); } @@ -80,11 +80,11 @@ class TimelineTestHelper : public AllStatic { static void FakeBegin(TimelineEventRecorder* recorder, const char* label, int64_t start) { - ASSERT(recorder != NULL); - ASSERT(label != NULL); + ASSERT(recorder != nullptr); + ASSERT(label != nullptr); ASSERT(start >= 0); TimelineEvent* event = recorder->StartEvent(); - ASSERT(event != NULL); + ASSERT(event != nullptr); event->Begin(label, start); event->Complete(); } @@ -92,11 +92,11 @@ class TimelineTestHelper : public AllStatic { static void FakeEnd(TimelineEventRecorder* recorder, const char* label, int64_t end) { - ASSERT(recorder != NULL); - ASSERT(label != NULL); + ASSERT(recorder != nullptr); + ASSERT(label != nullptr); ASSERT(end >= 0); TimelineEvent* event = recorder->StartEvent(); - ASSERT(event != NULL); + ASSERT(event != nullptr); event->End(label, end); event->Complete(); } @@ -297,7 +297,7 @@ TEST_CASE(TimelineEventCallbackRecorderBasic) { // Create a test stream. TimelineStream stream("testStream", "testStream", false, true); - TimelineEvent* event = NULL; + TimelineEvent* event = nullptr; event = stream.StartEvent(); EXPECT_EQ(0, override.recorder()->CountFor(TimelineEvent::kDuration)); @@ -347,9 +347,9 @@ TEST_CASE(TimelineRingRecorderJSONOrder) { TimelineRecorderOverride override(recorder); TimelineEventBlock* block_0 = Timeline::recorder()->GetNewBlock(); - EXPECT(block_0 != NULL); + EXPECT(block_0 != nullptr); TimelineEventBlock* block_1 = Timeline::recorder()->GetNewBlock(); - EXPECT(block_1 != NULL); + EXPECT(block_1 != nullptr); // Test that we wrapped. EXPECT(block_0 == Timeline::recorder()->GetNewBlock()); @@ -488,7 +488,7 @@ UNIT_TEST_CASE(DartAPI_SetTimelineRecorderCallback) { Dart_SetTimelineRecorderCallback(TestTimelineRecorderCallback); - EXPECT(Dart_SetVMFlags(argc, argv) == NULL); + EXPECT(Dart_SetVMFlags(argc, argv) == nullptr); Dart_InitializeParams params; memset(¶ms, 0, sizeof(Dart_InitializeParams)); params.version = DART_INITIALIZE_PARAMS_CURRENT_VERSION; @@ -498,7 +498,7 @@ UNIT_TEST_CASE(DartAPI_SetTimelineRecorderCallback) { params.cleanup_group = TesterState::group_cleanup_callback; params.start_kernel_isolate = true; - EXPECT(Dart_Initialize(¶ms) == NULL); + EXPECT(Dart_Initialize(¶ms) == nullptr); { TestIsolateScope scope; const char* kScriptChars = @@ -507,7 +507,7 @@ UNIT_TEST_CASE(DartAPI_SetTimelineRecorderCallback) { " Timeline.startSync('TestEvent', arguments: {'key':'value'});\n" " Timeline.finishSync();\n" "}\n"; - Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); + Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, nullptr); EXPECT_VALID(lib); expected_isolate = Dart_GetMainPortId(); @@ -517,15 +517,15 @@ UNIT_TEST_CASE(DartAPI_SetTimelineRecorderCallback) { saw_begin = false; saw_end = false; - Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL); + Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, nullptr); EXPECT_VALID(result); EXPECT(saw_begin); EXPECT(saw_end); } - EXPECT(Dart_Cleanup() == NULL); + EXPECT(Dart_Cleanup() == nullptr); - Dart_SetTimelineRecorderCallback(NULL); + Dart_SetTimelineRecorderCallback(nullptr); delete[] argv; } diff --git a/runtime/vm/token.h b/runtime/vm/token.h index e2fc07442c7..50cd1e72bfd 100644 --- a/runtime/vm/token.h +++ b/runtime/vm/token.h @@ -94,7 +94,7 @@ namespace dart { \ TOK(kNOT, "!", 0, kNoAttribute) \ TOK(kCONDITIONAL, "?", 3, kNoAttribute) \ - TOK(kIFNULL, "??", 4, kNoAttribute) \ + TOK(kIFnullptr, "??", 4, kNoAttribute) \ \ /* Equality operators. */ \ /* Please update IsEqualityOperator() if you make */ \ @@ -178,7 +178,7 @@ namespace dart { KW(kIS, "is", 11, kKeyword) \ KW(kLIBRARY, "library", 0, kPseudoKeyword) \ KW(kNEW, "new", 0, kKeyword) \ - KW(kNULL, "null", 0, kKeyword) \ + KW(knullptr, "null", 0, kKeyword) \ KW(kOPERATOR, "operator", 0, kPseudoKeyword) \ KW(kPART, "part", 0, kPseudoKeyword) \ KW(kRETHROW, "rethrow", 0, kKeyword) \ diff --git a/runtime/vm/type_testing_stubs.cc b/runtime/vm/type_testing_stubs.cc index 0f69744c2c0..5d420e3ef9c 100644 --- a/runtime/vm/type_testing_stubs.cc +++ b/runtime/vm/type_testing_stubs.cc @@ -257,7 +257,7 @@ CodePtr TypeTestingStubGenerator::BuildCodeForType(const AbstractType& type) { auto thread = Thread::Current(); auto zone = thread->zone(); HierarchyInfo* hi = thread->hierarchy_info(); - ASSERT(hi != NULL); + ASSERT(hi != nullptr); if (!hi->CanUseSubtypeRangeCheckFor(type) && !hi->CanUseGenericSubtypeRangeCheckFor(type) && @@ -1465,7 +1465,7 @@ AbstractTypePtr TypeArgumentInstantiator::InstantiateType( return to->ptr(); } UNREACHABLE(); - return NULL; + return nullptr; } TypeUsageInfo::TypeUsageInfo(Thread* thread) @@ -1481,7 +1481,7 @@ TypeUsageInfo::TypeUsageInfo(Thread* thread) } TypeUsageInfo::~TypeUsageInfo() { - thread()->set_type_usage_info(NULL); + thread()->set_type_usage_info(nullptr); delete[] instance_creation_arguments_; } diff --git a/runtime/vm/unit_test.cc b/runtime/vm/unit_test.cc index 2b1e2578c40..032153a7420 100644 --- a/runtime/vm/unit_test.cc +++ b/runtime/vm/unit_test.cc @@ -39,11 +39,11 @@ DECLARE_FLAG(bool, force_evacuation); const uint8_t* platform_strong_dill = kPlatformStrongDill; const intptr_t platform_strong_dill_size = kPlatformStrongDillSize; -const uint8_t* TesterState::vm_snapshot_data = NULL; -Dart_IsolateGroupCreateCallback TesterState::create_callback = NULL; -Dart_IsolateShutdownCallback TesterState::shutdown_callback = NULL; +const uint8_t* TesterState::vm_snapshot_data = nullptr; +Dart_IsolateGroupCreateCallback TesterState::create_callback = nullptr; +Dart_IsolateShutdownCallback TesterState::shutdown_callback = nullptr; Dart_IsolateGroupCleanupCallback TesterState::group_cleanup_callback = nullptr; -const char** TesterState::argv = NULL; +const char** TesterState::argv = nullptr; int TesterState::argc = 0; void KernelBufferList::AddBufferToList(const uint8_t* kernel_buffer) { @@ -51,16 +51,16 @@ void KernelBufferList::AddBufferToList(const uint8_t* kernel_buffer) { kernel_buffer_ = kernel_buffer; } -TestCaseBase* TestCaseBase::first_ = NULL; -TestCaseBase* TestCaseBase::tail_ = NULL; -KernelBufferList* TestCaseBase::current_kernel_buffers_ = NULL; +TestCaseBase* TestCaseBase::first_ = nullptr; +TestCaseBase* TestCaseBase::tail_ = nullptr; +KernelBufferList* TestCaseBase::current_kernel_buffers_ = nullptr; TestCaseBase::TestCaseBase(const char* name, const char* expectation) : raw_test_(false), - next_(NULL), + next_(nullptr), name_(name), expectation_(strlen(expectation) > 0 ? expectation : "Pass") { - if (first_ == NULL) { + if (first_ == nullptr) { first_ = this; } else { tail_->next_ = this; @@ -70,7 +70,7 @@ TestCaseBase::TestCaseBase(const char* name, const char* expectation) void TestCaseBase::RunAllRaw() { TestCaseBase* test = first_; - while (test != NULL) { + while (test != nullptr) { if (test->raw_test_) { test->RunTest(); CleanupState(); @@ -81,7 +81,7 @@ void TestCaseBase::RunAllRaw() { void TestCaseBase::RunAll() { TestCaseBase* test = first_; - while (test != NULL) { + while (test != nullptr) { if (!test->raw_test_) { test->RunTest(); CleanupState(); @@ -91,15 +91,15 @@ void TestCaseBase::RunAll() { } void TestCaseBase::CleanupState() { - if (current_kernel_buffers_ != NULL) { + if (current_kernel_buffers_ != nullptr) { delete current_kernel_buffers_; - current_kernel_buffers_ = NULL; + current_kernel_buffers_ = nullptr; } } void TestCaseBase::AddToKernelBuffers(const uint8_t* kernel_buffer) { - ASSERT(kernel_buffer != NULL); - if (current_kernel_buffers_ == NULL) { + ASSERT(kernel_buffer != nullptr); + if (current_kernel_buffers_ == nullptr) { current_kernel_buffers_ = new KernelBufferList(kernel_buffer); } else { current_kernel_buffers_->AddBufferToList(kernel_buffer); @@ -116,7 +116,7 @@ Dart_Isolate TestCase::CreateIsolate(const uint8_t* data_buffer, Dart_IsolateFlags api_flags; Isolate::FlagsInitialize(&api_flags); api_flags.null_safety = FLAG_sound_null_safety; - Dart_Isolate isolate = NULL; + Dart_Isolate isolate = nullptr; if (len == 0) { isolate = Dart_CreateIsolateGroup( /*script_uri=*/name, /*name=*/name, data_buffer, instr_buffer, @@ -127,12 +127,12 @@ Dart_Isolate TestCase::CreateIsolate(const uint8_t* data_buffer, &api_flags, group_data, isolate_data, &err); } - if (isolate == NULL) { + if (isolate == nullptr) { OS::PrintErr("Creation of isolate failed '%s'\n", err); free(err); } - EXPECT(isolate != NULL); + EXPECT(isolate != nullptr); return isolate; } @@ -179,14 +179,14 @@ struct TestLibEntry { const char* source; }; -static MallocGrowableArray* test_libs_ = NULL; +static MallocGrowableArray* test_libs_ = nullptr; const char* TestCase::url() { return RESOLVED_USER_TEST_URI; } void TestCase::AddTestLib(const char* url, const char* source) { - if (test_libs_ == NULL) { + if (test_libs_ == nullptr) { test_libs_ = new MallocGrowableArray(); } // If the test lib is already added, replace the source. @@ -203,15 +203,15 @@ void TestCase::AddTestLib(const char* url, const char* source) { } const char* TestCase::GetTestLib(const char* url) { - if (test_libs_ == NULL) { - return NULL; + if (test_libs_ == nullptr) { + return nullptr; } for (intptr_t i = 0; i < test_libs_->length(); i++) { if (strcmp(url, (*test_libs_)[i].url) == 0) { return (*test_libs_)[i].source; } } - return NULL; + return nullptr; } bool TestCase::IsNNBD() { @@ -249,11 +249,11 @@ static Dart_NativeFunction IsolateReloadTestNativeResolver( Dart_Handle name, int argument_count, bool* auto_setup_scope) { - const char* function_name = NULL; + const char* function_name = nullptr; Dart_Handle result = Dart_StringToCString(name, &function_name); ASSERT(!Dart_IsError(result)); - ASSERT(function_name != NULL); - ASSERT(auto_setup_scope != NULL); + ASSERT(function_name != nullptr); + ASSERT(auto_setup_scope != nullptr); *auto_setup_scope = true; int num_entries = sizeof(ReloadEntries) / sizeof(struct NativeEntries); for (int i = 0; i < num_entries; i++) { @@ -263,11 +263,11 @@ static Dart_NativeFunction IsolateReloadTestNativeResolver( return reinterpret_cast(entry->function_); } } - return NULL; + return nullptr; } void FUNCTION_NAME(Test_Reload)(Dart_NativeArguments native_args) { - Dart_Handle result = TestCase::TriggerReload(/* kernel_buffer= */ NULL, + Dart_Handle result = TestCase::TriggerReload(/* kernel_buffer= */ nullptr, /* kernel_buffer_size= */ 0); if (Dart_IsError(result)) { Dart_PropagateError(result); @@ -332,7 +332,7 @@ char* TestCase::CompileTestScriptWithDFE(const char* url, Zone* zone = Thread::Current()->zone(); Dart_KernelCompilationResult result = KernelIsolate::CompileToKernel( url, platform_strong_dill, platform_strong_dill_size, sourcefiles_count, - sourcefiles, incrementally, false, NULL, multiroot_filepaths, + sourcefiles, incrementally, false, nullptr, multiroot_filepaths, multiroot_scheme); if (result.status == Dart_KernelCompilationStatus_Ok) { if (KernelIsolate::AcceptCompilation().status != @@ -357,22 +357,22 @@ char* TestCase::ValidateCompilationResult( char* result = OS::SCreate(zone, "Compilation failed %s", compilation_result.error); free(compilation_result.error); - if (compilation_result.kernel != NULL) { + if (compilation_result.kernel != nullptr) { free(const_cast(compilation_result.kernel)); } - *kernel_buffer = NULL; + *kernel_buffer = nullptr; *kernel_buffer_size = 0; return result; } *kernel_buffer = compilation_result.kernel; *kernel_buffer_size = compilation_result.kernel_size; - if (compilation_result.error != NULL) { + if (compilation_result.error != nullptr) { free(compilation_result.error); } - if (kernel_buffer == NULL) { - return OS::SCreate(zone, "front end generated a NULL kernel file"); + if (kernel_buffer == nullptr) { + return OS::SCreate(zone, "front end generated a nullptr kernel file"); } - return NULL; + return nullptr; } static Dart_Handle LibraryTagHandler(Dart_LibraryTag tag, @@ -393,11 +393,11 @@ static intptr_t BuildSourceFilesArray( Dart_SourceFile** sourcefiles, const char* script, const char* script_url = RESOLVED_USER_TEST_URI) { - ASSERT(sourcefiles != NULL); - ASSERT(script != NULL); + ASSERT(sourcefiles != nullptr); + ASSERT(script != nullptr); intptr_t num_test_libs = 0; - if (test_libs_ != NULL) { + if (test_libs_ != nullptr) { num_test_libs = test_libs_->length(); } @@ -425,7 +425,7 @@ Dart_Handle TestCase::LoadTestScript(const char* script, bool finalize_classes, bool allow_compile_errors) { LoadIsolateReloadTestLibIfNeeded(script); - Dart_SourceFile* sourcefiles = NULL; + Dart_SourceFile* sourcefiles = nullptr; intptr_t num_sources = BuildSourceFilesArray(&sourcefiles, script, lib_url); Dart_Handle result = LoadTestScriptWithDFE(num_sources, sourcefiles, resolver, @@ -445,13 +445,13 @@ Dart_Handle TestCase::LoadTestLibrary(const char* lib_uri, const char* prefixed_lib_uri = OS::SCreate(Thread::Current()->zone(), "file:///%s", lib_uri); Dart_SourceFile sourcefiles[] = {{prefixed_lib_uri, script}}; - const uint8_t* kernel_buffer = NULL; + const uint8_t* kernel_buffer = nullptr; intptr_t kernel_buffer_size = 0; int sourcefiles_count = sizeof(sourcefiles) / sizeof(Dart_SourceFile); char* error = TestCase::CompileTestScriptWithDFE( sourcefiles[0].uri, sourcefiles_count, sourcefiles, &kernel_buffer, &kernel_buffer_size, true); - if ((kernel_buffer == NULL) && (error != NULL)) { + if ((kernel_buffer == nullptr) && (error != nullptr)) { return Dart_NewApiError(error); } @@ -469,7 +469,7 @@ Dart_Handle TestCase::LoadTestLibrary(const char* lib_uri, Dart_Handle result = Dart_SetRootLibrary(lib); EXPECT_VALID(result); - Dart_SetNativeResolver(lib, resolver, NULL); + Dart_SetNativeResolver(lib, resolver, nullptr); return lib; } @@ -485,14 +485,14 @@ Dart_Handle TestCase::LoadTestScriptWithDFE(int sourcefiles_count, // First script is the main script. Dart_Handle result = Dart_SetLibraryTagHandler(LibraryTagHandler); EXPECT_VALID(result); - const uint8_t* kernel_buffer = NULL; + const uint8_t* kernel_buffer = nullptr; intptr_t kernel_buffer_size = 0; char* error = TestCase::CompileTestScriptWithDFE( - entry_script_uri != NULL ? entry_script_uri : sourcefiles[0].uri, + entry_script_uri != nullptr ? entry_script_uri : sourcefiles[0].uri, sourcefiles_count, sourcefiles, &kernel_buffer, &kernel_buffer_size, incrementally, allow_compile_errors, multiroot_filepaths, multiroot_scheme); - if ((kernel_buffer == NULL) && error != NULL) { + if ((kernel_buffer == nullptr) && error != nullptr) { return Dart_NewApiError(error); } @@ -506,12 +506,12 @@ Dart_Handle TestCase::LoadTestScriptWithDFE(int sourcefiles_count, // BOGUS: Kernel doesn't correctly represent the root library. lib = Dart_LookupLibrary(Dart_NewStringFromCString( - entry_script_uri != NULL ? entry_script_uri : sourcefiles[0].uri)); + entry_script_uri != nullptr ? entry_script_uri : sourcefiles[0].uri)); EXPECT_VALID(lib); result = Dart_SetRootLibrary(lib); EXPECT_VALID(result); - result = Dart_SetNativeResolver(lib, resolver, NULL); + result = Dart_SetNativeResolver(lib, resolver, nullptr); EXPECT_VALID(result); if (finalize) { result = Dart_FinalizeLoading(false); @@ -528,7 +528,7 @@ Dart_Handle TestCase::SetReloadTestScript(const char* script) { FLAG_gc_during_reload = true; FLAG_force_evacuation = true; - Dart_SourceFile* sourcefiles = NULL; + Dart_SourceFile* sourcefiles = nullptr; intptr_t num_files = BuildSourceFilesArray(&sourcefiles, script); Dart_KernelCompilationResult compilation_result = KernelIsolate::UpdateInMemorySources(num_files, sourcefiles); @@ -570,7 +570,7 @@ Dart_Handle TestCase::TriggerReload( } TransitionNativeToVM transition(thread); - if (isolate_group->program_reload_context() != NULL) { + if (isolate_group->program_reload_context() != nullptr) { isolate_group->DeleteReloadContext(); } @@ -597,7 +597,7 @@ Dart_Handle TestCase::TriggerReload(const uint8_t* kernel_buffer, } Dart_Handle TestCase::ReloadTestScript(const char* script) { - Dart_SourceFile* sourcefiles = NULL; + Dart_SourceFile* sourcefiles = nullptr; intptr_t num_files = BuildSourceFilesArray(&sourcefiles, script); Dart_KernelCompilationResult compilation_result = KernelIsolate::UpdateInMemorySources(num_files, sourcefiles); @@ -605,13 +605,14 @@ Dart_Handle TestCase::ReloadTestScript(const char* script) { if (compilation_result.status != Dart_KernelCompilationStatus_Ok) { Dart_Handle result = Dart_NewApiError(compilation_result.error); free(compilation_result.error); - if (compilation_result.kernel != NULL) { + if (compilation_result.kernel != nullptr) { free(const_cast(compilation_result.kernel)); } return result; } - return TriggerReload(/* kernel_buffer= */ NULL, /* kernel_buffer_size= */ 0); + return TriggerReload(/* kernel_buffer= */ nullptr, + /* kernel_buffer_size= */ 0); } Dart_Handle TestCase::ReloadTestKernel(const uint8_t* kernel_buffer, @@ -753,7 +754,7 @@ void AssemblerTest::Assemble() { bool CompilerTest::TestCompileFunction(const Function& function) { Thread* thread = Thread::Current(); - ASSERT(thread != NULL); + ASSERT(thread != nullptr); ASSERT(ClassFinalizer::AllClassesFinalized()); const Object& result = Object::Handle(Compiler::CompileFunction(thread, function)); @@ -765,7 +766,7 @@ void ElideJSONSubstring(const char* prefix, char* out, const char* postfix) { const char* pos = strstr(in, prefix); - while (pos != NULL) { + while (pos != nullptr) { // Copy up to pos into the output buffer. while (in < pos) { *out++ = *in++; diff --git a/runtime/vm/unit_test.h b/runtime/vm/unit_test.h index 971630593f6..c7d5429ea50 100644 --- a/runtime/vm/unit_test.h +++ b/runtime/vm/unit_test.h @@ -241,7 +241,7 @@ class CodeGenerator; class VirtualMemory; namespace bin { -// Snapshot pieces if we link in a snapshot, otherwise initialized to NULL. +// Snapshot pieces if we link in a snapshot, otherwise initialized to nullptr. extern const uint8_t* vm_snapshot_data; extern const uint8_t* vm_snapshot_instructions; extern const uint8_t* core_isolate_snapshot_data; @@ -264,14 +264,14 @@ class TesterState : public AllStatic { class KernelBufferList { public: explicit KernelBufferList(const uint8_t* kernel_buffer) - : kernel_buffer_(kernel_buffer), next_(NULL) {} + : kernel_buffer_(kernel_buffer), next_(nullptr) {} KernelBufferList(const uint8_t* kernel_buffer, KernelBufferList* next) : kernel_buffer_(kernel_buffer), next_(next) {} ~KernelBufferList() { free(const_cast(kernel_buffer_)); - if (next_ != NULL) { + if (next_ != nullptr) { delete next_; } } @@ -325,23 +325,25 @@ class TestCase : TestCaseBase { TestCase(RunEntry* run, const char* name, const char* expectation) : TestCaseBase(name, expectation), run_(run) {} - static char* CompileTestScriptWithDFE(const char* url, - const char* source, - const uint8_t** kernel_buffer, - intptr_t* kernel_buffer_size, - bool incrementally = true, - bool allow_compile_errors = false, - const char* multiroot_filepaths = NULL, - const char* multiroot_scheme = NULL); - static char* CompileTestScriptWithDFE(const char* url, - int sourcefiles_count, - Dart_SourceFile sourcefiles[], - const uint8_t** kernel_buffer, - intptr_t* kernel_buffer_size, - bool incrementally = true, - bool allow_compile_errors = false, - const char* multiroot_filepaths = NULL, - const char* multiroot_scheme = NULL); + static char* CompileTestScriptWithDFE( + const char* url, + const char* source, + const uint8_t** kernel_buffer, + intptr_t* kernel_buffer_size, + bool incrementally = true, + bool allow_compile_errors = false, + const char* multiroot_filepaths = nullptr, + const char* multiroot_scheme = nullptr); + static char* CompileTestScriptWithDFE( + const char* url, + int sourcefiles_count, + Dart_SourceFile sourcefiles[], + const uint8_t** kernel_buffer, + intptr_t* kernel_buffer_size, + bool incrementally = true, + bool allow_compile_errors = false, + const char* multiroot_filepaths = nullptr, + const char* multiroot_scheme = nullptr); static Dart_Handle LoadTestScript( const char* script, Dart_NativeEntryResolver resolver, @@ -350,22 +352,23 @@ class TestCase : TestCaseBase { bool allow_compile_errors = false); static Dart_Handle LoadTestScriptWithErrors( const char* script, - Dart_NativeEntryResolver resolver = NULL, + Dart_NativeEntryResolver resolver = nullptr, const char* lib_uri = RESOLVED_USER_TEST_URI, bool finalize = true); - static Dart_Handle LoadTestLibrary(const char* lib_uri, - const char* script, - Dart_NativeEntryResolver resolver = NULL); + static Dart_Handle LoadTestLibrary( + const char* lib_uri, + const char* script, + Dart_NativeEntryResolver resolver = nullptr); static Dart_Handle LoadTestScriptWithDFE( int sourcefiles_count, Dart_SourceFile sourcefiles[], - Dart_NativeEntryResolver resolver = NULL, + Dart_NativeEntryResolver resolver = nullptr, bool finalize = true, bool incrementally = true, bool allow_compile_errors = false, - const char* entry_script_uri = NULL, - const char* multiroot_filepaths = NULL, - const char* multiroot_scheme = NULL); + const char* entry_script_uri = nullptr, + const char* multiroot_filepaths = nullptr, + const char* multiroot_scheme = nullptr); static Dart_Handle LoadCoreTestScript(const char* script, Dart_NativeEntryResolver resolver); @@ -376,9 +379,10 @@ class TestCase : TestCaseBase { static Dart_Handle lib(); static const char* url(); - static Dart_Isolate CreateTestIsolateFromSnapshot(uint8_t* buffer, - const char* name = NULL) { - return CreateIsolate(buffer, 0, NULL, name); + static Dart_Isolate CreateTestIsolateFromSnapshot( + uint8_t* buffer, + const char* name = nullptr) { + return CreateIsolate(buffer, 0, nullptr, name); } static Dart_Isolate CreateTestIsolate(const char* name = nullptr, void* isolate_group_data = nullptr, @@ -468,7 +472,7 @@ class TestIsolateScope { Dart_ExitScope(); // Exit the Dart API scope created for unit tests. ASSERT(isolate_ == Isolate::Current()); Dart_ShutdownIsolate(); - isolate_ = NULL; + isolate_ = nullptr; } Isolate* isolate() const { return isolate_; } @@ -509,8 +513,8 @@ class AssemblerTest { assembler_(assembler), code_(Code::ZoneHandle(zone)), disassembly_(zone->Alloc(DISASSEMBLY_SIZE)) { - ASSERT(name != NULL); - ASSERT(assembler != NULL); + ASSERT(name != nullptr); + ASSERT(assembler != nullptr); } ~AssemblerTest() {} @@ -540,7 +544,7 @@ class AssemblerTest { const bool fp_return = is_double::value; const bool fp_args = false; Thread* thread = Thread::Current(); - ASSERT(thread != NULL); + ASSERT(thread != nullptr); return bit_cast(Simulator::Current()->Call( bit_cast(entry()), reinterpret_cast(&code_), reinterpret_cast(thread), 0, 0, fp_return, fp_args)); @@ -552,7 +556,7 @@ class AssemblerTest { // TODO(fschneider): Support double arguments for simulator calls. COMPILE_ASSERT(!fp_args); Thread* thread = Thread::Current(); - ASSERT(thread != NULL); + ASSERT(thread != nullptr); return bit_cast(Simulator::Current()->Call( bit_cast(entry()), reinterpret_cast(&code_), reinterpret_cast(thread), reinterpret_cast(arg1), 0, @@ -591,7 +595,7 @@ class AssemblerTest { template ResultType InvokeWithCodeAndThread() { Thread* thread = Thread::Current(); - ASSERT(thread != NULL); + ASSERT(thread != nullptr); typedef ResultType (*FunctionType)(const Code&, Thread*); return reinterpret_cast(entry())(code_, thread); } @@ -599,7 +603,7 @@ class AssemblerTest { template ResultType InvokeWithCodeAndThread(Arg1Type arg1) { Thread* thread = Thread::Current(); - ASSERT(thread != NULL); + ASSERT(thread != nullptr); typedef ResultType (*FunctionType)(const Code&, Thread*, Arg1Type); return reinterpret_cast(entry())(code_, thread, arg1); } diff --git a/runtime/vm/uri.cc b/runtime/vm/uri.cc index 54cfabe40c2..f79ba1b1211 100644 --- a/runtime/vm/uri.cc +++ b/runtime/vm/uri.cc @@ -146,13 +146,13 @@ static void StringLower(char* str) { } static void ClearParsedUri(ParsedUri* parsed_uri) { - parsed_uri->scheme = NULL; - parsed_uri->userinfo = NULL; - parsed_uri->host = NULL; - parsed_uri->port = NULL; - parsed_uri->path = NULL; - parsed_uri->query = NULL; - parsed_uri->fragment = NULL; + parsed_uri->scheme = nullptr; + parsed_uri->userinfo = nullptr; + parsed_uri->host = nullptr; + parsed_uri->port = nullptr; + parsed_uri->path = nullptr; + parsed_uri->query = nullptr; + parsed_uri->fragment = nullptr; } static intptr_t ParseAuthority(const char* authority, ParsedUri* parsed_uri) { @@ -167,7 +167,7 @@ static intptr_t ParseAuthority(const char* authority, ParsedUri* parsed_uri) { current += userinfo_len + 1; len += userinfo_len + 1; } else { - parsed_uri->userinfo = NULL; + parsed_uri->userinfo = nullptr; } size_t host_len = strcspn(current, ":/"); @@ -183,7 +183,7 @@ static intptr_t ParseAuthority(const char* authority, ParsedUri* parsed_uri) { parsed_uri->port = zone->MakeCopyOfStringN(port_start, port_len); len += 1 + port_len; // +1 for ':' } else { - parsed_uri->port = NULL; + parsed_uri->port = nullptr; } return len; } @@ -203,7 +203,7 @@ bool ParseUri(const char* uri, ParsedUri* parsed_uri) { parsed_uri->scheme = scheme; rest = uri + scheme_len + 1; } else { - parsed_uri->scheme = NULL; + parsed_uri->scheme = nullptr; } // The first '#' separates the optional fragment @@ -214,7 +214,7 @@ bool ParseUri(const char* uri, ParsedUri* parsed_uri) { parsed_uri->fragment = NormalizeEscapes(fragment_start, strlen(fragment_start)); } else { - parsed_uri->fragment = NULL; + parsed_uri->fragment = nullptr; } // The first '?' or '#' separates the hierarchical part from the @@ -225,7 +225,7 @@ bool ParseUri(const char* uri, ParsedUri* parsed_uri) { const char* query_start = question_pos + 1; parsed_uri->query = NormalizeEscapes(query_start, (hash_pos - query_start)); } else { - parsed_uri->query = NULL; + parsed_uri->query = nullptr; } const char* path_start = rest; @@ -240,9 +240,9 @@ bool ParseUri(const char* uri, ParsedUri* parsed_uri) { } path_start = authority_start + authority_len; } else { - parsed_uri->userinfo = NULL; - parsed_uri->host = NULL; - parsed_uri->port = NULL; + parsed_uri->userinfo = nullptr; + parsed_uri->host = nullptr; + parsed_uri->port = nullptr; } // The path is the substring between the authority and the query. @@ -350,7 +350,7 @@ static const char* MergePaths(const char* base_path, const char* ref_path) { // We need to find the last '/' in base_path. const char* last_slash = strrchr(base_path, '/'); - if (last_slash == NULL) { + if (last_slash == nullptr) { // There is no slash in the base_path. Return the ref_path unchanged. return ref_path; } @@ -376,34 +376,35 @@ static const char* MergePaths(const char* base_path, const char* ref_path) { static char* BuildUri(const ParsedUri& uri) { Zone* zone = ThreadState::Current()->zone(); - ASSERT(uri.path != NULL); + ASSERT(uri.path != nullptr); - const char* fragment = uri.fragment == NULL ? "" : uri.fragment; - const char* fragment_separator = uri.fragment == NULL ? "" : "#"; - const char* query = uri.query == NULL ? "" : uri.query; - const char* query_separator = uri.query == NULL ? "" : "?"; + const char* fragment = uri.fragment == nullptr ? "" : uri.fragment; + const char* fragment_separator = uri.fragment == nullptr ? "" : "#"; + const char* query = uri.query == nullptr ? "" : uri.query; + const char* query_separator = uri.query == nullptr ? "" : "?"; // If there is no scheme for this uri, just build a relative uri of // the form: "path[?query][#fragment]". This occurs when we resolve // relative urls inside a "dart:" library. - if (uri.scheme == NULL) { - ASSERT(uri.userinfo == NULL && uri.host == NULL && uri.port == NULL); + if (uri.scheme == nullptr) { + ASSERT(uri.userinfo == nullptr && uri.host == nullptr && + uri.port == nullptr); return zone->PrintToString("%s%s%s%s%s", uri.path, query_separator, query, fragment_separator, fragment); } // Uri with no authority: "scheme:path[?query][#fragment]" - if (uri.host == NULL) { - ASSERT(uri.userinfo == NULL && uri.port == NULL); + if (uri.host == nullptr) { + ASSERT(uri.userinfo == nullptr && uri.port == nullptr); return zone->PrintToString("%s:%s%s%s%s%s", uri.scheme, uri.path, query_separator, query, fragment_separator, fragment); } - const char* user = uri.userinfo == NULL ? "" : uri.userinfo; - const char* user_separator = uri.userinfo == NULL ? "" : "@"; - const char* port = uri.port == NULL ? "" : uri.port; - const char* port_separator = uri.port == NULL ? "" : ":"; + const char* user = uri.userinfo == nullptr ? "" : uri.userinfo; + const char* user_separator = uri.userinfo == nullptr ? "" : "@"; + const char* port = uri.port == nullptr ? "" : uri.port; + const char* port_separator = uri.port == nullptr ? "" : ":"; // If the path doesn't start with a '/', add one. We need it to // separate the path from the authority. @@ -426,12 +427,12 @@ bool ResolveUri(const char* ref_uri, // Parse the reference uri. ParsedUri ref; if (!ParseUri(ref_uri, &ref)) { - *target_uri = NULL; + *target_uri = nullptr; return false; } ParsedUri target; - if (ref.scheme != NULL) { + if (ref.scheme != nullptr) { if (strcmp(ref.scheme, "dart") == 0) { Zone* zone = ThreadState::Current()->zone(); *target_uri = zone->MakeCopyOfString(ref_uri); @@ -453,17 +454,17 @@ bool ResolveUri(const char* ref_uri, // Parse the base uri. ParsedUri base; if (!ParseUri(base_uri, &base)) { - *target_uri = NULL; + *target_uri = nullptr; return false; } - if ((base.scheme != NULL) && strcmp(base.scheme, "dart") == 0) { + if ((base.scheme != nullptr) && strcmp(base.scheme, "dart") == 0) { Zone* zone = ThreadState::Current()->zone(); *target_uri = zone->MakeCopyOfString(ref_uri); return true; } - if (ref.host != NULL) { + if (ref.host != nullptr) { // When the ref_uri specifies an authority, we only use the base scheme. target.scheme = base.scheme; target.userinfo = ref.userinfo; @@ -483,7 +484,7 @@ bool ResolveUri(const char* ref_uri, target.host = base.host; target.port = base.port; target.path = base.path; - target.query = ((ref.query == NULL) ? base.query : ref.query); + target.query = ((ref.query == nullptr) ? base.query : ref.query); target.fragment = ref.fragment; *target_uri = BuildUri(target); return true; @@ -503,13 +504,13 @@ bool ResolveUri(const char* ref_uri, } else { // Relative path. We need to merge the base path and the ref path. - if (base.scheme == NULL && base.host == NULL && base.path[0] != '/') { + if (base.scheme == nullptr && base.host == nullptr && base.path[0] != '/') { // The dart:core Uri class handles resolving a relative uri // against a second relative uri specially, in a way not // described in the RFC. We do not need to support this for // library resolution. If we need to implement this later, we // can. - *target_uri = NULL; + *target_uri = nullptr; return false; } diff --git a/runtime/vm/uri_test.cc b/runtime/vm/uri_test.cc index a0470a38d00..3752a1be1bf 100644 --- a/runtime/vm/uri_test.cc +++ b/runtime/vm/uri_test.cc @@ -11,35 +11,35 @@ TEST_CASE(ParseUri_WithScheme_NoQueryNoUser) { ParsedUri uri; EXPECT(ParseUri("foo://example.com:8042/over/there", &uri)); EXPECT_STREQ("foo", uri.scheme); - EXPECT(uri.userinfo == NULL); + EXPECT(uri.userinfo == nullptr); EXPECT_STREQ("example.com", uri.host); EXPECT_STREQ("8042", uri.port); EXPECT_STREQ("/over/there", uri.path); - EXPECT(uri.query == NULL); - EXPECT(uri.fragment == NULL); + EXPECT(uri.query == nullptr); + EXPECT(uri.fragment == nullptr); } TEST_CASE(ParseUri_WithScheme_WithQuery) { ParsedUri uri; EXPECT(ParseUri("foo://example.com:8042/over/there?name=ferret", &uri)); EXPECT_STREQ("foo", uri.scheme); - EXPECT(uri.userinfo == NULL); + EXPECT(uri.userinfo == nullptr); EXPECT_STREQ("example.com", uri.host); EXPECT_STREQ("8042", uri.port); EXPECT_STREQ("/over/there", uri.path); EXPECT_STREQ("name=ferret", uri.query); - EXPECT(uri.fragment == NULL); + EXPECT(uri.fragment == nullptr); } TEST_CASE(ParseUri_WithScheme_WithFragment) { ParsedUri uri; EXPECT(ParseUri("foo://example.com:8042/over/there#fragment", &uri)); EXPECT_STREQ("foo", uri.scheme); - EXPECT(uri.userinfo == NULL); + EXPECT(uri.userinfo == nullptr); EXPECT_STREQ("example.com", uri.host); EXPECT_STREQ("8042", uri.port); EXPECT_STREQ("/over/there", uri.path); - EXPECT(uri.query == NULL); + EXPECT(uri.query == nullptr); EXPECT_STREQ("fragment", uri.fragment); } @@ -48,7 +48,7 @@ TEST_CASE(ParseUri_WithScheme_WithQueryWithFragment) { EXPECT( ParseUri("foo://example.com:8042/over/there?name=ferret#fragment", &uri)); EXPECT_STREQ("foo", uri.scheme); - EXPECT(uri.userinfo == NULL); + EXPECT(uri.userinfo == nullptr); EXPECT_STREQ("example.com", uri.host); EXPECT_STREQ("8042", uri.port); EXPECT_STREQ("/over/there", uri.path); @@ -64,151 +64,151 @@ TEST_CASE(ParseUri_WithScheme_WithUser) { EXPECT_STREQ("example.com", uri.host); EXPECT_STREQ("8042", uri.port); EXPECT_STREQ("/over/there", uri.path); - EXPECT(uri.query == NULL); - EXPECT(uri.fragment == NULL); + EXPECT(uri.query == nullptr); + EXPECT(uri.fragment == nullptr); } TEST_CASE(ParseUri_WithScheme_ShortPath) { ParsedUri uri; EXPECT(ParseUri("foo://example.com:8042/", &uri)); EXPECT_STREQ("foo", uri.scheme); - EXPECT(uri.userinfo == NULL); + EXPECT(uri.userinfo == nullptr); EXPECT_STREQ("example.com", uri.host); EXPECT_STREQ("8042", uri.port); EXPECT_STREQ("/", uri.path); - EXPECT(uri.query == NULL); - EXPECT(uri.fragment == NULL); + EXPECT(uri.query == nullptr); + EXPECT(uri.fragment == nullptr); } TEST_CASE(ParseUri_WithScheme_EmptyPath) { ParsedUri uri; EXPECT(ParseUri("foo://example.com:8042", &uri)); EXPECT_STREQ("foo", uri.scheme); - EXPECT(uri.userinfo == NULL); + EXPECT(uri.userinfo == nullptr); EXPECT_STREQ("example.com", uri.host); EXPECT_STREQ("8042", uri.port); EXPECT_STREQ("", uri.path); - EXPECT(uri.query == NULL); - EXPECT(uri.fragment == NULL); + EXPECT(uri.query == nullptr); + EXPECT(uri.fragment == nullptr); } TEST_CASE(ParseUri_WithScheme_Rootless1) { ParsedUri uri; EXPECT(ParseUri("foo:here", &uri)); EXPECT_STREQ("foo", uri.scheme); - EXPECT(uri.userinfo == NULL); - EXPECT(uri.host == NULL); - EXPECT(uri.port == NULL); + EXPECT(uri.userinfo == nullptr); + EXPECT(uri.host == nullptr); + EXPECT(uri.port == nullptr); EXPECT_STREQ("here", uri.path); - EXPECT(uri.query == NULL); - EXPECT(uri.fragment == NULL); + EXPECT(uri.query == nullptr); + EXPECT(uri.fragment == nullptr); } TEST_CASE(ParseUri_WithScheme_Rootless2) { ParsedUri uri; EXPECT(ParseUri("foo:or/here", &uri)); EXPECT_STREQ("foo", uri.scheme); - EXPECT(uri.userinfo == NULL); - EXPECT(uri.host == NULL); - EXPECT(uri.port == NULL); + EXPECT(uri.userinfo == nullptr); + EXPECT(uri.host == nullptr); + EXPECT(uri.port == nullptr); EXPECT_STREQ("or/here", uri.path); - EXPECT(uri.query == NULL); - EXPECT(uri.fragment == NULL); + EXPECT(uri.query == nullptr); + EXPECT(uri.fragment == nullptr); } TEST_CASE(ParseUri_NoScheme_AbsPath_WithAuthority) { ParsedUri uri; EXPECT(ParseUri("//example.com:8042/over/there", &uri)); - EXPECT(uri.scheme == NULL); - EXPECT(uri.userinfo == NULL); + EXPECT(uri.scheme == nullptr); + EXPECT(uri.userinfo == nullptr); EXPECT_STREQ("example.com", uri.host); EXPECT_STREQ("8042", uri.port); EXPECT_STREQ("/over/there", uri.path); - EXPECT(uri.query == NULL); - EXPECT(uri.fragment == NULL); + EXPECT(uri.query == nullptr); + EXPECT(uri.fragment == nullptr); } TEST_CASE(ParseUri_NoScheme_AbsPath_NoAuthority) { ParsedUri uri; EXPECT(ParseUri("/over/there", &uri)); - EXPECT(uri.scheme == NULL); - EXPECT(uri.userinfo == NULL); - EXPECT(uri.host == NULL); - EXPECT(uri.port == NULL); + EXPECT(uri.scheme == nullptr); + EXPECT(uri.userinfo == nullptr); + EXPECT(uri.host == nullptr); + EXPECT(uri.port == nullptr); EXPECT_STREQ("/over/there", uri.path); - EXPECT(uri.query == NULL); - EXPECT(uri.fragment == NULL); + EXPECT(uri.query == nullptr); + EXPECT(uri.fragment == nullptr); } // Colons are permitted in path segments, in many cases. TEST_CASE(ParseUri_NoScheme_AbsPath_StrayColon) { ParsedUri uri; EXPECT(ParseUri("/ov:er/there", &uri)); - EXPECT(uri.scheme == NULL); - EXPECT(uri.userinfo == NULL); - EXPECT(uri.host == NULL); - EXPECT(uri.port == NULL); + EXPECT(uri.scheme == nullptr); + EXPECT(uri.userinfo == nullptr); + EXPECT(uri.host == nullptr); + EXPECT(uri.port == nullptr); EXPECT_STREQ("/ov:er/there", uri.path); - EXPECT(uri.query == NULL); + EXPECT(uri.query == nullptr); } TEST_CASE(ParseUri_NoScheme_Rootless1) { ParsedUri uri; EXPECT(ParseUri("here", &uri)); - EXPECT(uri.scheme == NULL); - EXPECT(uri.userinfo == NULL); - EXPECT(uri.host == NULL); - EXPECT(uri.port == NULL); + EXPECT(uri.scheme == nullptr); + EXPECT(uri.userinfo == nullptr); + EXPECT(uri.host == nullptr); + EXPECT(uri.port == nullptr); EXPECT_STREQ("here", uri.path); - EXPECT(uri.query == NULL); - EXPECT(uri.fragment == NULL); + EXPECT(uri.query == nullptr); + EXPECT(uri.fragment == nullptr); } TEST_CASE(ParseUri_NoScheme_Rootless2) { ParsedUri uri; EXPECT(ParseUri("or/here", &uri)); - EXPECT(uri.scheme == NULL); - EXPECT(uri.userinfo == NULL); - EXPECT(uri.host == NULL); - EXPECT(uri.port == NULL); + EXPECT(uri.scheme == nullptr); + EXPECT(uri.userinfo == nullptr); + EXPECT(uri.host == nullptr); + EXPECT(uri.port == nullptr); EXPECT_STREQ("or/here", uri.path); - EXPECT(uri.query == NULL); - EXPECT(uri.fragment == NULL); + EXPECT(uri.query == nullptr); + EXPECT(uri.fragment == nullptr); } TEST_CASE(ParseUri_NoScheme_Empty) { ParsedUri uri; EXPECT(ParseUri("", &uri)); - EXPECT(uri.scheme == NULL); - EXPECT(uri.userinfo == NULL); - EXPECT(uri.host == NULL); - EXPECT(uri.port == NULL); + EXPECT(uri.scheme == nullptr); + EXPECT(uri.userinfo == nullptr); + EXPECT(uri.host == nullptr); + EXPECT(uri.port == nullptr); EXPECT_STREQ("", uri.path); - EXPECT(uri.query == NULL); - EXPECT(uri.fragment == NULL); + EXPECT(uri.query == nullptr); + EXPECT(uri.fragment == nullptr); } TEST_CASE(ParseUri_NoScheme_QueryOnly) { ParsedUri uri; EXPECT(ParseUri("?name=ferret", &uri)); - EXPECT(uri.scheme == NULL); - EXPECT(uri.userinfo == NULL); - EXPECT(uri.host == NULL); - EXPECT(uri.port == NULL); + EXPECT(uri.scheme == nullptr); + EXPECT(uri.userinfo == nullptr); + EXPECT(uri.host == nullptr); + EXPECT(uri.port == nullptr); EXPECT_STREQ("", uri.path); EXPECT_STREQ("name=ferret", uri.query); - EXPECT(uri.fragment == NULL); + EXPECT(uri.fragment == nullptr); } TEST_CASE(ParseUri_NoScheme_FragmentOnly) { ParsedUri uri; EXPECT(ParseUri("#fragment", &uri)); - EXPECT(uri.scheme == NULL); - EXPECT(uri.userinfo == NULL); - EXPECT(uri.host == NULL); - EXPECT(uri.port == NULL); + EXPECT(uri.scheme == nullptr); + EXPECT(uri.userinfo == nullptr); + EXPECT(uri.host == nullptr); + EXPECT(uri.port == nullptr); EXPECT_STREQ("", uri.path); - EXPECT(uri.query == NULL); + EXPECT(uri.query == nullptr); EXPECT_STREQ("fragment", uri.fragment); } @@ -216,12 +216,12 @@ TEST_CASE(ParseUri_LowerCaseScheme) { ParsedUri uri; EXPECT(ParseUri("ScHeMe:path", &uri)); EXPECT_STREQ("scheme", uri.scheme); - EXPECT(uri.userinfo == NULL); - EXPECT(uri.host == NULL); - EXPECT(uri.port == NULL); + EXPECT(uri.userinfo == nullptr); + EXPECT(uri.host == nullptr); + EXPECT(uri.port == nullptr); EXPECT_STREQ("path", uri.path); - EXPECT(uri.query == NULL); - EXPECT(uri.fragment == NULL); + EXPECT(uri.query == nullptr); + EXPECT(uri.fragment == nullptr); } TEST_CASE(ParseUri_NormalizeEscapes_PathQueryFragment) { @@ -229,9 +229,9 @@ TEST_CASE(ParseUri_NormalizeEscapes_PathQueryFragment) { EXPECT(ParseUri("scheme:/This%09Is A P%61th?This%09Is A Qu%65ry#A Fr%61gment", &uri)); EXPECT_STREQ("scheme", uri.scheme); - EXPECT(uri.userinfo == NULL); - EXPECT(uri.host == NULL); - EXPECT(uri.port == NULL); + EXPECT(uri.userinfo == nullptr); + EXPECT(uri.host == nullptr); + EXPECT(uri.port == nullptr); EXPECT_STREQ("/This%09Is%20A%20Path", uri.path); EXPECT_STREQ("This%09Is%20A%20Query", uri.query); EXPECT_STREQ("A%20Fragment", uri.fragment); @@ -241,12 +241,12 @@ TEST_CASE(ParseUri_NormalizeEscapes_UppercaseEscapesPreferred) { ParsedUri uri; EXPECT(ParseUri("scheme:/%1b%1B", &uri)); EXPECT_STREQ("scheme", uri.scheme); - EXPECT(uri.userinfo == NULL); - EXPECT(uri.host == NULL); - EXPECT(uri.port == NULL); + EXPECT(uri.userinfo == nullptr); + EXPECT(uri.host == nullptr); + EXPECT(uri.port == nullptr); EXPECT_STREQ("/%1B%1B", uri.path); - EXPECT(uri.query == NULL); - EXPECT(uri.fragment == NULL); + EXPECT(uri.query == nullptr); + EXPECT(uri.fragment == nullptr); } TEST_CASE(ParseUri_NormalizeEscapes_Authority) { @@ -257,32 +257,32 @@ TEST_CASE(ParseUri_NormalizeEscapes_Authority) { EXPECT_STREQ("host.com", uri.host); // Normalized, lower-cased. EXPECT_STREQ("80", uri.port); EXPECT_STREQ("/", uri.path); - EXPECT(uri.query == NULL); - EXPECT(uri.fragment == NULL); + EXPECT(uri.query == nullptr); + EXPECT(uri.fragment == nullptr); } TEST_CASE(ParseUri_NormalizeEscapes_UppercaseEscapeInHost) { ParsedUri uri; EXPECT(ParseUri("scheme://tEst%1b/", &uri)); EXPECT_STREQ("scheme", uri.scheme); - EXPECT(uri.userinfo == NULL); + EXPECT(uri.userinfo == nullptr); EXPECT_STREQ("test%1B", uri.host); // Notice that %1B is upper-cased. - EXPECT(uri.port == NULL); + EXPECT(uri.port == nullptr); EXPECT_STREQ("/", uri.path); - EXPECT(uri.query == NULL); - EXPECT(uri.fragment == NULL); + EXPECT(uri.query == nullptr); + EXPECT(uri.fragment == nullptr); } TEST_CASE(ParseUri_BrokenEscapeSequence) { ParsedUri uri; EXPECT(ParseUri("scheme:/%1g", &uri)); EXPECT_STREQ("scheme", uri.scheme); - EXPECT(uri.userinfo == NULL); - EXPECT(uri.host == NULL); - EXPECT(uri.port == NULL); + EXPECT(uri.userinfo == nullptr); + EXPECT(uri.host == nullptr); + EXPECT(uri.port == nullptr); EXPECT_STREQ("/%1g", uri.path); // Broken sequence is unchanged. - EXPECT(uri.query == NULL); - EXPECT(uri.fragment == NULL); + EXPECT(uri.query == nullptr); + EXPECT(uri.fragment == nullptr); } TEST_CASE(ResolveUri_WithScheme_NoAuthorityNoQuery) { @@ -481,25 +481,25 @@ TEST_CASE(ResolveUri_DataUri) { TEST_CASE(ResolveUri_RelativeBase_NotImplemented) { const char* target_uri; EXPECT(!ResolveUri("../r1", "b1/b2", &target_uri)); - EXPECT(target_uri == NULL); + EXPECT(target_uri == nullptr); EXPECT(!ResolveUri("..", "b1/b2", &target_uri)); - EXPECT(target_uri == NULL); + EXPECT(target_uri == nullptr); EXPECT(!ResolveUri("../..", "b1/b2", &target_uri)); - EXPECT(target_uri == NULL); + EXPECT(target_uri == nullptr); EXPECT(!ResolveUri("../../..", "b1/b2", &target_uri)); - EXPECT(target_uri == NULL); + EXPECT(target_uri == nullptr); EXPECT(!ResolveUri("../../../r1", "b1/b2", &target_uri)); - EXPECT(target_uri == NULL); + EXPECT(target_uri == nullptr); EXPECT(!ResolveUri("../r1", "../../b1/b2/b3", &target_uri)); - EXPECT(target_uri == NULL); + EXPECT(target_uri == nullptr); EXPECT(!ResolveUri("../../../r1", "../../b1/b2/b3", &target_uri)); - EXPECT(target_uri == NULL); + EXPECT(target_uri == nullptr); } static const char* TestResolve(const char* base_uri, const char* uri) { diff --git a/runtime/vm/virtual_memory.cc b/runtime/vm/virtual_memory.cc index 4f0ba4392d1..4901a38a637 100644 --- a/runtime/vm/virtual_memory.cc +++ b/runtime/vm/virtual_memory.cc @@ -36,7 +36,7 @@ VirtualMemory* VirtualMemory::ForImagePage(void* pointer, uword size) { // Memory for precompilated instructions was allocated by the embedder, so // create a VirtualMemory without allocating. MemoryRegion region(pointer, size); - MemoryRegion reserved(0, 0); // NULL reservation indicates VM should not + MemoryRegion reserved(0, 0); // nullptr reservation indicates VM should not // attempt to free this memory. VirtualMemory* memory = new VirtualMemory(region, region, reserved); ASSERT(!memory->vm_owns_region()); diff --git a/runtime/vm/virtual_memory.h b/runtime/vm/virtual_memory.h index d25093c5dad..3c2152b7c8e 100644 --- a/runtime/vm/virtual_memory.h +++ b/runtime/vm/virtual_memory.h @@ -49,7 +49,7 @@ class VirtualMemory { static void DontNeed(void* address, intptr_t size); // Reserves and commits a virtual memory segment with size. If a segment of - // the requested size cannot be allocated, NULL is returned. + // the requested size cannot be allocated, nullptr is returned. static VirtualMemory* Allocate(intptr_t size, bool is_executable, bool is_compressed, @@ -77,7 +77,7 @@ class VirtualMemory { // False for a part of a snapshot added directly to the Dart heap, which // belongs to the embedder and must not be deallocated or have its // protection status changed by the VM. - bool vm_owns_region() const { return reserved_.pointer() != NULL; } + bool vm_owns_region() const { return reserved_.pointer() != nullptr; } static VirtualMemory* ForImagePage(void* pointer, uword size); diff --git a/runtime/vm/virtual_memory_fuchsia.cc b/runtime/vm/virtual_memory_fuchsia.cc index a7e516402a5..e35125a0d42 100644 --- a/runtime/vm/virtual_memory_fuchsia.cc +++ b/runtime/vm/virtual_memory_fuchsia.cc @@ -166,10 +166,10 @@ VirtualMemory* VirtualMemory::AllocateAligned(intptr_t size, if (status != ZX_OK) { LOG_ERR("zx_vmo_create(0x%lx) failed: %s\n", size, zx_status_get_string(status)); - return NULL; + return nullptr; } - if (name != NULL) { + if (name != nullptr) { zx_object_set_property(vmo, ZX_PROP_NAME, name, strlen(name)); } @@ -181,7 +181,7 @@ VirtualMemory* VirtualMemory::AllocateAligned(intptr_t size, LOG_ERR("zx_vmo_replace_as_executable() failed: %s\n", zx_status_get_string(status)); zx_handle_close(vmo); - return NULL; + return nullptr; } } @@ -195,7 +195,7 @@ VirtualMemory* VirtualMemory::AllocateAligned(intptr_t size, LOG_ERR("zx_vmar_map(%u, 0x%lx, 0x%lx) failed: %s\n", region_options, base, size, zx_status_get_string(status)); zx_handle_close(vmo); - return NULL; + return nullptr; } void* region_ptr = reinterpret_cast(base); MemoryRegion region(region_ptr, size); @@ -214,7 +214,7 @@ VirtualMemory* VirtualMemory::AllocateAligned(intptr_t size, size, zx_status_get_string(status)); const uword region_base = reinterpret_cast(region_ptr); Unmap(vmar, region_base, region_base + size); - return NULL; + return nullptr; } void* alias_ptr = reinterpret_cast(base); ASSERT(region_ptr != alias_ptr); diff --git a/runtime/vm/virtual_memory_test.cc b/runtime/vm/virtual_memory_test.cc index 083c9061c35..e21a304bff2 100644 --- a/runtime/vm/virtual_memory_test.cc +++ b/runtime/vm/virtual_memory_test.cc @@ -23,8 +23,8 @@ VM_UNIT_TEST_CASE(AllocateVirtualMemory) { const intptr_t kVirtualMemoryBlockSize = 64 * KB; VirtualMemory* vm = VirtualMemory::Allocate(kVirtualMemoryBlockSize, false, false, "test"); - EXPECT(vm != NULL); - EXPECT(vm->address() != NULL); + EXPECT(vm != nullptr); + EXPECT(vm->address() != nullptr); EXPECT_EQ(vm->start(), reinterpret_cast(vm->address())); EXPECT_EQ(kVirtualMemoryBlockSize, vm->size()); EXPECT_EQ(vm->start() + kVirtualMemoryBlockSize, vm->end()); diff --git a/runtime/vm/zone.cc b/runtime/vm/zone.cc index d0d878c775d..f5dcc271fba 100644 --- a/runtime/vm/zone.cc +++ b/runtime/vm/zone.cc @@ -112,7 +112,7 @@ Zone::Segment* Zone::Segment::New(intptr_t size, Zone::Segment* next) { void Zone::Segment::DeleteSegmentList(Segment* head) { Segment* current = head; - while (current != NULL) { + while (current != nullptr) { intptr_t size = current->size(); Segment* next = current->next(); VirtualMemory* memory = current->memory(); @@ -286,7 +286,7 @@ char* Zone::MakeCopyOfStringN(const char* str, intptr_t len) { } char* Zone::ConcatStrings(const char* a, const char* b, char join) { - intptr_t a_len = (a == NULL) ? 0 : strlen(a); + intptr_t a_len = (a == nullptr) ? 0 : strlen(a); const intptr_t b_len = strlen(b) + 1; // '\0'-terminated. const intptr_t len = a_len + b_len; char* copy = Alloc(len); @@ -301,7 +301,7 @@ char* Zone::ConcatStrings(const char* a, const char* b, char join) { void Zone::VisitObjectPointers(ObjectPointerVisitor* visitor) { Zone* zone = this; - while (zone != NULL) { + while (zone != nullptr) { zone->handles()->VisitObjectPointers(visitor); zone = zone->previous_; } diff --git a/runtime/vm/zone.h b/runtime/vm/zone.h index 5919288ccef..d8f12477b3b 100644 --- a/runtime/vm/zone.h +++ b/runtime/vm/zone.h @@ -48,7 +48,7 @@ class Zone { // allocated area. char* MakeCopyOfStringN(const char* str, intptr_t len); - // Concatenate strings |a| and |b|. |a| may be NULL. If |a| is not NULL, + // Concatenate strings |a| and |b|. |a| may be nullptr. If |a| is not nullptr, // |join| will be inserted between |a| and |b|. char* ConcatStrings(const char* a, const char* b, char join = ','); @@ -77,7 +77,7 @@ class Zone { Zone* previous() const { return previous_; } bool ContainsNestedZone(Zone* other) const { - while (other != NULL) { + while (other != nullptr) { if (this == other) return true; other = other->previous_; } @@ -158,7 +158,7 @@ class Zone { // Total size of all segments in [head_]. intptr_t small_segment_capacity_ = 0; - // List of all segments allocated in this zone; may be NULL. + // List of all segments allocated in this zone; may be nullptr. Segment* segments_; // Used for chaining zones in order to allow unwinding of stacks. diff --git a/runtime/vm/zone_test.cc b/runtime/vm/zone_test.cc index 1b1daf2aeaf..9dec6b461b2 100644 --- a/runtime/vm/zone_test.cc +++ b/runtime/vm/zone_test.cc @@ -16,11 +16,11 @@ VM_UNIT_TEST_CASE(AllocateZone) { #endif TestCase::CreateTestIsolate(); Thread* thread = Thread::Current(); - EXPECT(thread->zone() == NULL); + EXPECT(thread->zone() == nullptr); { TransitionNativeToVM transition(thread); StackZone stack_zone(thread); - EXPECT(thread->zone() != NULL); + EXPECT(thread->zone() != nullptr); Zone* zone = stack_zone.GetZone(); uintptr_t allocated_size = 0; @@ -45,29 +45,29 @@ VM_UNIT_TEST_CASE(AllocateZone) { EXPECT_LE(allocated_size, zone->SizeInBytes()); // Test corner cases of kSegmentSize. - uint8_t* buffer = NULL; + uint8_t* buffer = nullptr; buffer = reinterpret_cast(zone->AllocUnsafe(kSegmentSize - kWordSize)); - EXPECT(buffer != NULL); + EXPECT(buffer != nullptr); buffer[(kSegmentSize - kWordSize) - 1] = 0; allocated_size += (kSegmentSize - kWordSize); EXPECT_LE(allocated_size, zone->SizeInBytes()); buffer = reinterpret_cast( zone->AllocUnsafe(kSegmentSize - (2 * kWordSize))); - EXPECT(buffer != NULL); + EXPECT(buffer != nullptr); buffer[(kSegmentSize - (2 * kWordSize)) - 1] = 0; allocated_size += (kSegmentSize - (2 * kWordSize)); EXPECT_LE(allocated_size, zone->SizeInBytes()); buffer = reinterpret_cast(zone->AllocUnsafe(kSegmentSize + kWordSize)); - EXPECT(buffer != NULL); + EXPECT(buffer != nullptr); buffer[(kSegmentSize + kWordSize) - 1] = 0; allocated_size += (kSegmentSize + kWordSize); EXPECT_LE(allocated_size, zone->SizeInBytes()); } - EXPECT(thread->zone() == NULL); + EXPECT(thread->zone() == nullptr); Dart_ShutdownIsolate(); } @@ -77,11 +77,11 @@ VM_UNIT_TEST_CASE(AllocGeneric_Success) { #endif TestCase::CreateTestIsolate(); Thread* thread = Thread::Current(); - EXPECT(thread->zone() == NULL); + EXPECT(thread->zone() == nullptr); { TransitionNativeToVM transition(thread); StackZone zone(thread); - EXPECT(thread->zone() != NULL); + EXPECT(thread->zone() != nullptr); uintptr_t allocated_size = 0; const intptr_t kNumElements = 1000; @@ -89,7 +89,7 @@ VM_UNIT_TEST_CASE(AllocGeneric_Success) { allocated_size += sizeof(uint32_t) * kNumElements; EXPECT_LE(allocated_size, zone.SizeInBytes()); } - EXPECT(thread->zone() == NULL); + EXPECT(thread->zone() == nullptr); Dart_ShutdownIsolate(); } @@ -100,10 +100,10 @@ VM_UNIT_TEST_CASE_WITH_EXPECTATION(AllocGeneric_Overflow, "Crash") { #endif TestCase::CreateTestIsolate(); Thread* thread = Thread::Current(); - EXPECT(thread->zone() == NULL); + EXPECT(thread->zone() == nullptr); { StackZone zone(thread); - EXPECT(thread->zone() != NULL); + EXPECT(thread->zone() != nullptr); const intptr_t kNumElements = (kIntptrMax / sizeof(uint32_t)) + 1; zone.GetZone()->Alloc(kNumElements); @@ -139,7 +139,7 @@ VM_UNIT_TEST_CASE(ZoneAllocated) { #endif TestCase::CreateTestIsolate(); Thread* thread = Thread::Current(); - EXPECT(thread->zone() == NULL); + EXPECT(thread->zone() == nullptr); static int marker; class SimpleZoneObject : public ZoneAllocated { @@ -159,9 +159,9 @@ VM_UNIT_TEST_CASE(ZoneAllocated) { StackZone zone(thread); EXPECT_EQ(0UL, zone.SizeInBytes()); SimpleZoneObject* first = new SimpleZoneObject(); - EXPECT(first != NULL); + EXPECT(first != nullptr); SimpleZoneObject* second = new SimpleZoneObject(); - EXPECT(second != NULL); + EXPECT(second != nullptr); EXPECT(first != second); uintptr_t expected_size = (2 * sizeof(SimpleZoneObject)); EXPECT_LE(expected_size, zone.SizeInBytes()); @@ -176,7 +176,7 @@ VM_UNIT_TEST_CASE(ZoneAllocated) { EXPECT_EQ(42, first->slot); EXPECT_EQ(87, second->slot); } - EXPECT(thread->zone() == NULL); + EXPECT(thread->zone() == nullptr); Dart_ShutdownIsolate(); }