comparison graal/GraalCompiler/src/com/sun/c1x/ir/AccessField.java @ 2595:4a4dab936c1e

new node layout: AccessField
author Lukas Stadler <lukas.stadler@jku.at>
date Thu, 05 May 2011 15:49:48 +0200
parents c58a301eb2d7
children 91d3952f7eb7
comparison
equal deleted inserted replaced
2594:092e628ddd5d 2595:4a4dab936c1e
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.oracle.graal.graph.*;
27 import com.sun.c1x.value.*; 28 import com.sun.c1x.value.*;
28 import com.sun.cri.ci.*; 29 import com.sun.cri.ci.*;
29 import com.sun.cri.ri.*; 30 import com.sun.cri.ri.*;
30 31
31 /** 32 /**
32 * The base class of all instructions that access fields. 33 * The base class of all instructions that access fields.
33 */ 34 */
34 public abstract class AccessField extends StateSplit { 35 public abstract class AccessField extends StateSplit {
35 36
36 private Value object; 37 private static final int INPUT_COUNT = 1;
38 private static final int INPUT_OBJECT = 0;
39
40 private static final int SUCCESSOR_COUNT = 0;
41
42 @Override
43 protected int inputCount() {
44 return super.inputCount() + INPUT_COUNT;
45 }
46
47 @Override
48 protected int successorCount() {
49 return super.successorCount() + SUCCESSOR_COUNT;
50 }
51
52 /**
53 * The instruction that produces the receiver object of this field access (for instance field accesses).
54 */
55 public Value object() {
56 return (Value) inputs().get(super.inputCount() + INPUT_OBJECT);
57 }
58
59 public Value setObject(Value n) {
60 return (Value) inputs().set(super.inputCount() + INPUT_OBJECT, n);
61 }
62
37 protected final RiField field; 63 protected final RiField field;
38 64
39 /** 65 /**
40 * Constructs a new access field object. 66 * Constructs a new access field object.
41 * @param kind the result kind of the access 67 * @param kind the result kind of the access
42 * @param object the instruction producing the receiver object 68 * @param object the instruction producing the receiver object
43 * @param field the compiler interface representation of the field 69 * @param field the compiler interface representation of the field
44 * @param isStatic indicates if the field is static
45 * @param stateBefore the state before the field access 70 * @param stateBefore the state before the field access
46 * @param isLoaded indicates if the class is loaded 71 * @param inputCount
72 * @param successorCount
73 * @param graph
47 */ 74 */
48 public AccessField(CiKind kind, Value object, RiField field, FrameState stateBefore) { 75 public AccessField(CiKind kind, Value object, RiField field, FrameState stateBefore, int inputCount, int successorCount, Graph graph) {
49 super(kind, stateBefore); 76 super(kind, stateBefore, inputCount + INPUT_COUNT, successorCount + SUCCESSOR_COUNT, graph);
50 this.object = object; 77 assert object != null : "every field access must reference some object";
51 this.field = field; 78 this.field = field;
52 assert object != null : "every field access must reference some object"; 79 setObject(object);
53 }
54
55 /**
56 * Gets the instruction that produces the receiver object of this field access
57 * (for instance field accesses).
58 * @return the instruction that produces the receiver object
59 */
60 public Value object() {
61 return object;
62 } 80 }
63 81
64 /** 82 /**
65 * Gets the compiler interface field for this field access. 83 * Gets the compiler interface field for this field access.
66 * @return the compiler interface field for this field access 84 * @return the compiler interface field for this field access
90 * @return {@code true} if the field is resolved and declared volatile 108 * @return {@code true} if the field is resolved and declared volatile
91 */ 109 */
92 public boolean isVolatile() { 110 public boolean isVolatile() {
93 return isLoaded() && Modifier.isVolatile(field.accessFlags()); 111 return isLoaded() && Modifier.isVolatile(field.accessFlags());
94 } 112 }
95
96 @Override
97 public void inputValuesDo(ValueClosure closure) {
98 object = closure.apply(object);
99 }
100 } 113 }