comparison graal/GraalCompiler/src/com/sun/c1x/ir/ArithmeticOp.java @ 2622:91d3952f7eb7

Framestate work : using stateAFter and reducting the number of nodes with framestates. Intermediate state (does not pass tests)
author Gilles Duboscq <gilles.duboscq@oracle.com>
date Tue, 10 May 2011 12:37:46 +0200
parents 3558ca7088c0
children 440ceca8e3d7
comparison
equal deleted inserted replaced
2621:dd115f80acf8 2622:91d3952f7eb7
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.oracle.graal.graph.*;
26 import com.sun.c1x.debug.*; 26 import com.sun.c1x.debug.*;
27 import com.sun.c1x.value.*;
28 import com.sun.cri.bytecode.*; 27 import com.sun.cri.bytecode.*;
29 import com.sun.cri.ci.*; 28 import com.sun.cri.ci.*;
30 29
31 /** 30 /**
32 * The {@code ArithmeticOp} class represents arithmetic operations such as addition, subtraction, etc. 31 * The {@code ArithmeticOp} class represents arithmetic operations such as addition, subtraction, etc.
33 */ 32 */
34 public final class ArithmeticOp extends Op2 { 33 public final class ArithmeticOp extends Op2 {
35 34
36 private static final int INPUT_COUNT = 1; 35 private static final int INPUT_COUNT = 0;
37 private static final int INPUT_STATE_BEFORE = 0;
38
39 private static final int SUCCESSOR_COUNT = 0; 36 private static final int SUCCESSOR_COUNT = 0;
40 37
41 @Override 38 private final boolean canTrap;
42 protected int inputCount() {
43 return super.inputCount() + INPUT_COUNT;
44 }
45
46 @Override
47 protected int successorCount() {
48 return super.successorCount() + SUCCESSOR_COUNT;
49 }
50
51 /**
52 * The state for this instruction.
53 */
54 @Override
55 public FrameState stateBefore() {
56 return (FrameState) inputs().get(super.inputCount() + INPUT_STATE_BEFORE);
57 }
58
59 private FrameState setStateBefore(FrameState n) {
60 return (FrameState) inputs().set(super.inputCount() + INPUT_STATE_BEFORE, n);
61 }
62
63 private final boolean isStrictFP; 39 private final boolean isStrictFP;
64 40
65 /** 41 /**
66 * Creates a new arithmetic operation. 42 * Creates a new arithmetic operation.
67 * @param opcode the bytecode opcode 43 * @param opcode the bytecode opcode
69 * @param x the first input instruction 45 * @param x the first input instruction
70 * @param y the second input instruction 46 * @param y the second input instruction
71 * @param isStrictFP indicates this operation has strict rounding semantics 47 * @param isStrictFP indicates this operation has strict rounding semantics
72 * @param stateBefore the state for instructions that may trap 48 * @param stateBefore the state for instructions that may trap
73 */ 49 */
74 public ArithmeticOp(int opcode, CiKind kind, Value x, Value y, boolean isStrictFP, FrameState stateBefore, Graph graph) { 50 public ArithmeticOp(int opcode, CiKind kind, Value x, Value y, boolean isStrictFP, boolean canTrap, Graph graph) {
75 super(kind, opcode, x, y, INPUT_COUNT, SUCCESSOR_COUNT, graph); 51 super(kind, opcode, x, y, INPUT_COUNT, SUCCESSOR_COUNT, graph);
76 this.isStrictFP = isStrictFP; 52 this.isStrictFP = isStrictFP;
77 setStateBefore(stateBefore); 53 this.canTrap = canTrap;
78 } 54 }
79 55
80 /** 56 /**
81 * Checks whether this instruction has strict fp semantics. 57 * Checks whether this instruction has strict fp semantics.
82 * @return {@code true} if this instruction has strict fp semantics 58 * @return {@code true} if this instruction has strict fp semantics
90 * only division and remainder operations can cause traps. 66 * only division and remainder operations can cause traps.
91 * @return {@code true} if this instruction can cause a trap 67 * @return {@code true} if this instruction can cause a trap
92 */ 68 */
93 @Override 69 @Override
94 public boolean canTrap() { 70 public boolean canTrap() {
95 return stateBefore() != null; 71 return canTrap;
96 } 72 }
97 73
98 @Override 74 @Override
99 public void accept(ValueVisitor v) { 75 public void accept(ValueVisitor v) {
100 v.visitArithmeticOp(this); 76 v.visitArithmeticOp(this);