diff options
author | 2024-05-02 10:56:42 +0000 | |
---|---|---|
committer | 2024-05-03 03:44:33 +0000 | |
commit | db15ea652d13811e236e1f12c88807ebfed05da9 (patch) | |
tree | 85d01be01468cd684a01dc0ee2b349867f6f2d6a /runtime/interpreter/interpreter_switch_impl-inl.h | |
parent | f91d21c0b0e4a03102eaa6cfae0f500f8139bc40 (diff) |
Refactor transaction checks in switch interpreter.
Prepare for moving the transactional interpreter from
`runtime/` to `dex2oat/` by moving transaction checking code
to a new file `active_transaction_checker.h`, and breaking
unstarted runtime dependency on transaction code by adding
an indirection with a virtual call through `ClassLinker`.
Consistently return the same value from contraint checks.
Previously we were returning the negated result from the
`CheckWrite{,Value}Constraint()` compared to the value we
received from `Transaction::Write{,Value}Constraint()`.
Test: m test-art-host-gtest
Test: testrunner.py --host --interp-ac
Change-Id: I88a168b6c770932d014e3a40486480590cef0401
Diffstat (limited to 'runtime/interpreter/interpreter_switch_impl-inl.h')
-rw-r--r-- | runtime/interpreter/interpreter_switch_impl-inl.h | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/runtime/interpreter/interpreter_switch_impl-inl.h b/runtime/interpreter/interpreter_switch_impl-inl.h index 8b23715ba6..0c50238e48 100644 --- a/runtime/interpreter/interpreter_switch_impl-inl.h +++ b/runtime/interpreter/interpreter_switch_impl-inl.h @@ -53,6 +53,9 @@ namespace interpreter { template<bool transaction_active, Instruction::Format kFormat> class InstructionHandler { public: + using TransactionChecker = typename std::conditional_t< + transaction_active, ActiveTransactionChecker, InactiveTransactionChecker>; + #define HANDLER_ATTRIBUTES ALWAYS_INLINE FLATTEN WARN_UNUSED REQUIRES_SHARED(Locks::mutator_lock_) HANDLER_ATTRIBUTES bool CheckTransactionAbort() { @@ -332,7 +335,7 @@ class InstructionHandler { if (UNLIKELY(!array->CheckIsValidIndex(index))) { return false; // Pending exception. } - if (transaction_active && !CheckWriteConstraint(Self(), array)) { + if (TransactionChecker::WriteConstraint(Self(), array)) { return false; } array->template SetWithoutChecks<transaction_active>(index, value); @@ -669,10 +672,7 @@ class InstructionHandler { if (LIKELY(c != nullptr)) { // Don't allow finalizable objects to be allocated during a transaction since these can't // be finalized without a started runtime. - if (transaction_active && c->IsFinalizable()) { - AbortTransactionF(Self(), - "Allocating finalizable object in transaction: %s", - c->PrettyDescriptor().c_str()); + if (TransactionChecker::AllocationConstraint(Self(), c)) { return false; // Pending exception. } gc::AllocatorType allocator_type = Runtime::Current()->GetHeap()->GetCurrentAllocator(); @@ -898,8 +898,8 @@ class InstructionHandler { ObjPtr<mirror::Object> val = GetVRegReference(A()); ObjPtr<mirror::ObjectArray<mirror::Object>> array = a->AsObjectArray<mirror::Object>(); if (array->CheckIsValidIndex(index) && array->CheckAssignable(val)) { - if (transaction_active && - (!CheckWriteConstraint(Self(), array) || !CheckWriteValueConstraint(Self(), val))) { + if (TransactionChecker::WriteConstraint(Self(), array) || + TransactionChecker::WriteValueConstraint(Self(), val)) { return false; } array->SetWithoutChecks<transaction_active>(index, val); |