Mercurial > hg > graal-jvmci-8
comparison graal/GraalCompiler/src/com/sun/c1x/ir/AccessField.java @ 2540:3fc322165071
More flags clean up.
author | Thomas Wuerthinger <thomas@wuerthinger.net> |
---|---|
date | Wed, 27 Apr 2011 20:27:43 +0200 |
parents | fa3bda50cbfd |
children | 0f9eeb15e636 |
comparison
equal
deleted
inserted
replaced
2539:fa3bda50cbfd | 2540:3fc322165071 |
---|---|
22 */ | 22 */ |
23 package com.sun.c1x.ir; | 23 package com.sun.c1x.ir; |
24 | 24 |
25 import java.lang.reflect.*; | 25 import java.lang.reflect.*; |
26 | 26 |
27 import com.sun.c1x.*; | |
28 import com.sun.c1x.value.*; | 27 import com.sun.c1x.value.*; |
29 import com.sun.cri.ci.*; | 28 import com.sun.cri.ci.*; |
30 import com.sun.cri.ri.*; | 29 import com.sun.cri.ri.*; |
31 | 30 |
32 /** | 31 /** |
34 */ | 33 */ |
35 public abstract class AccessField extends StateSplit { | 34 public abstract class AccessField extends StateSplit { |
36 | 35 |
37 private Value object; | 36 private Value object; |
38 protected final RiField field; | 37 protected final RiField field; |
39 private boolean needsPatching; | |
40 | 38 |
41 /** | 39 /** |
42 * Constructs a new access field object. | 40 * Constructs a new access field object. |
43 * @param kind the result kind of the access | 41 * @param kind the result kind of the access |
44 * @param object the instruction producing the receiver object | 42 * @param object the instruction producing the receiver object |
45 * @param field the compiler interface representation of the field | 43 * @param field the compiler interface representation of the field |
46 * @param isStatic indicates if the field is static | 44 * @param isStatic indicates if the field is static |
47 * @param stateBefore the state before the field access | 45 * @param stateBefore the state before the field access |
48 * @param isLoaded indicates if the class is loaded | 46 * @param isLoaded indicates if the class is loaded |
49 */ | 47 */ |
50 public AccessField(CiKind kind, Value object, RiField field, FrameState stateBefore, boolean isLoaded) { | 48 public AccessField(CiKind kind, Value object, RiField field, FrameState stateBefore) { |
51 super(kind, stateBefore); | 49 super(kind, stateBefore); |
52 this.object = object; | 50 this.object = object; |
53 this.field = field; | 51 this.field = field; |
54 if (!isLoaded || (C1XOptions.TestPatching && !Modifier.isVolatile(field.accessFlags()))) { | 52 if (field.isResolved() && object.isNonNull()) { |
55 // require patching if the field is not loaded (i.e. resolved), | |
56 // or if patch testing is turned on (but not if the field is volatile) | |
57 needsPatching = true; | |
58 } | |
59 initFlag(Flag.IsLoaded, isLoaded); | |
60 if (isLoaded && object.isNonNull()) { | |
61 eliminateNullCheck(); | 53 eliminateNullCheck(); |
62 } | 54 } |
63 assert object != null : "every field access must reference some object"; | 55 assert object != null : "every field access must reference some object"; |
64 } | 56 } |
65 | 57 |
91 /** | 83 /** |
92 * Checks whether the class of the field of this access is loaded. | 84 * Checks whether the class of the field of this access is loaded. |
93 * @return {@code true} if the class is loaded | 85 * @return {@code true} if the class is loaded |
94 */ | 86 */ |
95 public boolean isLoaded() { | 87 public boolean isLoaded() { |
96 return checkFlag(Flag.IsLoaded); | 88 return field.isResolved(); |
97 } | 89 } |
98 | 90 |
99 /** | 91 /** |
100 * Checks whether this field is declared volatile. | 92 * Checks whether this field is declared volatile. |
101 * @return {@code true} if the field is resolved and declared volatile | 93 * @return {@code true} if the field is resolved and declared volatile |
110 clearState(); | 102 clearState(); |
111 } | 103 } |
112 } | 104 } |
113 | 105 |
114 /** | 106 /** |
115 * Checks whether this field access will require patching. | |
116 * @return {@code true} if this field access will require patching | |
117 */ | |
118 public boolean needsPatching() { | |
119 return needsPatching; | |
120 } | |
121 | |
122 /** | |
123 * Checks whether this field access may cause a trap or an exception, which | 107 * Checks whether this field access may cause a trap or an exception, which |
124 * is if it either requires a null check or needs patching. | 108 * is if it either requires a null check or needs patching. |
125 * @return {@code true} if this field access can cause a trap | 109 * @return {@code true} if this field access can cause a trap |
126 */ | 110 */ |
127 @Override | 111 @Override |
128 public boolean canTrap() { | 112 public boolean canTrap() { |
129 return needsPatching() || needsNullCheck(); | 113 return !isLoaded() || needsNullCheck(); |
130 } | 114 } |
131 | 115 |
132 @Override | 116 @Override |
133 public void inputValuesDo(ValueClosure closure) { | 117 public void inputValuesDo(ValueClosure closure) { |
134 object = closure.apply(object); | 118 object = closure.apply(object); |