annotate graal/GraalCompiler/src/com/sun/c1x/ir/AccessField.java @ 2848:c061a6be3728

merge
author Gilles Duboscq <gilles.duboscq@oracle.com>
date Tue, 31 May 2011 15:19:30 +0200
parents bfce42cd9c07
children
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.cri.ci.*;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
29 import com.sun.cri.ri.*;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
30
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 * 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
33 */
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
34 public abstract class AccessField extends StateSplit {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
35
2595
4a4dab936c1e new node layout: AccessField
Lukas Stadler <lukas.stadler@jku.at>
parents: 2543
diff changeset
36 private static final int INPUT_COUNT = 1;
4a4dab936c1e new node layout: AccessField
Lukas Stadler <lukas.stadler@jku.at>
parents: 2543
diff changeset
37 private static final int INPUT_OBJECT = 0;
4a4dab936c1e new node layout: AccessField
Lukas Stadler <lukas.stadler@jku.at>
parents: 2543
diff changeset
38
4a4dab936c1e new node layout: AccessField
Lukas Stadler <lukas.stadler@jku.at>
parents: 2543
diff changeset
39 private static final int SUCCESSOR_COUNT = 0;
4a4dab936c1e new node layout: AccessField
Lukas Stadler <lukas.stadler@jku.at>
parents: 2543
diff changeset
40
4a4dab936c1e new node layout: AccessField
Lukas Stadler <lukas.stadler@jku.at>
parents: 2543
diff changeset
41 @Override
4a4dab936c1e new node layout: AccessField
Lukas Stadler <lukas.stadler@jku.at>
parents: 2543
diff changeset
42 protected int inputCount() {
4a4dab936c1e new node layout: AccessField
Lukas Stadler <lukas.stadler@jku.at>
parents: 2543
diff changeset
43 return super.inputCount() + INPUT_COUNT;
4a4dab936c1e new node layout: AccessField
Lukas Stadler <lukas.stadler@jku.at>
parents: 2543
diff changeset
44 }
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 @Override
4a4dab936c1e new node layout: AccessField
Lukas Stadler <lukas.stadler@jku.at>
parents: 2543
diff changeset
47 protected int successorCount() {
4a4dab936c1e new node layout: AccessField
Lukas Stadler <lukas.stadler@jku.at>
parents: 2543
diff changeset
48 return super.successorCount() + SUCCESSOR_COUNT;
4a4dab936c1e new node layout: AccessField
Lukas Stadler <lukas.stadler@jku.at>
parents: 2543
diff changeset
49 }
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 * 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
53 */
4a4dab936c1e new node layout: AccessField
Lukas Stadler <lukas.stadler@jku.at>
parents: 2543
diff changeset
54 public Value object() {
4a4dab936c1e new node layout: AccessField
Lukas Stadler <lukas.stadler@jku.at>
parents: 2543
diff changeset
55 return (Value) inputs().get(super.inputCount() + INPUT_OBJECT);
4a4dab936c1e new node layout: AccessField
Lukas Stadler <lukas.stadler@jku.at>
parents: 2543
diff changeset
56 }
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 public Value setObject(Value n) {
4a4dab936c1e new node layout: AccessField
Lukas Stadler <lukas.stadler@jku.at>
parents: 2543
diff changeset
59 return (Value) inputs().set(super.inputCount() + INPUT_OBJECT, n);
4a4dab936c1e new node layout: AccessField
Lukas Stadler <lukas.stadler@jku.at>
parents: 2543
diff changeset
60 }
4a4dab936c1e new node layout: AccessField
Lukas Stadler <lukas.stadler@jku.at>
parents: 2543
diff changeset
61
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
62 protected final RiField field;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
63
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 * Constructs a new access field object.
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
66 * @param kind the result kind of the access
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
67 * @param object the instruction producing the receiver object
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
68 * @param field the compiler interface representation of the field
2595
4a4dab936c1e new node layout: AccessField
Lukas Stadler <lukas.stadler@jku.at>
parents: 2543
diff changeset
69 * @param inputCount
4a4dab936c1e new node layout: AccessField
Lukas Stadler <lukas.stadler@jku.at>
parents: 2543
diff changeset
70 * @param successorCount
4a4dab936c1e new node layout: AccessField
Lukas Stadler <lukas.stadler@jku.at>
parents: 2543
diff changeset
71 * @param graph
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
72 */
2628
569228710be8 More FrameState work
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2622
diff changeset
73 public AccessField(CiKind kind, Value object, RiField field, int inputCount, int successorCount, Graph graph) {
569228710be8 More FrameState work
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2622
diff changeset
74 super(kind, inputCount + INPUT_COUNT, successorCount + SUCCESSOR_COUNT, graph);
2595
4a4dab936c1e new node layout: AccessField
Lukas Stadler <lukas.stadler@jku.at>
parents: 2543
diff changeset
75 this.field = field;
4a4dab936c1e new node layout: AccessField
Lukas Stadler <lukas.stadler@jku.at>
parents: 2543
diff changeset
76 setObject(object);
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
77 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
78
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
79 /**
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
80 * 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
81 * @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
82 */
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
83 public RiField field() {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
84 return field;
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
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
87 /**
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
88 * 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
89 * @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
90 */
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
91 public boolean isStatic() {
2538
e1ba5a93e997 Clean up on Value class and LIRGenerator/LIRItem-related things.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2509
diff changeset
92 return Modifier.isStatic(field.accessFlags());
2507
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
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
95 /**
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
96 * 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
97 * @return {@code true} if the class is loaded
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 public boolean isLoaded() {
2540
3fc322165071 More flags clean up.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2539
diff changeset
100 return field.isResolved();
2507
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
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
103 /**
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
104 * Checks whether this field is declared volatile.
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
105 * @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
106 */
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
107 public boolean isVolatile() {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
108 return isLoaded() && Modifier.isVolatile(field.accessFlags());
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 }