summaryrefslogtreecommitdiff
path: root/runtime/thread.h
diff options
context:
space:
mode:
author Andreas Gampe <agampe@google.com> 2015-06-03 20:27:44 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2015-06-03 20:27:44 +0000
commit99b4dcd19af9343bde1f6fbdb24bb010a70144c9 (patch)
tree7cce7361c88c8b30aeb8cb918af9feac367b0d2a /runtime/thread.h
parent9cfde7b21eeb18040f3264f3b5f66baa34b0c568 (diff)
parent520abbd0edcf333f07164539620ce65258c72383 (diff)
Merge "ART: Refactor Thread::Init" into mnc-dev
Diffstat (limited to 'runtime/thread.h')
-rw-r--r--runtime/thread.h18
1 files changed, 15 insertions, 3 deletions
diff --git a/runtime/thread.h b/runtime/thread.h
index 8c2e215ff8..3f0d0a59a9 100644
--- a/runtime/thread.h
+++ b/runtime/thread.h
@@ -975,7 +975,15 @@ class Thread {
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
void RemoveFromThreadGroup(ScopedObjectAccess& soa) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
- bool Init(ThreadList*, JavaVMExt*) EXCLUSIVE_LOCKS_REQUIRED(Locks::runtime_shutdown_lock_);
+ // Initialize a thread.
+ //
+ // The third parameter is not mandatory. If given, the thread will use this JNIEnvExt. In case
+ // Init succeeds, this means the thread takes ownership of it. If Init fails, it is the caller's
+ // responsibility to destroy the given JNIEnvExt. If the parameter is null, Init will try to
+ // create a JNIEnvExt on its own (and potentially fail at that stage, indicated by a return value
+ // of false).
+ bool Init(ThreadList*, JavaVMExt*, JNIEnvExt* jni_env_ext = nullptr)
+ EXCLUSIVE_LOCKS_REQUIRED(Locks::runtime_shutdown_lock_);
void InitCardTable();
void InitCpu();
void CleanupCpu();
@@ -1111,8 +1119,8 @@ class Thread {
struct PACKED(4) tls_ptr_sized_values {
tls_ptr_sized_values() : card_table(nullptr), exception(nullptr), stack_end(nullptr),
- managed_stack(), suspend_trigger(nullptr), jni_env(nullptr), self(nullptr), opeer(nullptr),
- jpeer(nullptr), stack_begin(nullptr), stack_size(0),
+ managed_stack(), suspend_trigger(nullptr), jni_env(nullptr), tmp_jni_env(nullptr),
+ self(nullptr), opeer(nullptr), jpeer(nullptr), stack_begin(nullptr), stack_size(0),
stack_trace_sample(nullptr), wait_next(nullptr), monitor_enter_object(nullptr),
top_handle_scope(nullptr), class_loader_override(nullptr), long_jump_context(nullptr),
instrumentation_stack(nullptr), debug_invoke_req(nullptr), single_step_control(nullptr),
@@ -1144,6 +1152,10 @@ class Thread {
// Every thread may have an associated JNI environment
JNIEnvExt* jni_env;
+ // Temporary storage to transfer a pre-allocated JNIEnvExt from the creating thread to the
+ // created thread.
+ JNIEnvExt* tmp_jni_env;
+
// Initialized to "this". On certain architectures (such as x86) reading off of Thread::Current
// is easy but getting the address of Thread::Current is hard. This field can be read off of
// Thread::Current to give the address.