< prev index next >

src/hotspot/share/gc/shared/oopStorage.cpp

Print this page




 132 }
 133 
 134 size_t OopStorage::ActiveArray::size() const {
 135   return _size;
 136 }
 137 
 138 size_t OopStorage::ActiveArray::block_count() const {
 139   return _block_count;
 140 }
 141 
 142 size_t OopStorage::ActiveArray::block_count_acquire() const {
 143   return Atomic::load_acquire(&_block_count);
 144 }
 145 
 146 void OopStorage::ActiveArray::increment_refcount() const {
 147   int new_value = Atomic::add(&_refcount, 1);
 148   assert(new_value >= 1, "negative refcount %d", new_value - 1);
 149 }
 150 
 151 bool OopStorage::ActiveArray::decrement_refcount() const {
 152   int new_value = Atomic::sub(1, &_refcount);
 153   assert(new_value >= 0, "negative refcount %d", new_value);
 154   return new_value == 0;
 155 }
 156 
 157 bool OopStorage::ActiveArray::push(Block* block) {
 158   size_t index = _block_count;
 159   if (index < _size) {
 160     block->set_active_index(index);
 161     *block_ptr(index) = block;
 162     // Use a release_store to ensure all the setup is complete before
 163     // making the block visible.
 164     Atomic::release_store(&_block_count, index + 1);
 165     return true;
 166   } else {
 167     return false;
 168   }
 169 }
 170 
 171 void OopStorage::ActiveArray::remove(Block* block) {
 172   assert(_block_count > 0, "array is empty");


 707     Block* block = find_block_or_null(ptrs[i]);
 708     assert(block != NULL, "%s: invalid release " PTR_FORMAT, name(), p2i(ptrs[i]));
 709     log_trace(oopstorage, ref)("%s: released " PTR_FORMAT, name(), p2i(ptrs[i]));
 710     size_t count = 0;
 711     uintx releasing = 0;
 712     for ( ; i < size; ++i) {
 713       const oop* entry = ptrs[i];
 714       check_release_entry(entry);
 715       // If entry not in block, finish block and resume outer loop with entry.
 716       if (!block->contains(entry)) break;
 717       // Add entry to releasing bitmap.
 718       log_trace(oopstorage, ref)("%s: released " PTR_FORMAT, name(), p2i(entry));
 719       uintx entry_bitmask = block->bitmask_for_entry(entry);
 720       assert((releasing & entry_bitmask) == 0,
 721              "Duplicate entry: " PTR_FORMAT, p2i(entry));
 722       releasing |= entry_bitmask;
 723       ++count;
 724     }
 725     // Release the contiguous entries that are in block.
 726     block->release_entries(releasing, this);
 727     Atomic::sub(count, &_allocation_count);
 728   }
 729 }
 730 
 731 const size_t initial_active_array_size = 8;
 732 
 733 OopStorage::OopStorage(const char* name,
 734                        Mutex* allocation_mutex,
 735                        Mutex* active_mutex) :
 736   _name(os::strdup(name)),
 737   _active_array(ActiveArray::create(initial_active_array_size)),
 738   _allocation_list(),
 739   _deferred_updates(NULL),
 740   _allocation_mutex(allocation_mutex),
 741   _active_mutex(active_mutex),
 742   _allocation_count(0),
 743   _concurrent_iteration_count(0),
 744   _needs_cleanup(false)
 745 {
 746   _active_array->increment_refcount();
 747   assert(_active_mutex->rank() < _allocation_mutex->rank(),




 132 }
 133 
 134 size_t OopStorage::ActiveArray::size() const {
 135   return _size;
 136 }
 137 
 138 size_t OopStorage::ActiveArray::block_count() const {
 139   return _block_count;
 140 }
 141 
 142 size_t OopStorage::ActiveArray::block_count_acquire() const {
 143   return Atomic::load_acquire(&_block_count);
 144 }
 145 
 146 void OopStorage::ActiveArray::increment_refcount() const {
 147   int new_value = Atomic::add(&_refcount, 1);
 148   assert(new_value >= 1, "negative refcount %d", new_value - 1);
 149 }
 150 
 151 bool OopStorage::ActiveArray::decrement_refcount() const {
 152   int new_value = Atomic::sub(&_refcount, 1);
 153   assert(new_value >= 0, "negative refcount %d", new_value);
 154   return new_value == 0;
 155 }
 156 
 157 bool OopStorage::ActiveArray::push(Block* block) {
 158   size_t index = _block_count;
 159   if (index < _size) {
 160     block->set_active_index(index);
 161     *block_ptr(index) = block;
 162     // Use a release_store to ensure all the setup is complete before
 163     // making the block visible.
 164     Atomic::release_store(&_block_count, index + 1);
 165     return true;
 166   } else {
 167     return false;
 168   }
 169 }
 170 
 171 void OopStorage::ActiveArray::remove(Block* block) {
 172   assert(_block_count > 0, "array is empty");


 707     Block* block = find_block_or_null(ptrs[i]);
 708     assert(block != NULL, "%s: invalid release " PTR_FORMAT, name(), p2i(ptrs[i]));
 709     log_trace(oopstorage, ref)("%s: released " PTR_FORMAT, name(), p2i(ptrs[i]));
 710     size_t count = 0;
 711     uintx releasing = 0;
 712     for ( ; i < size; ++i) {
 713       const oop* entry = ptrs[i];
 714       check_release_entry(entry);
 715       // If entry not in block, finish block and resume outer loop with entry.
 716       if (!block->contains(entry)) break;
 717       // Add entry to releasing bitmap.
 718       log_trace(oopstorage, ref)("%s: released " PTR_FORMAT, name(), p2i(entry));
 719       uintx entry_bitmask = block->bitmask_for_entry(entry);
 720       assert((releasing & entry_bitmask) == 0,
 721              "Duplicate entry: " PTR_FORMAT, p2i(entry));
 722       releasing |= entry_bitmask;
 723       ++count;
 724     }
 725     // Release the contiguous entries that are in block.
 726     block->release_entries(releasing, this);
 727     Atomic::sub(&_allocation_count, count);
 728   }
 729 }
 730 
 731 const size_t initial_active_array_size = 8;
 732 
 733 OopStorage::OopStorage(const char* name,
 734                        Mutex* allocation_mutex,
 735                        Mutex* active_mutex) :
 736   _name(os::strdup(name)),
 737   _active_array(ActiveArray::create(initial_active_array_size)),
 738   _allocation_list(),
 739   _deferred_updates(NULL),
 740   _allocation_mutex(allocation_mutex),
 741   _active_mutex(active_mutex),
 742   _allocation_count(0),
 743   _concurrent_iteration_count(0),
 744   _needs_cleanup(false)
 745 {
 746   _active_array->increment_refcount();
 747   assert(_active_mutex->rank() < _allocation_mutex->rank(),


< prev index next >