RFR: 8259316: [REDO] C1/C2 compiler support for blackholes [v4]

Aleksey Shipilev shade at openjdk.java.net
Thu Apr 22 14:24:45 UTC 2021


> This reworks the compiler support for blackholes. The key difference against the last version (#1203) is that blackholes are only acceptable as empty static methods, which both simplifies the implementation and eliminates a few compatibility questions.
> 
> JMH uses the `Blackhole::consume` methods to avoid dead-code elimination of the code that produces benchmark values. It now relies on producing opaque side-effects and breaking inlining. While it was proved useful for many years, it unfortunately comes with several major drawbacks. 
> 
> Instead of introducing public APIs or special-casing JMH methods in JVM, we can hook a new command to compiler control, and let JMH sign up its `Blackhole` methods for it with `-XX:CompileCommand=blackhole,org.openjdk.jmh.infra.Blackhole::consume`. See CSR and related discussion for alternatives and future plans.
> 
> C1 code is platform-independent, and it handles blackhole via the intrinsics paths, lowering it to nothing.
> 
> C2 makes the `Blackhole` the subclass of `MemBar`, and use the same `Matcher` path as `Op_MemCPUOrder`: it does not match to anything, but it survives until matching, and keeps arguments alive. Additionally, C1 and C2 hooks are now using the synthetic `_blackhole` intrinsic, similarly to existing `_compiledLambdaForm`. It avoids introducing new nodes in C1. It also seems to require the least fiddling with C2 internals.

Aleksey Shipilev has updated the pull request incrementally with one additional commit since the last revision:

  Remove @build in favor of @library

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

Changes:
  - all: https://git.openjdk.java.net/jdk/pull/2024/files
  - new: https://git.openjdk.java.net/jdk/pull/2024/files/00c199ba..f8bc8271

Webrevs:
 - full: https://webrevs.openjdk.java.net/?repo=jdk&pr=2024&range=03
 - incr: https://webrevs.openjdk.java.net/?repo=jdk&pr=2024&range=02-03

  Stats: 12 lines in 6 files changed: 0 ins; 6 del; 6 mod
  Patch: https://git.openjdk.java.net/jdk/pull/2024.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/2024/head:pull/2024

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


More information about the hotspot-dev mailing list