Move transaction creation to runtime
Move the transaction creation to runtime instead of passing a pointer to
runtime when EnterTransactionMode. Because later there will be more
places to create transaction so this makes the code cleaner and more
compact.
Test: make test-art-host -j64
Change-Id: I971edf3110eb6634b6e0f7f56256be04517a5281
diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc
index cf04e41..7970b4c 100644
--- a/compiler/driver/compiler_driver.cc
+++ b/compiler/driver/compiler_driver.cc
@@ -2331,10 +2331,8 @@
// a ReaderWriterMutex but we're holding the mutator lock so we fail mutex sanity
// checks in Thread::AssertThreadSuspensionIsAllowable.
Runtime* const runtime = Runtime::Current();
- Transaction transaction;
-
// Run the class initializer in transaction mode.
- runtime->EnterTransactionMode(&transaction);
+ runtime->EnterTransactionMode();
bool success = manager_->GetClassLinker()->EnsureInitialized(soa.Self(), klass, true,
true);
// TODO we detach transaction from runtime to indicate we quit the transactional
@@ -2343,7 +2341,11 @@
{
ScopedAssertNoThreadSuspension ants("Transaction end");
- runtime->ExitTransactionMode();
+
+ if (success) {
+ runtime->ExitTransactionMode();
+ DCHECK(!runtime->IsActiveTransaction());
+ }
if (!success) {
CHECK(soa.Self()->IsExceptionPending());
@@ -2357,7 +2359,7 @@
*file_log << exception->Dump() << "\n";
}
soa.Self()->ClearException();
- transaction.Rollback();
+ runtime->RollbackAndExitTransactionMode();
CHECK_EQ(old_status, klass->GetStatus()) << "Previous class status not restored";
} else if (is_boot_image) {
// For boot image, we want to put the updated status in the oat class since we can't