1 /*
2 * Copyright (c) 2015, 2018, 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 */
96 }
97
98 // Allocation succeeded in already installed page
99 addr = prev_addr;
100
101 // Undo new page allocation
102 ZHeap::heap()->undo_alloc_page(new_page);
103 }
104 }
105 }
106
107 return addr;
108 }
109
110 uintptr_t ZObjectAllocator::alloc_large_object(size_t size, ZAllocationFlags flags) {
111 assert(ZThread::is_java(), "Should be a Java thread");
112
113 uintptr_t addr = 0;
114
115 // Allocate new large page
116 const size_t page_size = align_up(size, ZPageSizeMin);
117 ZPage* const page = alloc_page(ZPageTypeLarge, page_size, flags);
118 if (page != NULL) {
119 // Allocate the object
120 addr = page->alloc_object(size);
121 }
122
123 return addr;
124 }
125
126 uintptr_t ZObjectAllocator::alloc_medium_object(size_t size, ZAllocationFlags flags) {
127 return alloc_object_in_shared_page(_shared_medium_page.addr(), ZPageTypeMedium, ZPageSizeMedium, size, flags);
128 }
129
130 uintptr_t ZObjectAllocator::alloc_small_object_from_nonworker(size_t size, ZAllocationFlags flags) {
131 assert(ZThread::is_java() || ZThread::is_vm() || ZThread::is_runtime_worker(),
132 "Should be a Java, VM or Runtime worker thread");
133
134 // Non-worker small page allocation can never use the reserve
135 flags.set_no_reserve();
136
|
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 */
96 }
97
98 // Allocation succeeded in already installed page
99 addr = prev_addr;
100
101 // Undo new page allocation
102 ZHeap::heap()->undo_alloc_page(new_page);
103 }
104 }
105 }
106
107 return addr;
108 }
109
110 uintptr_t ZObjectAllocator::alloc_large_object(size_t size, ZAllocationFlags flags) {
111 assert(ZThread::is_java(), "Should be a Java thread");
112
113 uintptr_t addr = 0;
114
115 // Allocate new large page
116 const size_t page_size = align_up(size, ZGranuleSize);
117 ZPage* const page = alloc_page(ZPageTypeLarge, page_size, flags);
118 if (page != NULL) {
119 // Allocate the object
120 addr = page->alloc_object(size);
121 }
122
123 return addr;
124 }
125
126 uintptr_t ZObjectAllocator::alloc_medium_object(size_t size, ZAllocationFlags flags) {
127 return alloc_object_in_shared_page(_shared_medium_page.addr(), ZPageTypeMedium, ZPageSizeMedium, size, flags);
128 }
129
130 uintptr_t ZObjectAllocator::alloc_small_object_from_nonworker(size_t size, ZAllocationFlags flags) {
131 assert(ZThread::is_java() || ZThread::is_vm() || ZThread::is_runtime_worker(),
132 "Should be a Java, VM or Runtime worker thread");
133
134 // Non-worker small page allocation can never use the reserve
135 flags.set_no_reserve();
136
|