1 /*
2 * Copyright (c) 2001, 2009, 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 // 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 {
39 assert(_g1_reserved.contains(addr), "invariant");
40 size_t index = pointer_delta(addr, _g1_reserved.start(), 1)
41 >> HeapRegion::LogOfHRGrainBytes;
42
43 HeapRegion* res = _hrs->at(index);
44 assert(res == _hrs->addr_to_region(addr), "sanity");
77 Heap_lock->unlock();
78 }
79 return res;
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
86 inline RefToScanQueue* G1CollectedHeap::task_queue(int i) const {
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 }
|
1 /*
2 * Copyright (c) 2001, 2010, 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_G1COLLECTEDHEAP_INLINE_HPP
26 #define SHARE_VM_GC_IMPLEMENTATION_G1_G1COLLECTEDHEAP_INLINE_HPP
27
28 #include "gc_implementation/g1/concurrentMark.hpp"
29 #include "gc_implementation/g1/g1CollectedHeap.hpp"
30 #include "gc_implementation/g1/heapRegionSeq.hpp"
31 #include "utilities/taskqueue.hpp"
32
33 // Inline functions for G1CollectedHeap
34
35 inline HeapRegion*
36 G1CollectedHeap::heap_region_containing(const void* addr) const {
37 HeapRegion* hr = _hrs->addr_to_region(addr);
38 // hr can be null if addr in perm_gen
39 if (hr != NULL && hr->continuesHumongous()) {
40 hr = hr->humongous_start_region();
41 }
42 return hr;
43 }
44
45 inline HeapRegion*
46 G1CollectedHeap::heap_region_containing_raw(const void* addr) const {
47 assert(_g1_reserved.contains(addr), "invariant");
48 size_t index = pointer_delta(addr, _g1_reserved.start(), 1)
49 >> HeapRegion::LogOfHRGrainBytes;
50
51 HeapRegion* res = _hrs->at(index);
52 assert(res == _hrs->addr_to_region(addr), "sanity");
85 Heap_lock->unlock();
86 }
87 return res;
88 }
89 }
90 // attempt_allocation_slow will also unlock the heap lock when appropriate.
91 return attempt_allocation_slow(word_size, permit_collection_pause);
92 }
93
94 inline RefToScanQueue* G1CollectedHeap::task_queue(int i) const {
95 return _task_queues->queue(i);
96 }
97
98 inline bool G1CollectedHeap::isMarkedPrev(oop obj) const {
99 return _cm->prevMarkBitMap()->isMarked((HeapWord *)obj);
100 }
101
102 inline bool G1CollectedHeap::isMarkedNext(oop obj) const {
103 return _cm->nextMarkBitMap()->isMarked((HeapWord *)obj);
104 }
105
106 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1COLLECTEDHEAP_INLINE_HPP
|