[crac] RFR: 8368929: [CRaC] Move CPUFeatures check to C/R engine

Jan Kratochvil jkratochvil at openjdk.org
Wed Oct 1 12:53:18 UTC 2025


On Wed, 1 Oct 2025 12:22:44 GMT, Radim Vansa <rvansa at openjdk.org> wrote:

>> src/hotspot/share/runtime/crac.cpp line 527:
>> 
>>> 525:   // Since the check itself is delegated to the C/R Engine we will simply
>>> 526:   // skip the check here (or prevent storing the features in the image).
>>> 527: #ifdef __x86_64__
>> 
>> One should not use `#ifdef` as it may lead to compilation errors on other arches.
>
> How is this different from creating an arch-specific method with different implementations? To me that look just like a boilerplate (and the presence is only checked for currently compiled arch - so I won't make sure that the code work on all archs).

It is true there are no target-specific files/classes. But there still can be:

class crac {
static bool is_x86_64() {
#ifdef __x86_64__
  return true;
#else
  return false;
#endif
  };
};
if (is_x86_64()) {
  ...
}

Then all arch-specific code is compile-time checked on all arches.

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

PR Review Comment: https://git.openjdk.org/crac/pull/266#discussion_r2394460939


More information about the crac-dev mailing list