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 *
23 */
24
25 #ifndef SHARE_VM_GC_SHARED_COLLECTEDHEAP_INLINE_HPP
26 #define SHARE_VM_GC_SHARED_COLLECTEDHEAP_INLINE_HPP
27
28 #include "classfile/javaClasses.hpp"
29 #include "gc/shared/allocTracer.hpp"
30 #include "gc/shared/collectedHeap.hpp"
31 #include "gc/shared/threadLocalAllocBuffer.inline.hpp"
32 #include "memory/universe.hpp"
33 #include "oops/arrayOop.hpp"
34 #include "oops/oop.inline.hpp"
35 #include "prims/jvmtiExport.hpp"
36 #include "runtime/sharedRuntime.hpp"
37 #include "runtime/thread.inline.hpp"
38 #include "services/lowMemoryDetector.hpp"
39 #include "utilities/align.hpp"
40 #include "utilities/copy.hpp"
41
42 // Inline allocation implementations.
43
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
137 return NULL; // caller does a CHECK_0 too
138 }
139
140 HeapWord* result = NULL;
141 if (UseTLAB) {
142 result = allocate_from_tlab(klass, THREAD, size);
143 if (result != NULL) {
144 assert(!HAS_PENDING_EXCEPTION,
145 "Unexpected exception, will result in uninitialized storage");
146 return result;
147 }
148 }
149 bool gc_overhead_limit_was_exceeded = false;
150 result = Universe::heap()->mem_allocate(size,
151 &gc_overhead_limit_was_exceeded);
152 if (result != NULL) {
153 NOT_PRODUCT(Universe::heap()->
154 check_for_non_bad_heap_word_value(result, size));
155 assert(!HAS_PENDING_EXCEPTION,
156 "Unexpected exception, will result in uninitialized storage");
157 THREAD->incr_allocated_bytes(size * HeapWordSize);
158
159 AllocTracer::send_allocation_outside_tlab(klass, result, size * HeapWordSize, THREAD);
160
161 if (UseTLAB) {
162 THREAD->tlab().handle_sample(THREAD, result, size);
163 }
164 return result;
165 }
166
167
168 if (!gc_overhead_limit_was_exceeded) {
169 // -XX:+HeapDumpOnOutOfMemoryError and -XX:OnOutOfMemoryError support
170 report_java_out_of_memory("Java heap space");
171
172 if (JvmtiExport::should_post_resource_exhausted()) {
173 JvmtiExport::post_resource_exhausted(
174 JVMTI_RESOURCE_EXHAUSTED_OOM_ERROR | JVMTI_RESOURCE_EXHAUSTED_JAVA_HEAP,
175 "Java heap space");
176 }
177
178 THROW_OOP_0(Universe::out_of_memory_error_java_heap());
179 } else {
180 // -XX:+HeapDumpOnOutOfMemoryError and -XX:OnOutOfMemoryError support
181 report_java_out_of_memory("GC overhead limit exceeded");
182
183 if (JvmtiExport::should_post_resource_exhausted()) {
184 JvmtiExport::post_resource_exhausted(
185 JVMTI_RESOURCE_EXHAUSTED_OOM_ERROR | JVMTI_RESOURCE_EXHAUSTED_JAVA_HEAP,
186 "GC overhead limit exceeded");
|
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 *
23 */
24
25 #ifndef SHARE_VM_GC_SHARED_COLLECTEDHEAP_INLINE_HPP
26 #define SHARE_VM_GC_SHARED_COLLECTEDHEAP_INLINE_HPP
27
28 #include "classfile/javaClasses.hpp"
29 #include "gc/shared/allocTracer.hpp"
30 #include "gc/shared/collectedHeap.hpp"
31 #include "gc/shared/threadLocalAllocBuffer.inline.hpp"
32 #include "memory/universe.hpp"
33 #include "oops/arrayOop.hpp"
34 #include "oops/oop.inline.hpp"
35 #include "prims/jvmtiExport.hpp"
36 #include "runtime/heapMonitoring.hpp"
37 #include "runtime/sharedRuntime.hpp"
38 #include "runtime/thread.inline.hpp"
39 #include "services/lowMemoryDetector.hpp"
40 #include "utilities/align.hpp"
41 #include "utilities/copy.hpp"
42
43 // Inline allocation implementations.
44
45 void CollectedHeap::post_allocation_setup_common(Klass* klass,
46 HeapWord* obj_ptr) {
47 post_allocation_setup_no_klass_install(klass, obj_ptr);
48 oop obj = (oop)obj_ptr;
49 #if ! INCLUDE_ALL_GCS
50 obj->set_klass(klass);
51 #else
52 // Need a release store to ensure array/class length, mark word, and
53 // object zeroing are visible before setting the klass non-NULL, for
54 // concurrent collectors.
55 obj->release_set_klass(klass);
56 #endif
138 return NULL; // caller does a CHECK_0 too
139 }
140
141 HeapWord* result = NULL;
142 if (UseTLAB) {
143 result = allocate_from_tlab(klass, THREAD, size);
144 if (result != NULL) {
145 assert(!HAS_PENDING_EXCEPTION,
146 "Unexpected exception, will result in uninitialized storage");
147 return result;
148 }
149 }
150 bool gc_overhead_limit_was_exceeded = false;
151 result = Universe::heap()->mem_allocate(size,
152 &gc_overhead_limit_was_exceeded);
153 if (result != NULL) {
154 NOT_PRODUCT(Universe::heap()->
155 check_for_non_bad_heap_word_value(result, size));
156 assert(!HAS_PENDING_EXCEPTION,
157 "Unexpected exception, will result in uninitialized storage");
158 int size_in_bytes = size * HeapWordSize;
159 THREAD->incr_allocated_bytes(size_in_bytes);
160
161 AllocTracer::send_allocation_outside_tlab(klass, result, size_in_bytes, THREAD);
162
163 if (UseTLAB) {
164 THREAD->tlab().handle_sample(THREAD, result, size_in_bytes);
165 }
166 return result;
167 }
168
169 if (!gc_overhead_limit_was_exceeded) {
170 // -XX:+HeapDumpOnOutOfMemoryError and -XX:OnOutOfMemoryError support
171 report_java_out_of_memory("Java heap space");
172
173 if (JvmtiExport::should_post_resource_exhausted()) {
174 JvmtiExport::post_resource_exhausted(
175 JVMTI_RESOURCE_EXHAUSTED_OOM_ERROR | JVMTI_RESOURCE_EXHAUSTED_JAVA_HEAP,
176 "Java heap space");
177 }
178
179 THROW_OOP_0(Universe::out_of_memory_error_java_heap());
180 } else {
181 // -XX:+HeapDumpOnOutOfMemoryError and -XX:OnOutOfMemoryError support
182 report_java_out_of_memory("GC overhead limit exceeded");
183
184 if (JvmtiExport::should_post_resource_exhausted()) {
185 JvmtiExport::post_resource_exhausted(
186 JVMTI_RESOURCE_EXHAUSTED_OOM_ERROR | JVMTI_RESOURCE_EXHAUSTED_JAVA_HEAP,
187 "GC overhead limit exceeded");
|