Use ResetTlab instead of setting to null

Added a function ResetTlab to reset the TLAB to empty. This is
in case the empty TLAB doesn't have null values.

Bug: 139805154
Test: make
Change-Id: Ife2225fc534999e53f2ecad41fc29e46c90a8817
diff --git a/runtime/gc/space/bump_pointer_space.cc b/runtime/gc/space/bump_pointer_space.cc
index 609ccee..c4fda14 100644
--- a/runtime/gc/space/bump_pointer_space.cc
+++ b/runtime/gc/space/bump_pointer_space.cc
@@ -206,7 +206,7 @@
 void BumpPointerSpace::RevokeThreadLocalBuffersLocked(Thread* thread) {
   objects_allocated_.fetch_add(thread->GetThreadLocalObjectsAllocated(), std::memory_order_relaxed);
   bytes_allocated_.fetch_add(thread->GetThreadLocalBytesAllocated(), std::memory_order_relaxed);
-  thread->SetTlab(nullptr, nullptr, nullptr);
+  thread->ResetTlab();
 }
 
 bool BumpPointerSpace::AllocNewTlab(Thread* self, size_t bytes) {
diff --git a/runtime/gc/space/region_space.cc b/runtime/gc/space/region_space.cc
index 8339822..c8b5669 100644
--- a/runtime/gc/space/region_space.cc
+++ b/runtime/gc/space/region_space.cc
@@ -868,7 +868,7 @@
     r->is_a_tlab_ = false;
     r->thread_ = nullptr;
   }
-  thread->SetTlab(nullptr, nullptr, nullptr);
+  thread->ResetTlab();
 }
 
 size_t RegionSpace::RevokeAllThreadLocalBuffers() {
diff --git a/runtime/thread.cc b/runtime/thread.cc
index 6e57ec6..c3e4afe 100644
--- a/runtime/thread.cc
+++ b/runtime/thread.cc
@@ -2322,6 +2322,7 @@
   tlsPtr_.thread_local_mark_stack = nullptr;
   tls32_.is_transitioning_to_runnable = false;
   tls32_.use_mterp = false;
+  ResetTlab();
 }
 
 void Thread::NotifyInTheadList() {
@@ -4169,8 +4170,12 @@
   tlsPtr_.thread_local_objects = 0;
 }
 
+void Thread::ResetTlab() {
+  SetTlab(nullptr, nullptr, nullptr);
+}
+
 bool Thread::HasTlab() const {
-  bool has_tlab = tlsPtr_.thread_local_pos != nullptr;
+  const bool has_tlab = tlsPtr_.thread_local_pos != nullptr;
   if (has_tlab) {
     DCHECK(tlsPtr_.thread_local_start != nullptr && tlsPtr_.thread_local_end != nullptr);
   } else {
diff --git a/runtime/thread.h b/runtime/thread.h
index 0f6b369..32a620c 100644
--- a/runtime/thread.h
+++ b/runtime/thread.h
@@ -1182,6 +1182,7 @@
   mirror::Object* AllocTlab(size_t bytes);
   void SetTlab(uint8_t* start, uint8_t* end, uint8_t* limit);
   bool HasTlab() const;
+  void ResetTlab();
   uint8_t* GetTlabStart() {
     return tlsPtr_.thread_local_start;
   }