Mercurial > hg > graal-jvmci-8
comparison graal/Compiler/src/com/sun/c1x/ir/PointerOp.java @ 2507:9ec15d6914ca
Pull over of compiler from maxine repository.
author | Thomas Wuerthinger <thomas@wuerthinger.net> |
---|---|
date | Wed, 27 Apr 2011 11:43:22 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
2506:4a3bf8a5bf41 | 2507:9ec15d6914ca |
---|---|
1 /* | |
2 * Copyright (c) 2010, 2010, Oracle and/or its affiliates. All rights reserved. | |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
20 * or visit www.oracle.com if you need additional information or have any | |
21 * questions. | |
22 */ | |
23 package com.sun.c1x.ir; | |
24 | |
25 import com.sun.c1x.value.*; | |
26 import com.sun.cri.ci.*; | |
27 | |
28 /** | |
29 * The base class for pointer access operations. | |
30 * | |
31 * @author Doug Simon | |
32 */ | |
33 public abstract class PointerOp extends StateSplit { | |
34 | |
35 /** | |
36 * The kind of value at the address accessed by the pointer operation. | |
37 */ | |
38 public final CiKind dataKind; | |
39 | |
40 public final int opcode; | |
41 protected Value pointer; | |
42 protected Value displacement; | |
43 protected Value offsetOrIndex; | |
44 protected final boolean isVolatile; | |
45 final boolean isPrefetch; | |
46 | |
47 /** | |
48 * Creates an instruction for a pointer operation. If {@code displacement != null}, the effective of the address of the operation is | |
49 * computed as the pointer plus a byte displacement plus a scaled index. Otherwise, the effective address is computed as the | |
50 * pointer plus a byte offset. | |
51 * | |
52 * @param kind the kind of value produced by this operation | |
53 * @param dataKind the kind of value at the address accessed by the pointer operation | |
54 * @param opcode the opcode of the instruction | |
55 * @param pointer the value producing the pointer | |
56 * @param displacement the value producing the displacement. This may be {@code null}. | |
57 * @param offsetOrIndex the value producing the scaled-index or the byte offset depending on whether {@code displacement} is {@code null} | |
58 * @param stateBefore the state before | |
59 * @param isVolatile {@code true} if the access is volatile | |
60 */ | |
61 public PointerOp(CiKind kind, CiKind dataKind, int opcode, Value pointer, Value displacement, Value offsetOrIndex, FrameState stateBefore, boolean isVolatile) { | |
62 super(kind.stackKind(), stateBefore); | |
63 this.opcode = opcode; | |
64 this.pointer = pointer; | |
65 this.dataKind = dataKind; | |
66 this.displacement = displacement; | |
67 this.offsetOrIndex = offsetOrIndex; | |
68 this.isVolatile = isVolatile; | |
69 this.isPrefetch = false; | |
70 if (pointer.isNonNull()) { | |
71 eliminateNullCheck(); | |
72 } | |
73 } | |
74 | |
75 public Value pointer() { | |
76 return pointer; | |
77 } | |
78 | |
79 public Value index() { | |
80 return offsetOrIndex; | |
81 } | |
82 | |
83 public Value offset() { | |
84 return offsetOrIndex; | |
85 } | |
86 | |
87 public Value displacement() { | |
88 return displacement; | |
89 } | |
90 | |
91 @Override | |
92 public void runtimeCheckCleared() { | |
93 clearState(); | |
94 } | |
95 | |
96 /** | |
97 * Checks whether this field access may cause a trap or an exception, which | |
98 * is if it either requires a null check or needs patching. | |
99 * @return {@code true} if this field access can cause a trap | |
100 */ | |
101 @Override | |
102 public boolean canTrap() { | |
103 return needsNullCheck(); | |
104 } | |
105 | |
106 /** | |
107 * Iterates over the input values to this instruction. | |
108 * @param closure the closure to apply to each value | |
109 */ | |
110 @Override | |
111 public void inputValuesDo(ValueClosure closure) { | |
112 pointer = closure.apply(pointer); | |
113 offsetOrIndex = closure.apply(offsetOrIndex); | |
114 if (displacement != null) { | |
115 displacement = closure.apply(displacement); | |
116 } | |
117 } | |
118 } |