Add strict flag in transaction
Add a flag named strict_ indicating whether we are compiling app images,
which need more strict constraints to control <clinit>s' behavours.
When the transaction is marked as strict mode, behaviour changes
including nested transactions, field access validation, memory
consumption limit and time out for <clinit> at compile time.
Test: make test-art-host -j64
Change-Id: I7cc0eea161803ad0d7763725d4deaeee21858054
diff --git a/runtime/transaction.cc b/runtime/transaction.cc
index 9e62aa6..b4e35cd 100644
--- a/runtime/transaction.cc
+++ b/runtime/transaction.cc
@@ -34,11 +34,14 @@
static constexpr bool kEnableTransactionStats = false;
Transaction::Transaction()
- : log_lock_("transaction log lock", kTransactionLogLock), aborted_(false) {
+ : log_lock_("transaction log lock", kTransactionLogLock),
+ aborted_(false),
+ strict_(false) {
CHECK(Runtime::Current()->IsAotCompiler());
}
-Transaction::Transaction(mirror::Class* root) : Transaction() {
+Transaction::Transaction(bool strict, mirror::Class* root) : Transaction() {
+ strict_ = strict;
root_ = root;
}
@@ -101,6 +104,11 @@
return aborted_;
}
+bool Transaction::IsStrict() {
+ MutexLock mu(Thread::Current(), log_lock_);
+ return strict_;
+}
+
const std::string& Transaction::GetAbortMessage() {
MutexLock mu(Thread::Current(), log_lock_);
return abort_message_;