On Sat, 17 Apr 2021 20:18:31 GMT, Doug Simon <dnsi...@openjdk.org> wrote:

> While porting [JDK-8224974](https://bugs.openjdk.java.net/browse/JDK-8224974) 
> to Graal, I noticed that new CPU features were defined for x86 and AArch64 
> without being exposed via JVMCI. To avoid this problem in future, this PR 
> updates x86 and AArch64 to define CPU features with a single macro that is 
> used to generate enum declarations as well as vmstructs entries.
> 
> In addition, the JVMCI API is updated to exposes the new CPU feature 
> constants and now has a check that ensure these constants are in sync with 
> the underlying macro definition.

src/hotspot/cpu/aarch64/vm_version_aarch64.cpp line 198:

> 196:   sprintf(buf, "0x%02x:0x%x:0x%03x:%d", _cpu, _variant, _model, 
> _revision);
> 197:   if (_model2) sprintf(buf+strlen(buf), "(0x%03x)", _model2);
> 198: #define ADD_FEATURE_IF_SUPPORTED(id, name, bit) if (_features & 
> CPU_##id) strcat(buf, ", " name);

I'm not sure why only some of the supported AArch64 CPU features were being 
added to `_features_string` but I assume there's no harm in adding them all.

src/hotspot/cpu/x86/vm_version_x86.hpp line 382:

> 380:   static const char* _features_names[];
> 381: 
> 382:   // NB! When adding new CPU feature detection consider updating 
> vmStructs_x86.hpp, vmStructs_jvmci.hpp, and 
> VM_Version::get_processor_features().

No need for this comment any more as the derivative declarations are now 
automatically kept up to date.

src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot.amd64/src/jdk/vm/ci/hotspot/amd64/AMD64HotSpotJVMCIBackendFactory.java
 line 57:

> 55: 
> 56:         Map<String, Long> constants = config.getStore().getConstants();
> 57:         Function<String, CPUFeature> nameToFeature = name -> 
> name.equals("3DNOW_PREFETCH") ? CPUFeature.AMD_3DNOW_PREFETCH : 
> CPUFeature.valueOf(name);

The `AMD_3DNOW_PREFETCH` enum constant has to keep its old name to preserve 
backward compatibility.

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

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

Reply via email to