351 } else { 352 return 0; 353 } 354 } 355 void set_generic_signature_index(u2 index) { 356 assert(has_generic_signature(), ""); 357 u2* addr = generic_signature_index_addr(); 358 *addr = index; 359 } 360 361 // Sizing 362 static int header_size() { 363 return align_size_up(sizeof(ConstMethod), wordSize) / wordSize; 364 } 365 366 // Size needed 367 static int size(int code_size, InlineTableSizes* sizes); 368 369 int size() const { return _constMethod_size;} 370 void set_constMethod_size(int size) { _constMethod_size = size; } 371 #if INCLUDE_SERVICES 372 void collect_statistics(KlassSizeStats *sz) const; 373 #endif 374 375 // code size 376 int code_size() const { return _code_size; } 377 void set_code_size(int size) { 378 assert(max_method_code_size < (1 << 16), 379 "u2 is too small to hold method code size in general"); 380 assert(0 <= size && size <= max_method_code_size, "invalid code size"); 381 _code_size = size; 382 } 383 384 // linenumber table - note that length is unknown until decompression, 385 // see class CompressedLineNumberReadStream. 386 u_char* compressed_linenumber_table() const; // not preserved by gc 387 u2* generic_signature_index_addr() const; 388 u2* checked_exceptions_length_addr() const; 389 u2* localvariable_table_length_addr() const; 390 u2* exception_table_length_addr() const; 511 512 // max stack 513 int max_stack() const { return _max_stack; } 514 void set_max_stack(int size) { _max_stack = size; } 515 516 // max locals 517 int max_locals() const { return _max_locals; } 518 void set_max_locals(int size) { _max_locals = size; } 519 520 // size of parameters 521 int size_of_parameters() const { return _size_of_parameters; } 522 void set_size_of_parameters(int size) { _size_of_parameters = size; } 523 524 void set_result_type(BasicType rt) { assert(rt < 16, "result type too large"); 525 _result_type = (u1)rt; } 526 // Deallocation for RedefineClasses 527 void deallocate_contents(ClassLoaderData* loader_data); 528 bool is_klass() const { return false; } 529 DEBUG_ONLY(bool on_stack() { return false; }) 530 531 private: 532 // Since the size of the compressed line number table is unknown, the 533 // offsets of the other variable sized sections are computed backwards 534 // from the end of the ConstMethod*. 535 536 // First byte after ConstMethod* 537 address constMethod_end() const 538 { return (address)((intptr_t*)this + _constMethod_size); } 539 540 // Last short in ConstMethod* 541 u2* last_u2_element() const; 542 543 public: 544 // Printing 545 void print_on (outputStream* st) const; 546 void print_value_on(outputStream* st) const; 547 548 const char* internal_name() const { return "{constMethod}"; } 549 550 // Verify | 351 } else { 352 return 0; 353 } 354 } 355 void set_generic_signature_index(u2 index) { 356 assert(has_generic_signature(), ""); 357 u2* addr = generic_signature_index_addr(); 358 *addr = index; 359 } 360 361 // Sizing 362 static int header_size() { 363 return align_size_up(sizeof(ConstMethod), wordSize) / wordSize; 364 } 365 366 // Size needed 367 static int size(int code_size, InlineTableSizes* sizes); 368 369 int size() const { return _constMethod_size;} 370 void set_constMethod_size(int size) { _constMethod_size = size; } 371 372 // ConstMethods should be stored in the read-only region of CDS archive. 373 static bool is_read_only_by_default() { return true; } 374 375 #if INCLUDE_SERVICES 376 void collect_statistics(KlassSizeStats *sz) const; 377 #endif 378 379 // code size 380 int code_size() const { return _code_size; } 381 void set_code_size(int size) { 382 assert(max_method_code_size < (1 << 16), 383 "u2 is too small to hold method code size in general"); 384 assert(0 <= size && size <= max_method_code_size, "invalid code size"); 385 _code_size = size; 386 } 387 388 // linenumber table - note that length is unknown until decompression, 389 // see class CompressedLineNumberReadStream. 390 u_char* compressed_linenumber_table() const; // not preserved by gc 391 u2* generic_signature_index_addr() const; 392 u2* checked_exceptions_length_addr() const; 393 u2* localvariable_table_length_addr() const; 394 u2* exception_table_length_addr() const; 515 516 // max stack 517 int max_stack() const { return _max_stack; } 518 void set_max_stack(int size) { _max_stack = size; } 519 520 // max locals 521 int max_locals() const { return _max_locals; } 522 void set_max_locals(int size) { _max_locals = size; } 523 524 // size of parameters 525 int size_of_parameters() const { return _size_of_parameters; } 526 void set_size_of_parameters(int size) { _size_of_parameters = size; } 527 528 void set_result_type(BasicType rt) { assert(rt < 16, "result type too large"); 529 _result_type = (u1)rt; } 530 // Deallocation for RedefineClasses 531 void deallocate_contents(ClassLoaderData* loader_data); 532 bool is_klass() const { return false; } 533 DEBUG_ONLY(bool on_stack() { return false; }) 534 535 void metaspace_pointers_do(MetaspaceClosure* it); 536 MetaspaceObj::Type type() const { return ConstMethodType; } 537 private: 538 // Since the size of the compressed line number table is unknown, the 539 // offsets of the other variable sized sections are computed backwards 540 // from the end of the ConstMethod*. 541 542 // First byte after ConstMethod* 543 address constMethod_end() const 544 { return (address)((intptr_t*)this + _constMethod_size); } 545 546 // Last short in ConstMethod* 547 u2* last_u2_element() const; 548 549 public: 550 // Printing 551 void print_on (outputStream* st) const; 552 void print_value_on(outputStream* st) const; 553 554 const char* internal_name() const { return "{constMethod}"; } 555 556 // Verify |