author | tonyp |
Tue, 17 Aug 2010 14:40:00 -0400 | |
changeset 6260 | fba83fd3adc7 |
parent 6251 | 90e562b9f1cc |
child 7397 | 5b173b4ca846 |
permissions | -rw-r--r-- |
1374 | 1 |
/* |
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
2742
diff
changeset
|
2 |
* Copyright (c) 2001, 2009, Oracle and/or its affiliates. All rights reserved. |
1374 | 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 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
2742
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
2742
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
2742
diff
changeset
|
21 |
* questions. |
1374 | 22 |
* |
23 |
*/ |
|
24 |
||
25 |
// Inline functions for G1CollectedHeap |
|
26 |
||
27 |
inline HeapRegion* |
|
28 |
G1CollectedHeap::heap_region_containing(const void* addr) const { |
|
29 |
HeapRegion* hr = _hrs->addr_to_region(addr); |
|
30 |
// hr can be null if addr in perm_gen |
|
31 |
if (hr != NULL && hr->continuesHumongous()) { |
|
32 |
hr = hr->humongous_start_region(); |
|
33 |
} |
|
34 |
return hr; |
|
35 |
} |
|
36 |
||
37 |
inline HeapRegion* |
|
38 |
G1CollectedHeap::heap_region_containing_raw(const void* addr) const { |
|
1902 | 39 |
assert(_g1_reserved.contains(addr), "invariant"); |
2742
5e88fa844ba0
6833576: G1: assert illegal index, growableArray.hpp:186
johnc
parents:
2105
diff
changeset
|
40 |
size_t index = pointer_delta(addr, _g1_reserved.start(), 1) |
5e88fa844ba0
6833576: G1: assert illegal index, growableArray.hpp:186
johnc
parents:
2105
diff
changeset
|
41 |
>> HeapRegion::LogOfHRGrainBytes; |
5e88fa844ba0
6833576: G1: assert illegal index, growableArray.hpp:186
johnc
parents:
2105
diff
changeset
|
42 |
|
1902 | 43 |
HeapRegion* res = _hrs->at(index); |
44 |
assert(res == _hrs->addr_to_region(addr), "sanity"); |
|
1374 | 45 |
return res; |
46 |
} |
|
47 |
||
48 |
inline bool G1CollectedHeap::obj_in_cs(oop obj) { |
|
49 |
HeapRegion* r = _hrs->addr_to_region(obj); |
|
50 |
return r != NULL && r->in_collection_set(); |
|
51 |
} |
|
52 |
||
53 |
inline HeapWord* G1CollectedHeap::attempt_allocation(size_t word_size, |
|
54 |
bool permit_collection_pause) { |
|
55 |
HeapWord* res = NULL; |
|
56 |
||
57 |
assert( SafepointSynchronize::is_at_safepoint() || |
|
58 |
Heap_lock->owned_by_self(), "pre-condition of the call" ); |
|
59 |
||
6260
fba83fd3adc7
6974928: G1: sometimes humongous objects are allocated in young regions
tonyp
parents:
6251
diff
changeset
|
60 |
// All humongous allocation requests should go through the slow path in |
fba83fd3adc7
6974928: G1: sometimes humongous objects are allocated in young regions
tonyp
parents:
6251
diff
changeset
|
61 |
// attempt_allocation_slow(). |
fba83fd3adc7
6974928: G1: sometimes humongous objects are allocated in young regions
tonyp
parents:
6251
diff
changeset
|
62 |
if (!isHumongous(word_size) && _cur_alloc_region != NULL) { |
1374 | 63 |
// If this allocation causes a region to become non empty, |
64 |
// then we need to update our free_regions count. |
|
65 |
||
66 |
if (_cur_alloc_region->is_empty()) { |
|
67 |
res = _cur_alloc_region->allocate(word_size); |
|
68 |
if (res != NULL) |
|
69 |
_free_regions--; |
|
70 |
} else { |
|
71 |
res = _cur_alloc_region->allocate(word_size); |
|
72 |
} |
|
6260
fba83fd3adc7
6974928: G1: sometimes humongous objects are allocated in young regions
tonyp
parents:
6251
diff
changeset
|
73 |
|
fba83fd3adc7
6974928: G1: sometimes humongous objects are allocated in young regions
tonyp
parents:
6251
diff
changeset
|
74 |
if (res != NULL) { |
fba83fd3adc7
6974928: G1: sometimes humongous objects are allocated in young regions
tonyp
parents:
6251
diff
changeset
|
75 |
if (!SafepointSynchronize::is_at_safepoint()) { |
fba83fd3adc7
6974928: G1: sometimes humongous objects are allocated in young regions
tonyp
parents:
6251
diff
changeset
|
76 |
assert( Heap_lock->owned_by_self(), "invariant" ); |
fba83fd3adc7
6974928: G1: sometimes humongous objects are allocated in young regions
tonyp
parents:
6251
diff
changeset
|
77 |
Heap_lock->unlock(); |
fba83fd3adc7
6974928: G1: sometimes humongous objects are allocated in young regions
tonyp
parents:
6251
diff
changeset
|
78 |
} |
fba83fd3adc7
6974928: G1: sometimes humongous objects are allocated in young regions
tonyp
parents:
6251
diff
changeset
|
79 |
return res; |
1374 | 80 |
} |
81 |
} |
|
82 |
// attempt_allocation_slow will also unlock the heap lock when appropriate. |
|
83 |
return attempt_allocation_slow(word_size, permit_collection_pause); |
|
84 |
} |
|
85 |
||
6251 | 86 |
inline RefToScanQueue* G1CollectedHeap::task_queue(int i) const { |
1374 | 87 |
return _task_queues->queue(i); |
88 |
} |
|
89 |
||
90 |
inline bool G1CollectedHeap::isMarkedPrev(oop obj) const { |
|
91 |
return _cm->prevMarkBitMap()->isMarked((HeapWord *)obj); |
|
92 |
} |
|
93 |
||
94 |
inline bool G1CollectedHeap::isMarkedNext(oop obj) const { |
|
95 |
return _cm->nextMarkBitMap()->isMarked((HeapWord *)obj); |
|
96 |
} |