38 import jdk.vm.ci.meta.ResolvedJavaType; 39 40 public class HotSpotSnippetReflectionProvider implements SnippetReflectionProvider { 41 42 private final HotSpotGraalRuntimeProvider runtime; 43 private final HotSpotConstantReflectionProvider constantReflection; 44 private final WordTypes wordTypes; 45 46 public HotSpotSnippetReflectionProvider(HotSpotGraalRuntimeProvider runtime, HotSpotConstantReflectionProvider constantReflection, WordTypes wordTypes) { 47 this.runtime = runtime; 48 this.constantReflection = constantReflection; 49 this.wordTypes = wordTypes; 50 } 51 52 @Override 53 public JavaConstant forObject(Object object) { 54 return constantReflection.forObject(object); 55 } 56 57 @Override 58 public Object asObject(ResolvedJavaType type, JavaConstant constant) { 59 if (constant.isNull()) { 60 return null; 61 } 62 HotSpotObjectConstant hsConstant = (HotSpotObjectConstant) constant; 63 return hsConstant.asObject(type); 64 } 65 66 @Override 67 public <T> T asObject(Class<T> type, JavaConstant constant) { 68 if (constant.isNull()) { 69 return null; 70 } 71 HotSpotObjectConstant hsConstant = (HotSpotObjectConstant) constant; 72 return hsConstant.asObject(type); 73 } 74 75 @Override 76 public JavaConstant forBoxed(JavaKind kind, Object value) { 77 if (kind == JavaKind.Object) { 78 return forObject(value); 79 } else { 80 return JavaConstant.forBoxedPrimitive(value); 81 } 82 } 83 84 // Lazily initialized 85 private Class<?> wordTypesType; 86 private Class<?> runtimeType; 87 private Class<?> configType; 88 89 @Override 90 public <T> T getInjectedNodeIntrinsicParameter(Class<T> type) { 91 // Need to test all fields since there no guarantee under the JMM 92 // about the order in which these fields are written. 93 GraalHotSpotVMConfig config = runtime.getVMConfig(); | 38 import jdk.vm.ci.meta.ResolvedJavaType; 39 40 public class HotSpotSnippetReflectionProvider implements SnippetReflectionProvider { 41 42 private final HotSpotGraalRuntimeProvider runtime; 43 private final HotSpotConstantReflectionProvider constantReflection; 44 private final WordTypes wordTypes; 45 46 public HotSpotSnippetReflectionProvider(HotSpotGraalRuntimeProvider runtime, HotSpotConstantReflectionProvider constantReflection, WordTypes wordTypes) { 47 this.runtime = runtime; 48 this.constantReflection = constantReflection; 49 this.wordTypes = wordTypes; 50 } 51 52 @Override 53 public JavaConstant forObject(Object object) { 54 return constantReflection.forObject(object); 55 } 56 57 @Override 58 public <T> T asObject(Class<T> type, JavaConstant constant) { 59 if (constant.isNull()) { 60 return null; 61 } 62 if (constant instanceof HotSpotObjectConstant) { 63 HotSpotObjectConstant hsConstant = (HotSpotObjectConstant) constant; 64 return hsConstant.asObject(type); 65 } 66 return null; 67 } 68 69 @Override 70 public JavaConstant forBoxed(JavaKind kind, Object value) { 71 if (kind == JavaKind.Object) { 72 return forObject(value); 73 } else { 74 return JavaConstant.forBoxedPrimitive(value); 75 } 76 } 77 78 // Lazily initialized 79 private Class<?> wordTypesType; 80 private Class<?> runtimeType; 81 private Class<?> configType; 82 83 @Override 84 public <T> T getInjectedNodeIntrinsicParameter(Class<T> type) { 85 // Need to test all fields since there no guarantee under the JMM 86 // about the order in which these fields are written. 87 GraalHotSpotVMConfig config = runtime.getVMConfig(); |