src/share/vm/oops/constMethod.hpp

Mon, 12 Aug 2019 18:30:40 +0300

author
apetushkov
date
Mon, 12 Aug 2019 18:30:40 +0300
changeset 9858
b985cbb00e68
parent 8368
32b682649973
child 8604
04d83ba48607
permissions
-rw-r--r--

8223147: JFR Backport
8199712: Flight Recorder
8203346: JFR: Inconsistent signature of jfr_add_string_constant
8195817: JFR.stop should require name of recording
8195818: JFR.start should increase autogenerated name by one
8195819: Remove recording=x from jcmd JFR.check output
8203921: JFR thread sampling is missing fixes from JDK-8194552
8203929: Limit amount of data for JFR.dump
8203664: JFR start failure after AppCDS archive created with JFR StartFlightRecording
8003209: JFR events for network utilization
8207392: [PPC64] Implement JFR profiling
8202835: jfr/event/os/TestSystemProcess.java fails on missing events
Summary: Backport JFR from JDK11. Initial integration
Reviewed-by: neugens

duke@435 1 /*
kevinw@8368 2 * Copyright (c) 2003, 2016, 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;
kevinw@8368 214 u1 _result_type; // BasicType of result
duke@435 215
coleenp@4037 216 // Size of Java bytecodes allocated immediately after Method*.
duke@435 217 u2 _code_size;
duke@435 218 u2 _name_index; // Method name (index in constant pool)
duke@435 219 u2 _signature_index; // Method signature (index in constant pool)
duke@435 220 u2 _method_idnum; // unique identification number for the method within the class
duke@435 221 // initially corresponds to the index into the methods array.
duke@435 222 // but this may change with redefinition
jiangli@4302 223 u2 _max_stack; // Maximum number of entries on the expression stack
jiangli@4338 224 u2 _max_locals; // Number of local variables used by this method
jiangli@4338 225 u2 _size_of_parameters; // size of the parameter block (receiver + arguments) in words
sspitsyn@7636 226 u2 _orig_method_idnum; // Original unique identification number for the method
coleenp@4037 227
coleenp@4037 228 // Constructor
coleenp@4037 229 ConstMethod(int byte_code_size,
coleenp@4572 230 InlineTableSizes* sizes,
kamg@4245 231 MethodType is_overpass,
kamg@4245 232 int size);
duke@435 233 public:
kamg@4245 234
coleenp@4037 235 static ConstMethod* allocate(ClassLoaderData* loader_data,
kamg@4245 236 int byte_code_size,
coleenp@4572 237 InlineTableSizes* sizes,
kamg@4245 238 MethodType mt,
kamg@4245 239 TRAPS);
coleenp@4037 240
coleenp@4037 241 bool is_constMethod() const { return true; }
coleenp@4037 242
duke@435 243 // Inlined tables
coleenp@4572 244 void set_inlined_tables_length(InlineTableSizes* sizes);
duke@435 245
jiangli@4302 246 bool has_generic_signature() const
jiangli@4302 247 { return (_flags & _has_generic_signature) != 0; }
jiangli@4302 248
duke@435 249 bool has_linenumber_table() const
duke@435 250 { return (_flags & _has_linenumber_table) != 0; }
duke@435 251
duke@435 252 bool has_checked_exceptions() const
duke@435 253 { return (_flags & _has_checked_exceptions) != 0; }
duke@435 254
duke@435 255 bool has_localvariable_table() const
duke@435 256 { return (_flags & _has_localvariable_table) != 0; }
duke@435 257
jiangli@3917 258 bool has_exception_handler() const
jiangli@3917 259 { return (_flags & _has_exception_table) != 0; }
jiangli@3917 260
coleenp@4398 261 bool has_method_parameters() const
coleenp@4398 262 { return (_flags & _has_method_parameters) != 0; }
coleenp@4398 263
kamg@4245 264 MethodType method_type() const {
kamg@4245 265 return ((_flags & _is_overpass) == 0) ? NORMAL : OVERPASS;
kamg@4245 266 }
kamg@4245 267
kamg@4245 268 void set_method_type(MethodType mt) {
kamg@4245 269 if (mt == NORMAL) {
kamg@4245 270 _flags &= ~(_is_overpass);
kamg@4245 271 } else {
kamg@4245 272 _flags |= _is_overpass;
kamg@4245 273 }
kamg@4245 274 }
kamg@4245 275
jiangli@3826 276 // constant pool
coleenp@4037 277 ConstantPool* constants() const { return _constants; }
coleenp@4037 278 void set_constants(ConstantPool* c) { _constants = c; }
duke@435 279
coleenp@4037 280 Method* method() const;
duke@435 281
duke@435 282 // stackmap table data
coleenp@4037 283 Array<u1>* stackmap_data() const { return _stackmap_data; }
coleenp@4037 284 void set_stackmap_data(Array<u1>* sd) { _stackmap_data = sd; }
coleenp@4719 285 void copy_stackmap_data(ClassLoaderData* loader_data, u1* sd, int length, TRAPS);
duke@435 286 bool has_stackmap_table() const { return _stackmap_data != NULL; }
duke@435 287
duke@435 288 void init_fingerprint() {
duke@435 289 const uint64_t initval = CONST64(0x8000000000000000);
duke@435 290 _fingerprint = initval;
duke@435 291 }
duke@435 292
duke@435 293 uint64_t fingerprint() const {
duke@435 294 // Since reads aren't atomic for 64 bits, if any of the high or low order
duke@435 295 // word is the initial value, return 0. See init_fingerprint for initval.
duke@435 296 uint high_fp = (uint)(_fingerprint >> 32);
duke@435 297 if ((int) _fingerprint == 0 || high_fp == 0x80000000) {
duke@435 298 return 0L;
duke@435 299 } else {
duke@435 300 return _fingerprint;
duke@435 301 }
duke@435 302 }
duke@435 303
duke@435 304 uint64_t set_fingerprint(uint64_t new_fingerprint) {
duke@435 305 #ifdef ASSERT
duke@435 306 // Assert only valid if complete/valid 64 bit _fingerprint value is read.
duke@435 307 uint64_t oldfp = fingerprint();
duke@435 308 #endif // ASSERT
duke@435 309 _fingerprint = new_fingerprint;
duke@435 310 assert(oldfp == 0L || new_fingerprint == oldfp,
duke@435 311 "fingerprint cannot change");
duke@435 312 assert(((new_fingerprint >> 32) != 0x80000000) && (int)new_fingerprint !=0,
duke@435 313 "fingerprint should call init to set initial value");
duke@435 314 return new_fingerprint;
duke@435 315 }
duke@435 316
duke@435 317 // name
duke@435 318 int name_index() const { return _name_index; }
duke@435 319 void set_name_index(int index) { _name_index = index; }
duke@435 320
duke@435 321 // signature
duke@435 322 int signature_index() const { return _signature_index; }
duke@435 323 void set_signature_index(int index) { _signature_index = index; }
duke@435 324
duke@435 325 // generics support
jiangli@4302 326 int generic_signature_index() const {
jiangli@4302 327 if (has_generic_signature()) {
jiangli@4302 328 return *generic_signature_index_addr();
jiangli@4302 329 } else {
jiangli@4302 330 return 0;
jiangli@4302 331 }
jiangli@4302 332 }
jiangli@4302 333 void set_generic_signature_index(u2 index) {
jiangli@4302 334 assert(has_generic_signature(), "");
jiangli@4302 335 u2* addr = generic_signature_index_addr();
jiangli@4302 336 *addr = index;
jiangli@4302 337 }
duke@435 338
duke@435 339 // Sizing
duke@435 340 static int header_size() {
coleenp@4037 341 return sizeof(ConstMethod)/HeapWordSize;
duke@435 342 }
duke@435 343
coleenp@4037 344 // Size needed
coleenp@4572 345 static int size(int code_size, InlineTableSizes* sizes);
duke@435 346
coleenp@4037 347 int size() const { return _constMethod_size;}
duke@435 348 void set_constMethod_size(int size) { _constMethod_size = size; }
acorn@4497 349 #if INCLUDE_SERVICES
acorn@4497 350 void collect_statistics(KlassSizeStats *sz) const;
acorn@4497 351 #endif
duke@435 352
duke@435 353 // code size
duke@435 354 int code_size() const { return _code_size; }
duke@435 355 void set_code_size(int size) {
duke@435 356 assert(max_method_code_size < (1 << 16),
duke@435 357 "u2 is too small to hold method code size in general");
duke@435 358 assert(0 <= size && size <= max_method_code_size, "invalid code size");
duke@435 359 _code_size = size;
duke@435 360 }
duke@435 361
duke@435 362 // linenumber table - note that length is unknown until decompression,
duke@435 363 // see class CompressedLineNumberReadStream.
duke@435 364 u_char* compressed_linenumber_table() const; // not preserved by gc
jiangli@4302 365 u2* generic_signature_index_addr() const;
duke@435 366 u2* checked_exceptions_length_addr() const;
duke@435 367 u2* localvariable_table_length_addr() const;
jiangli@3917 368 u2* exception_table_length_addr() const;
coleenp@4398 369 u2* method_parameters_length_addr() const;
duke@435 370
duke@435 371 // checked exceptions
duke@435 372 int checked_exceptions_length() const;
duke@435 373 CheckedExceptionElement* checked_exceptions_start() const;
duke@435 374
duke@435 375 // localvariable table
duke@435 376 int localvariable_table_length() const;
duke@435 377 LocalVariableTableElement* localvariable_table_start() const;
duke@435 378
jiangli@3917 379 // exception table
jiangli@3917 380 int exception_table_length() const;
jiangli@3917 381 ExceptionTableElement* exception_table_start() const;
jiangli@3917 382
coleenp@4398 383 // method parameters table
coleenp@4398 384 int method_parameters_length() const;
coleenp@4398 385 MethodParametersElement* method_parameters_start() const;
coleenp@4398 386
coleenp@4572 387 // method annotations
coleenp@4572 388 bool has_method_annotations() const
coleenp@4572 389 { return (_flags & _has_method_annotations) != 0; }
coleenp@4572 390
coleenp@4572 391 bool has_parameter_annotations() const
coleenp@4572 392 { return (_flags & _has_parameter_annotations) != 0; }
coleenp@4572 393
coleenp@4572 394 bool has_type_annotations() const
coleenp@4572 395 { return (_flags & _has_type_annotations) != 0; }
coleenp@4572 396
coleenp@4572 397 bool has_default_annotations() const
coleenp@4572 398 { return (_flags & _has_default_annotations) != 0; }
coleenp@4572 399
coleenp@4572 400
coleenp@4572 401 AnnotationArray** method_annotations_addr() const;
coleenp@4572 402 AnnotationArray* method_annotations() const {
coleenp@4572 403 return has_method_annotations() ? *(method_annotations_addr()) : NULL;
coleenp@4572 404 }
coleenp@4572 405 void set_method_annotations(AnnotationArray* anno) {
coleenp@4572 406 *(method_annotations_addr()) = anno;
coleenp@4572 407 }
coleenp@4572 408
coleenp@4572 409 AnnotationArray** parameter_annotations_addr() const;
coleenp@4572 410 AnnotationArray* parameter_annotations() const {
coleenp@4572 411 return has_parameter_annotations() ? *(parameter_annotations_addr()) : NULL;
coleenp@4572 412 }
coleenp@4572 413 void set_parameter_annotations(AnnotationArray* anno) {
coleenp@4572 414 *(parameter_annotations_addr()) = anno;
coleenp@4572 415 }
coleenp@4572 416
coleenp@4572 417 AnnotationArray** type_annotations_addr() const;
coleenp@4572 418 AnnotationArray* type_annotations() const {
coleenp@4572 419 return has_type_annotations() ? *(type_annotations_addr()) : NULL;
coleenp@4572 420 }
coleenp@4572 421 void set_type_annotations(AnnotationArray* anno) {
coleenp@4572 422 *(type_annotations_addr()) = anno;
coleenp@4572 423 }
coleenp@4572 424
coleenp@4572 425 AnnotationArray** default_annotations_addr() const;
coleenp@4572 426 AnnotationArray* default_annotations() const {
coleenp@4572 427 return has_default_annotations() ? *(default_annotations_addr()) : NULL;
coleenp@4572 428 }
coleenp@4572 429 void set_default_annotations(AnnotationArray* anno) {
coleenp@4572 430 *(default_annotations_addr()) = anno;
coleenp@4572 431 }
coleenp@4572 432
coleenp@4572 433 int method_annotations_length() const {
coleenp@4572 434 return has_method_annotations() ? method_annotations()->length() : 0;
coleenp@4572 435 }
coleenp@4572 436 int parameter_annotations_length() const {
coleenp@4572 437 return has_parameter_annotations() ? parameter_annotations()->length() : 0;
coleenp@4572 438 }
coleenp@4572 439 int type_annotations_length() const {
coleenp@4572 440 return has_type_annotations() ? type_annotations()->length() : 0;
coleenp@4572 441 }
coleenp@4572 442 int default_annotations_length() const {
coleenp@4572 443 return has_default_annotations() ? default_annotations()->length() : 0;
coleenp@4572 444 }
coleenp@4572 445
coleenp@4837 446 // Copy annotations from other ConstMethod
coleenp@4837 447 void copy_annotations_from(ConstMethod* cm);
coleenp@4837 448
duke@435 449 // byte codes
twisti@1573 450 void set_code(address code) {
twisti@1573 451 if (code_size() > 0) {
twisti@1573 452 memcpy(code_base(), code, code_size());
twisti@1573 453 }
twisti@1573 454 }
duke@435 455 address code_base() const { return (address) (this+1); }
duke@435 456 address code_end() const { return code_base() + code_size(); }
duke@435 457 bool contains(address bcp) const { return code_base() <= bcp
duke@435 458 && bcp < code_end(); }
duke@435 459 // Offset to bytecodes
duke@435 460 static ByteSize codes_offset()
coleenp@4037 461 { return in_ByteSize(sizeof(ConstMethod)); }
duke@435 462
jiangli@3826 463 static ByteSize constants_offset()
coleenp@4037 464 { return byte_offset_of(ConstMethod, _constants); }
duke@435 465
jiangli@4302 466 static ByteSize max_stack_offset()
jiangli@4302 467 { return byte_offset_of(ConstMethod, _max_stack); }
jiangli@4338 468 static ByteSize size_of_locals_offset()
jiangli@4338 469 { return byte_offset_of(ConstMethod, _max_locals); }
jiangli@4338 470 static ByteSize size_of_parameters_offset()
jiangli@4338 471 { return byte_offset_of(ConstMethod, _size_of_parameters); }
jiangli@4338 472
kevinw@8368 473 static ByteSize result_type_offset()
kevinw@8368 474 { return byte_offset_of(ConstMethod, _result_type); }
jiangli@4302 475
duke@435 476 // Unique id for the method
duke@435 477 static const u2 MAX_IDNUM;
duke@435 478 static const u2 UNSET_IDNUM;
duke@435 479 u2 method_idnum() const { return _method_idnum; }
duke@435 480 void set_method_idnum(u2 idnum) { _method_idnum = idnum; }
duke@435 481
sspitsyn@7636 482 u2 orig_method_idnum() const { return _orig_method_idnum; }
sspitsyn@7636 483 void set_orig_method_idnum(u2 idnum) { _orig_method_idnum = idnum; }
sspitsyn@7636 484
jiangli@4302 485 // max stack
jiangli@4302 486 int max_stack() const { return _max_stack; }
jiangli@4302 487 void set_max_stack(int size) { _max_stack = size; }
jiangli@4302 488
jiangli@4338 489 // max locals
jiangli@4338 490 int max_locals() const { return _max_locals; }
jiangli@4338 491 void set_max_locals(int size) { _max_locals = size; }
jiangli@4338 492
jiangli@4338 493 // size of parameters
jiangli@4338 494 int size_of_parameters() const { return _size_of_parameters; }
jiangli@4338 495 void set_size_of_parameters(int size) { _size_of_parameters = size; }
jiangli@4338 496
kevinw@8368 497 void set_result_type(BasicType rt) { assert(rt < 16, "result type too large");
kevinw@8368 498 _result_type = (u1)rt; }
coleenp@4037 499 // Deallocation for RedefineClasses
coleenp@4037 500 void deallocate_contents(ClassLoaderData* loader_data);
coleenp@4037 501 bool is_klass() const { return false; }
coleenp@4037 502 DEBUG_ONLY(bool on_stack() { return false; })
coleenp@4037 503
duke@435 504 private:
duke@435 505 // Since the size of the compressed line number table is unknown, the
duke@435 506 // offsets of the other variable sized sections are computed backwards
coleenp@4037 507 // from the end of the ConstMethod*.
duke@435 508
coleenp@4037 509 // First byte after ConstMethod*
duke@435 510 address constMethod_end() const
coleenp@4572 511 { return (address)((intptr_t*)this + _constMethod_size); }
duke@435 512
coleenp@4037 513 // Last short in ConstMethod*
coleenp@4572 514 u2* last_u2_element() const;
coleenp@4037 515
coleenp@4037 516 public:
coleenp@4037 517 // Printing
coleenp@4037 518 void print_on (outputStream* st) const;
coleenp@4037 519 void print_value_on(outputStream* st) const;
coleenp@4037 520
coleenp@4037 521 const char* internal_name() const { return "{constMethod}"; }
coleenp@4037 522
coleenp@4037 523 // Verify
coleenp@4037 524 void verify_on(outputStream* st);
duke@435 525 };
stefank@2314 526
stefank@2314 527 #endif // SHARE_VM_OOPS_CONSTMETHODOOP_HPP

mercurial