comparison src/share/vm/oops/cpCache.cpp @ 6942:64672b22ef05

8001658: No need to pass resolved_references as argument to ConstantPoolCacheEntry::set_method_handle_common Reviewed-by: twisti Contributed-by: Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
author twisti
date Fri, 02 Nov 2012 12:30:46 -0700
parents f6b0eb4e44cf
children a4e1bd941ded
comparison
equal deleted inserted replaced
6931:ca8168203393 6942:64672b22ef05
241 method()->size_of_parameters()); 241 method()->size_of_parameters());
242 set_bytecode_1(Bytecodes::_invokeinterface); 242 set_bytecode_1(Bytecodes::_invokeinterface);
243 } 243 }
244 244
245 245
246 void ConstantPoolCacheEntry::set_method_handle(constantPoolHandle cpool, 246 void ConstantPoolCacheEntry::set_method_handle(constantPoolHandle cpool, const CallInfo &call_info) {
247 methodHandle adapter, 247 set_method_handle_common(cpool, Bytecodes::_invokehandle, call_info);
248 Handle appendix, Handle method_type, 248 }
249 objArrayHandle resolved_references) { 249
250 set_method_handle_common(cpool, Bytecodes::_invokehandle, adapter, appendix, method_type, resolved_references); 250 void ConstantPoolCacheEntry::set_dynamic_call(constantPoolHandle cpool, const CallInfo &call_info) {
251 } 251 set_method_handle_common(cpool, Bytecodes::_invokedynamic, call_info);
252
253 void ConstantPoolCacheEntry::set_dynamic_call(constantPoolHandle cpool,
254 methodHandle adapter,
255 Handle appendix, Handle method_type,
256 objArrayHandle resolved_references) {
257 set_method_handle_common(cpool, Bytecodes::_invokedynamic, adapter, appendix, method_type, resolved_references);
258 } 252 }
259 253
260 void ConstantPoolCacheEntry::set_method_handle_common(constantPoolHandle cpool, 254 void ConstantPoolCacheEntry::set_method_handle_common(constantPoolHandle cpool,
261 Bytecodes::Code invoke_code, 255 Bytecodes::Code invoke_code,
262 methodHandle adapter, 256 const CallInfo &call_info) {
263 Handle appendix, Handle method_type,
264 objArrayHandle resolved_references) {
265 // NOTE: This CPCE can be the subject of data races. 257 // NOTE: This CPCE can be the subject of data races.
266 // There are three words to update: flags, refs[f2], f1 (in that order). 258 // There are three words to update: flags, refs[f2], f1 (in that order).
267 // Writers must store all other values before f1. 259 // Writers must store all other values before f1.
268 // Readers must test f1 first for non-null before reading other fields. 260 // Readers must test f1 first for non-null before reading other fields.
269 // Competing writers must acquire exclusive access via a lock. 261 // Competing writers must acquire exclusive access via a lock.
274 MonitorLockerEx ml(cpool->lock()); 266 MonitorLockerEx ml(cpool->lock());
275 if (!is_f1_null()) { 267 if (!is_f1_null()) {
276 return; 268 return;
277 } 269 }
278 270
271 const methodHandle adapter = call_info.resolved_method();
272 const Handle appendix = call_info.resolved_appendix();
273 const Handle method_type = call_info.resolved_method_type();
279 const bool has_appendix = appendix.not_null(); 274 const bool has_appendix = appendix.not_null();
280 const bool has_method_type = method_type.not_null(); 275 const bool has_method_type = method_type.not_null();
281 276
282 // Write the flags. 277 // Write the flags.
283 set_method_flags(as_TosState(adapter->result_type()), 278 set_method_flags(as_TosState(adapter->result_type()),
313 // not '(Ljava/lang/String;)Ljava/util/List;'. 308 // not '(Ljava/lang/String;)Ljava/util/List;'.
314 // The fact that String and List are involved is encoded in the MethodType in refs[f2]. 309 // The fact that String and List are involved is encoded in the MethodType in refs[f2].
315 // This allows us to create fewer method oops, while keeping type safety. 310 // This allows us to create fewer method oops, while keeping type safety.
316 // 311 //
317 312
313 objArrayHandle resolved_references = cpool->resolved_references();
318 // Store appendix, if any. 314 // Store appendix, if any.
319 if (has_appendix) { 315 if (has_appendix) {
320 const int appendix_index = f2_as_index() + _indy_resolved_references_appendix_offset; 316 const int appendix_index = f2_as_index() + _indy_resolved_references_appendix_offset;
321 assert(appendix_index >= 0 && appendix_index < resolved_references->length(), "oob"); 317 assert(appendix_index >= 0 && appendix_index < resolved_references->length(), "oob");
322 assert(resolved_references->obj_at(appendix_index) == NULL, "init just once"); 318 assert(resolved_references->obj_at(appendix_index) == NULL, "init just once");