src/share/vm/opto/compile.hpp

changeset 2350
2f644f85485d
parent 2314
f95d63e2154a
child 2658
c7f3d0b4570f
equal deleted inserted replaced
2349:5ddfcf4b079e 2350:2f644f85485d
46 class CallGenerator; 46 class CallGenerator;
47 class ConnectionGraph; 47 class ConnectionGraph;
48 class InlineTree; 48 class InlineTree;
49 class Int_Array; 49 class Int_Array;
50 class Matcher; 50 class Matcher;
51 class MachConstantNode;
52 class MachConstantBaseNode;
51 class MachNode; 53 class MachNode;
54 class MachOper;
52 class MachSafePointNode; 55 class MachSafePointNode;
53 class Node; 56 class Node;
54 class Node_Array; 57 class Node_Array;
55 class Node_Notes; 58 class Node_Notes;
56 class OptoReg; 59 class OptoReg;
137 struct AliasCacheEntry { const TypePtr* _adr_type; int _index; }; // simple duple type 140 struct AliasCacheEntry { const TypePtr* _adr_type; int _index; }; // simple duple type
138 enum { 141 enum {
139 trapHistLength = methodDataOopDesc::_trap_hist_limit 142 trapHistLength = methodDataOopDesc::_trap_hist_limit
140 }; 143 };
141 144
145 // Constant entry of the constant table.
146 class Constant {
147 private:
148 BasicType _type;
149 jvalue _value;
150 int _offset; // offset of this constant (in bytes) relative to the constant table base.
151 bool _can_be_reused; // true (default) if the value can be shared with other users.
152
153 public:
154 Constant() : _type(T_ILLEGAL), _offset(-1), _can_be_reused(true) { _value.l = 0; }
155 Constant(BasicType type, jvalue value, bool can_be_reused = true) :
156 _type(type),
157 _value(value),
158 _offset(-1),
159 _can_be_reused(can_be_reused)
160 {}
161
162 bool operator==(const Constant& other);
163
164 BasicType type() const { return _type; }
165
166 jlong get_jlong() const { return _value.j; }
167 jfloat get_jfloat() const { return _value.f; }
168 jdouble get_jdouble() const { return _value.d; }
169 jobject get_jobject() const { return _value.l; }
170
171 int offset() const { return _offset; }
172 void set_offset(int offset) { _offset = offset; }
173
174 bool can_be_reused() const { return _can_be_reused; }
175 };
176
177 // Constant table.
178 class ConstantTable {
179 private:
180 GrowableArray<Constant> _constants; // Constants of this table.
181 int _size; // Size in bytes the emitted constant table takes (including padding).
182 int _table_base_offset; // Offset of the table base that gets added to the constant offsets.
183
184 public:
185 ConstantTable() :
186 _size(-1),
187 _table_base_offset(-1) // We can use -1 here since the constant table is always bigger than 2 bytes (-(size / 2), see MachConstantBaseNode::emit).
188 {}
189
190 int size() const { assert(_size != -1, "size not yet calculated"); return _size; }
191
192 void set_table_base_offset(int x) { assert(_table_base_offset == -1, "set only once"); _table_base_offset = x; }
193 int table_base_offset() const { assert(_table_base_offset != -1, "table base offset not yet set"); return _table_base_offset; }
194
195 void emit(CodeBuffer& cb);
196
197 // Returns the offset of the last entry (the top) of the constant table.
198 int top_offset() const { assert(_constants.top().offset() != -1, "constant not yet bound"); return _constants.top().offset(); }
199
200 void calculate_offsets_and_size();
201 int find_offset(Constant& con) const;
202
203 void add(Constant& con);
204 Constant add(BasicType type, jvalue value);
205 Constant add(MachOper* oper);
206 Constant add(jfloat f) {
207 jvalue value; value.f = f;
208 return add(T_FLOAT, value);
209 }
210 Constant add(jdouble d) {
211 jvalue value; value.d = d;
212 return add(T_DOUBLE, value);
213 }
214
215 // Jump table
216 Constant allocate_jump_table(MachConstantNode* n);
217 void fill_jump_table(CodeBuffer& cb, MachConstantNode* n, GrowableArray<Label*> labels) const;
218 };
219
142 private: 220 private:
143 // Fixed parameters to this compilation. 221 // Fixed parameters to this compilation.
144 const int _compile_id; 222 const int _compile_id;
145 const bool _save_argument_registers; // save/restore arg regs for trampolines 223 const bool _save_argument_registers; // save/restore arg regs for trampolines
146 const bool _subsume_loads; // Load can be matched as part of a larger op. 224 const bool _subsume_loads; // Load can be matched as part of a larger op.
210 Node* _immutable_memory; // Initial memory state 288 Node* _immutable_memory; // Initial memory state
211 289
212 Node* _recent_alloc_obj; 290 Node* _recent_alloc_obj;
213 Node* _recent_alloc_ctl; 291 Node* _recent_alloc_ctl;
214 292
293 // Constant table
294 ConstantTable _constant_table; // The constant table for this compile.
295 MachConstantBaseNode* _mach_constant_base_node; // Constant table base node singleton.
296
297
215 // Blocked array of debugging and profiling information, 298 // Blocked array of debugging and profiling information,
216 // tracked per node. 299 // tracked per node.
217 enum { _log2_node_notes_block_size = 8, 300 enum { _log2_node_notes_block_size = 8,
218 _node_notes_block_size = (1<<_log2_node_notes_block_size) 301 _node_notes_block_size = (1<<_log2_node_notes_block_size)
219 }; 302 };
270 ImplicitExceptionTable _inc_table; // Table of implicit null checks in native code 353 ImplicitExceptionTable _inc_table; // Table of implicit null checks in native code
271 OopMapSet* _oop_map_set; // Table of oop maps (one for each safepoint location) 354 OopMapSet* _oop_map_set; // Table of oop maps (one for each safepoint location)
272 static int _CompiledZap_count; // counter compared against CompileZap[First/Last] 355 static int _CompiledZap_count; // counter compared against CompileZap[First/Last]
273 BufferBlob* _scratch_buffer_blob; // For temporary code buffers. 356 BufferBlob* _scratch_buffer_blob; // For temporary code buffers.
274 relocInfo* _scratch_locs_memory; // For temporary code buffers. 357 relocInfo* _scratch_locs_memory; // For temporary code buffers.
358 int _scratch_const_size; // For temporary code buffers.
359 bool _in_scratch_emit_size; // true when in scratch_emit_size.
275 360
276 public: 361 public:
277 // Accessors 362 // Accessors
278 363
279 // The Compile instance currently active in this (compiler) thread. 364 // The Compile instance currently active in this (compiler) thread.
452 void set_recent_alloc(Node* ctl, Node* obj) { 537 void set_recent_alloc(Node* ctl, Node* obj) {
453 _recent_alloc_ctl = ctl; 538 _recent_alloc_ctl = ctl;
454 _recent_alloc_obj = obj; 539 _recent_alloc_obj = obj;
455 } 540 }
456 541
542 // Constant table
543 ConstantTable& constant_table() { return _constant_table; }
544
545 MachConstantBaseNode* mach_constant_base_node();
546 bool has_mach_constant_base_node() const { return _mach_constant_base_node != NULL; }
547
457 // Handy undefined Node 548 // Handy undefined Node
458 Node* top() const { return _top; } 549 Node* top() const { return _top; }
459 550
460 // these are used by guys who need to know about creation and transformation of top: 551 // these are used by guys who need to know about creation and transformation of top:
461 Node* cached_top_node() { return _top; } 552 Node* cached_top_node() { return _top; }
603 OopMapSet* oop_map_set() { return _oop_map_set; } 694 OopMapSet* oop_map_set() { return _oop_map_set; }
604 DebugInformationRecorder* debug_info() { return env()->debug_info(); } 695 DebugInformationRecorder* debug_info() { return env()->debug_info(); }
605 Dependencies* dependencies() { return env()->dependencies(); } 696 Dependencies* dependencies() { return env()->dependencies(); }
606 static int CompiledZap_count() { return _CompiledZap_count; } 697 static int CompiledZap_count() { return _CompiledZap_count; }
607 BufferBlob* scratch_buffer_blob() { return _scratch_buffer_blob; } 698 BufferBlob* scratch_buffer_blob() { return _scratch_buffer_blob; }
608 void init_scratch_buffer_blob(); 699 void init_scratch_buffer_blob(int const_size);
700 void clear_scratch_buffer_blob();
609 void set_scratch_buffer_blob(BufferBlob* b) { _scratch_buffer_blob = b; } 701 void set_scratch_buffer_blob(BufferBlob* b) { _scratch_buffer_blob = b; }
610 relocInfo* scratch_locs_memory() { return _scratch_locs_memory; } 702 relocInfo* scratch_locs_memory() { return _scratch_locs_memory; }
611 void set_scratch_locs_memory(relocInfo* b) { _scratch_locs_memory = b; } 703 void set_scratch_locs_memory(relocInfo* b) { _scratch_locs_memory = b; }
612 704
613 // emit to scratch blob, report resulting size 705 // emit to scratch blob, report resulting size
614 uint scratch_emit_size(const Node* n); 706 uint scratch_emit_size(const Node* n);
707 void set_in_scratch_emit_size(bool x) { _in_scratch_emit_size = x; }
708 bool in_scratch_emit_size() const { return _in_scratch_emit_size; }
615 709
616 enum ScratchBufferBlob { 710 enum ScratchBufferBlob {
617 MAX_inst_size = 1024, 711 MAX_inst_size = 1024,
618 MAX_locs_size = 128, // number of relocInfo elements 712 MAX_locs_size = 128, // number of relocInfo elements
619 MAX_const_size = 128, 713 MAX_const_size = 128,
690 784
691 // Write out basic block data to code buffer 785 // Write out basic block data to code buffer
692 void Fill_buffer(); 786 void Fill_buffer();
693 787
694 // Determine which variable sized branches can be shortened 788 // Determine which variable sized branches can be shortened
695 void Shorten_branches(Label *labels, int& code_size, int& reloc_size, int& stub_size, int& const_size); 789 void Shorten_branches(Label *labels, int& code_size, int& reloc_size, int& stub_size);
696 790
697 // Compute the size of first NumberOfLoopInstrToAlign instructions 791 // Compute the size of first NumberOfLoopInstrToAlign instructions
698 // at the head of a loop. 792 // at the head of a loop.
699 void compute_loop_first_inst_sizes(); 793 void compute_loop_first_inst_sizes();
700 794

mercurial