src/share/vm/c1/c1_LIRGenerator.hpp

Tue, 17 Oct 2017 12:58:25 +0800

author
aoqi
date
Tue, 17 Oct 2017 12:58:25 +0800
changeset 7994
04ff2f6cd0eb
parent 7598
ddce0b7cee93
parent 7535
7ae4e26cb1e0
child 8604
04d83ba48607
permissions
-rw-r--r--

merge

     1 /*
     2  * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     8  *
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
    10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    12  * version 2 for more details (a copy is included in the LICENSE file that
    13  * accompanied this code).
    14  *
    15  * You should have received a copy of the GNU General Public License version
    16  * 2 along with this work; if not, write to the Free Software Foundation,
    17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    18  *
    19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    20  * or visit www.oracle.com if you need additional information or have any
    21  * questions.
    22  *
    23  */
    25 /*
    26  * This file has been modified by Loongson Technology in 2015. These
    27  * modifications are Copyright (c) 2015 Loongson Technology, and are made
    28  * available on the same license terms set forth above.
    29  */
    31 #ifndef SHARE_VM_C1_C1_LIRGENERATOR_HPP
    32 #define SHARE_VM_C1_C1_LIRGENERATOR_HPP
    34 #include "c1/c1_Instruction.hpp"
    35 #include "c1/c1_LIR.hpp"
    36 #include "ci/ciMethodData.hpp"
    37 #include "utilities/sizes.hpp"
    39 // The classes responsible for code emission and register allocation
    42 class LIRGenerator;
    43 class LIREmitter;
    44 class Invoke;
    45 class SwitchRange;
    46 class LIRItem;
    48 define_array(LIRItemArray, LIRItem*)
    49 define_stack(LIRItemList, LIRItemArray)
    51 class SwitchRange: public CompilationResourceObj {
    52  private:
    53   int _low_key;
    54   int _high_key;
    55   BlockBegin* _sux;
    56  public:
    57   SwitchRange(int start_key, BlockBegin* sux): _low_key(start_key), _high_key(start_key), _sux(sux) {}
    58   void set_high_key(int key) { _high_key = key; }
    60   int high_key() const { return _high_key; }
    61   int low_key() const { return _low_key; }
    62   BlockBegin* sux() const { return _sux; }
    63 };
    65 define_array(SwitchRangeArray, SwitchRange*)
    66 define_stack(SwitchRangeList, SwitchRangeArray)
    69 class ResolveNode;
    71 define_array(NodeArray, ResolveNode*);
    72 define_stack(NodeList, NodeArray);
    75 // Node objects form a directed graph of LIR_Opr
    76 // Edges between Nodes represent moves from one Node to its destinations
    77 class ResolveNode: public CompilationResourceObj {
    78  private:
    79   LIR_Opr    _operand;       // the source or destinaton
    80   NodeList   _destinations;  // for the operand
    81   bool       _assigned;      // Value assigned to this Node?
    82   bool       _visited;       // Node already visited?
    83   bool       _start_node;    // Start node already visited?
    85  public:
    86   ResolveNode(LIR_Opr operand)
    87     : _operand(operand)
    88     , _assigned(false)
    89     , _visited(false)
    90     , _start_node(false) {};
    92   // accessors
    93   LIR_Opr operand() const           { return _operand; }
    94   int no_of_destinations() const    { return _destinations.length(); }
    95   ResolveNode* destination_at(int i)     { return _destinations[i]; }
    96   bool assigned() const             { return _assigned; }
    97   bool visited() const              { return _visited; }
    98   bool start_node() const           { return _start_node; }
   100   // modifiers
   101   void append(ResolveNode* dest)         { _destinations.append(dest); }
   102   void set_assigned()               { _assigned = true; }
   103   void set_visited()                { _visited = true; }
   104   void set_start_node()             { _start_node = true; }
   105 };
   108 // This is shared state to be used by the PhiResolver so the operand
   109 // arrays don't have to be reallocated for reach resolution.
   110 class PhiResolverState: public CompilationResourceObj {
   111   friend class PhiResolver;
   113  private:
   114   NodeList _virtual_operands; // Nodes where the operand is a virtual register
   115   NodeList _other_operands;   // Nodes where the operand is not a virtual register
   116   NodeList _vreg_table;       // Mapping from virtual register to Node
   118  public:
   119   PhiResolverState() {}
   121   void reset(int max_vregs);
   122 };
   125 // class used to move value of phi operand to phi function
   126 class PhiResolver: public CompilationResourceObj {
   127  private:
   128   LIRGenerator*     _gen;
   129   PhiResolverState& _state; // temporary state cached by LIRGenerator
   131   ResolveNode*   _loop;
   132   LIR_Opr _temp;
   134   // access to shared state arrays
   135   NodeList& virtual_operands() { return _state._virtual_operands; }
   136   NodeList& other_operands()   { return _state._other_operands;   }
   137   NodeList& vreg_table()       { return _state._vreg_table;       }
   139   ResolveNode* create_node(LIR_Opr opr, bool source);
   140   ResolveNode* source_node(LIR_Opr opr)      { return create_node(opr, true); }
   141   ResolveNode* destination_node(LIR_Opr opr) { return create_node(opr, false); }
   143   void emit_move(LIR_Opr src, LIR_Opr dest);
   144   void move_to_temp(LIR_Opr src);
   145   void move_temp_to(LIR_Opr dest);
   146   void move(ResolveNode* src, ResolveNode* dest);
   148   LIRGenerator* gen() {
   149     return _gen;
   150   }
   152  public:
   153   PhiResolver(LIRGenerator* _lir_gen, int max_vregs);
   154   ~PhiResolver();
   156   void move(LIR_Opr src, LIR_Opr dest);
   157 };
   160 // only the classes below belong in the same file
   161 class LIRGenerator: public InstructionVisitor, public BlockClosure {
   163  private:
   164   Compilation*  _compilation;
   165   ciMethod*     _method;    // method that we are compiling
   166   PhiResolverState  _resolver_state;
   167   BlockBegin*   _block;
   168   int           _virtual_register_number;
   169   Values        _instruction_for_operand;
   170   BitMap2D      _vreg_flags; // flags which can be set on a per-vreg basis
   171   LIR_List*     _lir;
   172   BarrierSet*   _bs;
   174   LIRGenerator* gen() {
   175     return this;
   176   }
   178   void print_if_not_loaded(const NewInstance* new_instance) PRODUCT_RETURN;
   180 #ifdef ASSERT
   181   LIR_List* lir(const char * file, int line) const {
   182     _lir->set_file_and_line(file, line);
   183     return _lir;
   184   }
   185 #endif
   186   LIR_List* lir() const {
   187     return _lir;
   188   }
   190   // a simple cache of constants used within a block
   191   GrowableArray<LIR_Const*>       _constants;
   192   LIR_OprList                     _reg_for_constants;
   193   Values                          _unpinned_constants;
   195 #ifdef MIPS64
   196   LIR_Const*                      _card_table_base;
   197 #endif
   198   friend class PhiResolver;
   200   // unified bailout support
   201   void bailout(const char* msg) const            { compilation()->bailout(msg); }
   202   bool bailed_out() const                        { return compilation()->bailed_out(); }
   204   void block_do_prolog(BlockBegin* block);
   205   void block_do_epilog(BlockBegin* block);
   207   // register allocation
   208   LIR_Opr rlock(Value instr);                      // lock a free register
   209   LIR_Opr rlock_result(Value instr);
   210   LIR_Opr rlock_result(Value instr, BasicType type);
   211   LIR_Opr rlock_byte(BasicType type);
   212   LIR_Opr rlock_callee_saved(BasicType type);
   214   // get a constant into a register and get track of what register was used
   215   LIR_Opr load_constant(Constant* x);
   216   LIR_Opr load_constant(LIR_Const* constant);
   218 #ifdef MIPS64
   219   LIR_Const* card_table_base() const {
   220      return _card_table_base;
   221   }
   222 #endif
   223   // Given an immediate value, return an operand usable in logical ops.
   224   LIR_Opr load_immediate(int x, BasicType type);
   226   void  set_result(Value x, LIR_Opr opr)           {
   227     assert(opr->is_valid(), "must set to valid value");
   228     assert(x->operand()->is_illegal(), "operand should never change");
   229     assert(!opr->is_register() || opr->is_virtual(), "should never set result to a physical register");
   230     x->set_operand(opr);
   231     assert(opr == x->operand(), "must be");
   232     if (opr->is_virtual()) {
   233       _instruction_for_operand.at_put_grow(opr->vreg_number(), x, NULL);
   234     }
   235   }
   236   void  set_no_result(Value x)                     { assert(!x->has_uses(), "can't have use"); x->clear_operand(); }
   238   friend class LIRItem;
   240   LIR_Opr round_item(LIR_Opr opr);
   241   LIR_Opr force_to_spill(LIR_Opr value, BasicType t);
   243 #ifdef MIPS64
   244   void profile_branch(If* if_instr, If::Condition cond, LIR_Opr left, LIR_Opr right);
   245 #endif
   246   PhiResolverState& resolver_state() { return _resolver_state; }
   248   void  move_to_phi(PhiResolver* resolver, Value cur_val, Value sux_val);
   249   void  move_to_phi(ValueStack* cur_state);
   251   // code emission
   252   void do_ArithmeticOp_Long   (ArithmeticOp*    x);
   253   void do_ArithmeticOp_Int    (ArithmeticOp*    x);
   254   void do_ArithmeticOp_FPU    (ArithmeticOp*    x);
   256   // platform dependent
   257   LIR_Opr getThreadPointer();
   259   void do_RegisterFinalizer(Intrinsic* x);
   260   void do_isInstance(Intrinsic* x);
   261   void do_getClass(Intrinsic* x);
   262   void do_currentThread(Intrinsic* x);
   263   void do_MathIntrinsic(Intrinsic* x);
   264   void do_ArrayCopy(Intrinsic* x);
   265   void do_CompareAndSwap(Intrinsic* x, ValueType* type);
   266   void do_NIOCheckIndex(Intrinsic* x);
   267   void do_FPIntrinsics(Intrinsic* x);
   268   void do_Reference_get(Intrinsic* x);
   269   void do_update_CRC32(Intrinsic* x);
   271   void do_UnsafePrefetch(UnsafePrefetch* x, bool is_store);
   273   LIR_Opr call_runtime(BasicTypeArray* signature, LIRItemList* args, address entry, ValueType* result_type, CodeEmitInfo* info);
   274   LIR_Opr call_runtime(BasicTypeArray* signature, LIR_OprList* args, address entry, ValueType* result_type, CodeEmitInfo* info);
   276   // convenience functions
   277   LIR_Opr call_runtime(Value arg1, address entry, ValueType* result_type, CodeEmitInfo* info);
   278   LIR_Opr call_runtime(Value arg1, Value arg2, address entry, ValueType* result_type, CodeEmitInfo* info);
   280   // GC Barriers
   282   // generic interface
   284   void pre_barrier(LIR_Opr addr_opr, LIR_Opr pre_val, bool do_load, bool patch, CodeEmitInfo* info);
   285   void post_barrier(LIR_OprDesc* addr, LIR_OprDesc* new_val);
   287   // specific implementations
   288   // pre barriers
   290   void G1SATBCardTableModRef_pre_barrier(LIR_Opr addr_opr, LIR_Opr pre_val,
   291                                          bool do_load, bool patch, CodeEmitInfo* info);
   293   // post barriers
   295   void G1SATBCardTableModRef_post_barrier(LIR_OprDesc* addr, LIR_OprDesc* new_val);
   296   void CardTableModRef_post_barrier(LIR_OprDesc* addr, LIR_OprDesc* new_val);
   297 #ifdef CARDTABLEMODREF_POST_BARRIER_HELPER
   298   void CardTableModRef_post_barrier_helper(LIR_OprDesc* addr, LIR_Const* card_table_base);
   299 #endif
   302   static LIR_Opr result_register_for(ValueType* type, bool callee = false);
   304   ciObject* get_jobject_constant(Value value);
   306   LIRItemList* invoke_visit_arguments(Invoke* x);
   307   void invoke_load_arguments(Invoke* x, LIRItemList* args, const LIR_OprList* arg_list);
   309   void trace_block_entry(BlockBegin* block);
   311   // volatile field operations are never patchable because a klass
   312   // must be loaded to know it's volatile which means that the offset
   313   // it always known as well.
   314   void volatile_field_store(LIR_Opr value, LIR_Address* address, CodeEmitInfo* info);
   315   void volatile_field_load(LIR_Address* address, LIR_Opr result, CodeEmitInfo* info);
   317   void put_Object_unsafe(LIR_Opr src, LIR_Opr offset, LIR_Opr data, BasicType type, bool is_volatile);
   318   void get_Object_unsafe(LIR_Opr dest, LIR_Opr src, LIR_Opr offset, BasicType type, bool is_volatile);
   320   void arithmetic_call_op (Bytecodes::Code code, LIR_Opr result, LIR_OprList* args);
   322   void increment_counter(address counter, BasicType type, int step = 1);
   323   void increment_counter(LIR_Address* addr, int step = 1);
   325   // is_strictfp is only needed for mul and div (and only generates different code on i486)
   326   void arithmetic_op(Bytecodes::Code code, LIR_Opr result, LIR_Opr left, LIR_Opr right, bool is_strictfp, LIR_Opr tmp, CodeEmitInfo* info = NULL);
   327   // machine dependent.  returns true if it emitted code for the multiply
   328   bool strength_reduce_multiply(LIR_Opr left, int constant, LIR_Opr result, LIR_Opr tmp);
   330   void store_stack_parameter (LIR_Opr opr, ByteSize offset_from_sp_in_bytes);
   332   void klass2reg_with_patching(LIR_Opr r, ciMetadata* obj, CodeEmitInfo* info, bool need_resolve = false);
   334   // this loads the length and compares against the index
   335   void array_range_check          (LIR_Opr array, LIR_Opr index, CodeEmitInfo* null_check_info, CodeEmitInfo* range_check_info);
   336   // For java.nio.Buffer.checkIndex
   337   void nio_range_check            (LIR_Opr buffer, LIR_Opr index, LIR_Opr result, CodeEmitInfo* info);
   339   void arithmetic_op_int  (Bytecodes::Code code, LIR_Opr result, LIR_Opr left, LIR_Opr right, LIR_Opr tmp);
   340   void arithmetic_op_long (Bytecodes::Code code, LIR_Opr result, LIR_Opr left, LIR_Opr right, CodeEmitInfo* info = NULL);
   341   void arithmetic_op_fpu  (Bytecodes::Code code, LIR_Opr result, LIR_Opr left, LIR_Opr right, bool is_strictfp, LIR_Opr tmp = LIR_OprFact::illegalOpr);
   343   void shift_op   (Bytecodes::Code code, LIR_Opr dst_reg, LIR_Opr value, LIR_Opr count, LIR_Opr tmp);
   345   void logic_op   (Bytecodes::Code code, LIR_Opr dst_reg, LIR_Opr left, LIR_Opr right);
   347   void monitor_enter (LIR_Opr object, LIR_Opr lock, LIR_Opr hdr, LIR_Opr scratch, int monitor_no, CodeEmitInfo* info_for_exception, CodeEmitInfo* info);
   348   void monitor_exit  (LIR_Opr object, LIR_Opr lock, LIR_Opr hdr, LIR_Opr scratch, int monitor_no);
   350 #ifndef MIPS64
   351   void new_instance    (LIR_Opr  dst, ciInstanceKlass* klass, bool is_unresolved, LIR_Opr  scratch1, LIR_Opr  scratch2, LIR_Opr  scratch3,  LIR_Opr scratch4, LIR_Opr  klass_reg, CodeEmitInfo* info);
   352 #else
   353   void new_instance    (LIR_Opr  dst, ciInstanceKlass* klass, LIR_Opr  scratch1, LIR_Opr  scratch2, LIR_Opr  scratch3,  LIR_Opr scratch4, LIR_Opr  scratch5, LIR_Opr scratch6, LIR_Opr klass_reg, CodeEmitInfo* info);
   354 #endif
   356   // machine dependent
   357   void cmp_mem_int(LIR_Condition condition, LIR_Opr base, int disp, int c, CodeEmitInfo* info);
   358   void cmp_reg_mem(LIR_Condition condition, LIR_Opr reg, LIR_Opr base, int disp, BasicType type, CodeEmitInfo* info);
   359   void cmp_reg_mem(LIR_Condition condition, LIR_Opr reg, LIR_Opr base, LIR_Opr disp, BasicType type, CodeEmitInfo* info);
   361   void arraycopy_helper(Intrinsic* x, int* flags, ciArrayKlass** expected_type);
   363   // returns a LIR_Address to address an array location.  May also
   364   // emit some code as part of address calculation.  If
   365   // needs_card_mark is true then compute the full address for use by
   366   // both the store and the card mark.
   367   LIR_Address* generate_address(LIR_Opr base,
   368                                 LIR_Opr index, int shift,
   369                                 int disp,
   370                                 BasicType type);
   371   LIR_Address* generate_address(LIR_Opr base, int disp, BasicType type) {
   372     return generate_address(base, LIR_OprFact::illegalOpr, 0, disp, type);
   373   }
   374   LIR_Address* emit_array_address(LIR_Opr array_opr, LIR_Opr index_opr, BasicType type, bool needs_card_mark);
   376 #ifdef MIPS64
   377   void write_barrier(LIR_Opr addr);
   378 #endif
   379   // the helper for generate_address
   380   void add_large_constant(LIR_Opr src, int c, LIR_Opr dest);
   382   // machine preferences and characteristics
   383   bool can_inline_as_constant(Value i) const;
   384   bool can_inline_as_constant(LIR_Const* c) const;
   385   bool can_store_as_constant(Value i, BasicType type) const;
   387   LIR_Opr safepoint_poll_register();
   389   void profile_branch(If* if_instr, If::Condition cond);
   390   void increment_event_counter_impl(CodeEmitInfo* info,
   391                                     ciMethod *method, int frequency,
   392                                     int bci, bool backedge, bool notify);
   393   void increment_event_counter(CodeEmitInfo* info, int bci, bool backedge);
   394   void increment_invocation_counter(CodeEmitInfo *info) {
   395     if (compilation()->count_invocations()) {
   396       increment_event_counter(info, InvocationEntryBci, false);
   397     }
   398   }
   399   void increment_backedge_counter(CodeEmitInfo* info, int bci) {
   400     if (compilation()->count_backedges()) {
   401       increment_event_counter(info, bci, true);
   402     }
   403   }
   405   CodeEmitInfo* state_for(Instruction* x, ValueStack* state, bool ignore_xhandler = false);
   406   CodeEmitInfo* state_for(Instruction* x);
   408   // allocates a virtual register for this instruction if
   409   // one isn't already allocated.  Only for Phi and Local.
   410   LIR_Opr operand_for_instruction(Instruction *x);
   412   void set_block(BlockBegin* block)              { _block = block; }
   414   void block_prolog(BlockBegin* block);
   415   void block_epilog(BlockBegin* block);
   417   void do_root (Instruction* instr);
   418   void walk    (Instruction* instr);
   420   void bind_block_entry(BlockBegin* block);
   421   void start_block(BlockBegin* block);
   423   LIR_Opr new_register(BasicType type);
   424   LIR_Opr new_register(Value value)              { return new_register(as_BasicType(value->type())); }
   425   LIR_Opr new_register(ValueType* type)          { return new_register(as_BasicType(type)); }
   427   // returns a register suitable for doing pointer math
   428   LIR_Opr new_pointer_register() {
   429 #ifdef _LP64
   430     return new_register(T_LONG);
   431 #else
   432     return new_register(T_INT);
   433 #endif
   434   }
   436   static LIR_Condition lir_cond(If::Condition cond) {
   437     LIR_Condition l;
   438     switch (cond) {
   439     case If::eql: l = lir_cond_equal;        break;
   440     case If::neq: l = lir_cond_notEqual;     break;
   441     case If::lss: l = lir_cond_less;         break;
   442     case If::leq: l = lir_cond_lessEqual;    break;
   443     case If::geq: l = lir_cond_greaterEqual; break;
   444     case If::gtr: l = lir_cond_greater;      break;
   445     case If::aeq: l = lir_cond_aboveEqual;   break;
   446     case If::beq: l = lir_cond_belowEqual;   break;
   447     };
   448     return l;
   449   }
   451 #ifdef __SOFTFP__
   452   void do_soft_float_compare(If *x);
   453 #endif // __SOFTFP__
   455   void init();
   457   SwitchRangeArray* create_lookup_ranges(TableSwitch* x);
   458   SwitchRangeArray* create_lookup_ranges(LookupSwitch* x);
   459   void do_SwitchRanges(SwitchRangeArray* x, LIR_Opr value, BlockBegin* default_sux);
   461   void do_RuntimeCall(address routine, int expected_arguments, Intrinsic* x);
   462 #ifdef TRACE_HAVE_INTRINSICS
   463   void do_ThreadIDIntrinsic(Intrinsic* x);
   464   void do_ClassIDIntrinsic(Intrinsic* x);
   465 #endif
   466   ciKlass* profile_type(ciMethodData* md, int md_first_offset, int md_offset, intptr_t profiled_k,
   467                         Value arg, LIR_Opr& mdp, bool not_null, ciKlass* signature_at_call_k,
   468                         ciKlass* callee_signature_k);
   469   void profile_arguments(ProfileCall* x);
   470   void profile_parameters(Base* x);
   471   void profile_parameters_at_call(ProfileCall* x);
   473  public:
   474   Compilation*  compilation() const              { return _compilation; }
   475   FrameMap*     frame_map() const                { return _compilation->frame_map(); }
   476   ciMethod*     method() const                   { return _method; }
   477   BlockBegin*   block() const                    { return _block; }
   478   IRScope*      scope() const                    { return block()->scope(); }
   480   int max_virtual_register_number() const        { return _virtual_register_number; }
   482   void block_do(BlockBegin* block);
   484   // Flags that can be set on vregs
   485   enum VregFlag {
   486       must_start_in_memory = 0  // needs to be assigned a memory location at beginning, but may then be loaded in a register
   487     , callee_saved     = 1    // must be in a callee saved register
   488     , byte_reg         = 2    // must be in a byte register
   489     , num_vreg_flags
   491   };
   493   LIRGenerator(Compilation* compilation, ciMethod* method)
   494     : _compilation(compilation)
   495     , _method(method)
   496     , _virtual_register_number(LIR_OprDesc::vreg_base)
   497     , _vreg_flags(NULL, 0, num_vreg_flags) {
   498     init();
   499   }
   501   // for virtual registers, maps them back to Phi's or Local's
   502   Instruction* instruction_for_opr(LIR_Opr opr);
   503   Instruction* instruction_for_vreg(int reg_num);
   505   void set_vreg_flag   (int vreg_num, VregFlag f);
   506   bool is_vreg_flag_set(int vreg_num, VregFlag f);
   507   void set_vreg_flag   (LIR_Opr opr,  VregFlag f) { set_vreg_flag(opr->vreg_number(), f); }
   508   bool is_vreg_flag_set(LIR_Opr opr,  VregFlag f) { return is_vreg_flag_set(opr->vreg_number(), f); }
   510   // statics
   511   static LIR_Opr exceptionOopOpr();
   512   static LIR_Opr exceptionPcOpr();
   513   static LIR_Opr divInOpr();
   514   static LIR_Opr divOutOpr();
   515   static LIR_Opr remOutOpr();
   516   static LIR_Opr shiftCountOpr();
   517   LIR_Opr syncTempOpr();
   518   LIR_Opr atomicLockOpr();
   520   // returns a register suitable for saving the thread in a
   521   // call_runtime_leaf if one is needed.
   522   LIR_Opr getThreadTemp();
   524   // visitor functionality
   525   virtual void do_Phi            (Phi*             x);
   526   virtual void do_Local          (Local*           x);
   527   virtual void do_Constant       (Constant*        x);
   528   virtual void do_LoadField      (LoadField*       x);
   529   virtual void do_StoreField     (StoreField*      x);
   530   virtual void do_ArrayLength    (ArrayLength*     x);
   531   virtual void do_LoadIndexed    (LoadIndexed*     x);
   532   virtual void do_StoreIndexed   (StoreIndexed*    x);
   533   virtual void do_NegateOp       (NegateOp*        x);
   534   virtual void do_ArithmeticOp   (ArithmeticOp*    x);
   535   virtual void do_ShiftOp        (ShiftOp*         x);
   536   virtual void do_LogicOp        (LogicOp*         x);
   537   virtual void do_CompareOp      (CompareOp*       x);
   538   virtual void do_IfOp           (IfOp*            x);
   539   virtual void do_Convert        (Convert*         x);
   540   virtual void do_NullCheck      (NullCheck*       x);
   541   virtual void do_TypeCast       (TypeCast*        x);
   542   virtual void do_Invoke         (Invoke*          x);
   543   virtual void do_NewInstance    (NewInstance*     x);
   544   virtual void do_NewTypeArray   (NewTypeArray*    x);
   545   virtual void do_NewObjectArray (NewObjectArray*  x);
   546   virtual void do_NewMultiArray  (NewMultiArray*   x);
   547   virtual void do_CheckCast      (CheckCast*       x);
   548   virtual void do_InstanceOf     (InstanceOf*      x);
   549   virtual void do_MonitorEnter   (MonitorEnter*    x);
   550   virtual void do_MonitorExit    (MonitorExit*     x);
   551   virtual void do_Intrinsic      (Intrinsic*       x);
   552   virtual void do_BlockBegin     (BlockBegin*      x);
   553   virtual void do_Goto           (Goto*            x);
   554   virtual void do_If             (If*              x);
   555   virtual void do_IfInstanceOf   (IfInstanceOf*    x);
   556   virtual void do_TableSwitch    (TableSwitch*     x);
   557   virtual void do_LookupSwitch   (LookupSwitch*    x);
   558   virtual void do_Return         (Return*          x);
   559   virtual void do_Throw          (Throw*           x);
   560   virtual void do_Base           (Base*            x);
   561   virtual void do_OsrEntry       (OsrEntry*        x);
   562   virtual void do_ExceptionObject(ExceptionObject* x);
   563   virtual void do_RoundFP        (RoundFP*         x);
   564   virtual void do_UnsafeGetRaw   (UnsafeGetRaw*    x);
   565   virtual void do_UnsafePutRaw   (UnsafePutRaw*    x);
   566   virtual void do_UnsafeGetObject(UnsafeGetObject* x);
   567   virtual void do_UnsafePutObject(UnsafePutObject* x);
   568   virtual void do_UnsafeGetAndSetObject(UnsafeGetAndSetObject* x);
   569   virtual void do_UnsafePrefetchRead (UnsafePrefetchRead*  x);
   570   virtual void do_UnsafePrefetchWrite(UnsafePrefetchWrite* x);
   571   virtual void do_ProfileCall    (ProfileCall*     x);
   572   virtual void do_ProfileReturnType (ProfileReturnType* x);
   573   virtual void do_ProfileInvoke  (ProfileInvoke*   x);
   574   virtual void do_RuntimeCall    (RuntimeCall*     x);
   575   virtual void do_MemBar         (MemBar*          x);
   576   virtual void do_RangeCheckPredicate(RangeCheckPredicate* x);
   577 #ifdef ASSERT
   578   virtual void do_Assert         (Assert*          x);
   579 #endif
   581 #ifdef C1_LIRGENERATOR_MD_HPP
   582 #include C1_LIRGENERATOR_MD_HPP
   583 #endif
   584 };
   587 class LIRItem: public CompilationResourceObj {
   588  private:
   589   Value         _value;
   590   LIRGenerator* _gen;
   591   LIR_Opr       _result;
   592   bool          _destroys_register;
   593   LIR_Opr       _new_result;
   595   LIRGenerator* gen() const { return _gen; }
   597  public:
   598   LIRItem(Value value, LIRGenerator* gen) {
   599     _destroys_register = false;
   600     _gen = gen;
   601     set_instruction(value);
   602   }
   604   LIRItem(LIRGenerator* gen) {
   605     _destroys_register = false;
   606     _gen = gen;
   607     _result = LIR_OprFact::illegalOpr;
   608     set_instruction(NULL);
   609   }
   611   void set_instruction(Value value) {
   612     _value = value;
   613     _result = LIR_OprFact::illegalOpr;
   614     if (_value != NULL) {
   615       _gen->walk(_value);
   616       _result = _value->operand();
   617     }
   618     _new_result = LIR_OprFact::illegalOpr;
   619   }
   621   Value value() const          { return _value;          }
   622   ValueType* type() const      { return value()->type(); }
   623   LIR_Opr result()             {
   624     assert(!_destroys_register || (!_result->is_register() || _result->is_virtual()),
   625            "shouldn't use set_destroys_register with physical regsiters");
   626     if (_destroys_register && _result->is_register()) {
   627       if (_new_result->is_illegal()) {
   628         _new_result = _gen->new_register(type());
   629         gen()->lir()->move(_result, _new_result);
   630       }
   631       return _new_result;
   632     } else {
   633       return _result;
   634     }
   635     return _result;
   636   }
   638   void set_result(LIR_Opr opr);
   640   void load_item();
   641   void load_byte_item();
   642   void load_nonconstant();
   643   // load any values which can't be expressed as part of a single store instruction
   644   void load_for_store(BasicType store_type);
   645   void load_item_force(LIR_Opr reg);
   647   void dont_load_item() {
   648     // do nothing
   649   }
   651   void set_destroys_register() {
   652     _destroys_register = true;
   653   }
   655   bool is_constant() const { return value()->as_Constant() != NULL; }
   656   bool is_stack()          { return result()->is_stack(); }
   657   bool is_register()       { return result()->is_register(); }
   659   ciObject* get_jobject_constant() const;
   660   jint      get_jint_constant() const;
   661   jlong     get_jlong_constant() const;
   662   jfloat    get_jfloat_constant() const;
   663   jdouble   get_jdouble_constant() const;
   664   jint      get_address_constant() const;
   665 };
   667 #endif // SHARE_VM_C1_C1_LIRGENERATOR_HPP

mercurial