comparison graal/GraalCompiler/src/com/sun/c1x/ir/NullCheck.java @ 2541:0f9eeb15e636

More Value.Flag clean up.
author Thomas Wuerthinger <thomas@wuerthinger.net>
date Wed, 27 Apr 2011 20:58:01 +0200
parents 16b9a8b5ad39
children c58a301eb2d7
comparison
equal deleted inserted replaced
2540:3fc322165071 2541:0f9eeb15e636
28 import com.sun.cri.bytecode.*; 28 import com.sun.cri.bytecode.*;
29 import com.sun.cri.ri.*; 29 import com.sun.cri.ri.*;
30 30
31 /** 31 /**
32 * The {@code NullCheck} class represents an explicit null check instruction. 32 * The {@code NullCheck} class represents an explicit null check instruction.
33 *
34 * @author Ben L. Titzer
35 */ 33 */
36 public final class NullCheck extends StateSplit { 34 public final class NullCheck extends StateSplit {
37 35
38 Value object; 36 Value object;
39 37
44 */ 42 */
45 public NullCheck(Value obj, FrameState stateBefore) { 43 public NullCheck(Value obj, FrameState stateBefore) {
46 super(obj.kind, stateBefore); 44 super(obj.kind, stateBefore);
47 this.object = obj; 45 this.object = obj;
48 setFlag(Flag.NonNull); 46 setFlag(Flag.NonNull);
49 if (object.isNonNull()) {
50 eliminateNullCheck();
51 }
52 } 47 }
53 48
54 /** 49 /**
55 * Gets the instruction that produces the object tested against null. 50 * Gets the instruction that produces the object tested against null.
56 * @return the instruction producing the object 51 * @return the instruction producing the object
63 * Checks whether this instruction can cause a trap. 58 * Checks whether this instruction can cause a trap.
64 * @return {@code true} if this instruction can cause a trap 59 * @return {@code true} if this instruction can cause a trap
65 */ 60 */
66 @Override 61 @Override
67 public boolean canTrap() { 62 public boolean canTrap() {
68 return needsNullCheck(); 63 return true;
69 } 64 }
70 65
71 @Override 66 @Override
72 public void inputValuesDo(ValueClosure closure) { 67 public void inputValuesDo(ValueClosure closure) {
73 object = closure.apply(object); 68 object = closure.apply(object);
103 // null check does not alter the type of the object 98 // null check does not alter the type of the object
104 return object.exactType(); 99 return object.exactType();
105 } 100 }
106 101
107 @Override 102 @Override
108 public void runtimeCheckCleared() {
109 clearState();
110 }
111
112 @Override
113 public void print(LogStream out) { 103 public void print(LogStream out) {
114 out.print("null_check(").print(object()).print(')'); 104 out.print("null_check(").print(object()).print(')');
115 if (!canTrap()) { 105 if (!canTrap()) {
116 out.print(" (eliminated)"); 106 out.print(" (eliminated)");
117 } 107 }