264 bool is_executing_unit_tests() { 265 return ExecutingUnitTests; 266 } 267 268 void report_assert_msg(const char* msg, ...) { 269 va_list ap; 270 va_start(ap, msg); 271 272 fprintf(stderr, "assert failed: %s\n", err_msg(FormatBufferDummy(), msg, ap).buffer()); 273 274 va_end(ap); 275 } 276 #endif // ASSERT 277 278 void report_untested(const char* file, int line, const char* message) { 279 #ifndef PRODUCT 280 warning("Untested: %s in %s: %d\n", message, file, line); 281 #endif // !PRODUCT 282 } 283 284 void report_out_of_shared_space(SharedSpaceType shared_space) { 285 if (shared_space == SharedOptional) { 286 // The estimated shared_optional_space size is large enough 287 // for all class bytes. It should not run out of space. 288 ShouldNotReachHere(); 289 } 290 291 static const char* name[] = { 292 "shared read only space", 293 "shared read write space", 294 "shared miscellaneous data space", 295 "shared miscellaneous code space" 296 }; 297 static const char* flag[] = { 298 "SharedReadOnlySize", 299 "SharedReadWriteSize", 300 "SharedMiscDataSize", 301 "SharedMiscCodeSize" 302 }; 303 304 warning("\nThe %s is not large enough\n" 305 "to preload requested classes. Use -XX:%s=<size>\n" 306 "to increase the initial size of %s.\n", 307 name[shared_space], flag[shared_space], name[shared_space]); 308 exit(2); 309 } 310 311 312 void report_insufficient_metaspace(size_t required_size) { 313 warning("\nThe MaxMetaspaceSize of " SIZE_FORMAT " bytes is not large enough.\n" 314 "Either don't specify the -XX:MaxMetaspaceSize=<size>\n" 315 "or increase the size to at least " SIZE_FORMAT ".\n", 316 MaxMetaspaceSize, required_size); 317 exit(2); 318 } 319 320 void report_java_out_of_memory(const char* message) { 321 static jint out_of_memory_reported = 0; 322 323 // A number of threads may attempt to report OutOfMemoryError at around the 324 // same time. To avoid dumping the heap or executing the data collection 325 // commands multiple times we just do it once when the first threads reports 326 // the error. 327 if (Atomic::cmpxchg(1, &out_of_memory_reported, 0) == 0) { 328 // create heap dump before OnOutOfMemoryError commands are executed 329 if (HeapDumpOnOutOfMemoryError) { 330 tty->print_cr("java.lang.OutOfMemoryError: %s", message); 331 HeapDumper::dump_heap_from_oome(); 332 } 333 334 if (OnOutOfMemoryError && OnOutOfMemoryError[0]) { 335 VMError::report_java_out_of_memory(message); 336 } 337 338 if (CrashOnOutOfMemoryError) { 339 tty->print_cr("Aborting due to java.lang.OutOfMemoryError: %s", message); | 264 bool is_executing_unit_tests() { 265 return ExecutingUnitTests; 266 } 267 268 void report_assert_msg(const char* msg, ...) { 269 va_list ap; 270 va_start(ap, msg); 271 272 fprintf(stderr, "assert failed: %s\n", err_msg(FormatBufferDummy(), msg, ap).buffer()); 273 274 va_end(ap); 275 } 276 #endif // ASSERT 277 278 void report_untested(const char* file, int line, const char* message) { 279 #ifndef PRODUCT 280 warning("Untested: %s in %s: %d\n", message, file, line); 281 #endif // !PRODUCT 282 } 283 284 void report_java_out_of_memory(const char* message) { 285 static jint out_of_memory_reported = 0; 286 287 // A number of threads may attempt to report OutOfMemoryError at around the 288 // same time. To avoid dumping the heap or executing the data collection 289 // commands multiple times we just do it once when the first threads reports 290 // the error. 291 if (Atomic::cmpxchg(1, &out_of_memory_reported, 0) == 0) { 292 // create heap dump before OnOutOfMemoryError commands are executed 293 if (HeapDumpOnOutOfMemoryError) { 294 tty->print_cr("java.lang.OutOfMemoryError: %s", message); 295 HeapDumper::dump_heap_from_oome(); 296 } 297 298 if (OnOutOfMemoryError && OnOutOfMemoryError[0]) { 299 VMError::report_java_out_of_memory(message); 300 } 301 302 if (CrashOnOutOfMemoryError) { 303 tty->print_cr("Aborting due to java.lang.OutOfMemoryError: %s", message); |