1 /*
2 * Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
44 void CollectedHeap::post_allocation_setup_common(Klass* klass,
45 HeapWord* obj_ptr) {
46 post_allocation_setup_no_klass_install(klass, obj_ptr);
47 oop obj = (oop)obj_ptr;
48 #if ! INCLUDE_ALL_GCS
49 obj->set_klass(klass);
50 #else
51 // Need a release store to ensure array/class length, mark word, and
52 // object zeroing are visible before setting the klass non-NULL, for
53 // concurrent collectors.
54 obj->release_set_klass(klass);
55 #endif
56 }
57
58 void CollectedHeap::post_allocation_setup_no_klass_install(Klass* klass,
59 HeapWord* obj_ptr) {
60 oop obj = (oop)obj_ptr;
61
62 assert(obj != NULL, "NULL object pointer");
63 if (UseBiasedLocking && (klass != NULL)) {
64 obj->set_mark(klass->prototype_header());
65 } else {
66 // May be bootstrapping
67 obj->set_mark(markOopDesc::prototype());
68 }
69 }
70
71 // Support for jvmti and dtrace
72 inline void post_allocation_notify(Klass* klass, oop obj, int size) {
73 // support low memory notifications (no-op if not enabled)
74 LowMemoryDetector::detect_low_memory_for_collected_pools();
75
76 // support for JVMTI VMObjectAlloc event (no-op if not enabled)
77 JvmtiExport::vm_object_alloc_event_collector(obj);
78
79 if (DTraceAllocProbes) {
80 // support for Dtrace object alloc event (no-op most of the time)
81 if (klass != NULL && klass->name() != NULL) {
82 SharedRuntime::dtrace_object_alloc(obj, size);
83 }
84 }
85 }
86
87 void CollectedHeap::post_allocation_setup_obj(Klass* klass,
|
1 /*
2 * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
44 void CollectedHeap::post_allocation_setup_common(Klass* klass,
45 HeapWord* obj_ptr) {
46 post_allocation_setup_no_klass_install(klass, obj_ptr);
47 oop obj = (oop)obj_ptr;
48 #if ! INCLUDE_ALL_GCS
49 obj->set_klass(klass);
50 #else
51 // Need a release store to ensure array/class length, mark word, and
52 // object zeroing are visible before setting the klass non-NULL, for
53 // concurrent collectors.
54 obj->release_set_klass(klass);
55 #endif
56 }
57
58 void CollectedHeap::post_allocation_setup_no_klass_install(Klass* klass,
59 HeapWord* obj_ptr) {
60 oop obj = (oop)obj_ptr;
61
62 assert(obj != NULL, "NULL object pointer");
63 if (UseBiasedLocking && (klass != NULL)) {
64 obj->set_mark_raw(klass->prototype_header());
65 } else {
66 // May be bootstrapping
67 obj->set_mark_raw(markOopDesc::prototype());
68 }
69 }
70
71 // Support for jvmti and dtrace
72 inline void post_allocation_notify(Klass* klass, oop obj, int size) {
73 // support low memory notifications (no-op if not enabled)
74 LowMemoryDetector::detect_low_memory_for_collected_pools();
75
76 // support for JVMTI VMObjectAlloc event (no-op if not enabled)
77 JvmtiExport::vm_object_alloc_event_collector(obj);
78
79 if (DTraceAllocProbes) {
80 // support for Dtrace object alloc event (no-op most of the time)
81 if (klass != NULL && klass->name() != NULL) {
82 SharedRuntime::dtrace_object_alloc(obj, size);
83 }
84 }
85 }
86
87 void CollectedHeap::post_allocation_setup_obj(Klass* klass,
|