< prev index next >

src/hotspot/share/c1/c1_LIR.cpp

Print this page

   1 /*
   2  * Copyright (c) 2000, 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  *
  23  */
  24 
  25 #include "c1/c1_CodeStubs.hpp"
  26 #include "c1/c1_InstructionPrinter.hpp"
  27 #include "c1/c1_LIR.hpp"
  28 #include "c1/c1_LIRAssembler.hpp"
  29 #include "c1/c1_ValueStack.hpp"

  30 #include "ci/ciInstance.hpp"
  31 #include "runtime/safepointMechanism.inline.hpp"
  32 #include "runtime/sharedRuntime.hpp"
  33 #include "runtime/vm_version.hpp"
  34 
  35 Register LIR_Opr::as_register() const {
  36   return FrameMap::cpu_rnr2reg(cpu_regnr());
  37 }
  38 
  39 Register LIR_Opr::as_register_lo() const {
  40   return FrameMap::cpu_rnr2reg(cpu_regnrLo());
  41 }
  42 
  43 Register LIR_Opr::as_register_hi() const {
  44   return FrameMap::cpu_rnr2reg(cpu_regnrHi());
  45 }
  46 
  47 LIR_Opr LIR_OprFact::illegalOpr = LIR_OprFact::illegal();
  48 LIR_Opr LIR_OprFact::nullOpr = LIR_Opr();
  49 

 269   assert(_ublock != nullptr, "must have old block");
 270   _ublock = b;
 271 }
 272 
 273 void LIR_OpBranch::negate_cond() {
 274   switch (cond()) {
 275     case lir_cond_equal:        set_cond(lir_cond_notEqual);     break;
 276     case lir_cond_notEqual:     set_cond(lir_cond_equal);        break;
 277     case lir_cond_less:         set_cond(lir_cond_greaterEqual); break;
 278     case lir_cond_lessEqual:    set_cond(lir_cond_greater);      break;
 279     case lir_cond_greaterEqual: set_cond(lir_cond_less);         break;
 280     case lir_cond_greater:      set_cond(lir_cond_lessEqual);    break;
 281     default: ShouldNotReachHere();
 282   }
 283 }
 284 
 285 
 286 LIR_OpTypeCheck::LIR_OpTypeCheck(LIR_Code code, LIR_Opr result, LIR_Opr object, ciKlass* klass,
 287                                  LIR_Opr tmp1, LIR_Opr tmp2, LIR_Opr tmp3,
 288                                  bool fast_check, CodeEmitInfo* info_for_exception, CodeEmitInfo* info_for_patch,
 289                                  CodeStub* stub)
 290 
 291   : LIR_Op(code, result, nullptr)
 292   , _object(object)
 293   , _array(LIR_OprFact::illegalOpr)
 294   , _klass(klass)
 295   , _tmp1(tmp1)
 296   , _tmp2(tmp2)
 297   , _tmp3(tmp3)
 298   , _info_for_patch(info_for_patch)
 299   , _info_for_exception(info_for_exception)
 300   , _stub(stub)
 301   , _profiled_method(nullptr)
 302   , _profiled_bci(-1)
 303   , _should_profile(false)
 304   , _fast_check(fast_check)

 305 {
 306   if (code == lir_checkcast) {
 307     assert(info_for_exception != nullptr, "checkcast throws exceptions");
 308   } else if (code == lir_instanceof) {
 309     assert(info_for_exception == nullptr, "instanceof throws no exceptions");
 310   } else {
 311     ShouldNotReachHere();
 312   }
 313 }
 314 
 315 
 316 
 317 LIR_OpTypeCheck::LIR_OpTypeCheck(LIR_Code code, LIR_Opr object, LIR_Opr array, LIR_Opr tmp1, LIR_Opr tmp2, LIR_Opr tmp3, CodeEmitInfo* info_for_exception)
 318   : LIR_Op(code, LIR_OprFact::illegalOpr, nullptr)
 319   , _object(object)
 320   , _array(array)
 321   , _klass(nullptr)
 322   , _tmp1(tmp1)
 323   , _tmp2(tmp2)
 324   , _tmp3(tmp3)
 325   , _info_for_patch(nullptr)
 326   , _info_for_exception(info_for_exception)
 327   , _stub(nullptr)
 328   , _profiled_method(nullptr)
 329   , _profiled_bci(-1)
 330   , _should_profile(false)
 331   , _fast_check(false)

 332 {
 333   if (code == lir_store_check) {
 334     _stub = new ArrayStoreExceptionStub(object, info_for_exception);
 335     assert(info_for_exception != nullptr, "store_check throws exceptions");
 336   } else {
 337     ShouldNotReachHere();
 338   }
 339 }
 340 




























 341 
 342 LIR_OpArrayCopy::LIR_OpArrayCopy(LIR_Opr src, LIR_Opr src_pos, LIR_Opr dst, LIR_Opr dst_pos, LIR_Opr length,
 343                                  LIR_Opr tmp, ciArrayKlass* expected_type, int flags, CodeEmitInfo* info)
 344   : LIR_Op(lir_arraycopy, LIR_OprFact::illegalOpr, info)
 345   , _src(src)
 346   , _src_pos(src_pos)
 347   , _dst(dst)
 348   , _dst_pos(dst_pos)
 349   , _length(length)
 350   , _tmp(tmp)
 351   , _expected_type(expected_type)
 352   , _flags(flags) {
 353 #if defined(X86) || defined(AARCH64) || defined(S390) || defined(RISCV64) || defined(PPC64)
 354   if (expected_type != nullptr &&
 355       ((flags & ~LIR_OpArrayCopy::get_initial_copy_flags()) == 0)) {
 356     _stub = nullptr;
 357   } else {
 358     _stub = new ArrayCopyStub(this);
 359   }
 360 #else

 395 // complete rework of LIR instruction visitor.
 396 // The virtual call for each instruction type is replaced by a big
 397 // switch that adds the operands for each instruction
 398 
 399 void LIR_OpVisitState::visit(LIR_Op* op) {
 400   // copy information from the LIR_Op
 401   reset();
 402   set_op(op);
 403 
 404   switch (op->code()) {
 405 
 406 // LIR_Op0
 407     case lir_breakpoint:               // result and info always invalid
 408     case lir_membar:                   // result and info always invalid
 409     case lir_membar_acquire:           // result and info always invalid
 410     case lir_membar_release:           // result and info always invalid
 411     case lir_membar_loadload:          // result and info always invalid
 412     case lir_membar_storestore:        // result and info always invalid
 413     case lir_membar_loadstore:         // result and info always invalid
 414     case lir_membar_storeload:         // result and info always invalid

 415     case lir_on_spin_wait:
 416     {
 417       assert(op->as_Op0() != nullptr, "must be");
 418       assert(op->_info == nullptr, "info not used by this instruction");
 419       assert(op->_result->is_illegal(), "not used");
 420       break;
 421     }
 422 
 423     case lir_nop:                      // may have info, result always invalid
 424     case lir_std_entry:                // may have result, info always invalid
 425     case lir_osr_entry:                // may have result, info always invalid
 426     case lir_get_thread:               // may have result, info always invalid
 427     {
 428       assert(op->as_Op0() != nullptr, "must be");
 429       if (op->_info != nullptr)           do_info(op->_info);
 430       if (op->_result->is_valid())     do_output(op->_result);
 431       break;
 432     }
 433 
 434 

 772 
 773 
 774 // LIR_OpLock
 775     case lir_lock:
 776     case lir_unlock: {
 777       assert(op->as_OpLock() != nullptr, "must be");
 778       LIR_OpLock* opLock = (LIR_OpLock*)op;
 779 
 780       if (opLock->_info)                          do_info(opLock->_info);
 781 
 782       // TODO: check if these operands really have to be temp
 783       // (or if input is sufficient). This may have influence on the oop map!
 784       assert(opLock->_lock->is_valid(), "used");  do_temp(opLock->_lock);
 785       assert(opLock->_hdr->is_valid(),  "used");  do_temp(opLock->_hdr);
 786       assert(opLock->_obj->is_valid(),  "used");  do_temp(opLock->_obj);
 787 
 788       if (opLock->_scratch->is_valid())           do_temp(opLock->_scratch);
 789       assert(opLock->_result->is_illegal(), "unused");
 790 
 791       do_stub(opLock->_stub);

 792 
 793       break;
 794     }
 795 
 796 
 797 // LIR_OpTypeCheck
 798     case lir_instanceof:
 799     case lir_checkcast:
 800     case lir_store_check: {
 801       assert(op->as_OpTypeCheck() != nullptr, "must be");
 802       LIR_OpTypeCheck* opTypeCheck = (LIR_OpTypeCheck*)op;
 803 
 804       if (opTypeCheck->_info_for_exception)       do_info(opTypeCheck->_info_for_exception);
 805       if (opTypeCheck->_info_for_patch)           do_info(opTypeCheck->_info_for_patch);
 806       if (opTypeCheck->_object->is_valid())       do_input(opTypeCheck->_object);
 807       if (op->code() == lir_store_check && opTypeCheck->_object->is_valid()) {
 808         do_temp(opTypeCheck->_object);
 809       }
 810       if (opTypeCheck->_array->is_valid())        do_input(opTypeCheck->_array);
 811       if (opTypeCheck->_tmp1->is_valid())         do_temp(opTypeCheck->_tmp1);
 812       if (opTypeCheck->_tmp2->is_valid())         do_temp(opTypeCheck->_tmp2);
 813       if (opTypeCheck->_tmp3->is_valid())         do_temp(opTypeCheck->_tmp3);
 814       if (opTypeCheck->_result->is_valid())       do_output(opTypeCheck->_result);
 815       if (opTypeCheck->_stub != nullptr)          do_stub(opTypeCheck->_stub);
 816       break;
 817     }
 818 













































 819 // LIR_OpCompareAndSwap
 820     case lir_cas_long:
 821     case lir_cas_obj:
 822     case lir_cas_int: {
 823       assert(op->as_OpCompareAndSwap() != nullptr, "must be");
 824       LIR_OpCompareAndSwap* opCmpAndSwap = (LIR_OpCompareAndSwap*)op;
 825 
 826       if (opCmpAndSwap->_info)                              do_info(opCmpAndSwap->_info);
 827       assert(opCmpAndSwap->_addr->is_valid(), "used");      do_input(opCmpAndSwap->_addr);
 828                                                             do_temp(opCmpAndSwap->_addr);
 829       assert(opCmpAndSwap->_cmp_value->is_valid(), "used"); do_input(opCmpAndSwap->_cmp_value);
 830                                                             do_temp(opCmpAndSwap->_cmp_value);
 831       assert(opCmpAndSwap->_new_value->is_valid(), "used"); do_input(opCmpAndSwap->_new_value);
 832                                                             do_temp(opCmpAndSwap->_new_value);
 833       if (opCmpAndSwap->_tmp1->is_valid())                  do_temp(opCmpAndSwap->_tmp1);
 834       if (opCmpAndSwap->_tmp2->is_valid())                  do_temp(opCmpAndSwap->_tmp2);
 835       if (opCmpAndSwap->_result->is_valid())                do_output(opCmpAndSwap->_result);
 836 
 837       break;
 838     }

 876     case lir_profile_call: {
 877       assert(op->as_OpProfileCall() != nullptr, "must be");
 878       LIR_OpProfileCall* opProfileCall = (LIR_OpProfileCall*)op;
 879 
 880       if (opProfileCall->_recv->is_valid())              do_temp(opProfileCall->_recv);
 881       assert(opProfileCall->_mdo->is_valid(), "used");   do_temp(opProfileCall->_mdo);
 882       assert(opProfileCall->_tmp1->is_valid(), "used");  do_temp(opProfileCall->_tmp1);
 883       break;
 884     }
 885 
 886 // LIR_OpProfileType:
 887     case lir_profile_type: {
 888       assert(op->as_OpProfileType() != nullptr, "must be");
 889       LIR_OpProfileType* opProfileType = (LIR_OpProfileType*)op;
 890 
 891       do_input(opProfileType->_mdp); do_temp(opProfileType->_mdp);
 892       do_input(opProfileType->_obj);
 893       do_temp(opProfileType->_tmp);
 894       break;
 895     }
 896   default:











 897     op->visit(this);
 898   }
 899 }
 900 
 901 void LIR_Op::visit(LIR_OpVisitState* state) {
 902   ShouldNotReachHere();
 903 }
 904 
 905 void LIR_OpVisitState::do_stub(CodeStub* stub) {
 906   if (stub != nullptr) {
 907     stub->visit(this);
 908   }
 909 }
 910 
 911 XHandlers* LIR_OpVisitState::all_xhandler() {
 912   XHandlers* result = nullptr;
 913 
 914   int i;
 915   for (i = 0; i < info_count(); i++) {
 916     if (info_at(i)->exception_handlers() != nullptr) {

 949          !has_slow_case();
 950 }
 951 #endif
 952 
 953 // LIR_OpReturn
 954 LIR_OpReturn::LIR_OpReturn(LIR_Opr opr) :
 955     LIR_Op1(lir_return, opr, (CodeEmitInfo*)nullptr /* info */),
 956     _stub(nullptr) {
 957   if (VM_Version::supports_stack_watermark_barrier()) {
 958     _stub = new C1SafepointPollStub();
 959   }
 960 }
 961 
 962 //---------------------------------------------------
 963 
 964 
 965 void LIR_OpJavaCall::emit_code(LIR_Assembler* masm) {
 966   masm->emit_call(this);
 967 }
 968 




























 969 void LIR_OpRTCall::emit_code(LIR_Assembler* masm) {
 970   masm->emit_rtcall(this);
 971 }
 972 
 973 void LIR_OpLabel::emit_code(LIR_Assembler* masm) {
 974   masm->emit_opLabel(this);
 975 }
 976 
 977 void LIR_OpArrayCopy::emit_code(LIR_Assembler* masm) {
 978   masm->emit_arraycopy(this);
 979   ArrayCopyStub* code_stub = stub();
 980   if (code_stub != nullptr) {
 981     masm->append_code_stub(code_stub);
 982   }
 983 }
 984 
 985 void LIR_OpUpdateCRC32::emit_code(LIR_Assembler* masm) {
 986   masm->emit_updatecrc32(this);
 987 }
 988 

1009 void LIR_OpConvert::emit_code(LIR_Assembler* masm) {
1010   masm->emit_opConvert(this);
1011 }
1012 
1013 void LIR_Op2::emit_code(LIR_Assembler* masm) {
1014   masm->emit_op2(this);
1015 }
1016 
1017 void LIR_OpAllocArray::emit_code(LIR_Assembler* masm) {
1018   masm->emit_alloc_array(this);
1019   masm->append_code_stub(stub());
1020 }
1021 
1022 void LIR_OpTypeCheck::emit_code(LIR_Assembler* masm) {
1023   masm->emit_opTypeCheck(this);
1024   if (stub()) {
1025     masm->append_code_stub(stub());
1026   }
1027 }
1028 


















1029 void LIR_OpCompareAndSwap::emit_code(LIR_Assembler* masm) {
1030   masm->emit_compare_and_swap(this);
1031 }
1032 
1033 void LIR_Op3::emit_code(LIR_Assembler* masm) {
1034   masm->emit_op3(this);
1035 }
1036 
1037 void LIR_Op4::emit_code(LIR_Assembler* masm) {
1038   masm->emit_op4(this);
1039 }
1040 
1041 void LIR_OpLock::emit_code(LIR_Assembler* masm) {
1042   masm->emit_lock(this);
1043   if (stub()) {
1044     masm->append_code_stub(stub());
1045   }



1046 }
1047 
1048 void LIR_OpLoadKlass::emit_code(LIR_Assembler* masm) {
1049   masm->emit_load_klass(this);
1050 }
1051 
1052 #ifdef ASSERT
1053 void LIR_OpAssert::emit_code(LIR_Assembler* masm) {
1054   masm->emit_assert(this);
1055 }
1056 #endif
1057 
1058 void LIR_OpProfileCall::emit_code(LIR_Assembler* masm) {
1059   masm->emit_profile_call(this);
1060 }
1061 
1062 void LIR_OpProfileType::emit_code(LIR_Assembler* masm) {
1063   masm->emit_profile_type(this);
1064 }
1065 




1066 // LIR_List
1067 LIR_List::LIR_List(Compilation* compilation, BlockBegin* block)
1068   : _operations(8)
1069   , _compilation(compilation)
1070 #ifndef PRODUCT
1071   , _block(block)
1072 #endif
1073 #ifdef ASSERT
1074   , _file(nullptr)
1075   , _line(0)
1076 #endif
1077 #ifdef RISCV
1078   , _cmp_opr1(LIR_OprFact::illegalOpr)
1079   , _cmp_opr2(LIR_OprFact::illegalOpr)
1080 #endif
1081 { }
1082 
1083 
1084 #ifdef ASSERT
1085 void LIR_List::set_file_and_line(const char * file, int line) {

1321                     reg,
1322                     LIR_OprFact::address(addr),
1323                     info));
1324 }
1325 
1326 void LIR_List::allocate_object(LIR_Opr dst, LIR_Opr t1, LIR_Opr t2, LIR_Opr t3, LIR_Opr t4,
1327                                int header_size, int object_size, LIR_Opr klass, bool init_check, CodeStub* stub) {
1328   append(new LIR_OpAllocObj(
1329                            klass,
1330                            dst,
1331                            t1,
1332                            t2,
1333                            t3,
1334                            t4,
1335                            header_size,
1336                            object_size,
1337                            init_check,
1338                            stub));
1339 }
1340 
1341 void LIR_List::allocate_array(LIR_Opr dst, LIR_Opr len, LIR_Opr t1,LIR_Opr t2, LIR_Opr t3,LIR_Opr t4, BasicType type, LIR_Opr klass, CodeStub* stub, bool zero_array) {
1342   append(new LIR_OpAllocArray(
1343                            klass,
1344                            len,
1345                            dst,
1346                            t1,
1347                            t2,
1348                            t3,
1349                            t4,
1350                            type,
1351                            stub,
1352                            zero_array));

1353 }
1354 
1355 void LIR_List::shift_left(LIR_Opr value, LIR_Opr count, LIR_Opr dst, LIR_Opr tmp) {
1356  append(new LIR_Op2(
1357                     lir_shl,
1358                     value,
1359                     count,
1360                     dst,
1361                     tmp));
1362 }
1363 
1364 void LIR_List::shift_right(LIR_Opr value, LIR_Opr count, LIR_Opr dst, LIR_Opr tmp) {
1365  append(new LIR_Op2(
1366                     lir_shr,
1367                     value,
1368                     count,
1369                     dst,
1370                     tmp));
1371 }
1372 
1373 
1374 void LIR_List::unsigned_shift_right(LIR_Opr value, LIR_Opr count, LIR_Opr dst, LIR_Opr tmp) {
1375  append(new LIR_Op2(
1376                     lir_ushr,
1377                     value,
1378                     count,
1379                     dst,
1380                     tmp));
1381 }
1382 
1383 void LIR_List::fcmp2int(LIR_Opr left, LIR_Opr right, LIR_Opr dst, bool is_unordered_less) {
1384   append(new LIR_Op2(is_unordered_less ? lir_ucmp_fd2i : lir_cmp_fd2i,
1385                      left,
1386                      right,
1387                      dst));
1388 }
1389 
1390 void LIR_List::lock_object(LIR_Opr hdr, LIR_Opr obj, LIR_Opr lock, LIR_Opr scratch, CodeStub* stub, CodeEmitInfo* info) {
1391   append(new LIR_OpLock(
1392                     lir_lock,
1393                     hdr,
1394                     obj,
1395                     lock,
1396                     scratch,
1397                     stub,
1398                     info));

1399 }
1400 
1401 void LIR_List::unlock_object(LIR_Opr hdr, LIR_Opr obj, LIR_Opr lock, LIR_Opr scratch, CodeStub* stub) {
1402   append(new LIR_OpLock(
1403                     lir_unlock,
1404                     hdr,
1405                     obj,
1406                     lock,
1407                     scratch,
1408                     stub,
1409                     nullptr));
1410 }
1411 
1412 
1413 void check_LIR() {
1414   // cannot do the proper checking as PRODUCT and other modes return different results
1415   // guarantee(sizeof(LIR_Opr) == wordSize, "may not have a v-table");
1416 }
1417 
1418 
1419 
1420 void LIR_List::checkcast (LIR_Opr result, LIR_Opr object, ciKlass* klass,
1421                           LIR_Opr tmp1, LIR_Opr tmp2, LIR_Opr tmp3, bool fast_check,
1422                           CodeEmitInfo* info_for_exception, CodeEmitInfo* info_for_patch, CodeStub* stub,
1423                           ciMethod* profiled_method, int profiled_bci) {



1424   LIR_OpTypeCheck* c = new LIR_OpTypeCheck(lir_checkcast, result, object, klass,
1425                                            tmp1, tmp2, tmp3, fast_check, info_for_exception, info_for_patch, stub);

1426   if (profiled_method != nullptr && TypeProfileCasts) {
1427     c->set_profiled_method(profiled_method);
1428     c->set_profiled_bci(profiled_bci);
1429     c->set_should_profile(true);
1430   }
1431   append(c);
1432 }
1433 
1434 void LIR_List::instanceof(LIR_Opr result, LIR_Opr object, ciKlass* klass, LIR_Opr tmp1, LIR_Opr tmp2, LIR_Opr tmp3, bool fast_check, CodeEmitInfo* info_for_patch, ciMethod* profiled_method, int profiled_bci) {
1435   LIR_OpTypeCheck* c = new LIR_OpTypeCheck(lir_instanceof, result, object, klass, tmp1, tmp2, tmp3, fast_check, nullptr, info_for_patch, nullptr);
1436   if (profiled_method != nullptr && TypeProfileCasts) {
1437     c->set_profiled_method(profiled_method);
1438     c->set_profiled_bci(profiled_bci);
1439     c->set_should_profile(true);
1440   }
1441   append(c);
1442 }
1443 
1444 
1445 void LIR_List::store_check(LIR_Opr object, LIR_Opr array, LIR_Opr tmp1, LIR_Opr tmp2, LIR_Opr tmp3,
1446                            CodeEmitInfo* info_for_exception, ciMethod* profiled_method, int profiled_bci) {

1447   LIR_OpTypeCheck* c = new LIR_OpTypeCheck(lir_store_check, object, array, tmp1, tmp2, tmp3, info_for_exception);
1448   if (profiled_method != nullptr && TypeProfileCasts) {
1449     c->set_profiled_method(profiled_method);
1450     c->set_profiled_bci(profiled_bci);
1451     c->set_should_profile(true);
1452   }
1453   append(c);
1454 }
1455 
1456 void LIR_List::null_check(LIR_Opr opr, CodeEmitInfo* info, bool deoptimize_on_null) {
1457   if (deoptimize_on_null) {
1458     // Emit an explicit null check and deoptimize if opr is null
1459     CodeStub* deopt = new DeoptimizeStub(info, Deoptimization::Reason_null_check, Deoptimization::Action_none);
1460     cmp(lir_cond_equal, opr, LIR_OprFact::oopConst(nullptr));
1461     branch(lir_cond_equal, deopt);
1462   } else {
1463     // Emit an implicit null check
1464     append(new LIR_Op1(lir_null_check, opr, info));
1465   }
1466 }
1467 


















1468 void LIR_List::cas_long(LIR_Opr addr, LIR_Opr cmp_value, LIR_Opr new_value,
1469                         LIR_Opr t1, LIR_Opr t2, LIR_Opr result) {
1470   append(new LIR_OpCompareAndSwap(lir_cas_long, addr, cmp_value, new_value, t1, t2, result));
1471 }
1472 
1473 void LIR_List::cas_obj(LIR_Opr addr, LIR_Opr cmp_value, LIR_Opr new_value,
1474                        LIR_Opr t1, LIR_Opr t2, LIR_Opr result) {
1475   append(new LIR_OpCompareAndSwap(lir_cas_obj, addr, cmp_value, new_value, t1, t2, result));
1476 }
1477 
1478 void LIR_List::cas_int(LIR_Opr addr, LIR_Opr cmp_value, LIR_Opr new_value,
1479                        LIR_Opr t1, LIR_Opr t2, LIR_Opr result) {
1480   append(new LIR_OpCompareAndSwap(lir_cas_int, addr, cmp_value, new_value, t1, t2, result));
1481 }
1482 
1483 
1484 #ifdef PRODUCT
1485 
1486 void print_LIR(BlockList* blocks) {
1487 }

1663 }
1664 
1665 const char * LIR_Op::name() const {
1666   const char* s = nullptr;
1667   switch(code()) {
1668      // LIR_Op0
1669      case lir_membar:                s = "membar";        break;
1670      case lir_membar_acquire:        s = "membar_acquire"; break;
1671      case lir_membar_release:        s = "membar_release"; break;
1672      case lir_membar_loadload:       s = "membar_loadload";   break;
1673      case lir_membar_storestore:     s = "membar_storestore"; break;
1674      case lir_membar_loadstore:      s = "membar_loadstore";  break;
1675      case lir_membar_storeload:      s = "membar_storeload";  break;
1676      case lir_label:                 s = "label";         break;
1677      case lir_nop:                   s = "nop";           break;
1678      case lir_on_spin_wait:          s = "on_spin_wait";  break;
1679      case lir_std_entry:             s = "std_entry";     break;
1680      case lir_osr_entry:             s = "osr_entry";     break;
1681      case lir_breakpoint:            s = "breakpoint";    break;
1682      case lir_get_thread:            s = "get_thread";    break;

1683      // LIR_Op1
1684      case lir_push:                  s = "push";          break;
1685      case lir_pop:                   s = "pop";           break;
1686      case lir_null_check:            s = "null_check";    break;
1687      case lir_return:                s = "return";        break;
1688      case lir_safepoint:             s = "safepoint";     break;
1689      case lir_leal:                  s = "leal";          break;
1690      case lir_branch:                s = "branch";        break;
1691      case lir_cond_float_branch:     s = "flt_cond_br";   break;
1692      case lir_move:                  s = "move";          break;
1693      case lir_abs:                   s = "abs";           break;
1694      case lir_neg:                   s = "neg";           break;
1695      case lir_sqrt:                  s = "sqrt";          break;
1696      case lir_f2hf:                  s = "f2hf";          break;
1697      case lir_hf2f:                  s = "hf2f";          break;
1698      case lir_rtcall:                s = "rtcall";        break;
1699      case lir_throw:                 s = "throw";         break;
1700      case lir_unwind:                s = "unwind";        break;
1701      case lir_convert:               s = "convert";       break;
1702      case lir_alloc_object:          s = "alloc_obj";     break;

1726      case lir_fmad:                  s = "fmad";          break;
1727      case lir_fmaf:                  s = "fmaf";          break;
1728      // LIR_Op4
1729      case lir_cmove:                 s = "cmove";         break;
1730      // LIR_OpJavaCall
1731      case lir_static_call:           s = "static";        break;
1732      case lir_optvirtual_call:       s = "optvirtual";    break;
1733      case lir_icvirtual_call:        s = "icvirtual";     break;
1734      case lir_dynamic_call:          s = "dynamic";       break;
1735      // LIR_OpArrayCopy
1736      case lir_arraycopy:             s = "arraycopy";     break;
1737      // LIR_OpUpdateCRC32
1738      case lir_updatecrc32:           s = "updatecrc32";   break;
1739      // LIR_OpLock
1740      case lir_lock:                  s = "lock";          break;
1741      case lir_unlock:                s = "unlock";        break;
1742      // LIR_OpTypeCheck
1743      case lir_instanceof:            s = "instanceof";    break;
1744      case lir_checkcast:             s = "checkcast";     break;
1745      case lir_store_check:           s = "store_check";   break;






1746      // LIR_OpCompareAndSwap
1747      case lir_cas_long:              s = "cas_long";      break;
1748      case lir_cas_obj:               s = "cas_obj";      break;
1749      case lir_cas_int:               s = "cas_int";      break;
1750      // LIR_OpProfileCall
1751      case lir_profile_call:          s = "profile_call";  break;
1752      // LIR_OpProfileType
1753      case lir_profile_type:          s = "profile_type";  break;


1754      // LIR_OpAssert
1755 #ifdef ASSERT
1756      case lir_assert:                s = "assert";        break;
1757 #endif
1758      case lir_none:                  ShouldNotReachHere();break;
1759     default:                         s = "illegal_op";    break;
1760   }
1761   return s;
1762 }
1763 
1764 // LIR_OpJavaCall
1765 void LIR_OpJavaCall::print_instr(outputStream* out) const {
1766   out->print("call: ");
1767   out->print("[addr: " INTPTR_FORMAT "]", p2i(address()));
1768   if (receiver()->is_valid()) {
1769     out->print(" [recv: ");   receiver()->print(out);   out->print("]");
1770   }
1771   if (result_opr()->is_valid()) {
1772     out->print(" [result: "); result_opr()->print(out); out->print("]");
1773   }

1959   out->print("[label:" INTPTR_FORMAT "]", p2i(stub()->entry()));
1960 }
1961 
1962 
1963 void LIR_OpTypeCheck::print_instr(outputStream* out) const {
1964   object()->print(out);                  out->print(" ");
1965   if (code() == lir_store_check) {
1966     array()->print(out);                 out->print(" ");
1967   }
1968   if (code() != lir_store_check) {
1969     klass()->print_name_on(out);         out->print(" ");
1970     if (fast_check())                 out->print("fast_check ");
1971   }
1972   tmp1()->print(out);                    out->print(" ");
1973   tmp2()->print(out);                    out->print(" ");
1974   tmp3()->print(out);                    out->print(" ");
1975   result_opr()->print(out);              out->print(" ");
1976   if (info_for_exception() != nullptr) out->print(" [bci:%d]", info_for_exception()->stack()->bci());
1977 }
1978 




































1979 
1980 // LIR_Op3
1981 void LIR_Op3::print_instr(outputStream* out) const {
1982   in_opr1()->print(out);    out->print(" ");
1983   in_opr2()->print(out);    out->print(" ");
1984   in_opr3()->print(out);    out->print(" ");
1985   result_opr()->print(out);
1986 }
1987 
1988 // LIR_Op4
1989 void LIR_Op4::print_instr(outputStream* out) const {
1990   print_condition(out, condition()); out->print(" ");
1991   in_opr1()->print(out);             out->print(" ");
1992   in_opr2()->print(out);             out->print(" ");
1993   in_opr3()->print(out);             out->print(" ");
1994   in_opr4()->print(out);             out->print(" ");
1995   result_opr()->print(out);
1996 }
1997 
1998 void LIR_OpLock::print_instr(outputStream* out) const {

2029   mdo()->print(out);           out->print(" ");
2030   recv()->print(out);          out->print(" ");
2031   tmp1()->print(out);          out->print(" ");
2032 }
2033 
2034 // LIR_OpProfileType
2035 void LIR_OpProfileType::print_instr(outputStream* out) const {
2036   out->print("exact = ");
2037   if (exact_klass() == nullptr) {
2038     out->print("unknown");
2039   } else {
2040     exact_klass()->print_name_on(out);
2041   }
2042   out->print(" current = "); ciTypeEntries::print_ciklass(out, current_klass());
2043   out->print(" ");
2044   mdp()->print(out);          out->print(" ");
2045   obj()->print(out);          out->print(" ");
2046   tmp()->print(out);          out->print(" ");
2047 }
2048 








2049 #endif // PRODUCT
2050 
2051 // Implementation of LIR_InsertionBuffer
2052 
2053 void LIR_InsertionBuffer::append(int index, LIR_Op* op) {
2054   assert(_index_and_count.length() % 2 == 0, "must have a count for each index");
2055 
2056   int i = number_of_insertion_points() - 1;
2057   if (i < 0 || index_at(i) < index) {
2058     append_new(index, 1);
2059   } else {
2060     assert(index_at(i) == index, "can append LIR_Ops in ascending order only");
2061     assert(count_at(i) > 0, "check");
2062     set_count_at(i, count_at(i) + 1);
2063   }
2064   _ops.push(op);
2065 
2066   DEBUG_ONLY(verify());
2067 }
2068 

   1 /*
   2  * Copyright (c) 2000, 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  *
  23  */
  24 
  25 #include "c1/c1_CodeStubs.hpp"
  26 #include "c1/c1_InstructionPrinter.hpp"
  27 #include "c1/c1_LIR.hpp"
  28 #include "c1/c1_LIRAssembler.hpp"
  29 #include "c1/c1_ValueStack.hpp"
  30 #include "ci/ciInlineKlass.hpp"
  31 #include "ci/ciInstance.hpp"
  32 #include "runtime/safepointMechanism.inline.hpp"
  33 #include "runtime/sharedRuntime.hpp"
  34 #include "runtime/vm_version.hpp"
  35 
  36 Register LIR_Opr::as_register() const {
  37   return FrameMap::cpu_rnr2reg(cpu_regnr());
  38 }
  39 
  40 Register LIR_Opr::as_register_lo() const {
  41   return FrameMap::cpu_rnr2reg(cpu_regnrLo());
  42 }
  43 
  44 Register LIR_Opr::as_register_hi() const {
  45   return FrameMap::cpu_rnr2reg(cpu_regnrHi());
  46 }
  47 
  48 LIR_Opr LIR_OprFact::illegalOpr = LIR_OprFact::illegal();
  49 LIR_Opr LIR_OprFact::nullOpr = LIR_Opr();
  50 

 270   assert(_ublock != nullptr, "must have old block");
 271   _ublock = b;
 272 }
 273 
 274 void LIR_OpBranch::negate_cond() {
 275   switch (cond()) {
 276     case lir_cond_equal:        set_cond(lir_cond_notEqual);     break;
 277     case lir_cond_notEqual:     set_cond(lir_cond_equal);        break;
 278     case lir_cond_less:         set_cond(lir_cond_greaterEqual); break;
 279     case lir_cond_lessEqual:    set_cond(lir_cond_greater);      break;
 280     case lir_cond_greaterEqual: set_cond(lir_cond_less);         break;
 281     case lir_cond_greater:      set_cond(lir_cond_lessEqual);    break;
 282     default: ShouldNotReachHere();
 283   }
 284 }
 285 
 286 
 287 LIR_OpTypeCheck::LIR_OpTypeCheck(LIR_Code code, LIR_Opr result, LIR_Opr object, ciKlass* klass,
 288                                  LIR_Opr tmp1, LIR_Opr tmp2, LIR_Opr tmp3,
 289                                  bool fast_check, CodeEmitInfo* info_for_exception, CodeEmitInfo* info_for_patch,
 290                                  CodeStub* stub, bool need_null_check)
 291 
 292   : LIR_Op(code, result, nullptr)
 293   , _object(object)
 294   , _array(LIR_OprFact::illegalOpr)
 295   , _klass(klass)
 296   , _tmp1(tmp1)
 297   , _tmp2(tmp2)
 298   , _tmp3(tmp3)
 299   , _info_for_patch(info_for_patch)
 300   , _info_for_exception(info_for_exception)
 301   , _stub(stub)
 302   , _profiled_method(nullptr)
 303   , _profiled_bci(-1)
 304   , _should_profile(false)
 305   , _fast_check(fast_check)
 306   , _need_null_check(need_null_check)
 307 {
 308   if (code == lir_checkcast) {
 309     assert(info_for_exception != nullptr, "checkcast throws exceptions");
 310   } else if (code == lir_instanceof) {
 311     assert(info_for_exception == nullptr, "instanceof throws no exceptions");
 312   } else {
 313     ShouldNotReachHere();
 314   }
 315 }
 316 
 317 
 318 
 319 LIR_OpTypeCheck::LIR_OpTypeCheck(LIR_Code code, LIR_Opr object, LIR_Opr array, LIR_Opr tmp1, LIR_Opr tmp2, LIR_Opr tmp3, CodeEmitInfo* info_for_exception)
 320   : LIR_Op(code, LIR_OprFact::illegalOpr, nullptr)
 321   , _object(object)
 322   , _array(array)
 323   , _klass(nullptr)
 324   , _tmp1(tmp1)
 325   , _tmp2(tmp2)
 326   , _tmp3(tmp3)
 327   , _info_for_patch(nullptr)
 328   , _info_for_exception(info_for_exception)
 329   , _stub(nullptr)
 330   , _profiled_method(nullptr)
 331   , _profiled_bci(-1)
 332   , _should_profile(false)
 333   , _fast_check(false)
 334   , _need_null_check(true)
 335 {
 336   if (code == lir_store_check) {
 337     _stub = new ArrayStoreExceptionStub(object, info_for_exception);
 338     assert(info_for_exception != nullptr, "store_check throws exceptions");
 339   } else {
 340     ShouldNotReachHere();
 341   }
 342 }
 343 
 344 LIR_OpFlattenedArrayCheck::LIR_OpFlattenedArrayCheck(LIR_Opr array, LIR_Opr value, LIR_Opr tmp, CodeStub* stub)
 345   : LIR_Op(lir_flat_array_check, LIR_OprFact::illegalOpr, nullptr)
 346   , _array(array)
 347   , _value(value)
 348   , _tmp(tmp)
 349   , _stub(stub) {}
 350 
 351 
 352 LIR_OpNullFreeArrayCheck::LIR_OpNullFreeArrayCheck(LIR_Opr array, LIR_Opr tmp)
 353   : LIR_Op(lir_null_free_array_check, LIR_OprFact::illegalOpr, nullptr)
 354   , _array(array)
 355   , _tmp(tmp) {}
 356 
 357 
 358 LIR_OpSubstitutabilityCheck::LIR_OpSubstitutabilityCheck(LIR_Opr result, LIR_Opr left, LIR_Opr right, LIR_Opr equal_result, LIR_Opr not_equal_result,
 359                                                          ciKlass* left_klass, ciKlass* right_klass, LIR_Opr tmp1, LIR_Opr tmp2,
 360                                                          CodeEmitInfo* info, CodeStub* stub)
 361   : LIR_Op(lir_substitutability_check, result, info)
 362   , _left(left)
 363   , _right(right)
 364   , _equal_result(equal_result)
 365   , _not_equal_result(not_equal_result)
 366   , _left_klass(left_klass)
 367   , _right_klass(right_klass)
 368   , _tmp1(tmp1)
 369   , _tmp2(tmp2)
 370   , _stub(stub) {}
 371 
 372 
 373 LIR_OpArrayCopy::LIR_OpArrayCopy(LIR_Opr src, LIR_Opr src_pos, LIR_Opr dst, LIR_Opr dst_pos, LIR_Opr length,
 374                                  LIR_Opr tmp, ciArrayKlass* expected_type, int flags, CodeEmitInfo* info)
 375   : LIR_Op(lir_arraycopy, LIR_OprFact::illegalOpr, info)
 376   , _src(src)
 377   , _src_pos(src_pos)
 378   , _dst(dst)
 379   , _dst_pos(dst_pos)
 380   , _length(length)
 381   , _tmp(tmp)
 382   , _expected_type(expected_type)
 383   , _flags(flags) {
 384 #if defined(X86) || defined(AARCH64) || defined(S390) || defined(RISCV64) || defined(PPC64)
 385   if (expected_type != nullptr &&
 386       ((flags & ~LIR_OpArrayCopy::get_initial_copy_flags()) == 0)) {
 387     _stub = nullptr;
 388   } else {
 389     _stub = new ArrayCopyStub(this);
 390   }
 391 #else

 426 // complete rework of LIR instruction visitor.
 427 // The virtual call for each instruction type is replaced by a big
 428 // switch that adds the operands for each instruction
 429 
 430 void LIR_OpVisitState::visit(LIR_Op* op) {
 431   // copy information from the LIR_Op
 432   reset();
 433   set_op(op);
 434 
 435   switch (op->code()) {
 436 
 437 // LIR_Op0
 438     case lir_breakpoint:               // result and info always invalid
 439     case lir_membar:                   // result and info always invalid
 440     case lir_membar_acquire:           // result and info always invalid
 441     case lir_membar_release:           // result and info always invalid
 442     case lir_membar_loadload:          // result and info always invalid
 443     case lir_membar_storestore:        // result and info always invalid
 444     case lir_membar_loadstore:         // result and info always invalid
 445     case lir_membar_storeload:         // result and info always invalid
 446     case lir_check_orig_pc:            // result and info always invalid
 447     case lir_on_spin_wait:
 448     {
 449       assert(op->as_Op0() != nullptr, "must be");
 450       assert(op->_info == nullptr, "info not used by this instruction");
 451       assert(op->_result->is_illegal(), "not used");
 452       break;
 453     }
 454 
 455     case lir_nop:                      // may have info, result always invalid
 456     case lir_std_entry:                // may have result, info always invalid
 457     case lir_osr_entry:                // may have result, info always invalid
 458     case lir_get_thread:               // may have result, info always invalid
 459     {
 460       assert(op->as_Op0() != nullptr, "must be");
 461       if (op->_info != nullptr)           do_info(op->_info);
 462       if (op->_result->is_valid())     do_output(op->_result);
 463       break;
 464     }
 465 
 466 

 804 
 805 
 806 // LIR_OpLock
 807     case lir_lock:
 808     case lir_unlock: {
 809       assert(op->as_OpLock() != nullptr, "must be");
 810       LIR_OpLock* opLock = (LIR_OpLock*)op;
 811 
 812       if (opLock->_info)                          do_info(opLock->_info);
 813 
 814       // TODO: check if these operands really have to be temp
 815       // (or if input is sufficient). This may have influence on the oop map!
 816       assert(opLock->_lock->is_valid(), "used");  do_temp(opLock->_lock);
 817       assert(opLock->_hdr->is_valid(),  "used");  do_temp(opLock->_hdr);
 818       assert(opLock->_obj->is_valid(),  "used");  do_temp(opLock->_obj);
 819 
 820       if (opLock->_scratch->is_valid())           do_temp(opLock->_scratch);
 821       assert(opLock->_result->is_illegal(), "unused");
 822 
 823       do_stub(opLock->_stub);
 824       do_stub(opLock->_throw_ie_stub);
 825 
 826       break;
 827     }
 828 
 829 
 830 // LIR_OpTypeCheck
 831     case lir_instanceof:
 832     case lir_checkcast:
 833     case lir_store_check: {
 834       assert(op->as_OpTypeCheck() != nullptr, "must be");
 835       LIR_OpTypeCheck* opTypeCheck = (LIR_OpTypeCheck*)op;
 836 
 837       if (opTypeCheck->_info_for_exception)       do_info(opTypeCheck->_info_for_exception);
 838       if (opTypeCheck->_info_for_patch)           do_info(opTypeCheck->_info_for_patch);
 839       if (opTypeCheck->_object->is_valid())       do_input(opTypeCheck->_object);
 840       if (op->code() == lir_store_check && opTypeCheck->_object->is_valid()) {
 841         do_temp(opTypeCheck->_object);
 842       }
 843       if (opTypeCheck->_array->is_valid())        do_input(opTypeCheck->_array);
 844       if (opTypeCheck->_tmp1->is_valid())         do_temp(opTypeCheck->_tmp1);
 845       if (opTypeCheck->_tmp2->is_valid())         do_temp(opTypeCheck->_tmp2);
 846       if (opTypeCheck->_tmp3->is_valid())         do_temp(opTypeCheck->_tmp3);
 847       if (opTypeCheck->_result->is_valid())       do_output(opTypeCheck->_result);
 848       if (opTypeCheck->_stub != nullptr)          do_stub(opTypeCheck->_stub);
 849       break;
 850     }
 851 
 852 // LIR_OpFlattenedArrayCheck
 853     case lir_flat_array_check: {
 854       assert(op->as_OpFlattenedArrayCheck() != nullptr, "must be");
 855       LIR_OpFlattenedArrayCheck* opFlattenedArrayCheck = (LIR_OpFlattenedArrayCheck*)op;
 856 
 857       if (opFlattenedArrayCheck->_array->is_valid()) do_input(opFlattenedArrayCheck->_array);
 858       if (opFlattenedArrayCheck->_value->is_valid()) do_input(opFlattenedArrayCheck->_value);
 859       if (opFlattenedArrayCheck->_tmp->is_valid())   do_temp(opFlattenedArrayCheck->_tmp);
 860 
 861       do_stub(opFlattenedArrayCheck->_stub);
 862 
 863       break;
 864     }
 865 
 866 // LIR_OpNullFreeArrayCheck
 867     case lir_null_free_array_check: {
 868       assert(op->as_OpNullFreeArrayCheck() != nullptr, "must be");
 869       LIR_OpNullFreeArrayCheck* opNullFreeArrayCheck = (LIR_OpNullFreeArrayCheck*)op;
 870 
 871       if (opNullFreeArrayCheck->_array->is_valid()) do_input(opNullFreeArrayCheck->_array);
 872       if (opNullFreeArrayCheck->_tmp->is_valid())   do_temp(opNullFreeArrayCheck->_tmp);
 873       break;
 874     }
 875 
 876 // LIR_OpSubstitutabilityCheck
 877     case lir_substitutability_check: {
 878       assert(op->as_OpSubstitutabilityCheck() != nullptr, "must be");
 879       LIR_OpSubstitutabilityCheck* opSubstitutabilityCheck = (LIR_OpSubstitutabilityCheck*)op;
 880                                                                 do_input(opSubstitutabilityCheck->_left);
 881                                                                 do_temp (opSubstitutabilityCheck->_left);
 882                                                                 do_input(opSubstitutabilityCheck->_right);
 883                                                                 do_temp (opSubstitutabilityCheck->_right);
 884                                                                 do_input(opSubstitutabilityCheck->_equal_result);
 885                                                                 do_temp (opSubstitutabilityCheck->_equal_result);
 886                                                                 do_input(opSubstitutabilityCheck->_not_equal_result);
 887                                                                 do_temp (opSubstitutabilityCheck->_not_equal_result);
 888       if (opSubstitutabilityCheck->_tmp1->is_valid())           do_temp(opSubstitutabilityCheck->_tmp1);
 889       if (opSubstitutabilityCheck->_tmp2->is_valid())           do_temp(opSubstitutabilityCheck->_tmp2);
 890       if (opSubstitutabilityCheck->_result->is_valid())         do_output(opSubstitutabilityCheck->_result);
 891 
 892       do_info(opSubstitutabilityCheck->_info);
 893       do_stub(opSubstitutabilityCheck->_stub);
 894       break;
 895     }
 896 
 897 // LIR_OpCompareAndSwap
 898     case lir_cas_long:
 899     case lir_cas_obj:
 900     case lir_cas_int: {
 901       assert(op->as_OpCompareAndSwap() != nullptr, "must be");
 902       LIR_OpCompareAndSwap* opCmpAndSwap = (LIR_OpCompareAndSwap*)op;
 903 
 904       if (opCmpAndSwap->_info)                              do_info(opCmpAndSwap->_info);
 905       assert(opCmpAndSwap->_addr->is_valid(), "used");      do_input(opCmpAndSwap->_addr);
 906                                                             do_temp(opCmpAndSwap->_addr);
 907       assert(opCmpAndSwap->_cmp_value->is_valid(), "used"); do_input(opCmpAndSwap->_cmp_value);
 908                                                             do_temp(opCmpAndSwap->_cmp_value);
 909       assert(opCmpAndSwap->_new_value->is_valid(), "used"); do_input(opCmpAndSwap->_new_value);
 910                                                             do_temp(opCmpAndSwap->_new_value);
 911       if (opCmpAndSwap->_tmp1->is_valid())                  do_temp(opCmpAndSwap->_tmp1);
 912       if (opCmpAndSwap->_tmp2->is_valid())                  do_temp(opCmpAndSwap->_tmp2);
 913       if (opCmpAndSwap->_result->is_valid())                do_output(opCmpAndSwap->_result);
 914 
 915       break;
 916     }

 954     case lir_profile_call: {
 955       assert(op->as_OpProfileCall() != nullptr, "must be");
 956       LIR_OpProfileCall* opProfileCall = (LIR_OpProfileCall*)op;
 957 
 958       if (opProfileCall->_recv->is_valid())              do_temp(opProfileCall->_recv);
 959       assert(opProfileCall->_mdo->is_valid(), "used");   do_temp(opProfileCall->_mdo);
 960       assert(opProfileCall->_tmp1->is_valid(), "used");  do_temp(opProfileCall->_tmp1);
 961       break;
 962     }
 963 
 964 // LIR_OpProfileType:
 965     case lir_profile_type: {
 966       assert(op->as_OpProfileType() != nullptr, "must be");
 967       LIR_OpProfileType* opProfileType = (LIR_OpProfileType*)op;
 968 
 969       do_input(opProfileType->_mdp); do_temp(opProfileType->_mdp);
 970       do_input(opProfileType->_obj);
 971       do_temp(opProfileType->_tmp);
 972       break;
 973     }
 974 
 975     // LIR_OpProfileInlineType:
 976     case lir_profile_inline_type: {
 977       assert(op->as_OpProfileInlineType() != nullptr, "must be");
 978       LIR_OpProfileInlineType* opProfileInlineType = (LIR_OpProfileInlineType*)op;
 979 
 980       do_input(opProfileInlineType->_mdp); do_temp(opProfileInlineType->_mdp);
 981       do_input(opProfileInlineType->_obj);
 982       do_temp(opProfileInlineType->_tmp);
 983       break;
 984     }
 985 default:
 986     op->visit(this);
 987   }
 988 }
 989 
 990 void LIR_Op::visit(LIR_OpVisitState* state) {
 991   ShouldNotReachHere();
 992 }
 993 
 994 void LIR_OpVisitState::do_stub(CodeStub* stub) {
 995   if (stub != nullptr) {
 996     stub->visit(this);
 997   }
 998 }
 999 
1000 XHandlers* LIR_OpVisitState::all_xhandler() {
1001   XHandlers* result = nullptr;
1002 
1003   int i;
1004   for (i = 0; i < info_count(); i++) {
1005     if (info_at(i)->exception_handlers() != nullptr) {

1038          !has_slow_case();
1039 }
1040 #endif
1041 
1042 // LIR_OpReturn
1043 LIR_OpReturn::LIR_OpReturn(LIR_Opr opr) :
1044     LIR_Op1(lir_return, opr, (CodeEmitInfo*)nullptr /* info */),
1045     _stub(nullptr) {
1046   if (VM_Version::supports_stack_watermark_barrier()) {
1047     _stub = new C1SafepointPollStub();
1048   }
1049 }
1050 
1051 //---------------------------------------------------
1052 
1053 
1054 void LIR_OpJavaCall::emit_code(LIR_Assembler* masm) {
1055   masm->emit_call(this);
1056 }
1057 
1058 bool LIR_OpJavaCall::maybe_return_as_fields(ciInlineKlass** vk_ret) const {
1059   ciType* return_type = method()->return_type();
1060   if (InlineTypeReturnedAsFields) {
1061     if (return_type->is_inlinetype()) {
1062       ciInlineKlass* vk = return_type->as_inline_klass();
1063       if (vk->can_be_returned_as_fields()) {
1064         if (vk_ret != nullptr) {
1065           *vk_ret = vk;
1066         }
1067         return true;
1068       }
1069     } else if (return_type->is_instance_klass() &&
1070                (method()->is_method_handle_intrinsic() || !return_type->is_loaded() ||
1071                 StressCallingConvention)) {
1072       // An inline type might be returned from the call but we don't know its type.
1073       // This can happen with method handle intrinsics or when the return type is
1074       // not loaded (method holder is not loaded or preload attribute is missing).
1075       // If an inline type is returned, we either get an oop to a buffer and nothing
1076       // needs to be done or one of the values being returned is the klass of the
1077       // inline type (RAX on x64, with LSB set to 1) and we need to allocate an inline
1078       // type instance of that type and initialize it with the fields values being
1079       // returned in other registers.
1080       return true;
1081     }
1082   }
1083   return false;
1084 }
1085 
1086 void LIR_OpRTCall::emit_code(LIR_Assembler* masm) {
1087   masm->emit_rtcall(this);
1088 }
1089 
1090 void LIR_OpLabel::emit_code(LIR_Assembler* masm) {
1091   masm->emit_opLabel(this);
1092 }
1093 
1094 void LIR_OpArrayCopy::emit_code(LIR_Assembler* masm) {
1095   masm->emit_arraycopy(this);
1096   ArrayCopyStub* code_stub = stub();
1097   if (code_stub != nullptr) {
1098     masm->append_code_stub(code_stub);
1099   }
1100 }
1101 
1102 void LIR_OpUpdateCRC32::emit_code(LIR_Assembler* masm) {
1103   masm->emit_updatecrc32(this);
1104 }
1105 

1126 void LIR_OpConvert::emit_code(LIR_Assembler* masm) {
1127   masm->emit_opConvert(this);
1128 }
1129 
1130 void LIR_Op2::emit_code(LIR_Assembler* masm) {
1131   masm->emit_op2(this);
1132 }
1133 
1134 void LIR_OpAllocArray::emit_code(LIR_Assembler* masm) {
1135   masm->emit_alloc_array(this);
1136   masm->append_code_stub(stub());
1137 }
1138 
1139 void LIR_OpTypeCheck::emit_code(LIR_Assembler* masm) {
1140   masm->emit_opTypeCheck(this);
1141   if (stub()) {
1142     masm->append_code_stub(stub());
1143   }
1144 }
1145 
1146 void LIR_OpFlattenedArrayCheck::emit_code(LIR_Assembler* masm) {
1147   masm->emit_opFlattenedArrayCheck(this);
1148   if (stub() != nullptr) {
1149     masm->append_code_stub(stub());
1150   }
1151 }
1152 
1153 void LIR_OpNullFreeArrayCheck::emit_code(LIR_Assembler* masm) {
1154   masm->emit_opNullFreeArrayCheck(this);
1155 }
1156 
1157 void LIR_OpSubstitutabilityCheck::emit_code(LIR_Assembler* masm) {
1158   masm->emit_opSubstitutabilityCheck(this);
1159   if (stub() != nullptr) {
1160     masm->append_code_stub(stub());
1161   }
1162 }
1163 
1164 void LIR_OpCompareAndSwap::emit_code(LIR_Assembler* masm) {
1165   masm->emit_compare_and_swap(this);
1166 }
1167 
1168 void LIR_Op3::emit_code(LIR_Assembler* masm) {
1169   masm->emit_op3(this);
1170 }
1171 
1172 void LIR_Op4::emit_code(LIR_Assembler* masm) {
1173   masm->emit_op4(this);
1174 }
1175 
1176 void LIR_OpLock::emit_code(LIR_Assembler* masm) {
1177   masm->emit_lock(this);
1178   if (stub()) {
1179     masm->append_code_stub(stub());
1180   }
1181   if (throw_ie_stub()) {
1182     masm->append_code_stub(throw_ie_stub());
1183   }
1184 }
1185 
1186 void LIR_OpLoadKlass::emit_code(LIR_Assembler* masm) {
1187   masm->emit_load_klass(this);
1188 }
1189 
1190 #ifdef ASSERT
1191 void LIR_OpAssert::emit_code(LIR_Assembler* masm) {
1192   masm->emit_assert(this);
1193 }
1194 #endif
1195 
1196 void LIR_OpProfileCall::emit_code(LIR_Assembler* masm) {
1197   masm->emit_profile_call(this);
1198 }
1199 
1200 void LIR_OpProfileType::emit_code(LIR_Assembler* masm) {
1201   masm->emit_profile_type(this);
1202 }
1203 
1204 void LIR_OpProfileInlineType::emit_code(LIR_Assembler* masm) {
1205   masm->emit_profile_inline_type(this);
1206 }
1207 
1208 // LIR_List
1209 LIR_List::LIR_List(Compilation* compilation, BlockBegin* block)
1210   : _operations(8)
1211   , _compilation(compilation)
1212 #ifndef PRODUCT
1213   , _block(block)
1214 #endif
1215 #ifdef ASSERT
1216   , _file(nullptr)
1217   , _line(0)
1218 #endif
1219 #ifdef RISCV
1220   , _cmp_opr1(LIR_OprFact::illegalOpr)
1221   , _cmp_opr2(LIR_OprFact::illegalOpr)
1222 #endif
1223 { }
1224 
1225 
1226 #ifdef ASSERT
1227 void LIR_List::set_file_and_line(const char * file, int line) {

1463                     reg,
1464                     LIR_OprFact::address(addr),
1465                     info));
1466 }
1467 
1468 void LIR_List::allocate_object(LIR_Opr dst, LIR_Opr t1, LIR_Opr t2, LIR_Opr t3, LIR_Opr t4,
1469                                int header_size, int object_size, LIR_Opr klass, bool init_check, CodeStub* stub) {
1470   append(new LIR_OpAllocObj(
1471                            klass,
1472                            dst,
1473                            t1,
1474                            t2,
1475                            t3,
1476                            t4,
1477                            header_size,
1478                            object_size,
1479                            init_check,
1480                            stub));
1481 }
1482 
1483 void LIR_List::allocate_array(LIR_Opr dst, LIR_Opr len, LIR_Opr t1,LIR_Opr t2, LIR_Opr t3,LIR_Opr t4, BasicType type, LIR_Opr klass, CodeStub* stub, bool zero_array, bool always_slow_path) {
1484   append(new LIR_OpAllocArray(
1485                            klass,
1486                            len,
1487                            dst,
1488                            t1,
1489                            t2,
1490                            t3,
1491                            t4,
1492                            type,
1493                            stub,
1494                            zero_array,
1495                            always_slow_path));
1496 }
1497 
1498 void LIR_List::shift_left(LIR_Opr value, LIR_Opr count, LIR_Opr dst, LIR_Opr tmp) {
1499  append(new LIR_Op2(
1500                     lir_shl,
1501                     value,
1502                     count,
1503                     dst,
1504                     tmp));
1505 }
1506 
1507 void LIR_List::shift_right(LIR_Opr value, LIR_Opr count, LIR_Opr dst, LIR_Opr tmp) {
1508  append(new LIR_Op2(
1509                     lir_shr,
1510                     value,
1511                     count,
1512                     dst,
1513                     tmp));
1514 }
1515 
1516 
1517 void LIR_List::unsigned_shift_right(LIR_Opr value, LIR_Opr count, LIR_Opr dst, LIR_Opr tmp) {
1518  append(new LIR_Op2(
1519                     lir_ushr,
1520                     value,
1521                     count,
1522                     dst,
1523                     tmp));
1524 }
1525 
1526 void LIR_List::fcmp2int(LIR_Opr left, LIR_Opr right, LIR_Opr dst, bool is_unordered_less) {
1527   append(new LIR_Op2(is_unordered_less ? lir_ucmp_fd2i : lir_cmp_fd2i,
1528                      left,
1529                      right,
1530                      dst));
1531 }
1532 
1533 void LIR_List::lock_object(LIR_Opr hdr, LIR_Opr obj, LIR_Opr lock, LIR_Opr scratch, CodeStub* stub, CodeEmitInfo* info, CodeStub* throw_ie_stub) {
1534   append(new LIR_OpLock(
1535                     lir_lock,
1536                     hdr,
1537                     obj,
1538                     lock,
1539                     scratch,
1540                     stub,
1541                     info,
1542                     throw_ie_stub));
1543 }
1544 
1545 void LIR_List::unlock_object(LIR_Opr hdr, LIR_Opr obj, LIR_Opr lock, LIR_Opr scratch, CodeStub* stub) {
1546   append(new LIR_OpLock(
1547                     lir_unlock,
1548                     hdr,
1549                     obj,
1550                     lock,
1551                     scratch,
1552                     stub,
1553                     nullptr));
1554 }
1555 
1556 
1557 void check_LIR() {
1558   // cannot do the proper checking as PRODUCT and other modes return different results
1559   // guarantee(sizeof(LIR_Opr) == wordSize, "may not have a v-table");
1560 }
1561 
1562 
1563 
1564 void LIR_List::checkcast (LIR_Opr result, LIR_Opr object, ciKlass* klass,
1565                           LIR_Opr tmp1, LIR_Opr tmp2, LIR_Opr tmp3, bool fast_check,
1566                           CodeEmitInfo* info_for_exception, CodeEmitInfo* info_for_patch, CodeStub* stub,
1567                           ciMethod* profiled_method, int profiled_bci, bool is_null_free) {
1568   // If klass is non-nullable,  LIRGenerator::do_CheckCast has already performed null-check
1569   // on the object.
1570   bool need_null_check = !is_null_free;
1571   LIR_OpTypeCheck* c = new LIR_OpTypeCheck(lir_checkcast, result, object, klass,
1572                                            tmp1, tmp2, tmp3, fast_check, info_for_exception, info_for_patch, stub,
1573                                            need_null_check);
1574   if (profiled_method != nullptr && TypeProfileCasts) {
1575     c->set_profiled_method(profiled_method);
1576     c->set_profiled_bci(profiled_bci);
1577     c->set_should_profile(true);
1578   }
1579   append(c);
1580 }
1581 
1582 void LIR_List::instanceof(LIR_Opr result, LIR_Opr object, ciKlass* klass, LIR_Opr tmp1, LIR_Opr tmp2, LIR_Opr tmp3, bool fast_check, CodeEmitInfo* info_for_patch, ciMethod* profiled_method, int profiled_bci) {
1583   LIR_OpTypeCheck* c = new LIR_OpTypeCheck(lir_instanceof, result, object, klass, tmp1, tmp2, tmp3, fast_check, nullptr, info_for_patch, nullptr);
1584   if (profiled_method != nullptr && TypeProfileCasts) {
1585     c->set_profiled_method(profiled_method);
1586     c->set_profiled_bci(profiled_bci);
1587     c->set_should_profile(true);
1588   }
1589   append(c);
1590 }
1591 
1592 
1593 void LIR_List::store_check(LIR_Opr object, LIR_Opr array, LIR_Opr tmp1, LIR_Opr tmp2, LIR_Opr tmp3,
1594                            CodeEmitInfo* info_for_exception, ciMethod* profiled_method, int profiled_bci) {
1595   // FIXME -- if the types of the array and/or the object are known statically, we can avoid loading the klass
1596   LIR_OpTypeCheck* c = new LIR_OpTypeCheck(lir_store_check, object, array, tmp1, tmp2, tmp3, info_for_exception);
1597   if (profiled_method != nullptr && TypeProfileCasts) {
1598     c->set_profiled_method(profiled_method);
1599     c->set_profiled_bci(profiled_bci);
1600     c->set_should_profile(true);
1601   }
1602   append(c);
1603 }
1604 
1605 void LIR_List::null_check(LIR_Opr opr, CodeEmitInfo* info, bool deoptimize_on_null) {
1606   if (deoptimize_on_null) {
1607     // Emit an explicit null check and deoptimize if opr is null
1608     CodeStub* deopt = new DeoptimizeStub(info, Deoptimization::Reason_null_check, Deoptimization::Action_none);
1609     cmp(lir_cond_equal, opr, LIR_OprFact::oopConst(nullptr));
1610     branch(lir_cond_equal, deopt);
1611   } else {
1612     // Emit an implicit null check
1613     append(new LIR_Op1(lir_null_check, opr, info));
1614   }
1615 }
1616 
1617 void LIR_List::check_flat_array(LIR_Opr array, LIR_Opr value, LIR_Opr tmp, CodeStub* stub) {
1618   LIR_OpFlattenedArrayCheck* c = new LIR_OpFlattenedArrayCheck(array, value, tmp, stub);
1619   append(c);
1620 }
1621 
1622 void LIR_List::check_null_free_array(LIR_Opr array, LIR_Opr tmp) {
1623   LIR_OpNullFreeArrayCheck* c = new LIR_OpNullFreeArrayCheck(array, tmp);
1624   append(c);
1625 }
1626 
1627 void LIR_List::substitutability_check(LIR_Opr result, LIR_Opr left, LIR_Opr right, LIR_Opr equal_result, LIR_Opr not_equal_result,
1628                                       ciKlass* left_klass, ciKlass* right_klass, LIR_Opr tmp1, LIR_Opr tmp2,
1629                                       CodeEmitInfo* info, CodeStub* stub) {
1630   LIR_OpSubstitutabilityCheck* c = new LIR_OpSubstitutabilityCheck(result, left, right, equal_result, not_equal_result,
1631                                                                    left_klass, right_klass, tmp1, tmp2, info, stub);
1632   append(c);
1633 }
1634 
1635 void LIR_List::cas_long(LIR_Opr addr, LIR_Opr cmp_value, LIR_Opr new_value,
1636                         LIR_Opr t1, LIR_Opr t2, LIR_Opr result) {
1637   append(new LIR_OpCompareAndSwap(lir_cas_long, addr, cmp_value, new_value, t1, t2, result));
1638 }
1639 
1640 void LIR_List::cas_obj(LIR_Opr addr, LIR_Opr cmp_value, LIR_Opr new_value,
1641                        LIR_Opr t1, LIR_Opr t2, LIR_Opr result) {
1642   append(new LIR_OpCompareAndSwap(lir_cas_obj, addr, cmp_value, new_value, t1, t2, result));
1643 }
1644 
1645 void LIR_List::cas_int(LIR_Opr addr, LIR_Opr cmp_value, LIR_Opr new_value,
1646                        LIR_Opr t1, LIR_Opr t2, LIR_Opr result) {
1647   append(new LIR_OpCompareAndSwap(lir_cas_int, addr, cmp_value, new_value, t1, t2, result));
1648 }
1649 
1650 
1651 #ifdef PRODUCT
1652 
1653 void print_LIR(BlockList* blocks) {
1654 }

1830 }
1831 
1832 const char * LIR_Op::name() const {
1833   const char* s = nullptr;
1834   switch(code()) {
1835      // LIR_Op0
1836      case lir_membar:                s = "membar";        break;
1837      case lir_membar_acquire:        s = "membar_acquire"; break;
1838      case lir_membar_release:        s = "membar_release"; break;
1839      case lir_membar_loadload:       s = "membar_loadload";   break;
1840      case lir_membar_storestore:     s = "membar_storestore"; break;
1841      case lir_membar_loadstore:      s = "membar_loadstore";  break;
1842      case lir_membar_storeload:      s = "membar_storeload";  break;
1843      case lir_label:                 s = "label";         break;
1844      case lir_nop:                   s = "nop";           break;
1845      case lir_on_spin_wait:          s = "on_spin_wait";  break;
1846      case lir_std_entry:             s = "std_entry";     break;
1847      case lir_osr_entry:             s = "osr_entry";     break;
1848      case lir_breakpoint:            s = "breakpoint";    break;
1849      case lir_get_thread:            s = "get_thread";    break;
1850      case lir_check_orig_pc:         s = "check_orig_pc"; break;
1851      // LIR_Op1
1852      case lir_push:                  s = "push";          break;
1853      case lir_pop:                   s = "pop";           break;
1854      case lir_null_check:            s = "null_check";    break;
1855      case lir_return:                s = "return";        break;
1856      case lir_safepoint:             s = "safepoint";     break;
1857      case lir_leal:                  s = "leal";          break;
1858      case lir_branch:                s = "branch";        break;
1859      case lir_cond_float_branch:     s = "flt_cond_br";   break;
1860      case lir_move:                  s = "move";          break;
1861      case lir_abs:                   s = "abs";           break;
1862      case lir_neg:                   s = "neg";           break;
1863      case lir_sqrt:                  s = "sqrt";          break;
1864      case lir_f2hf:                  s = "f2hf";          break;
1865      case lir_hf2f:                  s = "hf2f";          break;
1866      case lir_rtcall:                s = "rtcall";        break;
1867      case lir_throw:                 s = "throw";         break;
1868      case lir_unwind:                s = "unwind";        break;
1869      case lir_convert:               s = "convert";       break;
1870      case lir_alloc_object:          s = "alloc_obj";     break;

1894      case lir_fmad:                  s = "fmad";          break;
1895      case lir_fmaf:                  s = "fmaf";          break;
1896      // LIR_Op4
1897      case lir_cmove:                 s = "cmove";         break;
1898      // LIR_OpJavaCall
1899      case lir_static_call:           s = "static";        break;
1900      case lir_optvirtual_call:       s = "optvirtual";    break;
1901      case lir_icvirtual_call:        s = "icvirtual";     break;
1902      case lir_dynamic_call:          s = "dynamic";       break;
1903      // LIR_OpArrayCopy
1904      case lir_arraycopy:             s = "arraycopy";     break;
1905      // LIR_OpUpdateCRC32
1906      case lir_updatecrc32:           s = "updatecrc32";   break;
1907      // LIR_OpLock
1908      case lir_lock:                  s = "lock";          break;
1909      case lir_unlock:                s = "unlock";        break;
1910      // LIR_OpTypeCheck
1911      case lir_instanceof:            s = "instanceof";    break;
1912      case lir_checkcast:             s = "checkcast";     break;
1913      case lir_store_check:           s = "store_check";   break;
1914      // LIR_OpFlattenedArrayCheck
1915      case lir_flat_array_check:      s = "flat_array_check"; break;
1916      // LIR_OpNullFreeArrayCheck
1917      case lir_null_free_array_check: s = "null_free_array_check"; break;
1918      // LIR_OpSubstitutabilityCheck
1919      case lir_substitutability_check: s = "substitutability_check"; break;
1920      // LIR_OpCompareAndSwap
1921      case lir_cas_long:              s = "cas_long";      break;
1922      case lir_cas_obj:               s = "cas_obj";      break;
1923      case lir_cas_int:               s = "cas_int";      break;
1924      // LIR_OpProfileCall
1925      case lir_profile_call:          s = "profile_call";  break;
1926      // LIR_OpProfileType
1927      case lir_profile_type:          s = "profile_type";  break;
1928      // LIR_OpProfileInlineType
1929      case lir_profile_inline_type:   s = "profile_inline_type"; break;
1930      // LIR_OpAssert
1931 #ifdef ASSERT
1932      case lir_assert:                s = "assert";        break;
1933 #endif
1934      case lir_none:                  ShouldNotReachHere();break;
1935     default:                         s = "illegal_op";    break;
1936   }
1937   return s;
1938 }
1939 
1940 // LIR_OpJavaCall
1941 void LIR_OpJavaCall::print_instr(outputStream* out) const {
1942   out->print("call: ");
1943   out->print("[addr: " INTPTR_FORMAT "]", p2i(address()));
1944   if (receiver()->is_valid()) {
1945     out->print(" [recv: ");   receiver()->print(out);   out->print("]");
1946   }
1947   if (result_opr()->is_valid()) {
1948     out->print(" [result: "); result_opr()->print(out); out->print("]");
1949   }

2135   out->print("[label:" INTPTR_FORMAT "]", p2i(stub()->entry()));
2136 }
2137 
2138 
2139 void LIR_OpTypeCheck::print_instr(outputStream* out) const {
2140   object()->print(out);                  out->print(" ");
2141   if (code() == lir_store_check) {
2142     array()->print(out);                 out->print(" ");
2143   }
2144   if (code() != lir_store_check) {
2145     klass()->print_name_on(out);         out->print(" ");
2146     if (fast_check())                 out->print("fast_check ");
2147   }
2148   tmp1()->print(out);                    out->print(" ");
2149   tmp2()->print(out);                    out->print(" ");
2150   tmp3()->print(out);                    out->print(" ");
2151   result_opr()->print(out);              out->print(" ");
2152   if (info_for_exception() != nullptr) out->print(" [bci:%d]", info_for_exception()->stack()->bci());
2153 }
2154 
2155 void LIR_OpFlattenedArrayCheck::print_instr(outputStream* out) const {
2156   array()->print(out);                   out->print(" ");
2157   value()->print(out);                   out->print(" ");
2158   tmp()->print(out);                     out->print(" ");
2159   if (stub() != nullptr) {
2160     out->print("[label:" INTPTR_FORMAT "]", p2i(stub()->entry()));
2161   }
2162 }
2163 
2164 void LIR_OpNullFreeArrayCheck::print_instr(outputStream* out) const {
2165   array()->print(out);                   out->print(" ");
2166   tmp()->print(out);                     out->print(" ");
2167 }
2168 
2169 void LIR_OpSubstitutabilityCheck::print_instr(outputStream* out) const {
2170   result_opr()->print(out);              out->print(" ");
2171   left()->print(out);                    out->print(" ");
2172   right()->print(out);                   out->print(" ");
2173   equal_result()->print(out);            out->print(" ");
2174   not_equal_result()->print(out);        out->print(" ");
2175   if (left_klass() == nullptr) {
2176     out->print("unknown ");
2177   } else {
2178     left_klass()->print(out);            out->print(" ");
2179   }
2180   if (right_klass() == nullptr) {
2181     out->print("unknown ");
2182   } else {
2183     right_klass()->print(out);           out->print(" ");
2184   }
2185   tmp1()->print(out);                    out->print(" ");
2186   tmp2()->print(out);                    out->print(" ");
2187   if (stub() != nullptr) {
2188     out->print("[label:" INTPTR_FORMAT "]", p2i(stub()->entry()));
2189   }
2190 }
2191 
2192 // LIR_Op3
2193 void LIR_Op3::print_instr(outputStream* out) const {
2194   in_opr1()->print(out);    out->print(" ");
2195   in_opr2()->print(out);    out->print(" ");
2196   in_opr3()->print(out);    out->print(" ");
2197   result_opr()->print(out);
2198 }
2199 
2200 // LIR_Op4
2201 void LIR_Op4::print_instr(outputStream* out) const {
2202   print_condition(out, condition()); out->print(" ");
2203   in_opr1()->print(out);             out->print(" ");
2204   in_opr2()->print(out);             out->print(" ");
2205   in_opr3()->print(out);             out->print(" ");
2206   in_opr4()->print(out);             out->print(" ");
2207   result_opr()->print(out);
2208 }
2209 
2210 void LIR_OpLock::print_instr(outputStream* out) const {

2241   mdo()->print(out);           out->print(" ");
2242   recv()->print(out);          out->print(" ");
2243   tmp1()->print(out);          out->print(" ");
2244 }
2245 
2246 // LIR_OpProfileType
2247 void LIR_OpProfileType::print_instr(outputStream* out) const {
2248   out->print("exact = ");
2249   if (exact_klass() == nullptr) {
2250     out->print("unknown");
2251   } else {
2252     exact_klass()->print_name_on(out);
2253   }
2254   out->print(" current = "); ciTypeEntries::print_ciklass(out, current_klass());
2255   out->print(" ");
2256   mdp()->print(out);          out->print(" ");
2257   obj()->print(out);          out->print(" ");
2258   tmp()->print(out);          out->print(" ");
2259 }
2260 
2261 // LIR_OpProfileInlineType
2262 void LIR_OpProfileInlineType::print_instr(outputStream* out) const {
2263   out->print(" flag = %x ", flag());
2264   mdp()->print(out);          out->print(" ");
2265   obj()->print(out);          out->print(" ");
2266   tmp()->print(out);          out->print(" ");
2267 }
2268 
2269 #endif // PRODUCT
2270 
2271 // Implementation of LIR_InsertionBuffer
2272 
2273 void LIR_InsertionBuffer::append(int index, LIR_Op* op) {
2274   assert(_index_and_count.length() % 2 == 0, "must have a count for each index");
2275 
2276   int i = number_of_insertion_points() - 1;
2277   if (i < 0 || index_at(i) < index) {
2278     append_new(index, 1);
2279   } else {
2280     assert(index_at(i) == index, "can append LIR_Ops in ascending order only");
2281     assert(count_at(i) > 0, "check");
2282     set_count_at(i, count_at(i) + 1);
2283   }
2284   _ops.push(op);
2285 
2286   DEBUG_ONLY(verify());
2287 }
2288 
< prev index next >