RFR: 8265711: C1: Canonicalize Class.getModifier intrinsic method [v2]

Tobias Hartmann thartmann at openjdk.java.net
Tue Apr 27 10:01:41 UTC 2021


On Tue, 27 Apr 2021 09:40:11 GMT, Yi Yang <yyang at openjdk.org> wrote:

>> It's relatively a common case to get modifiers from a constant Class instance, i.e. ThirdPartyClass.class.getModifiers(). Currently, C1 Canonicalizer missed the opportunity of replacing Class.getModifiers intrinsic calls with compile-time constants.
>
> Yi Yang has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains three additional commits since the last revision:
> 
>  - add missing stuff; change according to review comment
>  - Merge branch 'master' into canon_opt
>  - canonicalize well-chosen intrinsic methods

src/hotspot/share/c1/c1_LIRGenerator.cpp line 1333:

> 1331:   // Checking if it's a java mirror of primitive type
> 1332:   __ move(new LIR_Address(receiver.result(), java_lang_Class::klass_offset(), T_ADDRESS), temp, info);
> 1333:   __ cmp(lir_cond_notEqual, temp, LIR_OprFact::metadataConst(0));

The previous version of your patch was missing the check for a primitive type. Why did testing not catch this?

Also, your PR title is misleading. You are not simply canonicalizing `Class.getModifier.` You are intrinsifying it.

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

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


More information about the hotspot-compiler-dev mailing list