59 assert(klass() == NULL || klass()->klass_part() != NULL, "not a klass"); |
59 assert(klass() == NULL || klass()->klass_part() != NULL, "not a klass"); |
60 assert(obj != NULL, "NULL object pointer"); |
60 assert(obj != NULL, "NULL object pointer"); |
61 obj->set_klass(klass()); |
61 obj->set_klass(klass()); |
62 assert(!Universe::is_fully_initialized() || obj->blueprint() != NULL, |
62 assert(!Universe::is_fully_initialized() || obj->blueprint() != NULL, |
63 "missing blueprint"); |
63 "missing blueprint"); |
64 |
64 } |
|
65 |
|
66 // Support for jvmti and dtrace |
|
67 inline void post_allocation_notify(KlassHandle klass, oop obj) { |
65 // support for JVMTI VMObjectAlloc event (no-op if not enabled) |
68 // support for JVMTI VMObjectAlloc event (no-op if not enabled) |
66 JvmtiExport::vm_object_alloc_event_collector(obj); |
69 JvmtiExport::vm_object_alloc_event_collector(obj); |
67 |
70 |
68 if (DTraceAllocProbes) { |
71 if (DTraceAllocProbes) { |
69 // support for Dtrace object alloc event (no-op most of the time) |
72 // support for Dtrace object alloc event (no-op most of the time) |
77 HeapWord* obj, |
80 HeapWord* obj, |
78 size_t size) { |
81 size_t size) { |
79 post_allocation_setup_common(klass, obj, size); |
82 post_allocation_setup_common(klass, obj, size); |
80 assert(Universe::is_bootstrapping() || |
83 assert(Universe::is_bootstrapping() || |
81 !((oop)obj)->blueprint()->oop_is_array(), "must not be an array"); |
84 !((oop)obj)->blueprint()->oop_is_array(), "must not be an array"); |
|
85 // notify jvmti and dtrace |
|
86 post_allocation_notify(klass, (oop)obj); |
82 } |
87 } |
83 |
88 |
84 void CollectedHeap::post_allocation_setup_array(KlassHandle klass, |
89 void CollectedHeap::post_allocation_setup_array(KlassHandle klass, |
85 HeapWord* obj, |
90 HeapWord* obj, |
86 size_t size, |
91 size_t size, |
87 int length) { |
92 int length) { |
88 // Set array length before posting jvmti object alloc event |
|
89 // in post_allocation_setup_common() |
|
90 assert(length >= 0, "length should be non-negative"); |
93 assert(length >= 0, "length should be non-negative"); |
|
94 post_allocation_setup_common(klass, obj, size); |
|
95 // Must set length after installing klass as set_klass zeros the length |
|
96 // field in UseCompressedOops |
91 ((arrayOop)obj)->set_length(length); |
97 ((arrayOop)obj)->set_length(length); |
92 post_allocation_setup_common(klass, obj, size); |
|
93 assert(((oop)obj)->blueprint()->oop_is_array(), "must be an array"); |
98 assert(((oop)obj)->blueprint()->oop_is_array(), "must be an array"); |
|
99 // notify jvmti and dtrace (must be after length is set for dtrace) |
|
100 post_allocation_notify(klass, (oop)obj); |
94 } |
101 } |
95 |
102 |
96 HeapWord* CollectedHeap::common_mem_allocate_noinit(size_t size, bool is_noref, TRAPS) { |
103 HeapWord* CollectedHeap::common_mem_allocate_noinit(size_t size, bool is_noref, TRAPS) { |
97 |
104 |
98 // Clear unhandled oops for memory allocation. Memory allocation might |
105 // Clear unhandled oops for memory allocation. Memory allocation might |