1 /*
2 * Copyright (c) 2005, 2025, Oracle and/or its affiliates. All rights reserved.
3 * Copyright (c) 2012, 2024 SAP SE. All rights reserved.
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
6 * This code is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 only, as
8 * published by the Free Software Foundation.
9 *
10 * This code is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * version 2 for more details (a copy is included in the LICENSE file that
14 * accompanied this code).
15 *
16 * You should have received a copy of the GNU General Public License version
17 * 2 along with this work; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21 * or visit www.oracle.com if you need additional information or have any
22 * questions.
826 default: break;
827 }
828 __ convert(x->op(), value.result(), reg);
829 }
830
831
832 void LIRGenerator::do_NewInstance(NewInstance* x) {
833 // This instruction can be deoptimized in the slow path.
834 const LIR_Opr reg = result_register_for(x->type());
835 #ifndef PRODUCT
836 if (PrintNotLoaded && !x->klass()->is_loaded()) {
837 tty->print_cr(" ###class not loaded at new bci %d", x->printable_bci());
838 }
839 #endif
840 CodeEmitInfo* info = state_for(x, x->state());
841 LIR_Opr klass_reg = FrameMap::R4_metadata_opr; // Used by slow path (NewInstanceStub).
842 LIR_Opr tmp1 = FrameMap::R5_oop_opr;
843 LIR_Opr tmp2 = FrameMap::R6_oop_opr;
844 LIR_Opr tmp3 = FrameMap::R7_oop_opr;
845 LIR_Opr tmp4 = FrameMap::R8_oop_opr;
846 new_instance(reg, x->klass(), x->is_unresolved(), tmp1, tmp2, tmp3, tmp4, klass_reg, info);
847
848 // Must prevent reordering of stores for object initialization
849 // with stores that publish the new object.
850 __ membar_storestore();
851 LIR_Opr result = rlock_result(x);
852 __ move(reg, result);
853 }
854
855
856 void LIRGenerator::do_NewTypeArray(NewTypeArray* x) {
857 // Evaluate state_for early since it may emit code.
858 CodeEmitInfo* info = nullptr;
859 if (x->state_before() != nullptr && x->state_before()->force_reexecute()) {
860 info = state_for(x, x->state_before());
861 info->set_force_reexecute();
862 } else {
863 info = state_for(x, x->state());
864 }
865
866 LIRItem length(x->length(), this);
1010 state_for(x, x->state_before(), true /*ignore_xhandler*/));
1011
1012 if (x->is_incompatible_class_change_check()) {
1013 assert(patching_info == nullptr, "can't patch this");
1014 stub = new SimpleExceptionStub(StubId::c1_throw_incompatible_class_change_error_id,
1015 LIR_OprFact::illegalOpr, info_for_exception);
1016 } else if (x->is_invokespecial_receiver_check()) {
1017 assert(patching_info == nullptr, "can't patch this");
1018 stub = new DeoptimizeStub(info_for_exception,
1019 Deoptimization::Reason_class_check,
1020 Deoptimization::Action_none);
1021 } else {
1022 stub = new SimpleExceptionStub(StubId::c1_throw_class_cast_exception_id, obj.result(), info_for_exception);
1023 }
1024 // Following registers are used by slow_subtype_check:
1025 LIR_Opr tmp1 = FrameMap::R4_oop_opr; // super_klass
1026 LIR_Opr tmp2 = FrameMap::R5_oop_opr; // sub_klass
1027 LIR_Opr tmp3 = FrameMap::R6_oop_opr; // temp
1028 __ checkcast(out_reg, obj.result(), x->klass(), tmp1, tmp2, tmp3,
1029 x->direct_compare(), info_for_exception, patching_info, stub,
1030 x->profiled_method(), x->profiled_bci());
1031 }
1032
1033
1034 void LIRGenerator::do_InstanceOf(InstanceOf* x) {
1035 LIRItem obj(x->obj(), this);
1036 CodeEmitInfo* patching_info = nullptr;
1037 if (!x->klass()->is_loaded() || PatchALot) {
1038 patching_info = state_for(x, x->state_before());
1039 }
1040 // Ensure the result register is not the input register because the
1041 // result is initialized before the patching safepoint.
1042 obj.load_item();
1043 LIR_Opr out_reg = rlock_result(x);
1044 // Following registers are used by slow_subtype_check:
1045 LIR_Opr tmp1 = FrameMap::R4_oop_opr; // super_klass
1046 LIR_Opr tmp2 = FrameMap::R5_oop_opr; // sub_klass
1047 LIR_Opr tmp3 = FrameMap::R6_oop_opr; // temp
1048 __ instanceof(out_reg, obj.result(), x->klass(), tmp1, tmp2, tmp3,
1049 x->direct_compare(), patching_info,
1050 x->profiled_method(), x->profiled_bci());
|
1 /*
2 * Copyright (c) 2005, 2026, Oracle and/or its affiliates. All rights reserved.
3 * Copyright (c) 2012, 2024 SAP SE. All rights reserved.
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
6 * This code is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 only, as
8 * published by the Free Software Foundation.
9 *
10 * This code is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * version 2 for more details (a copy is included in the LICENSE file that
14 * accompanied this code).
15 *
16 * You should have received a copy of the GNU General Public License version
17 * 2 along with this work; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21 * or visit www.oracle.com if you need additional information or have any
22 * questions.
826 default: break;
827 }
828 __ convert(x->op(), value.result(), reg);
829 }
830
831
832 void LIRGenerator::do_NewInstance(NewInstance* x) {
833 // This instruction can be deoptimized in the slow path.
834 const LIR_Opr reg = result_register_for(x->type());
835 #ifndef PRODUCT
836 if (PrintNotLoaded && !x->klass()->is_loaded()) {
837 tty->print_cr(" ###class not loaded at new bci %d", x->printable_bci());
838 }
839 #endif
840 CodeEmitInfo* info = state_for(x, x->state());
841 LIR_Opr klass_reg = FrameMap::R4_metadata_opr; // Used by slow path (NewInstanceStub).
842 LIR_Opr tmp1 = FrameMap::R5_oop_opr;
843 LIR_Opr tmp2 = FrameMap::R6_oop_opr;
844 LIR_Opr tmp3 = FrameMap::R7_oop_opr;
845 LIR_Opr tmp4 = FrameMap::R8_oop_opr;
846 new_instance(reg, x->klass(), x->is_unresolved(), /* allow_inline */ false, tmp1, tmp2, tmp3, tmp4, klass_reg, info);
847
848 // Must prevent reordering of stores for object initialization
849 // with stores that publish the new object.
850 __ membar_storestore();
851 LIR_Opr result = rlock_result(x);
852 __ move(reg, result);
853 }
854
855
856 void LIRGenerator::do_NewTypeArray(NewTypeArray* x) {
857 // Evaluate state_for early since it may emit code.
858 CodeEmitInfo* info = nullptr;
859 if (x->state_before() != nullptr && x->state_before()->force_reexecute()) {
860 info = state_for(x, x->state_before());
861 info->set_force_reexecute();
862 } else {
863 info = state_for(x, x->state());
864 }
865
866 LIRItem length(x->length(), this);
1010 state_for(x, x->state_before(), true /*ignore_xhandler*/));
1011
1012 if (x->is_incompatible_class_change_check()) {
1013 assert(patching_info == nullptr, "can't patch this");
1014 stub = new SimpleExceptionStub(StubId::c1_throw_incompatible_class_change_error_id,
1015 LIR_OprFact::illegalOpr, info_for_exception);
1016 } else if (x->is_invokespecial_receiver_check()) {
1017 assert(patching_info == nullptr, "can't patch this");
1018 stub = new DeoptimizeStub(info_for_exception,
1019 Deoptimization::Reason_class_check,
1020 Deoptimization::Action_none);
1021 } else {
1022 stub = new SimpleExceptionStub(StubId::c1_throw_class_cast_exception_id, obj.result(), info_for_exception);
1023 }
1024 // Following registers are used by slow_subtype_check:
1025 LIR_Opr tmp1 = FrameMap::R4_oop_opr; // super_klass
1026 LIR_Opr tmp2 = FrameMap::R5_oop_opr; // sub_klass
1027 LIR_Opr tmp3 = FrameMap::R6_oop_opr; // temp
1028 __ checkcast(out_reg, obj.result(), x->klass(), tmp1, tmp2, tmp3,
1029 x->direct_compare(), info_for_exception, patching_info, stub,
1030 x->profiled_method(), x->profiled_bci(), /*is_null_free*/ false);
1031 }
1032
1033
1034 void LIRGenerator::do_InstanceOf(InstanceOf* x) {
1035 LIRItem obj(x->obj(), this);
1036 CodeEmitInfo* patching_info = nullptr;
1037 if (!x->klass()->is_loaded() || PatchALot) {
1038 patching_info = state_for(x, x->state_before());
1039 }
1040 // Ensure the result register is not the input register because the
1041 // result is initialized before the patching safepoint.
1042 obj.load_item();
1043 LIR_Opr out_reg = rlock_result(x);
1044 // Following registers are used by slow_subtype_check:
1045 LIR_Opr tmp1 = FrameMap::R4_oop_opr; // super_klass
1046 LIR_Opr tmp2 = FrameMap::R5_oop_opr; // sub_klass
1047 LIR_Opr tmp3 = FrameMap::R6_oop_opr; // temp
1048 __ instanceof(out_reg, obj.result(), x->klass(), tmp1, tmp2, tmp3,
1049 x->direct_compare(), patching_info,
1050 x->profiled_method(), x->profiled_bci());
|