Replace NULL with nullptr

Also fixed some lines that were too long, and a few other minor
details.

Change-Id: I6efba5fb6e03eb5d0a300fddb2a75bf8e2f175cb
diff --git a/runtime/stack.cc b/runtime/stack.cc
index 4ae49dd..aa3e320 100644
--- a/runtime/stack.cc
+++ b/runtime/stack.cc
@@ -36,12 +36,12 @@
 mirror::Object* ShadowFrame::GetThisObject() const {
   mirror::ArtMethod* m = GetMethod();
   if (m->IsStatic()) {
-    return NULL;
+    return nullptr;
   } else if (m->IsNative()) {
     return GetVRegReference(0);
   } else {
     const DexFile::CodeItem* code_item = m->GetCodeItem();
-    CHECK(code_item != NULL) << PrettyMethod(m);
+    CHECK(code_item != nullptr) << PrettyMethod(m);
     uint16_t reg = code_item->registers_size_ - code_item->ins_size_;
     return GetVRegReference(reg);
   }
@@ -50,7 +50,7 @@
 mirror::Object* ShadowFrame::GetThisObject(uint16_t num_ins) const {
   mirror::ArtMethod* m = GetMethod();
   if (m->IsStatic()) {
-    return NULL;
+    return nullptr;
   } else {
     return GetVRegReference(NumberOfVRegs() - num_ins);
   }
@@ -58,9 +58,9 @@
 
 size_t ManagedStack::NumJniShadowFrameReferences() const {
   size_t count = 0;
-  for (const ManagedStack* current_fragment = this; current_fragment != NULL;
+  for (const ManagedStack* current_fragment = this; current_fragment != nullptr;
        current_fragment = current_fragment->GetLink()) {
-    for (ShadowFrame* current_frame = current_fragment->top_shadow_frame_; current_frame != NULL;
+    for (ShadowFrame* current_frame = current_fragment->top_shadow_frame_; current_frame != nullptr;
          current_frame = current_frame->GetLink()) {
       if (current_frame->GetMethod()->IsNative()) {
         // The JNI ShadowFrame only contains references. (For indirect reference.)
@@ -72,9 +72,9 @@
 }
 
 bool ManagedStack::ShadowFramesContain(StackReference<mirror::Object>* shadow_frame_entry) const {
-  for (const ManagedStack* current_fragment = this; current_fragment != NULL;
+  for (const ManagedStack* current_fragment = this; current_fragment != nullptr;
        current_fragment = current_fragment->GetLink()) {
-    for (ShadowFrame* current_frame = current_fragment->top_shadow_frame_; current_frame != NULL;
+    for (ShadowFrame* current_frame = current_fragment->top_shadow_frame_; current_frame != nullptr;
          current_frame = current_frame->GetLink()) {
       if (current_frame->Contains(shadow_frame_entry)) {
         return true;
@@ -85,23 +85,23 @@
 }
 
 StackVisitor::StackVisitor(Thread* thread, Context* context)
-    : thread_(thread), cur_shadow_frame_(NULL),
-      cur_quick_frame_(NULL), cur_quick_frame_pc_(0), num_frames_(0), cur_depth_(0),
+    : thread_(thread), cur_shadow_frame_(nullptr),
+      cur_quick_frame_(nullptr), cur_quick_frame_pc_(0), num_frames_(0), cur_depth_(0),
       context_(context) {
   DCHECK(thread == Thread::Current() || thread->IsSuspended()) << *thread;
 }
 
 StackVisitor::StackVisitor(Thread* thread, Context* context, size_t num_frames)
-    : thread_(thread), cur_shadow_frame_(NULL),
-      cur_quick_frame_(NULL), cur_quick_frame_pc_(0), num_frames_(num_frames), cur_depth_(0),
+    : thread_(thread), cur_shadow_frame_(nullptr),
+      cur_quick_frame_(nullptr), cur_quick_frame_pc_(0), num_frames_(num_frames), cur_depth_(0),
       context_(context) {
   DCHECK(thread == Thread::Current() || thread->IsSuspended()) << *thread;
 }
 
 uint32_t StackVisitor::GetDexPc(bool abort_on_failure) const {
-  if (cur_shadow_frame_ != NULL) {
+  if (cur_shadow_frame_ != nullptr) {
     return cur_shadow_frame_->GetDexPC();
-  } else if (cur_quick_frame_ != NULL) {
+  } else if (cur_quick_frame_ != nullptr) {
     return GetMethod()->ToDexPc(cur_quick_frame_pc_, abort_on_failure);
   } else {
     return 0;
@@ -183,7 +183,7 @@
     return GetRegisterIfAccessible(reg, kind, val);
   } else {
     const DexFile::CodeItem* code_item = m->GetCodeItem();
-    DCHECK(code_item != nullptr) << PrettyMethod(m);  // Can't be NULL or how would we compile
+    DCHECK(code_item != nullptr) << PrettyMethod(m);  // Can't be null or how would we compile
                                                       // its instructions?
     *val = *GetVRegAddrFromQuickCode(cur_quick_frame_, code_item, frame_info.CoreSpillMask(),
                                      frame_info.FpSpillMask(), frame_info.FrameSizeInBytes(), vreg);
@@ -199,7 +199,7 @@
   CodeInfo code_info = m->GetOptimizedCodeInfo();
   StackMap stack_map = code_info.GetStackMapForNativePcOffset(native_pc_offset);
   const DexFile::CodeItem* code_item = m->GetCodeItem();
-  DCHECK(code_item != nullptr) << PrettyMethod(m);  // Can't be NULL or how would we compile
+  DCHECK(code_item != nullptr) << PrettyMethod(m);  // Can't be null or how would we compile
                                                     // its instructions?
   DCHECK_LT(vreg, code_item->registers_size_);
   uint16_t number_of_dex_registers = code_item->registers_size_;
@@ -297,7 +297,7 @@
     return GetRegisterPairIfAccessible(reg_lo, reg_hi, kind_lo, val);
   } else {
     const DexFile::CodeItem* code_item = m->GetCodeItem();
-    DCHECK(code_item != nullptr) << PrettyMethod(m);  // Can't be NULL or how would we compile
+    DCHECK(code_item != nullptr) << PrettyMethod(m);  // Can't be null or how would we compile
                                                       // its instructions?
     uint32_t* addr = GetVRegAddrFromQuickCode(
         cur_quick_frame_, code_item, frame_info.CoreSpillMask(),
@@ -372,7 +372,7 @@
     return SetRegisterIfAccessible(reg, new_value, kind);
   } else {
     const DexFile::CodeItem* code_item = m->GetCodeItem();
-    DCHECK(code_item != nullptr) << PrettyMethod(m);  // Can't be NULL or how would we compile
+    DCHECK(code_item != nullptr) << PrettyMethod(m);  // Can't be null or how would we compile
                                                       // its instructions?
     uint32_t* addr = GetVRegAddrFromQuickCode(
         cur_quick_frame_, code_item, frame_info.CoreSpillMask(),
@@ -390,7 +390,7 @@
   CodeInfo code_info = m->GetOptimizedCodeInfo();
   StackMap stack_map = code_info.GetStackMapForNativePcOffset(native_pc_offset);
   const DexFile::CodeItem* code_item = m->GetCodeItem();
-  DCHECK(code_item != nullptr) << PrettyMethod(m);  // Can't be NULL or how would we compile
+  DCHECK(code_item != nullptr) << PrettyMethod(m);  // Can't be null or how would we compile
                                                     // its instructions?
   uint16_t number_of_dex_registers = code_item->registers_size_;
   DCHECK_LT(vreg, number_of_dex_registers);
@@ -488,8 +488,8 @@
   }
 }
 
-bool StackVisitor::SetVRegPairFromQuickCode(mirror::ArtMethod* m, uint16_t vreg, uint64_t new_value,
-                                            VRegKind kind_lo, VRegKind kind_hi) {
+bool StackVisitor::SetVRegPairFromQuickCode(
+    mirror::ArtMethod* m, uint16_t vreg, uint64_t new_value, VRegKind kind_lo, VRegKind kind_hi) {
   const void* code_pointer = m->GetQuickOatCodePointer(sizeof(void*));
   DCHECK(code_pointer != nullptr);
   const VmapTable vmap_table(m->GetVmapTable(code_pointer, sizeof(void*)));
@@ -505,7 +505,7 @@
     return SetRegisterPairIfAccessible(reg_lo, reg_hi, new_value, is_float);
   } else {
     const DexFile::CodeItem* code_item = m->GetCodeItem();
-    DCHECK(code_item != nullptr) << PrettyMethod(m);  // Can't be NULL or how would we compile
+    DCHECK(code_item != nullptr) << PrettyMethod(m);  // Can't be null or how would we compile
                                                       // its instructions?
     uint32_t* addr = GetVRegAddrFromQuickCode(
         cur_quick_frame_, code_item, frame_info.CoreSpillMask(),
@@ -515,8 +515,8 @@
   }
 }
 
-bool StackVisitor::SetVRegPairFromOptimizedCode(mirror::ArtMethod* m, uint16_t vreg, uint64_t new_value,
-                                                VRegKind kind_lo, VRegKind kind_hi) {
+bool StackVisitor::SetVRegPairFromOptimizedCode(
+    mirror::ArtMethod* m, uint16_t vreg, uint64_t new_value, VRegKind kind_lo, VRegKind kind_hi) {
   uint32_t low_32bits = Low32Bits(new_value);
   uint32_t high_32bits = High32Bits(new_value);
   bool success = SetVRegFromOptimizedCode(m, vreg, low_32bits, kind_lo);
@@ -585,14 +585,14 @@
 
 uintptr_t StackVisitor::GetReturnPc() const {
   uint8_t* sp = reinterpret_cast<uint8_t*>(GetCurrentQuickFrame());
-  DCHECK(sp != NULL);
+  DCHECK(sp != nullptr);
   uint8_t* pc_addr = sp + GetMethod()->GetReturnPcOffset().SizeValue();
   return *reinterpret_cast<uintptr_t*>(pc_addr);
 }
 
 void StackVisitor::SetReturnPc(uintptr_t new_ret_pc) {
   uint8_t* sp = reinterpret_cast<uint8_t*>(GetCurrentQuickFrame());
-  CHECK(sp != NULL);
+  CHECK(sp != nullptr);
   uint8_t* pc_addr = sp + GetMethod()->GetReturnPcOffset().SizeValue();
   *reinterpret_cast<uintptr_t*>(pc_addr) = new_ret_pc;
 }
@@ -600,7 +600,7 @@
 size_t StackVisitor::ComputeNumFrames(Thread* thread) {
   struct NumFramesVisitor : public StackVisitor {
     explicit NumFramesVisitor(Thread* thread_in)
-        : StackVisitor(thread_in, NULL), frames(0) {}
+        : StackVisitor(thread_in, nullptr), frames(0) {}
 
     bool VisitFrame() OVERRIDE {
       frames++;
@@ -652,7 +652,7 @@
 void StackVisitor::DescribeStack(Thread* thread) {
   struct DescribeStackVisitor : public StackVisitor {
     explicit DescribeStackVisitor(Thread* thread_in)
-        : StackVisitor(thread_in, NULL) {}
+        : StackVisitor(thread_in, nullptr) {}
 
     bool VisitFrame() OVERRIDE SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
       LOG(INFO) << "Frame Id=" << GetFrameId() << " " << DescribeLocation();
@@ -666,7 +666,7 @@
 std::string StackVisitor::DescribeLocation() const {
   std::string result("Visiting method '");
   mirror::ArtMethod* m = GetMethod();
-  if (m == NULL) {
+  if (m == nullptr) {
     return "upcall";
   }
   result += PrettyMethod(m);
@@ -713,24 +713,24 @@
   bool exit_stubs_installed = Runtime::Current()->GetInstrumentation()->AreExitStubsInstalled();
   uint32_t instrumentation_stack_depth = 0;
 
-  for (const ManagedStack* current_fragment = thread_->GetManagedStack(); current_fragment != NULL;
-       current_fragment = current_fragment->GetLink()) {
+  for (const ManagedStack* current_fragment = thread_->GetManagedStack();
+       current_fragment != nullptr; current_fragment = current_fragment->GetLink()) {
     cur_shadow_frame_ = current_fragment->GetTopShadowFrame();
     cur_quick_frame_ = current_fragment->GetTopQuickFrame();
     cur_quick_frame_pc_ = 0;
 
-    if (cur_quick_frame_ != NULL) {  // Handle quick stack frames.
+    if (cur_quick_frame_ != nullptr) {  // Handle quick stack frames.
       // Can't be both a shadow and a quick fragment.
-      DCHECK(current_fragment->GetTopShadowFrame() == NULL);
+      DCHECK(current_fragment->GetTopShadowFrame() == nullptr);
       mirror::ArtMethod* method = cur_quick_frame_->AsMirrorPtr();
-      while (method != NULL) {
+      while (method != nullptr) {
         SanityCheckFrame();
         bool should_continue = VisitFrame();
         if (UNLIKELY(!should_continue)) {
           return;
         }
 
-        if (context_ != NULL) {
+        if (context_ != nullptr) {
           context_->FillCalleeSaves(*this);
         }
         size_t frame_size = method->GetFrameSizeInBytes();
@@ -748,7 +748,8 @@
             if (GetMethod() == Runtime::Current()->GetCalleeSaveMethod(Runtime::kSaveAll)) {
               // Skip runtime save all callee frames which are used to deliver exceptions.
             } else if (instrumentation_frame.interpreter_entry_) {
-              mirror::ArtMethod* callee = Runtime::Current()->GetCalleeSaveMethod(Runtime::kRefsAndArgs);
+              mirror::ArtMethod* callee =
+                  Runtime::Current()->GetCalleeSaveMethod(Runtime::kRefsAndArgs);
               CHECK_EQ(GetMethod(), callee) << "Expected: " << PrettyMethod(callee) << " Found: "
                                             << PrettyMethod(GetMethod());
             } else if (instrumentation_frame.method_ != GetMethod()) {
@@ -771,7 +772,7 @@
         cur_depth_++;
         method = cur_quick_frame_->AsMirrorPtr();
       }
-    } else if (cur_shadow_frame_ != NULL) {
+    } else if (cur_shadow_frame_ != nullptr) {
       do {
         SanityCheckFrame();
         bool should_continue = VisitFrame();
@@ -780,7 +781,7 @@
         }
         cur_depth_++;
         cur_shadow_frame_ = cur_shadow_frame_->GetLink();
-      } while (cur_shadow_frame_ != NULL);
+      } while (cur_shadow_frame_ != nullptr);
     }
     if (include_transitions) {
       bool should_continue = VisitFrame();