Mercurial > hg > graal-compiler
annotate src/share/vm/ci/ciField.hpp @ 4316:b4b16e4e043f
Fix eager resolving for class constants
author | Peter Hofer <peter.hofer@jku.at> |
---|---|
date | Mon, 23 Jan 2012 14:35:29 +0100 |
parents | 04b9a2566eec |
children | 957c266d8bc5 |
rev | line source |
---|---|
0 | 1 /* |
3852
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
1972
diff
changeset
|
2 * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. |
0 | 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 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1138
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1138
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1138
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
1972 | 25 #ifndef SHARE_VM_CI_CIFIELD_HPP |
26 #define SHARE_VM_CI_CIFIELD_HPP | |
27 | |
28 #include "ci/ciClassList.hpp" | |
29 #include "ci/ciConstant.hpp" | |
30 #include "ci/ciFlags.hpp" | |
31 #include "ci/ciInstance.hpp" | |
32 | |
0 | 33 // ciField |
34 // | |
35 // This class represents the result of a field lookup in the VM. | |
36 // The lookup may not succeed, in which case the information in | |
37 // the ciField will be incomplete. | |
38 class ciField : public ResourceObj { | |
39 CI_PACKAGE_ACCESS | |
40 friend class ciEnv; | |
41 friend class ciInstanceKlass; | |
42 friend class NonStaticFieldFiller; | |
43 | |
44 private: | |
45 ciFlags _flags; | |
46 ciInstanceKlass* _holder; | |
47 ciSymbol* _name; | |
48 ciSymbol* _signature; | |
49 ciType* _type; | |
50 int _offset; | |
51 bool _is_constant; | |
52 ciInstanceKlass* _known_to_link_with; | |
53 ciConstant _constant_value; | |
54 | |
55 // Used for will_link | |
56 int _cp_index; | |
57 | |
58 ciType* compute_type(); | |
59 ciType* compute_type_impl(); | |
60 | |
61 ciField(ciInstanceKlass* klass, int index); | |
62 ciField(fieldDescriptor* fd); | |
63 | |
64 // shared constructor code | |
65 void initialize_from(fieldDescriptor* fd); | |
66 | |
67 public: | |
68 ciFlags flags() { return _flags; } | |
69 | |
70 // Of which klass is this field a member? | |
71 // | |
72 // Usage note: the declared holder of a field is the class | |
73 // referenced by name in the bytecodes. The canonical holder | |
74 // is the most general class which holds the field. This | |
75 // method returns the canonical holder. The declared holder | |
76 // can be accessed via a method in ciBytecodeStream. | |
77 // | |
78 // Ex. | |
79 // class A { | |
80 // public int f = 7; | |
81 // } | |
82 // class B extends A { | |
83 // public void test() { | |
84 // System.out.println(f); | |
85 // } | |
86 // } | |
87 // | |
88 // A java compiler is permitted to compile the access to | |
89 // field f as: | |
90 // | |
91 // getfield B.f | |
92 // | |
93 // In that case the declared holder of f would be B and | |
94 // the canonical holder of f would be A. | |
95 ciInstanceKlass* holder() { return _holder; } | |
96 | |
97 // Name of this field? | |
98 ciSymbol* name() { return _name; } | |
99 | |
100 // Signature of this field? | |
101 ciSymbol* signature() { return _signature; } | |
102 | |
103 // Of what type is this field? | |
104 ciType* type() { return (_type == NULL) ? compute_type() : _type; } | |
105 | |
106 // How is this field actually stored in memory? | |
107 BasicType layout_type() { return type2field[(_type == NULL) ? T_OBJECT : _type->basic_type()]; } | |
108 | |
109 // How big is this field in memory? | |
29
d5fc211aea19
6633953: type2aelembytes{T_ADDRESS} should be 8 bytes in 64 bit VM
kvn
parents:
0
diff
changeset
|
110 int size_in_bytes() { return type2aelembytes(layout_type()); } |
0 | 111 |
112 // What is the offset of this field? | |
113 int offset() { | |
114 assert(_offset >= 1, "illegal call to offset()"); | |
115 return _offset; | |
116 } | |
117 | |
118 // Same question, explicit units. (Fields are aligned to the byte level.) | |
119 int offset_in_bytes() { | |
120 return offset(); | |
121 } | |
122 | |
123 // Is this field shared? | |
124 bool is_shared() { | |
125 // non-static fields of shared holders are cached | |
126 return _holder->is_shared() && !is_static(); | |
127 } | |
128 | |
129 // Is this field a constant? | |
130 // | |
131 // Clarification: A field is considered constant if: | |
132 // 1. The field is both static and final | |
133 // 2. The canonical holder of the field has undergone | |
134 // static initialization. | |
135 // 3. If the field is an object or array, then the oop | |
136 // in question is allocated in perm space. | |
137 // 4. The field is not one of the special static/final | |
138 // non-constant fields. These are java.lang.System.in | |
139 // and java.lang.System.out. Abomination. | |
140 // | |
141 // Note: the check for case 4 is not yet implemented. | |
142 bool is_constant() { return _is_constant; } | |
143 | |
144 // Get the constant value of this field. | |
145 ciConstant constant_value() { | |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
196
diff
changeset
|
146 assert(is_static() && is_constant(), "illegal call to constant_value()"); |
0 | 147 return _constant_value; |
148 } | |
149 | |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
196
diff
changeset
|
150 // Get the constant value of non-static final field in the given |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
196
diff
changeset
|
151 // object. |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
196
diff
changeset
|
152 ciConstant constant_value_of(ciObject* object) { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
196
diff
changeset
|
153 assert(!is_static() && is_constant(), "only if field is non-static constant"); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
196
diff
changeset
|
154 assert(object->is_instance(), "must be instance"); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
196
diff
changeset
|
155 return object->as_instance()->field_value(this); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
196
diff
changeset
|
156 } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
196
diff
changeset
|
157 |
0 | 158 // Check for link time errors. Accessing a field from a |
159 // certain class via a certain bytecode may or may not be legal. | |
160 // This call checks to see if an exception may be raised by | |
161 // an access of this field. | |
162 // | |
163 // Usage note: if the same field is accessed multiple times | |
164 // in the same compilation, will_link will need to be checked | |
165 // at each point of access. | |
166 bool will_link(ciInstanceKlass* accessing_klass, | |
167 Bytecodes::Code bc); | |
1459
a8f9f091c219
Don't mess with VMToNative transitions..
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1138
diff
changeset
|
168 bool will_link_from_vm(ciInstanceKlass* accessing_klass, |
a8f9f091c219
Don't mess with VMToNative transitions..
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1138
diff
changeset
|
169 Bytecodes::Code bc); |
0 | 170 |
171 // Java access flags | |
172 bool is_public () { return flags().is_public(); } | |
173 bool is_private () { return flags().is_private(); } | |
174 bool is_protected () { return flags().is_protected(); } | |
175 bool is_static () { return flags().is_static(); } | |
176 bool is_final () { return flags().is_final(); } | |
177 bool is_volatile () { return flags().is_volatile(); } | |
178 bool is_transient () { return flags().is_transient(); } | |
179 | |
3901
aa67216400d3
7085404: JSR 292: VolatileCallSites should have push notification too
twisti
parents:
3899
diff
changeset
|
180 bool is_call_site_target() { |
3907
7b5c767f229c
7086560: 7085404 changes broke VM with -XX:-EnableInvokeDynamic
kvn
parents:
3901
diff
changeset
|
181 ciInstanceKlass* callsite_klass = CURRENT_ENV->CallSite_klass(); |
7b5c767f229c
7086560: 7085404 changes broke VM with -XX:-EnableInvokeDynamic
kvn
parents:
3901
diff
changeset
|
182 if (callsite_klass == NULL) |
7b5c767f229c
7086560: 7085404 changes broke VM with -XX:-EnableInvokeDynamic
kvn
parents:
3901
diff
changeset
|
183 return false; |
7b5c767f229c
7086560: 7085404 changes broke VM with -XX:-EnableInvokeDynamic
kvn
parents:
3901
diff
changeset
|
184 return (holder()->is_subclass_of(callsite_klass) && (name() == ciSymbol::target_name())); |
3901
aa67216400d3
7085404: JSR 292: VolatileCallSites should have push notification too
twisti
parents:
3899
diff
changeset
|
185 } |
3852
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
1972
diff
changeset
|
186 |
0 | 187 // Debugging output |
188 void print(); | |
189 void print_name_on(outputStream* st); | |
190 }; | |
1972 | 191 |
192 #endif // SHARE_VM_CI_CIFIELD_HPP |