Mercurial > hg > graal-jvmci-8
comparison jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedJavaFieldImpl.java @ 23989:115d4e0d7b87
removed HotSpotResolvedJavaFieldImpl.name field
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Thu, 26 Jan 2017 13:02:37 +0100 |
parents | 09541f94f3e6 |
children | 11f0412408cd |
comparison
equal
deleted
inserted
replaced
23988:09541f94f3e6 | 23989:115d4e0d7b87 |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. | 2 * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | 4 * |
5 * This code is free software; you can redistribute it and/or modify it | 5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as | 6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
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; | |
25 import static jdk.vm.ci.hotspot.HotSpotModifiers.jvmFieldModifiers; | 26 import static jdk.vm.ci.hotspot.HotSpotModifiers.jvmFieldModifiers; |
26 import static jdk.vm.ci.hotspot.HotSpotVMConfig.config; | 27 import static jdk.vm.ci.hotspot.HotSpotVMConfig.config; |
27 | 28 |
28 import java.lang.annotation.Annotation; | 29 import java.lang.annotation.Annotation; |
29 import java.lang.reflect.Field; | 30 import java.lang.reflect.Field; |
35 * Represents a field in a HotSpot type. | 36 * Represents a field in a HotSpot type. |
36 */ | 37 */ |
37 class HotSpotResolvedJavaFieldImpl implements HotSpotResolvedJavaField { | 38 class HotSpotResolvedJavaFieldImpl implements HotSpotResolvedJavaField { |
38 | 39 |
39 private final HotSpotResolvedObjectTypeImpl holder; | 40 private final HotSpotResolvedObjectTypeImpl holder; |
40 private final String name; | |
41 private JavaType type; | 41 private JavaType type; |
42 private final int offset; | 42 private final int offset; |
43 private final short index; | |
43 | 44 |
44 /** | 45 /** |
45 * This value contains all flags as stored in the VM including internal ones. | 46 * This value contains all flags as stored in the VM including internal ones. |
46 */ | 47 */ |
47 private final int modifiers; | 48 private final int modifiers; |
48 | 49 |
49 HotSpotResolvedJavaFieldImpl(HotSpotResolvedObjectTypeImpl holder, String name, JavaType type, long offset, int modifiers) { | 50 HotSpotResolvedJavaFieldImpl(HotSpotResolvedObjectTypeImpl holder, JavaType type, long offset, int modifiers, int index) { |
50 this.holder = holder; | 51 this.holder = holder; |
51 this.name = name; | |
52 this.type = type; | 52 this.type = type; |
53 this.index = (short) index; | |
54 assert this.index == index; | |
53 assert offset != -1; | 55 assert offset != -1; |
54 assert offset == (int) offset : "offset larger than int"; | 56 assert offset == (int) offset : "offset larger than int"; |
55 this.offset = (int) offset; | 57 this.offset = (int) offset; |
56 this.modifiers = modifiers; | 58 this.modifiers = modifiers; |
57 } | 59 } |
72 return false; | 74 return false; |
73 } | 75 } |
74 | 76 |
75 @Override | 77 @Override |
76 public int hashCode() { | 78 public int hashCode() { |
77 return name.hashCode(); | 79 return offset ^ modifiers; |
78 } | 80 } |
79 | 81 |
80 @Override | 82 @Override |
81 public int getModifiers() { | 83 public int getModifiers() { |
82 return modifiers & jvmFieldModifiers(); | 84 return modifiers & jvmFieldModifiers(); |
105 return holder; | 107 return holder; |
106 } | 108 } |
107 | 109 |
108 @Override | 110 @Override |
109 public String getName() { | 111 public String getName() { |
110 return name; | 112 return compilerToVM().getFieldName(holder, index); |
111 } | 113 } |
112 | 114 |
113 @Override | 115 @Override |
114 public JavaType getType() { | 116 public JavaType getType() { |
115 // Pull field into local variable to prevent a race causing | 117 // Pull field into local variable to prevent a race causing |
185 | 187 |
186 if (isInternal()) { | 188 if (isInternal()) { |
187 return null; | 189 return null; |
188 } | 190 } |
189 try { | 191 try { |
190 return toJavaCache = holder.mirror().getDeclaredField(name); | 192 return toJavaCache = holder.mirror().getDeclaredField(getName()); |
191 } catch (NoSuchFieldException | NoClassDefFoundError e) { | 193 } catch (NoSuchFieldException | NoClassDefFoundError e) { |
192 return null; | 194 return null; |
193 } | 195 } |
194 } | 196 } |
195 } | 197 } |