src/share/vm/oops/constMethod.hpp

changeset 4572
927a311d00f9
parent 4524
24a91505f9d5
child 4719
c8b31b461e1a
     1.1 --- a/src/share/vm/oops/constMethod.hpp	Fri Feb 08 16:56:03 2013 -0800
     1.2 +++ b/src/share/vm/oops/constMethod.hpp	Mon Feb 11 14:06:22 2013 -0500
     1.3 @@ -86,19 +86,22 @@
     1.4  // | generic signature index (u2)                         |
     1.5  // |  (indexed from start of constMethodOop)              |
     1.6  // |------------------------------------------------------|
     1.7 +// | annotations arrays - method, parameter, type, default|
     1.8 +// | pointer to Array<u1> if annotation is present        |
     1.9 +// |------------------------------------------------------|
    1.10  //
    1.11  // IMPORTANT: If anything gets added here, there need to be changes to
    1.12  // ensure that ServicabilityAgent doesn't get broken as a result!
    1.13  
    1.14  
    1.15 -// Utitily class decribing elements in checked exceptions table inlined in Method*.
    1.16 +// Utility class describing elements in checked exceptions table inlined in Method*.
    1.17  class CheckedExceptionElement VALUE_OBJ_CLASS_SPEC {
    1.18   public:
    1.19    u2 class_cp_index;
    1.20  };
    1.21  
    1.22  
    1.23 -// Utitily class decribing elements in local variable table inlined in Method*.
    1.24 +// Utility class describing elements in local variable table inlined in Method*.
    1.25  class LocalVariableTableElement VALUE_OBJ_CLASS_SPEC {
    1.26   public:
    1.27    u2 start_bci;
    1.28 @@ -109,7 +112,7 @@
    1.29    u2 slot;
    1.30  };
    1.31  
    1.32 -// Utitily class describing elements in exception table
    1.33 +// Utility class describing elements in exception table
    1.34  class ExceptionTableElement VALUE_OBJ_CLASS_SPEC {
    1.35   public:
    1.36    u2 start_pc;
    1.37 @@ -127,6 +130,51 @@
    1.38  
    1.39  class KlassSizeStats;
    1.40  
    1.41 +// Class to collect the sizes of ConstMethod inline tables
    1.42 +#define INLINE_TABLES_DO(do_element)            \
    1.43 +  do_element(localvariable_table_length)        \
    1.44 +  do_element(compressed_linenumber_size)        \
    1.45 +  do_element(exception_table_length)            \
    1.46 +  do_element(checked_exceptions_length)         \
    1.47 +  do_element(method_parameters_length)          \
    1.48 +  do_element(generic_signature_index)           \
    1.49 +  do_element(method_annotations_length)         \
    1.50 +  do_element(parameter_annotations_length)      \
    1.51 +  do_element(type_annotations_length)           \
    1.52 +  do_element(default_annotations_length)
    1.53 +
    1.54 +#define INLINE_TABLE_DECLARE(sym)    int _##sym;
    1.55 +#define INLINE_TABLE_PARAM(sym)      int sym,
    1.56 +#define INLINE_TABLE_INIT(sym)       _##sym(sym),
    1.57 +#define INLINE_TABLE_NULL(sym)       _##sym(0),
    1.58 +#define INLINE_TABLE_ACCESSOR(sym)   int sym() const { return _##sym; }
    1.59 +
    1.60 +class InlineTableSizes : StackObj {
    1.61 +  // declarations
    1.62 +  INLINE_TABLES_DO(INLINE_TABLE_DECLARE)
    1.63 +  int _end;
    1.64 + public:
    1.65 +  InlineTableSizes(
    1.66 +      INLINE_TABLES_DO(INLINE_TABLE_PARAM)
    1.67 +      int end) :
    1.68 +      INLINE_TABLES_DO(INLINE_TABLE_INIT)
    1.69 +      _end(end) {}
    1.70 +
    1.71 +  // Default constructor for no inlined tables
    1.72 +  InlineTableSizes() :
    1.73 +      INLINE_TABLES_DO(INLINE_TABLE_NULL)
    1.74 +      _end(0) {}
    1.75 +
    1.76 +  // Accessors
    1.77 +  INLINE_TABLES_DO(INLINE_TABLE_ACCESSOR)
    1.78 +};
    1.79 +#undef INLINE_TABLE_ACCESSOR
    1.80 +#undef INLINE_TABLE_NULL
    1.81 +#undef INLINE_TABLE_INIT
    1.82 +#undef INLINE_TABLE_PARAM
    1.83 +#undef INLINE_TABLE_DECLARE
    1.84 +
    1.85 +
    1.86  class ConstMethod : public MetaspaceObj {
    1.87    friend class VMStructs;
    1.88  
    1.89 @@ -135,13 +183,17 @@
    1.90  
    1.91  private:
    1.92    enum {
    1.93 -    _has_linenumber_table = 1,
    1.94 -    _has_checked_exceptions = 2,
    1.95 -    _has_localvariable_table = 4,
    1.96 -    _has_exception_table = 8,
    1.97 -    _has_generic_signature = 16,
    1.98 -    _has_method_parameters = 32,
    1.99 -    _is_overpass = 64
   1.100 +    _has_linenumber_table = 0x0001,
   1.101 +    _has_checked_exceptions = 0x0002,
   1.102 +    _has_localvariable_table = 0x0004,
   1.103 +    _has_exception_table = 0x0008,
   1.104 +    _has_generic_signature = 0x0010,
   1.105 +    _has_method_parameters = 0x0020,
   1.106 +    _is_overpass = 0x0040,
   1.107 +    _has_method_annotations = 0x0080,
   1.108 +    _has_parameter_annotations = 0x0100,
   1.109 +    _has_type_annotations = 0x0200,
   1.110 +    _has_default_annotations = 0x0400
   1.111    };
   1.112  
   1.113    // Bit vector of signature
   1.114 @@ -158,8 +210,7 @@
   1.115    Array<u1>*        _stackmap_data;
   1.116  
   1.117    int               _constMethod_size;
   1.118 -  jbyte             _interpreter_kind;
   1.119 -  jbyte             _flags;
   1.120 +  u2                _flags;
   1.121  
   1.122    // Size of Java bytecodes allocated immediately after Method*.
   1.123    u2                _code_size;
   1.124 @@ -174,36 +225,21 @@
   1.125  
   1.126    // Constructor
   1.127    ConstMethod(int byte_code_size,
   1.128 -              int compressed_line_number_size,
   1.129 -              int localvariable_table_length,
   1.130 -              int exception_table_length,
   1.131 -              int checked_exceptions_length,
   1.132 -              int method_parameters_length,
   1.133 -              u2  generic_signature_index,
   1.134 +              InlineTableSizes* sizes,
   1.135                MethodType is_overpass,
   1.136                int size);
   1.137  public:
   1.138  
   1.139    static ConstMethod* allocate(ClassLoaderData* loader_data,
   1.140                                 int byte_code_size,
   1.141 -                               int compressed_line_number_size,
   1.142 -                               int localvariable_table_length,
   1.143 -                               int exception_table_length,
   1.144 -                               int checked_exceptions_length,
   1.145 -                               int method_parameters_length,
   1.146 -                               u2  generic_signature_index,
   1.147 +                               InlineTableSizes* sizes,
   1.148                                 MethodType mt,
   1.149                                 TRAPS);
   1.150  
   1.151    bool is_constMethod() const { return true; }
   1.152  
   1.153    // Inlined tables
   1.154 -  void set_inlined_tables_length(u2  generic_signature_index,
   1.155 -                                 int checked_exceptions_len,
   1.156 -                                 int compressed_line_number_size,
   1.157 -                                 int localvariable_table_len,
   1.158 -                                 int exception_table_len,
   1.159 -                                 int method_parameters_length);
   1.160 +  void set_inlined_tables_length(InlineTableSizes* sizes);
   1.161  
   1.162    bool has_generic_signature() const
   1.163      { return (_flags & _has_generic_signature) != 0; }
   1.164 @@ -235,10 +271,6 @@
   1.165      }
   1.166    }
   1.167  
   1.168 -
   1.169 -  void set_interpreter_kind(int kind)      { _interpreter_kind = kind; }
   1.170 -  int  interpreter_kind(void) const        { return _interpreter_kind; }
   1.171 -
   1.172    // constant pool
   1.173    ConstantPool* constants() const        { return _constants; }
   1.174    void set_constants(ConstantPool* c)    { _constants = c; }
   1.175 @@ -307,12 +339,7 @@
   1.176    }
   1.177  
   1.178    // Size needed
   1.179 -  static int size(int code_size, int compressed_line_number_size,
   1.180 -                  int local_variable_table_length,
   1.181 -                  int exception_table_length,
   1.182 -                  int checked_exceptions_length,
   1.183 -                  int method_parameters_length,
   1.184 -                  u2  generic_signature_index);
   1.185 +  static int size(int code_size, InlineTableSizes* sizes);
   1.186  
   1.187    int size() const                    { return _constMethod_size;}
   1.188    void set_constMethod_size(int size)     { _constMethod_size = size; }
   1.189 @@ -354,6 +381,65 @@
   1.190    int method_parameters_length() const;
   1.191    MethodParametersElement* method_parameters_start() const;
   1.192  
   1.193 +  // method annotations
   1.194 +  bool has_method_annotations() const
   1.195 +    { return (_flags & _has_method_annotations) != 0; }
   1.196 +
   1.197 +  bool has_parameter_annotations() const
   1.198 +    { return (_flags & _has_parameter_annotations) != 0; }
   1.199 +
   1.200 +  bool has_type_annotations() const
   1.201 +    { return (_flags & _has_type_annotations) != 0; }
   1.202 +
   1.203 +  bool has_default_annotations() const
   1.204 +    { return (_flags & _has_default_annotations) != 0; }
   1.205 +
   1.206 +
   1.207 +  AnnotationArray** method_annotations_addr() const;
   1.208 +  AnnotationArray* method_annotations() const  {
   1.209 +    return has_method_annotations() ? *(method_annotations_addr()) : NULL;
   1.210 +  }
   1.211 +  void set_method_annotations(AnnotationArray* anno) {
   1.212 +    *(method_annotations_addr()) = anno;
   1.213 +  }
   1.214 +
   1.215 +  AnnotationArray** parameter_annotations_addr() const;
   1.216 +  AnnotationArray* parameter_annotations() const {
   1.217 +    return has_parameter_annotations() ? *(parameter_annotations_addr()) : NULL;
   1.218 +  }
   1.219 +  void set_parameter_annotations(AnnotationArray* anno) {
   1.220 +    *(parameter_annotations_addr()) = anno;
   1.221 +  }
   1.222 +
   1.223 +  AnnotationArray** type_annotations_addr() const;
   1.224 +  AnnotationArray* type_annotations() const {
   1.225 +    return has_type_annotations() ? *(type_annotations_addr()) : NULL;
   1.226 +  }
   1.227 +  void set_type_annotations(AnnotationArray* anno) {
   1.228 +    *(type_annotations_addr()) = anno;
   1.229 +  }
   1.230 +
   1.231 +  AnnotationArray** default_annotations_addr() const;
   1.232 +  AnnotationArray* default_annotations() const {
   1.233 +    return has_default_annotations() ? *(default_annotations_addr()) : NULL;
   1.234 +  }
   1.235 +  void set_default_annotations(AnnotationArray* anno) {
   1.236 +    *(default_annotations_addr()) = anno;
   1.237 +  }
   1.238 +
   1.239 +  int method_annotations_length() const {
   1.240 +    return has_method_annotations() ? method_annotations()->length() : 0;
   1.241 +  }
   1.242 +  int parameter_annotations_length() const {
   1.243 +    return has_parameter_annotations() ? parameter_annotations()->length() : 0;
   1.244 +  }
   1.245 +  int type_annotations_length() const {
   1.246 +    return has_type_annotations() ? type_annotations()->length() : 0;
   1.247 +  }
   1.248 +  int default_annotations_length() const {
   1.249 +    return has_default_annotations() ? default_annotations()->length() : 0;
   1.250 +  }
   1.251 +
   1.252    // byte codes
   1.253    void    set_code(address code) {
   1.254      if (code_size() > 0) {
   1.255 @@ -409,11 +495,10 @@
   1.256  
   1.257    // First byte after ConstMethod*
   1.258    address constMethod_end() const
   1.259 -                          { return (address)((oop*)this + _constMethod_size); }
   1.260 +                          { return (address)((intptr_t*)this + _constMethod_size); }
   1.261  
   1.262    // Last short in ConstMethod*
   1.263 -  u2* last_u2_element() const
   1.264 -                                         { return (u2*)constMethod_end() - 1; }
   1.265 +  u2* last_u2_element() const;
   1.266  
   1.267   public:
   1.268    // Printing

mercurial