constMethodOop.hpp revision 579
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 * 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 * 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 * 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 * 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// An constMethodOop represents portions of a Java method which
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley// do not vary.
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// | header |
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// | byte codes |
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// Utitily class decribing elements in checked exceptions table inlined in methodOop.
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halleyclass CheckedExceptionElement VALUE_OBJ_CLASS_SPEC {
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley// Utitily class decribing elements in local variable table inlined in methodOop.
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halleyclass LocalVariableTableElement VALUE_OBJ_CLASS_SPEC {
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley friend class VMStructs;
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 bool _is_conc_safe; // if true, safe for concurrent GC processing
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley oop* oop_block_beg() const { return adr_method(); }
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley oop* oop_block_end() const { return adr_exception_table() + 1; }
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley // The oop block. See comment in klass.hpp before making changes.
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence // Backpointer to non-const methodOop (needed for some JVMTI operations)
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley // Raw stackmap data for the method
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
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley // End of the oop block.
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence // Size of Java bytecodes allocated immediately after methodOop.
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 // Inlined tables
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley void set_inlined_tables_length(int checked_exceptions_len,
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley { return (_flags & _has_linenumber_table) != 0; }
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley { return (_flags & _has_checked_exceptions) != 0; }
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley { return (_flags & _has_localvariable_table) != 0; }
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley void set_interpreter_kind(int kind) { _interpreter_kind = kind; }
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley int interpreter_kind(void) const { return _interpreter_kind; }
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley // backpointer to non-const methodOop
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley void set_method(methodOop m) { oop_store_without_check((oop*)&_method, (oop) m); }
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley // stackmap table data
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley typeArrayOop stackmap_data() const { return _stackmap_data; }
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley oop_store_without_check((oop*)&_stackmap_data, (oop)sd);
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley bool has_stackmap_table() const { return _stackmap_data != NULL; }
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 const uint64_t initval = CONST64(0x8000000000000000);
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 if ((int) _fingerprint == 0 || high_fp == 0x80000000) {
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley uint64_t set_fingerprint(uint64_t new_fingerprint) {
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley // Assert only valid if complete/valid 64 bit _fingerprint value is read.
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley#endif // ASSERT
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 void set_name_index(int index) { _name_index = index; }
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley int signature_index() const { return _signature_index; }
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley void set_signature_index(int index) { _signature_index = index; }
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 static int header_size() {
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley // Object size needed
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley static int object_size(int code_size, int compressed_line_number_size,
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 // code size
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 // 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
int checked_exceptions_length() const;
int localvariable_table_length() const;