annotate 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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1 /*
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
2 * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
4 *
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
7 * published by the Free Software Foundation.
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
8 *
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
13 * accompanied this code).
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
14 *
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
18 *
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
21 * questions.
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
22 */
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
23 package com.sun.c1x.ir;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
24
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
25 import java.lang.reflect.*;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
26
2595
4a4dab936c1e new node layout: AccessField
Lukas Stadler <lukas.stadler@jku.at>
parents: 2543
diff changeset
27 import com.oracle.graal.graph.*;
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
28 import com.sun.c1x.value.*;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
29 import com.sun.cri.ci.*;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
30 import com.sun.cri.ri.*;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
31
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
32 /**
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
33 * The base class of all instructions that access fields.
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
34 */
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
35 public abstract class AccessField extends StateSplit {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
36
2595
4a4dab936c1e new node layout: AccessField
Lukas Stadler <lukas.stadler@jku.at>
parents: 2543
diff changeset
37 private static final int INPUT_COUNT = 1;
4a4dab936c1e new node layout: AccessField
Lukas Stadler <lukas.stadler@jku.at>
parents: 2543
diff changeset
38 private static final int INPUT_OBJECT = 0;
4a4dab936c1e new node layout: AccessField
Lukas Stadler <lukas.stadler@jku.at>
parents: 2543
diff changeset
39
4a4dab936c1e new node layout: AccessField
Lukas Stadler <lukas.stadler@jku.at>
parents: 2543
diff changeset
40 private static final int SUCCESSOR_COUNT = 0;
4a4dab936c1e new node layout: AccessField
Lukas Stadler <lukas.stadler@jku.at>
parents: 2543
diff changeset
41
4a4dab936c1e new node layout: AccessField
Lukas Stadler <lukas.stadler@jku.at>
parents: 2543
diff changeset
42 @Override
4a4dab936c1e new node layout: AccessField
Lukas Stadler <lukas.stadler@jku.at>
parents: 2543
diff changeset
43 protected int inputCount() {
4a4dab936c1e new node layout: AccessField
Lukas Stadler <lukas.stadler@jku.at>
parents: 2543
diff changeset
44 return super.inputCount() + INPUT_COUNT;
4a4dab936c1e new node layout: AccessField
Lukas Stadler <lukas.stadler@jku.at>
parents: 2543
diff changeset
45 }
4a4dab936c1e new node layout: AccessField
Lukas Stadler <lukas.stadler@jku.at>
parents: 2543
diff changeset
46
4a4dab936c1e new node layout: AccessField
Lukas Stadler <lukas.stadler@jku.at>
parents: 2543
diff changeset
47 @Override
4a4dab936c1e new node layout: AccessField
Lukas Stadler <lukas.stadler@jku.at>
parents: 2543
diff changeset
48 protected int successorCount() {
4a4dab936c1e new node layout: AccessField
Lukas Stadler <lukas.stadler@jku.at>
parents: 2543
diff changeset
49 return super.successorCount() + SUCCESSOR_COUNT;
4a4dab936c1e new node layout: AccessField
Lukas Stadler <lukas.stadler@jku.at>
parents: 2543
diff changeset
50 }
4a4dab936c1e new node layout: AccessField
Lukas Stadler <lukas.stadler@jku.at>
parents: 2543
diff changeset
51
4a4dab936c1e new node layout: AccessField
Lukas Stadler <lukas.stadler@jku.at>
parents: 2543
diff changeset
52 /**
4a4dab936c1e new node layout: AccessField
Lukas Stadler <lukas.stadler@jku.at>
parents: 2543
diff changeset
53 * The instruction that produces the receiver object of this field access (for instance field accesses).
4a4dab936c1e new node layout: AccessField
Lukas Stadler <lukas.stadler@jku.at>
parents: 2543
diff changeset
54 */
4a4dab936c1e new node layout: AccessField
Lukas Stadler <lukas.stadler@jku.at>
parents: 2543
diff changeset
55 public Value object() {
4a4dab936c1e new node layout: AccessField
Lukas Stadler <lukas.stadler@jku.at>
parents: 2543
diff changeset
56 return (Value) inputs().get(super.inputCount() + INPUT_OBJECT);
4a4dab936c1e new node layout: AccessField
Lukas Stadler <lukas.stadler@jku.at>
parents: 2543
diff changeset
57 }
4a4dab936c1e new node layout: AccessField
Lukas Stadler <lukas.stadler@jku.at>
parents: 2543
diff changeset
58
4a4dab936c1e new node layout: AccessField
Lukas Stadler <lukas.stadler@jku.at>
parents: 2543
diff changeset
59 public Value setObject(Value n) {
4a4dab936c1e new node layout: AccessField
Lukas Stadler <lukas.stadler@jku.at>
parents: 2543
diff changeset
60 return (Value) inputs().set(super.inputCount() + INPUT_OBJECT, n);
4a4dab936c1e new node layout: AccessField
Lukas Stadler <lukas.stadler@jku.at>
parents: 2543
diff changeset
61 }
4a4dab936c1e new node layout: AccessField
Lukas Stadler <lukas.stadler@jku.at>
parents: 2543
diff changeset
62
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
63 protected final RiField field;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
64
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
65 /**
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
66 * Constructs a new access field object.
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
67 * @param kind the result kind of the access
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
68 * @param object the instruction producing the receiver object
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
69 * @param field the compiler interface representation of the field
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
70 * @param stateBefore the state before the field access
2595
4a4dab936c1e new node layout: AccessField
Lukas Stadler <lukas.stadler@jku.at>
parents: 2543
diff changeset
71 * @param inputCount
4a4dab936c1e new node layout: AccessField
Lukas Stadler <lukas.stadler@jku.at>
parents: 2543
diff changeset
72 * @param successorCount
4a4dab936c1e new node layout: AccessField
Lukas Stadler <lukas.stadler@jku.at>
parents: 2543
diff changeset
73 * @param graph
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
74 */
2595
4a4dab936c1e new node layout: AccessField
Lukas Stadler <lukas.stadler@jku.at>
parents: 2543
diff changeset
75 public AccessField(CiKind kind, Value object, RiField field, FrameState stateBefore, int inputCount, int successorCount, Graph graph) {
4a4dab936c1e new node layout: AccessField
Lukas Stadler <lukas.stadler@jku.at>
parents: 2543
diff changeset
76 super(kind, stateBefore, inputCount + INPUT_COUNT, successorCount + SUCCESSOR_COUNT, graph);
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
77 assert object != null : "every field access must reference some object";
2595
4a4dab936c1e new node layout: AccessField
Lukas Stadler <lukas.stadler@jku.at>
parents: 2543
diff changeset
78 this.field = field;
4a4dab936c1e new node layout: AccessField
Lukas Stadler <lukas.stadler@jku.at>
parents: 2543
diff changeset
79 setObject(object);
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
80 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
81
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
82 /**
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
83 * Gets the compiler interface field for this field access.
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
84 * @return the compiler interface field for this field access
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
85 */
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
86 public RiField field() {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
87 return field;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
88 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
89
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
90 /**
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
91 * Checks whether this field access is an access to a static field.
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
92 * @return {@code true} if this field access is to a static field
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
93 */
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
94 public boolean isStatic() {
2538
e1ba5a93e997 Clean up on Value class and LIRGenerator/LIRItem-related things.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2509
diff changeset
95 return Modifier.isStatic(field.accessFlags());
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
96 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
97
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
98 /**
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
99 * Checks whether the class of the field of this access is loaded.
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
100 * @return {@code true} if the class is loaded
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
101 */
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
102 public boolean isLoaded() {
2540
3fc322165071 More flags clean up.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2539
diff changeset
103 return field.isResolved();
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
104 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
105
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
106 /**
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
107 * Checks whether this field is declared volatile.
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
108 * @return {@code true} if the field is resolved and declared volatile
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
109 */
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
110 public boolean isVolatile() {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
111 return isLoaded() && Modifier.isVolatile(field.accessFlags());
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
112 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
113 }