Mercurial > hg > graal-compiler
comparison src/share/vm/ci/ciField.cpp @ 12355:cefad50507d8
Merge with hs25-b53
author | Gilles Duboscq <duboscq@ssw.jku.at> |
---|---|
date | Fri, 11 Oct 2013 10:38:03 +0200 |
parents | 989155e2d07a b2e698d2276c |
children | d8041d695d19 |
comparison
equal
deleted
inserted
replaced
12058:ccb4f2af2319 | 12355:cefad50507d8 |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. | 2 * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | 4 * |
5 * This code is free software; you can redistribute it and/or modify it | 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 | 6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
73 | 73 |
74 assert(ciObjectFactory::is_initialized(), "not a shared field"); | 74 assert(ciObjectFactory::is_initialized(), "not a shared field"); |
75 | 75 |
76 assert(klass->get_instanceKlass()->is_linked(), "must be linked before using its constan-pool"); | 76 assert(klass->get_instanceKlass()->is_linked(), "must be linked before using its constan-pool"); |
77 | 77 |
78 _cp_index = index; | |
79 constantPoolHandle cpool(thread, klass->get_instanceKlass()->constants()); | 78 constantPoolHandle cpool(thread, klass->get_instanceKlass()->constants()); |
80 | 79 |
81 // Get the field's name, signature, and type. | 80 // Get the field's name, signature, and type. |
82 Symbol* name = cpool->name_ref_at(index); | 81 Symbol* name = cpool->name_ref_at(index); |
83 _name = ciEnv::current(thread)->get_symbol(name); | 82 _name = ciEnv::current(thread)->get_symbol(name); |
114 klass)->as_instance_klass(); | 113 klass)->as_instance_klass(); |
115 | 114 |
116 // The declared holder of this field may not have been loaded. | 115 // The declared holder of this field may not have been loaded. |
117 // Bail out with partial field information. | 116 // Bail out with partial field information. |
118 if (!holder_is_accessible) { | 117 if (!holder_is_accessible) { |
119 // _cp_index and _type have already been set. | 118 // _type has already been set. |
120 // The default values for _flags and _constant_value will suffice. | 119 // The default values for _flags and _constant_value will suffice. |
121 // We need values for _holder, _offset, and _is_constant, | 120 // We need values for _holder, _offset, and _is_constant, |
122 _holder = declared_holder; | 121 _holder = declared_holder; |
123 _offset = -1; | 122 _offset = -1; |
124 _is_constant = false; | 123 _is_constant = false; |
144 } | 143 } |
145 | 144 |
146 ciField::ciField(fieldDescriptor *fd): _known_to_link_with_put(NULL), _known_to_link_with_get(NULL) { | 145 ciField::ciField(fieldDescriptor *fd): _known_to_link_with_put(NULL), _known_to_link_with_get(NULL) { |
147 ASSERT_IN_VM; | 146 ASSERT_IN_VM; |
148 | 147 |
149 _cp_index = -1; | |
150 | |
151 // Get the field's name, signature, and type. | 148 // Get the field's name, signature, and type. |
152 ciEnv* env = CURRENT_ENV; | 149 ciEnv* env = CURRENT_ENV; |
153 _name = env->get_symbol(fd->name()); | 150 _name = env->get_symbol(fd->name()); |
154 _signature = env->get_symbol(fd->signature()); | 151 _signature = env->get_symbol(fd->signature()); |
155 | 152 |
187 _flags = ciFlags(fd->access_flags()); | 184 _flags = ciFlags(fd->access_flags()); |
188 _offset = fd->offset(); | 185 _offset = fd->offset(); |
189 _holder = CURRENT_ENV->get_instance_klass(fd->field_holder()); | 186 _holder = CURRENT_ENV->get_instance_klass(fd->field_holder()); |
190 | 187 |
191 // Check to see if the field is constant. | 188 // Check to see if the field is constant. |
192 if (_holder->is_initialized() && this->is_final()) { | 189 bool is_final = this->is_final(); |
190 bool is_stable = FoldStableValues && this->is_stable(); | |
191 if (_holder->is_initialized() && (is_final || is_stable)) { | |
193 if (!this->is_static()) { | 192 if (!this->is_static()) { |
194 // A field can be constant if it's a final static field or if | 193 // 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 | 194 // it's a final non-static field of a trusted class (classes in |
196 // java.lang.invoke and sun.invoke packages and subpackages). | 195 // java.lang.invoke and sun.invoke packages and subpackages). |
197 if (trust_final_non_static_fields(_holder)) { | 196 if (is_stable || trust_final_non_static_fields(_holder)) { |
198 _is_constant = true; | 197 _is_constant = true; |
199 return; | 198 return; |
200 } | 199 } |
201 _is_constant = false; | 200 _is_constant = false; |
202 return; | 201 return; |
225 } | 224 } |
226 } | 225 } |
227 | 226 |
228 Handle mirror = k->java_mirror(); | 227 Handle mirror = k->java_mirror(); |
229 | 228 |
230 _is_constant = true; | |
231 switch(type()->basic_type()) { | 229 switch(type()->basic_type()) { |
232 case T_BYTE: | 230 case T_BYTE: |
233 _constant_value = ciConstant(type()->basic_type(), mirror->byte_field(_offset)); | 231 _constant_value = ciConstant(type()->basic_type(), mirror->byte_field(_offset)); |
234 break; | 232 break; |
235 case T_CHAR: | 233 case T_CHAR: |
270 } else { | 268 } else { |
271 _constant_value = ciConstant(type()->basic_type(), CURRENT_ENV->get_object(o)); | 269 _constant_value = ciConstant(type()->basic_type(), CURRENT_ENV->get_object(o)); |
272 assert(_constant_value.as_object() == CURRENT_ENV->get_object(o), "check interning"); | 270 assert(_constant_value.as_object() == CURRENT_ENV->get_object(o), "check interning"); |
273 } | 271 } |
274 } | 272 } |
273 } | |
274 if (is_stable && _constant_value.is_null_or_zero()) { | |
275 // It is not a constant after all; treat it as uninitialized. | |
276 _is_constant = false; | |
277 } else { | |
278 _is_constant = true; | |
275 } | 279 } |
276 } else { | 280 } else { |
277 _is_constant = false; | 281 _is_constant = false; |
278 } | 282 } |
279 } | 283 } |
342 if (_known_to_link_with_get == accessing_klass) { | 346 if (_known_to_link_with_get == accessing_klass) { |
343 return true; | 347 return true; |
344 } | 348 } |
345 } | 349 } |
346 | 350 |
347 FieldAccessInfo result; | 351 fieldDescriptor result; |
348 constantPoolHandle c_pool(THREAD, | 352 LinkResolver::resolve_field(result, _holder->get_instanceKlass(), |
349 accessing_klass->get_instanceKlass()->constants()); | 353 _name->get_symbol(), _signature->get_symbol(), |
350 LinkResolver::resolve_field(result, c_pool, _cp_index, | 354 accessing_klass->get_Klass(), bc, true, false, |
351 Bytecodes::java_code(bc), | 355 KILL_COMPILE_ON_FATAL_(false)); |
352 true, false, KILL_COMPILE_ON_FATAL_(false)); | |
353 | 356 |
354 // update the hit-cache, unless there is a problem with memory scoping: | 357 // update the hit-cache, unless there is a problem with memory scoping: |
355 if (accessing_klass->is_shared() || !is_shared()) { | 358 if (accessing_klass->is_shared() || !is_shared()) { |
356 if (is_put) { | 359 if (is_put) { |
357 _known_to_link_with_put = accessing_klass; | 360 _known_to_link_with_put = accessing_klass; |
371 tty->print("."); | 374 tty->print("."); |
372 _name->print_symbol(); | 375 _name->print_symbol(); |
373 tty->print(" signature="); | 376 tty->print(" signature="); |
374 _signature->print_symbol(); | 377 _signature->print_symbol(); |
375 tty->print(" offset=%d type=", _offset); | 378 tty->print(" offset=%d type=", _offset); |
376 if (_type != NULL) _type->print_name(); | 379 if (_type != NULL) |
377 else tty->print("(reference)"); | 380 _type->print_name(); |
381 else | |
382 tty->print("(reference)"); | |
383 tty->print(" flags=%04x", flags().as_int()); | |
378 tty->print(" is_constant=%s", bool_to_str(_is_constant)); | 384 tty->print(" is_constant=%s", bool_to_str(_is_constant)); |
379 if (_is_constant && is_static()) { | 385 if (_is_constant && is_static()) { |
380 tty->print(" constant_value="); | 386 tty->print(" constant_value="); |
381 _constant_value.print(); | 387 _constant_value.print(); |
382 } | 388 } |