Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
8259482: jni_Set/GetField_probe are the same as their _nh versions
Reviewed-by: hseigel, sspitsyn, dholmes
  • Loading branch information
coleenp committed Jan 11, 2021
1 parent 01b2804 commit 23801da94bb6477d2f6ee92f481c2c78ba3c5638
Showing with 4 additions and 37 deletions.
  1. +3 −3 src/hotspot/share/prims/jni.cpp
  2. +0 −27 src/hotspot/share/prims/jvmtiExport.cpp
  3. +1 −7 src/hotspot/share/prims/jvmtiExport.hpp
@@ -1942,7 +1942,7 @@ JNI_ENTRY_NO_PRESERVE(Return, jni_Get##Result##Field(JNIEnv *env, jobject obj, j
int offset = jfieldIDWorkaround::from_instance_jfieldID(k, fieldID); \
/* Keep JVMTI addition small and only check enabled flag here. */ \
if (JvmtiExport::should_post_field_access()) { \
o = JvmtiExport::jni_GetField_probe_nh(thread, obj, o, k, fieldID, false); \
o = JvmtiExport::jni_GetField_probe(thread, obj, o, k, fieldID, false); \
} \
ret = o->Fieldname##_field(offset); \
return ret; \
@@ -2009,7 +2009,7 @@ JNI_ENTRY_NO_PRESERVE(void, jni_SetObjectField(JNIEnv *env, jobject obj, jfieldI
if (JvmtiExport::should_post_field_modification()) {
jvalue field_value;
field_value.l = value;
o = JvmtiExport::jni_SetField_probe_nh(thread, obj, o, k, fieldID, false, JVM_SIGNATURE_CLASS, (jvalue *)&field_value);
o = JvmtiExport::jni_SetField_probe(thread, obj, o, k, fieldID, false, JVM_SIGNATURE_CLASS, (jvalue *)&field_value);
}
HeapAccess<ON_UNKNOWN_OOP_REF>::oop_store_at(o, offset, JNIHandles::resolve(value));
HOTSPOT_JNI_SETOBJECTFIELD_RETURN();
@@ -2031,7 +2031,7 @@ JNI_ENTRY_NO_PRESERVE(void, jni_Set##Result##Field(JNIEnv *env, jobject obj, jfi
if (JvmtiExport::should_post_field_modification()) { \
jvalue field_value; \
field_value.unionType = value; \
o = JvmtiExport::jni_SetField_probe_nh(thread, obj, o, k, fieldID, false, SigType, (jvalue *)&field_value); \
o = JvmtiExport::jni_SetField_probe(thread, obj, o, k, fieldID, false, SigType, (jvalue *)&field_value); \
} \
if (SigType == JVM_SIGNATURE_BOOLEAN) { value = ((jboolean)value) & 1; } \
o->Fieldname##_field_put(offset, value); \
@@ -1872,19 +1872,6 @@ void JvmtiExport::notice_unwind_due_to_exception(JavaThread *thread, Method* met

oop JvmtiExport::jni_GetField_probe(JavaThread *thread, jobject jobj, oop obj,
Klass* klass, jfieldID fieldID, bool is_static) {
if (*((int *)get_field_access_count_addr()) > 0 && thread->has_last_Java_frame()) {
// At least one field access watch is set so we have more work
// to do. This wrapper is used by entry points that allow us
// to create handles in post_field_access_by_jni().
post_field_access_by_jni(thread, obj, klass, fieldID, is_static);
// event posting can block so refetch oop if we were passed a jobj
if (jobj != NULL) return JNIHandles::resolve_non_null(jobj);
}
return obj;
}

oop JvmtiExport::jni_GetField_probe_nh(JavaThread *thread, jobject jobj, oop obj,
Klass* klass, jfieldID fieldID, bool is_static) {
if (*((int *)get_field_access_count_addr()) > 0 && thread->has_last_Java_frame()) {
// At least one field access watch is set so we have more work to do.
post_field_access_by_jni(thread, obj, klass, fieldID, is_static);
@@ -1962,20 +1949,6 @@ void JvmtiExport::post_field_access(JavaThread *thread, Method* method,
oop JvmtiExport::jni_SetField_probe(JavaThread *thread, jobject jobj, oop obj,
Klass* klass, jfieldID fieldID, bool is_static,
char sig_type, jvalue *value) {
if (*((int *)get_field_modification_count_addr()) > 0 && thread->has_last_Java_frame()) {
// At least one field modification watch is set so we have more work
// to do. This wrapper is used by entry points that allow us
// to create handles in post_field_modification_by_jni().
post_field_modification_by_jni(thread, obj, klass, fieldID, is_static, sig_type, value);
// event posting can block so refetch oop if we were passed a jobj
if (jobj != NULL) return JNIHandles::resolve_non_null(jobj);
}
return obj;
}

oop JvmtiExport::jni_SetField_probe_nh(JavaThread *thread, jobject jobj, oop obj,
Klass* klass, jfieldID fieldID, bool is_static,
char sig_type, jvalue *value) {
if (*((int *)get_field_modification_count_addr()) > 0 && thread->has_last_Java_frame()) {
// At least one field modification watch is set so we have more work to do.
post_field_modification_by_jni(thread, obj, klass, fieldID, is_static, sig_type, value);
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 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
@@ -310,19 +310,13 @@ class JvmtiExport : public AllStatic {
static oop jni_GetField_probe (JavaThread *thread, jobject jobj,
oop obj, Klass* klass, jfieldID fieldID, bool is_static)
NOT_JVMTI_RETURN_(NULL);
static oop jni_GetField_probe_nh (JavaThread *thread, jobject jobj,
oop obj, Klass* klass, jfieldID fieldID, bool is_static)
NOT_JVMTI_RETURN_(NULL);
static void post_field_access_by_jni (JavaThread *thread, oop obj,
Klass* klass, jfieldID fieldID, bool is_static) NOT_JVMTI_RETURN;
static void post_field_access (JavaThread *thread, Method* method,
address location, Klass* field_klass, Handle object, jfieldID field) NOT_JVMTI_RETURN;
static oop jni_SetField_probe (JavaThread *thread, jobject jobj,
oop obj, Klass* klass, jfieldID fieldID, bool is_static, char sig_type,
jvalue *value) NOT_JVMTI_RETURN_(NULL);
static oop jni_SetField_probe_nh (JavaThread *thread, jobject jobj,
oop obj, Klass* klass, jfieldID fieldID, bool is_static, char sig_type,
jvalue *value) NOT_JVMTI_RETURN_(NULL);
static void post_field_modification_by_jni(JavaThread *thread, oop obj,
Klass* klass, jfieldID fieldID, bool is_static, char sig_type,
jvalue *value);

0 comments on commit 23801da

Please sign in to comment.