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

Albert Mingkun Yang ayang at openjdk.org
Tue Jan 10 08:29:51 UTC 2023


On Tue, 10 Jan 2023 07:54:42 GMT, Axel Boldt-Christmas <aboldtch at openjdk.org> wrote:

> All the tags are mutually exclusive.

I see; could those tags be implemented using enum then? Sth like:


enum Tag {
  local = 0b00,
  jweak = 0b01,
  global = 0b10,
  mask = 0b11,
}

bool is_tagged_with(Handle h, Tag t) {
  return (h & mask) == t.
}


This makes the "mutual exclusiveness" more explicit and can probaly remove some redundancy in `assert(is_jweak); assert(!is_global);`.


> But we will get handles from the JNI external interface, and we want to check that the storage is correct in conjunction with checking that the tags are correct.

I don't know much about JNI; I thought all handles must be constructed using JNI APIs -- so, they must be correctly tagged.

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

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


More information about the hotspot-dev mailing list