comparison src/share/vm/oops/constantPoolOop.cpp @ 1660:083fde3b838e

6964498: JSR 292 invokedynamic sites need local bootstrap methods Summary: Add JVM_CONSTANT_InvokeDynamic records to constant pool to determine per-instruction BSMs. Reviewed-by: twisti
author jrose
date Thu, 15 Jul 2010 18:40:45 -0700
parents 136b78722a08
children d257356e35f0
comparison
equal deleted inserted replaced
1649:a528509c992b 1660:083fde3b838e
262 262
263 263
264 int constantPoolOopDesc::impl_name_and_type_ref_index_at(int which, bool uncached) { 264 int constantPoolOopDesc::impl_name_and_type_ref_index_at(int which, bool uncached) {
265 int i = which; 265 int i = which;
266 if (!uncached && cache() != NULL) { 266 if (!uncached && cache() != NULL) {
267 if (constantPoolCacheOopDesc::is_secondary_index(which)) 267 if (constantPoolCacheOopDesc::is_secondary_index(which)) {
268 // Invokedynamic indexes are always processed in native order 268 // Invokedynamic indexes are always processed in native order
269 // so there is no question of reading a native u2 in Java order here. 269 // so there is no question of reading a native u2 in Java order here.
270 return cache()->main_entry_at(which)->constant_pool_index(); 270 int pool_index = cache()->main_entry_at(which)->constant_pool_index();
271 if (tag_at(pool_index).is_invoke_dynamic())
272 pool_index = invoke_dynamic_name_and_type_ref_index_at(pool_index);
273 assert(tag_at(pool_index).is_name_and_type(), "");
274 return pool_index;
275 }
271 // change byte-ordering and go via cache 276 // change byte-ordering and go via cache
272 i = remap_instruction_operand_from_cache(which); 277 i = remap_instruction_operand_from_cache(which);
273 } else { 278 } else {
274 if (tag_at(which).is_name_and_type()) 279 if (tag_at(which).is_name_and_type())
275 // invokedynamic index is a simple name-and-type 280 // invokedynamic index is a simple name-and-type
828 return true; 833 return true;
829 } 834 }
830 } 835 }
831 } break; 836 } break;
832 837
838 case JVM_CONSTANT_InvokeDynamic:
839 {
840 int k1 = invoke_dynamic_bootstrap_method_ref_index_at(index1);
841 int k2 = cp2->invoke_dynamic_bootstrap_method_ref_index_at(index2);
842 if (k1 == k2) {
843 int i1 = invoke_dynamic_name_and_type_ref_index_at(index1);
844 int i2 = cp2->invoke_dynamic_name_and_type_ref_index_at(index2);
845 if (i1 == i2) {
846 return true;
847 }
848 }
849 } break;
850
833 case JVM_CONSTANT_UnresolvedString: 851 case JVM_CONSTANT_UnresolvedString:
834 { 852 {
835 symbolOop s1 = unresolved_string_at(index1); 853 symbolOop s1 = unresolved_string_at(index1);
836 symbolOop s2 = cp2->unresolved_string_at(index2); 854 symbolOop s2 = cp2->unresolved_string_at(index2);
837 if (s1 == s2) { 855 if (s1 == s2) {
1012 case JVM_CONSTANT_MethodHandle: 1030 case JVM_CONSTANT_MethodHandle:
1013 { 1031 {
1014 int k1 = method_handle_ref_kind_at(from_i); 1032 int k1 = method_handle_ref_kind_at(from_i);
1015 int k2 = method_handle_index_at(from_i); 1033 int k2 = method_handle_index_at(from_i);
1016 to_cp->method_handle_index_at_put(to_i, k1, k2); 1034 to_cp->method_handle_index_at_put(to_i, k1, k2);
1035 } break;
1036
1037 case JVM_CONSTANT_InvokeDynamic:
1038 {
1039 int k1 = invoke_dynamic_bootstrap_method_ref_index_at(from_i);
1040 int k2 = invoke_dynamic_name_and_type_ref_index_at(from_i);
1041 to_cp->invoke_dynamic_at_put(to_i, k1, k2);
1017 } break; 1042 } break;
1018 1043
1019 // Invalid is used as the tag for the second constant pool entry 1044 // Invalid is used as the tag for the second constant pool entry
1020 // occupied by JVM_CONSTANT_Double or JVM_CONSTANT_Long. It should 1045 // occupied by JVM_CONSTANT_Double or JVM_CONSTANT_Long. It should
1021 // not be seen by itself. 1046 // not be seen by itself.
1229 case JVM_CONSTANT_Float: 1254 case JVM_CONSTANT_Float:
1230 case JVM_CONSTANT_Fieldref: 1255 case JVM_CONSTANT_Fieldref:
1231 case JVM_CONSTANT_Methodref: 1256 case JVM_CONSTANT_Methodref:
1232 case JVM_CONSTANT_InterfaceMethodref: 1257 case JVM_CONSTANT_InterfaceMethodref:
1233 case JVM_CONSTANT_NameAndType: 1258 case JVM_CONSTANT_NameAndType:
1259 case JVM_CONSTANT_InvokeDynamic:
1234 return 5; 1260 return 5;
1235 1261
1236 case JVM_CONSTANT_Long: 1262 case JVM_CONSTANT_Long:
1237 case JVM_CONSTANT_Double: 1263 case JVM_CONSTANT_Double:
1238 return 9; 1264 return 9;
1442 idx1 = method_type_index_at(idx); 1468 idx1 = method_type_index_at(idx);
1443 Bytes::put_Java_u2((address) (bytes+1), idx1); 1469 Bytes::put_Java_u2((address) (bytes+1), idx1);
1444 DBG(printf("JVM_CONSTANT_MethodType: %hd", idx1)); 1470 DBG(printf("JVM_CONSTANT_MethodType: %hd", idx1));
1445 break; 1471 break;
1446 } 1472 }
1473 case JVM_CONSTANT_InvokeDynamic: {
1474 *bytes = JVM_CONSTANT_InvokeDynamic;
1475 idx1 = invoke_dynamic_bootstrap_method_ref_index_at(idx);
1476 idx2 = invoke_dynamic_name_and_type_ref_index_at(idx);
1477 Bytes::put_Java_u2((address) (bytes+1), idx1);
1478 Bytes::put_Java_u2((address) (bytes+3), idx2);
1479 DBG(printf("JVM_CONSTANT_InvokeDynamic: %hd %hd", idx1, idx2));
1480 break;
1481 }
1447 } 1482 }
1448 DBG(printf("\n")); 1483 DBG(printf("\n"));
1449 bytes += ent_size; 1484 bytes += ent_size;
1450 size += ent_size; 1485 size += ent_size;
1451 } 1486 }