Add Thread entry to signal if the thread can call into java
Compiler threads (AOT or JIT) should not call into Java as they have no
peers (which may lead to crashes, e.g. b/33067273)
Bug: 32602185
Bug: 33067273
Test: m test-art-host-run-test; m test-art-host-gtest
Change-Id: I97dda7a5444643db3c5d5318339a65a602f709e8
diff --git a/runtime/thread.h b/runtime/thread.h
index 31cd0eb..411d85f 100644
--- a/runtime/thread.h
+++ b/runtime/thread.h
@@ -881,6 +881,15 @@
--tls32_.disable_thread_flip_count;
}
+ // Returns true if the thread is allowed to call into java.
+ bool CanCallIntoJava() const {
+ return can_call_into_java_;
+ }
+
+ void SetCanCallIntoJava(bool can_call_into_java) {
+ can_call_into_java_ = can_call_into_java;
+ }
+
// Activates single step control for debugging. The thread takes the
// ownership of the given SingleStepControl*. It is deleted by a call
// to DeactivateSingleStepControl or upon thread destruction.
@@ -1588,6 +1597,10 @@
// Pending extra checkpoints if checkpoint_function_ is already used.
std::list<Closure*> checkpoint_overflow_ GUARDED_BY(Locks::thread_suspend_count_lock_);
+ // True if the thread is allowed to call back into java (for e.g. during class resolution).
+ // By default this is true.
+ bool can_call_into_java_;
+
friend class Dbg; // For SetStateUnsafe.
friend class gc::collector::SemiSpace; // For getting stack traces.
friend class Runtime; // For CreatePeer.