author | erikj |
Tue, 12 Sep 2017 19:03:39 +0200 | |
changeset 47216 | 71c04702a3d5 |
parent 39421 | hotspot/src/share/vm/ci/ciField.hpp@a9652c919db8 |
child 49449 | ef5d5d343e2a |
permissions | -rw-r--r-- |
1 | 1 |
/* |
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
19770
diff
changeset
|
2 |
* Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. |
1 | 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 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
4567
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
4567
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
4567
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 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 |
||
1 | 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 |
||
43 |
private: |
|
44 |
ciFlags _flags; |
|
45 |
ciInstanceKlass* _holder; |
|
46 |
ciSymbol* _name; |
|
47 |
ciSymbol* _signature; |
|
48 |
ciType* _type; |
|
49 |
int _offset; |
|
50 |
bool _is_constant; |
|
39421
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38030
diff
changeset
|
51 |
ciMethod* _known_to_link_with_put; |
12982 | 52 |
ciInstanceKlass* _known_to_link_with_get; |
1 | 53 |
ciConstant _constant_value; |
54 |
||
55 |
ciType* compute_type(); |
|
56 |
ciType* compute_type_impl(); |
|
57 |
||
58 |
ciField(ciInstanceKlass* klass, int index); |
|
59 |
ciField(fieldDescriptor* fd); |
|
60 |
||
61 |
// shared constructor code |
|
62 |
void initialize_from(fieldDescriptor* fd); |
|
63 |
||
64 |
public: |
|
38030
93f24e7b3c43
8152590: C2: @Stable support doesn't always work w/ incremental inlining
vlivanov
parents:
31857
diff
changeset
|
65 |
ciFlags flags() const { return _flags; } |
1 | 66 |
|
67 |
// Of which klass is this field a member? |
|
68 |
// |
|
69 |
// Usage note: the declared holder of a field is the class |
|
70 |
// referenced by name in the bytecodes. The canonical holder |
|
71 |
// is the most general class which holds the field. This |
|
72 |
// method returns the canonical holder. The declared holder |
|
73 |
// can be accessed via a method in ciBytecodeStream. |
|
74 |
// |
|
75 |
// Ex. |
|
76 |
// class A { |
|
77 |
// public int f = 7; |
|
78 |
// } |
|
79 |
// class B extends A { |
|
80 |
// public void test() { |
|
81 |
// System.out.println(f); |
|
82 |
// } |
|
83 |
// } |
|
84 |
// |
|
85 |
// A java compiler is permitted to compile the access to |
|
86 |
// field f as: |
|
87 |
// |
|
88 |
// getfield B.f |
|
89 |
// |
|
90 |
// In that case the declared holder of f would be B and |
|
91 |
// the canonical holder of f would be A. |
|
38030
93f24e7b3c43
8152590: C2: @Stable support doesn't always work w/ incremental inlining
vlivanov
parents:
31857
diff
changeset
|
92 |
ciInstanceKlass* holder() const { return _holder; } |
1 | 93 |
|
94 |
// Name of this field? |
|
38030
93f24e7b3c43
8152590: C2: @Stable support doesn't always work w/ incremental inlining
vlivanov
parents:
31857
diff
changeset
|
95 |
ciSymbol* name() const { return _name; } |
1 | 96 |
|
97 |
// Signature of this field? |
|
38030
93f24e7b3c43
8152590: C2: @Stable support doesn't always work w/ incremental inlining
vlivanov
parents:
31857
diff
changeset
|
98 |
ciSymbol* signature() const { return _signature; } |
1 | 99 |
|
100 |
// Of what type is this field? |
|
101 |
ciType* type() { return (_type == NULL) ? compute_type() : _type; } |
|
102 |
||
103 |
// How is this field actually stored in memory? |
|
104 |
BasicType layout_type() { return type2field[(_type == NULL) ? T_OBJECT : _type->basic_type()]; } |
|
105 |
||
106 |
// How big is this field in memory? |
|
202
dc13bf0e5d5d
6633953: type2aelembytes{T_ADDRESS} should be 8 bytes in 64 bit VM
kvn
parents:
1
diff
changeset
|
107 |
int size_in_bytes() { return type2aelembytes(layout_type()); } |
1 | 108 |
|
109 |
// What is the offset of this field? |
|
38030
93f24e7b3c43
8152590: C2: @Stable support doesn't always work w/ incremental inlining
vlivanov
parents:
31857
diff
changeset
|
110 |
int offset() const { |
1 | 111 |
assert(_offset >= 1, "illegal call to offset()"); |
112 |
return _offset; |
|
113 |
} |
|
114 |
||
115 |
// Same question, explicit units. (Fields are aligned to the byte level.) |
|
38030
93f24e7b3c43
8152590: C2: @Stable support doesn't always work w/ incremental inlining
vlivanov
parents:
31857
diff
changeset
|
116 |
int offset_in_bytes() const { |
1 | 117 |
return offset(); |
118 |
} |
|
119 |
||
120 |
// Is this field shared? |
|
121 |
bool is_shared() { |
|
122 |
// non-static fields of shared holders are cached |
|
123 |
return _holder->is_shared() && !is_static(); |
|
124 |
} |
|
125 |
||
126 |
// Is this field a constant? |
|
127 |
// |
|
128 |
// Clarification: A field is considered constant if: |
|
129 |
// 1. The field is both static and final |
|
38030
93f24e7b3c43
8152590: C2: @Stable support doesn't always work w/ incremental inlining
vlivanov
parents:
31857
diff
changeset
|
130 |
// 2. The field is not one of the special static/final |
1 | 131 |
// non-constant fields. These are java.lang.System.in |
132 |
// and java.lang.System.out. Abomination. |
|
133 |
// |
|
39421
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38030
diff
changeset
|
134 |
// A field is also considered constant if |
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38030
diff
changeset
|
135 |
// - it is marked @Stable and is non-null (or non-zero, if a primitive) or |
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38030
diff
changeset
|
136 |
// - it is trusted or |
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38030
diff
changeset
|
137 |
// - it is the target field of a CallSite object. |
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38030
diff
changeset
|
138 |
// |
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38030
diff
changeset
|
139 |
// See ciField::initialize_from() for more details. |
38030
93f24e7b3c43
8152590: C2: @Stable support doesn't always work w/ incremental inlining
vlivanov
parents:
31857
diff
changeset
|
140 |
// |
93f24e7b3c43
8152590: C2: @Stable support doesn't always work w/ incremental inlining
vlivanov
parents:
31857
diff
changeset
|
141 |
// A user should also check the field value (constant_value().is_valid()), since |
93f24e7b3c43
8152590: C2: @Stable support doesn't always work w/ incremental inlining
vlivanov
parents:
31857
diff
changeset
|
142 |
// constant fields of non-initialized classes don't have values yet. |
93f24e7b3c43
8152590: C2: @Stable support doesn't always work w/ incremental inlining
vlivanov
parents:
31857
diff
changeset
|
143 |
bool is_constant() const { return _is_constant; } |
1 | 144 |
|
38030
93f24e7b3c43
8152590: C2: @Stable support doesn't always work w/ incremental inlining
vlivanov
parents:
31857
diff
changeset
|
145 |
// Get the constant value of the static field. |
93f24e7b3c43
8152590: C2: @Stable support doesn't always work w/ incremental inlining
vlivanov
parents:
31857
diff
changeset
|
146 |
ciConstant constant_value(); |
93f24e7b3c43
8152590: C2: @Stable support doesn't always work w/ incremental inlining
vlivanov
parents:
31857
diff
changeset
|
147 |
|
93f24e7b3c43
8152590: C2: @Stable support doesn't always work w/ incremental inlining
vlivanov
parents:
31857
diff
changeset
|
148 |
bool is_static_constant() { |
93f24e7b3c43
8152590: C2: @Stable support doesn't always work w/ incremental inlining
vlivanov
parents:
31857
diff
changeset
|
149 |
return is_static() && is_constant() && constant_value().is_valid(); |
1 | 150 |
} |
151 |
||
4567
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
670
diff
changeset
|
152 |
// Get the constant value of non-static final field in the given |
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
670
diff
changeset
|
153 |
// object. |
38030
93f24e7b3c43
8152590: C2: @Stable support doesn't always work w/ incremental inlining
vlivanov
parents:
31857
diff
changeset
|
154 |
ciConstant constant_value_of(ciObject* object); |
4567
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
670
diff
changeset
|
155 |
|
1 | 156 |
// Check for link time errors. Accessing a field from a |
39421
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38030
diff
changeset
|
157 |
// certain method via a certain bytecode may or may not be legal. |
1 | 158 |
// This call checks to see if an exception may be raised by |
159 |
// an access of this field. |
|
160 |
// |
|
161 |
// Usage note: if the same field is accessed multiple times |
|
162 |
// in the same compilation, will_link will need to be checked |
|
163 |
// at each point of access. |
|
39421
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38030
diff
changeset
|
164 |
bool will_link(ciMethod* accessing_method, |
1 | 165 |
Bytecodes::Code bc); |
166 |
||
167 |
// Java access flags |
|
39421
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38030
diff
changeset
|
168 |
bool is_public () const { return flags().is_public(); } |
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38030
diff
changeset
|
169 |
bool is_private () const { return flags().is_private(); } |
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38030
diff
changeset
|
170 |
bool is_protected () const { return flags().is_protected(); } |
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38030
diff
changeset
|
171 |
bool is_static () const { return flags().is_static(); } |
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38030
diff
changeset
|
172 |
bool is_final () const { return flags().is_final(); } |
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38030
diff
changeset
|
173 |
bool is_stable () const { return flags().is_stable(); } |
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38030
diff
changeset
|
174 |
bool is_volatile () const { return flags().is_volatile(); } |
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38030
diff
changeset
|
175 |
bool is_transient () const { return flags().is_transient(); } |
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38030
diff
changeset
|
176 |
// The field is modified outside of instance initializer methods |
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38030
diff
changeset
|
177 |
// (or class/initializer methods if the field is static). |
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38030
diff
changeset
|
178 |
bool has_initialized_final_update() const { return flags().has_initialized_final_update(); } |
1 | 179 |
|
10510
ab626d1bdf53
7085404: JSR 292: VolatileCallSites should have push notification too
twisti
parents:
10508
diff
changeset
|
180 |
bool is_call_site_target() { |
10516
2797e487c09f
7086560: 7085404 changes broke VM with -XX:-EnableInvokeDynamic
kvn
parents:
10510
diff
changeset
|
181 |
ciInstanceKlass* callsite_klass = CURRENT_ENV->CallSite_klass(); |
2797e487c09f
7086560: 7085404 changes broke VM with -XX:-EnableInvokeDynamic
kvn
parents:
10510
diff
changeset
|
182 |
if (callsite_klass == NULL) |
2797e487c09f
7086560: 7085404 changes broke VM with -XX:-EnableInvokeDynamic
kvn
parents:
10510
diff
changeset
|
183 |
return false; |
2797e487c09f
7086560: 7085404 changes broke VM with -XX:-EnableInvokeDynamic
kvn
parents:
10510
diff
changeset
|
184 |
return (holder()->is_subclass_of(callsite_klass) && (name() == ciSymbol::target_name())); |
10510
ab626d1bdf53
7085404: JSR 292: VolatileCallSites should have push notification too
twisti
parents:
10508
diff
changeset
|
185 |
} |
10265
4c869854aebd
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
7397
diff
changeset
|
186 |
|
31857
adbf29d9ca43
8078629: VM should constant fold Unsafe.get*() loads from final fields
vlivanov
parents:
26706
diff
changeset
|
187 |
bool is_autobox_cache() { |
adbf29d9ca43
8078629: VM should constant fold Unsafe.get*() loads from final fields
vlivanov
parents:
26706
diff
changeset
|
188 |
ciSymbol* klass_name = holder()->name(); |
adbf29d9ca43
8078629: VM should constant fold Unsafe.get*() loads from final fields
vlivanov
parents:
26706
diff
changeset
|
189 |
return (name() == ciSymbol::cache_field_name() && |
adbf29d9ca43
8078629: VM should constant fold Unsafe.get*() loads from final fields
vlivanov
parents:
26706
diff
changeset
|
190 |
holder()->uses_default_loader() && |
adbf29d9ca43
8078629: VM should constant fold Unsafe.get*() loads from final fields
vlivanov
parents:
26706
diff
changeset
|
191 |
(klass_name == ciSymbol::java_lang_Character_CharacterCache() || |
adbf29d9ca43
8078629: VM should constant fold Unsafe.get*() loads from final fields
vlivanov
parents:
26706
diff
changeset
|
192 |
klass_name == ciSymbol::java_lang_Byte_ByteCache() || |
adbf29d9ca43
8078629: VM should constant fold Unsafe.get*() loads from final fields
vlivanov
parents:
26706
diff
changeset
|
193 |
klass_name == ciSymbol::java_lang_Short_ShortCache() || |
adbf29d9ca43
8078629: VM should constant fold Unsafe.get*() loads from final fields
vlivanov
parents:
26706
diff
changeset
|
194 |
klass_name == ciSymbol::java_lang_Integer_IntegerCache() || |
adbf29d9ca43
8078629: VM should constant fold Unsafe.get*() loads from final fields
vlivanov
parents:
26706
diff
changeset
|
195 |
klass_name == ciSymbol::java_lang_Long_LongCache())); |
adbf29d9ca43
8078629: VM should constant fold Unsafe.get*() loads from final fields
vlivanov
parents:
26706
diff
changeset
|
196 |
} |
adbf29d9ca43
8078629: VM should constant fold Unsafe.get*() loads from final fields
vlivanov
parents:
26706
diff
changeset
|
197 |
|
1 | 198 |
// Debugging output |
199 |
void print(); |
|
200 |
void print_name_on(outputStream* st); |
|
201 |
}; |
|
7397 | 202 |
|
203 |
#endif // SHARE_VM_CI_CIFIELD_HPP |