equal
deleted
inserted
replaced
30 #include "classfile/systemDictionary.hpp" |
30 #include "classfile/systemDictionary.hpp" |
31 #include "classfile/vmSymbols.hpp" |
31 #include "classfile/vmSymbols.hpp" |
32 #include "interpreter/linkResolver.hpp" |
32 #include "interpreter/linkResolver.hpp" |
33 #include "memory/heapInspection.hpp" |
33 #include "memory/heapInspection.hpp" |
34 #include "memory/metadataFactory.hpp" |
34 #include "memory/metadataFactory.hpp" |
|
35 #include "memory/metaspaceClosure.hpp" |
35 #include "memory/oopFactory.hpp" |
36 #include "memory/oopFactory.hpp" |
36 #include "memory/resourceArea.hpp" |
37 #include "memory/resourceArea.hpp" |
37 #include "oops/constantPool.hpp" |
38 #include "oops/constantPool.hpp" |
38 #include "oops/instanceKlass.hpp" |
39 #include "oops/instanceKlass.hpp" |
39 #include "oops/objArrayKlass.hpp" |
40 #include "oops/objArrayKlass.hpp" |
46 #include "runtime/signature.hpp" |
47 #include "runtime/signature.hpp" |
47 #include "runtime/vframe.hpp" |
48 #include "runtime/vframe.hpp" |
48 #include "utilities/copy.hpp" |
49 #include "utilities/copy.hpp" |
49 |
50 |
50 ConstantPool* ConstantPool::allocate(ClassLoaderData* loader_data, int length, TRAPS) { |
51 ConstantPool* ConstantPool::allocate(ClassLoaderData* loader_data, int length, TRAPS) { |
51 Array<u1>* tags = MetadataFactory::new_writeable_array<u1>(loader_data, length, 0, CHECK_NULL); |
52 Array<u1>* tags = MetadataFactory::new_array<u1>(loader_data, length, 0, CHECK_NULL); |
52 int size = ConstantPool::size(length); |
53 int size = ConstantPool::size(length); |
53 return new (loader_data, size, true, MetaspaceObj::ConstantPoolType, THREAD) ConstantPool(tags); |
54 return new (loader_data, size, MetaspaceObj::ConstantPoolType, THREAD) ConstantPool(tags); |
54 } |
55 } |
55 |
56 |
56 #ifdef ASSERT |
57 #ifdef ASSERT |
57 |
58 |
58 // MetaspaceObj allocation invariant is calloc equivalent memory |
59 // MetaspaceObj allocation invariant is calloc equivalent memory |
104 } |
105 } |
105 |
106 |
106 void ConstantPool::release_C_heap_structures() { |
107 void ConstantPool::release_C_heap_structures() { |
107 // walk constant pool and decrement symbol reference counts |
108 // walk constant pool and decrement symbol reference counts |
108 unreference_symbols(); |
109 unreference_symbols(); |
|
110 } |
|
111 |
|
112 void ConstantPool::metaspace_pointers_do(MetaspaceClosure* it) { |
|
113 log_trace(cds)("Iter(ConstantPool): %p", this); |
|
114 |
|
115 it->push(&_tags, MetaspaceClosure::_writable); |
|
116 it->push(&_cache); |
|
117 it->push(&_pool_holder); |
|
118 it->push(&_operands); |
|
119 it->push(&_resolved_klasses, MetaspaceClosure::_writable); |
|
120 |
|
121 for (int i = 0; i < length(); i++) { |
|
122 // The only MSO's embedded in the CP entries are Symbols: |
|
123 // JVM_CONSTANT_String (normal and pseudo) |
|
124 // JVM_CONSTANT_Utf8 |
|
125 constantTag ctag = tag_at(i); |
|
126 if (ctag.is_string() || ctag.is_utf8()) { |
|
127 it->push(symbol_at_addr(i)); |
|
128 } |
|
129 } |
109 } |
130 } |
110 |
131 |
111 objArrayOop ConstantPool::resolved_references() const { |
132 objArrayOop ConstantPool::resolved_references() const { |
112 return (objArrayOop)JNIHandles::resolve(_cache->resolved_references()); |
133 return (objArrayOop)JNIHandles::resolve(_cache->resolved_references()); |
113 } |
134 } |
152 // entry for the class's name. So at most we will have 0xfffe class entries. |
173 // entry for the class's name. So at most we will have 0xfffe class entries. |
153 // This allows us to use 0xffff (ConstantPool::_temp_resolved_klass_index) to indicate |
174 // This allows us to use 0xffff (ConstantPool::_temp_resolved_klass_index) to indicate |
154 // UnresolvedKlass entries that are temporarily created during class redefinition. |
175 // UnresolvedKlass entries that are temporarily created during class redefinition. |
155 assert(num_klasses < CPKlassSlot::_temp_resolved_klass_index, "sanity"); |
176 assert(num_klasses < CPKlassSlot::_temp_resolved_klass_index, "sanity"); |
156 assert(resolved_klasses() == NULL, "sanity"); |
177 assert(resolved_klasses() == NULL, "sanity"); |
157 Array<Klass*>* rk = MetadataFactory::new_writeable_array<Klass*>(loader_data, num_klasses, CHECK); |
178 Array<Klass*>* rk = MetadataFactory::new_array<Klass*>(loader_data, num_klasses, CHECK); |
158 set_resolved_klasses(rk); |
179 set_resolved_klasses(rk); |
159 } |
180 } |
160 |
181 |
161 void ConstantPool::initialize_unresolved_klasses(ClassLoaderData* loader_data, TRAPS) { |
182 void ConstantPool::initialize_unresolved_klasses(ClassLoaderData* loader_data, TRAPS) { |
162 int len = length(); |
183 int len = length(); |