25 #include "precompiled.hpp"
26 #include "classfile/classLoaderData.hpp"
27 #include "classfile/javaClasses.hpp"
28 #include "classfile/metadataOnStackMark.hpp"
29 #include "classfile/symbolTable.hpp"
30 #include "classfile/systemDictionary.hpp"
31 #include "classfile/vmSymbols.hpp"
32 #include "interpreter/linkResolver.hpp"
33 #include "memory/heapInspection.hpp"
34 #include "memory/metadataFactory.hpp"
35 #include "memory/oopFactory.hpp"
36 #include "oops/constantPool.hpp"
37 #include "oops/instanceKlass.hpp"
38 #include "oops/objArrayKlass.hpp"
39 #include "runtime/fieldType.hpp"
40 #include "runtime/init.hpp"
41 #include "runtime/javaCalls.hpp"
42 #include "runtime/signature.hpp"
43 #include "runtime/vframe.hpp"
44
45 ConstantPool* ConstantPool::allocate(ClassLoaderData* loader_data, int length, TRAPS) {
46 // Tags are RW but comment below applies to tags also.
47 Array<u1>* tags = MetadataFactory::new_writeable_array<u1>(loader_data, length, 0, CHECK_NULL);
48
49 int size = ConstantPool::size(length);
50
51 // CDS considerations:
52 // Allocate read-write but may be able to move to read-only at dumping time
53 // if all the klasses are resolved. The only other field that is writable is
54 // the resolved_references array, which is recreated at startup time.
55 // But that could be moved to InstanceKlass (although a pain to access from
56 // assembly code). Maybe it could be moved to the cpCache which is RW.
57 return new (loader_data, size, false, MetaspaceObj::ConstantPoolType, THREAD) ConstantPool(tags);
58 }
59
60 ConstantPool::ConstantPool(Array<u1>* tags) {
61 set_length(tags->length());
62 set_tags(NULL);
63 set_cache(NULL);
64 set_reference_map(NULL);
1866
1867 for (int i = 0; i< cp->length(); i++) {
1868 if (cp->tag_at(i).is_unresolved_klass()) {
1869 // This will force loading of the class
1870 Klass* klass = cp->klass_at(i, CHECK);
1871 if (klass->oop_is_instance()) {
1872 // Force initialization of class
1873 InstanceKlass::cast(klass)->initialize(CHECK);
1874 }
1875 }
1876 }
1877 }
1878
1879 #endif
1880
1881
1882 // Printing
1883
1884 void ConstantPool::print_on(outputStream* st) const {
1885 assert(is_constantPool(), "must be constantPool");
1886 st->print_cr(internal_name());
1887 if (flags() != 0) {
1888 st->print(" - flags: 0x%x", flags());
1889 if (has_preresolution()) st->print(" has_preresolution");
1890 if (on_stack()) st->print(" on_stack");
1891 st->cr();
1892 }
1893 if (pool_holder() != NULL) {
1894 st->print_cr(" - holder: " INTPTR_FORMAT, pool_holder());
1895 }
1896 st->print_cr(" - cache: " INTPTR_FORMAT, cache());
1897 st->print_cr(" - resolved_references: " INTPTR_FORMAT, (void *)resolved_references());
1898 st->print_cr(" - reference_map: " INTPTR_FORMAT, reference_map());
1899
1900 for (int index = 1; index < length(); index++) { // Index 0 is unused
1901 ((ConstantPool*)this)->print_entry_on(index, st);
1902 switch (tag_at(index).value()) {
1903 case JVM_CONSTANT_Long :
1904 case JVM_CONSTANT_Double :
1905 index++; // Skip entry following eigth-byte constant
1906 }
|
25 #include "precompiled.hpp"
26 #include "classfile/classLoaderData.hpp"
27 #include "classfile/javaClasses.hpp"
28 #include "classfile/metadataOnStackMark.hpp"
29 #include "classfile/symbolTable.hpp"
30 #include "classfile/systemDictionary.hpp"
31 #include "classfile/vmSymbols.hpp"
32 #include "interpreter/linkResolver.hpp"
33 #include "memory/heapInspection.hpp"
34 #include "memory/metadataFactory.hpp"
35 #include "memory/oopFactory.hpp"
36 #include "oops/constantPool.hpp"
37 #include "oops/instanceKlass.hpp"
38 #include "oops/objArrayKlass.hpp"
39 #include "runtime/fieldType.hpp"
40 #include "runtime/init.hpp"
41 #include "runtime/javaCalls.hpp"
42 #include "runtime/signature.hpp"
43 #include "runtime/vframe.hpp"
44
45 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
46
47 ConstantPool* ConstantPool::allocate(ClassLoaderData* loader_data, int length, TRAPS) {
48 // Tags are RW but comment below applies to tags also.
49 Array<u1>* tags = MetadataFactory::new_writeable_array<u1>(loader_data, length, 0, CHECK_NULL);
50
51 int size = ConstantPool::size(length);
52
53 // CDS considerations:
54 // Allocate read-write but may be able to move to read-only at dumping time
55 // if all the klasses are resolved. The only other field that is writable is
56 // the resolved_references array, which is recreated at startup time.
57 // But that could be moved to InstanceKlass (although a pain to access from
58 // assembly code). Maybe it could be moved to the cpCache which is RW.
59 return new (loader_data, size, false, MetaspaceObj::ConstantPoolType, THREAD) ConstantPool(tags);
60 }
61
62 ConstantPool::ConstantPool(Array<u1>* tags) {
63 set_length(tags->length());
64 set_tags(NULL);
65 set_cache(NULL);
66 set_reference_map(NULL);
1868
1869 for (int i = 0; i< cp->length(); i++) {
1870 if (cp->tag_at(i).is_unresolved_klass()) {
1871 // This will force loading of the class
1872 Klass* klass = cp->klass_at(i, CHECK);
1873 if (klass->oop_is_instance()) {
1874 // Force initialization of class
1875 InstanceKlass::cast(klass)->initialize(CHECK);
1876 }
1877 }
1878 }
1879 }
1880
1881 #endif
1882
1883
1884 // Printing
1885
1886 void ConstantPool::print_on(outputStream* st) const {
1887 assert(is_constantPool(), "must be constantPool");
1888 st->print_raw_cr(internal_name());
1889 if (flags() != 0) {
1890 st->print(" - flags: 0x%x", flags());
1891 if (has_preresolution()) st->print(" has_preresolution");
1892 if (on_stack()) st->print(" on_stack");
1893 st->cr();
1894 }
1895 if (pool_holder() != NULL) {
1896 st->print_cr(" - holder: " INTPTR_FORMAT, pool_holder());
1897 }
1898 st->print_cr(" - cache: " INTPTR_FORMAT, cache());
1899 st->print_cr(" - resolved_references: " INTPTR_FORMAT, (void *)resolved_references());
1900 st->print_cr(" - reference_map: " INTPTR_FORMAT, reference_map());
1901
1902 for (int index = 1; index < length(); index++) { // Index 0 is unused
1903 ((ConstantPool*)this)->print_entry_on(index, st);
1904 switch (tag_at(index).value()) {
1905 case JVM_CONSTANT_Long :
1906 case JVM_CONSTANT_Double :
1907 index++; // Skip entry following eigth-byte constant
1908 }
|