src/share/vm/c1/c1_LIR.cpp

Sat, 07 Nov 2020 10:30:02 +0800

author
aoqi
date
Sat, 07 Nov 2020 10:30:02 +0800
changeset 10026
8c95980d0b66
parent 9806
758c07667682
permissions
-rw-r--r--

Added tag mips-jdk8u275-b01 for changeset d3b4d62f391f

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

mercurial