Mercurial > hg > graal-compiler
annotate src/share/vm/memory/threadLocalAllocBuffer.inline.hpp @ 1476:1f81c0d18c75
Build also release version of VM. Fix towards making SpecJVM2008 run.
author | Thomas Wuerthinger <wuerthinger@ssw.jku.at> |
---|---|
date | Fri, 26 Nov 2010 12:12:35 +0100 |
parents | 2dd52dea6d28 |
children | c18cbe5936b8 2d127394260e |
rev | line source |
---|---|
0 | 1 /* |
1165
2dd52dea6d28
6902115: G1:assert(ignore_max_completed||thread->is_Java_thread()||SafepointSynchronize::is_at_safepoint())
johnc
parents:
0
diff
changeset
|
2 * Copyright 1999-2009 Sun Microsystems, Inc. All Rights Reserved. |
0 | 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, | |
20 * CA 95054 USA or visit www.sun.com if you need additional information or | |
21 * have any questions. | |
22 * | |
23 */ | |
24 | |
25 inline HeapWord* ThreadLocalAllocBuffer::allocate(size_t size) { | |
26 invariants(); | |
27 HeapWord* obj = top(); | |
28 if (pointer_delta(end(), obj) >= size) { | |
29 // 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
|
30 #ifdef ASSERT |
2dd52dea6d28
6902115: G1:assert(ignore_max_completed||thread->is_Java_thread()||SafepointSynchronize::is_at_safepoint())
johnc
parents:
0
diff
changeset
|
31 // 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
|
32 // 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
|
33 // any concurrent GC thread. |
2dd52dea6d28
6902115: G1:assert(ignore_max_completed||thread->is_Java_thread()||SafepointSynchronize::is_at_safepoint())
johnc
parents:
0
diff
changeset
|
34 size_t hdr_size = CollectedHeap::min_fill_size(); |
2dd52dea6d28
6902115: G1:assert(ignore_max_completed||thread->is_Java_thread()||SafepointSynchronize::is_at_safepoint())
johnc
parents:
0
diff
changeset
|
35 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
|
36 #endif // ASSERT |
0 | 37 // This addition is safe because we know that top is |
38 // at least size below end, so the add can't wrap. | |
39 set_top(obj + size); | |
40 | |
41 invariants(); | |
42 return obj; | |
43 } | |
44 return NULL; | |
45 } | |
46 | |
47 inline size_t ThreadLocalAllocBuffer::compute_size(size_t obj_size) { | |
48 const size_t aligned_obj_size = align_object_size(obj_size); | |
49 | |
50 // Compute the size for the new TLAB. | |
51 // The "last" tlab may be smaller to reduce fragmentation. | |
52 // unsafe_max_tlab_alloc is just a hint. | |
53 const size_t available_size = Universe::heap()->unsafe_max_tlab_alloc(myThread()) / | |
54 HeapWordSize; | |
55 size_t new_tlab_size = MIN2(available_size, desired_size() + aligned_obj_size); | |
56 | |
57 // Make sure there's enough room for object and filler int[]. | |
58 const size_t obj_plus_filler_size = aligned_obj_size + alignment_reserve(); | |
59 if (new_tlab_size < obj_plus_filler_size) { | |
60 // If there isn't enough room for the allocation, return failure. | |
61 if (PrintTLAB && Verbose) { | |
62 gclog_or_tty->print_cr("ThreadLocalAllocBuffer::compute_size(" SIZE_FORMAT ")" | |
63 " returns failure", | |
64 obj_size); | |
65 } | |
66 return 0; | |
67 } | |
68 if (PrintTLAB && Verbose) { | |
69 gclog_or_tty->print_cr("ThreadLocalAllocBuffer::compute_size(" SIZE_FORMAT ")" | |
70 " returns " SIZE_FORMAT, | |
71 obj_size, new_tlab_size); | |
72 } | |
73 return new_tlab_size; | |
74 } | |
75 | |
76 | |
77 void ThreadLocalAllocBuffer::record_slow_allocation(size_t obj_size) { | |
78 // Raise size required to bypass TLAB next time. Why? Else there's | |
79 // a risk that a thread that repeatedly allocates objects of one | |
80 // size will get stuck on this slow path. | |
81 | |
82 set_refill_waste_limit(refill_waste_limit() + refill_waste_limit_increment()); | |
83 | |
84 _slow_allocations++; | |
85 | |
86 if (PrintTLAB && Verbose) { | |
87 Thread* thrd = myThread(); | |
88 gclog_or_tty->print("TLAB: %s thread: "INTPTR_FORMAT" [id: %2d]" | |
89 " obj: "SIZE_FORMAT | |
90 " free: "SIZE_FORMAT | |
91 " waste: "SIZE_FORMAT"\n", | |
92 "slow", thrd, thrd->osthread()->thread_id(), | |
93 obj_size, free(), refill_waste_limit()); | |
94 } | |
95 } |