Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8295146: Clean up native code with newer C/C++ language features #11081

Closed
wants to merge 65 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
e668fa4
Cleanup
TheShermanTanker Oct 10, 2022
212299e
Merge remote-tracking branch 'upstream/master' into warnings
TheShermanTanker Oct 10, 2022
a0808e4
PRAGMA utility
TheShermanTanker Oct 10, 2022
eebe53b
Move PRAGMA to macros.hpp
TheShermanTanker Oct 10, 2022
daf5522
Merge remote-tracking branch 'upstream/master' into warnings
TheShermanTanker Oct 11, 2022
83ed3de
Comment PRAGMA macro and try removing the workaround from JDK-8274980
TheShermanTanker Oct 11, 2022
53062d9
Missing comparison
TheShermanTanker Oct 11, 2022
629a36a
Macro for checking empty define except strings
TheShermanTanker Oct 11, 2022
7f00d5e
Write limitations in comment instead
TheShermanTanker Oct 11, 2022
f46497b
Merge remote-tracking branch 'upstream/master' into warnings
TheShermanTanker Oct 12, 2022
06ffe35
Merge remote-tracking branch 'upstream/master' into warnings
TheShermanTanker Oct 13, 2022
d1b358e
Implement alignment with the C11 alignas feature
TheShermanTanker Oct 13, 2022
2a80644
Merge
TheShermanTanker Oct 13, 2022
ee8cc63
Make address a proper unsigned byte
TheShermanTanker Oct 13, 2022
9ea05d6
Make Pragma more robust to macro expansions
TheShermanTanker Oct 16, 2022
1a63cff
Merge branch 'openjdk:master' into warnings
TheShermanTanker Oct 16, 2022
f42f257
Merge branch 'openjdk:master' into warnings
TheShermanTanker Oct 17, 2022
e5f0ea4
Update compilerWarnings.hpp
TheShermanTanker Oct 17, 2022
5f1ed98
Update compilerWarnings_visCPP.hpp
TheShermanTanker Oct 17, 2022
86908cf
Update os_windows_x86.cpp
TheShermanTanker Oct 17, 2022
1c576fb
Update os_windows_aarch64.cpp
TheShermanTanker Oct 17, 2022
027a0ac
Update compilerWarnings_gcc.hpp
TheShermanTanker Oct 17, 2022
43406aa
Update compilerWarnings.hpp
TheShermanTanker Oct 17, 2022
f16109e
Update compilerWarnings_gcc.hpp
TheShermanTanker Oct 17, 2022
9252f15
Update globalDefinitions_gcc.hpp
TheShermanTanker Oct 17, 2022
c49f0b9
Merge branch 'openjdk:master' into warnings
TheShermanTanker Oct 17, 2022
63a2fa5
Oops
TheShermanTanker Oct 17, 2022
9ac2a54
Update os_linux.cpp
TheShermanTanker Oct 17, 2022
d4edc9e
Update sharedRuntime_x86_64.cpp
TheShermanTanker Oct 17, 2022
e8744fb
Update MsiCA.h
TheShermanTanker Oct 17, 2022
f190f05
Update assembler_aarch64.hpp
TheShermanTanker Oct 17, 2022
bab3add
Refine pragmas
TheShermanTanker Oct 18, 2022
55001a4
Merge branch 'openjdk:master' into warnings
TheShermanTanker Oct 18, 2022
7eec82b
Update macroAssembler_aarch64.cpp
TheShermanTanker Oct 18, 2022
3e1d1be
Merge branch 'openjdk:master' into warnings
TheShermanTanker Oct 19, 2022
54b41b0
Merge branch 'openjdk:master' into warnings
TheShermanTanker Oct 22, 2022
5d19718
Merge branch 'openjdk:master' into warnings
TheShermanTanker Oct 24, 2022
73a6e38
Merge branch 'openjdk:master' into warnings
TheShermanTanker Oct 26, 2022
9ab0af7
Revert
TheShermanTanker Oct 26, 2022
31970b9
Update macros.hpp
TheShermanTanker Oct 26, 2022
50e4223
Update MsiCA.h
TheShermanTanker Oct 26, 2022
b8ed539
IS_EMPTY_VALUE for macros.hpp
TheShermanTanker Oct 26, 2022
f2e3c72
Properly handle VERSION_BUILD
TheShermanTanker Oct 26, 2022
ffec8b0
macros.hpp whitespace
TheShermanTanker Oct 26, 2022
c43f955
Merge branch 'openjdk:master' into warnings
TheShermanTanker Oct 27, 2022
61bddd1
More changes to use C++11 attributes
TheShermanTanker Oct 27, 2022
48e262c
Try fixing the broken build the earlier commit caused
TheShermanTanker Oct 27, 2022
0a05374
formatBuffer.hpp hopefully won't break the build now
TheShermanTanker Oct 27, 2022
fbeae3f
Finish off remaining ATTRIBUTE_PRINTF
TheShermanTanker Oct 27, 2022
2d7c562
arguments.hpp
TheShermanTanker Oct 27, 2022
0f02174
arguments.hpp v2...
TheShermanTanker Oct 27, 2022
fb9ecb6
SCANF_ARGS and some Windows stuff
TheShermanTanker Oct 27, 2022
b55071a
Hopefully the last of arguments.hpp
TheShermanTanker Oct 27, 2022
2bf475f
Code style
TheShermanTanker Oct 29, 2022
6027331
Merge jdkMerge remote-tracking branch 'upstream/master' into warnings
TheShermanTanker Oct 29, 2022
e72b9b1
Further formatting
TheShermanTanker Oct 29, 2022
4d8b710
This will likely fail, but that's not important
TheShermanTanker Nov 9, 2022
05b31ea
Resolve Conflict
TheShermanTanker Nov 9, 2022
26b120e
Oops v2
TheShermanTanker Nov 9, 2022
85f6d91
Missed an attribute
TheShermanTanker Nov 9, 2022
7ba5a7d
Merge remote-tracking branch 'upstream/master' into conformance
TheShermanTanker Nov 12, 2022
5e4bbd0
Minor Style Changes
TheShermanTanker Nov 12, 2022
6d85c43
More Style Changes
TheShermanTanker Nov 12, 2022
bb3ef0d
ATTRIBUTE_SCANF
TheShermanTanker Nov 14, 2022
fe5371c
Revert to using simpler solution similar to the original 8274980
TheShermanTanker Nov 14, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion make/autoconf/flags-cflags.m4
Expand Up @@ -629,7 +629,7 @@ AC_DEFUN([FLAGS_SETUP_CFLAGS_HELPER],
STATIC_LIBS_CFLAGS="-DSTATIC_BUILD=1"
if test "x$TOOLCHAIN_TYPE" = xgcc || test "x$TOOLCHAIN_TYPE" = xclang; then
STATIC_LIBS_CFLAGS="$STATIC_LIBS_CFLAGS -ffunction-sections -fdata-sections \
-DJNIEXPORT='__attribute__((visibility(\"hidden\")))'"
-DJNIEXPORT='[[gnu::visibility(\"hidden\")]]'"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So IIUC we now use attributes via the C++11 syntax rather than compiler-specific syntax - even where the C++11 syntax is referring to a compiler specific attribute. Is that right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, just something that C++ does a little neater, at least in my view

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We (the HotSpot Group) have not discussed or approved the use of the new C++ attribute syntax, whether for standard attributes or compiler-specific ones. That involves an update to the Style Guide. I'm not convinced switching existing uses from compiler-specific __attribute__ syntax to compiler-specific [[attribute]] syntax is worth the substantial code churn.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was under the assumption that anything not listed under "Not discussed" or "Forbidden" was free game in HotSpot, I apologise for my goof since that isn't the case. That said, I am curious if there are any isolated conversations about the attribute syntax anywhere

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kimbarrett Aside from the attribute syntax (which you're already doing in a new proposal), now that alignas has been approved for use in HotSpot, is there anything that can be done for 8250269: Replace ATTRIBUTE_ALIGNED with alignas and the related Pull Request (https://git.openjdk.org/jdk/pull/11431)?

else
STATIC_LIBS_CFLAGS="$STATIC_LIBS_CFLAGS -DJNIEXPORT="
fi
Expand Down
5 changes: 0 additions & 5 deletions make/hotspot/lib/CompileJvm.gmk
Expand Up @@ -61,11 +61,6 @@ else
OPENJDK_TARGET_CPU_VM_VERSION := $(OPENJDK_TARGET_CPU)
endif

ifeq ($(VERSION_BUILD), )
# Hotspot cannot handle an empty build number
VERSION_BUILD := 0
endif
TheShermanTanker marked this conversation as resolved.
Show resolved Hide resolved

ifeq ($(HOTSPOT_BUILD_TIME), )
HOTSPOT_BUILD_TIME := $(call EpochToISO8601, $(shell $(DATE) +"%s"))
endif
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/cpu/aarch64/assembler_aarch64.hpp
Expand Up @@ -208,7 +208,7 @@ class Instruction_aarch64 {
return extend(uval, msb - lsb);
}

static ALWAYSINLINE void patch(address a, int msb, int lsb, uint64_t val) {
ALWAYSINLINE static void patch(address a, int msb, int lsb, uint64_t val) {
int nbits = msb - lsb + 1;
guarantee(val < (1ULL << nbits), "Field too big for insn");
assert_cond(msb >= lsb);
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp
Expand Up @@ -178,7 +178,7 @@ class RelocActions {
virtual int immediate(address insn_addr, address &target) = 0;
virtual void verify(address insn_addr, address &target) = 0;

int ALWAYSINLINE run(address insn_addr, address &target) {
ALWAYSINLINE int run(address insn_addr, address &target) {
int instructions = 1;

uint32_t dispatch = Instruction_aarch64::extract(_insn, 30, 25);
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/cpu/x86/sharedRuntime_x86_64.cpp
Expand Up @@ -3386,7 +3386,7 @@ do { \
// in A Cryptographic Library for the Motorola DSP56000,
// Dusse and Kaliski, Proc. EUROCRYPT 90, pp. 230-237.

static void NOINLINE
NOINLINE static void
montgomery_multiply(julong a[], julong b[], julong n[],
julong m[], julong inv, int len) {
julong t0 = 0, t1 = 0, t2 = 0; // Triple-precision accumulator
Expand Down Expand Up @@ -3428,7 +3428,7 @@ montgomery_multiply(julong a[], julong b[], julong n[],
// multiplication. However, its loop control is more complex and it
// may actually run slower on some machines.

static void NOINLINE
NOINLINE static void
montgomery_square(julong a[], julong n[],
julong m[], julong inv, int len) {
julong t0 = 0, t1 = 0, t2 = 0; // Triple-precision accumulator
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/os/linux/os_linux.cpp
Expand Up @@ -601,7 +601,7 @@ void os::Linux::libpthread_init() {
// _expand_stack_to() assumes its frame size is less than page size, which
// should always be true if the function is not inlined.

static void NOINLINE _expand_stack_to(address bottom) {
NOINLINE static void _expand_stack_to(address bottom) {
address sp;
size_t size;
volatile char *p;
Expand Down
9 changes: 6 additions & 3 deletions src/hotspot/os/linux/os_perf_linux.cpp
Expand Up @@ -230,7 +230,8 @@ static double get_cpu_load(int which_logical_cpu, CPUPerfCounters* counters, dou
/** reads /proc/<pid>/stat data, with some checks and some skips.
* Ensure that 'fmt' does _NOT_ contain the first two "%d %s"
*/
static int SCANF_ARGS(2, 0) vread_statdata(const char* procfile, _SCANFMT_ const char* fmt, va_list args) {
SCANF_ARGS(2, 0)
static int vread_statdata(const char* procfile, _SCANFMT_ const char* fmt, va_list args) {
FILE*f;
int n;
char buf[2048];
Expand Down Expand Up @@ -259,7 +260,8 @@ static int SCANF_ARGS(2, 0) vread_statdata(const char* procfile, _SCANFMT_ const
return n;
}

static int SCANF_ARGS(2, 3) read_statdata(const char* procfile, _SCANFMT_ const char* fmt, ...) {
SCANF_ARGS(2, 3)
static int read_statdata(const char* procfile, _SCANFMT_ const char* fmt, ...) {
int n;
va_list args;

Expand Down Expand Up @@ -394,7 +396,8 @@ static double get_cpu_load(int which_logical_cpu, CPUPerfCounters* counters, dou
return user_load;
}

static int SCANF_ARGS(1, 2) parse_stat(_SCANFMT_ const char* fmt, ...) {
SCANF_ARGS(1, 2)
static int parse_stat(_SCANFMT_ const char* fmt, ...) {
FILE *f;
va_list args;

Expand Down
2 changes: 2 additions & 0 deletions src/hotspot/os/windows/os_windows.hpp
Expand Up @@ -32,6 +32,8 @@
class outputStream;
class Thread;

static unsigned __stdcall thread_native_entry(Thread*);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this removed? This is needed to correctly specify the call sequence for the thread entry routine when used with _beginThreadex:
https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/beginthread-beginthreadex?view=msvc-170

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I follow, I didn't remove anything here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry my eyes must be playing tricks on me. ??

Why did you need to add this here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's to avoid redefining the linkage as static in os_windows.cpp (where it's implemented) after an extern declaration (inside the class), which is forbidden by C++11:

The linkages implied by successive declarations for a given entity shall agree. That is, within a given scope, each declaration declaring the same variable name or the same overloading of a function name shall imply the same linkage.

While 2019 by default seems to ignore this rule and accepts the conflicting linkage as a language extension, this can cause issues with newer and stricter versions of the Visual C++ compiler (especially with -permissive- passed during compilation, which Magnus and Daniel have pointed out in another discussion will become the default mode of compilation in the future). It's not possible to declare a static friend inside a class, so the addition above takes advantage of another C++ feature instead:

§11.3/4 [class.friend]
A function first declared in a friend declaration has external linkage (3.5). Otherwise, the function retains its previous linkage (7.1.1).

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the problem here is the friend declaration, which doesn't look like it's needed and could be deleted.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Digging into this some more, the friend declaration exists to provide access to the private os::win32::enum Ept.

One obvious and cheap solution to that would be to make that enum public. I think that would be an improvement vs the current friend declaration. But there are some other things one could complain about there, such as the type of the function requiring a complicated function pointer cast where it's used. Here's a patch that I think cleans this up.

diff --git a/src/hotspot/os/windows/os_windows.cpp b/src/hotspot/os/windows/os_windows.cpp
index 0651f0868f3..bf9e759b1d6 100644
--- a/src/hotspot/os/windows/os_windows.cpp
+++ b/src/hotspot/os/windows/os_windows.cpp
@@ -511,7 +511,9 @@ JNIEXPORT
 LONG WINAPI topLevelExceptionFilter(struct _EXCEPTION_POINTERS* exceptionInfo);
 
 // Thread start routine for all newly created threads
-static unsigned __stdcall thread_native_entry(Thread* thread) {
+// Called with the associated Thread* as the argument.
+unsigned __stdcall os::win32::thread_native_entry(void* t) {
+  Thread* thread = static_cast<Thread*>(t);
 
   thread->record_stack_base_and_size();
   thread->initialize_thread_current();
@@ -744,7 +746,7 @@ bool os::create_thread(Thread* thread, ThreadType thr_type,
     thread_handle =
       (HANDLE)_beginthreadex(NULL,
                              (unsigned)stack_size,
-                             (unsigned (__stdcall *)(void*)) thread_native_entry,
+                             &os::win32::thread_native_entry,
                              thread,
                              initflag,
                              &thread_id);
diff --git a/src/hotspot/os/windows/os_windows.hpp b/src/hotspot/os/windows/os_windows.hpp
index 94d7c3c5e2d..197797078d7 100644
--- a/src/hotspot/os/windows/os_windows.hpp
+++ b/src/hotspot/os/windows/os_windows.hpp
@@ -36,7 +36,6 @@ typedef void (*signal_handler_t)(int);
 
 class os::win32 {
   friend class os;
-  friend unsigned __stdcall thread_native_entry(Thread*);
 
  protected:
   static int    _processor_type;
@@ -70,6 +69,10 @@ class os::win32 {
   static HINSTANCE load_Windows_dll(const char* name, char *ebuf, int ebuflen);
 
  private:
+  // The handler passed to _beginthreadex().
+  // Called with the associated Thread* as the argument.
+  static unsigned __stdcall thread_native_entry(void*);
+
   enum Ept { EPT_THREAD, EPT_PROCESS, EPT_PROCESS_DIE };
   // Wrapper around _endthreadex(), exit() and _exit()
   static int exit_process_or_thread(Ept what, int exit_code);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue with that would be that thread_native_entry is declared as static to the compilation unit on other other Operating Systems as well, and having it as a static member on the win32 class instead would end up breaking this convention, for which I'm not sure if there's a reason why all of them are declared like this

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The thread entry functions are expected to be plain C functions as we use C library calls to create threads (_beginthreadex, pthread_create) not C++. They don't need to be visible outside the compilation unit hence static.


typedef void (*signal_handler_t)(int);

class os::win32 {
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/os_cpu/windows_aarch64/os_windows_aarch64.cpp
Expand Up @@ -65,7 +65,7 @@ void os::os_exception_wrapper(java_call_t f, JavaValue* value, const methodHandl
f(value, method, args, thread);
}

PRAGMA_DISABLE_MSVC_WARNING(4172)
PRAGMA_DISABLE_VISCPP_WARNING(4172)
// Returns an estimate of the current stack pointer. Result must be guaranteed
// to point into the calling threads stack, and be no lower than the current
// stack pointer.
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/os_cpu/windows_x86/os_windows_x86.cpp
Expand Up @@ -332,7 +332,7 @@ frame os::fetch_frame_from_context(const void* ucVoid) {
#ifndef AMD64
// Ignore "C4172: returning address of local variable or temporary" on 32bit
PRAGMA_DIAG_PUSH
PRAGMA_DISABLE_MSVC_WARNING(4172)
PRAGMA_DISABLE_VISCPP_WARNING(4172)
// Returns an estimate of the current stack pointer. Result must be guaranteed
// to point into the calling threads stack, and be no lower than the current
// stack pointer.
Expand Down
3 changes: 2 additions & 1 deletion src/hotspot/share/c1/c1_CFGPrinter.hpp
Expand Up @@ -62,7 +62,8 @@ class CFGPrinterOutput : public CHeapObj<mtCompiler> {

void inc_indent();
void dec_indent();
void print(const char* format, ...) ATTRIBUTE_PRINTF(2, 3);
ATTRIBUTE_PRINTF(2, 3)
void print(const char* format, ...);
void print_begin(const char* tag);
void print_end(const char* tag);

Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/cds/filemap.hpp
Expand Up @@ -479,8 +479,8 @@ class FileMapInfo : public CHeapObj<mtInternal> {
bool remap_shared_readonly_as_readwrite();

// Errors.
static void fail_stop(const char *msg, ...) ATTRIBUTE_PRINTF(1, 2);
static void fail_continue(const char *msg, ...) ATTRIBUTE_PRINTF(1, 2);
ATTRIBUTE_PRINTF(1, 2) static void fail_stop(const char *msg, ...);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again I suggest a newline after ATTRIBUTE_PRINTF

ATTRIBUTE_PRINTF(1, 2) static void fail_continue(const char *msg, ...);
static bool memory_mapping_failed() {
CDS_ONLY(return _memory_mapping_failed;)
NOT_CDS(return false;)
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/classfile/verifier.hpp
Expand Up @@ -432,8 +432,8 @@ class ClassVerifier : public StackObj {

// Called when verify or class format errors are encountered.
// May throw an exception based upon the mode.
void verify_error(ErrorContext ctx, const char* fmt, ...) ATTRIBUTE_PRINTF(3, 4);
void class_format_error(const char* fmt, ...) ATTRIBUTE_PRINTF(2, 3);
ATTRIBUTE_PRINTF(3, 4) void verify_error(ErrorContext ctx, const char* fmt, ...);
ATTRIBUTE_PRINTF(2, 3) void class_format_error(const char* fmt, ...);

Klass* load_class(Symbol* name, TRAPS);

Expand Down
5 changes: 3 additions & 2 deletions src/hotspot/share/compiler/compileLog.hpp
Expand Up @@ -55,7 +55,7 @@ class CompileLog : public xmlStream {

static CompileLog* _first; // head of static chain

void va_tag(bool push, const char* format, va_list ap) ATTRIBUTE_PRINTF(3, 0);
ATTRIBUTE_PRINTF(3, 0) void va_tag(bool push, const char* format, va_list ap);

public:
CompileLog(const char* file_name, FILE* fp, intx thread_id);
Expand All @@ -69,7 +69,8 @@ class CompileLog : public xmlStream {
// or reset, context string will be silently ignored
stringStream* context() { return &_context; }
void clear_context() { context()->reset(); }
void set_context(const char* format, ...) ATTRIBUTE_PRINTF(2, 3);
ATTRIBUTE_PRINTF(2, 3)
void set_context(const char* format, ...);

void name(ciSymbol* s); // name='s'
void name(Symbol* s) { xmlStream::name(s); }
Expand Down
15 changes: 10 additions & 5 deletions src/hotspot/share/gc/shared/gcLogPrecious.hpp
Expand Up @@ -60,22 +60,25 @@ class GCLogPrecious : public AllStatic {
// Protects the buffers
static Mutex* _lock;

ATTRIBUTE_PRINTF(2, 0)
static void vwrite_inner(LogTargetHandle log,
const char* format,
va_list args) ATTRIBUTE_PRINTF(2, 0);
va_list args);

public:
static void initialize();

ATTRIBUTE_PRINTF(2, 0)
static void vwrite(LogTargetHandle log,
const char* format,
va_list args) ATTRIBUTE_PRINTF(2, 0);
va_list args);

ATTRIBUTE_PRINTF(2, 0)
static void vwrite_and_debug(LogTargetHandle log,
const char* format,
va_list args
DEBUG_ONLY(COMMA const char* file)
DEBUG_ONLY(COMMA int line)) ATTRIBUTE_PRINTF(2, 0);
DEBUG_ONLY(COMMA int line));

static void print_on_error(outputStream* st);
};
Expand All @@ -94,14 +97,16 @@ class GCLogPreciousHandle {
DEBUG_ONLY(COMMA _line(line))
{}

void write(const char* format, ...) ATTRIBUTE_PRINTF(2, 3) {
ATTRIBUTE_PRINTF(2, 3)
void write(const char* format, ...) {
va_list args;
va_start(args, format);
GCLogPrecious::vwrite(_log, format, args);
va_end(args);
}

void write_and_debug(const char* format, ...) ATTRIBUTE_PRINTF(2, 3) {
ATTRIBUTE_PRINTF(2, 3)
void write_and_debug(const char* format, ...) {
va_list args;
va_start(args, format);
GCLogPrecious::vwrite_and_debug(_log, format, args DEBUG_ONLY(COMMA _file COMMA _line));
Expand Down
9 changes: 6 additions & 3 deletions src/hotspot/share/gc/z/zStat.cpp
Expand Up @@ -984,7 +984,8 @@ class ZStatTablePrinter {
_width(width),
_width_next(width_next) {}

ZColumn left(const char* fmt, ...) ATTRIBUTE_PRINTF(2, 3) {
ATTRIBUTE_PRINTF(2, 3)
ZColumn left(const char* fmt, ...) {
va_list va;

va_start(va, fmt);
Expand All @@ -999,7 +1000,8 @@ class ZStatTablePrinter {
return next();
}

ZColumn right(const char* fmt, ...) ATTRIBUTE_PRINTF(2, 3) {
ATTRIBUTE_PRINTF(2, 3)
ZColumn right(const char* fmt, ...) {
va_list va;

va_start(va, fmt);
Expand All @@ -1022,7 +1024,8 @@ class ZStatTablePrinter {
return next();
}

ZColumn center(const char* fmt, ...) ATTRIBUTE_PRINTF(2, 3) {
ATTRIBUTE_PRINTF(2, 3)
ZColumn center(const char* fmt, ...) {
va_list va;

va_start(va, fmt);
Expand Down
14 changes: 7 additions & 7 deletions src/hotspot/share/jvmci/jvmci.hpp
Expand Up @@ -173,18 +173,18 @@ class JVMCI : public AllStatic {
static JVMCIRuntime* compiler_runtime(JavaThread* thread, bool create=true);

// Appends an event to the JVMCI event log if JVMCIEventLogLevel >= `level`
static void vlog(int level, const char* format, va_list ap) ATTRIBUTE_PRINTF(2, 0);
ATTRIBUTE_PRINTF(2, 0) static void vlog(int level, const char* format, va_list ap);

// Traces an event to tty if JVMCITraceLevel >= `level`
static void vtrace(int level, const char* format, va_list ap) ATTRIBUTE_PRINTF(2, 0);
ATTRIBUTE_PRINTF(2, 0) static void vtrace(int level, const char* format, va_list ap);

public:
// Log/trace a JVMCI event
static void event(int level, const char* format, ...) ATTRIBUTE_PRINTF(2, 3);
static void event1(const char* format, ...) ATTRIBUTE_PRINTF(1, 2);
static void event2(const char* format, ...) ATTRIBUTE_PRINTF(1, 2);
static void event3(const char* format, ...) ATTRIBUTE_PRINTF(1, 2);
static void event4(const char* format, ...) ATTRIBUTE_PRINTF(1, 2);
ATTRIBUTE_PRINTF(2, 3) static void event(int level, const char* format, ...);
ATTRIBUTE_PRINTF(1, 2) static void event1(const char* format, ...);
ATTRIBUTE_PRINTF(1, 2) static void event2(const char* format, ...);
ATTRIBUTE_PRINTF(1, 2) static void event3(const char* format, ...);
ATTRIBUTE_PRINTF(1, 2) static void event4(const char* format, ...);
};

// JVMCI event macros.
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/jvmci/jvmciEnv.hpp
Expand Up @@ -344,7 +344,7 @@ class JVMCIEnv : public ResourceObj {

#undef DO_THROW

void fthrow_error(const char* file, int line, const char* format, ...) ATTRIBUTE_PRINTF(4, 5);
ATTRIBUTE_PRINTF(4, 5) void fthrow_error(const char* file, int line, const char* format, ...);

// Given an instance of HotSpotInstalledCode return the corresponding CodeBlob*.
CodeBlob* get_code_blob(JVMCIObject code);
Expand Down
5 changes: 3 additions & 2 deletions src/hotspot/share/logging/log.hpp
Expand Up @@ -153,7 +153,7 @@ class LogImpl {
vwrite(LogLevel::level, fmt, args); \
return *this; \
} \
LogImpl& name(const char* fmt, ...) ATTRIBUTE_PRINTF(2, 3) { \
ATTRIBUTE_PRINTF(2, 3) LogImpl& name(const char* fmt, ...) { \
va_list args; \
va_start(args, fmt); \
vwrite(LogLevel::level, fmt, args); \
Expand Down Expand Up @@ -189,7 +189,8 @@ class LogTargetImpl {
PRODUCT_ONLY(return false);
}

static void print(const char* fmt, ...) ATTRIBUTE_PRINTF(1, 2) {
ATTRIBUTE_PRINTF(1, 2)
static void print(const char* fmt, ...) {
va_list args;
va_start(args, fmt);
LogTagSetMapping<T0, T1, T2, T3, T4, GuardTag>::tagset().vwrite(level, fmt, args);
Expand Down
5 changes: 3 additions & 2 deletions src/hotspot/share/logging/logHandle.hpp
Expand Up @@ -52,7 +52,7 @@ class LogHandle {
_tagset.vwrite(LogLevel::level, fmt, args); \
return *this; \
} \
LogHandle& name(const char* fmt, ...) ATTRIBUTE_PRINTF(2, 3) { \
ATTRIBUTE_PRINTF(2, 3) LogHandle& name(const char* fmt, ...) { \
va_list args; \
va_start(args, fmt); \
_tagset.vwrite(LogLevel::level, fmt, args); \
Expand Down Expand Up @@ -90,7 +90,8 @@ class LogTargetHandle {
return LogTargetHandle(LogTargetImpl<level, T0, T1, T2, T3, T4, GuardTag>());
}

void print(const char* fmt, ...) ATTRIBUTE_PRINTF(2, 3) {
ATTRIBUTE_PRINTF(2, 3)
void print(const char* fmt, ...) {
va_list args;
va_start(args, fmt);
if (is_enabled()) {
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/logging/logMessageBuffer.hpp
Expand Up @@ -121,8 +121,8 @@ class LogMessageBuffer : public StackObj {
virtual void vwrite(LogLevelType level, const char* fmt, va_list args);

#define LOG_LEVEL(level, name) \
LogMessageBuffer& v##name(const char* fmt, va_list args) ATTRIBUTE_PRINTF(2, 0); \
LogMessageBuffer& name(const char* fmt, ...) ATTRIBUTE_PRINTF(2, 3);
ATTRIBUTE_PRINTF(2, 0) LogMessageBuffer& v##name(const char* fmt, va_list args); \
ATTRIBUTE_PRINTF(2, 3) LogMessageBuffer& name(const char* fmt, ...);
LOG_LEVEL_LIST
#undef LOG_LEVEL
};
Expand Down
3 changes: 2 additions & 1 deletion src/hotspot/share/logging/logStream.hpp
Expand Up @@ -148,7 +148,8 @@ class LogMessageHandle {
return _lm.is_level(_level);
}

void print(const char* fmt, ...) ATTRIBUTE_PRINTF(2, 3) {
ATTRIBUTE_PRINTF(2, 3)
void print(const char* fmt, ...) {
va_list args;
va_start(args, fmt);
if (is_enabled()) {
Expand Down
9 changes: 6 additions & 3 deletions src/hotspot/share/oops/generateOopMap.hpp
Expand Up @@ -407,9 +407,12 @@ class GenerateOopMap {
int copy_cts (CellTypeState *dst, CellTypeState *src);

// Error handling
void error_work (const char *format, va_list ap) ATTRIBUTE_PRINTF(2, 0);
void report_error (const char *format, ...) ATTRIBUTE_PRINTF(2, 3);
void verify_error (const char *format, ...) ATTRIBUTE_PRINTF(2, 3);
ATTRIBUTE_PRINTF(2, 0)
void error_work (const char *format, va_list ap);
ATTRIBUTE_PRINTF(2, 3)
void report_error (const char *format, ...);
ATTRIBUTE_PRINTF(2, 3)
void verify_error (const char *format, ...);
bool got_error() { return _got_error; }

// Create result set
Expand Down
8 changes: 8 additions & 0 deletions src/hotspot/share/runtime/abstract_vm_version.cpp
Expand Up @@ -80,13 +80,21 @@ VirtualizationType Abstract_VM_Version::_detected_virtualization = NoDetectedVir

#define VM_RELEASE HOTSPOT_VERSION_STRING

#define EMPTY(ARG) (0-ARG-1)==1 && (ARG+0)!=-2

// HOTSPOT_VERSION_STRING equals the JDK VERSION_STRING (unless overridden
// in a standalone build).
int Abstract_VM_Version::_vm_major_version = VERSION_FEATURE;
int Abstract_VM_Version::_vm_minor_version = VERSION_INTERIM;
int Abstract_VM_Version::_vm_security_version = VERSION_UPDATE;
int Abstract_VM_Version::_vm_patch_version = VERSION_PATCH;
#if EMPTY(VERSION_BUILD)
int Abstract_VM_Version::_vm_build_number = 0;
#else
int Abstract_VM_Version::_vm_build_number = VERSION_BUILD;
#endif

#undef EMPTY

#if defined(_LP64)
#define VMLP "64-Bit "
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/runtime/arguments.hpp
Expand Up @@ -43,7 +43,7 @@ class JVMFlag;
extern "C" {
typedef void (JNICALL *abort_hook_t)(void);
typedef void (JNICALL *exit_hook_t)(jint code);
typedef jint (JNICALL *vfprintf_hook_t)(FILE *fp, const char *format, va_list args) ATTRIBUTE_PRINTF(2, 0);
typedef jint (JNICALL *vfprintf_hook_t ATTRIBUTE_PRINTF(2, 0))(FILE *fp, const char *format, va_list args);
}

// Obsolete or deprecated -XX flag.
Expand Down