RFR: 8276215: Intrinsics matchers should handle native method flags better

Vladimir Kozlov kvn at openjdk.java.net
Tue Nov 9 20:02:34 UTC 2021


On Mon, 1 Nov 2021 12:22:37 GMT, Aleksey Shipilev <shade at openjdk.org> wrote:

> Found this while working on JDK-8276096. It seems when the actual method is native, `F_R` (regular) intrinsic definition still matches. I believe that happens because flag matchers check for native flags only optionally. It would be better to implement this more consistently. This requires a few simple adjustments to current intrinsics definitions. #6184 handled a larger `StrictMath` oddity.
> 
> Additional testing:
>  - [x] Linux x86_64 fastdebug `tier1`
>  - [x] Linux x86_64 fastdebug `tier2`
>  - [x] Linux x86_64 fastdebug `applications/ctw/modules` (which has a nice side-effect of touching a lot of JDK methods)

I am for more strict checks proposed here.

`?native` comment was added by Tom for JDK-6892658
https://hg.openjdk.java.net/jdk8u/jdk8u/hotspot/rev/7c57aead6d3e#l8.72

Originally runtime code looked for intrinsic per method and it did not check for `native` because we did not have many intrinsics at that timeI think:

    // Special case the sqrt function because the Math and StrictMath versions are identical for all cases
    // This allows the hardware to be used for all sqrt implementations
 } else if ((klass_name == vmSymbols::java_lang_Math() || klass_name == vmSymbols::java_lang_StrictMath()) &&
             name() == vmSymbols::java_lang_Math_sqrt_name() && is_static() && !is_synchronized()) {
    if (signature() == vmSymbols::java_lang_Math_sqrt_signature()) return vmIntrinsics::_dsqrt;


@rose00 re-wrote it into current macro form but kept not checking `native`:

^Ac 6525802, 6428387 Add intrinsics for reflections, data motion, etc.
^Ac Refactor intrinsic specifications for maintainability and verifiability.
^Ac Intrinsic identification is now the job of class vmIntrinsics, not methodOop.
^Ac Remove x_obj32 variants of sun.misc.Unsafe intrinsics (obsolete since 1.4.1).
^Ac Add query accessors symbol_at, find_sid, name_at, find_id, etc.
^Ac StressReflectiveCode supports stress testing.

inline bool match_F_S(jshort flags) {
  const int req = JVM_ACC_STATIC;
  const int neg = JVM_ACC_SYNCHRONIZED;
  return (flags & (req | neg)) == req;
}

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

PR: https://git.openjdk.java.net/jdk/pull/6187


More information about the hotspot-runtime-dev mailing list