src/share/vm/c1/c1_LIR.cpp

Tue, 21 Feb 2012 13:14:55 -0500

author
jiangli
date
Tue, 21 Feb 2012 13:14:55 -0500
changeset 3592
701a83c86f28
parent 3394
b642b49f9738
child 3787
6759698e3140
permissions
-rw-r--r--

7120481: storeStore barrier in constructor with final field
Summary: Issue storestore barrier before constructor return if the constructor write final field.
Reviewed-by: dholmes, jrose, roland, coleenp
Contributed-by: Jiangli Zhou <jiangli.zhou@oracle.com>

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

mercurial