1 /* 2 * Copyright (c) 2000, 2023, 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 "precompiled.hpp" 26 #include "c1/c1_CodeStubs.hpp" 27 #include "c1/c1_InstructionPrinter.hpp" 28 #include "c1/c1_LIR.hpp" 29 #include "c1/c1_LIRAssembler.hpp" 30 #include "c1/c1_ValueStack.hpp" 31 #include "ci/ciInlineKlass.hpp" 32 #include "ci/ciInstance.hpp" 33 #include "runtime/safepointMechanism.inline.hpp" 34 #include "runtime/sharedRuntime.hpp" 35 #include "runtime/vm_version.hpp" 36 37 Register LIR_Opr::as_register() const { 38 return FrameMap::cpu_rnr2reg(cpu_regnr()); 39 } 40 41 Register LIR_Opr::as_register_lo() const { 42 return FrameMap::cpu_rnr2reg(cpu_regnrLo()); 43 } 44 45 Register LIR_Opr::as_register_hi() const { 46 return FrameMap::cpu_rnr2reg(cpu_regnrHi()); 47 } 48 49 LIR_Opr LIR_OprFact::illegalOpr = LIR_OprFact::illegal(); 50 LIR_Opr LIR_OprFact::nullOpr = LIR_Opr(); 51 52 LIR_Opr LIR_OprFact::value_type(ValueType* type) { 53 ValueTag tag = type->tag(); 54 switch (tag) { 55 case metaDataTag : { 56 ClassConstant* c = type->as_ClassConstant(); 57 if (c != nullptr && !c->value()->is_loaded()) { 58 return LIR_OprFact::metadataConst(nullptr); 59 } else if (c != nullptr) { 60 return LIR_OprFact::metadataConst(c->value()->constant_encoding()); 61 } else { 62 MethodConstant* m = type->as_MethodConstant(); 63 assert (m != nullptr, "not a class or a method?"); 64 return LIR_OprFact::metadataConst(m->value()->constant_encoding()); 65 } 66 } 67 case objectTag : { 68 return LIR_OprFact::oopConst(type->as_ObjectType()->encoding()); 69 } 70 case addressTag: return LIR_OprFact::addressConst(type->as_AddressConstant()->value()); 71 case intTag : return LIR_OprFact::intConst(type->as_IntConstant()->value()); 72 case floatTag : return LIR_OprFact::floatConst(type->as_FloatConstant()->value()); 73 case longTag : return LIR_OprFact::longConst(type->as_LongConstant()->value()); 74 case doubleTag : return LIR_OprFact::doubleConst(type->as_DoubleConstant()->value()); 75 default: ShouldNotReachHere(); return LIR_OprFact::intConst(-1); 76 } 77 } 78 79 80 //--------------------------------------------------- 81 82 83 LIR_Address::Scale LIR_Address::scale(BasicType type) { 84 int elem_size = type2aelembytes(type); 85 switch (elem_size) { 86 case 1: return LIR_Address::times_1; 87 case 2: return LIR_Address::times_2; 88 case 4: return LIR_Address::times_4; 89 case 8: return LIR_Address::times_8; 90 } 91 ShouldNotReachHere(); 92 return LIR_Address::times_1; 93 } 94 95 //--------------------------------------------------- 96 97 char LIR_Opr::type_char(BasicType t) { 98 switch (t) { 99 case T_ARRAY: 100 t = T_OBJECT; 101 case T_BOOLEAN: 102 case T_CHAR: 103 case T_FLOAT: 104 case T_DOUBLE: 105 case T_BYTE: 106 case T_SHORT: 107 case T_INT: 108 case T_LONG: 109 case T_OBJECT: 110 case T_ADDRESS: 111 case T_VOID: 112 return ::type2char(t); 113 case T_METADATA: 114 return 'M'; 115 case T_ILLEGAL: 116 return '?'; 117 118 default: 119 ShouldNotReachHere(); 120 return '?'; 121 } 122 } 123 124 #ifndef PRODUCT 125 void LIR_Opr::validate_type() const { 126 127 #ifdef ASSERT 128 if (!is_pointer() && !is_illegal()) { 129 OprKind kindfield = kind_field(); // Factored out because of compiler bug, see 8002160 130 switch (as_BasicType(type_field())) { 131 case T_LONG: 132 assert((kindfield == cpu_register || kindfield == stack_value) && 133 size_field() == double_size, "must match"); 134 break; 135 case T_FLOAT: 136 // FP return values can be also in CPU registers on ARM (softfp ABI) 137 assert((kindfield == fpu_register || kindfield == stack_value 138 ARM_ONLY(|| kindfield == cpu_register) ) && 139 size_field() == single_size, "must match"); 140 break; 141 case T_DOUBLE: 142 // FP return values can be also in CPU registers on ARM (softfp ABI) 143 assert((kindfield == fpu_register || kindfield == stack_value 144 ARM_ONLY(|| kindfield == cpu_register) ) && 145 size_field() == double_size, "must match"); 146 break; 147 case T_BOOLEAN: 148 case T_CHAR: 149 case T_BYTE: 150 case T_SHORT: 151 case T_INT: 152 case T_ADDRESS: 153 case T_OBJECT: 154 case T_METADATA: 155 case T_ARRAY: 156 assert((kindfield == cpu_register || kindfield == stack_value) && 157 size_field() == single_size, "must match"); 158 break; 159 160 case T_ILLEGAL: 161 // XXX TKR also means unknown right now 162 // assert(is_illegal(), "must match"); 163 break; 164 165 default: 166 ShouldNotReachHere(); 167 } 168 } 169 #endif 170 171 } 172 #endif // PRODUCT 173 174 175 bool LIR_Opr::is_oop() const { 176 if (is_pointer()) { 177 return pointer()->is_oop_pointer(); 178 } else { 179 OprType t= type_field(); 180 assert(t != unknown_type, "not set"); 181 return t == object_type; 182 } 183 } 184 185 186 187 void LIR_Op2::verify() const { 188 #ifdef ASSERT 189 switch (code()) { 190 case lir_xchg: 191 break; 192 193 default: 194 assert(!result_opr()->is_register() || !result_opr()->is_oop_register(), 195 "can't produce oops from arith"); 196 } 197 198 if (two_operand_lir_form) { 199 200 bool threeOperandForm = false; 201 #ifdef S390 202 // There are 3 operand shifts on S390 (see LIR_Assembler::shift_op()). 203 threeOperandForm = 204 code() == lir_shl || 205 ((code() == lir_shr || code() == lir_ushr) && (result_opr()->is_double_cpu() || in_opr1()->type() == T_OBJECT)); 206 #endif 207 208 switch (code()) { 209 case lir_add: 210 case lir_sub: 211 case lir_mul: 212 case lir_div: 213 case lir_rem: 214 case lir_logic_and: 215 case lir_logic_or: 216 case lir_logic_xor: 217 case lir_shl: 218 case lir_shr: 219 assert(in_opr1() == result_opr() || threeOperandForm, "opr1 and result must match"); 220 assert(in_opr1()->is_valid() && in_opr2()->is_valid(), "must be valid"); 221 break; 222 223 // special handling for lir_ushr because of write barriers 224 case lir_ushr: 225 assert(in_opr1() == result_opr() || in_opr2()->is_constant() || threeOperandForm, "opr1 and result must match or shift count is constant"); 226 assert(in_opr1()->is_valid() && in_opr2()->is_valid(), "must be valid"); 227 break; 228 229 default: 230 break; 231 } 232 } 233 #endif 234 } 235 236 237 LIR_OpBranch::LIR_OpBranch(LIR_Condition cond, BlockBegin* block) 238 : LIR_Op2(lir_branch, cond, LIR_OprFact::illegalOpr, LIR_OprFact::illegalOpr, (CodeEmitInfo*)nullptr) 239 , _label(block->label()) 240 , _block(block) 241 , _ublock(nullptr) 242 , _stub(nullptr) { 243 } 244 245 LIR_OpBranch::LIR_OpBranch(LIR_Condition cond, CodeStub* stub) : 246 LIR_Op2(lir_branch, cond, LIR_OprFact::illegalOpr, LIR_OprFact::illegalOpr, (CodeEmitInfo*)nullptr) 247 , _label(stub->entry()) 248 , _block(nullptr) 249 , _ublock(nullptr) 250 , _stub(stub) { 251 } 252 253 LIR_OpBranch::LIR_OpBranch(LIR_Condition cond, BlockBegin* block, BlockBegin* ublock) 254 : LIR_Op2(lir_cond_float_branch, cond, LIR_OprFact::illegalOpr, LIR_OprFact::illegalOpr, (CodeEmitInfo*)nullptr) 255 , _label(block->label()) 256 , _block(block) 257 , _ublock(ublock) 258 , _stub(nullptr) 259 { 260 } 261 262 void LIR_OpBranch::change_block(BlockBegin* b) { 263 assert(_block != nullptr, "must have old block"); 264 assert(_block->label() == label(), "must be equal"); 265 266 _block = b; 267 _label = b->label(); 268 } 269 270 void LIR_OpBranch::change_ublock(BlockBegin* b) { 271 assert(_ublock != nullptr, "must have old block"); 272 _ublock = b; 273 } 274 275 void LIR_OpBranch::negate_cond() { 276 switch (cond()) { 277 case lir_cond_equal: set_cond(lir_cond_notEqual); break; 278 case lir_cond_notEqual: set_cond(lir_cond_equal); break; 279 case lir_cond_less: set_cond(lir_cond_greaterEqual); break; 280 case lir_cond_lessEqual: set_cond(lir_cond_greater); break; 281 case lir_cond_greaterEqual: set_cond(lir_cond_less); break; 282 case lir_cond_greater: set_cond(lir_cond_lessEqual); break; 283 default: ShouldNotReachHere(); 284 } 285 } 286 287 288 LIR_OpTypeCheck::LIR_OpTypeCheck(LIR_Code code, LIR_Opr result, LIR_Opr object, ciKlass* klass, 289 LIR_Opr tmp1, LIR_Opr tmp2, LIR_Opr tmp3, 290 bool fast_check, CodeEmitInfo* info_for_exception, CodeEmitInfo* info_for_patch, 291 CodeStub* stub, bool need_null_check) 292 293 : LIR_Op(code, result, nullptr) 294 , _object(object) 295 , _array(LIR_OprFact::illegalOpr) 296 , _klass(klass) 297 , _tmp1(tmp1) 298 , _tmp2(tmp2) 299 , _tmp3(tmp3) 300 , _info_for_patch(info_for_patch) 301 , _info_for_exception(info_for_exception) 302 , _stub(stub) 303 , _profiled_method(nullptr) 304 , _profiled_bci(-1) 305 , _should_profile(false) 306 , _fast_check(fast_check) 307 , _need_null_check(need_null_check) 308 { 309 if (code == lir_checkcast) { 310 assert(info_for_exception != nullptr, "checkcast throws exceptions"); 311 } else if (code == lir_instanceof) { 312 assert(info_for_exception == nullptr, "instanceof throws no exceptions"); 313 } else { 314 ShouldNotReachHere(); 315 } 316 } 317 318 319 320 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) 321 : LIR_Op(code, LIR_OprFact::illegalOpr, nullptr) 322 , _object(object) 323 , _array(array) 324 , _klass(nullptr) 325 , _tmp1(tmp1) 326 , _tmp2(tmp2) 327 , _tmp3(tmp3) 328 , _info_for_patch(nullptr) 329 , _info_for_exception(info_for_exception) 330 , _stub(nullptr) 331 , _profiled_method(nullptr) 332 , _profiled_bci(-1) 333 , _should_profile(false) 334 , _fast_check(false) 335 , _need_null_check(true) 336 { 337 if (code == lir_store_check) { 338 _stub = new ArrayStoreExceptionStub(object, info_for_exception); 339 assert(info_for_exception != nullptr, "store_check throws exceptions"); 340 } else { 341 ShouldNotReachHere(); 342 } 343 } 344 345 LIR_OpFlattenedArrayCheck::LIR_OpFlattenedArrayCheck(LIR_Opr array, LIR_Opr value, LIR_Opr tmp, CodeStub* stub) 346 : LIR_Op(lir_flat_array_check, LIR_OprFact::illegalOpr, nullptr) 347 , _array(array) 348 , _value(value) 349 , _tmp(tmp) 350 , _stub(stub) {} 351 352 353 LIR_OpNullFreeArrayCheck::LIR_OpNullFreeArrayCheck(LIR_Opr array, LIR_Opr tmp) 354 : LIR_Op(lir_null_free_array_check, LIR_OprFact::illegalOpr, nullptr) 355 , _array(array) 356 , _tmp(tmp) {} 357 358 359 LIR_OpSubstitutabilityCheck::LIR_OpSubstitutabilityCheck(LIR_Opr result, LIR_Opr left, LIR_Opr right, LIR_Opr equal_result, LIR_Opr not_equal_result, 360 LIR_Opr tmp1, LIR_Opr tmp2, 361 ciKlass* left_klass, ciKlass* right_klass, LIR_Opr left_klass_op, LIR_Opr right_klass_op, 362 CodeEmitInfo* info, CodeStub* stub) 363 : LIR_Op(lir_substitutability_check, result, info) 364 , _left(left) 365 , _right(right) 366 , _equal_result(equal_result) 367 , _not_equal_result(not_equal_result) 368 , _tmp1(tmp1) 369 , _tmp2(tmp2) 370 , _left_klass(left_klass) 371 , _right_klass(right_klass) 372 , _left_klass_op(left_klass_op) 373 , _right_klass_op(right_klass_op) 374 , _stub(stub) {} 375 376 377 LIR_OpArrayCopy::LIR_OpArrayCopy(LIR_Opr src, LIR_Opr src_pos, LIR_Opr dst, LIR_Opr dst_pos, LIR_Opr length, 378 LIR_Opr tmp, ciArrayKlass* expected_type, int flags, CodeEmitInfo* info) 379 : LIR_Op(lir_arraycopy, LIR_OprFact::illegalOpr, info) 380 , _src(src) 381 , _src_pos(src_pos) 382 , _dst(dst) 383 , _dst_pos(dst_pos) 384 , _length(length) 385 , _tmp(tmp) 386 , _expected_type(expected_type) 387 , _flags(flags) { 388 #if defined(X86) || defined(AARCH64) || defined(S390) || defined(RISCV) || defined(PPC64) 389 if (expected_type != nullptr && flags == 0) { 390 _stub = nullptr; 391 } else { 392 _stub = new ArrayCopyStub(this); 393 } 394 #else 395 _stub = new ArrayCopyStub(this); 396 #endif 397 } 398 399 LIR_OpUpdateCRC32::LIR_OpUpdateCRC32(LIR_Opr crc, LIR_Opr val, LIR_Opr res) 400 : LIR_Op(lir_updatecrc32, res, nullptr) 401 , _crc(crc) 402 , _val(val) { 403 } 404 405 //-------------------verify-------------------------- 406 407 void LIR_Op1::verify() const { 408 switch(code()) { 409 case lir_move: 410 assert(in_opr()->is_valid() && result_opr()->is_valid(), "must be"); 411 break; 412 case lir_null_check: 413 assert(in_opr()->is_register(), "must be"); 414 break; 415 case lir_return: 416 assert(in_opr()->is_register() || in_opr()->is_illegal(), "must be"); 417 break; 418 default: 419 break; 420 } 421 } 422 423 void LIR_OpRTCall::verify() const { 424 assert(strcmp(Runtime1::name_for_address(addr()), "<unknown function>") != 0, "unknown function"); 425 } 426 427 //-------------------visits-------------------------- 428 429 // complete rework of LIR instruction visitor. 430 // The virtual call for each instruction type is replaced by a big 431 // switch that adds the operands for each instruction 432 433 void LIR_OpVisitState::visit(LIR_Op* op) { 434 // copy information from the LIR_Op 435 reset(); 436 set_op(op); 437 438 switch (op->code()) { 439 440 // LIR_Op0 441 case lir_fpop_raw: // result and info always invalid 442 case lir_breakpoint: // result and info always invalid 443 case lir_membar: // result and info always invalid 444 case lir_membar_acquire: // result and info always invalid 445 case lir_membar_release: // result and info always invalid 446 case lir_membar_loadload: // result and info always invalid 447 case lir_membar_storestore: // result and info always invalid 448 case lir_membar_loadstore: // result and info always invalid 449 case lir_membar_storeload: // result and info always invalid 450 case lir_check_orig_pc: // result and info always invalid 451 case lir_on_spin_wait: 452 { 453 assert(op->as_Op0() != nullptr, "must be"); 454 assert(op->_info == nullptr, "info not used by this instruction"); 455 assert(op->_result->is_illegal(), "not used"); 456 break; 457 } 458 459 case lir_nop: // may have info, result always invalid 460 case lir_std_entry: // may have result, info always invalid 461 case lir_osr_entry: // may have result, info always invalid 462 case lir_get_thread: // may have result, info always invalid 463 { 464 assert(op->as_Op0() != nullptr, "must be"); 465 if (op->_info != nullptr) do_info(op->_info); 466 if (op->_result->is_valid()) do_output(op->_result); 467 break; 468 } 469 470 471 // LIR_OpLabel 472 case lir_label: // result and info always invalid 473 { 474 assert(op->as_OpLabel() != nullptr, "must be"); 475 assert(op->_info == nullptr, "info not used by this instruction"); 476 assert(op->_result->is_illegal(), "not used"); 477 break; 478 } 479 480 481 // LIR_Op1 482 case lir_fxch: // input always valid, result and info always invalid 483 case lir_fld: // input always valid, result and info always invalid 484 case lir_push: // input always valid, result and info always invalid 485 case lir_pop: // input always valid, result and info always invalid 486 case lir_leal: // input and result always valid, info always invalid 487 case lir_monaddr: // input and result always valid, info always invalid 488 case lir_null_check: // input and info always valid, result always invalid 489 case lir_move: // input and result always valid, may have info 490 { 491 assert(op->as_Op1() != nullptr, "must be"); 492 LIR_Op1* op1 = (LIR_Op1*)op; 493 494 if (op1->_info) do_info(op1->_info); 495 if (op1->_opr->is_valid()) do_input(op1->_opr); 496 if (op1->_result->is_valid()) do_output(op1->_result); 497 498 break; 499 } 500 501 case lir_return: 502 { 503 assert(op->as_OpReturn() != nullptr, "must be"); 504 LIR_OpReturn* op_ret = (LIR_OpReturn*)op; 505 506 if (op_ret->_info) do_info(op_ret->_info); 507 if (op_ret->_opr->is_valid()) do_input(op_ret->_opr); 508 if (op_ret->_result->is_valid()) do_output(op_ret->_result); 509 if (op_ret->stub() != nullptr) do_stub(op_ret->stub()); 510 511 break; 512 } 513 514 case lir_safepoint: 515 { 516 assert(op->as_Op1() != nullptr, "must be"); 517 LIR_Op1* op1 = (LIR_Op1*)op; 518 519 assert(op1->_info != nullptr, ""); do_info(op1->_info); 520 if (op1->_opr->is_valid()) do_temp(op1->_opr); // safepoints on SPARC need temporary register 521 assert(op1->_result->is_illegal(), "safepoint does not produce value"); 522 523 break; 524 } 525 526 // LIR_OpConvert; 527 case lir_convert: // input and result always valid, info always invalid 528 { 529 assert(op->as_OpConvert() != nullptr, "must be"); 530 LIR_OpConvert* opConvert = (LIR_OpConvert*)op; 531 532 assert(opConvert->_info == nullptr, "must be"); 533 if (opConvert->_opr->is_valid()) do_input(opConvert->_opr); 534 if (opConvert->_result->is_valid()) do_output(opConvert->_result); 535 do_stub(opConvert->_stub); 536 537 break; 538 } 539 540 // LIR_OpBranch; 541 case lir_branch: // may have info, input and result register always invalid 542 case lir_cond_float_branch: // may have info, input and result register always invalid 543 { 544 assert(op->as_OpBranch() != nullptr, "must be"); 545 LIR_OpBranch* opBranch = (LIR_OpBranch*)op; 546 547 assert(opBranch->_tmp1->is_illegal() && opBranch->_tmp2->is_illegal() && 548 opBranch->_tmp3->is_illegal() && opBranch->_tmp4->is_illegal() && 549 opBranch->_tmp5->is_illegal(), "not used"); 550 551 if (opBranch->_opr1->is_valid()) do_input(opBranch->_opr1); 552 if (opBranch->_opr2->is_valid()) do_input(opBranch->_opr2); 553 554 if (opBranch->_info != nullptr) do_info(opBranch->_info); 555 assert(opBranch->_result->is_illegal(), "not used"); 556 if (opBranch->_stub != nullptr) opBranch->stub()->visit(this); 557 558 break; 559 } 560 561 562 // LIR_OpAllocObj 563 case lir_alloc_object: 564 { 565 assert(op->as_OpAllocObj() != nullptr, "must be"); 566 LIR_OpAllocObj* opAllocObj = (LIR_OpAllocObj*)op; 567 568 if (opAllocObj->_info) do_info(opAllocObj->_info); 569 if (opAllocObj->_opr->is_valid()) { do_input(opAllocObj->_opr); 570 do_temp(opAllocObj->_opr); 571 } 572 if (opAllocObj->_tmp1->is_valid()) do_temp(opAllocObj->_tmp1); 573 if (opAllocObj->_tmp2->is_valid()) do_temp(opAllocObj->_tmp2); 574 if (opAllocObj->_tmp3->is_valid()) do_temp(opAllocObj->_tmp3); 575 if (opAllocObj->_tmp4->is_valid()) do_temp(opAllocObj->_tmp4); 576 if (opAllocObj->_result->is_valid()) do_output(opAllocObj->_result); 577 if (opAllocObj->_stub != nullptr) do_stub(opAllocObj->_stub); 578 break; 579 } 580 581 582 // LIR_OpRoundFP; 583 case lir_roundfp: { 584 assert(op->as_OpRoundFP() != nullptr, "must be"); 585 LIR_OpRoundFP* opRoundFP = (LIR_OpRoundFP*)op; 586 587 assert(op->_info == nullptr, "info not used by this instruction"); 588 assert(opRoundFP->_tmp->is_illegal(), "not used"); 589 do_input(opRoundFP->_opr); 590 do_output(opRoundFP->_result); 591 592 break; 593 } 594 595 596 // LIR_Op2 597 case lir_cmp: 598 case lir_cmp_l2i: 599 case lir_ucmp_fd2i: 600 case lir_cmp_fd2i: 601 case lir_add: 602 case lir_sub: 603 case lir_rem: 604 case lir_sqrt: 605 case lir_abs: 606 case lir_neg: 607 case lir_f2hf: 608 case lir_hf2f: 609 case lir_logic_and: 610 case lir_logic_or: 611 case lir_logic_xor: 612 case lir_shl: 613 case lir_shr: 614 case lir_ushr: 615 case lir_xadd: 616 case lir_xchg: 617 case lir_assert: 618 { 619 assert(op->as_Op2() != nullptr, "must be"); 620 LIR_Op2* op2 = (LIR_Op2*)op; 621 assert(op2->_tmp2->is_illegal() && op2->_tmp3->is_illegal() && 622 op2->_tmp4->is_illegal() && op2->_tmp5->is_illegal(), "not used"); 623 624 if (op2->_info) do_info(op2->_info); 625 if (op2->_opr1->is_valid()) do_input(op2->_opr1); 626 if (op2->_opr2->is_valid()) do_input(op2->_opr2); 627 if (op2->_tmp1->is_valid()) do_temp(op2->_tmp1); 628 if (op2->_result->is_valid()) do_output(op2->_result); 629 if (op->code() == lir_xchg || op->code() == lir_xadd) { 630 // on ARM and PPC, return value is loaded first so could 631 // destroy inputs. On other platforms that implement those 632 // (x86, sparc), the extra constrainsts are harmless. 633 if (op2->_opr1->is_valid()) do_temp(op2->_opr1); 634 if (op2->_opr2->is_valid()) do_temp(op2->_opr2); 635 } 636 637 break; 638 } 639 640 // special handling for cmove: right input operand must not be equal 641 // to the result operand, otherwise the backend fails 642 case lir_cmove: 643 { 644 assert(op->as_Op4() != nullptr, "must be"); 645 LIR_Op4* op4 = (LIR_Op4*)op; 646 647 assert(op4->_info == nullptr && op4->_tmp1->is_illegal() && op4->_tmp2->is_illegal() && 648 op4->_tmp3->is_illegal() && op4->_tmp4->is_illegal() && op4->_tmp5->is_illegal(), "not used"); 649 assert(op4->_opr1->is_valid() && op4->_opr2->is_valid() && op4->_result->is_valid(), "used"); 650 651 do_input(op4->_opr1); 652 do_input(op4->_opr2); 653 if (op4->_opr3->is_valid()) do_input(op4->_opr3); 654 if (op4->_opr4->is_valid()) do_input(op4->_opr4); 655 do_temp(op4->_opr2); 656 do_output(op4->_result); 657 658 break; 659 } 660 661 // vspecial handling for strict operations: register input operands 662 // as temp to guarantee that they do not overlap with other 663 // registers 664 case lir_mul: 665 case lir_div: 666 { 667 assert(op->as_Op2() != nullptr, "must be"); 668 LIR_Op2* op2 = (LIR_Op2*)op; 669 670 assert(op2->_info == nullptr, "not used"); 671 assert(op2->_opr1->is_valid(), "used"); 672 assert(op2->_opr2->is_valid(), "used"); 673 assert(op2->_result->is_valid(), "used"); 674 assert(op2->_tmp2->is_illegal() && op2->_tmp3->is_illegal() && 675 op2->_tmp4->is_illegal() && op2->_tmp5->is_illegal(), "not used"); 676 677 do_input(op2->_opr1); do_temp(op2->_opr1); 678 do_input(op2->_opr2); do_temp(op2->_opr2); 679 if (op2->_tmp1->is_valid()) do_temp(op2->_tmp1); 680 do_output(op2->_result); 681 682 break; 683 } 684 685 case lir_throw: { 686 assert(op->as_Op2() != nullptr, "must be"); 687 LIR_Op2* op2 = (LIR_Op2*)op; 688 689 if (op2->_info) do_info(op2->_info); 690 if (op2->_opr1->is_valid()) do_temp(op2->_opr1); 691 if (op2->_opr2->is_valid()) do_input(op2->_opr2); // exception object is input parameter 692 assert(op2->_result->is_illegal(), "no result"); 693 assert(op2->_tmp2->is_illegal() && op2->_tmp3->is_illegal() && 694 op2->_tmp4->is_illegal() && op2->_tmp5->is_illegal(), "not used"); 695 696 break; 697 } 698 699 case lir_unwind: { 700 assert(op->as_Op1() != nullptr, "must be"); 701 LIR_Op1* op1 = (LIR_Op1*)op; 702 703 assert(op1->_info == nullptr, "no info"); 704 assert(op1->_opr->is_valid(), "exception oop"); do_input(op1->_opr); 705 assert(op1->_result->is_illegal(), "no result"); 706 707 break; 708 } 709 710 // LIR_Op3 711 case lir_idiv: 712 case lir_irem: { 713 assert(op->as_Op3() != nullptr, "must be"); 714 LIR_Op3* op3= (LIR_Op3*)op; 715 716 if (op3->_info) do_info(op3->_info); 717 if (op3->_opr1->is_valid()) do_input(op3->_opr1); 718 719 // second operand is input and temp, so ensure that second operand 720 // and third operand get not the same register 721 if (op3->_opr2->is_valid()) do_input(op3->_opr2); 722 if (op3->_opr2->is_valid()) do_temp(op3->_opr2); 723 if (op3->_opr3->is_valid()) do_temp(op3->_opr3); 724 725 if (op3->_result->is_valid()) do_output(op3->_result); 726 727 break; 728 } 729 730 case lir_fmad: 731 case lir_fmaf: { 732 assert(op->as_Op3() != nullptr, "must be"); 733 LIR_Op3* op3= (LIR_Op3*)op; 734 assert(op3->_info == nullptr, "no info"); 735 do_input(op3->_opr1); 736 do_input(op3->_opr2); 737 do_input(op3->_opr3); 738 do_output(op3->_result); 739 break; 740 } 741 742 // LIR_OpJavaCall 743 case lir_static_call: 744 case lir_optvirtual_call: 745 case lir_icvirtual_call: 746 case lir_dynamic_call: { 747 LIR_OpJavaCall* opJavaCall = op->as_OpJavaCall(); 748 assert(opJavaCall != nullptr, "must be"); 749 750 if (opJavaCall->_receiver->is_valid()) do_input(opJavaCall->_receiver); 751 752 // only visit register parameters 753 int n = opJavaCall->_arguments->length(); 754 for (int i = opJavaCall->_receiver->is_valid() ? 1 : 0; i < n; i++) { 755 if (!opJavaCall->_arguments->at(i)->is_pointer()) { 756 do_input(*opJavaCall->_arguments->adr_at(i)); 757 } 758 } 759 760 if (opJavaCall->_info) do_info(opJavaCall->_info); 761 if (FrameMap::method_handle_invoke_SP_save_opr() != LIR_OprFact::illegalOpr && 762 opJavaCall->is_method_handle_invoke()) { 763 opJavaCall->_method_handle_invoke_SP_save_opr = FrameMap::method_handle_invoke_SP_save_opr(); 764 do_temp(opJavaCall->_method_handle_invoke_SP_save_opr); 765 } 766 do_call(); 767 if (opJavaCall->_result->is_valid()) do_output(opJavaCall->_result); 768 769 break; 770 } 771 772 773 // LIR_OpRTCall 774 case lir_rtcall: { 775 assert(op->as_OpRTCall() != nullptr, "must be"); 776 LIR_OpRTCall* opRTCall = (LIR_OpRTCall*)op; 777 778 // only visit register parameters 779 int n = opRTCall->_arguments->length(); 780 for (int i = 0; i < n; i++) { 781 if (!opRTCall->_arguments->at(i)->is_pointer()) { 782 do_input(*opRTCall->_arguments->adr_at(i)); 783 } 784 } 785 if (opRTCall->_info) do_info(opRTCall->_info); 786 if (opRTCall->_tmp->is_valid()) do_temp(opRTCall->_tmp); 787 do_call(); 788 if (opRTCall->_result->is_valid()) do_output(opRTCall->_result); 789 790 break; 791 } 792 793 794 // LIR_OpArrayCopy 795 case lir_arraycopy: { 796 assert(op->as_OpArrayCopy() != nullptr, "must be"); 797 LIR_OpArrayCopy* opArrayCopy = (LIR_OpArrayCopy*)op; 798 799 assert(opArrayCopy->_result->is_illegal(), "unused"); 800 assert(opArrayCopy->_src->is_valid(), "used"); do_input(opArrayCopy->_src); do_temp(opArrayCopy->_src); 801 assert(opArrayCopy->_src_pos->is_valid(), "used"); do_input(opArrayCopy->_src_pos); do_temp(opArrayCopy->_src_pos); 802 assert(opArrayCopy->_dst->is_valid(), "used"); do_input(opArrayCopy->_dst); do_temp(opArrayCopy->_dst); 803 assert(opArrayCopy->_dst_pos->is_valid(), "used"); do_input(opArrayCopy->_dst_pos); do_temp(opArrayCopy->_dst_pos); 804 assert(opArrayCopy->_length->is_valid(), "used"); do_input(opArrayCopy->_length); do_temp(opArrayCopy->_length); 805 assert(opArrayCopy->_tmp->is_valid(), "used"); do_temp(opArrayCopy->_tmp); 806 if (opArrayCopy->_info) do_info(opArrayCopy->_info); 807 808 // the implementation of arraycopy always has a call into the runtime 809 do_call(); 810 811 break; 812 } 813 814 815 // LIR_OpUpdateCRC32 816 case lir_updatecrc32: { 817 assert(op->as_OpUpdateCRC32() != nullptr, "must be"); 818 LIR_OpUpdateCRC32* opUp = (LIR_OpUpdateCRC32*)op; 819 820 assert(opUp->_crc->is_valid(), "used"); do_input(opUp->_crc); do_temp(opUp->_crc); 821 assert(opUp->_val->is_valid(), "used"); do_input(opUp->_val); do_temp(opUp->_val); 822 assert(opUp->_result->is_valid(), "used"); do_output(opUp->_result); 823 assert(opUp->_info == nullptr, "no info for LIR_OpUpdateCRC32"); 824 825 break; 826 } 827 828 829 // LIR_OpLock 830 case lir_lock: 831 case lir_unlock: { 832 assert(op->as_OpLock() != nullptr, "must be"); 833 LIR_OpLock* opLock = (LIR_OpLock*)op; 834 835 if (opLock->_info) do_info(opLock->_info); 836 837 // TODO: check if these operands really have to be temp 838 // (or if input is sufficient). This may have influence on the oop map! 839 assert(opLock->_lock->is_valid(), "used"); do_temp(opLock->_lock); 840 assert(opLock->_hdr->is_valid(), "used"); do_temp(opLock->_hdr); 841 assert(opLock->_obj->is_valid(), "used"); do_temp(opLock->_obj); 842 843 if (opLock->_scratch->is_valid()) do_temp(opLock->_scratch); 844 assert(opLock->_result->is_illegal(), "unused"); 845 846 do_stub(opLock->_stub); 847 do_stub(opLock->_throw_ie_stub); 848 849 break; 850 } 851 852 853 // LIR_OpDelay 854 case lir_delay_slot: { 855 assert(op->as_OpDelay() != nullptr, "must be"); 856 LIR_OpDelay* opDelay = (LIR_OpDelay*)op; 857 858 visit(opDelay->delay_op()); 859 break; 860 } 861 862 // LIR_OpTypeCheck 863 case lir_instanceof: 864 case lir_checkcast: 865 case lir_store_check: { 866 assert(op->as_OpTypeCheck() != nullptr, "must be"); 867 LIR_OpTypeCheck* opTypeCheck = (LIR_OpTypeCheck*)op; 868 869 if (opTypeCheck->_info_for_exception) do_info(opTypeCheck->_info_for_exception); 870 if (opTypeCheck->_info_for_patch) do_info(opTypeCheck->_info_for_patch); 871 if (opTypeCheck->_object->is_valid()) do_input(opTypeCheck->_object); 872 if (op->code() == lir_store_check && opTypeCheck->_object->is_valid()) { 873 do_temp(opTypeCheck->_object); 874 } 875 if (opTypeCheck->_array->is_valid()) do_input(opTypeCheck->_array); 876 if (opTypeCheck->_tmp1->is_valid()) do_temp(opTypeCheck->_tmp1); 877 if (opTypeCheck->_tmp2->is_valid()) do_temp(opTypeCheck->_tmp2); 878 if (opTypeCheck->_tmp3->is_valid()) do_temp(opTypeCheck->_tmp3); 879 if (opTypeCheck->_result->is_valid()) do_output(opTypeCheck->_result); 880 if (opTypeCheck->_stub != nullptr) do_stub(opTypeCheck->_stub); 881 break; 882 } 883 884 // LIR_OpFlattenedArrayCheck 885 case lir_flat_array_check: { 886 assert(op->as_OpFlattenedArrayCheck() != nullptr, "must be"); 887 LIR_OpFlattenedArrayCheck* opFlattenedArrayCheck = (LIR_OpFlattenedArrayCheck*)op; 888 889 if (opFlattenedArrayCheck->_array->is_valid()) do_input(opFlattenedArrayCheck->_array); 890 if (opFlattenedArrayCheck->_value->is_valid()) do_input(opFlattenedArrayCheck->_value); 891 if (opFlattenedArrayCheck->_tmp->is_valid()) do_temp(opFlattenedArrayCheck->_tmp); 892 893 do_stub(opFlattenedArrayCheck->_stub); 894 895 break; 896 } 897 898 // LIR_OpNullFreeArrayCheck 899 case lir_null_free_array_check: { 900 assert(op->as_OpNullFreeArrayCheck() != nullptr, "must be"); 901 LIR_OpNullFreeArrayCheck* opNullFreeArrayCheck = (LIR_OpNullFreeArrayCheck*)op; 902 903 if (opNullFreeArrayCheck->_array->is_valid()) do_input(opNullFreeArrayCheck->_array); 904 if (opNullFreeArrayCheck->_tmp->is_valid()) do_temp(opNullFreeArrayCheck->_tmp); 905 break; 906 } 907 908 // LIR_OpSubstitutabilityCheck 909 case lir_substitutability_check: { 910 assert(op->as_OpSubstitutabilityCheck() != nullptr, "must be"); 911 LIR_OpSubstitutabilityCheck* opSubstitutabilityCheck = (LIR_OpSubstitutabilityCheck*)op; 912 do_input(opSubstitutabilityCheck->_left); 913 do_temp (opSubstitutabilityCheck->_left); 914 do_input(opSubstitutabilityCheck->_right); 915 do_temp (opSubstitutabilityCheck->_right); 916 do_input(opSubstitutabilityCheck->_equal_result); 917 do_temp (opSubstitutabilityCheck->_equal_result); 918 do_input(opSubstitutabilityCheck->_not_equal_result); 919 do_temp (opSubstitutabilityCheck->_not_equal_result); 920 if (opSubstitutabilityCheck->_tmp1->is_valid()) do_temp(opSubstitutabilityCheck->_tmp1); 921 if (opSubstitutabilityCheck->_tmp2->is_valid()) do_temp(opSubstitutabilityCheck->_tmp2); 922 if (opSubstitutabilityCheck->_left_klass_op->is_valid()) do_temp(opSubstitutabilityCheck->_left_klass_op); 923 if (opSubstitutabilityCheck->_right_klass_op->is_valid()) do_temp(opSubstitutabilityCheck->_right_klass_op); 924 if (opSubstitutabilityCheck->_result->is_valid()) do_output(opSubstitutabilityCheck->_result); 925 926 do_info(opSubstitutabilityCheck->_info); 927 do_stub(opSubstitutabilityCheck->_stub); 928 break; 929 } 930 931 // LIR_OpCompareAndSwap 932 case lir_cas_long: 933 case lir_cas_obj: 934 case lir_cas_int: { 935 assert(op->as_OpCompareAndSwap() != nullptr, "must be"); 936 LIR_OpCompareAndSwap* opCmpAndSwap = (LIR_OpCompareAndSwap*)op; 937 938 if (opCmpAndSwap->_info) do_info(opCmpAndSwap->_info); 939 assert(opCmpAndSwap->_addr->is_valid(), "used"); do_input(opCmpAndSwap->_addr); 940 do_temp(opCmpAndSwap->_addr); 941 assert(opCmpAndSwap->_cmp_value->is_valid(), "used"); do_input(opCmpAndSwap->_cmp_value); 942 do_temp(opCmpAndSwap->_cmp_value); 943 assert(opCmpAndSwap->_new_value->is_valid(), "used"); do_input(opCmpAndSwap->_new_value); 944 do_temp(opCmpAndSwap->_new_value); 945 if (opCmpAndSwap->_tmp1->is_valid()) do_temp(opCmpAndSwap->_tmp1); 946 if (opCmpAndSwap->_tmp2->is_valid()) do_temp(opCmpAndSwap->_tmp2); 947 if (opCmpAndSwap->_result->is_valid()) do_output(opCmpAndSwap->_result); 948 949 break; 950 } 951 952 953 // LIR_OpAllocArray; 954 case lir_alloc_array: { 955 assert(op->as_OpAllocArray() != nullptr, "must be"); 956 LIR_OpAllocArray* opAllocArray = (LIR_OpAllocArray*)op; 957 958 if (opAllocArray->_info) do_info(opAllocArray->_info); 959 if (opAllocArray->_klass->is_valid()) { do_input(opAllocArray->_klass); 960 do_temp(opAllocArray->_klass); 961 } 962 if (opAllocArray->_len->is_valid()) { do_input(opAllocArray->_len); 963 do_temp(opAllocArray->_len); 964 } 965 if (opAllocArray->_tmp1->is_valid()) do_temp(opAllocArray->_tmp1); 966 if (opAllocArray->_tmp2->is_valid()) do_temp(opAllocArray->_tmp2); 967 if (opAllocArray->_tmp3->is_valid()) do_temp(opAllocArray->_tmp3); 968 if (opAllocArray->_tmp4->is_valid()) do_temp(opAllocArray->_tmp4); 969 if (opAllocArray->_result->is_valid()) do_output(opAllocArray->_result); 970 if (opAllocArray->_stub != nullptr) do_stub(opAllocArray->_stub); 971 break; 972 } 973 974 // LIR_OpLoadKlass 975 case lir_load_klass: 976 { 977 LIR_OpLoadKlass* opLoadKlass = op->as_OpLoadKlass(); 978 assert(opLoadKlass != nullptr, "must be"); 979 980 do_input(opLoadKlass->_obj); 981 do_output(opLoadKlass->_result); 982 if (opLoadKlass->_info) do_info(opLoadKlass->_info); 983 break; 984 } 985 986 987 // LIR_OpProfileCall: 988 case lir_profile_call: { 989 assert(op->as_OpProfileCall() != nullptr, "must be"); 990 LIR_OpProfileCall* opProfileCall = (LIR_OpProfileCall*)op; 991 992 if (opProfileCall->_recv->is_valid()) do_temp(opProfileCall->_recv); 993 assert(opProfileCall->_mdo->is_valid(), "used"); do_temp(opProfileCall->_mdo); 994 assert(opProfileCall->_tmp1->is_valid(), "used"); do_temp(opProfileCall->_tmp1); 995 break; 996 } 997 998 // LIR_OpProfileType: 999 case lir_profile_type: { 1000 assert(op->as_OpProfileType() != nullptr, "must be"); 1001 LIR_OpProfileType* opProfileType = (LIR_OpProfileType*)op; 1002 1003 do_input(opProfileType->_mdp); do_temp(opProfileType->_mdp); 1004 do_input(opProfileType->_obj); 1005 do_temp(opProfileType->_tmp); 1006 break; 1007 } 1008 1009 // LIR_OpProfileInlineType: 1010 case lir_profile_inline_type: { 1011 assert(op->as_OpProfileInlineType() != nullptr, "must be"); 1012 LIR_OpProfileInlineType* opProfileInlineType = (LIR_OpProfileInlineType*)op; 1013 1014 do_input(opProfileInlineType->_mdp); do_temp(opProfileInlineType->_mdp); 1015 do_input(opProfileInlineType->_obj); 1016 do_temp(opProfileInlineType->_tmp); 1017 break; 1018 } 1019 default: 1020 op->visit(this); 1021 } 1022 } 1023 1024 void LIR_Op::visit(LIR_OpVisitState* state) { 1025 ShouldNotReachHere(); 1026 } 1027 1028 void LIR_OpVisitState::do_stub(CodeStub* stub) { 1029 if (stub != nullptr) { 1030 stub->visit(this); 1031 } 1032 } 1033 1034 XHandlers* LIR_OpVisitState::all_xhandler() { 1035 XHandlers* result = nullptr; 1036 1037 int i; 1038 for (i = 0; i < info_count(); i++) { 1039 if (info_at(i)->exception_handlers() != nullptr) { 1040 result = info_at(i)->exception_handlers(); 1041 break; 1042 } 1043 } 1044 1045 #ifdef ASSERT 1046 for (i = 0; i < info_count(); i++) { 1047 assert(info_at(i)->exception_handlers() == nullptr || 1048 info_at(i)->exception_handlers() == result, 1049 "only one xhandler list allowed per LIR-operation"); 1050 } 1051 #endif 1052 1053 if (result != nullptr) { 1054 return result; 1055 } else { 1056 return new XHandlers(); 1057 } 1058 1059 return result; 1060 } 1061 1062 1063 #ifdef ASSERT 1064 bool LIR_OpVisitState::no_operands(LIR_Op* op) { 1065 visit(op); 1066 1067 return opr_count(inputMode) == 0 && 1068 opr_count(outputMode) == 0 && 1069 opr_count(tempMode) == 0 && 1070 info_count() == 0 && 1071 !has_call() && 1072 !has_slow_case(); 1073 } 1074 #endif 1075 1076 // LIR_OpReturn 1077 LIR_OpReturn::LIR_OpReturn(LIR_Opr opr) : 1078 LIR_Op1(lir_return, opr, (CodeEmitInfo*)nullptr /* info */), 1079 _stub(nullptr) { 1080 if (VM_Version::supports_stack_watermark_barrier()) { 1081 _stub = new C1SafepointPollStub(); 1082 } 1083 } 1084 1085 //--------------------------------------------------- 1086 1087 1088 void LIR_OpJavaCall::emit_code(LIR_Assembler* masm) { 1089 masm->emit_call(this); 1090 } 1091 1092 bool LIR_OpJavaCall::maybe_return_as_fields(ciInlineKlass** vk_ret) const { 1093 ciType* return_type = method()->return_type(); 1094 if (InlineTypeReturnedAsFields) { 1095 if (return_type->is_inlinetype()) { 1096 ciInlineKlass* vk = return_type->as_inline_klass(); 1097 if (vk->can_be_returned_as_fields()) { 1098 if (vk_ret != nullptr) { 1099 *vk_ret = vk; 1100 } 1101 return true; 1102 } 1103 } else if (return_type->is_instance_klass() && 1104 (method()->is_method_handle_intrinsic() || !return_type->is_loaded() || 1105 StressCallingConvention)) { 1106 // An inline type might be returned from the call but we don't know its type. 1107 // This can happen with method handle intrinsics or when the return type is 1108 // not loaded (method holder is not loaded or preload attribute is missing). 1109 // If an inline type is returned, we either get an oop to a buffer and nothing 1110 // needs to be done or one of the values being returned is the klass of the 1111 // inline type (RAX on x64, with LSB set to 1) and we need to allocate an inline 1112 // type instance of that type and initialize it with the fields values being 1113 // returned in other registers. 1114 return true; 1115 } 1116 } 1117 return false; 1118 } 1119 1120 void LIR_OpRTCall::emit_code(LIR_Assembler* masm) { 1121 masm->emit_rtcall(this); 1122 } 1123 1124 void LIR_OpLabel::emit_code(LIR_Assembler* masm) { 1125 masm->emit_opLabel(this); 1126 } 1127 1128 void LIR_OpArrayCopy::emit_code(LIR_Assembler* masm) { 1129 masm->emit_arraycopy(this); 1130 ArrayCopyStub* code_stub = stub(); 1131 if (code_stub != nullptr) { 1132 masm->append_code_stub(code_stub); 1133 } 1134 } 1135 1136 void LIR_OpUpdateCRC32::emit_code(LIR_Assembler* masm) { 1137 masm->emit_updatecrc32(this); 1138 } 1139 1140 void LIR_Op0::emit_code(LIR_Assembler* masm) { 1141 masm->emit_op0(this); 1142 } 1143 1144 void LIR_Op1::emit_code(LIR_Assembler* masm) { 1145 masm->emit_op1(this); 1146 } 1147 1148 void LIR_OpAllocObj::emit_code(LIR_Assembler* masm) { 1149 masm->emit_alloc_obj(this); 1150 masm->append_code_stub(stub()); 1151 } 1152 1153 void LIR_OpBranch::emit_code(LIR_Assembler* masm) { 1154 masm->emit_opBranch(this); 1155 if (stub()) { 1156 masm->append_code_stub(stub()); 1157 } 1158 } 1159 1160 void LIR_OpConvert::emit_code(LIR_Assembler* masm) { 1161 masm->emit_opConvert(this); 1162 if (stub() != nullptr) { 1163 masm->append_code_stub(stub()); 1164 } 1165 } 1166 1167 void LIR_Op2::emit_code(LIR_Assembler* masm) { 1168 masm->emit_op2(this); 1169 } 1170 1171 void LIR_OpAllocArray::emit_code(LIR_Assembler* masm) { 1172 masm->emit_alloc_array(this); 1173 masm->append_code_stub(stub()); 1174 } 1175 1176 void LIR_OpTypeCheck::emit_code(LIR_Assembler* masm) { 1177 masm->emit_opTypeCheck(this); 1178 if (stub()) { 1179 masm->append_code_stub(stub()); 1180 } 1181 } 1182 1183 void LIR_OpFlattenedArrayCheck::emit_code(LIR_Assembler* masm) { 1184 masm->emit_opFlattenedArrayCheck(this); 1185 if (stub() != nullptr) { 1186 masm->append_code_stub(stub()); 1187 } 1188 } 1189 1190 void LIR_OpNullFreeArrayCheck::emit_code(LIR_Assembler* masm) { 1191 masm->emit_opNullFreeArrayCheck(this); 1192 } 1193 1194 void LIR_OpSubstitutabilityCheck::emit_code(LIR_Assembler* masm) { 1195 masm->emit_opSubstitutabilityCheck(this); 1196 if (stub() != nullptr) { 1197 masm->append_code_stub(stub()); 1198 } 1199 } 1200 1201 void LIR_OpCompareAndSwap::emit_code(LIR_Assembler* masm) { 1202 masm->emit_compare_and_swap(this); 1203 } 1204 1205 void LIR_Op3::emit_code(LIR_Assembler* masm) { 1206 masm->emit_op3(this); 1207 } 1208 1209 void LIR_Op4::emit_code(LIR_Assembler* masm) { 1210 masm->emit_op4(this); 1211 } 1212 1213 void LIR_OpLock::emit_code(LIR_Assembler* masm) { 1214 masm->emit_lock(this); 1215 if (stub()) { 1216 masm->append_code_stub(stub()); 1217 } 1218 if (throw_ie_stub()) { 1219 masm->append_code_stub(throw_ie_stub()); 1220 } 1221 } 1222 1223 void LIR_OpLoadKlass::emit_code(LIR_Assembler* masm) { 1224 masm->emit_load_klass(this); 1225 } 1226 1227 #ifdef ASSERT 1228 void LIR_OpAssert::emit_code(LIR_Assembler* masm) { 1229 masm->emit_assert(this); 1230 } 1231 #endif 1232 1233 void LIR_OpDelay::emit_code(LIR_Assembler* masm) { 1234 masm->emit_delay(this); 1235 } 1236 1237 void LIR_OpProfileCall::emit_code(LIR_Assembler* masm) { 1238 masm->emit_profile_call(this); 1239 } 1240 1241 void LIR_OpProfileType::emit_code(LIR_Assembler* masm) { 1242 masm->emit_profile_type(this); 1243 } 1244 1245 void LIR_OpProfileInlineType::emit_code(LIR_Assembler* masm) { 1246 masm->emit_profile_inline_type(this); 1247 } 1248 1249 // LIR_List 1250 LIR_List::LIR_List(Compilation* compilation, BlockBegin* block) 1251 : _operations(8) 1252 , _compilation(compilation) 1253 #ifndef PRODUCT 1254 , _block(block) 1255 #endif 1256 #ifdef ASSERT 1257 , _file(nullptr) 1258 , _line(0) 1259 #endif 1260 #ifdef RISCV 1261 , _cmp_opr1(LIR_OprFact::illegalOpr) 1262 , _cmp_opr2(LIR_OprFact::illegalOpr) 1263 #endif 1264 { } 1265 1266 1267 #ifdef ASSERT 1268 void LIR_List::set_file_and_line(const char * file, int line) { 1269 const char * f = strrchr(file, '/'); 1270 if (f == nullptr) f = strrchr(file, '\\'); 1271 if (f == nullptr) { 1272 f = file; 1273 } else { 1274 f++; 1275 } 1276 _file = f; 1277 _line = line; 1278 } 1279 #endif 1280 1281 #ifdef RISCV 1282 void LIR_List::set_cmp_oprs(LIR_Op* op) { 1283 switch (op->code()) { 1284 case lir_cmp: 1285 _cmp_opr1 = op->as_Op2()->in_opr1(); 1286 _cmp_opr2 = op->as_Op2()->in_opr2(); 1287 break; 1288 case lir_branch: // fall through 1289 case lir_cond_float_branch: 1290 assert(op->as_OpBranch()->cond() == lir_cond_always || 1291 (_cmp_opr1 != LIR_OprFact::illegalOpr && _cmp_opr2 != LIR_OprFact::illegalOpr), 1292 "conditional branches must have legal operands"); 1293 if (op->as_OpBranch()->cond() != lir_cond_always) { 1294 op->as_Op2()->set_in_opr1(_cmp_opr1); 1295 op->as_Op2()->set_in_opr2(_cmp_opr2); 1296 } 1297 break; 1298 case lir_cmove: 1299 op->as_Op4()->set_in_opr3(_cmp_opr1); 1300 op->as_Op4()->set_in_opr4(_cmp_opr2); 1301 break; 1302 case lir_cas_long: 1303 case lir_cas_obj: 1304 case lir_cas_int: 1305 _cmp_opr1 = op->as_OpCompareAndSwap()->result_opr(); 1306 _cmp_opr2 = LIR_OprFact::intConst(0); 1307 break; 1308 #if INCLUDE_ZGC 1309 case lir_xloadbarrier_test: 1310 _cmp_opr1 = FrameMap::as_opr(t1); 1311 _cmp_opr2 = LIR_OprFact::intConst(0); 1312 break; 1313 #endif 1314 default: 1315 break; 1316 } 1317 } 1318 #endif 1319 1320 void LIR_List::append(LIR_InsertionBuffer* buffer) { 1321 assert(this == buffer->lir_list(), "wrong lir list"); 1322 const int n = _operations.length(); 1323 1324 if (buffer->number_of_ops() > 0) { 1325 // increase size of instructions list 1326 _operations.at_grow(n + buffer->number_of_ops() - 1, nullptr); 1327 // insert ops from buffer into instructions list 1328 int op_index = buffer->number_of_ops() - 1; 1329 int ip_index = buffer->number_of_insertion_points() - 1; 1330 int from_index = n - 1; 1331 int to_index = _operations.length() - 1; 1332 for (; ip_index >= 0; ip_index --) { 1333 int index = buffer->index_at(ip_index); 1334 // make room after insertion point 1335 while (index < from_index) { 1336 _operations.at_put(to_index --, _operations.at(from_index --)); 1337 } 1338 // insert ops from buffer 1339 for (int i = buffer->count_at(ip_index); i > 0; i --) { 1340 _operations.at_put(to_index --, buffer->op_at(op_index --)); 1341 } 1342 } 1343 } 1344 1345 buffer->finish(); 1346 } 1347 1348 1349 void LIR_List::oop2reg_patch(jobject o, LIR_Opr reg, CodeEmitInfo* info) { 1350 assert(reg->type() == T_OBJECT, "bad reg"); 1351 append(new LIR_Op1(lir_move, LIR_OprFact::oopConst(o), reg, T_OBJECT, lir_patch_normal, info)); 1352 } 1353 1354 void LIR_List::klass2reg_patch(Metadata* o, LIR_Opr reg, CodeEmitInfo* info) { 1355 assert(reg->type() == T_METADATA, "bad reg"); 1356 append(new LIR_Op1(lir_move, LIR_OprFact::metadataConst(o), reg, T_METADATA, lir_patch_normal, info)); 1357 } 1358 1359 void LIR_List::load(LIR_Address* addr, LIR_Opr src, CodeEmitInfo* info, LIR_PatchCode patch_code) { 1360 append(new LIR_Op1( 1361 lir_move, 1362 LIR_OprFact::address(addr), 1363 src, 1364 addr->type(), 1365 patch_code, 1366 info)); 1367 } 1368 1369 1370 void LIR_List::volatile_load_mem_reg(LIR_Address* address, LIR_Opr dst, CodeEmitInfo* info, LIR_PatchCode patch_code) { 1371 append(new LIR_Op1( 1372 lir_move, 1373 LIR_OprFact::address(address), 1374 dst, 1375 address->type(), 1376 patch_code, 1377 info, lir_move_volatile)); 1378 } 1379 1380 void LIR_List::volatile_load_unsafe_reg(LIR_Opr base, LIR_Opr offset, LIR_Opr dst, BasicType type, CodeEmitInfo* info, LIR_PatchCode patch_code) { 1381 append(new LIR_Op1( 1382 lir_move, 1383 LIR_OprFact::address(new LIR_Address(base, offset, type)), 1384 dst, 1385 type, 1386 patch_code, 1387 info, lir_move_volatile)); 1388 } 1389 1390 1391 void LIR_List::store_mem_int(jint v, LIR_Opr base, int offset_in_bytes, BasicType type, CodeEmitInfo* info, LIR_PatchCode patch_code) { 1392 append(new LIR_Op1( 1393 lir_move, 1394 LIR_OprFact::intConst(v), 1395 LIR_OprFact::address(new LIR_Address(base, offset_in_bytes, type)), 1396 type, 1397 patch_code, 1398 info)); 1399 } 1400 1401 1402 void LIR_List::store_mem_oop(jobject o, LIR_Opr base, int offset_in_bytes, BasicType type, CodeEmitInfo* info, LIR_PatchCode patch_code) { 1403 append(new LIR_Op1( 1404 lir_move, 1405 LIR_OprFact::oopConst(o), 1406 LIR_OprFact::address(new LIR_Address(base, offset_in_bytes, type)), 1407 type, 1408 patch_code, 1409 info)); 1410 } 1411 1412 1413 void LIR_List::store(LIR_Opr src, LIR_Address* addr, CodeEmitInfo* info, LIR_PatchCode patch_code) { 1414 append(new LIR_Op1( 1415 lir_move, 1416 src, 1417 LIR_OprFact::address(addr), 1418 addr->type(), 1419 patch_code, 1420 info)); 1421 } 1422 1423 1424 void LIR_List::volatile_store_mem_reg(LIR_Opr src, LIR_Address* addr, CodeEmitInfo* info, LIR_PatchCode patch_code) { 1425 append(new LIR_Op1( 1426 lir_move, 1427 src, 1428 LIR_OprFact::address(addr), 1429 addr->type(), 1430 patch_code, 1431 info, 1432 lir_move_volatile)); 1433 } 1434 1435 void LIR_List::volatile_store_unsafe_reg(LIR_Opr src, LIR_Opr base, LIR_Opr offset, BasicType type, CodeEmitInfo* info, LIR_PatchCode patch_code) { 1436 append(new LIR_Op1( 1437 lir_move, 1438 src, 1439 LIR_OprFact::address(new LIR_Address(base, offset, type)), 1440 type, 1441 patch_code, 1442 info, lir_move_volatile)); 1443 } 1444 1445 1446 void LIR_List::idiv(LIR_Opr left, LIR_Opr right, LIR_Opr res, LIR_Opr tmp, CodeEmitInfo* info) { 1447 append(new LIR_Op3( 1448 lir_idiv, 1449 left, 1450 right, 1451 tmp, 1452 res, 1453 info)); 1454 } 1455 1456 1457 void LIR_List::idiv(LIR_Opr left, int right, LIR_Opr res, LIR_Opr tmp, CodeEmitInfo* info) { 1458 append(new LIR_Op3( 1459 lir_idiv, 1460 left, 1461 LIR_OprFact::intConst(right), 1462 tmp, 1463 res, 1464 info)); 1465 } 1466 1467 1468 void LIR_List::irem(LIR_Opr left, LIR_Opr right, LIR_Opr res, LIR_Opr tmp, CodeEmitInfo* info) { 1469 append(new LIR_Op3( 1470 lir_irem, 1471 left, 1472 right, 1473 tmp, 1474 res, 1475 info)); 1476 } 1477 1478 1479 void LIR_List::irem(LIR_Opr left, int right, LIR_Opr res, LIR_Opr tmp, CodeEmitInfo* info) { 1480 append(new LIR_Op3( 1481 lir_irem, 1482 left, 1483 LIR_OprFact::intConst(right), 1484 tmp, 1485 res, 1486 info)); 1487 } 1488 1489 1490 void LIR_List::cmp_mem_int(LIR_Condition condition, LIR_Opr base, int disp, int c, CodeEmitInfo* info) { 1491 append(new LIR_Op2( 1492 lir_cmp, 1493 condition, 1494 LIR_OprFact::address(new LIR_Address(base, disp, T_INT)), 1495 LIR_OprFact::intConst(c), 1496 info)); 1497 } 1498 1499 1500 void LIR_List::cmp_reg_mem(LIR_Condition condition, LIR_Opr reg, LIR_Address* addr, CodeEmitInfo* info) { 1501 append(new LIR_Op2( 1502 lir_cmp, 1503 condition, 1504 reg, 1505 LIR_OprFact::address(addr), 1506 info)); 1507 } 1508 1509 void LIR_List::allocate_object(LIR_Opr dst, LIR_Opr t1, LIR_Opr t2, LIR_Opr t3, LIR_Opr t4, 1510 int header_size, int object_size, LIR_Opr klass, bool init_check, CodeStub* stub) { 1511 append(new LIR_OpAllocObj( 1512 klass, 1513 dst, 1514 t1, 1515 t2, 1516 t3, 1517 t4, 1518 header_size, 1519 object_size, 1520 init_check, 1521 stub)); 1522 } 1523 1524 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 is_null_free) { 1525 append(new LIR_OpAllocArray( 1526 klass, 1527 len, 1528 dst, 1529 t1, 1530 t2, 1531 t3, 1532 t4, 1533 type, 1534 stub, 1535 zero_array, 1536 is_null_free)); 1537 } 1538 1539 void LIR_List::shift_left(LIR_Opr value, LIR_Opr count, LIR_Opr dst, LIR_Opr tmp) { 1540 append(new LIR_Op2( 1541 lir_shl, 1542 value, 1543 count, 1544 dst, 1545 tmp)); 1546 } 1547 1548 void LIR_List::shift_right(LIR_Opr value, LIR_Opr count, LIR_Opr dst, LIR_Opr tmp) { 1549 append(new LIR_Op2( 1550 lir_shr, 1551 value, 1552 count, 1553 dst, 1554 tmp)); 1555 } 1556 1557 1558 void LIR_List::unsigned_shift_right(LIR_Opr value, LIR_Opr count, LIR_Opr dst, LIR_Opr tmp) { 1559 append(new LIR_Op2( 1560 lir_ushr, 1561 value, 1562 count, 1563 dst, 1564 tmp)); 1565 } 1566 1567 void LIR_List::fcmp2int(LIR_Opr left, LIR_Opr right, LIR_Opr dst, bool is_unordered_less) { 1568 append(new LIR_Op2(is_unordered_less ? lir_ucmp_fd2i : lir_cmp_fd2i, 1569 left, 1570 right, 1571 dst)); 1572 } 1573 1574 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) { 1575 append(new LIR_OpLock( 1576 lir_lock, 1577 hdr, 1578 obj, 1579 lock, 1580 scratch, 1581 stub, 1582 info, 1583 throw_ie_stub)); 1584 } 1585 1586 void LIR_List::unlock_object(LIR_Opr hdr, LIR_Opr obj, LIR_Opr lock, LIR_Opr scratch, CodeStub* stub) { 1587 append(new LIR_OpLock( 1588 lir_unlock, 1589 hdr, 1590 obj, 1591 lock, 1592 scratch, 1593 stub, 1594 nullptr)); 1595 } 1596 1597 1598 void check_LIR() { 1599 // cannot do the proper checking as PRODUCT and other modes return different results 1600 // guarantee(sizeof(LIR_Opr) == wordSize, "may not have a v-table"); 1601 } 1602 1603 1604 1605 void LIR_List::checkcast (LIR_Opr result, LIR_Opr object, ciKlass* klass, 1606 LIR_Opr tmp1, LIR_Opr tmp2, LIR_Opr tmp3, bool fast_check, 1607 CodeEmitInfo* info_for_exception, CodeEmitInfo* info_for_patch, CodeStub* stub, 1608 ciMethod* profiled_method, int profiled_bci, bool is_null_free) { 1609 // If klass is non-nullable, LIRGenerator::do_CheckCast has already performed null-check 1610 // on the object. 1611 bool need_null_check = !is_null_free; 1612 LIR_OpTypeCheck* c = new LIR_OpTypeCheck(lir_checkcast, result, object, klass, 1613 tmp1, tmp2, tmp3, fast_check, info_for_exception, info_for_patch, stub, 1614 need_null_check); 1615 if (profiled_method != nullptr) { 1616 c->set_profiled_method(profiled_method); 1617 c->set_profiled_bci(profiled_bci); 1618 c->set_should_profile(true); 1619 } 1620 append(c); 1621 } 1622 1623 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) { 1624 LIR_OpTypeCheck* c = new LIR_OpTypeCheck(lir_instanceof, result, object, klass, tmp1, tmp2, tmp3, fast_check, nullptr, info_for_patch, nullptr); 1625 if (profiled_method != nullptr) { 1626 c->set_profiled_method(profiled_method); 1627 c->set_profiled_bci(profiled_bci); 1628 c->set_should_profile(true); 1629 } 1630 append(c); 1631 } 1632 1633 1634 void LIR_List::store_check(LIR_Opr object, LIR_Opr array, LIR_Opr tmp1, LIR_Opr tmp2, LIR_Opr tmp3, 1635 CodeEmitInfo* info_for_exception, ciMethod* profiled_method, int profiled_bci) { 1636 // FIXME -- if the types of the array and/or the object are known statically, we can avoid loading the klass 1637 LIR_OpTypeCheck* c = new LIR_OpTypeCheck(lir_store_check, object, array, tmp1, tmp2, tmp3, info_for_exception); 1638 if (profiled_method != nullptr) { 1639 c->set_profiled_method(profiled_method); 1640 c->set_profiled_bci(profiled_bci); 1641 c->set_should_profile(true); 1642 } 1643 append(c); 1644 } 1645 1646 void LIR_List::null_check(LIR_Opr opr, CodeEmitInfo* info, bool deoptimize_on_null) { 1647 if (deoptimize_on_null) { 1648 // Emit an explicit null check and deoptimize if opr is null 1649 CodeStub* deopt = new DeoptimizeStub(info, Deoptimization::Reason_null_check, Deoptimization::Action_none); 1650 cmp(lir_cond_equal, opr, LIR_OprFact::oopConst(nullptr)); 1651 branch(lir_cond_equal, deopt); 1652 } else { 1653 // Emit an implicit null check 1654 append(new LIR_Op1(lir_null_check, opr, info)); 1655 } 1656 } 1657 1658 void LIR_List::check_flat_array(LIR_Opr array, LIR_Opr value, LIR_Opr tmp, CodeStub* stub) { 1659 LIR_OpFlattenedArrayCheck* c = new LIR_OpFlattenedArrayCheck(array, value, tmp, stub); 1660 append(c); 1661 } 1662 1663 void LIR_List::check_null_free_array(LIR_Opr array, LIR_Opr tmp) { 1664 LIR_OpNullFreeArrayCheck* c = new LIR_OpNullFreeArrayCheck(array, tmp); 1665 append(c); 1666 } 1667 1668 void LIR_List::substitutability_check(LIR_Opr result, LIR_Opr left, LIR_Opr right, LIR_Opr equal_result, LIR_Opr not_equal_result, 1669 LIR_Opr tmp1, LIR_Opr tmp2, 1670 ciKlass* left_klass, ciKlass* right_klass, LIR_Opr left_klass_op, LIR_Opr right_klass_op, 1671 CodeEmitInfo* info, CodeStub* stub) { 1672 LIR_OpSubstitutabilityCheck* c = new LIR_OpSubstitutabilityCheck(result, left, right, equal_result, not_equal_result, 1673 tmp1, tmp2, 1674 left_klass, right_klass, left_klass_op, right_klass_op, 1675 info, stub); 1676 append(c); 1677 } 1678 1679 void LIR_List::cas_long(LIR_Opr addr, LIR_Opr cmp_value, LIR_Opr new_value, 1680 LIR_Opr t1, LIR_Opr t2, LIR_Opr result) { 1681 append(new LIR_OpCompareAndSwap(lir_cas_long, addr, cmp_value, new_value, t1, t2, result)); 1682 } 1683 1684 void LIR_List::cas_obj(LIR_Opr addr, LIR_Opr cmp_value, LIR_Opr new_value, 1685 LIR_Opr t1, LIR_Opr t2, LIR_Opr result) { 1686 append(new LIR_OpCompareAndSwap(lir_cas_obj, addr, cmp_value, new_value, t1, t2, result)); 1687 } 1688 1689 void LIR_List::cas_int(LIR_Opr addr, LIR_Opr cmp_value, LIR_Opr new_value, 1690 LIR_Opr t1, LIR_Opr t2, LIR_Opr result) { 1691 append(new LIR_OpCompareAndSwap(lir_cas_int, addr, cmp_value, new_value, t1, t2, result)); 1692 } 1693 1694 1695 #ifdef PRODUCT 1696 1697 void print_LIR(BlockList* blocks) { 1698 } 1699 1700 #else 1701 // LIR_Opr 1702 void LIR_Opr::print() const { 1703 print(tty); 1704 } 1705 1706 void LIR_Opr::print(outputStream* out) const { 1707 if (is_illegal()) { 1708 return; 1709 } 1710 1711 out->print("["); 1712 if (is_pointer()) { 1713 pointer()->print_value_on(out); 1714 } else if (is_single_stack()) { 1715 out->print("stack:%d", single_stack_ix()); 1716 } else if (is_double_stack()) { 1717 out->print("dbl_stack:%d",double_stack_ix()); 1718 } else if (is_virtual()) { 1719 out->print("R%d", vreg_number()); 1720 } else if (is_single_cpu()) { 1721 out->print("%s", as_register()->name()); 1722 } else if (is_double_cpu()) { 1723 out->print("%s", as_register_hi()->name()); 1724 out->print("%s", as_register_lo()->name()); 1725 #if defined(X86) 1726 } else if (is_single_xmm()) { 1727 out->print("%s", as_xmm_float_reg()->name()); 1728 } else if (is_double_xmm()) { 1729 out->print("%s", as_xmm_double_reg()->name()); 1730 } else if (is_single_fpu()) { 1731 out->print("fpu%d", fpu_regnr()); 1732 } else if (is_double_fpu()) { 1733 out->print("fpu%d", fpu_regnrLo()); 1734 #elif defined(AARCH64) 1735 } else if (is_single_fpu()) { 1736 out->print("fpu%d", fpu_regnr()); 1737 } else if (is_double_fpu()) { 1738 out->print("fpu%d", fpu_regnrLo()); 1739 #elif defined(ARM) 1740 } else if (is_single_fpu()) { 1741 out->print("s%d", fpu_regnr()); 1742 } else if (is_double_fpu()) { 1743 out->print("d%d", fpu_regnrLo() >> 1); 1744 #else 1745 } else if (is_single_fpu()) { 1746 out->print("%s", as_float_reg()->name()); 1747 } else if (is_double_fpu()) { 1748 out->print("%s", as_double_reg()->name()); 1749 #endif 1750 1751 } else if (is_illegal()) { 1752 out->print("-"); 1753 } else { 1754 out->print("Unknown Operand"); 1755 } 1756 if (!is_illegal()) { 1757 out->print("|%c", type_char()); 1758 } 1759 if (is_register() && is_last_use()) { 1760 out->print("(last_use)"); 1761 } 1762 out->print("]"); 1763 } 1764 1765 1766 // LIR_Address 1767 void LIR_Const::print_value_on(outputStream* out) const { 1768 switch (type()) { 1769 case T_ADDRESS:out->print("address:%d",as_jint()); break; 1770 case T_INT: out->print("int:%d", as_jint()); break; 1771 case T_LONG: out->print("lng:" JLONG_FORMAT, as_jlong()); break; 1772 case T_FLOAT: out->print("flt:%f", as_jfloat()); break; 1773 case T_DOUBLE: out->print("dbl:%f", as_jdouble()); break; 1774 case T_OBJECT: out->print("obj:" INTPTR_FORMAT, p2i(as_jobject())); break; 1775 case T_METADATA: out->print("metadata:" INTPTR_FORMAT, p2i(as_metadata()));break; 1776 default: out->print("%3d:" UINT64_FORMAT_X, type(), (uint64_t)as_jlong()); break; 1777 } 1778 } 1779 1780 // LIR_Address 1781 void LIR_Address::print_value_on(outputStream* out) const { 1782 out->print("Base:"); _base->print(out); 1783 if (!_index->is_illegal()) { 1784 out->print(" Index:"); _index->print(out); 1785 switch (scale()) { 1786 case times_1: break; 1787 case times_2: out->print(" * 2"); break; 1788 case times_4: out->print(" * 4"); break; 1789 case times_8: out->print(" * 8"); break; 1790 } 1791 } 1792 out->print(" Disp: " INTX_FORMAT, _disp); 1793 } 1794 1795 // debug output of block header without InstructionPrinter 1796 // (because phi functions are not necessary for LIR) 1797 static void print_block(BlockBegin* x) { 1798 // print block id 1799 BlockEnd* end = x->end(); 1800 tty->print("B%d ", x->block_id()); 1801 1802 // print flags 1803 if (x->is_set(BlockBegin::std_entry_flag)) tty->print("std "); 1804 if (x->is_set(BlockBegin::osr_entry_flag)) tty->print("osr "); 1805 if (x->is_set(BlockBegin::exception_entry_flag)) tty->print("ex "); 1806 if (x->is_set(BlockBegin::subroutine_entry_flag)) tty->print("jsr "); 1807 if (x->is_set(BlockBegin::backward_branch_target_flag)) tty->print("bb "); 1808 if (x->is_set(BlockBegin::linear_scan_loop_header_flag)) tty->print("lh "); 1809 if (x->is_set(BlockBegin::linear_scan_loop_end_flag)) tty->print("le "); 1810 1811 // print block bci range 1812 tty->print("[%d, %d] ", x->bci(), (end == nullptr ? -1 : end->printable_bci())); 1813 1814 // print predecessors and successors 1815 if (x->number_of_preds() > 0) { 1816 tty->print("preds: "); 1817 for (int i = 0; i < x->number_of_preds(); i ++) { 1818 tty->print("B%d ", x->pred_at(i)->block_id()); 1819 } 1820 } 1821 1822 if (end != nullptr && x->number_of_sux() > 0) { 1823 tty->print("sux: "); 1824 for (int i = 0; i < x->number_of_sux(); i ++) { 1825 tty->print("B%d ", x->sux_at(i)->block_id()); 1826 } 1827 } 1828 1829 // print exception handlers 1830 if (x->number_of_exception_handlers() > 0) { 1831 tty->print("xhandler: "); 1832 for (int i = 0; i < x->number_of_exception_handlers(); i++) { 1833 tty->print("B%d ", x->exception_handler_at(i)->block_id()); 1834 } 1835 } 1836 1837 tty->cr(); 1838 } 1839 1840 void print_LIR(BlockList* blocks) { 1841 tty->print_cr("LIR:"); 1842 int i; 1843 for (i = 0; i < blocks->length(); i++) { 1844 BlockBegin* bb = blocks->at(i); 1845 print_block(bb); 1846 tty->print("__id_Instruction___________________________________________"); tty->cr(); 1847 bb->lir()->print_instructions(); 1848 } 1849 } 1850 1851 void LIR_List::print_instructions() { 1852 for (int i = 0; i < _operations.length(); i++) { 1853 _operations.at(i)->print(); tty->cr(); 1854 } 1855 tty->cr(); 1856 } 1857 1858 // LIR_Ops printing routines 1859 // LIR_Op 1860 void LIR_Op::print_on(outputStream* out) const { 1861 if (id() != -1 || PrintCFGToFile) { 1862 out->print("%4d ", id()); 1863 } else { 1864 out->print(" "); 1865 } 1866 out->print("%s ", name()); 1867 print_instr(out); 1868 if (info() != nullptr) out->print(" [bci:%d]", info()->stack()->bci()); 1869 #ifdef ASSERT 1870 if (Verbose && _file != nullptr) { 1871 out->print(" (%s:%d)", _file, _line); 1872 } 1873 #endif 1874 } 1875 1876 const char * LIR_Op::name() const { 1877 const char* s = nullptr; 1878 switch(code()) { 1879 // LIR_Op0 1880 case lir_membar: s = "membar"; break; 1881 case lir_membar_acquire: s = "membar_acquire"; break; 1882 case lir_membar_release: s = "membar_release"; break; 1883 case lir_membar_loadload: s = "membar_loadload"; break; 1884 case lir_membar_storestore: s = "membar_storestore"; break; 1885 case lir_membar_loadstore: s = "membar_loadstore"; break; 1886 case lir_membar_storeload: s = "membar_storeload"; break; 1887 case lir_label: s = "label"; break; 1888 case lir_nop: s = "nop"; break; 1889 case lir_on_spin_wait: s = "on_spin_wait"; break; 1890 case lir_std_entry: s = "std_entry"; break; 1891 case lir_osr_entry: s = "osr_entry"; break; 1892 case lir_fpop_raw: s = "fpop_raw"; break; 1893 case lir_breakpoint: s = "breakpoint"; break; 1894 case lir_get_thread: s = "get_thread"; break; 1895 case lir_check_orig_pc: s = "check_orig_pc"; break; 1896 // LIR_Op1 1897 case lir_fxch: s = "fxch"; break; 1898 case lir_fld: s = "fld"; break; 1899 case lir_push: s = "push"; break; 1900 case lir_pop: s = "pop"; break; 1901 case lir_null_check: s = "null_check"; break; 1902 case lir_return: s = "return"; break; 1903 case lir_safepoint: s = "safepoint"; break; 1904 case lir_leal: s = "leal"; break; 1905 case lir_branch: s = "branch"; break; 1906 case lir_cond_float_branch: s = "flt_cond_br"; break; 1907 case lir_move: s = "move"; break; 1908 case lir_roundfp: s = "roundfp"; break; 1909 case lir_rtcall: s = "rtcall"; break; 1910 case lir_throw: s = "throw"; break; 1911 case lir_unwind: s = "unwind"; break; 1912 case lir_convert: s = "convert"; break; 1913 case lir_alloc_object: s = "alloc_obj"; break; 1914 case lir_monaddr: s = "mon_addr"; break; 1915 // LIR_Op2 1916 case lir_cmp: s = "cmp"; break; 1917 case lir_cmp_l2i: s = "cmp_l2i"; break; 1918 case lir_ucmp_fd2i: s = "ucomp_fd2i"; break; 1919 case lir_cmp_fd2i: s = "comp_fd2i"; break; 1920 case lir_add: s = "add"; break; 1921 case lir_sub: s = "sub"; break; 1922 case lir_mul: s = "mul"; break; 1923 case lir_div: s = "div"; break; 1924 case lir_rem: s = "rem"; break; 1925 case lir_abs: s = "abs"; break; 1926 case lir_neg: s = "neg"; break; 1927 case lir_sqrt: s = "sqrt"; break; 1928 case lir_f2hf: s = "f2hf"; break; 1929 case lir_hf2f: s = "hf2f"; break; 1930 case lir_logic_and: s = "logic_and"; break; 1931 case lir_logic_or: s = "logic_or"; break; 1932 case lir_logic_xor: s = "logic_xor"; break; 1933 case lir_shl: s = "shift_left"; break; 1934 case lir_shr: s = "shift_right"; break; 1935 case lir_ushr: s = "ushift_right"; break; 1936 case lir_alloc_array: s = "alloc_array"; break; 1937 case lir_xadd: s = "xadd"; break; 1938 case lir_xchg: s = "xchg"; break; 1939 // LIR_Op3 1940 case lir_idiv: s = "idiv"; break; 1941 case lir_irem: s = "irem"; break; 1942 case lir_fmad: s = "fmad"; break; 1943 case lir_fmaf: s = "fmaf"; break; 1944 // LIR_Op4 1945 case lir_cmove: s = "cmove"; break; 1946 // LIR_OpJavaCall 1947 case lir_static_call: s = "static"; break; 1948 case lir_optvirtual_call: s = "optvirtual"; break; 1949 case lir_icvirtual_call: s = "icvirtual"; break; 1950 case lir_dynamic_call: s = "dynamic"; break; 1951 // LIR_OpArrayCopy 1952 case lir_arraycopy: s = "arraycopy"; break; 1953 // LIR_OpUpdateCRC32 1954 case lir_updatecrc32: s = "updatecrc32"; break; 1955 // LIR_OpLock 1956 case lir_lock: s = "lock"; break; 1957 case lir_unlock: s = "unlock"; break; 1958 // LIR_OpDelay 1959 case lir_delay_slot: s = "delay"; break; 1960 // LIR_OpTypeCheck 1961 case lir_instanceof: s = "instanceof"; break; 1962 case lir_checkcast: s = "checkcast"; break; 1963 case lir_store_check: s = "store_check"; break; 1964 // LIR_OpFlattenedArrayCheck 1965 case lir_flat_array_check: s = "flat_array_check"; break; 1966 // LIR_OpNullFreeArrayCheck 1967 case lir_null_free_array_check: s = "null_free_array_check"; break; 1968 // LIR_OpSubstitutabilityCheck 1969 case lir_substitutability_check: s = "substitutability_check"; break; 1970 // LIR_OpCompareAndSwap 1971 case lir_cas_long: s = "cas_long"; break; 1972 case lir_cas_obj: s = "cas_obj"; break; 1973 case lir_cas_int: s = "cas_int"; break; 1974 // LIR_OpProfileCall 1975 case lir_profile_call: s = "profile_call"; break; 1976 // LIR_OpProfileType 1977 case lir_profile_type: s = "profile_type"; break; 1978 // LIR_OpProfileInlineType 1979 case lir_profile_inline_type: s = "profile_inline_type"; break; 1980 // LIR_OpAssert 1981 #ifdef ASSERT 1982 case lir_assert: s = "assert"; break; 1983 #endif 1984 case lir_none: ShouldNotReachHere();break; 1985 default: s = "illegal_op"; break; 1986 } 1987 return s; 1988 } 1989 1990 // LIR_OpJavaCall 1991 void LIR_OpJavaCall::print_instr(outputStream* out) const { 1992 out->print("call: "); 1993 out->print("[addr: " INTPTR_FORMAT "]", p2i(address())); 1994 if (receiver()->is_valid()) { 1995 out->print(" [recv: "); receiver()->print(out); out->print("]"); 1996 } 1997 if (result_opr()->is_valid()) { 1998 out->print(" [result: "); result_opr()->print(out); out->print("]"); 1999 } 2000 } 2001 2002 // LIR_OpLabel 2003 void LIR_OpLabel::print_instr(outputStream* out) const { 2004 out->print("[label:" INTPTR_FORMAT "]", p2i(_label)); 2005 } 2006 2007 // LIR_OpArrayCopy 2008 void LIR_OpArrayCopy::print_instr(outputStream* out) const { 2009 src()->print(out); out->print(" "); 2010 src_pos()->print(out); out->print(" "); 2011 dst()->print(out); out->print(" "); 2012 dst_pos()->print(out); out->print(" "); 2013 length()->print(out); out->print(" "); 2014 tmp()->print(out); out->print(" "); 2015 } 2016 2017 // LIR_OpUpdateCRC32 2018 void LIR_OpUpdateCRC32::print_instr(outputStream* out) const { 2019 crc()->print(out); out->print(" "); 2020 val()->print(out); out->print(" "); 2021 result_opr()->print(out); out->print(" "); 2022 } 2023 2024 // LIR_OpCompareAndSwap 2025 void LIR_OpCompareAndSwap::print_instr(outputStream* out) const { 2026 addr()->print(out); out->print(" "); 2027 cmp_value()->print(out); out->print(" "); 2028 new_value()->print(out); out->print(" "); 2029 tmp1()->print(out); out->print(" "); 2030 tmp2()->print(out); out->print(" "); 2031 2032 } 2033 2034 // LIR_Op0 2035 void LIR_Op0::print_instr(outputStream* out) const { 2036 result_opr()->print(out); 2037 } 2038 2039 // LIR_Op1 2040 const char * LIR_Op1::name() const { 2041 if (code() == lir_move) { 2042 switch (move_kind()) { 2043 case lir_move_normal: 2044 return "move"; 2045 case lir_move_volatile: 2046 return "volatile_move"; 2047 case lir_move_wide: 2048 return "wide_move"; 2049 default: 2050 ShouldNotReachHere(); 2051 return "illegal_op"; 2052 } 2053 } else { 2054 return LIR_Op::name(); 2055 } 2056 } 2057 2058 2059 void LIR_Op1::print_instr(outputStream* out) const { 2060 _opr->print(out); out->print(" "); 2061 result_opr()->print(out); out->print(" "); 2062 print_patch_code(out, patch_code()); 2063 } 2064 2065 2066 // LIR_Op1 2067 void LIR_OpRTCall::print_instr(outputStream* out) const { 2068 intx a = (intx)addr(); 2069 out->print("%s", Runtime1::name_for_address(addr())); 2070 out->print(" "); 2071 tmp()->print(out); 2072 } 2073 2074 void LIR_Op1::print_patch_code(outputStream* out, LIR_PatchCode code) { 2075 switch(code) { 2076 case lir_patch_none: break; 2077 case lir_patch_low: out->print("[patch_low]"); break; 2078 case lir_patch_high: out->print("[patch_high]"); break; 2079 case lir_patch_normal: out->print("[patch_normal]"); break; 2080 default: ShouldNotReachHere(); 2081 } 2082 } 2083 2084 // LIR_OpBranch 2085 void LIR_OpBranch::print_instr(outputStream* out) const { 2086 print_condition(out, cond()); out->print(" "); 2087 in_opr1()->print(out); out->print(" "); 2088 in_opr2()->print(out); out->print(" "); 2089 if (block() != nullptr) { 2090 out->print("[B%d] ", block()->block_id()); 2091 } else if (stub() != nullptr) { 2092 out->print("["); 2093 stub()->print_name(out); 2094 out->print(": " INTPTR_FORMAT "]", p2i(stub())); 2095 if (stub()->info() != nullptr) out->print(" [bci:%d]", stub()->info()->stack()->bci()); 2096 } else { 2097 out->print("[label:" INTPTR_FORMAT "] ", p2i(label())); 2098 } 2099 if (ublock() != nullptr) { 2100 out->print("unordered: [B%d] ", ublock()->block_id()); 2101 } 2102 } 2103 2104 void LIR_Op::print_condition(outputStream* out, LIR_Condition cond) { 2105 switch(cond) { 2106 case lir_cond_equal: out->print("[EQ]"); break; 2107 case lir_cond_notEqual: out->print("[NE]"); break; 2108 case lir_cond_less: out->print("[LT]"); break; 2109 case lir_cond_lessEqual: out->print("[LE]"); break; 2110 case lir_cond_greaterEqual: out->print("[GE]"); break; 2111 case lir_cond_greater: out->print("[GT]"); break; 2112 case lir_cond_belowEqual: out->print("[BE]"); break; 2113 case lir_cond_aboveEqual: out->print("[AE]"); break; 2114 case lir_cond_always: out->print("[AL]"); break; 2115 default: out->print("[%d]",cond); break; 2116 } 2117 } 2118 2119 // LIR_OpConvert 2120 void LIR_OpConvert::print_instr(outputStream* out) const { 2121 print_bytecode(out, bytecode()); 2122 in_opr()->print(out); out->print(" "); 2123 result_opr()->print(out); out->print(" "); 2124 } 2125 2126 void LIR_OpConvert::print_bytecode(outputStream* out, Bytecodes::Code code) { 2127 switch(code) { 2128 case Bytecodes::_d2f: out->print("[d2f] "); break; 2129 case Bytecodes::_d2i: out->print("[d2i] "); break; 2130 case Bytecodes::_d2l: out->print("[d2l] "); break; 2131 case Bytecodes::_f2d: out->print("[f2d] "); break; 2132 case Bytecodes::_f2i: out->print("[f2i] "); break; 2133 case Bytecodes::_f2l: out->print("[f2l] "); break; 2134 case Bytecodes::_i2b: out->print("[i2b] "); break; 2135 case Bytecodes::_i2c: out->print("[i2c] "); break; 2136 case Bytecodes::_i2d: out->print("[i2d] "); break; 2137 case Bytecodes::_i2f: out->print("[i2f] "); break; 2138 case Bytecodes::_i2l: out->print("[i2l] "); break; 2139 case Bytecodes::_i2s: out->print("[i2s] "); break; 2140 case Bytecodes::_l2i: out->print("[l2i] "); break; 2141 case Bytecodes::_l2f: out->print("[l2f] "); break; 2142 case Bytecodes::_l2d: out->print("[l2d] "); break; 2143 default: 2144 out->print("[?%d]",code); 2145 break; 2146 } 2147 } 2148 2149 void LIR_OpAllocObj::print_instr(outputStream* out) const { 2150 klass()->print(out); out->print(" "); 2151 obj()->print(out); out->print(" "); 2152 tmp1()->print(out); out->print(" "); 2153 tmp2()->print(out); out->print(" "); 2154 tmp3()->print(out); out->print(" "); 2155 tmp4()->print(out); out->print(" "); 2156 out->print("[hdr:%d]", header_size()); out->print(" "); 2157 out->print("[obj:%d]", object_size()); out->print(" "); 2158 out->print("[lbl:" INTPTR_FORMAT "]", p2i(stub()->entry())); 2159 } 2160 2161 void LIR_OpRoundFP::print_instr(outputStream* out) const { 2162 _opr->print(out); out->print(" "); 2163 tmp()->print(out); out->print(" "); 2164 result_opr()->print(out); out->print(" "); 2165 } 2166 2167 // LIR_Op2 2168 void LIR_Op2::print_instr(outputStream* out) const { 2169 if (code() == lir_cmp || code() == lir_branch || code() == lir_cond_float_branch) { 2170 print_condition(out, condition()); out->print(" "); 2171 } 2172 in_opr1()->print(out); out->print(" "); 2173 in_opr2()->print(out); out->print(" "); 2174 if (tmp1_opr()->is_valid()) { tmp1_opr()->print(out); out->print(" "); } 2175 if (tmp2_opr()->is_valid()) { tmp2_opr()->print(out); out->print(" "); } 2176 if (tmp3_opr()->is_valid()) { tmp3_opr()->print(out); out->print(" "); } 2177 if (tmp4_opr()->is_valid()) { tmp4_opr()->print(out); out->print(" "); } 2178 if (tmp5_opr()->is_valid()) { tmp5_opr()->print(out); out->print(" "); } 2179 result_opr()->print(out); 2180 } 2181 2182 void LIR_OpAllocArray::print_instr(outputStream* out) const { 2183 klass()->print(out); out->print(" "); 2184 len()->print(out); out->print(" "); 2185 obj()->print(out); out->print(" "); 2186 tmp1()->print(out); out->print(" "); 2187 tmp2()->print(out); out->print(" "); 2188 tmp3()->print(out); out->print(" "); 2189 tmp4()->print(out); out->print(" "); 2190 out->print("[type:0x%x]", type()); out->print(" "); 2191 out->print("[label:" INTPTR_FORMAT "]", p2i(stub()->entry())); 2192 } 2193 2194 2195 void LIR_OpTypeCheck::print_instr(outputStream* out) const { 2196 object()->print(out); out->print(" "); 2197 if (code() == lir_store_check) { 2198 array()->print(out); out->print(" "); 2199 } 2200 if (code() != lir_store_check) { 2201 klass()->print_name_on(out); out->print(" "); 2202 if (fast_check()) out->print("fast_check "); 2203 } 2204 tmp1()->print(out); out->print(" "); 2205 tmp2()->print(out); out->print(" "); 2206 tmp3()->print(out); out->print(" "); 2207 result_opr()->print(out); out->print(" "); 2208 if (info_for_exception() != nullptr) out->print(" [bci:%d]", info_for_exception()->stack()->bci()); 2209 } 2210 2211 void LIR_OpFlattenedArrayCheck::print_instr(outputStream* out) const { 2212 array()->print(out); out->print(" "); 2213 value()->print(out); out->print(" "); 2214 tmp()->print(out); out->print(" "); 2215 if (stub() != nullptr) { 2216 out->print("[label:" INTPTR_FORMAT "]", p2i(stub()->entry())); 2217 } 2218 } 2219 2220 void LIR_OpNullFreeArrayCheck::print_instr(outputStream* out) const { 2221 array()->print(out); out->print(" "); 2222 tmp()->print(out); out->print(" "); 2223 } 2224 2225 void LIR_OpSubstitutabilityCheck::print_instr(outputStream* out) const { 2226 result_opr()->print(out); out->print(" "); 2227 left()->print(out); out->print(" "); 2228 right()->print(out); out->print(" "); 2229 equal_result()->print(out); out->print(" "); 2230 not_equal_result()->print(out); out->print(" "); 2231 tmp1()->print(out); out->print(" "); 2232 tmp2()->print(out); out->print(" "); 2233 if (left_klass() == nullptr) { 2234 out->print("unknown "); 2235 } else { 2236 left_klass()->print(out); out->print(" "); 2237 } 2238 if (right_klass() == nullptr) { 2239 out->print("unknown "); 2240 } else { 2241 right_klass()->print(out); out->print(" "); 2242 } 2243 left_klass_op()->print(out); out->print(" "); 2244 right_klass_op()->print(out); out->print(" "); 2245 if (stub() != nullptr) { 2246 out->print("[label:" INTPTR_FORMAT "]", p2i(stub()->entry())); 2247 } 2248 } 2249 2250 // LIR_Op3 2251 void LIR_Op3::print_instr(outputStream* out) const { 2252 in_opr1()->print(out); out->print(" "); 2253 in_opr2()->print(out); out->print(" "); 2254 in_opr3()->print(out); out->print(" "); 2255 result_opr()->print(out); 2256 } 2257 2258 // LIR_Op4 2259 void LIR_Op4::print_instr(outputStream* out) const { 2260 print_condition(out, condition()); out->print(" "); 2261 in_opr1()->print(out); out->print(" "); 2262 in_opr2()->print(out); out->print(" "); 2263 in_opr3()->print(out); out->print(" "); 2264 in_opr4()->print(out); out->print(" "); 2265 result_opr()->print(out); 2266 } 2267 2268 void LIR_OpLock::print_instr(outputStream* out) const { 2269 hdr_opr()->print(out); out->print(" "); 2270 obj_opr()->print(out); out->print(" "); 2271 lock_opr()->print(out); out->print(" "); 2272 if (_scratch->is_valid()) { 2273 _scratch->print(out); out->print(" "); 2274 } 2275 out->print("[lbl:" INTPTR_FORMAT "]", p2i(stub()->entry())); 2276 } 2277 2278 void LIR_OpLoadKlass::print_instr(outputStream* out) const { 2279 obj()->print(out); out->print(" "); 2280 result_opr()->print(out); out->print(" "); 2281 } 2282 2283 #ifdef ASSERT 2284 void LIR_OpAssert::print_instr(outputStream* out) const { 2285 print_condition(out, condition()); out->print(" "); 2286 in_opr1()->print(out); out->print(" "); 2287 in_opr2()->print(out); out->print(", \""); 2288 out->print("%s", msg()); out->print("\""); 2289 } 2290 #endif 2291 2292 2293 void LIR_OpDelay::print_instr(outputStream* out) const { 2294 _op->print_on(out); 2295 } 2296 2297 2298 // LIR_OpProfileCall 2299 void LIR_OpProfileCall::print_instr(outputStream* out) const { 2300 profiled_method()->name()->print_symbol_on(out); 2301 out->print("."); 2302 profiled_method()->holder()->name()->print_symbol_on(out); 2303 out->print(" @ %d ", profiled_bci()); 2304 mdo()->print(out); out->print(" "); 2305 recv()->print(out); out->print(" "); 2306 tmp1()->print(out); out->print(" "); 2307 } 2308 2309 // LIR_OpProfileType 2310 void LIR_OpProfileType::print_instr(outputStream* out) const { 2311 out->print("exact = "); 2312 if (exact_klass() == nullptr) { 2313 out->print("unknown"); 2314 } else { 2315 exact_klass()->print_name_on(out); 2316 } 2317 out->print(" current = "); ciTypeEntries::print_ciklass(out, current_klass()); 2318 out->print(" "); 2319 mdp()->print(out); out->print(" "); 2320 obj()->print(out); out->print(" "); 2321 tmp()->print(out); out->print(" "); 2322 } 2323 2324 // LIR_OpProfileInlineType 2325 void LIR_OpProfileInlineType::print_instr(outputStream* out) const { 2326 out->print(" flag = %x ", flag()); 2327 mdp()->print(out); out->print(" "); 2328 obj()->print(out); out->print(" "); 2329 tmp()->print(out); out->print(" "); 2330 } 2331 2332 #endif // PRODUCT 2333 2334 // Implementation of LIR_InsertionBuffer 2335 2336 void LIR_InsertionBuffer::append(int index, LIR_Op* op) { 2337 assert(_index_and_count.length() % 2 == 0, "must have a count for each index"); 2338 2339 int i = number_of_insertion_points() - 1; 2340 if (i < 0 || index_at(i) < index) { 2341 append_new(index, 1); 2342 } else { 2343 assert(index_at(i) == index, "can append LIR_Ops in ascending order only"); 2344 assert(count_at(i) > 0, "check"); 2345 set_count_at(i, count_at(i) + 1); 2346 } 2347 _ops.push(op); 2348 2349 DEBUG_ONLY(verify()); 2350 } 2351 2352 #ifdef ASSERT 2353 void LIR_InsertionBuffer::verify() { 2354 int sum = 0; 2355 int prev_idx = -1; 2356 2357 for (int i = 0; i < number_of_insertion_points(); i++) { 2358 assert(prev_idx < index_at(i), "index must be ordered ascending"); 2359 sum += count_at(i); 2360 } 2361 assert(sum == number_of_ops(), "wrong total sum"); 2362 } 2363 #endif