< prev index next >

src/share/vm/prims/jvmtiTagMap.cpp

Print this page
rev 12906 : [mq]: gc_interface

@@ -32,15 +32,17 @@
 #include "memory/resourceArea.hpp"
 #include "oops/instanceMirrorKlass.hpp"
 #include "oops/objArrayKlass.hpp"
 #include "oops/objArrayOop.inline.hpp"
 #include "oops/oop.inline.hpp"
+#include "oops/typeArrayOop.inline.hpp"
 #include "prims/jvmtiEventController.hpp"
 #include "prims/jvmtiEventController.inline.hpp"
 #include "prims/jvmtiExport.hpp"
 #include "prims/jvmtiImpl.hpp"
 #include "prims/jvmtiTagMap.hpp"
+#include "runtime/access.inline.hpp"
 #include "runtime/biasedLocking.hpp"
 #include "runtime/javaCalls.hpp"
 #include "runtime/jniHandles.hpp"
 #include "runtime/mutex.hpp"
 #include "runtime/mutexLocker.hpp"

@@ -48,14 +50,10 @@
 #include "runtime/vframe.hpp"
 #include "runtime/vmThread.hpp"
 #include "runtime/vm_operations.hpp"
 #include "services/serviceUtil.hpp"
 #include "utilities/macros.hpp"
-#if INCLUDE_ALL_GCS
-#include "gc/g1/g1SATBCardTableModRefBS.hpp"
-#include "gc/parallel/parallelScavengeHeap.hpp"
-#endif // INCLUDE_ALL_GCS
 
 // JvmtiTagHashmapEntry
 //
 // Each entry encapsulates a reference to the tagged object
 // and the tag value. In addition an entry includes a next pointer which

@@ -79,19 +77,25 @@
   JvmtiTagHashmapEntry(oop object, jlong tag)         { init(object, tag); }
 
  public:
 
   // accessor methods
-  inline oop object() const                           { return _object; }
   inline oop* object_addr()                           { return &_object; }
+  inline oop object()             { return RootAccess<GC_ACCESS_ON_PHANTOM>::oop_load(object_addr()); }
+  // Load the object weakly. The returned object is not allowed to be seen by the GC.
+  inline oop load_object_weakly() { return RootAccess<ACCESS_WEAK | GC_ACCESS_ON_PHANTOM>::oop_load(object_addr()); }
   inline jlong tag() const                            { return _tag; }
 
   inline void set_tag(jlong tag) {
     assert(tag != 0, "can't be zero");
     _tag = tag;
   }
 
+  inline bool equals(oop object) {
+    return object == load_object_weakly();
+  }
+
   inline JvmtiTagHashmapEntry* next() const             { return _next; }
   inline void set_next(JvmtiTagHashmapEntry* next)      { _next = next; }
 };
 
 

@@ -207,11 +211,11 @@
     // rehash all entries into the new table
     for (i=0; i<_size; i++) {
       JvmtiTagHashmapEntry* entry = _table[i];
       while (entry != NULL) {
         JvmtiTagHashmapEntry* next = entry->next();
-        oop key = entry->object();
+        oop key = entry->load_object_weakly();
         assert(key != NULL, "jni weak reference cleared!!");
         unsigned int h = hash(key, new_size);
         JvmtiTagHashmapEntry* anchor = new_table[h];
         if (anchor == NULL) {
           new_table[h] = entry;

@@ -300,11 +304,11 @@
   // find an entry in the hashmap, returns NULL if not found.
   inline JvmtiTagHashmapEntry* find(oop key) {
     unsigned int h = hash(key);
     JvmtiTagHashmapEntry* entry = _table[h];
     while (entry != NULL) {
-      if (entry->object() == key) {
+      if (entry->equals(key)) {
          return entry;
       }
       entry = entry->next();
     }
     return NULL;

@@ -1531,20 +1535,16 @@
   // and record the reference and tag value.
   //
   void do_entry(JvmtiTagHashmapEntry* entry) {
     for (int i=0; i<_tag_count; i++) {
       if (_tags[i] == entry->tag()) {
-        oop o = entry->object();
-        assert(o != NULL && Universe::heap()->is_in_reserved(o), "sanity check");
-#if INCLUDE_ALL_GCS
-        if (UseG1GC) {
+        oop* p = entry->object_addr();
           // The reference in this tag map could be the only (implicitly weak)
           // reference to that object. If we hand it out, we need to keep it live wrt
           // SATB marking similar to other j.l.ref.Reference referents.
-          G1SATBCardTableModRefBS::enqueue(o);
-        }
-#endif
+        oop o = RootAccess<GC_ACCESS_ON_PHANTOM>::oop_load(p);
+        assert(o != NULL && Universe::heap()->is_in_reserved(o), "sanity check");
         jobject ref = JNIHandles::make_local(JavaThread::current(), o);
         _object_results->append(ref);
         _tag_results->append((uint64_t)entry->tag());
       }
     }

@@ -3360,14 +3360,12 @@
     JvmtiTagHashmapEntry* prev = NULL;
 
     while (entry != NULL) {
       JvmtiTagHashmapEntry* next = entry->next();
 
-      oop* obj = entry->object_addr();
-
       // has object been GC'ed
-      if (!is_alive->do_object_b(entry->object())) {
+      if (!is_alive->do_object_b(entry->load_object_weakly())) {
         // grab the tag
         jlong tag = entry->tag();
         guarantee(tag != 0, "checking");
 
         // remove GC'ed entry from hashmap and return the

@@ -3381,11 +3379,11 @@
         }
 
         ++freed;
       } else {
         f->do_oop(entry->object_addr());
-        oop new_oop = entry->object();
+        oop new_oop = entry->load_object_weakly();
 
         // if the object has moved then re-hash it and move its
         // entry to its new location.
         unsigned int new_pos = JvmtiTagHashmap::hash(new_oop, size);
         if (new_pos != (unsigned int)pos) {

@@ -3415,11 +3413,11 @@
   }
 
   // Re-add all the entries which were kept aside
   while (delayed_add != NULL) {
     JvmtiTagHashmapEntry* next = delayed_add->next();
-    unsigned int pos = JvmtiTagHashmap::hash(delayed_add->object(), size);
+    unsigned int pos = JvmtiTagHashmap::hash(delayed_add->load_object_weakly(), size);
     delayed_add->set_next(table[pos]);
     table[pos] = delayed_add;
     delayed_add = next;
   }
 
< prev index next >