Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/c1/c1_LIR.cpp
32285 views
/*1* Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#include "precompiled.hpp"25#include "c1/c1_InstructionPrinter.hpp"26#include "c1/c1_LIR.hpp"27#include "c1/c1_LIRAssembler.hpp"28#include "c1/c1_ValueStack.hpp"29#include "ci/ciInstance.hpp"30#include "runtime/sharedRuntime.hpp"3132Register LIR_OprDesc::as_register() const {33return FrameMap::cpu_rnr2reg(cpu_regnr());34}3536Register LIR_OprDesc::as_register_lo() const {37return FrameMap::cpu_rnr2reg(cpu_regnrLo());38}3940Register LIR_OprDesc::as_register_hi() const {41return FrameMap::cpu_rnr2reg(cpu_regnrHi());42}4344#if defined(X86)4546XMMRegister LIR_OprDesc::as_xmm_float_reg() const {47return FrameMap::nr2xmmreg(xmm_regnr());48}4950XMMRegister LIR_OprDesc::as_xmm_double_reg() const {51assert(xmm_regnrLo() == xmm_regnrHi(), "assumed in calculation");52return FrameMap::nr2xmmreg(xmm_regnrLo());53}5455#endif // X865657#if defined(SPARC) || defined(PPC)5859FloatRegister LIR_OprDesc::as_float_reg() const {60return FrameMap::nr2floatreg(fpu_regnr());61}6263FloatRegister LIR_OprDesc::as_double_reg() const {64return FrameMap::nr2floatreg(fpu_regnrHi());65}6667#endif6869#if defined(ARM) || defined(AARCH64)7071FloatRegister LIR_OprDesc::as_float_reg() const {72return as_FloatRegister(fpu_regnr());73}7475FloatRegister LIR_OprDesc::as_double_reg() const {76return as_FloatRegister(fpu_regnrLo());77}7879#endif808182LIR_Opr LIR_OprFact::illegalOpr = LIR_OprFact::illegal();8384LIR_Opr LIR_OprFact::value_type(ValueType* type) {85ValueTag tag = type->tag();86switch (tag) {87case metaDataTag : {88ClassConstant* c = type->as_ClassConstant();89if (c != NULL && !c->value()->is_loaded()) {90return LIR_OprFact::metadataConst(NULL);91} else if (c != NULL) {92return LIR_OprFact::metadataConst(c->value()->constant_encoding());93} else {94MethodConstant* m = type->as_MethodConstant();95assert (m != NULL, "not a class or a method?");96return LIR_OprFact::metadataConst(m->value()->constant_encoding());97}98}99case objectTag : {100return LIR_OprFact::oopConst(type->as_ObjectType()->encoding());101}102case addressTag: return LIR_OprFact::addressConst(type->as_AddressConstant()->value());103case intTag : return LIR_OprFact::intConst(type->as_IntConstant()->value());104case floatTag : return LIR_OprFact::floatConst(type->as_FloatConstant()->value());105case longTag : return LIR_OprFact::longConst(type->as_LongConstant()->value());106case doubleTag : return LIR_OprFact::doubleConst(type->as_DoubleConstant()->value());107default: ShouldNotReachHere(); return LIR_OprFact::intConst(-1);108}109}110111112LIR_Opr LIR_OprFact::dummy_value_type(ValueType* type) {113switch (type->tag()) {114case objectTag: return LIR_OprFact::oopConst(NULL);115case addressTag:return LIR_OprFact::addressConst(0);116case intTag: return LIR_OprFact::intConst(0);117case floatTag: return LIR_OprFact::floatConst(0.0);118case longTag: return LIR_OprFact::longConst(0);119case doubleTag: return LIR_OprFact::doubleConst(0.0);120default: ShouldNotReachHere(); return LIR_OprFact::intConst(-1);121}122return illegalOpr;123}124125126127//---------------------------------------------------128129130LIR_Address::Scale LIR_Address::scale(BasicType type) {131int elem_size = type2aelembytes(type);132switch (elem_size) {133case 1: return LIR_Address::times_1;134case 2: return LIR_Address::times_2;135case 4: return LIR_Address::times_4;136case 8: return LIR_Address::times_8;137}138ShouldNotReachHere();139return LIR_Address::times_1;140}141142143#ifndef PRODUCT144void LIR_Address::verify0() const {145#if defined(SPARC) || defined(PPC)146assert(scale() == times_1, "Scaled addressing mode not available on SPARC/PPC and should not be used");147assert(disp() == 0 || index()->is_illegal(), "can't have both");148#endif149#ifdef _LP64150assert(base()->is_cpu_register(), "wrong base operand");151#ifndef AARCH64152assert(index()->is_illegal() || index()->is_double_cpu(), "wrong index operand");153#else154assert(index()->is_illegal() || index()->is_double_cpu() || index()->is_single_cpu(), "wrong index operand");155#endif156assert(base()->type() == T_OBJECT || base()->type() == T_LONG || base()->type() == T_METADATA,157"wrong type for addresses");158#else159assert(base()->is_single_cpu(), "wrong base operand");160assert(index()->is_illegal() || index()->is_single_cpu(), "wrong index operand");161assert(base()->type() == T_OBJECT || base()->type() == T_INT || base()->type() == T_METADATA,162"wrong type for addresses");163#endif164}165#endif166167168//---------------------------------------------------169170char LIR_OprDesc::type_char(BasicType t) {171switch (t) {172case T_ARRAY:173t = T_OBJECT;174case T_BOOLEAN:175case T_CHAR:176case T_FLOAT:177case T_DOUBLE:178case T_BYTE:179case T_SHORT:180case T_INT:181case T_LONG:182case T_OBJECT:183case T_ADDRESS:184case T_VOID:185return ::type2char(t);186case T_METADATA:187return 'M';188case T_ILLEGAL:189return '?';190191default:192ShouldNotReachHere();193return '?';194}195}196197#ifndef PRODUCT198void LIR_OprDesc::validate_type() const {199200#ifdef ASSERT201if (!is_pointer() && !is_illegal()) {202OprKind kindfield = kind_field(); // Factored out because of compiler bug, see 8002160203switch (as_BasicType(type_field())) {204case T_LONG:205assert((kindfield == cpu_register || kindfield == stack_value) &&206size_field() == double_size, "must match");207break;208case T_FLOAT:209// FP return values can be also in CPU registers on ARM and PPC (softfp ABI)210assert((kindfield == fpu_register || kindfield == stack_value211ARM_ONLY(|| kindfield == cpu_register)212PPC_ONLY(|| kindfield == cpu_register) ) &&213size_field() == single_size, "must match");214break;215case T_DOUBLE:216// FP return values can be also in CPU registers on ARM and PPC (softfp ABI)217assert((kindfield == fpu_register || kindfield == stack_value218ARM_ONLY(|| kindfield == cpu_register)219PPC_ONLY(|| kindfield == cpu_register) ) &&220size_field() == double_size, "must match");221break;222case T_BOOLEAN:223case T_CHAR:224case T_BYTE:225case T_SHORT:226case T_INT:227case T_ADDRESS:228case T_OBJECT:229case T_METADATA:230case T_ARRAY:231assert((kindfield == cpu_register || kindfield == stack_value) &&232size_field() == single_size, "must match");233break;234235case T_ILLEGAL:236// XXX TKR also means unknown right now237// assert(is_illegal(), "must match");238break;239240default:241ShouldNotReachHere();242}243}244#endif245246}247#endif // PRODUCT248249250bool LIR_OprDesc::is_oop() const {251if (is_pointer()) {252return pointer()->is_oop_pointer();253} else {254OprType t= type_field();255assert(t != unknown_type, "not set");256return t == object_type;257}258}259260261262void LIR_Op2::verify() const {263#ifdef ASSERT264switch (code()) {265case lir_cmove:266case lir_xchg:267break;268269default:270assert(!result_opr()->is_register() || !result_opr()->is_oop_register(),271"can't produce oops from arith");272}273274if (TwoOperandLIRForm) {275switch (code()) {276case lir_add:277case lir_sub:278case lir_mul:279case lir_mul_strictfp:280case lir_div:281case lir_div_strictfp:282case lir_rem:283case lir_logic_and:284case lir_logic_or:285case lir_logic_xor:286case lir_shl:287case lir_shr:288assert(in_opr1() == result_opr(), "opr1 and result must match");289assert(in_opr1()->is_valid() && in_opr2()->is_valid(), "must be valid");290break;291292// special handling for lir_ushr because of write barriers293case lir_ushr:294assert(in_opr1() == result_opr() || in_opr2()->is_constant(), "opr1 and result must match or shift count is constant");295assert(in_opr1()->is_valid() && in_opr2()->is_valid(), "must be valid");296break;297298}299}300#endif301}302303304LIR_OpBranch::LIR_OpBranch(LIR_Condition cond, BasicType type, BlockBegin* block)305: LIR_Op(lir_branch, LIR_OprFact::illegalOpr, (CodeEmitInfo*)NULL)306, _cond(cond)307, _type(type)308, _label(block->label())309, _block(block)310, _ublock(NULL)311, _stub(NULL) {312}313314LIR_OpBranch::LIR_OpBranch(LIR_Condition cond, BasicType type, CodeStub* stub) :315LIR_Op(lir_branch, LIR_OprFact::illegalOpr, (CodeEmitInfo*)NULL)316, _cond(cond)317, _type(type)318, _label(stub->entry())319, _block(NULL)320, _ublock(NULL)321, _stub(stub) {322}323324LIR_OpBranch::LIR_OpBranch(LIR_Condition cond, BasicType type, BlockBegin* block, BlockBegin* ublock)325: LIR_Op(lir_cond_float_branch, LIR_OprFact::illegalOpr, (CodeEmitInfo*)NULL)326, _cond(cond)327, _type(type)328, _label(block->label())329, _block(block)330, _ublock(ublock)331, _stub(NULL)332{333}334335void LIR_OpBranch::change_block(BlockBegin* b) {336assert(_block != NULL, "must have old block");337assert(_block->label() == label(), "must be equal");338339_block = b;340_label = b->label();341}342343void LIR_OpBranch::change_ublock(BlockBegin* b) {344assert(_ublock != NULL, "must have old block");345_ublock = b;346}347348void LIR_OpBranch::negate_cond() {349switch (_cond) {350case lir_cond_equal: _cond = lir_cond_notEqual; break;351case lir_cond_notEqual: _cond = lir_cond_equal; break;352case lir_cond_less: _cond = lir_cond_greaterEqual; break;353case lir_cond_lessEqual: _cond = lir_cond_greater; break;354case lir_cond_greaterEqual: _cond = lir_cond_less; break;355case lir_cond_greater: _cond = lir_cond_lessEqual; break;356default: ShouldNotReachHere();357}358}359360361LIR_OpTypeCheck::LIR_OpTypeCheck(LIR_Code code, LIR_Opr result, LIR_Opr object, ciKlass* klass,362LIR_Opr tmp1, LIR_Opr tmp2, LIR_Opr tmp3,363bool fast_check, CodeEmitInfo* info_for_exception, CodeEmitInfo* info_for_patch,364CodeStub* stub)365366: LIR_Op(code, result, NULL)367, _object(object)368, _array(LIR_OprFact::illegalOpr)369, _klass(klass)370, _tmp1(tmp1)371, _tmp2(tmp2)372, _tmp3(tmp3)373, _fast_check(fast_check)374, _stub(stub)375, _info_for_patch(info_for_patch)376, _info_for_exception(info_for_exception)377, _profiled_method(NULL)378, _profiled_bci(-1)379, _should_profile(false)380{381if (code == lir_checkcast) {382assert(info_for_exception != NULL, "checkcast throws exceptions");383} else if (code == lir_instanceof) {384assert(info_for_exception == NULL, "instanceof throws no exceptions");385} else {386ShouldNotReachHere();387}388}389390391392LIR_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)393: LIR_Op(code, LIR_OprFact::illegalOpr, NULL)394, _object(object)395, _array(array)396, _klass(NULL)397, _tmp1(tmp1)398, _tmp2(tmp2)399, _tmp3(tmp3)400, _fast_check(false)401, _stub(NULL)402, _info_for_patch(NULL)403, _info_for_exception(info_for_exception)404, _profiled_method(NULL)405, _profiled_bci(-1)406, _should_profile(false)407{408if (code == lir_store_check) {409_stub = new ArrayStoreExceptionStub(object, info_for_exception);410assert(info_for_exception != NULL, "store_check throws exceptions");411} else {412ShouldNotReachHere();413}414}415416417LIR_OpArrayCopy::LIR_OpArrayCopy(LIR_Opr src, LIR_Opr src_pos, LIR_Opr dst, LIR_Opr dst_pos, LIR_Opr length,418LIR_Opr tmp, ciArrayKlass* expected_type, int flags, CodeEmitInfo* info)419: LIR_Op(lir_arraycopy, LIR_OprFact::illegalOpr, info)420, _tmp(tmp)421, _src(src)422, _src_pos(src_pos)423, _dst(dst)424, _dst_pos(dst_pos)425, _flags(flags)426, _expected_type(expected_type)427, _length(length) {428_stub = new ArrayCopyStub(this);429}430431LIR_OpUpdateCRC32::LIR_OpUpdateCRC32(LIR_Opr crc, LIR_Opr val, LIR_Opr res)432: LIR_Op(lir_updatecrc32, res, NULL)433, _crc(crc)434, _val(val) {435}436437//-------------------verify--------------------------438439void LIR_Op1::verify() const {440switch(code()) {441case lir_move:442assert(in_opr()->is_valid() && result_opr()->is_valid(), "must be");443break;444case lir_null_check:445assert(in_opr()->is_register(), "must be");446break;447case lir_return:448assert(in_opr()->is_register() || in_opr()->is_illegal(), "must be");449break;450}451}452453void LIR_OpRTCall::verify() const {454assert(strcmp(Runtime1::name_for_address(addr()), "<unknown function>") != 0, "unknown function");455}456457//-------------------visits--------------------------458459// complete rework of LIR instruction visitor.460// The virtual call for each instruction type is replaced by a big461// switch that adds the operands for each instruction462463void LIR_OpVisitState::visit(LIR_Op* op) {464// copy information from the LIR_Op465reset();466set_op(op);467468switch (op->code()) {469470// LIR_Op0471case lir_word_align: // result and info always invalid472case lir_backwardbranch_target: // result and info always invalid473case lir_build_frame: // result and info always invalid474case lir_fpop_raw: // result and info always invalid475case lir_24bit_FPU: // result and info always invalid476case lir_reset_FPU: // result and info always invalid477case lir_breakpoint: // result and info always invalid478case lir_membar: // result and info always invalid479case lir_membar_acquire: // result and info always invalid480case lir_membar_release: // result and info always invalid481case lir_membar_loadload: // result and info always invalid482case lir_membar_storestore: // result and info always invalid483case lir_membar_loadstore: // result and info always invalid484case lir_membar_storeload: // result and info always invalid485{486assert(op->as_Op0() != NULL, "must be");487assert(op->_info == NULL, "info not used by this instruction");488assert(op->_result->is_illegal(), "not used");489break;490}491492case lir_nop: // may have info, result always invalid493case lir_std_entry: // may have result, info always invalid494case lir_osr_entry: // may have result, info always invalid495case lir_get_thread: // may have result, info always invalid496{497assert(op->as_Op0() != NULL, "must be");498if (op->_info != NULL) do_info(op->_info);499if (op->_result->is_valid()) do_output(op->_result);500break;501}502503504// LIR_OpLabel505case lir_label: // result and info always invalid506{507assert(op->as_OpLabel() != NULL, "must be");508assert(op->_info == NULL, "info not used by this instruction");509assert(op->_result->is_illegal(), "not used");510break;511}512513514// LIR_Op1515case lir_fxch: // input always valid, result and info always invalid516case lir_fld: // input always valid, result and info always invalid517case lir_ffree: // input always valid, result and info always invalid518case lir_push: // input always valid, result and info always invalid519case lir_pop: // input always valid, result and info always invalid520case lir_return: // input always valid, result and info always invalid521case lir_leal: // input and result always valid, info always invalid522case lir_neg: // input and result always valid, info always invalid523case lir_monaddr: // input and result always valid, info always invalid524case lir_null_check: // input and info always valid, result always invalid525case lir_move: // input and result always valid, may have info526case lir_pack64: // input and result always valid527case lir_unpack64: // input and result always valid528case lir_prefetchr: // input always valid, result and info always invalid529case lir_prefetchw: // input always valid, result and info always invalid530{531assert(op->as_Op1() != NULL, "must be");532LIR_Op1* op1 = (LIR_Op1*)op;533534if (op1->_info) do_info(op1->_info);535if (op1->_opr->is_valid()) do_input(op1->_opr);536if (op1->_result->is_valid()) do_output(op1->_result);537538break;539}540541case lir_safepoint:542{543assert(op->as_Op1() != NULL, "must be");544LIR_Op1* op1 = (LIR_Op1*)op;545546assert(op1->_info != NULL, ""); do_info(op1->_info);547if (op1->_opr->is_valid()) do_temp(op1->_opr); // safepoints on SPARC need temporary register548assert(op1->_result->is_illegal(), "safepoint does not produce value");549550break;551}552553// LIR_OpConvert;554case lir_convert: // input and result always valid, info always invalid555{556assert(op->as_OpConvert() != NULL, "must be");557LIR_OpConvert* opConvert = (LIR_OpConvert*)op;558559assert(opConvert->_info == NULL, "must be");560if (opConvert->_opr->is_valid()) do_input(opConvert->_opr);561if (opConvert->_result->is_valid()) do_output(opConvert->_result);562#if defined(PPC) || defined(AARCH64)563if (opConvert->_tmp1->is_valid()) do_temp(opConvert->_tmp1);564if (opConvert->_tmp2->is_valid()) do_temp(opConvert->_tmp2);565#endif566do_stub(opConvert->_stub);567568break;569}570571// LIR_OpBranch;572case lir_branch: // may have info, input and result register always invalid573case lir_cond_float_branch: // may have info, input and result register always invalid574{575assert(op->as_OpBranch() != NULL, "must be");576LIR_OpBranch* opBranch = (LIR_OpBranch*)op;577578if (opBranch->_info != NULL) do_info(opBranch->_info);579assert(opBranch->_result->is_illegal(), "not used");580if (opBranch->_stub != NULL) opBranch->stub()->visit(this);581582break;583}584585586// LIR_OpAllocObj587case lir_alloc_object:588{589assert(op->as_OpAllocObj() != NULL, "must be");590LIR_OpAllocObj* opAllocObj = (LIR_OpAllocObj*)op;591592if (opAllocObj->_info) do_info(opAllocObj->_info);593if (opAllocObj->_opr->is_valid()) { do_input(opAllocObj->_opr);594do_temp(opAllocObj->_opr);595}596if (opAllocObj->_tmp1->is_valid()) do_temp(opAllocObj->_tmp1);597if (opAllocObj->_tmp2->is_valid()) do_temp(opAllocObj->_tmp2);598if (opAllocObj->_tmp3->is_valid()) do_temp(opAllocObj->_tmp3);599if (opAllocObj->_tmp4->is_valid()) do_temp(opAllocObj->_tmp4);600if (opAllocObj->_result->is_valid()) do_output(opAllocObj->_result);601do_stub(opAllocObj->_stub);602break;603}604605606// LIR_OpRoundFP;607case lir_roundfp: {608assert(op->as_OpRoundFP() != NULL, "must be");609LIR_OpRoundFP* opRoundFP = (LIR_OpRoundFP*)op;610611assert(op->_info == NULL, "info not used by this instruction");612assert(opRoundFP->_tmp->is_illegal(), "not used");613do_input(opRoundFP->_opr);614do_output(opRoundFP->_result);615616break;617}618619620// LIR_Op2621case lir_cmp:622case lir_cmp_l2i:623case lir_ucmp_fd2i:624case lir_cmp_fd2i:625case lir_add:626case lir_sub:627case lir_mul:628case lir_div:629case lir_rem:630case lir_sqrt:631case lir_abs:632case lir_logic_and:633case lir_logic_or:634case lir_logic_xor:635case lir_shl:636case lir_shr:637case lir_ushr:638case lir_xadd:639case lir_xchg:640case lir_assert:641{642assert(op->as_Op2() != NULL, "must be");643LIR_Op2* op2 = (LIR_Op2*)op;644assert(op2->_tmp2->is_illegal() && op2->_tmp3->is_illegal() &&645op2->_tmp4->is_illegal() && op2->_tmp5->is_illegal(), "not used");646647if (op2->_info) do_info(op2->_info);648if (op2->_opr1->is_valid()) do_input(op2->_opr1);649if (op2->_opr2->is_valid()) do_input(op2->_opr2);650if (op2->_tmp1->is_valid()) do_temp(op2->_tmp1);651if (op2->_result->is_valid()) do_output(op2->_result);652if (op->code() == lir_xchg || op->code() == lir_xadd) {653// on ARM and PPC, return value is loaded first so could654// destroy inputs. On other platforms that implement those655// (x86, sparc), the extra constrainsts are harmless.656if (op2->_opr1->is_valid()) do_temp(op2->_opr1);657if (op2->_opr2->is_valid()) do_temp(op2->_opr2);658}659660break;661}662663// special handling for cmove: right input operand must not be equal664// to the result operand, otherwise the backend fails665case lir_cmove:666{667assert(op->as_Op2() != NULL, "must be");668LIR_Op2* op2 = (LIR_Op2*)op;669670assert(op2->_info == NULL && op2->_tmp1->is_illegal() && op2->_tmp2->is_illegal() &&671op2->_tmp3->is_illegal() && op2->_tmp4->is_illegal() && op2->_tmp5->is_illegal(), "not used");672assert(op2->_opr1->is_valid() && op2->_opr2->is_valid() && op2->_result->is_valid(), "used");673674do_input(op2->_opr1);675do_input(op2->_opr2);676do_temp(op2->_opr2);677do_output(op2->_result);678679break;680}681682// vspecial handling for strict operations: register input operands683// as temp to guarantee that they do not overlap with other684// registers685case lir_mul_strictfp:686case lir_div_strictfp:687{688assert(op->as_Op2() != NULL, "must be");689LIR_Op2* op2 = (LIR_Op2*)op;690691assert(op2->_info == NULL, "not used");692assert(op2->_opr1->is_valid(), "used");693assert(op2->_opr2->is_valid(), "used");694assert(op2->_result->is_valid(), "used");695assert(op2->_tmp2->is_illegal() && op2->_tmp3->is_illegal() &&696op2->_tmp4->is_illegal() && op2->_tmp5->is_illegal(), "not used");697698do_input(op2->_opr1); do_temp(op2->_opr1);699do_input(op2->_opr2); do_temp(op2->_opr2);700if (op2->_tmp1->is_valid()) do_temp(op2->_tmp1);701do_output(op2->_result);702703break;704}705706case lir_throw: {707assert(op->as_Op2() != NULL, "must be");708LIR_Op2* op2 = (LIR_Op2*)op;709710if (op2->_info) do_info(op2->_info);711if (op2->_opr1->is_valid()) do_temp(op2->_opr1);712if (op2->_opr2->is_valid()) do_input(op2->_opr2); // exception object is input parameter713assert(op2->_result->is_illegal(), "no result");714assert(op2->_tmp2->is_illegal() && op2->_tmp3->is_illegal() &&715op2->_tmp4->is_illegal() && op2->_tmp5->is_illegal(), "not used");716717break;718}719720case lir_unwind: {721assert(op->as_Op1() != NULL, "must be");722LIR_Op1* op1 = (LIR_Op1*)op;723724assert(op1->_info == NULL, "no info");725assert(op1->_opr->is_valid(), "exception oop"); do_input(op1->_opr);726assert(op1->_result->is_illegal(), "no result");727728break;729}730731732case lir_tan:733case lir_sin:734case lir_cos:735case lir_log:736case lir_log10:737case lir_exp: {738assert(op->as_Op2() != NULL, "must be");739LIR_Op2* op2 = (LIR_Op2*)op;740741// On x86 tan/sin/cos need two temporary fpu stack slots and742// log/log10 need one so handle opr2 and tmp as temp inputs.743// Register input operand as temp to guarantee that it doesn't744// overlap with the input.745assert(op2->_info == NULL, "not used");746assert(op2->_tmp5->is_illegal(), "not used");747assert(op2->_tmp2->is_valid() == (op->code() == lir_exp), "not used");748assert(op2->_tmp3->is_valid() == (op->code() == lir_exp), "not used");749assert(op2->_tmp4->is_valid() == (op->code() == lir_exp), "not used");750assert(op2->_opr1->is_valid(), "used");751do_input(op2->_opr1); do_temp(op2->_opr1);752753if (op2->_opr2->is_valid()) do_temp(op2->_opr2);754if (op2->_tmp1->is_valid()) do_temp(op2->_tmp1);755if (op2->_tmp2->is_valid()) do_temp(op2->_tmp2);756if (op2->_tmp3->is_valid()) do_temp(op2->_tmp3);757if (op2->_tmp4->is_valid()) do_temp(op2->_tmp4);758if (op2->_result->is_valid()) do_output(op2->_result);759760break;761}762763case lir_pow: {764assert(op->as_Op2() != NULL, "must be");765LIR_Op2* op2 = (LIR_Op2*)op;766767// On x86 pow needs two temporary fpu stack slots: tmp1 and768// tmp2. Register input operands as temps to guarantee that it769// doesn't overlap with the temporary slots.770assert(op2->_info == NULL, "not used");771assert(op2->_opr1->is_valid() && op2->_opr2->is_valid(), "used");772assert(op2->_tmp1->is_valid() && op2->_tmp2->is_valid() && op2->_tmp3->is_valid()773&& op2->_tmp4->is_valid() && op2->_tmp5->is_valid(), "used");774assert(op2->_result->is_valid(), "used");775776do_input(op2->_opr1); do_temp(op2->_opr1);777do_input(op2->_opr2); do_temp(op2->_opr2);778do_temp(op2->_tmp1);779do_temp(op2->_tmp2);780do_temp(op2->_tmp3);781do_temp(op2->_tmp4);782do_temp(op2->_tmp5);783do_output(op2->_result);784785break;786}787788// LIR_Op3789case lir_idiv:790case lir_irem: {791assert(op->as_Op3() != NULL, "must be");792LIR_Op3* op3= (LIR_Op3*)op;793794if (op3->_info) do_info(op3->_info);795if (op3->_opr1->is_valid()) do_input(op3->_opr1);796797// second operand is input and temp, so ensure that second operand798// and third operand get not the same register799if (op3->_opr2->is_valid()) do_input(op3->_opr2);800if (op3->_opr2->is_valid()) do_temp(op3->_opr2);801if (op3->_opr3->is_valid()) do_temp(op3->_opr3);802803if (op3->_result->is_valid()) do_output(op3->_result);804805break;806}807808809// LIR_OpJavaCall810case lir_static_call:811case lir_optvirtual_call:812case lir_icvirtual_call:813case lir_virtual_call:814case lir_dynamic_call: {815LIR_OpJavaCall* opJavaCall = op->as_OpJavaCall();816assert(opJavaCall != NULL, "must be");817818if (opJavaCall->_receiver->is_valid()) do_input(opJavaCall->_receiver);819820// only visit register parameters821int n = opJavaCall->_arguments->length();822for (int i = opJavaCall->_receiver->is_valid() ? 1 : 0; i < n; i++) {823if (!opJavaCall->_arguments->at(i)->is_pointer()) {824do_input(*opJavaCall->_arguments->adr_at(i));825}826}827828if (opJavaCall->_info) do_info(opJavaCall->_info);829if (FrameMap::method_handle_invoke_SP_save_opr() != LIR_OprFact::illegalOpr &&830opJavaCall->is_method_handle_invoke()) {831opJavaCall->_method_handle_invoke_SP_save_opr = FrameMap::method_handle_invoke_SP_save_opr();832do_temp(opJavaCall->_method_handle_invoke_SP_save_opr);833}834do_call();835if (opJavaCall->_result->is_valid()) do_output(opJavaCall->_result);836837break;838}839840841// LIR_OpRTCall842case lir_rtcall: {843assert(op->as_OpRTCall() != NULL, "must be");844LIR_OpRTCall* opRTCall = (LIR_OpRTCall*)op;845846// only visit register parameters847int n = opRTCall->_arguments->length();848for (int i = 0; i < n; i++) {849if (!opRTCall->_arguments->at(i)->is_pointer()) {850do_input(*opRTCall->_arguments->adr_at(i));851}852}853if (opRTCall->_info) do_info(opRTCall->_info);854if (opRTCall->_tmp->is_valid()) do_temp(opRTCall->_tmp);855do_call();856if (opRTCall->_result->is_valid()) do_output(opRTCall->_result);857858break;859}860861862// LIR_OpArrayCopy863case lir_arraycopy: {864assert(op->as_OpArrayCopy() != NULL, "must be");865LIR_OpArrayCopy* opArrayCopy = (LIR_OpArrayCopy*)op;866867assert(opArrayCopy->_result->is_illegal(), "unused");868assert(opArrayCopy->_src->is_valid(), "used"); do_input(opArrayCopy->_src); do_temp(opArrayCopy->_src);869assert(opArrayCopy->_src_pos->is_valid(), "used"); do_input(opArrayCopy->_src_pos); do_temp(opArrayCopy->_src_pos);870assert(opArrayCopy->_dst->is_valid(), "used"); do_input(opArrayCopy->_dst); do_temp(opArrayCopy->_dst);871assert(opArrayCopy->_dst_pos->is_valid(), "used"); do_input(opArrayCopy->_dst_pos); do_temp(opArrayCopy->_dst_pos);872assert(opArrayCopy->_length->is_valid(), "used"); do_input(opArrayCopy->_length); do_temp(opArrayCopy->_length);873assert(opArrayCopy->_tmp->is_valid(), "used"); do_temp(opArrayCopy->_tmp);874if (opArrayCopy->_info) do_info(opArrayCopy->_info);875876// the implementation of arraycopy always has a call into the runtime877do_call();878879break;880}881882883// LIR_OpUpdateCRC32884case lir_updatecrc32: {885assert(op->as_OpUpdateCRC32() != NULL, "must be");886LIR_OpUpdateCRC32* opUp = (LIR_OpUpdateCRC32*)op;887888assert(opUp->_crc->is_valid(), "used"); do_input(opUp->_crc); do_temp(opUp->_crc);889assert(opUp->_val->is_valid(), "used"); do_input(opUp->_val); do_temp(opUp->_val);890assert(opUp->_result->is_valid(), "used"); do_output(opUp->_result);891assert(opUp->_info == NULL, "no info for LIR_OpUpdateCRC32");892893break;894}895896897// LIR_OpLock898case lir_lock:899case lir_unlock: {900assert(op->as_OpLock() != NULL, "must be");901LIR_OpLock* opLock = (LIR_OpLock*)op;902903if (opLock->_info) do_info(opLock->_info);904905// TODO: check if these operands really have to be temp906// (or if input is sufficient). This may have influence on the oop map!907assert(opLock->_lock->is_valid(), "used"); do_temp(opLock->_lock);908assert(opLock->_hdr->is_valid(), "used"); do_temp(opLock->_hdr);909assert(opLock->_obj->is_valid(), "used"); do_temp(opLock->_obj);910911if (opLock->_scratch->is_valid()) do_temp(opLock->_scratch);912assert(opLock->_result->is_illegal(), "unused");913914do_stub(opLock->_stub);915916break;917}918919920// LIR_OpDelay921case lir_delay_slot: {922assert(op->as_OpDelay() != NULL, "must be");923LIR_OpDelay* opDelay = (LIR_OpDelay*)op;924925visit(opDelay->delay_op());926break;927}928929// LIR_OpTypeCheck930case lir_instanceof:931case lir_checkcast:932case lir_store_check: {933assert(op->as_OpTypeCheck() != NULL, "must be");934LIR_OpTypeCheck* opTypeCheck = (LIR_OpTypeCheck*)op;935936if (opTypeCheck->_info_for_exception) do_info(opTypeCheck->_info_for_exception);937if (opTypeCheck->_info_for_patch) do_info(opTypeCheck->_info_for_patch);938if (opTypeCheck->_object->is_valid()) do_input(opTypeCheck->_object);939if (op->code() == lir_store_check && opTypeCheck->_object->is_valid()) {940do_temp(opTypeCheck->_object);941}942if (opTypeCheck->_array->is_valid()) do_input(opTypeCheck->_array);943if (opTypeCheck->_tmp1->is_valid()) do_temp(opTypeCheck->_tmp1);944if (opTypeCheck->_tmp2->is_valid()) do_temp(opTypeCheck->_tmp2);945if (opTypeCheck->_tmp3->is_valid()) do_temp(opTypeCheck->_tmp3);946if (opTypeCheck->_result->is_valid()) do_output(opTypeCheck->_result);947do_stub(opTypeCheck->_stub);948break;949}950951// LIR_OpCompareAndSwap952case lir_cas_long:953case lir_cas_obj:954case lir_cas_int: {955assert(op->as_OpCompareAndSwap() != NULL, "must be");956LIR_OpCompareAndSwap* opCompareAndSwap = (LIR_OpCompareAndSwap*)op;957958assert(opCompareAndSwap->_addr->is_valid(), "used");959assert(opCompareAndSwap->_cmp_value->is_valid(), "used");960assert(opCompareAndSwap->_new_value->is_valid(), "used");961if (opCompareAndSwap->_info) do_info(opCompareAndSwap->_info);962do_input(opCompareAndSwap->_addr);963do_temp(opCompareAndSwap->_addr);964do_input(opCompareAndSwap->_cmp_value);965do_temp(opCompareAndSwap->_cmp_value);966do_input(opCompareAndSwap->_new_value);967do_temp(opCompareAndSwap->_new_value);968if (opCompareAndSwap->_tmp1->is_valid()) do_temp(opCompareAndSwap->_tmp1);969if (opCompareAndSwap->_tmp2->is_valid()) do_temp(opCompareAndSwap->_tmp2);970if (opCompareAndSwap->_result->is_valid()) do_output(opCompareAndSwap->_result);971972break;973}974975976// LIR_OpAllocArray;977case lir_alloc_array: {978assert(op->as_OpAllocArray() != NULL, "must be");979LIR_OpAllocArray* opAllocArray = (LIR_OpAllocArray*)op;980981if (opAllocArray->_info) do_info(opAllocArray->_info);982if (opAllocArray->_klass->is_valid()) do_input(opAllocArray->_klass); do_temp(opAllocArray->_klass);983if (opAllocArray->_len->is_valid()) do_input(opAllocArray->_len); do_temp(opAllocArray->_len);984if (opAllocArray->_tmp1->is_valid()) do_temp(opAllocArray->_tmp1);985if (opAllocArray->_tmp2->is_valid()) do_temp(opAllocArray->_tmp2);986if (opAllocArray->_tmp3->is_valid()) do_temp(opAllocArray->_tmp3);987if (opAllocArray->_tmp4->is_valid()) do_temp(opAllocArray->_tmp4);988if (opAllocArray->_result->is_valid()) do_output(opAllocArray->_result);989do_stub(opAllocArray->_stub);990break;991}992993// LIR_OpProfileCall:994case lir_profile_call: {995assert(op->as_OpProfileCall() != NULL, "must be");996LIR_OpProfileCall* opProfileCall = (LIR_OpProfileCall*)op;997998if (opProfileCall->_recv->is_valid()) do_temp(opProfileCall->_recv);999assert(opProfileCall->_mdo->is_valid(), "used"); do_temp(opProfileCall->_mdo);1000assert(opProfileCall->_tmp1->is_valid(), "used"); do_temp(opProfileCall->_tmp1);1001break;1002}10031004// LIR_OpProfileType:1005case lir_profile_type: {1006assert(op->as_OpProfileType() != NULL, "must be");1007LIR_OpProfileType* opProfileType = (LIR_OpProfileType*)op;10081009do_input(opProfileType->_mdp); do_temp(opProfileType->_mdp);1010do_input(opProfileType->_obj);1011do_temp(opProfileType->_tmp);1012break;1013}1014default:1015ShouldNotReachHere();1016}1017}101810191020void LIR_OpVisitState::do_stub(CodeStub* stub) {1021if (stub != NULL) {1022stub->visit(this);1023}1024}10251026XHandlers* LIR_OpVisitState::all_xhandler() {1027XHandlers* result = NULL;10281029int i;1030for (i = 0; i < info_count(); i++) {1031if (info_at(i)->exception_handlers() != NULL) {1032result = info_at(i)->exception_handlers();1033break;1034}1035}10361037#ifdef ASSERT1038for (i = 0; i < info_count(); i++) {1039assert(info_at(i)->exception_handlers() == NULL ||1040info_at(i)->exception_handlers() == result,1041"only one xhandler list allowed per LIR-operation");1042}1043#endif10441045if (result != NULL) {1046return result;1047} else {1048return new XHandlers();1049}10501051return result;1052}105310541055#ifdef ASSERT1056bool LIR_OpVisitState::no_operands(LIR_Op* op) {1057visit(op);10581059return opr_count(inputMode) == 0 &&1060opr_count(outputMode) == 0 &&1061opr_count(tempMode) == 0 &&1062info_count() == 0 &&1063!has_call() &&1064!has_slow_case();1065}1066#endif10671068//---------------------------------------------------106910701071void LIR_OpJavaCall::emit_code(LIR_Assembler* masm) {1072masm->emit_call(this);1073}10741075void LIR_OpRTCall::emit_code(LIR_Assembler* masm) {1076masm->emit_rtcall(this);1077}10781079void LIR_OpLabel::emit_code(LIR_Assembler* masm) {1080masm->emit_opLabel(this);1081}10821083void LIR_OpArrayCopy::emit_code(LIR_Assembler* masm) {1084masm->emit_arraycopy(this);1085masm->append_code_stub(stub());1086}10871088void LIR_OpUpdateCRC32::emit_code(LIR_Assembler* masm) {1089masm->emit_updatecrc32(this);1090}10911092void LIR_Op0::emit_code(LIR_Assembler* masm) {1093masm->emit_op0(this);1094}10951096void LIR_Op1::emit_code(LIR_Assembler* masm) {1097masm->emit_op1(this);1098}10991100void LIR_OpAllocObj::emit_code(LIR_Assembler* masm) {1101masm->emit_alloc_obj(this);1102masm->append_code_stub(stub());1103}11041105void LIR_OpBranch::emit_code(LIR_Assembler* masm) {1106masm->emit_opBranch(this);1107if (stub()) {1108masm->append_code_stub(stub());1109}1110}11111112void LIR_OpConvert::emit_code(LIR_Assembler* masm) {1113masm->emit_opConvert(this);1114if (stub() != NULL) {1115masm->append_code_stub(stub());1116}1117}11181119void LIR_Op2::emit_code(LIR_Assembler* masm) {1120masm->emit_op2(this);1121}11221123void LIR_OpAllocArray::emit_code(LIR_Assembler* masm) {1124masm->emit_alloc_array(this);1125masm->append_code_stub(stub());1126}11271128void LIR_OpTypeCheck::emit_code(LIR_Assembler* masm) {1129masm->emit_opTypeCheck(this);1130if (stub()) {1131masm->append_code_stub(stub());1132}1133}11341135void LIR_OpCompareAndSwap::emit_code(LIR_Assembler* masm) {1136masm->emit_compare_and_swap(this);1137}11381139void LIR_Op3::emit_code(LIR_Assembler* masm) {1140masm->emit_op3(this);1141}11421143void LIR_OpLock::emit_code(LIR_Assembler* masm) {1144masm->emit_lock(this);1145if (stub()) {1146masm->append_code_stub(stub());1147}1148}11491150#ifdef ASSERT1151void LIR_OpAssert::emit_code(LIR_Assembler* masm) {1152masm->emit_assert(this);1153}1154#endif11551156void LIR_OpDelay::emit_code(LIR_Assembler* masm) {1157masm->emit_delay(this);1158}11591160void LIR_OpProfileCall::emit_code(LIR_Assembler* masm) {1161masm->emit_profile_call(this);1162}11631164void LIR_OpProfileType::emit_code(LIR_Assembler* masm) {1165masm->emit_profile_type(this);1166}11671168// LIR_List1169LIR_List::LIR_List(Compilation* compilation, BlockBegin* block)1170: _operations(8)1171, _compilation(compilation)1172#ifndef PRODUCT1173, _block(block)1174#endif1175#ifdef ASSERT1176, _file(NULL)1177, _line(0)1178#endif1179{ }118011811182#ifdef ASSERT1183void LIR_List::set_file_and_line(const char * file, int line) {1184const char * f = strrchr(file, '/');1185if (f == NULL) f = strrchr(file, '\\');1186if (f == NULL) {1187f = file;1188} else {1189f++;1190}1191_file = f;1192_line = line;1193}1194#endif119511961197void LIR_List::append(LIR_InsertionBuffer* buffer) {1198assert(this == buffer->lir_list(), "wrong lir list");1199const int n = _operations.length();12001201if (buffer->number_of_ops() > 0) {1202// increase size of instructions list1203_operations.at_grow(n + buffer->number_of_ops() - 1, NULL);1204// insert ops from buffer into instructions list1205int op_index = buffer->number_of_ops() - 1;1206int ip_index = buffer->number_of_insertion_points() - 1;1207int from_index = n - 1;1208int to_index = _operations.length() - 1;1209for (; ip_index >= 0; ip_index --) {1210int index = buffer->index_at(ip_index);1211// make room after insertion point1212while (index < from_index) {1213_operations.at_put(to_index --, _operations.at(from_index --));1214}1215// insert ops from buffer1216for (int i = buffer->count_at(ip_index); i > 0; i --) {1217_operations.at_put(to_index --, buffer->op_at(op_index --));1218}1219}1220}12211222buffer->finish();1223}122412251226void LIR_List::oop2reg_patch(jobject o, LIR_Opr reg, CodeEmitInfo* info) {1227assert(reg->type() == T_OBJECT, "bad reg");1228append(new LIR_Op1(lir_move, LIR_OprFact::oopConst(o), reg, T_OBJECT, lir_patch_normal, info));1229}12301231void LIR_List::klass2reg_patch(Metadata* o, LIR_Opr reg, CodeEmitInfo* info) {1232assert(reg->type() == T_METADATA, "bad reg");1233append(new LIR_Op1(lir_move, LIR_OprFact::metadataConst(o), reg, T_METADATA, lir_patch_normal, info));1234}12351236void LIR_List::load(LIR_Address* addr, LIR_Opr src, CodeEmitInfo* info, LIR_PatchCode patch_code) {1237append(new LIR_Op1(1238lir_move,1239LIR_OprFact::address(addr),1240src,1241addr->type(),1242patch_code,1243info));1244}124512461247void LIR_List::volatile_load_mem_reg(LIR_Address* address, LIR_Opr dst, CodeEmitInfo* info, LIR_PatchCode patch_code) {1248append(new LIR_Op1(1249lir_move,1250LIR_OprFact::address(address),1251dst,1252address->type(),1253patch_code,1254info, lir_move_volatile));1255}12561257void LIR_List::volatile_load_unsafe_reg(LIR_Opr base, LIR_Opr offset, LIR_Opr dst, BasicType type, CodeEmitInfo* info, LIR_PatchCode patch_code) {1258append(new LIR_Op1(1259lir_move,1260LIR_OprFact::address(new LIR_Address(base, offset, type)),1261dst,1262type,1263patch_code,1264info, lir_move_volatile));1265}126612671268void LIR_List::prefetch(LIR_Address* addr, bool is_store) {1269append(new LIR_Op1(1270is_store ? lir_prefetchw : lir_prefetchr,1271LIR_OprFact::address(addr)));1272}127312741275void LIR_List::store_mem_int(jint v, LIR_Opr base, int offset_in_bytes, BasicType type, CodeEmitInfo* info, LIR_PatchCode patch_code) {1276append(new LIR_Op1(1277lir_move,1278LIR_OprFact::intConst(v),1279LIR_OprFact::address(new LIR_Address(base, offset_in_bytes, type)),1280type,1281patch_code,1282info));1283}128412851286void LIR_List::store_mem_oop(jobject o, LIR_Opr base, int offset_in_bytes, BasicType type, CodeEmitInfo* info, LIR_PatchCode patch_code) {1287append(new LIR_Op1(1288lir_move,1289LIR_OprFact::oopConst(o),1290LIR_OprFact::address(new LIR_Address(base, offset_in_bytes, type)),1291type,1292patch_code,1293info));1294}129512961297void LIR_List::store(LIR_Opr src, LIR_Address* addr, CodeEmitInfo* info, LIR_PatchCode patch_code) {1298append(new LIR_Op1(1299lir_move,1300src,1301LIR_OprFact::address(addr),1302addr->type(),1303patch_code,1304info));1305}130613071308void LIR_List::volatile_store_mem_reg(LIR_Opr src, LIR_Address* addr, CodeEmitInfo* info, LIR_PatchCode patch_code) {1309append(new LIR_Op1(1310lir_move,1311src,1312LIR_OprFact::address(addr),1313addr->type(),1314patch_code,1315info,1316lir_move_volatile));1317}13181319void LIR_List::volatile_store_unsafe_reg(LIR_Opr src, LIR_Opr base, LIR_Opr offset, BasicType type, CodeEmitInfo* info, LIR_PatchCode patch_code) {1320append(new LIR_Op1(1321lir_move,1322src,1323LIR_OprFact::address(new LIR_Address(base, offset, type)),1324type,1325patch_code,1326info, lir_move_volatile));1327}132813291330void LIR_List::idiv(LIR_Opr left, LIR_Opr right, LIR_Opr res, LIR_Opr tmp, CodeEmitInfo* info) {1331append(new LIR_Op3(1332lir_idiv,1333left,1334right,1335tmp,1336res,1337info));1338}133913401341void LIR_List::idiv(LIR_Opr left, int right, LIR_Opr res, LIR_Opr tmp, CodeEmitInfo* info) {1342append(new LIR_Op3(1343lir_idiv,1344left,1345LIR_OprFact::intConst(right),1346tmp,1347res,1348info));1349}135013511352void LIR_List::irem(LIR_Opr left, LIR_Opr right, LIR_Opr res, LIR_Opr tmp, CodeEmitInfo* info) {1353append(new LIR_Op3(1354lir_irem,1355left,1356right,1357tmp,1358res,1359info));1360}136113621363void LIR_List::irem(LIR_Opr left, int right, LIR_Opr res, LIR_Opr tmp, CodeEmitInfo* info) {1364append(new LIR_Op3(1365lir_irem,1366left,1367LIR_OprFact::intConst(right),1368tmp,1369res,1370info));1371}137213731374void LIR_List::cmp_mem_int(LIR_Condition condition, LIR_Opr base, int disp, int c, CodeEmitInfo* info) {1375append(new LIR_Op2(1376lir_cmp,1377condition,1378LIR_OprFact::address(new LIR_Address(base, disp, T_INT)),1379LIR_OprFact::intConst(c),1380info));1381}138213831384void LIR_List::cmp_reg_mem(LIR_Condition condition, LIR_Opr reg, LIR_Address* addr, CodeEmitInfo* info) {1385append(new LIR_Op2(1386lir_cmp,1387condition,1388reg,1389LIR_OprFact::address(addr),1390info));1391}13921393void LIR_List::allocate_object(LIR_Opr dst, LIR_Opr t1, LIR_Opr t2, LIR_Opr t3, LIR_Opr t4,1394int header_size, int object_size, LIR_Opr klass, bool init_check, CodeStub* stub) {1395append(new LIR_OpAllocObj(1396klass,1397dst,1398t1,1399t2,1400t3,1401t4,1402header_size,1403object_size,1404init_check,1405stub));1406}14071408void 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) {1409append(new LIR_OpAllocArray(1410klass,1411len,1412dst,1413t1,1414t2,1415t3,1416t4,1417type,1418stub));1419}14201421void LIR_List::shift_left(LIR_Opr value, LIR_Opr count, LIR_Opr dst, LIR_Opr tmp) {1422append(new LIR_Op2(1423lir_shl,1424value,1425count,1426dst,1427tmp));1428}14291430void LIR_List::shift_right(LIR_Opr value, LIR_Opr count, LIR_Opr dst, LIR_Opr tmp) {1431append(new LIR_Op2(1432lir_shr,1433value,1434count,1435dst,1436tmp));1437}143814391440void LIR_List::unsigned_shift_right(LIR_Opr value, LIR_Opr count, LIR_Opr dst, LIR_Opr tmp) {1441append(new LIR_Op2(1442lir_ushr,1443value,1444count,1445dst,1446tmp));1447}14481449void LIR_List::fcmp2int(LIR_Opr left, LIR_Opr right, LIR_Opr dst, bool is_unordered_less) {1450append(new LIR_Op2(is_unordered_less ? lir_ucmp_fd2i : lir_cmp_fd2i,1451left,1452right,1453dst));1454}14551456void LIR_List::lock_object(LIR_Opr hdr, LIR_Opr obj, LIR_Opr lock, LIR_Opr scratch, CodeStub* stub, CodeEmitInfo* info) {1457append(new LIR_OpLock(1458lir_lock,1459hdr,1460obj,1461lock,1462scratch,1463stub,1464info));1465}14661467void LIR_List::unlock_object(LIR_Opr hdr, LIR_Opr obj, LIR_Opr lock, LIR_Opr scratch, CodeStub* stub) {1468append(new LIR_OpLock(1469lir_unlock,1470hdr,1471obj,1472lock,1473scratch,1474stub,1475NULL));1476}147714781479void check_LIR() {1480// cannot do the proper checking as PRODUCT and other modes return different results1481// guarantee(sizeof(LIR_OprDesc) == wordSize, "may not have a v-table");1482}1483148414851486void LIR_List::checkcast (LIR_Opr result, LIR_Opr object, ciKlass* klass,1487LIR_Opr tmp1, LIR_Opr tmp2, LIR_Opr tmp3, bool fast_check,1488CodeEmitInfo* info_for_exception, CodeEmitInfo* info_for_patch, CodeStub* stub,1489ciMethod* profiled_method, int profiled_bci) {1490LIR_OpTypeCheck* c = new LIR_OpTypeCheck(lir_checkcast, result, object, klass,1491tmp1, tmp2, tmp3, fast_check, info_for_exception, info_for_patch, stub);1492if (profiled_method != NULL) {1493c->set_profiled_method(profiled_method);1494c->set_profiled_bci(profiled_bci);1495c->set_should_profile(true);1496}1497append(c);1498}14991500void 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) {1501LIR_OpTypeCheck* c = new LIR_OpTypeCheck(lir_instanceof, result, object, klass, tmp1, tmp2, tmp3, fast_check, NULL, info_for_patch, NULL);1502if (profiled_method != NULL) {1503c->set_profiled_method(profiled_method);1504c->set_profiled_bci(profiled_bci);1505c->set_should_profile(true);1506}1507append(c);1508}150915101511void LIR_List::store_check(LIR_Opr object, LIR_Opr array, LIR_Opr tmp1, LIR_Opr tmp2, LIR_Opr tmp3,1512CodeEmitInfo* info_for_exception, ciMethod* profiled_method, int profiled_bci) {1513LIR_OpTypeCheck* c = new LIR_OpTypeCheck(lir_store_check, object, array, tmp1, tmp2, tmp3, info_for_exception);1514if (profiled_method != NULL) {1515c->set_profiled_method(profiled_method);1516c->set_profiled_bci(profiled_bci);1517c->set_should_profile(true);1518}1519append(c);1520}15211522void LIR_List::null_check(LIR_Opr opr, CodeEmitInfo* info, bool deoptimize_on_null) {1523if (deoptimize_on_null) {1524// Emit an explicit null check and deoptimize if opr is null1525CodeStub* deopt = new DeoptimizeStub(info);1526cmp(lir_cond_equal, opr, LIR_OprFact::oopConst(NULL));1527branch(lir_cond_equal, T_OBJECT, deopt);1528} else {1529// Emit an implicit null check1530append(new LIR_Op1(lir_null_check, opr, info));1531}1532}15331534void LIR_List::cas_long(LIR_Opr addr, LIR_Opr cmp_value, LIR_Opr new_value,1535LIR_Opr t1, LIR_Opr t2, LIR_Opr result) {1536append(new LIR_OpCompareAndSwap(lir_cas_long, addr, cmp_value, new_value, t1, t2, result));1537}15381539void LIR_List::cas_obj(LIR_Opr addr, LIR_Opr cmp_value, LIR_Opr new_value,1540LIR_Opr t1, LIR_Opr t2, LIR_Opr result) {1541append(new LIR_OpCompareAndSwap(lir_cas_obj, addr, cmp_value, new_value, t1, t2, result));1542}15431544void LIR_List::cas_int(LIR_Opr addr, LIR_Opr cmp_value, LIR_Opr new_value,1545LIR_Opr t1, LIR_Opr t2, LIR_Opr result) {1546append(new LIR_OpCompareAndSwap(lir_cas_int, addr, cmp_value, new_value, t1, t2, result));1547}154815491550#ifdef PRODUCT15511552void print_LIR(BlockList* blocks) {1553}15541555#else1556// LIR_OprDesc1557void LIR_OprDesc::print() const {1558print(tty);1559}15601561void LIR_OprDesc::print(outputStream* out) const {1562if (is_illegal()) {1563return;1564}15651566out->print("[");1567if (is_pointer()) {1568pointer()->print_value_on(out);1569} else if (is_single_stack()) {1570out->print("stack:%d", single_stack_ix());1571} else if (is_double_stack()) {1572out->print("dbl_stack:%d",double_stack_ix());1573} else if (is_virtual()) {1574out->print("R%d", vreg_number());1575} else if (is_single_cpu()) {1576out->print("%s", as_register()->name());1577} else if (is_double_cpu()) {1578out->print("%s", as_register_hi()->name());1579out->print("%s", as_register_lo()->name());1580#if defined(AARCH64)1581} else if (is_single_fpu()) {1582out->print("fpu%d", fpu_regnr());1583} else if (is_double_fpu()) {1584out->print("fpu%d", fpu_regnrLo());1585#elif defined(X86)1586} else if (is_single_xmm()) {1587out->print("%s", as_xmm_float_reg()->name());1588} else if (is_double_xmm()) {1589out->print("%s", as_xmm_double_reg()->name());1590} else if (is_single_fpu()) {1591out->print("fpu%d", fpu_regnr());1592} else if (is_double_fpu()) {1593out->print("fpu%d", fpu_regnrLo());1594#elif defined(ARM)1595} else if (is_single_fpu()) {1596out->print("s%d", fpu_regnr());1597} else if (is_double_fpu()) {1598out->print("d%d", fpu_regnrLo() >> 1);1599#else1600} else if (is_single_fpu()) {1601out->print("%s", as_float_reg()->name());1602} else if (is_double_fpu()) {1603out->print("%s", as_double_reg()->name());1604#endif16051606} else if (is_illegal()) {1607out->print("-");1608} else {1609out->print("Unknown Operand");1610}1611if (!is_illegal()) {1612out->print("|%c", type_char());1613}1614if (is_register() && is_last_use()) {1615out->print("(last_use)");1616}1617out->print("]");1618}161916201621// LIR_Address1622void LIR_Const::print_value_on(outputStream* out) const {1623switch (type()) {1624case T_ADDRESS:out->print("address:%d",as_jint()); break;1625case T_INT: out->print("int:%d", as_jint()); break;1626case T_LONG: out->print("lng:" JLONG_FORMAT, as_jlong()); break;1627case T_FLOAT: out->print("flt:%f", as_jfloat()); break;1628case T_DOUBLE: out->print("dbl:%f", as_jdouble()); break;1629case T_OBJECT: out->print("obj:" INTPTR_FORMAT, p2i(as_jobject())); break;1630case T_METADATA: out->print("metadata:" INTPTR_FORMAT, p2i(as_metadata()));break;1631default: out->print("%3d:0x" UINT64_FORMAT_X, type(), (uint64_t)as_jlong()); break;1632}1633}16341635// LIR_Address1636void LIR_Address::print_value_on(outputStream* out) const {1637out->print("Base:"); _base->print(out);1638if (!_index->is_illegal()) {1639out->print(" Index:"); _index->print(out);1640switch (scale()) {1641case times_1: break;1642case times_2: out->print(" * 2"); break;1643case times_4: out->print(" * 4"); break;1644case times_8: out->print(" * 8"); break;1645}1646}1647out->print(" Disp: " INTX_FORMAT, _disp);1648}16491650// debug output of block header without InstructionPrinter1651// (because phi functions are not necessary for LIR)1652static void print_block(BlockBegin* x) {1653// print block id1654BlockEnd* end = x->end();1655tty->print("B%d ", x->block_id());16561657// print flags1658if (x->is_set(BlockBegin::std_entry_flag)) tty->print("std ");1659if (x->is_set(BlockBegin::osr_entry_flag)) tty->print("osr ");1660if (x->is_set(BlockBegin::exception_entry_flag)) tty->print("ex ");1661if (x->is_set(BlockBegin::subroutine_entry_flag)) tty->print("jsr ");1662if (x->is_set(BlockBegin::backward_branch_target_flag)) tty->print("bb ");1663if (x->is_set(BlockBegin::linear_scan_loop_header_flag)) tty->print("lh ");1664if (x->is_set(BlockBegin::linear_scan_loop_end_flag)) tty->print("le ");16651666// print block bci range1667tty->print("[%d, %d] ", x->bci(), (end == NULL ? -1 : end->printable_bci()));16681669// print predecessors and successors1670if (x->number_of_preds() > 0) {1671tty->print("preds: ");1672for (int i = 0; i < x->number_of_preds(); i ++) {1673tty->print("B%d ", x->pred_at(i)->block_id());1674}1675}16761677if (x->number_of_sux() > 0) {1678tty->print("sux: ");1679for (int i = 0; i < x->number_of_sux(); i ++) {1680tty->print("B%d ", x->sux_at(i)->block_id());1681}1682}16831684// print exception handlers1685if (x->number_of_exception_handlers() > 0) {1686tty->print("xhandler: ");1687for (int i = 0; i < x->number_of_exception_handlers(); i++) {1688tty->print("B%d ", x->exception_handler_at(i)->block_id());1689}1690}16911692tty->cr();1693}16941695void print_LIR(BlockList* blocks) {1696tty->print_cr("LIR:");1697int i;1698for (i = 0; i < blocks->length(); i++) {1699BlockBegin* bb = blocks->at(i);1700print_block(bb);1701tty->print("__id_Instruction___________________________________________"); tty->cr();1702bb->lir()->print_instructions();1703}1704}17051706void LIR_List::print_instructions() {1707for (int i = 0; i < _operations.length(); i++) {1708_operations.at(i)->print(); tty->cr();1709}1710tty->cr();1711}17121713// LIR_Ops printing routines1714// LIR_Op1715void LIR_Op::print_on(outputStream* out) const {1716if (id() != -1 || PrintCFGToFile) {1717out->print("%4d ", id());1718} else {1719out->print(" ");1720}1721out->print("%s ", name());1722print_instr(out);1723if (info() != NULL) out->print(" [bci:%d]", info()->stack()->bci());1724#ifdef ASSERT1725if (Verbose && _file != NULL) {1726out->print(" (%s:%d)", _file, _line);1727}1728#endif1729}17301731const char * LIR_Op::name() const {1732const char* s = NULL;1733switch(code()) {1734// LIR_Op01735case lir_membar: s = "membar"; break;1736case lir_membar_acquire: s = "membar_acquire"; break;1737case lir_membar_release: s = "membar_release"; break;1738case lir_membar_loadload: s = "membar_loadload"; break;1739case lir_membar_storestore: s = "membar_storestore"; break;1740case lir_membar_loadstore: s = "membar_loadstore"; break;1741case lir_membar_storeload: s = "membar_storeload"; break;1742case lir_word_align: s = "word_align"; break;1743case lir_label: s = "label"; break;1744case lir_nop: s = "nop"; break;1745case lir_backwardbranch_target: s = "backbranch"; break;1746case lir_std_entry: s = "std_entry"; break;1747case lir_osr_entry: s = "osr_entry"; break;1748case lir_build_frame: s = "build_frm"; break;1749case lir_fpop_raw: s = "fpop_raw"; break;1750case lir_24bit_FPU: s = "24bit_FPU"; break;1751case lir_reset_FPU: s = "reset_FPU"; break;1752case lir_breakpoint: s = "breakpoint"; break;1753case lir_get_thread: s = "get_thread"; break;1754// LIR_Op11755case lir_fxch: s = "fxch"; break;1756case lir_fld: s = "fld"; break;1757case lir_ffree: s = "ffree"; break;1758case lir_push: s = "push"; break;1759case lir_pop: s = "pop"; break;1760case lir_null_check: s = "null_check"; break;1761case lir_return: s = "return"; break;1762case lir_safepoint: s = "safepoint"; break;1763case lir_neg: s = "neg"; break;1764case lir_leal: s = "leal"; break;1765case lir_branch: s = "branch"; break;1766case lir_cond_float_branch: s = "flt_cond_br"; break;1767case lir_move: s = "move"; break;1768case lir_roundfp: s = "roundfp"; break;1769case lir_rtcall: s = "rtcall"; break;1770case lir_throw: s = "throw"; break;1771case lir_unwind: s = "unwind"; break;1772case lir_convert: s = "convert"; break;1773case lir_alloc_object: s = "alloc_obj"; break;1774case lir_monaddr: s = "mon_addr"; break;1775case lir_pack64: s = "pack64"; break;1776case lir_unpack64: s = "unpack64"; break;1777// LIR_Op21778case lir_cmp: s = "cmp"; break;1779case lir_cmp_l2i: s = "cmp_l2i"; break;1780case lir_ucmp_fd2i: s = "ucomp_fd2i"; break;1781case lir_cmp_fd2i: s = "comp_fd2i"; break;1782case lir_cmove: s = "cmove"; break;1783case lir_add: s = "add"; break;1784case lir_sub: s = "sub"; break;1785case lir_mul: s = "mul"; break;1786case lir_mul_strictfp: s = "mul_strictfp"; break;1787case lir_div: s = "div"; break;1788case lir_div_strictfp: s = "div_strictfp"; break;1789case lir_rem: s = "rem"; break;1790case lir_abs: s = "abs"; break;1791case lir_sqrt: s = "sqrt"; break;1792case lir_sin: s = "sin"; break;1793case lir_cos: s = "cos"; break;1794case lir_tan: s = "tan"; break;1795case lir_log: s = "log"; break;1796case lir_log10: s = "log10"; break;1797case lir_exp: s = "exp"; break;1798case lir_pow: s = "pow"; break;1799case lir_logic_and: s = "logic_and"; break;1800case lir_logic_or: s = "logic_or"; break;1801case lir_logic_xor: s = "logic_xor"; break;1802case lir_shl: s = "shift_left"; break;1803case lir_shr: s = "shift_right"; break;1804case lir_ushr: s = "ushift_right"; break;1805case lir_alloc_array: s = "alloc_array"; break;1806case lir_xadd: s = "xadd"; break;1807case lir_xchg: s = "xchg"; break;1808// LIR_Op31809case lir_idiv: s = "idiv"; break;1810case lir_irem: s = "irem"; break;1811// LIR_OpJavaCall1812case lir_static_call: s = "static"; break;1813case lir_optvirtual_call: s = "optvirtual"; break;1814case lir_icvirtual_call: s = "icvirtual"; break;1815case lir_virtual_call: s = "virtual"; break;1816case lir_dynamic_call: s = "dynamic"; break;1817// LIR_OpArrayCopy1818case lir_arraycopy: s = "arraycopy"; break;1819// LIR_OpUpdateCRC321820case lir_updatecrc32: s = "updatecrc32"; break;1821// LIR_OpLock1822case lir_lock: s = "lock"; break;1823case lir_unlock: s = "unlock"; break;1824// LIR_OpDelay1825case lir_delay_slot: s = "delay"; break;1826// LIR_OpTypeCheck1827case lir_instanceof: s = "instanceof"; break;1828case lir_checkcast: s = "checkcast"; break;1829case lir_store_check: s = "store_check"; break;1830// LIR_OpCompareAndSwap1831case lir_cas_long: s = "cas_long"; break;1832case lir_cas_obj: s = "cas_obj"; break;1833case lir_cas_int: s = "cas_int"; break;1834// LIR_OpProfileCall1835case lir_profile_call: s = "profile_call"; break;1836// LIR_OpProfileType1837case lir_profile_type: s = "profile_type"; break;1838// LIR_OpAssert1839#ifdef ASSERT1840case lir_assert: s = "assert"; break;1841#endif1842case lir_none: ShouldNotReachHere();break;1843default: s = "illegal_op"; break;1844}1845return s;1846}18471848// LIR_OpJavaCall1849void LIR_OpJavaCall::print_instr(outputStream* out) const {1850out->print("call: ");1851out->print("[addr: " INTPTR_FORMAT "]", p2i(address()));1852if (receiver()->is_valid()) {1853out->print(" [recv: "); receiver()->print(out); out->print("]");1854}1855if (result_opr()->is_valid()) {1856out->print(" [result: "); result_opr()->print(out); out->print("]");1857}1858}18591860// LIR_OpLabel1861void LIR_OpLabel::print_instr(outputStream* out) const {1862out->print("[label:" INTPTR_FORMAT "]", p2i(_label));1863}18641865// LIR_OpArrayCopy1866void LIR_OpArrayCopy::print_instr(outputStream* out) const {1867src()->print(out); out->print(" ");1868src_pos()->print(out); out->print(" ");1869dst()->print(out); out->print(" ");1870dst_pos()->print(out); out->print(" ");1871length()->print(out); out->print(" ");1872tmp()->print(out); out->print(" ");1873}18741875// LIR_OpUpdateCRC321876void LIR_OpUpdateCRC32::print_instr(outputStream* out) const {1877crc()->print(out); out->print(" ");1878val()->print(out); out->print(" ");1879result_opr()->print(out); out->print(" ");1880}18811882// LIR_OpCompareAndSwap1883void LIR_OpCompareAndSwap::print_instr(outputStream* out) const {1884addr()->print(out); out->print(" ");1885cmp_value()->print(out); out->print(" ");1886new_value()->print(out); out->print(" ");1887tmp1()->print(out); out->print(" ");1888tmp2()->print(out); out->print(" ");18891890}18911892// LIR_Op01893void LIR_Op0::print_instr(outputStream* out) const {1894result_opr()->print(out);1895}18961897// LIR_Op11898const char * LIR_Op1::name() const {1899if (code() == lir_move) {1900switch (move_kind()) {1901case lir_move_normal:1902return "move";1903case lir_move_unaligned:1904return "unaligned move";1905case lir_move_volatile:1906return "volatile_move";1907case lir_move_wide:1908return "wide_move";1909default:1910ShouldNotReachHere();1911return "illegal_op";1912}1913} else {1914return LIR_Op::name();1915}1916}191719181919void LIR_Op1::print_instr(outputStream* out) const {1920_opr->print(out); out->print(" ");1921result_opr()->print(out); out->print(" ");1922print_patch_code(out, patch_code());1923}192419251926// LIR_Op11927void LIR_OpRTCall::print_instr(outputStream* out) const {1928intx a = (intx)addr();1929out->print("%s", Runtime1::name_for_address(addr()));1930out->print(" ");1931tmp()->print(out);1932}19331934void LIR_Op1::print_patch_code(outputStream* out, LIR_PatchCode code) {1935switch(code) {1936case lir_patch_none: break;1937case lir_patch_low: out->print("[patch_low]"); break;1938case lir_patch_high: out->print("[patch_high]"); break;1939case lir_patch_normal: out->print("[patch_normal]"); break;1940default: ShouldNotReachHere();1941}1942}19431944// LIR_OpBranch1945void LIR_OpBranch::print_instr(outputStream* out) const {1946print_condition(out, cond()); out->print(" ");1947if (block() != NULL) {1948out->print("[B%d] ", block()->block_id());1949} else if (stub() != NULL) {1950out->print("[");1951stub()->print_name(out);1952out->print(": " INTPTR_FORMAT "]", p2i(stub()));1953if (stub()->info() != NULL) out->print(" [bci:%d]", stub()->info()->stack()->bci());1954} else {1955out->print("[label:" INTPTR_FORMAT "] ", p2i(label()));1956}1957if (ublock() != NULL) {1958out->print("unordered: [B%d] ", ublock()->block_id());1959}1960}19611962void LIR_Op::print_condition(outputStream* out, LIR_Condition cond) {1963switch(cond) {1964case lir_cond_equal: out->print("[EQ]"); break;1965case lir_cond_notEqual: out->print("[NE]"); break;1966case lir_cond_less: out->print("[LT]"); break;1967case lir_cond_lessEqual: out->print("[LE]"); break;1968case lir_cond_greaterEqual: out->print("[GE]"); break;1969case lir_cond_greater: out->print("[GT]"); break;1970case lir_cond_belowEqual: out->print("[BE]"); break;1971case lir_cond_aboveEqual: out->print("[AE]"); break;1972case lir_cond_always: out->print("[AL]"); break;1973default: out->print("[%d]",cond); break;1974}1975}19761977// LIR_OpConvert1978void LIR_OpConvert::print_instr(outputStream* out) const {1979print_bytecode(out, bytecode());1980in_opr()->print(out); out->print(" ");1981result_opr()->print(out); out->print(" ");1982#if defined(PPC) || defined(AARCH64)1983if(tmp1()->is_valid()) {1984tmp1()->print(out); out->print(" ");1985tmp2()->print(out); out->print(" ");1986}1987#endif1988}19891990void LIR_OpConvert::print_bytecode(outputStream* out, Bytecodes::Code code) {1991switch(code) {1992case Bytecodes::_d2f: out->print("[d2f] "); break;1993case Bytecodes::_d2i: out->print("[d2i] "); break;1994case Bytecodes::_d2l: out->print("[d2l] "); break;1995case Bytecodes::_f2d: out->print("[f2d] "); break;1996case Bytecodes::_f2i: out->print("[f2i] "); break;1997case Bytecodes::_f2l: out->print("[f2l] "); break;1998case Bytecodes::_i2b: out->print("[i2b] "); break;1999case Bytecodes::_i2c: out->print("[i2c] "); break;2000case Bytecodes::_i2d: out->print("[i2d] "); break;2001case Bytecodes::_i2f: out->print("[i2f] "); break;2002case Bytecodes::_i2l: out->print("[i2l] "); break;2003case Bytecodes::_i2s: out->print("[i2s] "); break;2004case Bytecodes::_l2i: out->print("[l2i] "); break;2005case Bytecodes::_l2f: out->print("[l2f] "); break;2006case Bytecodes::_l2d: out->print("[l2d] "); break;2007default:2008out->print("[?%d]",code);2009break;2010}2011}20122013void LIR_OpAllocObj::print_instr(outputStream* out) const {2014klass()->print(out); out->print(" ");2015obj()->print(out); out->print(" ");2016tmp1()->print(out); out->print(" ");2017tmp2()->print(out); out->print(" ");2018tmp3()->print(out); out->print(" ");2019tmp4()->print(out); out->print(" ");2020out->print("[hdr:%d]", header_size()); out->print(" ");2021out->print("[obj:%d]", object_size()); out->print(" ");2022out->print("[lbl:" INTPTR_FORMAT "]", p2i(stub()->entry()));2023}20242025void LIR_OpRoundFP::print_instr(outputStream* out) const {2026_opr->print(out); out->print(" ");2027tmp()->print(out); out->print(" ");2028result_opr()->print(out); out->print(" ");2029}20302031// LIR_Op22032void LIR_Op2::print_instr(outputStream* out) const {2033if (code() == lir_cmove) {2034print_condition(out, condition()); out->print(" ");2035}2036in_opr1()->print(out); out->print(" ");2037in_opr2()->print(out); out->print(" ");2038if (tmp1_opr()->is_valid()) { tmp1_opr()->print(out); out->print(" "); }2039if (tmp2_opr()->is_valid()) { tmp2_opr()->print(out); out->print(" "); }2040if (tmp3_opr()->is_valid()) { tmp3_opr()->print(out); out->print(" "); }2041if (tmp4_opr()->is_valid()) { tmp4_opr()->print(out); out->print(" "); }2042if (tmp5_opr()->is_valid()) { tmp5_opr()->print(out); out->print(" "); }2043result_opr()->print(out);2044}20452046void LIR_OpAllocArray::print_instr(outputStream* out) const {2047klass()->print(out); out->print(" ");2048len()->print(out); out->print(" ");2049obj()->print(out); out->print(" ");2050tmp1()->print(out); out->print(" ");2051tmp2()->print(out); out->print(" ");2052tmp3()->print(out); out->print(" ");2053tmp4()->print(out); out->print(" ");2054out->print("[type:0x%x]", type()); out->print(" ");2055out->print("[label:" INTPTR_FORMAT "]", p2i(stub()->entry()));2056}205720582059void LIR_OpTypeCheck::print_instr(outputStream* out) const {2060object()->print(out); out->print(" ");2061if (code() == lir_store_check) {2062array()->print(out); out->print(" ");2063}2064if (code() != lir_store_check) {2065klass()->print_name_on(out); out->print(" ");2066if (fast_check()) out->print("fast_check ");2067}2068tmp1()->print(out); out->print(" ");2069tmp2()->print(out); out->print(" ");2070tmp3()->print(out); out->print(" ");2071result_opr()->print(out); out->print(" ");2072if (info_for_exception() != NULL) out->print(" [bci:%d]", info_for_exception()->stack()->bci());2073}207420752076// LIR_Op32077void LIR_Op3::print_instr(outputStream* out) const {2078in_opr1()->print(out); out->print(" ");2079in_opr2()->print(out); out->print(" ");2080in_opr3()->print(out); out->print(" ");2081result_opr()->print(out);2082}208320842085void LIR_OpLock::print_instr(outputStream* out) const {2086hdr_opr()->print(out); out->print(" ");2087obj_opr()->print(out); out->print(" ");2088lock_opr()->print(out); out->print(" ");2089if (_scratch->is_valid()) {2090_scratch->print(out); out->print(" ");2091}2092out->print("[lbl:" INTPTR_FORMAT "]", p2i(stub()->entry()));2093}20942095#ifdef ASSERT2096void LIR_OpAssert::print_instr(outputStream* out) const {2097print_condition(out, condition()); out->print(" ");2098in_opr1()->print(out); out->print(" ");2099in_opr2()->print(out); out->print(", \"");2100out->print("%s", msg()); out->print("\"");2101}2102#endif210321042105void LIR_OpDelay::print_instr(outputStream* out) const {2106_op->print_on(out);2107}210821092110// LIR_OpProfileCall2111void LIR_OpProfileCall::print_instr(outputStream* out) const {2112profiled_method()->name()->print_symbol_on(out);2113out->print(".");2114profiled_method()->holder()->name()->print_symbol_on(out);2115out->print(" @ %d ", profiled_bci());2116mdo()->print(out); out->print(" ");2117recv()->print(out); out->print(" ");2118tmp1()->print(out); out->print(" ");2119}21202121// LIR_OpProfileType2122void LIR_OpProfileType::print_instr(outputStream* out) const {2123out->print("exact = ");2124if (exact_klass() == NULL) {2125out->print("unknown");2126} else {2127exact_klass()->print_name_on(out);2128}2129out->print(" current = "); ciTypeEntries::print_ciklass(out, current_klass());2130out->print(" ");2131mdp()->print(out); out->print(" ");2132obj()->print(out); out->print(" ");2133tmp()->print(out); out->print(" ");2134}21352136#endif // PRODUCT21372138// Implementation of LIR_InsertionBuffer21392140void LIR_InsertionBuffer::append(int index, LIR_Op* op) {2141assert(_index_and_count.length() % 2 == 0, "must have a count for each index");21422143int i = number_of_insertion_points() - 1;2144if (i < 0 || index_at(i) < index) {2145append_new(index, 1);2146} else {2147assert(index_at(i) == index, "can append LIR_Ops in ascending order only");2148assert(count_at(i) > 0, "check");2149set_count_at(i, count_at(i) + 1);2150}2151_ops.push(op);21522153DEBUG_ONLY(verify());2154}21552156#ifdef ASSERT2157void LIR_InsertionBuffer::verify() {2158int sum = 0;2159int prev_idx = -1;21602161for (int i = 0; i < number_of_insertion_points(); i++) {2162assert(prev_idx < index_at(i), "index must be ordered ascending");2163sum += count_at(i);2164}2165assert(sum == number_of_ops(), "wrong total sum");2166}2167#endif216821692170