# HG changeset patch # User Tom Rodriguez # Date 1412794080 25200 # Node ID 9928ad27a80e00fc2b30d3b23a15e08f74eff370 # Parent 467ffc7f01cb3d2a19569cf2a4b0ad5c65ca019d OopRecorder should check for duplicates diff -r 467ffc7f01cb -r 9928ad27a80e src/share/vm/code/oopRecorder.cpp --- 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 int ValueRecorder::_find_index_calls = 0; template int ValueRecorder::_hit_indexes = 0; template int ValueRecorder::_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 ValueRecorder::ValueRecorder(Arena* arena) { _handles = NULL; _indexes = NULL; diff -r 467ffc7f01cb -r 9928ad27a80e src/share/vm/code/oopRecorder.hpp --- 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);