src/share/vm/ci/ciEnv.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hotspot Sdiff src/share/vm/ci

src/share/vm/ci/ciEnv.cpp

Print this page
rev 7046 : 8058828: Wrong ciConstant type for arrays from ConstantPool::_resolved_reference
Reviewed-by: ?


 562                                    bool& is_accessible,
 563                                    ciInstanceKlass* accessor) {
 564   GUARDED_VM_ENTRY(return get_klass_by_index_impl(cpool, index, is_accessible, accessor);)
 565 }
 566 
 567 // ------------------------------------------------------------------
 568 // ciEnv::get_constant_by_index_impl
 569 //
 570 // Implementation of get_constant_by_index().
 571 ciConstant ciEnv::get_constant_by_index_impl(constantPoolHandle cpool,
 572                                              int pool_index, int cache_index,
 573                                              ciInstanceKlass* accessor) {
 574   bool ignore_will_link;
 575   EXCEPTION_CONTEXT;
 576   int index = pool_index;
 577   if (cache_index >= 0) {
 578     assert(index < 0, "only one kind of index at a time");
 579     oop obj = cpool->resolved_references()->obj_at(cache_index);
 580     if (obj != NULL) {
 581       ciObject* ciobj = get_object(obj);




 582       return ciConstant(T_OBJECT, ciobj);
 583     }

 584     index = cpool->object_to_cp_index(cache_index);
 585   }
 586   constantTag tag = cpool->tag_at(index);
 587   if (tag.is_int()) {
 588     return ciConstant(T_INT, (jint)cpool->int_at(index));
 589   } else if (tag.is_long()) {
 590     return ciConstant((jlong)cpool->long_at(index));
 591   } else if (tag.is_float()) {
 592     return ciConstant((jfloat)cpool->float_at(index));
 593   } else if (tag.is_double()) {
 594     return ciConstant((jdouble)cpool->double_at(index));
 595   } else if (tag.is_string()) {
 596     oop string = NULL;
 597     assert(cache_index >= 0, "should have a cache index");
 598     if (cpool->is_pseudo_string_at(index)) {
 599       string = cpool->pseudo_string_at(index, cache_index);
 600     } else {
 601       string = cpool->string_at(index, cache_index, THREAD);
 602       if (HAS_PENDING_EXCEPTION) {
 603         CLEAR_PENDING_EXCEPTION;
 604         record_out_of_memory_failure();
 605         return ciConstant();
 606       }
 607     }
 608     ciObject* constant = get_object(string);



 609     assert (constant->is_instance(), "must be an instance, or not? ");
 610     return ciConstant(T_OBJECT, constant);

 611   } else if (tag.is_klass() || tag.is_unresolved_klass()) {
 612     // 4881222: allow ldc to take a class type
 613     ciKlass* klass = get_klass_by_index_impl(cpool, index, ignore_will_link, accessor);
 614     if (HAS_PENDING_EXCEPTION) {
 615       CLEAR_PENDING_EXCEPTION;
 616       record_out_of_memory_failure();
 617       return ciConstant();
 618     }
 619     assert (klass->is_instance_klass() || klass->is_array_klass(),
 620             "must be an instance or array klass ");
 621     return ciConstant(T_OBJECT, klass->java_mirror());
 622   } else if (tag.is_method_type()) {
 623     // must execute Java code to link this CP entry into cache[i].f1
 624     ciSymbol* signature = get_symbol(cpool->method_type_signature_at(index));
 625     ciObject* ciobj = get_unloaded_method_type_constant(signature);
 626     return ciConstant(T_OBJECT, ciobj);
 627   } else if (tag.is_method_handle()) {
 628     // must execute Java code to link this CP entry into cache[i].f1
 629     int ref_kind        = cpool->method_handle_ref_kind_at(index);
 630     int callee_index    = cpool->method_handle_klass_index_at(index);




 562                                    bool& is_accessible,
 563                                    ciInstanceKlass* accessor) {
 564   GUARDED_VM_ENTRY(return get_klass_by_index_impl(cpool, index, is_accessible, accessor);)
 565 }
 566 
 567 // ------------------------------------------------------------------
 568 // ciEnv::get_constant_by_index_impl
 569 //
 570 // Implementation of get_constant_by_index().
 571 ciConstant ciEnv::get_constant_by_index_impl(constantPoolHandle cpool,
 572                                              int pool_index, int cache_index,
 573                                              ciInstanceKlass* accessor) {
 574   bool ignore_will_link;
 575   EXCEPTION_CONTEXT;
 576   int index = pool_index;
 577   if (cache_index >= 0) {
 578     assert(index < 0, "only one kind of index at a time");
 579     oop obj = cpool->resolved_references()->obj_at(cache_index);
 580     if (obj != NULL) {
 581       ciObject* ciobj = get_object(obj);
 582       if (ciobj->is_array()) {
 583         return ciConstant(T_ARRAY, ciobj);
 584       } else {
 585         assert(ciobj->is_instance(), "should be an instance");
 586         return ciConstant(T_OBJECT, ciobj);
 587       }
 588     }
 589     index = cpool->object_to_cp_index(cache_index);
 590   }
 591   constantTag tag = cpool->tag_at(index);
 592   if (tag.is_int()) {
 593     return ciConstant(T_INT, (jint)cpool->int_at(index));
 594   } else if (tag.is_long()) {
 595     return ciConstant((jlong)cpool->long_at(index));
 596   } else if (tag.is_float()) {
 597     return ciConstant((jfloat)cpool->float_at(index));
 598   } else if (tag.is_double()) {
 599     return ciConstant((jdouble)cpool->double_at(index));
 600   } else if (tag.is_string()) {
 601     oop string = NULL;
 602     assert(cache_index >= 0, "should have a cache index");
 603     if (cpool->is_pseudo_string_at(index)) {
 604       string = cpool->pseudo_string_at(index, cache_index);
 605     } else {
 606       string = cpool->string_at(index, cache_index, THREAD);
 607       if (HAS_PENDING_EXCEPTION) {
 608         CLEAR_PENDING_EXCEPTION;
 609         record_out_of_memory_failure();
 610         return ciConstant();
 611       }
 612     }
 613     ciObject* constant = get_object(string);
 614     if (constant->is_array()) {
 615       return ciConstant(T_ARRAY, constant);
 616     } else {
 617       assert (constant->is_instance(), "must be an instance, or not? ");
 618       return ciConstant(T_OBJECT, constant);
 619     }
 620   } else if (tag.is_klass() || tag.is_unresolved_klass()) {
 621     // 4881222: allow ldc to take a class type
 622     ciKlass* klass = get_klass_by_index_impl(cpool, index, ignore_will_link, accessor);
 623     if (HAS_PENDING_EXCEPTION) {
 624       CLEAR_PENDING_EXCEPTION;
 625       record_out_of_memory_failure();
 626       return ciConstant();
 627     }
 628     assert (klass->is_instance_klass() || klass->is_array_klass(),
 629             "must be an instance or array klass ");
 630     return ciConstant(T_OBJECT, klass->java_mirror());
 631   } else if (tag.is_method_type()) {
 632     // must execute Java code to link this CP entry into cache[i].f1
 633     ciSymbol* signature = get_symbol(cpool->method_type_signature_at(index));
 634     ciObject* ciobj = get_unloaded_method_type_constant(signature);
 635     return ciConstant(T_OBJECT, ciobj);
 636   } else if (tag.is_method_handle()) {
 637     // must execute Java code to link this CP entry into cache[i].f1
 638     int ref_kind        = cpool->method_handle_ref_kind_at(index);
 639     int callee_index    = cpool->method_handle_klass_index_at(index);


src/share/vm/ci/ciEnv.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File