< prev index next >
src/share/vm/prims/jvmtiTagMap.cpp
Print this page
rev 12906 : [mq]: gc_interface
*** 32,46 ****
--- 32,48 ----
#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,61 ****
#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
--- 50,59 ----
*** 79,97 ****
JvmtiTagHashmapEntry(oop object, jlong tag) { init(object, tag); }
public:
// accessor methods
- inline oop object() const { return _object; }
inline oop* object_addr() { return &_object; }
inline jlong tag() const { return _tag; }
inline void set_tag(jlong tag) {
assert(tag != 0, "can't be zero");
_tag = tag;
}
inline JvmtiTagHashmapEntry* next() const { return _next; }
inline void set_next(JvmtiTagHashmapEntry* next) { _next = next; }
};
--- 77,101 ----
JvmtiTagHashmapEntry(oop object, jlong tag) { init(object, tag); }
public:
// accessor methods
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,217 ****
// 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();
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;
--- 211,221 ----
// 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->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,310 ****
// 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) {
return entry;
}
entry = entry->next();
}
return NULL;
--- 304,314 ----
// 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->equals(key)) {
return entry;
}
entry = entry->next();
}
return NULL;
*** 1531,1550 ****
// 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) {
// 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
jobject ref = JNIHandles::make_local(JavaThread::current(), o);
_object_results->append(ref);
_tag_results->append((uint64_t)entry->tag());
}
}
--- 1535,1550 ----
// 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* 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.
! 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,3373 ****
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())) {
// grab the tag
jlong tag = entry->tag();
guarantee(tag != 0, "checking");
// remove GC'ed entry from hashmap and return the
--- 3360,3371 ----
JvmtiTagHashmapEntry* prev = NULL;
while (entry != NULL) {
JvmtiTagHashmapEntry* next = entry->next();
// has object been GC'ed
! 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,3391 ****
}
++freed;
} else {
f->do_oop(entry->object_addr());
! oop new_oop = entry->object();
// 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) {
--- 3379,3389 ----
}
++freed;
} else {
f->do_oop(entry->object_addr());
! 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,3425 ****
}
// 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);
delayed_add->set_next(table[pos]);
table[pos] = delayed_add;
delayed_add = next;
}
--- 3413,3423 ----
}
// 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->load_object_weakly(), size);
delayed_add->set_next(table[pos]);
table[pos] = delayed_add;
delayed_add = next;
}
< prev index next >