src/share/vm/c1/c1_LIR.cpp

Thu, 16 Aug 2018 15:34:19 +0800

author
fujie
date
Thu, 16 Aug 2018 15:34:19 +0800
changeset 9215
8843990f569c
parent 9214
950e185f5ded
child 9249
8401c6dc109a
permissions
-rw-r--r--

#7407 [C1] enable adjusted EdgeMoveOptimizer::optimize for mips
Summary:bool LIR_OprDesc::has_common_register(LIR_Opr opr) should return true for [t1t1|J] and [t1|I].

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

mercurial