1 /*
2  * Copyright (c) 2015, 2017, 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 #ifndef SHARE_GC_Z_ZHEAP_INLINE_HPP
25 #define SHARE_GC_Z_ZHEAP_INLINE_HPP
26 
27 #include "gc/z/zAddress.inline.hpp"
28 #include "gc/z/zHeap.hpp"
29 #include "gc/z/zMark.inline.hpp"
30 #include "gc/z/zOop.inline.hpp"
31 #include "gc/z/zPage.inline.hpp"
32 #include "gc/z/zPageTable.inline.hpp"
33 #include "gc/z/zUtils.inline.hpp"
34 #include "utilities/debug.hpp"
35 
heap()36 inline ZHeap* ZHeap::heap() {
37   assert(_heap != NULL, "Not initialized");
38   return _heap;
39 }
40 
reference_discoverer()41 inline ReferenceDiscoverer* ZHeap::reference_discoverer() {
42   return &_reference_processor;
43 }
44 
is_relocating(uintptr_t addr) const45 inline bool ZHeap::is_relocating(uintptr_t addr) const {
46   return _pagetable.is_relocating(addr);
47 }
48 
is_object_live(uintptr_t addr) const49 inline bool ZHeap::is_object_live(uintptr_t addr) const {
50   ZPage* page = _pagetable.get(addr);
51   return page->is_object_live(addr);
52 }
53 
is_object_strongly_live(uintptr_t addr) const54 inline bool ZHeap::is_object_strongly_live(uintptr_t addr) const {
55   ZPage* page = _pagetable.get(addr);
56   return page->is_object_strongly_live(addr);
57 }
58 
59 template <bool finalizable, bool publish>
mark_object(uintptr_t addr)60 inline void ZHeap::mark_object(uintptr_t addr) {
61   assert(ZGlobalPhase == ZPhaseMark, "Mark not allowed");
62   _mark.mark_object<finalizable, publish>(addr);
63 }
64 
alloc_tlab(size_t size)65 inline uintptr_t ZHeap::alloc_tlab(size_t size) {
66   guarantee(size <= max_tlab_size(), "TLAB too large");
67   return _object_allocator.alloc_object(size);
68 }
69 
alloc_object(size_t size)70 inline uintptr_t ZHeap::alloc_object(size_t size) {
71   uintptr_t addr = _object_allocator.alloc_object(size);
72   assert(ZAddress::is_good_or_null(addr), "Bad address");
73 
74   if (addr == 0) {
75     out_of_memory();
76   }
77 
78   return addr;
79 }
80 
alloc_object_for_relocation(size_t size)81 inline uintptr_t ZHeap::alloc_object_for_relocation(size_t size) {
82   uintptr_t addr = _object_allocator.alloc_object_for_relocation(size);
83   assert(ZAddress::is_good_or_null(addr), "Bad address");
84   return addr;
85 }
86 
undo_alloc_object_for_relocation(uintptr_t addr,size_t size)87 inline void ZHeap::undo_alloc_object_for_relocation(uintptr_t addr, size_t size) {
88   ZPage* const page = _pagetable.get(addr);
89   _object_allocator.undo_alloc_object_for_relocation(page, addr, size);
90 }
91 
is_alloc_stalled() const92 inline bool ZHeap::is_alloc_stalled() const {
93   return _page_allocator.is_alloc_stalled();
94 }
95 
check_out_of_memory()96 inline void ZHeap::check_out_of_memory() {
97   _page_allocator.check_out_of_memory();
98 }
99 
is_oop(oop object) const100 inline bool ZHeap::is_oop(oop object) const {
101   return ZOop::is_good(object);
102 }
103 
104 #endif // SHARE_GC_Z_ZHEAP_INLINE_HPP
105