hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/ConstMethod.java
author coleenp
Sat, 29 Sep 2012 06:40:00 -0400
changeset 13952 e3cf184080bc
parent 13728 882756847a04
child 14586 1262473e8fc1
permissions -rw-r--r--
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass Summary: Capitalize these metadata types (and objArrayKlass) Reviewed-by: stefank, twisti, kvn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
12937
0032fb2caff6 7172967: Eliminate constMethod's _method backpointer to methodOop.
jiangli
parents: 10251
diff changeset
     2
 * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
489c9b5090e2 Initial load
duke
parents:
diff changeset
    25
package sun.jvm.hotspot.oops;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
import java.io.*;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
import java.util.*;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
import sun.jvm.hotspot.code.*;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
import sun.jvm.hotspot.debugger.*;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
import sun.jvm.hotspot.interpreter.*;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
import sun.jvm.hotspot.memory.*;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
import sun.jvm.hotspot.runtime.*;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
import sun.jvm.hotspot.types.*;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
import sun.jvm.hotspot.utilities.*;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    37
public class ConstMethod extends VMObject {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
  static {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
    VM.registerVMInitializedObserver(new Observer() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
        public void update(Observable o, Object data) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
          initialize(VM.getVM().getTypeDataBase());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
      });
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
  // anon-enum constants for _flags.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
  private static int HAS_LINENUMBER_TABLE;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
  private static int HAS_CHECKED_EXCEPTIONS;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
  private static int HAS_LOCALVARIABLE_TABLE;
13282
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
    50
  private static int HAS_EXCEPTION_TABLE;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
  private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    53
    Type type                  = db.lookupType("ConstMethod");
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    54
    constants                  = new MetadataField(type.getAddressField("_constants"), 0);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
    constMethodSize            = new CIntField(type.getCIntegerField("_constMethod_size"), 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
    flags                      = new ByteField(type.getJByteField("_flags"), 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
    // enum constants for flags
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    59
    HAS_LINENUMBER_TABLE      = db.lookupIntConstant("ConstMethod::_has_linenumber_table").intValue();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    60
    HAS_CHECKED_EXCEPTIONS     = db.lookupIntConstant("ConstMethod::_has_checked_exceptions").intValue();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    61
    HAS_LOCALVARIABLE_TABLE   = db.lookupIntConstant("ConstMethod::_has_localvariable_table").intValue();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    62
    HAS_EXCEPTION_TABLE       = db.lookupIntConstant("ConstMethod::_has_exception_table").intValue();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    64
    // Size of Java bytecodes allocated immediately after ConstMethod*.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
    codeSize                   = new CIntField(type.getCIntegerField("_code_size"), 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
    nameIndex                  = new CIntField(type.getCIntegerField("_name_index"), 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
    signatureIndex             = new CIntField(type.getCIntegerField("_signature_index"), 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
    genericSignatureIndex      = new CIntField(type.getCIntegerField("_generic_signature_index"),0);
12937
0032fb2caff6 7172967: Eliminate constMethod's _method backpointer to methodOop.
jiangli
parents: 10251
diff changeset
    69
    idnum                      = new CIntField(type.getCIntegerField("_method_idnum"), 0);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
    // start of byte code
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
    bytecodeOffset = type.getSize();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
    type                       = db.lookupType("CheckedExceptionElement");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
    checkedExceptionElementSize = type.getSize();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
    type                       = db.lookupType("LocalVariableTableElement");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
    localVariableTableElementSize = type.getSize();
13282
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
    79
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
    80
    type                       = db.lookupType("ExceptionTableElement");
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
    81
    exceptionTableElementSize = type.getSize();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    84
  public ConstMethod(Address addr) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    85
    super(addr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
  // Fields
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    89
  private static MetadataField constants;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
  private static CIntField constMethodSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
  private static ByteField flags;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
  private static CIntField codeSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
  private static CIntField nameIndex;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
  private static CIntField signatureIndex;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
  private static CIntField genericSignatureIndex;
12937
0032fb2caff6 7172967: Eliminate constMethod's _method backpointer to methodOop.
jiangli
parents: 10251
diff changeset
    96
  private static CIntField idnum;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
  // start of bytecode
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
  private static long bytecodeOffset;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
  private static long checkedExceptionElementSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
  private static long localVariableTableElementSize;
13282
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   103
  private static long exceptionTableElementSize;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
12937
0032fb2caff6 7172967: Eliminate constMethod's _method backpointer to methodOop.
jiangli
parents: 10251
diff changeset
   105
  public Method getMethod() {
0032fb2caff6 7172967: Eliminate constMethod's _method backpointer to methodOop.
jiangli
parents: 10251
diff changeset
   106
    InstanceKlass ik = (InstanceKlass)getConstants().getPoolHolder();
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   107
    MethodArray methods = ik.getMethods();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   108
    return methods.at((int)getIdNum());
12937
0032fb2caff6 7172967: Eliminate constMethod's _method backpointer to methodOop.
jiangli
parents: 10251
diff changeset
   109
  }
0032fb2caff6 7172967: Eliminate constMethod's _method backpointer to methodOop.
jiangli
parents: 10251
diff changeset
   110
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
  // Accessors for declared fields
12937
0032fb2caff6 7172967: Eliminate constMethod's _method backpointer to methodOop.
jiangli
parents: 10251
diff changeset
   112
  public ConstantPool getConstants() {
0032fb2caff6 7172967: Eliminate constMethod's _method backpointer to methodOop.
jiangli
parents: 10251
diff changeset
   113
    return (ConstantPool) constants.getValue(this);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
  public long getConstMethodSize() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
    return constMethodSize.getValue(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
  public byte getFlags() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
    return flags.getValue(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
  public long getCodeSize() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
    return codeSize.getValue(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
  public long getNameIndex() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
    return nameIndex.getValue(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
  public long getSignatureIndex() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
    return signatureIndex.getValue(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
  public long getGenericSignatureIndex() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
    return genericSignatureIndex.getValue(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
12937
0032fb2caff6 7172967: Eliminate constMethod's _method backpointer to methodOop.
jiangli
parents: 10251
diff changeset
   140
  public long getIdNum() {
0032fb2caff6 7172967: Eliminate constMethod's _method backpointer to methodOop.
jiangli
parents: 10251
diff changeset
   141
    return idnum.getValue(this);
0032fb2caff6 7172967: Eliminate constMethod's _method backpointer to methodOop.
jiangli
parents: 10251
diff changeset
   142
  }
0032fb2caff6 7172967: Eliminate constMethod's _method backpointer to methodOop.
jiangli
parents: 10251
diff changeset
   143
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
  public Symbol getName() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
    return getMethod().getName();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
  public Symbol getSignature() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
    return getMethod().getSignature();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
  public Symbol getGenericSignature() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
    return getMethod().getGenericSignature();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
  // bytecode accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
  /** Get a bytecode or breakpoint at the given bci */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
  public int getBytecodeOrBPAt(int bci) {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   160
    return getAddress().getJByteAt(bytecodeOffset + bci) & 0xFF;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
  public byte getBytecodeByteArg(int bci) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
    return (byte) getBytecodeOrBPAt(bci);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
  /** Fetches a 16-bit big-endian ("Java ordered") value from the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
      bytecode stream */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
  public short getBytecodeShortArg(int bci) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
    int hi = getBytecodeOrBPAt(bci);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
    int lo = getBytecodeOrBPAt(bci + 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
    return (short) ((hi << 8) | lo);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
10251
71b8938a2821 7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents: 5547
diff changeset
   175
  /** Fetches a 16-bit native ordered value from the
71b8938a2821 7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents: 5547
diff changeset
   176
      bytecode stream */
71b8938a2821 7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents: 5547
diff changeset
   177
  public short getNativeShortArg(int bci) {
71b8938a2821 7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents: 5547
diff changeset
   178
    int hi = getBytecodeOrBPAt(bci);
71b8938a2821 7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents: 5547
diff changeset
   179
    int lo = getBytecodeOrBPAt(bci + 1);
71b8938a2821 7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents: 5547
diff changeset
   180
    if (VM.getVM().isBigEndian()) {
71b8938a2821 7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents: 5547
diff changeset
   181
        return (short) ((hi << 8) | lo);
71b8938a2821 7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents: 5547
diff changeset
   182
    } else {
71b8938a2821 7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents: 5547
diff changeset
   183
        return (short) ((lo << 8) | hi);
71b8938a2821 7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents: 5547
diff changeset
   184
    }
71b8938a2821 7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents: 5547
diff changeset
   185
  }
71b8938a2821 7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents: 5547
diff changeset
   186
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
  /** Fetches a 32-bit big-endian ("Java ordered") value from the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
      bytecode stream */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
  public int getBytecodeIntArg(int bci) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
    int b4 = getBytecodeOrBPAt(bci);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
    int b3 = getBytecodeOrBPAt(bci + 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
    int b2 = getBytecodeOrBPAt(bci + 2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
    int b1 = getBytecodeOrBPAt(bci + 3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
    return (b4 << 24) | (b3 << 16) | (b2 << 8) | b1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
10251
71b8938a2821 7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents: 5547
diff changeset
   198
  /** Fetches a 32-bit native ordered value from the
71b8938a2821 7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents: 5547
diff changeset
   199
      bytecode stream */
71b8938a2821 7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents: 5547
diff changeset
   200
  public int getNativeIntArg(int bci) {
71b8938a2821 7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents: 5547
diff changeset
   201
    int b4 = getBytecodeOrBPAt(bci);
71b8938a2821 7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents: 5547
diff changeset
   202
    int b3 = getBytecodeOrBPAt(bci + 1);
71b8938a2821 7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents: 5547
diff changeset
   203
    int b2 = getBytecodeOrBPAt(bci + 2);
71b8938a2821 7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents: 5547
diff changeset
   204
    int b1 = getBytecodeOrBPAt(bci + 3);
71b8938a2821 7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents: 5547
diff changeset
   205
71b8938a2821 7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents: 5547
diff changeset
   206
    if (VM.getVM().isBigEndian()) {
71b8938a2821 7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents: 5547
diff changeset
   207
        return (b4 << 24) | (b3 << 16) | (b2 << 8) | b1;
71b8938a2821 7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents: 5547
diff changeset
   208
    } else {
71b8938a2821 7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents: 5547
diff changeset
   209
        return (b1 << 24) | (b2 << 16) | (b3 << 8) | b4;
71b8938a2821 7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents: 5547
diff changeset
   210
    }
71b8938a2821 7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents: 5547
diff changeset
   211
  }
71b8938a2821 7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents: 5547
diff changeset
   212
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
  public byte[] getByteCode() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
     byte[] bc = new byte[ (int) getCodeSize() ];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
     for( int i=0; i < bc.length; i++ )
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
     {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
        long offs = bytecodeOffset + i;
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   218
        bc[i] = getAddress().getJByteAt( offs );
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
     }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
     return bc;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   223
  public long getSize() {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   224
    return getConstMethodSize();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
  public void printValueOn(PrintStream tty) {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   228
    tty.print("ConstMethod " + getName().asString() + getSignature().asString() + "@" + getAddress());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   231
  public void iterateFields(MetadataVisitor visitor) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   232
    visitor.doMetadata(constants, true);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
      visitor.doCInt(constMethodSize, true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
      visitor.doByte(flags, true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
      visitor.doCInt(codeSize, true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
      visitor.doCInt(nameIndex, true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
      visitor.doCInt(signatureIndex, true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
      visitor.doCInt(genericSignatureIndex, true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
      visitor.doCInt(codeSize, true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
  // Accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
  public boolean hasLineNumberTable() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
    return (getFlags() & HAS_LINENUMBER_TABLE) != 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
  public int getLineNumberFromBCI(int bci) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
    if (!VM.getVM().isCore()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
      if (bci == DebugInformationRecorder.SYNCHRONIZATION_ENTRY_BCI) bci = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
    if (isNative()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
      return -1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
    if (Assert.ASSERTS_ENABLED) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
      Assert.that(bci == 0 || 0 <= bci && bci < getCodeSize(), "illegal bci");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
    int bestBCI  =  0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
    int bestLine = -1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
    if (hasLineNumberTable()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
      // The line numbers are a short array of 2-tuples [start_pc, line_number].
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
      // Not necessarily sorted and not necessarily one-to-one.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
      CompressedLineNumberReadStream stream =
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   266
        new CompressedLineNumberReadStream(getAddress(), (int) offsetOfCompressedLineNumberTable());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
      while (stream.readPair()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
        if (stream.bci() == bci) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
          // perfect match
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
          return stream.line();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
        } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
          // update best_bci/line
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
          if (stream.bci() < bci && stream.bci() >= bestBCI) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
            bestBCI  = stream.bci();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
            bestLine = stream.line();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
          }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
    return bestLine;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
  public LineNumberTableElement[] getLineNumberTable() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
    if (Assert.ASSERTS_ENABLED) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
      Assert.that(hasLineNumberTable(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
                  "should only be called if table is present");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
    int len = getLineNumberTableLength();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
    CompressedLineNumberReadStream stream =
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   290
      new CompressedLineNumberReadStream(getAddress(), (int) offsetOfCompressedLineNumberTable());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
    LineNumberTableElement[] ret = new LineNumberTableElement[len];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
    for (int idx = 0; idx < len; idx++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
      stream.readPair();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
      ret[idx] = new LineNumberTableElement(stream.bci(), stream.line());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
    return ret;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
  public boolean hasLocalVariableTable() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
    return (getFlags() & HAS_LOCALVARIABLE_TABLE) != 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
  public Symbol getLocalVariableName(int bci, int slot) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
    return getMethod().getLocalVariableName(bci, slot);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
  /** Should only be called if table is present */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
  public LocalVariableTableElement[] getLocalVariableTable() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
    if (Assert.ASSERTS_ENABLED) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
      Assert.that(hasLocalVariableTable(), "should only be called if table is present");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   313
    LocalVariableTableElement[] ret = new LocalVariableTableElement[getLocalVariableTableLength()];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   314
    long offset = offsetOfLocalVariableTable();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   315
    for (int i = 0; i < ret.length; i++) {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   316
      ret[i] = new LocalVariableTableElement(getAddress(), offset);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   317
      offset += localVariableTableElementSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   318
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   319
    return ret;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   320
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   321
13282
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   322
  public boolean hasExceptionTable() {
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   323
    return (getFlags() & HAS_EXCEPTION_TABLE) != 0;
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   324
  }
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   325
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   326
  public ExceptionTableElement[] getExceptionTable() {
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   327
    if (Assert.ASSERTS_ENABLED) {
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   328
      Assert.that(hasExceptionTable(), "should only be called if table is present");
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   329
    }
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   330
    ExceptionTableElement[] ret = new ExceptionTableElement[getExceptionTableLength()];
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   331
    long offset = offsetOfExceptionTable();
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   332
    for (int i = 0; i < ret.length; i++) {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   333
      ret[i] = new ExceptionTableElement(getAddress(), offset);
13282
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   334
      offset += exceptionTableElementSize;
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   335
    }
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   336
    return ret;
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   337
  }
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   338
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   339
  public boolean hasCheckedExceptions() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   340
    return (getFlags() & HAS_CHECKED_EXCEPTIONS) != 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   341
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   342
489c9b5090e2 Initial load
duke
parents:
diff changeset
   343
  public CheckedExceptionElement[] getCheckedExceptions() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   344
    if (Assert.ASSERTS_ENABLED) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   345
      Assert.that(hasCheckedExceptions(), "should only be called if table is present");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   346
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   347
    CheckedExceptionElement[] ret = new CheckedExceptionElement[getCheckedExceptionsLength()];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   348
    long offset = offsetOfCheckedExceptions();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   349
    for (int i = 0; i < ret.length; i++) {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   350
      ret[i] = new CheckedExceptionElement(getAddress(), offset);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   351
      offset += checkedExceptionElementSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   352
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   353
    return ret;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   354
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   355
489c9b5090e2 Initial load
duke
parents:
diff changeset
   356
489c9b5090e2 Initial load
duke
parents:
diff changeset
   357
  //---------------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   358
  // Internals only below this point
489c9b5090e2 Initial load
duke
parents:
diff changeset
   359
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   360
489c9b5090e2 Initial load
duke
parents:
diff changeset
   361
  private boolean isNative() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   362
    return getMethod().isNative();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   363
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   364
489c9b5090e2 Initial load
duke
parents:
diff changeset
   365
  // Offset of end of code
489c9b5090e2 Initial load
duke
parents:
diff changeset
   366
  private long offsetOfCodeEnd() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   367
    return bytecodeOffset + getCodeSize();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   368
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   369
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   370
  // Offset of start of compressed line number table (see method.hpp)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   371
  private long offsetOfCompressedLineNumberTable() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   372
    return offsetOfCodeEnd() + (isNative() ? 2 * VM.getVM().getAddressSize() : 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   373
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   374
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   375
  // Offset of last short in Method*
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   376
  private long offsetOfLastU2Element() {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   377
    return getSize() * VM.getVM().getObjectHeap().getOopSize() - 2;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   378
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   379
489c9b5090e2 Initial load
duke
parents:
diff changeset
   380
  private long offsetOfCheckedExceptionsLength() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   381
    return offsetOfLastU2Element();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   382
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   383
489c9b5090e2 Initial load
duke
parents:
diff changeset
   384
  private int getCheckedExceptionsLength() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   385
    if (hasCheckedExceptions()) {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   386
      return (int) getAddress().getCIntegerAt(offsetOfCheckedExceptionsLength(), 2, true);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   387
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   388
      return 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   389
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   390
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   391
489c9b5090e2 Initial load
duke
parents:
diff changeset
   392
  // Offset of start of checked exceptions
489c9b5090e2 Initial load
duke
parents:
diff changeset
   393
  private long offsetOfCheckedExceptions() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   394
    long offset = offsetOfCheckedExceptionsLength();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   395
    long length = getCheckedExceptionsLength();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   396
    if (Assert.ASSERTS_ENABLED) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   397
      Assert.that(length > 0, "should only be called if table is present");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   398
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   399
    offset -= length * checkedExceptionElementSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   400
    return offset;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   401
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   402
489c9b5090e2 Initial load
duke
parents:
diff changeset
   403
  private int getLineNumberTableLength() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   404
    int len = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   405
    if (hasLineNumberTable()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   406
      CompressedLineNumberReadStream stream =
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   407
        new CompressedLineNumberReadStream(getAddress(), (int) offsetOfCompressedLineNumberTable());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   408
      while (stream.readPair()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   409
        len += 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   410
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   411
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   412
    return len;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   413
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   414
489c9b5090e2 Initial load
duke
parents:
diff changeset
   415
  private int getLocalVariableTableLength() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   416
    if (hasLocalVariableTable()) {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   417
      return (int) getAddress().getCIntegerAt(offsetOfLocalVariableTableLength(), 2, true);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   418
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   419
      return 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   420
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   421
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   422
489c9b5090e2 Initial load
duke
parents:
diff changeset
   423
  // Offset of local variable table length
489c9b5090e2 Initial load
duke
parents:
diff changeset
   424
  private long offsetOfLocalVariableTableLength() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   425
    if (Assert.ASSERTS_ENABLED) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   426
      Assert.that(hasLocalVariableTable(), "should only be called if table is present");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   427
    }
13282
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   428
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   429
    if (hasExceptionTable()) {
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   430
      return offsetOfExceptionTable() - 2;
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   431
    } else if (hasCheckedExceptions()) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   432
      return offsetOfCheckedExceptions() - 2;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   433
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   434
      return offsetOfLastU2Element();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   435
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   436
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   437
489c9b5090e2 Initial load
duke
parents:
diff changeset
   438
  private long offsetOfLocalVariableTable() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   439
    long offset = offsetOfLocalVariableTableLength();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   440
    long length = getLocalVariableTableLength();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   441
    if (Assert.ASSERTS_ENABLED) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   442
      Assert.that(length > 0, "should only be called if table is present");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   443
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   444
    offset -= length * localVariableTableElementSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   445
    return offset;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   446
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   447
13282
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   448
  private int getExceptionTableLength() {
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   449
    if (hasExceptionTable()) {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   450
      return (int) getAddress().getCIntegerAt(offsetOfExceptionTableLength(), 2, true);
13282
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   451
    } else {
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   452
      return 0;
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   453
    }
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   454
  }
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   455
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   456
  private long offsetOfExceptionTableLength() {
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   457
    if (Assert.ASSERTS_ENABLED) {
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   458
      Assert.that(hasExceptionTable(), "should only be called if table is present");
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   459
    }
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   460
    if (hasCheckedExceptions()) {
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   461
      return offsetOfCheckedExceptions() - 2;
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   462
    } else {
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   463
      return offsetOfLastU2Element();
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   464
    }
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   465
  }
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   466
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   467
  private long offsetOfExceptionTable() {
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   468
    long offset = offsetOfExceptionTableLength();
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   469
    long length = getExceptionTableLength();
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   470
    if (Assert.ASSERTS_ENABLED) {
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   471
      Assert.that(length > 0, "should only be called if table is present");
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   472
    }
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   473
    offset -= length * exceptionTableElementSize;
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   474
    return offset;
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   475
  }
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   476
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   477
}