1 /* 2 * Copyright (C) 2024 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #include "common_transaction_test.h" 18 19 #include "oat/aot_class_linker.h" 20 #include "runtime.h" 21 22 namespace art HIDDEN { 23 EnterTransactionMode()24void CommonTransactionTestImpl::EnterTransactionMode() { 25 CHECK(!Runtime::Current()->IsActiveTransaction()); 26 AotClassLinker* class_linker = down_cast<AotClassLinker*>(Runtime::Current()->GetClassLinker()); 27 class_linker->EnterTransactionMode(/*strict=*/ false, /*root=*/ nullptr); 28 } 29 ExitTransactionMode()30void CommonTransactionTestImpl::ExitTransactionMode() { 31 AotClassLinker* class_linker = down_cast<AotClassLinker*>(Runtime::Current()->GetClassLinker()); 32 class_linker->ExitTransactionMode(); 33 CHECK(!Runtime::Current()->IsActiveTransaction()); 34 } 35 RollbackAndExitTransactionMode()36void CommonTransactionTestImpl::RollbackAndExitTransactionMode() { 37 AotClassLinker* class_linker = down_cast<AotClassLinker*>(Runtime::Current()->GetClassLinker()); 38 class_linker->RollbackAndExitTransactionMode(); 39 CHECK(!Runtime::Current()->IsActiveTransaction()); 40 } 41 IsTransactionAborted()42bool CommonTransactionTestImpl::IsTransactionAborted() { 43 if (!Runtime::Current()->IsActiveTransaction()) { 44 return false; 45 } 46 AotClassLinker* class_linker = down_cast<AotClassLinker*>(Runtime::Current()->GetClassLinker()); 47 return class_linker->IsTransactionAborted(); 48 } 49 50 } // namespace art 51