< prev index next >

src/hotspot/share/gc/shared/memAllocator.cpp

Print this page




 103     *obj_ptr = NULL;
 104   }
 105 
 106   ~PreserveObj() {
 107     *_obj_ptr = _handle();
 108   }
 109 
 110   oop operator()() const {
 111     return _handle();
 112   }
 113 };
 114 
 115 bool MemAllocator::Allocation::check_out_of_memory() {
 116   Thread* THREAD = _thread;
 117   assert(!HAS_PENDING_EXCEPTION, "Unexpected exception, will result in uninitialized storage");
 118 
 119   if (obj() != NULL) {
 120     return false;
 121   }
 122 
 123   if (!_overhead_limit_exceeded) {

 124     // -XX:+HeapDumpOnOutOfMemoryError and -XX:OnOutOfMemoryError support
 125     report_java_out_of_memory("Java heap space");
 126 
 127     if (JvmtiExport::should_post_resource_exhausted()) {
 128       JvmtiExport::post_resource_exhausted(
 129         JVMTI_RESOURCE_EXHAUSTED_OOM_ERROR | JVMTI_RESOURCE_EXHAUSTED_JAVA_HEAP,
 130         "Java heap space");
 131     }
 132     THROW_OOP_(Universe::out_of_memory_error_java_heap(), true);



 133   } else {
 134     // -XX:+HeapDumpOnOutOfMemoryError and -XX:OnOutOfMemoryError support
 135     report_java_out_of_memory("GC overhead limit exceeded");
 136 
 137     if (JvmtiExport::should_post_resource_exhausted()) {
 138       JvmtiExport::post_resource_exhausted(
 139         JVMTI_RESOURCE_EXHAUSTED_OOM_ERROR | JVMTI_RESOURCE_EXHAUSTED_JAVA_HEAP,
 140         "GC overhead limit exceeded");
 141     }
 142 
 143     THROW_OOP_(Universe::out_of_memory_error_gc_overhead_limit(), true);
 144   }
 145 }
 146 
 147 void MemAllocator::Allocation::verify_before() {
 148   // Clear unhandled oops for memory allocation.  Memory allocation might
 149   // not take out a lock if from tlab, so clear here.
 150   Thread* THREAD = _thread;
 151   CHECK_UNHANDLED_OOPS_ONLY(THREAD->clear_unhandled_oops();)
 152   assert(!HAS_PENDING_EXCEPTION, "Should not allocate with exception pending");
 153   debug_only(check_for_valid_allocation_state());
 154   assert(!Universe::heap()->is_gc_active(), "Allocation during gc not allowed");
 155 }
 156 
 157 void MemAllocator::Allocation::verify_after() {
 158   NOT_PRODUCT(check_for_bad_heap_word_value();)
 159 }
 160 
 161 void MemAllocator::Allocation::check_for_bad_heap_word_value() const {
 162   MemRegion obj_range = _allocator.obj_memory_range(obj());
 163   HeapWord* addr = obj_range.start();




 103     *obj_ptr = NULL;
 104   }
 105 
 106   ~PreserveObj() {
 107     *_obj_ptr = _handle();
 108   }
 109 
 110   oop operator()() const {
 111     return _handle();
 112   }
 113 };
 114 
 115 bool MemAllocator::Allocation::check_out_of_memory() {
 116   Thread* THREAD = _thread;
 117   assert(!HAS_PENDING_EXCEPTION, "Unexpected exception, will result in uninitialized storage");
 118 
 119   if (obj() != NULL) {
 120     return false;
 121   }
 122 
 123   const char* message = _overhead_limit_exceeded ? "GC overhead limit exceeded" : "Java heap space";
 124   if (!THREAD->in_retryable_allocation()) {
 125     // -XX:+HeapDumpOnOutOfMemoryError and -XX:OnOutOfMemoryError support
 126     report_java_out_of_memory(message);
 127 
 128     if (JvmtiExport::should_post_resource_exhausted()) {
 129       JvmtiExport::post_resource_exhausted(
 130         JVMTI_RESOURCE_EXHAUSTED_OOM_ERROR | JVMTI_RESOURCE_EXHAUSTED_JAVA_HEAP,
 131         message);
 132     }
 133     oop exception = _overhead_limit_exceeded ?
 134         Universe::out_of_memory_error_gc_overhead_limit() :
 135         Universe::out_of_memory_error_java_heap();
 136     THROW_OOP_(exception, true);
 137   } else {
 138     THROW_OOP_(Universe::out_of_memory_error_retry(), true);









 139   }
 140 }
 141 
 142 void MemAllocator::Allocation::verify_before() {
 143   // Clear unhandled oops for memory allocation.  Memory allocation might
 144   // not take out a lock if from tlab, so clear here.
 145   Thread* THREAD = _thread;
 146   CHECK_UNHANDLED_OOPS_ONLY(THREAD->clear_unhandled_oops();)
 147   assert(!HAS_PENDING_EXCEPTION, "Should not allocate with exception pending");
 148   debug_only(check_for_valid_allocation_state());
 149   assert(!Universe::heap()->is_gc_active(), "Allocation during gc not allowed");
 150 }
 151 
 152 void MemAllocator::Allocation::verify_after() {
 153   NOT_PRODUCT(check_for_bad_heap_word_value();)
 154 }
 155 
 156 void MemAllocator::Allocation::check_for_bad_heap_word_value() const {
 157   MemRegion obj_range = _allocator.obj_memory_range(obj());
 158   HeapWord* addr = obj_range.start();


< prev index next >