685 #endif /*ASSERT*/
686 }
687 }
688 #endif
689 return can_eliminate;
690 }
691
692 // Do scalar replacement.
693 bool PhaseMacroExpand::scalar_replacement(AllocateNode *alloc, GrowableArray <SafePointNode *>& safepoints) {
694 GrowableArray <SafePointNode *> safepoints_done;
695
696 ciKlass* klass = NULL;
697 ciInstanceKlass* iklass = NULL;
698 int nfields = 0;
699 int array_base;
700 int element_size;
701 BasicType basic_elem_type;
702 ciType* elem_type;
703
704 Node* res = alloc->result_cast();
705 const TypeOopPtr* res_type = NULL;
706 if (res != NULL) { // Could be NULL when there are no users
707 res_type = _igvn.type(res)->isa_oopptr();
708 }
709
710 if (res != NULL) {
711 klass = res_type->klass();
712 if (res_type->isa_instptr()) {
713 // find the fields of the class which will be needed for safepoint debug information
714 assert(klass->is_instance_klass(), "must be an instance klass.");
715 iklass = klass->as_instance_klass();
716 nfields = iklass->nof_nonstatic_fields();
717 } else {
718 // find the array's elements which will be needed for safepoint debug information
719 nfields = alloc->in(AllocateNode::ALength)->find_int_con(-1);
720 assert(klass->is_array_klass() && nfields >= 0, "must be an array klass.");
721 elem_type = klass->as_array_klass()->element_type();
722 basic_elem_type = elem_type->basic_type();
723 array_base = arrayOopDesc::base_offset_in_bytes(basic_elem_type);
724 element_size = type2aelembytes(basic_elem_type);
1016
1017 process_users_of_allocation(alloc);
1018
1019 #ifndef PRODUCT
1020 if (PrintEliminateAllocations) {
1021 if (alloc->is_AllocateArray())
1022 tty->print_cr("++++ Eliminated: %d AllocateArray", alloc->_idx);
1023 else
1024 tty->print_cr("++++ Eliminated: %d Allocate", alloc->_idx);
1025 }
1026 #endif
1027
1028 return true;
1029 }
1030
1031 bool PhaseMacroExpand::eliminate_boxing_node(CallStaticJavaNode *boxing) {
1032 // EA should remove all uses of non-escaping boxing node.
1033 if (!C->eliminate_boxing() || boxing->proj_out(TypeFunc::Parms) != NULL) {
1034 return false;
1035 }
1036
1037 extract_call_projections(boxing);
1038
1039 const TypeTuple* r = boxing->tf()->range();
1040 assert(r->cnt() > TypeFunc::Parms, "sanity");
1041 const TypeInstPtr* t = r->field_at(TypeFunc::Parms)->isa_instptr();
1042 assert(t != NULL, "sanity");
1043
1044 CompileLog* log = C->log();
1045 if (log != NULL) {
1046 log->head("eliminate_boxing type='%d'",
1047 log->identify(t->klass()));
1048 JVMState* p = boxing->jvms();
1049 while (p != NULL) {
1050 log->elem("jvms bci='%d' method='%d'", p->bci(), log->identify(p->method()));
1051 p = p->caller();
1052 }
1053 log->tail("eliminate_boxing");
1054 }
1055
|
685 #endif /*ASSERT*/
686 }
687 }
688 #endif
689 return can_eliminate;
690 }
691
692 // Do scalar replacement.
693 bool PhaseMacroExpand::scalar_replacement(AllocateNode *alloc, GrowableArray <SafePointNode *>& safepoints) {
694 GrowableArray <SafePointNode *> safepoints_done;
695
696 ciKlass* klass = NULL;
697 ciInstanceKlass* iklass = NULL;
698 int nfields = 0;
699 int array_base;
700 int element_size;
701 BasicType basic_elem_type;
702 ciType* elem_type;
703
704 Node* res = alloc->result_cast();
705 assert(res == NULL || res->is_CheckCastPP(), "unexpected AllocateNode result");
706 const TypeOopPtr* res_type = NULL;
707 if (res != NULL) { // Could be NULL when there are no users
708 res_type = _igvn.type(res)->isa_oopptr();
709 }
710
711 if (res != NULL) {
712 klass = res_type->klass();
713 if (res_type->isa_instptr()) {
714 // find the fields of the class which will be needed for safepoint debug information
715 assert(klass->is_instance_klass(), "must be an instance klass.");
716 iklass = klass->as_instance_klass();
717 nfields = iklass->nof_nonstatic_fields();
718 } else {
719 // find the array's elements which will be needed for safepoint debug information
720 nfields = alloc->in(AllocateNode::ALength)->find_int_con(-1);
721 assert(klass->is_array_klass() && nfields >= 0, "must be an array klass.");
722 elem_type = klass->as_array_klass()->element_type();
723 basic_elem_type = elem_type->basic_type();
724 array_base = arrayOopDesc::base_offset_in_bytes(basic_elem_type);
725 element_size = type2aelembytes(basic_elem_type);
1017
1018 process_users_of_allocation(alloc);
1019
1020 #ifndef PRODUCT
1021 if (PrintEliminateAllocations) {
1022 if (alloc->is_AllocateArray())
1023 tty->print_cr("++++ Eliminated: %d AllocateArray", alloc->_idx);
1024 else
1025 tty->print_cr("++++ Eliminated: %d Allocate", alloc->_idx);
1026 }
1027 #endif
1028
1029 return true;
1030 }
1031
1032 bool PhaseMacroExpand::eliminate_boxing_node(CallStaticJavaNode *boxing) {
1033 // EA should remove all uses of non-escaping boxing node.
1034 if (!C->eliminate_boxing() || boxing->proj_out(TypeFunc::Parms) != NULL) {
1035 return false;
1036 }
1037
1038 assert(boxing->result_cast() == NULL, "unexpected boxing node result");
1039
1040 extract_call_projections(boxing);
1041
1042 const TypeTuple* r = boxing->tf()->range();
1043 assert(r->cnt() > TypeFunc::Parms, "sanity");
1044 const TypeInstPtr* t = r->field_at(TypeFunc::Parms)->isa_instptr();
1045 assert(t != NULL, "sanity");
1046
1047 CompileLog* log = C->log();
1048 if (log != NULL) {
1049 log->head("eliminate_boxing type='%d'",
1050 log->identify(t->klass()));
1051 JVMState* p = boxing->jvms();
1052 while (p != NULL) {
1053 log->elem("jvms bci='%d' method='%d'", p->bci(), log->identify(p->method()));
1054 p = p->caller();
1055 }
1056 log->tail("eliminate_boxing");
1057 }
1058
|