equal
deleted
inserted
replaced
131 } |
131 } |
132 |
132 |
133 uintptr_t ZObjectAllocator::alloc_small_object_from_nonworker(size_t size, ZAllocationFlags flags) { |
133 uintptr_t ZObjectAllocator::alloc_small_object_from_nonworker(size_t size, ZAllocationFlags flags) { |
134 assert(ZThread::is_java() || ZThread::is_vm(), "Should be a Java or VM thread"); |
134 assert(ZThread::is_java() || ZThread::is_vm(), "Should be a Java or VM thread"); |
135 |
135 |
136 if (flags.relocation() && flags.java_thread() && UseTLAB) { |
|
137 // For relocations from Java threads, try TLAB allocation first |
|
138 const uintptr_t addr = (uintptr_t)Thread::current()->tlab().allocate(ZUtils::bytes_to_words(size)); |
|
139 if (addr != 0) { |
|
140 return addr; |
|
141 } |
|
142 } |
|
143 |
|
144 // Non-worker small page allocation can never use the reserve |
136 // Non-worker small page allocation can never use the reserve |
145 flags.set_no_reserve(); |
137 flags.set_no_reserve(); |
146 |
138 |
147 return alloc_object_in_shared_page(_shared_small_page.addr(), ZPageTypeSmall, ZPageSizeSmall, size, flags); |
139 return alloc_object_in_shared_page(_shared_small_page.addr(), ZPageTypeSmall, ZPageSizeSmall, size, flags); |
148 } |
140 } |
236 } |
228 } |
237 |
229 |
238 bool ZObjectAllocator::undo_alloc_small_object_from_nonworker(ZPage* page, uintptr_t addr, size_t size) { |
230 bool ZObjectAllocator::undo_alloc_small_object_from_nonworker(ZPage* page, uintptr_t addr, size_t size) { |
239 assert(page->type() == ZPageTypeSmall, "Invalid page type"); |
231 assert(page->type() == ZPageTypeSmall, "Invalid page type"); |
240 |
232 |
241 if (ZThread::is_java()) { |
|
242 // Try undo allocation in TLAB |
|
243 if (Thread::current()->tlab().undo_allocate((HeapWord*)addr, ZUtils::bytes_to_words(size))) { |
|
244 return true; |
|
245 } |
|
246 } |
|
247 |
|
248 // Try atomic undo on shared page |
233 // Try atomic undo on shared page |
249 return page->undo_alloc_object_atomic(addr, size); |
234 return page->undo_alloc_object_atomic(addr, size); |
250 } |
235 } |
251 |
236 |
252 bool ZObjectAllocator::undo_alloc_small_object_from_worker(ZPage* page, uintptr_t addr, size_t size) { |
237 bool ZObjectAllocator::undo_alloc_small_object_from_worker(ZPage* page, uintptr_t addr, size_t size) { |