Skip to content

Commit c6721a0

Browse files
committedSep 17, 2024
8340009: Improve the output from assert_different_registers
Reviewed-by: aboldtch, dholmes, shade, mli
1 parent 7834662 commit c6721a0

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed
 

‎src/hotspot/share/asm/register.hpp

+7-3
Original file line numberDiff line numberDiff line change
@@ -276,19 +276,23 @@ inline constexpr bool different_registers(R first_register, Rx... more_registers
276276
}
277277

278278
template<typename R, typename... Rx>
279-
inline void assert_different_registers(R first_register, Rx... more_registers) {
279+
inline void assert_different_registers_impl(const char* file, int line, R first_register, Rx... more_registers) {
280280
#ifdef ASSERT
281281
if (!different_registers(first_register, more_registers...)) {
282282
const R regs[] = { first_register, more_registers... };
283283
// Find a duplicate entry.
284284
for (size_t i = 0; i < ARRAY_SIZE(regs) - 1; ++i) {
285285
for (size_t j = i + 1; j < ARRAY_SIZE(regs); ++j) {
286-
assert(!regs[i]->is_valid() || regs[i] != regs[j],
287-
"Multiple uses of register: %s", regs[i]->name());
286+
if (regs[i]->is_valid()) {
287+
assert_with_file_and_line(regs[i] != regs[j], file, line, "regs[%zu] and regs[%zu] are both: %s",
288+
i, j, regs[i]->name());
289+
}
288290
}
289291
}
290292
}
291293
#endif
292294
}
293295

296+
#define assert_different_registers(...) assert_different_registers_impl(__FILE__, __LINE__, __VA_ARGS__)
297+
294298
#endif // SHARE_ASM_REGISTER_HPP

‎src/hotspot/share/utilities/debug.hpp

+9-6
Original file line numberDiff line numberDiff line change
@@ -139,22 +139,25 @@ class DebuggingContext {
139139

140140
// assertions
141141
#ifndef ASSERT
142+
#define vmassert_with_file_and_line(p, file, line, ...)
142143
#define vmassert(p, ...)
143144
#else
144145
// Note: message says "assert" rather than "vmassert" for backward
145146
// compatibility with tools that parse/match the message text.
146147
// Note: The signature is vmassert(p, format, ...), but the solaris
147148
// compiler can't handle an empty ellipsis in a macro without a warning.
148-
#define vmassert(p, ...) \
149-
do { \
150-
if (! VMASSERT_CHECK_PASSED(p)) { \
151-
TOUCH_ASSERT_POISON; \
152-
report_vm_error(__FILE__, __LINE__, "assert(" #p ") failed", __VA_ARGS__); \
153-
} \
149+
#define vmassert_with_file_and_line(p, file, line, ...) \
150+
do { \
151+
if (! VMASSERT_CHECK_PASSED(p)) { \
152+
TOUCH_ASSERT_POISON; \
153+
report_vm_error(file, line, "assert(" #p ") failed", __VA_ARGS__); \
154+
} \
154155
} while (0)
156+
#define vmassert(p, ...) vmassert_with_file_and_line(p, __FILE__, __LINE__, __VA_ARGS__)
155157
#endif
156158

157159
// For backward compatibility.
160+
#define assert_with_file_and_line(p, file, line, ...) vmassert_with_file_and_line(p, file, line, __VA_ARGS__)
158161
#define assert(p, ...) vmassert(p, __VA_ARGS__)
159162

160163
#define precond(p) assert(p, "precond")

0 commit comments

Comments
 (0)
Please sign in to comment.