RFR: 8263582: WB_IsMethodCompilable ignores compiler directives

Christian Hagedorn chagedorn at openjdk.java.net
Thu Mar 25 15:06:42 UTC 2021


While playing around with `WB_IsMethodCompilable` together with `compileonly` I ran into some surprising results for methods that should never be compiled (not part of `compileonly`): `isMethodCompilable` returns true instead of false when such an excluded method was not yet tried to be compiled. 

The reason for it is that `WB_IsMethodCompilable` directly checks `CompilationPolicy::can_be_compiled()` which calls `Method::is_not_compilable()`. However, the `ExcludeOption` compiler directive is only evaluated lazily upon a compilation attempt. Therefore, if a method was not tried to be compiled, yet, `Method::is_not_compilable()` always returns false, regardless of any set compiler directive.

I therefore suggest to additionally check the `ExcludeOption` in `WB_IsMethodCompilable`. I also cleaned up some wrong use of `CompLevel_any` and `CompLevel_all` as suggested by @veresov: `CompLevel_any` should only be used to query the state as in `is_*()` methods and `CompLevel_all` when changing the state is in `set_*()` methods.

Thanks,
Christian

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

Commit messages:
 - Fix some CompLevel_all to CompLevel_any
 - 8263582: WB_IsMethodCompilable ignores compiler directives

Changes: https://git.openjdk.java.net/jdk/pull/3195/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=3195&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8263582
  Stats: 141 lines in 5 files changed: 128 ins; 0 del; 13 mod
  Patch: https://git.openjdk.java.net/jdk/pull/3195.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/3195/head:pull/3195

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


More information about the hotspot-dev mailing list