comparison src/share/vm/prims/jvmtiClassFileReconstituter.cpp @ 6725:da91efe96a93

6964458: Reimplement class meta-data storage to use native memory Summary: Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland Contributed-by: jmasa <jon.masamitsu@oracle.com>, stefank <stefan.karlsson@oracle.com>, mgerdin <mikael.gerdin@oracle.com>, never <tom.rodriguez@oracle.com>
author coleenp
date Sat, 01 Sep 2012 13:25:18 -0400
parents e74da3c2b827
children 1cb8583c3da8
comparison
equal deleted inserted replaced
6724:36d1d483d5d6 6725:da91efe96a93
43 #ifdef TARGET_ARCH_ppc 43 #ifdef TARGET_ARCH_ppc
44 # include "bytes_ppc.hpp" 44 # include "bytes_ppc.hpp"
45 #endif 45 #endif
46 // FIXME: add Deprecated, LVTT attributes 46 // FIXME: add Deprecated, LVTT attributes
47 // FIXME: fix Synthetic attribute 47 // FIXME: fix Synthetic attribute
48 // FIXME: per Serguei, add error return handling for constantPoolOopDesc::copy_cpool_bytes() 48 // FIXME: per Serguei, add error return handling for ConstantPool::copy_cpool_bytes()
49 49
50 50
51 // Write the field information portion of ClassFile structure 51 // Write the field information portion of ClassFile structure
52 // JVMSpec| u2 fields_count; 52 // JVMSpec| u2 fields_count;
53 // JVMSpec| field_info fields[fields_count]; 53 // JVMSpec| field_info fields[fields_count];
54 void JvmtiClassFileReconstituter::write_field_infos() { 54 void JvmtiClassFileReconstituter::write_field_infos() {
55 HandleMark hm(thread()); 55 HandleMark hm(thread());
56 objArrayHandle fields_anno(thread(), ikh()->fields_annotations()); 56 Array<AnnotationArray*>* fields_anno = ikh()->fields_annotations();
57 57
58 // Compute the real number of Java fields 58 // Compute the real number of Java fields
59 int java_fields = ikh()->java_fields_count(); 59 int java_fields = ikh()->java_fields_count();
60 60
61 write_u2(java_fields); 61 write_u2(java_fields);
65 int signature_index = fs.signature_index(); 65 int signature_index = fs.signature_index();
66 int initial_value_index = fs.initval_index(); 66 int initial_value_index = fs.initval_index();
67 guarantee(name_index != 0 && signature_index != 0, "bad constant pool index for field"); 67 guarantee(name_index != 0 && signature_index != 0, "bad constant pool index for field");
68 // int offset = ikh()->field_offset( index ); 68 // int offset = ikh()->field_offset( index );
69 int generic_signature_index = fs.generic_signature_index(); 69 int generic_signature_index = fs.generic_signature_index();
70 typeArrayHandle anno(thread(), fields_anno.not_null() ? 70 AnnotationArray* anno = fields_anno == NULL ? NULL : fields_anno->at(fs.index());
71 (typeArrayOop)(fields_anno->obj_at(fs.index())) :
72 (typeArrayOop)NULL);
73 71
74 // JVMSpec| field_info { 72 // JVMSpec| field_info {
75 // JVMSpec| u2 access_flags; 73 // JVMSpec| u2 access_flags;
76 // JVMSpec| u2 name_index; 74 // JVMSpec| u2 name_index;
77 // JVMSpec| u2 descriptor_index; 75 // JVMSpec| u2 descriptor_index;
90 // ++attr_count; 88 // ++attr_count;
91 } 89 }
92 if (generic_signature_index != 0) { 90 if (generic_signature_index != 0) {
93 ++attr_count; 91 ++attr_count;
94 } 92 }
95 if (anno.not_null()) { 93 if (anno != NULL) {
96 ++attr_count; // has RuntimeVisibleAnnotations attribute 94 ++attr_count; // has RuntimeVisibleAnnotations attribute
97 } 95 }
98 96
99 write_u2(attr_count); 97 write_u2(attr_count);
100 98
107 // write_synthetic_attribute(); 105 // write_synthetic_attribute();
108 } 106 }
109 if (generic_signature_index != 0) { 107 if (generic_signature_index != 0) {
110 write_signature_attribute(generic_signature_index); 108 write_signature_attribute(generic_signature_index);
111 } 109 }
112 if (anno.not_null()) { 110 if (anno != NULL) {
113 write_annotations_attribute("RuntimeVisibleAnnotations", anno); 111 write_annotations_attribute("RuntimeVisibleAnnotations", anno);
114 } 112 }
115 } 113 }
116 } 114 }
117 115
131 // JVMSpec| } exception_table[exception_table_length]; 129 // JVMSpec| } exception_table[exception_table_length];
132 // JVMSpec| u2 attributes_count; 130 // JVMSpec| u2 attributes_count;
133 // JVMSpec| attribute_info attributes[attributes_count]; 131 // JVMSpec| attribute_info attributes[attributes_count];
134 // JVMSpec| } 132 // JVMSpec| }
135 void JvmtiClassFileReconstituter::write_code_attribute(methodHandle method) { 133 void JvmtiClassFileReconstituter::write_code_attribute(methodHandle method) {
136 constMethodHandle const_method(thread(), method->constMethod()); 134 ConstMethod* const_method = method->constMethod();
137 u2 line_num_cnt = 0; 135 u2 line_num_cnt = 0;
138 int stackmap_len = 0; 136 int stackmap_len = 0;
139 int local_variable_table_length = 0; 137 int local_variable_table_length = 0;
140 138
141 // compute number and length of attributes 139 // compute number and length of attributes
232 // JVMSpec| u2 attribute_name_index; 230 // JVMSpec| u2 attribute_name_index;
233 // JVMSpec| u4 attribute_length; 231 // JVMSpec| u4 attribute_length;
234 // JVMSpec| u2 number_of_exceptions; 232 // JVMSpec| u2 number_of_exceptions;
235 // JVMSpec| u2 exception_index_table[number_of_exceptions]; 233 // JVMSpec| u2 exception_index_table[number_of_exceptions];
236 // JVMSpec| } 234 // JVMSpec| }
237 void JvmtiClassFileReconstituter::write_exceptions_attribute(constMethodHandle const_method) { 235 void JvmtiClassFileReconstituter::write_exceptions_attribute(ConstMethod* const_method) {
238 CheckedExceptionElement* checked_exceptions = const_method->checked_exceptions_start(); 236 CheckedExceptionElement* checked_exceptions = const_method->checked_exceptions_start();
239 int checked_exceptions_length = const_method->checked_exceptions_length(); 237 int checked_exceptions_length = const_method->checked_exceptions_length();
240 int size = 238 int size =
241 2 + // number_of_exceptions 239 2 + // number_of_exceptions
242 2 * checked_exceptions_length; // exception_index_table 240 2 * checked_exceptions_length; // exception_index_table
305 // JSR202| u2 attribute_name_index; 303 // JSR202| u2 attribute_name_index;
306 // JSR202| u4 attribute_length; 304 // JSR202| u4 attribute_length;
307 // JSR202| ... 305 // JSR202| ...
308 // JSR202| } 306 // JSR202| }
309 void JvmtiClassFileReconstituter::write_annotations_attribute(const char* attr_name, 307 void JvmtiClassFileReconstituter::write_annotations_attribute(const char* attr_name,
310 typeArrayHandle annos) { 308 AnnotationArray* annos) {
311 u4 length = annos->length(); 309 u4 length = annos->length();
312 write_attribute_name_index(attr_name); 310 write_attribute_name_index(attr_name);
313 write_u4(length); 311 write_u4(length);
314 memcpy(writeable_address(length), annos->byte_at_addr(0), length); 312 memcpy(writeable_address(length), annos->adr_at(0), length);
315 } 313 }
316 314
317 315
318 // Write InnerClasses attribute 316 // Write InnerClasses attribute
319 // JVMSpec| InnerClasses_attribute { 317 // JVMSpec| InnerClasses_attribute {
328 // JVMSpec| } 326 // JVMSpec| }
329 void JvmtiClassFileReconstituter::write_inner_classes_attribute(int length) { 327 void JvmtiClassFileReconstituter::write_inner_classes_attribute(int length) {
330 InnerClassesIterator iter(ikh()); 328 InnerClassesIterator iter(ikh());
331 guarantee(iter.length() != 0 && iter.length() == length, 329 guarantee(iter.length() != 0 && iter.length() == length,
332 "caller must check"); 330 "caller must check");
333 u2 entry_count = length / instanceKlass::inner_class_next_offset; 331 u2 entry_count = length / InstanceKlass::inner_class_next_offset;
334 u4 size = 2 + entry_count * (2+2+2+2); 332 u4 size = 2 + entry_count * (2+2+2+2);
335 333
336 write_attribute_name_index("InnerClasses"); 334 write_attribute_name_index("InnerClasses");
337 write_u4(size); 335 write_u4(size);
338 write_u2(entry_count); 336 write_u2(entry_count);
431 429
432 write_attribute_name_index("StackMapTable"); 430 write_attribute_name_index("StackMapTable");
433 write_u4(stackmap_len); 431 write_u4(stackmap_len);
434 memcpy( 432 memcpy(
435 writeable_address(stackmap_len), 433 writeable_address(stackmap_len),
436 (void*)(method->stackmap_data()->byte_at_addr(0)), 434 (void*)(method->stackmap_data()->adr_at(0)),
437 stackmap_len); 435 stackmap_len);
438 } 436 }
439 437
440 // Write one method_info structure 438 // Write one method_info structure
441 // JVMSpec| method_info { 439 // JVMSpec| method_info {
445 // JVMSpec| u2 attributes_count; 443 // JVMSpec| u2 attributes_count;
446 // JVMSpec| attribute_info attributes[attributes_count]; 444 // JVMSpec| attribute_info attributes[attributes_count];
447 // JVMSpec| } 445 // JVMSpec| }
448 void JvmtiClassFileReconstituter::write_method_info(methodHandle method) { 446 void JvmtiClassFileReconstituter::write_method_info(methodHandle method) {
449 AccessFlags access_flags = method->access_flags(); 447 AccessFlags access_flags = method->access_flags();
450 constMethodHandle const_method(thread(), method->constMethod()); 448 ConstMethod* const_method = method->constMethod();
451 u2 generic_signature_index = const_method->generic_signature_index(); 449 u2 generic_signature_index = const_method->generic_signature_index();
452 typeArrayHandle anno(thread(), method->annotations()); 450 AnnotationArray* anno = method->annotations();
453 typeArrayHandle param_anno(thread(), method->parameter_annotations()); 451 AnnotationArray* param_anno = method->parameter_annotations();
454 typeArrayHandle default_anno(thread(), method->annotation_default()); 452 AnnotationArray* default_anno = method->annotation_default();
455 453
456 write_u2(access_flags.get_flags() & JVM_RECOGNIZED_METHOD_MODIFIERS); 454 write_u2(access_flags.get_flags() & JVM_RECOGNIZED_METHOD_MODIFIERS);
457 write_u2(const_method->name_index()); 455 write_u2(const_method->name_index());
458 write_u2(const_method->signature_index()); 456 write_u2(const_method->signature_index());
459 457
464 ++attr_count; // has Code attribute 462 ++attr_count; // has Code attribute
465 } 463 }
466 if (const_method->has_checked_exceptions()) { 464 if (const_method->has_checked_exceptions()) {
467 ++attr_count; // has Exceptions attribute 465 ++attr_count; // has Exceptions attribute
468 } 466 }
469 if (default_anno.not_null()) { 467 if (default_anno != NULL) {
470 ++attr_count; // has AnnotationDefault attribute 468 ++attr_count; // has AnnotationDefault attribute
471 } 469 }
472 // Deprecated attribute would go here 470 // Deprecated attribute would go here
473 if (access_flags.is_synthetic()) { // FIXME 471 if (access_flags.is_synthetic()) { // FIXME
474 // ++attr_count; 472 // ++attr_count;
475 } 473 }
476 if (generic_signature_index != 0) { 474 if (generic_signature_index != 0) {
477 ++attr_count; 475 ++attr_count;
478 } 476 }
479 if (anno.not_null()) { 477 if (anno != NULL) {
480 ++attr_count; // has RuntimeVisibleAnnotations attribute 478 ++attr_count; // has RuntimeVisibleAnnotations attribute
481 } 479 }
482 if (param_anno.not_null()) { 480 if (param_anno != NULL) {
483 ++attr_count; // has RuntimeVisibleParameterAnnotations attribute 481 ++attr_count; // has RuntimeVisibleParameterAnnotations attribute
484 } 482 }
485 483
486 write_u2(attr_count); 484 write_u2(attr_count);
487 if (const_method->code_size() > 0) { 485 if (const_method->code_size() > 0) {
488 write_code_attribute(method); 486 write_code_attribute(method);
489 } 487 }
490 if (const_method->has_checked_exceptions()) { 488 if (const_method->has_checked_exceptions()) {
491 write_exceptions_attribute(const_method); 489 write_exceptions_attribute(const_method);
492 } 490 }
493 if (default_anno.not_null()) { 491 if (default_anno != NULL) {
494 write_annotations_attribute("AnnotationDefault", default_anno); 492 write_annotations_attribute("AnnotationDefault", default_anno);
495 } 493 }
496 // Deprecated attribute would go here 494 // Deprecated attribute would go here
497 if (access_flags.is_synthetic()) { 495 if (access_flags.is_synthetic()) {
498 // write_synthetic_attribute(); 496 // write_synthetic_attribute();
499 } 497 }
500 if (generic_signature_index != 0) { 498 if (generic_signature_index != 0) {
501 write_signature_attribute(generic_signature_index); 499 write_signature_attribute(generic_signature_index);
502 } 500 }
503 if (anno.not_null()) { 501 if (anno != NULL) {
504 write_annotations_attribute("RuntimeVisibleAnnotations", anno); 502 write_annotations_attribute("RuntimeVisibleAnnotations", anno);
505 } 503 }
506 if (param_anno.not_null()) { 504 if (param_anno != NULL) {
507 write_annotations_attribute("RuntimeVisibleParameterAnnotations", param_anno); 505 write_annotations_attribute("RuntimeVisibleParameterAnnotations", param_anno);
508 } 506 }
509 } 507 }
510 508
511 // Write the class attributes portion of ClassFile structure 509 // Write the class attributes portion of ClassFile structure
512 // JVMSpec| u2 attributes_count; 510 // JVMSpec| u2 attributes_count;
513 // JVMSpec| attribute_info attributes[attributes_count]; 511 // JVMSpec| attribute_info attributes[attributes_count];
514 void JvmtiClassFileReconstituter::write_class_attributes() { 512 void JvmtiClassFileReconstituter::write_class_attributes() {
515 u2 inner_classes_length = inner_classes_attribute_length(); 513 u2 inner_classes_length = inner_classes_attribute_length();
516 Symbol* generic_signature = ikh()->generic_signature(); 514 Symbol* generic_signature = ikh()->generic_signature();
517 typeArrayHandle anno(thread(), ikh()->class_annotations()); 515 AnnotationArray* anno = ikh()->class_annotations();
518 516
519 int attr_count = 0; 517 int attr_count = 0;
520 if (generic_signature != NULL) { 518 if (generic_signature != NULL) {
521 ++attr_count; 519 ++attr_count;
522 } 520 }
527 ++attr_count; 525 ++attr_count;
528 } 526 }
529 if (inner_classes_length > 0) { 527 if (inner_classes_length > 0) {
530 ++attr_count; 528 ++attr_count;
531 } 529 }
532 if (anno.not_null()) { 530 if (anno != NULL) {
533 ++attr_count; // has RuntimeVisibleAnnotations attribute 531 ++attr_count; // has RuntimeVisibleAnnotations attribute
534 } 532 }
535 533
536 write_u2(attr_count); 534 write_u2(attr_count);
537 535
545 write_source_debug_extension_attribute(); 543 write_source_debug_extension_attribute();
546 } 544 }
547 if (inner_classes_length > 0) { 545 if (inner_classes_length > 0) {
548 write_inner_classes_attribute(inner_classes_length); 546 write_inner_classes_attribute(inner_classes_length);
549 } 547 }
550 if (anno.not_null()) { 548 if (anno != NULL) {
551 write_annotations_attribute("RuntimeVisibleAnnotations", anno); 549 write_annotations_attribute("RuntimeVisibleAnnotations", anno);
552 } 550 }
553 } 551 }
554 552
555 // Write the method information portion of ClassFile structure 553 // Write the method information portion of ClassFile structure
556 // JVMSpec| u2 methods_count; 554 // JVMSpec| u2 methods_count;
557 // JVMSpec| method_info methods[methods_count]; 555 // JVMSpec| method_info methods[methods_count];
558 void JvmtiClassFileReconstituter::write_method_infos() { 556 void JvmtiClassFileReconstituter::write_method_infos() {
559 HandleMark hm(thread()); 557 HandleMark hm(thread());
560 objArrayHandle methods(thread(), ikh()->methods()); 558 Array<Method*>* methods = ikh()->methods();
561 int num_methods = methods->length(); 559 int num_methods = methods->length();
562 560
563 write_u2(num_methods); 561 write_u2(num_methods);
564 if (JvmtiExport::can_maintain_original_method_order()) { 562 if (JvmtiExport::can_maintain_original_method_order()) {
565 int index; 563 int index;
566 int original_index; 564 int original_index;
567 int* method_order = NEW_RESOURCE_ARRAY(int, num_methods); 565 intArray method_order(num_methods, 0);
568 566
569 // invert the method order mapping 567 // invert the method order mapping
570 for (index = 0; index < num_methods; index++) { 568 for (index = 0; index < num_methods; index++) {
571 original_index = ikh()->method_ordering()->int_at(index); 569 original_index = ikh()->method_ordering()->at(index);
572 assert(original_index >= 0 && original_index < num_methods, 570 assert(original_index >= 0 && original_index < num_methods,
573 "invalid original method index"); 571 "invalid original method index");
574 method_order[original_index] = index; 572 method_order.at_put(original_index, index);
575 } 573 }
576 574
577 // write in original order 575 // write in original order
578 for (original_index = 0; original_index < num_methods; original_index++) { 576 for (original_index = 0; original_index < num_methods; original_index++) {
579 index = method_order[original_index]; 577 index = method_order.at(original_index);
580 methodHandle method(thread(), (methodOop)(ikh()->methods()->obj_at(index))); 578 methodHandle method(thread(), methods->at(index));
581 write_method_info(method); 579 write_method_info(method);
582 } 580 }
583 } else { 581 } else {
584 // method order not preserved just dump the method infos 582 // method order not preserved just dump the method infos
585 for (int index = 0; index < num_methods; index++) { 583 for (int index = 0; index < num_methods; index++) {
586 methodHandle method(thread(), (methodOop)(ikh()->methods()->obj_at(index))); 584 methodHandle method(thread(), methods->at(index));
587 write_method_info(method); 585 write_method_info(method);
588 } 586 }
589 } 587 }
590 } 588 }
591 589
611 write_u2(ikh()->access_flags().get_flags() & JVM_RECOGNIZED_CLASS_MODIFIERS); 609 write_u2(ikh()->access_flags().get_flags() & JVM_RECOGNIZED_CLASS_MODIFIERS);
612 610
613 // JVMSpec| u2 this_class; 611 // JVMSpec| u2 this_class;
614 // JVMSpec| u2 super_class; 612 // JVMSpec| u2 super_class;
615 write_u2(class_symbol_to_cpool_index(ikh()->name())); 613 write_u2(class_symbol_to_cpool_index(ikh()->name()));
616 klassOop super_class = ikh()->super(); 614 Klass* super_class = ikh()->super();
617 write_u2(super_class == NULL? 0 : // zero for java.lang.Object 615 write_u2(super_class == NULL? 0 : // zero for java.lang.Object
618 class_symbol_to_cpool_index(super_class->klass_part()->name())); 616 class_symbol_to_cpool_index(super_class->name()));
619 617
620 // JVMSpec| u2 interfaces_count; 618 // JVMSpec| u2 interfaces_count;
621 // JVMSpec| u2 interfaces[interfaces_count]; 619 // JVMSpec| u2 interfaces[interfaces_count];
622 objArrayHandle interfaces(thread(), ikh()->local_interfaces()); 620 Array<Klass*>* interfaces = ikh()->local_interfaces();
623 int num_interfaces = interfaces->length(); 621 int num_interfaces = interfaces->length();
624 write_u2(num_interfaces); 622 write_u2(num_interfaces);
625 for (int index = 0; index < num_interfaces; index++) { 623 for (int index = 0; index < num_interfaces; index++) {
626 HandleMark hm(thread()); 624 HandleMark hm(thread());
627 instanceKlassHandle iikh(thread(), klassOop(interfaces->obj_at(index))); 625 instanceKlassHandle iikh(thread(), interfaces->at(index));
628 write_u2(class_symbol_to_cpool_index(iikh->name())); 626 write_u2(class_symbol_to_cpool_index(iikh->name()));
629 } 627 }
630 628
631 // JVMSpec| u2 fields_count; 629 // JVMSpec| u2 fields_count;
632 // JVMSpec| field_info fields[fields_count]; 630 // JVMSpec| field_info fields[fields_count];
691 689
692 BytecodeStream bs(mh); 690 BytecodeStream bs(mh);
693 691
694 unsigned char* p = bytecodes; 692 unsigned char* p = bytecodes;
695 Bytecodes::Code code; 693 Bytecodes::Code code;
696 bool is_rewritten = instanceKlass::cast(mh->method_holder())->is_rewritten(); 694 bool is_rewritten = InstanceKlass::cast(mh->method_holder())->is_rewritten();
697 695
698 while ((code = bs.next()) >= 0) { 696 while ((code = bs.next()) >= 0) {
699 assert(Bytecodes::is_java_code(code), "sanity check"); 697 assert(Bytecodes::is_java_code(code), "sanity check");
700 assert(code != Bytecodes::_breakpoint, "sanity check"); 698 assert(code != Bytecodes::_breakpoint, "sanity check");
701 699
711 } 709 }
712 710
713 // During linking the get/put and invoke instructions are rewritten 711 // During linking the get/put and invoke instructions are rewritten
714 // with an index into the constant pool cache. The original constant 712 // with an index into the constant pool cache. The original constant
715 // pool index must be returned to caller. Rewrite the index. 713 // pool index must be returned to caller. Rewrite the index.
716 if (is_rewritten && len >= 3) { 714 if (is_rewritten && len > 1) {
715 bool is_wide = false;
717 switch (code) { 716 switch (code) {
718 case Bytecodes::_getstatic : // fall through 717 case Bytecodes::_getstatic : // fall through
719 case Bytecodes::_putstatic : // fall through 718 case Bytecodes::_putstatic : // fall through
720 case Bytecodes::_getfield : // fall through 719 case Bytecodes::_getfield : // fall through
721 case Bytecodes::_putfield : // fall through 720 case Bytecodes::_putfield : // fall through
722 case Bytecodes::_invokevirtual : // fall through 721 case Bytecodes::_invokevirtual : // fall through
723 case Bytecodes::_invokespecial : // fall through 722 case Bytecodes::_invokespecial : // fall through
724 case Bytecodes::_invokestatic : // fall through 723 case Bytecodes::_invokestatic : // fall through
725 case Bytecodes::_invokedynamic : // fall through 724 case Bytecodes::_invokedynamic : // fall through
726 case Bytecodes::_invokeinterface : 725 case Bytecodes::_invokeinterface : {
727 assert(len == 3 || 726 assert(len == 3 ||
728 (code == Bytecodes::_invokeinterface && len == 5) || 727 (code == Bytecodes::_invokeinterface && len == 5) ||
729 (code == Bytecodes::_invokedynamic && len == 5), 728 (code == Bytecodes::_invokedynamic && len == 5),
730 "sanity check"); 729 "sanity check");
731 730
732 int cpci = Bytes::get_native_u2(bcp+1); 731 int cpci = Bytes::get_native_u2(bcp+1);
733 bool is_invokedynamic = (EnableInvokeDynamic && code == Bytecodes::_invokedynamic); 732 bool is_invokedynamic = (EnableInvokeDynamic && code == Bytecodes::_invokedynamic);
734 if (is_invokedynamic) 733 ConstantPoolCacheEntry* entry;
734 if (is_invokedynamic) {
735 cpci = Bytes::get_native_u4(bcp+1); 735 cpci = Bytes::get_native_u4(bcp+1);
736 entry = mh->constants()->invokedynamic_cp_cache_entry_at(cpci);
737 } else {
736 // cache cannot be pre-fetched since some classes won't have it yet 738 // cache cannot be pre-fetched since some classes won't have it yet
737 ConstantPoolCacheEntry* entry = 739 entry = mh->constants()->cache()->entry_at(cpci);
738 mh->constants()->cache()->main_entry_at(cpci); 740 }
739 int i = entry->constant_pool_index(); 741 int i = entry->constant_pool_index();
740 assert(i < mh->constants()->length(), "sanity check"); 742 assert(i < mh->constants()->length(), "sanity check");
741 Bytes::put_Java_u2((address)(p+1), (u2)i); // java byte ordering 743 Bytes::put_Java_u2((address)(p+1), (u2)i); // java byte ordering
742 if (is_invokedynamic) *(p+3) = *(p+4) = 0; 744 if (is_invokedynamic) *(p+3) = *(p+4) = 0;
743 break; 745 break;
744 } 746 }
747 case Bytecodes::_ldc_w:
748 is_wide = true; // fall through
749 case Bytecodes::_ldc: {
750 if (bs.raw_code() == Bytecodes::_fast_aldc || bs.raw_code() == Bytecodes::_fast_aldc_w) {
751 int cpci = is_wide ? Bytes::get_native_u2(bcp+1) : (u1)(*(bcp+1));
752 int i = mh->constants()->object_to_cp_index(cpci);
753 assert(i < mh->constants()->length(), "sanity check");
754 if (is_wide) {
755 Bytes::put_Java_u2((address)(p+1), (u2)i); // java byte ordering
756 } else {
757 *(p+1) = (u1)i;
758 }
759 }
760 break;
761 }
762 }
745 } 763 }
746 764
747 p += len; 765 p += len;
748 } 766 }
749 } 767 }