annotate jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMConfigAccess.java @ 23686:50465926fbeb jvmci-0.12

make all HotSpotVMConfigAccess subclasses and their members package-private remove toString methods from HotSpotVMConfigAccess subclasses remove HotSpotVMConfigVerifier
author Doug Simon <doug.simon@oracle.com>
date Wed, 15 Jun 2016 15:29:38 +0200
parents b5557b757040
children 9e1235406b59
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
23679
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1 /*
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
4 *
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
8 *
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
13 * accompanied this code).
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
14 *
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
18 *
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
21 * questions.
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
22 */
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
23 package jdk.vm.ci.hotspot;
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
24
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
25 import jdk.vm.ci.common.JVMCIError;
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
26
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
27 /**
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
28 * Access to VM configuration data.
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
29 */
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
30 public class HotSpotVMConfigAccess {
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
31
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
32 /**
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
33 * Gets the address of a C++ symbol.
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
34 *
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
35 * @param name name of C++ symbol
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
36 * @param notPresent if non-null and the symbol is not present then this value is returned
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
37 * @return the address of the symbol
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
38 * @throws JVMCIError if the symbol is not present and {@code notPresent == null}
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
39 */
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
40 public long getAddress(String name, Long notPresent) {
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
41 Long entry = store.vmAddresses.get(name);
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
42 if (entry == null) {
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
43 if (notPresent != null) {
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
44 return notPresent;
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
45 }
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
46 throw new JVMCIError("expected VM symbol not found: " + name);
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
47 }
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
48 return entry;
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
49 }
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
50
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
51 /**
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
52 * Gets the address of a C++ symbol.
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
53 *
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
54 * @param name name of C++ symbol
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
55 * @return the address of the symbol
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
56 * @throws JVMCIError if the symbol is not present
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
57 */
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
58 public long getAddress(String name) {
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
59 return getAddress(name, null);
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
60 }
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
61
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
62 /**
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
63 * Gets the size of a C++ type.
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
64 *
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
65 * @param name name of the type
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
66 * @return the size in bytes of the requested field
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
67 * @throws JVMCIError if the field is not present and {@code notPresent} is null
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
68 */
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
69 public int getTypeSize(String name) {
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
70 Long entry = store.vmTypeSizes.get(name);
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
71 if (entry == null) {
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
72 throw new JVMCIError("expected VM type not found: " + name);
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
73 }
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
74 return (int) (long) entry;
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
75 }
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
76
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
77 /**
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
78 * Gets the value of a C++ constant.
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
79 *
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
80 * @param name name of the constant (e.g., {@code "frame::arg_reg_save_area_bytes"})
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
81 * @param type the boxed type to which the constant value will be converted
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
82 * @param notPresent if non-null and the constant is not present then this value is returned
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
83 * @return the constant value converted to {@code type}
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
84 * @throws JVMCIError if the constant is not present and {@code notPresent == null}
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
85 */
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
86 public <T> T getConstant(String name, Class<T> type, T notPresent) {
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
87 Long c = store.vmConstants.get(name);
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
88 if (c == null) {
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
89 if (notPresent != null) {
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
90 return notPresent;
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
91 }
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
92 throw new JVMCIError("expected VM constant not found: " + name);
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
93 }
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
94 return type.cast(convertValue(name, type, c, null));
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
95 }
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
96
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
97 /**
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
98 * Gets the value of a C++ constant.
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
99 *
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
100 * @param name name of the constant (e.g., {@code "frame::arg_reg_save_area_bytes"})
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
101 * @param type the boxed type to which the constant value will be converted
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
102 * @return the constant value converted to {@code type}
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
103 * @throws JVMCIError if the constant is not present
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
104 */
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
105 public <T> T getConstant(String name, Class<T> type) {
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
106 return getConstant(name, type, null);
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
107 }
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
108
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
109 /**
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
110 * Gets the offset of a non-static C++ field.
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
111 *
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
112 * @param name fully qualified name of the field
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
113 * @param type the boxed type to which the offset value will be converted (must be
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
114 * {@link Integer} or {@link Long})
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
115 * @param cppType if non-null, the expected C++ type of the field (e.g., {@code "HeapWord*"})
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
116 * @param notPresent if non-null and the field is not present then this value is returned
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
117 * @return the offset in bytes of the requested field
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
118 * @throws JVMCIError if the field is static or not present and {@code notPresent} is null
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
119 */
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
120 public <T> T getFieldOffset(String name, Class<T> type, String cppType, T notPresent) {
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
121 assert type == Integer.class || type == Long.class;
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
122 VMField entry = getField(name, cppType, notPresent == null);
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
123 if (entry == null) {
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
124 return notPresent;
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
125 }
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
126 if (entry.address != 0) {
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
127 throw new JVMCIError("cannot get offset of static field " + name);
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
128 }
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
129 return entry == null ? notPresent : type.cast(convertValue(name, type, entry.offset, cppType));
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
130 }
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
131
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
132 /**
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
133 * Gets the offset of a non-static C++ field.
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
134 *
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
135 * @param name fully qualified name of the field
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
136 * @param type the boxed type to which the offset value will be converted (must be
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
137 * {@link Integer} or {@link Long})
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
138 * @param cppType if non-null, the expected C++ type of the field (e.g., {@code "HeapWord*"})
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
139 * @return the offset in bytes of the requested field
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
140 * @throws JVMCIError if the field is static or not present
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
141 */
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
142 public <T> T getFieldOffset(String name, Class<T> type, String cppType) {
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
143 return getFieldOffset(name, type, cppType, null);
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
144 }
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
145
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
146 /**
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
147 * Gets the offset of a non-static C++ field.
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
148 *
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
149 * @param name fully qualified name of the field
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
150 * @param type the boxed type to which the offset value will be converted (must be
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
151 * {@link Integer} or {@link Long})
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
152 * @return the offset in bytes of the requested field
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
153 * @throws JVMCIError if the field is static or not present
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
154 */
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
155 public <T> T getFieldOffset(String name, Class<T> type) {
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
156 return getFieldOffset(name, type, null, null);
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
157 }
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
158
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
159 /**
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
160 * Gets the address of a static C++ field.
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
161 *
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
162 * @param name fully qualified name of the field
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
163 * @param cppType if non-null, the expected C++ type of the field (e.g., {@code "HeapWord*"})
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
164 * @param notPresent if non-null and the field is not present then this value is returned
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
165 * @return the address of the requested field
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
166 * @throws JVMCIError if the field is not static or not present and {@code notPresent} is null
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
167 */
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
168 public long getFieldAddress(String name, String cppType, Long notPresent) {
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
169 VMField entry = getField(name, cppType, notPresent == null);
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
170 if (entry == null) {
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
171 return notPresent;
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
172 }
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
173 if (entry.address == 0) {
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
174 throw new JVMCIError(name + " is not a static field");
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
175 }
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
176 return entry == null ? notPresent : entry.address;
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
177 }
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
178
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
179 /**
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
180 * Gets the address of a static C++ field.
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
181 *
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
182 * @param name fully qualified name of the field
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
183 * @param cppType if non-null, the expected C++ type of the field (e.g., {@code "HeapWord*"})
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
184 * @return the address of the requested field
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
185 * @throws JVMCIError if the field is not static or not present
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
186 */
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
187 public long getFieldAddress(String name, String cppType) {
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
188 return getFieldAddress(name, cppType, null);
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
189 }
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
190
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
191 /**
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
192 * Gets the value of a static C++ field.
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
193 *
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
194 * @param name fully qualified name of the field
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
195 * @param type the boxed type to which the constant value will be converted
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
196 * @param cppType if non-null, the expected C++ type of the field (e.g., {@code "HeapWord*"})
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
197 * @param notPresent if non-null and the field is not present then this value is returned
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
198 * @return the value of the requested field
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
199 * @throws JVMCIError if the field is not static or not present and {@code notPresent} is null
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
200 */
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
201 public <T> T getFieldValue(String name, Class<T> type, String cppType, T notPresent) {
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
202 VMField entry = getField(name, cppType, notPresent == null);
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
203 if (entry == null) {
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
204 return notPresent;
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
205 }
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
206 if (entry.value == null) {
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
207 throw new JVMCIError(name + " is not a static field");
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
208 }
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
209 return type.cast(convertValue(name, type, entry.value, cppType));
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
210 }
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
211
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
212 /**
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
213 * Gets the value of a static C++ field.
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
214 *
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
215 * @param name fully qualified name of the field
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
216 * @param type the boxed type to which the constant value will be converted
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
217 * @param cppType if non-null, the expected C++ type of the field (e.g., {@code "HeapWord*"})
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
218 * @return the value of the requested field
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
219 * @throws JVMCIError if the field is not static or not present
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
220 */
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
221 public <T> T getFieldValue(String name, Class<T> type, String cppType) {
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
222 return getFieldValue(name, type, cppType, null);
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
223 }
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
224
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
225 /**
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
226 * Gets the value of a static C++ field.
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
227 *
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
228 * @param name fully qualified name of the field
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
229 * @param type the boxed type to which the constant value will be converted
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
230 * @return the value of the requested field
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
231 * @throws JVMCIError if the field is not static or not present
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
232 */
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
233 public <T> T getFieldValue(String name, Class<T> type) {
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
234 return getFieldValue(name, type, null, null);
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
235 }
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
236
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
237 /**
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
238 * Gets a C++ field.
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
239 *
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
240 * @param name fully qualified name of the field
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
241 * @param cppType if non-null, the expected C++ type of the field (e.g., {@code "HeapWord*"})
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
242 * @param required specifies if the field must be present
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
243 * @return the field
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
244 * @throws JVMCIError if the field is not present and {@code required == true}
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
245 */
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
246 private VMField getField(String name, String cppType, boolean required) {
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
247 VMField entry = store.vmFields.get(name);
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
248 if (entry == null) {
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
249 if (!required) {
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
250 return null;
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
251 }
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
252 throw new JVMCIError("expected VM field not found: " + name);
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
253 }
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
254
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
255 // Make sure the native type is still the type we expect.
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
256 if (cppType != null && !cppType.equals(entry.type)) {
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
257 throw new JVMCIError("expected type " + cppType + " but VM field " + name + " is of type " + entry.type);
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
258 }
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
259 return entry;
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
260 }
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
261
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
262 /**
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
263 * Gets a VM flag value.
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
264 *
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
265 * @param name name of the flag (e.g., {@code "CompileTheWorldStartAt"})
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
266 * @param type the boxed type to which the flag's value will be converted
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
267 * @return the flag's value converted to {@code type} or {@code notPresent} if the flag is not
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
268 * present
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
269 * @throws JVMCIError if the flag is not present
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
270 */
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
271 public <T> T getFlag(String name, Class<T> type) {
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
272 return getFlag(name, type, null);
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
273 }
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
274
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
275 /**
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
276 * Gets a VM flag value.
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
277 *
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
278 * @param name name of the flag (e.g., {@code "CompileTheWorldStartAt"})
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
279 * @param type the boxed type to which the flag's value will be converted
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
280 * @param notPresent if non-null and the flag is not present then this value is returned
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
281 * @return the flag's value converted to {@code type} or {@code notPresent} if the flag is not
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
282 * present
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
283 * @throws JVMCIError if the flag is not present and {@code notPresent == null}
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
284 */
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
285 public <T> T getFlag(String name, Class<T> type, T notPresent) {
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
286 VMFlag entry = store.vmFlags.get(name);
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
287 if (entry == null) {
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
288 if (notPresent != null) {
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
289 return notPresent;
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
290 }
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
291 throw new JVMCIError("expected VM flag not found: " + name);
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
292 }
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
293 return type.cast(convertValue(name, type, entry.value, entry.type));
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
294 }
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
295
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
296 private static <T> Object convertValue(String name, Class<T> toType, Object value, String cppType) throws JVMCIError {
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
297 if (toType == Boolean.class) {
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
298 if (value instanceof String) {
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
299 return Boolean.valueOf((String) value);
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
300 } else if (value instanceof Boolean) {
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
301 return value;
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
302 } else if (value instanceof Long) {
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
303 return ((long) value) != 0;
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
304 }
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
305 } else if (toType == Byte.class) {
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
306 if (value instanceof Long) {
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
307 return (byte) (long) value;
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
308 }
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
309 } else if (toType == Integer.class) {
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
310 if (value instanceof Integer) {
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
311 return value;
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
312 } else if (value instanceof Long) {
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
313 return (int) (long) value;
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
314 }
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
315 } else if (toType == Long.class) {
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
316 return (long) value;
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
317 }
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
318
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
319 throw new JVMCIError("cannot convert " + name + " of type " + value.getClass().getSimpleName() + (cppType == null ? "" : " [" + cppType + "]") + " to " + toType.getSimpleName());
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
320 }
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
321
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
322 private final HotSpotVMConfigStore store;
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
323
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
324 public HotSpotVMConfigAccess(HotSpotVMConfigStore store) {
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
325 this.store = store;
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
326 }
b5557b757040 fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
327 }