1 /* 2 * Copyright (c) 2015, 2019, 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_ZPAGE_HPP 25 #define SHARE_GC_Z_ZPAGE_HPP 26 27 #include "gc/z/zList.hpp" 28 #include "gc/z/zLiveMap.hpp" 29 #include "gc/z/zPhysicalMemory.hpp" 30 #include "gc/z/zVirtualMemory.hpp" 31 #include "memory/allocation.hpp" 32 33 class ZPage : public CHeapObj<mtGC> { 34 friend class VMStructs; 35 friend class ZList<ZPage>; 36 37 private: 38 uint8_t _type; 39 uint8_t _numa_id; 40 uint32_t _seqnum; 41 ZVirtualMemory _virtual; 42 volatile uintptr_t _top; 43 ZLiveMap _livemap; 44 uint64_t _last_used; 45 ZPhysicalMemory _physical; 46 ZListNode<ZPage> _node; 47 48 void assert_initialized() const; 49 50 uint8_t type_from_size(size_t size) const; 51 const char* type_to_string() const; 52 53 bool is_object_marked(uintptr_t addr) const; 54 bool is_object_strongly_marked(uintptr_t addr) const; 55 56 public: 57 ZPage(const ZVirtualMemory& vmem, const ZPhysicalMemory& pmem); 58 ZPage(uint8_t type, const ZVirtualMemory& vmem, const ZPhysicalMemory& pmem); 59 60 uint32_t object_max_count() const; 61 size_t object_alignment_shift() const; 62 size_t object_alignment() const; 63 64 uint8_t type() const; 65 uintptr_t start() const; 66 uintptr_t end() const; 67 size_t size() const; 68 uintptr_t top() const; 69 size_t remaining() const; 70 71 const ZPhysicalMemory& physical_memory() const; 72 const ZVirtualMemory& virtual_memory() const; 73 74 uint8_t numa_id(); 75 76 bool is_allocating() const; 77 void pin_allocating(); 78 void unpin_allocating(); 79 80 bool is_relocatable() const; 81 82 bool is_mapped() const; 83 void set_pre_mapped(); 84 85 uint64_t last_used() const; 86 void set_last_used(); 87 88 void reset(); 89 90 ZPage* retype(uint8_t type); 91 ZPage* split(size_t size); 92 ZPage* split(uint8_t type, size_t size); 93 94 bool is_in(uintptr_t addr) const; 95 96 uintptr_t block_start(uintptr_t addr) const; 97 bool block_is_obj(uintptr_t addr) const; 98 99 bool is_marked() const; 100 bool is_object_live(uintptr_t addr) const; 101 bool is_object_strongly_live(uintptr_t addr) const; 102 bool mark_object(uintptr_t addr, bool finalizable, bool& inc_live); 103 104 void inc_live_atomic(uint32_t objects, size_t bytes); 105 uint32_t live_objects() const; 106 size_t live_bytes() const; 107 108 void object_iterate(ObjectClosure* cl); 109 110 uintptr_t alloc_object(size_t size); 111 uintptr_t alloc_object_atomic(size_t size); 112 113 bool undo_alloc_object(uintptr_t addr, size_t size); 114 bool undo_alloc_object_atomic(uintptr_t addr, size_t size); 115 116 void print_on(outputStream* out) const; 117 void print() const; 118 }; 119 120 #endif // SHARE_GC_Z_ZPAGE_HPP