Use nullptr instead of NULL where possible

New code should use nullptr instead of NULL.

This patch updates existing use of NULL to nullptr where applicable,
making the code base more consistent.

BUG=v8:6928,v8:6921

Cq-Include-Trybots: master.tryserver.chromium.linux:linux_chromium_rel_ng;master.tryserver.v8:v8_linux_noi18n_rel_ng
Change-Id: I4687f5b96fcfd88b41fa970a2b937b4f6538777c
Reviewed-on: https://chromium-review.googlesource.com/718338
Commit-Queue: Mathias Bynens <mathias@chromium.org>
Reviewed-by: Andreas Haas <ahaas@chromium.org>
Reviewed-by: Benedikt Meurer <bmeurer@chromium.org>
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Reviewed-by: Toon Verwaest <verwaest@chromium.org>
Reviewed-by: Jakob Gruber <jgruber@chromium.org>
Reviewed-by: Yang Guo <yangguo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#48557}
This commit is contained in:
Mathias Bynens 2017-10-13 18:33:03 +02:00 committed by Commit Bot
parent 61292f0b60
commit 62f929ff4c
370 changed files with 5237 additions and 5822 deletions

View File

@ -12,7 +12,7 @@ namespace internal {
RootIndexMap::RootIndexMap(Isolate* isolate) {
map_ = isolate->root_index_map();
if (map_ != NULL) return;
if (map_ != nullptr) return;
map_ = new HeapObjectToIndexHashMap();
for (uint32_t i = 0; i < Heap::kStrongRootListLength; i++) {
Heap::RootListIndex root_index = static_cast<Heap::RootListIndex>(i);

View File

@ -241,7 +241,7 @@ void* GetRandomMmapAddr() {
#if defined(ADDRESS_SANITIZER) || defined(MEMORY_SANITIZER) || \
defined(THREAD_SANITIZER)
// Dynamic tools do not support custom mmap addresses.
return NULL;
return nullptr;
#endif
uintptr_t raw_addr;
random_number_generator.Pointer()->NextBytes(&raw_addr, sizeof(raw_addr));

View File

@ -390,7 +390,7 @@ void i::V8::FatalProcessOutOfMemory(const char* location, bool is_heap_oom) {
// HeapIterator here without doing a special GC.
isolate->heap()->RecordStats(&heap_stats, false);
char* first_newline = strchr(last_few_messages, '\n');
if (first_newline == NULL || first_newline[1] == '\0')
if (first_newline == nullptr || first_newline[1] == '\0')
first_newline = last_few_messages;
PrintF("\n<--- Last few GCs --->\n%s\n", first_newline);
PrintF("\n<--- JS stacktrace --->\n%s\n", js_stacktrace);
@ -483,7 +483,7 @@ class ArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
public:
virtual void* Allocate(size_t length) {
void* data = AllocateUninitialized(length);
return data == NULL ? data : memset(data, 0, length);
return data == nullptr ? data : memset(data, 0, length);
}
virtual void* AllocateUninitialized(size_t length) { return malloc(length); }
virtual void Free(void* data, size_t) { free(data); }
@ -778,7 +778,7 @@ StartupData V8::CreateSnapshotDataBlob(const char* embedded_source) {
{
HandleScope scope(isolate);
Local<Context> context = Context::New(isolate);
if (embedded_source != NULL &&
if (embedded_source != nullptr &&
!RunExtraCode(isolate, context, embedded_source, "<embedded>")) {
return result;
}
@ -798,8 +798,8 @@ StartupData V8::CreateSnapshotDataBlob(const char* embedded_source) {
StartupData V8::WarmUpSnapshotDataBlob(StartupData cold_snapshot_blob,
const char* warmup_source) {
CHECK(cold_snapshot_blob.raw_size > 0 && cold_snapshot_blob.data != NULL);
CHECK(warmup_source != NULL);
CHECK(cold_snapshot_blob.raw_size > 0 && cold_snapshot_blob.data != nullptr);
CHECK(warmup_source != nullptr);
// Use following steps to create a warmed up snapshot blob from a cold one:
// - Create a new isolate from the cold snapshot.
// - Create a new context to run the warmup script. This will trigger
@ -851,9 +851,7 @@ void V8::SetFlagsFromCommandLine(int* argc, char** argv, bool remove_flags) {
i::FlagList::SetFlagsFromCommandLine(argc, argv, remove_flags);
}
RegisteredExtension* RegisteredExtension::first_extension_ = NULL;
RegisteredExtension* RegisteredExtension::first_extension_ = nullptr;
RegisteredExtension::RegisteredExtension(Extension* extension)
: extension_(extension) { }
@ -867,12 +865,12 @@ void RegisteredExtension::Register(RegisteredExtension* that) {
void RegisteredExtension::UnregisterAll() {
RegisteredExtension* re = first_extension_;
while (re != NULL) {
while (re != nullptr) {
RegisteredExtension* next = re->next();
delete re;
re = next;
}
first_extension_ = NULL;
first_extension_ = nullptr;
}
@ -895,13 +893,13 @@ Extension::Extension(const char* name,
dep_count_(dep_count),
deps_(deps),
auto_enable_(false) {
CHECK(source != NULL || source_length_ == 0);
CHECK(source != nullptr || source_length_ == 0);
}
ResourceConstraints::ResourceConstraints()
: max_semi_space_size_in_kb_(0),
max_old_space_size_(0),
stack_limit_(NULL),
stack_limit_(nullptr),
code_range_size_(0),
max_zone_pool_size_(0) {}
@ -934,7 +932,7 @@ void SetResourceConstraints(i::Isolate* isolate,
}
isolate->allocator()->ConfigureSegmentPool(max_pool_size);
if (constraints.stack_limit() != NULL) {
if (constraints.stack_limit() != nullptr) {
uintptr_t limit = reinterpret_cast<uintptr_t>(constraints.stack_limit());
isolate->stack_guard()->SetStackLimit(limit);
}
@ -1097,9 +1095,9 @@ i::Object** EscapableHandleScope::Escape(i::Object** escape_value) {
i::Heap* heap = reinterpret_cast<i::Isolate*>(GetIsolate())->heap();
Utils::ApiCheck((*escape_slot_)->IsTheHole(heap->isolate()),
"EscapableHandleScope::Escape", "Escape value set twice");
if (escape_value == NULL) {
if (escape_value == nullptr) {
*escape_slot_ = heap->undefined_value();
return NULL;
return nullptr;
}
*escape_slot_ = *escape_value;
return escape_slot_;
@ -1237,7 +1235,7 @@ void Context::SetEmbedderData(int index, v8::Local<Value> value) {
void* Context::SlowGetAlignedPointerFromEmbedderData(int index) {
const char* location = "v8::Context::GetAlignedPointerFromEmbedderData()";
i::Handle<i::FixedArray> data = EmbedderDataFor(this, index, false, location);
if (data.is_null()) return NULL;
if (data.is_null()) return nullptr;
return DecodeSmiToAligned(data->get(index), location);
}
@ -2292,7 +2290,7 @@ MaybeLocal<UnboundScript> ScriptCompiler::CompileUnboundInternal(
options = kNoCompileOptions;
}
i::ScriptData* script_data = NULL;
i::ScriptData* script_data = nullptr;
if (options == kConsumeParserCache || options == kConsumeCodeCache) {
DCHECK(source->cached_data);
// ScriptData takes care of pointer-aligning the data.
@ -2330,19 +2328,19 @@ MaybeLocal<UnboundScript> ScriptCompiler::CompileUnboundInternal(
i::MaybeHandle<i::SharedFunctionInfo> maybe_function_info =
i::Compiler::GetSharedFunctionInfoForScript(
str, name_obj, line_offset, column_offset, source->resource_options,
source_map_url, isolate->native_context(), NULL, &script_data,
source_map_url, isolate->native_context(), nullptr, &script_data,
options, i::NOT_NATIVES_CODE, host_defined_options);
has_pending_exception = !maybe_function_info.ToHandle(&result);
if (has_pending_exception && script_data != NULL) {
if (has_pending_exception && script_data != nullptr) {
// This case won't happen during normal operation; we have compiled
// successfully and produced cached data, and but the second compilation
// of the same source code fails.
delete script_data;
script_data = NULL;
script_data = nullptr;
}
RETURN_ON_FAILED_EXECUTION(UnboundScript);
if (produce_cache && script_data != NULL) {
if (produce_cache && script_data != nullptr) {
// script_data now contains the data that was generated. source will
// take the ownership.
source->cached_data = new CachedData(
@ -2424,7 +2422,7 @@ class IsIdentifierHelper {
bool Check(i::String* string) {
i::ConsString* cons_string = i::String::VisitFlat(this, string, 0);
if (cons_string == NULL) return is_identifier_;
if (cons_string == nullptr) return is_identifier_;
// We don't support cons strings here.
return false;
}
@ -3906,7 +3904,7 @@ Local<Uint32> Value::ToUint32(Isolate* isolate) const {
void i::Internals::CheckInitializedImpl(v8::Isolate* external_isolate) {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(external_isolate);
Utils::ApiCheck(isolate != NULL && !isolate->IsDead(),
Utils::ApiCheck(isolate != nullptr && !isolate->IsDead(),
"v8::internal::Internals::CheckInitialized",
"Isolate is not initialized or V8 has died");
}
@ -4086,21 +4084,20 @@ void v8::SharedArrayBuffer::CheckCast(Value* that) {
void v8::Date::CheckCast(v8::Value* that) {
i::Handle<i::Object> obj = Utils::OpenHandle(that);
i::Isolate* isolate = NULL;
i::Isolate* isolate = nullptr;
if (obj->IsHeapObject()) isolate = i::HeapObject::cast(*obj)->GetIsolate();
Utils::ApiCheck(isolate != NULL &&
obj->HasSpecificClassOf(isolate->heap()->Date_string()),
"v8::Date::Cast()",
"Could not convert to date");
Utils::ApiCheck(isolate != nullptr &&
obj->HasSpecificClassOf(isolate->heap()->Date_string()),
"v8::Date::Cast()", "Could not convert to date");
}
void v8::StringObject::CheckCast(v8::Value* that) {
i::Handle<i::Object> obj = Utils::OpenHandle(that);
i::Isolate* isolate = NULL;
i::Isolate* isolate = nullptr;
if (obj->IsHeapObject()) isolate = i::HeapObject::cast(*obj)->GetIsolate();
Utils::ApiCheck(isolate != NULL &&
obj->HasSpecificClassOf(isolate->heap()->String_string()),
Utils::ApiCheck(isolate != nullptr &&
obj->HasSpecificClassOf(isolate->heap()->String_string()),
"v8::StringObject::Cast()",
"Could not convert to StringObject");
}
@ -4108,10 +4105,10 @@ void v8::StringObject::CheckCast(v8::Value* that) {
void v8::SymbolObject::CheckCast(v8::Value* that) {
i::Handle<i::Object> obj = Utils::OpenHandle(that);
i::Isolate* isolate = NULL;
i::Isolate* isolate = nullptr;
if (obj->IsHeapObject()) isolate = i::HeapObject::cast(*obj)->GetIsolate();
Utils::ApiCheck(isolate != NULL &&
obj->HasSpecificClassOf(isolate->heap()->Symbol_string()),
Utils::ApiCheck(isolate != nullptr &&
obj->HasSpecificClassOf(isolate->heap()->Symbol_string()),
"v8::SymbolObject::Cast()",
"Could not convert to SymbolObject");
}
@ -4119,10 +4116,10 @@ void v8::SymbolObject::CheckCast(v8::Value* that) {
void v8::NumberObject::CheckCast(v8::Value* that) {
i::Handle<i::Object> obj = Utils::OpenHandle(that);
i::Isolate* isolate = NULL;
i::Isolate* isolate = nullptr;
if (obj->IsHeapObject()) isolate = i::HeapObject::cast(*obj)->GetIsolate();
Utils::ApiCheck(isolate != NULL &&
obj->HasSpecificClassOf(isolate->heap()->Number_string()),
Utils::ApiCheck(isolate != nullptr &&
obj->HasSpecificClassOf(isolate->heap()->Number_string()),
"v8::NumberObject::Cast()",
"Could not convert to NumberObject");
}
@ -4130,12 +4127,12 @@ void v8::NumberObject::CheckCast(v8::Value* that) {
void v8::BooleanObject::CheckCast(v8::Value* that) {
i::Handle<i::Object> obj = Utils::OpenHandle(that);
i::Isolate* isolate = NULL;
i::Isolate* isolate = nullptr;
if (obj->IsHeapObject()) isolate = i::HeapObject::cast(*obj)->GetIsolate();
Utils::ApiCheck(isolate != NULL &&
obj->HasSpecificClassOf(isolate->heap()->Boolean_string()),
"v8::BooleanObject::Cast()",
"Could not convert to BooleanObject");
Utils::ApiCheck(
isolate != nullptr &&
obj->HasSpecificClassOf(isolate->heap()->Boolean_string()),
"v8::BooleanObject::Cast()", "Could not convert to BooleanObject");
}
@ -5389,7 +5386,7 @@ Local<Function> Function::New(Isolate* v8_isolate, FunctionCallback callback,
Local<v8::Object> Function::NewInstance() const {
return NewInstance(Isolate::GetCurrent()->GetCurrentContext(), 0, NULL)
return NewInstance(Isolate::GetCurrent()->GetCurrentContext(), 0, nullptr)
.FromMaybe(Local<Object>());
}
@ -5640,7 +5637,7 @@ class ContainsOnlyOneByteHelper {
ContainsOnlyOneByteHelper() : is_one_byte_(true) {}
bool Check(i::String* string) {
i::ConsString* cons_string = i::String::VisitFlat(this, string, 0);
if (cons_string == NULL) return is_one_byte_;
if (cons_string == nullptr) return is_one_byte_;
return CheckCons(cons_string);
}
void VisitOneByteString(const uint8_t* chars, int length) {
@ -5692,7 +5689,7 @@ class ContainsOnlyOneByteHelper {
i::String::VisitFlat(this, right, 0);
if (!is_one_byte_) return false;
// Standard recurse/iterate trick.
if (left_as_cons != NULL && right_as_cons != NULL) {
if (left_as_cons != nullptr && right_as_cons != nullptr) {
if (left->length() < right->length()) {
CheckCons(left_as_cons);
cons_string = right_as_cons;
@ -5705,12 +5702,12 @@ class ContainsOnlyOneByteHelper {
continue;
}
// Descend left in place.
if (left_as_cons != NULL) {
if (left_as_cons != nullptr) {
cons_string = left_as_cons;
continue;
}
// Descend right in place.
if (right_as_cons != NULL) {
if (right_as_cons != nullptr) {
cons_string = right_as_cons;
continue;
}
@ -5864,16 +5861,16 @@ class Utf8LengthHelper : public i::AllStatic {
int leaf_length;
ConsString* left_as_cons =
Visitor::VisitFlat(left, &leaf_length, &left_leaf_state);
if (left_as_cons == NULL) {
if (left_as_cons == nullptr) {
total_length += leaf_length;
MergeLeafLeft(&total_length, &state, left_leaf_state);
}
ConsString* right_as_cons =
Visitor::VisitFlat(right, &leaf_length, &right_leaf_state);
if (right_as_cons == NULL) {
if (right_as_cons == nullptr) {
total_length += leaf_length;
MergeLeafRight(&total_length, &state, right_leaf_state);
if (left_as_cons != NULL) {
if (left_as_cons != nullptr) {
// 1 Leaf node. Descend in place.
current = left_as_cons;
continue;
@ -5882,7 +5879,7 @@ class Utf8LengthHelper : public i::AllStatic {
MergeTerminal(&total_length, state, state_out);
return total_length;
}
} else if (left_as_cons == NULL) {
} else if (left_as_cons == nullptr) {
// 1 Leaf node. Descend in place.
current = right_as_cons;
continue;
@ -5918,7 +5915,7 @@ static int Utf8Length(i::String* str, i::Isolate* isolate) {
uint8_t state;
i::ConsString* cons_string =
Utf8LengthHelper::Visitor::VisitFlat(str, &length, &state);
if (cons_string == NULL) return length;
if (cons_string == nullptr) return length;
return Utf8LengthHelper::Calculate(cons_string);
}
@ -6085,7 +6082,7 @@ class Utf8WriterVisitor {
int CompleteWrite(bool write_null, int* utf16_chars_read_out) {
// Write out number of utf16 characters written to the stream.
if (utf16_chars_read_out != NULL) {
if (utf16_chars_read_out != nullptr) {
*utf16_chars_read_out = utf16_chars_read_;
}
// Only null terminate if all of the string was written and there's space.
@ -6115,7 +6112,7 @@ static bool RecursivelySerializeToUtf8(i::String* current,
int recursion_budget) {
while (!writer->IsDone()) {
i::ConsString* cons_string = i::String::VisitFlat(writer, current);
if (cons_string == NULL) return true; // Leaf node.
if (cons_string == nullptr) return true; // Leaf node.
if (recursion_budget <= 0) return false;
// Must write the left branch first.
i::String* first = cons_string->first();
@ -6158,7 +6155,7 @@ int String::WriteUtf8(char* buffer,
// one-byte fast path.
if (utf8_bytes == string_length) {
WriteOneByte(reinterpret_cast<uint8_t*>(buffer), 0, capacity, options);
if (nchars_ref != NULL) *nchars_ref = string_length;
if (nchars_ref != nullptr) *nchars_ref = string_length;
if (write_null && (utf8_bytes+1 <= capacity)) {
return string_length + 1;
}
@ -6247,7 +6244,7 @@ void v8::String::VerifyExternalStringResource(
i::Handle<i::ExternalTwoByteString>::cast(str)->resource();
expected = reinterpret_cast<const ExternalStringResource*>(resource);
} else {
expected = NULL;
expected = nullptr;
}
CHECK_EQ(expected, value);
}
@ -6268,7 +6265,7 @@ void v8::String::VerifyExternalStringResourceBase(
expected = reinterpret_cast<const ExternalStringResourceBase*>(resource);
expectedEncoding = TWO_BYTE_ENCODING;
} else {
expected = NULL;
expected = nullptr;
expectedEncoding =
str->IsOneByteRepresentation() ? ONE_BYTE_ENCODING : TWO_BYTE_ENCODING;
}
@ -6284,7 +6281,7 @@ v8::String::GetExternalOneByteStringResource() const {
i::Handle<i::ExternalOneByteString>::cast(str)->resource();
return reinterpret_cast<const ExternalOneByteStringResource*>(resource);
} else {
return NULL;
return nullptr;
}
}
@ -6377,7 +6374,7 @@ void v8::Object::SetInternalField(int index, v8::Local<Value> value) {
void* v8::Object::SlowGetAlignedPointerFromInternalField(int index) {
i::Handle<i::JSReceiver> obj = Utils::OpenHandle(this);
const char* location = "v8::Object::GetAlignedPointerFromInternalField()";
if (!InternalFieldOK(obj, index, location)) return NULL;
if (!InternalFieldOK(obj, index, location)) return nullptr;
return DecodeSmiToAligned(
i::Handle<i::JSObject>::cast(obj)->GetEmbedderField(index), location);
}
@ -6414,7 +6411,7 @@ static void* ExternalValue(i::Object* obj) {
// Obscure semantics for undefined, but somehow checked in our unit tests...
if (!obj->IsSmi() &&
obj->IsUndefined(i::HeapObject::cast(obj)->GetIsolate())) {
return NULL;
return nullptr;
}
i::Object* foreign = i::JSObject::cast(obj)->GetEmbedderField(0);
return i::Foreign::cast(foreign)->foreign_address();
@ -6669,7 +6666,7 @@ Local<Context> NewContext(
LOG_API(isolate, Context, New);
i::HandleScope scope(isolate);
ExtensionConfiguration no_extensions;
if (extensions == NULL) extensions = &no_extensions;
if (extensions == nullptr) extensions = &no_extensions;
i::Handle<i::Context> env = CreateEnvironment<i::Context>(
isolate, extensions, global_template, global_object,
context_snapshot_index, embedder_fields_deserializer);
@ -7649,7 +7646,7 @@ MaybeLocal<Promise::Resolver> Promise::Resolver::New(Local<Context> context) {
i::Handle<i::Object> result;
has_pending_exception =
!i::Execution::Call(isolate, isolate->promise_internal_constructor(),
isolate->factory()->undefined_value(), 0, NULL)
isolate->factory()->undefined_value(), 0, nullptr)
.ToHandle(&result);
RETURN_ON_FAILED_EXECUTION(Promise::Resolver);
RETURN_ESCAPED(Local<Promise::Resolver>::Cast(Utils::ToLocal(result)));
@ -8107,7 +8104,7 @@ Local<ArrayBuffer> v8::ArrayBuffer::New(Isolate* isolate, void* data,
size_t byte_length,
ArrayBufferCreationMode mode) {
// Embedders must guarantee that the external backing store is valid.
CHECK(byte_length == 0 || data != NULL);
CHECK(byte_length == 0 || data != nullptr);
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
LOG_API(i_isolate, ArrayBuffer, New);
ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate);
@ -8312,7 +8309,7 @@ Local<SharedArrayBuffer> v8::SharedArrayBuffer::New(
ArrayBufferCreationMode mode) {
CHECK(i::FLAG_harmony_sharedarraybuffer);
// Embedders must guarantee that the external backing store is valid.
CHECK(byte_length == 0 || data != NULL);
CHECK(byte_length == 0 || data != nullptr);
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
LOG_API(i_isolate, SharedArrayBuffer, New);
ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate);
@ -8457,16 +8454,16 @@ CpuProfiler* Isolate::GetCpuProfiler() {
bool Isolate::InContext() {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
return isolate->context() != NULL;
return isolate->context() != nullptr;
}
v8::Local<v8::Context> Isolate::GetCurrentContext() {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
i::Context* context = isolate->context();
if (context == NULL) return Local<Context>();
if (context == nullptr) return Local<Context>();
i::Context* native_context = context->native_context();
if (native_context == NULL) return Local<Context>();
if (native_context == nullptr) return Local<Context>();
return Utils::ToLocal(i::Handle<i::Context>(native_context));
}
@ -8651,9 +8648,9 @@ Isolate* Isolate::New(const Isolate::CreateParams& params) {
Isolate* IsolateNewImpl(internal::Isolate* isolate,
const v8::Isolate::CreateParams& params) {
Isolate* v8_isolate = reinterpret_cast<Isolate*>(isolate);
CHECK(params.array_buffer_allocator != NULL);
CHECK(params.array_buffer_allocator != nullptr);
isolate->set_array_buffer_allocator(params.array_buffer_allocator);
if (params.snapshot_blob != NULL) {
if (params.snapshot_blob != nullptr) {
isolate->set_snapshot_blob(params.snapshot_blob);
} else {
isolate->set_snapshot_blob(i::Snapshot::DefaultSnapshotBlob());
@ -8700,7 +8697,7 @@ Isolate* IsolateNewImpl(internal::Isolate* isolate,
if (params.entry_hook || !i::Snapshot::Initialize(isolate)) {
base::ElapsedTimer timer;
if (i::FLAG_profile_deserialization) timer.Start();
isolate->Init(NULL);
isolate->Init(nullptr);
if (i::FLAG_profile_deserialization) {
double ms = timer.Elapsed().InMillisecondsF();
i::PrintF("[Initializing isolate from scratch took %0.3f ms]\n", ms);
@ -8933,7 +8930,7 @@ void Isolate::SetEventLogger(LogEventCallback that) {
void Isolate::AddBeforeCallEnteredCallback(BeforeCallEnteredCallback callback) {
if (callback == NULL) return;
if (callback == nullptr) return;
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
isolate->AddBeforeCallEnteredCallback(callback);
}
@ -8947,7 +8944,7 @@ void Isolate::RemoveBeforeCallEnteredCallback(
void Isolate::AddCallCompletedCallback(CallCompletedCallback callback) {
if (callback == NULL) return;
if (callback == nullptr) return;
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
isolate->AddCallCompletedCallback(callback);
}
@ -8977,7 +8974,7 @@ void Isolate::SetPromiseHook(PromiseHook hook) {
}
void Isolate::SetPromiseRejectCallback(PromiseRejectCallback callback) {
if (callback == NULL) return;
if (callback == nullptr) return;
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
isolate->SetPromiseRejectCallback(callback);
}
@ -9180,7 +9177,7 @@ void Isolate::GetCodeRange(void** start, size_t* length_in_bytes) {
*length_in_bytes =
isolate->heap()->memory_allocator()->code_range()->size();
} else {
*start = NULL;
*start = nullptr;
*length_in_bytes = 0;
}
}
@ -9361,7 +9358,7 @@ bool MicrotasksScope::IsRunningMicrotasks(Isolate* v8Isolate) {
}
String::Utf8Value::Utf8Value(v8::Isolate* isolate, v8::Local<v8::Value> obj)
: str_(NULL), length_(0) {
: str_(nullptr), length_(0) {
if (obj.IsEmpty()) return;
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
ENTER_V8_DO_NOT_USE(i_isolate);
@ -9384,7 +9381,7 @@ String::Utf8Value::~Utf8Value() {
}
String::Value::Value(v8::Isolate* isolate, v8::Local<v8::Value> obj)
: str_(NULL), length_(0) {
: str_(nullptr), length_(0) {
if (obj.IsEmpty()) return;
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
ENTER_V8_DO_NOT_USE(i_isolate);
@ -9437,7 +9434,7 @@ Local<Message> Exception::CreateMessage(Isolate* isolate,
ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate);
i::HandleScope scope(i_isolate);
return Utils::MessageToLocal(
scope.CloseAndEscape(i_isolate->CreateMessage(obj, NULL)));
scope.CloseAndEscape(i_isolate->CreateMessage(obj, nullptr)));
}
@ -9968,7 +9965,7 @@ MaybeLocal<UnboundScript> debug::CompileInspectorScript(Isolate* v8_isolate,
Local<String> source) {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
PREPARE_FOR_DEBUG_INTERFACE_EXECUTION_WITH_ISOLATE(isolate, UnboundScript);
i::ScriptData* script_data = NULL;
i::ScriptData* script_data = nullptr;
i::Handle<i::String> str = Utils::OpenHandle(*source);
i::Handle<i::SharedFunctionInfo> result;
{
@ -9976,7 +9973,7 @@ MaybeLocal<UnboundScript> debug::CompileInspectorScript(Isolate* v8_isolate,
i::MaybeHandle<i::SharedFunctionInfo> maybe_function_info =
i::Compiler::GetSharedFunctionInfoForScript(
str, i::MaybeHandle<i::Object>(), 0, 0, origin_options,
i::MaybeHandle<i::Object>(), isolate->native_context(), NULL,
i::MaybeHandle<i::Object>(), isolate->native_context(), nullptr,
&script_data, ScriptCompiler::kNoCompileOptions,
i::FLAG_expose_inspector_scripts ? i::NOT_NATIVES_CODE
: i::INSPECTOR_CODE,
@ -10470,7 +10467,7 @@ void CpuProfiler::SetIdle(bool is_idle) {
if (!isolate->is_profiling()) return;
v8::StateTag state = isolate->current_vm_state();
DCHECK(state == v8::EXTERNAL || state == v8::IDLE);
if (isolate->js_entry_sp() != NULL) return;
if (isolate->js_entry_sp() != nullptr) return;
if (is_idle) {
isolate->set_current_vm_state(v8::IDLE);
} else if (state == v8::IDLE) {
@ -10817,7 +10814,7 @@ void HandleScopeImplementer::IterateThis(RootVisitor* v) {
// Iterate over all handles in the blocks except for the last.
for (int i = static_cast<int>(blocks()->size()) - 2; i >= 0; --i) {
Object** block = blocks()->at(i);
if (last_handle_before_deferred_block_ != NULL &&
if (last_handle_before_deferred_block_ != nullptr &&
(last_handle_before_deferred_block_ <= &block[kHandleBlockSize]) &&
(last_handle_before_deferred_block_ >= block)) {
v->VisitRootPointers(Root::kHandleScope, block,
@ -10831,7 +10828,7 @@ void HandleScopeImplementer::IterateThis(RootVisitor* v) {
}
}
DCHECK(last_handle_before_deferred_block_ == NULL ||
DCHECK(last_handle_before_deferred_block_ == nullptr ||
found_block_before_deferred);
// Iterate over live handles in the last block (if any).
@ -10887,17 +10884,17 @@ DeferredHandles* HandleScopeImplementer::Detach(Object** prev_limit) {
// HandleScope stack since BeginDeferredScope was called, but in
// reverse order.
DCHECK(prev_limit == NULL || !blocks_.empty());
DCHECK(prev_limit == nullptr || !blocks_.empty());
DCHECK(!blocks_.empty() && prev_limit != NULL);
DCHECK(last_handle_before_deferred_block_ != NULL);
last_handle_before_deferred_block_ = NULL;
DCHECK(!blocks_.empty() && prev_limit != nullptr);
DCHECK(last_handle_before_deferred_block_ != nullptr);
last_handle_before_deferred_block_ = nullptr;
return deferred;
}
void HandleScopeImplementer::BeginDeferredScope() {
DCHECK(last_handle_before_deferred_block_ == NULL);
DCHECK(last_handle_before_deferred_block_ == nullptr);
last_handle_before_deferred_block_ = isolate()->handle_scope_data()->next;
}

View File

@ -347,8 +347,8 @@ MAKE_TO_LOCAL(ScriptOrModuleToLocal, Script, ScriptOrModule)
#define MAKE_OPEN_HANDLE(From, To) \
v8::internal::Handle<v8::internal::To> Utils::OpenHandle( \
const v8::From* that, bool allow_empty_handle) { \
DCHECK(allow_empty_handle || that != NULL); \
DCHECK(that == NULL || \
DCHECK(allow_empty_handle || that != nullptr); \
DCHECK(that == nullptr || \
(*reinterpret_cast<v8::internal::Object* const*>(that))->Is##To()); \
return v8::internal::Handle<v8::internal::To>( \
reinterpret_cast<v8::internal::To**>(const_cast<v8::From*>(that))); \
@ -370,8 +370,8 @@ class V8_EXPORT_PRIVATE DeferredHandles {
private:
DeferredHandles(Object** first_block_limit, Isolate* isolate)
: next_(NULL),
previous_(NULL),
: next_(nullptr),
previous_(nullptr),
first_block_limit_(first_block_limit),
isolate_(isolate) {
isolate->LinkDeferredHandles(this);
@ -404,7 +404,7 @@ class HandleScopeImplementer {
explicit HandleScopeImplementer(Isolate* isolate)
: isolate_(isolate),
microtask_context_(nullptr),
spare_(NULL),
spare_(nullptr),
call_depth_(0),
microtasks_depth_(0),
microtasks_suppressions_(0),
@ -413,7 +413,7 @@ class HandleScopeImplementer {
debug_microtasks_depth_(0),
#endif
microtasks_policy_(v8::MicrotasksPolicy::kAuto),
last_handle_before_deferred_block_(NULL) {
last_handle_before_deferred_block_(nullptr) {
}
~HandleScopeImplementer() {
@ -487,8 +487,8 @@ class HandleScopeImplementer {
Isolate* isolate() const { return isolate_; }
void ReturnBlock(Object** block) {
DCHECK(block != NULL);
if (spare_ != NULL) DeleteArray(spare_);
DCHECK_NOT_NULL(block);
if (spare_ != nullptr) DeleteArray(spare_);
spare_ = block;
}
@ -499,8 +499,8 @@ class HandleScopeImplementer {
saved_contexts_.detach();
microtask_context_ = nullptr;
entered_context_count_during_microtasks_ = 0;
spare_ = NULL;
last_handle_before_deferred_block_ = NULL;
spare_ = nullptr;
last_handle_before_deferred_block_ = nullptr;
call_depth_ = 0;
}
@ -513,9 +513,9 @@ class HandleScopeImplementer {
blocks_.free();
entered_contexts_.free();
saved_contexts_.free();
if (spare_ != NULL) {
if (spare_ != nullptr) {
DeleteArray(spare_);
spare_ = NULL;
spare_ = nullptr;
}
DCHECK(call_depth_ == 0);
}
@ -620,10 +620,10 @@ Handle<Context> HandleScopeImplementer::MicrotaskContext() {
// If there's a spare block, use it for growing the current scope.
internal::Object** HandleScopeImplementer::GetSpareOrNewBlock() {
internal::Object** block = (spare_ != NULL) ?
spare_ :
NewArray<internal::Object*>(kHandleBlockSize);
spare_ = NULL;
internal::Object** block =
(spare_ != nullptr) ? spare_
: NewArray<internal::Object*>(kHandleBlockSize);
spare_ = nullptr;
return block;
}
@ -645,13 +645,13 @@ void HandleScopeImplementer::DeleteExtensions(internal::Object** prev_limit) {
#ifdef ENABLE_HANDLE_ZAPPING
internal::HandleScope::ZapRange(block_start, block_limit);
#endif
if (spare_ != NULL) {
if (spare_ != nullptr) {
DeleteArray(spare_);
}
spare_ = block_start;
}
DCHECK((blocks_.empty() && prev_limit == NULL) ||
(!blocks_.empty() && prev_limit != NULL));
DCHECK((blocks_.empty() && prev_limit == nullptr) ||
(!blocks_.empty() && prev_limit != nullptr));
}
// Interceptor functions called from generated inline caches to notify

View File

@ -113,7 +113,7 @@ void RelocInfo::set_target_object(HeapObject* target,
Assembler::set_target_address_at(target->GetIsolate(), pc_, host_,
reinterpret_cast<Address>(target),
icache_flush_mode);
if (write_barrier_mode == UPDATE_WRITE_BARRIER && host() != NULL) {
if (write_barrier_mode == UPDATE_WRITE_BARRIER && host() != nullptr) {
host()->GetHeap()->incremental_marking()->RecordWriteIntoCode(host(), this,
target);
host()->GetHeap()->RecordWriteIntoCode(host(), this, target);
@ -157,9 +157,9 @@ void RelocInfo::WipeOut(Isolate* isolate) {
IsRuntimeEntry(rmode_) || IsExternalReference(rmode_) ||
IsInternalReference(rmode_));
if (IsInternalReference(rmode_)) {
Memory::Address_at(pc_) = NULL;
Memory::Address_at(pc_) = nullptr;
} else {
Assembler::set_target_address_at(isolate, pc_, host_, NULL);
Assembler::set_target_address_at(isolate, pc_, host_, nullptr);
}
}
@ -384,14 +384,14 @@ void Assembler::set_target_address_at(Isolate* isolate, Address pc,
}
Address Assembler::target_address_at(Address pc, Code* code) {
Address constant_pool = code ? code->constant_pool() : NULL;
Address constant_pool = code ? code->constant_pool() : nullptr;
return target_address_at(pc, constant_pool);
}
void Assembler::set_target_address_at(Isolate* isolate, Address pc, Code* code,
Address target,
ICacheFlushMode icache_flush_mode) {
Address constant_pool = code ? code->constant_pool() : NULL;
Address constant_pool = code ? code->constant_pool() : nullptr;
set_target_address_at(isolate, pc, constant_pool, target, icache_flush_mode);
}

View File

@ -250,12 +250,12 @@ void CpuFeatures::ProbeImpl(bool cross_compile) {
void CpuFeatures::PrintTarget() {
const char* arm_arch = NULL;
const char* arm_arch = nullptr;
const char* arm_target_type = "";
const char* arm_no_probe = "";
const char* arm_fpu = "";
const char* arm_thumb = "";
const char* arm_float_abi = NULL;
const char* arm_float_abi = nullptr;
#if !defined __arm__
arm_target_type = " simulator";
@ -1043,9 +1043,9 @@ bool FitsShifter(uint32_t imm32, uint32_t* rotate_imm, uint32_t* immed_8,
}
// If the opcode is one with a complementary version and the complementary
// immediate fits, change the opcode.
if (instr != NULL) {
if (instr != nullptr) {
if ((*instr & kMovMvnMask) == kMovMvnPattern) {
if (FitsShifter(~imm32, rotate_imm, immed_8, NULL)) {
if (FitsShifter(~imm32, rotate_imm, immed_8, nullptr)) {
*instr ^= kMovMvnFlip;
return true;
} else if ((*instr & kMovLeaveCCMask) == kMovLeaveCCPattern) {
@ -1059,7 +1059,7 @@ bool FitsShifter(uint32_t imm32, uint32_t* rotate_imm, uint32_t* immed_8,
}
}
} else if ((*instr & kCmpCmnMask) == kCmpCmnPattern) {
if (FitsShifter(-static_cast<int>(imm32), rotate_imm, immed_8, NULL)) {
if (FitsShifter(-static_cast<int>(imm32), rotate_imm, immed_8, nullptr)) {
*instr ^= kCmpCmnFlip;
return true;
}
@ -1067,13 +1067,14 @@ bool FitsShifter(uint32_t imm32, uint32_t* rotate_imm, uint32_t* immed_8,
Instr alu_insn = (*instr & kALUMask);
if (alu_insn == ADD ||
alu_insn == SUB) {
if (FitsShifter(-static_cast<int>(imm32), rotate_imm, immed_8, NULL)) {
if (FitsShifter(-static_cast<int>(imm32), rotate_imm, immed_8,
nullptr)) {
*instr ^= kAddSubFlip;
return true;
}
} else if (alu_insn == AND ||
alu_insn == BIC) {
if (FitsShifter(~imm32, rotate_imm, immed_8, NULL)) {
if (FitsShifter(~imm32, rotate_imm, immed_8, nullptr)) {
*instr ^= kAndBicFlip;
return true;
}
@ -1089,7 +1090,7 @@ bool FitsShifter(uint32_t imm32, uint32_t* rotate_imm, uint32_t* immed_8,
// encoded.
bool MustOutputRelocInfo(RelocInfo::Mode rmode, const Assembler* assembler) {
if (rmode == RelocInfo::EXTERNAL_REFERENCE) {
if (assembler != NULL && assembler->predictable_code_size()) return true;
if (assembler != nullptr && assembler->predictable_code_size()) return true;
return assembler->serializer_enabled();
} else if (RelocInfo::IsNone(rmode)) {
return false;
@ -2069,7 +2070,7 @@ void Assembler::msr(SRegisterFieldMask fields, const Operand& src,
uint32_t rotate_imm;
uint32_t immed_8;
if (src.MustOutputRelocInfo(this) ||
!FitsShifter(src.immediate(), &rotate_imm, &immed_8, NULL)) {
!FitsShifter(src.immediate(), &rotate_imm, &immed_8, nullptr)) {
UseScratchRegisterScope temps(this);
Register scratch = temps.Acquire();
// Immediate operand cannot be encoded, load it first to a scratch
@ -4960,7 +4961,7 @@ int Assembler::DecodeShiftImm(Instr instr) {
Instr Assembler::PatchShiftImm(Instr instr, int immed) {
uint32_t rotate_imm = 0;
uint32_t immed_8 = 0;
bool immed_fits = FitsShifter(immed, &rotate_imm, &immed_8, NULL);
bool immed_fits = FitsShifter(immed, &rotate_imm, &immed_8, nullptr);
DCHECK(immed_fits);
USE(immed_fits);
return (instr & ~kOff12Mask) | (rotate_imm << 8) | immed_8;
@ -4988,7 +4989,7 @@ bool Assembler::IsOrrImmed(Instr instr) {
bool Assembler::ImmediateFitsAddrMode1Instruction(int32_t imm32) {
uint32_t dummy1;
uint32_t dummy2;
return FitsShifter(imm32, &dummy1, &dummy2, NULL);
return FitsShifter(imm32, &dummy1, &dummy2, nullptr);
}
@ -5098,7 +5099,7 @@ void Assembler::RecordRelocInfo(RelocInfo::Mode rmode, intptr_t data) {
return;
}
DCHECK(buffer_space() >= kMaxRelocSize); // too late to grow buffer here
RelocInfo rinfo(pc_, rmode, data, NULL);
RelocInfo rinfo(pc_, rmode, data, nullptr);
reloc_info_writer.Write(&rinfo);
}

View File

@ -596,14 +596,15 @@ class Assembler : public AssemblerBase {
// 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
// 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 nullptr, 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
// 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.
// If the provided buffer is not nullptr, 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.
Assembler(Isolate* isolate, void* buffer, int buffer_size)
: Assembler(IsolateData(isolate), buffer, buffer_size) {}
Assembler(IsolateData isolate_data, void* buffer, int buffer_size);

View File

@ -986,7 +986,7 @@ void RecordWriteStub::CheckNeedsToInformIncrementalMarker(
void ProfileEntryHookStub::MaybeCallEntryHookDelayed(TurboAssembler* tasm,
Zone* zone) {
if (tasm->isolate()->function_entry_hook() != NULL) {
if (tasm->isolate()->function_entry_hook() != nullptr) {
tasm->MaybeCheckConstPool();
PredictableCodeSizeScope predictable(tasm);
predictable.ExpectSize(tasm->CallStubSize() + 2 * Assembler::kInstrSize);
@ -997,7 +997,7 @@ void ProfileEntryHookStub::MaybeCallEntryHookDelayed(TurboAssembler* tasm,
}
void ProfileEntryHookStub::MaybeCallEntryHook(MacroAssembler* masm) {
if (masm->isolate()->function_entry_hook() != NULL) {
if (masm->isolate()->function_entry_hook() != nullptr) {
ProfileEntryHookStub stub(masm->isolate());
masm->MaybeCheckConstPool();
PredictableCodeSizeScope predictable(masm);
@ -1235,7 +1235,7 @@ void ArrayConstructorStub::Generate(MacroAssembler* masm) {
// Initial map for the builtin Array function should be a map.
__ ldr(r4, FieldMemOperand(r1, JSFunction::kPrototypeOrInitialMapOffset));
// Will both indicate a NULL and a Smi.
// Will both indicate a nullptr and a Smi.
__ tst(r4, Operand(kSmiTagMask));
__ Assert(ne, kUnexpectedInitialMapForArrayFunction);
__ CompareObjectType(r4, r4, r5, MAP_TYPE);
@ -1315,7 +1315,7 @@ void InternalArrayConstructorStub::Generate(MacroAssembler* masm) {
// Initial map for the builtin Array function should be a map.
__ ldr(r3, FieldMemOperand(r1, JSFunction::kPrototypeOrInitialMapOffset));
// Will both indicate a NULL and a Smi.
// Will both indicate a nullptr and a Smi.
__ tst(r3, Operand(kSmiTagMask));
__ Assert(ne, kUnexpectedInitialMapForArrayFunction);
__ CompareObjectType(r3, r3, r4, MAP_TYPE);
@ -1449,17 +1449,18 @@ static void CallApiFunctionAndReturn(MacroAssembler* masm,
// Leave the API exit frame.
__ bind(&leave_exit_frame);
bool restore_context = context_restore_operand != NULL;
bool restore_context = context_restore_operand != nullptr;
if (restore_context) {
__ ldr(cp, *context_restore_operand);
}
// LeaveExitFrame expects unwind space to be in a register.
if (stack_space_operand != NULL) {
if (stack_space_operand != nullptr) {
__ ldr(r4, *stack_space_operand);
} else {
__ mov(r4, Operand(stack_space));
}
__ LeaveExitFrame(false, r4, !restore_context, stack_space_operand != NULL);
__ LeaveExitFrame(false, r4, !restore_context,
stack_space_operand != nullptr);
// Check if the function scheduled an exception.
__ LoadRoot(r4, Heap::kTheHoleValueRootIndex);
@ -1681,7 +1682,8 @@ void CallApiGetterStub::Generate(MacroAssembler* masm) {
MemOperand return_value_operand(
fp, (PropertyCallbackArguments::kReturnValueOffset + 3) * kPointerSize);
CallApiFunctionAndReturn(masm, api_function_address, thunk_ref,
kStackUnwindSpace, NULL, return_value_operand, NULL);
kStackUnwindSpace, nullptr, return_value_operand,
nullptr);
}
#undef __

View File

@ -41,15 +41,8 @@ const char* Registers::names_[kNumRegisters] = {
// List of alias names which can be used when referring to ARM registers.
const Registers::RegisterAlias Registers::aliases_[] = {
{10, "sl"},
{11, "r11"},
{12, "r12"},
{13, "r13"},
{14, "r14"},
{15, "r15"},
{kNoRegister, NULL}
};
{10, "sl"}, {11, "r11"}, {12, "r12"}, {13, "r13"},
{14, "r14"}, {15, "r15"}, {kNoRegister, nullptr}};
// Support for VFP registers s0 to s31 (d0 to d15) and d16-d31.
// Note that "sN:sM" is the same as "dN/2" up to d15.

View File

@ -217,7 +217,7 @@ void ArrayConstructorDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
// kTarget, kNewTarget, kActualArgumentsCount, kAllocationSite
Register registers[] = {r1, r3, r0, r2};
data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
data->InitializePlatformSpecific(arraysize(registers), registers, nullptr);
}
void ArrayNoArgumentConstructorDescriptor::InitializePlatformSpecific(
@ -227,7 +227,7 @@ void ArrayNoArgumentConstructorDescriptor::InitializePlatformSpecific(
// r1 -- function
// r2 -- allocation site with elements kind
Register registers[] = {r1, r2, r0};
data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
data->InitializePlatformSpecific(arraysize(registers), registers, nullptr);
}
void ArraySingleArgumentConstructorDescriptor::InitializePlatformSpecific(
@ -237,7 +237,7 @@ void ArraySingleArgumentConstructorDescriptor::InitializePlatformSpecific(
// r1 -- function
// r2 -- allocation site with elements kind
Register registers[] = {r1, r2, r0};
data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
data->InitializePlatformSpecific(arraysize(registers), registers, nullptr);
}
void ArrayNArgumentsConstructorDescriptor::InitializePlatformSpecific(

View File

@ -1858,7 +1858,7 @@ void TurboAssembler::Abort(BailoutReason reason) {
bind(&abort_start);
#ifdef DEBUG
const char* msg = GetBailoutReason(reason);
if (msg != NULL) {
if (msg != nullptr) {
RecordComment("Abort message: ");
RecordComment(msg);
}

View File

@ -136,7 +136,7 @@ bool ArmDebugger::GetVFPDoubleValue(const char* desc, double* value) {
bool ArmDebugger::SetBreakpoint(Instruction* 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;
}
@ -150,25 +150,25 @@ bool ArmDebugger::SetBreakpoint(Instruction* breakpc) {
bool ArmDebugger::DeleteBreakpoint(Instruction* 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 ArmDebugger::UndoBreakpoints() {
if (sim_->break_pc_ != NULL) {
if (sim_->break_pc_ != nullptr) {
sim_->break_pc_->SetInstructionBits(sim_->break_instr_);
}
}
void ArmDebugger::RedoBreakpoints() {
if (sim_->break_pc_ != NULL) {
if (sim_->break_pc_ != nullptr) {
sim_->break_pc_->SetInstructionBits(kBreakpointInstr);
}
}
@ -210,11 +210,11 @@ void ArmDebugger::Debug() {
last_pc = sim_->get_pc();
}
char* line = ReadLine("sim> ");
if (line == NULL) {
if (line == nullptr) {
break;
} else {
char* last_input = sim_->last_debugger_input();
if (strcmp(line, "\n") == 0 && last_input != NULL) {
if (strcmp(line, "\n") == 0 && last_input != nullptr) {
line = last_input;
} else {
// Ownership is transferred to sim_;
@ -305,8 +305,8 @@ void ArmDebugger::Debug() {
PrintF("printobject <value>\n");
}
} else if (strcmp(cmd, "stack") == 0 || strcmp(cmd, "mem") == 0) {
int32_t* cur = NULL;
int32_t* end = NULL;
int32_t* cur = nullptr;
int32_t* end = nullptr;
int next_arg = 1;
if (strcmp(cmd, "stack") == 0) {
@ -356,9 +356,9 @@ void ArmDebugger::Debug() {
// use a reasonably large buffer
v8::internal::EmbeddedVector<char, 256> buffer;
byte* prev = NULL;
byte* cur = NULL;
byte* end = NULL;
byte* prev = nullptr;
byte* cur = nullptr;
byte* end = nullptr;
if (argc == 1) {
cur = reinterpret_cast<byte*>(sim_->get_pc());
@ -415,7 +415,7 @@ void ArmDebugger::Debug() {
PrintF("break <address>\n");
}
} else if (strcmp(cmd, "del") == 0) {
if (!DeleteBreakpoint(NULL)) {
if (!DeleteBreakpoint(nullptr)) {
PrintF("deleting breakpoint failed\n");
}
} else if (strcmp(cmd, "flags") == 0) {
@ -598,7 +598,7 @@ void Simulator::FlushICache(base::CustomMatcherHashMap* i_cache,
CachePage* Simulator::GetCachePage(base::CustomMatcherHashMap* i_cache,
void* page) {
base::HashMap::Entry* entry = i_cache->LookupOrInsert(page, ICacheHash(page));
if (entry->value == NULL) {
if (entry->value == nullptr) {
CachePage* new_page = new CachePage();
entry->value = new_page;
}
@ -653,7 +653,7 @@ void Simulator::Initialize(Isolate* isolate) {
Simulator::Simulator(Isolate* isolate) : isolate_(isolate) {
i_cache_ = isolate_->simulator_i_cache();
if (i_cache_ == NULL) {
if (i_cache_ == nullptr) {
i_cache_ = new base::CustomMatcherHashMap(&ICacheMatch);
isolate_->set_simulator_i_cache(i_cache_);
}
@ -664,7 +664,7 @@ Simulator::Simulator(Isolate* isolate) : isolate_(isolate) {
stack_ = reinterpret_cast<char*>(malloc(stack_size));
pc_modified_ = false;
icount_ = 0;
break_pc_ = NULL;
break_pc_ = nullptr;
break_instr_ = 0;
// Set up architecture state.
@ -706,7 +706,7 @@ Simulator::Simulator(Isolate* isolate) : isolate_(isolate) {
registers_[pc] = bad_lr;
registers_[lr] = bad_lr;
last_debugger_input_ = NULL;
last_debugger_input_ = nullptr;
}
Simulator::~Simulator() {
@ -728,7 +728,7 @@ class Redirection {
: external_function_(external_function),
swi_instruction_(al | (0xf * B24) | kCallRtRedirected),
type_(type),
next_(NULL) {
next_(nullptr) {
next_ = isolate->simulator_redirection();
Simulator::current(isolate)->
FlushICache(isolate->simulator_i_cache(),
@ -747,7 +747,7 @@ class Redirection {
static Redirection* Get(Isolate* isolate, void* external_function,
ExternalReference::Type type) {
Redirection* current = isolate->simulator_redirection();
for (; current != NULL; current = current->next_) {
for (; current != nullptr; current = current->next_) {
if (current->external_function_ == external_function) {
DCHECK_EQ(current->type(), type);
return current;
@ -813,10 +813,10 @@ void* Simulator::RedirectExternalReference(Isolate* isolate,
Simulator* Simulator::current(Isolate* isolate) {
v8::internal::Isolate::PerIsolateThreadData* isolate_data =
isolate->FindOrAllocatePerThreadDataForThisThread();
DCHECK(isolate_data != NULL);
DCHECK(isolate_data != nullptr);
Simulator* sim = isolate_data->simulator();
if (sim == NULL) {
if (sim == nullptr) {
// TODO(146): delete the simulator object when a thread/isolate goes away.
sim = new Simulator(isolate);
isolate_data->set_simulator(sim);

View File

@ -533,7 +533,7 @@ Address Assembler::target_address_at(Address pc, Address constant_pool) {
Address Assembler::target_address_at(Address pc, Code* code) {
Address constant_pool = code ? code->constant_pool() : NULL;
Address constant_pool = code ? code->constant_pool() : nullptr;
return target_address_at(pc, constant_pool);
}
@ -618,7 +618,7 @@ void Assembler::set_target_address_at(Isolate* isolate, Address pc,
void Assembler::set_target_address_at(Isolate* isolate, Address pc, Code* code,
Address target,
ICacheFlushMode icache_flush_mode) {
Address constant_pool = code ? code->constant_pool() : NULL;
Address constant_pool = code ? code->constant_pool() : nullptr;
set_target_address_at(isolate, pc, constant_pool, target, icache_flush_mode);
}
@ -665,7 +665,7 @@ void RelocInfo::set_target_object(HeapObject* target,
Assembler::set_target_address_at(target->GetIsolate(), pc_, host_,
reinterpret_cast<Address>(target),
icache_flush_mode);
if (write_barrier_mode == UPDATE_WRITE_BARRIER && host() != NULL) {
if (write_barrier_mode == UPDATE_WRITE_BARRIER && host() != nullptr) {
host()->GetHeap()->incremental_marking()->RecordWriteIntoCode(host(), this,
target);
host()->GetHeap()->RecordWriteIntoCode(host(), this, target);
@ -710,9 +710,9 @@ void RelocInfo::WipeOut(Isolate* isolate) {
IsRuntimeEntry(rmode_) || IsExternalReference(rmode_) ||
IsInternalReference(rmode_));
if (IsInternalReference(rmode_)) {
Memory::Address_at(pc_) = NULL;
Memory::Address_at(pc_) = nullptr;
} else {
Assembler::set_target_address_at(isolate, pc_, host_, NULL);
Assembler::set_target_address_at(isolate, pc_, host_, nullptr);
}
}

View File

@ -699,7 +699,7 @@ void Assembler::RemoveBranchFromLabelLinkChain(Instruction* branch,
// The branch is in the middle of the chain.
if (prev_link->IsTargetInImmPCOffsetRange(next_link)) {
prev_link->SetImmPCOffsetTarget(isolate_data(), next_link);
} else if (label_veneer != NULL) {
} else if (label_veneer != nullptr) {
// Use the veneer for all previous links in the chain.
prev_link->SetImmPCOffsetTarget(isolate_data(), prev_link);
@ -4064,7 +4064,7 @@ void Assembler::EmitStringData(const char* string) {
size_t len = strlen(string) + 1;
DCHECK_LE(RoundUp(len, kInstructionSize), static_cast<size_t>(kGap));
EmitData(string, static_cast<int>(len));
// Pad with NULL characters until pc_ is aligned.
// Pad with nullptr characters until pc_ is aligned.
const char pad[] = {'\0', '\0', '\0', '\0'};
static_assert(sizeof(pad) == kInstructionSize,
"Size of padding must match instruction size.");
@ -4438,7 +4438,7 @@ bool Assembler::IsImmLogical(uint64_t value,
unsigned* n,
unsigned* imm_s,
unsigned* imm_r) {
DCHECK((n != NULL) && (imm_s != NULL) && (imm_r != NULL));
DCHECK((n != nullptr) && (imm_s != nullptr) && (imm_r != nullptr));
DCHECK((width == kWRegSizeInBits) || (width == kXRegSizeInBits));
bool negate = false;
@ -4748,7 +4748,7 @@ void Assembler::GrowBuffer() {
void Assembler::RecordRelocInfo(RelocInfo::Mode rmode, intptr_t data) {
// We do not try to reuse pool constants.
RelocInfo rinfo(reinterpret_cast<byte*>(pc_), rmode, data, NULL);
RelocInfo rinfo(reinterpret_cast<byte*>(pc_), rmode, data, nullptr);
bool write_reloc_info = true;
if ((rmode == RelocInfo::COMMENT) ||
@ -4862,7 +4862,7 @@ bool Assembler::ShouldEmitVeneer(int max_reachable_pc, int margin) {
void Assembler::RecordVeneerPool(int location_offset, int size) {
RelocInfo rinfo(buffer_ + location_offset, RelocInfo::VENEER_POOL,
static_cast<intptr_t>(size), NULL);
static_cast<intptr_t>(size), nullptr);
reloc_info_writer.Write(&rinfo);
}

View File

@ -935,14 +935,15 @@ class Assembler : public AssemblerBase {
// 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
// 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 nullptr, 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
// 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.
// If the provided buffer is not nullptr, 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.
Assembler(Isolate* isolate, void* buffer, int buffer_size)
: Assembler(IsolateData(isolate), buffer, buffer_size) {}
Assembler(IsolateData isolate_data, void* buffer, int buffer_size);
@ -965,8 +966,8 @@ class Assembler : public AssemblerBase {
// desc. GetCode() is idempotent; it returns the same result if no other
// Assembler functions are invoked in between GetCode() calls.
//
// The descriptor (desc) can be NULL. In that case, the code is finalized as
// usual, but the descriptor is not populated.
// The descriptor (desc) can be nullptr. In that case, the code is finalized
// as usual, but the descriptor is not populated.
void GetCode(Isolate* isolate, CodeDesc* desc);
// Insert the smallest number of nop instructions
@ -2872,9 +2873,9 @@ class Assembler : public AssemblerBase {
// Emit an address in the instruction stream.
void dcptr(Label* label);
// Copy a string into the instruction stream, including the terminating NULL
// character. The instruction pointer (pc_) is then aligned correctly for
// subsequent instructions.
// Copy a string into the instruction stream, including the terminating
// nullptr character. The instruction pointer (pc_) is then aligned correctly
// for subsequent instructions.
void EmitStringData(const char* string);
// Pseudo-instructions ------------------------------------------------------
@ -3353,9 +3354,8 @@ class Assembler : public AssemblerBase {
// Remove the specified branch from the unbound label link chain.
// If available, a veneer for this label can be used for other branches in the
// chain if the link chain cannot be fixed up without this branch.
void RemoveBranchFromLabelLinkChain(Instruction* branch,
Label* label,
Instruction* label_veneer = NULL);
void RemoveBranchFromLabelLinkChain(Instruction* branch, Label* label,
Instruction* label_veneer = nullptr);
// Prevent sharing of code target constant pool entries until
// EndBlockCodeTargetSharing is called. Calls to this function can be nested

View File

@ -1003,7 +1003,7 @@ static const unsigned int kProfileEntryHookCallSize =
void ProfileEntryHookStub::MaybeCallEntryHookDelayed(TurboAssembler* tasm,
Zone* zone) {
if (tasm->isolate()->function_entry_hook() != NULL) {
if (tasm->isolate()->function_entry_hook() != nullptr) {
Assembler::BlockConstPoolScope no_const_pools(tasm);
DontEmitDebugCodeScope no_debug_code(tasm);
Label entry_hook_call_start;
@ -1017,7 +1017,7 @@ void ProfileEntryHookStub::MaybeCallEntryHookDelayed(TurboAssembler* tasm,
}
void ProfileEntryHookStub::MaybeCallEntryHook(MacroAssembler* masm) {
if (masm->isolate()->function_entry_hook() != NULL) {
if (masm->isolate()->function_entry_hook() != nullptr) {
ProfileEntryHookStub stub(masm->isolate());
Assembler::BlockConstPoolScope no_const_pools(masm);
DontEmitDebugCodeScope no_debug_code(masm);
@ -1429,7 +1429,7 @@ void ArrayConstructorStub::Generate(MacroAssembler* masm) {
// Initial map for the builtin Array function should be a map.
__ Ldr(x10, FieldMemOperand(constructor,
JSFunction::kPrototypeOrInitialMapOffset));
// Will both indicate a NULL and a Smi.
// Will both indicate a nullptr and a Smi.
__ JumpIfSmi(x10, &unexpected_map);
__ JumpIfObjectType(x10, x10, x11, MAP_TYPE, &map_ok);
__ Bind(&unexpected_map);
@ -1526,7 +1526,7 @@ void InternalArrayConstructorStub::Generate(MacroAssembler* masm) {
// Initial map for the builtin Array function should be a map.
__ Ldr(x10, FieldMemOperand(constructor,
JSFunction::kPrototypeOrInitialMapOffset));
// Will both indicate a NULL and a Smi.
// Will both indicate a nullptr and a Smi.
__ JumpIfSmi(x10, &unexpected_map);
__ JumpIfObjectType(x10, x10, x11, MAP_TYPE, &map_ok);
__ Bind(&unexpected_map);
@ -1680,7 +1680,7 @@ static void CallApiFunctionAndReturn(MacroAssembler* masm,
__ Peek(x21, (spill_offset + 2) * kXRegSize);
__ Peek(x22, (spill_offset + 3) * kXRegSize);
bool restore_context = context_restore_operand != NULL;
bool restore_context = context_restore_operand != nullptr;
if (restore_context) {
__ Ldr(cp, *context_restore_operand);
}
@ -1918,7 +1918,7 @@ void CallApiGetterStub::Generate(MacroAssembler* masm) {
fp, (PropertyCallbackArguments::kReturnValueOffset + 3) * kPointerSize);
CallApiFunctionAndReturn(masm, api_function_address, thunk_ref,
kStackUnwindSpace, spill_offset,
return_value_operand, NULL);
return_value_operand, nullptr);
}
#undef __

View File

@ -547,7 +547,7 @@ void DisassemblingDecoder::VisitUnconditionalBranchToRegister(
case RET: {
mnemonic = "ret";
if (instr->Rn() == kLinkRegCode) {
form = NULL;
form = nullptr;
}
break;
}
@ -1244,7 +1244,7 @@ void DisassemblingDecoder::VisitSystem(Instruction* instr) {
switch (instr->ImmHint()) {
case NOP: {
mnemonic = "nop";
form = NULL;
form = nullptr;
break;
}
}
@ -1262,7 +1262,7 @@ void DisassemblingDecoder::VisitSystem(Instruction* instr) {
}
case ISB: {
mnemonic = "isb";
form = NULL;
form = nullptr;
break;
}
}
@ -1334,8 +1334,8 @@ void DisassemblingDecoder::VisitNEON3Same(Instruction* instr) {
"shadd", "uhadd", "shadd", "uhadd",
"sqadd", "uqadd", "sqadd", "uqadd",
"srhadd", "urhadd", "srhadd", "urhadd",
NULL, NULL, NULL,
NULL, // Handled by logical cases above.
nullptr, nullptr, nullptr,
nullptr, // Handled by logical cases above.
"shsub", "uhsub", "shsub", "uhsub",
"sqsub", "uqsub", "sqsub", "uqsub",
"cmgt", "cmhi", "cmgt", "cmhi",
@ -1976,8 +1976,8 @@ void DisassemblingDecoder::VisitNEONExtract(Instruction* instr) {
}
void DisassemblingDecoder::VisitNEONLoadStoreMultiStruct(Instruction* instr) {
const char* mnemonic = NULL;
const char* form = NULL;
const char* mnemonic = nullptr;
const char* form = nullptr;
const char* form_1v = "{'Vt.%1$s}, ['Xns]";
const char* form_2v = "{'Vt.%1$s, 'Vt2.%1$s}, ['Xns]";
const char* form_3v = "{'Vt.%1$s, 'Vt2.%1$s, 'Vt3.%1$s}, ['Xns]";
@ -2046,7 +2046,7 @@ void DisassemblingDecoder::VisitNEONLoadStoreMultiStruct(Instruction* instr) {
}
// Work out unallocated encodings.
bool allocated = (mnemonic != NULL);
bool allocated = (mnemonic != nullptr);
switch (instr->Mask(NEONLoadStoreMultiStructMask)) {
case NEON_LD2:
case NEON_LD3:
@ -2073,8 +2073,8 @@ void DisassemblingDecoder::VisitNEONLoadStoreMultiStruct(Instruction* instr) {
void DisassemblingDecoder::VisitNEONLoadStoreMultiStructPostIndex(
Instruction* instr) {
const char* mnemonic = NULL;
const char* form = NULL;
const char* mnemonic = nullptr;
const char* form = nullptr;
const char* form_1v = "{'Vt.%1$s}, ['Xns], 'Xmr1";
const char* form_2v = "{'Vt.%1$s, 'Vt2.%1$s}, ['Xns], 'Xmr2";
const char* form_3v = "{'Vt.%1$s, 'Vt2.%1$s, 'Vt3.%1$s}, ['Xns], 'Xmr3";
@ -2144,7 +2144,7 @@ void DisassemblingDecoder::VisitNEONLoadStoreMultiStructPostIndex(
}
// Work out unallocated encodings.
bool allocated = (mnemonic != NULL);
bool allocated = (mnemonic != nullptr);
switch (instr->Mask(NEONLoadStoreMultiStructPostIndexMask)) {
case NEON_LD2_post:
case NEON_LD3_post:
@ -2170,8 +2170,8 @@ void DisassemblingDecoder::VisitNEONLoadStoreMultiStructPostIndex(
}
void DisassemblingDecoder::VisitNEONLoadStoreSingleStruct(Instruction* instr) {
const char* mnemonic = NULL;
const char* form = NULL;
const char* mnemonic = nullptr;
const char* form = nullptr;
const char* form_1b = "{'Vt.b}['IVLSLane0], ['Xns]";
const char* form_1h = "{'Vt.h}['IVLSLane1], ['Xns]";
@ -2294,7 +2294,7 @@ void DisassemblingDecoder::VisitNEONLoadStoreSingleStruct(Instruction* instr) {
}
// Work out unallocated encodings.
bool allocated = (mnemonic != NULL);
bool allocated = (mnemonic != nullptr);
switch (instr->Mask(NEONLoadStoreSingleStructMask)) {
case NEON_LD1_h:
case NEON_LD2_h:
@ -2342,8 +2342,8 @@ void DisassemblingDecoder::VisitNEONLoadStoreSingleStruct(Instruction* instr) {
void DisassemblingDecoder::VisitNEONLoadStoreSingleStructPostIndex(
Instruction* instr) {
const char* mnemonic = NULL;
const char* form = NULL;
const char* mnemonic = nullptr;
const char* form = nullptr;
const char* form_1b = "{'Vt.b}['IVLSLane0], ['Xns], 'Xmb1";
const char* form_1h = "{'Vt.h}['IVLSLane1], ['Xns], 'Xmb2";
@ -2455,7 +2455,7 @@ void DisassemblingDecoder::VisitNEONLoadStoreSingleStructPostIndex(
}
// Work out unallocated encodings.
bool allocated = (mnemonic != NULL);
bool allocated = (mnemonic != nullptr);
switch (instr->Mask(NEONLoadStoreSingleStructPostIndexMask)) {
case NEON_LD1_h_post:
case NEON_LD2_h_post:
@ -3355,10 +3355,10 @@ void DisassemblingDecoder::Format(Instruction* instr, const char* mnemonic,
const char* format) {
// TODO(mcapewel) don't think I can use the instr address here - there needs
// to be a base address too
DCHECK(mnemonic != NULL);
DCHECK(mnemonic != nullptr);
ResetOutput();
Substitute(instr, mnemonic);
if (format != NULL) {
if (format != nullptr) {
buffer_[buffer_pos_++] = ' ';
Substitute(instr, format);
}

View File

@ -657,8 +657,8 @@ void NEONFormatDecoder::SetFormatMaps(const NEONFormatMap* format0,
const NEONFormatMap* format2) {
DCHECK_NOT_NULL(format0);
formats_[0] = format0;
formats_[1] = (format1 == NULL) ? formats_[0] : format1;
formats_[2] = (format2 == NULL) ? formats_[1] : format2;
formats_[1] = (format1 == nullptr) ? formats_[0] : format1;
formats_[2] = (format2 == nullptr) ? formats_[1] : format2;
}
void NEONFormatDecoder::SetFormatMap(unsigned index,

View File

@ -551,7 +551,7 @@ const Instr kImmExceptionIsDebug = 0xdeb0;
// Parameters are inlined in the code after a debug pseudo-instruction:
// - Debug code.
// - Debug parameters.
// - Debug message string. This is a NULL-terminated ASCII string, padded to
// - Debug message string. This is a nullptr-terminated ASCII string, padded to
// kInstructionSize so that subsequent instructions are correctly aligned.
// - A kImmExceptionIsUnreachable marker, to catch accidental execution of the
// string data.
@ -642,8 +642,8 @@ class NEONFormatDecoder {
// Set the format mapping for all or individual substitutions.
void SetFormatMaps(const NEONFormatMap* format0,
const NEONFormatMap* format1 = NULL,
const NEONFormatMap* format2 = NULL);
const NEONFormatMap* format1 = nullptr,
const NEONFormatMap* format2 = nullptr);
void SetFormatMap(unsigned index, const NEONFormatMap* format);
// Substitute %s in the input string with the placeholder string for each

View File

@ -9,7 +9,7 @@ namespace internal {
Counter::Counter(const char* name, CounterType type)
: count_(0), enabled_(false), type_(type) {
DCHECK(name != NULL);
DCHECK(name != nullptr);
strncpy(name_, name, kCounterNameMaxLength);
}
@ -96,12 +96,11 @@ static const CounterDescriptor kCounterList[] = {
Instrument::Instrument(const char* datafile, uint64_t sample_period)
: output_stream_(stderr), sample_period_(sample_period) {
// Set up the output stream. If datafile is non-NULL, use that file. If it
// can't be opened, or datafile is NULL, use stderr.
if (datafile != NULL) {
// Set up the output stream. If datafile is non-nullptr, use that file. If it
// can't be opened, or datafile is nullptr, use stderr.
if (datafile != nullptr) {
output_stream_ = fopen(datafile, "w");
if (output_stream_ == NULL) {
if (output_stream_ == nullptr) {
fprintf(stderr, "Can't open output file %s. Using stderr.\n", datafile);
output_stream_ = stderr;
}

View File

@ -52,8 +52,9 @@ class Counter {
class Instrument: public DecoderVisitor {
public:
explicit Instrument(const char* datafile = NULL,
uint64_t sample_period = kDefaultInstrumentationSamplingPeriod);
explicit Instrument(
const char* datafile = nullptr,
uint64_t sample_period = kDefaultInstrumentationSamplingPeriod);
~Instrument();
// Declare all Visitor functions.

View File

@ -222,7 +222,7 @@ void ArrayConstructorDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
// kTarget, kNewTarget, kActualArgumentsCount, kAllocationSite
Register registers[] = {x1, x3, x0, x2};
data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
data->InitializePlatformSpecific(arraysize(registers), registers, nullptr);
}
void ArrayNoArgumentConstructorDescriptor::InitializePlatformSpecific(
@ -232,7 +232,7 @@ void ArrayNoArgumentConstructorDescriptor::InitializePlatformSpecific(
// x2: allocation site with elements kind
// x0: number of arguments to the constructor function
Register registers[] = {x1, x2, x0};
data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
data->InitializePlatformSpecific(arraysize(registers), registers, nullptr);
}
void ArraySingleArgumentConstructorDescriptor::InitializePlatformSpecific(
@ -242,7 +242,7 @@ void ArraySingleArgumentConstructorDescriptor::InitializePlatformSpecific(
// x1: function
// x2: allocation site with elements kind
Register registers[] = {x1, x2, x0};
data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
data->InitializePlatformSpecific(arraysize(registers), registers, nullptr);
}
void ArrayNArgumentsConstructorDescriptor::InitializePlatformSpecific(

View File

@ -1173,7 +1173,7 @@ void TurboAssembler::JumpIfSmi(Register value, Label* smi_label,
void MacroAssembler::JumpIfNotSmi(Register value, Label* not_smi_label) {
JumpIfSmi(value, NULL, not_smi_label);
JumpIfSmi(value, nullptr, not_smi_label);
}
@ -1206,14 +1206,14 @@ void MacroAssembler::JumpIfEitherSmi(Register value1,
void MacroAssembler::JumpIfEitherNotSmi(Register value1,
Register value2,
Label* not_smi_label) {
JumpIfBothSmi(value1, value2, NULL, not_smi_label);
JumpIfBothSmi(value1, value2, nullptr, not_smi_label);
}
void MacroAssembler::JumpIfBothNotSmi(Register value1,
Register value2,
Label* not_smi_label) {
JumpIfEitherSmi(value1, value2, NULL, not_smi_label);
JumpIfEitherSmi(value1, value2, nullptr, not_smi_label);
}

View File

@ -1015,12 +1015,12 @@ void TurboAssembler::Abs(const Register& rd, const Register& rm,
// If the comparison sets the v flag, the input was the smallest value
// representable by rm, and the mathematical result of abs(rm) is not
// representable using two's complement.
if ((is_not_representable != NULL) && (is_representable != NULL)) {
if ((is_not_representable != nullptr) && (is_representable != nullptr)) {
B(is_not_representable, vs);
B(is_representable);
} else if (is_not_representable != NULL) {
} else if (is_not_representable != nullptr) {
B(is_not_representable, vs);
} else if (is_representable != NULL) {
} else if (is_representable != nullptr) {
B(is_representable, vc);
}
}
@ -3584,7 +3584,7 @@ void InlineSmiCheckInfo::Emit(MacroAssembler* masm, const Register& reg,
}
InlineSmiCheckInfo::InlineSmiCheckInfo(Address info)
: reg_(NoReg), smi_check_delta_(0), smi_check_(NULL) {
: reg_(NoReg), smi_check_delta_(0), smi_check_(nullptr) {
InstructionSequence* inline_data = InstructionSequence::At(info);
DCHECK(inline_data->IsInlineData());
if (inline_data->IsInlineData()) {

View File

@ -867,7 +867,7 @@ class TurboAssembler : public Assembler {
inline void Brk(int code);
inline void JumpIfSmi(Register value, Label* smi_label,
Label* not_smi_label = NULL);
Label* not_smi_label = nullptr);
inline void Fmov(VRegister fd, VRegister fn);
inline void Fmov(VRegister fd, Register rn);
@ -1211,7 +1211,8 @@ class TurboAssembler : public Assembler {
// If rm is the minimum representable value, the result is not representable.
// Handlers for each case can be specified using the relevant labels.
void Abs(const Register& rd, const Register& rm,
Label* is_not_representable = NULL, Label* is_representable = NULL);
Label* is_not_representable = nullptr,
Label* is_representable = nullptr);
inline void Cls(const Register& rd, const Register& rn);
inline void Cneg(const Register& rd, const Register& rn, Condition cond);
@ -1254,7 +1255,7 @@ class TurboAssembler : public Assembler {
// The 'args' argument should point to an array of variable arguments in their
// proper PCS registers (and in calling order). The argument registers can
// have mixed types. The format string (x0) should not be included.
void CallPrintf(int arg_count = 0, const CPURegister* args = NULL);
void CallPrintf(int arg_count = 0, const CPURegister* args = nullptr);
private:
bool has_frame_ = false;
@ -1755,14 +1756,12 @@ class MacroAssembler : public TurboAssembler {
inline void SmiTagAndPush(Register src1, Register src2);
inline void JumpIfNotSmi(Register value, Label* not_smi_label);
inline void JumpIfBothSmi(Register value1,
Register value2,
inline void JumpIfBothSmi(Register value1, Register value2,
Label* both_smi_label,
Label* not_smi_label = NULL);
inline void JumpIfEitherSmi(Register value1,
Register value2,
Label* not_smi_label = nullptr);
inline void JumpIfEitherSmi(Register value1, Register value2,
Label* either_smi_label,
Label* not_smi_label = NULL);
Label* not_smi_label = nullptr);
inline void JumpIfEitherNotSmi(Register value1,
Register value2,
Label* not_smi_label);
@ -1806,8 +1805,8 @@ class MacroAssembler : public TurboAssembler {
// On output the Z flag is set if the operation was successful.
void TryRepresentDoubleAsInt64(Register as_int, VRegister value,
VRegister scratch_d,
Label* on_successful_conversion = NULL,
Label* on_failed_conversion = NULL) {
Label* on_successful_conversion = nullptr,
Label* on_failed_conversion = nullptr) {
DCHECK(as_int.Is64Bits());
TryRepresentDoubleAsInt(as_int, value, scratch_d, on_successful_conversion,
on_failed_conversion);
@ -2168,8 +2167,8 @@ class MacroAssembler : public TurboAssembler {
// On output the Z flag is set if the operation was successful.
void TryRepresentDoubleAsInt(Register as_int, VRegister value,
VRegister scratch_d,
Label* on_successful_conversion = NULL,
Label* on_failed_conversion = NULL);
Label* on_successful_conversion = nullptr,
Label* on_failed_conversion = nullptr);
public:
// Far branches resolving.
@ -2288,9 +2287,7 @@ class InlineSmiCheckInfo {
public:
explicit InlineSmiCheckInfo(Address info);
bool HasSmiCheck() const {
return smi_check_ != NULL;
}
bool HasSmiCheck() const { return smi_check_ != nullptr; }
const Register& SmiRegister() const {
return reg_;

View File

@ -72,9 +72,7 @@ void Simulator::TraceSim(const char* format, ...) {
}
}
const Instruction* Simulator::kEndOfSimAddress = NULL;
const Instruction* Simulator::kEndOfSimAddress = nullptr;
void SimSystemRegister::SetBits(int msb, int lsb, uint32_t bits) {
int width = msb - lsb + 1;
@ -111,10 +109,10 @@ void Simulator::Initialize(Isolate* isolate) {
Simulator* Simulator::current(Isolate* isolate) {
Isolate::PerIsolateThreadData* isolate_data =
isolate->FindOrAllocatePerThreadDataForThisThread();
DCHECK(isolate_data != NULL);
DCHECK(isolate_data != nullptr);
Simulator* sim = isolate_data->simulator();
if (sim == NULL) {
if (sim == nullptr) {
if (FLAG_trace_sim || FLAG_log_instruction_stats || FLAG_debug_sim) {
sim = new Simulator(new Decoder<DispatchingDecoderVisitor>(), isolate);
} else {
@ -352,11 +350,10 @@ uintptr_t Simulator::StackLimit(uintptr_t c_limit) const {
return stack_limit_ + 1024;
}
Simulator::Simulator(Decoder<DispatchingDecoderVisitor>* decoder,
Isolate* isolate, FILE* stream)
: decoder_(decoder),
last_debugger_input_(NULL),
last_debugger_input_(nullptr),
log_parameters_(NO_PARAM),
isolate_(isolate) {
// Setup the decoder.
@ -376,12 +373,11 @@ Simulator::Simulator(Decoder<DispatchingDecoderVisitor>* decoder,
}
}
Simulator::Simulator()
: decoder_(NULL),
last_debugger_input_(NULL),
: decoder_(nullptr),
last_debugger_input_(nullptr),
log_parameters_(NO_PARAM),
isolate_(NULL) {
isolate_(nullptr) {
Init(stdout);
CHECK(!FLAG_trace_sim && !FLAG_log_instruction_stats);
}
@ -414,7 +410,7 @@ void Simulator::ResetState() {
fpcr_ = SimSystemRegister::DefaultValueFor(FPCR);
// Reset registers to 0.
pc_ = NULL;
pc_ = nullptr;
for (unsigned i = 0; i < kNumberOfRegisters; i++) {
set_xreg(i, 0xbadbeef);
}
@ -473,7 +469,7 @@ class Redirection {
public:
Redirection(Isolate* isolate, void* external_function,
ExternalReference::Type type)
: external_function_(external_function), type_(type), next_(NULL) {
: external_function_(external_function), type_(type), next_(nullptr) {
redirect_call_.SetInstructionBits(
HLT | Assembler::ImmException(kImmExceptionIsRedirectedCall));
next_ = isolate->simulator_redirection();
@ -493,7 +489,7 @@ class Redirection {
static Redirection* Get(Isolate* isolate, void* external_function,
ExternalReference::Type type) {
Redirection* current = isolate->simulator_redirection();
for (; current != NULL; current = current->next_) {
for (; current != nullptr; current = current->next_) {
if (current->external_function_ == external_function) {
DCHECK_EQ(current->type(), type);
return current;
@ -3216,12 +3212,12 @@ void Simulator::Debug() {
PrintInstructionsAt(pc_, 1);
// Read the command line.
char* line = ReadLine("sim> ");
if (line == NULL) {
if (line == nullptr) {
break;
} else {
// Repeat last command by default.
char* last_input = last_debugger_input();
if (strcmp(line, "\n") == 0 && (last_input != NULL)) {
if (strcmp(line, "\n") == 0 && (last_input != nullptr)) {
DeleteArray(line);
line = last_input;
} else {
@ -3341,8 +3337,8 @@ void Simulator::Debug() {
// stack / mem ----------------------------------------------------------
} else if (strcmp(cmd, "stack") == 0 || strcmp(cmd, "mem") == 0) {
int64_t* cur = NULL;
int64_t* end = NULL;
int64_t* cur = nullptr;
int64_t* end = nullptr;
int next_arg = 1;
if (strcmp(cmd, "stack") == 0) {
@ -3504,7 +3500,7 @@ void Simulator::VisitException(Instruction* instr) {
// We are going to break, so printing something is not an issue in
// terms of speed.
if (FLAG_trace_sim_messages || FLAG_trace_sim || (parameters & BREAK)) {
if (message != NULL) {
if (message != nullptr) {
PrintF(stream_,
"# %sDebugger hit %d: %s%s%s\n",
clr_debug_number,
@ -4341,7 +4337,7 @@ void Simulator::VisitNEONByIndexedElement(Instruction* instr) {
SimVRegister& rd = vreg(instr->Rd());
SimVRegister& rn = vreg(instr->Rn());
ByElementOp Op = NULL;
ByElementOp Op = nullptr;
int rm_reg = instr->Rm();
int index = (instr->NEONH() << 1) | instr->NEONL();
@ -5275,7 +5271,7 @@ void Simulator::VisitNEONScalarByIndexedElement(Instruction* instr) {
SimVRegister& rd = vreg(instr->Rd());
SimVRegister& rn = vreg(instr->Rn());
ByElementOp Op = NULL;
ByElementOp Op = nullptr;
int rm_reg = instr->Rm();
int index = (instr->NEONH() << 1) | instr->NEONL();
@ -5730,7 +5726,7 @@ void Simulator::DoPrintf(Instruction* instr) {
// Leave enough space for one extra character per expected argument (plus the
// '\0' termination).
const char * format_base = reg<const char *>(0);
DCHECK(format_base != NULL);
DCHECK(format_base != nullptr);
size_t length = strlen(format_base) + 1;
char * const format = new char[length + arg_count];

View File

@ -690,8 +690,7 @@ class Simulator : public DecoderVisitor {
}
explicit Simulator(Decoder<DispatchingDecoderVisitor>* decoder,
Isolate* isolate = NULL,
FILE* stream = stderr);
Isolate* isolate = nullptr, FILE* stream = stderr);
Simulator();
~Simulator();
@ -1700,9 +1699,9 @@ class Simulator : public DecoderVisitor {
LogicVRegister Table(VectorFormat vform, LogicVRegister dst,
const LogicVRegister& ind, bool zero_out_of_bounds,
const LogicVRegister* tab1,
const LogicVRegister* tab2 = NULL,
const LogicVRegister* tab3 = NULL,
const LogicVRegister* tab4 = NULL);
const LogicVRegister* tab2 = nullptr,
const LogicVRegister* tab3 = nullptr,
const LogicVRegister* tab4 = nullptr);
LogicVRegister tbl(VectorFormat vform, LogicVRegister dst,
const LogicVRegister& tab, const LogicVRegister& ind);
LogicVRegister tbl(VectorFormat vform, LogicVRegister dst,

View File

@ -2159,7 +2159,7 @@ LogicVRegister Simulator::Table(VectorFormat vform, LogicVRegister dst,
uint64_t j = ind.Uint(vform, i);
int tab_idx = static_cast<int>(j >> 4);
int j_idx = static_cast<int>(j & 15);
if ((tab_idx < 4) && (tab[tab_idx] != NULL)) {
if ((tab_idx < 4) && (tab[tab_idx] != nullptr)) {
result[i] = tab[tab_idx]->Uint(kFormat16B, j_idx);
}
}

View File

@ -162,7 +162,7 @@ AssemblerBase::AssemblerBase(IsolateData isolate_data, void* buffer,
predictable_code_size_(false),
constant_pool_available_(false),
jump_optimization_info_(nullptr) {
own_buffer_ = buffer == NULL;
own_buffer_ = buffer == nullptr;
if (buffer_size == 0) buffer_size = kMinimalBufferSize;
DCHECK(buffer_size > 0);
if (own_buffer_) buffer = NewArray<byte>(buffer_size);
@ -356,7 +356,7 @@ void RelocInfo::set_target_address(Isolate* isolate, Address target,
DCHECK(IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_));
Assembler::set_target_address_at(isolate, pc_, host_, target,
icache_flush_mode);
if (write_barrier_mode == UPDATE_WRITE_BARRIER && host() != NULL &&
if (write_barrier_mode == UPDATE_WRITE_BARRIER && host() != nullptr &&
IsCodeTarget(rmode_)) {
Code* target_code = Code::GetCodeFromTargetAddress(target);
host()->GetHeap()->incremental_marking()->RecordWriteIntoCode(host(), this,
@ -678,8 +678,7 @@ void RelocInfo::Print(Isolate* isolate, std::ostream& os) { // NOLINT
Code* code = Code::GetCodeFromTargetAddress(target_address());
os << " (" << Code::Kind2String(code->kind()) << ") ("
<< static_cast<const void*>(target_address()) << ")";
} else if (IsRuntimeEntry(rmode_) &&
isolate->deoptimizer_data() != NULL) {
} else if (IsRuntimeEntry(rmode_) && isolate->deoptimizer_data() != nullptr) {
// Depotimization bailouts are stored as runtime entries.
int id = Deoptimizer::GetDeoptimizationId(
isolate, target_address(), Deoptimizer::EAGER);
@ -703,7 +702,7 @@ void RelocInfo::Verify(Isolate* isolate) {
case CODE_TARGET: {
// convert inline target address to code object
Address addr = target_address();
CHECK(addr != NULL);
CHECK(addr != nullptr);
// Check that we can find the right code object.
Code* code = Code::GetCodeFromTargetAddress(addr);
Object* found = isolate->FindCodeObject(addr);
@ -772,10 +771,9 @@ ExternalReference::ExternalReference(Address address, Isolate* isolate)
: address_(Redirect(isolate, address)) {}
ExternalReference::ExternalReference(
ApiFunction* fun,
Type type = ExternalReference::BUILTIN_CALL,
Isolate* isolate = NULL)
: address_(Redirect(isolate, fun->address(), type)) {}
ApiFunction* fun, Type type = ExternalReference::BUILTIN_CALL,
Isolate* isolate = nullptr)
: address_(Redirect(isolate, fun->address(), type)) {}
ExternalReference::ExternalReference(Runtime::FunctionId id, Isolate* isolate)
: ExternalReference(Runtime::FunctionForId(id), isolate) {}
@ -852,7 +850,7 @@ ExternalReference ExternalReference::date_cache_stamp(Isolate* isolate) {
void ExternalReference::set_redirector(
Isolate* isolate, ExternalReferenceRedirector* redirector) {
// We can't stack them.
DCHECK(isolate->external_reference_redirector() == NULL);
DCHECK(isolate->external_reference_redirector() == nullptr);
isolate->set_external_reference_redirector(
reinterpret_cast<ExternalReferenceRedirectorPointer*>(redirector));
}

View File

@ -634,7 +634,7 @@ class RelocInfo {
// lower addresses.
class RelocInfoWriter BASE_EMBEDDED {
public:
RelocInfoWriter() : pos_(NULL), last_pc_(NULL) {}
RelocInfoWriter() : pos_(nullptr), last_pc_(nullptr) {}
RelocInfoWriter(byte* pos, byte* pc) : pos_(pos), last_pc_(pc) {}
byte* pos() const { return pos_; }
@ -799,7 +799,7 @@ class ExternalReference BASE_EMBEDDED {
typedef void* ExternalReferenceRedirector(Isolate* isolate, void* original,
Type type);
ExternalReference() : address_(NULL) {}
ExternalReference() : address_(nullptr) {}
ExternalReference(Address address, Isolate* isolate);
@ -1053,8 +1053,9 @@ class ExternalReference BASE_EMBEDDED {
reinterpret_cast<ExternalReferenceRedirector*>(
isolate->external_reference_redirector());
void* address = reinterpret_cast<void*>(address_arg);
void* answer =
(redirector == NULL) ? address : (*redirector)(isolate, address, type);
void* answer = (redirector == nullptr)
? address
: (*redirector)(isolate, address, type);
return answer;
}

View File

@ -71,7 +71,7 @@ class PerThreadAssertData final {
template <PerThreadAssertType kType, bool kAllow>
PerThreadAssertScope<kType, kAllow>::PerThreadAssertScope()
: data_(PerThreadAssertData::GetCurrent()) {
if (data_ == NULL) {
if (data_ == nullptr) {
data_ = new PerThreadAssertData();
PerThreadAssertData::SetCurrent(data_);
}
@ -92,7 +92,7 @@ void PerThreadAssertScope<kType, kAllow>::Release() {
DCHECK_NOT_NULL(data_);
data_->Set(kType, old_state_);
if (data_->DecrementLevel()) {
PerThreadAssertData::SetCurrent(NULL);
PerThreadAssertData::SetCurrent(nullptr);
delete data_;
}
data_ = nullptr;
@ -102,7 +102,7 @@ void PerThreadAssertScope<kType, kAllow>::Release() {
template <PerThreadAssertType kType, bool kAllow>
bool PerThreadAssertScope<kType, kAllow>::IsAllowed() {
PerThreadAssertData* data = PerThreadAssertData::GetCurrent();
return data == NULL || data->Get(kType);
return data == nullptr || data->Get(kType);
}

View File

@ -39,10 +39,10 @@ void AstExpressionRewriter::VisitStatements(ZoneList<Statement*>* statements) {
void AstExpressionRewriter::VisitExpressions(
ZoneList<Expression*>* expressions) {
for (int i = 0; i < expressions->length(); i++) {
// The variable statement visiting code may pass NULL expressions
// The variable statement visiting code may pass null expressions
// to this code. Maybe this should be handled by introducing an
// undefined expression or literal? Revisit this code if this
// changes
// undefined expression or literal? Revisit this code if this
// changes.
if (expressions->at(i) != nullptr) {
AST_REWRITE_LIST_ELEMENT(Expression, expressions, i);
}

View File

@ -400,10 +400,10 @@ void AstNumberingVisitor::VisitSwitchStatement(SwitchStatement* node) {
void AstNumberingVisitor::VisitForStatement(ForStatement* node) {
if (node->init() != NULL) Visit(node->init()); // Not part of loop.
if (node->init() != nullptr) Visit(node->init()); // Not part of loop.
node->set_first_suspend_id(suspend_count_);
if (node->cond() != NULL) Visit(node->cond());
if (node->next() != NULL) Visit(node->next());
if (node->cond() != nullptr) Visit(node->cond());
if (node->next() != nullptr) Visit(node->next());
Visit(node->body());
node->set_suspend_count(suspend_count_ - node->first_suspend_id());
}
@ -461,7 +461,7 @@ void AstNumberingVisitor::VisitCallNew(CallNew* node) {
void AstNumberingVisitor::VisitStatements(ZoneList<Statement*>* statements) {
if (statements == NULL) return;
if (statements == nullptr) return;
for (int i = 0; i < statements->length(); i++) {
Visit(statements->at(i));
if (statements->at(i)->IsJump()) break;

View File

@ -228,13 +228,13 @@ void AstTraversalVisitor<Subclass>::VisitWhileStatement(WhileStatement* stmt) {
template <class Subclass>
void AstTraversalVisitor<Subclass>::VisitForStatement(ForStatement* stmt) {
PROCESS_NODE(stmt);
if (stmt->init() != NULL) {
if (stmt->init() != nullptr) {
RECURSE(Visit(stmt->init()));
}
if (stmt->cond() != NULL) {
if (stmt->cond() != nullptr) {
RECURSE(Visit(stmt->cond()));
}
if (stmt->next() != NULL) {
if (stmt->next() != nullptr) {
RECURSE(Visit(stmt->next()));
}
RECURSE(Visit(stmt->body()));

View File

@ -204,7 +204,7 @@ bool AstValue::IsPropertyName() const {
bool AstValue::BooleanValue() const {
switch (type_) {
case STRING:
DCHECK(string_ != NULL);
DCHECK(string_ != nullptr);
return !string_->IsEmpty();
case SYMBOL:
UNREACHABLE();
@ -317,7 +317,7 @@ AstRawString* AstValueFactory::GetTwoByteStringInternal(
const AstRawString* AstValueFactory::GetString(Handle<String> literal) {
AstRawString* result = NULL;
AstRawString* result = nullptr;
DisallowHeapAllocation no_gc;
String::FlatContent content = literal->GetFlatContent();
if (content.IsOneByte()) {

View File

@ -468,7 +468,7 @@ class AstValueFactory {
AstRawString* GetString(uint32_t hash, bool is_one_byte,
Vector<const byte> literal_bytes);
// All strings are copied here, one after another (no NULLs inbetween).
// All strings are copied here, one after another (no zeroes inbetween).
base::CustomMatcherHashMap string_table_;
// For keeping track of all AstValues and AstRawStrings we've created (so that
// they can be internalized later).

View File

@ -118,7 +118,7 @@ bool Expression::IsUndefinedLiteral() const {
Variable* var = var_proxy->var();
// The global identifier "undefined" is immutable. Everything
// else could be reassigned.
return var != NULL && var->IsUnallocated() &&
return var != nullptr && var->IsUnallocated() &&
var_proxy->raw_name()->IsOneByteEqualTo("undefined");
}
@ -323,7 +323,7 @@ ObjectLiteralProperty::ObjectLiteralProperty(AstValueFactory* ast_value_factory,
key->AsLiteral()->raw_value()->EqualsString(
ast_value_factory->proto_string())) {
kind_ = PROTOTYPE;
} else if (value_->AsMaterializedLiteral() != NULL) {
} else if (value_->AsMaterializedLiteral() != nullptr) {
kind_ = MATERIALIZED_LITERAL;
} else if (value_->IsLiteral()) {
kind_ = CONSTANT;
@ -479,7 +479,7 @@ void ObjectLiteral::CalculateEmitStore(Zone* zone) {
// entry was also an accessor.
uint32_t hash = literal->Hash();
ZoneHashMap::Entry* entry = table.LookupOrInsert(literal, hash, allocator);
if (entry->value != NULL) {
if (entry->value != nullptr) {
auto previous_kind =
static_cast<ObjectLiteral::Property*>(entry->value)->kind();
if (!((property->kind() == GETTER && previous_kind == SETTER) ||
@ -611,7 +611,7 @@ void ObjectLiteral::BuildConstantProperties(Isolate* isolate) {
DCHECK(!property->is_computed_name());
MaterializedLiteral* m_literal = property->value()->AsMaterializedLiteral();
if (m_literal != NULL) {
if (m_literal != nullptr) {
m_literal->BuildConstants(isolate);
}
@ -665,7 +665,7 @@ int ArrayLiteral::InitDepthAndFlags() {
Expression* element = values()->at(array_index);
DCHECK(!element->IsSpread());
MaterializedLiteral* literal = element->AsMaterializedLiteral();
if (literal != NULL) {
if (literal != nullptr) {
int subliteral_depth = literal->InitDepthAndFlags() + 1;
if (subliteral_depth > depth_acc) depth_acc = subliteral_depth;
}
@ -700,7 +700,7 @@ void ArrayLiteral::BuildConstantElements(Isolate* isolate) {
Expression* element = values()->at(array_index);
DCHECK(!element->IsSpread());
MaterializedLiteral* m_literal = element->AsMaterializedLiteral();
if (m_literal != NULL) {
if (m_literal != nullptr) {
m_literal->BuildConstants(isolate);
}
@ -909,7 +909,7 @@ bool BinaryOperation::IsSmiLiteralOperation(Expression** subexpr,
static bool IsTypeof(Expression* expr) {
UnaryOperation* maybe_unary = expr->AsUnaryOperation();
return maybe_unary != NULL && maybe_unary->op() == Token::TYPEOF;
return maybe_unary != nullptr && maybe_unary->op() == Token::TYPEOF;
}
void CompareOperation::AssignFeedbackSlots(FeedbackVectorSpec* spec,
@ -949,9 +949,8 @@ bool CompareOperation::IsLiteralCompareTypeof(Expression** expr,
static bool IsVoidOfLiteral(Expression* expr) {
UnaryOperation* maybe_unary = expr->AsUnaryOperation();
return maybe_unary != NULL &&
maybe_unary->op() == Token::VOID &&
maybe_unary->expression()->IsLiteral();
return maybe_unary != nullptr && maybe_unary->op() == Token::VOID &&
maybe_unary->expression()->IsLiteral();
}
@ -1008,7 +1007,7 @@ void Call::AssignFeedbackSlots(FeedbackVectorSpec* spec,
Call::CallType Call::GetCallType() const {
VariableProxy* proxy = expression()->AsVariableProxy();
if (proxy != NULL) {
if (proxy != nullptr) {
if (proxy->var()->IsUnallocated()) {
return GLOBAL_CALL;
} else if (proxy->var()->IsLookupSlot()) {

View File

@ -206,7 +206,7 @@ class AstNode: public ZoneObject {
class Statement : public AstNode {
public:
bool IsEmpty() { return AsEmptyStatement() != NULL; }
bool IsEmpty() { return AsEmptyStatement() != nullptr; }
bool IsJump() const;
protected:
@ -312,8 +312,8 @@ class Block : public BreakableStatement {
inline ZoneList<const AstRawString*>* labels() const;
bool IsJump() const {
return !statements_.is_empty() && statements_.last()->IsJump()
&& labels() == NULL; // Good enough as an approximation...
return !statements_.is_empty() && statements_.last()->IsJump() &&
labels() == nullptr; // Good enough as an approximation...
}
Scope* scope() const { return scope_; }
@ -335,7 +335,7 @@ class Block : public BreakableStatement {
bool ignore_completion_value)
: BreakableStatement(TARGET_FOR_NAMED_ONLY, kNoSourcePosition, kBlock),
statements_(capacity, zone),
scope_(NULL) {
scope_(nullptr) {
bit_field_ |= IgnoreCompletionField::encode(ignore_completion_value) |
IsLabeledField::encode(labels != nullptr);
}
@ -455,7 +455,7 @@ class FunctionDeclaration final : public Declaration {
FunctionDeclaration(VariableProxy* proxy, FunctionLiteral* fun, int pos)
: Declaration(proxy, pos, kFunctionDeclaration), fun_(fun) {
DCHECK(fun != NULL);
DCHECK(fun != nullptr);
}
FunctionLiteral* fun_;
@ -481,7 +481,7 @@ class IterationStatement : public BreakableStatement {
NodeType type)
: BreakableStatement(TARGET_FOR_ANONYMOUS, pos, type),
labels_(labels),
body_(NULL),
body_(nullptr),
suspend_count_(0),
first_suspend_id_(0) {}
void Initialize(Statement* body) { body_ = body; }
@ -511,7 +511,7 @@ class DoWhileStatement final : public IterationStatement {
friend class AstNodeFactory;
DoWhileStatement(ZoneList<const AstRawString*>* labels, int pos)
: IterationStatement(labels, pos, kDoWhileStatement), cond_(NULL) {}
: IterationStatement(labels, pos, kDoWhileStatement), cond_(nullptr) {}
Expression* cond_;
};
@ -531,7 +531,7 @@ class WhileStatement final : public IterationStatement {
friend class AstNodeFactory;
WhileStatement(ZoneList<const AstRawString*>* labels, int pos)
: IterationStatement(labels, pos, kWhileStatement), cond_(NULL) {}
: IterationStatement(labels, pos, kWhileStatement), cond_(nullptr) {}
Expression* cond_;
};
@ -560,9 +560,9 @@ class ForStatement final : public IterationStatement {
ForStatement(ZoneList<const AstRawString*>* labels, int pos)
: IterationStatement(labels, pos, kForStatement),
init_(NULL),
cond_(NULL),
next_(NULL) {}
init_(nullptr),
cond_(nullptr),
next_(nullptr) {}
Statement* init_;
Expression* cond_;
@ -690,11 +690,11 @@ class ForOfStatement final : public ForEachStatement {
ForOfStatement(ZoneList<const AstRawString*>* labels, int pos)
: ForEachStatement(labels, pos, kForOfStatement),
iterator_(NULL),
assign_iterator_(NULL),
next_result_(NULL),
result_done_(NULL),
assign_each_(NULL) {}
iterator_(nullptr),
assign_iterator_(nullptr),
next_result_(nullptr),
result_done_(nullptr),
assign_each_(nullptr) {}
Variable* iterator_;
Expression* assign_iterator_;
@ -811,7 +811,7 @@ class WithStatement final : public Statement {
class CaseClause final : public ZoneObject {
public:
bool is_default() const { return label_ == NULL; }
bool is_default() const { return label_ == nullptr; }
Expression* label() const {
DCHECK(!is_default());
return label_;
@ -1348,7 +1348,7 @@ class ObjectLiteral final : public AggregateLiteral {
static_cast<int>(kFastElements));
struct Accessors: public ZoneObject {
Accessors() : getter(NULL), setter(NULL) {}
Accessors() : getter(nullptr), setter(nullptr) {}
ObjectLiteralProperty* getter;
ObjectLiteralProperty* setter;
};
@ -1414,7 +1414,9 @@ class AccessorTable
Iterator lookup(Literal* literal) {
Iterator it = find(literal, true, ZoneAllocationPolicy(zone_));
if (it->second == NULL) it->second = new (zone_) ObjectLiteral::Accessors();
if (it->second == nullptr) {
it->second = new (zone_) ObjectLiteral::Accessors();
}
return it;
}
@ -1625,7 +1627,7 @@ class Property final : public Expression {
// Returns the properties assign type.
static LhsKind GetAssignType(Property* property) {
if (property == NULL) return VARIABLE;
if (property == nullptr) return VARIABLE;
bool super_access = property->IsSuperAccess();
return (property->key()->IsPropertyName())
? (super_access ? NAMED_SUPER_PROPERTY : NAMED_PROPERTY)
@ -1768,7 +1770,7 @@ class CallNew final : public Expression {
class CallRuntime final : public Expression {
public:
ZoneList<Expression*>* arguments() const { return arguments_; }
bool is_jsruntime() const { return function_ == NULL; }
bool is_jsruntime() const { return function_ == nullptr; }
int context_index() const {
DCHECK(is_jsruntime());
@ -1796,7 +1798,7 @@ class CallRuntime final : public Expression {
CallRuntime(int context_index, ZoneList<Expression*>* arguments, int pos)
: Expression(pos, kCallRuntime),
context_index_(context_index),
function_(NULL),
function_(nullptr),
arguments_(arguments) {}
int context_index_;
@ -2356,7 +2358,7 @@ class FunctionLiteral final : public Expression {
}
Handle<String> debug_name() const {
if (raw_name_ != NULL && !raw_name_->IsEmpty()) {
if (raw_name_ != nullptr && !raw_name_->IsEmpty()) {
return raw_name_->string();
}
return inferred_name();
@ -2364,10 +2366,10 @@ class FunctionLiteral final : public Expression {
Handle<String> inferred_name() const {
if (!inferred_name_.is_null()) {
DCHECK(raw_inferred_name_ == NULL);
DCHECK(raw_inferred_name_ == nullptr);
return inferred_name_;
}
if (raw_inferred_name_ != NULL) {
if (raw_inferred_name_ != nullptr) {
return raw_inferred_name_->string();
}
UNREACHABLE();
@ -2377,12 +2379,12 @@ class FunctionLiteral final : public Expression {
void set_inferred_name(Handle<String> inferred_name) {
DCHECK(!inferred_name.is_null());
inferred_name_ = inferred_name;
DCHECK(raw_inferred_name_== NULL || raw_inferred_name_->IsEmpty());
raw_inferred_name_ = NULL;
DCHECK(raw_inferred_name_ == nullptr || raw_inferred_name_->IsEmpty());
raw_inferred_name_ = nullptr;
}
void set_raw_inferred_name(const AstConsString* raw_inferred_name) {
DCHECK(raw_inferred_name != NULL);
DCHECK(raw_inferred_name != nullptr);
raw_inferred_name_ = raw_inferred_name;
DCHECK(inferred_name_.is_null());
inferred_name_ = Handle<String>();
@ -2829,12 +2831,12 @@ class AstVisitor BASE_EMBEDDED {
void VisitExpressions(ZoneList<Expression*>* expressions) {
for (int i = 0; i < expressions->length(); i++) {
// The variable statement visiting code may pass NULL expressions
// The variable statement visiting code may pass null expressions
// to this code. Maybe this should be handled by introducing an
// undefined expression or literal? Revisit this code if this
// changes
// undefined expression or literal? Revisit this code if this
// changes.
Expression* expression = expressions->at(i);
if (expression != NULL) Visit(expression);
if (expression != nullptr) Visit(expression);
}
}
@ -3450,38 +3452,39 @@ class AstNodeFactory final BASE_EMBEDDED {
// Type testing & conversion functions overridden by concrete subclasses.
// Inline functions for AstNode.
#define DECLARE_NODE_FUNCTIONS(type) \
bool AstNode::Is##type() const { \
NodeType mine = node_type(); \
if (mine == AstNode::kRewritableExpression && \
AstNode::k##type != AstNode::kRewritableExpression) \
mine = reinterpret_cast<const RewritableExpression*>(this) \
->expression() \
->node_type(); \
return mine == AstNode::k##type; \
} \
type* AstNode::As##type() { \
NodeType mine = node_type(); \
AstNode* result = this; \
if (mine == AstNode::kRewritableExpression && \
AstNode::k##type != AstNode::kRewritableExpression) { \
result = \
reinterpret_cast<const RewritableExpression*>(this)->expression(); \
mine = result->node_type(); \
} \
return mine == AstNode::k##type ? reinterpret_cast<type*>(result) : NULL; \
} \
const type* AstNode::As##type() const { \
NodeType mine = node_type(); \
const AstNode* result = this; \
if (mine == AstNode::kRewritableExpression && \
AstNode::k##type != AstNode::kRewritableExpression) { \
result = \
reinterpret_cast<const RewritableExpression*>(this)->expression(); \
mine = result->node_type(); \
} \
return mine == AstNode::k##type ? reinterpret_cast<const type*>(result) \
: NULL; \
#define DECLARE_NODE_FUNCTIONS(type) \
bool AstNode::Is##type() const { \
NodeType mine = node_type(); \
if (mine == AstNode::kRewritableExpression && \
AstNode::k##type != AstNode::kRewritableExpression) \
mine = reinterpret_cast<const RewritableExpression*>(this) \
->expression() \
->node_type(); \
return mine == AstNode::k##type; \
} \
type* AstNode::As##type() { \
NodeType mine = node_type(); \
AstNode* result = this; \
if (mine == AstNode::kRewritableExpression && \
AstNode::k##type != AstNode::kRewritableExpression) { \
result = \
reinterpret_cast<const RewritableExpression*>(this)->expression(); \
mine = result->node_type(); \
} \
return mine == AstNode::k##type ? reinterpret_cast<type*>(result) \
: nullptr; \
} \
const type* AstNode::As##type() const { \
NodeType mine = node_type(); \
const AstNode* result = this; \
if (mine == AstNode::kRewritableExpression && \
AstNode::k##type != AstNode::kRewritableExpression) { \
result = \
reinterpret_cast<const RewritableExpression*>(this)->expression(); \
mine = result->node_type(); \
} \
return mine == AstNode::k##type ? reinterpret_cast<const type*>(result) \
: nullptr; \
}
AST_NODE_LIST(DECLARE_NODE_FUNCTIONS)
#undef DECLARE_NODE_FUNCTIONS

View File

@ -36,8 +36,8 @@ class ContextSlotCache {
private:
ContextSlotCache() {
for (int i = 0; i < kLength; ++i) {
keys_[i].data = NULL;
keys_[i].name = NULL;
keys_[i].data = nullptr;
keys_[i].name = nullptr;
values_[i] = static_cast<uint32_t>(kNotFound);
}
}

View File

@ -146,11 +146,11 @@ void CallPrinter::VisitWhileStatement(WhileStatement* node) {
void CallPrinter::VisitForStatement(ForStatement* node) {
if (node->init() != NULL) {
if (node->init() != nullptr) {
Find(node->init());
}
if (node->cond() != NULL) Find(node->cond());
if (node->next() != NULL) Find(node->next());
if (node->cond() != nullptr) Find(node->cond());
if (node->next() != nullptr) Find(node->next());
Find(node->body());
}
@ -279,7 +279,7 @@ void CallPrinter::VisitThrow(Throw* node) { Find(node->exception()); }
void CallPrinter::VisitProperty(Property* node) {
Expression* key = node->key();
Literal* literal = key->AsLiteral();
if (literal != NULL && literal->value()->IsInternalizedString()) {
if (literal != nullptr && literal->value()->IsInternalizedString()) {
Find(node->obj(), true);
Print(".");
PrintLiteral(literal->value(), false);
@ -442,7 +442,7 @@ void CallPrinter::VisitRewritableExpression(RewritableExpression* node) {
void CallPrinter::FindStatements(ZoneList<Statement*>* statements) {
if (statements == NULL) return;
if (statements == nullptr) return;
for (int i = 0; i < statements->length(); i++) {
Find(statements->at(i));
}
@ -506,7 +506,7 @@ const char* AstPrinter::Print(AstNode* node) {
void AstPrinter::Init() {
if (size_ == 0) {
DCHECK(output_ == NULL);
DCHECK(output_ == nullptr);
const int initial_size = 256;
output_ = NewArray<char>(initial_size);
size_ = initial_size;
@ -542,7 +542,7 @@ void AstPrinter::Print(const char* format, ...) {
}
void AstPrinter::PrintLabels(ZoneList<const AstRawString*>* labels) {
if (labels != NULL) {
if (labels != nullptr) {
for (int i = 0; i < labels->length(); i++) {
PrintLiteral(labels->at(i), false);
Print(": ");
@ -669,7 +669,7 @@ void AstPrinter::PrintLiteralIndented(const char* info,
void AstPrinter::PrintLiteralWithModeIndented(const char* info,
Variable* var,
Handle<Object> value) {
if (var == NULL) {
if (var == nullptr) {
PrintLiteralIndented(info, value, true);
} else {
EmbeddedVector<char, 256> buf;
@ -683,7 +683,7 @@ void AstPrinter::PrintLiteralWithModeIndented(const char* info,
void AstPrinter::PrintLabelsIndented(ZoneList<const AstRawString*>* labels) {
if (labels == NULL || labels->length() == 0) return;
if (labels == nullptr || labels->length() == 0) return;
PrintIndented("LABELS ");
PrintLabels(labels);
Print("\n");
@ -1174,7 +1174,7 @@ void AstPrinter::VisitProperty(Property* node) {
Visit(node->obj());
Literal* literal = node->key()->AsLiteral();
if (literal != NULL && literal->value()->IsInternalizedString()) {
if (literal != nullptr && literal->value()->IsInternalizedString()) {
PrintLiteralIndented("NAME", literal->value(), false);
} else {
PrintIndentedVisit("KEY", node->key());

View File

@ -98,12 +98,12 @@ void VariableMap::Add(Zone* zone, Variable* var) {
Variable* VariableMap::Lookup(const AstRawString* name) {
Entry* p = ZoneHashMap::Lookup(const_cast<AstRawString*>(name), name->Hash());
if (p != NULL) {
if (p != nullptr) {
DCHECK(reinterpret_cast<const AstRawString*>(p->key) == name);
DCHECK(p->value != NULL);
DCHECK(p->value != nullptr);
return reinterpret_cast<Variable*>(p->value);
}
return NULL;
return nullptr;
}
void SloppyBlockFunctionMap::Delegate::set_statement(Statement* statement) {
@ -650,7 +650,7 @@ void DeclarationScope::AttachOuterScopeInfo(ParseInfo* info, Isolate* isolate) {
void DeclarationScope::Analyze(ParseInfo* info) {
RuntimeCallTimerScope runtimeTimer(info->runtime_call_stats(),
&RuntimeCallStats::CompileScopeAnalysis);
DCHECK(info->literal() != NULL);
DCHECK(info->literal() != nullptr);
DeclarationScope* scope = info->literal()->scope();
base::Optional<AllowHandleDereference> allow_deref;
@ -998,13 +998,11 @@ Variable* Scope::LookupInScopeInfo(const AstRawString* name) {
}
Variable* Scope::Lookup(const AstRawString* name) {
for (Scope* scope = this;
scope != NULL;
scope = scope->outer_scope()) {
for (Scope* scope = this; scope != nullptr; scope = scope->outer_scope()) {
Variable* var = scope->LookupLocal(name);
if (var != NULL) return var;
if (var != nullptr) return var;
}
return NULL;
return nullptr;
}
Variable* DeclarationScope::DeclareParameter(
@ -1098,7 +1096,7 @@ Variable* Scope::DeclareVariable(
(IsLexicalVariableMode(mode) && is_block_scope()));
VariableProxy* proxy = declaration->proxy();
DCHECK(proxy->raw_name() != NULL);
DCHECK(proxy->raw_name() != nullptr);
const AstRawString* name = proxy->raw_name();
bool is_function_declaration = declaration->IsFunctionDeclaration();
@ -1125,7 +1123,7 @@ Variable* Scope::DeclareVariable(
} else {
// Declare the variable in the declaration scope.
var = LookupLocal(name);
if (var == NULL) {
if (var == nullptr) {
// Declare the name.
VariableKind kind = NORMAL_VARIABLE;
if (is_function_declaration) {
@ -1391,7 +1389,7 @@ bool DeclarationScope::AllowsLazyCompilation() const {
int Scope::ContextChainLength(Scope* scope) const {
int n = 0;
for (const Scope* s = this; s != scope; s = s->outer_scope_) {
DCHECK(s != NULL); // scope must be in the scope chain
DCHECK(s != nullptr); // scope must be in the scope chain
if (s->NeedsContext()) n++;
}
return n;

View File

@ -173,7 +173,8 @@ class V8_EXPORT_PRIVATE Scope : public NON_EXPORTED_BASE(ZoneObject) {
// ---------------------------------------------------------------------------
// Declarations
// Lookup a variable in this scope. Returns the variable or NULL if not found.
// Lookup a variable in this scope. Returns the variable or nullptr if not
// found.
Variable* LookupLocal(const AstRawString* name) {
Variable* result = variables_.Lookup(name);
if (result != nullptr || scope_info_.is_null()) return result;
@ -183,7 +184,7 @@ class V8_EXPORT_PRIVATE Scope : public NON_EXPORTED_BASE(ZoneObject) {
Variable* LookupInScopeInfo(const AstRawString* name);
// Lookup a variable in this scope or outer scopes.
// Returns the variable or NULL if not found.
// Returns the variable or nullptr if not found.
Variable* Lookup(const AstRawString* name);
// Declare a local variable in this scope. If the variable has been
@ -393,7 +394,7 @@ class V8_EXPORT_PRIVATE Scope : public NON_EXPORTED_BASE(ZoneObject) {
Scope* inner_scope() const { return inner_scope_; }
Scope* sibling() const { return sibling_; }
// The scope immediately surrounding this scope, or NULL.
// The scope immediately surrounding this scope, or nullptr.
Scope* outer_scope() const { return outer_scope_; }
Variable* catch_variable() const {
@ -517,7 +518,7 @@ class V8_EXPORT_PRIVATE Scope : public NON_EXPORTED_BASE(ZoneObject) {
Zone* zone_;
// Scope tree.
Scope* outer_scope_; // the immediately enclosing outer scope, or NULL
Scope* outer_scope_; // the immediately enclosing outer scope, or nullptr
Scope* inner_scope_; // an inner scope of this scope
Scope* sibling_; // a sibling inner scope of the outer scope of this scope.
@ -763,7 +764,7 @@ class V8_EXPORT_PRIVATE DeclarationScope : public Scope {
Variable* new_target_var() { return new_target_; }
// The variable holding the function literal for named function
// literals, or NULL. Only valid for function scopes.
// literals, or nullptr. Only valid for function scopes.
Variable* function_var() const {
DCHECK(is_function_scope());
return function_;
@ -814,7 +815,8 @@ class V8_EXPORT_PRIVATE DeclarationScope : public Scope {
has_simple_parameters_ = false;
}
// The local variable 'arguments' if we need to allocate it; NULL otherwise.
// The local variable 'arguments' if we need to allocate it; nullptr
// otherwise.
Variable* arguments() const {
DCHECK(!is_arrow_scope() || arguments_ == nullptr);
return arguments_;

View File

@ -43,7 +43,7 @@ class Variable final : public ZoneObject {
// The source code for an eval() call may refer to a variable that is
// in an outer scope about which we don't know anything (it may not
// be the script scope). scope() is NULL in that case. Currently the
// be the script scope). scope() is nullptr in that case. Currently the
// scope is only used to follow the context chain length.
Scope* scope() const { return scope_; }
@ -137,7 +137,7 @@ class Variable final : public ZoneObject {
}
Variable* local_if_not_shadowed() const {
DCHECK(mode() == DYNAMIC_LOCAL && local_if_not_shadowed_ != NULL);
DCHECK(mode() == DYNAMIC_LOCAL && local_if_not_shadowed_ != nullptr);
return local_if_not_shadowed_;
}

View File

@ -115,7 +115,7 @@ static uint32_t ReadELFHWCaps() {
#else
// Read the ELF HWCAP flags by parsing /proc/self/auxv.
FILE* fp = fopen("/proc/self/auxv", "r");
if (fp != NULL) {
if (fp != nullptr) {
struct { uint32_t tag; uint32_t value; } entry;
for (;;) {
size_t n = fread(&entry, sizeof(entry), 1, fp);
@ -186,7 +186,7 @@ class CPUInfo final {
// when using fseek(0, SEEK_END) + ftell(). Nor can the 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);
@ -201,7 +201,7 @@ class CPUInfo final {
// Read the contents of the cpuinfo file.
data_ = new char[datalen_ + 1];
fp = fopen(PATHNAME, "r");
if (fp != NULL) {
if (fp != nullptr) {
for (size_t offset = 0; offset < datalen_; ) {
size_t n = fread(data_ + offset, 1, datalen_ - offset, fp);
if (n == 0) {
@ -223,17 +223,17 @@ class CPUInfo final {
// 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 delete[].
// Return NULL if not found.
// Return nullptr if not found.
char* ExtractField(const char* field) const {
DCHECK(field != NULL);
DCHECK(field != nullptr);
// Look for first field occurrence, and ensure it starts the line.
size_t fieldlen = strlen(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;
@ -243,21 +243,21 @@ class CPUInfo final {
// Skip to the first colon followed by a space.
p = strchr(p + fieldlen, ':');
if (p == NULL || !isspace(p[1])) {
return NULL;
if (p == nullptr || !isspace(p[1])) {
return nullptr;
}
p += 2;
// Find the end of the line.
char* q = strchr(p, '\n');
if (q == NULL) {
if (q == nullptr) {
q = data_ + datalen_;
}
// Copy the line into a heap-allocated buffer.
size_t len = q - p;
char* result = new char[len + 1];
if (result != NULL) {
if (result != nullptr) {
memcpy(result, p, len);
result[len] = '\0';
}
@ -273,7 +273,7 @@ class CPUInfo final {
static bool HasListItem(const char* list, const char* item) {
ssize_t item_len = strlen(item);
const char* p = list;
if (p != NULL) {
if (p != nullptr) {
while (*p != '\0') {
// Skip whitespace.
while (isspace(*p)) ++p;
@ -427,7 +427,7 @@ CPU::CPU()
// Extract implementor from the "CPU implementer" field.
char* implementer = cpu_info.ExtractField("CPU implementer");
if (implementer != NULL) {
if (implementer != nullptr) {
char* end;
implementer_ = strtol(implementer, &end, 0);
if (end == implementer) {
@ -437,7 +437,7 @@ CPU::CPU()
}
char* variant = cpu_info.ExtractField("CPU variant");
if (variant != NULL) {
if (variant != nullptr) {
char* end;
variant_ = strtol(variant, &end, 0);
if (end == variant) {
@ -448,7 +448,7 @@ CPU::CPU()
// Extract part number from the "CPU part" field.
char* part = cpu_info.ExtractField("CPU part");
if (part != NULL) {
if (part != nullptr) {
char* end;
part_ = strtol(part, &end, 0);
if (end == part) {
@ -464,7 +464,7 @@ CPU::CPU()
// $KERNEL/arch/arm/kernel/setup.c and the 'c_show' function in
// same file.
char* architecture = cpu_info.ExtractField("CPU architecture");
if (architecture != NULL) {
if (architecture != nullptr) {
char* end;
architecture_ = strtol(architecture, &end, 10);
if (end == architecture) {
@ -608,9 +608,9 @@ CPU::CPU()
#ifndef USE_SIMULATOR
#if V8_OS_LINUX
// Read processor info from /proc/self/auxv.
char* auxv_cpu_type = NULL;
char* auxv_cpu_type = nullptr;
FILE* fp = fopen("/proc/self/auxv", "r");
if (fp != NULL) {
if (fp != nullptr) {
#if V8_TARGET_ARCH_PPC64
Elf64_auxv_t entry;
#else

View File

@ -26,7 +26,7 @@ StackTrace::~StackTrace() {}
const void* const* StackTrace::Addresses(size_t* count) const {
*count = count_;
if (count_) return trace_;
return NULL;
return nullptr;
}
std::string StackTrace::ToString() const {

View File

@ -63,7 +63,7 @@ bool EnableInProcessStackDumping() {
memset(&action, 0, sizeof(action));
action.sa_handler = SIG_IGN;
sigemptyset(&action.sa_mask);
return (sigaction(SIGPIPE, &action, NULL) == 0);
return (sigaction(SIGPIPE, &action, nullptr) == 0);
}
void DisableSignalStackDump() {

View File

@ -51,8 +51,8 @@ namespace internal {
// POSIX doesn't define any async-signal safe function for converting
// an integer to ASCII. We'll have to define our own version.
// itoa_r() converts a (signed) integer to ASCII. It returns "buf", if the
// conversion was successful or NULL otherwise. It never writes more than "sz"
// bytes. Output will be truncated as needed, and a NUL character is always
// conversion was successful or nullptr otherwise. It never writes more than
// "sz" bytes. Output will be truncated as needed, and a NUL character is always
// appended.
char* itoa_r(intptr_t i, char* buf, size_t sz, int base, size_t padding);
@ -104,7 +104,7 @@ void DemangleSymbols(std::string* text) {
// Try to demangle the mangled symbol candidate.
int status = 0;
std::unique_ptr<char, FreeDeleter> demangled_symbol(
abi::__cxa_demangle(mangled_symbol.c_str(), NULL, 0, &status));
abi::__cxa_demangle(mangled_symbol.c_str(), nullptr, 0, &status));
if (status == 0) { // Demangling is successful.
// Remove the mangled symbol.
text->erase(mangled_start, mangled_end - mangled_start);
@ -334,7 +334,7 @@ bool EnableInProcessStackDumping() {
memset(&sigpipe_action, 0, sizeof(sigpipe_action));
sigpipe_action.sa_handler = SIG_IGN;
sigemptyset(&sigpipe_action.sa_mask);
bool success = (sigaction(SIGPIPE, &sigpipe_action, NULL) == 0);
bool success = (sigaction(SIGPIPE, &sigpipe_action, nullptr) == 0);
// Avoid hangs during backtrace initialization, see above.
WarmUpBacktrace();
@ -345,12 +345,12 @@ bool EnableInProcessStackDumping() {
action.sa_sigaction = &StackDumpSignalHandler;
sigemptyset(&action.sa_mask);
success &= (sigaction(SIGILL, &action, NULL) == 0);
success &= (sigaction(SIGABRT, &action, NULL) == 0);
success &= (sigaction(SIGFPE, &action, NULL) == 0);
success &= (sigaction(SIGBUS, &action, NULL) == 0);
success &= (sigaction(SIGSEGV, &action, NULL) == 0);
success &= (sigaction(SIGSYS, &action, NULL) == 0);
success &= (sigaction(SIGILL, &action, nullptr) == 0);
success &= (sigaction(SIGABRT, &action, nullptr) == 0);
success &= (sigaction(SIGFPE, &action, nullptr) == 0);
success &= (sigaction(SIGBUS, &action, nullptr) == 0);
success &= (sigaction(SIGSEGV, &action, nullptr) == 0);
success &= (sigaction(SIGSYS, &action, nullptr) == 0);
dump_stack_in_signal_handler = true;
@ -397,11 +397,11 @@ namespace internal {
char* itoa_r(intptr_t i, char* buf, size_t sz, int base, size_t padding) {
// Make sure we can write at least one NUL byte.
size_t n = 1;
if (n > sz) return NULL;
if (n > sz) return nullptr;
if (base < 2 || base > 16) {
buf[0] = '\000';
return NULL;
return nullptr;
}
char* start = buf;
@ -416,7 +416,7 @@ char* itoa_r(intptr_t i, char* buf, size_t sz, int base, size_t padding) {
// Make sure we can write the '-' character.
if (++n > sz) {
buf[0] = '\000';
return NULL;
return nullptr;
}
*start++ = '-';
}
@ -428,7 +428,7 @@ char* itoa_r(intptr_t i, char* buf, size_t sz, int base, size_t padding) {
// Make sure there is still enough space left in our output buffer.
if (++n > sz) {
buf[0] = '\000';
return NULL;
return nullptr;
}
// Output the next digit.

View File

@ -24,9 +24,9 @@ namespace debug {
namespace {
// Previous unhandled filter. Will be called if not NULL when we intercept an
// Previous unhandled filter. Will be called if not nullptr when we intercept an
// exception. Only used in unit tests.
LPTOP_LEVEL_EXCEPTION_FILTER g_previous_filter = NULL;
LPTOP_LEVEL_EXCEPTION_FILTER g_previous_filter = nullptr;
bool g_dump_stack_in_signal_handler = true;
bool g_initialized_symbols = false;
@ -43,7 +43,7 @@ long WINAPI StackDumpExceptionFilter(EXCEPTION_POINTERS* info) { // NOLINT
}
void GetExePath(wchar_t* path_out) {
GetModuleFileName(NULL, path_out, MAX_PATH);
GetModuleFileName(nullptr, path_out, MAX_PATH);
path_out[MAX_PATH - 1] = L'\0';
PathRemoveFileSpec(path_out);
}
@ -54,7 +54,7 @@ bool InitializeSymbols() {
// Defer symbol load until they're needed, use undecorated names, and get line
// numbers.
SymSetOptions(SYMOPT_DEFERRED_LOADS | SYMOPT_UNDNAME | SYMOPT_LOAD_LINES);
if (!SymInitialize(GetCurrentProcess(), NULL, TRUE)) {
if (!SymInitialize(GetCurrentProcess(), nullptr, TRUE)) {
g_init_error = GetLastError();
// TODO(awong): Handle error: SymInitialize can fail with
// ERROR_INVALID_PARAMETER.
@ -174,7 +174,7 @@ void DisableSignalStackDump() {
StackTrace::StackTrace() {
// When walking our own stack, use CaptureStackBackTrace().
count_ = CaptureStackBackTrace(0, arraysize(trace_), trace_, NULL);
count_ = CaptureStackBackTrace(0, arraysize(trace_), trace_, nullptr);
}
#if defined(V8_CC_MSVC)
@ -216,13 +216,13 @@ void StackTrace::InitTrace(const CONTEXT* context_record) {
stack_frame.AddrFrame.Mode = AddrModeFlat;
stack_frame.AddrStack.Mode = AddrModeFlat;
while (StackWalk64(machine_type, GetCurrentProcess(), GetCurrentThread(),
&stack_frame, &context_copy, NULL,
&SymFunctionTableAccess64, &SymGetModuleBase64, NULL) &&
&stack_frame, &context_copy, nullptr,
&SymFunctionTableAccess64, &SymGetModuleBase64, nullptr) &&
count_ < arraysize(trace_)) {
trace_[count_++] = reinterpret_cast<void*>(stack_frame.AddrPC.Offset);
}
for (size_t i = count_; i < arraysize(trace_); ++i) trace_[i] = NULL;
for (size_t i = count_; i < arraysize(trace_); ++i) trace_[i] = nullptr;
}
void StackTrace::Print() const { OutputToStream(&std::cerr); }

View File

@ -85,7 +85,8 @@ V8_BASE_EXPORT void CallOnceImpl(OnceType* once, PointerArgFunction init_func,
inline void CallOnce(OnceType* once, NoArgFunction init_func) {
if (Acquire_Load(once) != ONCE_STATE_DONE) {
CallOnceImpl(once, reinterpret_cast<PointerArgFunction>(init_func), NULL);
CallOnceImpl(once, reinterpret_cast<PointerArgFunction>(init_func),
nullptr);
}
}

View File

@ -28,7 +28,7 @@ ConditionVariable::ConditionVariable() {
DCHECK_EQ(0, result);
result = pthread_condattr_destroy(&attr);
#else
int result = pthread_cond_init(&native_handle_, NULL);
int result = pthread_cond_init(&native_handle_, nullptr);
#endif
DCHECK_EQ(0, result);
USE(result);

View File

@ -25,7 +25,7 @@ static V8_INLINE void InitializeNativeHandle(pthread_mutex_t* mutex) {
result = pthread_mutexattr_destroy(&attr);
#else
// Use a fast mutex (default attributes).
result = pthread_mutex_init(mutex, NULL);
result = pthread_mutex_init(mutex, nullptr);
#endif // defined(DEBUG)
DCHECK_EQ(0, result);
USE(result);

View File

@ -49,17 +49,17 @@ const char* AIXTimezoneCache::LocalTimezone(double time) {
time_t tv = static_cast<time_t>(floor(time / msPerSecond));
struct tm tm;
struct tm* t = localtime_r(&tv, &tm);
if (NULL == t) return "";
if (nullptr == t) return "";
return tzname[0]; // The location of the timezone string on AIX.
}
double AIXTimezoneCache::LocalTimeOffset() {
// On AIX, struct tm does not contain a tm_gmtoff field.
time_t utc = time(NULL);
time_t utc = time(nullptr);
DCHECK(utc != -1);
struct tm tm;
struct tm* loc = localtime_r(&utc, &tm);
DCHECK(loc != NULL);
DCHECK(loc != nullptr);
return static_cast<double>((mktime(loc) - utc) * msPerSecond);
}
@ -76,7 +76,7 @@ void* OS::Allocate(const size_t requested, size_t* allocated,
void* mbase = mmap(hint, msize, prot, MAP_PRIVATE | MAP_ANONYMOUS, kMmapFd,
kMmapFdOffset);
if (mbase == MAP_FAILED) return NULL;
if (mbase == MAP_FAILED) return nullptr;
*allocated = msize;
return mbase;
}
@ -161,7 +161,7 @@ bool OS::ReleasePartialRegion(void* address, size_t size) {
bool OS::HasLazyCommits() { return true; }
static unsigned StringToLong(char* buffer) {
return static_cast<unsigned>(strtol(buffer, NULL, 16)); // NOLINT
return static_cast<unsigned>(strtol(buffer, nullptr, 16)); // NOLINT
}
std::vector<OS::SharedLibraryAddress> OS::GetSharedLibraryAddresses() {
@ -196,7 +196,7 @@ std::vector<OS::SharedLibraryAddress> OS::GetSharedLibraryAddresses() {
if (buffer[3] != 'x') continue;
char* start_of_path = index(buffer, '/');
// There may be no filename in this line. Skip to next.
if (start_of_path == NULL) continue;
if (start_of_path == nullptr) continue;
buffer[bytes_read] = 0;
result.push_back(SharedLibraryAddress(start_of_path, start, end));
}

View File

@ -36,7 +36,7 @@ namespace {
static void* RandomizedVirtualAlloc(size_t size, int action, int protection,
void* hint) {
LPVOID base = NULL;
LPVOID base = nullptr;
if (protection == PAGE_EXECUTE_READWRITE || protection == PAGE_NOACCESS) {
// For exectutable pages try and randomize the allocation address
@ -44,7 +44,7 @@ static void* RandomizedVirtualAlloc(size_t size, int action, int protection,
}
// After three attempts give up and let the OS find an address to use.
if (base == NULL) base = VirtualAlloc(NULL, size, action, protection);
if (base == nullptr) base = VirtualAlloc(nullptr, size, action, protection);
return base;
}
@ -64,17 +64,17 @@ const char* CygwinTimezoneCache::LocalTimezone(double time) {
time_t tv = static_cast<time_t>(std::floor(time/msPerSecond));
struct tm tm;
struct tm* t = localtime_r(&tv, &tm);
if (NULL == t) return "";
if (nullptr == t) return "";
return tzname[0]; // The location of the timezone string on Cygwin.
}
double CygwinTimezoneCache::LocalTimeOffset() {
// On Cygwin, struct tm does not contain a tm_gmtoff field.
time_t utc = time(NULL);
time_t utc = time(nullptr);
DCHECK(utc != -1);
struct tm tm;
struct tm* loc = localtime_r(&utc, &tm);
DCHECK(loc != NULL);
DCHECK(loc != nullptr);
// time - localtime includes any daylight savings offset, so subtract it.
return static_cast<double>((mktime(loc) - utc) * msPerSecond -
(loc->tm_isdst > 0 ? 3600 * msPerSecond : 0));
@ -84,8 +84,8 @@ void* OS::Allocate(const size_t requested, size_t* allocated,
OS::MemoryPermission access, void* hint) {
const size_t msize = RoundUp(requested, sysconf(_SC_PAGESIZE));
int prot = GetProtectionFromMemoryPermission(access);
void* mbase = mmap(NULL, msize, prot, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
if (mbase == MAP_FAILED) return NULL;
void* mbase = mmap(nullptr, msize, prot, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
if (mbase == MAP_FAILED) return nullptr;
*allocated = msize;
return mbase;
}
@ -103,7 +103,7 @@ void* OS::ReserveAlignedRegion(size_t size, size_t alignment, void* hint,
size_t request_size =
RoundUp(size + alignment, static_cast<intptr_t>(OS::AllocateAlignment()));
void* address = ReserveRegion(request_size, hint);
if (address == NULL) {
if (address == nullptr) {
*allocated = 0;
return nullptr;
}
@ -132,7 +132,7 @@ void* OS::ReserveAlignedRegion(size_t size, size_t alignment, void* hint,
// static
bool OS::CommitRegion(void* address, size_t size, bool is_executable) {
int prot = is_executable ? PAGE_EXECUTE_READWRITE : PAGE_READWRITE;
if (NULL == VirtualAlloc(address, size, MEM_COMMIT, prot)) {
if (nullptr == VirtualAlloc(address, size, MEM_COMMIT, prot)) {
return false;
}
return true;
@ -165,7 +165,7 @@ std::vector<OS::SharedLibraryAddress> OS::GetSharedLibraryAddresses() {
// hex_start_addr-hex_end_addr rwxp <unused data> [binary_file_name]
// If we encounter an unexpected situation we abort scanning further entries.
FILE* fp = fopen("/proc/self/maps", "r");
if (fp == NULL) return result;
if (fp == nullptr) return result;
// Allocate enough room to be able to store a full file name.
const int kLibNameLen = FILENAME_MAX + 1;
@ -193,7 +193,7 @@ std::vector<OS::SharedLibraryAddress> OS::GetSharedLibraryAddresses() {
ungetc(c, fp); // Push the '/' back into the stream to be read below.
// Read to the end of the line. Exit if the read fails.
if (fgets(lib_name, kLibNameLen, fp) == NULL) break;
if (fgets(lib_name, kLibNameLen, fp) == nullptr) break;
// Drop the newline character read by fgets. We do not need to check
// for a zero-length string because we know that we at least read the

View File

@ -51,7 +51,7 @@ void* OS::Allocate(const size_t requested, size_t* allocated,
void* mbase =
mmap(hint, msize, prot, MAP_PRIVATE | MAP_ANON, kMmapFd, kMmapFdOffset);
if (mbase == MAP_FAILED) return NULL;
if (mbase == MAP_FAILED) return nullptr;
*allocated = msize;
return mbase;
}
@ -61,7 +61,7 @@ void* OS::ReserveRegion(size_t size, void* hint) {
void* result = mmap(hint, size, PROT_NONE, MAP_PRIVATE | MAP_ANON, kMmapFd,
kMmapFdOffset);
if (result == MAP_FAILED) return NULL;
if (result == MAP_FAILED) return nullptr;
return result;
}
@ -139,7 +139,7 @@ bool OS::HasLazyCommits() {
}
static unsigned StringToLong(char* buffer) {
return static_cast<unsigned>(strtol(buffer, NULL, 16)); // NOLINT
return static_cast<unsigned>(strtol(buffer, nullptr, 16)); // NOLINT
}
std::vector<OS::SharedLibraryAddress> OS::GetSharedLibraryAddresses() {
@ -174,7 +174,7 @@ std::vector<OS::SharedLibraryAddress> OS::GetSharedLibraryAddresses() {
if (buffer[3] != 'x') continue;
char* start_of_path = index(buffer, '/');
// There may be no filename in this line. Skip to next.
if (start_of_path == NULL) continue;
if (start_of_path == nullptr) continue;
buffer[bytes_read] = 0;
result.push_back(SharedLibraryAddress(start_of_path, start, end));
}

View File

@ -195,7 +195,7 @@ std::vector<OS::SharedLibraryAddress> OS::GetSharedLibraryAddresses() {
// hex_start_addr-hex_end_addr rwxp <unused data> [binary_file_name]
// If we encounter an unexpected situation we abort scanning further entries.
FILE* fp = fopen("/proc/self/maps", "r");
if (fp == NULL) return result;
if (fp == nullptr) return result;
// Allocate enough room to be able to store a full file name.
const int kLibNameLen = FILENAME_MAX + 1;
@ -224,7 +224,7 @@ std::vector<OS::SharedLibraryAddress> OS::GetSharedLibraryAddresses() {
ungetc(c, fp);
// Read to the end of the line. Exit if the read fails.
if (fgets(lib_name, kLibNameLen, fp) == NULL) break;
if (fgets(lib_name, kLibNameLen, fp) == nullptr) break;
// Drop the newline character read by fgets. We do not need to check
// for a zero-length string because we know that we at least read the
@ -261,7 +261,7 @@ void OS::SignalCodeMovingGC(void* hint) {
// kernel log.
long size = sysconf(_SC_PAGESIZE); // NOLINT(runtime/int)
FILE* f = fopen(OS::GetGCFakeMMapFile(), "w+");
if (f == NULL) {
if (f == nullptr) {
OS::PrintError("Failed to open %s\n", OS::GetGCFakeMMapFile());
OS::Abort();
}

View File

@ -58,7 +58,7 @@ void* OS::Allocate(const size_t requested, size_t* allocated,
int prot = GetProtectionFromMemoryPermission(access);
void* mbase =
mmap(hint, msize, prot, MAP_PRIVATE | MAP_ANON, kMmapFd, kMmapFdOffset);
if (mbase == MAP_FAILED) return NULL;
if (mbase == MAP_FAILED) return nullptr;
*allocated = msize;
return mbase;
}
@ -155,7 +155,7 @@ std::vector<OS::SharedLibraryAddress> OS::GetSharedLibraryAddresses() {
unsigned int images_count = _dyld_image_count();
for (unsigned int i = 0; i < images_count; ++i) {
const mach_header* header = _dyld_get_image_header(i);
if (header == NULL) continue;
if (header == nullptr) continue;
#if V8_HOST_ARCH_X64
uint64_t size;
char* code_ptr = getsectdatafromheader_64(
@ -165,7 +165,7 @@ std::vector<OS::SharedLibraryAddress> OS::GetSharedLibraryAddresses() {
unsigned int size;
char* code_ptr = getsectdatafromheader(header, SEG_TEXT, SECT_TEXT, &size);
#endif
if (code_ptr == NULL) continue;
if (code_ptr == nullptr) continue;
const intptr_t slide = _dyld_get_image_vmaddr_slide(i);
const uintptr_t start = reinterpret_cast<uintptr_t>(code_ptr) + slide;
result.push_back(SharedLibraryAddress(_dyld_get_image_name(i), start,

View File

@ -48,7 +48,7 @@ void* OS::Allocate(const size_t requested, size_t* allocated,
int prot = GetProtectionFromMemoryPermission(access);
void* mbase =
mmap(hint, msize, prot, MAP_PRIVATE | MAP_ANON, kMmapFd, kMmapFdOffset);
if (mbase == MAP_FAILED) return NULL;
if (mbase == MAP_FAILED) return nullptr;
*allocated = msize;
return mbase;
}
@ -59,7 +59,7 @@ void* OS::ReserveRegion(size_t size, void* hint) {
mmap(hint, size, PROT_NONE, MAP_PRIVATE | MAP_ANON | MAP_NORESERVE,
kMmapFd, kMmapFdOffset);
if (result == MAP_FAILED) return NULL;
if (result == MAP_FAILED) return nullptr;
return result;
}
@ -143,7 +143,7 @@ std::vector<OS::SharedLibraryAddress> OS::GetSharedLibraryAddresses() {
// hex_start_addr-hex_end_addr rwxp <unused data> [binary_file_name]
// If we encounter an unexpected situation we abort scanning further entries.
FILE* fp = fopen("/proc/self/maps", "r");
if (fp == NULL) return result;
if (fp == nullptr) return result;
// Allocate enough room to be able to store a full file name.
const int kLibNameLen = FILENAME_MAX + 1;
@ -171,7 +171,7 @@ std::vector<OS::SharedLibraryAddress> OS::GetSharedLibraryAddresses() {
ungetc(c, fp); // Push the '/' back into the stream to be read below.
// Read to the end of the line. Exit if the read fails.
if (fgets(lib_name, kLibNameLen, fp) == NULL) break;
if (fgets(lib_name, kLibNameLen, fp) == nullptr) break;
// Drop the newline character read by fgets. We do not need to check
// for a zero-length string because we know that we at least read the
@ -208,7 +208,7 @@ void OS::SignalCodeMovingGC(void* hint) {
// kernel log.
int size = sysconf(_SC_PAGESIZE);
FILE* f = fopen(OS::GetGCFakeMMapFile(), "w+");
if (f == NULL) {
if (f == nullptr) {
OS::PrintError("Failed to open %s\n", OS::GetGCFakeMMapFile());
OS::Abort();
}

View File

@ -19,7 +19,7 @@ const char* PosixDefaultTimezoneCache::LocalTimezone(double time) {
}
double PosixDefaultTimezoneCache::LocalTimeOffset() {
time_t tv = time(NULL);
time_t tv = time(nullptr);
struct tm tm;
struct tm* t = localtime_r(&tv, &tm);
// tm_gmtoff includes any daylight savings offset, so subtract it.

View File

@ -71,7 +71,7 @@ const pthread_t kNoThread = (pthread_t) 0;
bool g_hard_abort = false;
const char* g_gc_fake_mmap = NULL;
const char* g_gc_fake_mmap = nullptr;
} // namespace
@ -309,7 +309,7 @@ double PosixTimezoneCache::DaylightSavingsOffset(double time) {
time_t tv = static_cast<time_t>(std::floor(time/msPerSecond));
struct tm tm;
struct tm* t = localtime_r(&tv, &tm);
if (NULL == t) return std::numeric_limits<double>::quiet_NaN();
if (nullptr == t) return std::numeric_limits<double>::quiet_NaN();
return t->tm_isdst > 0 ? 3600 * msPerSecond : 0;
}
@ -325,16 +325,16 @@ int OS::GetLastError() {
FILE* OS::FOpen(const char* path, const char* mode) {
FILE* file = fopen(path, mode);
if (file == NULL) return NULL;
if (file == nullptr) return nullptr;
struct stat file_stat;
if (fstat(fileno(file), &file_stat) != 0) {
fclose(file);
return NULL;
return nullptr;
}
bool is_regular_file = ((file_stat.st_mode & S_IFREG) != 0);
if (is_regular_file) return file;
fclose(file);
return NULL;
return nullptr;
}
@ -462,7 +462,7 @@ class Thread::PlatformData {
Thread::Thread(const Options& options)
: data_(new PlatformData),
stack_size_(options.stack_size()),
start_semaphore_(NULL) {
start_semaphore_(nullptr) {
if (stack_size_ > 0 && static_cast<size_t>(stack_size_) < PTHREAD_STACK_MIN) {
stack_size_ = PTHREAD_STACK_MIN;
}
@ -487,8 +487,7 @@ static void SetThreadName(const char* name) {
int (*dynamic_pthread_setname_np)(const char*);
*reinterpret_cast<void**>(&dynamic_pthread_setname_np) =
dlsym(RTLD_DEFAULT, "pthread_setname_np");
if (dynamic_pthread_setname_np == NULL)
return;
if (dynamic_pthread_setname_np == nullptr) return;
// Mac OS X does not expose the length limit of the name, so hardcode it.
static const int kMaxNameLength = 63;
@ -511,7 +510,7 @@ static void* ThreadEntry(void* arg) {
SetThreadName(thread->name());
DCHECK(thread->data()->thread_ != kNoThread);
thread->NotifyStartedAndRun();
return NULL;
return nullptr;
}
@ -552,11 +551,7 @@ void Thread::Start() {
USE(result);
}
void Thread::Join() {
pthread_join(data_->thread_, NULL);
}
void Thread::Join() { pthread_join(data_->thread_, nullptr); }
static Thread::LocalStorageKey PthreadKeyToLocalKey(pthread_key_t pthread_key) {
#if V8_OS_CYGWIN
@ -595,7 +590,7 @@ static void InitializeTlsBaseOffset() {
char buffer[kBufferSize];
size_t buffer_size = kBufferSize;
int ctl_name[] = { CTL_KERN , KERN_OSRELEASE };
if (sysctl(ctl_name, 2, buffer, &buffer_size, NULL, 0) != 0) {
if (sysctl(ctl_name, 2, buffer, &buffer_size, nullptr, 0) != 0) {
V8_Fatal(__FILE__, __LINE__, "V8 failed to get kernel version");
}
// The buffer now contains a string of the form XX.YY.ZZ, where
@ -605,7 +600,7 @@ static void InitializeTlsBaseOffset() {
char* period_pos = strchr(buffer, '.');
*period_pos = '\0';
int kernel_version_major =
static_cast<int>(strtol(buffer, NULL, 10)); // NOLINT
static_cast<int>(strtol(buffer, nullptr, 10)); // NOLINT
// The constants below are taken from pthreads.s from the XNU kernel
// sources archive at www.opensource.apple.com.
if (kernel_version_major < 11) {
@ -633,7 +628,7 @@ static void CheckFastTls(Thread::LocalStorageKey key) {
V8_Fatal(__FILE__, __LINE__,
"V8 failed to initialize fast TLS on current kernel");
}
Thread::SetThreadLocal(key, NULL);
Thread::SetThreadLocal(key, nullptr);
}
#endif // V8_FAST_TLS_SUPPORTED
@ -648,7 +643,7 @@ Thread::LocalStorageKey Thread::CreateThreadLocalKey() {
}
#endif
pthread_key_t key;
int result = pthread_key_create(&key, NULL);
int result = pthread_key_create(&key, nullptr);
DCHECK_EQ(0, result);
USE(result);
LocalStorageKey local_key = PthreadKeyToLocalKey(key);

View File

@ -99,7 +99,7 @@ void* OS::Allocate(const size_t requested, size_t* allocated,
int prot = GetProtectionFromMemoryPermission(access);
void* mbase = mmap(hint, msize, prot, MAP_PRIVATE | MAP_ANONYMOUS, kMmapFd,
kMmapFdOffset);
if (mbase == MAP_FAILED) return NULL;
if (mbase == MAP_FAILED) return nullptr;
*allocated = msize;
return mbase;
}
@ -110,7 +110,7 @@ void* OS::ReserveRegion(size_t size, void* hint) {
mmap(hint, size, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_LAZY,
kMmapFd, kMmapFdOffset);
if (result == MAP_FAILED) return NULL;
if (result == MAP_FAILED) return nullptr;
return result;
}
@ -188,7 +188,7 @@ bool OS::HasLazyCommits() { return false; }
std::vector<OS::SharedLibraryAddress> OS::GetSharedLibraryAddresses() {
std::vector<SharedLibraryAddress> result;
procfs_mapinfo *mapinfos = NULL, *mapinfo;
procfs_mapinfo *mapinfos = nullptr, *mapinfo;
int proc_fd, num, i;
struct {
@ -205,14 +205,14 @@ std::vector<OS::SharedLibraryAddress> OS::GetSharedLibraryAddresses() {
}
/* Get the number of map entries. */
if (devctl(proc_fd, DCMD_PROC_MAPINFO, NULL, 0, &num) != EOK) {
if (devctl(proc_fd, DCMD_PROC_MAPINFO, nullptr, 0, &num) != EOK) {
close(proc_fd);
return result;
}
mapinfos =
reinterpret_cast<procfs_mapinfo*>(malloc(num * sizeof(procfs_mapinfo)));
if (mapinfos == NULL) {
if (mapinfos == nullptr) {
close(proc_fd);
return result;
}

View File

@ -47,7 +47,7 @@ const char* SolarisTimezoneCache::LocalTimezone(double time) {
time_t tv = static_cast<time_t>(std::floor(time/msPerSecond));
struct tm tm;
struct tm* t = localtime_r(&tv, &tm);
if (NULL == t) return "";
if (nullptr == t) return "";
return tzname[0]; // The location of the timezone string on Solaris.
}
@ -69,7 +69,7 @@ void* OS::Allocate(const size_t requested, size_t* allocated,
void* mbase =
mmap(hint, msize, prot, MAP_PRIVATE | MAP_ANON, kMmapFd, kMmapFdOffset);
if (mbase == MAP_FAILED) return NULL;
if (mbase == MAP_FAILED) return nullptr;
*allocated = msize;
return mbase;
}
@ -80,7 +80,7 @@ void* OS::ReserveRegion(size_t size, void* hint) {
mmap(hint, size, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE,
kMmapFd, kMmapFdOffset);
if (result == MAP_FAILED) return NULL;
if (result == MAP_FAILED) return nullptr;
return result;
}

View File

@ -160,12 +160,12 @@ class V8_BASE_EXPORT OS {
enum class MemoryPermission { kNoAccess, kReadWrite, kReadWriteExecute };
// Allocate/Free memory used by JS heap. Permissions are set according to the
// is_* flags. Returns the address of allocated memory, or NULL if failed.
// is_* flags. Returns the address of allocated memory, or nullptr if failed.
static void* Allocate(const size_t requested, size_t* allocated,
MemoryPermission access, void* hint = nullptr);
// Allocate/Free memory used by JS heap. Pages are readable/writable, but
// they are not guaranteed to be executable unless 'executable' is true.
// Returns the address of allocated memory, or NULL if failed.
// Returns the address of allocated memory, or nullptr if failed.
static void* Allocate(const size_t requested, size_t* allocated,
bool is_executable, void* hint = nullptr);
static void Free(void* address, const size_t size);
@ -335,7 +335,7 @@ class V8_BASE_EXPORT Thread {
Start();
start_semaphore_->Wait();
delete start_semaphore_;
start_semaphore_ = NULL;
start_semaphore_ = nullptr;
}
// Wait until thread terminates.
@ -360,7 +360,7 @@ class V8_BASE_EXPORT Thread {
SetThreadLocal(key, reinterpret_cast<void*>(static_cast<intptr_t>(value)));
}
static bool HasThreadLocal(LocalStorageKey key) {
return GetThreadLocal(key) != NULL;
return GetThreadLocal(key) != nullptr;
}
#ifdef V8_FAST_TLS_SUPPORTED

View File

@ -136,8 +136,8 @@ bool Semaphore::WaitFor(const TimeDelta& rel_time) {
Semaphore::Semaphore(int count) {
DCHECK(count >= 0);
native_handle_ = ::CreateSemaphoreA(NULL, count, 0x7fffffff, NULL);
DCHECK(native_handle_ != NULL);
native_handle_ = ::CreateSemaphoreA(nullptr, count, 0x7fffffff, nullptr);
DCHECK(native_handle_ != nullptr);
}

View File

@ -338,7 +338,7 @@ FILETIME Time::ToFiletime() const {
Time Time::Now() {
struct timeval tv;
int result = gettimeofday(&tv, NULL);
int result = gettimeofday(&tv, nullptr);
DCHECK_EQ(0, result);
USE(result);
return FromTimeval(tv);

View File

@ -280,7 +280,7 @@ class TimeBase {
class V8_BASE_EXPORT Time final : public time_internal::TimeBase<Time> {
public:
// Contains the NULL time. Use Time::Now() to get the current time.
// Contains the nullptr time. Use Time::Now() to get the current time.
Time() : TimeBase(0) {}
// Returns the current time. Watch out, the system might adjust its clock

View File

@ -33,7 +33,7 @@ int SysInfo::NumberOfProcessors() {
int mib[2] = {CTL_HW, HW_NCPU};
int ncpu = 0;
size_t len = sizeof(ncpu);
if (sysctl(mib, arraysize(mib), &ncpu, &len, NULL, 0) != 0) {
if (sysctl(mib, arraysize(mib), &ncpu, &len, nullptr, 0) != 0) {
return 1;
}
return ncpu;
@ -57,15 +57,15 @@ int64_t SysInfo::AmountOfPhysicalMemory() {
int mib[2] = {CTL_HW, HW_MEMSIZE};
int64_t memsize = 0;
size_t len = sizeof(memsize);
if (sysctl(mib, arraysize(mib), &memsize, &len, NULL, 0) != 0) {
if (sysctl(mib, arraysize(mib), &memsize, &len, nullptr, 0) != 0) {
return 0;
}
return memsize;
#elif V8_OS_FREEBSD
int pages, page_size;
size_t size = sizeof(pages);
sysctlbyname("vm.stats.vm.v_page_count", &pages, &size, NULL, 0);
sysctlbyname("vm.stats.vm.v_page_size", &page_size, &size, NULL, 0);
sysctlbyname("vm.stats.vm.v_page_count", &pages, &size, nullptr, 0);
sysctlbyname("vm.stats.vm.v_page_size", &page_size, &size, nullptr, 0);
if (pages == -1 || page_size == -1) {
return 0;
}

View File

@ -18,8 +18,7 @@ namespace v8 {
namespace base {
static LazyMutex entropy_mutex = LAZY_MUTEX_INITIALIZER;
static RandomNumberGenerator::EntropySource entropy_source = NULL;
static RandomNumberGenerator::EntropySource entropy_source = nullptr;
// static
void RandomNumberGenerator::SetEntropySource(EntropySource source) {
@ -31,7 +30,7 @@ void RandomNumberGenerator::SetEntropySource(EntropySource source) {
RandomNumberGenerator::RandomNumberGenerator() {
// Check if embedder supplied an entropy source.
{ LockGuard<Mutex> lock_guard(entropy_mutex.Pointer());
if (entropy_source != NULL) {
if (entropy_source != nullptr) {
int64_t seed;
if (entropy_source(reinterpret_cast<unsigned char*>(&seed),
sizeof(seed))) {
@ -53,7 +52,7 @@ RandomNumberGenerator::RandomNumberGenerator() {
#else
// Gather entropy from /dev/urandom if available.
FILE* fp = fopen("/dev/urandom", "rb");
if (fp != NULL) {
if (fp != nullptr) {
int64_t seed;
size_t n = fread(&seed, sizeof(seed), 1, fp);
fclose(fp);

View File

@ -31,7 +31,7 @@ namespace v8 {
namespace internal {
void SourceCodeCache::Initialize(Isolate* isolate, bool create_heap_objects) {
cache_ = create_heap_objects ? isolate->heap()->empty_fixed_array() : NULL;
cache_ = create_heap_objects ? isolate->heap()->empty_fixed_array() : nullptr;
}
bool SourceCodeCache::Lookup(Vector<const char> name,
@ -86,17 +86,17 @@ void Bootstrapper::Initialize(bool create_heap_objects) {
static const char* GCFunctionName() {
bool flag_given = FLAG_expose_gc_as != NULL && strlen(FLAG_expose_gc_as) != 0;
bool flag_given =
FLAG_expose_gc_as != nullptr && strlen(FLAG_expose_gc_as) != 0;
return flag_given ? FLAG_expose_gc_as : "gc";
}
v8::Extension* Bootstrapper::free_buffer_extension_ = NULL;
v8::Extension* Bootstrapper::gc_extension_ = NULL;
v8::Extension* Bootstrapper::externalize_string_extension_ = NULL;
v8::Extension* Bootstrapper::statistics_extension_ = NULL;
v8::Extension* Bootstrapper::trigger_failure_extension_ = NULL;
v8::Extension* Bootstrapper::ignition_statistics_extension_ = NULL;
v8::Extension* Bootstrapper::free_buffer_extension_ = nullptr;
v8::Extension* Bootstrapper::gc_extension_ = nullptr;
v8::Extension* Bootstrapper::externalize_string_extension_ = nullptr;
v8::Extension* Bootstrapper::statistics_extension_ = nullptr;
v8::Extension* Bootstrapper::trigger_failure_extension_ = nullptr;
v8::Extension* Bootstrapper::ignition_statistics_extension_ = nullptr;
void Bootstrapper::InitializeOncePerProcess() {
free_buffer_extension_ = new FreeBufferExtension;
@ -116,17 +116,17 @@ void Bootstrapper::InitializeOncePerProcess() {
void Bootstrapper::TearDownExtensions() {
delete free_buffer_extension_;
free_buffer_extension_ = NULL;
free_buffer_extension_ = nullptr;
delete gc_extension_;
gc_extension_ = NULL;
gc_extension_ = nullptr;
delete externalize_string_extension_;
externalize_string_extension_ = NULL;
externalize_string_extension_ = nullptr;
delete statistics_extension_;
statistics_extension_ = NULL;
statistics_extension_ = nullptr;
delete trigger_failure_extension_;
trigger_failure_extension_ = NULL;
trigger_failure_extension_ = nullptr;
delete ignition_statistics_extension_;
ignition_statistics_extension_ = NULL;
ignition_statistics_extension_ = nullptr;
}
void Bootstrapper::TearDown() {
@ -1363,7 +1363,7 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
// --- N a t i v e C o n t e x t ---
// Use the empty function as closure (no scope info).
native_context()->set_closure(*empty_function);
native_context()->set_previous(NULL);
native_context()->set_previous(nullptr);
// Set extension and global object.
native_context()->set_extension(*global_object);
// Security setup: Set the security token of the native context to the global
@ -3644,7 +3644,7 @@ bool Bootstrapper::CompileNative(Isolate* isolate, Vector<const char> name,
MaybeHandle<SharedFunctionInfo> maybe_function_info =
Compiler::GetSharedFunctionInfoForScript(
source, script_name, 0, 0, ScriptOriginOptions(),
MaybeHandle<Object>(), context, NULL, NULL,
MaybeHandle<Object>(), context, nullptr, nullptr,
ScriptCompiler::kNoCompileOptions, natives_flag,
MaybeHandle<FixedArray>());
Handle<SharedFunctionInfo> function_info;
@ -3710,7 +3710,7 @@ bool Genesis::CompileExtension(Isolate* isolate, v8::Extension* extension) {
MaybeHandle<SharedFunctionInfo> maybe_function_info =
Compiler::GetSharedFunctionInfoForScript(
source, script_name, 0, 0, ScriptOriginOptions(),
MaybeHandle<Object>(), context, extension, NULL,
MaybeHandle<Object>(), context, extension, nullptr,
ScriptCompiler::kNoCompileOptions, EXTENSION_CODE,
MaybeHandle<FixedArray>());
if (!maybe_function_info.ToHandle(&function_info)) return false;
@ -3738,7 +3738,7 @@ static Handle<JSObject> ResolveBuiltinIdHolder(Handle<Context> native_context,
Factory* factory = isolate->factory();
Handle<JSGlobalObject> global(native_context->global_object());
const char* period_pos = strchr(holder_expr, '.');
if (period_pos == NULL) {
if (period_pos == nullptr) {
return Handle<JSObject>::cast(
Object::GetPropertyOrElement(
global, factory->InternalizeUtf8String(holder_expr))
@ -3772,7 +3772,7 @@ void Genesis::ConfigureUtilsObject(GlobalContextType context_type) {
case FULL_CONTEXT: {
// We still need the utils object after deserialization.
if (isolate()->serializer_enabled()) return;
if (FLAG_expose_natives_as == NULL) break;
if (FLAG_expose_natives_as == nullptr) break;
if (strlen(FLAG_expose_natives_as) == 0) break;
HandleScope scope(isolate());
Handle<String> natives_key =
@ -4994,7 +4994,7 @@ Genesis::ExtensionStates::ExtensionStates() : map_(8) {}
Genesis::ExtensionTraversalState Genesis::ExtensionStates::get_state(
RegisteredExtension* extension) {
base::HashMap::Entry* entry = map_.Lookup(extension, Hash(extension));
if (entry == NULL) {
if (entry == nullptr) {
return UNVISITED;
}
return static_cast<ExtensionTraversalState>(
@ -5033,8 +5033,7 @@ bool Genesis::InstallExtensions(Handle<Context> native_context,
bool Genesis::InstallAutoExtensions(Isolate* isolate,
ExtensionStates* extension_states) {
for (v8::RegisteredExtension* it = v8::RegisteredExtension::first_extension();
it != NULL;
it = it->next()) {
it != nullptr; it = it->next()) {
if (it->extension()->auto_enable() &&
!InstallExtension(isolate, it, extension_states)) {
return false;
@ -5060,8 +5059,7 @@ bool Genesis::InstallExtension(Isolate* isolate,
const char* name,
ExtensionStates* extension_states) {
for (v8::RegisteredExtension* it = v8::RegisteredExtension::first_extension();
it != NULL;
it = it->next()) {
it != nullptr; it = it->next()) {
if (strcmp(name, it->extension()->name()) == 0) {
return InstallExtension(isolate, it, extension_states);
}

View File

@ -20,7 +20,7 @@ namespace internal {
// generate an index for each native JS file.
class SourceCodeCache final BASE_EMBEDDED {
public:
explicit SourceCodeCache(Script::Type type): type_(type), cache_(NULL) { }
explicit SourceCodeCache(Script::Type type) : type_(type), cache_(nullptr) {}
void Initialize(Isolate* isolate, bool create_heap_objects);

View File

@ -891,7 +891,7 @@ BUILTIN(DatePrototypeToJson) {
isolate, NewTypeError(MessageTemplate::kCalledNonCallable, name));
}
RETURN_RESULT_OR_FAILURE(
isolate, Execution::Call(isolate, function, receiver_obj, 0, NULL));
isolate, Execution::Call(isolate, function, receiver_obj, 0, nullptr));
}
}

View File

@ -53,7 +53,7 @@ TF_BUILTIN(MathAbs, CodeStubAssembler) {
BIND(&if_xissmi);
{
Label if_overflow(this, Label::kDeferred), if_notoverflow(this);
Node* pair = NULL;
Node* pair = nullptr;
// check if support abs function
if (IsIntPtrAbsWithOverflowSupported()) {

View File

@ -98,7 +98,7 @@ const char* Builtins::Lookup(byte* pc) {
if (entry->contains(pc)) return name(i);
}
}
return NULL;
return nullptr;
}
Handle<Code> Builtins::NewFunctionContext(ScopeType scope_type) {

View File

@ -1843,7 +1843,7 @@ void Builtins::Generate_InternalArrayConstructor(MacroAssembler* masm) {
if (FLAG_debug_code) {
// Initial map for the builtin InternalArray function should be a map.
__ mov(ebx, FieldOperand(edi, JSFunction::kPrototypeOrInitialMapOffset));
// Will both indicate a NULL and a Smi.
// Will both indicate a nullptr and a Smi.
__ test(ebx, Immediate(kSmiTagMask));
__ Assert(not_zero, kUnexpectedInitialMapForInternalArrayFunction);
__ CmpObjectType(ebx, MAP_TYPE, ecx);
@ -1872,7 +1872,7 @@ void Builtins::Generate_ArrayConstructor(MacroAssembler* masm) {
if (FLAG_debug_code) {
// Initial map for the builtin Array function should be a map.
__ mov(ebx, FieldOperand(edi, JSFunction::kPrototypeOrInitialMapOffset));
// Will both indicate a NULL and a Smi.
// Will both indicate a nullptr and a Smi.
__ test(ebx, Immediate(kSmiTagMask));
__ Assert(not_zero, kUnexpectedInitialMapForArrayFunction);
__ CmpObjectType(ebx, MAP_TYPE, ecx);

View File

@ -1832,7 +1832,7 @@ void Builtins::Generate_InternalArrayConstructor(MacroAssembler* masm) {
if (FLAG_debug_code) {
// Initial map for the builtin InternalArray functions should be maps.
__ movp(rbx, FieldOperand(rdi, JSFunction::kPrototypeOrInitialMapOffset));
// Will both indicate a NULL and a Smi.
// Will both indicate a nullptr and a Smi.
STATIC_ASSERT(kSmiTag == 0);
Condition not_smi = NegateCondition(masm->CheckSmi(rbx));
__ Check(not_smi, kUnexpectedInitialMapForInternalArrayFunction);
@ -1861,7 +1861,7 @@ void Builtins::Generate_ArrayConstructor(MacroAssembler* masm) {
if (FLAG_debug_code) {
// Initial map for the builtin Array functions should be maps.
__ movp(rbx, FieldOperand(rdi, JSFunction::kPrototypeOrInitialMapOffset));
// Will both indicate a NULL and a Smi.
// Will both indicate a nullptr and a Smi.
STATIC_ASSERT(kSmiTag == 0);
Condition not_smi = NegateCondition(masm->CheckSmi(rbx));
__ Check(not_smi, kUnexpectedInitialMapForArrayFunction);

View File

@ -34,7 +34,7 @@ CodeStubDescriptor::CodeStubDescriptor(CodeStub* stub)
stack_parameter_count_(no_reg),
hint_stack_parameter_count_(-1),
function_mode_(NOT_JS_FUNCTION_STUB_MODE),
deoptimization_handler_(NULL),
deoptimization_handler_(nullptr),
miss_handler_(),
has_miss_handler_(false) {
stub->InitializeDescriptor(this);
@ -45,7 +45,7 @@ CodeStubDescriptor::CodeStubDescriptor(Isolate* isolate, uint32_t stub_key)
stack_parameter_count_(no_reg),
hint_stack_parameter_count_(-1),
function_mode_(NOT_JS_FUNCTION_STUB_MODE),
deoptimization_handler_(NULL),
deoptimization_handler_(nullptr),
miss_handler_(),
has_miss_handler_(false) {
CodeStub::InitializeDescriptor(isolate, stub_key, this);
@ -108,7 +108,7 @@ Handle<Code> PlatformCodeStub::GenerateCode() {
Factory* factory = isolate()->factory();
// Generate the new code.
MacroAssembler masm(isolate(), NULL, 256, CodeObjectRequired::kYes);
MacroAssembler masm(isolate(), nullptr, 256, CodeObjectRequired::kYes);
{
// Update the static counter each time a new code stub is generated.
@ -188,7 +188,7 @@ const char* CodeStub::MajorName(CodeStub::Major major_key) {
case NUMBER_OF_IDS:
UNREACHABLE();
}
return NULL;
return nullptr;
}
@ -591,7 +591,7 @@ void ProfileEntryHookStub::EntryHookTrampoline(intptr_t function,
intptr_t stack_pointer,
Isolate* isolate) {
FunctionEntryHook entry_hook = isolate->function_entry_hook();
DCHECK(entry_hook != NULL);
DCHECK(entry_hook != nullptr);
entry_hook(function, stack_pointer);
}

View File

@ -329,11 +329,11 @@ class CodeStubDescriptor {
CodeStubDescriptor(Isolate* isolate, uint32_t stub_key);
void Initialize(Address deoptimization_handler = NULL,
void Initialize(Address deoptimization_handler = nullptr,
int hint_stack_parameter_count = -1,
StubFunctionMode function_mode = NOT_JS_FUNCTION_STUB_MODE);
void Initialize(Register stack_parameter_count,
Address deoptimization_handler = NULL,
Address deoptimization_handler = nullptr,
int hint_stack_parameter_count = -1,
StubFunctionMode function_mode = NOT_JS_FUNCTION_STUB_MODE);

View File

@ -92,7 +92,7 @@ OptimizingCompileDispatcher::~OptimizingCompileDispatcher() {
CompilationJob* OptimizingCompileDispatcher::NextInput(bool check_if_flushing) {
base::LockGuard<base::Mutex> access_input_queue_(&input_queue_mutex_);
if (input_queue_length_ == 0) return NULL;
if (input_queue_length_ == 0) return nullptr;
CompilationJob* job = input_queue_[InputQueueIndex(0)];
DCHECK_NOT_NULL(job);
input_queue_shift_ = InputQueueIndex(1);
@ -101,7 +101,7 @@ CompilationJob* OptimizingCompileDispatcher::NextInput(bool check_if_flushing) {
if (static_cast<ModeFlag>(base::Acquire_Load(&mode_)) == FLUSH) {
AllowHandleDereference allow_handle_dereference;
DisposeCompilationJob(job, true);
return NULL;
return nullptr;
}
}
return job;
@ -124,7 +124,7 @@ void OptimizingCompileDispatcher::CompileNext(CompilationJob* job) {
void OptimizingCompileDispatcher::FlushOutputQueue(bool restore_function_code) {
for (;;) {
CompilationJob* job = NULL;
CompilationJob* job = nullptr;
{
base::LockGuard<base::Mutex> access_output_queue_(&output_queue_mutex_);
if (output_queue_.empty()) return;
@ -189,7 +189,7 @@ void OptimizingCompileDispatcher::InstallOptimizedFunctions() {
HandleScope handle_scope(isolate_);
for (;;) {
CompilationJob* job = NULL;
CompilationJob* job = nullptr;
{
base::LockGuard<base::Mutex> access_output_queue_(&output_queue_mutex_);
if (output_queue_.empty()) return;

View File

@ -59,7 +59,7 @@ class CompilationHandleScope final {
// Helper that times a scoped region and records the elapsed time.
struct ScopedTimer {
explicit ScopedTimer(base::TimeDelta* location) : location_(location) {
DCHECK(location_ != NULL);
DCHECK(location_ != nullptr);
timer_.Start();
}
@ -1172,7 +1172,7 @@ bool Compiler::CodeGenerationFromStringsAllowed(Isolate* isolate,
// Check with callback if set.
AllowCodeGenerationFromStringsCallback callback =
isolate->allow_code_gen_callback();
if (callback == NULL) {
if (callback == nullptr) {
// No callback set and code generation disallowed.
return false;
} else {
@ -1217,17 +1217,17 @@ MaybeHandle<SharedFunctionInfo> Compiler::GetSharedFunctionInfoForScript(
MaybeHandle<FixedArray> maybe_host_defined_options) {
Isolate* isolate = source->GetIsolate();
if (compile_options == ScriptCompiler::kNoCompileOptions) {
cached_data = NULL;
cached_data = nullptr;
} else if (compile_options == ScriptCompiler::kProduceParserCache ||
ShouldProduceCodeCache(compile_options)) {
DCHECK(cached_data && !*cached_data);
DCHECK(extension == NULL);
DCHECK(extension == nullptr);
DCHECK(!isolate->debug()->is_loaded());
} else {
DCHECK(compile_options == ScriptCompiler::kConsumeParserCache ||
compile_options == ScriptCompiler::kConsumeCodeCache);
DCHECK(cached_data && *cached_data);
DCHECK(extension == NULL);
DCHECK(extension == nullptr);
}
int source_length = source->length();
isolate->counters()->total_load_size()->Increment(source_length);
@ -1239,7 +1239,7 @@ MaybeHandle<SharedFunctionInfo> Compiler::GetSharedFunctionInfoForScript(
// Do a lookup in the compilation cache but not for extensions.
MaybeHandle<SharedFunctionInfo> maybe_result;
Handle<Cell> vector;
if (extension == NULL) {
if (extension == nullptr) {
// First check per-isolate compilation cache.
InfoVectorPair pair = compilation_cache->LookupScript(
source, maybe_script_name, line_offset, column_offset, resource_options,
@ -1336,7 +1336,7 @@ MaybeHandle<SharedFunctionInfo> Compiler::GetSharedFunctionInfoForScript(
static_cast<LanguageMode>(parse_info.language_mode() | language_mode));
maybe_result = CompileToplevel(&parse_info, isolate);
Handle<SharedFunctionInfo> result;
if (extension == NULL && maybe_result.ToHandle(&result)) {
if (extension == nullptr && maybe_result.ToHandle(&result)) {
// We need a feedback vector.
DCHECK(result->is_compiled());
Handle<FeedbackVector> feedback_vector =

View File

@ -96,7 +96,7 @@ class S390OperandConverter final : public InstructionOperandConverter {
UNREACHABLE();
}
MemOperand MemoryOperand(AddressingMode* mode = NULL,
MemOperand MemoryOperand(AddressingMode* mode = nullptr,
size_t first_index = 0) {
return MemoryOperand(mode, &first_index);
}
@ -2353,13 +2353,13 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
__ LoadlW(i.OutputRegister(), i.MemoryOperand());
break;
case kAtomicStoreWord8:
__ StoreByte(i.InputRegister(0), i.MemoryOperand(NULL, 1));
__ StoreByte(i.InputRegister(0), i.MemoryOperand(nullptr, 1));
break;
case kAtomicStoreWord16:
__ StoreHalfWord(i.InputRegister(0), i.MemoryOperand(NULL, 1));
__ StoreHalfWord(i.InputRegister(0), i.MemoryOperand(nullptr, 1));
break;
case kAtomicStoreWord32:
__ StoreW(i.InputRegister(0), i.MemoryOperand(NULL, 1));
__ StoreW(i.InputRegister(0), i.MemoryOperand(nullptr, 1));
break;
// 0x aa bb cc dd
// index = 3..2..1..0

View File

@ -1406,8 +1406,8 @@ static inline bool TryMatchDoubleConstructFromInsert(
S390OperandGenerator g(selector);
Node* left = node->InputAt(0);
Node* right = node->InputAt(1);
Node* lo32 = NULL;
Node* hi32 = NULL;
Node* lo32 = nullptr;
Node* hi32 = nullptr;
if (node->opcode() == IrOpcode::kFloat64InsertLowWord32) {
lo32 = right;

View File

@ -561,14 +561,14 @@ bool Type::Maybe(Type* that) {
return this->SimplyEquals(that);
}
// Return the range in [this], or [NULL].
// Return the range in [this], or [nullptr].
Type* Type::GetRange() {
DisallowHeapAllocation no_allocation;
if (this->IsRange()) return this;
if (this->IsUnion() && this->AsUnion()->Get(1)->IsRange()) {
return this->AsUnion()->Get(1);
}
return NULL;
return nullptr;
}
bool UnionType::Wellformed() {
@ -852,15 +852,15 @@ Type* Type::Union(Type* type1, Type* type2, Zone* zone) {
Type* range = None();
Type* range1 = type1->GetRange();
Type* range2 = type2->GetRange();
if (range1 != NULL && range2 != NULL) {
if (range1 != nullptr && range2 != nullptr) {
RangeType::Limits lims =
RangeType::Limits::Union(RangeType::Limits(range1->AsRange()),
RangeType::Limits(range2->AsRange()));
Type* union_range = RangeType::New(lims, zone);
range = NormalizeRangeAndBitset(union_range, &new_bitset, zone);
} else if (range1 != NULL) {
} else if (range1 != nullptr) {
range = NormalizeRangeAndBitset(range1, &new_bitset, zone);
} else if (range2 != NULL) {
} else if (range2 != nullptr) {
range = NormalizeRangeAndBitset(range2, &new_bitset, zone);
}
Type* bits = BitsetType::New(new_bitset);
@ -938,7 +938,7 @@ const char* BitsetType::Name(bitset bits) {
#undef RETURN_NAMED_TYPE
default:
return NULL;
return nullptr;
}
}
@ -946,7 +946,7 @@ void BitsetType::Print(std::ostream& os, // NOLINT
bitset bits) {
DisallowHeapAllocation no_allocation;
const char* name = Name(bits);
if (name != NULL) {
if (name != nullptr) {
os << name;
return;
}

View File

@ -608,7 +608,7 @@ class V8_EXPORT_PRIVATE Type {
double Max();
// Extracts a range from the type: if the type is a range or a union
// containing a range, that range is returned; otherwise, NULL is returned.
// containing a range, that range is returned; otherwise, nullptr is returned.
Type* GetRange();
static bool IsInteger(i::Object* x);

View File

@ -1102,7 +1102,7 @@ char* DoubleToPrecisionCString(double value, int p) {
int exponent = decimal_point - 1;
char* result = NULL;
char* result = nullptr;
if (exponent < -6 || exponent >= p) {
result =

View File

@ -16,9 +16,9 @@ namespace v8 {
namespace internal {
StatsTable::StatsTable(Counters* counters)
: lookup_function_(NULL),
create_histogram_function_(NULL),
add_histogram_sample_function_(NULL) {}
: lookup_function_(nullptr),
create_histogram_function_(nullptr),
add_histogram_sample_function_(nullptr) {}
void StatsTable::SetCounterFunction(CounterLookupCallback f) {
lookup_function_ = f;

View File

@ -46,23 +46,21 @@ class StatsTable {
add_histogram_sample_function_ = f;
}
bool HasCounterFunction() const {
return lookup_function_ != NULL;
}
bool HasCounterFunction() const { return lookup_function_ != nullptr; }
// Lookup the location of a counter by name. If the lookup
// is successful, returns a non-NULL pointer for writing the
// is successful, returns a non-nullptr pointer for writing the
// value of the counter. Each thread calling this function
// may receive a different location to store it's counter.
// The return value must not be cached and re-used across
// threads, although a single thread is free to cache it.
int* FindLocation(const char* name) {
if (!lookup_function_) return NULL;
if (!lookup_function_) return nullptr;
return lookup_function_(name);
}
// Create a histogram by name. If the create is successful,
// returns a non-NULL pointer for use with AddHistogramSample
// returns a non-nullptr pointer for use with AddHistogramSample
// function. min and max define the expected minimum and maximum
// sample values. buckets is the maximum number of buckets
// that the samples will be grouped into.
@ -70,7 +68,7 @@ class StatsTable {
int min,
int max,
size_t buckets) {
if (!create_histogram_function_) return NULL;
if (!create_histogram_function_) return nullptr;
return create_histogram_function_(name, min, max, buckets);
}
@ -149,16 +147,14 @@ class StatsCounter : public StatsCounterBase {
// Is this counter enabled?
// Returns false if table is full.
bool Enabled() {
return GetPtr() != NULL;
}
bool Enabled() { return GetPtr() != nullptr; }
// Get the internal pointer to the counter. This is used
// by the code generator to emit code that manipulates a
// given counter without calling the runtime system.
int* GetInternalPointer() {
int* loc = GetPtr();
DCHECK(loc != NULL);
DCHECK(loc != nullptr);
return loc;
}
@ -191,9 +187,9 @@ class StatsCounterThreadSafe : public StatsCounterBase {
void Increment(int value);
void Decrement();
void Decrement(int value);
bool Enabled() { return ptr_ != NULL; }
bool Enabled() { return ptr_ != nullptr; }
int* GetInternalPointer() {
DCHECK(ptr_ != NULL);
DCHECK(ptr_ != nullptr);
return ptr_;
}
@ -466,7 +462,7 @@ class AggregatedMemoryHistogram {
last_ms_(0.0),
aggregate_value_(0.0),
last_value_(0.0),
backing_histogram_(NULL) {}
backing_histogram_(nullptr) {}
double Aggregate(double current_ms, double current_value);
bool is_initialized_;

View File

@ -87,7 +87,7 @@ static bool WaitOnFD(int fd,
int gone = 0;
if (total_timeout != -1) {
struct timeval time_now;
gettimeofday(&time_now, NULL);
gettimeofday(&time_now, nullptr);
time_t seconds = time_now.tv_sec - start_time.tv_sec;
gone = static_cast<int>(seconds * 1000 +
(time_now.tv_usec - start_time.tv_usec) / 1000);
@ -104,11 +104,8 @@ static bool WaitOnFD(int fd,
}
timeout.tv_usec = (read_timeout % 1000) * 1000;
timeout.tv_sec = read_timeout / 1000;
int number_of_fds_ready = select(fd + 1,
&readfds,
&writefds,
&exceptfds,
read_timeout != -1 ? &timeout : NULL);
int number_of_fds_ready = select(fd + 1, &readfds, &writefds, &exceptfds,
read_timeout != -1 ? &timeout : nullptr);
return number_of_fds_ready == 1;
}
@ -118,7 +115,7 @@ static bool WaitOnFD(int fd,
static bool TimeIsOut(const struct timeval& start_time, const int& total_time) {
if (total_time == -1) return false;
struct timeval time_now;
gettimeofday(&time_now, NULL);
gettimeofday(&time_now, nullptr);
// Careful about overflow.
int seconds = static_cast<int>(time_now.tv_sec - start_time.tv_sec);
if (seconds > 100) {
@ -139,7 +136,9 @@ static bool TimeIsOut(const struct timeval& start_time, const int& total_time) {
class ZombieProtector {
public:
explicit ZombieProtector(int pid): pid_(pid) { }
~ZombieProtector() { if (pid_ != 0) waitpid(pid_, NULL, 0); }
~ZombieProtector() {
if (pid_ != 0) waitpid(pid_, nullptr, 0);
}
void ChildIsDeadNow() { pid_ = 0; }
private:
int pid_;
@ -161,12 +160,10 @@ class OpenFDCloser {
// scope.
class ExecArgs {
public:
ExecArgs() {
exec_args_[0] = NULL;
}
ExecArgs() { exec_args_[0] = nullptr; }
bool Init(Isolate* isolate, Local<Value> arg0, Local<Array> command_args) {
String::Utf8Value prog(isolate, arg0);
if (*prog == NULL) {
if (*prog == nullptr) {
const char* message =
"os.system(): String conversion of program name failed";
isolate->ThrowException(
@ -184,8 +181,8 @@ class ExecArgs {
command_args->Get(isolate->GetCurrentContext(),
Integer::New(isolate, j)).ToLocalChecked());
String::Utf8Value utf8_arg(isolate, arg);
if (*utf8_arg == NULL) {
exec_args_[i] = NULL; // Consistent state for destructor.
if (*utf8_arg == nullptr) {
exec_args_[i] = nullptr; // Consistent state for destructor.
const char* message =
"os.system(): String conversion of argument failed.";
isolate->ThrowException(
@ -198,12 +195,12 @@ class ExecArgs {
snprintf(c_arg, len, "%s", *utf8_arg);
exec_args_[i] = c_arg;
}
exec_args_[i] = NULL;
exec_args_[i] = nullptr;
return true;
}
~ExecArgs() {
for (unsigned i = 0; i < kMaxArgs; i++) {
if (exec_args_[i] == NULL) {
if (exec_args_[i] == nullptr) {
return;
}
delete [] exec_args_[i];
@ -490,7 +487,7 @@ void Shell::System(const v8::FunctionCallbackInfo<v8::Value>& args) {
}
struct timeval start_time;
gettimeofday(&start_time, NULL);
gettimeofday(&start_time, nullptr);
ExecArgs exec_args;
if (!exec_args.Init(args.GetIsolate(), args[0], command_args)) {
@ -554,7 +551,7 @@ void Shell::ChangeDirectory(const v8::FunctionCallbackInfo<v8::Value>& args) {
return;
}
String::Utf8Value directory(args.GetIsolate(), args[0]);
if (*directory == NULL) {
if (*directory == nullptr) {
const char* message = "os.chdir(): String conversion of argument failed.";
args.GetIsolate()->ThrowException(
String::NewFromUtf8(args.GetIsolate(), message, NewStringType::kNormal)
@ -619,7 +616,7 @@ static bool mkdirp(Isolate* isolate, char* directory, mode_t mask) {
return CheckItsADirectory(isolate, directory);
} else if (errno == ENOENT) { // Intermediate path element is missing.
char* last_slash = strrchr(directory, '/');
if (last_slash == NULL) {
if (last_slash == nullptr) {
isolate->ThrowException(
String::NewFromUtf8(isolate, strerror(errno), NewStringType::kNormal)
.ToLocalChecked());
@ -668,7 +665,7 @@ void Shell::MakeDirectory(const v8::FunctionCallbackInfo<v8::Value>& args) {
return;
}
String::Utf8Value directory(args.GetIsolate(), args[0]);
if (*directory == NULL) {
if (*directory == nullptr) {
const char* message = "os.mkdirp(): String conversion of argument failed.";
args.GetIsolate()->ThrowException(
String::NewFromUtf8(args.GetIsolate(), message, NewStringType::kNormal)
@ -688,7 +685,7 @@ void Shell::RemoveDirectory(const v8::FunctionCallbackInfo<v8::Value>& args) {
return;
}
String::Utf8Value directory(args.GetIsolate(), args[0]);
if (*directory == NULL) {
if (*directory == nullptr) {
const char* message = "os.rmdir(): String conversion of argument failed.";
args.GetIsolate()->ThrowException(
String::NewFromUtf8(args.GetIsolate(), message, NewStringType::kNormal)
@ -709,7 +706,7 @@ void Shell::SetEnvironment(const v8::FunctionCallbackInfo<v8::Value>& args) {
}
String::Utf8Value var(args.GetIsolate(), args[0]);
String::Utf8Value value(args.GetIsolate(), args[1]);
if (*var == NULL) {
if (*var == nullptr) {
const char* message =
"os.setenv(): String conversion of variable name failed.";
args.GetIsolate()->ThrowException(
@ -717,7 +714,7 @@ void Shell::SetEnvironment(const v8::FunctionCallbackInfo<v8::Value>& args) {
.ToLocalChecked());
return;
}
if (*value == NULL) {
if (*value == nullptr) {
const char* message =
"os.setenv(): String conversion of variable contents failed.";
args.GetIsolate()->ThrowException(
@ -738,7 +735,7 @@ void Shell::UnsetEnvironment(const v8::FunctionCallbackInfo<v8::Value>& args) {
return;
}
String::Utf8Value var(args.GetIsolate(), args[0]);
if (*var == NULL) {
if (*var == nullptr) {
const char* message =
"os.setenv(): String conversion of variable name failed.";
args.GetIsolate()->ThrowException(
@ -825,7 +822,7 @@ char* Shell::ReadCharsFromTcpPort(const char* name, int* size_out) {
fprintf(stderr, "Received length %d for %s from localhost:%d\n",
file_length, name, Shell::options.read_from_tcp_port);
close(sockfd);
return NULL;
return nullptr;
}
// Allocate the output array.
@ -841,7 +838,7 @@ char* Shell::ReadCharsFromTcpPort(const char* name, int* size_out) {
Shell::options.read_from_tcp_port);
close(sockfd);
delete[] chars;
return NULL;
return nullptr;
}
total_received += received;
}

148
src/d8.cc
View File

@ -124,7 +124,7 @@ class ShellArrayBufferAllocator : public ArrayBufferAllocatorBase {
}
#endif
void* data = AllocateUninitialized(length);
return data == NULL ? data : memset(data, 0, length);
return data == nullptr ? data : memset(data, 0, length);
}
void* AllocateUninitialized(size_t length) override {
#if USE_VM
@ -184,7 +184,7 @@ class MockArrayBufferAllocator : public ArrayBufferAllocatorBase {
void* Allocate(size_t length) override {
const size_t actual_length = get_actual_length(length);
void* data = AllocateUninitialized(actual_length);
return data == NULL ? data : memset(data, 0, actual_length);
return data == nullptr ? data : memset(data, 0, actual_length);
}
void* AllocateUninitialized(size_t length) override {
return malloc(get_actual_length(length));
@ -252,8 +252,7 @@ class PredictablePlatform : public Platform {
DISALLOW_COPY_AND_ASSIGN(PredictablePlatform);
};
v8::Platform* g_platform = NULL;
v8::Platform* g_platform = nullptr;
v8::Platform* GetDefaultPlatform() {
return i::FLAG_verify_predictable
@ -270,14 +269,14 @@ static Local<Value> Throw(Isolate* isolate, const char* message) {
Worker* GetWorkerFromInternalField(Isolate* isolate, Local<Object> object) {
if (object->InternalFieldCount() != 1) {
Throw(isolate, "this is not a Worker");
return NULL;
return nullptr;
}
Worker* worker =
static_cast<Worker*>(object->GetAlignedPointerFromInternalField(0));
if (worker == NULL) {
if (worker == nullptr) {
Throw(isolate, "Worker is defunct because main thread is terminating");
return NULL;
return nullptr;
}
return worker;
@ -401,12 +400,13 @@ static platform::tracing::TraceConfig* CreateTraceConfigFromJSON(
class PerIsolateData {
public:
explicit PerIsolateData(Isolate* isolate) : isolate_(isolate), realms_(NULL) {
explicit PerIsolateData(Isolate* isolate)
: isolate_(isolate), realms_(nullptr) {
isolate->SetData(0, this);
}
~PerIsolateData() {
isolate_->SetData(0, NULL); // Not really needed, just to be sure...
isolate_->SetData(0, nullptr); // Not really needed, just to be sure...
}
inline static PerIsolateData* Get(Isolate* isolate) {
@ -473,7 +473,7 @@ class ExternalOwningOneByteStringResource
};
CounterMap* Shell::counter_map_;
base::OS::MemoryMappedFile* Shell::counters_file_ = NULL;
base::OS::MemoryMappedFile* Shell::counters_file_ = nullptr;
CounterCollection Shell::local_counters_;
CounterCollection* Shell::counters_ = &local_counters_;
base::LazyMutex Shell::context_mutex_;
@ -506,7 +506,7 @@ ScriptCompiler::CachedData* CompileForCachedData(
uint16_t* source_buffer = new uint16_t[source_length];
source->Write(source_buffer, 0, source_length);
int name_length = 0;
uint16_t* name_buffer = NULL;
uint16_t* name_buffer = nullptr;
if (name->IsString()) {
Local<String> name_string = Local<String>::Cast(name);
name_length = name_string->Length();
@ -520,7 +520,7 @@ ScriptCompiler::CachedData* CompileForCachedData(
Shell::HostImportModuleDynamically);
temp_isolate->SetHostInitializeImportMetaObjectCallback(
Shell::HostInitializeImportMetaObject);
ScriptCompiler::CachedData* result = NULL;
ScriptCompiler::CachedData* result = nullptr;
{
Isolate::Scope isolate_scope(temp_isolate);
HandleScope handle_scope(temp_isolate);
@ -578,10 +578,10 @@ MaybeLocal<Script> Shell::CompileString(
} else {
DCHECK(false); // A new compile option?
}
if (data == NULL) compile_options = ScriptCompiler::kNoCompileOptions;
if (data == nullptr) compile_options = ScriptCompiler::kNoCompileOptions;
MaybeLocal<Script> result =
ScriptCompiler::Compile(context, &cached_source, compile_options);
CHECK(data == NULL || !data->rejected);
CHECK(data == nullptr || !data->rejected);
return result;
}
@ -1081,7 +1081,7 @@ MaybeLocal<Context> Shell::CreateRealm(
}
Local<ObjectTemplate> global_template = CreateGlobalTemplate(isolate);
Local<Context> context =
Context::New(isolate, NULL, global_template, global_object);
Context::New(isolate, nullptr, global_template, global_object);
DCHECK(!try_catch.HasCaught());
if (context.IsEmpty()) return MaybeLocal<Context>();
InitializeModuleEmbedderData(context);
@ -1262,7 +1262,7 @@ void Shell::Write(const v8::FunctionCallbackInfo<v8::Value>& args) {
void Shell::Read(const v8::FunctionCallbackInfo<v8::Value>& args) {
String::Utf8Value file(args.GetIsolate(), args[0]);
if (*file == NULL) {
if (*file == nullptr) {
Throw(args.GetIsolate(), "Error loading file");
return;
}
@ -1292,9 +1292,9 @@ Local<String> Shell::ReadFromStdin(Isolate* isolate) {
// Continue reading if the line ends with an escape '\\' or the line has
// not been fully read into the buffer yet (does not end with '\n').
// If fgets gets an error, just give up.
char* input = NULL;
char* input = nullptr;
input = fgets(buffer, kBufferSize, stdin);
if (input == NULL) return Local<String>();
if (input == nullptr) return Local<String>();
length = static_cast<int>(strlen(buffer));
if (length == 0) {
return accumulator;
@ -1323,7 +1323,7 @@ void Shell::Load(const v8::FunctionCallbackInfo<v8::Value>& args) {
for (int i = 0; i < args.Length(); i++) {
HandleScope handle_scope(args.GetIsolate());
String::Utf8Value file(args.GetIsolate(), args[i]);
if (*file == NULL) {
if (*file == nullptr) {
Throw(args.GetIsolate(), "Error loading file");
return;
}
@ -1372,10 +1372,10 @@ void Shell::WorkerNew(const v8::FunctionCallbackInfo<v8::Value>& args) {
return;
}
// Initialize the embedder field to NULL; if we return early without
// Initialize the embedder field to nullptr; if we return early without
// creating a new Worker (because the main thread is terminating) we can
// early-out from the instance calls.
args.Holder()->SetAlignedPointerInInternalField(0, NULL);
args.Holder()->SetAlignedPointerInInternalField(0, nullptr);
if (!allow_new_workers_) return;
@ -1567,7 +1567,7 @@ CounterCollection::CounterCollection() {
Counter* CounterCollection::GetNextCounter() {
if (counters_in_use_ == kMaxCounters) return NULL;
if (counters_in_use_ == kMaxCounters) return nullptr;
return &counters_[counters_in_use_++];
}
@ -1575,9 +1575,9 @@ Counter* CounterCollection::GetNextCounter() {
void Shell::MapCounters(v8::Isolate* isolate, const char* name) {
counters_file_ = base::OS::MemoryMappedFile::create(
name, nullptr, sizeof(CounterCollection), &local_counters_);
void* memory = (counters_file_ == NULL) ?
NULL : counters_file_->memory();
if (memory == NULL) {
void* memory =
(counters_file_ == nullptr) ? nullptr : counters_file_->memory();
if (memory == nullptr) {
printf("Could not map counters file %s\n", name);
Exit(1);
}
@ -1602,9 +1602,9 @@ int CounterMap::Hash(const char* name) {
Counter* Shell::GetCounter(const char* name, bool is_histogram) {
Counter* counter = counter_map_->Lookup(name);
if (counter == NULL) {
if (counter == nullptr) {
counter = counters_->GetNextCounter();
if (counter != NULL) {
if (counter != nullptr) {
counter_map_->Set(name, counter);
counter->Bind(name, is_histogram);
}
@ -1618,10 +1618,10 @@ Counter* Shell::GetCounter(const char* name, bool is_histogram) {
int* Shell::LookupCounter(const char* name) {
Counter* counter = GetCounter(name, false);
if (counter != NULL) {
if (counter != nullptr) {
return counter->ptr();
} else {
return NULL;
return nullptr;
}
}
@ -1893,7 +1893,7 @@ Local<Context> Shell::CreateEvaluationContext(Isolate* isolate) {
// Initialize the global objects
Local<ObjectTemplate> global_template = CreateGlobalTemplate(isolate);
EscapableHandleScope handle_scope(isolate);
Local<Context> context = Context::New(isolate, NULL, global_template);
Local<Context> context = Context::New(isolate, nullptr, global_template);
DCHECK(!context.IsEmpty());
InitializeModuleEmbedderData(context);
Context::Scope scope(context);
@ -2104,17 +2104,17 @@ static FILE* FOpen(const char* path, const char* mode) {
if (fopen_s(&result, path, mode) == 0) {
return result;
} else {
return NULL;
return nullptr;
}
#else
FILE* file = fopen(path, mode);
if (file == NULL) return NULL;
if (file == nullptr) return nullptr;
struct stat file_stat;
if (fstat(fileno(file), &file_stat) != 0) return NULL;
if (fstat(fileno(file), &file_stat) != 0) return nullptr;
bool is_regular_file = ((file_stat.st_mode & S_IFREG) != 0);
if (is_regular_file) return file;
fclose(file);
return NULL;
return nullptr;
#endif
}
@ -2124,7 +2124,7 @@ static char* ReadChars(const char* name, int* size_out) {
}
FILE* file = FOpen(name, "rb");
if (file == NULL) return NULL;
if (file == nullptr) return nullptr;
fseek(file, 0, SEEK_END);
size_t size = ftell(file);
@ -2170,14 +2170,14 @@ void Shell::ReadBuffer(const v8::FunctionCallbackInfo<v8::Value>& args) {
Isolate* isolate = args.GetIsolate();
String::Utf8Value filename(isolate, args[0]);
int length;
if (*filename == NULL) {
if (*filename == nullptr) {
Throw(isolate, "Error loading file");
return;
}
DataAndPersistent* data = new DataAndPersistent;
data->data = reinterpret_cast<uint8_t*>(ReadChars(*filename, &length));
if (data->data == NULL) {
if (data->data == nullptr) {
delete data;
Throw(isolate, "Error reading file");
return;
@ -2197,7 +2197,7 @@ void Shell::ReadBuffer(const v8::FunctionCallbackInfo<v8::Value>& args) {
Local<String> Shell::ReadFile(Isolate* isolate, const char* name) {
int size = 0;
char* chars = ReadChars(name, &size);
if (chars == NULL) return Local<String>();
if (chars == nullptr) return Local<String>();
Local<String> result;
if (i::FLAG_use_external_strings && internal::String::IsAscii(chars, size)) {
String::ExternalOneByteStringResource* resource =
@ -2372,7 +2372,7 @@ class InspectorClient : public v8_inspector::V8InspectorClient {
SourceGroup::~SourceGroup() {
delete thread_;
thread_ = NULL;
thread_ = nullptr;
}
@ -2484,7 +2484,7 @@ void SourceGroup::ExecuteInThread() {
void SourceGroup::StartExecuteInThread() {
if (thread_ == NULL) {
if (thread_ == nullptr) {
thread_ = new IsolateThread(this);
thread_->Start();
}
@ -2493,13 +2493,13 @@ void SourceGroup::StartExecuteInThread() {
void SourceGroup::WaitForThread() {
if (thread_ == NULL) return;
if (thread_ == nullptr) return;
done_semaphore_.Wait();
}
void SourceGroup::JoinThread() {
if (thread_ == NULL) return;
if (thread_ == nullptr) return;
thread_->Join();
}
@ -2534,20 +2534,18 @@ void SerializationDataQueue::Clear() {
data_.clear();
}
Worker::Worker()
: in_semaphore_(0),
out_semaphore_(0),
thread_(NULL),
script_(NULL),
thread_(nullptr),
script_(nullptr),
running_(false) {}
Worker::~Worker() {
delete thread_;
thread_ = NULL;
thread_ = nullptr;
delete[] script_;
script_ = NULL;
script_ = nullptr;
in_queue_.Clear();
out_queue_.Clear();
}
@ -2579,9 +2577,9 @@ std::unique_ptr<SerializationData> Worker::GetMessage() {
void Worker::Terminate() {
base::Relaxed_Store(&running_, false);
// Post NULL to wake the Worker thread message loop, and tell it to stop
// Post nullptr to wake the Worker thread message loop, and tell it to stop
// running.
PostMessage(NULL);
PostMessage(nullptr);
}
@ -2668,8 +2666,8 @@ void Worker::ExecuteInThread() {
}
isolate->Dispose();
// Post NULL to wake the thread waiting on GetMessage() if there is one.
out_queue_.Enqueue(NULL);
// Post nullptr to wake the thread waiting on GetMessage() if there is one.
out_queue_.Enqueue(nullptr);
out_semaphore_.Signal();
}
@ -2707,17 +2705,17 @@ bool Shell::SetOptions(int argc, char* argv[]) {
for (int i = 0; i < argc; i++) {
if (strcmp(argv[i], "--stress-opt") == 0) {
options.stress_opt = true;
argv[i] = NULL;
argv[i] = nullptr;
} else if (strcmp(argv[i], "--nostress-opt") == 0 ||
strcmp(argv[i], "--no-stress-opt") == 0) {
options.stress_opt = false;
argv[i] = NULL;
argv[i] = nullptr;
} else if (strcmp(argv[i], "--stress-deopt") == 0) {
options.stress_deopt = true;
argv[i] = NULL;
argv[i] = nullptr;
} else if (strcmp(argv[i], "--mock-arraybuffer-allocator") == 0) {
options.mock_arraybuffer_allocator = true;
argv[i] = NULL;
argv[i] = nullptr;
} else if (strcmp(argv[i], "--noalways-opt") == 0 ||
strcmp(argv[i], "--no-always-opt") == 0) {
// No support for stressing if we can't use --always-opt.
@ -2725,28 +2723,28 @@ bool Shell::SetOptions(int argc, char* argv[]) {
options.stress_deopt = false;
} else if (strcmp(argv[i], "--logfile-per-isolate") == 0) {
logfile_per_isolate = true;
argv[i] = NULL;
argv[i] = nullptr;
} else if (strcmp(argv[i], "--shell") == 0) {
options.interactive_shell = true;
argv[i] = NULL;
argv[i] = nullptr;
} else if (strcmp(argv[i], "--test") == 0) {
options.test_shell = true;
argv[i] = NULL;
argv[i] = nullptr;
} else if (strcmp(argv[i], "--notest") == 0 ||
strcmp(argv[i], "--no-test") == 0) {
options.test_shell = false;
argv[i] = NULL;
argv[i] = nullptr;
} else if (strcmp(argv[i], "--send-idle-notification") == 0) {
options.send_idle_notification = true;
argv[i] = NULL;
argv[i] = nullptr;
} else if (strcmp(argv[i], "--invoke-weak-callbacks") == 0) {
options.invoke_weak_callbacks = true;
// TODO(jochen) See issue 3351
options.send_idle_notification = true;
argv[i] = NULL;
argv[i] = nullptr;
} else if (strcmp(argv[i], "--omit-quit") == 0) {
options.omit_quit = true;
argv[i] = NULL;
argv[i] = nullptr;
} else if (strcmp(argv[i], "-f") == 0) {
// Ignore any -f flags for compatibility with other stand-alone
// JavaScript engines.
@ -2755,17 +2753,17 @@ bool Shell::SetOptions(int argc, char* argv[]) {
options.num_isolates++;
} else if (strcmp(argv[i], "--throws") == 0) {
options.expected_to_throw = true;
argv[i] = NULL;
argv[i] = nullptr;
} else if (strncmp(argv[i], "--icu-data-file=", 16) == 0) {
options.icu_data_file = argv[i] + 16;
argv[i] = NULL;
argv[i] = nullptr;
#ifdef V8_USE_EXTERNAL_STARTUP_DATA
} else if (strncmp(argv[i], "--natives_blob=", 15) == 0) {
options.natives_blob = argv[i] + 15;
argv[i] = NULL;
argv[i] = nullptr;
} else if (strncmp(argv[i], "--snapshot_blob=", 16) == 0) {
options.snapshot_blob = argv[i] + 16;
argv[i] = NULL;
argv[i] = nullptr;
#endif // V8_USE_EXTERNAL_STARTUP_DATA
} else if (strcmp(argv[i], "--cache") == 0 ||
strncmp(argv[i], "--cache=", 8) == 0) {
@ -2780,30 +2778,30 @@ bool Shell::SetOptions(int argc, char* argv[]) {
printf("Unknown option to --cache.\n");
return false;
}
argv[i] = NULL;
argv[i] = nullptr;
} else if (strcmp(argv[i], "--enable-tracing") == 0) {
options.trace_enabled = true;
argv[i] = NULL;
argv[i] = nullptr;
} else if (strncmp(argv[i], "--trace-config=", 15) == 0) {
options.trace_config = argv[i] + 15;
argv[i] = NULL;
argv[i] = nullptr;
} else if (strcmp(argv[i], "--enable-inspector") == 0) {
options.enable_inspector = true;
argv[i] = NULL;
argv[i] = nullptr;
} else if (strncmp(argv[i], "--lcov=", 7) == 0) {
options.lcov_file = argv[i] + 7;
argv[i] = NULL;
argv[i] = nullptr;
} else if (strcmp(argv[i], "--disable-in-process-stack-traces") == 0) {
options.disable_in_process_stack_traces = true;
argv[i] = NULL;
argv[i] = nullptr;
#ifdef V8_OS_POSIX
} else if (strncmp(argv[i], "--read-from-tcp-port=", 21) == 0) {
options.read_from_tcp_port = atoi(argv[i] + 21);
argv[i] = NULL;
argv[i] = nullptr;
#endif // V8_OS_POSIX
} else if (strcmp(argv[i], "--enable-os-system") == 0) {
options.enable_os_system = true;
argv[i] = NULL;
argv[i] = nullptr;
}
}

View File

@ -63,13 +63,13 @@ class CounterMap {
Counter* Lookup(const char* name) {
base::HashMap::Entry* answer =
hash_map_.Lookup(const_cast<char*>(name), Hash(name));
if (!answer) return NULL;
if (!answer) return nullptr;
return reinterpret_cast<Counter*>(answer->value);
}
void Set(const char* name, Counter* value) {
base::HashMap::Entry* answer =
hash_map_.LookupOrInsert(const_cast<char*>(name), Hash(name));
DCHECK(answer != NULL);
DCHECK(answer != nullptr);
answer->value = value;
}
class Iterator {
@ -77,7 +77,7 @@ class CounterMap {
explicit Iterator(CounterMap* map)
: map_(&map->hash_map_), entry_(map_->Start()) { }
void Next() { entry_ = map_->Next(entry_); }
bool More() { return entry_ != NULL; }
bool More() { return entry_ != nullptr; }
const char* CurrentKey() { return static_cast<const char*>(entry_->key); }
Counter* CurrentValue() { return static_cast<Counter*>(entry_->value); }
private:
@ -94,13 +94,13 @@ class CounterMap {
class SourceGroup {
public:
SourceGroup() :
next_semaphore_(0),
done_semaphore_(0),
thread_(NULL),
argv_(NULL),
begin_offset_(0),
end_offset_(0) {}
SourceGroup()
: next_semaphore_(0),
done_semaphore_(0),
thread_(nullptr),
argv_(nullptr),
begin_offset_(0),
end_offset_(0) {}
~SourceGroup();
@ -297,13 +297,13 @@ class ShellOptions {
enable_inspector(false),
num_isolates(1),
compile_options(v8::ScriptCompiler::kNoCompileOptions),
isolate_sources(NULL),
icu_data_file(NULL),
natives_blob(NULL),
snapshot_blob(NULL),
isolate_sources(nullptr),
icu_data_file(nullptr),
natives_blob(nullptr),
snapshot_blob(nullptr),
trace_enabled(false),
trace_config(NULL),
lcov_file(NULL),
trace_config(nullptr),
lcov_file(nullptr),
disable_in_process_stack_traces(false),
read_from_tcp_port(-1) {}

View File

@ -337,17 +337,17 @@ int DateCache::DaylightSavingsOffsetInMs(int64_t time_ms) {
void DateCache::ProbeDST(int time_sec) {
DST* before = NULL;
DST* after = NULL;
DST* before = nullptr;
DST* after = nullptr;
DCHECK(before_ != after_);
for (int i = 0; i < kDSTSize; ++i) {
if (dst_[i].start_sec <= time_sec) {
if (before == NULL || before->start_sec < dst_[i].start_sec) {
if (before == nullptr || before->start_sec < dst_[i].start_sec) {
before = &dst_[i];
}
} else if (time_sec < dst_[i].end_sec) {
if (after == NULL || after->end_sec > dst_[i].end_sec) {
if (after == nullptr || after->end_sec > dst_[i].end_sec) {
after = &dst_[i];
}
}
@ -355,16 +355,16 @@ void DateCache::ProbeDST(int time_sec) {
// If before or after segments were not found,
// then set them to any invalid segment.
if (before == NULL) {
if (before == nullptr) {
before = InvalidSegment(before_) ? before_ : LeastRecentlyUsedDST(after);
}
if (after == NULL) {
if (after == nullptr) {
after = InvalidSegment(after_) && before != after_
? after_ : LeastRecentlyUsedDST(before);
}
DCHECK(before != NULL);
DCHECK(after != NULL);
DCHECK(before != nullptr);
DCHECK(after != nullptr);
DCHECK(before != after);
DCHECK(InvalidSegment(before) || before->start_sec <= time_sec);
DCHECK(InvalidSegment(after) || time_sec < after->start_sec);
@ -377,10 +377,10 @@ void DateCache::ProbeDST(int time_sec) {
DateCache::DST* DateCache::LeastRecentlyUsedDST(DST* skip) {
DST* result = NULL;
DST* result = nullptr;
for (int i = 0; i < kDSTSize; ++i) {
if (&dst_[i] == skip) continue;
if (result == NULL || result->last_used > dst_[i].last_used) {
if (result == nullptr || result->last_used > dst_[i].last_used) {
result = &dst_[i];
}
}

View File

@ -43,7 +43,7 @@ class DateCache {
virtual ~DateCache() {
delete tz_cache_;
tz_cache_ = NULL;
tz_cache_ = nullptr;
}

View File

@ -32,10 +32,10 @@ MaybeHandle<Object> DebugEvaluate::Global(Isolate* isolate,
// Enter the top context from before the debugger was invoked.
SaveContext save(isolate);
SaveContext* top = &save;
while (top != NULL && IsDebugContext(isolate, *top->context())) {
while (top != nullptr && IsDebugContext(isolate, *top->context())) {
top = top->prev();
}
if (top != NULL) isolate->set_context(*top->context());
if (top != nullptr) isolate->set_context(*top->context());
// Get the native context now set to the top context from before the
// debugger was invoked.
@ -101,8 +101,8 @@ MaybeHandle<Object> DebugEvaluate::Evaluate(
{
NoSideEffectScope no_side_effect(isolate, throw_on_side_effect);
ASSIGN_RETURN_ON_EXCEPTION(
isolate, result, Execution::Call(isolate, eval_fun, receiver, 0, NULL),
Object);
isolate, result,
Execution::Call(isolate, eval_fun, receiver, 0, nullptr), Object);
}
// Skip the global proxy as it has no properties and always delegates to the

View File

@ -224,10 +224,10 @@ bool FrameInspector::ParameterIsShadowedByContextLocal(
SaveContext* DebugFrameHelper::FindSavedContextForFrame(Isolate* isolate,
StandardFrame* frame) {
SaveContext* save = isolate->save_context();
while (save != NULL && !save->IsBelowFrame(frame)) {
while (save != nullptr && !save->IsBelowFrame(frame)) {
save = save->prev();
}
DCHECK(save != NULL);
DCHECK(save != nullptr);
return save;
}

View File

@ -253,7 +253,7 @@ void ScopeIterator::Next() {
} else {
do {
if (LastNestedScopeChain().scope_info->HasContext()) {
DCHECK(context_->previous() != NULL);
DCHECK(context_->previous() != nullptr);
context_ = Handle<Context>(context_->previous(), isolate_);
}
nested_scope_chain_.pop_back();

View File

@ -46,7 +46,7 @@ Debug::Debug(Isolate* isolate)
break_on_exception_(false),
break_on_uncaught_exception_(false),
side_effect_check_failed_(false),
debug_info_list_(NULL),
debug_info_list_(nullptr),
feature_tracker_(isolate),
isolate_(isolate) {
ThreadInit();
@ -282,7 +282,7 @@ void Debug::Iterate(RootVisitor* v) {
v->VisitRootPointer(Root::kDebug, &thread_local_.ignore_step_into_function_);
}
DebugInfoListNode::DebugInfoListNode(DebugInfo* debug_info): next_(NULL) {
DebugInfoListNode::DebugInfoListNode(DebugInfo* debug_info) : next_(nullptr) {
// Globalize the request debug info object and make it weak.
GlobalHandles* global_handles = debug_info->GetIsolate()->global_handles();
debug_info_ = global_handles->Create(debug_info).location();
@ -658,7 +658,7 @@ void Debug::ClearBreakPoints(Handle<DebugInfo> debug_info) {
void Debug::ClearBreakPoint(Handle<Object> break_point_object) {
HandleScope scope(isolate_);
for (DebugInfoListNode* node = debug_info_list_; node != NULL;
for (DebugInfoListNode* node = debug_info_list_; node != nullptr;
node = node->next()) {
Handle<Object> result =
DebugInfo::FindBreakPointInfo(node->debug_info(), break_point_object);
@ -1025,7 +1025,7 @@ void Debug::ClearOneShot() {
// The current implementation just runs through all the breakpoints. When the
// last break point for a function is removed that function is automatically
// removed from the list.
for (DebugInfoListNode* node = debug_info_list_; node != NULL;
for (DebugInfoListNode* node = debug_info_list_; node != nullptr;
node = node->next()) {
Handle<DebugInfo> debug_info = node->debug_info();
ClearBreakPoints(debug_info);
@ -1201,12 +1201,12 @@ void Debug::RecordGenerator(Handle<JSGeneratorObject> generator_object) {
class SharedFunctionInfoFinder {
public:
explicit SharedFunctionInfoFinder(int target_position)
: current_candidate_(NULL),
current_candidate_closure_(NULL),
: current_candidate_(nullptr),
current_candidate_closure_(nullptr),
current_start_position_(kNoSourcePosition),
target_position_(target_position) {}
void NewCandidate(SharedFunctionInfo* shared, JSFunction* closure = NULL) {
void NewCandidate(SharedFunctionInfo* shared, JSFunction* closure = nullptr) {
if (!shared->IsSubjectToDebugging()) return;
int start_position = shared->function_token_position();
if (start_position == kNoSourcePosition) {
@ -1216,11 +1216,11 @@ class SharedFunctionInfoFinder {
if (start_position > target_position_) return;
if (target_position_ > shared->end_position()) return;
if (current_candidate_ != NULL) {
if (current_candidate_ != nullptr) {
if (current_start_position_ == start_position &&
shared->end_position() == current_candidate_->end_position()) {
// If we already have a matching closure, do not throw it away.
if (current_candidate_closure_ != NULL && closure == NULL) return;
if (current_candidate_closure_ != nullptr && closure == nullptr) return;
// If a top-level function contains only one function
// declaration the source for the top-level and the function
// is the same. In that case prefer the non top-level function.
@ -1272,7 +1272,7 @@ Handle<Object> Debug::FindSharedFunctionInfoInScript(Handle<Script> script,
finder.NewCandidate(info);
}
shared = finder.Result();
if (shared == NULL) break;
if (shared == nullptr) break;
// We found it if it's already compiled.
if (shared->is_compiled()) {
Handle<SharedFunctionInfo> shared_handle(shared);
@ -1408,7 +1408,7 @@ void Debug::FreeDebugInfoListNode(DebugInfoListNode* prev,
DebugInfoListNode* node) {
DCHECK(node->debug_info()->IsEmpty());
// Unlink from list. If prev is NULL we are looking at the first element.
// Unlink from list. If prev is nullptr we are looking at the first element.
if (prev == nullptr) {
debug_info_list_ = node->next();
} else {
@ -1565,7 +1565,7 @@ void Debug::OnPromiseReject(Handle<Object> promise, Handle<Object> value) {
namespace {
v8::Local<v8::Context> GetDebugEventContext(Isolate* isolate) {
Handle<Context> context = isolate->debug()->debugger_entry()->GetContext();
// Isolate::context() may have been NULL when "script collected" event
// Isolate::context() may have been nullptr when "script collected" event
// occurred.
if (context.is_null()) return v8::Local<v8::Context>();
Handle<Context> native_context(context->native_context());

View File

@ -754,8 +754,8 @@ class FeedbackVectorFixer {
static void IterateJSFunctions(Handle<SharedFunctionInfo> shared_info,
Visitor* visitor) {
HeapIterator iterator(shared_info->GetHeap());
for (HeapObject* obj = iterator.next(); obj != NULL;
obj = iterator.next()) {
for (HeapObject* obj = iterator.next(); obj != nullptr;
obj = iterator.next()) {
if (obj->IsJSFunction()) {
JSFunction* function = JSFunction::cast(obj);
if (function->shared() == *shared_info) {
@ -1108,9 +1108,7 @@ class MultipleFunctionTarget {
LiveEdit::FunctionPatchabilityStatus status) {
return CheckActivation(old_shared_array_, result_, frame, status);
}
const char* GetNotFoundMessage() const {
return NULL;
}
const char* GetNotFoundMessage() const { return nullptr; }
bool FrameUsesNewTarget(StackFrame* frame) {
if (!frame->is_java_script()) return false;
JavaScriptFrame* jsframe = JavaScriptFrame::cast(frame);
@ -1238,25 +1236,25 @@ static const char* DropActivationsInActiveThreadImpl(Isolate* isolate,
if (frame->is_java_script()) {
if (target.MatchActivation(frame, non_droppable_reason)) {
// Fail.
return NULL;
return nullptr;
}
if (non_droppable_reason ==
LiveEdit::FUNCTION_BLOCKED_UNDER_GENERATOR &&
!target_frame_found) {
// Fail.
target.set_status(non_droppable_reason);
return NULL;
return nullptr;
}
}
}
}
// We cannot restart a frame that uses new.target.
if (target.FrameUsesNewTarget(frames[bottom_js_frame_index])) return NULL;
if (target.FrameUsesNewTarget(frames[bottom_js_frame_index])) return nullptr;
if (!do_drop) {
// We are in check-only mode.
return NULL;
return nullptr;
}
if (!target_frame_found) {
@ -1269,7 +1267,7 @@ static const char* DropActivationsInActiveThreadImpl(Isolate* isolate,
}
debug->ScheduleFrameRestart(frames[bottom_js_frame_index]);
return NULL;
return nullptr;
}
@ -1299,7 +1297,7 @@ static const char* DropActivationsInActiveThread(
SetElementSloppy(result, i, replaced);
}
}
return NULL;
return nullptr;
}
@ -1315,8 +1313,8 @@ bool LiveEdit::FindActiveGenerators(Handle<FixedArray> shared_info_array,
Heap* heap = isolate->heap();
HeapIterator iterator(heap, HeapIterator::kFilterUnreachable);
HeapObject* obj = NULL;
while ((obj = iterator.next()) != NULL) {
HeapObject* obj = nullptr;
while ((obj = iterator.next()) != nullptr) {
if (!obj->IsJSGeneratorObject()) continue;
JSGeneratorObject* gen = JSGeneratorObject::cast(obj);
@ -1408,7 +1406,7 @@ Handle<JSArray> LiveEdit::CheckAndDropActivations(
// Try to drop activations from the current stack.
const char* error_message = DropActivationsInActiveThread(
old_shared_array, new_shared_array, result, do_drop);
if (error_message != NULL) {
if (error_message != nullptr) {
// Add error message as an array extra element.
Handle<String> str =
isolate->factory()->NewStringFromAsciiChecked(error_message);
@ -1456,15 +1454,14 @@ class SingleFrameTarget {
LiveEdit::FunctionPatchabilityStatus m_saved_status;
};
// Finds a drops required frame and all frames above.
// Returns error message or NULL.
// Returns error message or nullptr.
const char* LiveEdit::RestartFrame(JavaScriptFrame* frame) {
SingleFrameTarget target(frame);
const char* result =
DropActivationsInActiveThreadImpl(frame->isolate(), target, true);
if (result != NULL) {
if (result != nullptr) {
return result;
}
if (target.saved_status() == LiveEdit::FUNCTION_BLOCKED_UNDER_NATIVE_CODE) {
@ -1473,7 +1470,7 @@ const char* LiveEdit::RestartFrame(JavaScriptFrame* frame) {
if (target.saved_status() == LiveEdit::FUNCTION_BLOCKED_UNDER_GENERATOR) {
return "Function is blocked under a generator activation";
}
return NULL;
return nullptr;
}
Handle<JSArray> LiveEditFunctionTracker::Collect(FunctionLiteral* node,
@ -1541,7 +1538,7 @@ Handle<Object> LiveEditFunctionTracker::SerializeFunctionScope(Scope* scope) {
// variables in the whole scope chain. Null-named slots delimit
// scopes of this chain.
Scope* current_scope = scope;
while (current_scope != NULL) {
while (current_scope != nullptr) {
HandleScope handle_scope(isolate_);
for (Variable* var : *current_scope->locals()) {
if (!var->IsContextSlot()) continue;

View File

@ -123,7 +123,7 @@ class LiveEdit : AllStatic {
bool do_drop);
// Restarts the call frame and completely drops all frames above it.
// Return error message or NULL.
// Return error message or nullptr.
static const char* RestartFrame(JavaScriptFrame* frame);
// A copy of this is in liveedit.js.

View File

@ -27,13 +27,11 @@ namespace internal {
static MemoryChunk* AllocateCodeChunk(MemoryAllocator* allocator) {
return allocator->AllocateChunk(Deoptimizer::GetMaxDeoptTableSize(),
MemoryAllocator::GetCommitPageSize(),
EXECUTABLE, NULL);
EXECUTABLE, nullptr);
}
DeoptimizerData::DeoptimizerData(MemoryAllocator* allocator)
: allocator_(allocator),
current_(NULL) {
: allocator_(allocator), current_(nullptr) {
for (int i = 0; i <= Deoptimizer::kLastBailoutType; ++i) {
deopt_entry_code_entries_[i] = -1;
deopt_entry_code_[i] = AllocateCodeChunk(allocator);
@ -44,7 +42,7 @@ DeoptimizerData::DeoptimizerData(MemoryAllocator* allocator)
DeoptimizerData::~DeoptimizerData() {
for (int i = 0; i <= Deoptimizer::kLastBailoutType; ++i) {
allocator_->Free<MemoryAllocator::kFull>(deopt_entry_code_[i]);
deopt_entry_code_[i] = NULL;
deopt_entry_code_[i] = nullptr;
}
}
@ -62,7 +60,7 @@ Code* Deoptimizer::FindDeoptimizingCode(Address addr) {
element = code->next_code_link();
}
}
return NULL;
return nullptr;
}
@ -76,7 +74,7 @@ Deoptimizer* Deoptimizer::New(JSFunction* function,
Isolate* isolate) {
Deoptimizer* deoptimizer = new Deoptimizer(isolate, function, type,
bailout_id, from, fp_to_sp_delta);
CHECK(isolate->deoptimizer_data()->current_ == NULL);
CHECK(isolate->deoptimizer_data()->current_ == nullptr);
isolate->deoptimizer_data()->current_ = deoptimizer;
return deoptimizer;
}
@ -100,7 +98,7 @@ Deoptimizer* Deoptimizer::Grab(Isolate* isolate) {
Deoptimizer* result = isolate->deoptimizer_data()->current_;
CHECK_NOT_NULL(result);
result->DeleteFrameDescriptions();
isolate->deoptimizer_data()->current_ = NULL;
isolate->deoptimizer_data()->current_ = nullptr;
return result;
}
@ -194,7 +192,7 @@ void Deoptimizer::DeoptimizeMarkedCodeForContext(Context* context) {
DisallowHeapAllocation no_allocation;
Isolate* isolate = context->GetHeap()->isolate();
Code* topmost_optimized_code = NULL;
Code* topmost_optimized_code = nullptr;
bool safe_to_deopt_topmost_optimized_code = false;
#ifdef DEBUG
// Make sure all activations of optimized code can deopt at their current PC.
@ -224,9 +222,9 @@ void Deoptimizer::DeoptimizeMarkedCodeForContext(Context* context) {
deopt_index != Safepoint::kNoDeoptimizationIndex ||
is_non_deoptimizing_asm_code;
bool is_builtin_code = code->kind() == Code::BUILTIN;
DCHECK(topmost_optimized_code == NULL || safe_if_deopt_triggered ||
DCHECK(topmost_optimized_code == nullptr || safe_if_deopt_triggered ||
is_non_deoptimizing_asm_code || is_builtin_code);
if (topmost_optimized_code == NULL) {
if (topmost_optimized_code == nullptr) {
topmost_optimized_code = code;
safe_to_deopt_topmost_optimized_code = safe_if_deopt_triggered;
}
@ -241,7 +239,7 @@ void Deoptimizer::DeoptimizeMarkedCodeForContext(Context* context) {
// Move marked code from the optimized code list to the deoptimized
// code list.
// Walk over all optimized code objects in this native context.
Code* prev = NULL;
Code* prev = nullptr;
Object* element = context->OptimizedCodeListHead();
while (!element->IsUndefined(isolate)) {
Code* code = Code::cast(element);
@ -253,7 +251,7 @@ void Deoptimizer::DeoptimizeMarkedCodeForContext(Context* context) {
code->InvalidateEmbeddedObjects();
codes.insert(code);
if (prev != NULL) {
if (prev != nullptr) {
// Skip this code in the optimized code list.
prev->set_next_code_link(next);
} else {
@ -380,7 +378,7 @@ const char* Deoptimizer::MessageFor(BailoutType type) {
case LAZY: return "lazy";
}
FATAL("Unsupported deopt type");
return NULL;
return nullptr;
}
namespace {
@ -431,11 +429,12 @@ Deoptimizer::Deoptimizer(Isolate* isolate, JSFunction* function,
DCHECK(from != nullptr);
compiled_code_ = FindOptimizedCode();
DCHECK(compiled_code_ != NULL);
DCHECK(compiled_code_ != nullptr);
DCHECK(function->IsJSFunction());
trace_scope_ =
FLAG_trace_deopt ? new CodeTracer::Scope(isolate->GetCodeTracer()) : NULL;
trace_scope_ = FLAG_trace_deopt
? new CodeTracer::Scope(isolate->GetCodeTracer())
: nullptr;
#ifdef DEBUG
DCHECK(AllowHeapAllocation::IsAllowed());
disallow_heap_allocation_ = new DisallowHeapAllocation();
@ -468,7 +467,7 @@ Deoptimizer::Deoptimizer(Isolate* isolate, JSFunction* function,
Code* Deoptimizer::FindOptimizedCode() {
Code* compiled_code = FindDeoptimizingCode(from_);
return (compiled_code == NULL)
return (compiled_code == nullptr)
? static_cast<Code*>(isolate_->FindCodeObject(from_))
: compiled_code;
}
@ -491,8 +490,8 @@ Handle<Code> Deoptimizer::compiled_code() const {
}
Deoptimizer::~Deoptimizer() {
DCHECK(input_ == NULL && output_ == NULL);
DCHECK(disallow_heap_allocation_ == NULL);
DCHECK(input_ == nullptr && output_ == nullptr);
DCHECK(disallow_heap_allocation_ == nullptr);
delete trace_scope_;
}
@ -503,13 +502,13 @@ void Deoptimizer::DeleteFrameDescriptions() {
if (output_[i] != input_) delete output_[i];
}
delete[] output_;
input_ = NULL;
output_ = NULL;
input_ = nullptr;
output_ = nullptr;
#ifdef DEBUG
DCHECK(!AllowHeapAllocation::IsAllowed());
DCHECK(disallow_heap_allocation_ != NULL);
DCHECK(disallow_heap_allocation_ != nullptr);
delete disallow_heap_allocation_;
disallow_heap_allocation_ = NULL;
disallow_heap_allocation_ = nullptr;
#endif // DEBUG
}
@ -519,7 +518,7 @@ Address Deoptimizer::GetDeoptimizationEntry(Isolate* isolate,
BailoutType type,
GetEntryMode mode) {
CHECK_GE(id, 0);
if (id >= kMaxNumberOfEntries) return NULL;
if (id >= kMaxNumberOfEntries) return nullptr;
if (mode == ENSURE_ENTRY_CODE) {
EnsureCodeForDeoptimizationEntry(isolate, type, id);
} else {
@ -619,7 +618,7 @@ void Deoptimizer::DoComputeOutputFrames() {
}
}
if (trace_scope_ != NULL) {
if (trace_scope_ != nullptr) {
timer.Start();
PrintF(trace_scope_->file(), "[deoptimizing (DEOPT %s): begin ",
MessageFor(bailout_type_));
@ -666,10 +665,10 @@ void Deoptimizer::DoComputeOutputFrames() {
count = catch_handler_frame_index + 1;
}
DCHECK(output_ == NULL);
DCHECK(output_ == nullptr);
output_ = new FrameDescription*[count];
for (size_t i = 0; i < count; ++i) {
output_[i] = NULL;
output_[i] = nullptr;
}
output_count_ = static_cast<int>(count);
@ -709,7 +708,7 @@ void Deoptimizer::DoComputeOutputFrames() {
}
// Print some helpful diagnostic information.
if (trace_scope_ != NULL) {
if (trace_scope_ != nullptr) {
double ms = timer.Elapsed().InMillisecondsF();
int index = output_count_ - 1; // Index of the topmost frame.
PrintF(trace_scope_->file(), "[deoptimizing (%s): end ",
@ -750,7 +749,7 @@ void Deoptimizer::DoComputeInterpretedFrame(TranslatedFrame* translated_frame,
Object* function = value_iterator->GetRawValue();
value_iterator++;
input_index++;
if (trace_scope_ != NULL) {
if (trace_scope_ != nullptr) {
PrintF(trace_scope_->file(), " translating interpreted frame ");
std::unique_ptr<char[]> name = shared->DebugName()->ToCString();
PrintF(trace_scope_->file(), "%s", name.get());
@ -1017,7 +1016,7 @@ void Deoptimizer::DoComputeArgumentsAdaptorFrame(
Object* function = value_iterator->GetRawValue();
value_iterator++;
input_index++;
if (trace_scope_ != NULL) {
if (trace_scope_ != nullptr) {
PrintF(trace_scope_->file(),
" translating arguments adaptor => height=%d\n", height_in_bytes);
}
@ -1032,7 +1031,7 @@ void Deoptimizer::DoComputeArgumentsAdaptorFrame(
// Arguments adaptor can not be topmost.
CHECK(frame_index < output_count_ - 1);
CHECK(output_[frame_index] == NULL);
CHECK(output_[frame_index] == nullptr);
output_[frame_index] = output_frame;
// The top address of the frame is computed from the previous frame's top and
@ -1164,7 +1163,7 @@ void Deoptimizer::DoComputeConstructStubFrame(TranslatedFrame* translated_frame,
JSFunction* function = JSFunction::cast(value_iterator->GetRawValue());
value_iterator++;
input_index++;
if (trace_scope_ != NULL) {
if (trace_scope_ != nullptr) {
PrintF(trace_scope_->file(),
" translating construct stub => bailout_id=%d (%s), height=%d\n",
bailout_id.ToInt(),
@ -1181,7 +1180,7 @@ void Deoptimizer::DoComputeConstructStubFrame(TranslatedFrame* translated_frame,
// Construct stub can not be topmost.
DCHECK(frame_index > 0 && frame_index < output_count_);
DCHECK(output_[frame_index] == NULL);
DCHECK(output_[frame_index] == nullptr);
output_[frame_index] = output_frame;
// The top address of the frame is computed from the previous frame's top and
@ -1363,7 +1362,7 @@ void Deoptimizer::DoComputeAccessorStubFrame(TranslatedFrame* translated_frame,
}
const char* kind = is_setter_stub_frame ? "setter" : "getter";
if (trace_scope_ != NULL) {
if (trace_scope_ != nullptr) {
PrintF(trace_scope_->file(),
" translating %s stub => height=%u\n", kind, height_in_bytes);
}
@ -1624,7 +1623,7 @@ void Deoptimizer::DoComputeBuiltinContinuation(
}
CHECK_EQ(java_script_builtin, has_argc);
if (trace_scope_ != NULL) {
if (trace_scope_ != nullptr) {
PrintF(trace_scope_->file(),
" translating BuiltinContinuation to %s,"
" register param count %d,"
@ -2002,7 +2001,7 @@ void Deoptimizer::EnsureCodeForDeoptimizationEntry(Isolate* isolate,
while (max_entry_id >= entry_count) entry_count *= 2;
CHECK(entry_count <= Deoptimizer::kMaxNumberOfEntries);
MacroAssembler masm(isolate, NULL, 16 * KB, CodeObjectRequired::kYes);
MacroAssembler masm(isolate, nullptr, 16 * KB, CodeObjectRequired::kYes);
masm.set_emit_debug_code(false);
GenerateDeoptimizationEntries(&masm, entry_count, type);
CodeDesc desc;

View File

@ -39,14 +39,14 @@ class V8NameConverter: public disasm::NameConverter {
const char* V8NameConverter::NameOfAddress(byte* pc) const {
const char* name =
code_ == NULL ? NULL : code_->GetIsolate()->builtins()->Lookup(pc);
code_ == nullptr ? nullptr : code_->GetIsolate()->builtins()->Lookup(pc);
if (name != NULL) {
if (name != nullptr) {
SNPrintF(v8_buffer_, "%p (%s)", static_cast<void*>(pc), name);
return v8_buffer_.start();
}
if (code_ != NULL) {
if (code_ != nullptr) {
int offs = static_cast<int>(pc - code_->instruction_start());
// print as code offset, if it seems reasonable
if (0 <= offs && offs < code_->instruction_size()) {
@ -62,7 +62,7 @@ const char* V8NameConverter::NameOfAddress(byte* pc) const {
const char* V8NameConverter::NameInCode(byte* addr) const {
// The V8NameConverter is used for well known code, so we can "safely"
// dereference pointers in generated code.
return (code_ != NULL) ? reinterpret_cast<const char*>(addr) : "";
return (code_ != nullptr) ? reinterpret_cast<const char*>(addr) : "";
}
@ -166,8 +166,8 @@ static int DecodeIt(Isolate* isolate, std::ostream* os,
StringBuilder out(out_buffer.start(), out_buffer.length());
byte* pc = begin;
disasm::Disassembler d(converter);
RelocIterator* it = NULL;
if (converter.code() != NULL) {
RelocIterator* it = nullptr;
if (converter.code() != nullptr) {
it = new RelocIterator(converter.code());
} else {
// No relocation information when printing code stubs.
@ -191,8 +191,8 @@ static int DecodeIt(Isolate* isolate, std::ostream* os,
*reinterpret_cast<int32_t*>(pc), num_const);
constants = num_const;
pc += 4;
} else if (it != NULL && !it->done() && it->rinfo()->pc() == pc &&
it->rinfo()->rmode() == RelocInfo::INTERNAL_REFERENCE) {
} else if (it != nullptr && !it->done() && it->rinfo()->pc() == pc &&
it->rinfo()->rmode() == RelocInfo::INTERNAL_REFERENCE) {
// raw pointer embedded in code stream, e.g., jump table
byte* ptr = *reinterpret_cast<byte**>(pc);
SNPrintF(
@ -210,7 +210,7 @@ static int DecodeIt(Isolate* isolate, std::ostream* os,
std::vector<byte*> pcs;
std::vector<RelocInfo::Mode> rmodes;
std::vector<intptr_t> datas;
if (it != NULL) {
if (it != nullptr) {
while (!it->done() && it->rinfo()->pc() < pc) {
if (RelocInfo::IsComment(it->rinfo()->rmode())) {
// For comments just collect the text.
@ -274,7 +274,7 @@ static int DecodeIt(Isolate* isolate, std::ostream* os,
}
// Emit comments following the last instruction (if any).
if (it != NULL) {
if (it != nullptr) {
for ( ; !it->done(); it->next()) {
if (RelocInfo::IsComment(it->rinfo()->rmode())) {
out.AddFormatted(" %s",

View File

@ -17,7 +17,7 @@ class Disassembler : public AllStatic {
// instruction could be decoded.
// the code object is used for name resolution and may be null.
static int Decode(Isolate* isolate, std::ostream* os, byte* begin, byte* end,
Code* code = NULL);
Code* code = nullptr);
};
} // namespace internal

View File

@ -4181,7 +4181,7 @@ class SlowStringWrapperElementsAccessor
void CheckArrayAbuse(Handle<JSObject> obj, const char* op, uint32_t index,
bool allow_appending) {
DisallowHeapAllocation no_allocation;
Object* raw_length = NULL;
Object* raw_length = nullptr;
const char* elements_type = "array";
if (obj->IsJSArray()) {
JSArray* array = JSArray::cast(*obj);
@ -4323,11 +4323,11 @@ void ElementsAccessor::InitializeOncePerProcess() {
void ElementsAccessor::TearDown() {
if (elements_accessors_ == NULL) return;
if (elements_accessors_ == nullptr) return;
#define ACCESSOR_DELETE(Class, Kind, Store) delete elements_accessors_[Kind];
ELEMENTS_LIST(ACCESSOR_DELETE)
#undef ACCESSOR_DELETE
elements_accessors_ = NULL;
elements_accessors_ = nullptr;
}
Handle<JSArray> ElementsAccessor::Concat(Isolate* isolate, Arguments* args,
@ -4382,6 +4382,6 @@ Handle<JSArray> ElementsAccessor::Concat(Isolate* isolate, Arguments* args,
return result_array;
}
ElementsAccessor** ElementsAccessor::elements_accessors_ = NULL;
ElementsAccessor** ElementsAccessor::elements_accessors_ = nullptr;
} // namespace internal
} // namespace v8

Some files were not shown because too many files have changed in this diff Show More