Mercurial > hg > graal-jvmci-8
comparison src/share/vm/gc_implementation/g1/g1AllocRegion.inline.hpp @ 2433:abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
7023151: G1: refactor the code that operates on _cur_alloc_region to be re-used for allocs by the GC threads
7018286: G1: humongous allocation attempts should take the GC locker into account
Summary: First, this change replaces the asymmetric locking scheme in the G1 slow alloc path by a summetric one. Second, it factors out the code that operates on _cur_alloc_region so that it can be re-used for allocations by the GC threads in the future.
Reviewed-by: stefank, brutisso, johnc
author | tonyp |
---|---|
date | Wed, 30 Mar 2011 10:26:59 -0400 |
parents | |
children | 63a4eb8bcd23 1526a938e670 |
comparison
equal
deleted
inserted
replaced
2432:455328d90876 | 2433:abdfc822206f |
---|---|
1 /* | |
2 * Copyright (c) 2011, 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 * | |
23 */ | |
24 | |
25 #ifndef SHARE_VM_GC_IMPLEMENTATION_G1_G1ALLOCREGION_INLINE_HPP | |
26 #define SHARE_VM_GC_IMPLEMENTATION_G1_G1ALLOCREGION_INLINE_HPP | |
27 | |
28 #include "gc_implementation/g1/g1AllocRegion.hpp" | |
29 | |
30 inline HeapWord* G1AllocRegion::allocate(HeapRegion* alloc_region, | |
31 size_t word_size, | |
32 bool bot_updates) { | |
33 assert(alloc_region != NULL, err_msg("pre-condition")); | |
34 | |
35 if (!bot_updates) { | |
36 return alloc_region->allocate_no_bot_updates(word_size); | |
37 } else { | |
38 return alloc_region->allocate(word_size); | |
39 } | |
40 } | |
41 | |
42 inline HeapWord* G1AllocRegion::par_allocate(HeapRegion* alloc_region, | |
43 size_t word_size, | |
44 bool bot_updates) { | |
45 assert(alloc_region != NULL, err_msg("pre-condition")); | |
46 assert(!alloc_region->is_empty(), err_msg("pre-condition")); | |
47 | |
48 if (!bot_updates) { | |
49 return alloc_region->par_allocate_no_bot_updates(word_size); | |
50 } else { | |
51 return alloc_region->par_allocate(word_size); | |
52 } | |
53 } | |
54 | |
55 inline HeapWord* G1AllocRegion::attempt_allocation(size_t word_size, | |
56 bool bot_updates) { | |
57 assert(bot_updates == _bot_updates, ar_ext_msg(this, "pre-condition")); | |
58 | |
59 HeapRegion* alloc_region = _alloc_region; | |
60 assert(alloc_region != NULL, ar_ext_msg(this, "not initialized properly")); | |
61 | |
62 HeapWord* result = par_allocate(alloc_region, word_size, bot_updates); | |
63 if (result != NULL) { | |
64 trace("alloc", word_size, result); | |
65 return result; | |
66 } | |
67 trace("alloc failed", word_size); | |
68 return NULL; | |
69 } | |
70 | |
71 inline HeapWord* G1AllocRegion::attempt_allocation_locked(size_t word_size, | |
72 bool bot_updates) { | |
73 // First we have to tedo the allocation, assuming we're holding the | |
74 // appropriate lock, in case another thread changed the region while | |
75 // we were waiting to get the lock. | |
76 HeapWord* result = attempt_allocation(word_size, bot_updates); | |
77 if (result != NULL) { | |
78 return result; | |
79 } | |
80 | |
81 retire(true /* fill_up */); | |
82 result = new_alloc_region_and_allocate(word_size, false /* force */); | |
83 if (result != NULL) { | |
84 trace("alloc locked (second attempt)", word_size, result); | |
85 return result; | |
86 } | |
87 trace("alloc locked failed", word_size); | |
88 return NULL; | |
89 } | |
90 | |
91 inline HeapWord* G1AllocRegion::attempt_allocation_force(size_t word_size, | |
92 bool bot_updates) { | |
93 assert(bot_updates == _bot_updates, ar_ext_msg(this, "pre-condition")); | |
94 assert(_alloc_region != NULL, ar_ext_msg(this, "not initialized properly")); | |
95 | |
96 trace("forcing alloc"); | |
97 HeapWord* result = new_alloc_region_and_allocate(word_size, true /* force */); | |
98 if (result != NULL) { | |
99 trace("alloc forced", word_size, result); | |
100 return result; | |
101 } | |
102 trace("alloc forced failed", word_size); | |
103 return NULL; | |
104 } | |
105 | |
106 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1ALLOCREGION_INLINE_HPP |