Cleanup transaction support

Updates Thread::CreateInternalStackTrace to support both transactional and
non-transactional modes using template.

Generalizes non-transactional mode for invariant fields (which are set only
once).

Removes ArrayLog::VisitRoots as we never create Array logs of ObjectArray. As
ObjectArray elements are set using Object::SetFieldObject, they are already
recorded in the object logs: the object is the array itself and the offset
corresponds to the element index in this array. And also checks we never log
ObjectArray in array logs.

Fixes location of thrown exception when calling native method during class
initialization.

Change-Id: Idbc368d3b8292b85ff40bc8a7c559e085477bf89
diff --git a/runtime/transaction.cc b/runtime/transaction.cc
index fcda6c9..e18cf04 100644
--- a/runtime/transaction.cc
+++ b/runtime/transaction.cc
@@ -84,19 +84,18 @@
 void Transaction::RecordWriteArray(mirror::Array* array, size_t index, uint64_t value) {
   DCHECK(array != nullptr);
   DCHECK(array->IsArrayInstance());
+  DCHECK(!array->IsObjectArray());
   MutexLock mu(Thread::Current(), log_lock_);
   ArrayLog& array_log = array_logs_[array];
   array_log.LogValue(index, value);
 }
 
 void Transaction::RecordStrongStringInsertion(mirror::String* s, uint32_t hash_code) {
-  DCHECK(s != nullptr);
   InternStringLog log(s, hash_code, InternStringLog::kStrongString, InternStringLog::kInsert);
   LogInternedString(log);
 }
 
 void Transaction::RecordWeakStringInsertion(mirror::String* s, uint32_t hash_code) {
-  DCHECK(s != nullptr);
   InternStringLog log(s, hash_code, InternStringLog::kWeakString, InternStringLog::kInsert);
   LogInternedString(log);
 }
@@ -198,9 +197,7 @@
 
   for (auto it : array_logs_) {
     mirror::Array* old_root = it.first;
-    if (old_root->IsObjectArray()) {
-      it.second.VisitRoots(callback, arg);
-    }
+    CHECK(!old_root->IsObjectArray());
     mirror::Array* new_root = old_root;
     callback(reinterpret_cast<mirror::Object**>(&new_root), arg, 0, kRootUnknown);
     if (new_root != old_root) {
@@ -403,23 +400,12 @@
     case Primitive::kPrimDouble:
       array->AsDoubleArray()->SetWithoutChecks<false>(index, static_cast<double>(value));
       break;
-    case Primitive::kPrimNot: {
-      mirror::ObjectArray<mirror::Object>* obj_array = array->AsObjectArray<mirror::Object>();
-      obj_array->SetWithoutChecks<false>(index, reinterpret_cast<mirror::Object*>(
-          static_cast<uintptr_t>(value)));
+    case Primitive::kPrimNot:
+      LOG(FATAL) << "ObjectArray should be treated as Object";
       break;
-    }
     default:
       LOG(FATAL) << "Unsupported type " << array_type;
   }
 }
 
-void Transaction::ArrayLog::VisitRoots(RootCallback* callback, void* arg) {
-  for (auto& it : array_values_) {
-    mirror::Object* obj = reinterpret_cast<mirror::Object*>(static_cast<uintptr_t>(it.second));
-    callback(&obj, arg, 0, kRootUnknown);
-    it.second = reinterpret_cast<uintptr_t>(obj);
-  }
-}
-
 }  // namespace art