732 break;
733 case vmIntrinsics::_dlog:
734 runtime_entry = CAST_FROM_FN_PTR(address, SharedRuntime::dlog);
735 break;
736 case vmIntrinsics::_dlog10:
737 runtime_entry = CAST_FROM_FN_PTR(address, SharedRuntime::dlog10);
738 break;
739 default:
740 ShouldNotReachHere();
741 }
742
743 LIR_Opr result = call_runtime(x->argument_at(0), runtime_entry, x->type(), NULL);
744 set_result(x, result);
745 }
746 }
747 }
748
749
750 void LIRGenerator::do_ArrayCopy(Intrinsic* x) {
751 assert(x->number_of_arguments() == 5, "wrong type");
752 // Note: spill caller save before setting the item
753 LIRItem src (x->argument_at(0), this);
754 LIRItem src_pos (x->argument_at(1), this);
755 LIRItem dst (x->argument_at(2), this);
756 LIRItem dst_pos (x->argument_at(3), this);
757 LIRItem length (x->argument_at(4), this);
758 // load all values in callee_save_registers, as this makes the
759 // parameter passing to the fast case simpler
760 src.load_item_force (rlock_callee_saved(T_OBJECT));
761 src_pos.load_item_force (rlock_callee_saved(T_INT));
762 dst.load_item_force (rlock_callee_saved(T_OBJECT));
763 dst_pos.load_item_force (rlock_callee_saved(T_INT));
764 length.load_item_force (rlock_callee_saved(T_INT));
765
766 int flags;
767 ciArrayKlass* expected_type;
768 arraycopy_helper(x, &flags, &expected_type);
769
770 CodeEmitInfo* info = state_for(x, x->state());
771 __ arraycopy(src.result(), src_pos.result(), dst.result(), dst_pos.result(),
772 length.result(), rlock_callee_saved(T_INT),
773 expected_type, flags, info);
774 set_no_result(x);
775 }
776
777 // _i2l, _i2f, _i2d, _l2i, _l2f, _l2d, _f2i, _f2l, _f2d, _d2i, _d2l, _d2f
778 // _i2b, _i2c, _i2s
779 void LIRGenerator::do_Convert(Convert* x) {
780
781 switch (x->op()) {
782 case Bytecodes::_f2l:
783 case Bytecodes::_d2l:
784 case Bytecodes::_d2i:
785 case Bytecodes::_l2f:
786 case Bytecodes::_l2d: {
787
788 address entry;
789 switch (x->op()) {
790 case Bytecodes::_l2f:
861 // This instruction can be deoptimized in the slow path : use
862 // O0 as result register.
863 const LIR_Opr reg = result_register_for(x->type());
864
865 if (PrintNotLoaded && !x->klass()->is_loaded()) {
866 tty->print_cr(" ###class not loaded at new bci %d", x->bci());
867 }
868 CodeEmitInfo* info = state_for(x, x->state());
869 LIR_Opr tmp1 = FrameMap::G1_oop_opr;
870 LIR_Opr tmp2 = FrameMap::G3_oop_opr;
871 LIR_Opr tmp3 = FrameMap::G4_oop_opr;
872 LIR_Opr tmp4 = FrameMap::O1_oop_opr;
873 LIR_Opr klass_reg = FrameMap::G5_oop_opr;
874 new_instance(reg, x->klass(), tmp1, tmp2, tmp3, tmp4, klass_reg, info);
875 LIR_Opr result = rlock_result(x);
876 __ move(reg, result);
877 }
878
879
880 void LIRGenerator::do_NewTypeArray(NewTypeArray* x) {
881 LIRItem length(x->length(), this);
882 length.load_item();
883
884 LIR_Opr reg = result_register_for(x->type());
885 LIR_Opr tmp1 = FrameMap::G1_oop_opr;
886 LIR_Opr tmp2 = FrameMap::G3_oop_opr;
887 LIR_Opr tmp3 = FrameMap::G4_oop_opr;
888 LIR_Opr tmp4 = FrameMap::O1_oop_opr;
889 LIR_Opr klass_reg = FrameMap::G5_oop_opr;
890 LIR_Opr len = length.result();
891 BasicType elem_type = x->elt_type();
892
893 __ oop2reg(ciTypeArrayKlass::make(elem_type)->encoding(), klass_reg);
894
895 CodeEmitInfo* info = state_for(x, x->state());
896 CodeStub* slow_path = new NewTypeArrayStub(klass_reg, len, reg, info);
897 __ allocate_array(reg, len, tmp1, tmp2, tmp3, tmp4, elem_type, klass_reg, slow_path);
898
899 LIR_Opr result = rlock_result(x);
900 __ move(reg, result);
901 }
902
903
904 void LIRGenerator::do_NewObjectArray(NewObjectArray* x) {
905 LIRItem length(x->length(), this);
906 // in case of patching (i.e., object class is not yet loaded), we need to reexecute the instruction
907 // and therefore provide the state before the parameters have been consumed
908 CodeEmitInfo* patching_info = NULL;
909 if (!x->klass()->is_loaded() || PatchALot) {
910 patching_info = state_for(x, x->state_before());
911 }
912
913 length.load_item();
914
915 const LIR_Opr reg = result_register_for(x->type());
916 LIR_Opr tmp1 = FrameMap::G1_oop_opr;
917 LIR_Opr tmp2 = FrameMap::G3_oop_opr;
918 LIR_Opr tmp3 = FrameMap::G4_oop_opr;
919 LIR_Opr tmp4 = FrameMap::O1_oop_opr;
920 LIR_Opr klass_reg = FrameMap::G5_oop_opr;
921 LIR_Opr len = length.result();
922 CodeEmitInfo* info = state_for(x, x->state());
923
924 CodeStub* slow_path = new NewObjectArrayStub(klass_reg, len, reg, info);
925 ciObject* obj = (ciObject*) ciObjArrayKlass::make(x->klass());
926 if (obj == ciEnv::unloaded_ciobjarrayklass()) {
927 BAILOUT("encountered unloaded_ciobjarrayklass due to out of memory error");
928 }
929 jobject2reg_with_patching(klass_reg, obj, patching_info);
930 __ allocate_array(reg, len, tmp1, tmp2, tmp3, tmp4, T_OBJECT, klass_reg, slow_path);
931
932 LIR_Opr result = rlock_result(x);
933 __ move(reg, result);
934 }
935
936
937 void LIRGenerator::do_NewMultiArray(NewMultiArray* x) {
938 Values* dims = x->dims();
939 int i = dims->length();
940 LIRItemList* items = new LIRItemList(dims->length(), NULL);
941 while (i-- > 0) {
942 LIRItem* size = new LIRItem(dims->at(i), this);
943 items->at_put(i, size);
944 }
945
946 // need to get the info before, as the items may become invalid through item_free
947 CodeEmitInfo* patching_info = NULL;
948 if (!x->klass()->is_loaded() || PatchALot) {
949 patching_info = state_for(x, x->state_before());
950
951 // cannot re-use same xhandlers for multiple CodeEmitInfos, so
952 // clone all handlers
953 x->set_exception_handlers(new XHandlers(x->exception_handlers()));
954 }
955
956 i = dims->length();
957 while (i-- > 0) {
958 LIRItem* size = items->at(i);
959 // if a patching_info was generated above then debug information for the state before
960 // the call is going to be emitted. The LIRGenerator calls above may have left some values
961 // in registers and that's been recorded in the CodeEmitInfo. In that case the items
962 // for those values can't simply be freed if they are registers because the values
963 // might be destroyed by store_stack_parameter. So in the case of patching, delay the
964 // freeing of the items that already were in registers
965 size->load_item();
966 store_stack_parameter (size->result(),
967 in_ByteSize(STACK_BIAS +
968 frame::memory_parameter_word_sp_offset * wordSize +
969 i * sizeof(jint)));
970 }
971
972 // This instruction can be deoptimized in the slow path : use
973 // O0 as result register.
974 const LIR_Opr reg = result_register_for(x->type());
975 CodeEmitInfo* info = state_for(x, x->state());
976
977 jobject2reg_with_patching(reg, x->klass(), patching_info);
978 LIR_Opr rank = FrameMap::O1_opr;
979 __ move(LIR_OprFact::intConst(x->rank()), rank);
980 LIR_Opr varargs = FrameMap::as_pointer_opr(O2);
981 int offset_from_sp = (frame::memory_parameter_word_sp_offset * wordSize) + STACK_BIAS;
982 __ add(FrameMap::SP_opr,
983 LIR_OprFact::intptrConst(offset_from_sp),
984 varargs);
985 LIR_OprList* args = new LIR_OprList(3);
986 args->append(reg);
987 args->append(rank);
988 args->append(varargs);
989 __ call_runtime(Runtime1::entry_for(Runtime1::new_multi_array_id),
990 LIR_OprFact::illegalOpr,
991 reg, args, info);
992
993 LIR_Opr result = rlock_result(x);
994 __ move(reg, result);
995 }
996
|
732 break;
733 case vmIntrinsics::_dlog:
734 runtime_entry = CAST_FROM_FN_PTR(address, SharedRuntime::dlog);
735 break;
736 case vmIntrinsics::_dlog10:
737 runtime_entry = CAST_FROM_FN_PTR(address, SharedRuntime::dlog10);
738 break;
739 default:
740 ShouldNotReachHere();
741 }
742
743 LIR_Opr result = call_runtime(x->argument_at(0), runtime_entry, x->type(), NULL);
744 set_result(x, result);
745 }
746 }
747 }
748
749
750 void LIRGenerator::do_ArrayCopy(Intrinsic* x) {
751 assert(x->number_of_arguments() == 5, "wrong type");
752
753 // Make all state_for calls early since they can emit code
754 CodeEmitInfo* info = state_for(x, x->state());
755
756 // Note: spill caller save before setting the item
757 LIRItem src (x->argument_at(0), this);
758 LIRItem src_pos (x->argument_at(1), this);
759 LIRItem dst (x->argument_at(2), this);
760 LIRItem dst_pos (x->argument_at(3), this);
761 LIRItem length (x->argument_at(4), this);
762 // load all values in callee_save_registers, as this makes the
763 // parameter passing to the fast case simpler
764 src.load_item_force (rlock_callee_saved(T_OBJECT));
765 src_pos.load_item_force (rlock_callee_saved(T_INT));
766 dst.load_item_force (rlock_callee_saved(T_OBJECT));
767 dst_pos.load_item_force (rlock_callee_saved(T_INT));
768 length.load_item_force (rlock_callee_saved(T_INT));
769
770 int flags;
771 ciArrayKlass* expected_type;
772 arraycopy_helper(x, &flags, &expected_type);
773
774 __ arraycopy(src.result(), src_pos.result(), dst.result(), dst_pos.result(),
775 length.result(), rlock_callee_saved(T_INT),
776 expected_type, flags, info);
777 set_no_result(x);
778 }
779
780 // _i2l, _i2f, _i2d, _l2i, _l2f, _l2d, _f2i, _f2l, _f2d, _d2i, _d2l, _d2f
781 // _i2b, _i2c, _i2s
782 void LIRGenerator::do_Convert(Convert* x) {
783
784 switch (x->op()) {
785 case Bytecodes::_f2l:
786 case Bytecodes::_d2l:
787 case Bytecodes::_d2i:
788 case Bytecodes::_l2f:
789 case Bytecodes::_l2d: {
790
791 address entry;
792 switch (x->op()) {
793 case Bytecodes::_l2f:
864 // This instruction can be deoptimized in the slow path : use
865 // O0 as result register.
866 const LIR_Opr reg = result_register_for(x->type());
867
868 if (PrintNotLoaded && !x->klass()->is_loaded()) {
869 tty->print_cr(" ###class not loaded at new bci %d", x->bci());
870 }
871 CodeEmitInfo* info = state_for(x, x->state());
872 LIR_Opr tmp1 = FrameMap::G1_oop_opr;
873 LIR_Opr tmp2 = FrameMap::G3_oop_opr;
874 LIR_Opr tmp3 = FrameMap::G4_oop_opr;
875 LIR_Opr tmp4 = FrameMap::O1_oop_opr;
876 LIR_Opr klass_reg = FrameMap::G5_oop_opr;
877 new_instance(reg, x->klass(), tmp1, tmp2, tmp3, tmp4, klass_reg, info);
878 LIR_Opr result = rlock_result(x);
879 __ move(reg, result);
880 }
881
882
883 void LIRGenerator::do_NewTypeArray(NewTypeArray* x) {
884 // Evaluate state_for early since it may emit code
885 CodeEmitInfo* info = state_for(x, x->state());
886
887 LIRItem length(x->length(), this);
888 length.load_item();
889
890 LIR_Opr reg = result_register_for(x->type());
891 LIR_Opr tmp1 = FrameMap::G1_oop_opr;
892 LIR_Opr tmp2 = FrameMap::G3_oop_opr;
893 LIR_Opr tmp3 = FrameMap::G4_oop_opr;
894 LIR_Opr tmp4 = FrameMap::O1_oop_opr;
895 LIR_Opr klass_reg = FrameMap::G5_oop_opr;
896 LIR_Opr len = length.result();
897 BasicType elem_type = x->elt_type();
898
899 __ oop2reg(ciTypeArrayKlass::make(elem_type)->encoding(), klass_reg);
900
901 CodeStub* slow_path = new NewTypeArrayStub(klass_reg, len, reg, info);
902 __ allocate_array(reg, len, tmp1, tmp2, tmp3, tmp4, elem_type, klass_reg, slow_path);
903
904 LIR_Opr result = rlock_result(x);
905 __ move(reg, result);
906 }
907
908
909 void LIRGenerator::do_NewObjectArray(NewObjectArray* x) {
910 // Evaluate state_for early since it may emit code.
911 CodeEmitInfo* info = state_for(x, x->state());
912 // in case of patching (i.e., object class is not yet loaded), we need to reexecute the instruction
913 // and therefore provide the state before the parameters have been consumed
914 CodeEmitInfo* patching_info = NULL;
915 if (!x->klass()->is_loaded() || PatchALot) {
916 patching_info = state_for(x, x->state_before());
917 }
918
919 LIRItem length(x->length(), this);
920 length.load_item();
921
922 const LIR_Opr reg = result_register_for(x->type());
923 LIR_Opr tmp1 = FrameMap::G1_oop_opr;
924 LIR_Opr tmp2 = FrameMap::G3_oop_opr;
925 LIR_Opr tmp3 = FrameMap::G4_oop_opr;
926 LIR_Opr tmp4 = FrameMap::O1_oop_opr;
927 LIR_Opr klass_reg = FrameMap::G5_oop_opr;
928 LIR_Opr len = length.result();
929
930 CodeStub* slow_path = new NewObjectArrayStub(klass_reg, len, reg, info);
931 ciObject* obj = (ciObject*) ciObjArrayKlass::make(x->klass());
932 if (obj == ciEnv::unloaded_ciobjarrayklass()) {
933 BAILOUT("encountered unloaded_ciobjarrayklass due to out of memory error");
934 }
935 jobject2reg_with_patching(klass_reg, obj, patching_info);
936 __ allocate_array(reg, len, tmp1, tmp2, tmp3, tmp4, T_OBJECT, klass_reg, slow_path);
937
938 LIR_Opr result = rlock_result(x);
939 __ move(reg, result);
940 }
941
942
943 void LIRGenerator::do_NewMultiArray(NewMultiArray* x) {
944 Values* dims = x->dims();
945 int i = dims->length();
946 LIRItemList* items = new LIRItemList(dims->length(), NULL);
947 while (i-- > 0) {
948 LIRItem* size = new LIRItem(dims->at(i), this);
949 items->at_put(i, size);
950 }
951
952 // Evaluate state_for early since it may emit code.
953 CodeEmitInfo* info = state_for(x, x->state());
954 CodeEmitInfo* patching_info = NULL;
955 if (!x->klass()->is_loaded() || PatchALot) {
956 patching_info = state_for(x, x->state_before());
957
958 // cannot re-use same xhandlers for multiple CodeEmitInfos, so
959 // clone all handlers.
960 x->set_exception_handlers(new XHandlers(x->exception_handlers()));
961 }
962
963 i = dims->length();
964 while (i-- > 0) {
965 LIRItem* size = items->at(i);
966 size->load_item();
967 store_stack_parameter (size->result(),
968 in_ByteSize(STACK_BIAS +
969 frame::memory_parameter_word_sp_offset * wordSize +
970 i * sizeof(jint)));
971 }
972
973 // This instruction can be deoptimized in the slow path : use
974 // O0 as result register.
975 const LIR_Opr reg = result_register_for(x->type());
976 jobject2reg_with_patching(reg, x->klass(), patching_info);
977 LIR_Opr rank = FrameMap::O1_opr;
978 __ move(LIR_OprFact::intConst(x->rank()), rank);
979 LIR_Opr varargs = FrameMap::as_pointer_opr(O2);
980 int offset_from_sp = (frame::memory_parameter_word_sp_offset * wordSize) + STACK_BIAS;
981 __ add(FrameMap::SP_opr,
982 LIR_OprFact::intptrConst(offset_from_sp),
983 varargs);
984 LIR_OprList* args = new LIR_OprList(3);
985 args->append(reg);
986 args->append(rank);
987 args->append(varargs);
988 __ call_runtime(Runtime1::entry_for(Runtime1::new_multi_array_id),
989 LIR_OprFact::illegalOpr,
990 reg, args, info);
991
992 LIR_Opr result = rlock_result(x);
993 __ move(reg, result);
994 }
995
|