1 /*
2 * Copyright (c) 2008, 2025, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
927 __ convert(x->op(), value.result(), reg);
928 return;
929 }
930 }
931
932 LIR_Opr result = call_runtime(x->value(), runtime_func, x->type(), nullptr);
933 set_result(x, result);
934 }
935
936
937 void LIRGenerator::do_NewInstance(NewInstance* x) {
938 print_if_not_loaded(x);
939
940 CodeEmitInfo* info = state_for(x, x->state());
941 LIR_Opr reg = result_register_for(x->type()); // R0 is required by runtime call in NewInstanceStub::emit_code
942 LIR_Opr klass_reg = FrameMap::R1_metadata_opr; // R1 is required by runtime call in NewInstanceStub::emit_code
943 LIR_Opr tmp1 = new_register(objectType);
944 LIR_Opr tmp2 = new_register(objectType);
945 LIR_Opr tmp3 = FrameMap::LR_oop_opr;
946
947 new_instance(reg, x->klass(), x->is_unresolved(), tmp1, tmp2, tmp3,
948 LIR_OprFact::illegalOpr, klass_reg, info);
949
950 LIR_Opr result = rlock_result(x);
951 __ move(reg, result);
952 }
953
954
955 void LIRGenerator::do_NewTypeArray(NewTypeArray* x) {
956 // Evaluate state_for() first, because it can emit code
957 // with the same fixed registers that are used here (R1, R2)
958 CodeEmitInfo* info = state_for(x, x->state());
959 LIRItem length(x->length(), this);
960
961 length.load_item_force(FrameMap::R2_opr); // R2 is required by runtime call in NewTypeArrayStub::emit_code
962 LIR_Opr len = length.result();
963
964 LIR_Opr reg = result_register_for(x->type()); // R0 is required by runtime call in NewTypeArrayStub::emit_code
965 LIR_Opr klass_reg = FrameMap::R1_metadata_opr; // R1 is required by runtime call in NewTypeArrayStub::emit_code
966
967 LIR_Opr tmp1 = new_register(objectType);
1087 if (x->is_incompatible_class_change_check()) {
1088 assert(patching_info == nullptr, "can't patch this");
1089 stub = new SimpleExceptionStub(StubId::c1_throw_incompatible_class_change_error_id,
1090 LIR_OprFact::illegalOpr, info_for_exception);
1091 } else if (x->is_invokespecial_receiver_check()) {
1092 assert(patching_info == nullptr, "can't patch this");
1093 stub = new DeoptimizeStub(info_for_exception,
1094 Deoptimization::Reason_class_check,
1095 Deoptimization::Action_none);
1096 } else {
1097 stub = new SimpleExceptionStub(StubId::c1_throw_class_cast_exception_id,
1098 LIR_OprFact::illegalOpr, info_for_exception);
1099 }
1100
1101 LIR_Opr out_reg = rlock_result(x);
1102 LIR_Opr tmp1 = FrameMap::R0_oop_opr;
1103 LIR_Opr tmp2 = FrameMap::R1_oop_opr;
1104 LIR_Opr tmp3 = LIR_OprFact::illegalOpr;
1105
1106 __ checkcast(out_reg, obj.result(), x->klass(), tmp1, tmp2, tmp3, x->direct_compare(),
1107 info_for_exception, patching_info, stub, x->profiled_method(), x->profiled_bci());
1108 }
1109
1110
1111 void LIRGenerator::do_InstanceOf(InstanceOf* x) {
1112 LIRItem obj(x->obj(), this);
1113 CodeEmitInfo* patching_info = nullptr;
1114 if (!x->klass()->is_loaded() || PatchALot) {
1115 patching_info = state_for(x, x->state_before());
1116 }
1117
1118 obj.load_item();
1119 LIR_Opr out_reg = rlock_result(x);
1120 LIR_Opr tmp1 = FrameMap::R0_oop_opr;
1121 LIR_Opr tmp2 = FrameMap::R1_oop_opr;
1122 LIR_Opr tmp3 = LIR_OprFact::illegalOpr;
1123
1124 __ instanceof(out_reg, obj.result(), x->klass(), tmp1, tmp2, tmp3,
1125 x->direct_compare(), patching_info, x->profiled_method(), x->profiled_bci());
1126 }
1127
|
1 /*
2 * Copyright (c) 2008, 2026, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
927 __ convert(x->op(), value.result(), reg);
928 return;
929 }
930 }
931
932 LIR_Opr result = call_runtime(x->value(), runtime_func, x->type(), nullptr);
933 set_result(x, result);
934 }
935
936
937 void LIRGenerator::do_NewInstance(NewInstance* x) {
938 print_if_not_loaded(x);
939
940 CodeEmitInfo* info = state_for(x, x->state());
941 LIR_Opr reg = result_register_for(x->type()); // R0 is required by runtime call in NewInstanceStub::emit_code
942 LIR_Opr klass_reg = FrameMap::R1_metadata_opr; // R1 is required by runtime call in NewInstanceStub::emit_code
943 LIR_Opr tmp1 = new_register(objectType);
944 LIR_Opr tmp2 = new_register(objectType);
945 LIR_Opr tmp3 = FrameMap::LR_oop_opr;
946
947 new_instance(reg, x->klass(), x->is_unresolved(), /* allow_inline */ false, tmp1, tmp2, tmp3,
948 LIR_OprFact::illegalOpr, klass_reg, info);
949
950 LIR_Opr result = rlock_result(x);
951 __ move(reg, result);
952 }
953
954
955 void LIRGenerator::do_NewTypeArray(NewTypeArray* x) {
956 // Evaluate state_for() first, because it can emit code
957 // with the same fixed registers that are used here (R1, R2)
958 CodeEmitInfo* info = state_for(x, x->state());
959 LIRItem length(x->length(), this);
960
961 length.load_item_force(FrameMap::R2_opr); // R2 is required by runtime call in NewTypeArrayStub::emit_code
962 LIR_Opr len = length.result();
963
964 LIR_Opr reg = result_register_for(x->type()); // R0 is required by runtime call in NewTypeArrayStub::emit_code
965 LIR_Opr klass_reg = FrameMap::R1_metadata_opr; // R1 is required by runtime call in NewTypeArrayStub::emit_code
966
967 LIR_Opr tmp1 = new_register(objectType);
1087 if (x->is_incompatible_class_change_check()) {
1088 assert(patching_info == nullptr, "can't patch this");
1089 stub = new SimpleExceptionStub(StubId::c1_throw_incompatible_class_change_error_id,
1090 LIR_OprFact::illegalOpr, info_for_exception);
1091 } else if (x->is_invokespecial_receiver_check()) {
1092 assert(patching_info == nullptr, "can't patch this");
1093 stub = new DeoptimizeStub(info_for_exception,
1094 Deoptimization::Reason_class_check,
1095 Deoptimization::Action_none);
1096 } else {
1097 stub = new SimpleExceptionStub(StubId::c1_throw_class_cast_exception_id,
1098 LIR_OprFact::illegalOpr, info_for_exception);
1099 }
1100
1101 LIR_Opr out_reg = rlock_result(x);
1102 LIR_Opr tmp1 = FrameMap::R0_oop_opr;
1103 LIR_Opr tmp2 = FrameMap::R1_oop_opr;
1104 LIR_Opr tmp3 = LIR_OprFact::illegalOpr;
1105
1106 __ checkcast(out_reg, obj.result(), x->klass(), tmp1, tmp2, tmp3, x->direct_compare(),
1107 info_for_exception, patching_info, stub,
1108 x->profiled_method(), x->profiled_bci(), /*is_null_free*/ false);
1109 }
1110
1111
1112 void LIRGenerator::do_InstanceOf(InstanceOf* x) {
1113 LIRItem obj(x->obj(), this);
1114 CodeEmitInfo* patching_info = nullptr;
1115 if (!x->klass()->is_loaded() || PatchALot) {
1116 patching_info = state_for(x, x->state_before());
1117 }
1118
1119 obj.load_item();
1120 LIR_Opr out_reg = rlock_result(x);
1121 LIR_Opr tmp1 = FrameMap::R0_oop_opr;
1122 LIR_Opr tmp2 = FrameMap::R1_oop_opr;
1123 LIR_Opr tmp3 = LIR_OprFact::illegalOpr;
1124
1125 __ instanceof(out_reg, obj.result(), x->klass(), tmp1, tmp2, tmp3,
1126 x->direct_compare(), patching_info, x->profiled_method(), x->profiled_bci());
1127 }
1128
|