src/share/vm/c1/c1_LIR.cpp

Thu, 24 May 2018 19:49:50 +0800

author
aoqi
date
Thu, 24 May 2018 19:49:50 +0800
changeset 8865
ffcdff41a92f
parent 8856
ac27a9c85bea
child 9126
bc5b8e3dcb6b
permissions
-rw-r--r--

some C1 fix
Contributed-by: chenhaoxuan, zhaixiang, aoqi

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

mercurial