aboutsummaryrefslogtreecommitdiff
path: root/src/share/vm/oops/constantPool.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/share/vm/oops/constantPool.cpp')
-rw-r--r--src/share/vm/oops/constantPool.cpp105
1 files changed, 60 insertions, 45 deletions
diff --git a/src/share/vm/oops/constantPool.cpp b/src/share/vm/oops/constantPool.cpp
index 770510c78..1c21420c2 100644
--- a/src/share/vm/oops/constantPool.cpp
+++ b/src/share/vm/oops/constantPool.cpp
@@ -25,16 +25,17 @@
#include "precompiled.hpp"
#include "classfile/classLoaderData.hpp"
#include "classfile/javaClasses.hpp"
+#include "classfile/metadataOnStackMark.hpp"
#include "classfile/symbolTable.hpp"
#include "classfile/systemDictionary.hpp"
#include "classfile/vmSymbols.hpp"
#include "interpreter/linkResolver.hpp"
+#include "memory/heapInspection.hpp"
#include "memory/metadataFactory.hpp"
#include "memory/oopFactory.hpp"
#include "oops/constantPool.hpp"
#include "oops/instanceKlass.hpp"
#include "oops/objArrayKlass.hpp"
-#include "prims/jvmtiRedefineClasses.hpp"
#include "runtime/fieldType.hpp"
#include "runtime/init.hpp"
#include "runtime/javaCalls.hpp"
@@ -65,11 +66,10 @@ ConstantPool::ConstantPool(Array<u1>* tags) {
set_operands(NULL);
set_pool_holder(NULL);
set_flags(0);
+
// only set to non-zero if constant pool is merged by RedefineClasses
set_version(0);
set_lock(new Monitor(Monitor::nonleaf + 2, "A constant pool lock"));
- // all fields are initialized; needed for GC
- set_on_stack(false);
// initialize tag array
int length = tags->length();
@@ -100,18 +100,6 @@ void ConstantPool::release_C_heap_structures() {
set_lock(NULL);
}
-void ConstantPool::set_flag_at(FlagBit fb) {
- const int MAX_STATE_CHANGES = 2;
- for (int i = MAX_STATE_CHANGES + 10; i > 0; i--) {
- int oflags = _flags;
- int nflags = oflags | (1 << (int)fb);
- if (Atomic::cmpxchg(nflags, &_flags, oflags) == oflags)
- return;
- }
- assert(false, "failed to cmpxchg flags");
- _flags |= (1 << (int)fb); // better than nothing
-}
-
objArrayOop ConstantPool::resolved_references() const {
return (objArrayOop)JNIHandles::resolve(_resolved_references);
}
@@ -1111,32 +1099,9 @@ bool ConstantPool::compare_entry_to(int index1, constantPoolHandle cp2,
} // end compare_entry_to()
-// Copy this constant pool's entries at start_i to end_i (inclusive)
-// to the constant pool to_cp's entries starting at to_i. A total of
-// (end_i - start_i) + 1 entries are copied.
-void ConstantPool::copy_cp_to_impl(constantPoolHandle from_cp, int start_i, int end_i,
- constantPoolHandle to_cp, int to_i, TRAPS) {
-
- int dest_i = to_i; // leave original alone for debug purposes
-
- for (int src_i = start_i; src_i <= end_i; /* see loop bottom */ ) {
- copy_entry_to(from_cp, src_i, to_cp, dest_i, CHECK);
-
- switch (from_cp->tag_at(src_i).value()) {
- case JVM_CONSTANT_Double:
- case JVM_CONSTANT_Long:
- // double and long take two constant pool entries
- src_i += 2;
- dest_i += 2;
- break;
-
- default:
- // all others take one constant pool entry
- src_i++;
- dest_i++;
- break;
- }
- }
+void ConstantPool::copy_operands(constantPoolHandle from_cp,
+ constantPoolHandle to_cp,
+ TRAPS) {
int from_oplen = operand_array_length(from_cp->operands());
int old_oplen = operand_array_length(to_cp->operands());
@@ -1164,7 +1129,7 @@ void ConstantPool::copy_cp_to_impl(constantPoolHandle from_cp, int start_i, int
(len = old_off) * sizeof(u2));
fillp += len;
// first part of src
- Copy::conjoint_memory_atomic(to_cp->operands()->adr_at(0),
+ Copy::conjoint_memory_atomic(from_cp->operands()->adr_at(0),
new_operands->adr_at(fillp),
(len = from_off) * sizeof(u2));
fillp += len;
@@ -1174,7 +1139,7 @@ void ConstantPool::copy_cp_to_impl(constantPoolHandle from_cp, int start_i, int
(len = old_len - old_off) * sizeof(u2));
fillp += len;
// second part of src
- Copy::conjoint_memory_atomic(to_cp->operands()->adr_at(from_off),
+ Copy::conjoint_memory_atomic(from_cp->operands()->adr_at(from_off),
new_operands->adr_at(fillp),
(len = from_len - from_off) * sizeof(u2));
fillp += len;
@@ -1192,8 +1157,39 @@ void ConstantPool::copy_cp_to_impl(constantPoolHandle from_cp, int start_i, int
to_cp->set_operands(new_operands);
}
}
+} // end copy_operands()
-} // end copy_cp_to()
+
+// Copy this constant pool's entries at start_i to end_i (inclusive)
+// to the constant pool to_cp's entries starting at to_i. A total of
+// (end_i - start_i) + 1 entries are copied.
+void ConstantPool::copy_cp_to_impl(constantPoolHandle from_cp, int start_i, int end_i,
+ constantPoolHandle to_cp, int to_i, TRAPS) {
+
+
+ int dest_i = to_i; // leave original alone for debug purposes
+
+ for (int src_i = start_i; src_i <= end_i; /* see loop bottom */ ) {
+ copy_entry_to(from_cp, src_i, to_cp, dest_i, CHECK);
+
+ switch (from_cp->tag_at(src_i).value()) {
+ case JVM_CONSTANT_Double:
+ case JVM_CONSTANT_Long:
+ // double and long take two constant pool entries
+ src_i += 2;
+ dest_i += 2;
+ break;
+
+ default:
+ // all others take one constant pool entry
+ src_i++;
+ dest_i++;
+ break;
+ }
+ }
+ copy_operands(from_cp, to_cp, CHECK);
+
+} // end copy_cp_to_impl()
// Copy this constant pool's entry at from_i to the constant pool
@@ -1755,7 +1751,11 @@ int ConstantPool::copy_cpool_bytes(int cpool_size,
void ConstantPool::set_on_stack(const bool value) {
- _on_stack = value;
+ if (value) {
+ _flags |= _on_stack;
+ } else {
+ _flags &= ~_on_stack;
+ }
if (value) MetadataOnStackMark::record(this);
}
@@ -1827,6 +1827,7 @@ void ConstantPool::print_on(outputStream* st) const {
if (has_pseudo_string()) st->print(" has_pseudo_string");
if (has_invokedynamic()) st->print(" has_invokedynamic");
if (has_preresolution()) st->print(" has_preresolution");
+ if (on_stack()) st->print(" on_stack");
st->cr();
}
if (pool_holder() != NULL) {
@@ -1954,6 +1955,20 @@ void ConstantPool::print_value_on(outputStream* st) const {
}
}
+#if INCLUDE_SERVICES
+// Size Statistics
+void ConstantPool::collect_statistics(KlassSizeStats *sz) const {
+ sz->_cp_all_bytes += (sz->_cp_bytes = sz->count(this));
+ sz->_cp_all_bytes += (sz->_cp_tags_bytes = sz->count_array(tags()));
+ sz->_cp_all_bytes += (sz->_cp_cache_bytes = sz->count(cache()));
+ sz->_cp_all_bytes += (sz->_cp_operands_bytes = sz->count_array(operands()));
+ sz->_cp_all_bytes += (sz->_cp_refmap_bytes = sz->count_array(reference_map()));
+
+ sz->_ro_bytes += sz->_cp_operands_bytes + sz->_cp_tags_bytes +
+ sz->_cp_refmap_bytes;
+ sz->_rw_bytes += sz->_cp_bytes + sz->_cp_cache_bytes;
+}
+#endif // INCLUDE_SERVICES
// Verification