793 Node *use = p->fast_out(i);
794 if (use->is_CheckCastPP()) {
795 if (cast != NULL) {
796 return this; // more than 1 CheckCastPP
797 }
798 cast = use;
799 } else if (!use->is_Initialize() &&
800 !use->is_AddP() &&
801 use->Opcode() != Op_MemBarStoreStore) {
802 // Expected uses are restricted to a CheckCastPP, an Initialize
803 // node, a MemBarStoreStore (clone) and AddP nodes. If we
804 // encounter any other use (a Phi node can be seen in rare
805 // cases) return this to prevent incorrect optimizations.
806 return this;
807 }
808 }
809 return cast;
810 }
811
812
813 void CallNode::extract_projections(CallProjections* projs, bool separate_io_proj) {
814 projs->fallthrough_proj = NULL;
815 projs->fallthrough_catchproj = NULL;
816 projs->fallthrough_ioproj = NULL;
817 projs->catchall_ioproj = NULL;
818 projs->catchall_catchproj = NULL;
819 projs->fallthrough_memproj = NULL;
820 projs->catchall_memproj = NULL;
821 projs->resproj = NULL;
822 projs->exobj = NULL;
823
824 for (DUIterator_Fast imax, i = fast_outs(imax); i < imax; i++) {
825 ProjNode *pn = fast_out(i)->as_Proj();
826 if (pn->outcnt() == 0) continue;
827 switch (pn->_con) {
828 case TypeFunc::Control:
829 {
830 // For Control (fallthrough) and I_O (catch_all_index) we have CatchProj -> Catch -> Proj
831 projs->fallthrough_proj = pn;
832 DUIterator_Fast jmax, j = pn->fast_outs(jmax);
833 const Node *cn = pn->fast_out(j);
856 if (e->Opcode() == Op_CreateEx && e->in(0)->is_CatchProj() && e->outcnt() > 0) {
857 assert(projs->exobj == NULL, "only one");
858 projs->exobj = e;
859 }
860 }
861 break;
862 case TypeFunc::Memory:
863 if (pn->_is_io_use)
864 projs->catchall_memproj = pn;
865 else
866 projs->fallthrough_memproj = pn;
867 break;
868 case TypeFunc::Parms:
869 projs->resproj = pn;
870 break;
871 default:
872 assert(false, "unexpected projection from allocation node.");
873 }
874 }
875
876 // The resproj may not exist because the result couuld be ignored
877 // and the exception object may not exist if an exception handler
878 // swallows the exception but all the other must exist and be found.
879 assert(projs->fallthrough_proj != NULL, "must be found");
880 assert(Compile::current()->inlining_incrementally() || projs->fallthrough_catchproj != NULL, "must be found");
881 assert(Compile::current()->inlining_incrementally() || projs->fallthrough_memproj != NULL, "must be found");
882 assert(Compile::current()->inlining_incrementally() || projs->fallthrough_ioproj != NULL, "must be found");
883 assert(Compile::current()->inlining_incrementally() || projs->catchall_catchproj != NULL, "must be found");
884 if (separate_io_proj) {
885 assert(Compile::current()->inlining_incrementally() || projs->catchall_memproj != NULL, "must be found");
886 assert(Compile::current()->inlining_incrementally() || projs->catchall_ioproj != NULL, "must be found");
887 }
888 }
889
890 Node *CallNode::Ideal(PhaseGVN *phase, bool can_reshape) {
891 CallGenerator* cg = generator();
892 if (can_reshape && cg != NULL && cg->is_mh_late_inline() && !cg->already_attempted()) {
893 // Check whether this MH handle call becomes a candidate for inlining
894 ciMethod* callee = cg->method();
895 vmIntrinsics::ID iid = callee->intrinsic_id();
896 if (iid == vmIntrinsics::_invokeBasic) {
897 if (in(TypeFunc::Parms)->Opcode() == Op_ConP) {
898 phase->C->prepend_late_inline(cg);
899 set_generator(NULL);
900 }
901 } else {
902 assert(callee->has_member_arg(), "wrong type of call?");
903 if (in(TypeFunc::Parms + callee->arg_size() - 1)->Opcode() == Op_ConP) {
904 phase->C->prepend_late_inline(cg);
905 set_generator(NULL);
906 }
|
793 Node *use = p->fast_out(i);
794 if (use->is_CheckCastPP()) {
795 if (cast != NULL) {
796 return this; // more than 1 CheckCastPP
797 }
798 cast = use;
799 } else if (!use->is_Initialize() &&
800 !use->is_AddP() &&
801 use->Opcode() != Op_MemBarStoreStore) {
802 // Expected uses are restricted to a CheckCastPP, an Initialize
803 // node, a MemBarStoreStore (clone) and AddP nodes. If we
804 // encounter any other use (a Phi node can be seen in rare
805 // cases) return this to prevent incorrect optimizations.
806 return this;
807 }
808 }
809 return cast;
810 }
811
812
813 void CallNode::extract_projections(CallProjections* projs, bool separate_io_proj, bool do_asserts) {
814 projs->fallthrough_proj = NULL;
815 projs->fallthrough_catchproj = NULL;
816 projs->fallthrough_ioproj = NULL;
817 projs->catchall_ioproj = NULL;
818 projs->catchall_catchproj = NULL;
819 projs->fallthrough_memproj = NULL;
820 projs->catchall_memproj = NULL;
821 projs->resproj = NULL;
822 projs->exobj = NULL;
823
824 for (DUIterator_Fast imax, i = fast_outs(imax); i < imax; i++) {
825 ProjNode *pn = fast_out(i)->as_Proj();
826 if (pn->outcnt() == 0) continue;
827 switch (pn->_con) {
828 case TypeFunc::Control:
829 {
830 // For Control (fallthrough) and I_O (catch_all_index) we have CatchProj -> Catch -> Proj
831 projs->fallthrough_proj = pn;
832 DUIterator_Fast jmax, j = pn->fast_outs(jmax);
833 const Node *cn = pn->fast_out(j);
856 if (e->Opcode() == Op_CreateEx && e->in(0)->is_CatchProj() && e->outcnt() > 0) {
857 assert(projs->exobj == NULL, "only one");
858 projs->exobj = e;
859 }
860 }
861 break;
862 case TypeFunc::Memory:
863 if (pn->_is_io_use)
864 projs->catchall_memproj = pn;
865 else
866 projs->fallthrough_memproj = pn;
867 break;
868 case TypeFunc::Parms:
869 projs->resproj = pn;
870 break;
871 default:
872 assert(false, "unexpected projection from allocation node.");
873 }
874 }
875
876 // The resproj may not exist because the result could be ignored
877 // and the exception object may not exist if an exception handler
878 // swallows the exception but all the other must exist and be found.
879 assert(projs->fallthrough_proj != NULL, "must be found");
880 do_asserts = do_asserts && !Compile::current()->inlining_incrementally();
881 assert(!do_asserts || projs->fallthrough_catchproj != NULL, "must be found");
882 assert(!do_asserts || projs->fallthrough_memproj != NULL, "must be found");
883 assert(!do_asserts || projs->fallthrough_ioproj != NULL, "must be found");
884 assert(!do_asserts || projs->catchall_catchproj != NULL, "must be found");
885 if (separate_io_proj) {
886 assert(!do_asserts || projs->catchall_memproj != NULL, "must be found");
887 assert(!do_asserts || projs->catchall_ioproj != NULL, "must be found");
888 }
889 }
890
891 Node *CallNode::Ideal(PhaseGVN *phase, bool can_reshape) {
892 CallGenerator* cg = generator();
893 if (can_reshape && cg != NULL && cg->is_mh_late_inline() && !cg->already_attempted()) {
894 // Check whether this MH handle call becomes a candidate for inlining
895 ciMethod* callee = cg->method();
896 vmIntrinsics::ID iid = callee->intrinsic_id();
897 if (iid == vmIntrinsics::_invokeBasic) {
898 if (in(TypeFunc::Parms)->Opcode() == Op_ConP) {
899 phase->C->prepend_late_inline(cg);
900 set_generator(NULL);
901 }
902 } else {
903 assert(callee->has_member_arg(), "wrong type of call?");
904 if (in(TypeFunc::Parms + callee->arg_size() - 1)->Opcode() == Op_ConP) {
905 phase->C->prepend_late_inline(cg);
906 set_generator(NULL);
907 }
|