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();
820 value.load_item();
821 switch (x->op()) {
822 case Bytecodes::_f2l:
823 case Bytecodes::_d2l:
824 case Bytecodes::_f2i:
825 case Bytecodes::_d2i: value.set_destroys_register(); break; // USE_KILL
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);
895 // In case of patching (i.e., object class is not yet loaded),
896 // we need to reexecute the instruction and therefore provide
897 // the state before the parameters have been consumed.
898 CodeEmitInfo* patching_info = nullptr;
899 if (!x->klass()->is_loaded() || PatchALot) {
900 patching_info = state_for(x, x->state_before());
901 }
902
903 LIRItem length(x->length(), this);
904 length.load_item();
905
906 const LIR_Opr reg = result_register_for(x->type());
907 LIR_Opr klass_reg = FrameMap::R4_metadata_opr; // Used by slow path (NewObjectArrayStub).
908 // We use R5 in order to get a temp effect. This reg is used in slow path (NewObjectArrayStub).
909 LIR_Opr tmp1 = FrameMap::R5_oop_opr;
910 LIR_Opr tmp2 = FrameMap::R6_oop_opr;
911 LIR_Opr tmp3 = FrameMap::R7_oop_opr;
912 LIR_Opr tmp4 = FrameMap::R8_oop_opr;
913 LIR_Opr len = length.result();
914
915 CodeStub* slow_path = new NewObjectArrayStub(klass_reg, len, reg, info);
916 ciMetadata* obj = ciObjArrayKlass::make(x->klass());
917 if (obj == ciEnv::unloaded_ciobjarrayklass()) {
918 BAILOUT("encountered unloaded_ciobjarrayklass due to out of memory error");
919 }
920 klass2reg_with_patching(klass_reg, obj, patching_info);
921 __ allocate_array(reg, len, tmp1, tmp2, tmp3, tmp4, T_OBJECT, klass_reg, slow_path);
922
923 // Must prevent reordering of stores for object initialization
924 // with stores that publish the new object.
925 __ membar_storestore();
926 LIR_Opr result = rlock_result(x);
927 __ move(reg, result);
928 }
929
930
931 void LIRGenerator::do_NewMultiArray(NewMultiArray* x) {
932 Values* dims = x->dims();
933 int i = dims->length();
934 LIRItemList* items = new LIRItemList(i, i, nullptr);
935 while (i-- > 0) {
936 LIRItem* size = new LIRItem(dims->at(i), this);
937 items->at_put(i, size);
938 }
939
940 // Evaluate state_for early since it may emit code.
941 CodeEmitInfo* patching_info = nullptr;
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());
1055 address LIRGenerator::isInstance_entry() {
1056 return Runtime1::entry_for(StubId::c1_is_instance_of_id);
1057 }
1058
1059
1060 void LIRGenerator::do_If(If* x) {
1061 assert(x->number_of_sux() == 2, "inconsistency");
1062 ValueTag tag = x->x()->type()->tag();
1063 LIRItem xitem(x->x(), this);
1064 LIRItem yitem(x->y(), this);
1065 LIRItem* xin = &xitem;
1066 LIRItem* yin = &yitem;
1067 If::Condition cond = x->cond();
1068
1069 LIR_Opr left = LIR_OprFact::illegalOpr;
1070 LIR_Opr right = LIR_OprFact::illegalOpr;
1071
1072 xin->load_item();
1073 left = xin->result();
1074
1075 if (yin->result()->is_constant() && yin->result()->type() == T_INT &&
1076 Assembler::is_simm16(yin->result()->as_constant_ptr()->as_jint())) {
1077 // Inline int constants which are small enough to be immediate operands.
1078 right = LIR_OprFact::value_type(yin->value()->type());
1079 } else if (tag == longTag && yin->is_constant() && yin->get_jlong_constant() == 0 &&
1080 (cond == If::eql || cond == If::neq)) {
1081 // Inline long zero.
1082 right = LIR_OprFact::value_type(yin->value()->type());
1083 } else if (tag == objectTag && yin->is_constant() && (yin->get_jobject_constant()->is_null_object())) {
1084 right = LIR_OprFact::value_type(yin->value()->type());
1085 } else {
1086 yin->load_item();
1087 right = yin->result();
1088 }
1089 set_no_result(x);
1090
1091 // Add safepoint before generating condition code so it can be recomputed.
1092 if (x->is_safepoint()) {
1093 // Increment backedge counter if needed.
1094 increment_backedge_counter_conditionally(lir_cond(cond), left, right, state_for(x, x->state_before()),
1095 x->tsux()->bci(), x->fsux()->bci(), x->profiled_bci());
1096 __ safepoint(safepoint_poll_register(), state_for(x, x->state_before()));
1097 }
1098
1099 __ cmp(lir_cond(cond), left, right);
1100 // Generate branch profiling. Profiling code doesn't kill flags.
1101 profile_branch(x, cond);
1102 move_to_phi(x->state());
1103 if (x->x()->type()->is_float_kind()) {
1104 __ branch(lir_cond(cond), x->tsux(), x->usux());
1105 } else {
1106 __ branch(lir_cond(cond), x->tsux());
1107 }
1108 assert(x->default_sux() == x->fsux(), "wrong destination above");
1109 __ jump(x->default_sux());
1110 }
1111
1112
1113 LIR_Opr LIRGenerator::getThreadPointer() {
1114 return FrameMap::as_pointer_opr(R16_thread);
1115 }
1116
1117
1118 void LIRGenerator::trace_block_entry(BlockBegin* block) {
1119 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();
826 value.load_item();
827 switch (x->op()) {
828 case Bytecodes::_f2l:
829 case Bytecodes::_d2l:
830 case Bytecodes::_f2i:
831 case Bytecodes::_d2i: value.set_destroys_register(); break; // USE_KILL
832 default: break;
833 }
834 __ convert(x->op(), value.result(), reg);
835 }
836
837
838 void LIRGenerator::do_NewInstance(NewInstance* x) {
839 // This instruction can be deoptimized in the slow path.
840 const LIR_Opr reg = result_register_for(x->type());
841 #ifndef PRODUCT
842 if (PrintNotLoaded && !x->klass()->is_loaded()) {
843 tty->print_cr(" ###class not loaded at new bci %d", x->printable_bci());
844 }
845 #endif
846 CodeEmitInfo* info = state_for(x, x->needs_state_before() ? x->state_before() : x->state());
847 LIR_Opr klass_reg = FrameMap::R4_metadata_opr; // Used by slow path (NewInstanceStub).
848 LIR_Opr tmp1 = FrameMap::R5_oop_opr;
849 LIR_Opr tmp2 = FrameMap::R6_oop_opr;
850 LIR_Opr tmp3 = FrameMap::R7_oop_opr;
851 LIR_Opr tmp4 = FrameMap::R8_oop_opr;
852 new_instance(reg, x->klass(), x->is_unresolved(), !x->is_unresolved() && x->klass()->is_inlinetype(),
853 tmp1, tmp2, tmp3, tmp4, klass_reg, info);
854
855 // Must prevent reordering of stores for object initialization
856 // with stores that publish the new object.
857 __ membar_storestore();
858 LIR_Opr result = rlock_result(x);
859 __ move(reg, result);
860 }
861
862
863 void LIRGenerator::do_NewTypeArray(NewTypeArray* x) {
864 // Evaluate state_for early since it may emit code.
865 CodeEmitInfo* info = nullptr;
866 if (x->state_before() != nullptr && x->state_before()->force_reexecute()) {
867 info = state_for(x, x->state_before());
868 info->set_force_reexecute();
869 } else {
870 info = state_for(x, x->state());
871 }
872
873 LIRItem length(x->length(), this);
902 // In case of patching (i.e., object class is not yet loaded),
903 // we need to reexecute the instruction and therefore provide
904 // the state before the parameters have been consumed.
905 CodeEmitInfo* patching_info = nullptr;
906 if (!x->klass()->is_loaded() || PatchALot) {
907 patching_info = state_for(x, x->state_before());
908 }
909
910 LIRItem length(x->length(), this);
911 length.load_item();
912
913 const LIR_Opr reg = result_register_for(x->type());
914 LIR_Opr klass_reg = FrameMap::R4_metadata_opr; // Used by slow path (NewObjectArrayStub).
915 // We use R5 in order to get a temp effect. This reg is used in slow path (NewObjectArrayStub).
916 LIR_Opr tmp1 = FrameMap::R5_oop_opr;
917 LIR_Opr tmp2 = FrameMap::R6_oop_opr;
918 LIR_Opr tmp3 = FrameMap::R7_oop_opr;
919 LIR_Opr tmp4 = FrameMap::R8_oop_opr;
920 LIR_Opr len = length.result();
921
922 ciKlass* obj = ciObjArrayKlass::make(x->klass());
923
924 // TODO 8265122 Implement a fast path for this
925 bool is_flat = obj->is_loaded() && obj->is_flat_array_klass();
926 bool is_null_free = obj->is_loaded() && obj->as_array_klass()->is_elem_null_free();
927
928 CodeStub* slow_path = new NewObjectArrayStub(klass_reg, len, reg, info, is_null_free);
929 if (obj == ciEnv::unloaded_ciobjarrayklass()) {
930 BAILOUT("encountered unloaded_ciobjarrayklass due to out of memory error");
931 }
932 klass2reg_with_patching(klass_reg, obj, patching_info);
933 __ allocate_array(reg, len, tmp1, tmp2, tmp3, tmp4, T_OBJECT, klass_reg, slow_path, true, is_null_free || is_flat);
934
935 // Must prevent reordering of stores for object initialization
936 // with stores that publish the new object.
937 __ membar_storestore();
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(i, i, nullptr);
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* patching_info = nullptr;
1022 state_for(x, x->state_before(), true /*ignore_xhandler*/));
1023
1024 if (x->is_incompatible_class_change_check()) {
1025 assert(patching_info == nullptr, "can't patch this");
1026 stub = new SimpleExceptionStub(StubId::c1_throw_incompatible_class_change_error_id,
1027 LIR_OprFact::illegalOpr, info_for_exception);
1028 } else if (x->is_invokespecial_receiver_check()) {
1029 assert(patching_info == nullptr, "can't patch this");
1030 stub = new DeoptimizeStub(info_for_exception,
1031 Deoptimization::Reason_class_check,
1032 Deoptimization::Action_none);
1033 } else {
1034 stub = new SimpleExceptionStub(StubId::c1_throw_class_cast_exception_id, obj.result(), info_for_exception);
1035 }
1036 // Following registers are used by slow_subtype_check:
1037 LIR_Opr tmp1 = FrameMap::R4_oop_opr; // super_klass
1038 LIR_Opr tmp2 = FrameMap::R5_oop_opr; // sub_klass
1039 LIR_Opr tmp3 = FrameMap::R6_oop_opr; // temp
1040 __ checkcast(out_reg, obj.result(), x->klass(), tmp1, tmp2, tmp3,
1041 x->direct_compare(), info_for_exception, patching_info, stub,
1042 x->profiled_method(), x->profiled_bci(), x->is_null_free());
1043 }
1044
1045
1046 void LIRGenerator::do_InstanceOf(InstanceOf* x) {
1047 LIRItem obj(x->obj(), this);
1048 CodeEmitInfo* patching_info = nullptr;
1049 if (!x->klass()->is_loaded() || PatchALot) {
1050 patching_info = state_for(x, x->state_before());
1051 }
1052 // Ensure the result register is not the input register because the
1053 // result is initialized before the patching safepoint.
1054 obj.load_item();
1055 LIR_Opr out_reg = rlock_result(x);
1056 // Following registers are used by slow_subtype_check:
1057 LIR_Opr tmp1 = FrameMap::R4_oop_opr; // super_klass
1058 LIR_Opr tmp2 = FrameMap::R5_oop_opr; // sub_klass
1059 LIR_Opr tmp3 = FrameMap::R6_oop_opr; // temp
1060 __ instanceof(out_reg, obj.result(), x->klass(), tmp1, tmp2, tmp3,
1061 x->direct_compare(), patching_info,
1062 x->profiled_method(), x->profiled_bci());
1067 address LIRGenerator::isInstance_entry() {
1068 return Runtime1::entry_for(StubId::c1_is_instance_of_id);
1069 }
1070
1071
1072 void LIRGenerator::do_If(If* x) {
1073 assert(x->number_of_sux() == 2, "inconsistency");
1074 ValueTag tag = x->x()->type()->tag();
1075 LIRItem xitem(x->x(), this);
1076 LIRItem yitem(x->y(), this);
1077 LIRItem* xin = &xitem;
1078 LIRItem* yin = &yitem;
1079 If::Condition cond = x->cond();
1080
1081 LIR_Opr left = LIR_OprFact::illegalOpr;
1082 LIR_Opr right = LIR_OprFact::illegalOpr;
1083
1084 xin->load_item();
1085 left = xin->result();
1086
1087 if (yin->result()->is_constant() && !x->substitutability_check()) {
1088 if (yin->result()->type() == T_INT &&
1089 Assembler::is_simm16(yin->result()->as_constant_ptr()->as_jint())) {
1090 // Inline int constants which are small enough to be immediate operands.
1091 right = LIR_OprFact::value_type(yin->value()->type());
1092 } else if (tag == longTag && yin->get_jlong_constant() == 0 &&
1093 (cond == If::eql || cond == If::neq)) {
1094 // Inline long zero.
1095 right = LIR_OprFact::value_type(yin->value()->type());
1096 } else if (tag == objectTag && (yin->get_jobject_constant()->is_null_object())) {
1097 right = LIR_OprFact::value_type(yin->value()->type());
1098 }
1099 }
1100
1101 if (right == LIR_OprFact::illegalOpr) {
1102 yin->load_item();
1103 right = yin->result();
1104 }
1105 set_no_result(x);
1106
1107 // Add safepoint before generating condition code so it can be recomputed.
1108 if (x->is_safepoint()) {
1109 // Increment backedge counter if needed.
1110 increment_backedge_counter_conditionally(lir_cond(cond), left, right, state_for(x, x->state_before()),
1111 x->tsux()->bci(), x->fsux()->bci(), x->profiled_bci());
1112 __ safepoint(safepoint_poll_register(), state_for(x, x->state_before()));
1113 }
1114
1115 if (x->substitutability_check()) {
1116 substitutability_check(x, *xin, *yin);
1117 } else {
1118 __ cmp(lir_cond(cond), left, right);
1119 }
1120
1121 // Generate branch profiling. Profiling code doesn't kill flags.
1122 profile_branch(x, cond);
1123 move_to_phi(x->state());
1124 if (x->x()->type()->is_float_kind()) {
1125 __ branch(lir_cond(cond), x->tsux(), x->usux());
1126 } else {
1127 __ branch(lir_cond(cond), x->tsux());
1128 }
1129 assert(x->default_sux() == x->fsux(), "wrong destination above");
1130 __ jump(x->default_sux());
1131 }
1132
1133
1134 LIR_Opr LIRGenerator::getThreadPointer() {
1135 return FrameMap::as_pointer_opr(R16_thread);
1136 }
1137
1138
1139 void LIRGenerator::trace_block_entry(BlockBegin* block) {
1140 LIR_Opr arg1 = FrameMap::R3_opr; // ARG1
|