Mercurial > hg > truffle
comparison src/share/vm/ci/ciField.cpp @ 1339:09ac706c2623
Merge
author | asaha |
---|---|
date | Wed, 24 Mar 2010 17:16:33 -0700 |
parents | 73b22f919c34 |
children | a8f9f091c219 c18cbe5936b8 |
comparison
equal
deleted
inserted
replaced
1338:f5dd08ad65df | 1339:09ac706c2623 |
---|---|
1 /* | 1 /* |
2 * Copyright 1999-2007 Sun Microsystems, Inc. All Rights Reserved. | 2 * Copyright 1999-2009 Sun Microsystems, Inc. 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. |
84 // field. | 84 // field. |
85 if (field_type == T_OBJECT || field_type == T_ARRAY) { | 85 if (field_type == T_OBJECT || field_type == T_ARRAY) { |
86 bool ignore; | 86 bool ignore; |
87 // This is not really a class reference; the index always refers to the | 87 // This is not really a class reference; the index always refers to the |
88 // field's type signature, as a symbol. Linkage checks do not apply. | 88 // field's type signature, as a symbol. Linkage checks do not apply. |
89 _type = ciEnv::current(thread)->get_klass_by_index(klass, sig_index, ignore); | 89 _type = ciEnv::current(thread)->get_klass_by_index(cpool, sig_index, ignore, klass); |
90 } else { | 90 } else { |
91 _type = ciType::make(field_type); | 91 _type = ciType::make(field_type); |
92 } | 92 } |
93 | 93 |
94 _name = (ciSymbol*)ciEnv::current(thread)->get_object(name()); | 94 _name = (ciSymbol*)ciEnv::current(thread)->get_object(name()); |
98 // Note: we actually create a ciInstanceKlass for this klass, | 98 // Note: we actually create a ciInstanceKlass for this klass, |
99 // even though we may not need to. | 99 // even though we may not need to. |
100 int holder_index = cpool->klass_ref_index_at(index); | 100 int holder_index = cpool->klass_ref_index_at(index); |
101 bool holder_is_accessible; | 101 bool holder_is_accessible; |
102 ciInstanceKlass* declared_holder = | 102 ciInstanceKlass* declared_holder = |
103 ciEnv::current(thread)->get_klass_by_index(klass, holder_index, | 103 ciEnv::current(thread)->get_klass_by_index(cpool, holder_index, |
104 holder_is_accessible) | 104 holder_is_accessible, |
105 ->as_instance_klass(); | 105 klass)->as_instance_klass(); |
106 | 106 |
107 // The declared holder of this field may not have been loaded. | 107 // The declared holder of this field may not have been loaded. |
108 // Bail out with partial field information. | 108 // Bail out with partial field information. |
109 if (!holder_is_accessible) { | 109 if (!holder_is_accessible) { |
110 // _cp_index and _type have already been set. | 110 // _cp_index and _type have already been set. |
159 // Either (a) it is marked shared, or else (b) we are done bootstrapping. | 159 // Either (a) it is marked shared, or else (b) we are done bootstrapping. |
160 assert(is_shared() || ciObjectFactory::is_initialized(), | 160 assert(is_shared() || ciObjectFactory::is_initialized(), |
161 "bootstrap classes must not create & cache unshared fields"); | 161 "bootstrap classes must not create & cache unshared fields"); |
162 } | 162 } |
163 | 163 |
164 static bool trust_final_non_static_fields(ciInstanceKlass* holder) { | |
165 if (holder == NULL) | |
166 return false; | |
167 if (holder->name() == ciSymbol::java_lang_System()) | |
168 // Never trust strangely unstable finals: System.out, etc. | |
169 return false; | |
170 // Even if general trusting is disabled, trust system-built closures in these packages. | |
171 if (holder->is_in_package("java/dyn") || holder->is_in_package("sun/dyn")) | |
172 return true; | |
173 return TrustFinalNonStaticFields; | |
174 } | |
175 | |
164 void ciField::initialize_from(fieldDescriptor* fd) { | 176 void ciField::initialize_from(fieldDescriptor* fd) { |
165 // Get the flags, offset, and canonical holder of the field. | 177 // Get the flags, offset, and canonical holder of the field. |
166 _flags = ciFlags(fd->access_flags()); | 178 _flags = ciFlags(fd->access_flags()); |
167 _offset = fd->offset(); | 179 _offset = fd->offset(); |
168 _holder = CURRENT_ENV->get_object(fd->field_holder())->as_instance_klass(); | 180 _holder = CURRENT_ENV->get_object(fd->field_holder())->as_instance_klass(); |
169 | 181 |
170 // Check to see if the field is constant. | 182 // Check to see if the field is constant. |
171 if (_holder->is_initialized() && | 183 if (_holder->is_initialized() && this->is_final()) { |
172 this->is_final() && this->is_static()) { | 184 if (!this->is_static()) { |
185 // A field can be constant if it's a final static field or if it's | |
186 // a final non-static field of a trusted class ({java,sun}.dyn). | |
187 if (trust_final_non_static_fields(_holder)) { | |
188 _is_constant = true; | |
189 return; | |
190 } | |
191 _is_constant = false; | |
192 return; | |
193 } | |
194 | |
173 // This field just may be constant. The only cases where it will | 195 // This field just may be constant. The only cases where it will |
174 // not be constant are: | 196 // not be constant are: |
175 // | 197 // |
176 // 1. The field holds a non-perm-space oop. The field is, strictly | 198 // 1. The field holds a non-perm-space oop. The field is, strictly |
177 // speaking, constant but we cannot embed non-perm-space oops into | 199 // speaking, constant but we cannot embed non-perm-space oops into |
180 // 2. The field is a *special* static&final field whose value | 202 // 2. The field is a *special* static&final field whose value |
181 // may change. The three examples are java.lang.System.in, | 203 // may change. The three examples are java.lang.System.in, |
182 // java.lang.System.out, and java.lang.System.err. | 204 // java.lang.System.out, and java.lang.System.err. |
183 | 205 |
184 klassOop k = _holder->get_klassOop(); | 206 klassOop k = _holder->get_klassOop(); |
185 assert( SystemDictionary::system_klass() != NULL, "Check once per vm"); | 207 assert( SystemDictionary::System_klass() != NULL, "Check once per vm"); |
186 if( k == SystemDictionary::system_klass() ) { | 208 if( k == SystemDictionary::System_klass() ) { |
187 // Check offsets for case 2: System.in, System.out, or System.err | 209 // Check offsets for case 2: System.in, System.out, or System.err |
188 if( _offset == java_lang_System::in_offset_in_bytes() || | 210 if( _offset == java_lang_System::in_offset_in_bytes() || |
189 _offset == java_lang_System::out_offset_in_bytes() || | 211 _offset == java_lang_System::out_offset_in_bytes() || |
190 _offset == java_lang_System::err_offset_in_bytes() ) { | 212 _offset == java_lang_System::err_offset_in_bytes() ) { |
191 _is_constant = false; | 213 _is_constant = false; |