< prev index next >

src/hotspot/share/gc/z/zPage.inline.hpp

Print this page




 277     }
 278 
 279     // Retry
 280     addr = prev_top;
 281   }
 282 }
 283 
 284 inline bool ZPage::undo_alloc_object(uintptr_t addr, size_t size) {
 285   assert(is_allocating(), "Invalid state");
 286 
 287   const uintptr_t offset = ZAddress::offset(addr);
 288   const size_t aligned_size = align_up(size, object_alignment());
 289   const uintptr_t old_top = top();
 290   const uintptr_t new_top = old_top - aligned_size;
 291 
 292   if (new_top != offset) {
 293     // Failed to undo allocation, not the last allocated object
 294     return false;
 295   }
 296 



 297   _top = new_top;
 298 
 299   // Success
 300   return true;
 301 }
 302 
 303 inline bool ZPage::undo_alloc_object_atomic(uintptr_t addr, size_t size) {
 304   assert(is_allocating(), "Invalid state");
 305 
 306   const uintptr_t offset = ZAddress::offset(addr);
 307   const size_t aligned_size = align_up(size, object_alignment());
 308   uintptr_t old_top = top();
 309 
 310   for (;;) {
 311     const uintptr_t new_top = old_top - aligned_size;
 312     if (new_top != offset) {
 313       // Failed to undo allocation, not the last allocated object
 314       return false;
 315     }



 316 
 317     const uintptr_t prev_top = Atomic::cmpxchg(new_top, &_top, old_top);
 318     if (prev_top == old_top) {
 319       // Success
 320       return true;
 321     }
 322 
 323     // Retry
 324     old_top = prev_top;
 325   }
 326 }
 327 
 328 #endif // SHARE_GC_Z_ZPAGE_INLINE_HPP


 277     }
 278 
 279     // Retry
 280     addr = prev_top;
 281   }
 282 }
 283 
 284 inline bool ZPage::undo_alloc_object(uintptr_t addr, size_t size) {
 285   assert(is_allocating(), "Invalid state");
 286 
 287   const uintptr_t offset = ZAddress::offset(addr);
 288   const size_t aligned_size = align_up(size, object_alignment());
 289   const uintptr_t old_top = top();
 290   const uintptr_t new_top = old_top - aligned_size;
 291 
 292   if (new_top != offset) {
 293     // Failed to undo allocation, not the last allocated object
 294     return false;
 295   }
 296 
 297   // Clear memory
 298   ZUtils::zero(addr, size);
 299 
 300   _top = new_top;
 301 
 302   // Success
 303   return true;
 304 }
 305 
 306 inline bool ZPage::undo_alloc_object_atomic(uintptr_t addr, size_t size) {
 307   assert(is_allocating(), "Invalid state");
 308 
 309   const uintptr_t offset = ZAddress::offset(addr);
 310   const size_t aligned_size = align_up(size, object_alignment());
 311   uintptr_t old_top = top();
 312 
 313   for (;;) {
 314     const uintptr_t new_top = old_top - aligned_size;
 315     if (new_top != offset) {
 316       // Failed to undo allocation, not the last allocated object
 317       return false;
 318     }
 319 
 320     // Clear memory
 321     ZUtils::zero(addr, size);
 322 
 323     const uintptr_t prev_top = Atomic::cmpxchg(new_top, &_top, old_top);
 324     if (prev_top == old_top) {
 325       // Success
 326       return true;
 327     }
 328 
 329     // Retry
 330     old_top = prev_top;
 331   }
 332 }
 333 
 334 #endif // SHARE_GC_Z_ZPAGE_INLINE_HPP
< prev index next >