Mercurial > hg > graal-jvmci-8
annotate jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMConfigAccess.java @ 24127:6d70d9c43369
added ResolvedJavaType.isPlatformType (JDK-8177845)
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Sat, 15 Apr 2017 23:54:19 +0200 |
parents | 11f0412408cd |
children |
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 /** |
23740
724fbad94ee3
expose Hotspot intrinsics and HotSpotIntrinsicCandidate info to JVMCI compilers (JDK-8164358)
Doug Simon <doug.simon@oracle.com>
parents:
23700
diff
changeset
|
33 * Gets the available configuration data. |
724fbad94ee3
expose Hotspot intrinsics and HotSpotIntrinsicCandidate info to JVMCI compilers (JDK-8164358)
Doug Simon <doug.simon@oracle.com>
parents:
23700
diff
changeset
|
34 */ |
724fbad94ee3
expose Hotspot intrinsics and HotSpotIntrinsicCandidate info to JVMCI compilers (JDK-8164358)
Doug Simon <doug.simon@oracle.com>
parents:
23700
diff
changeset
|
35 public HotSpotVMConfigStore getStore() { |
724fbad94ee3
expose Hotspot intrinsics and HotSpotIntrinsicCandidate info to JVMCI compilers (JDK-8164358)
Doug Simon <doug.simon@oracle.com>
parents:
23700
diff
changeset
|
36 return store; |
724fbad94ee3
expose Hotspot intrinsics and HotSpotIntrinsicCandidate info to JVMCI compilers (JDK-8164358)
Doug Simon <doug.simon@oracle.com>
parents:
23700
diff
changeset
|
37 } |
724fbad94ee3
expose Hotspot intrinsics and HotSpotIntrinsicCandidate info to JVMCI compilers (JDK-8164358)
Doug Simon <doug.simon@oracle.com>
parents:
23700
diff
changeset
|
38 |
724fbad94ee3
expose Hotspot intrinsics and HotSpotIntrinsicCandidate info to JVMCI compilers (JDK-8164358)
Doug Simon <doug.simon@oracle.com>
parents:
23700
diff
changeset
|
39 /** |
23679
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
40 * Gets the address of a C++ symbol. |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
41 * |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
42 * @param name name of C++ symbol |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
43 * @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
|
44 * @return the address of the symbol |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
45 * @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
|
46 */ |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
47 public long getAddress(String name, Long notPresent) { |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
48 Long entry = store.vmAddresses.get(name); |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
49 if (entry == null) { |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
50 if (notPresent != null) { |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
51 return notPresent; |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
52 } |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
53 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
|
54 } |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
55 return entry; |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
56 } |
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 /** |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
59 * Gets the address of a C++ symbol. |
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 * @param name name of C++ symbol |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
62 * @return the address of the symbol |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
63 * @throws JVMCIError if the symbol is not present |
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 public long getAddress(String name) { |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
66 return getAddress(name, null); |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
67 } |
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 /** |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
70 * Gets the value of a C++ constant. |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
71 * |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
72 * @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
|
73 * @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
|
74 * @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
|
75 * @return the constant value converted to {@code type} |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
76 * @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
|
77 */ |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
78 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
|
79 Long c = store.vmConstants.get(name); |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
80 if (c == null) { |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
81 if (notPresent != null) { |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
82 return notPresent; |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
83 } |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
84 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
|
85 } |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
86 return type.cast(convertValue(name, type, c, null)); |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
87 } |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
88 |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
89 /** |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
90 * Gets the value of a C++ constant. |
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 * @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
|
93 * @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
|
94 * @return the constant value converted to {@code type} |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
95 * @throws JVMCIError if the constant is not present |
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 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
|
98 return getConstant(name, type, null); |
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 |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
101 /** |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
102 * 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
|
103 * |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
104 * @param name fully qualified name of the field |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
105 * @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
|
106 * {@link Integer} or {@link Long}) |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
107 * @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
|
108 * @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
|
109 * @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
|
110 * @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
|
111 */ |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
112 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
|
113 assert type == Integer.class || type == Long.class; |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
114 VMField entry = getField(name, cppType, notPresent == null); |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
115 if (entry == null) { |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
116 return notPresent; |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
117 } |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
118 if (entry.address != 0) { |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
119 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
|
120 } |
23700
9e1235406b59
[Findbugs] various warnings reported for JVMCI sources (JDK-8159613)
Doug Simon <doug.simon@oracle.com>
parents:
23686
diff
changeset
|
121 return type.cast(convertValue(name, type, entry.offset, cppType)); |
23679
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
122 } |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
123 |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
124 /** |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
125 * 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
|
126 * |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
127 * @param name fully qualified name of the field |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
128 * @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
|
129 * {@link Integer} or {@link Long}) |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
130 * @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
|
131 * @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
|
132 * @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
|
133 */ |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
134 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
|
135 return getFieldOffset(name, type, cppType, null); |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
136 } |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
137 |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
138 /** |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
139 * 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
|
140 * |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
141 * @param name fully qualified name of the field |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
142 * @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
|
143 * {@link Integer} or {@link Long}) |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
144 * @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
|
145 * @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
|
146 */ |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
147 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
|
148 return getFieldOffset(name, type, null, null); |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
149 } |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
150 |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
151 /** |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
152 * Gets the address of a static C++ field. |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
153 * |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
154 * @param name fully qualified name of the field |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
155 * @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
|
156 * @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
|
157 * @return the address of the requested field |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
158 * @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
|
159 */ |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
160 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
|
161 VMField entry = getField(name, cppType, notPresent == null); |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
162 if (entry == null) { |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
163 return notPresent; |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
164 } |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
165 if (entry.address == 0) { |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
166 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
|
167 } |
23700
9e1235406b59
[Findbugs] various warnings reported for JVMCI sources (JDK-8159613)
Doug Simon <doug.simon@oracle.com>
parents:
23686
diff
changeset
|
168 return entry.address; |
23679
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
169 } |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
170 |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
171 /** |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
172 * Gets the address of a static C++ field. |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
173 * |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
174 * @param name fully qualified name of the field |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
175 * @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
|
176 * @return the address of the requested field |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
177 * @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
|
178 */ |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
179 public long getFieldAddress(String name, String cppType) { |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
180 return getFieldAddress(name, cppType, null); |
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 |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
183 /** |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
184 * Gets the value of a static C++ field. |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
185 * |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
186 * @param name fully qualified name of the field |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
187 * @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
|
188 * @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
|
189 * @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
|
190 * @return the value of the requested field |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
191 * @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
|
192 */ |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
193 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
|
194 VMField entry = getField(name, cppType, notPresent == null); |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
195 if (entry == null) { |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
196 return notPresent; |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
197 } |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
198 if (entry.value == null) { |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
199 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
|
200 } |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
201 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
|
202 } |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
203 |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
204 /** |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
205 * Gets the value of a static C++ field. |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
206 * |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
207 * @param name fully qualified name of the field |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
208 * @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
|
209 * @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
|
210 * @return the value of the requested field |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
211 * @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
|
212 */ |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
213 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
|
214 return getFieldValue(name, type, cppType, null); |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
215 } |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
216 |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
217 /** |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
218 * Gets the value of a static C++ field. |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
219 * |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
220 * @param name fully qualified name of the field |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
221 * @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
|
222 * @return the value of the requested field |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
223 * @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
|
224 */ |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
225 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
|
226 return getFieldValue(name, type, null, null); |
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 |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
229 /** |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
230 * Gets a C++ field. |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
231 * |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
232 * @param name fully qualified name of the field |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
233 * @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
|
234 * @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
|
235 * @return the field |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
236 * @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
|
237 */ |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
238 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
|
239 VMField entry = store.vmFields.get(name); |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
240 if (entry == null) { |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
241 if (!required) { |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
242 return null; |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
243 } |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
244 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
|
245 } |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
246 |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
247 // 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
|
248 if (cppType != null && !cppType.equals(entry.type)) { |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
249 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
|
250 } |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
251 return entry; |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
252 } |
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 * Gets a VM flag value. |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
256 * |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
257 * @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
|
258 * @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
|
259 * @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
|
260 * present |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
261 * @throws JVMCIError if the flag is not present |
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 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
|
264 return getFlag(name, type, null); |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
265 } |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
266 |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
267 /** |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
268 * Gets a VM flag value. |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
269 * |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
270 * @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
|
271 * @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
|
272 * @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
|
273 * @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
|
274 * present |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
275 * @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
|
276 */ |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
277 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
|
278 VMFlag entry = store.vmFlags.get(name); |
23994
ebce30b702eb
[GR-2538] reduced memory overhead of HotSpotVMConfigStore
Doug Simon <doug.simon@oracle.com>
parents:
23740
diff
changeset
|
279 Object value; |
ebce30b702eb
[GR-2538] reduced memory overhead of HotSpotVMConfigStore
Doug Simon <doug.simon@oracle.com>
parents:
23740
diff
changeset
|
280 String cppType; |
23679
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
281 if (entry == null) { |
23994
ebce30b702eb
[GR-2538] reduced memory overhead of HotSpotVMConfigStore
Doug Simon <doug.simon@oracle.com>
parents:
23740
diff
changeset
|
282 // Fall back to VM call |
ebce30b702eb
[GR-2538] reduced memory overhead of HotSpotVMConfigStore
Doug Simon <doug.simon@oracle.com>
parents:
23740
diff
changeset
|
283 value = store.compilerToVm.getFlagValue(name); |
23996
11f0412408cd
8173912: [JVMCI] fix memory overhead of JVMCI
Doug Simon <doug.simon@oracle.com>
parents:
23994
diff
changeset
|
284 if (value == store.compilerToVm) { |
23994
ebce30b702eb
[GR-2538] reduced memory overhead of HotSpotVMConfigStore
Doug Simon <doug.simon@oracle.com>
parents:
23740
diff
changeset
|
285 if (notPresent != null) { |
ebce30b702eb
[GR-2538] reduced memory overhead of HotSpotVMConfigStore
Doug Simon <doug.simon@oracle.com>
parents:
23740
diff
changeset
|
286 return notPresent; |
ebce30b702eb
[GR-2538] reduced memory overhead of HotSpotVMConfigStore
Doug Simon <doug.simon@oracle.com>
parents:
23740
diff
changeset
|
287 } |
ebce30b702eb
[GR-2538] reduced memory overhead of HotSpotVMConfigStore
Doug Simon <doug.simon@oracle.com>
parents:
23740
diff
changeset
|
288 throw new JVMCIError("expected VM flag not found: " + name); |
ebce30b702eb
[GR-2538] reduced memory overhead of HotSpotVMConfigStore
Doug Simon <doug.simon@oracle.com>
parents:
23740
diff
changeset
|
289 } else { |
ebce30b702eb
[GR-2538] reduced memory overhead of HotSpotVMConfigStore
Doug Simon <doug.simon@oracle.com>
parents:
23740
diff
changeset
|
290 cppType = null; |
23679
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
291 } |
23994
ebce30b702eb
[GR-2538] reduced memory overhead of HotSpotVMConfigStore
Doug Simon <doug.simon@oracle.com>
parents:
23740
diff
changeset
|
292 } else { |
ebce30b702eb
[GR-2538] reduced memory overhead of HotSpotVMConfigStore
Doug Simon <doug.simon@oracle.com>
parents:
23740
diff
changeset
|
293 value = entry.value; |
ebce30b702eb
[GR-2538] reduced memory overhead of HotSpotVMConfigStore
Doug Simon <doug.simon@oracle.com>
parents:
23740
diff
changeset
|
294 cppType = entry.type; |
23679
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
295 } |
23994
ebce30b702eb
[GR-2538] reduced memory overhead of HotSpotVMConfigStore
Doug Simon <doug.simon@oracle.com>
parents:
23740
diff
changeset
|
296 return type.cast(convertValue(name, type, value, cppType)); |
23679
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
297 } |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
298 |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
299 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
|
300 if (toType == Boolean.class) { |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
301 if (value instanceof String) { |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
302 return Boolean.valueOf((String) value); |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
303 } else if (value instanceof Boolean) { |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
304 return value; |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
305 } else if (value instanceof Long) { |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
306 return ((long) value) != 0; |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
307 } |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
308 } else if (toType == Byte.class) { |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
309 if (value instanceof Long) { |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
310 return (byte) (long) value; |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
311 } |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
312 } else if (toType == Integer.class) { |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
313 if (value instanceof Integer) { |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
314 return value; |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
315 } else if (value instanceof Long) { |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
316 return (int) (long) value; |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
317 } |
23996
11f0412408cd
8173912: [JVMCI] fix memory overhead of JVMCI
Doug Simon <doug.simon@oracle.com>
parents:
23994
diff
changeset
|
318 } else if (toType == String.class) { |
11f0412408cd
8173912: [JVMCI] fix memory overhead of JVMCI
Doug Simon <doug.simon@oracle.com>
parents:
23994
diff
changeset
|
319 if (value == null || value instanceof String) { |
11f0412408cd
8173912: [JVMCI] fix memory overhead of JVMCI
Doug Simon <doug.simon@oracle.com>
parents:
23994
diff
changeset
|
320 return value; |
11f0412408cd
8173912: [JVMCI] fix memory overhead of JVMCI
Doug Simon <doug.simon@oracle.com>
parents:
23994
diff
changeset
|
321 } |
23679
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
322 } else if (toType == Long.class) { |
23700
9e1235406b59
[Findbugs] various warnings reported for JVMCI sources (JDK-8159613)
Doug Simon <doug.simon@oracle.com>
parents:
23686
diff
changeset
|
323 return value; |
23679
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
324 } |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
325 |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
326 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
|
327 } |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
328 |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
329 private final HotSpotVMConfigStore store; |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
330 |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
331 public HotSpotVMConfigAccess(HotSpotVMConfigStore store) { |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
332 this.store = store; |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
333 } |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
334 } |