< prev index next >

hotspot/src/share/vm/c1/c1_Instruction.hpp

Print this page
rev 10453 : imported patch update dates
   1 /*
   2  * Copyright (c) 1999, 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  *


  98 class   UnsafeOp;
  99 class     UnsafeRawOp;
 100 class       UnsafeGetRaw;
 101 class       UnsafePutRaw;
 102 class     UnsafeObjectOp;
 103 class       UnsafeGetObject;
 104 class       UnsafePutObject;
 105 class         UnsafeGetAndSetObject;
 106 class   ProfileCall;
 107 class   ProfileReturnType;
 108 class   ProfileInvoke;
 109 class   RuntimeCall;
 110 class   MemBar;
 111 class   RangeCheckPredicate;
 112 #ifdef ASSERT
 113 class   Assert;
 114 #endif
 115 
 116 // A Value is a reference to the instruction creating the value
 117 typedef Instruction* Value;
 118 define_array(ValueArray, Value)
 119 define_stack(Values, ValueArray)
 120 
 121 define_array(ValueStackArray, ValueStack*)
 122 define_stack(ValueStackStack, ValueStackArray)
 123 
 124 // BlockClosure is the base class for block traversal/iteration.
 125 
 126 class BlockClosure: public CompilationResourceObj {
 127  public:
 128   virtual void block_do(BlockBegin* block)       = 0;
 129 };
 130 
 131 
 132 // A simple closure class for visiting the values of an Instruction
 133 class ValueVisitor: public StackObj {
 134  public:
 135   virtual void visit(Value* v) = 0;
 136 };
 137 
 138 
 139 // Some array and list classes
 140 define_array(BlockBeginArray, BlockBegin*)
 141 define_stack(_BlockList, BlockBeginArray)
 142 
 143 class BlockList: public _BlockList {
 144  public:
 145   BlockList(): _BlockList() {}
 146   BlockList(const int size): _BlockList(size) {}
 147   BlockList(const int size, BlockBegin* init): _BlockList(size, init) {}
 148 
 149   void iterate_forward(BlockClosure* closure);
 150   void iterate_backward(BlockClosure* closure);
 151   void blocks_do(void f(BlockBegin*));
 152   void values_do(ValueVisitor* f);
 153   void print(bool cfg_only = false, bool live_only = false) PRODUCT_RETURN;
 154 };
 155 
 156 
 157 // InstructionVisitors provide type-based dispatch for instructions.
 158 // For each concrete Instruction class X, a virtual function do_X is
 159 // provided. Functionality that needs to be implemented for all classes
 160 // (e.g., printing, code generation) is factored out into a specialised
 161 // visitor instead of added to the Instruction classes itself.
 162 
 163 class InstructionVisitor: public StackObj {
 164  public:
 165   virtual void do_Phi            (Phi*             x) = 0;
 166   virtual void do_Local          (Local*           x) = 0;
 167   virtual void do_Constant       (Constant*        x) = 0;


1727   void set_fpu_stack_state(intArray* state)      { _fpu_stack_state = state;  }
1728   void set_first_lir_instruction_id(int id)      { _first_lir_instruction_id = id;  }
1729   void set_last_lir_instruction_id(int id)       { _last_lir_instruction_id = id;  }
1730   void increment_total_preds(int n = 1)          { _total_preds += n; }
1731   void init_stores_to_locals(int locals_count)   { _stores_to_locals = BitMap(locals_count); _stores_to_locals.clear(); }
1732 
1733   // generic
1734   virtual void state_values_do(ValueVisitor* f);
1735 
1736   // successors and predecessors
1737   int number_of_sux() const;
1738   BlockBegin* sux_at(int i) const;
1739   void add_successor(BlockBegin* sux);
1740   void remove_successor(BlockBegin* pred);
1741   bool is_successor(BlockBegin* sux) const       { return _successors.contains(sux); }
1742 
1743   void add_predecessor(BlockBegin* pred);
1744   void remove_predecessor(BlockBegin* pred);
1745   bool is_predecessor(BlockBegin* pred) const    { return _predecessors.contains(pred); }
1746   int number_of_preds() const                    { return _predecessors.length(); }
1747   BlockBegin* pred_at(int i) const               { return _predecessors[i]; }
1748 
1749   // exception handlers potentially invoked by this block
1750   void add_exception_handler(BlockBegin* b);
1751   bool is_exception_handler(BlockBegin* b) const { return _exception_handlers.contains(b); }
1752   int  number_of_exception_handlers() const      { return _exception_handlers.length(); }
1753   BlockBegin* exception_handler_at(int i) const  { return _exception_handlers.at(i); }
1754 
1755   // states of the instructions that have an edge to this exception handler
1756   int number_of_exception_states()               { assert(is_set(exception_entry_flag), "only for xhandlers"); return _exception_states == NULL ? 0 : _exception_states->length(); }
1757   ValueStack* exception_state_at(int idx) const  { assert(is_set(exception_entry_flag), "only for xhandlers"); return _exception_states->at(idx); }
1758   int add_exception_state(ValueStack* state);
1759 
1760   // flags
1761   enum Flag {
1762     no_flag                       = 0,
1763     std_entry_flag                = 1 << 0,
1764     osr_entry_flag                = 1 << 1,
1765     exception_entry_flag          = 1 << 2,
1766     subroutine_entry_flag         = 1 << 3,
1767     backward_branch_target_flag   = 1 << 4,


2592 
2593   LIR_Code code()           { return _code; }
2594 
2595   virtual void input_values_do(ValueVisitor*)   {}
2596 };
2597 
2598 class BlockPair: public CompilationResourceObj {
2599  private:
2600   BlockBegin* _from;
2601   BlockBegin* _to;
2602  public:
2603   BlockPair(BlockBegin* from, BlockBegin* to): _from(from), _to(to) {}
2604   BlockBegin* from() const { return _from; }
2605   BlockBegin* to() const   { return _to;   }
2606   bool is_same(BlockBegin* from, BlockBegin* to) const { return  _from == from && _to == to; }
2607   bool is_same(BlockPair* p) const { return  _from == p->from() && _to == p->to(); }
2608   void set_to(BlockBegin* b)   { _to = b; }
2609   void set_from(BlockBegin* b) { _from = b; }
2610 };
2611 
2612 
2613 define_array(BlockPairArray, BlockPair*)
2614 define_stack(BlockPairList, BlockPairArray)
2615 
2616 
2617 inline int         BlockBegin::number_of_sux() const            { assert(_end == NULL || _end->number_of_sux() == _successors.length(), "mismatch"); return _successors.length(); }
2618 inline BlockBegin* BlockBegin::sux_at(int i) const              { assert(_end == NULL || _end->sux_at(i) == _successors.at(i), "mismatch");          return _successors.at(i); }
2619 inline void        BlockBegin::add_successor(BlockBegin* sux)   { assert(_end == NULL, "Would create mismatch with successors of BlockEnd");         _successors.append(sux); }
2620 
2621 #undef ASSERT_VALUES
2622 
2623 #endif // SHARE_VM_C1_C1_INSTRUCTION_HPP
   1 /*
   2  * Copyright (c) 1999, 2016, 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  *


  98 class   UnsafeOp;
  99 class     UnsafeRawOp;
 100 class       UnsafeGetRaw;
 101 class       UnsafePutRaw;
 102 class     UnsafeObjectOp;
 103 class       UnsafeGetObject;
 104 class       UnsafePutObject;
 105 class         UnsafeGetAndSetObject;
 106 class   ProfileCall;
 107 class   ProfileReturnType;
 108 class   ProfileInvoke;
 109 class   RuntimeCall;
 110 class   MemBar;
 111 class   RangeCheckPredicate;
 112 #ifdef ASSERT
 113 class   Assert;
 114 #endif
 115 
 116 // A Value is a reference to the instruction creating the value
 117 typedef Instruction* Value;
 118 typedef GrowableArray<Value> Values;
 119 typedef GrowableArray<ValueStack*> ValueStackStack;



 120 
 121 // BlockClosure is the base class for block traversal/iteration.
 122 
 123 class BlockClosure: public CompilationResourceObj {
 124  public:
 125   virtual void block_do(BlockBegin* block)       = 0;
 126 };
 127 
 128 
 129 // A simple closure class for visiting the values of an Instruction
 130 class ValueVisitor: public StackObj {
 131  public:
 132   virtual void visit(Value* v) = 0;
 133 };
 134 
 135 
 136 // Some array and list classes
 137 typedef GrowableArray<BlockBegin*> BlockBeginArray;

 138 
 139 class BlockList: public GrowableArray<BlockBegin*> {
 140  public:
 141   BlockList(): GrowableArray<BlockBegin*>() {}
 142   BlockList(const int size): GrowableArray<BlockBegin*>(size) {}
 143   BlockList(const int size, BlockBegin* init): GrowableArray<BlockBegin*>(size, size, init) {}
 144 
 145   void iterate_forward(BlockClosure* closure);
 146   void iterate_backward(BlockClosure* closure);
 147   void blocks_do(void f(BlockBegin*));
 148   void values_do(ValueVisitor* f);
 149   void print(bool cfg_only = false, bool live_only = false) PRODUCT_RETURN;
 150 };
 151 
 152 
 153 // InstructionVisitors provide type-based dispatch for instructions.
 154 // For each concrete Instruction class X, a virtual function do_X is
 155 // provided. Functionality that needs to be implemented for all classes
 156 // (e.g., printing, code generation) is factored out into a specialised
 157 // visitor instead of added to the Instruction classes itself.
 158 
 159 class InstructionVisitor: public StackObj {
 160  public:
 161   virtual void do_Phi            (Phi*             x) = 0;
 162   virtual void do_Local          (Local*           x) = 0;
 163   virtual void do_Constant       (Constant*        x) = 0;


1723   void set_fpu_stack_state(intArray* state)      { _fpu_stack_state = state;  }
1724   void set_first_lir_instruction_id(int id)      { _first_lir_instruction_id = id;  }
1725   void set_last_lir_instruction_id(int id)       { _last_lir_instruction_id = id;  }
1726   void increment_total_preds(int n = 1)          { _total_preds += n; }
1727   void init_stores_to_locals(int locals_count)   { _stores_to_locals = BitMap(locals_count); _stores_to_locals.clear(); }
1728 
1729   // generic
1730   virtual void state_values_do(ValueVisitor* f);
1731 
1732   // successors and predecessors
1733   int number_of_sux() const;
1734   BlockBegin* sux_at(int i) const;
1735   void add_successor(BlockBegin* sux);
1736   void remove_successor(BlockBegin* pred);
1737   bool is_successor(BlockBegin* sux) const       { return _successors.contains(sux); }
1738 
1739   void add_predecessor(BlockBegin* pred);
1740   void remove_predecessor(BlockBegin* pred);
1741   bool is_predecessor(BlockBegin* pred) const    { return _predecessors.contains(pred); }
1742   int number_of_preds() const                    { return _predecessors.length(); }
1743   BlockBegin* pred_at(int i) const               { return _predecessors.at(i); }
1744 
1745   // exception handlers potentially invoked by this block
1746   void add_exception_handler(BlockBegin* b);
1747   bool is_exception_handler(BlockBegin* b) const { return _exception_handlers.contains(b); }
1748   int  number_of_exception_handlers() const      { return _exception_handlers.length(); }
1749   BlockBegin* exception_handler_at(int i) const  { return _exception_handlers.at(i); }
1750 
1751   // states of the instructions that have an edge to this exception handler
1752   int number_of_exception_states()               { assert(is_set(exception_entry_flag), "only for xhandlers"); return _exception_states == NULL ? 0 : _exception_states->length(); }
1753   ValueStack* exception_state_at(int idx) const  { assert(is_set(exception_entry_flag), "only for xhandlers"); return _exception_states->at(idx); }
1754   int add_exception_state(ValueStack* state);
1755 
1756   // flags
1757   enum Flag {
1758     no_flag                       = 0,
1759     std_entry_flag                = 1 << 0,
1760     osr_entry_flag                = 1 << 1,
1761     exception_entry_flag          = 1 << 2,
1762     subroutine_entry_flag         = 1 << 3,
1763     backward_branch_target_flag   = 1 << 4,


2588 
2589   LIR_Code code()           { return _code; }
2590 
2591   virtual void input_values_do(ValueVisitor*)   {}
2592 };
2593 
2594 class BlockPair: public CompilationResourceObj {
2595  private:
2596   BlockBegin* _from;
2597   BlockBegin* _to;
2598  public:
2599   BlockPair(BlockBegin* from, BlockBegin* to): _from(from), _to(to) {}
2600   BlockBegin* from() const { return _from; }
2601   BlockBegin* to() const   { return _to;   }
2602   bool is_same(BlockBegin* from, BlockBegin* to) const { return  _from == from && _to == to; }
2603   bool is_same(BlockPair* p) const { return  _from == p->from() && _to == p->to(); }
2604   void set_to(BlockBegin* b)   { _to = b; }
2605   void set_from(BlockBegin* b) { _from = b; }
2606 };
2607 
2608 typedef GrowableArray<BlockPair*> BlockPairList;



2609 
2610 inline int         BlockBegin::number_of_sux() const            { assert(_end == NULL || _end->number_of_sux() == _successors.length(), "mismatch"); return _successors.length(); }
2611 inline BlockBegin* BlockBegin::sux_at(int i) const              { assert(_end == NULL || _end->sux_at(i) == _successors.at(i), "mismatch");          return _successors.at(i); }
2612 inline void        BlockBegin::add_successor(BlockBegin* sux)   { assert(_end == NULL, "Would create mismatch with successors of BlockEnd");         _successors.append(sux); }
2613 
2614 #undef ASSERT_VALUES
2615 
2616 #endif // SHARE_VM_C1_C1_INSTRUCTION_HPP
< prev index next >