hotspot/src/share/vm/oops/constantPool.cpp
changeset 29576 c223b0a9872e
parent 29081 c61eb4914428
child 31038 2fd2fdc6a70a
--- a/hotspot/src/share/vm/oops/constantPool.cpp	Tue Mar 10 19:56:19 2015 -0700
+++ b/hotspot/src/share/vm/oops/constantPool.cpp	Fri Mar 13 12:40:39 2015 -0400
@@ -1790,17 +1790,10 @@
 
 void ConstantPool::set_on_stack(const bool value) {
   if (value) {
-    int old_flags = *const_cast<volatile int *>(&_flags);
-    while ((old_flags & _on_stack) == 0) {
-      int new_flags = old_flags | _on_stack;
-      int result = Atomic::cmpxchg(new_flags, &_flags, old_flags);
-
-      if (result == old_flags) {
-        // Succeeded.
-        MetadataOnStackMark::record(this, Thread::current());
-        return;
-      }
-      old_flags = result;
+    // Only record if it's not already set.
+    if (!on_stack()) {
+      _flags |= _on_stack;
+      MetadataOnStackMark::record(this);
     }
   } else {
     // Clearing is done single-threadedly.