@@ -63,10 +63,10 @@ address VM_Version::_cpuinfo_cont_addr_apx = nullptr;
6363static BufferBlob* stub_blob;
6464static const int stub_size = 2000 ;
6565
66- uint32_t VM_Features::_features_vector_element_shift_count = 6 ;
67- uint32_t VM_Features::_features_vector_size = MAX_FEATURE_VEC_SIZE;
68- VM_Features VM_Version::_features;
69- VM_Features VM_Version::_cpu_features;
66+ int VM_Version:: VM_Features::_features_bitmap_size_in_bytes = sizeof (VM_Version::VM_Features::_features_bitmap) ;
67+
68+ VM_Version:: VM_Features VM_Version::_features;
69+ VM_Version:: VM_Features VM_Version::_cpu_features;
7070
7171extern " C" {
7272 typedef void (*get_cpu_info_stub_t )(void *);
@@ -1101,11 +1101,8 @@ void VM_Version::get_processor_features() {
11011101 cores_per_cpu (), threads_per_core (),
11021102 cpu_family (), _model, _stepping, os::cpu_microcode_revision ());
11031103 assert (cpu_info_size > 0 , " not enough temporary space allocated" );
1104- size_t buf_iter = cpu_info_size;
1105- for (uint64_t i = 0 ; i < VM_Features::features_vector_size (); i++) {
1106- insert_features_names (features_vector_elem (i), buf + buf_iter, sizeof (buf) - buf_iter, _features_names, 64 * i);
1107- buf_iter = strlen (buf);
1108- }
1104+
1105+ insert_features_names (_features, buf + cpu_info_size, sizeof (buf) - cpu_info_size);
11091106
11101107 _cpu_info_string = os::strdup (buf);
11111108
@@ -2107,7 +2104,6 @@ static bool _vm_version_initialized = false;
21072104
21082105void VM_Version::initialize () {
21092106 ResourceMark rm;
2110- assert (VM_Features::is_within_feature_vector_bounds (MAX_CPU_FEATURES), " Feature out of vector bounds" );
21112107
21122108 // Making this stub must be FIRST use of assembler
21132109 stub_blob = BufferBlob::create (" VM_Version stub" , stub_size);
@@ -2884,7 +2880,7 @@ int64_t VM_Version::maximum_qualified_cpu_frequency(void) {
28842880 return _max_qualified_cpu_frequency;
28852881}
28862882
2887- VM_Features VM_Version::CpuidInfo::feature_flags () const {
2883+ VM_Version:: VM_Features VM_Version::CpuidInfo::feature_flags () const {
28882884 VM_Features vm_features;
28892885 if (std_cpuid1_edx.bits .cmpxchg8 != 0 )
28902886 vm_features.set_feature (CPU_CX8);
@@ -3280,47 +3276,13 @@ bool VM_Version::is_intrinsic_supported(vmIntrinsicID id) {
32803276 return true ;
32813277}
32823278
3283- void VM_Features::set_feature (uint32_t feature) {
3284- uint32_t index = feature >> _features_vector_element_shift_count;
3285- uint32_t index_mask = (1 << _features_vector_element_shift_count) - 1 ;
3286- assert (index < _features_vector_size, " Features array index out of bounds" );
3287- _features_vector[index] |= (1ULL << (feature & index_mask));
3288- }
3289-
3290- void VM_Features::clear_feature (uint32_t feature) {
3291- uint32_t index = feature >> _features_vector_element_shift_count;
3292- uint32_t index_mask = (1 << _features_vector_element_shift_count) - 1 ;
3293- assert (index < _features_vector_size, " Features array index out of bounds" );
3294- _features_vector[index] &= ~(1ULL << (feature & index_mask));
3295- }
3296-
3297- void VM_Features::clear_features () {
3298- for (uint32_t i = 0 ; i < _features_vector_size; i++) {
3299- _features_vector[i] = 0 ;
3300- }
3301- }
3302-
3303- bool VM_Features::supports_feature (uint32_t feature) {
3304- uint32_t index = feature >> _features_vector_element_shift_count;
3305- uint32_t index_mask = (1 << _features_vector_element_shift_count) - 1 ;
3306- assert (index < _features_vector_size, " Features array index out of bounds" );
3307- return (_features_vector[index] & (1ULL << (feature & index_mask))) != 0 ;
3308- }
3309-
3310- bool VM_Features::is_within_feature_vector_bounds (uint32_t num_features) {
3311- return _features_vector_size >= ((num_features >> _features_vector_element_shift_count) + 1 );
3312- }
3313-
3314- void VM_Version::insert_features_names (uint64_t features, char * buf, size_t buflen, const char * features_names[],
3315- uint features_names_index) {
3316- while (features != 0 ) {
3317- if (features & 1 ) {
3318- int res = jio_snprintf (buf, buflen, " , %s" , features_names[features_names_index]);
3279+ void VM_Version::insert_features_names (VM_Version::VM_Features features, char * buf, size_t buflen) {
3280+ for (int i = 0 ; i < MAX_CPU_FEATURES; i++) {
3281+ if (features.supports_feature ((VM_Version::Feature_Flag)i)) {
3282+ int res = jio_snprintf (buf, buflen, " , %s" , _features_names[i]);
33193283 assert (res > 0 , " not enough temporary space allocated" );
33203284 buf += res;
33213285 buflen -= res;
33223286 }
3323- features >>= 1 ;
3324- ++features_names_index;
33253287 }
33263288}
0 commit comments