src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/BasicTypeSize.java
author ysuenaga
Fri, 01 Dec 2017 10:04:31 +0900
changeset 48175 babef393c286
parent 47216 71c04702a3d5
permissions -rw-r--r--
8190837: BasicType and BasicTypeSize should refer to HotSpot values Reviewed-by: dholmes, jgeorge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
48175
babef393c286 8190837: BasicType and BasicTypeSize should refer to HotSpot values
ysuenaga
parents: 47216
diff changeset
     2
 * Copyright (c) 2001, 2017, 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.runtime;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
48175
babef393c286 8190837: BasicType and BasicTypeSize should refer to HotSpot values
ysuenaga
parents: 47216
diff changeset
    27
import java.util.Observer;
babef393c286 8190837: BasicType and BasicTypeSize should refer to HotSpot values
ysuenaga
parents: 47216
diff changeset
    28
import sun.jvm.hotspot.types.TypeDataBase;
babef393c286 8190837: BasicType and BasicTypeSize should refer to HotSpot values
ysuenaga
parents: 47216
diff changeset
    29
babef393c286 8190837: BasicType and BasicTypeSize should refer to HotSpot values
ysuenaga
parents: 47216
diff changeset
    30
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
/** Encapsulates the BasicTypeSize enum in globalDefinitions.hpp in
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
    the VM. */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
public class BasicTypeSize {
48175
babef393c286 8190837: BasicType and BasicTypeSize should refer to HotSpot values
ysuenaga
parents: 47216
diff changeset
    35
  private static int tBooleanSize;
babef393c286 8190837: BasicType and BasicTypeSize should refer to HotSpot values
ysuenaga
parents: 47216
diff changeset
    36
  private static int tCharSize;
babef393c286 8190837: BasicType and BasicTypeSize should refer to HotSpot values
ysuenaga
parents: 47216
diff changeset
    37
  private static int tFloatSize;
babef393c286 8190837: BasicType and BasicTypeSize should refer to HotSpot values
ysuenaga
parents: 47216
diff changeset
    38
  private static int tDoubleSize;
babef393c286 8190837: BasicType and BasicTypeSize should refer to HotSpot values
ysuenaga
parents: 47216
diff changeset
    39
  private static int tByteSize;
babef393c286 8190837: BasicType and BasicTypeSize should refer to HotSpot values
ysuenaga
parents: 47216
diff changeset
    40
  private static int tShortSize;
babef393c286 8190837: BasicType and BasicTypeSize should refer to HotSpot values
ysuenaga
parents: 47216
diff changeset
    41
  private static int tIntSize;
babef393c286 8190837: BasicType and BasicTypeSize should refer to HotSpot values
ysuenaga
parents: 47216
diff changeset
    42
  private static int tLongSize;
babef393c286 8190837: BasicType and BasicTypeSize should refer to HotSpot values
ysuenaga
parents: 47216
diff changeset
    43
  private static int tObjectSize;
babef393c286 8190837: BasicType and BasicTypeSize should refer to HotSpot values
ysuenaga
parents: 47216
diff changeset
    44
  private static int tArraySize;
babef393c286 8190837: BasicType and BasicTypeSize should refer to HotSpot values
ysuenaga
parents: 47216
diff changeset
    45
  private static int tNarrowOopSize;
babef393c286 8190837: BasicType and BasicTypeSize should refer to HotSpot values
ysuenaga
parents: 47216
diff changeset
    46
  private static int tNarrowKlassSize;
babef393c286 8190837: BasicType and BasicTypeSize should refer to HotSpot values
ysuenaga
parents: 47216
diff changeset
    47
  private static int tVoidSize;
babef393c286 8190837: BasicType and BasicTypeSize should refer to HotSpot values
ysuenaga
parents: 47216
diff changeset
    48
babef393c286 8190837: BasicType and BasicTypeSize should refer to HotSpot values
ysuenaga
parents: 47216
diff changeset
    49
  static {
babef393c286 8190837: BasicType and BasicTypeSize should refer to HotSpot values
ysuenaga
parents: 47216
diff changeset
    50
    VM.registerVMInitializedObserver(
babef393c286 8190837: BasicType and BasicTypeSize should refer to HotSpot values
ysuenaga
parents: 47216
diff changeset
    51
        (o, d) -> initialize(VM.getVM().getTypeDataBase()));
babef393c286 8190837: BasicType and BasicTypeSize should refer to HotSpot values
ysuenaga
parents: 47216
diff changeset
    52
  }
babef393c286 8190837: BasicType and BasicTypeSize should refer to HotSpot values
ysuenaga
parents: 47216
diff changeset
    53
babef393c286 8190837: BasicType and BasicTypeSize should refer to HotSpot values
ysuenaga
parents: 47216
diff changeset
    54
  private static synchronized void initialize(TypeDataBase db) {
babef393c286 8190837: BasicType and BasicTypeSize should refer to HotSpot values
ysuenaga
parents: 47216
diff changeset
    55
    tBooleanSize     = db.lookupIntConstant("T_BOOLEAN_size").intValue();
babef393c286 8190837: BasicType and BasicTypeSize should refer to HotSpot values
ysuenaga
parents: 47216
diff changeset
    56
    tCharSize        = db.lookupIntConstant("T_INT_size").intValue();
babef393c286 8190837: BasicType and BasicTypeSize should refer to HotSpot values
ysuenaga
parents: 47216
diff changeset
    57
    tFloatSize       = db.lookupIntConstant("T_FLOAT_size").intValue();
babef393c286 8190837: BasicType and BasicTypeSize should refer to HotSpot values
ysuenaga
parents: 47216
diff changeset
    58
    tDoubleSize      = db.lookupIntConstant("T_DOUBLE_size").intValue();
babef393c286 8190837: BasicType and BasicTypeSize should refer to HotSpot values
ysuenaga
parents: 47216
diff changeset
    59
    tByteSize        = db.lookupIntConstant("T_BYTE_size").intValue();
babef393c286 8190837: BasicType and BasicTypeSize should refer to HotSpot values
ysuenaga
parents: 47216
diff changeset
    60
    tShortSize       = db.lookupIntConstant("T_SHORT_size").intValue();
babef393c286 8190837: BasicType and BasicTypeSize should refer to HotSpot values
ysuenaga
parents: 47216
diff changeset
    61
    tIntSize         = db.lookupIntConstant("T_INT_size").intValue();
babef393c286 8190837: BasicType and BasicTypeSize should refer to HotSpot values
ysuenaga
parents: 47216
diff changeset
    62
    tLongSize        = db.lookupIntConstant("T_LONG_size").intValue();
babef393c286 8190837: BasicType and BasicTypeSize should refer to HotSpot values
ysuenaga
parents: 47216
diff changeset
    63
    tObjectSize      = db.lookupIntConstant("T_OBJECT_size").intValue();
babef393c286 8190837: BasicType and BasicTypeSize should refer to HotSpot values
ysuenaga
parents: 47216
diff changeset
    64
    tArraySize       = db.lookupIntConstant("T_ARRAY_size").intValue();
babef393c286 8190837: BasicType and BasicTypeSize should refer to HotSpot values
ysuenaga
parents: 47216
diff changeset
    65
    tNarrowOopSize   = db.lookupIntConstant("T_NARROWOOP_size").intValue();
babef393c286 8190837: BasicType and BasicTypeSize should refer to HotSpot values
ysuenaga
parents: 47216
diff changeset
    66
    tNarrowKlassSize = db.lookupIntConstant("T_NARROWKLASS_size").intValue();
babef393c286 8190837: BasicType and BasicTypeSize should refer to HotSpot values
ysuenaga
parents: 47216
diff changeset
    67
    tVoidSize        = db.lookupIntConstant("T_VOID_size").intValue();
babef393c286 8190837: BasicType and BasicTypeSize should refer to HotSpot values
ysuenaga
parents: 47216
diff changeset
    68
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
  public static int getTBooleanSize() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
    return tBooleanSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
  public static int getTCharSize() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
    return tCharSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
  public static int getTFloatSize() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
    return tFloatSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
  public static int getTDoubleSize() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
    return tDoubleSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  public static int getTByteSize() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
    return tByteSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
  public static int getTShortSize() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
    return tShortSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
  public static int getTIntSize() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
    return tIntSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
  public static int getTLongSize() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
    return tLongSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
  public static int getTObjectSize() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
    return tObjectSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
  public static int getTArraySize() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
    return tArraySize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
48175
babef393c286 8190837: BasicType and BasicTypeSize should refer to HotSpot values
ysuenaga
parents: 47216
diff changeset
   110
  public static int getTNarrowOopSize() {
babef393c286 8190837: BasicType and BasicTypeSize should refer to HotSpot values
ysuenaga
parents: 47216
diff changeset
   111
    return tNarrowOopSize;
babef393c286 8190837: BasicType and BasicTypeSize should refer to HotSpot values
ysuenaga
parents: 47216
diff changeset
   112
  }
babef393c286 8190837: BasicType and BasicTypeSize should refer to HotSpot values
ysuenaga
parents: 47216
diff changeset
   113
babef393c286 8190837: BasicType and BasicTypeSize should refer to HotSpot values
ysuenaga
parents: 47216
diff changeset
   114
  public static int getTNarrowKlassSize() {
babef393c286 8190837: BasicType and BasicTypeSize should refer to HotSpot values
ysuenaga
parents: 47216
diff changeset
   115
    return tNarrowKlassSize;
babef393c286 8190837: BasicType and BasicTypeSize should refer to HotSpot values
ysuenaga
parents: 47216
diff changeset
   116
  }
babef393c286 8190837: BasicType and BasicTypeSize should refer to HotSpot values
ysuenaga
parents: 47216
diff changeset
   117
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
  public static int getTVoidSize() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
    return tVoidSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
}