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_ZOBJECTALLOCATOR_HPP 25 #define SHARE_GC_Z_ZOBJECTALLOCATOR_HPP 26 27 #include "gc/z/zAllocationFlags.hpp" 28 #include "gc/z/zPage.hpp" 29 #include "gc/z/zValue.hpp" 30 #include "memory/allocation.hpp" 31 32 class ZObjectAllocator { 33 private: 34 ZPerCPU<size_t> _used; 35 ZPerCPU<size_t> _undone; 36 ZContended<ZPage*> _shared_medium_page; 37 ZPerCPU<ZPage*> _shared_small_page; 38 ZPerWorker<ZPage*> _worker_small_page; 39 40 ZPage* alloc_page(uint8_t type, size_t size, ZAllocationFlags flags); 41 void undo_alloc_page(ZPage* page); 42 43 // Allocate an object in a shared page. Allocate and 44 // atomically install a new page if necessary. 45 uintptr_t alloc_object_in_shared_page(ZPage** shared_page, 46 uint8_t page_type, 47 size_t page_size, 48 size_t size, 49 ZAllocationFlags flags); 50 51 uintptr_t alloc_large_object(size_t size, ZAllocationFlags flags); 52 uintptr_t alloc_medium_object(size_t size, ZAllocationFlags flags); 53 uintptr_t alloc_small_object_from_nonworker(size_t size, ZAllocationFlags flags); 54 uintptr_t alloc_small_object_from_worker(size_t size, ZAllocationFlags flags); 55 uintptr_t alloc_small_object(size_t size, ZAllocationFlags flags); 56 uintptr_t alloc_object(size_t size, ZAllocationFlags flags); 57 58 bool undo_alloc_large_object(ZPage* page); | 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_ZOBJECTALLOCATOR_HPP 25 #define SHARE_GC_Z_ZOBJECTALLOCATOR_HPP 26 27 #include "gc/z/zAllocationFlags.hpp" 28 #include "gc/z/zPage.hpp" 29 #include "gc/z/zValue.hpp" 30 #include "memory/allocation.hpp" 31 32 class ZObjectAllocator { 33 private: 34 const bool _per_cpu_shared_small_page; 35 ZPerCPU<size_t> _used; 36 ZPerCPU<size_t> _undone; 37 ZContended<ZPage*> _shared_medium_page; 38 ZPerCPU<ZPage*> _shared_small_page; 39 ZPerWorker<ZPage*> _worker_small_page; 40 41 ZPage** shared_small_page_addr(); 42 ZPage* const* shared_small_page_addr() const; 43 44 ZPage* alloc_page(uint8_t type, size_t size, ZAllocationFlags flags); 45 void undo_alloc_page(ZPage* page); 46 47 // Allocate an object in a shared page. Allocate and 48 // atomically install a new page if necessary. 49 uintptr_t alloc_object_in_shared_page(ZPage** shared_page, 50 uint8_t page_type, 51 size_t page_size, 52 size_t size, 53 ZAllocationFlags flags); 54 55 uintptr_t alloc_large_object(size_t size, ZAllocationFlags flags); 56 uintptr_t alloc_medium_object(size_t size, ZAllocationFlags flags); 57 uintptr_t alloc_small_object_from_nonworker(size_t size, ZAllocationFlags flags); 58 uintptr_t alloc_small_object_from_worker(size_t size, ZAllocationFlags flags); 59 uintptr_t alloc_small_object(size_t size, ZAllocationFlags flags); 60 uintptr_t alloc_object(size_t size, ZAllocationFlags flags); 61 62 bool undo_alloc_large_object(ZPage* page); |