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.
23 *
24 */
25
26 #include "asm/macroAssembler.inline.hpp"
27 #include "c1/c1_Compilation.hpp"
28 #include "c1/c1_FrameMap.hpp"
29 #include "c1/c1_Instruction.hpp"
30 #include "c1/c1_LIRAssembler.hpp"
31 #include "c1/c1_LIRGenerator.hpp"
32 #include "c1/c1_Runtime1.hpp"
33 #include "c1/c1_ValueStack.hpp"
34 #include "ci/ciArray.hpp"
35 #include "ci/ciObjArrayKlass.hpp"
36 #include "ci/ciTypeArrayKlass.hpp"
37 #include "runtime/sharedRuntime.hpp"
38 #include "runtime/stubRoutines.hpp"
39 #include "runtime/vm_version.hpp"
40 #include "utilities/powerOfTwo.hpp"
41 #include "vmreg_ppc.inline.hpp"
42 #include <stdint.h>
43
44 #ifdef ASSERT
45 #define __ gen()->lir(__FILE__, __LINE__)->
46 #else
47 #define __ gen()->lir()->
48 #endif
49
50 void LIRItem::load_byte_item() {
51 // Byte loads use same registers as other loads.
52 load_item();
53 }
54
334 }
335
336
337 void LIRGenerator::do_MonitorEnter(MonitorEnter* x) {
338 assert(x->is_pinned(),"");
339 LIRItem obj(x->obj(), this);
340 obj.load_item();
341
342 set_no_result(x);
343
344 // We use R4+R5 in order to get a temp effect. These regs are used in slow path (MonitorEnterStub).
345 LIR_Opr lock = FrameMap::R5_opr;
346 LIR_Opr scratch = FrameMap::R4_opr;
347 LIR_Opr hdr = FrameMap::R6_opr;
348
349 CodeEmitInfo* info_for_exception = nullptr;
350 if (x->needs_null_check()) {
351 info_for_exception = state_for(x);
352 }
353
354 // This CodeEmitInfo must not have the xhandlers because here the
355 // object is already locked (xhandlers expects object to be unlocked).
356 CodeEmitInfo* info = state_for(x, x->state(), true);
357 monitor_enter(obj.result(), lock, hdr, scratch, x->monitor_no(), info_for_exception, info);
358 }
359
360
361 void LIRGenerator::do_MonitorExit(MonitorExit* x) {
362 assert(x->is_pinned(),"");
363 LIRItem obj(x->obj(), this);
364 obj.dont_load_item();
365
366 set_no_result(x);
367 LIR_Opr lock = FrameMap::R5_opr;
368 LIR_Opr hdr = FrameMap::R4_opr; // Used for slow path (MonitorExitStub).
369 LIR_Opr obj_temp = FrameMap::R6_opr;
370 monitor_exit(obj_temp, lock, hdr, LIR_OprFact::illegalOpr, x->monitor_no());
371 }
372
373
374 // _ineg, _lneg, _fneg, _dneg
375 void LIRGenerator::do_NegateOp(NegateOp* x) {
376 LIRItem value(x->x(), this);
377 value.load_item();
815 value.load_item();
816 switch (x->op()) {
817 case Bytecodes::_f2l:
818 case Bytecodes::_d2l:
819 case Bytecodes::_f2i:
820 case Bytecodes::_d2i: value.set_destroys_register(); break; // USE_KILL
821 default: break;
822 }
823 __ convert(x->op(), value.result(), reg);
824 }
825
826
827 void LIRGenerator::do_NewInstance(NewInstance* x) {
828 // This instruction can be deoptimized in the slow path.
829 const LIR_Opr reg = result_register_for(x->type());
830 #ifndef PRODUCT
831 if (PrintNotLoaded && !x->klass()->is_loaded()) {
832 tty->print_cr(" ###class not loaded at new bci %d", x->printable_bci());
833 }
834 #endif
835 CodeEmitInfo* info = state_for(x, x->state());
836 LIR_Opr klass_reg = FrameMap::R4_metadata_opr; // Used by slow path (NewInstanceStub).
837 LIR_Opr tmp1 = FrameMap::R5_oop_opr;
838 LIR_Opr tmp2 = FrameMap::R6_oop_opr;
839 LIR_Opr tmp3 = FrameMap::R7_oop_opr;
840 LIR_Opr tmp4 = FrameMap::R8_oop_opr;
841 new_instance(reg, x->klass(), x->is_unresolved(), tmp1, tmp2, tmp3, tmp4, klass_reg, info);
842
843 // Must prevent reordering of stores for object initialization
844 // with stores that publish the new object.
845 __ membar_storestore();
846 LIR_Opr result = rlock_result(x);
847 __ move(reg, result);
848 }
849
850
851 void LIRGenerator::do_NewTypeArray(NewTypeArray* x) {
852 // Evaluate state_for early since it may emit code.
853 CodeEmitInfo* info = nullptr;
854 if (x->state_before() != nullptr && x->state_before()->force_reexecute()) {
855 info = state_for(x, x->state_before());
856 info->set_force_reexecute();
857 } else {
858 info = state_for(x, x->state());
859 }
860
861 LIRItem length(x->length(), this);
890 // In case of patching (i.e., object class is not yet loaded),
891 // we need to reexecute the instruction and therefore provide
892 // the state before the parameters have been consumed.
893 CodeEmitInfo* patching_info = nullptr;
894 if (!x->klass()->is_loaded() || PatchALot) {
895 patching_info = state_for(x, x->state_before());
896 }
897
898 LIRItem length(x->length(), this);
899 length.load_item();
900
901 const LIR_Opr reg = result_register_for(x->type());
902 LIR_Opr klass_reg = FrameMap::R4_metadata_opr; // Used by slow path (NewObjectArrayStub).
903 // We use R5 in order to get a temp effect. This reg is used in slow path (NewObjectArrayStub).
904 LIR_Opr tmp1 = FrameMap::R5_oop_opr;
905 LIR_Opr tmp2 = FrameMap::R6_oop_opr;
906 LIR_Opr tmp3 = FrameMap::R7_oop_opr;
907 LIR_Opr tmp4 = FrameMap::R8_oop_opr;
908 LIR_Opr len = length.result();
909
910 CodeStub* slow_path = new NewObjectArrayStub(klass_reg, len, reg, info);
911 ciMetadata* obj = ciObjArrayKlass::make(x->klass());
912 if (obj == ciEnv::unloaded_ciobjarrayklass()) {
913 BAILOUT("encountered unloaded_ciobjarrayklass due to out of memory error");
914 }
915 klass2reg_with_patching(klass_reg, obj, patching_info);
916 __ allocate_array(reg, len, tmp1, tmp2, tmp3, tmp4, T_OBJECT, klass_reg, slow_path);
917
918 // Must prevent reordering of stores for object initialization
919 // with stores that publish the new object.
920 __ membar_storestore();
921 LIR_Opr result = rlock_result(x);
922 __ move(reg, result);
923 }
924
925
926 void LIRGenerator::do_NewMultiArray(NewMultiArray* x) {
927 Values* dims = x->dims();
928 int i = dims->length();
929 LIRItemList* items = new LIRItemList(i, i, nullptr);
930 while (i-- > 0) {
931 LIRItem* size = new LIRItem(dims->at(i), this);
932 items->at_put(i, size);
933 }
934
935 // Evaluate state_for early since it may emit code.
936 CodeEmitInfo* patching_info = nullptr;
1005 state_for(x, x->state_before(), true /*ignore_xhandler*/));
1006
1007 if (x->is_incompatible_class_change_check()) {
1008 assert(patching_info == nullptr, "can't patch this");
1009 stub = new SimpleExceptionStub(StubId::c1_throw_incompatible_class_change_error_id,
1010 LIR_OprFact::illegalOpr, info_for_exception);
1011 } else if (x->is_invokespecial_receiver_check()) {
1012 assert(patching_info == nullptr, "can't patch this");
1013 stub = new DeoptimizeStub(info_for_exception,
1014 Deoptimization::Reason_class_check,
1015 Deoptimization::Action_none);
1016 } else {
1017 stub = new SimpleExceptionStub(StubId::c1_throw_class_cast_exception_id, obj.result(), info_for_exception);
1018 }
1019 // Following registers are used by slow_subtype_check:
1020 LIR_Opr tmp1 = FrameMap::R4_oop_opr; // super_klass
1021 LIR_Opr tmp2 = FrameMap::R5_oop_opr; // sub_klass
1022 LIR_Opr tmp3 = FrameMap::R6_oop_opr; // temp
1023 __ checkcast(out_reg, obj.result(), x->klass(), tmp1, tmp2, tmp3,
1024 x->direct_compare(), info_for_exception, patching_info, stub,
1025 x->profiled_method(), x->profiled_bci());
1026 }
1027
1028
1029 void LIRGenerator::do_InstanceOf(InstanceOf* x) {
1030 LIRItem obj(x->obj(), this);
1031 CodeEmitInfo* patching_info = nullptr;
1032 if (!x->klass()->is_loaded() || PatchALot) {
1033 patching_info = state_for(x, x->state_before());
1034 }
1035 // Ensure the result register is not the input register because the
1036 // result is initialized before the patching safepoint.
1037 obj.load_item();
1038 LIR_Opr out_reg = rlock_result(x);
1039 // Following registers are used by slow_subtype_check:
1040 LIR_Opr tmp1 = FrameMap::R4_oop_opr; // super_klass
1041 LIR_Opr tmp2 = FrameMap::R5_oop_opr; // sub_klass
1042 LIR_Opr tmp3 = FrameMap::R6_oop_opr; // temp
1043 __ instanceof(out_reg, obj.result(), x->klass(), tmp1, tmp2, tmp3,
1044 x->direct_compare(), patching_info,
1045 x->profiled_method(), x->profiled_bci());
1050 address LIRGenerator::isInstance_entry() {
1051 return Runtime1::entry_for(StubId::c1_is_instance_of_id);
1052 }
1053
1054
1055 void LIRGenerator::do_If(If* x) {
1056 assert(x->number_of_sux() == 2, "inconsistency");
1057 ValueTag tag = x->x()->type()->tag();
1058 LIRItem xitem(x->x(), this);
1059 LIRItem yitem(x->y(), this);
1060 LIRItem* xin = &xitem;
1061 LIRItem* yin = &yitem;
1062 If::Condition cond = x->cond();
1063
1064 LIR_Opr left = LIR_OprFact::illegalOpr;
1065 LIR_Opr right = LIR_OprFact::illegalOpr;
1066
1067 xin->load_item();
1068 left = xin->result();
1069
1070 if (yin->result()->is_constant() && yin->result()->type() == T_INT &&
1071 Assembler::is_simm16(yin->result()->as_constant_ptr()->as_jint())) {
1072 // Inline int constants which are small enough to be immediate operands.
1073 right = LIR_OprFact::value_type(yin->value()->type());
1074 } else if (tag == longTag && yin->is_constant() && yin->get_jlong_constant() == 0 &&
1075 (cond == If::eql || cond == If::neq)) {
1076 // Inline long zero.
1077 right = LIR_OprFact::value_type(yin->value()->type());
1078 } else if (tag == objectTag && yin->is_constant() && (yin->get_jobject_constant()->is_null_object())) {
1079 right = LIR_OprFact::value_type(yin->value()->type());
1080 } else {
1081 yin->load_item();
1082 right = yin->result();
1083 }
1084 set_no_result(x);
1085
1086 // Add safepoint before generating condition code so it can be recomputed.
1087 if (x->is_safepoint()) {
1088 // Increment backedge counter if needed.
1089 increment_backedge_counter_conditionally(lir_cond(cond), left, right, state_for(x, x->state_before()),
1090 x->tsux()->bci(), x->fsux()->bci(), x->profiled_bci());
1091 __ safepoint(safepoint_poll_register(), state_for(x, x->state_before()));
1092 }
1093
1094 __ cmp(lir_cond(cond), left, right);
1095 // Generate branch profiling. Profiling code doesn't kill flags.
1096 profile_branch(x, cond);
1097 move_to_phi(x->state());
1098 if (x->x()->type()->is_float_kind()) {
1099 __ branch(lir_cond(cond), x->tsux(), x->usux());
1100 } else {
1101 __ branch(lir_cond(cond), x->tsux());
1102 }
1103 assert(x->default_sux() == x->fsux(), "wrong destination above");
1104 __ jump(x->default_sux());
1105 }
1106
1107
1108 LIR_Opr LIRGenerator::getThreadPointer() {
1109 return FrameMap::as_pointer_opr(R16_thread);
1110 }
1111
1112
1113 void LIRGenerator::trace_block_entry(BlockBegin* block) {
1114 LIR_Opr arg1 = FrameMap::R3_opr; // ARG1
|
1 /*
2 * Copyright (c) 2005, 2026, Oracle and/or its affiliates. All rights reserved.
3 * Copyright (c) 2012, 2026 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.
23 *
24 */
25
26 #include "asm/macroAssembler.inline.hpp"
27 #include "c1/c1_Compilation.hpp"
28 #include "c1/c1_FrameMap.hpp"
29 #include "c1/c1_Instruction.hpp"
30 #include "c1/c1_LIRAssembler.hpp"
31 #include "c1/c1_LIRGenerator.hpp"
32 #include "c1/c1_Runtime1.hpp"
33 #include "c1/c1_ValueStack.hpp"
34 #include "ci/ciArray.hpp"
35 #include "ci/ciInlineKlass.hpp"
36 #include "ci/ciObjArrayKlass.hpp"
37 #include "ci/ciTypeArrayKlass.hpp"
38 #include "runtime/sharedRuntime.hpp"
39 #include "runtime/stubRoutines.hpp"
40 #include "runtime/vm_version.hpp"
41 #include "utilities/powerOfTwo.hpp"
42 #include "vmreg_ppc.inline.hpp"
43 #include <stdint.h>
44
45 #ifdef ASSERT
46 #define __ gen()->lir(__FILE__, __LINE__)->
47 #else
48 #define __ gen()->lir()->
49 #endif
50
51 void LIRItem::load_byte_item() {
52 // Byte loads use same registers as other loads.
53 load_item();
54 }
55
335 }
336
337
338 void LIRGenerator::do_MonitorEnter(MonitorEnter* x) {
339 assert(x->is_pinned(),"");
340 LIRItem obj(x->obj(), this);
341 obj.load_item();
342
343 set_no_result(x);
344
345 // We use R4+R5 in order to get a temp effect. These regs are used in slow path (MonitorEnterStub).
346 LIR_Opr lock = FrameMap::R5_opr;
347 LIR_Opr scratch = FrameMap::R4_opr;
348 LIR_Opr hdr = FrameMap::R6_opr;
349
350 CodeEmitInfo* info_for_exception = nullptr;
351 if (x->needs_null_check()) {
352 info_for_exception = state_for(x);
353 }
354
355 CodeStub* throw_ie_stub =
356 x->maybe_inlinetype() ?
357 new SimpleExceptionStub(StubId::c1_throw_identity_exception_id, obj.result(), state_for(x)) :
358 nullptr;
359
360 // This CodeEmitInfo must not have the xhandlers because here the
361 // object is already locked (xhandlers expects object to be unlocked).
362 CodeEmitInfo* info = state_for(x, x->state(), true);
363 monitor_enter(obj.result(), lock, hdr, scratch, x->monitor_no(), info_for_exception, info, throw_ie_stub);
364 }
365
366
367 void LIRGenerator::do_MonitorExit(MonitorExit* x) {
368 assert(x->is_pinned(),"");
369 LIRItem obj(x->obj(), this);
370 obj.dont_load_item();
371
372 set_no_result(x);
373 LIR_Opr lock = FrameMap::R5_opr;
374 LIR_Opr hdr = FrameMap::R4_opr; // Used for slow path (MonitorExitStub).
375 LIR_Opr obj_temp = FrameMap::R6_opr;
376 monitor_exit(obj_temp, lock, hdr, LIR_OprFact::illegalOpr, x->monitor_no());
377 }
378
379
380 // _ineg, _lneg, _fneg, _dneg
381 void LIRGenerator::do_NegateOp(NegateOp* x) {
382 LIRItem value(x->x(), this);
383 value.load_item();
821 value.load_item();
822 switch (x->op()) {
823 case Bytecodes::_f2l:
824 case Bytecodes::_d2l:
825 case Bytecodes::_f2i:
826 case Bytecodes::_d2i: value.set_destroys_register(); break; // USE_KILL
827 default: break;
828 }
829 __ convert(x->op(), value.result(), reg);
830 }
831
832
833 void LIRGenerator::do_NewInstance(NewInstance* x) {
834 // This instruction can be deoptimized in the slow path.
835 const LIR_Opr reg = result_register_for(x->type());
836 #ifndef PRODUCT
837 if (PrintNotLoaded && !x->klass()->is_loaded()) {
838 tty->print_cr(" ###class not loaded at new bci %d", x->printable_bci());
839 }
840 #endif
841 CodeEmitInfo* info = state_for(x, x->needs_state_before() ? x->state_before() : x->state());
842 LIR_Opr klass_reg = FrameMap::R4_metadata_opr; // Used by slow path (NewInstanceStub).
843 LIR_Opr tmp1 = FrameMap::R5_oop_opr;
844 LIR_Opr tmp2 = FrameMap::R6_oop_opr;
845 LIR_Opr tmp3 = FrameMap::R7_oop_opr;
846 LIR_Opr tmp4 = FrameMap::R8_oop_opr;
847 new_instance(reg, x->klass(), x->is_unresolved(), !x->is_unresolved() && x->klass()->is_inlinetype(),
848 tmp1, tmp2, tmp3, tmp4, klass_reg, info);
849
850 // Must prevent reordering of stores for object initialization
851 // with stores that publish the new object.
852 __ membar_storestore();
853 LIR_Opr result = rlock_result(x);
854 __ move(reg, result);
855 }
856
857
858 void LIRGenerator::do_NewTypeArray(NewTypeArray* x) {
859 // Evaluate state_for early since it may emit code.
860 CodeEmitInfo* info = nullptr;
861 if (x->state_before() != nullptr && x->state_before()->force_reexecute()) {
862 info = state_for(x, x->state_before());
863 info->set_force_reexecute();
864 } else {
865 info = state_for(x, x->state());
866 }
867
868 LIRItem length(x->length(), this);
897 // In case of patching (i.e., object class is not yet loaded),
898 // we need to reexecute the instruction and therefore provide
899 // the state before the parameters have been consumed.
900 CodeEmitInfo* patching_info = nullptr;
901 if (!x->klass()->is_loaded() || PatchALot) {
902 patching_info = state_for(x, x->state_before());
903 }
904
905 LIRItem length(x->length(), this);
906 length.load_item();
907
908 const LIR_Opr reg = result_register_for(x->type());
909 LIR_Opr klass_reg = FrameMap::R4_metadata_opr; // Used by slow path (NewObjectArrayStub).
910 // We use R5 in order to get a temp effect. This reg is used in slow path (NewObjectArrayStub).
911 LIR_Opr tmp1 = FrameMap::R5_oop_opr;
912 LIR_Opr tmp2 = FrameMap::R6_oop_opr;
913 LIR_Opr tmp3 = FrameMap::R7_oop_opr;
914 LIR_Opr tmp4 = FrameMap::R8_oop_opr;
915 LIR_Opr len = length.result();
916
917 ciKlass* obj = ciObjArrayKlass::make(x->klass());
918
919 // TODO 8265122 Implement a fast path for this
920 bool is_flat = obj->is_loaded() && obj->is_flat_array_klass();
921 bool is_null_free = obj->is_loaded() && obj->as_array_klass()->is_elem_null_free();
922
923 CodeStub* slow_path = new NewObjectArrayStub(klass_reg, len, reg, info, is_null_free);
924 if (obj == ciEnv::unloaded_ciobjarrayklass()) {
925 BAILOUT("encountered unloaded_ciobjarrayklass due to out of memory error");
926 }
927 klass2reg_with_patching(klass_reg, obj, patching_info);
928 bool always_slow_path = is_null_free || is_flat;
929 __ allocate_array(reg, len, tmp1, tmp2, tmp3, tmp4, T_OBJECT, klass_reg, slow_path, true /*zero_array*/, always_slow_path);
930
931 // Must prevent reordering of stores for object initialization
932 // with stores that publish the new object.
933 __ membar_storestore();
934 LIR_Opr result = rlock_result(x);
935 __ move(reg, result);
936 }
937
938
939 void LIRGenerator::do_NewMultiArray(NewMultiArray* x) {
940 Values* dims = x->dims();
941 int i = dims->length();
942 LIRItemList* items = new LIRItemList(i, i, nullptr);
943 while (i-- > 0) {
944 LIRItem* size = new LIRItem(dims->at(i), this);
945 items->at_put(i, size);
946 }
947
948 // Evaluate state_for early since it may emit code.
949 CodeEmitInfo* patching_info = nullptr;
1018 state_for(x, x->state_before(), true /*ignore_xhandler*/));
1019
1020 if (x->is_incompatible_class_change_check()) {
1021 assert(patching_info == nullptr, "can't patch this");
1022 stub = new SimpleExceptionStub(StubId::c1_throw_incompatible_class_change_error_id,
1023 LIR_OprFact::illegalOpr, info_for_exception);
1024 } else if (x->is_invokespecial_receiver_check()) {
1025 assert(patching_info == nullptr, "can't patch this");
1026 stub = new DeoptimizeStub(info_for_exception,
1027 Deoptimization::Reason_class_check,
1028 Deoptimization::Action_none);
1029 } else {
1030 stub = new SimpleExceptionStub(StubId::c1_throw_class_cast_exception_id, obj.result(), info_for_exception);
1031 }
1032 // Following registers are used by slow_subtype_check:
1033 LIR_Opr tmp1 = FrameMap::R4_oop_opr; // super_klass
1034 LIR_Opr tmp2 = FrameMap::R5_oop_opr; // sub_klass
1035 LIR_Opr tmp3 = FrameMap::R6_oop_opr; // temp
1036 __ checkcast(out_reg, obj.result(), x->klass(), tmp1, tmp2, tmp3,
1037 x->direct_compare(), info_for_exception, patching_info, stub,
1038 x->profiled_method(), x->profiled_bci(), x->is_null_free());
1039 }
1040
1041
1042 void LIRGenerator::do_InstanceOf(InstanceOf* x) {
1043 LIRItem obj(x->obj(), this);
1044 CodeEmitInfo* patching_info = nullptr;
1045 if (!x->klass()->is_loaded() || PatchALot) {
1046 patching_info = state_for(x, x->state_before());
1047 }
1048 // Ensure the result register is not the input register because the
1049 // result is initialized before the patching safepoint.
1050 obj.load_item();
1051 LIR_Opr out_reg = rlock_result(x);
1052 // Following registers are used by slow_subtype_check:
1053 LIR_Opr tmp1 = FrameMap::R4_oop_opr; // super_klass
1054 LIR_Opr tmp2 = FrameMap::R5_oop_opr; // sub_klass
1055 LIR_Opr tmp3 = FrameMap::R6_oop_opr; // temp
1056 __ instanceof(out_reg, obj.result(), x->klass(), tmp1, tmp2, tmp3,
1057 x->direct_compare(), patching_info,
1058 x->profiled_method(), x->profiled_bci());
1063 address LIRGenerator::isInstance_entry() {
1064 return Runtime1::entry_for(StubId::c1_is_instance_of_id);
1065 }
1066
1067
1068 void LIRGenerator::do_If(If* x) {
1069 assert(x->number_of_sux() == 2, "inconsistency");
1070 ValueTag tag = x->x()->type()->tag();
1071 LIRItem xitem(x->x(), this);
1072 LIRItem yitem(x->y(), this);
1073 LIRItem* xin = &xitem;
1074 LIRItem* yin = &yitem;
1075 If::Condition cond = x->cond();
1076
1077 LIR_Opr left = LIR_OprFact::illegalOpr;
1078 LIR_Opr right = LIR_OprFact::illegalOpr;
1079
1080 xin->load_item();
1081 left = xin->result();
1082
1083 if (yin->result()->is_constant() && !x->substitutability_check()) {
1084 if (yin->result()->type() == T_INT &&
1085 Assembler::is_simm16(yin->result()->as_constant_ptr()->as_jint())) {
1086 // Inline int constants which are small enough to be immediate operands.
1087 right = LIR_OprFact::value_type(yin->value()->type());
1088 } else if (tag == longTag && yin->get_jlong_constant() == 0 &&
1089 (cond == If::eql || cond == If::neq)) {
1090 // Inline long zero.
1091 right = LIR_OprFact::value_type(yin->value()->type());
1092 } else if (tag == objectTag && (yin->get_jobject_constant()->is_null_object())) {
1093 right = LIR_OprFact::value_type(yin->value()->type());
1094 }
1095 }
1096
1097 if (right == LIR_OprFact::illegalOpr) {
1098 yin->load_item();
1099 right = yin->result();
1100 }
1101 set_no_result(x);
1102
1103 // Add safepoint before generating condition code so it can be recomputed.
1104 if (x->is_safepoint()) {
1105 // Increment backedge counter if needed.
1106 increment_backedge_counter_conditionally(lir_cond(cond), left, right, state_for(x, x->state_before()),
1107 x->tsux()->bci(), x->fsux()->bci(), x->profiled_bci());
1108 __ safepoint(safepoint_poll_register(), state_for(x, x->state_before()));
1109 }
1110
1111 if (x->substitutability_check()) {
1112 substitutability_check(x, *xin, *yin);
1113 } else {
1114 __ cmp(lir_cond(cond), left, right);
1115 }
1116
1117 // Generate branch profiling. Profiling code doesn't kill flags.
1118 profile_branch(x, cond);
1119 move_to_phi(x->state());
1120 if (x->x()->type()->is_float_kind()) {
1121 __ branch(lir_cond(cond), x->tsux(), x->usux());
1122 } else {
1123 __ branch(lir_cond(cond), x->tsux());
1124 }
1125 assert(x->default_sux() == x->fsux(), "wrong destination above");
1126 __ jump(x->default_sux());
1127 }
1128
1129
1130 LIR_Opr LIRGenerator::getThreadPointer() {
1131 return FrameMap::as_pointer_opr(R16_thread);
1132 }
1133
1134
1135 void LIRGenerator::trace_block_entry(BlockBegin* block) {
1136 LIR_Opr arg1 = FrameMap::R3_opr; // ARG1
|