218 }
219 }
220 allocate_resolved_klasses(loader_data, num_klasses, THREAD);
221 }
222
223 // Unsafe anonymous class support:
224 void ConstantPool::klass_at_put(int class_index, int name_index, int resolved_klass_index, Klass* k, Symbol* name) {
225 assert(is_within_bounds(class_index), "index out of bounds");
226 assert(is_within_bounds(name_index), "index out of bounds");
227 assert((resolved_klass_index & 0xffff0000) == 0, "must be");
228 *int_at_addr(class_index) =
229 build_int_from_shorts((jushort)resolved_klass_index, (jushort)name_index);
230
231 symbol_at_put(name_index, name);
232 name->increment_refcount();
233 Klass** adr = resolved_klasses()->adr_at(resolved_klass_index);
234 OrderAccess::release_store(adr, k);
235
236 // The interpreter assumes when the tag is stored, the klass is resolved
237 // and the Klass* non-NULL, so we need hardware store ordering here.
238 jbyte qdesc_bit = name->is_Q_signature() ? (jbyte)JVM_CONSTANT_QDESC_BIT : 0;
239 if (k != NULL) {
240 release_tag_at_put(class_index, JVM_CONSTANT_Class | qdesc_bit);
241 } else {
242 release_tag_at_put(class_index, JVM_CONSTANT_UnresolvedClass | qdesc_bit);
243 }
244 }
245
246 // Unsafe anonymous class support:
247 void ConstantPool::klass_at_put(int class_index, Klass* k) {
248 assert(k != NULL, "must be valid klass");
249 CPKlassSlot kslot = klass_slot_at(class_index);
250 int resolved_klass_index = kslot.resolved_klass_index();
251 Klass** adr = resolved_klasses()->adr_at(resolved_klass_index);
252 OrderAccess::release_store(adr, k);
253
254 // The interpreter assumes when the tag is stored, the klass is resolved
255 // and the Klass* non-NULL, so we need hardware store ordering here.
256 release_tag_at_put(class_index, JVM_CONSTANT_Class);
257 }
258
259 #if INCLUDE_CDS_JAVA_HEAP
260 // Archive the resolved references
261 void ConstantPool::archive_resolved_references(Thread* THREAD) {
262 if (_cache == NULL) {
263 return; // nothing to do
264 }
265
266 InstanceKlass *ik = pool_holder();
267 if (!(ik->is_shared_boot_class() || ik->is_shared_platform_class() ||
268 ik->is_shared_app_class())) {
269 // Archiving resolved references for classes from non-builtin loaders
270 // is not yet supported.
271 set_resolved_references(NULL);
272 return;
273 }
274
275 objArrayOop rr = resolved_references();
1970 case JVM_CONSTANT_Long: {
1971 u8 val = Bytes::get_Java_u8(bytes);
1972 printf("long " INT64_FORMAT, (int64_t) *(jlong *) &val);
1973 ent_size = 8;
1974 idx++; // Long takes two cpool slots
1975 break;
1976 }
1977 case JVM_CONSTANT_Double: {
1978 u8 val = Bytes::get_Java_u8(bytes);
1979 printf("double %5.3fd", *(jdouble *)&val);
1980 ent_size = 8;
1981 idx++; // Double takes two cpool slots
1982 break;
1983 }
1984 case JVM_CONSTANT_Class: {
1985 idx1 = Bytes::get_Java_u2(bytes);
1986 printf("class #%03d", idx1);
1987 ent_size = 2;
1988 break;
1989 }
1990 case JVM_CONSTANT_String: {
1991 idx1 = Bytes::get_Java_u2(bytes);
1992 printf("String #%03d", idx1);
1993 ent_size = 2;
1994 break;
1995 }
1996 case JVM_CONSTANT_Fieldref: {
1997 idx1 = Bytes::get_Java_u2(bytes);
1998 idx2 = Bytes::get_Java_u2(bytes+2);
1999 printf("Field #%03d, #%03d", (int) idx1, (int) idx2);
2000 ent_size = 4;
2001 break;
2002 }
2003 case JVM_CONSTANT_Methodref: {
2004 idx1 = Bytes::get_Java_u2(bytes);
2005 idx2 = Bytes::get_Java_u2(bytes+2);
2006 printf("Method #%03d, #%03d", idx1, idx2);
2007 ent_size = 4;
2008 break;
2009 }
2012 idx2 = Bytes::get_Java_u2(bytes+2);
2013 printf("InterfMethod #%03d, #%03d", idx1, idx2);
2014 ent_size = 4;
2015 break;
2016 }
2017 case JVM_CONSTANT_NameAndType: {
2018 idx1 = Bytes::get_Java_u2(bytes);
2019 idx2 = Bytes::get_Java_u2(bytes+2);
2020 printf("NameAndType #%03d, #%03d", idx1, idx2);
2021 ent_size = 4;
2022 break;
2023 }
2024 case JVM_CONSTANT_ClassIndex: {
2025 printf("ClassIndex %s", WARN_MSG);
2026 break;
2027 }
2028 case JVM_CONSTANT_UnresolvedClass: {
2029 printf("UnresolvedClass: %s", WARN_MSG);
2030 break;
2031 }
2032 case JVM_CONSTANT_UnresolvedClassInError: {
2033 printf("UnresolvedClassInErr: %s", WARN_MSG);
2034 break;
2035 }
2036 case JVM_CONSTANT_StringIndex: {
2037 printf("StringIndex: %s", WARN_MSG);
2038 break;
2039 }
2040 }
2041 printf(";\n");
2042 bytes += ent_size;
2043 size += ent_size;
2044 }
2045 printf("Cpool size: %d\n", size);
2046 fflush(0);
2047 return;
2048 } /* end print_cpool_bytes */
2049
2050
2051 // Returns size of constant pool entry.
2183 case JVM_CONSTANT_Float: {
2184 jfloat val = float_at(idx);
2185 Bytes::put_Java_u4((address) (bytes+1), *(u4*)&val);
2186 break;
2187 }
2188 case JVM_CONSTANT_Long: {
2189 jlong val = long_at(idx);
2190 Bytes::put_Java_u8((address) (bytes+1), *(u8*)&val);
2191 idx++; // Long takes two cpool slots
2192 break;
2193 }
2194 case JVM_CONSTANT_Double: {
2195 jdouble val = double_at(idx);
2196 Bytes::put_Java_u8((address) (bytes+1), *(u8*)&val);
2197 idx++; // Double takes two cpool slots
2198 break;
2199 }
2200 case JVM_CONSTANT_Class:
2201 case JVM_CONSTANT_UnresolvedClass:
2202 case JVM_CONSTANT_UnresolvedClassInError: {
2203 *bytes = JVM_CONSTANT_Class;
2204 Symbol* sym = klass_name_at(idx);
2205 idx1 = tbl->symbol_to_value(sym);
2206 assert(idx1 != 0, "Have not found a hashtable entry");
2207 Bytes::put_Java_u2((address) (bytes+1), idx1);
2208 DBG(printf("JVM_CONSTANT_Class: idx=#%03hd, %s", idx1, sym->as_utf8()));
2209 break;
2210 }
2211 case JVM_CONSTANT_String: {
2212 *bytes = JVM_CONSTANT_String;
2213 Symbol* sym = unresolved_string_at(idx);
2214 idx1 = tbl->symbol_to_value(sym);
2215 assert(idx1 != 0, "Have not found a hashtable entry");
2216 Bytes::put_Java_u2((address) (bytes+1), idx1);
2217 DBG(printf("JVM_CONSTANT_String: idx=#%03hd, %s", idx1, sym->as_utf8()));
2218 break;
2219 }
2220 case JVM_CONSTANT_Fieldref:
2221 case JVM_CONSTANT_Methodref:
2222 case JVM_CONSTANT_InterfaceMethodref: {
|
218 }
219 }
220 allocate_resolved_klasses(loader_data, num_klasses, THREAD);
221 }
222
223 // Unsafe anonymous class support:
224 void ConstantPool::klass_at_put(int class_index, int name_index, int resolved_klass_index, Klass* k, Symbol* name) {
225 assert(is_within_bounds(class_index), "index out of bounds");
226 assert(is_within_bounds(name_index), "index out of bounds");
227 assert((resolved_klass_index & 0xffff0000) == 0, "must be");
228 *int_at_addr(class_index) =
229 build_int_from_shorts((jushort)resolved_klass_index, (jushort)name_index);
230
231 symbol_at_put(name_index, name);
232 name->increment_refcount();
233 Klass** adr = resolved_klasses()->adr_at(resolved_klass_index);
234 OrderAccess::release_store(adr, k);
235
236 // The interpreter assumes when the tag is stored, the klass is resolved
237 // and the Klass* non-NULL, so we need hardware store ordering here.
238 jbyte qdesc_bit = (name->is_Q_signature() || name->is_Q_array_signature()) ? (jbyte)JVM_CONSTANT_QDESC_BIT : 0;
239 if (k != NULL) {
240 release_tag_at_put(class_index, JVM_CONSTANT_Class | qdesc_bit);
241 } else {
242 release_tag_at_put(class_index, JVM_CONSTANT_UnresolvedClass | qdesc_bit);
243 }
244 }
245
246 // Unsafe anonymous class support:
247 void ConstantPool::klass_at_put(int class_index, Klass* k) {
248 assert(k != NULL, "must be valid klass");
249 CPKlassSlot kslot = klass_slot_at(class_index);
250 int resolved_klass_index = kslot.resolved_klass_index();
251 Klass** adr = resolved_klasses()->adr_at(resolved_klass_index);
252 OrderAccess::release_store(adr, k);
253
254 // The interpreter assumes when the tag is stored, the klass is resolved
255 // and the Klass* non-NULL, so we need hardware store ordering here.
256 assert(!(k->name()->is_Q_signature() || k->name()->is_Q_array_signature()), "Q-type without JVM_CONSTANT_QDESC_BIT");
257 release_tag_at_put(class_index, JVM_CONSTANT_Class);
258 }
259
260 #if INCLUDE_CDS_JAVA_HEAP
261 // Archive the resolved references
262 void ConstantPool::archive_resolved_references(Thread* THREAD) {
263 if (_cache == NULL) {
264 return; // nothing to do
265 }
266
267 InstanceKlass *ik = pool_holder();
268 if (!(ik->is_shared_boot_class() || ik->is_shared_platform_class() ||
269 ik->is_shared_app_class())) {
270 // Archiving resolved references for classes from non-builtin loaders
271 // is not yet supported.
272 set_resolved_references(NULL);
273 return;
274 }
275
276 objArrayOop rr = resolved_references();
1971 case JVM_CONSTANT_Long: {
1972 u8 val = Bytes::get_Java_u8(bytes);
1973 printf("long " INT64_FORMAT, (int64_t) *(jlong *) &val);
1974 ent_size = 8;
1975 idx++; // Long takes two cpool slots
1976 break;
1977 }
1978 case JVM_CONSTANT_Double: {
1979 u8 val = Bytes::get_Java_u8(bytes);
1980 printf("double %5.3fd", *(jdouble *)&val);
1981 ent_size = 8;
1982 idx++; // Double takes two cpool slots
1983 break;
1984 }
1985 case JVM_CONSTANT_Class: {
1986 idx1 = Bytes::get_Java_u2(bytes);
1987 printf("class #%03d", idx1);
1988 ent_size = 2;
1989 break;
1990 }
1991 case (JVM_CONSTANT_Class | JVM_CONSTANT_QDESC_BIT): {
1992 idx1 = Bytes::get_Java_u2(bytes);
1993 printf("qclass #%03d", idx1);
1994 ent_size = 2;
1995 break;
1996 }
1997 case JVM_CONSTANT_String: {
1998 idx1 = Bytes::get_Java_u2(bytes);
1999 printf("String #%03d", idx1);
2000 ent_size = 2;
2001 break;
2002 }
2003 case JVM_CONSTANT_Fieldref: {
2004 idx1 = Bytes::get_Java_u2(bytes);
2005 idx2 = Bytes::get_Java_u2(bytes+2);
2006 printf("Field #%03d, #%03d", (int) idx1, (int) idx2);
2007 ent_size = 4;
2008 break;
2009 }
2010 case JVM_CONSTANT_Methodref: {
2011 idx1 = Bytes::get_Java_u2(bytes);
2012 idx2 = Bytes::get_Java_u2(bytes+2);
2013 printf("Method #%03d, #%03d", idx1, idx2);
2014 ent_size = 4;
2015 break;
2016 }
2019 idx2 = Bytes::get_Java_u2(bytes+2);
2020 printf("InterfMethod #%03d, #%03d", idx1, idx2);
2021 ent_size = 4;
2022 break;
2023 }
2024 case JVM_CONSTANT_NameAndType: {
2025 idx1 = Bytes::get_Java_u2(bytes);
2026 idx2 = Bytes::get_Java_u2(bytes+2);
2027 printf("NameAndType #%03d, #%03d", idx1, idx2);
2028 ent_size = 4;
2029 break;
2030 }
2031 case JVM_CONSTANT_ClassIndex: {
2032 printf("ClassIndex %s", WARN_MSG);
2033 break;
2034 }
2035 case JVM_CONSTANT_UnresolvedClass: {
2036 printf("UnresolvedClass: %s", WARN_MSG);
2037 break;
2038 }
2039 case (JVM_CONSTANT_UnresolvedClass | JVM_CONSTANT_QDESC_BIT): {
2040 printf("UnresolvedQClass: %s", WARN_MSG);
2041 break;
2042 }
2043 case JVM_CONSTANT_UnresolvedClassInError: {
2044 printf("UnresolvedClassInErr: %s", WARN_MSG);
2045 break;
2046 }
2047 case JVM_CONSTANT_StringIndex: {
2048 printf("StringIndex: %s", WARN_MSG);
2049 break;
2050 }
2051 }
2052 printf(";\n");
2053 bytes += ent_size;
2054 size += ent_size;
2055 }
2056 printf("Cpool size: %d\n", size);
2057 fflush(0);
2058 return;
2059 } /* end print_cpool_bytes */
2060
2061
2062 // Returns size of constant pool entry.
2194 case JVM_CONSTANT_Float: {
2195 jfloat val = float_at(idx);
2196 Bytes::put_Java_u4((address) (bytes+1), *(u4*)&val);
2197 break;
2198 }
2199 case JVM_CONSTANT_Long: {
2200 jlong val = long_at(idx);
2201 Bytes::put_Java_u8((address) (bytes+1), *(u8*)&val);
2202 idx++; // Long takes two cpool slots
2203 break;
2204 }
2205 case JVM_CONSTANT_Double: {
2206 jdouble val = double_at(idx);
2207 Bytes::put_Java_u8((address) (bytes+1), *(u8*)&val);
2208 idx++; // Double takes two cpool slots
2209 break;
2210 }
2211 case JVM_CONSTANT_Class:
2212 case JVM_CONSTANT_UnresolvedClass:
2213 case JVM_CONSTANT_UnresolvedClassInError: {
2214 assert(!tag_at(idx).is_Qdescriptor_klass(), "Failed to encode QDesc");
2215 *bytes = JVM_CONSTANT_Class;
2216 Symbol* sym = klass_name_at(idx);
2217 idx1 = tbl->symbol_to_value(sym);
2218 assert(idx1 != 0, "Have not found a hashtable entry");
2219 Bytes::put_Java_u2((address) (bytes+1), idx1);
2220 DBG(printf("JVM_CONSTANT_Class: idx=#%03hd, %s", idx1, sym->as_utf8()));
2221 break;
2222 }
2223 case JVM_CONSTANT_String: {
2224 *bytes = JVM_CONSTANT_String;
2225 Symbol* sym = unresolved_string_at(idx);
2226 idx1 = tbl->symbol_to_value(sym);
2227 assert(idx1 != 0, "Have not found a hashtable entry");
2228 Bytes::put_Java_u2((address) (bytes+1), idx1);
2229 DBG(printf("JVM_CONSTANT_String: idx=#%03hd, %s", idx1, sym->as_utf8()));
2230 break;
2231 }
2232 case JVM_CONSTANT_Fieldref:
2233 case JVM_CONSTANT_Methodref:
2234 case JVM_CONSTANT_InterfaceMethodref: {
|