1.1 --- a/src/share/vm/oops/annotations.cpp Fri Feb 08 16:56:03 2013 -0800 1.2 +++ b/src/share/vm/oops/annotations.cpp Mon Feb 11 14:06:22 2013 -0500 1.3 @@ -36,16 +36,8 @@ 1.4 return new (loader_data, size(), true, THREAD) Annotations(); 1.5 } 1.6 1.7 -Annotations* Annotations::allocate(ClassLoaderData* loader_data, 1.8 - Array<AnnotationArray*>* fa, 1.9 - Array<AnnotationArray*>* ma, 1.10 - Array<AnnotationArray*>* mpa, 1.11 - Array<AnnotationArray*>* mda, TRAPS) { 1.12 - return new (loader_data, size(), true, THREAD) Annotations(fa, ma, mpa, mda); 1.13 -} 1.14 - 1.15 // helper 1.16 -static void free_contents(ClassLoaderData* loader_data, Array<AnnotationArray*>* p) { 1.17 +void Annotations::free_contents(ClassLoaderData* loader_data, Array<AnnotationArray*>* p) { 1.18 if (p != NULL) { 1.19 for (int i = 0; i < p->length(); i++) { 1.20 MetadataFactory::free_array<u1>(loader_data, p->at(i)); 1.21 @@ -59,44 +51,16 @@ 1.22 MetadataFactory::free_array<u1>(loader_data, class_annotations()); 1.23 } 1.24 free_contents(loader_data, fields_annotations()); 1.25 - free_contents(loader_data, methods_annotations()); 1.26 - free_contents(loader_data, methods_parameter_annotations()); 1.27 - free_contents(loader_data, methods_default_annotations()); 1.28 1.29 - // Recursively deallocate optional Annotations linked through this one 1.30 - MetadataFactory::free_metadata(loader_data, type_annotations()); 1.31 + if (class_type_annotations() != NULL) { 1.32 + MetadataFactory::free_array<u1>(loader_data, class_type_annotations()); 1.33 + } 1.34 + free_contents(loader_data, fields_type_annotations()); 1.35 } 1.36 1.37 -// Set the annotation at 'idnum' to 'anno'. 1.38 -// We don't want to create or extend the array if 'anno' is NULL, since that is the 1.39 -// default value. However, if the array exists and is long enough, we must set NULL values. 1.40 -void Annotations::set_methods_annotations_of(instanceKlassHandle ik, 1.41 - int idnum, AnnotationArray* anno, 1.42 - Array<AnnotationArray*>** md_p, 1.43 - TRAPS) { 1.44 - Array<AnnotationArray*>* md = *md_p; 1.45 - if (md != NULL && md->length() > idnum) { 1.46 - md->at_put(idnum, anno); 1.47 - } else if (anno != NULL) { 1.48 - // create the array 1.49 - int length = MAX2(idnum+1, (int)ik->idnum_allocated_count()); 1.50 - md = MetadataFactory::new_array<AnnotationArray*>(ik->class_loader_data(), length, CHECK); 1.51 - if (*md_p != NULL) { 1.52 - // copy the existing entries 1.53 - for (int index = 0; index < (*md_p)->length(); index++) { 1.54 - md->at_put(index, (*md_p)->at(index)); 1.55 - } 1.56 - } 1.57 - set_annotations(md, md_p); 1.58 - md->at_put(idnum, anno); 1.59 - } // if no array and idnum isn't included there is nothing to do 1.60 -} 1.61 - 1.62 -// Keep created annotations in a global growable array (should be hashtable) 1.63 -// need to add, search, delete when class is unloaded. 1.64 -// Does it need a lock? yes. This sucks. 1.65 - 1.66 // Copy annotations to JVM call or reflection to the java heap. 1.67 +// The alternative to creating this array and adding to Java heap pressure 1.68 +// is to have a hashtable of the already created typeArrayOops 1.69 typeArrayOop Annotations::make_java_array(AnnotationArray* annotations, TRAPS) { 1.70 if (annotations != NULL) { 1.71 int length = annotations->length(); 1.72 @@ -132,28 +96,15 @@ 1.73 void Annotations::collect_statistics(KlassSizeStats *sz) const { 1.74 sz->_annotations_bytes = sz->count(this); 1.75 sz->_class_annotations_bytes = sz->count(class_annotations()); 1.76 + sz->_class_type_annotations_bytes = sz->count(class_type_annotations()); 1.77 sz->_fields_annotations_bytes = count_bytes(fields_annotations()); 1.78 - sz->_methods_annotations_bytes = count_bytes(methods_annotations()); 1.79 - sz->_methods_parameter_annotations_bytes = 1.80 - count_bytes(methods_parameter_annotations()); 1.81 - sz->_methods_default_annotations_bytes = 1.82 - count_bytes(methods_default_annotations()); 1.83 - 1.84 - const Annotations* type_anno = type_annotations(); 1.85 - if (type_anno != NULL) { 1.86 - sz->_type_annotations_bytes = sz->count(type_anno); 1.87 - sz->_type_annotations_bytes += sz->count(type_anno->class_annotations()); 1.88 - sz->_type_annotations_bytes += count_bytes(type_anno->fields_annotations()); 1.89 - sz->_type_annotations_bytes += count_bytes(type_anno->methods_annotations()); 1.90 - } 1.91 + sz->_fields_type_annotations_bytes = count_bytes(fields_type_annotations()); 1.92 1.93 sz->_annotations_bytes += 1.94 sz->_class_annotations_bytes + 1.95 + sz->_class_type_annotations_bytes + 1.96 sz->_fields_annotations_bytes + 1.97 - sz->_methods_annotations_bytes + 1.98 - sz->_methods_parameter_annotations_bytes + 1.99 - sz->_methods_default_annotations_bytes + 1.100 - sz->_type_annotations_bytes; 1.101 + sz->_fields_type_annotations_bytes; 1.102 1.103 sz->_ro_bytes += sz->_annotations_bytes; 1.104 } 1.105 @@ -165,8 +116,7 @@ 1.106 void Annotations::print_on(outputStream* st) const { 1.107 st->print(BULLET"class_annotations "); class_annotations()->print_value_on(st); 1.108 st->print(BULLET"fields_annotations "); fields_annotations()->print_value_on(st); 1.109 - st->print(BULLET"methods_annotations "); methods_annotations()->print_value_on(st); 1.110 - st->print(BULLET"methods_parameter_annotations"); methods_parameter_annotations()->print_value_on(st); 1.111 - st->print(BULLET"methods_default_annotations "); methods_default_annotations()->print_value_on(st); 1.112 + st->print(BULLET"class_type_annotations "); class_type_annotations()->print_value_on(st); 1.113 + st->print(BULLET"fields_type_annotations "); fields_type_annotations()->print_value_on(st); 1.114 } 1.115 #endif // PRODUCT