changeset 472:34aa8c19bcaa

annot: incorporate review comments
author jrose
date Wed, 11 Jul 2012 17:17:50 -0700
parents 22a0e2e50ec4
children a3668184eaae
files annot-6711908.patch
diffstat 1 files changed, 33 insertions(+), 42 deletions(-) [+]
line wrap: on
line diff
--- a/annot-6711908.patch	Wed Jul 11 15:32:12 2012 -0700
+++ b/annot-6711908.patch	Wed Jul 11 17:17:50 2012 -0700
@@ -1,22 +1,20 @@
 6711908: JVM needs direct access to some annotations
 Summary: Add annotation extraction code to class file parser.
 Contributed-by: jrose, michael.haupt@oracle.com
-Reviewed-by: twisti, jrose
+Reviewed-by: twisti, jrose, kvn
 
 diff --git a/src/share/vm/c1/c1_GraphBuilder.cpp b/src/share/vm/c1/c1_GraphBuilder.cpp
 --- a/src/share/vm/c1/c1_GraphBuilder.cpp
 +++ b/src/share/vm/c1/c1_GraphBuilder.cpp
-@@ -3505,8 +3505,9 @@
+@@ -3505,7 +3505,7 @@
    }
  
    // now perform tests that are based on flag settings
 -  if (callee->should_inline()) {
 +  if (callee->force_inline() || callee->should_inline()) {
      // ignore heuristic controls on inlining
-+    _inline_bailout_msg = "forced inlining";
    } else {
      if (inline_level() > MaxInlineLevel                         ) INLINE_BAILOUT("too-deep inlining");
-     if (recursive_inline_level(callee) > MaxRecursiveInlineLevel) INLINE_BAILOUT("too-deep recursive inlining");
 @@ -3531,7 +3532,7 @@
    }
  
@@ -87,7 +85,7 @@
  
      BasicType type = cp->basic_type_for_signature_at(signature_index);
  
-@@ -1638,12 +1650,159 @@
+@@ -1638,12 +1650,158 @@
        name->as_C_string(), _class_name->as_C_string(), sig->as_C_string());
  }
  
@@ -167,7 +165,7 @@
 +      c_size = 9,       // end of 'c' annotation
 +    min_size = 6        // smallest possible size (zero members)
 +  };
-+  while (--nann >= 0 && index-2 + min_size <= limit) {
++  while ((--nann) >= 0 && (index-2 + min_size <= limit)) {
 +    int index0 = index;
 +    index = skip_annotation(buffer, limit, index);
 +    u1* abase = buffer + index0;
@@ -189,27 +187,26 @@
 +    // If there are no values, just set the bit and move on:
 +    if (count == 0)   continue;
 +
-+#if 0
-+    // The parsing of @Retention is for example only.
-+    if (id == AnnotationCollector::_class_Retention) {
-+      Symbol* payload = NULL;
-+      if (count == 1
-+          && e_size == (index0 - index)  // match size
-+          && e_tag_val == *(abase + tag_off)
-+          && (check_symbol_at(cp, Bytes::get_Java_u2(abase + e_type_off))
-+              == vmSymbols::RetentionPolicy_signature())
-+          && member == vmSymbols::value_name()) {
-+        payload = check_symbol_at(cp, Bytes::get_Java_u2(abase + e_con_off));
-+      }
-+      check_property(payload != NULL,
-+                     "Invalid @Retention annotation at offset %u in class file %s",
-+                     index0, CHECK);
-+      if (payload != NULL) {
-+          payload->increment_refcount();
-+          coll->_class_RetentionPolicy = payload;
-+      }
-+    }
-+#endif //0
++    // For the record, here is how annotation payloads can be collected.
++    // Suppose we want to capture @Retention.value.  Here is how:
++    //if (id == AnnotationCollector::_class_Retention) {
++    //  Symbol* payload = NULL;
++    //  if (count == 1
++    //      && e_size == (index0 - index)  // match size
++    //      && e_tag_val == *(abase + tag_off)
++    //      && (check_symbol_at(cp, Bytes::get_Java_u2(abase + e_type_off))
++    //          == vmSymbols::RetentionPolicy_signature())
++    //      && member == vmSymbols::value_name()) {
++    //    payload = check_symbol_at(cp, Bytes::get_Java_u2(abase + e_con_off));
++    //  }
++    //  check_property(payload != NULL,
++    //                 "Invalid @Retention annotation at offset %u in class file %s",
++    //                 index0, CHECK);
++    //  if (payload != NULL) {
++    //      payload->increment_refcount();
++    //      coll->_class_RetentionPolicy = payload;
++    //  }
++    //}
 +  }
 +}
 +
@@ -217,7 +214,7 @@
 +  vmSymbols::SID sid = vmSymbols::find_sid(name);
 +  switch (sid) {
 +  case vmSymbols::VM_SYMBOL_ENUM_NAME(java_lang_invoke_ForceInline_signature):
-+    if (_location != _in_class)  break;
++    if (_location != _in_method)  break;  // only allow for methods
 +    return _method_ForceInline;
 +  default: break;
 +  }
@@ -225,7 +222,7 @@
 +}
 +
 +void ClassFileParser::FieldAnnotationCollector::apply_to(FieldInfo* f) {
-+  assert(false, "");
++  guarantee(false, "no field annotations yet");
 +}
 +
 +void ClassFileParser::MethodAnnotationCollector::apply_to(methodHandle m) {
@@ -234,7 +231,7 @@
 +}
 +
 +void ClassFileParser::ClassAnnotationCollector::apply_to(instanceKlassHandle k) {
-+  assert(false, "");
++  guarantee(false, "no class annotations yet");
 +}
 +
 +
@@ -374,14 +371,6 @@
    cfs->guarantee_more(2, CHECK);  // attributes_count
    u2 attributes_count = cfs->get_u2_fast();
    bool parsed_sourcefile_attribute = false;
-@@ -2562,6 +2729,7 @@
-   u4  inner_classes_attribute_length = 0;
-   u2  enclosing_method_class_index = 0;
-   u2  enclosing_method_method_index = 0;
-+  TempNewSymbol sde_symbol = NULL;
-   // Iterate over attributes
-   while (attributes_count--) {
-     cfs->guarantee_more(6, CHECK);  // attribute_name_index, attribute_length
 @@ -2583,10 +2751,10 @@
        } else {
          parsed_sourcefile_attribute = true;
@@ -510,7 +499,7 @@
  class FieldAllocationCount;
  
  
-@@ -54,6 +54,54 @@
+@@ -54,6 +54,56 @@
    bool _has_empty_finalizer;
    bool _has_vanilla_constructor;
  
@@ -534,12 +523,14 @@
 +    int _annotations_present;
 +    AnnotationCollector(Location location)
 +    : _location(location), _annotations_present(0)
-+    { }
++    {
++      assert((int)_annotation_LIMIT <= (int)sizeof(_annotations_present) * BitsPerByte, "");
++    }
 +    // If this annotation name has an ID, report it (or _none).
 +    ID annotation_index(Symbol* name);
 +    // Set the annotation name:
 +    void set_annotation(ID id) {
-+      assert((int)id >= 0 && (int)id < BitsPerInt, "oob");
++      assert((int)id >= 0 && (int)id < (int)_annotation_LIMIT, "oob");
 +      _annotations_present |= nth_bit((int)id);
 +    }
 +    // Report if the annotation is present.
@@ -599,7 +590,7 @@
 -  void parse_classfile_bootstrap_methods_attribute(constantPoolHandle cp, instanceKlassHandle k, u4 attribute_length, TRAPS);
 +                                               typeArrayHandle* inner_classes, TRAPS);
 +  void parse_classfile_attributes(constantPoolHandle cp,
-+                                  ClassFileParser::ClassAnnotationCollector* parsed_annotations,
++                                  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);