--- old/src/share/vm/oops/constantPool.hpp Wed Nov 26 00:35:44 2014 +++ new/src/share/vm/oops/constantPool.hpp Wed Nov 26 00:35:43 2014 @@ -83,6 +83,12 @@ jobject _resolved_references; Array* _reference_map; + // Needed for JvmtiConstantPoolReconstituter. + // Map from a pseudo-string index to the original Utf8 entry index. + // Each u4 entry consist of two packed u2 integers: + // JVM_CONSTANT_String index and JVM_CONSTANT_Utf8 index + GrowableArray* _pseudo_string_map; + enum { _has_preresolution = 1, // Flags _on_stack = 2 @@ -160,6 +166,36 @@ Array* tags() const { return _tags; } Array* operands() const { return _operands; } + GrowableArray* pseudo_string_map() { + if (_pseudo_string_map == NULL) { + _pseudo_string_map = new(ResourceObj::C_HEAP, mtClass) GrowableArray(1, true); + } + return _pseudo_string_map; + } + + void map_pseudo_string_indices(u2 index, u2 utf8_idx) { + u4 packed = index << 16 | utf8_idx; + pseudo_string_map()->append(packed); + } + + u2 get_pseudo_string_utf8_index(u2 index) { + GrowableArray* map = pseudo_string_map(); + int len = map->length(); + // The entries are ordered by value so that a binary search can be + // used if a performance bottleneck is observed in this area. + for (int i = 0; i < len; i++) { + u4 packed = map->at(i); + u2 idx = (packed >> 16) & 0xFF; + if (idx == index) { + u2 utf8_idx = packed & 0xFF; + assert(utf8_idx > 0, "Utf8 cp index in pseudo-string map must be positive"); + return utf8_idx; + } + } + assert(true, "not found a matching entry in pseudo-string map"); + return 0; + } + bool has_preresolution() const { return (_flags & _has_preresolution) != 0; } void set_has_preresolution() { _flags |= _has_preresolution; }