comparison jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMConfigStore.java @ 23740:724fbad94ee3

expose Hotspot intrinsics and HotSpotIntrinsicCandidate info to JVMCI compilers (JDK-8164358)
author Doug Simon <doug.simon@oracle.com>
date Tue, 23 Aug 2016 22:46:08 +0200
parents 1140503536ae
children ebce30b702eb
comparison
equal deleted inserted replaced
23739:8e907980771e 23740:724fbad94ee3
22 */ 22 */
23 package jdk.vm.ci.hotspot; 23 package jdk.vm.ci.hotspot;
24 24
25 import static jdk.vm.ci.common.InitTimer.timer; 25 import static jdk.vm.ci.common.InitTimer.timer;
26 26
27 import java.util.Arrays;
27 import java.util.Collections; 28 import java.util.Collections;
28 import java.util.HashMap; 29 import java.util.HashMap;
30 import java.util.List;
29 import java.util.Map; 31 import java.util.Map;
30 32
31 import jdk.vm.ci.common.InitTimer; 33 import jdk.vm.ci.common.InitTimer;
32 34
33 /** 35 /**
78 */ 80 */
79 public Map<String, VMField> getFields() { 81 public Map<String, VMField> getFields() {
80 return Collections.unmodifiableMap(vmFields); 82 return Collections.unmodifiableMap(vmFields);
81 } 83 }
82 84
85 /**
86 * Gets the VM intrinsic descriptions exposed by this object.
87 */
88 public List<VMIntrinsicMethod> getIntrinsics() {
89 return Collections.unmodifiableList(vmIntrinsics);
90 }
91
83 final HashMap<String, VMField> vmFields; 92 final HashMap<String, VMField> vmFields;
84 final HashMap<String, Long> vmTypeSizes; 93 final HashMap<String, Long> vmTypeSizes;
85 final HashMap<String, Long> vmConstants; 94 final HashMap<String, Long> vmConstants;
86 final HashMap<String, Long> vmAddresses; 95 final HashMap<String, Long> vmAddresses;
87 final HashMap<String, VMFlag> vmFlags; 96 final HashMap<String, VMFlag> vmFlags;
97 final List<VMIntrinsicMethod> vmIntrinsics;
88 98
89 /** 99 /**
90 * Reads the database of VM info. The return value encodes the info in a nested object array 100 * Reads the database of VM info. The return value encodes the info in a nested object array
91 * that is described by the pseudo Java object {@code info} below: 101 * that is described by the pseudo Java object {@code info} below:
92 * 102 *
95 * VMField[] vmFields, 105 * VMField[] vmFields,
96 * [String name, Long size, ...] vmTypeSizes, 106 * [String name, Long size, ...] vmTypeSizes,
97 * [String name, Long value, ...] vmConstants, 107 * [String name, Long value, ...] vmConstants,
98 * [String name, Long value, ...] vmAddresses, 108 * [String name, Long value, ...] vmAddresses,
99 * VMFlag[] vmFlags 109 * VMFlag[] vmFlags
110 * VMIntrinsicMethod[] vmIntrinsics
100 * ] 111 * ]
101 * </pre> 112 * </pre>
102 */ 113 */
103 @SuppressWarnings("try") 114 @SuppressWarnings("try")
104 HotSpotVMConfigStore(CompilerToVM compilerToVm) { 115 HotSpotVMConfigStore(CompilerToVM compilerToVm) {
105 Object[] data; 116 Object[] data;
106 try (InitTimer t = timer("CompilerToVm readConfiguration")) { 117 try (InitTimer t = timer("CompilerToVm readConfiguration")) {
107 data = compilerToVm.readConfiguration(); 118 data = compilerToVm.readConfiguration();
108 } 119 }
109 assert data.length == 5 : data.length; 120 assert data.length == 6 : data.length;
110 121
111 // @formatter:off 122 // @formatter:off
112 VMField[] vmFieldsInfo = (VMField[]) data[0]; 123 VMField[] vmFieldsInfo = (VMField[]) data[0];
113 Object[] vmTypesSizesInfo = (Object[]) data[1]; 124 Object[] vmTypesSizesInfo = (Object[]) data[1];
114 Object[] vmConstantsInfo = (Object[]) data[2]; 125 Object[] vmConstantsInfo = (Object[]) data[2];
115 Object[] vmAddressesInfo = (Object[]) data[3]; 126 Object[] vmAddressesInfo = (Object[]) data[3];
116 VMFlag[] vmFlagsInfo = (VMFlag[]) data[4]; 127 VMFlag[] vmFlagsInfo = (VMFlag[]) data[4];
117 128
118 vmFields = new HashMap<>(vmFieldsInfo.length); 129 vmFields = new HashMap<>(vmFieldsInfo.length);
119 vmTypeSizes = new HashMap<>(vmTypesSizesInfo.length); 130 vmTypeSizes = new HashMap<>(vmTypesSizesInfo.length);
120 vmConstants = new HashMap<>(vmConstantsInfo.length); 131 vmConstants = new HashMap<>(vmConstantsInfo.length);
121 vmAddresses = new HashMap<>(vmAddressesInfo.length); 132 vmAddresses = new HashMap<>(vmAddressesInfo.length);
122 vmFlags = new HashMap<>(vmFlagsInfo.length); 133 vmFlags = new HashMap<>(vmFlagsInfo.length);
134 vmIntrinsics = Arrays.asList((VMIntrinsicMethod[]) data[5]);
123 // @formatter:on 135 // @formatter:on
124 136
125 try (InitTimer t = timer("HotSpotVMConfigStore<init> fill maps")) { 137 try (InitTimer t = timer("HotSpotVMConfigStore<init> fill maps")) {
126 for (VMField vmField : vmFieldsInfo) { 138 for (VMField vmField : vmFieldsInfo) {
127 vmFields.put(vmField.name, vmField); 139 vmFields.put(vmField.name, vmField);