constMethodOop.hpp revision 579
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley/*
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley * Copyright 2003-2009 Sun Microsystems, Inc. All Rights Reserved.
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley *
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley * This code is free software; you can redistribute it and/or modify it
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley * under the terms of the GNU General Public License version 2 only, as
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley * published by the Free Software Foundation.
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley *
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley * This code is distributed in the hope that it will be useful, but WITHOUT
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley * version 2 for more details (a copy is included in the LICENSE file that
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley * accompanied this code).
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley *
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley * You should have received a copy of the GNU General Public License version
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley * 2 along with this work; if not, write to the Free Software Foundation,
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley *
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley * CA 95054 USA or visit www.sun.com if you need additional information or
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley * have any questions.
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley *
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley */
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley// An constMethodOop represents portions of a Java method which
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley// do not vary.
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley//
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley// Memory layout (each line represents a word). Note that most
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley// applications load thousands of methods, so keeping the size of this
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley// structure small has a big impact on footprint.
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley//
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley// |------------------------------------------------------|
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley// | header |
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley// | klass |
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley// |------------------------------------------------------|
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley// | fingerprint 1 |
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley// | fingerprint 2 |
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley// | method (oop) |
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley// | stackmap_data (oop) |
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley// | exception_table (oop) |
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley// | constMethod_size |
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley// | interp_kind | flags | code_size |
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley// | name index | signature index |
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley// | method_idnum | generic_signature_index |
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley// |------------------------------------------------------|
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley// | |
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley// | byte codes |
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley// | |
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley// |------------------------------------------------------|
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley// | compressed linenumber table |
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley// | (see class CompressedLineNumberReadStream) |
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley// | (note that length is unknown until decompressed) |
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley// | (access flags bit tells whether table is present) |
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley// | (indexed from start of constMethodOop) |
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley// | (elements not necessarily sorted!) |
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley// |------------------------------------------------------|
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley// | localvariable table elements + length (length last) |
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley// | (length is u2, elements are 6-tuples of u2) |
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley// | (see class LocalVariableTableElement) |
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley// | (access flags bit tells whether table is present) |
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley// | (indexed from end of contMethodOop) |
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley// |------------------------------------------------------|
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley// | checked exceptions elements + length (length last) |
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley// | (length is u2, elements are u2) |
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley// | (see class CheckedExceptionElement) |
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley// | (access flags bit tells whether table is present) |
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley// | (indexed from end of constMethodOop) |
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley// |------------------------------------------------------|
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley// Utitily class decribing elements in checked exceptions table inlined in methodOop.
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halleyclass CheckedExceptionElement VALUE_OBJ_CLASS_SPEC {
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley public:
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley u2 class_cp_index;
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley};
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley// Utitily class decribing elements in local variable table inlined in methodOop.
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halleyclass LocalVariableTableElement VALUE_OBJ_CLASS_SPEC {
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley public:
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley u2 start_bci;
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley u2 length;
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley u2 name_cp_index;
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley u2 descriptor_cp_index;
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley u2 signature_cp_index;
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley u2 slot;
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley};
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halleyclass constMethodOopDesc : public oopDesc {
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley friend class constMethodKlass;
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley friend class VMStructs;
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halleyprivate:
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley enum {
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley _has_linenumber_table = 1,
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley _has_checked_exceptions = 2,
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley _has_localvariable_table = 4
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley };
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley // Bit vector of signature
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley // Callers interpret 0=not initialized yet and
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley // -1=too many args to fix, must parse the slow way.
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley // The real initial value is special to account for nonatomicity of 64 bit
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley // loads and stores. This value may updated and read without a lock by
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley // multiple threads, so is volatile.
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley volatile uint64_t _fingerprint;
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley volatile bool _is_conc_safe; // if true, safe for concurrent GC processing
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halleypublic:
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley oop* oop_block_beg() const { return adr_method(); }
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley oop* oop_block_end() const { return adr_exception_table() + 1; }
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halleyprivate:
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley //
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley // The oop block. See comment in klass.hpp before making changes.
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley //
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence // Backpointer to non-const methodOop (needed for some JVMTI operations)
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley methodOop _method;
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley // Raw stackmap data for the method
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley typeArrayOop _stackmap_data;
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley // The exception handler table. 4-tuples of ints [start_pc, end_pc,
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley // handler_pc, catch_type index] For methods with no exceptions the
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley // table is pointing to Universe::the_empty_int_array
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence typeArrayOop _exception_table;
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley //
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley // End of the oop block.
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley //
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley int _constMethod_size;
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley jbyte _interpreter_kind;
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley jbyte _flags;
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence // Size of Java bytecodes allocated immediately after methodOop.
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley u2 _code_size;
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley u2 _name_index; // Method name (index in constant pool)
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley u2 _signature_index; // Method signature (index in constant pool)
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley u2 _method_idnum; // unique identification number for the method within the class
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley // initially corresponds to the index into the methods array.
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley // but this may change with redefinition
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley u2 _generic_signature_index; // Generic signature (index in constant pool, 0 if absent)
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halleypublic:
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley // Inlined tables
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley void set_inlined_tables_length(int checked_exceptions_len,
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley int compressed_line_number_size,
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley int localvariable_table_len);
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley bool has_linenumber_table() const
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley { return (_flags & _has_linenumber_table) != 0; }
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley bool has_checked_exceptions() const
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley { return (_flags & _has_checked_exceptions) != 0; }
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley bool has_localvariable_table() const
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley { return (_flags & _has_localvariable_table) != 0; }
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley void set_interpreter_kind(int kind) { _interpreter_kind = kind; }
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley int interpreter_kind(void) const { return _interpreter_kind; }
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley // backpointer to non-const methodOop
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence methodOop method() const { return _method; }
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley void set_method(methodOop m) { oop_store_without_check((oop*)&_method, (oop) m); }
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley // stackmap table data
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley typeArrayOop stackmap_data() const { return _stackmap_data; }
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley void set_stackmap_data(typeArrayOop sd) {
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley oop_store_without_check((oop*)&_stackmap_data, (oop)sd);
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley }
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley bool has_stackmap_table() const { return _stackmap_data != NULL; }
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley // exception handler table
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley typeArrayOop exception_table() const { return _exception_table; }
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley void set_exception_table(typeArrayOop e) { oop_store_without_check((oop*) &_exception_table, (oop) e); }
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley bool has_exception_handler() const { return exception_table() != NULL && exception_table()->length() > 0; }
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley void init_fingerprint() {
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley const uint64_t initval = CONST64(0x8000000000000000);
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley _fingerprint = initval;
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley }
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley uint64_t fingerprint() const {
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley // Since reads aren't atomic for 64 bits, if any of the high or low order
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley // word is the initial value, return 0. See init_fingerprint for initval.
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley uint high_fp = (uint)(_fingerprint >> 32);
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley if ((int) _fingerprint == 0 || high_fp == 0x80000000) {
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley return 0L;
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley } else {
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley return _fingerprint;
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley }
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley }
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley uint64_t set_fingerprint(uint64_t new_fingerprint) {
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley#ifdef ASSERT
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley // Assert only valid if complete/valid 64 bit _fingerprint value is read.
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley uint64_t oldfp = fingerprint();
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley#endif // ASSERT
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley _fingerprint = new_fingerprint;
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley assert(oldfp == 0L || new_fingerprint == oldfp,
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence "fingerprint cannot change");
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley assert(((new_fingerprint >> 32) != 0x80000000) && (int)new_fingerprint !=0,
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley "fingerprint should call init to set initial value");
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley return new_fingerprint;
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence }
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley // name
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley int name_index() const { return _name_index; }
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley void set_name_index(int index) { _name_index = index; }
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence // signature
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley int signature_index() const { return _signature_index; }
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley void set_signature_index(int index) { _signature_index = index; }
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley // generics support
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley int generic_signature_index() const { return _generic_signature_index; }
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley void set_generic_signature_index(int index) { _generic_signature_index = index; }
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley // Sizing
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley static int header_size() {
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley return sizeof(constMethodOopDesc)/HeapWordSize;
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley }
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley // Object size needed
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley static int object_size(int code_size, int compressed_line_number_size,
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley int local_variable_table_length,
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley int checked_exceptions_length);
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley int object_size() const { return _constMethod_size; }
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley void set_constMethod_size(int size) { _constMethod_size = size; }
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley // Is object parsable by gc
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley bool object_is_parsable() { return object_size() > 0; }
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley // code size
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley int code_size() const { return _code_size; }
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley void set_code_size(int size) {
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley assert(max_method_code_size < (1 << 16),
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley "u2 is too small to hold method code size in general");
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley assert(0 <= size && size <= max_method_code_size, "invalid code size");
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley _code_size = size;
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley }
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley // linenumber table - note that length is unknown until decompression,
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley // see class CompressedLineNumberReadStream.
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley u_char* compressed_linenumber_table() const; // not preserved by gc
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley u2* checked_exceptions_length_addr() const;
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley u2* localvariable_table_length_addr() const;
// checked exceptions
int checked_exceptions_length() const;
CheckedExceptionElement* checked_exceptions_start() const;
// localvariable table
int localvariable_table_length() const;
LocalVariableTableElement* localvariable_table_start() const;
// byte codes
address code_base() const { return (address) (this+1); }
address code_end() const { return code_base() + code_size(); }
bool contains(address bcp) const { return code_base() <= bcp
&& bcp < code_end(); }
// Offset to bytecodes
static ByteSize codes_offset()
{ return in_ByteSize(sizeof(constMethodOopDesc)); }
// interpreter support
static ByteSize exception_table_offset()
{ return byte_offset_of(constMethodOopDesc, _exception_table); }
// Garbage collection support
oop* adr_method() const { return (oop*)&_method; }
oop* adr_stackmap_data() const { return (oop*)&_stackmap_data; }
oop* adr_exception_table() const { return (oop*)&_exception_table; }
bool is_conc_safe() { return _is_conc_safe; }
void set_is_conc_safe(bool v) { _is_conc_safe = v; }
// Unique id for the method
static const u2 MAX_IDNUM;
static const u2 UNSET_IDNUM;
u2 method_idnum() const { return _method_idnum; }
void set_method_idnum(u2 idnum) { _method_idnum = idnum; }
private:
// Since the size of the compressed line number table is unknown, the
// offsets of the other variable sized sections are computed backwards
// from the end of the constMethodOop.
// First byte after constMethodOop
address constMethod_end() const
{ return (address)((oop*)this + _constMethod_size); }
// Last short in constMethodOop
u2* last_u2_element() const
{ return (u2*)constMethod_end() - 1; }
};