676 ciKlass* klass = NULL; 677 ciInstanceKlass* iklass = NULL; 678 int nfields = 0; 679 int array_base; 680 int element_size; 681 BasicType basic_elem_type; 682 ciType* elem_type; 683 684 Node* res = alloc->result_cast(); 685 const TypeOopPtr* res_type = NULL; 686 if (res != NULL) { // Could be NULL when there are no users 687 res_type = _igvn.type(res)->isa_oopptr(); 688 } 689 690 if (res != NULL) { 691 klass = res_type->klass(); 692 if (res_type->isa_instptr()) { 693 // find the fields of the class which will be needed for safepoint debug information 694 assert(klass->is_instance_klass(), "must be an instance klass."); 695 iklass = klass->as_instance_klass(); 696 nfields = iklass->nof_nonstatic_fields(); 697 } else { 698 // find the array's elements which will be needed for safepoint debug information 699 nfields = alloc->in(AllocateNode::ALength)->find_int_con(-1); 700 assert(klass->is_array_klass() && nfields >= 0, "must be an array klass."); 701 elem_type = klass->as_array_klass()->element_type(); 702 basic_elem_type = elem_type->basic_type(); 703 array_base = arrayOopDesc::base_offset_in_bytes(basic_elem_type); 704 element_size = type2aelembytes(basic_elem_type); 705 } 706 } 707 // 708 // Process the safepoint uses 709 // 710 while (safepoints.length() > 0) { 711 SafePointNode* sfpt = safepoints.pop(); 712 Node* mem = sfpt->memory(); 713 uint first_ind = sfpt->req(); 714 SafePointScalarObjectNode* sobj = new (C, 1) SafePointScalarObjectNode(res_type, 715 #ifdef ASSERT 716 alloc, 717 #endif 718 first_ind, nfields); 719 sobj->init_req(0, sfpt->in(TypeFunc::Control)); 720 transform_later(sobj); 721 722 // Scan object's fields adding an input to the safepoint for each field. 723 for (int j = 0; j < nfields; j++) { 724 intptr_t offset; 725 ciField* field = NULL; 726 if (iklass != NULL) { 727 field = iklass->nonstatic_field_at(j); 728 offset = field->offset(); 729 elem_type = field->type(); 730 basic_elem_type = field->layout_type(); 731 } else { 732 offset = array_base + j * (intptr_t)element_size; 733 } 734 735 const Type *field_type; 736 // The next code is taken from Parse::do_get_xxx(). 737 if (basic_elem_type == T_OBJECT || basic_elem_type == T_ARRAY) { 738 if (!elem_type->is_loaded()) { 739 field_type = TypeInstPtr::BOTTOM; 740 } else if (field != NULL && field->is_constant() && field->is_static()) { 741 // This can happen if the constant oop is non-perm. 742 ciObject* con = field->constant_value().as_object(); 743 // Do not "join" in the previous type; it doesn't add value, 744 // and may yield a vacuous result if the field is of interface type. 745 field_type = TypeOopPtr::make_from_constant(con)->isa_oopptr(); 746 assert(field_type != NULL, "field singleton type must be consistent"); 747 } else { | 676 ciKlass* klass = NULL; 677 ciInstanceKlass* iklass = NULL; 678 int nfields = 0; 679 int array_base; 680 int element_size; 681 BasicType basic_elem_type; 682 ciType* elem_type; 683 684 Node* res = alloc->result_cast(); 685 const TypeOopPtr* res_type = NULL; 686 if (res != NULL) { // Could be NULL when there are no users 687 res_type = _igvn.type(res)->isa_oopptr(); 688 } 689 690 if (res != NULL) { 691 klass = res_type->klass(); 692 if (res_type->isa_instptr()) { 693 // find the fields of the class which will be needed for safepoint debug information 694 assert(klass->is_instance_klass(), "must be an instance klass."); 695 iklass = klass->as_instance_klass(); 696 nfields = iklass->nonstatic_fields()->length(); 697 } else { 698 // find the array's elements which will be needed for safepoint debug information 699 nfields = alloc->in(AllocateNode::ALength)->find_int_con(-1); 700 assert(klass->is_array_klass() && nfields >= 0, "must be an array klass."); 701 elem_type = klass->as_array_klass()->element_type(); 702 basic_elem_type = elem_type->basic_type(); 703 array_base = arrayOopDesc::base_offset_in_bytes(basic_elem_type); 704 element_size = type2aelembytes(basic_elem_type); 705 } 706 } 707 // 708 // Process the safepoint uses 709 // 710 while (safepoints.length() > 0) { 711 SafePointNode* sfpt = safepoints.pop(); 712 Node* mem = sfpt->memory(); 713 uint first_ind = sfpt->req(); 714 SafePointScalarObjectNode* sobj = new (C, 1) SafePointScalarObjectNode(res_type, 715 #ifdef ASSERT 716 alloc, 717 #endif 718 first_ind, nfields); 719 sobj->init_req(0, sfpt->in(TypeFunc::Control)); 720 transform_later(sobj); 721 722 // Scan object's fields adding an input to the safepoint for each field. 723 for (int j = 0; j < nfields; j++) { 724 intptr_t offset; 725 ciField* field = NULL; 726 if (iklass != NULL) { 727 field = iklass->nonstatic_fields()->at(j); 728 offset = field->offset(); 729 elem_type = field->type(); 730 basic_elem_type = field->layout_type(); 731 } else { 732 offset = array_base + j * (intptr_t)element_size; 733 } 734 735 const Type *field_type; 736 // The next code is taken from Parse::do_get_xxx(). 737 if (basic_elem_type == T_OBJECT || basic_elem_type == T_ARRAY) { 738 if (!elem_type->is_loaded()) { 739 field_type = TypeInstPtr::BOTTOM; 740 } else if (field != NULL && field->is_constant() && field->is_static()) { 741 // This can happen if the constant oop is non-perm. 742 ciObject* con = field->constant_value().as_object(); 743 // Do not "join" in the previous type; it doesn't add value, 744 // and may yield a vacuous result if the field is of interface type. 745 field_type = TypeOopPtr::make_from_constant(con)->isa_oopptr(); 746 assert(field_type != NULL, "field singleton type must be consistent"); 747 } else { |