Mercurial > hg > graal-jvmci-8
comparison src/share/vm/ci/ciField.cpp @ 12190:edb5ab0f3fe5
8001107: @Stable annotation for constant folding of lazily evaluated variables
Reviewed-by: rbackman, twisti, kvn
Contributed-by: john.r.rose@oracle.com, vladimir.x.ivanov@oracle.com
author | vlivanov |
---|---|
date | Tue, 10 Sep 2013 14:51:48 -0700 |
parents | ad5dd04754ee |
children | b2e698d2276c |
comparison
equal
deleted
inserted
replaced
12188:cd16d587b0fa | 12190:edb5ab0f3fe5 |
---|---|
187 _flags = ciFlags(fd->access_flags()); | 187 _flags = ciFlags(fd->access_flags()); |
188 _offset = fd->offset(); | 188 _offset = fd->offset(); |
189 _holder = CURRENT_ENV->get_instance_klass(fd->field_holder()); | 189 _holder = CURRENT_ENV->get_instance_klass(fd->field_holder()); |
190 | 190 |
191 // Check to see if the field is constant. | 191 // Check to see if the field is constant. |
192 if (_holder->is_initialized() && this->is_final()) { | 192 bool is_final = this->is_final(); |
193 bool is_stable = FoldStableValues && this->is_stable(); | |
194 if (_holder->is_initialized() && (is_final || is_stable)) { | |
193 if (!this->is_static()) { | 195 if (!this->is_static()) { |
194 // A field can be constant if it's a final static field or if | 196 // A field can be constant if it's a final static field or if |
195 // it's a final non-static field of a trusted class (classes in | 197 // it's a final non-static field of a trusted class (classes in |
196 // java.lang.invoke and sun.invoke packages and subpackages). | 198 // java.lang.invoke and sun.invoke packages and subpackages). |
197 if (trust_final_non_static_fields(_holder)) { | 199 if (is_stable || trust_final_non_static_fields(_holder)) { |
198 _is_constant = true; | 200 _is_constant = true; |
199 return; | 201 return; |
200 } | 202 } |
201 _is_constant = false; | 203 _is_constant = false; |
202 return; | 204 return; |
225 } | 227 } |
226 } | 228 } |
227 | 229 |
228 Handle mirror = k->java_mirror(); | 230 Handle mirror = k->java_mirror(); |
229 | 231 |
230 _is_constant = true; | |
231 switch(type()->basic_type()) { | 232 switch(type()->basic_type()) { |
232 case T_BYTE: | 233 case T_BYTE: |
233 _constant_value = ciConstant(type()->basic_type(), mirror->byte_field(_offset)); | 234 _constant_value = ciConstant(type()->basic_type(), mirror->byte_field(_offset)); |
234 break; | 235 break; |
235 case T_CHAR: | 236 case T_CHAR: |
270 } else { | 271 } else { |
271 _constant_value = ciConstant(type()->basic_type(), CURRENT_ENV->get_object(o)); | 272 _constant_value = ciConstant(type()->basic_type(), CURRENT_ENV->get_object(o)); |
272 assert(_constant_value.as_object() == CURRENT_ENV->get_object(o), "check interning"); | 273 assert(_constant_value.as_object() == CURRENT_ENV->get_object(o), "check interning"); |
273 } | 274 } |
274 } | 275 } |
276 } | |
277 if (is_stable && _constant_value.is_null_or_zero()) { | |
278 // It is not a constant after all; treat it as uninitialized. | |
279 _is_constant = false; | |
280 } else { | |
281 _is_constant = true; | |
275 } | 282 } |
276 } else { | 283 } else { |
277 _is_constant = false; | 284 _is_constant = false; |
278 } | 285 } |
279 } | 286 } |
371 tty->print("."); | 378 tty->print("."); |
372 _name->print_symbol(); | 379 _name->print_symbol(); |
373 tty->print(" signature="); | 380 tty->print(" signature="); |
374 _signature->print_symbol(); | 381 _signature->print_symbol(); |
375 tty->print(" offset=%d type=", _offset); | 382 tty->print(" offset=%d type=", _offset); |
376 if (_type != NULL) _type->print_name(); | 383 if (_type != NULL) |
377 else tty->print("(reference)"); | 384 _type->print_name(); |
385 else | |
386 tty->print("(reference)"); | |
387 tty->print(" flags=%04x", flags().as_int()); | |
378 tty->print(" is_constant=%s", bool_to_str(_is_constant)); | 388 tty->print(" is_constant=%s", bool_to_str(_is_constant)); |
379 if (_is_constant && is_static()) { | 389 if (_is_constant && is_static()) { |
380 tty->print(" constant_value="); | 390 tty->print(" constant_value="); |
381 _constant_value.print(); | 391 _constant_value.print(); |
382 } | 392 } |