79 JvmtiExport::vm_object_alloc_event_collector(obj);
80
81 if (DTraceAllocProbes) {
82 // support for Dtrace object alloc event (no-op most of the time)
83 if (klass() != NULL && klass()->name() != NULL) {
84 SharedRuntime::dtrace_object_alloc(obj, size);
85 }
86 }
87 }
88
89 void CollectedHeap::post_allocation_setup_obj(KlassHandle klass,
90 HeapWord* obj,
91 int size) {
92 post_allocation_setup_common(klass, obj);
93 assert(Universe::is_bootstrapping() ||
94 !((oop)obj)->is_array(), "must not be an array");
95 // notify jvmti and dtrace
96 post_allocation_notify(klass, (oop)obj, size);
97 }
98
99 void CollectedHeap::post_allocation_setup_array(KlassHandle klass,
100 HeapWord* obj,
101 int length) {
102 // Set array length before setting the _klass field
103 // in post_allocation_setup_common() because the klass field
104 // indicates that the object is parsable by concurrent GC.
105 assert(length >= 0, "length should be non-negative");
106 ((arrayOop)obj)->set_length(length);
107 post_allocation_setup_common(klass, obj);
108 oop new_obj = (oop)obj;
109 assert(new_obj->is_array(), "must be an array");
110 // notify jvmti and dtrace (must be after length is set for dtrace)
111 post_allocation_notify(klass, new_obj, new_obj->size());
112 }
113
114 HeapWord* CollectedHeap::common_mem_allocate_noinit(KlassHandle klass, size_t size, TRAPS) {
115
116 // Clear unhandled oops for memory allocation. Memory allocation might
117 // not take out a lock if from tlab, so clear here.
118 CHECK_UNHANDLED_OOPS_ONLY(THREAD->clear_unhandled_oops();)
186 return obj;
187 }
188 // Otherwise...
189 return allocate_from_tlab_slow(klass, thread, size);
190 }
191
192 void CollectedHeap::init_obj(HeapWord* obj, size_t size) {
193 assert(obj != NULL, "cannot initialize NULL object");
194 const size_t hs = oopDesc::header_size();
195 assert(size >= hs, "unexpected object size");
196 ((oop)obj)->set_klass_gap(0);
197 Copy::fill_to_aligned_words(obj + hs, size - hs);
198 }
199
200 oop CollectedHeap::obj_allocate(KlassHandle klass, int size, TRAPS) {
201 debug_only(check_for_valid_allocation_state());
202 assert(!Universe::heap()->is_gc_active(), "Allocation during gc not allowed");
203 assert(size >= 0, "int won't convert to size_t");
204 HeapWord* obj = common_mem_allocate_init(klass, size, CHECK_NULL);
205 post_allocation_setup_obj(klass, obj, size);
206 NOT_PRODUCT(Universe::heap()->check_for_bad_heap_word_value(obj, size));
207 return (oop)obj;
208 }
209
210 oop CollectedHeap::array_allocate(KlassHandle klass,
211 int size,
212 int length,
213 TRAPS) {
214 debug_only(check_for_valid_allocation_state());
215 assert(!Universe::heap()->is_gc_active(), "Allocation during gc not allowed");
216 assert(size >= 0, "int won't convert to size_t");
217 HeapWord* obj = common_mem_allocate_init(klass, size, CHECK_NULL);
218 post_allocation_setup_array(klass, obj, length);
219 NOT_PRODUCT(Universe::heap()->check_for_bad_heap_word_value(obj, size));
220 return (oop)obj;
221 }
222
223 oop CollectedHeap::array_allocate_nozero(KlassHandle klass,
224 int size,
225 int length,
|
79 JvmtiExport::vm_object_alloc_event_collector(obj);
80
81 if (DTraceAllocProbes) {
82 // support for Dtrace object alloc event (no-op most of the time)
83 if (klass() != NULL && klass()->name() != NULL) {
84 SharedRuntime::dtrace_object_alloc(obj, size);
85 }
86 }
87 }
88
89 void CollectedHeap::post_allocation_setup_obj(KlassHandle klass,
90 HeapWord* obj,
91 int size) {
92 post_allocation_setup_common(klass, obj);
93 assert(Universe::is_bootstrapping() ||
94 !((oop)obj)->is_array(), "must not be an array");
95 // notify jvmti and dtrace
96 post_allocation_notify(klass, (oop)obj, size);
97 }
98
99 void CollectedHeap::post_allocation_setup_class(KlassHandle klass,
100 HeapWord* obj,
101 int size,
102 int size_field_offset) {
103 // Set oop_size field before setting the _klass field
104 // in post_allocation_setup_common() because the klass field
105 // indicates that the object is parsable by concurrent GC.
106 oop new_obj = (oop)obj;
107 assert(size > 0, "oop_size must be positive.");
108 assert(size_field_offset > 0, "size_field_offset must be initialized.");
109 new_obj->int_field_put(size_field_offset, size);
110 post_allocation_setup_common(klass, obj);
111 assert(Universe::is_bootstrapping() ||
112 !new_obj->is_array(), "must not be an array");
113 // notify jvmti and dtrace
114 post_allocation_notify(klass, new_obj, size);
115 }
116
117 void CollectedHeap::post_allocation_setup_array(KlassHandle klass,
118 HeapWord* obj,
119 int length) {
120 // Set array length before setting the _klass field
121 // in post_allocation_setup_common() because the klass field
122 // indicates that the object is parsable by concurrent GC.
123 assert(length >= 0, "length should be non-negative");
124 ((arrayOop)obj)->set_length(length);
125 post_allocation_setup_common(klass, obj);
126 oop new_obj = (oop)obj;
127 assert(new_obj->is_array(), "must be an array");
128 // notify jvmti and dtrace (must be after length is set for dtrace)
129 post_allocation_notify(klass, new_obj, new_obj->size());
130 }
131
132 HeapWord* CollectedHeap::common_mem_allocate_noinit(KlassHandle klass, size_t size, TRAPS) {
133
134 // Clear unhandled oops for memory allocation. Memory allocation might
135 // not take out a lock if from tlab, so clear here.
136 CHECK_UNHANDLED_OOPS_ONLY(THREAD->clear_unhandled_oops();)
204 return obj;
205 }
206 // Otherwise...
207 return allocate_from_tlab_slow(klass, thread, size);
208 }
209
210 void CollectedHeap::init_obj(HeapWord* obj, size_t size) {
211 assert(obj != NULL, "cannot initialize NULL object");
212 const size_t hs = oopDesc::header_size();
213 assert(size >= hs, "unexpected object size");
214 ((oop)obj)->set_klass_gap(0);
215 Copy::fill_to_aligned_words(obj + hs, size - hs);
216 }
217
218 oop CollectedHeap::obj_allocate(KlassHandle klass, int size, TRAPS) {
219 debug_only(check_for_valid_allocation_state());
220 assert(!Universe::heap()->is_gc_active(), "Allocation during gc not allowed");
221 assert(size >= 0, "int won't convert to size_t");
222 HeapWord* obj = common_mem_allocate_init(klass, size, CHECK_NULL);
223 post_allocation_setup_obj(klass, obj, size);
224 NOT_PRODUCT(Universe::heap()->check_for_bad_heap_word_value(obj, size));
225 return (oop)obj;
226 }
227
228 // Instances of j.l.Class have an oop_size field that must be set before the
229 // the header is set in order to parse the instances's size correctly.
230 oop CollectedHeap::class_allocate(KlassHandle klass, int size, int size_field_offset, TRAPS) {
231 debug_only(check_for_valid_allocation_state());
232 assert(!Universe::heap()->is_gc_active(), "Allocation during gc not allowed");
233 assert(size >= 0, "int won't convert to size_t");
234 HeapWord* obj = common_mem_allocate_init(klass, size, CHECK_NULL);
235 post_allocation_setup_class(klass, obj, size, size_field_offset); // set oop_size
236 NOT_PRODUCT(Universe::heap()->check_for_bad_heap_word_value(obj, size));
237 return (oop)obj;
238 }
239
240 oop CollectedHeap::array_allocate(KlassHandle klass,
241 int size,
242 int length,
243 TRAPS) {
244 debug_only(check_for_valid_allocation_state());
245 assert(!Universe::heap()->is_gc_active(), "Allocation during gc not allowed");
246 assert(size >= 0, "int won't convert to size_t");
247 HeapWord* obj = common_mem_allocate_init(klass, size, CHECK_NULL);
248 post_allocation_setup_array(klass, obj, length);
249 NOT_PRODUCT(Universe::heap()->check_for_bad_heap_word_value(obj, size));
250 return (oop)obj;
251 }
252
253 oop CollectedHeap::array_allocate_nozero(KlassHandle klass,
254 int size,
255 int length,
|