Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/c1/c1_LIR.hpp
32285 views
/*1* Copyright (c) 2000, 2018, 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#ifndef SHARE_VM_C1_C1_LIR_HPP25#define SHARE_VM_C1_C1_LIR_HPP2627#include "c1/c1_Defs.hpp"28#include "c1/c1_ValueType.hpp"29#include "oops/method.hpp"3031class BlockBegin;32class BlockList;33class LIR_Assembler;34class CodeEmitInfo;35class CodeStub;36class CodeStubList;37class ArrayCopyStub;38class LIR_Op;39class ciType;40class ValueType;41class LIR_OpVisitState;42class FpuStackSim;4344//---------------------------------------------------------------------45// LIR Operands46// LIR_OprDesc47// LIR_OprPtr48// LIR_Const49// LIR_Address50//---------------------------------------------------------------------51class LIR_OprDesc;52class LIR_OprPtr;53class LIR_Const;54class LIR_Address;55class LIR_OprVisitor;565758typedef LIR_OprDesc* LIR_Opr;59typedef int RegNr;6061define_array(LIR_OprArray, LIR_Opr)62define_stack(LIR_OprList, LIR_OprArray)6364define_array(LIR_OprRefArray, LIR_Opr*)65define_stack(LIR_OprRefList, LIR_OprRefArray)6667define_array(CodeEmitInfoArray, CodeEmitInfo*)68define_stack(CodeEmitInfoList, CodeEmitInfoArray)6970define_array(LIR_OpArray, LIR_Op*)71define_stack(LIR_OpList, LIR_OpArray)7273// define LIR_OprPtr early so LIR_OprDesc can refer to it74class LIR_OprPtr: public CompilationResourceObj {75public:76bool is_oop_pointer() const { return (type() == T_OBJECT); }77bool is_float_kind() const { BasicType t = type(); return (t == T_FLOAT) || (t == T_DOUBLE); }7879virtual LIR_Const* as_constant() { return NULL; }80virtual LIR_Address* as_address() { return NULL; }81virtual BasicType type() const = 0;82virtual void print_value_on(outputStream* out) const = 0;83};84858687// LIR constants88class LIR_Const: public LIR_OprPtr {89private:90JavaValue _value;9192void type_check(BasicType t) const { assert(type() == t, "type check"); }93void type_check(BasicType t1, BasicType t2) const { assert(type() == t1 || type() == t2, "type check"); }94void type_check(BasicType t1, BasicType t2, BasicType t3) const { assert(type() == t1 || type() == t2 || type() == t3, "type check"); }9596public:97LIR_Const(jint i, bool is_address=false) { _value.set_type(is_address?T_ADDRESS:T_INT); _value.set_jint(i); }98LIR_Const(jlong l) { _value.set_type(T_LONG); _value.set_jlong(l); }99LIR_Const(jfloat f) { _value.set_type(T_FLOAT); _value.set_jfloat(f); }100LIR_Const(jdouble d) { _value.set_type(T_DOUBLE); _value.set_jdouble(d); }101LIR_Const(jobject o) { _value.set_type(T_OBJECT); _value.set_jobject(o); }102LIR_Const(void* p) {103#ifdef _LP64104assert(sizeof(jlong) >= sizeof(p), "too small");;105_value.set_type(T_LONG); _value.set_jlong((jlong)p);106#else107assert(sizeof(jint) >= sizeof(p), "too small");;108_value.set_type(T_INT); _value.set_jint((jint)p);109#endif110}111LIR_Const(Metadata* m) {112_value.set_type(T_METADATA);113#ifdef _LP64114_value.set_jlong((jlong)m);115#else116_value.set_jint((jint)m);117#endif // _LP64118}119120virtual BasicType type() const { return _value.get_type(); }121virtual LIR_Const* as_constant() { return this; }122123jint as_jint() const { type_check(T_INT, T_ADDRESS); return _value.get_jint(); }124jlong as_jlong() const { type_check(T_LONG ); return _value.get_jlong(); }125jfloat as_jfloat() const { type_check(T_FLOAT ); return _value.get_jfloat(); }126jdouble as_jdouble() const { type_check(T_DOUBLE); return _value.get_jdouble(); }127jobject as_jobject() const { type_check(T_OBJECT); return _value.get_jobject(); }128jint as_jint_lo() const { type_check(T_LONG ); return low(_value.get_jlong()); }129jint as_jint_hi() const { type_check(T_LONG ); return high(_value.get_jlong()); }130131#ifdef _LP64132address as_pointer() const { type_check(T_LONG ); return (address)_value.get_jlong(); }133Metadata* as_metadata() const { type_check(T_METADATA); return (Metadata*)_value.get_jlong(); }134#else135address as_pointer() const { type_check(T_INT ); return (address)_value.get_jint(); }136Metadata* as_metadata() const { type_check(T_METADATA); return (Metadata*)_value.get_jint(); }137#endif138139140jint as_jint_bits() const { type_check(T_FLOAT, T_INT, T_ADDRESS); return _value.get_jint(); }141jint as_jint_lo_bits() const {142if (type() == T_DOUBLE) {143return low(jlong_cast(_value.get_jdouble()));144} else {145return as_jint_lo();146}147}148jint as_jint_hi_bits() const {149if (type() == T_DOUBLE) {150return high(jlong_cast(_value.get_jdouble()));151} else {152return as_jint_hi();153}154}155jlong as_jlong_bits() const {156if (type() == T_DOUBLE) {157return jlong_cast(_value.get_jdouble());158} else {159return as_jlong();160}161}162163virtual void print_value_on(outputStream* out) const PRODUCT_RETURN;164165166bool is_zero_float() {167jfloat f = as_jfloat();168jfloat ok = 0.0f;169return jint_cast(f) == jint_cast(ok);170}171172bool is_one_float() {173jfloat f = as_jfloat();174return !g_isnan(f) && g_isfinite(f) && f == 1.0;175}176177bool is_zero_double() {178jdouble d = as_jdouble();179jdouble ok = 0.0;180return jlong_cast(d) == jlong_cast(ok);181}182183bool is_one_double() {184jdouble d = as_jdouble();185return !g_isnan(d) && g_isfinite(d) && d == 1.0;186}187};188189190//---------------------LIR Operand descriptor------------------------------------191//192// The class LIR_OprDesc represents a LIR instruction operand;193// it can be a register (ALU/FPU), stack location or a constant;194// Constants and addresses are represented as resource area allocated195// structures (see above).196// Registers and stack locations are inlined into the this pointer197// (see value function).198199class LIR_OprDesc: public CompilationResourceObj {200public:201// value structure:202// data opr-type opr-kind203// +--------------+-------+-------+204// [max...........|7 6 5 4|3 2 1 0]205// ^206// is_pointer bit207//208// lowest bit cleared, means it is a structure pointer209// we need 4 bits to represent types210211private:212friend class LIR_OprFact;213214// Conversion215intptr_t value() const { return (intptr_t) this; }216217bool check_value_mask(intptr_t mask, intptr_t masked_value) const {218return (value() & mask) == masked_value;219}220221enum OprKind {222pointer_value = 0223, stack_value = 1224, cpu_register = 3225, fpu_register = 5226, illegal_value = 7227};228229enum OprBits {230pointer_bits = 1231, kind_bits = 3232, type_bits = 4233, size_bits = 2234, destroys_bits = 1235, virtual_bits = 1236, is_xmm_bits = 1237, last_use_bits = 1238, is_fpu_stack_offset_bits = 1 // used in assertion checking on x86 for FPU stack slot allocation239, non_data_bits = kind_bits + type_bits + size_bits + destroys_bits + last_use_bits +240is_fpu_stack_offset_bits + virtual_bits + is_xmm_bits241, data_bits = BitsPerInt - non_data_bits242, reg_bits = data_bits / 2 // for two registers in one value encoding243};244245enum OprShift {246kind_shift = 0247, type_shift = kind_shift + kind_bits248, size_shift = type_shift + type_bits249, destroys_shift = size_shift + size_bits250, last_use_shift = destroys_shift + destroys_bits251, is_fpu_stack_offset_shift = last_use_shift + last_use_bits252, virtual_shift = is_fpu_stack_offset_shift + is_fpu_stack_offset_bits253, is_xmm_shift = virtual_shift + virtual_bits254, data_shift = is_xmm_shift + is_xmm_bits255, reg1_shift = data_shift256, reg2_shift = data_shift + reg_bits257258};259260enum OprSize {261single_size = 0 << size_shift262, double_size = 1 << size_shift263};264265enum OprMask {266kind_mask = right_n_bits(kind_bits)267, type_mask = right_n_bits(type_bits) << type_shift268, size_mask = right_n_bits(size_bits) << size_shift269, last_use_mask = right_n_bits(last_use_bits) << last_use_shift270, is_fpu_stack_offset_mask = right_n_bits(is_fpu_stack_offset_bits) << is_fpu_stack_offset_shift271, virtual_mask = right_n_bits(virtual_bits) << virtual_shift272, is_xmm_mask = right_n_bits(is_xmm_bits) << is_xmm_shift273, pointer_mask = right_n_bits(pointer_bits)274, lower_reg_mask = right_n_bits(reg_bits)275, no_type_mask = (int)(~(type_mask | last_use_mask | is_fpu_stack_offset_mask))276};277278uintptr_t data() const { return value() >> data_shift; }279int lo_reg_half() const { return data() & lower_reg_mask; }280int hi_reg_half() const { return (data() >> reg_bits) & lower_reg_mask; }281OprKind kind_field() const { return (OprKind)(value() & kind_mask); }282OprSize size_field() const { return (OprSize)(value() & size_mask); }283284static char type_char(BasicType t);285286public:287enum {288vreg_base = ConcreteRegisterImpl::number_of_registers,289vreg_max = (1 << data_bits) - 1290};291292static inline LIR_Opr illegalOpr();293294enum OprType {295unknown_type = 0 << type_shift // means: not set (catch uninitialized types)296, int_type = 1 << type_shift297, long_type = 2 << type_shift298, object_type = 3 << type_shift299, address_type = 4 << type_shift300, float_type = 5 << type_shift301, double_type = 6 << type_shift302, metadata_type = 7 << type_shift303};304friend OprType as_OprType(BasicType t);305friend BasicType as_BasicType(OprType t);306307OprType type_field_valid() const { assert(is_register() || is_stack(), "should not be called otherwise"); return (OprType)(value() & type_mask); }308OprType type_field() const { return is_illegal() ? unknown_type : (OprType)(value() & type_mask); }309310static OprSize size_for(BasicType t) {311switch (t) {312case T_LONG:313case T_DOUBLE:314return double_size;315break;316317case T_FLOAT:318case T_BOOLEAN:319case T_CHAR:320case T_BYTE:321case T_SHORT:322case T_INT:323case T_ADDRESS:324case T_OBJECT:325case T_ARRAY:326case T_METADATA:327return single_size;328break;329330default:331ShouldNotReachHere();332return single_size;333}334}335336337void validate_type() const PRODUCT_RETURN;338339BasicType type() const {340if (is_pointer()) {341return pointer()->type();342}343return as_BasicType(type_field());344}345346347ValueType* value_type() const { return as_ValueType(type()); }348349char type_char() const { return type_char((is_pointer()) ? pointer()->type() : type()); }350351bool is_equal(LIR_Opr opr) const { return this == opr; }352// checks whether types are same353bool is_same_type(LIR_Opr opr) const {354assert(type_field() != unknown_type &&355opr->type_field() != unknown_type, "shouldn't see unknown_type");356return type_field() == opr->type_field();357}358bool is_same_register(LIR_Opr opr) {359return (is_register() && opr->is_register() &&360kind_field() == opr->kind_field() &&361(value() & no_type_mask) == (opr->value() & no_type_mask));362}363364bool is_pointer() const { return check_value_mask(pointer_mask, pointer_value); }365bool is_illegal() const { return kind_field() == illegal_value; }366bool is_valid() const { return kind_field() != illegal_value; }367368bool is_register() const { return is_cpu_register() || is_fpu_register(); }369bool is_virtual() const { return is_virtual_cpu() || is_virtual_fpu(); }370371bool is_constant() const { return is_pointer() && pointer()->as_constant() != NULL; }372bool is_address() const { return is_pointer() && pointer()->as_address() != NULL; }373374bool is_float_kind() const { return is_pointer() ? pointer()->is_float_kind() : (kind_field() == fpu_register); }375bool is_oop() const;376377// semantic for fpu- and xmm-registers:378// * is_float and is_double return true for xmm_registers379// (so is_single_fpu and is_single_xmm are true)380// * So you must always check for is_???_xmm prior to is_???_fpu to381// distinguish between fpu- and xmm-registers382383bool is_stack() const { validate_type(); return check_value_mask(kind_mask, stack_value); }384bool is_single_stack() const { validate_type(); return check_value_mask(kind_mask | size_mask, stack_value | single_size); }385bool is_double_stack() const { validate_type(); return check_value_mask(kind_mask | size_mask, stack_value | double_size); }386387bool is_cpu_register() const { validate_type(); return check_value_mask(kind_mask, cpu_register); }388bool is_virtual_cpu() const { validate_type(); return check_value_mask(kind_mask | virtual_mask, cpu_register | virtual_mask); }389bool is_fixed_cpu() const { validate_type(); return check_value_mask(kind_mask | virtual_mask, cpu_register); }390bool is_single_cpu() const { validate_type(); return check_value_mask(kind_mask | size_mask, cpu_register | single_size); }391bool is_double_cpu() const { validate_type(); return check_value_mask(kind_mask | size_mask, cpu_register | double_size); }392393bool is_fpu_register() const { validate_type(); return check_value_mask(kind_mask, fpu_register); }394bool is_virtual_fpu() const { validate_type(); return check_value_mask(kind_mask | virtual_mask, fpu_register | virtual_mask); }395bool is_fixed_fpu() const { validate_type(); return check_value_mask(kind_mask | virtual_mask, fpu_register); }396bool is_single_fpu() const { validate_type(); return check_value_mask(kind_mask | size_mask, fpu_register | single_size); }397bool is_double_fpu() const { validate_type(); return check_value_mask(kind_mask | size_mask, fpu_register | double_size); }398399bool is_xmm_register() const { validate_type(); return check_value_mask(kind_mask | is_xmm_mask, fpu_register | is_xmm_mask); }400bool is_single_xmm() const { validate_type(); return check_value_mask(kind_mask | size_mask | is_xmm_mask, fpu_register | single_size | is_xmm_mask); }401bool is_double_xmm() const { validate_type(); return check_value_mask(kind_mask | size_mask | is_xmm_mask, fpu_register | double_size | is_xmm_mask); }402403// fast accessor functions for special bits that do not work for pointers404// (in this functions, the check for is_pointer() is omitted)405bool is_single_word() const { assert(is_register() || is_stack(), "type check"); return check_value_mask(size_mask, single_size); }406bool is_double_word() const { assert(is_register() || is_stack(), "type check"); return check_value_mask(size_mask, double_size); }407bool is_virtual_register() const { assert(is_register(), "type check"); return check_value_mask(virtual_mask, virtual_mask); }408bool is_oop_register() const { assert(is_register() || is_stack(), "type check"); return type_field_valid() == object_type; }409BasicType type_register() const { assert(is_register() || is_stack(), "type check"); return as_BasicType(type_field_valid()); }410411bool is_last_use() const { assert(is_register(), "only works for registers"); return (value() & last_use_mask) != 0; }412bool is_fpu_stack_offset() const { assert(is_register(), "only works for registers"); return (value() & is_fpu_stack_offset_mask) != 0; }413LIR_Opr make_last_use() { assert(is_register(), "only works for registers"); return (LIR_Opr)(value() | last_use_mask); }414LIR_Opr make_fpu_stack_offset() { assert(is_register(), "only works for registers"); return (LIR_Opr)(value() | is_fpu_stack_offset_mask); }415416417int single_stack_ix() const { assert(is_single_stack() && !is_virtual(), "type check"); return (int)data(); }418int double_stack_ix() const { assert(is_double_stack() && !is_virtual(), "type check"); return (int)data(); }419RegNr cpu_regnr() const { assert(is_single_cpu() && !is_virtual(), "type check"); return (RegNr)data(); }420RegNr cpu_regnrLo() const { assert(is_double_cpu() && !is_virtual(), "type check"); return (RegNr)lo_reg_half(); }421RegNr cpu_regnrHi() const { assert(is_double_cpu() && !is_virtual(), "type check"); return (RegNr)hi_reg_half(); }422RegNr fpu_regnr() const { assert(is_single_fpu() && !is_virtual(), "type check"); return (RegNr)data(); }423RegNr fpu_regnrLo() const { assert(is_double_fpu() && !is_virtual(), "type check"); return (RegNr)lo_reg_half(); }424RegNr fpu_regnrHi() const { assert(is_double_fpu() && !is_virtual(), "type check"); return (RegNr)hi_reg_half(); }425RegNr xmm_regnr() const { assert(is_single_xmm() && !is_virtual(), "type check"); return (RegNr)data(); }426RegNr xmm_regnrLo() const { assert(is_double_xmm() && !is_virtual(), "type check"); return (RegNr)lo_reg_half(); }427RegNr xmm_regnrHi() const { assert(is_double_xmm() && !is_virtual(), "type check"); return (RegNr)hi_reg_half(); }428int vreg_number() const { assert(is_virtual(), "type check"); return (RegNr)data(); }429430LIR_OprPtr* pointer() const { assert(is_pointer(), "type check"); return (LIR_OprPtr*)this; }431LIR_Const* as_constant_ptr() const { return pointer()->as_constant(); }432LIR_Address* as_address_ptr() const { return pointer()->as_address(); }433434Register as_register() const;435Register as_register_lo() const;436Register as_register_hi() const;437438Register as_pointer_register() {439#ifdef _LP64440if (is_double_cpu()) {441assert(as_register_lo() == as_register_hi(), "should be a single register");442return as_register_lo();443}444#endif445return as_register();446}447448#if defined(X86)449XMMRegister as_xmm_float_reg() const;450XMMRegister as_xmm_double_reg() const;451// for compatibility with RInfo452int fpu () const { return lo_reg_half(); }453#endif454#if defined(SPARC) || defined(ARM) || defined(PPC) || defined(AARCH64)455FloatRegister as_float_reg () const;456FloatRegister as_double_reg () const;457#endif458459jint as_jint() const { return as_constant_ptr()->as_jint(); }460jlong as_jlong() const { return as_constant_ptr()->as_jlong(); }461jfloat as_jfloat() const { return as_constant_ptr()->as_jfloat(); }462jdouble as_jdouble() const { return as_constant_ptr()->as_jdouble(); }463jobject as_jobject() const { return as_constant_ptr()->as_jobject(); }464465void print() const PRODUCT_RETURN;466void print(outputStream* out) const PRODUCT_RETURN;467};468469470inline LIR_OprDesc::OprType as_OprType(BasicType type) {471switch (type) {472case T_INT: return LIR_OprDesc::int_type;473case T_LONG: return LIR_OprDesc::long_type;474case T_FLOAT: return LIR_OprDesc::float_type;475case T_DOUBLE: return LIR_OprDesc::double_type;476case T_OBJECT:477case T_ARRAY: return LIR_OprDesc::object_type;478case T_ADDRESS: return LIR_OprDesc::address_type;479case T_METADATA: return LIR_OprDesc::metadata_type;480case T_ILLEGAL: // fall through481default: ShouldNotReachHere(); return LIR_OprDesc::unknown_type;482}483}484485inline BasicType as_BasicType(LIR_OprDesc::OprType t) {486switch (t) {487case LIR_OprDesc::int_type: return T_INT;488case LIR_OprDesc::long_type: return T_LONG;489case LIR_OprDesc::float_type: return T_FLOAT;490case LIR_OprDesc::double_type: return T_DOUBLE;491case LIR_OprDesc::object_type: return T_OBJECT;492case LIR_OprDesc::address_type: return T_ADDRESS;493case LIR_OprDesc::metadata_type:return T_METADATA;494case LIR_OprDesc::unknown_type: // fall through495default: ShouldNotReachHere(); return T_ILLEGAL;496}497}498499500// LIR_Address501class LIR_Address: public LIR_OprPtr {502friend class LIR_OpVisitState;503504public:505// NOTE: currently these must be the log2 of the scale factor (and506// must also be equivalent to the ScaleFactor enum in507// assembler_i486.hpp)508enum Scale {509times_1 = 0,510times_2 = 1,511times_4 = 2,512times_8 = 3513};514515private:516LIR_Opr _base;517LIR_Opr _index;518Scale _scale;519intx _disp;520BasicType _type;521522public:523LIR_Address(LIR_Opr base, LIR_Opr index, BasicType type):524_base(base)525, _index(index)526, _scale(times_1)527, _type(type)528, _disp(0) { verify(); }529530LIR_Address(LIR_Opr base, intx disp, BasicType type):531_base(base)532, _index(LIR_OprDesc::illegalOpr())533, _scale(times_1)534, _type(type)535, _disp(disp) { verify(); }536537LIR_Address(LIR_Opr base, BasicType type):538_base(base)539, _index(LIR_OprDesc::illegalOpr())540, _scale(times_1)541, _type(type)542, _disp(0) { verify(); }543544#if defined(X86) || defined(ARM) || defined(AARCH64)545LIR_Address(LIR_Opr base, LIR_Opr index, Scale scale, intx disp, BasicType type):546_base(base)547, _index(index)548, _scale(scale)549, _type(type)550, _disp(disp) { verify(); }551#endif // X86 || ARM552553LIR_Opr base() const { return _base; }554LIR_Opr index() const { return _index; }555Scale scale() const { return _scale; }556intx disp() const { return _disp; }557558bool equals(LIR_Address* other) const { return base() == other->base() && index() == other->index() && disp() == other->disp() && scale() == other->scale(); }559560virtual LIR_Address* as_address() { return this; }561virtual BasicType type() const { return _type; }562virtual void print_value_on(outputStream* out) const PRODUCT_RETURN;563564void verify0() const PRODUCT_RETURN;565#if defined(LIR_ADDRESS_PD_VERIFY) && !defined(PRODUCT)566void pd_verify() const;567void verify() const { pd_verify(); }568#else569void verify() const { verify0(); }570#endif571572static Scale scale(BasicType type);573};574575576// operand factory577class LIR_OprFact: public AllStatic {578public:579580static LIR_Opr illegalOpr;581582static LIR_Opr single_cpu(int reg) {583return (LIR_Opr)(intptr_t)((reg << LIR_OprDesc::reg1_shift) |584LIR_OprDesc::int_type |585LIR_OprDesc::cpu_register |586LIR_OprDesc::single_size);587}588static LIR_Opr single_cpu_oop(int reg) {589return (LIR_Opr)(intptr_t)((reg << LIR_OprDesc::reg1_shift) |590LIR_OprDesc::object_type |591LIR_OprDesc::cpu_register |592LIR_OprDesc::single_size);593}594static LIR_Opr single_cpu_address(int reg) {595return (LIR_Opr)(intptr_t)((reg << LIR_OprDesc::reg1_shift) |596LIR_OprDesc::address_type |597LIR_OprDesc::cpu_register |598LIR_OprDesc::single_size);599}600static LIR_Opr single_cpu_metadata(int reg) {601return (LIR_Opr)(intptr_t)((reg << LIR_OprDesc::reg1_shift) |602LIR_OprDesc::metadata_type |603LIR_OprDesc::cpu_register |604LIR_OprDesc::single_size);605}606static LIR_Opr double_cpu(int reg1, int reg2) {607LP64_ONLY(assert(reg1 == reg2, "must be identical"));608return (LIR_Opr)(intptr_t)((reg1 << LIR_OprDesc::reg1_shift) |609(reg2 << LIR_OprDesc::reg2_shift) |610LIR_OprDesc::long_type |611LIR_OprDesc::cpu_register |612LIR_OprDesc::double_size);613}614615static LIR_Opr single_fpu(int reg) { return (LIR_Opr)(intptr_t)((reg << LIR_OprDesc::reg1_shift) |616LIR_OprDesc::float_type |617LIR_OprDesc::fpu_register |618LIR_OprDesc::single_size); }619#if defined(C1_LIR_MD_HPP)620# include C1_LIR_MD_HPP621#elif defined(SPARC) || defined(AARCH32)622static LIR_Opr double_fpu(int reg1, int reg2) { return (LIR_Opr)(intptr_t)((reg1 << LIR_OprDesc::reg1_shift) |623(reg2 << LIR_OprDesc::reg2_shift) |624LIR_OprDesc::double_type |625LIR_OprDesc::fpu_register |626LIR_OprDesc::double_size); }627#elif defined(X86) || defined(AARCH64)628static LIR_Opr double_fpu(int reg) { return (LIR_Opr)(intptr_t)((reg << LIR_OprDesc::reg1_shift) |629(reg << LIR_OprDesc::reg2_shift) |630LIR_OprDesc::double_type |631LIR_OprDesc::fpu_register |632LIR_OprDesc::double_size); }633634static LIR_Opr single_xmm(int reg) { return (LIR_Opr)(intptr_t)((reg << LIR_OprDesc::reg1_shift) |635LIR_OprDesc::float_type |636LIR_OprDesc::fpu_register |637LIR_OprDesc::single_size |638LIR_OprDesc::is_xmm_mask); }639static LIR_Opr double_xmm(int reg) { return (LIR_Opr)(intptr_t)((reg << LIR_OprDesc::reg1_shift) |640(reg << LIR_OprDesc::reg2_shift) |641LIR_OprDesc::double_type |642LIR_OprDesc::fpu_register |643LIR_OprDesc::double_size |644LIR_OprDesc::is_xmm_mask); }645#elif defined(PPC)646static LIR_Opr double_fpu(int reg) { return (LIR_Opr)(intptr_t)((reg << LIR_OprDesc::reg1_shift) |647(reg << LIR_OprDesc::reg2_shift) |648LIR_OprDesc::double_type |649LIR_OprDesc::fpu_register |650LIR_OprDesc::double_size); }651static LIR_Opr single_softfp(int reg) { return (LIR_Opr)((reg << LIR_OprDesc::reg1_shift) |652LIR_OprDesc::float_type |653LIR_OprDesc::cpu_register |654LIR_OprDesc::single_size); }655static LIR_Opr double_softfp(int reg1, int reg2) { return (LIR_Opr)((reg2 << LIR_OprDesc::reg1_shift) |656(reg1 << LIR_OprDesc::reg2_shift) |657LIR_OprDesc::double_type |658LIR_OprDesc::cpu_register |659LIR_OprDesc::double_size); }660#endif // PPC661662static LIR_Opr virtual_register(int index, BasicType type) {663LIR_Opr res;664switch (type) {665case T_OBJECT: // fall through666case T_ARRAY:667res = (LIR_Opr)(intptr_t)((index << LIR_OprDesc::data_shift) |668LIR_OprDesc::object_type |669LIR_OprDesc::cpu_register |670LIR_OprDesc::single_size |671LIR_OprDesc::virtual_mask);672break;673674case T_METADATA:675res = (LIR_Opr)(intptr_t)((index << LIR_OprDesc::data_shift) |676LIR_OprDesc::metadata_type|677LIR_OprDesc::cpu_register |678LIR_OprDesc::single_size |679LIR_OprDesc::virtual_mask);680break;681682case T_INT:683res = (LIR_Opr)(intptr_t)((index << LIR_OprDesc::data_shift) |684LIR_OprDesc::int_type |685LIR_OprDesc::cpu_register |686LIR_OprDesc::single_size |687LIR_OprDesc::virtual_mask);688break;689690case T_ADDRESS:691res = (LIR_Opr)(intptr_t)((index << LIR_OprDesc::data_shift) |692LIR_OprDesc::address_type |693LIR_OprDesc::cpu_register |694LIR_OprDesc::single_size |695LIR_OprDesc::virtual_mask);696break;697698case T_LONG:699res = (LIR_Opr)(intptr_t)((index << LIR_OprDesc::data_shift) |700LIR_OprDesc::long_type |701LIR_OprDesc::cpu_register |702LIR_OprDesc::double_size |703LIR_OprDesc::virtual_mask);704break;705706#ifdef __SOFTFP__707case T_FLOAT:708#ifdef AARCH32709if (hasFPU()) {710res = (LIR_Opr)(intptr_t)((index << LIR_OprDesc::data_shift) |711LIR_OprDesc::float_type |712LIR_OprDesc::fpu_register |713LIR_OprDesc::single_size |714LIR_OprDesc::virtual_mask);715} else716#endif // AARCH32717{718res = (LIR_Opr)(intptr_t)((index << LIR_OprDesc::data_shift) |719LIR_OprDesc::float_type |720LIR_OprDesc::cpu_register |721LIR_OprDesc::single_size |722LIR_OprDesc::virtual_mask);723}724break;725case T_DOUBLE:726#ifdef AARCH32727if(hasFPU()) {728res = (LIR_Opr)(intptr_t)((index << LIR_OprDesc::data_shift) |729LIR_OprDesc::double_type |730LIR_OprDesc::fpu_register |731LIR_OprDesc::double_size |732LIR_OprDesc::virtual_mask);733} else734#endif735{736res = (LIR_Opr)(intptr_t)((index << LIR_OprDesc::data_shift) |737LIR_OprDesc::double_type |738LIR_OprDesc::cpu_register |739LIR_OprDesc::double_size |740LIR_OprDesc::virtual_mask);741}742break;743#else // __SOFTFP__744case T_FLOAT:745res = (LIR_Opr)(intptr_t)((index << LIR_OprDesc::data_shift) |746LIR_OprDesc::float_type |747LIR_OprDesc::fpu_register |748LIR_OprDesc::single_size |749LIR_OprDesc::virtual_mask);750break;751752case753T_DOUBLE: res = (LIR_Opr)(intptr_t)((index << LIR_OprDesc::data_shift) |754LIR_OprDesc::double_type |755LIR_OprDesc::fpu_register |756LIR_OprDesc::double_size |757LIR_OprDesc::virtual_mask);758break;759#endif // __SOFTFP__760default: ShouldNotReachHere(); res = illegalOpr;761}762763#ifdef ASSERT764res->validate_type();765assert(res->vreg_number() == index, "conversion check");766assert(index >= LIR_OprDesc::vreg_base, "must start at vreg_base");767assert(index <= (max_jint >> LIR_OprDesc::data_shift), "index is too big");768769// old-style calculation; check if old and new method are equal770LIR_OprDesc::OprType t = as_OprType(type);771#ifdef __SOFTFP__772LIR_Opr old_res = (LIR_Opr)(intptr_t)((index << LIR_OprDesc::data_shift) |773t |774LIR_OprDesc::cpu_register |775LIR_OprDesc::size_for(type) | LIR_OprDesc::virtual_mask);776#else // __SOFTFP__777LIR_Opr old_res = (LIR_Opr)(intptr_t)((index << LIR_OprDesc::data_shift) | t |778((type == T_FLOAT || type == T_DOUBLE) ? LIR_OprDesc::fpu_register : LIR_OprDesc::cpu_register) |779LIR_OprDesc::size_for(type) | LIR_OprDesc::virtual_mask);780assert(res == old_res, "old and new method not equal");781#endif // __SOFTFP__782#endif // ASSERT783784return res;785}786787// 'index' is computed by FrameMap::local_stack_pos(index); do not use other parameters as788// the index is platform independent; a double stack useing indeces 2 and 3 has always789// index 2.790static LIR_Opr stack(int index, BasicType type) {791LIR_Opr res;792switch (type) {793case T_OBJECT: // fall through794case T_ARRAY:795res = (LIR_Opr)(intptr_t)((index << LIR_OprDesc::data_shift) |796LIR_OprDesc::object_type |797LIR_OprDesc::stack_value |798LIR_OprDesc::single_size);799break;800801case T_METADATA:802res = (LIR_Opr)(intptr_t)((index << LIR_OprDesc::data_shift) |803LIR_OprDesc::metadata_type |804LIR_OprDesc::stack_value |805LIR_OprDesc::single_size);806break;807case T_INT:808res = (LIR_Opr)(intptr_t)((index << LIR_OprDesc::data_shift) |809LIR_OprDesc::int_type |810LIR_OprDesc::stack_value |811LIR_OprDesc::single_size);812break;813814case T_ADDRESS:815res = (LIR_Opr)(intptr_t)((index << LIR_OprDesc::data_shift) |816LIR_OprDesc::address_type |817LIR_OprDesc::stack_value |818LIR_OprDesc::single_size);819break;820821case T_LONG:822res = (LIR_Opr)(intptr_t)((index << LIR_OprDesc::data_shift) |823LIR_OprDesc::long_type |824LIR_OprDesc::stack_value |825LIR_OprDesc::double_size);826break;827828case T_FLOAT:829res = (LIR_Opr)(intptr_t)((index << LIR_OprDesc::data_shift) |830LIR_OprDesc::float_type |831LIR_OprDesc::stack_value |832LIR_OprDesc::single_size);833break;834case T_DOUBLE:835res = (LIR_Opr)(intptr_t)((index << LIR_OprDesc::data_shift) |836LIR_OprDesc::double_type |837LIR_OprDesc::stack_value |838LIR_OprDesc::double_size);839break;840841default: ShouldNotReachHere(); res = illegalOpr;842}843844#ifdef ASSERT845assert(index >= 0, "index must be positive");846assert(index <= (max_jint >> LIR_OprDesc::data_shift), "index is too big");847848LIR_Opr old_res = (LIR_Opr)(intptr_t)((index << LIR_OprDesc::data_shift) |849LIR_OprDesc::stack_value |850as_OprType(type) |851LIR_OprDesc::size_for(type));852assert(res == old_res, "old and new method not equal");853#endif854855return res;856}857858static LIR_Opr intConst(jint i) { return (LIR_Opr)(new LIR_Const(i)); }859static LIR_Opr longConst(jlong l) { return (LIR_Opr)(new LIR_Const(l)); }860static LIR_Opr floatConst(jfloat f) { return (LIR_Opr)(new LIR_Const(f)); }861static LIR_Opr doubleConst(jdouble d) { return (LIR_Opr)(new LIR_Const(d)); }862static LIR_Opr oopConst(jobject o) { return (LIR_Opr)(new LIR_Const(o)); }863static LIR_Opr address(LIR_Address* a) { return (LIR_Opr)a; }864static LIR_Opr intptrConst(void* p) { return (LIR_Opr)(new LIR_Const(p)); }865static LIR_Opr intptrConst(intptr_t v) { return (LIR_Opr)(new LIR_Const((void*)v)); }866static LIR_Opr illegal() { return (LIR_Opr)-1; }867static LIR_Opr addressConst(jint i) { return (LIR_Opr)(new LIR_Const(i, true)); }868static LIR_Opr metadataConst(Metadata* m) { return (LIR_Opr)(new LIR_Const(m)); }869870static LIR_Opr value_type(ValueType* type);871static LIR_Opr dummy_value_type(ValueType* type);872};873874875//-------------------------------------------------------------------------------876// LIR Instructions877//-------------------------------------------------------------------------------878//879// Note:880// - every instruction has a result operand881// - every instruction has an CodeEmitInfo operand (can be revisited later)882// - every instruction has a LIR_OpCode operand883// - LIR_OpN, means an instruction that has N input operands884//885// class hierarchy:886//887class LIR_Op;888class LIR_Op0;889class LIR_OpLabel;890class LIR_Op1;891class LIR_OpBranch;892class LIR_OpConvert;893class LIR_OpAllocObj;894class LIR_OpRoundFP;895class LIR_Op2;896class LIR_OpDelay;897class LIR_Op3;898class LIR_OpAllocArray;899class LIR_OpCall;900class LIR_OpJavaCall;901class LIR_OpRTCall;902class LIR_OpArrayCopy;903class LIR_OpUpdateCRC32;904class LIR_OpLock;905class LIR_OpTypeCheck;906class LIR_OpCompareAndSwap;907class LIR_OpProfileCall;908class LIR_OpProfileType;909#ifdef ASSERT910class LIR_OpAssert;911#endif912913// LIR operation codes914enum LIR_Code {915lir_none916, begin_op0917, lir_word_align918, lir_label919, lir_nop920, lir_backwardbranch_target921, lir_std_entry922, lir_osr_entry923, lir_build_frame924, lir_fpop_raw925, lir_24bit_FPU926, lir_reset_FPU927, lir_breakpoint928, lir_rtcall929, lir_membar930, lir_membar_acquire931, lir_membar_release932, lir_membar_loadload933, lir_membar_storestore934, lir_membar_loadstore935, lir_membar_storeload936, lir_get_thread937, end_op0938, begin_op1939, lir_fxch940, lir_fld941, lir_ffree942, lir_push943, lir_pop944, lir_null_check945, lir_return946, lir_leal947, lir_neg948, lir_branch949, lir_cond_float_branch950, lir_move951, lir_prefetchr952, lir_prefetchw953, lir_convert954, lir_alloc_object955, lir_monaddr956, lir_roundfp957, lir_safepoint958, lir_pack64959, lir_unpack64960, lir_unwind961, end_op1962, begin_op2963, lir_cmp964, lir_cmp_l2i965, lir_ucmp_fd2i966, lir_cmp_fd2i967, lir_cmove968, lir_add969, lir_sub970, lir_mul971, lir_mul_strictfp972, lir_div973, lir_div_strictfp974, lir_rem975, lir_sqrt976, lir_abs977, lir_sin978, lir_cos979, lir_tan980, lir_log981, lir_log10982, lir_exp983, lir_pow984, lir_logic_and985, lir_logic_or986, lir_logic_xor987, lir_shl988, lir_shr989, lir_ushr990, lir_alloc_array991, lir_throw992, lir_compare_to993, lir_xadd994, lir_xchg995, end_op2996, begin_op3997, lir_idiv998, lir_irem999, end_op31000, begin_opJavaCall1001, lir_static_call1002, lir_optvirtual_call1003, lir_icvirtual_call1004, lir_virtual_call1005, lir_dynamic_call1006, end_opJavaCall1007, begin_opArrayCopy1008, lir_arraycopy1009, end_opArrayCopy1010, begin_opUpdateCRC321011, lir_updatecrc321012, end_opUpdateCRC321013, begin_opLock1014, lir_lock1015, lir_unlock1016, end_opLock1017, begin_delay_slot1018, lir_delay_slot1019, end_delay_slot1020, begin_opTypeCheck1021, lir_instanceof1022, lir_checkcast1023, lir_store_check1024, end_opTypeCheck1025, begin_opCompareAndSwap1026, lir_cas_long1027, lir_cas_obj1028, lir_cas_int1029, end_opCompareAndSwap1030, begin_opMDOProfile1031, lir_profile_call1032, lir_profile_type1033, end_opMDOProfile1034, begin_opAssert1035, lir_assert1036, end_opAssert1037};103810391040enum LIR_Condition {1041lir_cond_equal1042, lir_cond_notEqual1043, lir_cond_less1044, lir_cond_lessEqual1045, lir_cond_greaterEqual1046, lir_cond_greater1047, lir_cond_belowEqual1048, lir_cond_aboveEqual1049, lir_cond_always1050, lir_cond_unknown = -11051};105210531054enum LIR_PatchCode {1055lir_patch_none,1056lir_patch_low,1057lir_patch_high,1058lir_patch_normal1059};106010611062enum LIR_MoveKind {1063lir_move_normal,1064lir_move_volatile,1065lir_move_unaligned,1066lir_move_wide,1067lir_move_max_flag1068};106910701071// --------------------------------------------------1072// LIR_Op1073// --------------------------------------------------1074class LIR_Op: public CompilationResourceObj {1075friend class LIR_OpVisitState;10761077#ifdef ASSERT1078private:1079const char * _file;1080int _line;1081#endif10821083protected:1084LIR_Opr _result;1085unsigned short _code;1086unsigned short _flags;1087CodeEmitInfo* _info;1088int _id; // value id for register allocation1089int _fpu_pop_count;1090Instruction* _source; // for debugging10911092static void print_condition(outputStream* out, LIR_Condition cond) PRODUCT_RETURN;10931094protected:1095static bool is_in_range(LIR_Code test, LIR_Code start, LIR_Code end) { return start < test && test < end; }10961097public:1098LIR_Op()1099: _result(LIR_OprFact::illegalOpr)1100, _code(lir_none)1101, _flags(0)1102, _info(NULL)1103#ifdef ASSERT1104, _file(NULL)1105, _line(0)1106#endif1107, _fpu_pop_count(0)1108, _source(NULL)1109, _id(-1) {}11101111LIR_Op(LIR_Code code, LIR_Opr result, CodeEmitInfo* info)1112: _result(result)1113, _code(code)1114, _flags(0)1115, _info(info)1116#ifdef ASSERT1117, _file(NULL)1118, _line(0)1119#endif1120, _fpu_pop_count(0)1121, _source(NULL)1122, _id(-1) {}11231124CodeEmitInfo* info() const { return _info; }1125LIR_Code code() const { return (LIR_Code)_code; }1126LIR_Opr result_opr() const { return _result; }1127void set_result_opr(LIR_Opr opr) { _result = opr; }11281129#ifdef ASSERT1130void set_file_and_line(const char * file, int line) {1131_file = file;1132_line = line;1133}1134#endif11351136virtual const char * name() const PRODUCT_RETURN0;11371138int id() const { return _id; }1139void set_id(int id) { _id = id; }11401141// FPU stack simulation helpers -- only used on Intel1142void set_fpu_pop_count(int count) { assert(count >= 0 && count <= 1, "currently only 0 and 1 are valid"); _fpu_pop_count = count; }1143int fpu_pop_count() const { return _fpu_pop_count; }1144bool pop_fpu_stack() { return _fpu_pop_count > 0; }11451146Instruction* source() const { return _source; }1147void set_source(Instruction* ins) { _source = ins; }11481149virtual void emit_code(LIR_Assembler* masm) = 0;1150virtual void print_instr(outputStream* out) const = 0;1151virtual void print_on(outputStream* st) const PRODUCT_RETURN;11521153virtual bool is_patching() { return false; }1154virtual LIR_OpCall* as_OpCall() { return NULL; }1155virtual LIR_OpJavaCall* as_OpJavaCall() { return NULL; }1156virtual LIR_OpLabel* as_OpLabel() { return NULL; }1157virtual LIR_OpDelay* as_OpDelay() { return NULL; }1158virtual LIR_OpLock* as_OpLock() { return NULL; }1159virtual LIR_OpAllocArray* as_OpAllocArray() { return NULL; }1160virtual LIR_OpAllocObj* as_OpAllocObj() { return NULL; }1161virtual LIR_OpRoundFP* as_OpRoundFP() { return NULL; }1162virtual LIR_OpBranch* as_OpBranch() { return NULL; }1163virtual LIR_OpRTCall* as_OpRTCall() { return NULL; }1164virtual LIR_OpConvert* as_OpConvert() { return NULL; }1165virtual LIR_Op0* as_Op0() { return NULL; }1166virtual LIR_Op1* as_Op1() { return NULL; }1167virtual LIR_Op2* as_Op2() { return NULL; }1168virtual LIR_Op3* as_Op3() { return NULL; }1169virtual LIR_OpArrayCopy* as_OpArrayCopy() { return NULL; }1170virtual LIR_OpUpdateCRC32* as_OpUpdateCRC32() { return NULL; }1171virtual LIR_OpTypeCheck* as_OpTypeCheck() { return NULL; }1172virtual LIR_OpCompareAndSwap* as_OpCompareAndSwap() { return NULL; }1173virtual LIR_OpProfileCall* as_OpProfileCall() { return NULL; }1174virtual LIR_OpProfileType* as_OpProfileType() { return NULL; }1175#ifdef ASSERT1176virtual LIR_OpAssert* as_OpAssert() { return NULL; }1177#endif11781179virtual void verify() const {}1180};11811182// for calls1183class LIR_OpCall: public LIR_Op {1184friend class LIR_OpVisitState;11851186protected:1187address _addr;1188LIR_OprList* _arguments;1189protected:1190LIR_OpCall(LIR_Code code, address addr, LIR_Opr result,1191LIR_OprList* arguments, CodeEmitInfo* info = NULL)1192: LIR_Op(code, result, info)1193, _arguments(arguments)1194, _addr(addr) {}11951196public:1197address addr() const { return _addr; }1198const LIR_OprList* arguments() const { return _arguments; }1199virtual LIR_OpCall* as_OpCall() { return this; }1200};120112021203// --------------------------------------------------1204// LIR_OpJavaCall1205// --------------------------------------------------1206class LIR_OpJavaCall: public LIR_OpCall {1207friend class LIR_OpVisitState;12081209private:1210ciMethod* _method;1211LIR_Opr _receiver;1212LIR_Opr _method_handle_invoke_SP_save_opr; // Used in LIR_OpVisitState::visit to store the reference to FrameMap::method_handle_invoke_SP_save_opr.12131214public:1215LIR_OpJavaCall(LIR_Code code, ciMethod* method,1216LIR_Opr receiver, LIR_Opr result,1217address addr, LIR_OprList* arguments,1218CodeEmitInfo* info)1219: LIR_OpCall(code, addr, result, arguments, info)1220, _receiver(receiver)1221, _method(method)1222, _method_handle_invoke_SP_save_opr(LIR_OprFact::illegalOpr)1223{ assert(is_in_range(code, begin_opJavaCall, end_opJavaCall), "code check"); }12241225LIR_OpJavaCall(LIR_Code code, ciMethod* method,1226LIR_Opr receiver, LIR_Opr result, intptr_t vtable_offset,1227LIR_OprList* arguments, CodeEmitInfo* info)1228: LIR_OpCall(code, (address)vtable_offset, result, arguments, info)1229, _receiver(receiver)1230, _method(method)1231, _method_handle_invoke_SP_save_opr(LIR_OprFact::illegalOpr)1232{ assert(is_in_range(code, begin_opJavaCall, end_opJavaCall), "code check"); }12331234LIR_Opr receiver() const { return _receiver; }1235ciMethod* method() const { return _method; }12361237// JSR 292 support.1238bool is_invokedynamic() const { return code() == lir_dynamic_call; }1239bool is_method_handle_invoke() const {1240return method()->is_compiled_lambda_form() || // Java-generated lambda form1241method()->is_method_handle_intrinsic(); // JVM-generated MH intrinsic1242}12431244intptr_t vtable_offset() const {1245assert(_code == lir_virtual_call, "only have vtable for real vcall");1246return (intptr_t) addr();1247}12481249virtual void emit_code(LIR_Assembler* masm);1250virtual LIR_OpJavaCall* as_OpJavaCall() { return this; }1251virtual void print_instr(outputStream* out) const PRODUCT_RETURN;1252};12531254// --------------------------------------------------1255// LIR_OpLabel1256// --------------------------------------------------1257// Location where a branch can continue1258class LIR_OpLabel: public LIR_Op {1259friend class LIR_OpVisitState;12601261private:1262Label* _label;1263public:1264LIR_OpLabel(Label* lbl)1265: LIR_Op(lir_label, LIR_OprFact::illegalOpr, NULL)1266, _label(lbl) {}1267Label* label() const { return _label; }12681269virtual void emit_code(LIR_Assembler* masm);1270virtual LIR_OpLabel* as_OpLabel() { return this; }1271virtual void print_instr(outputStream* out) const PRODUCT_RETURN;1272};12731274// LIR_OpArrayCopy1275class LIR_OpArrayCopy: public LIR_Op {1276friend class LIR_OpVisitState;12771278private:1279ArrayCopyStub* _stub;1280LIR_Opr _src;1281LIR_Opr _src_pos;1282LIR_Opr _dst;1283LIR_Opr _dst_pos;1284LIR_Opr _length;1285LIR_Opr _tmp;1286ciArrayKlass* _expected_type;1287int _flags;12881289public:1290enum Flags {1291src_null_check = 1 << 0,1292dst_null_check = 1 << 1,1293src_pos_positive_check = 1 << 2,1294dst_pos_positive_check = 1 << 3,1295length_positive_check = 1 << 4,1296src_range_check = 1 << 5,1297dst_range_check = 1 << 6,1298type_check = 1 << 7,1299overlapping = 1 << 8,1300unaligned = 1 << 9,1301src_objarray = 1 << 10,1302dst_objarray = 1 << 11,1303all_flags = (1 << 12) - 11304};13051306LIR_OpArrayCopy(LIR_Opr src, LIR_Opr src_pos, LIR_Opr dst, LIR_Opr dst_pos, LIR_Opr length, LIR_Opr tmp,1307ciArrayKlass* expected_type, int flags, CodeEmitInfo* info);13081309LIR_Opr src() const { return _src; }1310LIR_Opr src_pos() const { return _src_pos; }1311LIR_Opr dst() const { return _dst; }1312LIR_Opr dst_pos() const { return _dst_pos; }1313LIR_Opr length() const { return _length; }1314LIR_Opr tmp() const { return _tmp; }1315int flags() const { return _flags; }1316ciArrayKlass* expected_type() const { return _expected_type; }1317ArrayCopyStub* stub() const { return _stub; }13181319virtual void emit_code(LIR_Assembler* masm);1320virtual LIR_OpArrayCopy* as_OpArrayCopy() { return this; }1321void print_instr(outputStream* out) const PRODUCT_RETURN;1322};13231324// LIR_OpUpdateCRC321325class LIR_OpUpdateCRC32: public LIR_Op {1326friend class LIR_OpVisitState;13271328private:1329LIR_Opr _crc;1330LIR_Opr _val;13311332public:13331334LIR_OpUpdateCRC32(LIR_Opr crc, LIR_Opr val, LIR_Opr res);13351336LIR_Opr crc() const { return _crc; }1337LIR_Opr val() const { return _val; }13381339virtual void emit_code(LIR_Assembler* masm);1340virtual LIR_OpUpdateCRC32* as_OpUpdateCRC32() { return this; }1341void print_instr(outputStream* out) const PRODUCT_RETURN;1342};13431344// --------------------------------------------------1345// LIR_Op01346// --------------------------------------------------1347class LIR_Op0: public LIR_Op {1348friend class LIR_OpVisitState;13491350public:1351LIR_Op0(LIR_Code code)1352: LIR_Op(code, LIR_OprFact::illegalOpr, NULL) { assert(is_in_range(code, begin_op0, end_op0), "code check"); }1353LIR_Op0(LIR_Code code, LIR_Opr result, CodeEmitInfo* info = NULL)1354: LIR_Op(code, result, info) { assert(is_in_range(code, begin_op0, end_op0), "code check"); }13551356virtual void emit_code(LIR_Assembler* masm);1357virtual LIR_Op0* as_Op0() { return this; }1358virtual void print_instr(outputStream* out) const PRODUCT_RETURN;1359};136013611362// --------------------------------------------------1363// LIR_Op11364// --------------------------------------------------13651366class LIR_Op1: public LIR_Op {1367friend class LIR_OpVisitState;13681369protected:1370LIR_Opr _opr; // input operand1371BasicType _type; // Operand types1372LIR_PatchCode _patch; // only required with patchin (NEEDS_CLEANUP: do we want a special instruction for patching?)13731374static void print_patch_code(outputStream* out, LIR_PatchCode code);13751376void set_kind(LIR_MoveKind kind) {1377assert(code() == lir_move, "must be");1378_flags = kind;1379}13801381public:1382LIR_Op1(LIR_Code code, LIR_Opr opr, LIR_Opr result = LIR_OprFact::illegalOpr, BasicType type = T_ILLEGAL, LIR_PatchCode patch = lir_patch_none, CodeEmitInfo* info = NULL)1383: LIR_Op(code, result, info)1384, _opr(opr)1385, _patch(patch)1386, _type(type) { assert(is_in_range(code, begin_op1, end_op1), "code check"); }13871388LIR_Op1(LIR_Code code, LIR_Opr opr, LIR_Opr result, BasicType type, LIR_PatchCode patch, CodeEmitInfo* info, LIR_MoveKind kind)1389: LIR_Op(code, result, info)1390, _opr(opr)1391, _patch(patch)1392, _type(type) {1393assert(code == lir_move, "must be");1394set_kind(kind);1395}13961397LIR_Op1(LIR_Code code, LIR_Opr opr, CodeEmitInfo* info)1398: LIR_Op(code, LIR_OprFact::illegalOpr, info)1399, _opr(opr)1400, _patch(lir_patch_none)1401, _type(T_ILLEGAL) { assert(is_in_range(code, begin_op1, end_op1), "code check"); }14021403LIR_Opr in_opr() const { return _opr; }1404LIR_PatchCode patch_code() const { return _patch; }1405BasicType type() const { return _type; }14061407LIR_MoveKind move_kind() const {1408assert(code() == lir_move, "must be");1409return (LIR_MoveKind)_flags;1410}14111412virtual bool is_patching() { return _patch != lir_patch_none; }1413virtual void emit_code(LIR_Assembler* masm);1414virtual LIR_Op1* as_Op1() { return this; }1415virtual const char * name() const PRODUCT_RETURN0;14161417void set_in_opr(LIR_Opr opr) { _opr = opr; }14181419virtual void print_instr(outputStream* out) const PRODUCT_RETURN;1420virtual void verify() const;1421};142214231424// for runtime calls1425class LIR_OpRTCall: public LIR_OpCall {1426friend class LIR_OpVisitState;14271428private:1429LIR_Opr _tmp;1430public:1431LIR_OpRTCall(address addr, LIR_Opr tmp,1432LIR_Opr result, LIR_OprList* arguments, CodeEmitInfo* info = NULL)1433: LIR_OpCall(lir_rtcall, addr, result, arguments, info)1434, _tmp(tmp) {}14351436virtual void print_instr(outputStream* out) const PRODUCT_RETURN;1437virtual void emit_code(LIR_Assembler* masm);1438virtual LIR_OpRTCall* as_OpRTCall() { return this; }14391440LIR_Opr tmp() const { return _tmp; }14411442virtual void verify() const;1443};144414451446class LIR_OpBranch: public LIR_Op {1447friend class LIR_OpVisitState;14481449private:1450LIR_Condition _cond;1451BasicType _type;1452Label* _label;1453BlockBegin* _block; // if this is a branch to a block, this is the block1454BlockBegin* _ublock; // if this is a float-branch, this is the unorderd block1455CodeStub* _stub; // if this is a branch to a stub, this is the stub14561457public:1458LIR_OpBranch(LIR_Condition cond, BasicType type, Label* lbl)1459: LIR_Op(lir_branch, LIR_OprFact::illegalOpr, (CodeEmitInfo*) NULL)1460, _cond(cond)1461, _type(type)1462, _label(lbl)1463, _block(NULL)1464, _ublock(NULL)1465, _stub(NULL) { }14661467LIR_OpBranch(LIR_Condition cond, BasicType type, BlockBegin* block);1468LIR_OpBranch(LIR_Condition cond, BasicType type, CodeStub* stub);14691470// for unordered comparisons1471LIR_OpBranch(LIR_Condition cond, BasicType type, BlockBegin* block, BlockBegin* ublock);14721473LIR_Condition cond() const { return _cond; }1474BasicType type() const { return _type; }1475Label* label() const { return _label; }1476BlockBegin* block() const { return _block; }1477BlockBegin* ublock() const { return _ublock; }1478CodeStub* stub() const { return _stub; }14791480void change_block(BlockBegin* b);1481void change_ublock(BlockBegin* b);1482void negate_cond();14831484virtual void emit_code(LIR_Assembler* masm);1485virtual LIR_OpBranch* as_OpBranch() { return this; }1486virtual void print_instr(outputStream* out) const PRODUCT_RETURN;1487};148814891490class ConversionStub;14911492class LIR_OpConvert: public LIR_Op1 {1493friend class LIR_OpVisitState;14941495private:1496Bytecodes::Code _bytecode;1497ConversionStub* _stub;1498#if defined(PPC) || defined(AARCH64)1499LIR_Opr _tmp1;1500LIR_Opr _tmp2;1501#endif15021503public:1504LIR_OpConvert(Bytecodes::Code code, LIR_Opr opr, LIR_Opr result, ConversionStub* stub)1505: LIR_Op1(lir_convert, opr, result)1506, _stub(stub)1507#ifdef PPC1508, _tmp1(LIR_OprDesc::illegalOpr())1509, _tmp2(LIR_OprDesc::illegalOpr())1510#endif1511, _bytecode(code) {}15121513#if defined(PPC) || defined(AARCH64)1514LIR_OpConvert(Bytecodes::Code code, LIR_Opr opr, LIR_Opr result, ConversionStub* stub1515,LIR_Opr tmp1, LIR_Opr tmp2)1516: LIR_Op1(lir_convert, opr, result)1517, _stub(stub)1518, _tmp1(tmp1)1519, _tmp2(tmp2)1520, _bytecode(code) {}1521#endif15221523Bytecodes::Code bytecode() const { return _bytecode; }1524ConversionStub* stub() const { return _stub; }1525#if defined(PPC) || defined(AARCH64)1526LIR_Opr tmp1() const { return _tmp1; }1527LIR_Opr tmp2() const { return _tmp2; }1528#endif15291530virtual void emit_code(LIR_Assembler* masm);1531virtual LIR_OpConvert* as_OpConvert() { return this; }1532virtual void print_instr(outputStream* out) const PRODUCT_RETURN;15331534static void print_bytecode(outputStream* out, Bytecodes::Code code) PRODUCT_RETURN;1535};153615371538// LIR_OpAllocObj1539class LIR_OpAllocObj : public LIR_Op1 {1540friend class LIR_OpVisitState;15411542private:1543LIR_Opr _tmp1;1544LIR_Opr _tmp2;1545LIR_Opr _tmp3;1546LIR_Opr _tmp4;1547int _hdr_size;1548int _obj_size;1549CodeStub* _stub;1550bool _init_check;15511552public:1553LIR_OpAllocObj(LIR_Opr klass, LIR_Opr result,1554LIR_Opr t1, LIR_Opr t2, LIR_Opr t3, LIR_Opr t4,1555int hdr_size, int obj_size, bool init_check, CodeStub* stub)1556: LIR_Op1(lir_alloc_object, klass, result)1557, _tmp1(t1)1558, _tmp2(t2)1559, _tmp3(t3)1560, _tmp4(t4)1561, _hdr_size(hdr_size)1562, _obj_size(obj_size)1563, _init_check(init_check)1564, _stub(stub) { }15651566LIR_Opr klass() const { return in_opr(); }1567LIR_Opr obj() const { return result_opr(); }1568LIR_Opr tmp1() const { return _tmp1; }1569LIR_Opr tmp2() const { return _tmp2; }1570LIR_Opr tmp3() const { return _tmp3; }1571LIR_Opr tmp4() const { return _tmp4; }1572int header_size() const { return _hdr_size; }1573int object_size() const { return _obj_size; }1574bool init_check() const { return _init_check; }1575CodeStub* stub() const { return _stub; }15761577virtual void emit_code(LIR_Assembler* masm);1578virtual LIR_OpAllocObj * as_OpAllocObj () { return this; }1579virtual void print_instr(outputStream* out) const PRODUCT_RETURN;1580};158115821583// LIR_OpRoundFP1584class LIR_OpRoundFP : public LIR_Op1 {1585friend class LIR_OpVisitState;15861587private:1588LIR_Opr _tmp;15891590public:1591LIR_OpRoundFP(LIR_Opr reg, LIR_Opr stack_loc_temp, LIR_Opr result)1592: LIR_Op1(lir_roundfp, reg, result)1593, _tmp(stack_loc_temp) {}15941595LIR_Opr tmp() const { return _tmp; }1596virtual LIR_OpRoundFP* as_OpRoundFP() { return this; }1597void print_instr(outputStream* out) const PRODUCT_RETURN;1598};15991600// LIR_OpTypeCheck1601class LIR_OpTypeCheck: public LIR_Op {1602friend class LIR_OpVisitState;16031604private:1605LIR_Opr _object;1606LIR_Opr _array;1607ciKlass* _klass;1608LIR_Opr _tmp1;1609LIR_Opr _tmp2;1610LIR_Opr _tmp3;1611bool _fast_check;1612CodeEmitInfo* _info_for_patch;1613CodeEmitInfo* _info_for_exception;1614CodeStub* _stub;1615ciMethod* _profiled_method;1616int _profiled_bci;1617bool _should_profile;16181619public:1620LIR_OpTypeCheck(LIR_Code code, LIR_Opr result, LIR_Opr object, ciKlass* klass,1621LIR_Opr tmp1, LIR_Opr tmp2, LIR_Opr tmp3, bool fast_check,1622CodeEmitInfo* info_for_exception, CodeEmitInfo* info_for_patch, CodeStub* stub);1623LIR_OpTypeCheck(LIR_Code code, LIR_Opr object, LIR_Opr array,1624LIR_Opr tmp1, LIR_Opr tmp2, LIR_Opr tmp3, CodeEmitInfo* info_for_exception);16251626LIR_Opr object() const { return _object; }1627LIR_Opr array() const { assert(code() == lir_store_check, "not valid"); return _array; }1628LIR_Opr tmp1() const { return _tmp1; }1629LIR_Opr tmp2() const { return _tmp2; }1630LIR_Opr tmp3() const { return _tmp3; }1631ciKlass* klass() const { assert(code() == lir_instanceof || code() == lir_checkcast, "not valid"); return _klass; }1632bool fast_check() const { assert(code() == lir_instanceof || code() == lir_checkcast, "not valid"); return _fast_check; }1633CodeEmitInfo* info_for_patch() const { return _info_for_patch; }1634CodeEmitInfo* info_for_exception() const { return _info_for_exception; }1635CodeStub* stub() const { return _stub; }16361637// MethodData* profiling1638void set_profiled_method(ciMethod *method) { _profiled_method = method; }1639void set_profiled_bci(int bci) { _profiled_bci = bci; }1640void set_should_profile(bool b) { _should_profile = b; }1641ciMethod* profiled_method() const { return _profiled_method; }1642int profiled_bci() const { return _profiled_bci; }1643bool should_profile() const { return _should_profile; }16441645virtual bool is_patching() { return _info_for_patch != NULL; }1646virtual void emit_code(LIR_Assembler* masm);1647virtual LIR_OpTypeCheck* as_OpTypeCheck() { return this; }1648void print_instr(outputStream* out) const PRODUCT_RETURN;1649};16501651// LIR_Op21652class LIR_Op2: public LIR_Op {1653friend class LIR_OpVisitState;16541655int _fpu_stack_size; // for sin/cos implementation on Intel16561657protected:1658LIR_Opr _opr1;1659LIR_Opr _opr2;1660BasicType _type;1661LIR_Opr _tmp1;1662LIR_Opr _tmp2;1663LIR_Opr _tmp3;1664LIR_Opr _tmp4;1665LIR_Opr _tmp5;1666LIR_Condition _condition;16671668void verify() const;16691670public:1671LIR_Op2(LIR_Code code, LIR_Condition condition, LIR_Opr opr1, LIR_Opr opr2, CodeEmitInfo* info = NULL)1672: LIR_Op(code, LIR_OprFact::illegalOpr, info)1673, _opr1(opr1)1674, _opr2(opr2)1675, _type(T_ILLEGAL)1676, _condition(condition)1677, _fpu_stack_size(0)1678, _tmp1(LIR_OprFact::illegalOpr)1679, _tmp2(LIR_OprFact::illegalOpr)1680, _tmp3(LIR_OprFact::illegalOpr)1681, _tmp4(LIR_OprFact::illegalOpr)1682, _tmp5(LIR_OprFact::illegalOpr) {1683assert(code == lir_cmp || code == lir_assert, "code check");1684}16851686LIR_Op2(LIR_Code code, LIR_Condition condition, LIR_Opr opr1, LIR_Opr opr2, LIR_Opr result, BasicType type)1687: LIR_Op(code, result, NULL)1688, _opr1(opr1)1689, _opr2(opr2)1690, _type(type)1691, _condition(condition)1692, _fpu_stack_size(0)1693, _tmp1(LIR_OprFact::illegalOpr)1694, _tmp2(LIR_OprFact::illegalOpr)1695, _tmp3(LIR_OprFact::illegalOpr)1696, _tmp4(LIR_OprFact::illegalOpr)1697, _tmp5(LIR_OprFact::illegalOpr) {1698assert(code == lir_cmove, "code check");1699assert(type != T_ILLEGAL, "cmove should have type");1700}17011702LIR_Op2(LIR_Code code, LIR_Opr opr1, LIR_Opr opr2, LIR_Opr result = LIR_OprFact::illegalOpr,1703CodeEmitInfo* info = NULL, BasicType type = T_ILLEGAL)1704: LIR_Op(code, result, info)1705, _opr1(opr1)1706, _opr2(opr2)1707, _type(type)1708, _condition(lir_cond_unknown)1709, _fpu_stack_size(0)1710, _tmp1(LIR_OprFact::illegalOpr)1711, _tmp2(LIR_OprFact::illegalOpr)1712, _tmp3(LIR_OprFact::illegalOpr)1713, _tmp4(LIR_OprFact::illegalOpr)1714, _tmp5(LIR_OprFact::illegalOpr) {1715assert(code != lir_cmp && is_in_range(code, begin_op2, end_op2), "code check");1716}17171718LIR_Op2(LIR_Code code, LIR_Opr opr1, LIR_Opr opr2, LIR_Opr result, LIR_Opr tmp1, LIR_Opr tmp2 = LIR_OprFact::illegalOpr,1719LIR_Opr tmp3 = LIR_OprFact::illegalOpr, LIR_Opr tmp4 = LIR_OprFact::illegalOpr, LIR_Opr tmp5 = LIR_OprFact::illegalOpr)1720: LIR_Op(code, result, NULL)1721, _opr1(opr1)1722, _opr2(opr2)1723, _type(T_ILLEGAL)1724, _condition(lir_cond_unknown)1725, _fpu_stack_size(0)1726, _tmp1(tmp1)1727, _tmp2(tmp2)1728, _tmp3(tmp3)1729, _tmp4(tmp4)1730, _tmp5(tmp5) {1731assert(code != lir_cmp && is_in_range(code, begin_op2, end_op2), "code check");1732}17331734LIR_Opr in_opr1() const { return _opr1; }1735LIR_Opr in_opr2() const { return _opr2; }1736BasicType type() const { return _type; }1737LIR_Opr tmp1_opr() const { return _tmp1; }1738LIR_Opr tmp2_opr() const { return _tmp2; }1739LIR_Opr tmp3_opr() const { return _tmp3; }1740LIR_Opr tmp4_opr() const { return _tmp4; }1741LIR_Opr tmp5_opr() const { return _tmp5; }1742LIR_Condition condition() const {1743assert(code() == lir_cmp || code() == lir_cmove || code() == lir_assert, "only valid for cmp and cmove and assert"); return _condition;1744}1745void set_condition(LIR_Condition condition) {1746assert(code() == lir_cmp || code() == lir_cmove, "only valid for cmp and cmove"); _condition = condition;1747}17481749void set_fpu_stack_size(int size) { _fpu_stack_size = size; }1750int fpu_stack_size() const { return _fpu_stack_size; }17511752void set_in_opr1(LIR_Opr opr) { _opr1 = opr; }1753void set_in_opr2(LIR_Opr opr) { _opr2 = opr; }17541755virtual void emit_code(LIR_Assembler* masm);1756virtual LIR_Op2* as_Op2() { return this; }1757virtual void print_instr(outputStream* out) const PRODUCT_RETURN;1758};17591760class LIR_OpAllocArray : public LIR_Op {1761friend class LIR_OpVisitState;17621763private:1764LIR_Opr _klass;1765LIR_Opr _len;1766LIR_Opr _tmp1;1767LIR_Opr _tmp2;1768LIR_Opr _tmp3;1769LIR_Opr _tmp4;1770BasicType _type;1771CodeStub* _stub;17721773public:1774LIR_OpAllocArray(LIR_Opr klass, LIR_Opr len, LIR_Opr result, LIR_Opr t1, LIR_Opr t2, LIR_Opr t3, LIR_Opr t4, BasicType type, CodeStub* stub)1775: LIR_Op(lir_alloc_array, result, NULL)1776, _klass(klass)1777, _len(len)1778, _tmp1(t1)1779, _tmp2(t2)1780, _tmp3(t3)1781, _tmp4(t4)1782, _type(type)1783, _stub(stub) {}17841785LIR_Opr klass() const { return _klass; }1786LIR_Opr len() const { return _len; }1787LIR_Opr obj() const { return result_opr(); }1788LIR_Opr tmp1() const { return _tmp1; }1789LIR_Opr tmp2() const { return _tmp2; }1790LIR_Opr tmp3() const { return _tmp3; }1791LIR_Opr tmp4() const { return _tmp4; }1792BasicType type() const { return _type; }1793CodeStub* stub() const { return _stub; }17941795virtual void emit_code(LIR_Assembler* masm);1796virtual LIR_OpAllocArray * as_OpAllocArray () { return this; }1797virtual void print_instr(outputStream* out) const PRODUCT_RETURN;1798};179918001801class LIR_Op3: public LIR_Op {1802friend class LIR_OpVisitState;18031804private:1805LIR_Opr _opr1;1806LIR_Opr _opr2;1807LIR_Opr _opr3;1808public:1809LIR_Op3(LIR_Code code, LIR_Opr opr1, LIR_Opr opr2, LIR_Opr opr3, LIR_Opr result, CodeEmitInfo* info = NULL)1810: LIR_Op(code, result, info)1811, _opr1(opr1)1812, _opr2(opr2)1813, _opr3(opr3) { assert(is_in_range(code, begin_op3, end_op3), "code check"); }1814LIR_Opr in_opr1() const { return _opr1; }1815LIR_Opr in_opr2() const { return _opr2; }1816LIR_Opr in_opr3() const { return _opr3; }18171818virtual void emit_code(LIR_Assembler* masm);1819virtual LIR_Op3* as_Op3() { return this; }1820virtual void print_instr(outputStream* out) const PRODUCT_RETURN;1821};182218231824//--------------------------------1825class LabelObj: public CompilationResourceObj {1826private:1827Label _label;1828public:1829LabelObj() {}1830Label* label() { return &_label; }1831};183218331834class LIR_OpLock: public LIR_Op {1835friend class LIR_OpVisitState;18361837private:1838LIR_Opr _hdr;1839LIR_Opr _obj;1840LIR_Opr _lock;1841LIR_Opr _scratch;1842CodeStub* _stub;1843public:1844LIR_OpLock(LIR_Code code, LIR_Opr hdr, LIR_Opr obj, LIR_Opr lock, LIR_Opr scratch, CodeStub* stub, CodeEmitInfo* info)1845: LIR_Op(code, LIR_OprFact::illegalOpr, info)1846, _hdr(hdr)1847, _obj(obj)1848, _lock(lock)1849, _scratch(scratch)1850, _stub(stub) {}18511852LIR_Opr hdr_opr() const { return _hdr; }1853LIR_Opr obj_opr() const { return _obj; }1854LIR_Opr lock_opr() const { return _lock; }1855LIR_Opr scratch_opr() const { return _scratch; }1856CodeStub* stub() const { return _stub; }18571858virtual void emit_code(LIR_Assembler* masm);1859virtual LIR_OpLock* as_OpLock() { return this; }1860void print_instr(outputStream* out) const PRODUCT_RETURN;1861};186218631864class LIR_OpDelay: public LIR_Op {1865friend class LIR_OpVisitState;18661867private:1868LIR_Op* _op;18691870public:1871LIR_OpDelay(LIR_Op* op, CodeEmitInfo* info):1872LIR_Op(lir_delay_slot, LIR_OprFact::illegalOpr, info),1873_op(op) {1874assert(op->code() == lir_nop || LIRFillDelaySlots, "should be filling with nops");1875}1876virtual void emit_code(LIR_Assembler* masm);1877virtual LIR_OpDelay* as_OpDelay() { return this; }1878void print_instr(outputStream* out) const PRODUCT_RETURN;1879LIR_Op* delay_op() const { return _op; }1880CodeEmitInfo* call_info() const { return info(); }1881};18821883#ifdef ASSERT1884// LIR_OpAssert1885class LIR_OpAssert : public LIR_Op2 {1886friend class LIR_OpVisitState;18871888private:1889const char* _msg;1890bool _halt;18911892public:1893LIR_OpAssert(LIR_Condition condition, LIR_Opr opr1, LIR_Opr opr2, const char* msg, bool halt)1894: LIR_Op2(lir_assert, condition, opr1, opr2)1895, _halt(halt)1896, _msg(msg) {1897}18981899const char* msg() const { return _msg; }1900bool halt() const { return _halt; }19011902virtual void emit_code(LIR_Assembler* masm);1903virtual LIR_OpAssert* as_OpAssert() { return this; }1904virtual void print_instr(outputStream* out) const PRODUCT_RETURN;1905};1906#endif19071908// LIR_OpCompareAndSwap1909class LIR_OpCompareAndSwap : public LIR_Op {1910friend class LIR_OpVisitState;19111912private:1913LIR_Opr _addr;1914LIR_Opr _cmp_value;1915LIR_Opr _new_value;1916LIR_Opr _tmp1;1917LIR_Opr _tmp2;19181919public:1920LIR_OpCompareAndSwap(LIR_Code code, LIR_Opr addr, LIR_Opr cmp_value, LIR_Opr new_value,1921LIR_Opr t1, LIR_Opr t2, LIR_Opr result)1922: LIR_Op(code, result, NULL) // no result, no info1923, _addr(addr)1924, _cmp_value(cmp_value)1925, _new_value(new_value)1926, _tmp1(t1)1927, _tmp2(t2) { }19281929LIR_Opr addr() const { return _addr; }1930LIR_Opr cmp_value() const { return _cmp_value; }1931LIR_Opr new_value() const { return _new_value; }1932LIR_Opr tmp1() const { return _tmp1; }1933LIR_Opr tmp2() const { return _tmp2; }19341935virtual void emit_code(LIR_Assembler* masm);1936virtual LIR_OpCompareAndSwap * as_OpCompareAndSwap () { return this; }1937virtual void print_instr(outputStream* out) const PRODUCT_RETURN;1938};19391940// LIR_OpProfileCall1941class LIR_OpProfileCall : public LIR_Op {1942friend class LIR_OpVisitState;19431944private:1945ciMethod* _profiled_method;1946int _profiled_bci;1947ciMethod* _profiled_callee;1948LIR_Opr _mdo;1949LIR_Opr _recv;1950LIR_Opr _tmp1;1951ciKlass* _known_holder;19521953public:1954// Destroys recv1955LIR_OpProfileCall(ciMethod* profiled_method, int profiled_bci, ciMethod* profiled_callee, LIR_Opr mdo, LIR_Opr recv, LIR_Opr t1, ciKlass* known_holder)1956: LIR_Op(lir_profile_call, LIR_OprFact::illegalOpr, NULL) // no result, no info1957, _profiled_method(profiled_method)1958, _profiled_bci(profiled_bci)1959, _profiled_callee(profiled_callee)1960, _mdo(mdo)1961, _recv(recv)1962, _tmp1(t1)1963, _known_holder(known_holder) { }19641965ciMethod* profiled_method() const { return _profiled_method; }1966int profiled_bci() const { return _profiled_bci; }1967ciMethod* profiled_callee() const { return _profiled_callee; }1968LIR_Opr mdo() const { return _mdo; }1969LIR_Opr recv() const { return _recv; }1970LIR_Opr tmp1() const { return _tmp1; }1971ciKlass* known_holder() const { return _known_holder; }19721973virtual void emit_code(LIR_Assembler* masm);1974virtual LIR_OpProfileCall* as_OpProfileCall() { return this; }1975virtual void print_instr(outputStream* out) const PRODUCT_RETURN;1976};19771978// LIR_OpProfileType1979class LIR_OpProfileType : public LIR_Op {1980friend class LIR_OpVisitState;19811982private:1983LIR_Opr _mdp;1984LIR_Opr _obj;1985LIR_Opr _tmp;1986ciKlass* _exact_klass; // non NULL if we know the klass statically (no need to load it from _obj)1987intptr_t _current_klass; // what the profiling currently reports1988bool _not_null; // true if we know statically that _obj cannot be null1989bool _no_conflict; // true if we're profling parameters, _exact_klass is not NULL and we know1990// _exact_klass it the only possible type for this parameter in any context.19911992public:1993// Destroys recv1994LIR_OpProfileType(LIR_Opr mdp, LIR_Opr obj, ciKlass* exact_klass, intptr_t current_klass, LIR_Opr tmp, bool not_null, bool no_conflict)1995: LIR_Op(lir_profile_type, LIR_OprFact::illegalOpr, NULL) // no result, no info1996, _mdp(mdp)1997, _obj(obj)1998, _exact_klass(exact_klass)1999, _current_klass(current_klass)2000, _tmp(tmp)2001, _not_null(not_null)2002, _no_conflict(no_conflict) { }20032004LIR_Opr mdp() const { return _mdp; }2005LIR_Opr obj() const { return _obj; }2006LIR_Opr tmp() const { return _tmp; }2007ciKlass* exact_klass() const { return _exact_klass; }2008intptr_t current_klass() const { return _current_klass; }2009bool not_null() const { return _not_null; }2010bool no_conflict() const { return _no_conflict; }20112012virtual void emit_code(LIR_Assembler* masm);2013virtual LIR_OpProfileType* as_OpProfileType() { return this; }2014virtual void print_instr(outputStream* out) const PRODUCT_RETURN;2015};20162017class LIR_InsertionBuffer;20182019//--------------------------------LIR_List---------------------------------------------------2020// Maintains a list of LIR instructions (one instance of LIR_List per basic block)2021// The LIR instructions are appended by the LIR_List class itself;2022//2023// Notes:2024// - all offsets are(should be) in bytes2025// - local positions are specified with an offset, with offset 0 being local 020262027class LIR_List: public CompilationResourceObj {2028private:2029LIR_OpList _operations;20302031Compilation* _compilation;2032#ifndef PRODUCT2033BlockBegin* _block;2034#endif2035#ifdef ASSERT2036const char * _file;2037int _line;2038#endif20392040void append(LIR_Op* op) {2041if (op->source() == NULL)2042op->set_source(_compilation->current_instruction());2043#ifndef PRODUCT2044if (PrintIRWithLIR) {2045_compilation->maybe_print_current_instruction();2046op->print(); tty->cr();2047}2048#endif // PRODUCT20492050_operations.append(op);20512052#ifdef ASSERT2053op->verify();2054op->set_file_and_line(_file, _line);2055_file = NULL;2056_line = 0;2057#endif2058}20592060public:2061LIR_List(Compilation* compilation, BlockBegin* block = NULL);20622063#ifdef ASSERT2064void set_file_and_line(const char * file, int line);2065#endif20662067//---------- accessors ---------------2068LIR_OpList* instructions_list() { return &_operations; }2069int length() const { return _operations.length(); }2070LIR_Op* at(int i) const { return _operations.at(i); }20712072NOT_PRODUCT(BlockBegin* block() const { return _block; });20732074// insert LIR_Ops in buffer to right places in LIR_List2075void append(LIR_InsertionBuffer* buffer);20762077//---------- mutators ---------------2078void insert_before(int i, LIR_List* op_list) { _operations.insert_before(i, op_list->instructions_list()); }2079void insert_before(int i, LIR_Op* op) { _operations.insert_before(i, op); }2080void remove_at(int i) { _operations.remove_at(i); }20812082//---------- printing -------------2083void print_instructions() PRODUCT_RETURN;208420852086//---------- instructions -------------2087void call_opt_virtual(ciMethod* method, LIR_Opr receiver, LIR_Opr result,2088address dest, LIR_OprList* arguments,2089CodeEmitInfo* info) {2090append(new LIR_OpJavaCall(lir_optvirtual_call, method, receiver, result, dest, arguments, info));2091}2092void call_static(ciMethod* method, LIR_Opr result,2093address dest, LIR_OprList* arguments, CodeEmitInfo* info) {2094append(new LIR_OpJavaCall(lir_static_call, method, LIR_OprFact::illegalOpr, result, dest, arguments, info));2095}2096void call_icvirtual(ciMethod* method, LIR_Opr receiver, LIR_Opr result,2097address dest, LIR_OprList* arguments, CodeEmitInfo* info) {2098append(new LIR_OpJavaCall(lir_icvirtual_call, method, receiver, result, dest, arguments, info));2099}2100void call_virtual(ciMethod* method, LIR_Opr receiver, LIR_Opr result,2101intptr_t vtable_offset, LIR_OprList* arguments, CodeEmitInfo* info) {2102append(new LIR_OpJavaCall(lir_virtual_call, method, receiver, result, vtable_offset, arguments, info));2103}2104void call_dynamic(ciMethod* method, LIR_Opr receiver, LIR_Opr result,2105address dest, LIR_OprList* arguments, CodeEmitInfo* info) {2106append(new LIR_OpJavaCall(lir_dynamic_call, method, receiver, result, dest, arguments, info));2107}21082109void get_thread(LIR_Opr result) { append(new LIR_Op0(lir_get_thread, result)); }2110void word_align() { append(new LIR_Op0(lir_word_align)); }2111void membar() { append(new LIR_Op0(lir_membar)); }2112void membar_acquire() { append(new LIR_Op0(lir_membar_acquire)); }2113void membar_release() { append(new LIR_Op0(lir_membar_release)); }2114void membar_loadload() { append(new LIR_Op0(lir_membar_loadload)); }2115void membar_storestore() { append(new LIR_Op0(lir_membar_storestore)); }2116void membar_loadstore() { append(new LIR_Op0(lir_membar_loadstore)); }2117void membar_storeload() { append(new LIR_Op0(lir_membar_storeload)); }21182119void nop() { append(new LIR_Op0(lir_nop)); }2120void build_frame() { append(new LIR_Op0(lir_build_frame)); }21212122void std_entry(LIR_Opr receiver) { append(new LIR_Op0(lir_std_entry, receiver)); }2123void osr_entry(LIR_Opr osrPointer) { append(new LIR_Op0(lir_osr_entry, osrPointer)); }21242125void branch_destination(Label* lbl) { append(new LIR_OpLabel(lbl)); }21262127void negate(LIR_Opr from, LIR_Opr to) { append(new LIR_Op1(lir_neg, from, to)); }2128void leal(LIR_Opr from, LIR_Opr result_reg, LIR_PatchCode patch_code = lir_patch_none, CodeEmitInfo* info = NULL) { append(new LIR_Op1(lir_leal, from, result_reg, T_ILLEGAL, patch_code, info)); }21292130// result is a stack location for old backend and vreg for UseLinearScan2131// stack_loc_temp is an illegal register for old backend2132void roundfp(LIR_Opr reg, LIR_Opr stack_loc_temp, LIR_Opr result) { append(new LIR_OpRoundFP(reg, stack_loc_temp, result)); }2133void unaligned_move(LIR_Address* src, LIR_Opr dst) { append(new LIR_Op1(lir_move, LIR_OprFact::address(src), dst, dst->type(), lir_patch_none, NULL, lir_move_unaligned)); }2134void unaligned_move(LIR_Opr src, LIR_Address* dst) { append(new LIR_Op1(lir_move, src, LIR_OprFact::address(dst), src->type(), lir_patch_none, NULL, lir_move_unaligned)); }2135void unaligned_move(LIR_Opr src, LIR_Opr dst) { append(new LIR_Op1(lir_move, src, dst, dst->type(), lir_patch_none, NULL, lir_move_unaligned)); }2136void move(LIR_Opr src, LIR_Opr dst, CodeEmitInfo* info = NULL) { append(new LIR_Op1(lir_move, src, dst, dst->type(), lir_patch_none, info)); }2137void move(LIR_Address* src, LIR_Opr dst, CodeEmitInfo* info = NULL) { append(new LIR_Op1(lir_move, LIR_OprFact::address(src), dst, src->type(), lir_patch_none, info)); }2138void move(LIR_Opr src, LIR_Address* dst, CodeEmitInfo* info = NULL) { append(new LIR_Op1(lir_move, src, LIR_OprFact::address(dst), dst->type(), lir_patch_none, info)); }2139void move_wide(LIR_Address* src, LIR_Opr dst, CodeEmitInfo* info = NULL) {2140if (UseCompressedOops) {2141append(new LIR_Op1(lir_move, LIR_OprFact::address(src), dst, src->type(), lir_patch_none, info, lir_move_wide));2142} else {2143move(src, dst, info);2144}2145}2146void move_wide(LIR_Opr src, LIR_Address* dst, CodeEmitInfo* info = NULL) {2147if (UseCompressedOops) {2148append(new LIR_Op1(lir_move, src, LIR_OprFact::address(dst), dst->type(), lir_patch_none, info, lir_move_wide));2149} else {2150move(src, dst, info);2151}2152}2153void volatile_move(LIR_Opr src, LIR_Opr dst, BasicType type, CodeEmitInfo* info = NULL, LIR_PatchCode patch_code = lir_patch_none) { append(new LIR_Op1(lir_move, src, dst, type, patch_code, info, lir_move_volatile)); }21542155void oop2reg (jobject o, LIR_Opr reg) { assert(reg->type() == T_OBJECT, "bad reg"); append(new LIR_Op1(lir_move, LIR_OprFact::oopConst(o), reg)); }2156void oop2reg_patch(jobject o, LIR_Opr reg, CodeEmitInfo* info);21572158void metadata2reg (Metadata* o, LIR_Opr reg) { assert(reg->type() == T_METADATA, "bad reg"); append(new LIR_Op1(lir_move, LIR_OprFact::metadataConst(o), reg)); }2159void klass2reg_patch(Metadata* o, LIR_Opr reg, CodeEmitInfo* info);21602161void return_op(LIR_Opr result) { append(new LIR_Op1(lir_return, result)); }21622163void safepoint(LIR_Opr tmp, CodeEmitInfo* info) { append(new LIR_Op1(lir_safepoint, tmp, info)); }21642165#ifdef PPC2166void convert(Bytecodes::Code code, LIR_Opr left, LIR_Opr dst, LIR_Opr tmp1, LIR_Opr tmp2) { append(new LIR_OpConvert(code, left, dst, NULL, tmp1, tmp2)); }2167#endif2168#if defined(AARCH64)2169void convert(Bytecodes::Code code, LIR_Opr left, LIR_Opr dst,2170ConversionStub* stub = NULL, LIR_Opr tmp1 = LIR_OprDesc::illegalOpr()) {2171append(new LIR_OpConvert(code, left, dst, stub, tmp1, LIR_OprDesc::illegalOpr()));2172}2173#else2174void convert(Bytecodes::Code code, LIR_Opr left, LIR_Opr dst, ConversionStub* stub = NULL/*, bool is_32bit = false*/) { append(new LIR_OpConvert(code, left, dst, stub)); }2175#endif21762177void logical_and (LIR_Opr left, LIR_Opr right, LIR_Opr dst) { append(new LIR_Op2(lir_logic_and, left, right, dst)); }2178void logical_or (LIR_Opr left, LIR_Opr right, LIR_Opr dst) { append(new LIR_Op2(lir_logic_or, left, right, dst)); }2179void logical_xor (LIR_Opr left, LIR_Opr right, LIR_Opr dst) { append(new LIR_Op2(lir_logic_xor, left, right, dst)); }21802181void pack64(LIR_Opr src, LIR_Opr dst) { append(new LIR_Op1(lir_pack64, src, dst, T_LONG, lir_patch_none, NULL)); }2182void unpack64(LIR_Opr src, LIR_Opr dst) { append(new LIR_Op1(lir_unpack64, src, dst, T_LONG, lir_patch_none, NULL)); }21832184void null_check(LIR_Opr opr, CodeEmitInfo* info, bool deoptimize_on_null = false);2185void throw_exception(LIR_Opr exceptionPC, LIR_Opr exceptionOop, CodeEmitInfo* info) {2186append(new LIR_Op2(lir_throw, exceptionPC, exceptionOop, LIR_OprFact::illegalOpr, info));2187}2188void unwind_exception(LIR_Opr exceptionOop) {2189append(new LIR_Op1(lir_unwind, exceptionOop));2190}21912192void compare_to (LIR_Opr left, LIR_Opr right, LIR_Opr dst) {2193append(new LIR_Op2(lir_compare_to, left, right, dst));2194}21952196void push(LIR_Opr opr) { append(new LIR_Op1(lir_push, opr)); }2197void pop(LIR_Opr reg) { append(new LIR_Op1(lir_pop, reg)); }21982199void cmp(LIR_Condition condition, LIR_Opr left, LIR_Opr right, CodeEmitInfo* info = NULL) {2200append(new LIR_Op2(lir_cmp, condition, left, right, info));2201}2202void cmp(LIR_Condition condition, LIR_Opr left, int right, CodeEmitInfo* info = NULL) {2203cmp(condition, left, LIR_OprFact::intConst(right), info);2204}22052206void cmp_mem_int(LIR_Condition condition, LIR_Opr base, int disp, int c, CodeEmitInfo* info);2207void cmp_reg_mem(LIR_Condition condition, LIR_Opr reg, LIR_Address* addr, CodeEmitInfo* info);22082209void cmove(LIR_Condition condition, LIR_Opr src1, LIR_Opr src2, LIR_Opr dst, BasicType type) {2210append(new LIR_Op2(lir_cmove, condition, src1, src2, dst, type));2211}22122213void cas_long(LIR_Opr addr, LIR_Opr cmp_value, LIR_Opr new_value,2214LIR_Opr t1, LIR_Opr t2, LIR_Opr result = LIR_OprFact::illegalOpr);2215void cas_obj(LIR_Opr addr, LIR_Opr cmp_value, LIR_Opr new_value,2216LIR_Opr t1, LIR_Opr t2, LIR_Opr result = LIR_OprFact::illegalOpr);2217void cas_int(LIR_Opr addr, LIR_Opr cmp_value, LIR_Opr new_value,2218LIR_Opr t1, LIR_Opr t2, LIR_Opr result = LIR_OprFact::illegalOpr);22192220void abs (LIR_Opr from, LIR_Opr to, LIR_Opr tmp) { append(new LIR_Op2(lir_abs , from, tmp, to)); }2221void sqrt(LIR_Opr from, LIR_Opr to, LIR_Opr tmp) { append(new LIR_Op2(lir_sqrt, from, tmp, to)); }2222void log (LIR_Opr from, LIR_Opr to, LIR_Opr tmp) { append(new LIR_Op2(lir_log, from, LIR_OprFact::illegalOpr, to, tmp)); }2223void log10 (LIR_Opr from, LIR_Opr to, LIR_Opr tmp) { append(new LIR_Op2(lir_log10, from, LIR_OprFact::illegalOpr, to, tmp)); }2224void sin (LIR_Opr from, LIR_Opr to, LIR_Opr tmp1, LIR_Opr tmp2) { append(new LIR_Op2(lir_sin , from, tmp1, to, tmp2)); }2225void cos (LIR_Opr from, LIR_Opr to, LIR_Opr tmp1, LIR_Opr tmp2) { append(new LIR_Op2(lir_cos , from, tmp1, to, tmp2)); }2226void tan (LIR_Opr from, LIR_Opr to, LIR_Opr tmp1, LIR_Opr tmp2) { append(new LIR_Op2(lir_tan , from, tmp1, to, tmp2)); }2227void exp (LIR_Opr from, LIR_Opr to, LIR_Opr tmp1, LIR_Opr tmp2, LIR_Opr tmp3, LIR_Opr tmp4, LIR_Opr tmp5) { append(new LIR_Op2(lir_exp , from, tmp1, to, tmp2, tmp3, tmp4, tmp5)); }2228void pow (LIR_Opr arg1, LIR_Opr arg2, LIR_Opr res, LIR_Opr tmp1, LIR_Opr tmp2, LIR_Opr tmp3, LIR_Opr tmp4, LIR_Opr tmp5) { append(new LIR_Op2(lir_pow, arg1, arg2, res, tmp1, tmp2, tmp3, tmp4, tmp5)); }22292230void add (LIR_Opr left, LIR_Opr right, LIR_Opr res) { append(new LIR_Op2(lir_add, left, right, res)); }2231void sub (LIR_Opr left, LIR_Opr right, LIR_Opr res, CodeEmitInfo* info = NULL) { append(new LIR_Op2(lir_sub, left, right, res, info)); }2232void mul (LIR_Opr left, LIR_Opr right, LIR_Opr res) { append(new LIR_Op2(lir_mul, left, right, res)); }2233void mul_strictfp (LIR_Opr left, LIR_Opr right, LIR_Opr res, LIR_Opr tmp) { append(new LIR_Op2(lir_mul_strictfp, left, right, res, tmp)); }2234void div (LIR_Opr left, LIR_Opr right, LIR_Opr res, CodeEmitInfo* info = NULL) { append(new LIR_Op2(lir_div, left, right, res, info)); }2235void div_strictfp (LIR_Opr left, LIR_Opr right, LIR_Opr res, LIR_Opr tmp) { append(new LIR_Op2(lir_div_strictfp, left, right, res, tmp)); }2236void rem (LIR_Opr left, LIR_Opr right, LIR_Opr res, CodeEmitInfo* info = NULL) { append(new LIR_Op2(lir_rem, left, right, res, info)); }22372238void volatile_load_mem_reg(LIR_Address* address, LIR_Opr dst, CodeEmitInfo* info, LIR_PatchCode patch_code = lir_patch_none);2239void volatile_load_unsafe_reg(LIR_Opr base, LIR_Opr offset, LIR_Opr dst, BasicType type, CodeEmitInfo* info, LIR_PatchCode patch_code);22402241void load(LIR_Address* addr, LIR_Opr src, CodeEmitInfo* info = NULL, LIR_PatchCode patch_code = lir_patch_none);22422243void prefetch(LIR_Address* addr, bool is_store);22442245void store_mem_int(jint v, LIR_Opr base, int offset_in_bytes, BasicType type, CodeEmitInfo* info, LIR_PatchCode patch_code = lir_patch_none);2246void store_mem_oop(jobject o, LIR_Opr base, int offset_in_bytes, BasicType type, CodeEmitInfo* info, LIR_PatchCode patch_code = lir_patch_none);2247void store(LIR_Opr src, LIR_Address* addr, CodeEmitInfo* info = NULL, LIR_PatchCode patch_code = lir_patch_none);2248void volatile_store_mem_reg(LIR_Opr src, LIR_Address* address, CodeEmitInfo* info, LIR_PatchCode patch_code = lir_patch_none);2249void volatile_store_unsafe_reg(LIR_Opr src, LIR_Opr base, LIR_Opr offset, BasicType type, CodeEmitInfo* info, LIR_PatchCode patch_code);22502251void idiv(LIR_Opr left, LIR_Opr right, LIR_Opr res, LIR_Opr tmp, CodeEmitInfo* info);2252void idiv(LIR_Opr left, int right, LIR_Opr res, LIR_Opr tmp, CodeEmitInfo* info);2253void irem(LIR_Opr left, LIR_Opr right, LIR_Opr res, LIR_Opr tmp, CodeEmitInfo* info);2254void irem(LIR_Opr left, int right, LIR_Opr res, LIR_Opr tmp, CodeEmitInfo* info);22552256void allocate_object(LIR_Opr dst, LIR_Opr t1, LIR_Opr t2, LIR_Opr t3, LIR_Opr t4, int header_size, int object_size, LIR_Opr klass, bool init_check, CodeStub* stub);2257void 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);22582259// jump is an unconditional branch2260void jump(BlockBegin* block) {2261append(new LIR_OpBranch(lir_cond_always, T_ILLEGAL, block));2262}2263void jump(CodeStub* stub) {2264append(new LIR_OpBranch(lir_cond_always, T_ILLEGAL, stub));2265}2266void branch(LIR_Condition cond, BasicType type, Label* lbl) { append(new LIR_OpBranch(cond, type, lbl)); }2267void branch(LIR_Condition cond, BasicType type, BlockBegin* block) {2268assert(type != T_FLOAT && type != T_DOUBLE, "no fp comparisons");2269append(new LIR_OpBranch(cond, type, block));2270}2271void branch(LIR_Condition cond, BasicType type, CodeStub* stub) {2272assert(type != T_FLOAT && type != T_DOUBLE, "no fp comparisons");2273append(new LIR_OpBranch(cond, type, stub));2274}2275void branch(LIR_Condition cond, BasicType type, BlockBegin* block, BlockBegin* unordered) {2276assert(type == T_FLOAT || type == T_DOUBLE, "fp comparisons only");2277append(new LIR_OpBranch(cond, type, block, unordered));2278}22792280void shift_left(LIR_Opr value, LIR_Opr count, LIR_Opr dst, LIR_Opr tmp);2281void shift_right(LIR_Opr value, LIR_Opr count, LIR_Opr dst, LIR_Opr tmp);2282void unsigned_shift_right(LIR_Opr value, LIR_Opr count, LIR_Opr dst, LIR_Opr tmp);22832284void shift_left(LIR_Opr value, int count, LIR_Opr dst) { shift_left(value, LIR_OprFact::intConst(count), dst, LIR_OprFact::illegalOpr); }2285void shift_right(LIR_Opr value, int count, LIR_Opr dst) { shift_right(value, LIR_OprFact::intConst(count), dst, LIR_OprFact::illegalOpr); }2286void unsigned_shift_right(LIR_Opr value, int count, LIR_Opr dst) { unsigned_shift_right(value, LIR_OprFact::intConst(count), dst, LIR_OprFact::illegalOpr); }22872288void lcmp2int(LIR_Opr left, LIR_Opr right, LIR_Opr dst) { append(new LIR_Op2(lir_cmp_l2i, left, right, dst)); }2289void fcmp2int(LIR_Opr left, LIR_Opr right, LIR_Opr dst, bool is_unordered_less);22902291void call_runtime_leaf(address routine, LIR_Opr tmp, LIR_Opr result, LIR_OprList* arguments) {2292append(new LIR_OpRTCall(routine, tmp, result, arguments));2293}22942295void call_runtime(address routine, LIR_Opr tmp, LIR_Opr result,2296LIR_OprList* arguments, CodeEmitInfo* info) {2297append(new LIR_OpRTCall(routine, tmp, result, arguments, info));2298}22992300void load_stack_address_monitor(int monitor_ix, LIR_Opr dst) { append(new LIR_Op1(lir_monaddr, LIR_OprFact::intConst(monitor_ix), dst)); }2301void unlock_object(LIR_Opr hdr, LIR_Opr obj, LIR_Opr lock, LIR_Opr scratch, CodeStub* stub);2302void lock_object(LIR_Opr hdr, LIR_Opr obj, LIR_Opr lock, LIR_Opr scratch, CodeStub* stub, CodeEmitInfo* info);23032304void set_24bit_fpu() { append(new LIR_Op0(lir_24bit_FPU )); }2305void restore_fpu() { append(new LIR_Op0(lir_reset_FPU )); }2306void breakpoint() { append(new LIR_Op0(lir_breakpoint)); }23072308void arraycopy(LIR_Opr src, LIR_Opr src_pos, LIR_Opr dst, LIR_Opr dst_pos, LIR_Opr length, LIR_Opr tmp, ciArrayKlass* expected_type, int flags, CodeEmitInfo* info) { append(new LIR_OpArrayCopy(src, src_pos, dst, dst_pos, length, tmp, expected_type, flags, info)); }23092310void update_crc32(LIR_Opr crc, LIR_Opr val, LIR_Opr res) { append(new LIR_OpUpdateCRC32(crc, val, res)); }23112312void fpop_raw() { append(new LIR_Op0(lir_fpop_raw)); }23132314void 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);2315void store_check(LIR_Opr object, LIR_Opr array, LIR_Opr tmp1, LIR_Opr tmp2, LIR_Opr tmp3, CodeEmitInfo* info_for_exception, ciMethod* profiled_method, int profiled_bci);23162317void checkcast (LIR_Opr result, LIR_Opr object, ciKlass* klass,2318LIR_Opr tmp1, LIR_Opr tmp2, LIR_Opr tmp3, bool fast_check,2319CodeEmitInfo* info_for_exception, CodeEmitInfo* info_for_patch, CodeStub* stub,2320ciMethod* profiled_method, int profiled_bci);2321// MethodData* profiling2322void profile_call(ciMethod* method, int bci, ciMethod* callee, LIR_Opr mdo, LIR_Opr recv, LIR_Opr t1, ciKlass* cha_klass) {2323append(new LIR_OpProfileCall(method, bci, callee, mdo, recv, t1, cha_klass));2324}2325void profile_type(LIR_Address* mdp, LIR_Opr obj, ciKlass* exact_klass, intptr_t current_klass, LIR_Opr tmp, bool not_null, bool no_conflict) {2326append(new LIR_OpProfileType(LIR_OprFact::address(mdp), obj, exact_klass, current_klass, tmp, not_null, no_conflict));2327}23282329void xadd(LIR_Opr src, LIR_Opr add, LIR_Opr res, LIR_Opr tmp) { append(new LIR_Op2(lir_xadd, src, add, res, tmp)); }2330void xchg(LIR_Opr src, LIR_Opr set, LIR_Opr res, LIR_Opr tmp) { append(new LIR_Op2(lir_xchg, src, set, res, tmp)); }2331#ifdef ASSERT2332void lir_assert(LIR_Condition condition, LIR_Opr opr1, LIR_Opr opr2, const char* msg, bool halt) { append(new LIR_OpAssert(condition, opr1, opr2, msg, halt)); }2333#endif2334};23352336void print_LIR(BlockList* blocks);23372338class LIR_InsertionBuffer : public CompilationResourceObj {2339private:2340LIR_List* _lir; // the lir list where ops of this buffer should be inserted later (NULL when uninitialized)23412342// list of insertion points. index and count are stored alternately:2343// _index_and_count[i * 2]: the index into lir list where "count" ops should be inserted2344// _index_and_count[i * 2 + 1]: the number of ops to be inserted at index2345intStack _index_and_count;23462347// the LIR_Ops to be inserted2348LIR_OpList _ops;23492350void append_new(int index, int count) { _index_and_count.append(index); _index_and_count.append(count); }2351void set_index_at(int i, int value) { _index_and_count.at_put((i << 1), value); }2352void set_count_at(int i, int value) { _index_and_count.at_put((i << 1) + 1, value); }23532354#ifdef ASSERT2355void verify();2356#endif2357public:2358LIR_InsertionBuffer() : _lir(NULL), _index_and_count(8), _ops(8) { }23592360// must be called before using the insertion buffer2361void init(LIR_List* lir) { assert(!initialized(), "already initialized"); _lir = lir; _index_and_count.clear(); _ops.clear(); }2362bool initialized() const { return _lir != NULL; }2363// called automatically when the buffer is appended to the LIR_List2364void finish() { _lir = NULL; }23652366// accessors2367LIR_List* lir_list() const { return _lir; }2368int number_of_insertion_points() const { return _index_and_count.length() >> 1; }2369int index_at(int i) const { return _index_and_count.at((i << 1)); }2370int count_at(int i) const { return _index_and_count.at((i << 1) + 1); }23712372int number_of_ops() const { return _ops.length(); }2373LIR_Op* op_at(int i) const { return _ops.at(i); }23742375// append an instruction to the buffer2376void append(int index, LIR_Op* op);23772378// instruction2379void move(int index, LIR_Opr src, LIR_Opr dst, CodeEmitInfo* info = NULL) { append(index, new LIR_Op1(lir_move, src, dst, dst->type(), lir_patch_none, info)); }2380};238123822383//2384// LIR_OpVisitState is used for manipulating LIR_Ops in an abstract way.2385// Calling a LIR_Op's visit function with a LIR_OpVisitState causes2386// information about the input, output and temporaries used by the2387// op to be recorded. It also records whether the op has call semantics2388// and also records all the CodeEmitInfos used by this op.2389//239023912392class LIR_OpVisitState: public StackObj {2393public:2394typedef enum { inputMode, firstMode = inputMode, tempMode, outputMode, numModes, invalidMode = -1 } OprMode;23952396enum {2397maxNumberOfOperands = 20,2398maxNumberOfInfos = 42399};24002401private:2402LIR_Op* _op;24032404// optimization: the operands and infos are not stored in a variable-length2405// list, but in a fixed-size array to save time of size checks and resizing2406int _oprs_len[numModes];2407LIR_Opr* _oprs_new[numModes][maxNumberOfOperands];2408int _info_len;2409CodeEmitInfo* _info_new[maxNumberOfInfos];24102411bool _has_call;2412bool _has_slow_case;241324142415// only include register operands2416// addresses are decomposed to the base and index registers2417// constants and stack operands are ignored2418void append(LIR_Opr& opr, OprMode mode) {2419assert(opr->is_valid(), "should not call this otherwise");2420assert(mode >= 0 && mode < numModes, "bad mode");24212422if (opr->is_register()) {2423assert(_oprs_len[mode] < maxNumberOfOperands, "array overflow");2424_oprs_new[mode][_oprs_len[mode]++] = &opr;24252426} else if (opr->is_pointer()) {2427LIR_Address* address = opr->as_address_ptr();2428if (address != NULL) {2429// special handling for addresses: add base and index register of the address2430// both are always input operands or temp if we want to extend2431// their liveness!2432if (mode == outputMode) {2433mode = inputMode;2434}2435assert (mode == inputMode || mode == tempMode, "input or temp only for addresses");2436if (address->_base->is_valid()) {2437assert(address->_base->is_register(), "must be");2438assert(_oprs_len[mode] < maxNumberOfOperands, "array overflow");2439_oprs_new[mode][_oprs_len[mode]++] = &address->_base;2440}2441if (address->_index->is_valid()) {2442assert(address->_index->is_register(), "must be");2443assert(_oprs_len[mode] < maxNumberOfOperands, "array overflow");2444_oprs_new[mode][_oprs_len[mode]++] = &address->_index;2445}24462447} else {2448assert(opr->is_constant(), "constant operands are not processed");2449}2450} else {2451assert(opr->is_stack(), "stack operands are not processed");2452}2453}24542455void append(CodeEmitInfo* info) {2456assert(info != NULL, "should not call this otherwise");2457assert(_info_len < maxNumberOfInfos, "array overflow");2458_info_new[_info_len++] = info;2459}24602461public:2462LIR_OpVisitState() { reset(); }24632464LIR_Op* op() const { return _op; }2465void set_op(LIR_Op* op) { reset(); _op = op; }24662467bool has_call() const { return _has_call; }2468bool has_slow_case() const { return _has_slow_case; }24692470void reset() {2471_op = NULL;2472_has_call = false;2473_has_slow_case = false;24742475_oprs_len[inputMode] = 0;2476_oprs_len[tempMode] = 0;2477_oprs_len[outputMode] = 0;2478_info_len = 0;2479}248024812482int opr_count(OprMode mode) const {2483assert(mode >= 0 && mode < numModes, "bad mode");2484return _oprs_len[mode];2485}24862487LIR_Opr opr_at(OprMode mode, int index) const {2488assert(mode >= 0 && mode < numModes, "bad mode");2489assert(index >= 0 && index < _oprs_len[mode], "index out of bound");2490return *_oprs_new[mode][index];2491}24922493void set_opr_at(OprMode mode, int index, LIR_Opr opr) const {2494assert(mode >= 0 && mode < numModes, "bad mode");2495assert(index >= 0 && index < _oprs_len[mode], "index out of bound");2496*_oprs_new[mode][index] = opr;2497}24982499int info_count() const {2500return _info_len;2501}25022503CodeEmitInfo* info_at(int index) const {2504assert(index < _info_len, "index out of bounds");2505return _info_new[index];2506}25072508XHandlers* all_xhandler();25092510// collects all register operands of the instruction2511void visit(LIR_Op* op);25122513#ifdef ASSERT2514// check that an operation has no operands2515bool no_operands(LIR_Op* op);2516#endif25172518// LIR_Op visitor functions use these to fill in the state2519void do_input(LIR_Opr& opr) { append(opr, LIR_OpVisitState::inputMode); }2520void do_output(LIR_Opr& opr) { append(opr, LIR_OpVisitState::outputMode); }2521void do_temp(LIR_Opr& opr) { append(opr, LIR_OpVisitState::tempMode); }2522void do_info(CodeEmitInfo* info) { append(info); }25232524void do_stub(CodeStub* stub);2525void do_call() { _has_call = true; }2526void do_slow_case() { _has_slow_case = true; }2527void do_slow_case(CodeEmitInfo* info) {2528_has_slow_case = true;2529append(info);2530}2531};253225332534inline LIR_Opr LIR_OprDesc::illegalOpr() { return LIR_OprFact::illegalOpr; };25352536#endif // SHARE_VM_C1_C1_LIR_HPP253725382539