31 #include "ci/ciInstance.hpp"
32
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;
51 ciInstanceKlass* _known_to_link_with_put;
52 ciInstanceKlass* _known_to_link_with_get;
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:
65 ciFlags flags() const { return _flags; }
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
114
115 // Same question, explicit units. (Fields are aligned to the byte level.)
116 int offset_in_bytes() const {
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
130 // 2. The field is not one of the special static/final
131 // non-constant fields. These are java.lang.System.in
132 // and java.lang.System.out. Abomination.
133 //
134 // A field is also considered constant if it is marked @Stable
135 // and is non-null (or non-zero, if a primitive).
136 //
137 // A user should also check the field value (constant_value().is_valid()), since
138 // constant fields of non-initialized classes don't have values yet.
139 bool is_constant() const { return _is_constant; }
140
141 // Get the constant value of the static field.
142 ciConstant constant_value();
143
144 bool is_static_constant() {
145 return is_static() && is_constant() && constant_value().is_valid();
146 }
147
148 // Get the constant value of non-static final field in the given
149 // object.
150 ciConstant constant_value_of(ciObject* object);
151
152 // Check for link time errors. Accessing a field from a
153 // certain class via a certain bytecode may or may not be legal.
154 // This call checks to see if an exception may be raised by
155 // an access of this field.
156 //
157 // Usage note: if the same field is accessed multiple times
158 // in the same compilation, will_link will need to be checked
159 // at each point of access.
160 bool will_link(ciInstanceKlass* accessing_klass,
161 Bytecodes::Code bc);
162
163 // Java access flags
164 bool is_public () const { return flags().is_public(); }
165 bool is_private () const { return flags().is_private(); }
166 bool is_protected () const { return flags().is_protected(); }
167 bool is_static () const { return flags().is_static(); }
168 bool is_final () const { return flags().is_final(); }
169 bool is_stable () const { return flags().is_stable(); }
170 bool is_volatile () const { return flags().is_volatile(); }
171 bool is_transient () const { return flags().is_transient(); }
172
173 bool is_call_site_target() {
174 ciInstanceKlass* callsite_klass = CURRENT_ENV->CallSite_klass();
175 if (callsite_klass == NULL)
176 return false;
177 return (holder()->is_subclass_of(callsite_klass) && (name() == ciSymbol::target_name()));
178 }
179
180 bool is_autobox_cache() {
181 ciSymbol* klass_name = holder()->name();
182 return (name() == ciSymbol::cache_field_name() &&
183 holder()->uses_default_loader() &&
184 (klass_name == ciSymbol::java_lang_Character_CharacterCache() ||
185 klass_name == ciSymbol::java_lang_Byte_ByteCache() ||
186 klass_name == ciSymbol::java_lang_Short_ShortCache() ||
187 klass_name == ciSymbol::java_lang_Integer_IntegerCache() ||
188 klass_name == ciSymbol::java_lang_Long_LongCache()));
189 }
190
191 // Debugging output
|
31 #include "ci/ciInstance.hpp"
32
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;
51 ciMethod* _known_to_link_with_put;
52 ciInstanceKlass* _known_to_link_with_get;
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:
65 ciFlags flags() const { return _flags; }
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
114
115 // Same question, explicit units. (Fields are aligned to the byte level.)
116 int offset_in_bytes() const {
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
130 // 2. The field is not one of the special static/final
131 // non-constant fields. These are java.lang.System.in
132 // and java.lang.System.out. Abomination.
133 //
134 // A field is also considered constant if
135 // - it is marked @Stable and is non-null (or non-zero, if a primitive) or
136 // - it is trusted or
137 // - it is the target field of a CallSite object.
138 //
139 // See ciField::initialize_from() for more details.
140 //
141 // A user should also check the field value (constant_value().is_valid()), since
142 // constant fields of non-initialized classes don't have values yet.
143 bool is_constant() const { return _is_constant; }
144
145 // Get the constant value of the static field.
146 ciConstant constant_value();
147
148 bool is_static_constant() {
149 return is_static() && is_constant() && constant_value().is_valid();
150 }
151
152 // Get the constant value of non-static final field in the given
153 // object.
154 ciConstant constant_value_of(ciObject* object);
155
156 // Check for link time errors. Accessing a field from a
157 // certain method via a certain bytecode may or may not be legal.
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.
164 bool will_link(ciMethod* accessing_method,
165 Bytecodes::Code bc);
166
167 // Java access flags
168 bool is_public () const { return flags().is_public(); }
169 bool is_private () const { return flags().is_private(); }
170 bool is_protected () const { return flags().is_protected(); }
171 bool is_static () const { return flags().is_static(); }
172 bool is_final () const { return flags().is_final(); }
173 bool is_stable () const { return flags().is_stable(); }
174 bool is_volatile () const { return flags().is_volatile(); }
175 bool is_transient () const { return flags().is_transient(); }
176 // The field is modified outside of instance initializer methods
177 // (or class/initializer methods if the field is static).
178 bool has_initialized_final_update() const { return flags().has_initialized_final_update(); }
179
180 bool is_call_site_target() {
181 ciInstanceKlass* callsite_klass = CURRENT_ENV->CallSite_klass();
182 if (callsite_klass == NULL)
183 return false;
184 return (holder()->is_subclass_of(callsite_klass) && (name() == ciSymbol::target_name()));
185 }
186
187 bool is_autobox_cache() {
188 ciSymbol* klass_name = holder()->name();
189 return (name() == ciSymbol::cache_field_name() &&
190 holder()->uses_default_loader() &&
191 (klass_name == ciSymbol::java_lang_Character_CharacterCache() ||
192 klass_name == ciSymbol::java_lang_Byte_ByteCache() ||
193 klass_name == ciSymbol::java_lang_Short_ShortCache() ||
194 klass_name == ciSymbol::java_lang_Integer_IntegerCache() ||
195 klass_name == ciSymbol::java_lang_Long_LongCache()));
196 }
197
198 // Debugging output
|