comparison src/share/vm/gc_interface/collectedHeap.hpp @ 481:7d7a7c599c17

6578152: fill_region_with_object has usability and safety issues Reviewed-by: apetrusenko, ysr
author jcoomes
date Thu, 11 Dec 2008 12:05:08 -0800
parents 1ee8caae33af
children e9be0e04635a
comparison
equal deleted inserted replaced
480:d249b360e026 481:7d7a7c599c17
45 45
46 #ifdef ASSERT 46 #ifdef ASSERT
47 static int _fire_out_of_memory_count; 47 static int _fire_out_of_memory_count;
48 #endif 48 #endif
49 49
50 // Used for filler objects (static, but initialized in ctor).
51 static size_t _filler_array_max_size;
52
50 protected: 53 protected:
51 MemRegion _reserved; 54 MemRegion _reserved;
52 BarrierSet* _barrier_set; 55 BarrierSet* _barrier_set;
53 bool _is_gc_active; 56 bool _is_gc_active;
54 unsigned int _total_collections; // ... started 57 unsigned int _total_collections; // ... started
116 HeapWord* obj, size_t size, 119 HeapWord* obj, size_t size,
117 int length); 120 int length);
118 121
119 // Clears an allocated object. 122 // Clears an allocated object.
120 inline static void init_obj(HeapWord* obj, size_t size); 123 inline static void init_obj(HeapWord* obj, size_t size);
124
125 // Filler object utilities.
126 static inline size_t filler_array_hdr_size();
127 static inline size_t filler_array_min_size();
128 static inline size_t filler_array_max_size();
129
130 DEBUG_ONLY(static void fill_args_check(HeapWord* start, size_t words);)
131 DEBUG_ONLY(static void zap_filler_array(HeapWord* start, size_t words);)
132
133 // Fill with a single array; caller must ensure filler_array_min_size() <=
134 // words <= filler_array_max_size().
135 static inline void fill_with_array(HeapWord* start, size_t words);
136
137 // Fill with a single object (either an int array or a java.lang.Object).
138 static inline void fill_with_object_impl(HeapWord* start, size_t words);
121 139
122 // Verification functions 140 // Verification functions
123 virtual void check_for_bad_heap_word_value(HeapWord* addr, size_t size) 141 virtual void check_for_bad_heap_word_value(HeapWord* addr, size_t size)
124 PRODUCT_RETURN; 142 PRODUCT_RETURN;
125 virtual void check_for_non_bad_heap_word_value(HeapWord* addr, size_t size) 143 virtual void check_for_non_bad_heap_word_value(HeapWord* addr, size_t size)
292 virtual HeapWord* permanent_mem_allocate(size_t size) = 0; 310 virtual HeapWord* permanent_mem_allocate(size_t size) = 0;
293 311
294 // The boundary between a "large" and "small" array of primitives, in words. 312 // The boundary between a "large" and "small" array of primitives, in words.
295 virtual size_t large_typearray_limit() = 0; 313 virtual size_t large_typearray_limit() = 0;
296 314
315 // Utilities for turning raw memory into filler objects.
316 //
317 // min_fill_size() is the smallest region that can be filled.
318 // fill_with_objects() can fill arbitrary-sized regions of the heap using
319 // multiple objects. fill_with_object() is for regions known to be smaller
320 // than the largest array of integers; it uses a single object to fill the
321 // region and has slightly less overhead.
322 static size_t min_fill_size() {
323 return size_t(align_object_size(oopDesc::header_size()));
324 }
325
326 static void fill_with_objects(HeapWord* start, size_t words);
327
328 static void fill_with_object(HeapWord* start, size_t words);
329 static void fill_with_object(MemRegion region) {
330 fill_with_object(region.start(), region.word_size());
331 }
332 static void fill_with_object(HeapWord* start, HeapWord* end) {
333 fill_with_object(start, pointer_delta(end, start));
334 }
335
297 // Some heaps may offer a contiguous region for shared non-blocking 336 // Some heaps may offer a contiguous region for shared non-blocking
298 // allocation, via inlined code (by exporting the address of the top and 337 // allocation, via inlined code (by exporting the address of the top and
299 // end fields defining the extent of the contiguous allocation region.) 338 // end fields defining the extent of the contiguous allocation region.)
300 339
301 // This function returns "true" iff the heap supports this kind of 340 // This function returns "true" iff the heap supports this kind of