comparison graal/GraalCompiler/src/com/sun/c1x/ir/AccessMonitor.java @ 2596:1c36b17f7ee0

new node layout: AccessMonitor, Invoke
author Lukas Stadler <lukas.stadler@jku.at>
date Thu, 05 May 2011 16:07:00 +0200
parents 16b9a8b5ad39
children 91d3952f7eb7
comparison
equal deleted inserted replaced
2595:4a4dab936c1e 2596:1c36b17f7ee0
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 com.sun.c1x.ir; 23 package com.sun.c1x.ir;
24 24
25 import com.oracle.graal.graph.*;
25 import com.sun.c1x.value.*; 26 import com.sun.c1x.value.*;
26 import com.sun.cri.ci.*; 27 import com.sun.cri.ci.*;
27 28
28 /** 29 /**
29 * The {@code AccessMonitor} instruction is the base class of both monitor acquisition and release. 30 * The {@code AccessMonitor} instruction is the base class of both monitor acquisition and release.
30 *
31 * @author Ben L. Titzer
32 */ 31 */
33 public abstract class AccessMonitor extends StateSplit { 32 public abstract class AccessMonitor extends StateSplit {
34 33
35 /** 34 private static final int INPUT_COUNT = 2;
36 * The object locked or unlocked by this instruction. 35 private static final int INPUT_OBJECT = 0;
37 */ 36 private static final int INPUT_LOCK_ADDRESS = 1;
38 private Value object; 37
38 private static final int SUCCESSOR_COUNT = 0;
39
40 @Override
41 protected int inputCount() {
42 return super.inputCount() + INPUT_COUNT;
43 }
44
45 @Override
46 protected int successorCount() {
47 return super.successorCount() + SUCCESSOR_COUNT;
48 }
39 49
40 /** 50 /**
41 * The address of the on-stack lock object or {@code null} if the runtime does not place locks on the stack. 51 * The instruction producing the object locked or unlocked by this instruction.
42 */ 52 */
43 private Value lockAddress; 53 public Value object() {
54 return (Value) inputs().get(super.inputCount() + INPUT_OBJECT);
55 }
56
57 public Value setObject(Value n) {
58 return (Value) inputs().set(super.inputCount() + INPUT_OBJECT, n);
59 }
60
61 /**
62 * The instruction producing the address of the lock object.
63 */
64 public Value lockAddress() {
65 return (Value) inputs().get(super.inputCount() + INPUT_LOCK_ADDRESS);
66 }
67
68 public Value setLockAddress(Value n) {
69 return (Value) inputs().set(super.inputCount() + INPUT_LOCK_ADDRESS, n);
70 }
44 71
45 /** 72 /**
46 * The lock number of this monitor access. 73 * The lock number of this monitor access.
47 */ 74 */
48 public final int lockNumber; 75 public final int lockNumber;
49
50 76
51 /** 77 /**
52 * Creates a new AccessMonitor instruction. 78 * Creates a new AccessMonitor instruction.
53 * 79 *
54 * @param object the instruction producing the object 80 * @param object the instruction producing the object
55 * @param lockAddress the address of the on-stack lock object or {@code null} if the runtime does not place locks on the stack 81 * @param lockAddress the address of the on-stack lock object or {@code null} if the runtime does not place locks on the stack
56 * @param stateBefore the state before executing the monitor operation 82 * @param stateBefore the state before executing the monitor operation
57 * @param lockNumber the number of the lock being acquired 83 * @param lockNumber the number of the lock being acquired
84 * @param inputCount
85 * @param successorCount
86 * @param graph
58 */ 87 */
59 public AccessMonitor(Value object, Value lockAddress, FrameState stateBefore, int lockNumber) { 88 public AccessMonitor(Value object, Value lockAddress, FrameState stateBefore, int lockNumber, int inputCount, int successorCount, Graph graph) {
60 super(CiKind.Illegal, stateBefore); 89 super(CiKind.Illegal, stateBefore, inputCount + INPUT_COUNT, successorCount + SUCCESSOR_COUNT, graph);
61 this.object = object;
62 this.lockAddress = lockAddress;
63 this.lockNumber = lockNumber; 90 this.lockNumber = lockNumber;
64 } 91 setObject(object);
65 92 setLockAddress(lockAddress);
66 /**
67 * Gets the instruction producing the object locked or unlocked by this instruction.
68 */
69 public Value object() {
70 return object;
71 }
72
73 /**
74 * Gets the instruction producing the address of the lock object.
75 */
76 public Value lockAddress() {
77 return lockAddress;
78 }
79
80 @Override
81 public void inputValuesDo(ValueClosure closure) {
82 object = closure.apply(object);
83 if (lockAddress != null) {
84 lockAddress = closure.apply(lockAddress);
85 }
86 } 93 }
87 } 94 }