comparison jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMetaAccessProvider.java @ 23315:21fe118a18e6

Backed out changeset 2d1ca131b8be
author Doug Simon <doug.simon@oracle.com>
date Tue, 08 Mar 2016 09:17:23 +0100
parents 2d1ca131b8be
children c0df579bf9db
comparison
equal deleted inserted replaced
23314:2d1ca131b8be 23315:21fe118a18e6
83 * {@link Field} object of {@link Method#slot}. 83 * {@link Field} object of {@link Method#slot}.
84 */ 84 */
85 private Field reflectionMethodSlot = getReflectionSlotField(Method.class); 85 private Field reflectionMethodSlot = getReflectionSlotField(Method.class);
86 86
87 /** 87 /**
88 * {@link Field} object of {@link Field#slot}.
89 */
90 private Field reflectionFieldSlot = getReflectionSlotField(Field.class);
91
92 /**
93 * {@link Field} object of {@link Constructor#slot}. 88 * {@link Field} object of {@link Constructor#slot}.
94 */ 89 */
95 private Field reflectionConstructorSlot = getReflectionSlotField(Constructor.class); 90 private Field reflectionConstructorSlot = getReflectionSlotField(Constructor.class);
96 91
97 private static Field getReflectionSlotField(Class<?> reflectionClass) { 92 private static Field getReflectionSlotField(Class<?> reflectionClass) {
114 throw new JVMCIError(e); 109 throw new JVMCIError(e);
115 } 110 }
116 } 111 }
117 112
118 public ResolvedJavaField lookupJavaField(Field reflectionField) { 113 public ResolvedJavaField lookupJavaField(Field reflectionField) {
119 try { 114 String name = reflectionField.getName();
120 String name = reflectionField.getName(); 115 Class<?> fieldHolder = reflectionField.getDeclaringClass();
121 Class<?> fieldHolder = reflectionField.getDeclaringClass(); 116 Class<?> fieldType = reflectionField.getType();
122 Class<?> fieldType = reflectionField.getType(); 117 // java.lang.reflect.Field's modifiers should be enough here since VM internal modifier bits
123 final int slot = reflectionFieldSlot.getInt(reflectionField); 118 // are not used (yet).
124 119 final int modifiers = reflectionField.getModifiers();
125 HotSpotResolvedObjectType holder = fromObjectClass(fieldHolder); 120 final long offset = Modifier.isStatic(modifiers) ? UNSAFE.staticFieldOffset(reflectionField) : UNSAFE.objectFieldOffset(reflectionField);
126 final int flags = runtime.getCompilerToVM().getResolvedJavaFieldFlagsAtSlot(fieldHolder, slot); 121
127 final long offset = Modifier.isStatic(flags) ? UNSAFE.staticFieldOffset(reflectionField) : UNSAFE.objectFieldOffset(reflectionField); 122 HotSpotResolvedObjectType holder = fromObjectClass(fieldHolder);
128 JavaType type = runtime.fromClass(fieldType); 123 JavaType type = runtime.fromClass(fieldType);
129 124
130 if (offset != -1) { 125 if (offset != -1) {
131 HotSpotResolvedObjectType resolved = holder; 126 HotSpotResolvedObjectType resolved = holder;
132 return resolved.createField(name, type, offset, flags); 127 return resolved.createField(name, type, offset, modifiers);
133 } else { 128 } else {
134 throw new JVMCIError("unresolved field %s", reflectionField); 129 throw new JVMCIError("unresolved field %s", reflectionField);
135 }
136 } catch (IllegalArgumentException | IllegalAccessException e) {
137 throw new JVMCIError(e);
138 } 130 }
139 } 131 }
140 132
141 private static int intMaskRight(int n) { 133 private static int intMaskRight(int n) {
142 assert n <= 32; 134 assert n <= 32;