hotspot/src/share/vm/oops/constantPool.cpp
changeset 29576 c223b0a9872e
parent 29081 c61eb4914428
child 31038 2fd2fdc6a70a
equal deleted inserted replaced
29574:ab0121071f54 29576:c223b0a9872e
  1788 #undef DBG
  1788 #undef DBG
  1789 
  1789 
  1790 
  1790 
  1791 void ConstantPool::set_on_stack(const bool value) {
  1791 void ConstantPool::set_on_stack(const bool value) {
  1792   if (value) {
  1792   if (value) {
  1793     int old_flags = *const_cast<volatile int *>(&_flags);
  1793     // Only record if it's not already set.
  1794     while ((old_flags & _on_stack) == 0) {
  1794     if (!on_stack()) {
  1795       int new_flags = old_flags | _on_stack;
  1795       _flags |= _on_stack;
  1796       int result = Atomic::cmpxchg(new_flags, &_flags, old_flags);
  1796       MetadataOnStackMark::record(this);
  1797 
       
  1798       if (result == old_flags) {
       
  1799         // Succeeded.
       
  1800         MetadataOnStackMark::record(this, Thread::current());
       
  1801         return;
       
  1802       }
       
  1803       old_flags = result;
       
  1804     }
  1797     }
  1805   } else {
  1798   } else {
  1806     // Clearing is done single-threadedly.
  1799     // Clearing is done single-threadedly.
  1807     _flags &= ~_on_stack;
  1800     _flags &= ~_on_stack;
  1808   }
  1801   }