Wed, 03 Sep 2014 09:25:44 +0200
Merge
duke@435 | 1 | /* |
acorn@4497 | 2 | * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. |
duke@435 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
duke@435 | 4 | * |
duke@435 | 5 | * This code is free software; you can redistribute it and/or modify it |
duke@435 | 6 | * under the terms of the GNU General Public License version 2 only, as |
duke@435 | 7 | * published by the Free Software Foundation. |
duke@435 | 8 | * |
duke@435 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
duke@435 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
duke@435 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
duke@435 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
duke@435 | 13 | * accompanied this code). |
duke@435 | 14 | * |
duke@435 | 15 | * You should have received a copy of the GNU General Public License version |
duke@435 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
duke@435 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
duke@435 | 18 | * |
trims@1907 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
trims@1907 | 20 | * or visit www.oracle.com if you need additional information or have any |
trims@1907 | 21 | * questions. |
duke@435 | 22 | * |
duke@435 | 23 | */ |
duke@435 | 24 | |
stefank@2314 | 25 | #ifndef SHARE_VM_OOPS_CONSTMETHODOOP_HPP |
stefank@2314 | 26 | #define SHARE_VM_OOPS_CONSTMETHODOOP_HPP |
stefank@2314 | 27 | |
stefank@2314 | 28 | #include "oops/oop.hpp" |
stefank@2314 | 29 | |
coleenp@4037 | 30 | // An ConstMethod* represents portions of a Java method which |
duke@435 | 31 | // do not vary. |
duke@435 | 32 | // |
duke@435 | 33 | // Memory layout (each line represents a word). Note that most |
duke@435 | 34 | // applications load thousands of methods, so keeping the size of this |
duke@435 | 35 | // structure small has a big impact on footprint. |
duke@435 | 36 | // |
duke@435 | 37 | // |------------------------------------------------------| |
duke@435 | 38 | // | header | |
duke@435 | 39 | // | klass | |
duke@435 | 40 | // |------------------------------------------------------| |
duke@435 | 41 | // | fingerprint 1 | |
duke@435 | 42 | // | fingerprint 2 | |
jiangli@3826 | 43 | // | constants (oop) | |
duke@435 | 44 | // | stackmap_data (oop) | |
duke@435 | 45 | // | constMethod_size | |
duke@435 | 46 | // | interp_kind | flags | code_size | |
duke@435 | 47 | // | name index | signature index | |
jiangli@4302 | 48 | // | method_idnum | max_stack | |
jiangli@4338 | 49 | // | max_locals | size_of_parameters | |
duke@435 | 50 | // |------------------------------------------------------| |
duke@435 | 51 | // | | |
duke@435 | 52 | // | byte codes | |
duke@435 | 53 | // | | |
duke@435 | 54 | // |------------------------------------------------------| |
duke@435 | 55 | // | compressed linenumber table | |
duke@435 | 56 | // | (see class CompressedLineNumberReadStream) | |
duke@435 | 57 | // | (note that length is unknown until decompressed) | |
duke@435 | 58 | // | (access flags bit tells whether table is present) | |
jiangli@4302 | 59 | // | (indexed from start of ConstMethod*) | |
duke@435 | 60 | // | (elements not necessarily sorted!) | |
duke@435 | 61 | // |------------------------------------------------------| |
duke@435 | 62 | // | localvariable table elements + length (length last) | |
duke@435 | 63 | // | (length is u2, elements are 6-tuples of u2) | |
duke@435 | 64 | // | (see class LocalVariableTableElement) | |
duke@435 | 65 | // | (access flags bit tells whether table is present) | |
jiangli@4302 | 66 | // | (indexed from end of ConstMethod*) | |
jiangli@3917 | 67 | // |------------------------------------------------------| |
jiangli@3917 | 68 | // | exception table + length (length last) | |
jiangli@3917 | 69 | // | (length is u2, elements are 4-tuples of u2) | |
jiangli@3917 | 70 | // | (see class ExceptionTableElement) | |
jiangli@3917 | 71 | // | (access flags bit tells whether table is present) | |
jiangli@4302 | 72 | // | (indexed from end of ConstMethod*) | |
duke@435 | 73 | // |------------------------------------------------------| |
duke@435 | 74 | // | checked exceptions elements + length (length last) | |
duke@435 | 75 | // | (length is u2, elements are u2) | |
duke@435 | 76 | // | (see class CheckedExceptionElement) | |
duke@435 | 77 | // | (access flags bit tells whether table is present) | |
jiangli@4302 | 78 | // | (indexed from end of ConstMethod*) | |
jiangli@4302 | 79 | // |------------------------------------------------------| |
coleenp@4398 | 80 | // | method parameters elements + length (length last) | |
coleenp@4398 | 81 | // | (length is u2, elements are u2, u4 structures) | |
coleenp@4398 | 82 | // | (see class MethodParametersElement) | |
coleenp@4398 | 83 | // | (access flags bit tells whether table is present) | |
coleenp@4398 | 84 | // | (indexed from end of ConstMethod*) | |
coleenp@4398 | 85 | // |------------------------------------------------------| |
jiangli@4302 | 86 | // | generic signature index (u2) | |
jiangli@4302 | 87 | // | (indexed from start of constMethodOop) | |
duke@435 | 88 | // |------------------------------------------------------| |
coleenp@4572 | 89 | // | annotations arrays - method, parameter, type, default| |
coleenp@4572 | 90 | // | pointer to Array<u1> if annotation is present | |
coleenp@4572 | 91 | // |------------------------------------------------------| |
coleenp@4398 | 92 | // |
coleenp@4398 | 93 | // IMPORTANT: If anything gets added here, there need to be changes to |
coleenp@4398 | 94 | // ensure that ServicabilityAgent doesn't get broken as a result! |
duke@435 | 95 | |
duke@435 | 96 | |
coleenp@4572 | 97 | // Utility class describing elements in checked exceptions table inlined in Method*. |
duke@435 | 98 | class CheckedExceptionElement VALUE_OBJ_CLASS_SPEC { |
duke@435 | 99 | public: |
duke@435 | 100 | u2 class_cp_index; |
duke@435 | 101 | }; |
duke@435 | 102 | |
duke@435 | 103 | |
coleenp@4572 | 104 | // Utility class describing elements in local variable table inlined in Method*. |
duke@435 | 105 | class LocalVariableTableElement VALUE_OBJ_CLASS_SPEC { |
duke@435 | 106 | public: |
duke@435 | 107 | u2 start_bci; |
duke@435 | 108 | u2 length; |
duke@435 | 109 | u2 name_cp_index; |
duke@435 | 110 | u2 descriptor_cp_index; |
duke@435 | 111 | u2 signature_cp_index; |
duke@435 | 112 | u2 slot; |
duke@435 | 113 | }; |
duke@435 | 114 | |
coleenp@4572 | 115 | // Utility class describing elements in exception table |
jiangli@3917 | 116 | class ExceptionTableElement VALUE_OBJ_CLASS_SPEC { |
jiangli@3917 | 117 | public: |
jiangli@3917 | 118 | u2 start_pc; |
jiangli@3917 | 119 | u2 end_pc; |
jiangli@3917 | 120 | u2 handler_pc; |
jiangli@3917 | 121 | u2 catch_type_index; |
jiangli@3917 | 122 | }; |
jiangli@3917 | 123 | |
coleenp@4398 | 124 | // Utility class describing elements in method parameters |
coleenp@4398 | 125 | class MethodParametersElement VALUE_OBJ_CLASS_SPEC { |
coleenp@4398 | 126 | public: |
coleenp@4398 | 127 | u2 name_cp_index; |
emc@4524 | 128 | u2 flags; |
coleenp@4398 | 129 | }; |
coleenp@4398 | 130 | |
acorn@4497 | 131 | class KlassSizeStats; |
coleenp@4037 | 132 | |
coleenp@4572 | 133 | // Class to collect the sizes of ConstMethod inline tables |
coleenp@4572 | 134 | #define INLINE_TABLES_DO(do_element) \ |
coleenp@4572 | 135 | do_element(localvariable_table_length) \ |
coleenp@4572 | 136 | do_element(compressed_linenumber_size) \ |
coleenp@4572 | 137 | do_element(exception_table_length) \ |
coleenp@4572 | 138 | do_element(checked_exceptions_length) \ |
coleenp@4572 | 139 | do_element(method_parameters_length) \ |
coleenp@4572 | 140 | do_element(generic_signature_index) \ |
coleenp@4572 | 141 | do_element(method_annotations_length) \ |
coleenp@4572 | 142 | do_element(parameter_annotations_length) \ |
coleenp@4572 | 143 | do_element(type_annotations_length) \ |
coleenp@4572 | 144 | do_element(default_annotations_length) |
coleenp@4572 | 145 | |
coleenp@4572 | 146 | #define INLINE_TABLE_DECLARE(sym) int _##sym; |
coleenp@4572 | 147 | #define INLINE_TABLE_PARAM(sym) int sym, |
coleenp@4572 | 148 | #define INLINE_TABLE_INIT(sym) _##sym(sym), |
coleenp@4572 | 149 | #define INLINE_TABLE_NULL(sym) _##sym(0), |
coleenp@4572 | 150 | #define INLINE_TABLE_ACCESSOR(sym) int sym() const { return _##sym; } |
coleenp@4572 | 151 | |
coleenp@4572 | 152 | class InlineTableSizes : StackObj { |
coleenp@4572 | 153 | // declarations |
coleenp@4572 | 154 | INLINE_TABLES_DO(INLINE_TABLE_DECLARE) |
coleenp@4572 | 155 | int _end; |
coleenp@4572 | 156 | public: |
coleenp@4572 | 157 | InlineTableSizes( |
coleenp@4572 | 158 | INLINE_TABLES_DO(INLINE_TABLE_PARAM) |
coleenp@4572 | 159 | int end) : |
coleenp@4572 | 160 | INLINE_TABLES_DO(INLINE_TABLE_INIT) |
coleenp@4572 | 161 | _end(end) {} |
coleenp@4572 | 162 | |
coleenp@4572 | 163 | // Default constructor for no inlined tables |
coleenp@4572 | 164 | InlineTableSizes() : |
coleenp@4572 | 165 | INLINE_TABLES_DO(INLINE_TABLE_NULL) |
coleenp@4572 | 166 | _end(0) {} |
coleenp@4572 | 167 | |
coleenp@4572 | 168 | // Accessors |
coleenp@4572 | 169 | INLINE_TABLES_DO(INLINE_TABLE_ACCESSOR) |
coleenp@4572 | 170 | }; |
coleenp@4572 | 171 | #undef INLINE_TABLE_ACCESSOR |
coleenp@4572 | 172 | #undef INLINE_TABLE_NULL |
coleenp@4572 | 173 | #undef INLINE_TABLE_INIT |
coleenp@4572 | 174 | #undef INLINE_TABLE_PARAM |
coleenp@4572 | 175 | #undef INLINE_TABLE_DECLARE |
coleenp@4572 | 176 | |
coleenp@4572 | 177 | |
coleenp@4037 | 178 | class ConstMethod : public MetaspaceObj { |
duke@435 | 179 | friend class VMStructs; |
kamg@4245 | 180 | |
kamg@4245 | 181 | public: |
kamg@4245 | 182 | typedef enum { NORMAL, OVERPASS } MethodType; |
kamg@4245 | 183 | |
duke@435 | 184 | private: |
duke@435 | 185 | enum { |
coleenp@4572 | 186 | _has_linenumber_table = 0x0001, |
coleenp@4572 | 187 | _has_checked_exceptions = 0x0002, |
coleenp@4572 | 188 | _has_localvariable_table = 0x0004, |
coleenp@4572 | 189 | _has_exception_table = 0x0008, |
coleenp@4572 | 190 | _has_generic_signature = 0x0010, |
coleenp@4572 | 191 | _has_method_parameters = 0x0020, |
coleenp@4572 | 192 | _is_overpass = 0x0040, |
coleenp@4572 | 193 | _has_method_annotations = 0x0080, |
coleenp@4572 | 194 | _has_parameter_annotations = 0x0100, |
coleenp@4572 | 195 | _has_type_annotations = 0x0200, |
coleenp@4572 | 196 | _has_default_annotations = 0x0400 |
duke@435 | 197 | }; |
duke@435 | 198 | |
duke@435 | 199 | // Bit vector of signature |
duke@435 | 200 | // Callers interpret 0=not initialized yet and |
duke@435 | 201 | // -1=too many args to fix, must parse the slow way. |
duke@435 | 202 | // The real initial value is special to account for nonatomicity of 64 bit |
duke@435 | 203 | // loads and stores. This value may updated and read without a lock by |
duke@435 | 204 | // multiple threads, so is volatile. |
duke@435 | 205 | volatile uint64_t _fingerprint; |
duke@435 | 206 | |
coleenp@4037 | 207 | ConstantPool* _constants; // Constant pool |
duke@435 | 208 | |
duke@435 | 209 | // Raw stackmap data for the method |
coleenp@4037 | 210 | Array<u1>* _stackmap_data; |
duke@435 | 211 | |
duke@435 | 212 | int _constMethod_size; |
coleenp@4572 | 213 | u2 _flags; |
duke@435 | 214 | |
coleenp@4037 | 215 | // Size of Java bytecodes allocated immediately after Method*. |
duke@435 | 216 | u2 _code_size; |
duke@435 | 217 | u2 _name_index; // Method name (index in constant pool) |
duke@435 | 218 | u2 _signature_index; // Method signature (index in constant pool) |
duke@435 | 219 | u2 _method_idnum; // unique identification number for the method within the class |
duke@435 | 220 | // initially corresponds to the index into the methods array. |
duke@435 | 221 | // but this may change with redefinition |
jiangli@4302 | 222 | u2 _max_stack; // Maximum number of entries on the expression stack |
jiangli@4338 | 223 | u2 _max_locals; // Number of local variables used by this method |
jiangli@4338 | 224 | u2 _size_of_parameters; // size of the parameter block (receiver + arguments) in words |
coleenp@4037 | 225 | |
coleenp@4037 | 226 | // Constructor |
coleenp@4037 | 227 | ConstMethod(int byte_code_size, |
coleenp@4572 | 228 | InlineTableSizes* sizes, |
kamg@4245 | 229 | MethodType is_overpass, |
kamg@4245 | 230 | int size); |
duke@435 | 231 | public: |
kamg@4245 | 232 | |
coleenp@4037 | 233 | static ConstMethod* allocate(ClassLoaderData* loader_data, |
kamg@4245 | 234 | int byte_code_size, |
coleenp@4572 | 235 | InlineTableSizes* sizes, |
kamg@4245 | 236 | MethodType mt, |
kamg@4245 | 237 | TRAPS); |
coleenp@4037 | 238 | |
coleenp@4037 | 239 | bool is_constMethod() const { return true; } |
coleenp@4037 | 240 | |
duke@435 | 241 | // Inlined tables |
coleenp@4572 | 242 | void set_inlined_tables_length(InlineTableSizes* sizes); |
duke@435 | 243 | |
jiangli@4302 | 244 | bool has_generic_signature() const |
jiangli@4302 | 245 | { return (_flags & _has_generic_signature) != 0; } |
jiangli@4302 | 246 | |
duke@435 | 247 | bool has_linenumber_table() const |
duke@435 | 248 | { return (_flags & _has_linenumber_table) != 0; } |
duke@435 | 249 | |
duke@435 | 250 | bool has_checked_exceptions() const |
duke@435 | 251 | { return (_flags & _has_checked_exceptions) != 0; } |
duke@435 | 252 | |
duke@435 | 253 | bool has_localvariable_table() const |
duke@435 | 254 | { return (_flags & _has_localvariable_table) != 0; } |
duke@435 | 255 | |
jiangli@3917 | 256 | bool has_exception_handler() const |
jiangli@3917 | 257 | { return (_flags & _has_exception_table) != 0; } |
jiangli@3917 | 258 | |
coleenp@4398 | 259 | bool has_method_parameters() const |
coleenp@4398 | 260 | { return (_flags & _has_method_parameters) != 0; } |
coleenp@4398 | 261 | |
kamg@4245 | 262 | MethodType method_type() const { |
kamg@4245 | 263 | return ((_flags & _is_overpass) == 0) ? NORMAL : OVERPASS; |
kamg@4245 | 264 | } |
kamg@4245 | 265 | |
kamg@4245 | 266 | void set_method_type(MethodType mt) { |
kamg@4245 | 267 | if (mt == NORMAL) { |
kamg@4245 | 268 | _flags &= ~(_is_overpass); |
kamg@4245 | 269 | } else { |
kamg@4245 | 270 | _flags |= _is_overpass; |
kamg@4245 | 271 | } |
kamg@4245 | 272 | } |
kamg@4245 | 273 | |
jiangli@3826 | 274 | // constant pool |
coleenp@4037 | 275 | ConstantPool* constants() const { return _constants; } |
coleenp@4037 | 276 | void set_constants(ConstantPool* c) { _constants = c; } |
duke@435 | 277 | |
coleenp@4037 | 278 | Method* method() const; |
duke@435 | 279 | |
duke@435 | 280 | // stackmap table data |
coleenp@4037 | 281 | Array<u1>* stackmap_data() const { return _stackmap_data; } |
coleenp@4037 | 282 | void set_stackmap_data(Array<u1>* sd) { _stackmap_data = sd; } |
coleenp@4719 | 283 | void copy_stackmap_data(ClassLoaderData* loader_data, u1* sd, int length, TRAPS); |
duke@435 | 284 | bool has_stackmap_table() const { return _stackmap_data != NULL; } |
duke@435 | 285 | |
duke@435 | 286 | void init_fingerprint() { |
duke@435 | 287 | const uint64_t initval = CONST64(0x8000000000000000); |
duke@435 | 288 | _fingerprint = initval; |
duke@435 | 289 | } |
duke@435 | 290 | |
duke@435 | 291 | uint64_t fingerprint() const { |
duke@435 | 292 | // Since reads aren't atomic for 64 bits, if any of the high or low order |
duke@435 | 293 | // word is the initial value, return 0. See init_fingerprint for initval. |
duke@435 | 294 | uint high_fp = (uint)(_fingerprint >> 32); |
duke@435 | 295 | if ((int) _fingerprint == 0 || high_fp == 0x80000000) { |
duke@435 | 296 | return 0L; |
duke@435 | 297 | } else { |
duke@435 | 298 | return _fingerprint; |
duke@435 | 299 | } |
duke@435 | 300 | } |
duke@435 | 301 | |
duke@435 | 302 | uint64_t set_fingerprint(uint64_t new_fingerprint) { |
duke@435 | 303 | #ifdef ASSERT |
duke@435 | 304 | // Assert only valid if complete/valid 64 bit _fingerprint value is read. |
duke@435 | 305 | uint64_t oldfp = fingerprint(); |
duke@435 | 306 | #endif // ASSERT |
duke@435 | 307 | _fingerprint = new_fingerprint; |
duke@435 | 308 | assert(oldfp == 0L || new_fingerprint == oldfp, |
duke@435 | 309 | "fingerprint cannot change"); |
duke@435 | 310 | assert(((new_fingerprint >> 32) != 0x80000000) && (int)new_fingerprint !=0, |
duke@435 | 311 | "fingerprint should call init to set initial value"); |
duke@435 | 312 | return new_fingerprint; |
duke@435 | 313 | } |
duke@435 | 314 | |
duke@435 | 315 | // name |
duke@435 | 316 | int name_index() const { return _name_index; } |
duke@435 | 317 | void set_name_index(int index) { _name_index = index; } |
duke@435 | 318 | |
duke@435 | 319 | // signature |
duke@435 | 320 | int signature_index() const { return _signature_index; } |
duke@435 | 321 | void set_signature_index(int index) { _signature_index = index; } |
duke@435 | 322 | |
duke@435 | 323 | // generics support |
jiangli@4302 | 324 | int generic_signature_index() const { |
jiangli@4302 | 325 | if (has_generic_signature()) { |
jiangli@4302 | 326 | return *generic_signature_index_addr(); |
jiangli@4302 | 327 | } else { |
jiangli@4302 | 328 | return 0; |
jiangli@4302 | 329 | } |
jiangli@4302 | 330 | } |
jiangli@4302 | 331 | void set_generic_signature_index(u2 index) { |
jiangli@4302 | 332 | assert(has_generic_signature(), ""); |
jiangli@4302 | 333 | u2* addr = generic_signature_index_addr(); |
jiangli@4302 | 334 | *addr = index; |
jiangli@4302 | 335 | } |
duke@435 | 336 | |
duke@435 | 337 | // Sizing |
duke@435 | 338 | static int header_size() { |
coleenp@4037 | 339 | return sizeof(ConstMethod)/HeapWordSize; |
duke@435 | 340 | } |
duke@435 | 341 | |
coleenp@4037 | 342 | // Size needed |
coleenp@4572 | 343 | static int size(int code_size, InlineTableSizes* sizes); |
duke@435 | 344 | |
coleenp@4037 | 345 | int size() const { return _constMethod_size;} |
duke@435 | 346 | void set_constMethod_size(int size) { _constMethod_size = size; } |
acorn@4497 | 347 | #if INCLUDE_SERVICES |
acorn@4497 | 348 | void collect_statistics(KlassSizeStats *sz) const; |
acorn@4497 | 349 | #endif |
duke@435 | 350 | |
duke@435 | 351 | // code size |
duke@435 | 352 | int code_size() const { return _code_size; } |
duke@435 | 353 | void set_code_size(int size) { |
duke@435 | 354 | assert(max_method_code_size < (1 << 16), |
duke@435 | 355 | "u2 is too small to hold method code size in general"); |
duke@435 | 356 | assert(0 <= size && size <= max_method_code_size, "invalid code size"); |
duke@435 | 357 | _code_size = size; |
duke@435 | 358 | } |
duke@435 | 359 | |
duke@435 | 360 | // linenumber table - note that length is unknown until decompression, |
duke@435 | 361 | // see class CompressedLineNumberReadStream. |
duke@435 | 362 | u_char* compressed_linenumber_table() const; // not preserved by gc |
jiangli@4302 | 363 | u2* generic_signature_index_addr() const; |
duke@435 | 364 | u2* checked_exceptions_length_addr() const; |
duke@435 | 365 | u2* localvariable_table_length_addr() const; |
jiangli@3917 | 366 | u2* exception_table_length_addr() const; |
coleenp@4398 | 367 | u2* method_parameters_length_addr() const; |
duke@435 | 368 | |
duke@435 | 369 | // checked exceptions |
duke@435 | 370 | int checked_exceptions_length() const; |
duke@435 | 371 | CheckedExceptionElement* checked_exceptions_start() const; |
duke@435 | 372 | |
duke@435 | 373 | // localvariable table |
duke@435 | 374 | int localvariable_table_length() const; |
duke@435 | 375 | LocalVariableTableElement* localvariable_table_start() const; |
duke@435 | 376 | |
jiangli@3917 | 377 | // exception table |
jiangli@3917 | 378 | int exception_table_length() const; |
jiangli@3917 | 379 | ExceptionTableElement* exception_table_start() const; |
jiangli@3917 | 380 | |
coleenp@4398 | 381 | // method parameters table |
coleenp@4398 | 382 | int method_parameters_length() const; |
coleenp@4398 | 383 | MethodParametersElement* method_parameters_start() const; |
coleenp@4398 | 384 | |
coleenp@4572 | 385 | // method annotations |
coleenp@4572 | 386 | bool has_method_annotations() const |
coleenp@4572 | 387 | { return (_flags & _has_method_annotations) != 0; } |
coleenp@4572 | 388 | |
coleenp@4572 | 389 | bool has_parameter_annotations() const |
coleenp@4572 | 390 | { return (_flags & _has_parameter_annotations) != 0; } |
coleenp@4572 | 391 | |
coleenp@4572 | 392 | bool has_type_annotations() const |
coleenp@4572 | 393 | { return (_flags & _has_type_annotations) != 0; } |
coleenp@4572 | 394 | |
coleenp@4572 | 395 | bool has_default_annotations() const |
coleenp@4572 | 396 | { return (_flags & _has_default_annotations) != 0; } |
coleenp@4572 | 397 | |
coleenp@4572 | 398 | |
coleenp@4572 | 399 | AnnotationArray** method_annotations_addr() const; |
coleenp@4572 | 400 | AnnotationArray* method_annotations() const { |
coleenp@4572 | 401 | return has_method_annotations() ? *(method_annotations_addr()) : NULL; |
coleenp@4572 | 402 | } |
coleenp@4572 | 403 | void set_method_annotations(AnnotationArray* anno) { |
coleenp@4572 | 404 | *(method_annotations_addr()) = anno; |
coleenp@4572 | 405 | } |
coleenp@4572 | 406 | |
coleenp@4572 | 407 | AnnotationArray** parameter_annotations_addr() const; |
coleenp@4572 | 408 | AnnotationArray* parameter_annotations() const { |
coleenp@4572 | 409 | return has_parameter_annotations() ? *(parameter_annotations_addr()) : NULL; |
coleenp@4572 | 410 | } |
coleenp@4572 | 411 | void set_parameter_annotations(AnnotationArray* anno) { |
coleenp@4572 | 412 | *(parameter_annotations_addr()) = anno; |
coleenp@4572 | 413 | } |
coleenp@4572 | 414 | |
coleenp@4572 | 415 | AnnotationArray** type_annotations_addr() const; |
coleenp@4572 | 416 | AnnotationArray* type_annotations() const { |
coleenp@4572 | 417 | return has_type_annotations() ? *(type_annotations_addr()) : NULL; |
coleenp@4572 | 418 | } |
coleenp@4572 | 419 | void set_type_annotations(AnnotationArray* anno) { |
coleenp@4572 | 420 | *(type_annotations_addr()) = anno; |
coleenp@4572 | 421 | } |
coleenp@4572 | 422 | |
coleenp@4572 | 423 | AnnotationArray** default_annotations_addr() const; |
coleenp@4572 | 424 | AnnotationArray* default_annotations() const { |
coleenp@4572 | 425 | return has_default_annotations() ? *(default_annotations_addr()) : NULL; |
coleenp@4572 | 426 | } |
coleenp@4572 | 427 | void set_default_annotations(AnnotationArray* anno) { |
coleenp@4572 | 428 | *(default_annotations_addr()) = anno; |
coleenp@4572 | 429 | } |
coleenp@4572 | 430 | |
coleenp@4572 | 431 | int method_annotations_length() const { |
coleenp@4572 | 432 | return has_method_annotations() ? method_annotations()->length() : 0; |
coleenp@4572 | 433 | } |
coleenp@4572 | 434 | int parameter_annotations_length() const { |
coleenp@4572 | 435 | return has_parameter_annotations() ? parameter_annotations()->length() : 0; |
coleenp@4572 | 436 | } |
coleenp@4572 | 437 | int type_annotations_length() const { |
coleenp@4572 | 438 | return has_type_annotations() ? type_annotations()->length() : 0; |
coleenp@4572 | 439 | } |
coleenp@4572 | 440 | int default_annotations_length() const { |
coleenp@4572 | 441 | return has_default_annotations() ? default_annotations()->length() : 0; |
coleenp@4572 | 442 | } |
coleenp@4572 | 443 | |
coleenp@4837 | 444 | // Copy annotations from other ConstMethod |
coleenp@4837 | 445 | void copy_annotations_from(ConstMethod* cm); |
coleenp@4837 | 446 | |
duke@435 | 447 | // byte codes |
twisti@1573 | 448 | void set_code(address code) { |
twisti@1573 | 449 | if (code_size() > 0) { |
twisti@1573 | 450 | memcpy(code_base(), code, code_size()); |
twisti@1573 | 451 | } |
twisti@1573 | 452 | } |
duke@435 | 453 | address code_base() const { return (address) (this+1); } |
duke@435 | 454 | address code_end() const { return code_base() + code_size(); } |
duke@435 | 455 | bool contains(address bcp) const { return code_base() <= bcp |
duke@435 | 456 | && bcp < code_end(); } |
duke@435 | 457 | // Offset to bytecodes |
duke@435 | 458 | static ByteSize codes_offset() |
coleenp@4037 | 459 | { return in_ByteSize(sizeof(ConstMethod)); } |
duke@435 | 460 | |
jiangli@3826 | 461 | static ByteSize constants_offset() |
coleenp@4037 | 462 | { return byte_offset_of(ConstMethod, _constants); } |
duke@435 | 463 | |
jiangli@4302 | 464 | static ByteSize max_stack_offset() |
jiangli@4302 | 465 | { return byte_offset_of(ConstMethod, _max_stack); } |
jiangli@4338 | 466 | static ByteSize size_of_locals_offset() |
jiangli@4338 | 467 | { return byte_offset_of(ConstMethod, _max_locals); } |
jiangli@4338 | 468 | static ByteSize size_of_parameters_offset() |
jiangli@4338 | 469 | { return byte_offset_of(ConstMethod, _size_of_parameters); } |
jiangli@4338 | 470 | |
jiangli@4302 | 471 | |
duke@435 | 472 | // Unique id for the method |
duke@435 | 473 | static const u2 MAX_IDNUM; |
duke@435 | 474 | static const u2 UNSET_IDNUM; |
duke@435 | 475 | u2 method_idnum() const { return _method_idnum; } |
duke@435 | 476 | void set_method_idnum(u2 idnum) { _method_idnum = idnum; } |
duke@435 | 477 | |
jiangli@4302 | 478 | // max stack |
jiangli@4302 | 479 | int max_stack() const { return _max_stack; } |
jiangli@4302 | 480 | void set_max_stack(int size) { _max_stack = size; } |
jiangli@4302 | 481 | |
jiangli@4338 | 482 | // max locals |
jiangli@4338 | 483 | int max_locals() const { return _max_locals; } |
jiangli@4338 | 484 | void set_max_locals(int size) { _max_locals = size; } |
jiangli@4338 | 485 | |
jiangli@4338 | 486 | // size of parameters |
jiangli@4338 | 487 | int size_of_parameters() const { return _size_of_parameters; } |
jiangli@4338 | 488 | void set_size_of_parameters(int size) { _size_of_parameters = size; } |
jiangli@4338 | 489 | |
coleenp@4037 | 490 | // Deallocation for RedefineClasses |
coleenp@4037 | 491 | void deallocate_contents(ClassLoaderData* loader_data); |
coleenp@4037 | 492 | bool is_klass() const { return false; } |
coleenp@4037 | 493 | DEBUG_ONLY(bool on_stack() { return false; }) |
coleenp@4037 | 494 | |
duke@435 | 495 | private: |
duke@435 | 496 | // Since the size of the compressed line number table is unknown, the |
duke@435 | 497 | // offsets of the other variable sized sections are computed backwards |
coleenp@4037 | 498 | // from the end of the ConstMethod*. |
duke@435 | 499 | |
coleenp@4037 | 500 | // First byte after ConstMethod* |
duke@435 | 501 | address constMethod_end() const |
coleenp@4572 | 502 | { return (address)((intptr_t*)this + _constMethod_size); } |
duke@435 | 503 | |
coleenp@4037 | 504 | // Last short in ConstMethod* |
coleenp@4572 | 505 | u2* last_u2_element() const; |
coleenp@4037 | 506 | |
coleenp@4037 | 507 | public: |
coleenp@4037 | 508 | // Printing |
coleenp@4037 | 509 | void print_on (outputStream* st) const; |
coleenp@4037 | 510 | void print_value_on(outputStream* st) const; |
coleenp@4037 | 511 | |
coleenp@4037 | 512 | const char* internal_name() const { return "{constMethod}"; } |
coleenp@4037 | 513 | |
coleenp@4037 | 514 | // Verify |
coleenp@4037 | 515 | void verify_on(outputStream* st); |
duke@435 | 516 | }; |
stefank@2314 | 517 | |
stefank@2314 | 518 | #endif // SHARE_VM_OOPS_CONSTMETHODOOP_HPP |