4115 return JNI_EVERSION;
4116 }
4117 */
4118
4119 Thread* t = Thread::current_or_null();
4120 if (t != NULL) {
4121 // If the thread has been attached this operation is a no-op
4122 *(JNIEnv**)penv = ((JavaThread*) t)->jni_environment();
4123 return JNI_OK;
4124 }
4125
4126 // Create a thread and mark it as attaching so it will be skipped by the
4127 // ThreadsListEnumerator - see CR 6404306
4128 JavaThread* thread = new JavaThread(true);
4129
4130 // Set correct safepoint info. The thread is going to call into Java when
4131 // initializing the Java level thread object. Hence, the correct state must
4132 // be set in order for the Safepoint code to deal with it correctly.
4133 thread->set_thread_state(_thread_in_vm);
4134 thread->record_stack_base_and_size();
4135 thread->initialize_thread_current();
4136
4137 if (!os::create_attached_thread(thread)) {
4138 thread->smr_delete();
4139 return JNI_ERR;
4140 }
4141 // Enable stack overflow checks
4142 thread->create_stack_guard_pages();
4143
4144 thread->initialize_tlab();
4145
4146 thread->cache_global_variables();
4147
4148 // Crucial that we do not have a safepoint check for this thread, since it has
4149 // not been added to the Thread list yet.
4150 { Threads_lock->lock_without_safepoint_check();
4151 // This must be inside this lock in order to get FullGCALot to work properly, i.e., to
4152 // avoid this thread trying to do a GC before it is added to the thread-list
4153 thread->set_active_handles(JNIHandleBlock::allocate_block());
4154 Threads::add(thread, daemon);
|
4115 return JNI_EVERSION;
4116 }
4117 */
4118
4119 Thread* t = Thread::current_or_null();
4120 if (t != NULL) {
4121 // If the thread has been attached this operation is a no-op
4122 *(JNIEnv**)penv = ((JavaThread*) t)->jni_environment();
4123 return JNI_OK;
4124 }
4125
4126 // Create a thread and mark it as attaching so it will be skipped by the
4127 // ThreadsListEnumerator - see CR 6404306
4128 JavaThread* thread = new JavaThread(true);
4129
4130 // Set correct safepoint info. The thread is going to call into Java when
4131 // initializing the Java level thread object. Hence, the correct state must
4132 // be set in order for the Safepoint code to deal with it correctly.
4133 thread->set_thread_state(_thread_in_vm);
4134 thread->record_stack_base_and_size();
4135 thread->register_thread_stack_with_NMT();
4136 thread->initialize_thread_current();
4137
4138 if (!os::create_attached_thread(thread)) {
4139 thread->smr_delete();
4140 return JNI_ERR;
4141 }
4142 // Enable stack overflow checks
4143 thread->create_stack_guard_pages();
4144
4145 thread->initialize_tlab();
4146
4147 thread->cache_global_variables();
4148
4149 // Crucial that we do not have a safepoint check for this thread, since it has
4150 // not been added to the Thread list yet.
4151 { Threads_lock->lock_without_safepoint_check();
4152 // This must be inside this lock in order to get FullGCALot to work properly, i.e., to
4153 // avoid this thread trying to do a GC before it is added to the thread-list
4154 thread->set_active_handles(JNIHandleBlock::allocate_block());
4155 Threads::add(thread, daemon);
|