Mercurial > hg > truffle
diff src/share/vm/code/oopRecorder.hpp @ 17375:44b83285b645
Deduplicate constant oops during code installation
author | Tom Rodriguez <tom.rodriguez@oracle.com> |
---|---|
date | Wed, 08 Oct 2014 11:50:00 -0700 |
parents | 9928ad27a80e |
children | 50942f016967 |
line wrap: on
line diff
--- a/src/share/vm/code/oopRecorder.hpp Wed Oct 08 11:48:00 2014 -0700 +++ b/src/share/vm/code/oopRecorder.hpp Wed Oct 08 11:50:00 2014 -0700 @@ -146,12 +146,51 @@ #endif }; +class OopRecorder; + +class ObjectLookup : public ResourceObj { + private: + class ObjectEntry { + private: + jobject _value; + int _index; + + public: + ObjectEntry(jobject value, int index): _value(value), _index(index) {} + ObjectEntry() {} + oop oop_value(); // { return JNIHandles::resolve(_value); } + int index() { return _index; } + }; + + GrowableArray<ObjectEntry> _values; + unsigned int _gc_count; + + // Utility sort functions + static int sort_by_address(oop a, oop b); + static int sort_by_address(ObjectEntry* a, ObjectEntry* b); + static int sort_oop_by_address(oop a, ObjectEntry b); + + public: + ObjectLookup(); + + // Resort list if a GC has occurred since the last sort + void maybe_resort(); + int find_index(jobject object, OopRecorder* oop_recorder); +}; + class OopRecorder : public ResourceObj { private: ValueRecorder<jobject> _oops; ValueRecorder<Metadata*> _metadata; + ObjectLookup* _object_lookup; public: - OopRecorder(Arena* arena = NULL): _oops(arena), _metadata(arena) {} + OopRecorder(Arena* arena = NULL, bool deduplicate = false): _oops(arena), _metadata(arena) { + if (deduplicate) { + _object_lookup = new ObjectLookup(); + } else { + _object_lookup = NULL; + } + } void check_for_duplicates(int index, jobject h) NOT_DEBUG_RETURN; @@ -159,7 +198,7 @@ return _oops.allocate_index(h); } int find_index(jobject h) { - int result = _oops.find_index(h); + int result = _object_lookup != NULL ? _object_lookup->find_index(h, this) : _oops.find_index(h); check_for_duplicates(result, h); return result; }