Mercurial > hg > truffle
comparison src/share/vm/ci/ciField.cpp @ 1173:73b22f919c34
6912065: final fields in objects need to support inlining optimizations for JSR 292
Reviewed-by: twisti, kvn
author | jrose |
---|---|
date | Wed, 13 Jan 2010 23:05:52 -0800 |
parents | 4ce7240d622c |
children | a8f9f091c219 c18cbe5936b8 |
comparison
equal
deleted
inserted
replaced
1172:b2b6a9bf6238 | 1173:73b22f919c34 |
---|---|
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(); |
170 // Check to see if the field is constant. | 182 // Check to see if the field is constant. |
171 if (_holder->is_initialized() && this->is_final()) { | 183 if (_holder->is_initialized() && this->is_final()) { |
172 if (!this->is_static()) { | 184 if (!this->is_static()) { |
173 // A field can be constant if it's a final static field or if it's | 185 // A field can be constant if it's a final static field or if it's |
174 // a final non-static field of a trusted class ({java,sun}.dyn). | 186 // a final non-static field of a trusted class ({java,sun}.dyn). |
175 if (_holder->is_in_package("java/dyn") || _holder->is_in_package("sun/dyn")) { | 187 if (trust_final_non_static_fields(_holder)) { |
176 _is_constant = true; | 188 _is_constant = true; |
177 return; | 189 return; |
178 } | 190 } |
179 _is_constant = false; | 191 _is_constant = false; |
180 return; | 192 return; |