changeset 475:7b29f3a51eea

annot: update for review comments
author jrose
date Wed, 11 Jul 2012 23:33:23 -0700
parents c748a6624c8b
children 0ffb542eb0de
files annot-6711908.patch
diffstat 1 files changed, 109 insertions(+), 72 deletions(-) [+]
line wrap: on
line diff
--- a/annot-6711908.patch	Wed Jul 11 17:29:28 2012 -0700
+++ b/annot-6711908.patch	Wed Jul 11 23:33:23 2012 -0700
@@ -15,7 +15,7 @@
      // ignore heuristic controls on inlining
    } else {
      if (inline_level() > MaxInlineLevel                         ) INLINE_BAILOUT("too-deep inlining");
-@@ -3531,7 +3532,7 @@
+@@ -3531,7 +3531,7 @@
    }
  
  #ifndef PRODUCT
@@ -245,7 +245,7 @@
  // methodOop to save footprint, so we only know the size of the resulting methodOop when the
  // entire method attribute is parsed.
  //
-@@ -1733,6 +1892,7 @@
+@@ -1733,6 +1891,7 @@
    // stackmap attribute - JDK1.5
    typeArrayHandle stackmap_data;
    u2 generic_signature_index = 0;
@@ -253,7 +253,7 @@
    u1* runtime_visible_annotations = NULL;
    int runtime_visible_annotations_length = 0;
    u1* runtime_invisible_annotations = NULL;
-@@ -1959,6 +2119,7 @@
+@@ -1959,6 +2118,7 @@
          runtime_visible_annotations_length = method_attribute_length;
          runtime_visible_annotations = cfs->get_u1_buffer();
          assert(runtime_visible_annotations != NULL, "null visible annotations");
@@ -261,7 +261,7 @@
          cfs->skip_u1(runtime_visible_annotations_length, CHECK_(nullHandle));
        } else if (PreserveAllAnnotations && method_attribute_name == vmSymbols::tag_runtime_invisible_annotations()) {
          runtime_invisible_annotations_length = method_attribute_length;
-@@ -2136,6 +2297,8 @@
+@@ -2136,6 +2296,8 @@
      clear_hashtable(lvt_Hash);
    }
  
@@ -270,85 +270,80 @@
    *method_annotations = assemble_annotations(runtime_visible_annotations,
                                               runtime_visible_annotations_length,
                                               runtime_invisible_annotations,
-@@ -2314,7 +2477,7 @@
+@@ -2314,7 +2476,7 @@
  }
  
  
 -void ClassFileParser::parse_classfile_sourcefile_attribute(constantPoolHandle cp, instanceKlassHandle k, TRAPS) {
-+void ClassFileParser::parse_classfile_sourcefile_attribute(constantPoolHandle cp, Symbol** sourcefile_ret, TRAPS) {
++void ClassFileParser::parse_classfile_sourcefile_attribute(constantPoolHandle cp, TRAPS) {
    ClassFileStream* cfs = stream();
    cfs->guarantee_more(2, CHECK);  // sourcefile_index
    u2 sourcefile_index = cfs->get_u2_fast();
-@@ -2323,14 +2486,16 @@
+@@ -2323,13 +2485,12 @@
        cp->tag_at(sourcefile_index).is_utf8(),
      "Invalid SourceFile attribute at constant pool index %u in class file %s",
      sourcefile_index, CHECK);
 -  k->set_source_file_name(cp->symbol_at(sourcefile_index));
-+  (*sourcefile_ret) = cp->symbol_at(sourcefile_index);
-+  (*sourcefile_ret)->increment_refcount();
++  set_class_sourcefile(cp->symbol_at(sourcefile_index));
  }
  
  
  
  void ClassFileParser::parse_classfile_source_debug_extension_attribute(constantPoolHandle cp,
 -                                                                       instanceKlassHandle k,
--                                                                       int length, TRAPS) {
-+                                                                       int length,
-+                                                                       TempNewSymbol* sde_symbol_ret,
-+                                                                       TRAPS) {
+                                                                        int length, TRAPS) {
    ClassFileStream* cfs = stream();
    u1* sde_buffer = cfs->get_u1_buffer();
-   assert(sde_buffer != NULL, "null sde buffer");
-@@ -2339,8 +2504,7 @@
-   if (JvmtiExport::can_get_source_debug_extension()) {
+@@ -2340,9 +2501,9 @@
      // Optimistically assume that only 1 byte UTF format is used
      // (common case)
--    TempNewSymbol sde_symbol = SymbolTable::new_symbol((const char*)sde_buffer, length, CHECK);
+     TempNewSymbol sde_symbol = SymbolTable::new_symbol((const char*)sde_buffer, length, CHECK);
 -    k->set_source_debug_extension(sde_symbol);
-+    (*sde_symbol_ret) = SymbolTable::new_symbol((const char*)sde_buffer, length, CHECK);
      // Note that set_source_debug_extension() increments the reference count
      // for its copy of the Symbol*, so use a TempNewSymbol here.
++    set_class_sde_symbol(sde_symbol);
    }
-@@ -2358,7 +2522,7 @@
+   // Got utf8 string, set stream position forward
+   cfs->skip_u1(length, CHECK);
+@@ -2358,7 +2519,7 @@
                                                              u2 enclosing_method_class_index,
                                                              u2 enclosing_method_method_index,
                                                              constantPoolHandle cp,
 -                                                            instanceKlassHandle k, TRAPS) {
-+                                                            typeArrayHandle* inner_classes_ret, TRAPS) {
++                                                            TRAPS) {
    ClassFileStream* cfs = stream();
    u1* current_mark = cfs->current();
    u2 length = 0;
-@@ -2449,7 +2613,7 @@
+@@ -2449,7 +2610,7 @@
    assert(index == size, "wrong size");
  
    // Update instanceKlass with inner class info.
 -  k->set_inner_classes(inner_classes());
-+  (*inner_classes_ret) = inner_classes;
++  set_class_inner_classes(inner_classes);
  
    // Restore buffer's current position.
    cfs->set_current(current_mark);
-@@ -2457,11 +2621,11 @@
+@@ -2457,11 +2618,11 @@
    return length;
  }
  
 -void ClassFileParser::parse_classfile_synthetic_attribute(constantPoolHandle cp, instanceKlassHandle k, TRAPS) {
 -  k->set_is_synthetic();
-+void ClassFileParser::parse_classfile_synthetic_attribute(constantPoolHandle cp, bool* synthetic_flag_ret, TRAPS) {
-+  (*synthetic_flag_ret) = true;
++void ClassFileParser::parse_classfile_synthetic_attribute(constantPoolHandle cp, TRAPS) {
++  set_class_synthetic_flag(true);
  }
  
 -void ClassFileParser::parse_classfile_signature_attribute(constantPoolHandle cp, instanceKlassHandle k, TRAPS) {
-+void ClassFileParser::parse_classfile_signature_attribute(constantPoolHandle cp, Symbol** signature_ret, TRAPS) {
++void ClassFileParser::parse_classfile_signature_attribute(constantPoolHandle cp, TRAPS) {
    ClassFileStream* cfs = stream();
    u2 signature_index = cfs->get_u2(CHECK);
    check_property(
-@@ -2469,10 +2633,11 @@
+@@ -2469,10 +2630,10 @@
        cp->tag_at(signature_index).is_utf8(),
      "Invalid constant pool index %u in Signature attribute in class file %s",
      signature_index, CHECK);
 -  k->set_generic_signature(cp->symbol_at(signature_index));
-+  (*signature_ret) = cp->symbol_at(signature_index);
-+  (*signature_ret)->increment_refcount();
++  set_class_generic_signature(cp->symbol_at(signature_index));
  }
  
 -void ClassFileParser::parse_classfile_bootstrap_methods_attribute(constantPoolHandle cp, instanceKlassHandle k,
@@ -356,7 +351,7 @@
                                                                    u4 attribute_byte_length, TRAPS) {
    ClassFileStream* cfs = stream();
    u1* current_start = cfs->current();
-@@ -2544,10 +2709,12 @@
+@@ -2544,10 +2705,12 @@
  }
  
  
@@ -371,34 +366,34 @@
    cfs->guarantee_more(2, CHECK);  // attributes_count
    u2 attributes_count = cfs->get_u2_fast();
    bool parsed_sourcefile_attribute = false;
-@@ -2583,10 +2751,10 @@
+@@ -2583,10 +2746,10 @@
        } else {
          parsed_sourcefile_attribute = true;
        }
 -      parse_classfile_sourcefile_attribute(cp, k, CHECK);
-+      parse_classfile_sourcefile_attribute(cp, &_sourcefile, CHECK);
++      parse_classfile_sourcefile_attribute(cp, CHECK);
      } else if (tag == vmSymbols::tag_source_debug_extension()) {
        // Check for SourceDebugExtension tag
 -      parse_classfile_source_debug_extension_attribute(cp, k, (int)attribute_length, CHECK);
-+      parse_classfile_source_debug_extension_attribute(cp, (int)attribute_length, &_sde_symbol, CHECK);
++      parse_classfile_source_debug_extension_attribute(cp, (int)attribute_length, CHECK);
      } else if (tag == vmSymbols::tag_inner_classes()) {
        // Check for InnerClasses tag
        if (parsed_innerclasses_attribute) {
-@@ -2605,7 +2773,7 @@
+@@ -2605,7 +2768,7 @@
            "Invalid Synthetic classfile attribute length %u in class file %s",
            attribute_length, CHECK);
        }
 -      parse_classfile_synthetic_attribute(cp, k, CHECK);
-+      parse_classfile_synthetic_attribute(cp, &_synthetic_flag, CHECK);
++      parse_classfile_synthetic_attribute(cp, CHECK);
      } else if (tag == vmSymbols::tag_deprecated()) {
        // Check for Deprecatd tag - 4276120
        if (attribute_length != 0) {
-@@ -2620,11 +2788,16 @@
+@@ -2620,11 +2783,16 @@
              "Wrong Signature attribute length %u in class file %s",
              attribute_length, CHECK);
          }
 -        parse_classfile_signature_attribute(cp, k, CHECK);
-+        parse_classfile_signature_attribute(cp, &_generic_signature, CHECK);
++        parse_classfile_signature_attribute(cp, CHECK);
        } else if (tag == vmSymbols::tag_runtime_visible_annotations()) {
          runtime_visible_annotations_length = attribute_length;
          runtime_visible_annotations = cfs->get_u1_buffer();
@@ -411,7 +406,7 @@
          cfs->skip_u1(runtime_visible_annotations_length, CHECK);
        } else if (PreserveAllAnnotations && tag == vmSymbols::tag_runtime_invisible_annotations()) {
          runtime_invisible_annotations_length = attribute_length;
-@@ -2658,7 +2831,7 @@
+@@ -2658,7 +2826,7 @@
          if (parsed_bootstrap_methods_attribute)
            classfile_parse_error("Multiple BootstrapMethods attributes in class file %s", CHECK);
          parsed_bootstrap_methods_attribute = true;
@@ -420,7 +415,7 @@
        } else {
          // Unknown attribute
          cfs->skip_u1(attribute_length, CHECK);
-@@ -2673,7 +2846,7 @@
+@@ -2673,7 +2841,7 @@
                                                       runtime_invisible_annotations,
                                                       runtime_invisible_annotations_length,
                                                       CHECK);
@@ -429,29 +424,48 @@
  
    if (parsed_innerclasses_attribute || parsed_enclosingmethod_attribute) {
      u2 num_of_classes = parse_classfile_inner_classes_attribute(
-@@ -2681,7 +2854,7 @@
+@@ -2681,7 +2849,7 @@
                              parsed_innerclasses_attribute,
                              enclosing_method_class_index,
                              enclosing_method_method_index,
 -                            cp, k, CHECK);
-+                            cp, &_inner_classes, CHECK);
++                            cp, CHECK);
      if (parsed_innerclasses_attribute &&_need_verify && _major_version >= JAVA_1_5_VERSION) {
        guarantee_property(
          inner_classes_attribute_length == sizeof(num_of_classes) + 4 * sizeof(u2) * num_of_classes,
-@@ -2748,6 +2921,12 @@
-   _has_finalizer = _has_empty_finalizer = _has_vanilla_constructor = false;
-   _max_bootstrap_specifier_index = -1;
+@@ -2695,6 +2863,21 @@
+   }
+ }
  
-+  _synthetic_flag = false;
-+
-+  _sourcefile = NULL;
-+  _generic_signature = NULL;
-+  _sde_symbol = NULL;
-+
++void ClassFileParser::apply_parsed_class_attributes(instanceKlassHandle k) {
++  if (_synthetic_flag)
++    k->set_is_synthetic();
++  if (_sourcefile != NULL) {
++    _sourcefile->increment_refcount();
++    k->set_source_file_name(_sourcefile);
++  }
++  if (_generic_signature != NULL) {
++    _generic_signature->increment_refcount();
++    k->set_generic_signature(_generic_signature);
++  }
++  k->set_source_debug_extension(_sde_symbol);  // increment_refcount inside
++  k->set_inner_classes(_inner_classes());
++  k->set_class_annotations(_annotations());
++}
+ 
+ typeArrayHandle ClassFileParser::assemble_annotations(u1* runtime_visible_annotations,
+                                                       int runtime_visible_annotations_length,
+@@ -2745,8 +2928,7 @@
+                             jt->get_thread_stat()->perf_timers_addr(),
+                             PerfClassTraceTime::PARSE_CLASS);
+ 
+-  _has_finalizer = _has_empty_finalizer = _has_vanilla_constructor = false;
+-  _max_bootstrap_specifier_index = -1;
++  init_parsed_class_attributes();
+ 
    if (JvmtiExport::should_post_class_file_load_hook()) {
      // Get the cached class file bytes (if any) from the class that
-     // is being redefined or retransformed. We use jvmti_thread_state()
-@@ -2979,6 +3158,13 @@
+@@ -2979,6 +3161,13 @@
      objArrayHandle methods_parameter_annotations(THREAD, methods_parameter_annotations_oop);
      objArrayHandle methods_default_annotations(THREAD, methods_default_annotations_oop);
  
@@ -465,7 +479,7 @@
      // We check super class after class file is parsed and format is checked
      if (super_class_index > 0 && super_klass.is_null()) {
        Symbol*  sk  = cp->klass_name_at(super_class_index);
-@@ -3467,11 +3653,15 @@
+@@ -3467,11 +3656,10 @@
        this_klass->set_has_miranda_methods(); // then set a flag
      }
  
@@ -474,18 +488,21 @@
 -
 -    // Make sure this is the end of class file stream
 -    guarantee_property(cfs->at_eos(), "Extra bytes at the end of class file %s", CHECK_(nullHandle));
-+    // Fill in field values from parse_classfile_attributes:
-+    this_klass->set_inner_classes(_inner_classes());
-+    this_klass->set_source_file_name(_sourcefile);
-+    this_klass->set_source_debug_extension(_sde_symbol);
-+    this_klass->set_generic_signature(_generic_signature);
-+    if (_synthetic_flag)  this_klass->set_is_synthetic();
++    // Fill in field values obtained by parse_classfile_attributes
 +    if (parsed_annotations.has_any_annotations())
 +      parsed_annotations.apply_to(this_klass);
-+    this_klass->set_class_annotations(_annotations());
++    apply_parsed_class_attributes(this_klass);
  
      // VerifyOops believes that once this has been set, the object is completely loaded.
      // Compute transitive closure of interfaces this class implements
+@@ -3486,6 +3674,7 @@
+     // Do final class setup
+     fill_oop_maps(this_klass, nonstatic_oop_map_count, nonstatic_oop_offsets, nonstatic_oop_counts);
+ 
++    // Fill in has_finalizer, has_vanilla_constructor, and layout_helper
+     set_precomputed_flags(this_klass);
+ 
+     // reinitialize modifiers, using the InnerClasses attribute
 diff --git a/src/share/vm/classfile/classFileParser.hpp b/src/share/vm/classfile/classFileParser.hpp
 --- a/src/share/vm/classfile/classFileParser.hpp
 +++ b/src/share/vm/classfile/classFileParser.hpp
@@ -499,10 +516,17 @@
  class FieldAllocationCount;
  
  
-@@ -54,6 +54,56 @@
+@@ -50,11 +50,77 @@
+   KlassHandle _host_klass;
+   GrowableArray<Handle>* _cp_patches; // overrides for CP entries
+ 
++  // precomputed flags
+   bool _has_finalizer;
    bool _has_empty_finalizer;
    bool _has_vanilla_constructor;
++  int _max_bootstrap_specifier_index;  // detects BSS values
  
+-  int _max_bootstrap_specifier_index;
 +  // class attributes parsed before the instance klass is created:
 +  bool       _synthetic_flag;
 +  Symbol*    _sourcefile;
@@ -511,6 +535,22 @@
 +  typeArrayHandle _inner_classes;
 +  typeArrayHandle _annotations;
 +
++  void set_class_synthetic_flag(bool x)           { _synthetic_flag = x; }
++  void set_class_sourcefile(Symbol* x)            { _sourcefile = x; }
++  void set_class_generic_signature(Symbol* x)     { _generic_signature = x; }
++  void set_class_sde_symbol(Symbol* x)            { _sde_symbol = x; }
++  void set_class_inner_classes(typeArrayHandle x) { _inner_classes = x; }
++  void set_class_annotations(typeArrayHandle x)   { _annotations = x; }
++  void init_parsed_class_attributes() {
++    _synthetic_flag = false;
++    _sourcefile = NULL;
++    _generic_signature = NULL;
++    // initialize the other flags too:
++    _has_finalizer = _has_empty_finalizer = _has_vanilla_constructor = false;
++    _max_bootstrap_specifier_index = -1;
++  }
++  void apply_parsed_class_attributes(instanceKlassHandle k);  // update k
++
 +  class AnnotationCollector {
 +  public:
 +    enum Location { _in_field, _in_method, _in_class };
@@ -552,11 +592,10 @@
 +    ClassAnnotationCollector() : AnnotationCollector(_in_class) { }
 +    void apply_to(instanceKlassHandle k);
 +  };
-+
-   int _max_bootstrap_specifier_index;
  
    enum { fixed_buffer_size = 128 };
-@@ -87,7 +135,9 @@
+   u_char linenumbertable_buffer[fixed_buffer_size];
+@@ -87,7 +153,9 @@
                                u2* constantvalue_index_addr,
                                bool* is_synthetic_addr,
                                u2* generic_signature_index_addr,
@@ -567,17 +606,15 @@
    typeArrayHandle parse_fields(Symbol* class_name,
                                 constantPoolHandle cp, bool is_interface,
                                 FieldAllocationCount *fac,
-@@ -128,25 +178,34 @@
+@@ -128,25 +196,32 @@
    typeArrayOop parse_stackmap_table(u4 code_attribute_length, TRAPS);
  
    // Classfile attribute parsing
 -  void parse_classfile_sourcefile_attribute(constantPoolHandle cp, instanceKlassHandle k, TRAPS);
 -  void parse_classfile_source_debug_extension_attribute(constantPoolHandle cp,
 -                                                instanceKlassHandle k, int length, TRAPS);
-+  void parse_classfile_sourcefile_attribute(constantPoolHandle cp, Symbol** sourcefile, TRAPS);
-+  void parse_classfile_source_debug_extension_attribute(constantPoolHandle cp, int length,
-+                                                        TempNewSymbol* sde_symbol_ret,
-+                                                        TRAPS);
++  void parse_classfile_sourcefile_attribute(constantPoolHandle cp, TRAPS);
++  void parse_classfile_source_debug_extension_attribute(constantPoolHandle cp, int length, TRAPS);
    u2   parse_classfile_inner_classes_attribute(u1* inner_classes_attribute_start,
                                                 bool parsed_enclosingmethod_attribute,
                                                 u2 enclosing_method_class_index,
@@ -588,12 +625,12 @@
 -  void parse_classfile_synthetic_attribute(constantPoolHandle cp, instanceKlassHandle k, TRAPS);
 -  void parse_classfile_signature_attribute(constantPoolHandle cp, instanceKlassHandle k, TRAPS);
 -  void parse_classfile_bootstrap_methods_attribute(constantPoolHandle cp, instanceKlassHandle k, u4 attribute_length, TRAPS);
-+                                               typeArrayHandle* inner_classes, TRAPS);
++                                               TRAPS);
 +  void parse_classfile_attributes(constantPoolHandle cp,
 +                                  ClassAnnotationCollector* parsed_annotations,
 +                                  TRAPS);
-+  void parse_classfile_synthetic_attribute(constantPoolHandle cp, bool* synthetic_flag, TRAPS);
-+  void parse_classfile_signature_attribute(constantPoolHandle cp, Symbol** signature, TRAPS);
++  void parse_classfile_synthetic_attribute(constantPoolHandle cp, TRAPS);
++  void parse_classfile_signature_attribute(constantPoolHandle cp, TRAPS);
 +  void parse_classfile_bootstrap_methods_attribute(constantPoolHandle cp, u4 attribute_length, TRAPS);
  
    // Annotations handling