comparison jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMetaAccessProvider.java @ 23392:b3a816d3b844

Backed out changeset: a920338dd4d4
author Doug Simon <doug.simon@oracle.com>
date Thu, 12 May 2016 11:06:49 +0200
parents 19855d029fc0
children 1d4ce2d19e52
comparison
equal deleted inserted replaced
23391:dd9f3badc978 23392:b3a816d3b844
34 import java.lang.reflect.Method; 34 import java.lang.reflect.Method;
35 import java.lang.reflect.Modifier; 35 import java.lang.reflect.Modifier;
36 36
37 import jdk.vm.ci.code.CodeUtil; 37 import jdk.vm.ci.code.CodeUtil;
38 import jdk.vm.ci.code.TargetDescription; 38 import jdk.vm.ci.code.TargetDescription;
39 import jdk.vm.ci.common.JVMCIError;
39 import jdk.vm.ci.meta.DeoptimizationAction; 40 import jdk.vm.ci.meta.DeoptimizationAction;
40 import jdk.vm.ci.meta.DeoptimizationReason; 41 import jdk.vm.ci.meta.DeoptimizationReason;
41 import jdk.vm.ci.meta.JavaConstant; 42 import jdk.vm.ci.meta.JavaConstant;
42 import jdk.vm.ci.meta.JavaKind; 43 import jdk.vm.ci.meta.JavaKind;
43 import jdk.vm.ci.meta.MetaAccessProvider; 44 import jdk.vm.ci.meta.MetaAccessProvider;
91 try { 92 try {
92 Field field = reflectionClass.getDeclaredField("slot"); 93 Field field = reflectionClass.getDeclaredField("slot");
93 field.setAccessible(true); 94 field.setAccessible(true);
94 return field; 95 return field;
95 } catch (NoSuchFieldException | SecurityException e) { 96 } catch (NoSuchFieldException | SecurityException e) {
96 throw new InternalError(e); 97 throw new JVMCIError(e);
97 } 98 }
98 } 99 }
99 100
100 public ResolvedJavaMethod lookupJavaMethod(Executable reflectionMethod) { 101 public ResolvedJavaMethod lookupJavaMethod(Executable reflectionMethod) {
101 try { 102 try {
102 Class<?> holder = reflectionMethod.getDeclaringClass(); 103 Class<?> holder = reflectionMethod.getDeclaringClass();
103 Field slotField = reflectionMethod instanceof Constructor ? reflectionConstructorSlot : reflectionMethodSlot; 104 Field slotField = reflectionMethod instanceof Constructor ? reflectionConstructorSlot : reflectionMethodSlot;
104 final int slot = slotField.getInt(reflectionMethod); 105 final int slot = slotField.getInt(reflectionMethod);
105 return runtime.getCompilerToVM().getResolvedJavaMethodAtSlot(holder, slot); 106 return runtime.getCompilerToVM().getResolvedJavaMethodAtSlot(holder, slot);
106 } catch (IllegalArgumentException | IllegalAccessException e) { 107 } catch (IllegalArgumentException | IllegalAccessException e) {
107 throw new InternalError(e); 108 throw new JVMCIError(e);
108 } 109 }
109 } 110 }
110 111
111 public ResolvedJavaField lookupJavaField(Field reflectionField) { 112 public ResolvedJavaField lookupJavaField(Field reflectionField) {
112 Class<?> fieldHolder = reflectionField.getDeclaringClass(); 113 Class<?> fieldHolder = reflectionField.getDeclaringClass();
126 return field; 127 return field;
127 } 128 }
128 } 129 }
129 } 130 }
130 131
131 throw new InternalError("unresolved field " + reflectionField); 132 throw new JVMCIError("unresolved field %s", reflectionField);
132 } 133 }
133 134
134 private static int intMaskRight(int n) { 135 private static int intMaskRight(int n) {
135 assert n <= 32; 136 assert n <= 32;
136 return n == 32 ? -1 : (1 << n) - 1; 137 return n == 32 ? -1 : (1 << n) - 1;
179 case InvalidateRecompile: 180 case InvalidateRecompile:
180 return config.deoptActionMakeNotEntrant; 181 return config.deoptActionMakeNotEntrant;
181 case InvalidateStopCompiling: 182 case InvalidateStopCompiling:
182 return config.deoptActionMakeNotCompilable; 183 return config.deoptActionMakeNotCompilable;
183 default: 184 default:
184 throw new InternalError(action.toString()); 185 throw new JVMCIError("%s", action);
185 } 186 }
186 } 187 }
187 188
188 public DeoptimizationAction convertDeoptAction(int action) { 189 public DeoptimizationAction convertDeoptAction(int action) {
189 HotSpotVMConfig config = runtime.getConfig(); 190 HotSpotVMConfig config = runtime.getConfig();
200 return DeoptimizationAction.InvalidateRecompile; 201 return DeoptimizationAction.InvalidateRecompile;
201 } 202 }
202 if (action == config.deoptActionMakeNotCompilable) { 203 if (action == config.deoptActionMakeNotCompilable) {
203 return DeoptimizationAction.InvalidateStopCompiling; 204 return DeoptimizationAction.InvalidateStopCompiling;
204 } 205 }
205 throw new InternalError(String.valueOf(action)); 206 throw new JVMCIError("%d", action);
206 } 207 }
207 208
208 public int convertDeoptReason(DeoptimizationReason reason) { 209 public int convertDeoptReason(DeoptimizationReason reason) {
209 HotSpotVMConfig config = runtime.getConfig(); 210 HotSpotVMConfig config = runtime.getConfig();
210 switch (reason) { 211 switch (reason) {
239 case Aliasing: 240 case Aliasing:
240 return config.deoptReasonAliasing; 241 return config.deoptReasonAliasing;
241 case TransferToInterpreter: 242 case TransferToInterpreter:
242 return config.deoptReasonTransferToInterpreter; 243 return config.deoptReasonTransferToInterpreter;
243 default: 244 default:
244 throw new InternalError(reason.toString()); 245 throw new JVMCIError("%s", reason);
245 } 246 }
246 } 247 }
247 248
248 public DeoptimizationReason convertDeoptReason(int reason) { 249 public DeoptimizationReason convertDeoptReason(int reason) {
249 HotSpotVMConfig config = runtime.getConfig(); 250 HotSpotVMConfig config = runtime.getConfig();
293 return DeoptimizationReason.Aliasing; 294 return DeoptimizationReason.Aliasing;
294 } 295 }
295 if (reason == config.deoptReasonTransferToInterpreter) { 296 if (reason == config.deoptReasonTransferToInterpreter) {
296 return DeoptimizationReason.TransferToInterpreter; 297 return DeoptimizationReason.TransferToInterpreter;
297 } 298 }
298 throw new InternalError(String.format("%x", reason)); 299 throw new JVMCIError("%x", reason);
299 } 300 }
300 301
301 @Override 302 @Override
302 public long getMemorySize(JavaConstant constant) { 303 public long getMemorySize(JavaConstant constant) {
303 if (constant.getJavaKind() == JavaKind.Object) { 304 if (constant.getJavaKind() == JavaKind.Object) {