1 /* 2 * Copyright (c) 2001, 2020, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 * 23 */ 24 25 package sun.jvm.hotspot.runtime; 26 27 import sun.jvm.hotspot.types.TypeDataBase; 28 29 30 /** Encapsulates the BasicTypeSize enum in globalDefinitions.hpp in 31 the VM. */ 32 33 public class BasicTypeSize { 34 private static int tBooleanSize; 35 private static int tCharSize; 36 private static int tFloatSize; 37 private static int tDoubleSize; 38 private static int tByteSize; 39 private static int tShortSize; 40 private static int tIntSize; 41 private static int tLongSize; 42 private static int tObjectSize; 43 private static int tArraySize; 44 private static int tNarrowOopSize; 45 private static int tNarrowKlassSize; 46 private static int tVoidSize; 47 48 static { VM.registerVMInitializedObserver(o, d) -> initialize(VM.getVM().getTypeDataBase())49 VM.registerVMInitializedObserver( 50 (o, d) -> initialize(VM.getVM().getTypeDataBase())); 51 } 52 initialize(TypeDataBase db)53 private static synchronized void initialize(TypeDataBase db) { 54 tBooleanSize = db.lookupIntConstant("T_BOOLEAN_size").intValue(); 55 tCharSize = db.lookupIntConstant("T_INT_size").intValue(); 56 tFloatSize = db.lookupIntConstant("T_FLOAT_size").intValue(); 57 tDoubleSize = db.lookupIntConstant("T_DOUBLE_size").intValue(); 58 tByteSize = db.lookupIntConstant("T_BYTE_size").intValue(); 59 tShortSize = db.lookupIntConstant("T_SHORT_size").intValue(); 60 tIntSize = db.lookupIntConstant("T_INT_size").intValue(); 61 tLongSize = db.lookupIntConstant("T_LONG_size").intValue(); 62 tObjectSize = db.lookupIntConstant("T_OBJECT_size").intValue(); 63 tArraySize = db.lookupIntConstant("T_ARRAY_size").intValue(); 64 tNarrowOopSize = db.lookupIntConstant("T_NARROWOOP_size").intValue(); 65 tNarrowKlassSize = db.lookupIntConstant("T_NARROWKLASS_size").intValue(); 66 tVoidSize = db.lookupIntConstant("T_VOID_size").intValue(); 67 } 68 getTBooleanSize()69 public static int getTBooleanSize() { 70 return tBooleanSize; 71 } 72 getTCharSize()73 public static int getTCharSize() { 74 return tCharSize; 75 } 76 getTFloatSize()77 public static int getTFloatSize() { 78 return tFloatSize; 79 } 80 getTDoubleSize()81 public static int getTDoubleSize() { 82 return tDoubleSize; 83 } 84 getTByteSize()85 public static int getTByteSize() { 86 return tByteSize; 87 } 88 getTShortSize()89 public static int getTShortSize() { 90 return tShortSize; 91 } 92 getTIntSize()93 public static int getTIntSize() { 94 return tIntSize; 95 } 96 getTLongSize()97 public static int getTLongSize() { 98 return tLongSize; 99 } 100 getTObjectSize()101 public static int getTObjectSize() { 102 return tObjectSize; 103 } 104 getTArraySize()105 public static int getTArraySize() { 106 return tArraySize; 107 } 108 getTNarrowOopSize()109 public static int getTNarrowOopSize() { 110 return tNarrowOopSize; 111 } 112 getTNarrowKlassSize()113 public static int getTNarrowKlassSize() { 114 return tNarrowKlassSize; 115 } 116 getTVoidSize()117 public static int getTVoidSize() { 118 return tVoidSize; 119 } 120 } 121