< prev index next >

src/hotspot/share/opto/output.hpp

Print this page

 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  */
 24 
 25 #ifndef SHARE_OPTO_OUTPUT_HPP
 26 #define SHARE_OPTO_OUTPUT_HPP
 27 
 28 #include "code/debugInfo.hpp"
 29 #include "code/exceptionHandlerTable.hpp"
 30 #include "metaprogramming/enableIf.hpp"
 31 #include "opto/ad.hpp"

 32 #include "opto/constantTable.hpp"
 33 #include "opto/phase.hpp"
 34 #include "runtime/vm_version.hpp"
 35 #include "utilities/globalDefinitions.hpp"
 36 #include "utilities/macros.hpp"
 37 
 38 class AbstractCompiler;
 39 class Arena;
 40 class Bundle;
 41 class Block;
 42 class Block_Array;
 43 class ciMethod;
 44 class Compile;
 45 class MachNode;
 46 class MachSafePointNode;
 47 class Node;
 48 class PhaseCFG;
 49 #ifndef PRODUCT
 50 #define DEBUG_ARG(x) , x
 51 #else

 55 // Define the initial sizes for allocation of the resizable code buffer
 56 enum {
 57   initial_const_capacity =   4 * 1024
 58 };
 59 
 60 class BufferSizingData {
 61 public:
 62   int _stub;
 63   int _code;
 64   int _const;
 65   int _reloc;
 66 
 67   BufferSizingData() :
 68     _stub(0),
 69     _code(0),
 70     _const(0),
 71     _reloc(0)
 72   { };
 73 };
 74 
 75 class C2SafepointPollStubTable {
 76 private:
 77   struct C2SafepointPollStub: public ResourceObj {
 78     uintptr_t _safepoint_offset;
 79     Label     _stub_label;
 80     Label     _trampoline_label;
 81     C2SafepointPollStub(uintptr_t safepoint_offset) :
 82       _safepoint_offset(safepoint_offset),
 83       _stub_label(),
 84       _trampoline_label() {}
 85   };
 86 
 87   GrowableArray<C2SafepointPollStub*> _safepoints;
 88 
 89   static volatile int _stub_size;
 90 
 91   void emit_stub_impl(MacroAssembler& masm, C2SafepointPollStub* entry) const;
 92 
 93   // The selection logic below relieves the need to add dummy files to unsupported platforms.
 94   template <bool enabled>
 95   typename EnableIf<enabled>::type
 96   select_emit_stub(MacroAssembler& masm, C2SafepointPollStub* entry) const {
 97     emit_stub_impl(masm, entry);
 98   }
 99 
100   template <bool enabled>
101   typename EnableIf<!enabled>::type
102   select_emit_stub(MacroAssembler& masm, C2SafepointPollStub* entry) const {}
103 
104   void emit_stub(MacroAssembler& masm, C2SafepointPollStub* entry) const {
105     select_emit_stub<VM_Version::supports_stack_watermark_barrier()>(masm, entry);
106   }
107 
108   int stub_size_lazy() const;
109 
110 public:
111   Label& add_safepoint(uintptr_t safepoint_offset);
112   int estimate_stub_size() const;
113   void emit(CodeBuffer& cb);
114 };
115 
116 class PhaseOutput : public Phase {
117 private:
118   // Instruction bits passed off to the VM
119   int                    _method_size;           // Size of nmethod code segment in bytes
120   CodeBuffer             _code_buffer;           // Where the code is assembled
121   int                    _first_block_size;      // Size of unvalidated entry point code / OSR poison code
122   ExceptionHandlerTable  _handler_table;         // Table of native-code exception handlers
123   ImplicitExceptionTable _inc_table;             // Table of implicit null checks in native code
124   C2SafepointPollStubTable _safepoint_poll_table;// Table for safepoint polls
125   OopMapSet*             _oop_map_set;           // Table of oop maps (one for each safepoint location)
126   BufferBlob*            _scratch_buffer_blob;   // For temporary code buffers.
127   relocInfo*             _scratch_locs_memory;   // For temporary code buffers.
128   int                    _scratch_const_size;    // For temporary code buffers.
129   bool                   _in_scratch_emit_size;  // true when in scratch_emit_size.
130 
131   int                    _frame_slots;           // Size of total frame in stack slots
132   CodeOffsets            _code_offsets;          // Offsets into the code for various interesting entries
133 
134   uint                   _node_bundling_limit;
135   Bundle*                _node_bundling_base;    // Information for instruction bundling
136 
137   // For deopt
138   int                    _orig_pc_slot;
139   int                    _orig_pc_slot_offset_in_bytes;
140 
141   ConstantTable          _constant_table;        // The constant table for this compilation unit.
142 
143   BufferSizingData       _buf_sizes;
144   Block*                 _block;

152   ~PhaseOutput();
153 
154   // Convert Nodes to instruction bits and pass off to the VM
155   void Output();
156   bool need_stack_bang(int frame_size_in_bytes) const;
157   bool need_register_stack_bang() const;
158   void compute_loop_first_inst_sizes();
159 
160   void install_code(ciMethod*         target,
161                     int               entry_bci,
162                     AbstractCompiler* compiler,
163                     bool              has_unsafe_access,
164                     bool              has_wide_vectors,
165                     RTMState          rtm_state);
166 
167   void install_stub(const char* stub_name);
168 
169   // Constant table
170   ConstantTable& constant_table() { return _constant_table; }
171 
172   // Safepoint poll table
173   C2SafepointPollStubTable* safepoint_poll_table() { return &_safepoint_poll_table; }
174 
175   // Code emission iterator
176   Block* block()   { return _block; }
177   int index()      { return _index; }
178 
179   // The architecture description provides short branch variants for some long
180   // branch instructions. Replace eligible long branches with short branches.
181   void shorten_branches(uint* blk_starts);
182   // If "objs" contains an ObjectValue whose id is "id", returns it, else null.
183   static ObjectValue* sv_for_node_id(GrowableArray<ScopeValue*> *objs, int id);
184   static void set_sv_for_object_node(GrowableArray<ScopeValue*> *objs, ObjectValue* sv);
185   void FillLocArray( int idx, MachSafePointNode* sfpt, Node *local,
186                      GrowableArray<ScopeValue*> *array,
187                      GrowableArray<ScopeValue*> *objs );
188 
189   void Process_OopMap_Node(MachNode *mach, int current_offset);
190 
191   // Initialize code buffer
192   void estimate_buffer_size(int& const_req);
193   CodeBuffer* init_buffer();

 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  */
 24 
 25 #ifndef SHARE_OPTO_OUTPUT_HPP
 26 #define SHARE_OPTO_OUTPUT_HPP
 27 
 28 #include "code/debugInfo.hpp"
 29 #include "code/exceptionHandlerTable.hpp"
 30 #include "metaprogramming/enableIf.hpp"
 31 #include "opto/ad.hpp"
 32 #include "opto/c2_CodeStubs.hpp"
 33 #include "opto/constantTable.hpp"
 34 #include "opto/phase.hpp"
 35 #include "runtime/vm_version.hpp"
 36 #include "utilities/globalDefinitions.hpp"
 37 #include "utilities/macros.hpp"
 38 
 39 class AbstractCompiler;
 40 class Arena;
 41 class Bundle;
 42 class Block;
 43 class Block_Array;
 44 class ciMethod;
 45 class Compile;
 46 class MachNode;
 47 class MachSafePointNode;
 48 class Node;
 49 class PhaseCFG;
 50 #ifndef PRODUCT
 51 #define DEBUG_ARG(x) , x
 52 #else

 56 // Define the initial sizes for allocation of the resizable code buffer
 57 enum {
 58   initial_const_capacity =   4 * 1024
 59 };
 60 
 61 class BufferSizingData {
 62 public:
 63   int _stub;
 64   int _code;
 65   int _const;
 66   int _reloc;
 67 
 68   BufferSizingData() :
 69     _stub(0),
 70     _code(0),
 71     _const(0),
 72     _reloc(0)
 73   { };
 74 };
 75 









































 76 class PhaseOutput : public Phase {
 77 private:
 78   // Instruction bits passed off to the VM
 79   int                    _method_size;           // Size of nmethod code segment in bytes
 80   CodeBuffer             _code_buffer;           // Where the code is assembled
 81   int                    _first_block_size;      // Size of unvalidated entry point code / OSR poison code
 82   ExceptionHandlerTable  _handler_table;         // Table of native-code exception handlers
 83   ImplicitExceptionTable _inc_table;             // Table of implicit null checks in native code
 84   C2CodeStubList         _stub_list;             // List of code stubs
 85   OopMapSet*             _oop_map_set;           // Table of oop maps (one for each safepoint location)
 86   BufferBlob*            _scratch_buffer_blob;   // For temporary code buffers.
 87   relocInfo*             _scratch_locs_memory;   // For temporary code buffers.
 88   int                    _scratch_const_size;    // For temporary code buffers.
 89   bool                   _in_scratch_emit_size;  // true when in scratch_emit_size.
 90 
 91   int                    _frame_slots;           // Size of total frame in stack slots
 92   CodeOffsets            _code_offsets;          // Offsets into the code for various interesting entries
 93 
 94   uint                   _node_bundling_limit;
 95   Bundle*                _node_bundling_base;    // Information for instruction bundling
 96 
 97   // For deopt
 98   int                    _orig_pc_slot;
 99   int                    _orig_pc_slot_offset_in_bytes;
100 
101   ConstantTable          _constant_table;        // The constant table for this compilation unit.
102 
103   BufferSizingData       _buf_sizes;
104   Block*                 _block;

112   ~PhaseOutput();
113 
114   // Convert Nodes to instruction bits and pass off to the VM
115   void Output();
116   bool need_stack_bang(int frame_size_in_bytes) const;
117   bool need_register_stack_bang() const;
118   void compute_loop_first_inst_sizes();
119 
120   void install_code(ciMethod*         target,
121                     int               entry_bci,
122                     AbstractCompiler* compiler,
123                     bool              has_unsafe_access,
124                     bool              has_wide_vectors,
125                     RTMState          rtm_state);
126 
127   void install_stub(const char* stub_name);
128 
129   // Constant table
130   ConstantTable& constant_table() { return _constant_table; }
131 
132   // Code stubs list
133   void add_stub(C2CodeStub* stub) { _stub_list.add_stub(stub); }
134 
135   // Code emission iterator
136   Block* block()   { return _block; }
137   int index()      { return _index; }
138 
139   // The architecture description provides short branch variants for some long
140   // branch instructions. Replace eligible long branches with short branches.
141   void shorten_branches(uint* blk_starts);
142   // If "objs" contains an ObjectValue whose id is "id", returns it, else null.
143   static ObjectValue* sv_for_node_id(GrowableArray<ScopeValue*> *objs, int id);
144   static void set_sv_for_object_node(GrowableArray<ScopeValue*> *objs, ObjectValue* sv);
145   void FillLocArray( int idx, MachSafePointNode* sfpt, Node *local,
146                      GrowableArray<ScopeValue*> *array,
147                      GrowableArray<ScopeValue*> *objs );
148 
149   void Process_OopMap_Node(MachNode *mach, int current_offset);
150 
151   // Initialize code buffer
152   void estimate_buffer_size(int& const_req);
153   CodeBuffer* init_buffer();
< prev index next >