< prev index next >

src/hotspot/share/memory/universe.cpp

Print this page




 563   return ((throwable() != Universe::_out_of_memory_error_java_heap) &&
 564           (throwable() != Universe::_out_of_memory_error_metaspace)  &&
 565           (throwable() != Universe::_out_of_memory_error_class_metaspace)  &&
 566           (throwable() != Universe::_out_of_memory_error_array_size) &&
 567           (throwable() != Universe::_out_of_memory_error_gc_overhead_limit) &&
 568           (throwable() != Universe::_out_of_memory_error_realloc_objects) &&
 569           (throwable() != Universe::_out_of_memory_error_retry));
 570 }
 571 
 572 
 573 oop Universe::gen_out_of_memory_error(oop default_err) {
 574   // generate an out of memory error:
 575   // - if there is a preallocated error and stack traces are available
 576   //   (j.l.Throwable is initialized), then return the preallocated
 577   //   error with a filled in stack trace, and with the message
 578   //   provided by the default error.
 579   // - otherwise, return the default error, without a stack trace.
 580   int next;
 581   if ((_preallocated_out_of_memory_error_avail_count > 0) &&
 582       SystemDictionary::Throwable_klass()->is_initialized()) {
 583     next = (int)Atomic::add(-1, &_preallocated_out_of_memory_error_avail_count);
 584     assert(next < (int)PreallocatedOutOfMemoryErrorCount, "avail count is corrupt");
 585   } else {
 586     next = -1;
 587   }
 588   if (next < 0) {
 589     // all preallocated errors have been used.
 590     // return default
 591     return default_err;
 592   } else {
 593     Thread* THREAD = Thread::current();
 594     Handle default_err_h(THREAD, default_err);
 595     // get the error object at the slot and set set it to NULL so that the
 596     // array isn't keeping it alive anymore.
 597     Handle exc(THREAD, preallocated_out_of_memory_errors()->obj_at(next));
 598     assert(exc() != NULL, "slot has been used already");
 599     preallocated_out_of_memory_errors()->obj_at_put(next, NULL);
 600 
 601     // use the message from the default error
 602     oop msg = java_lang_Throwable::message(default_err_h());
 603     assert(msg != NULL, "no message");




 563   return ((throwable() != Universe::_out_of_memory_error_java_heap) &&
 564           (throwable() != Universe::_out_of_memory_error_metaspace)  &&
 565           (throwable() != Universe::_out_of_memory_error_class_metaspace)  &&
 566           (throwable() != Universe::_out_of_memory_error_array_size) &&
 567           (throwable() != Universe::_out_of_memory_error_gc_overhead_limit) &&
 568           (throwable() != Universe::_out_of_memory_error_realloc_objects) &&
 569           (throwable() != Universe::_out_of_memory_error_retry));
 570 }
 571 
 572 
 573 oop Universe::gen_out_of_memory_error(oop default_err) {
 574   // generate an out of memory error:
 575   // - if there is a preallocated error and stack traces are available
 576   //   (j.l.Throwable is initialized), then return the preallocated
 577   //   error with a filled in stack trace, and with the message
 578   //   provided by the default error.
 579   // - otherwise, return the default error, without a stack trace.
 580   int next;
 581   if ((_preallocated_out_of_memory_error_avail_count > 0) &&
 582       SystemDictionary::Throwable_klass()->is_initialized()) {
 583     next = (int)Atomic::add(&_preallocated_out_of_memory_error_avail_count, -1);
 584     assert(next < (int)PreallocatedOutOfMemoryErrorCount, "avail count is corrupt");
 585   } else {
 586     next = -1;
 587   }
 588   if (next < 0) {
 589     // all preallocated errors have been used.
 590     // return default
 591     return default_err;
 592   } else {
 593     Thread* THREAD = Thread::current();
 594     Handle default_err_h(THREAD, default_err);
 595     // get the error object at the slot and set set it to NULL so that the
 596     // array isn't keeping it alive anymore.
 597     Handle exc(THREAD, preallocated_out_of_memory_errors()->obj_at(next));
 598     assert(exc() != NULL, "slot has been used already");
 599     preallocated_out_of_memory_errors()->obj_at_put(next, NULL);
 600 
 601     // use the message from the default error
 602     oop msg = java_lang_Throwable::message(default_err_h());
 603     assert(msg != NULL, "no message");


< prev index next >