hotspot/src/share/vm/oops/constantPoolOop.cpp
changeset 1550 be2fc37a817f
parent 1 489c9b5090e2
child 1623 a0dd9009e992
child 1889 24b003a6fe46
--- a/hotspot/src/share/vm/oops/constantPoolOop.cpp	Wed Nov 12 11:01:31 2008 -0800
+++ b/hotspot/src/share/vm/oops/constantPoolOop.cpp	Wed Nov 12 22:33:26 2008 -0800
@@ -25,6 +25,18 @@
 # include "incls/_precompiled.incl"
 # include "incls/_constantPoolOop.cpp.incl"
 
+void constantPoolOopDesc::set_flag_at(FlagBit fb) {
+  const int MAX_STATE_CHANGES = 2;
+  for (int i = MAX_STATE_CHANGES + 10; i > 0; i--) {
+    int oflags = _flags;
+    int nflags = oflags | (1 << (int)fb);
+    if (Atomic::cmpxchg(nflags, &_flags, oflags) == oflags)
+      return;
+  }
+  assert(false, "failed to cmpxchg flags");
+  _flags |= (1 << (int)fb);     // better than nothing
+}
+
 klassOop constantPoolOopDesc::klass_at_impl(constantPoolHandle this_oop, int which, TRAPS) {
   // A resolved constantPool entry will contain a klassOop, otherwise a symbolOop.
   // It is not safe to rely on the tag bit's here, since we don't have a lock, and the entry and
@@ -333,8 +345,10 @@
   oop entry = *(obj_at_addr(which));
   if (entry->is_symbol()) {
     return ((symbolOop)entry)->as_C_string();
+  } else if (java_lang_String::is_instance(entry)) {
+    return java_lang_String::as_utf8_string(entry);
   } else {
-    return java_lang_String::as_utf8_string(entry);
+    return (char*)"<pseudo-string>";
   }
 }
 
@@ -385,6 +399,19 @@
 }
 
 
+bool constantPoolOopDesc::is_pseudo_string_at(int which) {
+  oop entry = *(obj_at_addr(which));
+  if (entry->is_symbol())
+    // Not yet resolved, but it will resolve to a string.
+    return false;
+  else if (java_lang_String::is_instance(entry))
+    return false; // actually, it might be a non-interned or non-perm string
+  else
+    // truly pseudo
+    return true;
+}
+
+
 bool constantPoolOopDesc::klass_name_at_matches(instanceKlassHandle k,
                                                 int which) {
   // Names are interned, so we can compare symbolOops directly