changeset 17374:9928ad27a80e

OopRecorder should check for duplicates
author Tom Rodriguez <tom.rodriguez@oracle.com>
date Wed, 08 Oct 2014 11:48:00 -0700
parents 467ffc7f01cb
children 44b83285b645
files src/share/vm/code/oopRecorder.cpp src/share/vm/code/oopRecorder.hpp
diffstat 2 files changed, 14 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/code/oopRecorder.cpp	Wed Oct 08 11:46:00 2014 -0700
+++ b/src/share/vm/code/oopRecorder.cpp	Wed Oct 08 11:48:00 2014 -0700
@@ -34,9 +34,17 @@
 template <class T> int ValueRecorder<T>::_find_index_calls = 0;
 template <class T> int ValueRecorder<T>::_hit_indexes      = 0;
 template <class T> int ValueRecorder<T>::_missed_indexes   = 0;
+
+void OopRecorder::check_for_duplicates(int index, jobject h) {
+  oop o = JNIHandles::resolve(h);
+  for (int i = 1; i < oop_count(); i++) {
+    if (o == JNIHandles::resolve(oop_at(i)) && index != i) {
+      assert(false, "duplicate found");
+    }
+  }
+}
 #endif //ASSERT
 
-
 template <class T> ValueRecorder<T>::ValueRecorder(Arena* arena) {
   _handles  = NULL;
   _indexes  = NULL;
--- a/src/share/vm/code/oopRecorder.hpp	Wed Oct 08 11:46:00 2014 -0700
+++ b/src/share/vm/code/oopRecorder.hpp	Wed Oct 08 11:48:00 2014 -0700
@@ -153,11 +153,15 @@
  public:
   OopRecorder(Arena* arena = NULL): _oops(arena), _metadata(arena) {}
 
+  void check_for_duplicates(int index, jobject h) NOT_DEBUG_RETURN;
+
   int allocate_oop_index(jobject h) {
     return _oops.allocate_index(h);
   }
   int find_index(jobject h) {
-    return _oops.find_index(h);
+    int result = _oops.find_index(h);
+    check_for_duplicates(result, h);
+    return result;
   }
   jobject oop_at(int index) {
     return _oops.at(index);