src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/types/Field.java
author hseigel
Wed, 03 Oct 2018 09:46:46 -0400
changeset 51997 9ce37fa2e179
parent 47216 71c04702a3d5
permissions -rw-r--r--
8209138: Symbol constructor uses u1 as the element type of its name argument Summary: Maske u1 the type for Symbol values and add a function to return it as a char. Reviewed-by: dholmes, coleenp
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
51997
9ce37fa2e179 8209138: Symbol constructor uses u1 as the element type of its name argument
hseigel
parents: 47216
diff changeset
     2
 * Copyright (c) 2000, 2018, 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: 670
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 670
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: 670
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.types;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
import sun.jvm.hotspot.debugger.*;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
/** <P> This is the basic interface which describes a field in a C/C++
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
    data structure or a Java object. </P>
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
    <P> The accessors in this class are designed to allow manual
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
    coercion of the data within the field, which is often necessary
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
    when interfacing with C programs. Therefore, the accessors here do
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
    not perform any type checking. Specializations of the Field
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
    interface, such as JByteField, provide getValue() methods which
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
    both perform type checking and return the appropriate specialized
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
    type. </P>
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
    <P> See @see CIntegerType for a description of why all C integer
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
    types are bundled into the category "CIntegerType". </P>
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
    <P> As an example, coercing a pointer field into an int can be
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
    done in the following fashion (assuming the application has
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
    registered an integer type in the type database called
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
    "intptr_t"): </P>
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
    <PRE>
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
    {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
      ...
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
      Address myObject = ...;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
      CIntegerType intptr_tType = (CIntegerType) db.lookupType("intptr_t");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
      long addrVal = field.getCInteger(myObject, intptr_tType);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
      ...
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
    </PRE>
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
    FIXME: among other things, this interface is not sufficient to
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 5547
diff changeset
    59
    describe fields which are themselves arrays (like Symbol's
51997
9ce37fa2e179 8209138: Symbol constructor uses u1 as the element type of its name argument
hseigel
parents: 47216
diff changeset
    60
    u1 _body[1]).  */
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
public interface Field {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
  /** Get the name of this field */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
  public String getName();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
  /** Get the type of this field */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
  public Type getType();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
  /** Get the size, in bytes, of this field. Used for manual data
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
      structure traversal where necessary. */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
  public long getSize();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
  /** Is this a static field? */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
  public boolean isStatic();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
  /** The offset of this field, in bytes, in its containing data
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
      structure, if nonstatic. If this is a static field, throws a
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
      WrongTypeException. */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
  public long getOffset() throws WrongTypeException;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
  /** The address of this field, if it is a static field. If this is a
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
      nonstatic field, throws a WrongTypeException. */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
  public Address getStaticFieldAddress() throws WrongTypeException;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
  /** <P> These accessors require that the field be nonstatic;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
      otherwise, a WrongTypeException will be thrown. Note that type
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
      checking is not performed by these accessors in order to allow
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
      manual type coercion of field data. For better protection when
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
      accessing primitive fields, use the get(Type)Field accessors in
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
      Type.java. </P>
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
      <P> NOTE that the Address passed in to these routines may, in
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
      fact, be an OopHandle. Specifically, in a reflective system,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
      dereferencing operations applied to the OopHandle must be
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
      performed atomically with respect to GC. </P>
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
      <P> See @see CIntegerType for a description of why all C integer
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
      types are bundled into the category "CIntegerType". </P>
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
  */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
  public boolean   getJBoolean (Address addr) throws UnmappedAddressException, UnalignedAddressException, WrongTypeException;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
  public byte      getJByte    (Address addr) throws UnmappedAddressException, UnalignedAddressException, WrongTypeException;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
  public char      getJChar    (Address addr) throws UnmappedAddressException, UnalignedAddressException, WrongTypeException;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
  public short     getJShort   (Address addr) throws UnmappedAddressException, UnalignedAddressException, WrongTypeException;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
  public int       getJInt     (Address addr) throws UnmappedAddressException, UnalignedAddressException, WrongTypeException;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
  public long      getJLong    (Address addr) throws UnmappedAddressException, UnalignedAddressException, WrongTypeException;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
  public float     getJFloat   (Address addr) throws UnmappedAddressException, UnalignedAddressException, WrongTypeException;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
  public double    getJDouble  (Address addr) throws UnmappedAddressException, UnalignedAddressException, WrongTypeException;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
  public long      getCInteger (Address addr, CIntegerType type)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
    throws UnmappedAddressException, UnalignedAddressException, WrongTypeException;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
  public Address   getAddress  (Address addr) throws UnmappedAddressException, UnalignedAddressException, WrongTypeException;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
  public OopHandle getOopHandle(Address addr)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
    throws UnmappedAddressException, UnalignedAddressException, WrongTypeException, NotInHeapException;
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   112
  public OopHandle getNarrowOopHandle(Address addr)
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   113
    throws UnmappedAddressException, UnalignedAddressException, WrongTypeException, NotInHeapException;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
  /** <P> These accessors require that the field be static; otherwise,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
      a WrongTypeException will be thrown. Note that type checking is
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
      not performed by these accessors in order to allow manual type
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
      coercion of field data. For better protection when accessing
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
      primitive fields, use the get(Type)Field accessors in
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
      Type.java. </P>
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
      <P> NOTE that the Address passed in to these routines may, in
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
      fact, be an OopHandle. Specifically, in a reflective system,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
      dereferencing operations applied to the OopHandle must be
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
      performed atomically with respect to GC. </P>
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
      <P> See @see CIntegerType for a description of why all C integer
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
      types are bundled into the category "CIntegerType". </P>
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
  */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
  public boolean   getJBoolean () throws UnmappedAddressException, UnalignedAddressException, WrongTypeException;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
  public byte      getJByte    () throws UnmappedAddressException, UnalignedAddressException, WrongTypeException;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
  public char      getJChar    () throws UnmappedAddressException, UnalignedAddressException, WrongTypeException;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
  public float     getJFloat   () throws UnmappedAddressException, UnalignedAddressException, WrongTypeException;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
  public double    getJDouble  () throws UnmappedAddressException, UnalignedAddressException, WrongTypeException;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
  public int       getJInt     () throws UnmappedAddressException, UnalignedAddressException, WrongTypeException;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
  public long      getJLong    () throws UnmappedAddressException, UnalignedAddressException, WrongTypeException;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
  public short     getJShort   () throws UnmappedAddressException, UnalignedAddressException, WrongTypeException;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
  public long      getCInteger (CIntegerType type)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
    throws UnmappedAddressException, UnalignedAddressException, WrongTypeException;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
  public Address   getAddress  () throws UnmappedAddressException, UnalignedAddressException;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
  public OopHandle getOopHandle()
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
    throws UnmappedAddressException, UnalignedAddressException, NotInHeapException;
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   143
  public OopHandle getNarrowOopHandle()
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   144
    throws UnmappedAddressException, UnalignedAddressException, NotInHeapException;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
}