comparison jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedJavaFieldImpl.java @ 23996:11f0412408cd

8173912: [JVMCI] fix memory overhead of JVMCI
author Doug Simon <doug.simon@oracle.com>
date Fri, 03 Feb 2017 21:08:05 +0100
parents 115d4e0d7b87
children 9a740aa0d87b
comparison
equal deleted inserted replaced
23995:988dc143e0bf 23996:11f0412408cd
20 * or visit www.oracle.com if you need additional information or have any 20 * or visit www.oracle.com if you need additional information or have any
21 * questions. 21 * questions.
22 */ 22 */
23 package jdk.vm.ci.hotspot; 23 package jdk.vm.ci.hotspot;
24 24
25 import static jdk.vm.ci.hotspot.CompilerToVM.compilerToVM;
26 import static jdk.vm.ci.hotspot.HotSpotModifiers.jvmFieldModifiers; 25 import static jdk.vm.ci.hotspot.HotSpotModifiers.jvmFieldModifiers;
27 import static jdk.vm.ci.hotspot.HotSpotVMConfig.config; 26 import static jdk.vm.ci.hotspot.HotSpotVMConfig.config;
28 27
29 import java.lang.annotation.Annotation; 28 import java.lang.annotation.Annotation;
30 import java.lang.reflect.Field; 29 import java.lang.reflect.Field;
49 48
50 HotSpotResolvedJavaFieldImpl(HotSpotResolvedObjectTypeImpl holder, JavaType type, long offset, int modifiers, int index) { 49 HotSpotResolvedJavaFieldImpl(HotSpotResolvedObjectTypeImpl holder, JavaType type, long offset, int modifiers, int index) {
51 this.holder = holder; 50 this.holder = holder;
52 this.type = type; 51 this.type = type;
53 this.index = (short) index; 52 this.index = (short) index;
53 this.offset = (int) offset;
54 this.modifiers = modifiers;
54 assert this.index == index; 55 assert this.index == index;
55 assert offset != -1; 56 assert offset != -1;
56 assert offset == (int) offset : "offset larger than int"; 57 assert offset == (int) offset : "offset larger than int";
57 this.offset = (int) offset;
58 this.modifiers = modifiers;
59 } 58 }
60 59
61 @Override 60 @Override
62 public boolean equals(Object obj) { 61 public boolean equals(Object obj) {
63 if (this == obj) { 62 if (this == obj) {
107 return holder; 106 return holder;
108 } 107 }
109 108
110 @Override 109 @Override
111 public String getName() { 110 public String getName() {
112 return compilerToVM().getFieldName(holder, index); 111 return holder.createFieldInfo(index).getName();
113 } 112 }
114 113
115 @Override 114 @Override
116 public JavaType getType() { 115 public JavaType getType() {
117 // Pull field into local variable to prevent a race causing 116 // Pull field into local variable to prevent a race causing
176 return javaField.getAnnotation(annotationClass); 175 return javaField.getAnnotation(annotationClass);
177 } 176 }
178 return null; 177 return null;
179 } 178 }
180 179
181 private Field toJavaCache;
182
183 private Field toJava() { 180 private Field toJava() {
184 if (toJavaCache != null) {
185 return toJavaCache;
186 }
187
188 if (isInternal()) { 181 if (isInternal()) {
189 return null; 182 return null;
190 } 183 }
191 try { 184 try {
192 return toJavaCache = holder.mirror().getDeclaredField(getName()); 185 return holder.mirror().getDeclaredField(getName());
193 } catch (NoSuchFieldException | NoClassDefFoundError e) { 186 } catch (NoSuchFieldException | NoClassDefFoundError e) {
194 return null; 187 return null;
195 } 188 }
196 } 189 }
197 } 190 }