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 post_allocation_setup_no_klass_install(klass, obj);
104
105 // set the j.l.Class instance's oop_size field BEFORE setting the header:
106 ((oop)obj)->int_field_put(size_field_offset, size);
107
108 post_allocation_install_obj_klass(klass, oop(obj)); // set the header
109 assert(Universe::is_bootstrapping() ||
110 !((oop)obj)->is_array(), "must not be an array");
111 // notify jvmti and dtrace
112 post_allocation_notify(klass, (oop)obj, size);
113 }
114
115 void CollectedHeap::post_allocation_setup_array(KlassHandle klass,
116 HeapWord* obj,
117 int length) {
118 // Set array length before setting the _klass field
119 // in post_allocation_setup_common() because the klass field
120 // indicates that the object is parsable by concurrent GC.
121 assert(length >= 0, "length should be non-negative");
122 ((arrayOop)obj)->set_length(length);
123 post_allocation_setup_common(klass, obj);
124 oop new_obj = (oop)obj;
125 assert(new_obj->is_array(), "must be an array");
126 // notify jvmti and dtrace (must be after length is set for dtrace)
127 post_allocation_notify(klass, new_obj, new_obj->size());
128 }
129
130 HeapWord* CollectedHeap::common_mem_allocate_noinit(KlassHandle klass, size_t size, TRAPS) {
131
132 // Clear unhandled oops for memory allocation. Memory allocation might
133 // not take out a lock if from tlab, so clear here.
134 CHECK_UNHANDLED_OOPS_ONLY(THREAD->clear_unhandled_oops();)
202 return obj;
203 }
204 // Otherwise...
205 return allocate_from_tlab_slow(klass, thread, size);
206 }
207
208 void CollectedHeap::init_obj(HeapWord* obj, size_t size) {
209 assert(obj != NULL, "cannot initialize NULL object");
210 const size_t hs = oopDesc::header_size();
211 assert(size >= hs, "unexpected object size");
212 ((oop)obj)->set_klass_gap(0);
213 Copy::fill_to_aligned_words(obj + hs, size - hs);
214 }
215
216 oop CollectedHeap::obj_allocate(KlassHandle klass, int size, TRAPS) {
217 debug_only(check_for_valid_allocation_state());
218 assert(!Universe::heap()->is_gc_active(), "Allocation during gc not allowed");
219 assert(size >= 0, "int won't convert to size_t");
220 HeapWord* obj = common_mem_allocate_init(klass, size, CHECK_NULL);
221 post_allocation_setup_obj(klass, obj, size);
222 NOT_PRODUCT(Universe::heap()->check_for_bad_heap_word_value(obj, size));
223 return (oop)obj;
224 }
225
226 // Instances of j.l.Class have an oop_size field that must be set before the
227 // the header is set in order to parse the instances's size correctly.
228 oop CollectedHeap::class_allocate(KlassHandle klass, int size, int size_field_offset, TRAPS) {
229 debug_only(check_for_valid_allocation_state());
230 assert(!Universe::heap()->is_gc_active(), "Allocation during gc not allowed");
231 assert(size >= 0, "int won't convert to size_t");
232 HeapWord* obj = common_mem_allocate_init(klass, size, CHECK_NULL);
233 post_allocation_setup_class(klass, obj, size, size_field_offset); // set oop_size
234 NOT_PRODUCT(Universe::heap()->check_for_bad_heap_word_value(obj, size));
235 return (oop)obj;
236 }
237
238 oop CollectedHeap::array_allocate(KlassHandle klass,
239 int size,
240 int length,
241 TRAPS) {
242 debug_only(check_for_valid_allocation_state());
243 assert(!Universe::heap()->is_gc_active(), "Allocation during gc not allowed");
244 assert(size >= 0, "int won't convert to size_t");
245 HeapWord* obj = common_mem_allocate_init(klass, size, CHECK_NULL);
246 post_allocation_setup_array(klass, obj, length);
247 NOT_PRODUCT(Universe::heap()->check_for_bad_heap_word_value(obj, size));
248 return (oop)obj;
249 }
250
251 oop CollectedHeap::array_allocate_nozero(KlassHandle klass,
252 int size,
253 int length,
|