8268368: Adopt cast notation for JavaThread conversions
Reviewed-by: dholmes, stefank
This commit is contained in:
parent
b6cfca8a89
commit
cd678a383f
src/hotspot
cpu/zero
os/windows
share
code
compiler
gc
g1
shared
shenandoah
z
jfr
jni
periodic/sampling
recorder
checkpoint
repository
service
stacktrace
support
writers
jvmci
oops
prims
jni.cppjniCheck.cppjvmtiEnter.xsljvmtiEnvBase.cppjvmtiEnvThreadState.cppjvmtiEventController.cppjvmtiExport.cppjvmtiRawMonitor.cppjvmtiTrace.cppuniversalUpcallHandler.cppwhitebox.cpp
runtime
deoptimization.cpphandshake.cppinterfaceSupport.cppinterfaceSupport.inline.hppjava.cppjniHandles.cppmutex.cppobjectMonitor.cppos.cppsafepoint.cppsafepointVerifiers.cppsharedRuntime.cppstackWatermarkSet.cppsweeper.cppsynchronizer.cppthread.cppthread.hppvmOperations.cppvmThread.cpp
services
utilities
@ -100,7 +100,7 @@ void frame::patch_pc(Thread* thread, address pc) {
|
||||
// We borrow this call to set the thread pointer in the interpreter
|
||||
// state; the hook to set up deoptimized frames isn't supplied it.
|
||||
assert(pc == NULL, "should be");
|
||||
get_interpreterState()->set_thread(thread->as_Java_thread());
|
||||
get_interpreterState()->set_thread(JavaThread::cast(thread));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2288,7 +2288,7 @@ LONG Handle_Exception(struct _EXCEPTION_POINTERS* exceptionInfo,
|
||||
|
||||
// Save pc in thread
|
||||
if (thread != nullptr && thread->is_Java_thread()) {
|
||||
thread->as_Java_thread()->set_saved_exception_pc((address)(DWORD_PTR)exceptionInfo->ContextRecord->PC_NAME);
|
||||
JavaThread::cast(thread)->set_saved_exception_pc((address)(DWORD_PTR)exceptionInfo->ContextRecord->PC_NAME);
|
||||
}
|
||||
|
||||
// Set pc to handler
|
||||
@ -2582,7 +2582,7 @@ LONG WINAPI topLevelExceptionFilter(struct _EXCEPTION_POINTERS* exceptionInfo) {
|
||||
#endif
|
||||
|
||||
if (t != NULL && t->is_Java_thread()) {
|
||||
JavaThread* thread = t->as_Java_thread();
|
||||
JavaThread* thread = JavaThread::cast(t);
|
||||
bool in_java = thread->thread_state() == _thread_in_Java;
|
||||
bool in_native = thread->thread_state() == _thread_in_native;
|
||||
bool in_vm = thread->thread_state() == _thread_in_vm;
|
||||
|
@ -51,7 +51,7 @@
|
||||
static bool must_be_in_vm() {
|
||||
Thread* thread = Thread::current();
|
||||
if (thread->is_Java_thread()) {
|
||||
return thread->as_Java_thread()->thread_state() == _thread_in_vm;
|
||||
return JavaThread::cast(thread)->thread_state() == _thread_in_vm;
|
||||
} else {
|
||||
return true; // Could be VMThread or GC thread
|
||||
}
|
||||
|
@ -1276,7 +1276,7 @@ void CompileBroker::compile_method_base(const methodHandle& method,
|
||||
|
||||
if (!UseJVMCINativeLibrary) {
|
||||
// Don't allow blocking compiles if inside a class initializer or while performing class loading
|
||||
vframeStream vfst(thread->as_Java_thread());
|
||||
vframeStream vfst(JavaThread::cast(thread));
|
||||
for (; !vfst.at_end(); vfst.next()) {
|
||||
if (vfst.method()->is_static_initializer() ||
|
||||
(vfst.method()->method_holder()->is_subclass_of(vmClasses::ClassLoader_klass()) &&
|
||||
|
@ -1693,7 +1693,7 @@ class G1RemarkThreadsClosure : public ThreadClosure {
|
||||
// * Weakly reachable otherwise
|
||||
// Some objects reachable from nmethods, such as the class loader (or klass_holder) of the receiver should be
|
||||
// live by the SATB invariant but other oops recorded in nmethods may behave differently.
|
||||
thread->as_Java_thread()->nmethods_do(&_code_cl);
|
||||
JavaThread::cast(thread)->nmethods_do(&_code_cl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -187,7 +187,7 @@ void CardTableBarrierSet::on_thread_detach(Thread* thread) {
|
||||
// card-table (or other remembered set structure) before GC starts
|
||||
// processing the card-table (or other remembered set).
|
||||
if (thread->is_Java_thread()) { // Only relevant for Java threads.
|
||||
flush_deferred_card_mark_barrier(thread->as_Java_thread());
|
||||
flush_deferred_card_mark_barrier(JavaThread::cast(thread));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -172,7 +172,7 @@ void MemAllocator::Allocation::check_for_valid_allocation_state() const {
|
||||
assert(!_thread->has_pending_exception(),
|
||||
"shouldn't be allocating with pending exception");
|
||||
// Allocation of an oop can always invoke a safepoint.
|
||||
_thread->as_Java_thread()->check_for_valid_safepoint_state();
|
||||
JavaThread::cast(_thread)->check_for_valid_safepoint_state();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -102,7 +102,7 @@ void ShenandoahBarrierSet::on_thread_attach(Thread *thread) {
|
||||
ShenandoahThreadLocalData::set_disarmed_value(thread, ShenandoahCodeRoots::disarmed_value());
|
||||
|
||||
if (ShenandoahStackWatermarkBarrier) {
|
||||
JavaThread* const jt = thread->as_Java_thread();
|
||||
JavaThread* const jt = JavaThread::cast(thread);
|
||||
StackWatermark* const watermark = new ShenandoahStackWatermark(jt);
|
||||
StackWatermarkSet::add_watermark(jt, watermark);
|
||||
}
|
||||
@ -122,10 +122,10 @@ void ShenandoahBarrierSet::on_thread_detach(Thread *thread) {
|
||||
if (ShenandoahStackWatermarkBarrier) {
|
||||
if (_heap->is_concurrent_mark_in_progress()) {
|
||||
ShenandoahKeepAliveClosure oops;
|
||||
StackWatermarkSet::finish_processing(thread->as_Java_thread(), &oops, StackWatermarkKind::gc);
|
||||
StackWatermarkSet::finish_processing(JavaThread::cast(thread), &oops, StackWatermarkKind::gc);
|
||||
} else if (_heap->is_concurrent_weak_root_in_progress() && _heap->is_evacuation_in_progress()) {
|
||||
ShenandoahContextEvacuateUpdateRootsClosure oops;
|
||||
StackWatermarkSet::finish_processing(thread->as_Java_thread(), &oops, StackWatermarkKind::gc);
|
||||
StackWatermarkSet::finish_processing(JavaThread::cast(thread), &oops, StackWatermarkKind::gc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -621,7 +621,7 @@ ShenandoahConcurrentEvacThreadClosure::ShenandoahConcurrentEvacThreadClosure(Oop
|
||||
}
|
||||
|
||||
void ShenandoahConcurrentEvacThreadClosure::do_thread(Thread* thread) {
|
||||
JavaThread* const jt = thread->as_Java_thread();
|
||||
JavaThread* const jt = JavaThread::cast(thread);
|
||||
StackWatermarkSet::finish_processing(jt, _oops, StackWatermarkKind::gc);
|
||||
}
|
||||
|
||||
@ -934,7 +934,7 @@ ShenandoahUpdateThreadClosure::ShenandoahUpdateThreadClosure() :
|
||||
|
||||
void ShenandoahUpdateThreadClosure::do_thread(Thread* thread) {
|
||||
if (thread->is_Java_thread()) {
|
||||
JavaThread* jt = thread->as_Java_thread();
|
||||
JavaThread* jt = JavaThread::cast(thread);
|
||||
ResourceMark rm;
|
||||
jt->oops_do(&_cl, NULL);
|
||||
}
|
||||
|
@ -1750,7 +1750,7 @@ bool ShenandoahHeap::try_cancel_gc() {
|
||||
if (thread->is_Java_thread()) {
|
||||
// We need to provide a safepoint here, otherwise we might
|
||||
// spin forever if a SP is pending.
|
||||
ThreadBlockInVM sp(thread->as_Java_thread());
|
||||
ThreadBlockInVM sp(JavaThread::cast(thread));
|
||||
SpinPause();
|
||||
}
|
||||
}
|
||||
|
@ -144,7 +144,7 @@ ShenandoahConcurrentMarkThreadClosure::ShenandoahConcurrentMarkThreadClosure(Oop
|
||||
|
||||
void ShenandoahConcurrentMarkThreadClosure::do_thread(Thread* thread) {
|
||||
assert(thread->is_Java_thread(), "Must be");
|
||||
JavaThread* const jt = thread->as_Java_thread();
|
||||
JavaThread* const jt = JavaThread::cast(thread);
|
||||
|
||||
StackWatermarkSet::finish_processing(jt, _oops, StackWatermarkKind::gc);
|
||||
}
|
||||
@ -202,7 +202,7 @@ void ShenandoahConcurrentRootScanner::update_tlab_stats() {
|
||||
for (uint i = 0; i < _java_threads.length(); i ++) {
|
||||
Thread* thr = _java_threads.thread_at(i);
|
||||
if (thr->is_Java_thread()) {
|
||||
ShenandoahStackWatermark* wm = StackWatermarkSet::get<ShenandoahStackWatermark>(thr->as_Java_thread(), StackWatermarkKind::gc);
|
||||
ShenandoahStackWatermark* wm = StackWatermarkSet::get<ShenandoahStackWatermark>(JavaThread::cast(thr), StackWatermarkKind::gc);
|
||||
total.update(wm->stats());
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -81,7 +81,7 @@ void ZBarrierSet::on_thread_attach(Thread* thread) {
|
||||
// Set thread local address bad mask
|
||||
ZThreadLocalData::set_address_bad_mask(thread, ZAddressBadMask);
|
||||
if (thread->is_Java_thread()) {
|
||||
JavaThread* const jt = thread->as_Java_thread();
|
||||
JavaThread* const jt = JavaThread::cast(thread);
|
||||
StackWatermark* const watermark = new ZStackWatermark(jt);
|
||||
StackWatermarkSet::add_watermark(jt, watermark);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -47,7 +47,7 @@ inline T ZFuture<T>::get() {
|
||||
// Wait for notification
|
||||
Thread* const thread = Thread::current();
|
||||
if (thread->is_Java_thread()) {
|
||||
_sema.wait_with_safepoint_check(thread->as_Java_thread());
|
||||
_sema.wait_with_safepoint_check(JavaThread::cast(thread));
|
||||
} else {
|
||||
_sema.wait();
|
||||
}
|
||||
|
@ -622,7 +622,7 @@ public:
|
||||
ZThreadLocalAllocBuffer::publish_statistics();
|
||||
}
|
||||
virtual void do_thread(Thread* thread) {
|
||||
JavaThread* const jt = thread->as_Java_thread();
|
||||
JavaThread* const jt = JavaThread::cast(thread);
|
||||
StackWatermarkSet::finish_processing(jt, _cl, StackWatermarkKind::gc);
|
||||
ZThreadLocalAllocBuffer::update_stats(jt);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -55,7 +55,7 @@ oop ZObjArrayAllocator::finish(HeapWord* mem) const {
|
||||
|
||||
if (remaining > 0) {
|
||||
// Safepoint
|
||||
ThreadBlockInVM tbivm(_thread->as_Java_thread());
|
||||
ThreadBlockInVM tbivm(JavaThread::cast(_thread));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -218,7 +218,7 @@ public:
|
||||
virtual void do_thread(Thread* thread) {
|
||||
thread->oops_do_no_frames(_cl, NULL);
|
||||
|
||||
JavaThread* const jt = thread->as_Java_thread();
|
||||
JavaThread* const jt = JavaThread::cast(thread);
|
||||
if (!jt->has_last_Java_frame()) {
|
||||
return;
|
||||
}
|
||||
|
@ -821,9 +821,9 @@ void JfrJavaSupport::on_thread_start(Thread* t) {
|
||||
if (!t->is_Java_thread()) {
|
||||
return;
|
||||
}
|
||||
DEBUG_ONLY(check_new_unstarted_java_thread(t->as_Java_thread());)
|
||||
DEBUG_ONLY(check_new_unstarted_java_thread(JavaThread::cast(t));)
|
||||
HandleMark hm(t);
|
||||
if (check_exclusion_state_on_thread_start(t->as_Java_thread())) {
|
||||
if (check_exclusion_state_on_thread_start(JavaThread::cast(t))) {
|
||||
JfrThreadLocal::exclude(t);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -175,7 +175,7 @@ void OSThreadSampler::do_task(const os::SuspendedThreadTaskContext& context) {
|
||||
* using a signal handler / __try block. Don't take locks, rely on destructors or
|
||||
* leave memory (in case of signal / exception) in an inconsistent state. */
|
||||
void OSThreadSampler::protected_task(const os::SuspendedThreadTaskContext& context) {
|
||||
JavaThread* jth = context.thread()->as_Java_thread();
|
||||
JavaThread* jth = JavaThread::cast(context.thread());
|
||||
// Skip sample if we signaled a thread that moved to other state
|
||||
if (!thread_state_in_java(jth)) {
|
||||
return;
|
||||
|
@ -449,7 +449,7 @@ size_t JfrCheckpointManager::flush_type_set() {
|
||||
Thread* const thread = Thread::current();
|
||||
if (thread->is_Java_thread()) {
|
||||
// can safepoint here
|
||||
ThreadInVMfromNative transition(thread->as_Java_thread());
|
||||
ThreadInVMfromNative transition(JavaThread::cast(thread));
|
||||
elements = ::flush_type_set(thread);
|
||||
} else {
|
||||
elements = ::flush_type_set(thread);
|
||||
@ -478,7 +478,7 @@ class JfrNotifyClosure : public ThreadClosure {
|
||||
void do_thread(Thread* thread) {
|
||||
assert(thread != NULL, "invariant");
|
||||
assert_locked_or_safepoint(Threads_lock);
|
||||
JfrJavaEventWriter::notify(thread->as_Java_thread());
|
||||
JfrJavaEventWriter::notify(JavaThread::cast(thread));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -89,7 +89,7 @@ traceid JfrThreadId::id(const Thread* t) {
|
||||
if (!t->is_Java_thread()) {
|
||||
return os_id(t);
|
||||
}
|
||||
const oop thread_obj = t->as_Java_thread()->threadObj();
|
||||
const oop thread_obj = JavaThread::cast(t)->threadObj();
|
||||
return thread_obj != NULL ? java_lang_Thread::thread_id(thread_obj) : 0;
|
||||
}
|
||||
|
||||
@ -123,5 +123,5 @@ const char* get_java_thread_name(const JavaThread* jt) {
|
||||
|
||||
const char* JfrThreadName::name(const Thread* t) {
|
||||
assert(t != NULL, "invariant");
|
||||
return t->is_Java_thread() ? get_java_thread_name(t->as_Java_thread()) : t->name();
|
||||
return t->is_Java_thread() ? get_java_thread_name(JavaThread::cast(t)) : t->name();
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ void JfrCheckpointThreadClosure::do_thread(Thread* t) {
|
||||
if (t->is_Java_thread()) {
|
||||
_writer.write(name);
|
||||
_writer.write(JfrThreadId::id(t));
|
||||
_writer.write(JfrThreadGroup::thread_group_id(t->as_Java_thread(), _curthread));
|
||||
_writer.write(JfrThreadGroup::thread_group_id(JavaThread::cast(t), _curthread));
|
||||
return;
|
||||
}
|
||||
_writer.write((const char*)NULL); // java name
|
||||
@ -276,7 +276,7 @@ void JfrThreadConstant::serialize(JfrCheckpointWriter& writer) {
|
||||
if (_thread->is_Java_thread()) {
|
||||
writer.write(name);
|
||||
writer.write(JfrThreadId::id(_thread));
|
||||
JavaThread* const jt = _thread->as_Java_thread();
|
||||
JavaThread* const jt = JavaThread::cast(_thread);
|
||||
const traceid thread_group_id = JfrThreadGroup::thread_group_id(jt, jt);
|
||||
writer.write(thread_group_id);
|
||||
JfrThreadGroup::serialize(&writer, thread_group_id);
|
||||
|
@ -501,7 +501,7 @@ class JavaThreadInVMAndNative : public StackObj {
|
||||
JavaThreadState _original_state;
|
||||
public:
|
||||
|
||||
JavaThreadInVMAndNative(Thread* t) : _jt(t->is_Java_thread() ? t->as_Java_thread() : NULL),
|
||||
JavaThreadInVMAndNative(Thread* t) : _jt(t->is_Java_thread() ? JavaThread::cast(t) : NULL),
|
||||
_original_state(_thread_max_state) {
|
||||
if (_jt != NULL) {
|
||||
_original_state = _jt->thread_state();
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2013, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -62,7 +62,7 @@ JfrPostBox::JfrPostBox() :
|
||||
|
||||
static bool is_thread_lock_aversive() {
|
||||
Thread* const thread = Thread::current();
|
||||
return (thread->is_Java_thread() && thread->as_Java_thread()->thread_state() != _thread_in_vm) || thread->is_VM_thread();
|
||||
return (thread->is_Java_thread() && JavaThread::cast(thread)->thread_state() != _thread_in_vm) || thread->is_VM_thread();
|
||||
}
|
||||
|
||||
static bool is_synchronous(int messages) {
|
||||
|
@ -163,7 +163,7 @@ traceid JfrStackTraceRepository::record(Thread* thread, int skip /* 0 */) {
|
||||
}
|
||||
assert(frames != NULL, "invariant");
|
||||
assert(tl->stackframes() == frames, "invariant");
|
||||
return instance().record_for(thread->as_Java_thread(), skip, frames, tl->stackdepth());
|
||||
return instance().record_for(JavaThread::cast(thread), skip, frames, tl->stackdepth());
|
||||
}
|
||||
|
||||
traceid JfrStackTraceRepository::record_for(JavaThread* thread, int skip, JfrStackFrame *frames, u4 max_frames) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -95,7 +95,7 @@ void JfrThreadLocal::on_start(Thread* t) {
|
||||
JfrCheckpointManager::write_thread_checkpoint(t);
|
||||
if (!t->jfr_thread_local()->is_excluded()) {
|
||||
if (t->is_Java_thread()) {
|
||||
send_java_thread_start_event(t->as_Java_thread());
|
||||
send_java_thread_start_event(JavaThread::cast(t));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -160,7 +160,7 @@ void JfrThreadLocal::on_exit(Thread* t) {
|
||||
assert(!tl->is_dead(), "invariant");
|
||||
if (JfrRecorder::is_recording()) {
|
||||
if (t->is_Java_thread()) {
|
||||
JavaThread* const jt = t->as_Java_thread();
|
||||
JavaThread* const jt = JavaThread::cast(t);
|
||||
ObjectSampleCheckpoint::on_thread_exit(jt);
|
||||
send_java_thread_end_events(tl->thread_id(), jt);
|
||||
}
|
||||
|
@ -171,7 +171,7 @@ class JfrJavaEventWriterNotificationClosure : public ThreadClosure {
|
||||
public:
|
||||
void do_thread(Thread* t) {
|
||||
if (t->is_Java_thread()) {
|
||||
JfrJavaEventWriter::notify(t->as_Java_thread());
|
||||
JfrJavaEventWriter::notify(JavaThread::cast(t));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -148,7 +148,7 @@ static JavaThread* get_current_thread(bool allow_null=true) {
|
||||
assert(allow_null, "npe");
|
||||
return NULL;
|
||||
}
|
||||
return thread->as_Java_thread();
|
||||
return JavaThread::cast(thread);
|
||||
}
|
||||
|
||||
// Entry to native method implementation that transitions
|
||||
|
@ -314,7 +314,7 @@ JVMCIEnv::~JVMCIEnv() {
|
||||
} else {
|
||||
Thread* thread = Thread::current();
|
||||
if (thread->is_Java_thread()) {
|
||||
JavaThread* THREAD = thread->as_Java_thread(); // For exception macros.
|
||||
JavaThread* THREAD = JavaThread::cast(thread); // For exception macros.
|
||||
if (HAS_PENDING_EXCEPTION) {
|
||||
Handle throwable = Handle(THREAD, PENDING_EXCEPTION);
|
||||
CLEAR_PENDING_EXCEPTION;
|
||||
|
@ -586,7 +586,7 @@ Klass* ConstantPool::klass_at_if_loaded(const constantPoolHandle& this_cp, int w
|
||||
// Avoid constant pool verification at a safepoint, as it takes the Module_lock.
|
||||
if (k != NULL && current->is_Java_thread()) {
|
||||
// Make sure that resolving is legal
|
||||
JavaThread* THREAD = current->as_Java_thread(); // For exception macros.
|
||||
JavaThread* THREAD = JavaThread::cast(current); // For exception macros.
|
||||
ExceptionMark em(THREAD);
|
||||
// return NULL if verification fails
|
||||
verify_constant_pool_resolve(this_cp, k, THREAD);
|
||||
|
@ -2152,7 +2152,7 @@ void GenerateOopMap::error_work(const char *format, va_list ap) {
|
||||
os::snprintf(msg_buffer2, sizeof(msg_buffer2), "%s in method %s", msg_buffer, method()->name()->as_C_string());
|
||||
Thread* current = Thread::current();
|
||||
if (current->can_call_java()) {
|
||||
_exception = Exceptions::new_exception(current->as_Java_thread(),
|
||||
_exception = Exceptions::new_exception(JavaThread::cast(current),
|
||||
vmSymbols::java_lang_LinkageError(),
|
||||
msg_buffer2);
|
||||
} else {
|
||||
|
@ -3624,7 +3624,7 @@ void InstanceKlass::print_class_load_logging(ClassLoaderData* loader_data,
|
||||
} else if (loader_data == ClassLoaderData::the_null_class_loader_data()) {
|
||||
Thread* current = Thread::current();
|
||||
Klass* caller = current->is_Java_thread() ?
|
||||
current->as_Java_thread()->security_get_caller_class(1):
|
||||
JavaThread::cast(current)->security_get_caller_class(1):
|
||||
NULL;
|
||||
// caller can be NULL, for example, during a JVMTI VM_Init hook
|
||||
if (caller != NULL) {
|
||||
|
@ -613,7 +613,7 @@ MethodCounters* Method::build_method_counters(Thread* current, Method* m) {
|
||||
methodHandle mh(current, m);
|
||||
MethodCounters* counters;
|
||||
if (current->is_Java_thread()) {
|
||||
JavaThread* THREAD = current->as_Java_thread(); // For exception macros.
|
||||
JavaThread* THREAD = JavaThread::cast(current); // For exception macros.
|
||||
// Use the TRAPS version for a JavaThread so it will adjust the GC threshold
|
||||
// if needed.
|
||||
counters = MethodCounters::allocate_with_exception(mh, THREAD);
|
||||
|
@ -3767,7 +3767,7 @@ static jint attach_current_thread(JavaVM *vm, void **penv, void *_args, bool dae
|
||||
// If executing from an atexit hook we may be in the VMThread.
|
||||
if (t->is_Java_thread()) {
|
||||
// If the thread has been attached this operation is a no-op
|
||||
*(JNIEnv**)penv = t->as_Java_thread()->jni_environment();
|
||||
*(JNIEnv**)penv = JavaThread::cast(t)->jni_environment();
|
||||
return JNI_OK;
|
||||
} else {
|
||||
return JNI_ERR;
|
||||
@ -3904,7 +3904,7 @@ jint JNICALL jni_DetachCurrentThread(JavaVM *vm) {
|
||||
|
||||
VM_Exit::block_if_vm_exited();
|
||||
|
||||
JavaThread* thread = current->as_Java_thread();
|
||||
JavaThread* thread = JavaThread::cast(current);
|
||||
if (thread->has_last_Java_frame()) {
|
||||
HOTSPOT_JNI_DETACHCURRENTTHREAD_RETURN((uint32_t) JNI_ERR);
|
||||
// Can't detach a thread that's running java, that can't work.
|
||||
@ -3966,7 +3966,7 @@ jint JNICALL jni_GetEnv(JavaVM *vm, void **penv, jint version) {
|
||||
Thread* thread = Thread::current_or_null();
|
||||
if (thread != NULL && thread->is_Java_thread()) {
|
||||
if (Threads::is_supported_jni_version_including_1_1(version)) {
|
||||
*(JNIEnv**)penv = thread->as_Java_thread()->jni_environment();
|
||||
*(JNIEnv**)penv = JavaThread::cast(thread)->jni_environment();
|
||||
ret = JNI_OK;
|
||||
return ret;
|
||||
|
||||
|
@ -99,7 +99,7 @@ extern "C" { \
|
||||
tty->print_cr("%s", fatal_using_jnienv_in_nonjava); \
|
||||
os::abort(true); \
|
||||
} \
|
||||
JavaThread* thr = cur->as_Java_thread(); \
|
||||
JavaThread* thr = JavaThread::cast(cur); \
|
||||
JNIEnv* xenv = thr->jni_environment(); \
|
||||
if (env != xenv) { \
|
||||
NativeReportJNIFatalError(thr, warn_wrong_jnienv); \
|
||||
|
@ -433,7 +433,7 @@ struct jvmtiInterface_1_ jvmti</xsl:text>
|
||||
<xsl:text>}</xsl:text>
|
||||
<xsl:value-of select="$space"/>
|
||||
<xsl:if test="count(@impl)=0 or not(contains(@impl,'innative'))">
|
||||
<xsl:text>JavaThread* current_thread = this_thread->as_Java_thread();</xsl:text>
|
||||
<xsl:text>JavaThread* current_thread = JavaThread::cast(this_thread);</xsl:text>
|
||||
<xsl:value-of select="$space"/>
|
||||
<xsl:text>MACOS_AARCH64_ONLY(ThreadWXEnable __wx(WXWrite, current_thread));</xsl:text>
|
||||
<xsl:value-of select="$space"/>
|
||||
|
@ -1269,7 +1269,7 @@ VM_GetThreadListStackTraces::doit() {
|
||||
|
||||
void
|
||||
GetSingleStackTraceClosure::do_thread(Thread *target) {
|
||||
JavaThread *jt = target->as_Java_thread();
|
||||
JavaThread *jt = JavaThread::cast(target);
|
||||
oop thread_oop = jt->threadObj();
|
||||
|
||||
if (!jt->is_exiting() && thread_oop != NULL) {
|
||||
@ -1393,7 +1393,7 @@ JvmtiEnvBase::force_early_return(JavaThread* java_thread, jvalue value, TosState
|
||||
|
||||
void
|
||||
SetForceEarlyReturn::doit(Thread *target, bool self) {
|
||||
JavaThread* java_thread = target->as_Java_thread();
|
||||
JavaThread* java_thread = JavaThread::cast(target);
|
||||
Thread* current_thread = Thread::current();
|
||||
HandleMark hm(current_thread);
|
||||
|
||||
@ -1528,7 +1528,7 @@ void
|
||||
UpdateForPopTopFrameClosure::doit(Thread *target, bool self) {
|
||||
Thread* current_thread = Thread::current();
|
||||
HandleMark hm(current_thread);
|
||||
JavaThread* java_thread = target->as_Java_thread();
|
||||
JavaThread* java_thread = JavaThread::cast(target);
|
||||
assert(java_thread == _state->get_thread(), "Must be");
|
||||
|
||||
if (!self && !java_thread->is_suspended()) {
|
||||
@ -1618,7 +1618,7 @@ UpdateForPopTopFrameClosure::doit(Thread *target, bool self) {
|
||||
void
|
||||
SetFramePopClosure::doit(Thread *target, bool self) {
|
||||
ResourceMark rm;
|
||||
JavaThread* java_thread = target->as_Java_thread();
|
||||
JavaThread* java_thread = JavaThread::cast(target);
|
||||
|
||||
assert(_state->get_thread() == java_thread, "Must be");
|
||||
|
||||
@ -1649,7 +1649,7 @@ SetFramePopClosure::doit(Thread *target, bool self) {
|
||||
|
||||
void
|
||||
GetOwnedMonitorInfoClosure::do_thread(Thread *target) {
|
||||
JavaThread *jt = target->as_Java_thread();
|
||||
JavaThread *jt = JavaThread::cast(target);
|
||||
if (!jt->is_exiting() && (jt->threadObj() != NULL)) {
|
||||
_result = ((JvmtiEnvBase *)_env)->get_owned_monitors(_calling_thread,
|
||||
jt,
|
||||
@ -1659,7 +1659,7 @@ GetOwnedMonitorInfoClosure::do_thread(Thread *target) {
|
||||
|
||||
void
|
||||
GetCurrentContendedMonitorClosure::do_thread(Thread *target) {
|
||||
JavaThread *jt = target->as_Java_thread();
|
||||
JavaThread *jt = JavaThread::cast(target);
|
||||
if (!jt->is_exiting() && (jt->threadObj() != NULL)) {
|
||||
_result = ((JvmtiEnvBase *)_env)->get_current_contended_monitor(_calling_thread,
|
||||
jt,
|
||||
@ -1669,7 +1669,7 @@ GetCurrentContendedMonitorClosure::do_thread(Thread *target) {
|
||||
|
||||
void
|
||||
GetStackTraceClosure::do_thread(Thread *target) {
|
||||
JavaThread *jt = target->as_Java_thread();
|
||||
JavaThread *jt = JavaThread::cast(target);
|
||||
if (!jt->is_exiting() && jt->threadObj() != NULL) {
|
||||
_result = ((JvmtiEnvBase *)_env)->get_stack_trace(jt,
|
||||
_start_depth, _max_count,
|
||||
@ -1688,7 +1688,7 @@ GetFrameCountClosure::do_thread(Thread *target) {
|
||||
|
||||
void
|
||||
GetFrameLocationClosure::do_thread(Thread *target) {
|
||||
JavaThread *jt = target->as_Java_thread();
|
||||
JavaThread *jt = JavaThread::cast(target);
|
||||
if (!jt->is_exiting() && jt->threadObj() != NULL) {
|
||||
_result = ((JvmtiEnvBase*)_env)->get_frame_location(jt, _depth,
|
||||
_method_ptr, _location_ptr);
|
||||
|
@ -255,7 +255,7 @@ class GetCurrentLocationClosure : public HandshakeClosure {
|
||||
_bci(0),
|
||||
_completed(false) {}
|
||||
void do_thread(Thread *target) {
|
||||
JavaThread *jt = target->as_Java_thread();
|
||||
JavaThread *jt = JavaThread::cast(target);
|
||||
ResourceMark rmark; // jt != Thread::current()
|
||||
RegisterMap rm(jt, false);
|
||||
// There can be a race condition between a handshake
|
||||
|
@ -201,7 +201,7 @@ class EnterInterpOnlyModeClosure : public HandshakeClosure {
|
||||
public:
|
||||
EnterInterpOnlyModeClosure() : HandshakeClosure("EnterInterpOnlyMode"), _completed(false) { }
|
||||
void do_thread(Thread* th) {
|
||||
JavaThread* jt = th->as_Java_thread();
|
||||
JavaThread* jt = JavaThread::cast(th);
|
||||
JvmtiThreadState* state = jt->jvmti_thread_state();
|
||||
|
||||
// Set up the current stack depth for later tracking
|
||||
|
@ -112,7 +112,7 @@ private:
|
||||
public:
|
||||
JvmtiThreadEventTransition(Thread *thread) : _rm(), _hm(thread) {
|
||||
if (thread->is_Java_thread()) {
|
||||
_jthread = thread->as_Java_thread();
|
||||
_jthread = JavaThread::cast(thread);
|
||||
_saved_state = _jthread->thread_state();
|
||||
if (_saved_state == _thread_in_Java) {
|
||||
ThreadStateTransition::transition_from_java(_jthread, _thread_in_native);
|
||||
@ -2307,7 +2307,7 @@ void JvmtiExport::record_vm_internal_object_allocation(oop obj) {
|
||||
NoSafepointVerifier no_sfpt;
|
||||
// Cannot take safepoint here so do not use state_for to get
|
||||
// jvmti thread state.
|
||||
JvmtiThreadState *state = thread->as_Java_thread()->jvmti_thread_state();
|
||||
JvmtiThreadState *state = JavaThread::cast(thread)->jvmti_thread_state();
|
||||
if (state != NULL) {
|
||||
// state is non NULL when VMObjectAllocEventCollector is enabled.
|
||||
JvmtiVMObjectAllocEventCollector *collector;
|
||||
@ -2331,7 +2331,7 @@ void JvmtiExport::record_sampled_internal_object_allocation(oop obj) {
|
||||
NoSafepointVerifier no_sfpt;
|
||||
// Cannot take safepoint here so do not use state_for to get
|
||||
// jvmti thread state.
|
||||
JvmtiThreadState *state = thread->as_Java_thread()->jvmti_thread_state();
|
||||
JvmtiThreadState *state = JavaThread::cast(thread)->jvmti_thread_state();
|
||||
if (state != NULL) {
|
||||
// state is non NULL when SampledObjectAllocEventCollector is enabled.
|
||||
JvmtiSampledObjectAllocEventCollector *collector;
|
||||
@ -2867,7 +2867,7 @@ NoJvmtiVMObjectAllocMark::NoJvmtiVMObjectAllocMark() : _collector(NULL) {
|
||||
}
|
||||
Thread* thread = Thread::current_or_null();
|
||||
if (thread != NULL && thread->is_Java_thread()) {
|
||||
JavaThread* current_thread = thread->as_Java_thread();
|
||||
JavaThread* current_thread = JavaThread::cast(thread);
|
||||
JvmtiThreadState *state = current_thread->jvmti_thread_state();
|
||||
if (state != NULL) {
|
||||
JvmtiVMObjectAllocEventCollector *collector;
|
||||
|
@ -236,7 +236,7 @@ int JvmtiRawMonitor::simple_wait(Thread* self, jlong millis) {
|
||||
|
||||
int ret = M_OK;
|
||||
if (self->is_Java_thread()) {
|
||||
JavaThread* jt = self->as_Java_thread();
|
||||
JavaThread* jt = JavaThread::cast(self);
|
||||
guarantee(jt->thread_state() == _thread_in_native, "invariant");
|
||||
{
|
||||
// This transition must be after we exited the monitor.
|
||||
@ -326,7 +326,7 @@ void JvmtiRawMonitor::raw_enter(Thread* self) {
|
||||
if (!self->is_Java_thread()) {
|
||||
simple_enter(self);
|
||||
} else {
|
||||
JavaThread* jt = self->as_Java_thread();
|
||||
JavaThread* jt = JavaThread::cast(self);
|
||||
guarantee(jt->thread_state() == _thread_in_native, "invariant");
|
||||
ThreadInVMfromNative tivmfn(jt);
|
||||
for (;;) {
|
||||
@ -379,7 +379,7 @@ int JvmtiRawMonitor::raw_wait(jlong millis, Thread* self) {
|
||||
// Now we need to re-enter the monitor. For JavaThreads
|
||||
// we need to manage suspend requests.
|
||||
if (self->is_Java_thread()) { // JavaThread re-enter
|
||||
JavaThread* jt = self->as_Java_thread();
|
||||
JavaThread* jt = JavaThread::cast(self);
|
||||
ThreadInVMfromNative tivmfn(jt);
|
||||
for (;;) {
|
||||
ExitOnSuspend eos(this);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -277,7 +277,7 @@ const char *JvmtiTrace::safe_get_thread_name(Thread *thread) {
|
||||
if (!thread->is_Java_thread()) {
|
||||
return thread->name();
|
||||
}
|
||||
oop threadObj = thread->as_Java_thread()->threadObj();
|
||||
oop threadObj = JavaThread::cast(thread)->threadObj();
|
||||
if (threadObj == NULL) {
|
||||
return "NULL";
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -77,7 +77,7 @@ void ProgrammableUpcallHandler::attach_thread_and_do_upcall(jobject rec, address
|
||||
|
||||
{
|
||||
MACOS_AARCH64_ONLY(ThreadWXEnable wx(WXWrite, thread));
|
||||
upcall_helper(thread->as_Java_thread(), rec, buff);
|
||||
upcall_helper(JavaThread::cast(thread), rec, buff);
|
||||
}
|
||||
|
||||
if (should_detach) {
|
||||
|
@ -2022,7 +2022,7 @@ WB_ENTRY(jint, WB_HandshakeWalkStack(JNIEnv* env, jobject wb, jobject thread_han
|
||||
jint _num_threads_completed;
|
||||
|
||||
void do_thread(Thread* th) {
|
||||
JavaThread* jt = th->as_Java_thread();
|
||||
JavaThread* jt = JavaThread::cast(th);
|
||||
ResourceMark rm;
|
||||
|
||||
jt->print_on(tty);
|
||||
@ -2058,7 +2058,7 @@ WB_ENTRY(void, WB_AsyncHandshakeWalkStack(JNIEnv* env, jobject wb, jobject threa
|
||||
// AsynchHandshake handshakes are only executed by target.
|
||||
assert(_self == th, "Must be");
|
||||
assert(Thread::current() == th, "Must be");
|
||||
JavaThread* jt = th->as_Java_thread();
|
||||
JavaThread* jt = JavaThread::cast(th);
|
||||
ResourceMark rm;
|
||||
jt->print_on(tty);
|
||||
jt->print_stack_on(tty);
|
||||
|
@ -869,7 +869,7 @@ class DeoptimizeMarkedClosure : public HandshakeClosure {
|
||||
public:
|
||||
DeoptimizeMarkedClosure() : HandshakeClosure("Deoptimize") {}
|
||||
void do_thread(Thread* thread) {
|
||||
JavaThread* jt = thread->as_Java_thread();
|
||||
JavaThread* jt = JavaThread::cast(thread);
|
||||
jt->deoptimize_marked_methods();
|
||||
}
|
||||
};
|
||||
|
@ -166,7 +166,7 @@ class HandshakeSpinYield : public StackObj {
|
||||
// On UP this is always true.
|
||||
Thread* self = Thread::current();
|
||||
if (self->is_Java_thread()) {
|
||||
wait_blocked(self->as_Java_thread(), now);
|
||||
wait_blocked(JavaThread::cast(self), now);
|
||||
} else {
|
||||
wait_raw(now);
|
||||
}
|
||||
@ -300,7 +300,7 @@ void HandshakeOperation::prepare(JavaThread* current_target, Thread* executing_t
|
||||
if (_requester != NULL && _requester != executing_thread && _requester->is_Java_thread()) {
|
||||
// The handshake closure may contain oop Handles from the _requester.
|
||||
// We must make sure we can use them.
|
||||
StackWatermarkSet::start_processing(_requester->as_Java_thread(), StackWatermarkKind::gc);
|
||||
StackWatermarkSet::start_processing(JavaThread::cast(_requester), StackWatermarkKind::gc);
|
||||
}
|
||||
}
|
||||
|
||||
@ -617,7 +617,7 @@ class ThreadSelfSuspensionHandshake : public AsyncHandshakeClosure {
|
||||
public:
|
||||
ThreadSelfSuspensionHandshake() : AsyncHandshakeClosure("ThreadSelfSuspensionHandshake") {}
|
||||
void do_thread(Thread* thr) {
|
||||
JavaThread* current = thr->as_Java_thread();
|
||||
JavaThread* current = JavaThread::cast(thr);
|
||||
assert(current == Thread::current(), "Must be self executed.");
|
||||
current->handshake_state()->do_self_suspend();
|
||||
}
|
||||
@ -660,7 +660,7 @@ class SuspendThreadHandshake : public HandshakeClosure {
|
||||
public:
|
||||
SuspendThreadHandshake() : HandshakeClosure("SuspendThread"), _did_suspend(false) {}
|
||||
void do_thread(Thread* thr) {
|
||||
JavaThread* target = thr->as_Java_thread();
|
||||
JavaThread* target = JavaThread::cast(thr);
|
||||
_did_suspend = target->handshake_state()->suspend_with_handshake();
|
||||
}
|
||||
bool did_suspend() { return _did_suspend; }
|
||||
|
@ -84,7 +84,7 @@ void InterfaceSupport::gc_alot() {
|
||||
Thread *thread = Thread::current();
|
||||
if (!thread->is_Java_thread()) return; // Avoid concurrent calls
|
||||
// Check for new, not quite initialized thread. A thread in new mode cannot initiate a GC.
|
||||
JavaThread *current_thread = thread->as_Java_thread();
|
||||
JavaThread *current_thread = JavaThread::cast(thread);
|
||||
if (current_thread->active_handles() == NULL) return;
|
||||
|
||||
// Short-circuit any possible re-entrant gc-a-lot attempt
|
||||
|
@ -178,7 +178,7 @@ class ThreadInVMfromUnknown {
|
||||
ThreadInVMfromUnknown() : _thread(NULL) {
|
||||
Thread* t = Thread::current();
|
||||
if (t->is_Java_thread()) {
|
||||
JavaThread* t2 = t->as_Java_thread();
|
||||
JavaThread* t2 = JavaThread::cast(t);
|
||||
if (t2->thread_state() == _thread_in_native) {
|
||||
_thread = t2;
|
||||
ThreadStateTransition::transition_from_native(t2, _thread_in_vm);
|
||||
|
@ -561,7 +561,7 @@ void vm_exit(int code) {
|
||||
// Historically there must have been some exit path for which
|
||||
// that was not the case and so we set it explicitly - even
|
||||
// though we no longer know what that path may be.
|
||||
thread->as_Java_thread()->set_thread_state(_thread_in_vm);
|
||||
JavaThread::cast(thread)->set_thread_state(_thread_in_vm);
|
||||
}
|
||||
|
||||
// Fire off a VM_Exit operation to bring VM to a safepoint and exit
|
||||
@ -609,7 +609,7 @@ void vm_perform_shutdown_actions() {
|
||||
if (thread != NULL && thread->is_Java_thread()) {
|
||||
// We are leaving the VM, set state to native (in case any OS exit
|
||||
// handlers call back to the VM)
|
||||
JavaThread* jt = thread->as_Java_thread();
|
||||
JavaThread* jt = JavaThread::cast(thread);
|
||||
// Must always be walkable or have no last_Java_frame when in
|
||||
// thread_in_native
|
||||
jt->frame_anchor()->make_walkable(jt);
|
||||
|
@ -207,7 +207,7 @@ jobjectRefType JNIHandles::handle_type(Thread* thread, jobject handle) {
|
||||
// Not in global storage. Might be a local handle.
|
||||
if (is_local_handle(thread, handle) ||
|
||||
(thread->is_Java_thread() &&
|
||||
is_frame_handle(thread->as_Java_thread(), handle))) {
|
||||
is_frame_handle(JavaThread::cast(thread), handle))) {
|
||||
result = JNILocalRefType;
|
||||
}
|
||||
break;
|
||||
@ -302,7 +302,7 @@ void JNIHandles::verify() {
|
||||
bool JNIHandles::current_thread_in_native() {
|
||||
Thread* thread = Thread::current();
|
||||
return (thread->is_Java_thread() &&
|
||||
thread->as_Java_thread()->thread_state() == _thread_in_native);
|
||||
JavaThread::cast(thread)->thread_state() == _thread_in_native);
|
||||
}
|
||||
|
||||
|
||||
|
@ -55,7 +55,7 @@ void Mutex::check_safepoint_state(Thread* thread) {
|
||||
name());
|
||||
|
||||
// Also check NoSafepointVerifier, and thread state is _thread_in_vm
|
||||
thread->as_Java_thread()->check_for_valid_safepoint_state();
|
||||
JavaThread::cast(thread)->check_for_valid_safepoint_state();
|
||||
} else {
|
||||
// If initialized with safepoint_check_never, a NonJavaThread should never ask to safepoint check either.
|
||||
assert(_safepoint_check_required != _safepoint_check_never,
|
||||
@ -85,7 +85,7 @@ void Mutex::lock_contended(Thread* self) {
|
||||
// Is it a JavaThread participating in the safepoint protocol.
|
||||
if (is_active_Java_thread) {
|
||||
assert(rank() > Mutex::special, "Potential deadlock with special or lesser rank mutex");
|
||||
{ ThreadBlockInVM tbivmdc(self->as_Java_thread(), &in_flight_mutex);
|
||||
{ ThreadBlockInVM tbivmdc(JavaThread::cast(self), &in_flight_mutex);
|
||||
in_flight_mutex = this; // save for ~ThreadBlockInVM
|
||||
_lock.lock();
|
||||
}
|
||||
@ -440,7 +440,7 @@ void Mutex::set_owner_implementation(Thread *new_owner) {
|
||||
// The tty_lock is special because it is released for the safepoint by
|
||||
// the safepoint mechanism.
|
||||
if (new_owner->is_Java_thread() && _allow_vm_block && this != tty_lock) {
|
||||
new_owner->as_Java_thread()->inc_no_safepoint_count();
|
||||
JavaThread::cast(new_owner)->inc_no_safepoint_count();
|
||||
}
|
||||
|
||||
} else {
|
||||
@ -477,7 +477,7 @@ void Mutex::set_owner_implementation(Thread *new_owner) {
|
||||
|
||||
// ~NSV implied with locking allow_vm_block flag.
|
||||
if (old_owner->is_Java_thread() && _allow_vm_block && this != tty_lock) {
|
||||
old_owner->as_Java_thread()->dec_no_safepoint_count();
|
||||
JavaThread::cast(old_owner)->dec_no_safepoint_count();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -252,7 +252,7 @@ static void check_object_context() {
|
||||
Thread* self = Thread::current();
|
||||
if (self->is_Java_thread()) {
|
||||
// Mostly called from JavaThreads so sanity check the thread state.
|
||||
JavaThread* jt = self->as_Java_thread();
|
||||
JavaThread* jt = JavaThread::cast(self);
|
||||
switch (jt->thread_state()) {
|
||||
case _thread_in_vm: // the usual case
|
||||
case _thread_in_Java: // during deopt
|
||||
|
@ -1467,7 +1467,7 @@ bool os::stack_shadow_pages_available(Thread *thread, const methodHandle& method
|
||||
const int framesize_in_bytes =
|
||||
Interpreter::size_top_interpreter_activation(method()) * wordSize;
|
||||
|
||||
address limit = thread->as_Java_thread()->stack_end() +
|
||||
address limit = JavaThread::cast(thread)->stack_end() +
|
||||
(StackOverflow::stack_guard_zone_size() + StackOverflow::stack_shadow_zone_size());
|
||||
|
||||
return sp > (limit + framesize_in_bytes);
|
||||
|
@ -510,7 +510,7 @@ class ParallelSPCleanupThreadClosure : public ThreadClosure {
|
||||
public:
|
||||
void do_thread(Thread* thread) {
|
||||
if (thread->is_Java_thread()) {
|
||||
StackWatermarkSet::start_processing(thread->as_Java_thread(), StackWatermarkKind::gc);
|
||||
StackWatermarkSet::start_processing(JavaThread::cast(thread), StackWatermarkKind::gc);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -33,13 +33,13 @@
|
||||
|
||||
NoSafepointVerifier::NoSafepointVerifier() : _thread(Thread::current()) {
|
||||
if (_thread->is_Java_thread()) {
|
||||
_thread->as_Java_thread()->inc_no_safepoint_count();
|
||||
JavaThread::cast(_thread)->inc_no_safepoint_count();
|
||||
}
|
||||
}
|
||||
|
||||
NoSafepointVerifier::~NoSafepointVerifier() {
|
||||
if (_thread->is_Java_thread()) {
|
||||
_thread->as_Java_thread()->dec_no_safepoint_count();
|
||||
JavaThread::cast(_thread)->dec_no_safepoint_count();
|
||||
}
|
||||
}
|
||||
|
||||
@ -47,13 +47,13 @@ PauseNoSafepointVerifier::PauseNoSafepointVerifier(NoSafepointVerifier* nsv)
|
||||
: _nsv(nsv) {
|
||||
assert(_nsv->_thread == Thread::current(), "must be");
|
||||
if (_nsv->_thread->is_Java_thread()) {
|
||||
_nsv->_thread->as_Java_thread()->dec_no_safepoint_count();
|
||||
JavaThread::cast(_nsv->_thread)->dec_no_safepoint_count();
|
||||
}
|
||||
}
|
||||
|
||||
PauseNoSafepointVerifier::~PauseNoSafepointVerifier() {
|
||||
if (_nsv->_thread->is_Java_thread()) {
|
||||
_nsv->_thread->as_Java_thread()->inc_no_safepoint_count();
|
||||
JavaThread::cast(_nsv->_thread)->inc_no_safepoint_count();
|
||||
}
|
||||
}
|
||||
#endif // ASSERT
|
||||
|
@ -990,7 +990,7 @@ JRT_END
|
||||
jlong SharedRuntime::get_java_tid(Thread* thread) {
|
||||
if (thread != NULL) {
|
||||
if (thread->is_Java_thread()) {
|
||||
oop obj = thread->as_Java_thread()->threadObj();
|
||||
oop obj = JavaThread::cast(thread)->threadObj();
|
||||
return (obj == NULL) ? 0 : java_lang_Thread::thread_id(obj);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -67,7 +67,7 @@ static void verify_processing_context() {
|
||||
#ifdef ASSERT
|
||||
Thread* thread = Thread::current();
|
||||
if (thread->is_Java_thread()) {
|
||||
JavaThread* jt = thread->as_Java_thread();
|
||||
JavaThread* jt = JavaThread::cast(thread);
|
||||
JavaThreadState state = jt->thread_state();
|
||||
assert(state != _thread_in_native, "unsafe thread state");
|
||||
assert(state != _thread_blocked, "unsafe thread state");
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -158,7 +158,7 @@ public:
|
||||
NMethodMarkingClosure(CodeBlobClosure* cl) : HandshakeClosure("NMethodMarking"), _cl(cl) {}
|
||||
void do_thread(Thread* thread) {
|
||||
if (thread->is_Java_thread() && ! thread->is_Code_cache_sweeper_thread()) {
|
||||
thread->as_Java_thread()->nmethods_do(_cl);
|
||||
JavaThread::cast(thread)->nmethods_do(_cl);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -127,7 +127,7 @@ size_t MonitorList::unlink_deflated(Thread* current, LogStream* ls,
|
||||
|
||||
if (current->is_Java_thread()) {
|
||||
// A JavaThread must check for a safepoint/handshake and honor it.
|
||||
ObjectSynchronizer::chk_for_block_req(current->as_Java_thread(), "unlinking",
|
||||
ObjectSynchronizer::chk_for_block_req(JavaThread::cast(current), "unlinking",
|
||||
"unlinked_count", unlinked_count,
|
||||
ls, timer_p);
|
||||
}
|
||||
@ -859,7 +859,7 @@ intptr_t ObjectSynchronizer::FastHashCode(Thread* current, oop obj) {
|
||||
if (SafepointSynchronize::is_at_safepoint()) {
|
||||
BiasedLocking::revoke_at_safepoint(hobj);
|
||||
} else {
|
||||
BiasedLocking::revoke(current->as_Java_thread(), hobj);
|
||||
BiasedLocking::revoke(JavaThread::cast(current), hobj);
|
||||
}
|
||||
obj = hobj();
|
||||
assert(!obj->mark().has_bias_pattern(), "biases should be revoked by now");
|
||||
@ -1417,7 +1417,7 @@ size_t ObjectSynchronizer::deflate_monitor_list(Thread* current, LogStream* ls,
|
||||
|
||||
if (current->is_Java_thread()) {
|
||||
// A JavaThread must check for a safepoint/handshake and honor it.
|
||||
chk_for_block_req(current->as_Java_thread(), "deflation", "deflated_count",
|
||||
chk_for_block_req(JavaThread::cast(current), "deflation", "deflated_count",
|
||||
deflated_count, ls, timer_p);
|
||||
}
|
||||
}
|
||||
@ -1507,7 +1507,7 @@ size_t ObjectSynchronizer::deflate_idle_monitors() {
|
||||
|
||||
if (current->is_Java_thread()) {
|
||||
// A JavaThread must check for a safepoint/handshake and honor it.
|
||||
chk_for_block_req(current->as_Java_thread(), "deletion", "deleted_count",
|
||||
chk_for_block_req(JavaThread::cast(current), "deletion", "deleted_count",
|
||||
deleted_count, ls, &timer);
|
||||
}
|
||||
}
|
||||
|
@ -349,7 +349,7 @@ void Thread::record_stack_base_and_size() {
|
||||
|
||||
// Set stack limits after thread is initialized.
|
||||
if (is_Java_thread()) {
|
||||
as_Java_thread()->stack_overflow_state()->initialize(stack_base(), stack_end());
|
||||
JavaThread::cast(this)->stack_overflow_state()->initialize(stack_base(), stack_end());
|
||||
}
|
||||
}
|
||||
|
||||
@ -461,10 +461,10 @@ Thread::~Thread() {
|
||||
// the current thread, it is not on a ThreadsList, or not at safepoint.
|
||||
void Thread::check_for_dangling_thread_pointer(Thread *thread) {
|
||||
assert(!thread->is_Java_thread() ||
|
||||
thread->as_Java_thread()->is_handshake_safe_for(Thread::current()) ||
|
||||
!thread->as_Java_thread()->on_thread_list() ||
|
||||
JavaThread::cast(thread)->is_handshake_safe_for(Thread::current()) ||
|
||||
!JavaThread::cast(thread)->on_thread_list() ||
|
||||
SafepointSynchronize::is_at_safepoint() ||
|
||||
ThreadsSMRSupport::is_a_protected_JavaThread_with_lock(thread->as_Java_thread()),
|
||||
ThreadsSMRSupport::is_a_protected_JavaThread_with_lock(JavaThread::cast(thread)),
|
||||
"possibility of dangling Thread pointer");
|
||||
}
|
||||
#endif
|
||||
@ -536,7 +536,7 @@ void Thread::start(Thread* thread) {
|
||||
// Can not set it after the thread started because we do not know the
|
||||
// exact thread state at that time. It could be in MONITOR_WAIT or
|
||||
// in SLEEPING or some other state.
|
||||
java_lang_Thread::set_thread_status(thread->as_Java_thread()->threadObj(),
|
||||
java_lang_Thread::set_thread_status(JavaThread::cast(thread)->threadObj(),
|
||||
JavaThreadStatus::RUNNABLE);
|
||||
}
|
||||
os::start_thread(thread);
|
||||
@ -705,7 +705,7 @@ bool Thread::set_as_starting_thread() {
|
||||
"_starting_thread=" INTPTR_FORMAT, p2i(_starting_thread));
|
||||
// NOTE: this must be called inside the main thread.
|
||||
DEBUG_ONLY(_starting_thread = this;)
|
||||
return os::create_main_thread(this->as_Java_thread());
|
||||
return os::create_main_thread(JavaThread::cast(this));
|
||||
}
|
||||
|
||||
static void initialize_class(Symbol* class_name, TRAPS) {
|
||||
@ -1547,11 +1547,11 @@ void JavaThread::cleanup_failed_attach_current_thread(bool is_daemon) {
|
||||
JavaThread* JavaThread::active() {
|
||||
Thread* thread = Thread::current();
|
||||
if (thread->is_Java_thread()) {
|
||||
return thread->as_Java_thread();
|
||||
return JavaThread::cast(thread);
|
||||
} else {
|
||||
assert(thread->is_VM_thread(), "this must be a vm thread");
|
||||
VM_Operation* op = ((VMThread*) thread)->vm_operation();
|
||||
JavaThread *ret = op == NULL ? NULL : op->calling_thread()->as_Java_thread();
|
||||
JavaThread *ret = op == NULL ? NULL : JavaThread::cast(op->calling_thread());
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
@ -1709,7 +1709,7 @@ public:
|
||||
InstallAsyncExceptionClosure(Handle throwable) : HandshakeClosure("InstallAsyncException"), _throwable(throwable) {}
|
||||
|
||||
void do_thread(Thread* thr) {
|
||||
JavaThread* target = thr->as_Java_thread();
|
||||
JavaThread* target = JavaThread::cast(thr);
|
||||
// Note that this now allows multiple ThreadDeath exceptions to be
|
||||
// thrown at a thread.
|
||||
// The target thread has run and has not exited yet.
|
||||
|
@ -355,10 +355,6 @@ class Thread: public ThreadShadow {
|
||||
// If so it must participate in the safepoint protocol.
|
||||
virtual bool is_active_Java_thread() const { return false; }
|
||||
|
||||
// Casts
|
||||
inline JavaThread* as_Java_thread();
|
||||
inline const JavaThread* as_Java_thread() const;
|
||||
|
||||
virtual char* name() const { return (char*)"Unknown thread"; }
|
||||
|
||||
// Returns the current thread (ASSERTS if NULL)
|
||||
@ -1420,7 +1416,20 @@ class JavaThread: public Thread {
|
||||
|
||||
public:
|
||||
// Returns the running thread as a JavaThread
|
||||
static inline JavaThread* current();
|
||||
static JavaThread* current() {
|
||||
return JavaThread::cast(Thread::current());
|
||||
}
|
||||
|
||||
// Casts
|
||||
static JavaThread* cast(Thread* t) {
|
||||
assert(t->is_Java_thread(), "incorrect cast to JavaThread");
|
||||
return static_cast<JavaThread*>(t);
|
||||
}
|
||||
|
||||
static const JavaThread* cast(const Thread* t) {
|
||||
assert(t->is_Java_thread(), "incorrect cast to const JavaThread");
|
||||
return static_cast<const JavaThread*>(t);
|
||||
}
|
||||
|
||||
// Returns the active Java thread. Do not use this if you know you are calling
|
||||
// from a JavaThread, as it's slower than JavaThread::current. If called from
|
||||
@ -1586,21 +1595,6 @@ public:
|
||||
static void verify_cross_modify_fence_failure(JavaThread *thread) PRODUCT_RETURN;
|
||||
};
|
||||
|
||||
// Inline implementation of JavaThread::current
|
||||
inline JavaThread* JavaThread::current() {
|
||||
return Thread::current()->as_Java_thread();
|
||||
}
|
||||
|
||||
inline JavaThread* Thread::as_Java_thread() {
|
||||
assert(is_Java_thread(), "incorrect cast to JavaThread");
|
||||
return static_cast<JavaThread*>(this);
|
||||
}
|
||||
|
||||
inline const JavaThread* Thread::as_Java_thread() const {
|
||||
assert(is_Java_thread(), "incorrect cast to const JavaThread");
|
||||
return static_cast<const JavaThread*>(this);
|
||||
}
|
||||
|
||||
// The active thread queue. It also keeps track of the current used
|
||||
// thread priorities.
|
||||
class Threads: AllStatic {
|
||||
|
@ -153,7 +153,7 @@ void VM_DeoptimizeAll::doit() {
|
||||
|
||||
|
||||
void VM_ZombieAll::doit() {
|
||||
calling_thread()->as_Java_thread()->make_zombies();
|
||||
JavaThread::cast(calling_thread())->make_zombies();
|
||||
}
|
||||
|
||||
#endif // !PRODUCT
|
||||
|
@ -283,7 +283,7 @@ class HandshakeALotClosure : public HandshakeClosure {
|
||||
HandshakeALotClosure() : HandshakeClosure("HandshakeALot") {}
|
||||
void do_thread(Thread* thread) {
|
||||
#ifdef ASSERT
|
||||
thread->as_Java_thread()->verify_states_for_handshake();
|
||||
JavaThread::cast(thread)->verify_states_for_handshake();
|
||||
#endif
|
||||
}
|
||||
};
|
||||
@ -522,7 +522,7 @@ void VMThread::execute(VM_Operation* op) {
|
||||
|
||||
// JavaThread or WatcherThread
|
||||
if (t->is_Java_thread()) {
|
||||
t->as_Java_thread()->check_for_valid_safepoint_state();
|
||||
JavaThread::cast(t)->check_for_valid_safepoint_state();
|
||||
}
|
||||
|
||||
// New request from Java thread, evaluate prologue
|
||||
|
@ -427,7 +427,7 @@ DeadlockCycle* ThreadService::find_deadlocks_at_safepoint(ThreadsList * t_list,
|
||||
Thread* owner = waitingToLockRawMonitor->owner();
|
||||
if (owner != NULL && // the raw monitor could be released at any time
|
||||
owner->is_Java_thread()) {
|
||||
currentThread = owner->as_Java_thread();
|
||||
currentThread = JavaThread::cast(owner);
|
||||
}
|
||||
} else if (waitingToLockMonitor != NULL) {
|
||||
address currentOwner = (address)waitingToLockMonitor->owner();
|
||||
@ -986,7 +986,7 @@ void DeadlockCycle::print_on_with(ThreadsList * t_list, outputStream* st) const
|
||||
// Could be NULL as the raw monitor could be released at any time if held by non-JavaThread
|
||||
if (owner != NULL) {
|
||||
if (owner->is_Java_thread()) {
|
||||
currentThread = owner->as_Java_thread();
|
||||
currentThread = JavaThread::cast(owner);
|
||||
st->print_cr("%s \"%s\"", owner_desc, currentThread->get_thread_name());
|
||||
} else {
|
||||
st->print_cr(",\n which has now been released");
|
||||
|
@ -153,7 +153,7 @@ static void print_bug_submit_message(outputStream *out, Thread *thread) {
|
||||
// provider of that code.
|
||||
if (thread && thread->is_Java_thread() &&
|
||||
!thread->is_hidden_from_external_view()) {
|
||||
if (thread->as_Java_thread()->thread_state() == _thread_in_native) {
|
||||
if (JavaThread::cast(thread)->thread_state() == _thread_in_native) {
|
||||
out->print_cr("# The crash happened outside the Java Virtual Machine in native code.\n# See problematic frame for where to report the bug.");
|
||||
}
|
||||
}
|
||||
@ -264,7 +264,7 @@ void VMError::print_native_stack(outputStream* st, frame fr, Thread* t, char* bu
|
||||
break;
|
||||
}
|
||||
if (fr.is_java_frame() || fr.is_native_frame() || fr.is_runtime_frame()) {
|
||||
RegisterMap map(t->as_Java_thread(), false); // No update
|
||||
RegisterMap map(JavaThread::cast(t), false); // No update
|
||||
fr = fr.sender(&map);
|
||||
} else {
|
||||
// is_first_C_frame() does only simple checks for frame pointer,
|
||||
@ -750,7 +750,7 @@ void VMError::report(outputStream* st, bool _verbose) {
|
||||
STEP("printing Java stack")
|
||||
|
||||
if (_verbose && _thread && _thread->is_Java_thread()) {
|
||||
print_stack_trace(st, _thread->as_Java_thread(), buf, sizeof(buf));
|
||||
print_stack_trace(st, JavaThread::cast(_thread), buf, sizeof(buf));
|
||||
}
|
||||
|
||||
STEP("printing target Java thread stack")
|
||||
@ -759,7 +759,7 @@ void VMError::report(outputStream* st, bool _verbose) {
|
||||
if (_verbose && _thread && (_thread->is_Named_thread())) {
|
||||
Thread* thread = ((NamedThread *)_thread)->processed_thread();
|
||||
if (thread != NULL && thread->is_Java_thread()) {
|
||||
JavaThread* jt = thread->as_Java_thread();
|
||||
JavaThread* jt = JavaThread::cast(thread);
|
||||
st->print_cr("JavaThread " PTR_FORMAT " (nid = %d) was being processed", p2i(jt), jt->osthread()->thread_id());
|
||||
print_stack_trace(st, jt, buf, sizeof(buf), true);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user