annotate src/share/vm/memory/threadLocalAllocBuffer.inline.hpp @ 1972:f95d63e2154a

6989984: Use standard include model for Hospot Summary: Replaced MakeDeps and the includeDB files with more standardized solutions. Reviewed-by: coleenp, kvn, kamg
author stefank
date Tue, 23 Nov 2010 13:22:55 -0800
parents e9ff18c4ace7
children c760f78e0a53
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1579
diff changeset
2 * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1165
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1165
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1165
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1579
diff changeset
25 #ifndef SHARE_VM_MEMORY_THREADLOCALALLOCBUFFER_INLINE_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1579
diff changeset
26 #define SHARE_VM_MEMORY_THREADLOCALALLOCBUFFER_INLINE_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1579
diff changeset
27
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1579
diff changeset
28 #include "gc_interface/collectedHeap.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1579
diff changeset
29 #include "memory/threadLocalAllocBuffer.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1579
diff changeset
30 #include "runtime/atomic.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1579
diff changeset
31 #include "utilities/copy.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1579
diff changeset
32
0
a61af66fc99e Initial load
duke
parents:
diff changeset
33 inline HeapWord* ThreadLocalAllocBuffer::allocate(size_t size) {
a61af66fc99e Initial load
duke
parents:
diff changeset
34 invariants();
a61af66fc99e Initial load
duke
parents:
diff changeset
35 HeapWord* obj = top();
a61af66fc99e Initial load
duke
parents:
diff changeset
36 if (pointer_delta(end(), obj) >= size) {
a61af66fc99e Initial load
duke
parents:
diff changeset
37 // successful thread-local allocation
1165
2dd52dea6d28 6902115: G1:assert(ignore_max_completed||thread->is_Java_thread()||SafepointSynchronize::is_at_safepoint())
johnc
parents: 0
diff changeset
38 #ifdef ASSERT
2dd52dea6d28 6902115: G1:assert(ignore_max_completed||thread->is_Java_thread()||SafepointSynchronize::is_at_safepoint())
johnc
parents: 0
diff changeset
39 // Skip mangling the space corresponding to the object header to
2dd52dea6d28 6902115: G1:assert(ignore_max_completed||thread->is_Java_thread()||SafepointSynchronize::is_at_safepoint())
johnc
parents: 0
diff changeset
40 // ensure that the returned space is not considered parsable by
2dd52dea6d28 6902115: G1:assert(ignore_max_completed||thread->is_Java_thread()||SafepointSynchronize::is_at_safepoint())
johnc
parents: 0
diff changeset
41 // any concurrent GC thread.
1571
2d127394260e 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 1165
diff changeset
42 size_t hdr_size = oopDesc::header_size();
1165
2dd52dea6d28 6902115: G1:assert(ignore_max_completed||thread->is_Java_thread()||SafepointSynchronize::is_at_safepoint())
johnc
parents: 0
diff changeset
43 Copy::fill_to_words(obj + hdr_size, size - hdr_size, badHeapWordVal);
2dd52dea6d28 6902115: G1:assert(ignore_max_completed||thread->is_Java_thread()||SafepointSynchronize::is_at_safepoint())
johnc
parents: 0
diff changeset
44 #endif // ASSERT
0
a61af66fc99e Initial load
duke
parents:
diff changeset
45 // This addition is safe because we know that top is
a61af66fc99e Initial load
duke
parents:
diff changeset
46 // at least size below end, so the add can't wrap.
a61af66fc99e Initial load
duke
parents:
diff changeset
47 set_top(obj + size);
a61af66fc99e Initial load
duke
parents:
diff changeset
48
a61af66fc99e Initial load
duke
parents:
diff changeset
49 invariants();
a61af66fc99e Initial load
duke
parents:
diff changeset
50 return obj;
a61af66fc99e Initial load
duke
parents:
diff changeset
51 }
a61af66fc99e Initial load
duke
parents:
diff changeset
52 return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
53 }
a61af66fc99e Initial load
duke
parents:
diff changeset
54
a61af66fc99e Initial load
duke
parents:
diff changeset
55 inline size_t ThreadLocalAllocBuffer::compute_size(size_t obj_size) {
a61af66fc99e Initial load
duke
parents:
diff changeset
56 const size_t aligned_obj_size = align_object_size(obj_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
57
a61af66fc99e Initial load
duke
parents:
diff changeset
58 // Compute the size for the new TLAB.
a61af66fc99e Initial load
duke
parents:
diff changeset
59 // The "last" tlab may be smaller to reduce fragmentation.
a61af66fc99e Initial load
duke
parents:
diff changeset
60 // unsafe_max_tlab_alloc is just a hint.
a61af66fc99e Initial load
duke
parents:
diff changeset
61 const size_t available_size = Universe::heap()->unsafe_max_tlab_alloc(myThread()) /
a61af66fc99e Initial load
duke
parents:
diff changeset
62 HeapWordSize;
a61af66fc99e Initial load
duke
parents:
diff changeset
63 size_t new_tlab_size = MIN2(available_size, desired_size() + aligned_obj_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
64
a61af66fc99e Initial load
duke
parents:
diff changeset
65 // Make sure there's enough room for object and filler int[].
a61af66fc99e Initial load
duke
parents:
diff changeset
66 const size_t obj_plus_filler_size = aligned_obj_size + alignment_reserve();
a61af66fc99e Initial load
duke
parents:
diff changeset
67 if (new_tlab_size < obj_plus_filler_size) {
a61af66fc99e Initial load
duke
parents:
diff changeset
68 // If there isn't enough room for the allocation, return failure.
a61af66fc99e Initial load
duke
parents:
diff changeset
69 if (PrintTLAB && Verbose) {
a61af66fc99e Initial load
duke
parents:
diff changeset
70 gclog_or_tty->print_cr("ThreadLocalAllocBuffer::compute_size(" SIZE_FORMAT ")"
a61af66fc99e Initial load
duke
parents:
diff changeset
71 " returns failure",
a61af66fc99e Initial load
duke
parents:
diff changeset
72 obj_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
73 }
a61af66fc99e Initial load
duke
parents:
diff changeset
74 return 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
75 }
a61af66fc99e Initial load
duke
parents:
diff changeset
76 if (PrintTLAB && Verbose) {
a61af66fc99e Initial load
duke
parents:
diff changeset
77 gclog_or_tty->print_cr("ThreadLocalAllocBuffer::compute_size(" SIZE_FORMAT ")"
a61af66fc99e Initial load
duke
parents:
diff changeset
78 " returns " SIZE_FORMAT,
a61af66fc99e Initial load
duke
parents:
diff changeset
79 obj_size, new_tlab_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
80 }
a61af66fc99e Initial load
duke
parents:
diff changeset
81 return new_tlab_size;
a61af66fc99e Initial load
duke
parents:
diff changeset
82 }
a61af66fc99e Initial load
duke
parents:
diff changeset
83
a61af66fc99e Initial load
duke
parents:
diff changeset
84
a61af66fc99e Initial load
duke
parents:
diff changeset
85 void ThreadLocalAllocBuffer::record_slow_allocation(size_t obj_size) {
a61af66fc99e Initial load
duke
parents:
diff changeset
86 // Raise size required to bypass TLAB next time. Why? Else there's
a61af66fc99e Initial load
duke
parents:
diff changeset
87 // a risk that a thread that repeatedly allocates objects of one
a61af66fc99e Initial load
duke
parents:
diff changeset
88 // size will get stuck on this slow path.
a61af66fc99e Initial load
duke
parents:
diff changeset
89
a61af66fc99e Initial load
duke
parents:
diff changeset
90 set_refill_waste_limit(refill_waste_limit() + refill_waste_limit_increment());
a61af66fc99e Initial load
duke
parents:
diff changeset
91
a61af66fc99e Initial load
duke
parents:
diff changeset
92 _slow_allocations++;
a61af66fc99e Initial load
duke
parents:
diff changeset
93
a61af66fc99e Initial load
duke
parents:
diff changeset
94 if (PrintTLAB && Verbose) {
a61af66fc99e Initial load
duke
parents:
diff changeset
95 Thread* thrd = myThread();
a61af66fc99e Initial load
duke
parents:
diff changeset
96 gclog_or_tty->print("TLAB: %s thread: "INTPTR_FORMAT" [id: %2d]"
a61af66fc99e Initial load
duke
parents:
diff changeset
97 " obj: "SIZE_FORMAT
a61af66fc99e Initial load
duke
parents:
diff changeset
98 " free: "SIZE_FORMAT
a61af66fc99e Initial load
duke
parents:
diff changeset
99 " waste: "SIZE_FORMAT"\n",
a61af66fc99e Initial load
duke
parents:
diff changeset
100 "slow", thrd, thrd->osthread()->thread_id(),
a61af66fc99e Initial load
duke
parents:
diff changeset
101 obj_size, free(), refill_waste_limit());
a61af66fc99e Initial load
duke
parents:
diff changeset
102 }
a61af66fc99e Initial load
duke
parents:
diff changeset
103 }
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1579
diff changeset
104
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1579
diff changeset
105 #endif // SHARE_VM_MEMORY_THREADLOCALALLOCBUFFER_INLINE_HPP