8006040: NPG: on_stack processing wastes space in ConstantPool
Added on_stack bit to flags. Also MetadataMarkOnStack is used for more than JVMTI so had to be moved.
Reviewed-by: dholmes, stefank
diff --git a/hotspot/src/share/vm/oops/constantPool.hpp b/hotspot/src/share/vm/oops/constantPool.hpp
index 6554602..ea4b13f 100644
--- a/hotspot/src/share/vm/oops/constantPool.hpp
+++ b/hotspot/src/share/vm/oops/constantPool.hpp
@@ -95,10 +95,15 @@
jobject _resolved_references;
Array<u2>* _reference_map;
- int _flags; // a few header bits to describe contents for GC
- int _length; // number of elements in the array
+ enum {
+ _has_invokedynamic = 1, // Flags
+ _has_pseudo_string = 2,
+ _has_preresolution = 4,
+ _on_stack = 8
+ };
- bool _on_stack; // Redefined method still executing refers to this constant pool.
+ int _flags; // old fashioned bit twiddling
+ int _length; // number of elements in the array
union {
// set for CDS to restore resolved references
@@ -115,17 +120,8 @@
void set_operands(Array<u2>* operands) { _operands = operands; }
- enum FlagBit {
- FB_has_invokedynamic = 1,
- FB_has_pseudo_string = 2,
- FB_has_preresolution = 3
- };
-
- int flags() const { return _flags; }
- void set_flags(int f) { _flags = f; }
- bool flag_at(FlagBit fb) const { return (_flags & (1 << (int)fb)) != 0; }
- void set_flag_at(FlagBit fb);
- // no clear_flag_at function; they only increase
+ int flags() const { return _flags; }
+ void set_flags(int f) { _flags = f; }
private:
intptr_t* base() const { return (intptr_t*) (((char*) this) + sizeof(ConstantPool)); }
@@ -178,18 +174,20 @@
Array<u1>* tags() const { return _tags; }
Array<u2>* operands() const { return _operands; }
- bool has_pseudo_string() const { return flag_at(FB_has_pseudo_string); }
- bool has_invokedynamic() const { return flag_at(FB_has_invokedynamic); }
- bool has_preresolution() const { return flag_at(FB_has_preresolution); }
- void set_pseudo_string() { set_flag_at(FB_has_pseudo_string); }
- void set_invokedynamic() { set_flag_at(FB_has_invokedynamic); }
- void set_preresolution() { set_flag_at(FB_has_preresolution); }
+ bool has_invokedynamic() const { return (_flags & _has_invokedynamic) != 0; }
+ void set_has_invokedynamic() { _flags |= _has_invokedynamic; }
+
+ bool has_pseudo_string() const { return (_flags & _has_pseudo_string) != 0; }
+ void set_has_pseudo_string() { _flags |= _has_pseudo_string; }
+
+ bool has_preresolution() const { return (_flags & _has_preresolution) != 0; }
+ void set_has_preresolution() { _flags |= _has_preresolution; }
// Redefine classes support. If a method refering to this constant pool
// is on the executing stack, or as a handle in vm code, this constant pool
// can't be removed from the set of previous versions saved in the instance
// class.
- bool on_stack() const { return _on_stack; }
+ bool on_stack() const { return (_flags &_on_stack) != 0; }
void set_on_stack(const bool value);
// Klass holding pool
@@ -457,7 +455,7 @@
void pseudo_string_at_put(int which, int obj_index, oop x) {
assert(EnableInvokeDynamic, "");
- set_pseudo_string(); // mark header
+ set_has_pseudo_string(); // mark header
assert(tag_at(which).is_string(), "Corrupted constant pool");
string_at_put(which, obj_index, x); // this works just fine
}