← Back to Pull requests

8396438: AArch64: Remove unnecessary checks for CPU_ASIMD feature #33704

Open
adinn opened this pull request with 62 lines diff across 1 files
View on GitHub
adinn adinn commented on Nov 03, 2026 16:55 UTC
Author

Trivial fix to remove all tests of CPU_ASIMD during argument processing, replacing them with an assert that the feature is present.

---------

  • I confirm that I make this contribution in accordance with the OpenJDK Interim AI Policy.
  • <!-- Anything below this marker will be automatically updated, please do not edit manually! -->
    ---------

    Progress


  • \[x\] Change must not contain extraneous whitespace

  • \[x\] Commit message must refer to an issue

  • \[ \] Change must be properly reviewed (2 reviews required, with at least 1 Reviewer, 1 Author)
  • Issue


    JDK-8396438: AArch64: Remove unnecessary checks for CPU_ASIMD feature (Enhancement - P4)

    Reviewers


    Vladimir Kozlov (@vnkozlov - Reviewer) 🔄 Re-review required (review applies to a807924b)
    * David Holmes (@dholmes-ora - Reviewer)

    Reviewing


    <details><summary>Using <code>git</code></summary>

    Checkout this PR locally: \
    $ git fetch https://git.openjdk.org/jdk.git pull/33704/head:pull/33704 \
    $ git checkout pull/33704

    Update a local copy of the PR: \
    $ git checkout pull/33704 \
    $ git pull https://git.openjdk.org/jdk.git pull/33704/head

    </details>
    <details><summary>Using Skara CLI tools</summary>

    Checkout this PR locally: \
    $ git pr checkout 33704

    View PR using the GUI difftool: \
    $ git pr show -t 33704

    </details>
    <details><summary>Using diff file</summary>

    Download this PR as a diff file: \
    <a href="https://git.openjdk.org/jdk/pull/33704.diff">https://git.openjdk.org/jdk/pull/33704.diff</a>

    </details>
    <details><summary>Using Webrev</summary>

    Link to Webrev Comment
    </details>

    Diff: 62 lines (+22 / -40) across 1 files Reviewer: vnkozlov Review duration: 46045m
    All Vouch review confidence checks passed
    Residual risk 0.04 = Change Risk (0.35) × (1 − Review Confidence (0.89)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.35 · 62 lines diff across 1 files
    0.35
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.89 · 5 substantive comment(s)
    0.89
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 50%
    88%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.248
    Real PR Conversation Timeline
    28 items
    bridgekeeper[bot] bridgekeeper[bot] commented on Nov 03, 2026 17:18 UTC
    Bot

    <!-- Welcome message -->

    :wave: Welcome back adinn! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

    openjdk[bot] openjdk[bot] commented on Nov 03, 2026 17:21 UTC
    Bot

    ❗ This change is not yet ready to be integrated.
    See the Progress checklist in the description for automated requirements.
    <!-- PullRequestBot merge is ready comment -->
    <!-- PullRequestBot placeholder -->

    openjdk[bot] openjdk[bot] commented on Nov 03, 2026 17:24 UTC
    Bot

    @adinn The following label will be automatically applied to this pull request:

  • hotspot
  • When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.
    <!-- PullRequestBot initial label help comment -->
    <!-- PullRequest Bot label commit '07a9c53b951101fb1c176aa01e84cc05c55c6150' -->

    openjdk[bot] openjdk[bot] commented on Nov 03, 2026 17:25 UTC
    Bot

    The total number of required reviews for this PR has been set to 2 based on the presence of this label: hotspot. This can be overridden with the /reviewers command.
    <!-- additional required reviewers id marker (2) (authors) (bot)-->
    <!-- two-reviewers applied -->

    mlbridge[bot] mlbridge[bot] commented on Nov 03, 2026 17:31 UTC
    Bot

    <!-- mlbridge webrev comment -->
    <!-- mlbridge webrev header -->

    Webrevs


    <!-- mlbridge webrev list -->
    02: Full (07a9c53b)
    01: Full - Incremental (a807924b)
    * 00: Full (b19a6d72)

    vnkozlov vnkozlov commented on Nov 03, 2026 17:40 UTC
    Reviewer

    Please use FLAG_SET_DEFAULT() macro in these changes to match other parts of code.

    dholmes-ora dholmes-ora commented on code on Nov 03, 2026 23:46 UTC
    Code Review
    src/hotspot/cpu/aarch64/vm_version_aarch64.cpp:1
    @@ -443,41 +447,20 @@ void VM_Version::initialize() {
         FLAG_SET_DEFAULT(UseGHASHIntrinsics, false);
       }
     
    -  if (supports_feature(CPU_ASIMD)) {
    -    if (FLAG_IS_DEFAULT(UseChaCha20Intrinsics)) {
    -      UseChaCha20Intrinsics = true;
    -    }
    -  } else if (UseChaCha20Intrinsics) {
    -    if (!FLAG_IS_DEFAULT(UseChaCha20Intrinsics)) {
    -      warning("ChaCha20 intrinsic requires ASIMD instructions");
    -    }
    -    FLAG_SET_DEFAULT(UseChaCha20Intrinsics, false);
    +  if (FLAG_IS_DEFAULT(UseChaCha20Intrinsics)) {
    +    UseChaCha20Intrinsics = true;
       }

    Drive-by comment but these checks don't make any sense to me. The default value of the flags being checked is already true so setting them to true is just redundant.

    dholmes-ora dholmes-ora commented on code on Nov 03, 2026 23:49 UTC
    Code Review
    src/hotspot/cpu/aarch64/vm_version_aarch64.cpp:1
    @@ -443,41 +447,20 @@ void VM_Version::initialize() {
         FLAG_SET_DEFAULT(UseGHASHIntrinsics, false);
       }
     
    -  if (supports_feature(CPU_ASIMD)) {
    -    if (FLAG_IS_DEFAULT(UseChaCha20Intrinsics)) {
    -      UseChaCha20Intrinsics = true;
    -    }
    -  } else if (UseChaCha20Intrinsics) {
    -    if (!FLAG_IS_DEFAULT(UseChaCha20Intrinsics)) {
    -      warning("ChaCha20 intrinsic requires ASIMD instructions");
    -    }
    -    FLAG_SET_DEFAULT(UseChaCha20Intrinsics, false);
    +  if (FLAG_IS_DEFAULT(UseChaCha20Intrinsics)) {
    +    UseChaCha20Intrinsics = true;
       }

    Sorry my mistake I was checking a fastdebug build. But in that case what we have still doesn't make sense. We are basically saying we assume we always have CPU_ASIMD so we will always set the flag to true, even though it is listed as a default of false. So we may as well just change the default to true and drop the code to check it.

    adinn adinn commented on code on Nov 04, 2026 09:40 UTC
    Code Review
    src/hotspot/cpu/aarch64/vm_version_aarch64.cpp:1
    @@ -443,41 +447,20 @@ void VM_Version::initialize() {
         FLAG_SET_DEFAULT(UseGHASHIntrinsics, false);
       }
     
    -  if (supports_feature(CPU_ASIMD)) {
    -    if (FLAG_IS_DEFAULT(UseChaCha20Intrinsics)) {
    -      UseChaCha20Intrinsics = true;
    -    }
    -  } else if (UseChaCha20Intrinsics) {
    -    if (!FLAG_IS_DEFAULT(UseChaCha20Intrinsics)) {
    -      warning("ChaCha20 intrinsic requires ASIMD instructions");
    -    }
    -    FLAG_SET_DEFAULT(UseChaCha20Intrinsics, false);
    +  if (FLAG_IS_DEFAULT(UseChaCha20Intrinsics)) {
    +    UseChaCha20Intrinsics = true;
       }

    I'm not sure why this would be any different in a fastdebug build.

    This is a generic flag that controls the use of generated intrinsic code.

    $ grep -r UseChaCha20Intrinsics src/hotspot/share/
    src/hotspot/share/classfile/vmIntrinsics.cpp:    if (!UseChaCha20Intrinsics) return true;
    . . .
    src/hotspot/share/runtime/globals.hpp:  product(bool, UseChaCha20Intrinsics, false, DIAGNOSTIC,                   \
    

    It has to be set to false by default because not all architectures implement the intrinsic. The resetting of the default to true on an architecture which supports the intrinsic has to happen in arch-specific code (specifically in the vm_version implementation file). Hence the need for the above code.

    adinn adinn commented on Nov 04, 2026 10:20 UTC
    Author

    @vnkozlov I updated all the previously modified locations to use FLAG_SET_DEFAULT(). I then found that there were a lot of other places where a FLAG_IS_DEFAULT() test was followed by a bare assignment so I updated them too.

    I noticed two places where a direct assignment was done in an else clause i.e. UseSVE = 0 and MaxVectorSize = new_vl.

    Neither of these is a direct else clause for a FLAG_IS_DEFAULT() test. That said, I believe they are both ok because they represent an explicit decision to repair an erroneous configuration rather than a simple reset of a default. However, I'll be happy to follow your guidance on that.

    vnkozlov vnkozlov commented on code on Nov 04, 2026 16:28 UTC
    Code Review
    src/hotspot/cpu/aarch64/vm_version_aarch64.cpp:1
    @@ -443,41 +447,20 @@ void VM_Version::initialize() {
         FLAG_SET_DEFAULT(UseGHASHIntrinsics, false);
       }
     
    -  if (supports_feature(CPU_ASIMD)) {
    -    if (FLAG_IS_DEFAULT(UseChaCha20Intrinsics)) {
    -      UseChaCha20Intrinsics = true;
    -    }
    -  } else if (UseChaCha20Intrinsics) {
    -    if (!FLAG_IS_DEFAULT(UseChaCha20Intrinsics)) {
    -      warning("ChaCha20 intrinsic requires ASIMD instructions");
    -    }
    -    FLAG_SET_DEFAULT(UseChaCha20Intrinsics, false);
    +  if (FLAG_IS_DEFAULT(UseChaCha20Intrinsics)) {
    +    UseChaCha20Intrinsics = true;
       }

    What @adinn said. It is a generic flag which should be set separately for each platform which support it.

    vnkozlov vnkozlov approved these changes on Nov 04, 2026 16:29 UTC
    Approved Reviewer

    Looks good. I will submit our testing.

    vnkozlov vnkozlov commented on Nov 05, 2026 02:18 UTC
    Contributor

    My testing passed.

    dholmes-ora dholmes-ora commented on code on Nov 05, 2026 05:21 UTC
    Code Review
    src/hotspot/cpu/aarch64/vm_version_aarch64.cpp:1
    @@ -443,41 +447,20 @@ void VM_Version::initialize() {
         FLAG_SET_DEFAULT(UseGHASHIntrinsics, false);
       }
     
    -  if (supports_feature(CPU_ASIMD)) {
    -    if (FLAG_IS_DEFAULT(UseChaCha20Intrinsics)) {
    -      UseChaCha20Intrinsics = true;
    -    }
    -  } else if (UseChaCha20Intrinsics) {
    -    if (!FLAG_IS_DEFAULT(UseChaCha20Intrinsics)) {
    -      warning("ChaCha20 intrinsic requires ASIMD instructions");
    -    }
    -    FLAG_SET_DEFAULT(UseChaCha20Intrinsics, false);
    +  if (FLAG_IS_DEFAULT(UseChaCha20Intrinsics)) {
    +    UseChaCha20Intrinsics = true;
       }

    Sorry I missed the generic nature of the flag.

    dholmes-ora dholmes-ora commented on code on Nov 05, 2026 05:29 UTC
    Code Review
    src/hotspot/cpu/aarch64/vm_version_aarch64.cpp:1
    @@ -159,7 +163,7 @@ void VM_Version::initialize() {
       }
     
       if (FLAG_IS_DEFAULT(ContendedPaddingWidth) && (dcache_line > ContendedPaddingWidth)) {
    -    ContendedPaddingWidth = dcache_line;
    +    FLAG_SET_DEFAULT(ContendedPaddingWidth, dcache_line);

    I'm not sure I see a reason to make this kind of change given that FLAG_SET_DEFAULT does not change the origin value of the flag. Why it doesn't set the origin perplexes me. That aside if we are making a conscious decision to adjust flags based on available capabilities shouldn't we be using FLAG_SET_ERGO here?

    I fear our flag handling code is very messy and inconsistent.

    adinn adinn commented on code on Nov 05, 2026 11:31 UTC
    Code Review
    src/hotspot/cpu/aarch64/vm_version_aarch64.cpp:1
    @@ -159,7 +163,7 @@ void VM_Version::initialize() {
       }
     
       if (FLAG_IS_DEFAULT(ContendedPaddingWidth) && (dcache_line > ContendedPaddingWidth)) {
    -    ContendedPaddingWidth = dcache_line;
    +    FLAG_SET_DEFAULT(ContendedPaddingWidth, dcache_line);

    @dholmes-ora

    shouldn't we be using FLAG_SET_ERGO here?

    That sounds probable. I'm very happy to be guided by you and @vnkozlov here.

    I think in some of the cases I changed, i.e. where we see the reset of a generic intrinsic flag to a cpu-specific variant, the re-assignment is adjusting a 'presumed default' to the 'correct default' for the platform. In those cases I suggest it is correct to use FLAG_SET_DEFAULT because a subsequent FLAG_IS_DEFAULT test (if there is one) should not see this sort of update as having left the flag in a non-default state.

    In other cases -- perhaps indeed the one you mention here -- I'm not sure whether the reset is meant to preserve the 'defaultness' of the flag or meant to mark it as having changed. What does FLAG_SET_ERGO mean in terms of any subsequent FLAG_IS_DEFAULT test. Perhaps you can clarify that?

    I fear our flag handling code is very messy and inconsistent.

    That is undoubtedly true given the number of bare 'reset' assignments already found in this file. ;-(

    On the plus side, having stumbled on the problem we now have a chance to record some of the constraints and fix at least some of the errors (n.b. I'm honestly trying to be positive without resorting to platitudes about all problems being opportunities, clouds having silver linings, etc, etc ;-)

    vnkozlov vnkozlov commented on code on Nov 05, 2026 17:54 UTC
    Code Review
    src/hotspot/cpu/aarch64/vm_version_aarch64.cpp:1
    @@ -159,7 +163,7 @@ void VM_Version::initialize() {
       }
     
       if (FLAG_IS_DEFAULT(ContendedPaddingWidth) && (dcache_line > ContendedPaddingWidth)) {
    -    ContendedPaddingWidth = dcache_line;
    +    FLAG_SET_DEFAULT(ContendedPaddingWidth, dcache_line);

    I agree with @adinn here. When we set a generic flag based on current CPU feature we should use FLAG_SET_DEFAULT. Using FLAG_SET_ERGO to set flag setting based on some other properties should be done separately. It should be discussed in detail when and where it should be done. Definitely not in these changes.

    dholmes-ora dholmes-ora commented on code on Nov 06, 2026 02:45 UTC
    Code Review
    src/hotspot/cpu/aarch64/vm_version_aarch64.cpp:1
    @@ -159,7 +163,7 @@ void VM_Version::initialize() {
       }
     
       if (FLAG_IS_DEFAULT(ContendedPaddingWidth) && (dcache_line > ContendedPaddingWidth)) {
    -    ContendedPaddingWidth = dcache_line;
    +    FLAG_SET_DEFAULT(ContendedPaddingWidth, dcache_line);

    I think we are hitting the classic problem with flag management: in the query FLAG_IS_DEFAULT the term DEFAULT does not relate to the value of the flag but to the origin of the flag i.e. where it was set.

    adinn adinn commented on code on Nov 09, 2026 10:57 UTC
    Code Review
    src/hotspot/cpu/aarch64/vm_version_aarch64.cpp:1
    @@ -159,7 +163,7 @@ void VM_Version::initialize() {
       }
     
       if (FLAG_IS_DEFAULT(ContendedPaddingWidth) && (dcache_line > ContendedPaddingWidth)) {
    -    ContendedPaddingWidth = dcache_line;
    +    FLAG_SET_DEFAULT(ContendedPaddingWidth, dcache_line);

    in the query FLAG_IS_DEFAULT the term DEFAULT does not relate to the value of the flag but to the origin of the flag i.e. where it was set.

    @dholmes-ora I'm not sure I am following you correctly here but I think that observation was priced into my previous comment and that of @vnkozlov.

    What I take you to be saying is that FLAG_IS_DEFAULT reports whether the flag has had its value reset after its initial assignment during construction via the wrapper which tracks changes. So, it is not about recording what it was reset to but the fact of its having been updated at all. Is that correct?

    Two qualifications:

    - As described above this would allow a flag to be 'reset' with the same value as the default and still look like it had been changed. Is that a possibility? I'm assuming not i.e. that we only mark a departure from the default setting when a 'reset' to some other value occurs.

    - I'm also assuming that the point of FLAG_SET_DEFAULT is to change a 'default' setting to something else without it looking as if the value has been reset i.e. to update the setting yet still allow a subsequent FLAG_IS_DEFAULT test to return true.

    That was the basis for my suggestion that we should use FLAG_SET_DEFAULT when overriding a generic intrinsic default of false with a cpu-specific intrinsic default of true. If I am reading your comment above correctly then I think my suggestion takes what it emphasises into account. If not then could you please clarify where I have misunderstood you and/or whatever difference is at play in the way that the flag tracking code is supposed to operate?

    dholmes-ora dholmes-ora commented on code on Nov 10, 2026 01:20 UTC
    Code Review
    src/hotspot/cpu/aarch64/vm_version_aarch64.cpp:1
    @@ -159,7 +163,7 @@ void VM_Version::initialize() {
       }
     
       if (FLAG_IS_DEFAULT(ContendedPaddingWidth) && (dcache_line > ContendedPaddingWidth)) {
    -    ContendedPaddingWidth = dcache_line;
    +    FLAG_SET_DEFAULT(ContendedPaddingWidth, dcache_line);

    What I take you to be saying is that FLAG_IS_DEFAULT reports whether the flag has had its value reset after its initial assignment during construction via the wrapper which tracks changes. So, it is not about recording what it was reset to but the fact of its having been updated at all. Is that correct?

    It returns true if the flags ORIGIN is still DEFAULT, irrespective of what the actual value of the flag currently is.

    As described above this would allow a flag to be 'reset' with the same value as the default and still look like it had been changed. Is that a possibility? I'm assuming not i.e. that we only mark a departure from the default setting when a 'reset' to some other value occurs.

    That would be the expected usage yes - though nothing enforces that. A typical usage would be to switch the flag from its default value under specific conditions:

    if (flag && someCondition()) {
      FLAG_SET_ERGO(flag, false);
    }
    

    though those conditions may also include "unless the user set it on the command-line" for which FLAG_IS_DEFAULT may be used as a proxy (as long as we process everything in the right order).

    I'm also assuming that the point of FLAG_SET_DEFAULT is to change a 'default' setting to something else without it looking as if the value has been reset i.e. to update the setting yet still allow a subsequent FLAG_IS_DEFAULT test to return true.

    I don't know what point it serves. Given FLAG_SET_ERGO sets the origin to ERGO one might reasonably expect that FLAG_SET_DEFAULT sets the origin to DEFAULT - but it doesn't. If you want to change the value without changing the origin then that is what direct assignment does: flag = x;.

    So to me direct assignment for a cpu-specific default is preferable to using FLAG_SET_DEFAULT. If we want something that keeps the DEFAULT origin and updates the value and is highly visible in the code, then the following would seem a better idiom to me:

    #define FLAG_SET_IF_DEFAULT(flag, val) if (FLAG_IS_DEFAULT(flag)) flag = val;
    

    Bottom line is I don't think some of the changes in the PR were necessary and I question the claim they are "better", but as the saying goes I'm not trying, or willing, to die on this hill. Flag management is a mess, and complicated and we can't solve that here.

    adinn adinn commented on code on Nov 11, 2026 09:39 UTC
    Code Review
    src/hotspot/cpu/aarch64/vm_version_aarch64.cpp:1
    @@ -159,7 +163,7 @@ void VM_Version::initialize() {
       }
     
       if (FLAG_IS_DEFAULT(ContendedPaddingWidth) && (dcache_line > ContendedPaddingWidth)) {
    -    ContendedPaddingWidth = dcache_line;
    +    FLAG_SET_DEFAULT(ContendedPaddingWidth, dcache_line);

    > I'm also assuming that the point of FLAG_SET_DEFAULT is to change a 'default' setting to something else without it looking as if the value has been reset i.e. to update the setting yet still allow a subsequent FLAG_IS_DEFAULT test to return true.

    > I don't know what point it serves. Given FLAG_SET_ERGO sets the origin to ERGO one might reasonably expect that FLAG_SET_DEFAULT sets the origin to DEFAULT - but it doesn't. If you want to change the value without changing the origin then that is what direct assignment does: flag = x;.

    > So to me direct assignment for a cpu-specific default is preferable to using FLAG_SET_DEFAULT.

    Well, yes, a direct assignment does not change the status of the value and indeed neither does FLAG_SET_DEFAULT as currently defined:

    #define FLAG_SET_DEFAULT(name, value) ((name) = (value))
    
    

    So, whatever difference we might be discussing here arises only in terms of 'presentational' semantics rather than any program semantic. n.b. by that term I merely mean to clarify the target of the discussion here. I don't want to deprecate having code that signals intent -- quite the opposite.

    If we want something that keeps the DEFAULT origin and updates the value and is highly visible in the code, then the following would seem a better idiom to me:

    > #define FLAG_SET_IF_DEFAULT(flag, val) if (FLAG_IS_DEFAULT(flag)) flag = val;
    > 

    I am not sure this signals the intention more clearly rather than the (program-)semantically equivalent code we currently have e.g, we can certainly replace the current

        if (FLAG_IS_DEFAULT(UseSignumIntrinsic)) {
          FLAG_SET_DEFAULT(UseSignumIntrinsic, true);
        }
    

    with the semantically equivalent
        FLAG_SET_IF_DEFAULT(UseSignumIntrinsic, true);
    

    but I think this actually makes it less clear what is going on. The former makes an explicit statement that status of the new value after reassignment is still that of a DEFAULT. The latter leaves it implicit.

    adinn adinn commented on Nov 16, 2026 17:20 UTC
    Author

    @dholmes-ora Are you willing to approve this PR or do I need to make some changes?

    dholmes-ora dholmes-ora commented on code on Nov 17, 2026 06:33 UTC
    Code Review
    src/hotspot/cpu/aarch64/vm_version_aarch64.cpp:1
    @@ -443,41 +447,20 @@ void VM_Version::initialize() {
         FLAG_SET_DEFAULT(UseGHASHIntrinsics, false);
       }
     
    -  if (supports_feature(CPU_ASIMD)) {
    -    if (FLAG_IS_DEFAULT(UseChaCha20Intrinsics)) {
    -      UseChaCha20Intrinsics = true;
    -    }
    -  } else if (UseChaCha20Intrinsics) {
    -    if (!FLAG_IS_DEFAULT(UseChaCha20Intrinsics)) {
    -      warning("ChaCha20 intrinsic requires ASIMD instructions");
    -    }
    -    FLAG_SET_DEFAULT(UseChaCha20Intrinsics, false);
    +  if (FLAG_IS_DEFAULT(UseChaCha20Intrinsics)) {
    +    UseChaCha20Intrinsics = true;
       }

    Just an observation but shouldn't this then be declared as a "pd" flag so that each platform can directly declare its own default value?

    dholmes-ora dholmes-ora approved these changes on Nov 17, 2026 06:35 UTC
    Approved Reviewer

    Approved with mild reluctance. :) Thanks

    adinn adinn commented on code on Nov 17, 2026 13:07 UTC
    Code Review
    src/hotspot/cpu/aarch64/vm_version_aarch64.cpp:1
    @@ -443,41 +447,20 @@ void VM_Version::initialize() {
         FLAG_SET_DEFAULT(UseGHASHIntrinsics, false);
       }
     
    -  if (supports_feature(CPU_ASIMD)) {
    -    if (FLAG_IS_DEFAULT(UseChaCha20Intrinsics)) {
    -      UseChaCha20Intrinsics = true;
    -    }
    -  } else if (UseChaCha20Intrinsics) {
    -    if (!FLAG_IS_DEFAULT(UseChaCha20Intrinsics)) {
    -      warning("ChaCha20 intrinsic requires ASIMD instructions");
    -    }
    -    FLAG_SET_DEFAULT(UseChaCha20Intrinsics, false);
    +  if (FLAG_IS_DEFAULT(UseChaCha20Intrinsics)) {
    +    UseChaCha20Intrinsics = true;
       }

    Yes, I think that is probably how it ought to be done. However, I think the fact that it is done the current way reflects a pragmatic compromise (not trying to take a side here, just observing the status quo). The considerations influencing that compromise are as follows:

    1. Flags which reflect the availability of intrinsics, such as UseChaCha20Intrinsics, need to be global because they are accessed by generic (compiler) code.
    2. Any stub generator code whose action is gated by the flag setting is always arch-specific.
    3. Historically may of these intrinsic flags that have only been implemented by a subset of architectures i.e. there is no corresponding generator routine.

    So, if a pd_product declaration were employed to declare, say, UseChaCha20Intrinsics then every architecture would need to provide a define_pd_global defaulting that intrinsic flag (situated in the generator code), even when it did not implement the intrinsic, while still retaining the existing logic to ensure that it is not mistakenly enabled on the command line (situated in the vm_version code). The compromise uses a common declaration, avoiding a dangling define_pd_global that applies to non-existent code, and supplements the logic that tests for invalid settings with a reset of the default (all in the vm_version code).

    I'm not averse to 'fixing' this the way you suggest at some point but . . . not here ;-)

    Thank you for the review!

    adinn adinn commented on Nov 17, 2026 13:08 UTC
    Author

    @vnkozlov Could you re-review this following the merge?

    dholmes-ora dholmes-ora commented on code on Nov 18, 2026 04:17 UTC
    Code Review
    src/hotspot/cpu/aarch64/vm_version_aarch64.cpp:1
    @@ -443,41 +447,20 @@ void VM_Version::initialize() {
         FLAG_SET_DEFAULT(UseGHASHIntrinsics, false);
       }
     
    -  if (supports_feature(CPU_ASIMD)) {
    -    if (FLAG_IS_DEFAULT(UseChaCha20Intrinsics)) {
    -      UseChaCha20Intrinsics = true;
    -    }
    -  } else if (UseChaCha20Intrinsics) {
    -    if (!FLAG_IS_DEFAULT(UseChaCha20Intrinsics)) {
    -      warning("ChaCha20 intrinsic requires ASIMD instructions");
    -    }
    -    FLAG_SET_DEFAULT(UseChaCha20Intrinsics, false);
    +  if (FLAG_IS_DEFAULT(UseChaCha20Intrinsics)) {
    +    UseChaCha20Intrinsics = true;
       }

    Yes I see that now. All platforms get the shared global flag in a disabled state; platforms that support it then opt-in by flipping the value at runtime. I wonder if we can augment the pd flag handling so that it acts the same way ... something to think on.

    Reviewers
    Assignees
    adinn adinn
    Labels
    risk: low confidence: 88.6% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 34.8% (LOW) · Higher = larger blast radius
    34.8%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 88.6% · Lower = rushed or shallow review
    88.6%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 4.0% · Safe to merge
    4.0%
    Repository