< prev index next >

src/hotspot/share/gc/z/zMarkStackAllocator.cpp

Print this page




  53 
  54   // Register mark stack space start
  55   ZMarkStackSpaceStart = _start;
  56 }
  57 
  58 bool ZMarkStackSpace::is_initialized() const {
  59   return _start != 0;
  60 }
  61 
  62 uintptr_t ZMarkStackSpace::alloc_space(size_t size) {
  63   uintptr_t top = Atomic::load(&_top);
  64 
  65   for (;;) {
  66     const uintptr_t end = Atomic::load(&_end);
  67     const uintptr_t new_top = top + size;
  68     if (new_top > end) {
  69       // Not enough space left
  70       return 0;
  71     }
  72 
  73     const uintptr_t prev_top = Atomic::cmpxchg(new_top, &_top, top);
  74     if (prev_top == top) {
  75       // Success
  76       return top;
  77     }
  78 
  79     // Retry
  80     top = prev_top;
  81   }
  82 }
  83 
  84 uintptr_t ZMarkStackSpace::expand_and_alloc_space(size_t size) {
  85   ZLocker<ZLock> locker(&_expand_lock);
  86 
  87   // Retry allocation before expanding
  88   uintptr_t addr = alloc_space(size);
  89   if (addr != 0) {
  90     return addr;
  91   }
  92 
  93   // Check expansion limit




  53 
  54   // Register mark stack space start
  55   ZMarkStackSpaceStart = _start;
  56 }
  57 
  58 bool ZMarkStackSpace::is_initialized() const {
  59   return _start != 0;
  60 }
  61 
  62 uintptr_t ZMarkStackSpace::alloc_space(size_t size) {
  63   uintptr_t top = Atomic::load(&_top);
  64 
  65   for (;;) {
  66     const uintptr_t end = Atomic::load(&_end);
  67     const uintptr_t new_top = top + size;
  68     if (new_top > end) {
  69       // Not enough space left
  70       return 0;
  71     }
  72 
  73     const uintptr_t prev_top = Atomic::cmpxchg(&_top, top, new_top);
  74     if (prev_top == top) {
  75       // Success
  76       return top;
  77     }
  78 
  79     // Retry
  80     top = prev_top;
  81   }
  82 }
  83 
  84 uintptr_t ZMarkStackSpace::expand_and_alloc_space(size_t size) {
  85   ZLocker<ZLock> locker(&_expand_lock);
  86 
  87   // Retry allocation before expanding
  88   uintptr_t addr = alloc_space(size);
  89   if (addr != 0) {
  90     return addr;
  91   }
  92 
  93   // Check expansion limit


< prev index next >