Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 3 additions & 0 deletions make/autoconf/flags-cflags.m4
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,9 @@ AC_DEFUN([FLAGS_SETUP_CFLAGS_CPU_DEP],
$1_DEFINES_CPU_JDK="${$1_DEFINES_CPU_JDK} -DARCH='\"$FLAGS_CPU_LEGACY\"' \
-D$FLAGS_CPU_LEGACY"

# setup arch name (the same as 'os.arch' system property)
$1_DEFINES_CPU_JVM="${$1_DEFINES_CPU_JVM} -DARCHPROPNAME='\"$OPENJDK_TARGET_CPU_OSARCH\"'"

if test "x$FLAGS_CPU_BITS" = x64; then
$1_DEFINES_CPU_JDK="${$1_DEFINES_CPU_JDK} -D_LP64=1"
$1_DEFINES_CPU_JVM="${$1_DEFINES_CPU_JVM} -D_LP64=1"
Expand Down
4 changes: 3 additions & 1 deletion src/hotspot/cpu/aarch64/vm_version_aarch64.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ class VM_Version : public Abstract_VM_Version {
public:
// Initialization
static void initialize();
struct VM_Features {};
struct VM_Features {
inline int print_numbers(char *buf_orig, size_t buflen, bool hexonly = false) const { return 0; }
};
static bool cpu_features_binary(VM_Features *data) { return false; }
static bool cpu_features_binary_check(const VM_Features *data) { return data == nullptr; }
static bool ignore_cpu_features() { return true; }
Expand Down
4 changes: 3 additions & 1 deletion src/hotspot/cpu/arm/vm_version_arm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ class VM_Version: public Abstract_VM_Version {
public:
static void initialize();
static bool is_initialized() { return _is_initialized; }
struct VM_Features {};
struct VM_Features {
inline int print_numbers(char *buf_orig, size_t buflen, bool hexonly = false) const { return 0; }
};
static bool cpu_features_binary(VM_Features *data) { return false; }
static bool cpu_features_binary_check(const VM_Features *data) { return data == nullptr; }
static bool ignore_cpu_features() { return true; }
Expand Down
4 changes: 3 additions & 1 deletion src/hotspot/cpu/ppc/vm_version_ppc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ class VM_Version: public Abstract_VM_Version {
// Initialization
static void initialize();
static void check_virtualizations();
struct VM_Features {};
struct VM_Features {
inline int print_numbers(char *buf_orig, size_t buflen, bool hexonly = false) const { return 0; }
};
static bool cpu_features_binary(VM_Features *data) { return false; }
static bool cpu_features_binary_check(const VM_Features *data) { return data == nullptr; }
static bool ignore_cpu_features() { return true; }
Expand Down
4 changes: 3 additions & 1 deletion src/hotspot/cpu/riscv/vm_version_riscv.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,9 @@ class VM_Version : public Abstract_VM_Version {
// Initialization
static void initialize();
static void initialize_cpu_information();
struct VM_Features {};
struct VM_Features {
inline int print_numbers(char *buf_orig, size_t buflen, bool hexonly = false) const { return 0; }
};
static bool cpu_features_binary(VM_Features *data) { return false; }
static bool cpu_features_binary_check(const VM_Features *data) { return data == nullptr; }
static bool ignore_cpu_features() { return true; }
Expand Down
4 changes: 3 additions & 1 deletion src/hotspot/cpu/s390/vm_version_s390.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,9 @@ class VM_Version: public Abstract_VM_Version {
static void initialize();
static void print_features();
static bool is_determine_features_test_running() { return _is_determine_features_test_running; }
struct VM_Features {};
struct VM_Features {
inline int print_numbers(char *buf_orig, size_t buflen, bool hexonly = false) const { return 0; }
};
static bool cpu_features_binary(VM_Features *data) { return false; }
static bool cpu_features_binary_check(const VM_Features *data) { return data == nullptr; }
static bool ignore_cpu_features() { return true; }
Expand Down
20 changes: 10 additions & 10 deletions src/hotspot/cpu/x86/vm_version_x86.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ bool VM_Version::supports_clflush() {
VM_Features flush;
flush.set_feature(CPU_FLUSH);
char buf[MAX_CPU_FEATURES];
flush.print_numbers(buf, sizeof(buf));
guarantee(flush.print_numbers(buf, sizeof(buf)) >= 0, "buffer too short");
vm_exit_during_initialization(err_msg("-XX:CPUFeatures option requires FLUSH flag to be set: %s", buf));
return false;
}
Expand Down Expand Up @@ -1261,9 +1261,9 @@ bool VM_Version::glibc_not_using() {
all_features.set_all_features();
if (handled != all_features) {
char buf_handled[MAX_CPU_FEATURES];
handled.print_numbers(buf_handled, sizeof(buf_handled));
guarantee(handled.print_numbers(buf_handled, sizeof(buf_handled)) >= 0, "buffer too short");
char buf_all_features[MAX_CPU_FEATURES];
all_features.print_numbers(buf_all_features, sizeof(buf_all_features));
guarantee(all_features.print_numbers(buf_all_features, sizeof(buf_all_features)) >= 0, "buffer too short");
vm_exit_during_initialization(err_msg("internal error: Unsupported disabling of some CPU_* %s != full %s", buf_handled, buf_all_features));
}
#endif // ASSERT
Expand All @@ -1282,7 +1282,7 @@ void VM_Version::print_using_features_cr() {
tty->print_cr("CPU features are being kept intact as requested by -XX:CPUFeatures=ignore");
} else {
char buf[MAX_CPU_FEATURES];
_features.print_numbers(buf, sizeof(buf));
guarantee(_features.print_numbers(buf, sizeof(buf)) >= 0, "buffer too short");
tty->print_cr("CPU features being used are: -XX:CPUFeatures=%s", buf);
}
}
Expand Down Expand Up @@ -1322,7 +1322,7 @@ void VM_Version::get_processor_features_hardware() {

if (ShowCPUFeatures) {
char buf[MAX_CPU_FEATURES];
_features.print_numbers(buf, sizeof(buf));
guarantee(_features.print_numbers(buf, sizeof(buf)) >= 0, "buffer too short");
tty->print_cr("This machine's CPU features are: -XX:CPUFeatures=%s", buf);
}
}
Expand All @@ -1334,7 +1334,7 @@ void VM_Version::get_processor_features_hotspot() {
VM_Features sse2;
sse2.set_feature(CPU_SSE2);
char buf[MAX_CPU_FEATURES];
sse2.print_numbers(buf, sizeof(buf));
guarantee(sse2.print_numbers(buf, sizeof(buf)) >= 0, "buffer too short");
vm_exit_during_initialization(err_msg("-XX:CPUFeatures option requires SSE2 flag to be set: %s", buf));
}
vm_exit_during_initialization("Unknown x64 processor: SSE2 not supported");
Expand Down Expand Up @@ -2581,9 +2581,9 @@ bool VM_Version::cpu_features_binary_check(const VM_Version::VM_Features *data_p

if (!features_missing.empty()) {
char buf_use[MAX_CPU_FEATURES];
(data & _features).print_numbers(buf_use, sizeof(buf_use));
guarantee((data & _features).print_numbers(buf_use, sizeof(buf_use)) >= 0, "buffer too short");
char buf_have[MAX_CPU_FEATURES];
data.print_numbers(buf_have, sizeof(buf_have));
guarantee(data.print_numbers(buf_have, sizeof(buf_have)) >= 0, "buffer too short");
tty->print("You have to specify -XX:CPUFeatures=%s together with -XX:CRaCCheckpointTo when making a checkpoint file"
"; specified -XX:CRaCRestoreFrom file contains CPU features %s",
buf_use, buf_have);
Expand Down Expand Up @@ -2671,9 +2671,9 @@ void VM_Version::initialize() {

if (!features_missing.empty()) {
char buf_CPUFeatures_parsed[MAX_CPU_FEATURES];
CPUFeatures_parsed.print_numbers(buf_CPUFeatures_parsed, sizeof(buf_CPUFeatures_parsed));
guarantee(CPUFeatures_parsed.print_numbers(buf_CPUFeatures_parsed, sizeof(buf_CPUFeatures_parsed)) >= 0, "buffer too short");
char buf_features[MAX_CPU_FEATURES];
_features.print_numbers(buf_features, sizeof(buf_features));
guarantee(_features.print_numbers(buf_features, sizeof(buf_features)) >= 0, "buffer too short");
tty->print("Specified -XX:CPUFeatures=%s; this machine's CPU features are %s", buf_CPUFeatures_parsed, buf_features);
features_missing.print_missing_features();
vm_exit_during_initialization();
Expand Down
16 changes: 12 additions & 4 deletions src/hotspot/cpu/x86/vm_version_x86.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -596,24 +596,32 @@ class VM_Version : public Abstract_VM_Version {
return *this == empty_features;
}

int print_numbers(char *buf_orig, size_t buflen) const {
int print_numbers(char *buf_orig, size_t buflen, bool hexonly = false) const {
char *buf = buf_orig;
const char *format = hexonly ? UINT64_FORMAT_0 : UINT64_FORMAT_X;
apply_to_all_features([&](uint64_t u, int idx) {
int res = jio_snprintf(buf, buflen, UINT64_FORMAT_X, u);
int res = jio_snprintf(buf, buflen, format, u);
if (res < 0) {
buflen = 0;
return;
}
buf += res;
buflen -= res;
assert(res > 0 && buflen >= 1, "not enough temporary space allocated");
if (idx + 1 < features_bitmap_element_count()) {
if (!hexonly && idx + 1 < features_bitmap_element_count() && buflen > 0) {
*buf++ = ',';
--buflen;
}
});
if (buflen == 0) {
return -1;
}
*buf = 0;
return buf - buf_orig;
}

void print_numbers_and_names(char *buf, size_t buflen) const {
int res = print_numbers(buf, buflen);
assert(res >= 0, "buffer too short");
buf += res;
buflen -= res;
assert(buflen >= 3, "not enough temporary space allocated");
Expand Down
4 changes: 3 additions & 1 deletion src/hotspot/cpu/zero/vm_version_zero.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@
class VM_Version : public Abstract_VM_Version {
public:
static void initialize();
struct VM_Features {};
struct VM_Features {
inline int print_numbers(char *buf_orig, size_t buflen, bool hexonly = false) const { return 0; }
};
static bool cpu_features_binary(VM_Features *data) { return false; }
static bool cpu_features_binary_check(const VM_Features *data) { return data == nullptr; }
static bool ignore_cpu_features() { return true; }
Expand Down
Loading