39 #ifdef TARGET_OS_FAMILY_linux 40 # include "thread_linux.inline.hpp" 41 #endif 42 #ifdef TARGET_OS_FAMILY_solaris 43 # include "thread_solaris.inline.hpp" 44 #endif 45 #ifdef TARGET_OS_FAMILY_windows 46 # include "thread_windows.inline.hpp" 47 #endif 48 #ifdef TARGET_OS_FAMILY_bsd 49 # include "thread_bsd.inline.hpp" 50 #endif 51 52 53 #ifdef ASSERT 54 int CollectedHeap::_fire_out_of_memory_count = 0; 55 #endif 56 57 size_t CollectedHeap::_filler_array_max_size = 0; 58 59 template <> 60 void EventLogBase<GCMessage>::print(outputStream* st, GCMessage& m) { 61 st->print_cr("GC heap %s", m.is_before ? "before" : "after"); 62 st->print_raw(m); 63 } 64 65 void GCHeapLog::log_heap(bool before) { 66 if (!should_log()) { 67 return; 68 } 69 70 double timestamp = fetch_timestamp(); 71 MutexLockerEx ml(&_mutex, Mutex::_no_safepoint_check_flag); 72 int index = compute_log_index(); 73 _records[index].thread = NULL; // Its the GC thread so it's not that interesting. 74 _records[index].timestamp = timestamp; 75 _records[index].data.is_before = before; 76 stringStream st(_records[index].data.buffer(), _records[index].data.size()); 77 if (before) { 78 Universe::print_heap_before_gc(&st, true); 163 _defer_initial_card_mark = false; // strengthened by subclass in pre_initialize() below. 164 // Create the ring log 165 if (LogEvents) { 166 _gc_heap_log = new GCHeapLog(); 167 } else { 168 _gc_heap_log = NULL; 169 } 170 } 171 172 void CollectedHeap::pre_initialize() { 173 // Used for ReduceInitialCardMarks (when COMPILER2 is used); 174 // otherwise remains unused. 175 #ifdef COMPILER2 176 _defer_initial_card_mark = ReduceInitialCardMarks && can_elide_tlab_store_barriers() 177 && (DeferInitialCardMark || card_mark_must_follow_store()); 178 #else 179 assert(_defer_initial_card_mark == false, "Who would set it?"); 180 #endif 181 } 182 183 #ifndef PRODUCT 184 void CollectedHeap::check_for_bad_heap_word_value(HeapWord* addr, size_t size) { 185 if (CheckMemoryInitialization && ZapUnusedHeapArea) { 186 for (size_t slot = 0; slot < size; slot += 1) { 187 assert((*(intptr_t*) (addr + slot)) != ((intptr_t) badHeapWordVal), 188 "Found badHeapWordValue in post-allocation check"); 189 } 190 } 191 } 192 193 void CollectedHeap::check_for_non_bad_heap_word_value(HeapWord* addr, size_t size) { 194 if (CheckMemoryInitialization && ZapUnusedHeapArea) { 195 for (size_t slot = 0; slot < size; slot += 1) { 196 assert((*(intptr_t*) (addr + slot)) == ((intptr_t) badHeapWordVal), 197 "Found non badHeapWordValue in pre-allocation check"); 198 } 199 } 200 } 201 #endif // PRODUCT 202 | 39 #ifdef TARGET_OS_FAMILY_linux 40 # include "thread_linux.inline.hpp" 41 #endif 42 #ifdef TARGET_OS_FAMILY_solaris 43 # include "thread_solaris.inline.hpp" 44 #endif 45 #ifdef TARGET_OS_FAMILY_windows 46 # include "thread_windows.inline.hpp" 47 #endif 48 #ifdef TARGET_OS_FAMILY_bsd 49 # include "thread_bsd.inline.hpp" 50 #endif 51 52 53 #ifdef ASSERT 54 int CollectedHeap::_fire_out_of_memory_count = 0; 55 #endif 56 57 size_t CollectedHeap::_filler_array_max_size = 0; 58 59 const char* CollectedHeap::OverflowMessage 60 = "The size of the object heap + perm gen exceeds the maximum representable size"; 61 62 template <> 63 void EventLogBase<GCMessage>::print(outputStream* st, GCMessage& m) { 64 st->print_cr("GC heap %s", m.is_before ? "before" : "after"); 65 st->print_raw(m); 66 } 67 68 void GCHeapLog::log_heap(bool before) { 69 if (!should_log()) { 70 return; 71 } 72 73 double timestamp = fetch_timestamp(); 74 MutexLockerEx ml(&_mutex, Mutex::_no_safepoint_check_flag); 75 int index = compute_log_index(); 76 _records[index].thread = NULL; // Its the GC thread so it's not that interesting. 77 _records[index].timestamp = timestamp; 78 _records[index].data.is_before = before; 79 stringStream st(_records[index].data.buffer(), _records[index].data.size()); 80 if (before) { 81 Universe::print_heap_before_gc(&st, true); 166 _defer_initial_card_mark = false; // strengthened by subclass in pre_initialize() below. 167 // Create the ring log 168 if (LogEvents) { 169 _gc_heap_log = new GCHeapLog(); 170 } else { 171 _gc_heap_log = NULL; 172 } 173 } 174 175 void CollectedHeap::pre_initialize() { 176 // Used for ReduceInitialCardMarks (when COMPILER2 is used); 177 // otherwise remains unused. 178 #ifdef COMPILER2 179 _defer_initial_card_mark = ReduceInitialCardMarks && can_elide_tlab_store_barriers() 180 && (DeferInitialCardMark || card_mark_must_follow_store()); 181 #else 182 assert(_defer_initial_card_mark == false, "Who would set it?"); 183 #endif 184 } 185 186 size_t CollectedHeap::add_and_check_overflow(size_t total, size_t size) { 187 assert(size >= 0, "must be"); 188 size_t result = total + size; 189 if (result < size) { 190 // We must have overflowed 191 vm_exit_during_initialization(CollectedHeap::OverflowMessage); 192 } 193 return result; 194 } 195 196 size_t CollectedHeap::round_up_and_check_overflow(size_t total, size_t size) { 197 assert(size >= 0, "must be"); 198 size_t result = round_to(total, size); 199 if (result < size) { 200 // We must have overflowed 201 vm_exit_during_initialization(CollectedHeap::OverflowMessage); 202 } 203 return result; 204 } 205 206 #ifndef PRODUCT 207 void CollectedHeap::check_for_bad_heap_word_value(HeapWord* addr, size_t size) { 208 if (CheckMemoryInitialization && ZapUnusedHeapArea) { 209 for (size_t slot = 0; slot < size; slot += 1) { 210 assert((*(intptr_t*) (addr + slot)) != ((intptr_t) badHeapWordVal), 211 "Found badHeapWordValue in post-allocation check"); 212 } 213 } 214 } 215 216 void CollectedHeap::check_for_non_bad_heap_word_value(HeapWord* addr, size_t size) { 217 if (CheckMemoryInitialization && ZapUnusedHeapArea) { 218 for (size_t slot = 0; slot < size; slot += 1) { 219 assert((*(intptr_t*) (addr + slot)) == ((intptr_t) badHeapWordVal), 220 "Found non badHeapWordValue in pre-allocation check"); 221 } 222 } 223 } 224 #endif // PRODUCT 225 |