Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
331 changes: 191 additions & 140 deletions src/hotspot/cpu/x86/vm_version_x86.cpp

Large diffs are not rendered by default.

208 changes: 127 additions & 81 deletions src/hotspot/cpu/x86/vm_version_x86.hpp

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions src/hotspot/share/jvmci/vmStructs_jvmci.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,6 @@
JVMTI_ONLY(static_field(CompilerToVM::Data, _should_notify_object_alloc, int*)) \
\
static_field(Abstract_VM_Version, _features, uint64_t) \
static_field(Abstract_VM_Version, _vm_target_features, VM_Features) \
\
nonstatic_field(VM_Features, _features_vector, VM_Features::FeatureVector) \
static_field(VM_Features, _features_vector_size, uint32_t) \
static_field(VM_Features, _features_vector_element_shift_count, uint32_t) \
\
nonstatic_field(Annotations, _class_annotations, AnnotationArray*) \
nonstatic_field(Annotations, _fields_annotations, Array<AnnotationArray*>*) \
Expand Down Expand Up @@ -980,7 +975,12 @@

#define VM_STRUCTS_CPU(nonstatic_field, static_field, unchecked_nonstatic_field, volatile_nonstatic_field, nonproduct_nonstatic_field) \
volatile_nonstatic_field(JavaFrameAnchor, _last_Java_fp, intptr_t*) \
static_field(VM_Version, _has_intel_jcc_erratum, bool)
static_field(VM_Version, _features, VM_Features) \
\
nonstatic_field(VM_Features, _features_vector, VM_Features::FeatureVector) \
static_field(VM_Features, _features_vector_size, uint32_t) \
static_field(VM_Features, _features_vector_element_shift_count, uint32_t) \
static_field(VM_Version, _has_intel_jcc_erratum, bool)

#define VM_INT_CONSTANTS_CPU(declare_constant, declare_preprocessor_constant) \
LP64_ONLY(declare_constant(frame::arg_reg_save_area_bytes)) \
Expand Down
44 changes: 0 additions & 44 deletions src/hotspot/share/runtime/abstract_vm_version.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,6 @@ const char* Abstract_VM_Version::_features_string = "";
const char* Abstract_VM_Version::_cpu_info_string = "";
uint64_t Abstract_VM_Version::_cpu_features = 0;

uint32_t VM_Features::_features_vector_element_shift_count = 6;
uint32_t VM_Features::_features_vector_size = MAX_FEATURE_VEC_SIZE;
VM_Features Abstract_VM_Version::_vm_target_features = {{0, 0, 0, 0}};
VM_Features Abstract_VM_Version::_cpu_target_features = {{0, 0, 0, 0}};

#ifndef SUPPORTS_NATIVE_CX8
bool Abstract_VM_Version::_supports_cx8 = false;
#endif
Expand Down Expand Up @@ -330,20 +325,6 @@ unsigned int Abstract_VM_Version::jvm_version() {
(Abstract_VM_Version::vm_build_number() & 0xFF);
}

void Abstract_VM_Version::insert_features_names(uint64_t features, char* buf, size_t buflen, const char* features_names[],
uint features_names_index) {
while (features != 0) {
if (features & 1) {
int res = jio_snprintf(buf, buflen, ", %s", features_names[features_names_index]);
assert(res > 0, "not enough temporary space allocated");
buf += res;
buflen -= res;
}
features >>= 1;
++features_names_index;
}
}

const char* Abstract_VM_Version::extract_features_string(const char* cpu_info_string,
size_t cpu_info_string_len,
size_t features_offset) {
Expand Down Expand Up @@ -421,28 +402,3 @@ const char* Abstract_VM_Version::cpu_description(void) {
strncpy(tmp, _cpu_desc, CPU_DETAILED_DESC_BUF_SIZE);
return tmp;
}

void VM_Features::set_feature(uint32_t feature) {
uint32_t index = feature >> _features_vector_element_shift_count;
uint32_t index_mask = (1 << _features_vector_element_shift_count) - 1;
assert(index < _features_vector_size, "Features array index out of bounds");
_features_vector[index] |= (1ULL << (feature & index_mask));
}

void VM_Features::clear_feature(uint32_t feature) {
uint32_t index = feature >> _features_vector_element_shift_count;
uint32_t index_mask = (1 << _features_vector_element_shift_count) - 1;
assert(index < _features_vector_size, "Features array index out of bounds");
_features_vector[index] &= ~(1ULL << (feature & index_mask));
}

bool VM_Features::supports_feature(uint32_t feature) {
uint32_t index = feature >> _features_vector_element_shift_count;
uint32_t index_mask = (1 << _features_vector_element_shift_count) - 1;
assert(index < _features_vector_size, "Features array index out of bounds");
return (_features_vector[index] & (1ULL << (feature & index_mask))) != 0;
}

bool VM_Features::is_within_feature_vector_bounds(uint32_t num_features) {
return _features_vector_size >= ((num_features >> _features_vector_element_shift_count) + 1);
}
56 changes: 1 addition & 55 deletions src/hotspot/share/runtime/abstract_vm_version.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,29 +44,6 @@ typedef enum {
class outputStream;
enum class vmIntrinsicID;

#define MAX_FEATURE_VEC_SIZE 4

class VM_Features {
public:
using FeatureVector = uint64_t [MAX_FEATURE_VEC_SIZE];

// Feature vector bitmap currently only used by x86 backend.
FeatureVector _features_vector;

// Size of feature vector bitmap.
static uint32_t _features_vector_size;

// Log2 of feature vector element size in bits, used by JVMCI to check enabled feature bits.
// Refer HotSpotJVMCIBackendFactory::convertFeaturesVector.
static uint32_t _features_vector_element_shift_count;

static bool is_within_feature_vector_bounds(uint32_t num_features);

void set_feature(uint32_t feature);
void clear_feature(uint32_t feature);
bool supports_feature(uint32_t feature);
};

// Abstract_VM_Version provides information about the VM.

class Abstract_VM_Version: AllStatic {
Expand All @@ -87,34 +64,6 @@ class Abstract_VM_Version: AllStatic {
// Original CPU feature flags, not affected by VM settings.
static uint64_t _cpu_features;

// CPU feature flags vector, can be affected by VM settings.
static VM_Features _vm_target_features;

// Original CPU feature flags vector, not affected by VM settings.
static VM_Features _cpu_target_features;

static void sync_cpu_features() {
memcpy(_cpu_target_features._features_vector, _vm_target_features._features_vector,
sizeof(uint64_t) * VM_Features::_features_vector_size);
}

static void clear_cpu_features() {
memset(_vm_target_features._features_vector, 0, sizeof(uint64_t) * VM_Features::_features_vector_size);
}

static bool vm_features_exist() {
return VM_Features::_features_vector_size > 0;
}

static uint32_t features_vector_size() {
return VM_Features::_features_vector_size;
}

static uint64_t features_vector_elem(uint32_t elem) {
assert(elem < VM_Features::_features_vector_size, "");
return _vm_target_features._features_vector[elem];
}

// These are set by machine-dependent initializations
#ifndef SUPPORTS_NATIVE_CX8
static bool _supports_cx8;
Expand Down Expand Up @@ -180,13 +129,10 @@ class Abstract_VM_Version: AllStatic {
static const char* jdk_debug_level();
static const char* printable_jdk_debug_level();

static uint64_t features() {
return _features;
}
static uint64_t features() { return _features; }

static const char* features_string() { return _features_string; }

static void insert_features_names(uint64_t features, char* buf, size_t buflen, const char* features_names[], uint features_names_index = 0);
static const char* cpu_info_string() { return _cpu_info_string; }
static const char* extract_features_string(const char* cpu_info_string,
size_t cpu_info_string_len,
Expand Down
1 change: 0 additions & 1 deletion src/hotspot/share/runtime/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ void classLoader_init1();
void compilationPolicy_init();
void codeCache_init();
void VM_Version_init();
void VM_Version_pre_init();
void icache_init2();
void initial_stubs_init();

Expand Down
13 changes: 7 additions & 6 deletions src/hotspot/share/runtime/vmStructs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -707,11 +707,11 @@
static_field(Abstract_VM_Version, _vm_minor_version, int) \
static_field(Abstract_VM_Version, _vm_security_version, int) \
static_field(Abstract_VM_Version, _vm_build_number, int) \
static_field(Abstract_VM_Version, _vm_target_features, VM_Features) \
\
nonstatic_field(VM_Features, _features_vector, VM_Features::FeatureVector) \
static_field(VM_Features, _features_vector_size, uint32_t) \
static_field(VM_Features, _features_vector_element_shift_count, uint32_t) \
NOT_ZERO(X86_ONLY(static_field(VM_Version, _features, VM_Features))) \
NOT_ZERO(X86_ONLY(nonstatic_field(VM_Features, _features_vector, VM_Features::FeatureVector))) \
NOT_ZERO(X86_ONLY(static_field(VM_Features, _features_vector_size, uint32_t))) \
NOT_ZERO(X86_ONLY(static_field(VM_Features, _features_vector_element_shift_count, uint32_t))) \
\
/*************************/ \
/* JVMTI */ \
Expand Down Expand Up @@ -1169,8 +1169,9 @@
/********************/ \
\
declare_toplevel_type(Abstract_VM_Version) \
declare_toplevel_type(VM_Features) \
declare_toplevel_type(VM_Features::FeatureVector) \
NOT_ZERO(declare_toplevel_type(VM_Features)) \
NOT_ZERO(declare_toplevel_type(VM_Version)) \
NOT_ZERO(declare_toplevel_type(VM_Features::FeatureVector)) \
\
/*************/ \
/* Arguments */ \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ private static EnumSet<CPUFeature> computeFeatures(AMD64HotSpotVMConfig config)
Map<String, String> renaming = Map.of("3DNOW_PREFETCH", "AMD_3DNOW_PREFETCH");
assert config.useSSE >= 2 : "minimum config for x64";
EnumSet<CPUFeature> features = HotSpotJVMCIBackendFactory.convertFeaturesVector(CPUFeature.class, constants,
config.vmVersionTargetFeatures,
config.vmVersionFeatures,
config.vmFeaturesFeaturesVecOffset,
config.vmFeaturesFeaturesVecSize,
config.vmFeaturesFeaturesElemShiftCnt,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class AMD64HotSpotVMConfig extends HotSpotVMConfigAccess {
final boolean useCountTrailingZerosInstruction = getFlag("UseCountTrailingZerosInstruction", Boolean.class);
final boolean useCompressedOops = getFlag("UseCompressedOops", Boolean.class);

final long vmVersionTargetFeatures = getFieldAddress("Abstract_VM_Version::_vm_target_features", "VM_Features");
final long vmVersionFeatures = getFieldAddress("VM_Version::_features", "VM_Features");
final long vmFeaturesFeaturesVecOffset = getFieldOffset("VM_Features::_features_vector", Long.class, "VM_Features::FeatureVector");
final long vmFeaturesFeaturesVecSize = getFieldValue("VM_Features::_features_vector_size", Long.class, "uint32_t");
final long vmFeaturesFeaturesElemShiftCnt = getFieldValue("VM_Features::_features_vector_element_shift_count", Long.class, "uint32_t");
Expand Down