RFR: 8299089: Instrument global jni handles with tag to make them distinguishable [v2]

Axel Boldt-Christmas aboldtch at openjdk.org
Wed Jan 11 06:47:14 UTC 2023


On Tue, 10 Jan 2023 16:11:37 GMT, Albert Mingkun Yang <ayang at openjdk.org> wrote:

> I think `is_local/jweak/global` is clear enough; the `_tagged` suffix is impl-detail.

I think the tag suffix is fine, it is a private shorthand function to check the tag value. 
The public methods never mention tags. So the implementation detail is not leaked.

> src/hotspot/share/runtime/jniHandles.hpp line 69:
> 
>> 67:   enum TypeTag {
>> 68:     local = 0b00,
>> 69:     weak = 0b01,
> 
> Maybe `jweak`? Just to be less ambiguous.

I think I should fix all the references, currently we use `global weak`, `weak global`, `weak` and `jweak`. jweak belongs to C, it is just a typedef to make the API signatures more clear (it is the same type as jobject). And use `weak global` everywhere which is how the C API actually names the types:

typedef enum _jobjectType {
     JNIInvalidRefType    = 0,
     JNILocalRefType      = 1,
     JNIGlobalRefType     = 2,
     JNIWeakGlobalRefType = 3
} jobjectRefType;

> src/hotspot/share/runtime/jniHandles.inline.hpp line 122:
> 
>> 120:   if (handle != NULL) {
>> 121:     assert(!is_jweak_tagged(handle), "Invalid JNI local handle");
>> 122:     assert(!is_global_tagged(handle), "Invalid JNI local handle");
> 
> Why isn't `is_local_tagged` used here?

Yeah I just missed it. I see there are more asserts which should just be one tag check. Will fix.

-------------

PR: https://git.openjdk.org/jdk/pull/11740


More information about the hotspot-dev mailing list