8068396: Rename assert() to vmassert()

Macro renaming, with temporary old name synonyms for compatibilty

Reviewed-by: ehelin, dholmes, coleenp
This commit is contained in:
Kim Barrett 2015-01-13 14:30:53 -05:00
parent 9000f8c3c7
commit 77f22c1241
5 changed files with 28 additions and 67 deletions
hotspot/src/share/vm

@ -2951,10 +2951,6 @@ class CommandLineFlags {
develop(intx, MallocCatchPtr, -1, \
"Hit breakpoint when mallocing/freeing this pointer") \
\
notproduct(intx, AssertRepeat, 1, \
"number of times to evaluate expression in assert " \
"(to estimate overhead); only works with -DUSE_REPEATED_ASSERTS") \
\
notproduct(ccstrlist, SuppressErrorAt, "", \
"List of assertions (file:line) to muzzle") \
\

@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright 2008, 2009, 2010 Red Hat, Inc.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -87,30 +87,7 @@
#undef assert
#endif
// from hotspot/src/share/vm/utilities/debug.hpp
#ifdef ASSERT
#ifndef USE_REPEATED_ASSERTS
#define assert(p, msg) \
do { \
if (!(p)) { \
report_vm_error(__FILE__, __LINE__, "assert(" #p ") failed", msg); \
BREAKPOINT; \
} \
} while (0)
#else // #ifndef USE_REPEATED_ASSERTS
#define assert(p, msg)
do { \
for (int __i = 0; __i < AssertRepeat; __i++) { \
if (!(p)) { \
report_vm_error(__FILE__, __LINE__, "assert(" #p ") failed", msg); \
BREAKPOINT; \
} \
} \
} while (0)
#endif // #ifndef USE_REPEATED_ASSERTS
#else
#define assert(p, msg)
#endif
#define assert(p, msg) vmassert(p, msg)
#ifdef DEBUG
#undef DEBUG

@ -334,9 +334,9 @@ void test_error_handler() {
// Keep this in sync with test/runtime/6888954/vmerrors.sh.
switch (n) {
case 1: assert(str == NULL, "expected null");
case 2: assert(num == 1023 && *str == 'X',
err_msg("num=" SIZE_FORMAT " str=\"%s\"", num, str));
case 1: vmassert(str == NULL, "expected null");
case 2: vmassert(num == 1023 && *str == 'X',
err_msg("num=" SIZE_FORMAT " str=\"%s\"", num, str));
case 3: guarantee(str == NULL, "expected null");
case 4: guarantee(num == 1023 && *str == 'X',
err_msg("num=" SIZE_FORMAT " str=\"%s\"", num, str));

@ -105,58 +105,42 @@ void FormatBuffer<bufsz>::append(const char* format, ...) {
va_end(argp);
}
// Used to format messages for assert(), guarantee(), fatal(), etc.
// Used to format messages for vmassert(), guarantee(), fatal(), etc.
typedef FormatBuffer<> err_msg;
typedef FormatBufferResource err_msg_res;
// assertions
#ifdef ASSERT
#ifndef USE_REPEATED_ASSERTS
#define assert(p, msg) \
#ifndef ASSERT
#define vmassert(p, msg)
#else
// Note: message says "assert" rather than "vmassert" for backward
// compatibility with tools that parse/match the message text.
#define vmassert(p, msg) \
do { \
if (!(p)) { \
report_vm_error(__FILE__, __LINE__, "assert(" #p ") failed", msg); \
BREAKPOINT; \
} \
} while (0)
#else // #ifndef USE_REPEATED_ASSERTS
#define assert(p, msg)
do { \
for (int __i = 0; __i < AssertRepeat; __i++) { \
if (!(p)) { \
report_vm_error(__FILE__, __LINE__, "assert(" #p ") failed", msg); \
BREAKPOINT; \
} \
} \
} while (0)
#endif // #ifndef USE_REPEATED_ASSERTS
#endif
// This version of assert is for use with checking return status from
// For backward compatibility.
#define assert(p, msg) vmassert(p, msg)
// This version of vmassert is for use with checking return status from
// library calls that return actual error values eg. EINVAL,
// ENOMEM etc, rather than returning -1 and setting errno.
// When the status is not what is expected it is very useful to know
// what status was actually returned, so we pass the status variable as
// an extra arg and use strerror to convert it to a meaningful string
// like "Invalid argument", "out of memory" etc
#define assert_status(p, status, msg) \
do { \
if (!(p)) { \
report_vm_error(__FILE__, __LINE__, "assert(" #p ") failed", \
err_msg("error %s(%d) %s", strerror(status), \
status, msg)); \
BREAKPOINT; \
} \
} while (0)
#define vmassert_status(p, status, msg) \
vmassert(p, err_msg("error %s(%d), %s", strerror(status), status, msg))
// Do not assert this condition if there's already another error reported.
#define assert_if_no_error(cond,msg) assert((cond) || is_error_reported(), msg)
#else // #ifdef ASSERT
#define assert(p,msg)
#define assert_status(p,status,msg)
#define assert_if_no_error(cond,msg)
#endif // #ifdef ASSERT
// For backward compatibility.
#define assert_status(p, status, msg) vmassert_status(p, status, msg)
// guarantee is like assert except it's always executed -- use it for
// guarantee is like vmassert except it's always executed -- use it for
// cheap tests that catch errors that would otherwise be hard to find.
// guarantee is also used for Verify options.
#define guarantee(p, msg) \
@ -260,7 +244,7 @@ void report_java_out_of_memory(const char* message);
bool is_error_reported();
void set_error_reported();
/* Test assert(), fatal(), guarantee(), etc. */
/* Test vmassert(), fatal(), guarantee(), etc. */
NOT_PRODUCT(void test_error_handler();)
void pd_ps(frame f);

@ -1,5 +1,5 @@
/*
* Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -33,6 +33,10 @@
#include "runtime/vmThread.hpp"
#include "utilities/xmlstream.hpp"
// Do not assert this condition if there's already another error reported.
#define assert_if_no_error(cond, msg) \
vmassert((cond) || is_error_reported(), msg)
void xmlStream::initialize(outputStream* out) {
_out = out;
_last_flush = 0;