120 assert(((oop)obj)->blueprint()->oop_is_array(), "must be an array"); |
120 assert(((oop)obj)->blueprint()->oop_is_array(), "must be an array"); |
121 // notify jvmti and dtrace (must be after length is set for dtrace) |
121 // notify jvmti and dtrace (must be after length is set for dtrace) |
122 post_allocation_notify(klass, (oop)obj); |
122 post_allocation_notify(klass, (oop)obj); |
123 } |
123 } |
124 |
124 |
125 HeapWord* CollectedHeap::common_mem_allocate_noinit(size_t size, bool is_noref, TRAPS) { |
125 HeapWord* CollectedHeap::common_mem_allocate_noinit(size_t size, TRAPS) { |
126 |
126 |
127 // Clear unhandled oops for memory allocation. Memory allocation might |
127 // Clear unhandled oops for memory allocation. Memory allocation might |
128 // not take out a lock if from tlab, so clear here. |
128 // not take out a lock if from tlab, so clear here. |
129 CHECK_UNHANDLED_OOPS_ONLY(THREAD->clear_unhandled_oops();) |
129 CHECK_UNHANDLED_OOPS_ONLY(THREAD->clear_unhandled_oops();) |
130 |
130 |
131 if (HAS_PENDING_EXCEPTION) { |
131 if (HAS_PENDING_EXCEPTION) { |
132 NOT_PRODUCT(guarantee(false, "Should not allocate with exception pending")); |
132 NOT_PRODUCT(guarantee(false, "Should not allocate with exception pending")); |
133 return NULL; // caller does a CHECK_0 too |
133 return NULL; // caller does a CHECK_0 too |
134 } |
134 } |
135 |
135 |
136 // We may want to update this, is_noref objects might not be allocated in TLABs. |
|
137 HeapWord* result = NULL; |
136 HeapWord* result = NULL; |
138 if (UseTLAB) { |
137 if (UseTLAB) { |
139 result = CollectedHeap::allocate_from_tlab(THREAD, size); |
138 result = CollectedHeap::allocate_from_tlab(THREAD, size); |
140 if (result != NULL) { |
139 if (result != NULL) { |
141 assert(!HAS_PENDING_EXCEPTION, |
140 assert(!HAS_PENDING_EXCEPTION, |
143 return result; |
142 return result; |
144 } |
143 } |
145 } |
144 } |
146 bool gc_overhead_limit_was_exceeded = false; |
145 bool gc_overhead_limit_was_exceeded = false; |
147 result = Universe::heap()->mem_allocate(size, |
146 result = Universe::heap()->mem_allocate(size, |
148 is_noref, |
|
149 false, |
|
150 &gc_overhead_limit_was_exceeded); |
147 &gc_overhead_limit_was_exceeded); |
151 if (result != NULL) { |
148 if (result != NULL) { |
152 NOT_PRODUCT(Universe::heap()-> |
149 NOT_PRODUCT(Universe::heap()-> |
153 check_for_non_bad_heap_word_value(result, size)); |
150 check_for_non_bad_heap_word_value(result, size)); |
154 assert(!HAS_PENDING_EXCEPTION, |
151 assert(!HAS_PENDING_EXCEPTION, |
181 |
178 |
182 THROW_OOP_0(Universe::out_of_memory_error_gc_overhead_limit()); |
179 THROW_OOP_0(Universe::out_of_memory_error_gc_overhead_limit()); |
183 } |
180 } |
184 } |
181 } |
185 |
182 |
186 HeapWord* CollectedHeap::common_mem_allocate_init(size_t size, bool is_noref, TRAPS) { |
183 HeapWord* CollectedHeap::common_mem_allocate_init(size_t size, TRAPS) { |
187 HeapWord* obj = common_mem_allocate_noinit(size, is_noref, CHECK_NULL); |
184 HeapWord* obj = common_mem_allocate_noinit(size, CHECK_NULL); |
188 init_obj(obj, size); |
185 init_obj(obj, size); |
189 return obj; |
186 return obj; |
190 } |
187 } |
191 |
188 |
192 // Need to investigate, do we really want to throw OOM exception here? |
189 // Need to investigate, do we really want to throw OOM exception here? |
253 |
250 |
254 oop CollectedHeap::obj_allocate(KlassHandle klass, int size, TRAPS) { |
251 oop CollectedHeap::obj_allocate(KlassHandle klass, int size, TRAPS) { |
255 debug_only(check_for_valid_allocation_state()); |
252 debug_only(check_for_valid_allocation_state()); |
256 assert(!Universe::heap()->is_gc_active(), "Allocation during gc not allowed"); |
253 assert(!Universe::heap()->is_gc_active(), "Allocation during gc not allowed"); |
257 assert(size >= 0, "int won't convert to size_t"); |
254 assert(size >= 0, "int won't convert to size_t"); |
258 HeapWord* obj = common_mem_allocate_init(size, false, CHECK_NULL); |
255 HeapWord* obj = common_mem_allocate_init(size, CHECK_NULL); |
259 post_allocation_setup_obj(klass, obj, size); |
256 post_allocation_setup_obj(klass, obj, size); |
260 NOT_PRODUCT(Universe::heap()->check_for_bad_heap_word_value(obj, size)); |
257 NOT_PRODUCT(Universe::heap()->check_for_bad_heap_word_value(obj, size)); |
261 return (oop)obj; |
258 return (oop)obj; |
262 } |
259 } |
263 |
260 |
266 int length, |
263 int length, |
267 TRAPS) { |
264 TRAPS) { |
268 debug_only(check_for_valid_allocation_state()); |
265 debug_only(check_for_valid_allocation_state()); |
269 assert(!Universe::heap()->is_gc_active(), "Allocation during gc not allowed"); |
266 assert(!Universe::heap()->is_gc_active(), "Allocation during gc not allowed"); |
270 assert(size >= 0, "int won't convert to size_t"); |
267 assert(size >= 0, "int won't convert to size_t"); |
271 HeapWord* obj = common_mem_allocate_init(size, false, CHECK_NULL); |
268 HeapWord* obj = common_mem_allocate_init(size, CHECK_NULL); |
272 post_allocation_setup_array(klass, obj, size, length); |
|
273 NOT_PRODUCT(Universe::heap()->check_for_bad_heap_word_value(obj, size)); |
|
274 return (oop)obj; |
|
275 } |
|
276 |
|
277 oop CollectedHeap::large_typearray_allocate(KlassHandle klass, |
|
278 int size, |
|
279 int length, |
|
280 TRAPS) { |
|
281 debug_only(check_for_valid_allocation_state()); |
|
282 assert(!Universe::heap()->is_gc_active(), "Allocation during gc not allowed"); |
|
283 assert(size >= 0, "int won't convert to size_t"); |
|
284 HeapWord* obj = common_mem_allocate_init(size, true, CHECK_NULL); |
|
285 post_allocation_setup_array(klass, obj, size, length); |
269 post_allocation_setup_array(klass, obj, size, length); |
286 NOT_PRODUCT(Universe::heap()->check_for_bad_heap_word_value(obj, size)); |
270 NOT_PRODUCT(Universe::heap()->check_for_bad_heap_word_value(obj, size)); |
287 return (oop)obj; |
271 return (oop)obj; |
288 } |
272 } |
289 |
273 |