Skip to content

Commit

Permalink
8289004: investigate if SharedRuntime::get_java_tid parameter should …
Browse files Browse the repository at this point in the history
…be a JavaThread*

Reviewed-by: dholmes, jsjolen
  • Loading branch information
robehn committed Oct 5, 2022
1 parent b9eeec2 commit 979efd4
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 23 deletions.
14 changes: 7 additions & 7 deletions src/hotspot/share/gc/shared/memAllocator.cpp
Expand Up @@ -56,11 +56,11 @@ class MemAllocator::Allocation: StackObj {
bool check_out_of_memory();
void verify_before();
void verify_after();
void notify_allocation();
void notify_allocation(JavaThread* thread);
void notify_allocation_jvmti_sampler();
void notify_allocation_low_memory_detector();
void notify_allocation_jfr_sampler();
void notify_allocation_dtrace_sampler();
void notify_allocation_dtrace_sampler(JavaThread* thread);
void check_for_bad_heap_word_value() const;
#ifdef ASSERT
void check_for_valid_allocation_state() const;
Expand All @@ -84,7 +84,7 @@ class MemAllocator::Allocation: StackObj {
~Allocation() {
if (!check_out_of_memory()) {
verify_after();
notify_allocation();
notify_allocation(_thread);
}
}

Expand Down Expand Up @@ -235,21 +235,21 @@ void MemAllocator::Allocation::notify_allocation_jfr_sampler() {
}
}

void MemAllocator::Allocation::notify_allocation_dtrace_sampler() {
void MemAllocator::Allocation::notify_allocation_dtrace_sampler(JavaThread* thread) {
if (DTraceAllocProbes) {
// support for Dtrace object alloc event (no-op most of the time)
Klass* klass = obj()->klass();
size_t word_size = _allocator._word_size;
if (klass != NULL && klass->name() != NULL) {
SharedRuntime::dtrace_object_alloc(Thread::current(), obj(), word_size);
SharedRuntime::dtrace_object_alloc(thread, obj(), word_size);
}
}
}

void MemAllocator::Allocation::notify_allocation() {
void MemAllocator::Allocation::notify_allocation(JavaThread* thread) {
notify_allocation_low_memory_detector();
notify_allocation_jfr_sampler();
notify_allocation_dtrace_sampler();
notify_allocation_dtrace_sampler(thread);
notify_allocation_jvmti_sampler();
}

Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/opto/macro.cpp
Expand Up @@ -1626,7 +1626,7 @@ void PhaseMacroExpand::expand_dtrace_alloc_probe(AllocateNode* alloc, Node* oop,
int size = TypeFunc::Parms + 2;
CallLeafNode *call = new CallLeafNode(OptoRuntime::dtrace_object_alloc_Type(),
CAST_FROM_FN_PTR(address,
static_cast<int (*)(Thread*, oopDesc*)>(SharedRuntime::dtrace_object_alloc)),
static_cast<int (*)(JavaThread*, oopDesc*)>(SharedRuntime::dtrace_object_alloc)),
"dtrace_object_alloc",
TypeRawPtr::BOTTOM);

Expand Down
22 changes: 11 additions & 11 deletions src/hotspot/share/runtime/sharedRuntime.cpp
Expand Up @@ -996,15 +996,15 @@ JRT_ENTRY_NO_ASYNC(void, SharedRuntime::register_finalizer(JavaThread* current,
InstanceKlass::register_finalizer(instanceOop(obj), CHECK);
JRT_END

jlong SharedRuntime::get_java_tid(Thread* thread) {
if (thread != NULL && thread->is_Java_thread()) {
Thread* current = Thread::current();
guarantee(current != thread || JavaThread::cast(thread)->is_oop_safe(),
"current cannot touch oops after its GC barrier is detached.");
oop obj = JavaThread::cast(thread)->threadObj();
return (obj == NULL) ? 0 : java_lang_Thread::thread_id(obj);
jlong SharedRuntime::get_java_tid(JavaThread* thread) {
assert(thread != NULL, "No thread");
if (thread == NULL) {
return 0;
}
return 0;
guarantee(Thread::current() != thread || thread->is_oop_safe(),
"current cannot touch oops after its GC barrier is detached.");
oop obj = thread->threadObj();
return (obj == NULL) ? 0 : java_lang_Thread::thread_id(obj);
}

/**
Expand All @@ -1013,14 +1013,14 @@ jlong SharedRuntime::get_java_tid(Thread* thread) {
* 6254741. Once that is fixed we can remove the dummy return value.
*/
int SharedRuntime::dtrace_object_alloc(oopDesc* o) {
return dtrace_object_alloc(Thread::current(), o, o->size());
return dtrace_object_alloc(JavaThread::current(), o, o->size());
}

int SharedRuntime::dtrace_object_alloc(Thread* thread, oopDesc* o) {
int SharedRuntime::dtrace_object_alloc(JavaThread* thread, oopDesc* o) {
return dtrace_object_alloc(thread, o, o->size());
}

int SharedRuntime::dtrace_object_alloc(Thread* thread, oopDesc* o, size_t size) {
int SharedRuntime::dtrace_object_alloc(JavaThread* thread, oopDesc* o, size_t size) {
assert(DTraceAllocProbes, "wrong call");
Klass* klass = o->klass();
Symbol* name = klass->name();
Expand Down
6 changes: 3 additions & 3 deletions src/hotspot/share/runtime/sharedRuntime.hpp
Expand Up @@ -277,14 +277,14 @@ class SharedRuntime: AllStatic {

// dtrace notifications
static int dtrace_object_alloc(oopDesc* o);
static int dtrace_object_alloc(Thread* thread, oopDesc* o);
static int dtrace_object_alloc(Thread* thread, oopDesc* o, size_t size);
static int dtrace_object_alloc(JavaThread* thread, oopDesc* o);
static int dtrace_object_alloc(JavaThread* thread, oopDesc* o, size_t size);
static int dtrace_method_entry(JavaThread* thread, Method* m);
static int dtrace_method_exit(JavaThread* thread, Method* m);

// Utility method for retrieving the Java thread id, returns 0 if the
// thread is not a well formed Java thread.
static jlong get_java_tid(Thread* thread);
static jlong get_java_tid(JavaThread* thread);


// used by native wrappers to re-enable yellow if overflow happened in native code
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/runtime/synchronizer.cpp
Expand Up @@ -240,7 +240,7 @@ ObjectMonitor* MonitorList::Iterator::next() {
#endif // ndef DTRACE_ENABLED

// This exists only as a workaround of dtrace bug 6254741
int dtrace_waited_probe(ObjectMonitor* monitor, Handle obj, Thread* thr) {
int dtrace_waited_probe(ObjectMonitor* monitor, Handle obj, JavaThread* thr) {
DTRACE_MONITOR_PROBE(waited, monitor, obj(), thr);
return 0;
}
Expand Down

1 comment on commit 979efd4

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.