src/share/vm/c1/c1_LIR.cpp

Mon, 09 Jul 2018 09:20:14 +0800

author
fujie
date
Mon, 09 Jul 2018 09:20:14 +0800
changeset 9157
2966b0be4027
parent 9143
239e32ede77d
child 9167
1336d592e5b8
permissions
-rw-r--r--

#7238 [C1] cmove was added for mips to profile branch.

Effect:
java \
-Xcomp \
-XX:-PrintCompilation \
-XX:TieredStopAtLevel=3 \
-version

Exception in thread "main" was fixed.

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

mercurial