equal
deleted
inserted
replaced
142 size_t OopStorage::ActiveArray::block_count_acquire() const { |
142 size_t OopStorage::ActiveArray::block_count_acquire() const { |
143 return Atomic::load_acquire(&_block_count); |
143 return Atomic::load_acquire(&_block_count); |
144 } |
144 } |
145 |
145 |
146 void OopStorage::ActiveArray::increment_refcount() const { |
146 void OopStorage::ActiveArray::increment_refcount() const { |
147 int new_value = Atomic::add(1, &_refcount); |
147 int new_value = Atomic::add(&_refcount, 1); |
148 assert(new_value >= 1, "negative refcount %d", new_value - 1); |
148 assert(new_value >= 1, "negative refcount %d", new_value - 1); |
149 } |
149 } |
150 |
150 |
151 bool OopStorage::ActiveArray::decrement_refcount() const { |
151 bool OopStorage::ActiveArray::decrement_refcount() const { |
152 int new_value = Atomic::sub(1, &_refcount); |
152 int new_value = Atomic::sub(1, &_refcount); |
1008 size_t step = MIN2(max_step, 1 + (remaining / _estimated_thread_count)); |
1008 size_t step = MIN2(max_step, 1 + (remaining / _estimated_thread_count)); |
1009 // Atomic::add with possible overshoot. This can perform better |
1009 // Atomic::add with possible overshoot. This can perform better |
1010 // than a CAS loop on some platforms when there is contention. |
1010 // than a CAS loop on some platforms when there is contention. |
1011 // We can cope with the uncertainty by recomputing start/end from |
1011 // We can cope with the uncertainty by recomputing start/end from |
1012 // the result of the add, and dealing with potential overshoot. |
1012 // the result of the add, and dealing with potential overshoot. |
1013 size_t end = Atomic::add(step, &_next_block); |
1013 size_t end = Atomic::add(&_next_block, step); |
1014 // _next_block may have changed, so recompute start from result of add. |
1014 // _next_block may have changed, so recompute start from result of add. |
1015 start = end - step; |
1015 start = end - step; |
1016 // _next_block may have changed so much that end has overshot. |
1016 // _next_block may have changed so much that end has overshot. |
1017 end = MIN2(end, _block_count); |
1017 end = MIN2(end, _block_count); |
1018 // _next_block may have changed so much that even start has overshot. |
1018 // _next_block may have changed so much that even start has overshot. |