src/share/vm/oops/constantPool.cpp

changeset 7333
b12a2a9b05ca
parent 6680
78bbf4d43a14
child 7535
7ae4e26cb1e0
child 9327
f96fcd9e1e1b
equal deleted inserted replaced
7332:7024b693c8f9 7333:b12a2a9b05ca
1815 #undef DBG 1815 #undef DBG
1816 1816
1817 1817
1818 void ConstantPool::set_on_stack(const bool value) { 1818 void ConstantPool::set_on_stack(const bool value) {
1819 if (value) { 1819 if (value) {
1820 _flags |= _on_stack; 1820 int old_flags = *const_cast<volatile int *>(&_flags);
1821 while ((old_flags & _on_stack) == 0) {
1822 int new_flags = old_flags | _on_stack;
1823 int result = Atomic::cmpxchg(new_flags, &_flags, old_flags);
1824
1825 if (result == old_flags) {
1826 // Succeeded.
1827 MetadataOnStackMark::record(this, Thread::current());
1828 return;
1829 }
1830 old_flags = result;
1831 }
1821 } else { 1832 } else {
1833 // Clearing is done single-threadedly.
1822 _flags &= ~_on_stack; 1834 _flags &= ~_on_stack;
1823 } 1835 }
1824 if (value) MetadataOnStackMark::record(this);
1825 } 1836 }
1826 1837
1827 // JSR 292 support for patching constant pool oops after the class is linked and 1838 // JSR 292 support for patching constant pool oops after the class is linked and
1828 // the oop array for resolved references are created. 1839 // the oop array for resolved references are created.
1829 // We can't do this during classfile parsing, which is how the other indexes are 1840 // We can't do this during classfile parsing, which is how the other indexes are

mercurial