2007-12-01 00:00:00 +00:00
|
|
|
/*
|
2013-01-25 15:06:18 -05:00
|
|
|
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
|
2007-12-01 00:00:00 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
|
|
*
|
|
|
|
* This code is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License version 2 only, as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* version 2 for more details (a copy is included in the LICENSE file that
|
|
|
|
* accompanied this code).
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License version
|
|
|
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*
|
2010-05-27 19:08:38 -07:00
|
|
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
|
|
* or visit www.oracle.com if you need additional information or have any
|
|
|
|
* questions.
|
2007-12-01 00:00:00 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2010-11-23 13:22:55 -08:00
|
|
|
#ifndef SHARE_VM_OOPS_CONSTMETHODOOP_HPP
|
|
|
|
#define SHARE_VM_OOPS_CONSTMETHODOOP_HPP
|
|
|
|
|
|
|
|
#include "oops/oop.hpp"
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
// An ConstMethod* represents portions of a Java method which
|
2007-12-01 00:00:00 +00:00
|
|
|
// do not vary.
|
|
|
|
//
|
|
|
|
// Memory layout (each line represents a word). Note that most
|
|
|
|
// applications load thousands of methods, so keeping the size of this
|
|
|
|
// structure small has a big impact on footprint.
|
|
|
|
//
|
|
|
|
// |------------------------------------------------------|
|
|
|
|
// | header |
|
|
|
|
// | klass |
|
|
|
|
// |------------------------------------------------------|
|
|
|
|
// | fingerprint 1 |
|
|
|
|
// | fingerprint 2 |
|
2012-06-06 14:33:43 -04:00
|
|
|
// | constants (oop) |
|
2007-12-01 00:00:00 +00:00
|
|
|
// | stackmap_data (oop) |
|
|
|
|
// | constMethod_size |
|
|
|
|
// | interp_kind | flags | code_size |
|
|
|
|
// | name index | signature index |
|
2012-11-27 17:03:56 -05:00
|
|
|
// | method_idnum | max_stack |
|
2012-12-11 12:41:31 -05:00
|
|
|
// | max_locals | size_of_parameters |
|
2007-12-01 00:00:00 +00:00
|
|
|
// |------------------------------------------------------|
|
|
|
|
// | |
|
|
|
|
// | byte codes |
|
|
|
|
// | |
|
|
|
|
// |------------------------------------------------------|
|
|
|
|
// | compressed linenumber table |
|
|
|
|
// | (see class CompressedLineNumberReadStream) |
|
|
|
|
// | (note that length is unknown until decompressed) |
|
|
|
|
// | (access flags bit tells whether table is present) |
|
2012-11-27 17:03:56 -05:00
|
|
|
// | (indexed from start of ConstMethod*) |
|
2007-12-01 00:00:00 +00:00
|
|
|
// | (elements not necessarily sorted!) |
|
|
|
|
// |------------------------------------------------------|
|
|
|
|
// | localvariable table elements + length (length last) |
|
|
|
|
// | (length is u2, elements are 6-tuples of u2) |
|
|
|
|
// | (see class LocalVariableTableElement) |
|
|
|
|
// | (access flags bit tells whether table is present) |
|
2012-11-27 17:03:56 -05:00
|
|
|
// | (indexed from end of ConstMethod*) |
|
2012-06-26 19:08:44 -04:00
|
|
|
// |------------------------------------------------------|
|
|
|
|
// | exception table + length (length last) |
|
|
|
|
// | (length is u2, elements are 4-tuples of u2) |
|
|
|
|
// | (see class ExceptionTableElement) |
|
|
|
|
// | (access flags bit tells whether table is present) |
|
2012-11-27 17:03:56 -05:00
|
|
|
// | (indexed from end of ConstMethod*) |
|
2007-12-01 00:00:00 +00:00
|
|
|
// |------------------------------------------------------|
|
|
|
|
// | checked exceptions elements + length (length last) |
|
|
|
|
// | (length is u2, elements are u2) |
|
|
|
|
// | (see class CheckedExceptionElement) |
|
|
|
|
// | (access flags bit tells whether table is present) |
|
2012-11-27 17:03:56 -05:00
|
|
|
// | (indexed from end of ConstMethod*) |
|
|
|
|
// |------------------------------------------------------|
|
2013-01-08 14:01:36 -05:00
|
|
|
// | method parameters elements + length (length last) |
|
|
|
|
// | (length is u2, elements are u2, u4 structures) |
|
|
|
|
// | (see class MethodParametersElement) |
|
|
|
|
// | (access flags bit tells whether table is present) |
|
|
|
|
// | (indexed from end of ConstMethod*) |
|
|
|
|
// |------------------------------------------------------|
|
2012-11-27 17:03:56 -05:00
|
|
|
// | generic signature index (u2) |
|
|
|
|
// | (indexed from start of constMethodOop) |
|
2007-12-01 00:00:00 +00:00
|
|
|
// |------------------------------------------------------|
|
2013-01-08 14:01:36 -05:00
|
|
|
//
|
|
|
|
// IMPORTANT: If anything gets added here, there need to be changes to
|
|
|
|
// ensure that ServicabilityAgent doesn't get broken as a result!
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
// Utitily class decribing elements in checked exceptions table inlined in Method*.
|
2007-12-01 00:00:00 +00:00
|
|
|
class CheckedExceptionElement VALUE_OBJ_CLASS_SPEC {
|
|
|
|
public:
|
|
|
|
u2 class_cp_index;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
// Utitily class decribing elements in local variable table inlined in Method*.
|
2007-12-01 00:00:00 +00:00
|
|
|
class LocalVariableTableElement VALUE_OBJ_CLASS_SPEC {
|
|
|
|
public:
|
|
|
|
u2 start_bci;
|
|
|
|
u2 length;
|
|
|
|
u2 name_cp_index;
|
|
|
|
u2 descriptor_cp_index;
|
|
|
|
u2 signature_cp_index;
|
|
|
|
u2 slot;
|
|
|
|
};
|
|
|
|
|
2012-06-26 19:08:44 -04:00
|
|
|
// Utitily class describing elements in exception table
|
|
|
|
class ExceptionTableElement VALUE_OBJ_CLASS_SPEC {
|
|
|
|
public:
|
|
|
|
u2 start_pc;
|
|
|
|
u2 end_pc;
|
|
|
|
u2 handler_pc;
|
|
|
|
u2 catch_type_index;
|
|
|
|
};
|
|
|
|
|
2013-01-08 14:01:36 -05:00
|
|
|
// Utility class describing elements in method parameters
|
|
|
|
class MethodParametersElement VALUE_OBJ_CLASS_SPEC {
|
|
|
|
public:
|
|
|
|
u2 name_cp_index;
|
2013-01-14 11:01:39 -05:00
|
|
|
// This has to happen, otherwise it will cause SIGBUS from a
|
|
|
|
// misaligned u4 on some architectures (ie SPARC)
|
|
|
|
// because MethodParametersElements are only aligned mod 2
|
|
|
|
// within the ConstMethod container u2 flags_hi;
|
|
|
|
u2 flags_hi;
|
|
|
|
u2 flags_lo;
|
2013-01-08 14:01:36 -05:00
|
|
|
};
|
|
|
|
|
2013-01-25 15:06:18 -05:00
|
|
|
class KlassSizeStats;
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
|
|
|
class ConstMethod : public MetaspaceObj {
|
2007-12-01 00:00:00 +00:00
|
|
|
friend class VMStructs;
|
2012-10-11 12:25:42 -04:00
|
|
|
|
|
|
|
public:
|
|
|
|
typedef enum { NORMAL, OVERPASS } MethodType;
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
private:
|
|
|
|
enum {
|
|
|
|
_has_linenumber_table = 1,
|
|
|
|
_has_checked_exceptions = 2,
|
2012-06-26 19:08:44 -04:00
|
|
|
_has_localvariable_table = 4,
|
2012-10-11 12:25:42 -04:00
|
|
|
_has_exception_table = 8,
|
2012-11-27 17:03:56 -05:00
|
|
|
_has_generic_signature = 16,
|
2013-01-08 14:01:36 -05:00
|
|
|
_has_method_parameters = 32,
|
|
|
|
_is_overpass = 64
|
2007-12-01 00:00:00 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// Bit vector of signature
|
|
|
|
// Callers interpret 0=not initialized yet and
|
|
|
|
// -1=too many args to fix, must parse the slow way.
|
|
|
|
// The real initial value is special to account for nonatomicity of 64 bit
|
|
|
|
// loads and stores. This value may updated and read without a lock by
|
|
|
|
// multiple threads, so is volatile.
|
|
|
|
volatile uint64_t _fingerprint;
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
ConstantPool* _constants; // Constant pool
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// Raw stackmap data for the method
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
Array<u1>* _stackmap_data;
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
int _constMethod_size;
|
|
|
|
jbyte _interpreter_kind;
|
|
|
|
jbyte _flags;
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
// Size of Java bytecodes allocated immediately after Method*.
|
2007-12-01 00:00:00 +00:00
|
|
|
u2 _code_size;
|
|
|
|
u2 _name_index; // Method name (index in constant pool)
|
|
|
|
u2 _signature_index; // Method signature (index in constant pool)
|
|
|
|
u2 _method_idnum; // unique identification number for the method within the class
|
|
|
|
// initially corresponds to the index into the methods array.
|
|
|
|
// but this may change with redefinition
|
2012-11-27 17:03:56 -05:00
|
|
|
u2 _max_stack; // Maximum number of entries on the expression stack
|
2012-12-11 12:41:31 -05:00
|
|
|
u2 _max_locals; // Number of local variables used by this method
|
|
|
|
u2 _size_of_parameters; // size of the parameter block (receiver + arguments) in words
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
|
|
|
// Constructor
|
|
|
|
ConstMethod(int byte_code_size,
|
2012-10-11 12:25:42 -04:00
|
|
|
int compressed_line_number_size,
|
|
|
|
int localvariable_table_length,
|
|
|
|
int exception_table_length,
|
|
|
|
int checked_exceptions_length,
|
2013-01-08 14:01:36 -05:00
|
|
|
int method_parameters_length,
|
2012-11-27 17:03:56 -05:00
|
|
|
u2 generic_signature_index,
|
2012-10-11 12:25:42 -04:00
|
|
|
MethodType is_overpass,
|
|
|
|
int size);
|
2007-12-01 00:00:00 +00:00
|
|
|
public:
|
2012-10-11 12:25:42 -04:00
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
static ConstMethod* allocate(ClassLoaderData* loader_data,
|
2012-10-11 12:25:42 -04:00
|
|
|
int byte_code_size,
|
|
|
|
int compressed_line_number_size,
|
|
|
|
int localvariable_table_length,
|
|
|
|
int exception_table_length,
|
|
|
|
int checked_exceptions_length,
|
2013-01-08 14:01:36 -05:00
|
|
|
int method_parameters_length,
|
2012-11-27 17:03:56 -05:00
|
|
|
u2 generic_signature_index,
|
2012-10-11 12:25:42 -04:00
|
|
|
MethodType mt,
|
|
|
|
TRAPS);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
|
|
|
bool is_constMethod() const { return true; }
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
// Inlined tables
|
2012-11-27 17:03:56 -05:00
|
|
|
void set_inlined_tables_length(u2 generic_signature_index,
|
|
|
|
int checked_exceptions_len,
|
2007-12-01 00:00:00 +00:00
|
|
|
int compressed_line_number_size,
|
2012-06-26 19:08:44 -04:00
|
|
|
int localvariable_table_len,
|
2013-01-08 14:01:36 -05:00
|
|
|
int exception_table_len,
|
|
|
|
int method_parameters_length);
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2012-11-27 17:03:56 -05:00
|
|
|
bool has_generic_signature() const
|
|
|
|
{ return (_flags & _has_generic_signature) != 0; }
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
bool has_linenumber_table() const
|
|
|
|
{ return (_flags & _has_linenumber_table) != 0; }
|
|
|
|
|
|
|
|
bool has_checked_exceptions() const
|
|
|
|
{ return (_flags & _has_checked_exceptions) != 0; }
|
|
|
|
|
|
|
|
bool has_localvariable_table() const
|
|
|
|
{ return (_flags & _has_localvariable_table) != 0; }
|
|
|
|
|
2012-06-26 19:08:44 -04:00
|
|
|
bool has_exception_handler() const
|
|
|
|
{ return (_flags & _has_exception_table) != 0; }
|
|
|
|
|
2013-01-08 14:01:36 -05:00
|
|
|
bool has_method_parameters() const
|
|
|
|
{ return (_flags & _has_method_parameters) != 0; }
|
|
|
|
|
2012-10-11 12:25:42 -04:00
|
|
|
MethodType method_type() const {
|
|
|
|
return ((_flags & _is_overpass) == 0) ? NORMAL : OVERPASS;
|
|
|
|
}
|
|
|
|
|
|
|
|
void set_method_type(MethodType mt) {
|
|
|
|
if (mt == NORMAL) {
|
|
|
|
_flags &= ~(_is_overpass);
|
|
|
|
} else {
|
|
|
|
_flags |= _is_overpass;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
void set_interpreter_kind(int kind) { _interpreter_kind = kind; }
|
|
|
|
int interpreter_kind(void) const { return _interpreter_kind; }
|
|
|
|
|
2012-06-06 14:33:43 -04:00
|
|
|
// constant pool
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
ConstantPool* constants() const { return _constants; }
|
|
|
|
void set_constants(ConstantPool* c) { _constants = c; }
|
2007-12-01 00:00:00 +00:00
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
Method* method() const;
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// stackmap table data
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
Array<u1>* stackmap_data() const { return _stackmap_data; }
|
|
|
|
void set_stackmap_data(Array<u1>* sd) { _stackmap_data = sd; }
|
2007-12-01 00:00:00 +00:00
|
|
|
bool has_stackmap_table() const { return _stackmap_data != NULL; }
|
|
|
|
|
|
|
|
void init_fingerprint() {
|
|
|
|
const uint64_t initval = CONST64(0x8000000000000000);
|
|
|
|
_fingerprint = initval;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint64_t fingerprint() const {
|
|
|
|
// Since reads aren't atomic for 64 bits, if any of the high or low order
|
|
|
|
// word is the initial value, return 0. See init_fingerprint for initval.
|
|
|
|
uint high_fp = (uint)(_fingerprint >> 32);
|
|
|
|
if ((int) _fingerprint == 0 || high_fp == 0x80000000) {
|
|
|
|
return 0L;
|
|
|
|
} else {
|
|
|
|
return _fingerprint;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
uint64_t set_fingerprint(uint64_t new_fingerprint) {
|
|
|
|
#ifdef ASSERT
|
|
|
|
// Assert only valid if complete/valid 64 bit _fingerprint value is read.
|
|
|
|
uint64_t oldfp = fingerprint();
|
|
|
|
#endif // ASSERT
|
|
|
|
_fingerprint = new_fingerprint;
|
|
|
|
assert(oldfp == 0L || new_fingerprint == oldfp,
|
|
|
|
"fingerprint cannot change");
|
|
|
|
assert(((new_fingerprint >> 32) != 0x80000000) && (int)new_fingerprint !=0,
|
|
|
|
"fingerprint should call init to set initial value");
|
|
|
|
return new_fingerprint;
|
|
|
|
}
|
|
|
|
|
|
|
|
// name
|
|
|
|
int name_index() const { return _name_index; }
|
|
|
|
void set_name_index(int index) { _name_index = index; }
|
|
|
|
|
|
|
|
// signature
|
|
|
|
int signature_index() const { return _signature_index; }
|
|
|
|
void set_signature_index(int index) { _signature_index = index; }
|
|
|
|
|
|
|
|
// generics support
|
2012-11-27 17:03:56 -05:00
|
|
|
int generic_signature_index() const {
|
|
|
|
if (has_generic_signature()) {
|
|
|
|
return *generic_signature_index_addr();
|
|
|
|
} else {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
void set_generic_signature_index(u2 index) {
|
|
|
|
assert(has_generic_signature(), "");
|
|
|
|
u2* addr = generic_signature_index_addr();
|
|
|
|
*addr = index;
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// Sizing
|
|
|
|
static int header_size() {
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
return sizeof(ConstMethod)/HeapWordSize;
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
// Size needed
|
|
|
|
static int size(int code_size, int compressed_line_number_size,
|
2013-01-08 14:01:36 -05:00
|
|
|
int local_variable_table_length,
|
|
|
|
int exception_table_length,
|
|
|
|
int checked_exceptions_length,
|
|
|
|
int method_parameters_length,
|
|
|
|
u2 generic_signature_index);
|
2007-12-01 00:00:00 +00:00
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
int size() const { return _constMethod_size;}
|
2007-12-01 00:00:00 +00:00
|
|
|
void set_constMethod_size(int size) { _constMethod_size = size; }
|
2013-01-25 15:06:18 -05:00
|
|
|
#if INCLUDE_SERVICES
|
|
|
|
void collect_statistics(KlassSizeStats *sz) const;
|
|
|
|
#endif
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// code size
|
|
|
|
int code_size() const { return _code_size; }
|
|
|
|
void set_code_size(int size) {
|
|
|
|
assert(max_method_code_size < (1 << 16),
|
|
|
|
"u2 is too small to hold method code size in general");
|
|
|
|
assert(0 <= size && size <= max_method_code_size, "invalid code size");
|
|
|
|
_code_size = size;
|
|
|
|
}
|
|
|
|
|
|
|
|
// linenumber table - note that length is unknown until decompression,
|
|
|
|
// see class CompressedLineNumberReadStream.
|
|
|
|
u_char* compressed_linenumber_table() const; // not preserved by gc
|
2012-11-27 17:03:56 -05:00
|
|
|
u2* generic_signature_index_addr() const;
|
2007-12-01 00:00:00 +00:00
|
|
|
u2* checked_exceptions_length_addr() const;
|
|
|
|
u2* localvariable_table_length_addr() const;
|
2012-06-26 19:08:44 -04:00
|
|
|
u2* exception_table_length_addr() const;
|
2013-01-08 14:01:36 -05:00
|
|
|
u2* method_parameters_length_addr() const;
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// checked exceptions
|
|
|
|
int checked_exceptions_length() const;
|
|
|
|
CheckedExceptionElement* checked_exceptions_start() const;
|
|
|
|
|
|
|
|
// localvariable table
|
|
|
|
int localvariable_table_length() const;
|
|
|
|
LocalVariableTableElement* localvariable_table_start() const;
|
|
|
|
|
2012-06-26 19:08:44 -04:00
|
|
|
// exception table
|
|
|
|
int exception_table_length() const;
|
|
|
|
ExceptionTableElement* exception_table_start() const;
|
|
|
|
|
2013-01-08 14:01:36 -05:00
|
|
|
// method parameters table
|
|
|
|
int method_parameters_length() const;
|
|
|
|
MethodParametersElement* method_parameters_start() const;
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
// byte codes
|
2010-01-05 15:21:25 +01:00
|
|
|
void set_code(address code) {
|
|
|
|
if (code_size() > 0) {
|
|
|
|
memcpy(code_base(), code, code_size());
|
|
|
|
}
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
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()
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
{ return in_ByteSize(sizeof(ConstMethod)); }
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2012-06-06 14:33:43 -04:00
|
|
|
static ByteSize constants_offset()
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
{ return byte_offset_of(ConstMethod, _constants); }
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2012-11-27 17:03:56 -05:00
|
|
|
static ByteSize max_stack_offset()
|
|
|
|
{ return byte_offset_of(ConstMethod, _max_stack); }
|
2012-12-11 12:41:31 -05:00
|
|
|
static ByteSize size_of_locals_offset()
|
|
|
|
{ return byte_offset_of(ConstMethod, _max_locals); }
|
|
|
|
static ByteSize size_of_parameters_offset()
|
|
|
|
{ return byte_offset_of(ConstMethod, _size_of_parameters); }
|
|
|
|
|
2012-11-27 17:03:56 -05:00
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
// 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; }
|
|
|
|
|
2012-11-27 17:03:56 -05:00
|
|
|
// max stack
|
|
|
|
int max_stack() const { return _max_stack; }
|
|
|
|
void set_max_stack(int size) { _max_stack = size; }
|
|
|
|
|
2012-12-11 12:41:31 -05:00
|
|
|
// max locals
|
|
|
|
int max_locals() const { return _max_locals; }
|
|
|
|
void set_max_locals(int size) { _max_locals = size; }
|
|
|
|
|
|
|
|
// size of parameters
|
|
|
|
int size_of_parameters() const { return _size_of_parameters; }
|
|
|
|
void set_size_of_parameters(int size) { _size_of_parameters = size; }
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
// Deallocation for RedefineClasses
|
|
|
|
void deallocate_contents(ClassLoaderData* loader_data);
|
|
|
|
bool is_klass() const { return false; }
|
|
|
|
DEBUG_ONLY(bool on_stack() { return false; })
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
private:
|
|
|
|
// Since the size of the compressed line number table is unknown, the
|
|
|
|
// offsets of the other variable sized sections are computed backwards
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
// from the end of the ConstMethod*.
|
2007-12-01 00:00:00 +00:00
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
// First byte after ConstMethod*
|
2007-12-01 00:00:00 +00:00
|
|
|
address constMethod_end() const
|
|
|
|
{ return (address)((oop*)this + _constMethod_size); }
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
// Last short in ConstMethod*
|
2007-12-01 00:00:00 +00:00
|
|
|
u2* last_u2_element() const
|
|
|
|
{ return (u2*)constMethod_end() - 1; }
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
|
|
|
public:
|
|
|
|
// Printing
|
|
|
|
void print_on (outputStream* st) const;
|
|
|
|
void print_value_on(outputStream* st) const;
|
|
|
|
|
|
|
|
const char* internal_name() const { return "{constMethod}"; }
|
|
|
|
|
|
|
|
// Verify
|
|
|
|
void verify_on(outputStream* st);
|
2007-12-01 00:00:00 +00:00
|
|
|
};
|
2010-11-23 13:22:55 -08:00
|
|
|
|
|
|
|
#endif // SHARE_VM_OOPS_CONSTMETHODOOP_HPP
|