@@ -444,7 +444,7 @@ void VMError::report(outputStream* st, bool _verbose) {
444444 " Runtime Environment to continue." );
445445 }
446446
447- #ifndef PRODUCT
447+ #ifdef ASSERT
448448 // Error handler self tests
449449
450450 // test secondary error handling. Test it twice, to test that resetting
@@ -503,7 +503,7 @@ void VMError::report(outputStream* st, bool _verbose) {
503503 st->print_cr (" not possible; skipped." );
504504 }
505505 }
506- #endif // PRODUCT
506+ #endif // ASSERT
507507
508508 STEP (" printing type of error" )
509509
@@ -1737,7 +1737,7 @@ bool VMError::check_timeout() {
17371737
17381738}
17391739
1740- #ifndef PRODUCT
1740+ #ifdef ASSERT
17411741typedef void (*voidfun_t )();
17421742
17431743// Crash with an authentic sigfpe
@@ -1765,47 +1765,13 @@ static void crash_with_segfault() {
17651765
17661766} // end: crash_with_segfault
17671767
1768- void VMError::test_error_handler () {
1769- controlled_crash (ErrorHandlerTest);
1770- }
1771-
17721768// crash in a controlled way:
1773- // how can be one of:
1774- // 1,2 - asserts
1775- // 3,4 - guarantee
1776- // 5-7 - fatal
1777- // 8 - vm_exit_out_of_memory
1778- // 9 - ShouldNotCallThis
1779- // 10 - ShouldNotReachHere
1780- // 11 - Unimplemented
1781- // 12,13 - (not guaranteed) crashes
1769+ // 1 - assert
1770+ // 2 - guarantee
17821771// 14 - SIGSEGV
17831772// 15 - SIGFPE
17841773void VMError::controlled_crash (int how) {
1785- if (how == 0 ) return ;
1786-
1787- // If asserts are disabled, use the corresponding guarantee instead.
1788- NOT_DEBUG (if (how <= 2 ) how += 2 );
1789-
1790- const char * const str = " hello" ;
1791- const size_t num = (size_t )os::vm_page_size ();
1792-
1793- const char * const eol = os::line_separator ();
1794- const char * const msg = " this message should be truncated during formatting" ;
1795- char * const dataPtr = NULL ; // bad data pointer
1796- const void (*funcPtr)(void ); // bad function pointer
17971774
1798- #if defined(PPC64) && !defined(ABI_ELFv2)
1799- struct FunctionDescriptor functionDescriptor;
1800-
1801- functionDescriptor.set_entry ((address) 0xF );
1802- funcPtr = (const void (*)()) &functionDescriptor;
1803- #else
1804- funcPtr = (const void (*)()) 0xF ;
1805- #endif
1806-
1807- // Keep this in sync with test/hotspot/jtreg/runtime/ErrorHandling/ErrorHandler.java
1808- // which tests cases 1 thru 13.
18091775 // Case 14 is tested by test/hotspot/jtreg/runtime/ErrorHandling/SafeFetchInErrorHandlingTest.java.
18101776 // Case 15 is tested by test/hotspot/jtreg/runtime/ErrorHandling/SecondaryErrorTest.java.
18111777 // Case 16 is tested by test/hotspot/jtreg/runtime/ErrorHandling/ThreadsListHandleInErrorHandlingTest.java.
@@ -1821,30 +1787,10 @@ void VMError::controlled_crash(int how) {
18211787 }
18221788
18231789 switch (how) {
1824- case 1 : vmassert (str == NULL , " expected null" ); break ;
1825- case 2 : vmassert (num == 1023 && *str == ' X' ,
1826- " num=" SIZE_FORMAT " str=\" %s\" " , num, str); break ;
1827- case 3 : guarantee (str == NULL , " expected null" ); break ;
1828- case 4 : guarantee (num == 1023 && *str == ' X' ,
1829- " num=" SIZE_FORMAT " str=\" %s\" " , num, str); break ;
1830- case 5 : fatal (" expected null" ); break ;
1831- case 6 : fatal (" num=" SIZE_FORMAT " str=\" %s\" " , num, str); break ;
1832- case 7 : fatal (" %s%s# %s%s# %s%s# %s%s# %s%s# "
1833- " %s%s# %s%s# %s%s# %s%s# %s%s# "
1834- " %s%s# %s%s# %s%s# %s%s# %s" ,
1835- msg, eol, msg, eol, msg, eol, msg, eol, msg, eol,
1836- msg, eol, msg, eol, msg, eol, msg, eol, msg, eol,
1837- msg, eol, msg, eol, msg, eol, msg, eol, msg); break ;
1838- case 8 : vm_exit_out_of_memory (num, OOM_MALLOC_ERROR, " ChunkPool::allocate" ); break ;
1839- case 9 : ShouldNotCallThis (); break ;
1840- case 10 : ShouldNotReachHere (); break ;
1841- case 11 : Unimplemented (); break ;
1842- // There's no guarantee the bad data pointer will crash us
1843- // so "break" out to the ShouldNotReachHere().
1844- case 12 : *dataPtr = ' \0 ' ; break ;
1845- // There's no guarantee the bad function pointer will crash us
1846- // so "break" out to the ShouldNotReachHere().
1847- case 13 : (*funcPtr)(); break ;
1790+ case 1 : assert (how == 0 , " test assert" ); break ;
1791+ case 2 : guarantee (how == 0 , " test guarantee" ); break ;
1792+
1793+ // The other cases are unused.
18481794 case 14 : crash_with_segfault (); break ;
18491795 case 15 : crash_with_sigfpe (); break ;
18501796 case 16 : {
@@ -1858,19 +1804,11 @@ void VMError::controlled_crash(int how) {
18581804 fatal (" Force crash with a nested ThreadsListHandle." );
18591805 }
18601806 }
1861- case 18 : {
1862- // Check for assert when allocating from resource area without a
1863- // ResourceMark. There must not be a ResourceMark on the
1864- // current stack when invoking this test case.
1865- ResourceArea* area = Thread::current ()->resource_area ();
1866- assert (area->nesting () == 0 , " unexpected ResourceMark" );
1867- area->allocate_bytes (100 );
1868- break ;
1869- }
1870-
1871- default : tty->print_cr (" ERROR: %d: unexpected test_num value." , how);
1807+ default :
1808+ // If another number is given, give a generic crash.
1809+ fatal (" Crashing with number %d" , how);
18721810 }
1873- tty->print_cr (" VMError:: controlled_crash: survived intentional crash. Did you suppress the assert?" );
1811+ tty->print_cr (" controlled_crash: survived intentional crash. Did you suppress the assert?" );
18741812 ShouldNotReachHere ();
18751813}
1876- #endif // !PRODUCT
1814+ #endif // !ASSERT
0 commit comments