mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-18 01:54:47 +02:00
8240363: Refactor Compile::Output() to its own Phase
Reviewed-by: kvn, vlivanov
This commit is contained in:
parent
6ddb0f2b2c
commit
21cd75cb98
28 changed files with 1388 additions and 1228 deletions
|
@ -28,7 +28,6 @@
|
|||
#include "asm/codeBuffer.hpp"
|
||||
#include "ci/compilerInterface.hpp"
|
||||
#include "code/debugInfoRec.hpp"
|
||||
#include "code/exceptionHandlerTable.hpp"
|
||||
#include "compiler/compilerOracle.hpp"
|
||||
#include "compiler/compileBroker.hpp"
|
||||
#include "libadt/dict.hpp"
|
||||
|
@ -48,7 +47,6 @@
|
|||
class AddPNode;
|
||||
class Block;
|
||||
class Bundle;
|
||||
class C2Compiler;
|
||||
class CallGenerator;
|
||||
class CloneMap;
|
||||
class ConnectionGraph;
|
||||
|
@ -72,6 +70,7 @@ class PhaseIterGVN;
|
|||
class PhaseRegAlloc;
|
||||
class PhaseCCP;
|
||||
class PhaseCCP_DCE;
|
||||
class PhaseOutput;
|
||||
class RootNode;
|
||||
class relocInfo;
|
||||
class Scope;
|
||||
|
@ -240,121 +239,6 @@ class Compile : public Phase {
|
|||
trapHistLength = MethodData::_trap_hist_limit
|
||||
};
|
||||
|
||||
// Constant entry of the constant table.
|
||||
class Constant {
|
||||
private:
|
||||
BasicType _type;
|
||||
union {
|
||||
jvalue _value;
|
||||
Metadata* _metadata;
|
||||
} _v;
|
||||
int _offset; // offset of this constant (in bytes) relative to the constant table base.
|
||||
float _freq;
|
||||
bool _can_be_reused; // true (default) if the value can be shared with other users.
|
||||
|
||||
public:
|
||||
Constant() : _type(T_ILLEGAL), _offset(-1), _freq(0.0f), _can_be_reused(true) { _v._value.l = 0; }
|
||||
Constant(BasicType type, jvalue value, float freq = 0.0f, bool can_be_reused = true) :
|
||||
_type(type),
|
||||
_offset(-1),
|
||||
_freq(freq),
|
||||
_can_be_reused(can_be_reused)
|
||||
{
|
||||
assert(type != T_METADATA, "wrong constructor");
|
||||
_v._value = value;
|
||||
}
|
||||
Constant(Metadata* metadata, bool can_be_reused = true) :
|
||||
_type(T_METADATA),
|
||||
_offset(-1),
|
||||
_freq(0.0f),
|
||||
_can_be_reused(can_be_reused)
|
||||
{
|
||||
_v._metadata = metadata;
|
||||
}
|
||||
|
||||
bool operator==(const Constant& other);
|
||||
|
||||
BasicType type() const { return _type; }
|
||||
|
||||
jint get_jint() const { return _v._value.i; }
|
||||
jlong get_jlong() const { return _v._value.j; }
|
||||
jfloat get_jfloat() const { return _v._value.f; }
|
||||
jdouble get_jdouble() const { return _v._value.d; }
|
||||
jobject get_jobject() const { return _v._value.l; }
|
||||
|
||||
Metadata* get_metadata() const { return _v._metadata; }
|
||||
|
||||
int offset() const { return _offset; }
|
||||
void set_offset(int offset) { _offset = offset; }
|
||||
|
||||
float freq() const { return _freq; }
|
||||
void inc_freq(float freq) { _freq += freq; }
|
||||
|
||||
bool can_be_reused() const { return _can_be_reused; }
|
||||
};
|
||||
|
||||
// Constant table.
|
||||
class ConstantTable {
|
||||
private:
|
||||
GrowableArray<Constant> _constants; // Constants of this table.
|
||||
int _size; // Size in bytes the emitted constant table takes (including padding).
|
||||
int _table_base_offset; // Offset of the table base that gets added to the constant offsets.
|
||||
int _nof_jump_tables; // Number of jump-tables in this constant table.
|
||||
|
||||
static int qsort_comparator(Constant* a, Constant* b);
|
||||
|
||||
// We use negative frequencies to keep the order of the
|
||||
// jump-tables in which they were added. Otherwise we get into
|
||||
// trouble with relocation.
|
||||
float next_jump_table_freq() { return -1.0f * (++_nof_jump_tables); }
|
||||
|
||||
public:
|
||||
ConstantTable() :
|
||||
_size(-1),
|
||||
_table_base_offset(-1), // We can use -1 here since the constant table is always bigger than 2 bytes (-(size / 2), see MachConstantBaseNode::emit).
|
||||
_nof_jump_tables(0)
|
||||
{}
|
||||
|
||||
int size() const { assert(_size != -1, "not calculated yet"); return _size; }
|
||||
|
||||
int calculate_table_base_offset() const; // AD specific
|
||||
void set_table_base_offset(int x) { assert(_table_base_offset == -1 || x == _table_base_offset, "can't change"); _table_base_offset = x; }
|
||||
int table_base_offset() const { assert(_table_base_offset != -1, "not set yet"); return _table_base_offset; }
|
||||
|
||||
void emit(CodeBuffer& cb);
|
||||
|
||||
// Returns the offset of the last entry (the top) of the constant table.
|
||||
int top_offset() const { assert(_constants.top().offset() != -1, "not bound yet"); return _constants.top().offset(); }
|
||||
|
||||
void calculate_offsets_and_size();
|
||||
int find_offset(Constant& con) const;
|
||||
|
||||
void add(Constant& con);
|
||||
Constant add(MachConstantNode* n, BasicType type, jvalue value);
|
||||
Constant add(Metadata* metadata);
|
||||
Constant add(MachConstantNode* n, MachOper* oper);
|
||||
Constant add(MachConstantNode* n, jint i) {
|
||||
jvalue value; value.i = i;
|
||||
return add(n, T_INT, value);
|
||||
}
|
||||
Constant add(MachConstantNode* n, jlong j) {
|
||||
jvalue value; value.j = j;
|
||||
return add(n, T_LONG, value);
|
||||
}
|
||||
Constant add(MachConstantNode* n, jfloat f) {
|
||||
jvalue value; value.f = f;
|
||||
return add(n, T_FLOAT, value);
|
||||
}
|
||||
Constant add(MachConstantNode* n, jdouble d) {
|
||||
jvalue value; value.d = d;
|
||||
return add(n, T_DOUBLE, value);
|
||||
}
|
||||
|
||||
// Jump-table
|
||||
Constant add_jump_table(MachConstantNode* n);
|
||||
void fill_jump_table(CodeBuffer& cb, MachConstantNode* n, GrowableArray<Label*> labels) const;
|
||||
};
|
||||
|
||||
private:
|
||||
// Fixed parameters to this compilation.
|
||||
const int _compile_id;
|
||||
|
@ -376,9 +260,6 @@ class Compile : public Phase {
|
|||
int _fixed_slots; // count of frame slots not allocated by the register
|
||||
// allocator i.e. locks, original deopt pc, etc.
|
||||
uintx _max_node_limit; // Max unique node count during a single compilation.
|
||||
// For deopt
|
||||
int _orig_pc_slot;
|
||||
int _orig_pc_slot_offset_in_bytes;
|
||||
|
||||
int _major_progress; // Count of something big happening
|
||||
bool _inlining_progress; // progress doing incremental inlining?
|
||||
|
@ -457,7 +338,6 @@ class Compile : public Phase {
|
|||
Node* _recent_alloc_ctl;
|
||||
|
||||
// Constant table
|
||||
ConstantTable _constant_table; // The constant table for this compile.
|
||||
MachConstantBaseNode* _mach_constant_base_node; // Constant table base node singleton.
|
||||
|
||||
|
||||
|
@ -586,27 +466,12 @@ class Compile : public Phase {
|
|||
int _inner_loops; // Number of inner loops in the method
|
||||
Matcher* _matcher; // Engine to map ideal to machine instructions
|
||||
PhaseRegAlloc* _regalloc; // Results of register allocation.
|
||||
int _frame_slots; // Size of total frame in stack slots
|
||||
CodeOffsets _code_offsets; // Offsets into the code for various interesting entries
|
||||
RegMask _FIRST_STACK_mask; // All stack slots usable for spills (depends on frame layout)
|
||||
Arena* _indexSet_arena; // control IndexSet allocation within PhaseChaitin
|
||||
void* _indexSet_free_block_list; // free list of IndexSet bit blocks
|
||||
int _interpreter_frame_size;
|
||||
|
||||
uint _node_bundling_limit;
|
||||
Bundle* _node_bundling_base; // Information for instruction bundling
|
||||
|
||||
// Instruction bits passed off to the VM
|
||||
int _method_size; // Size of nmethod code segment in bytes
|
||||
CodeBuffer _code_buffer; // Where the code is assembled
|
||||
int _first_block_size; // Size of unvalidated entry point code / OSR poison code
|
||||
ExceptionHandlerTable _handler_table; // Table of native-code exception handlers
|
||||
ImplicitExceptionTable _inc_table; // Table of implicit null checks in native code
|
||||
OopMapSet* _oop_map_set; // Table of oop maps (one for each safepoint location)
|
||||
BufferBlob* _scratch_buffer_blob; // For temporary code buffers.
|
||||
relocInfo* _scratch_locs_memory; // For temporary code buffers.
|
||||
int _scratch_const_size; // For temporary code buffers.
|
||||
bool _in_scratch_emit_size; // true when in scratch_emit_size.
|
||||
PhaseOutput* _output;
|
||||
|
||||
void reshape_address(AddPNode* n);
|
||||
|
||||
|
@ -618,6 +483,11 @@ class Compile : public Phase {
|
|||
return (Compile*) ciEnv::current()->compiler_data();
|
||||
}
|
||||
|
||||
int interpreter_frame_size() const { return _interpreter_frame_size; }
|
||||
|
||||
PhaseOutput* output() const { return _output; }
|
||||
void set_output(PhaseOutput* o) { _output = o; }
|
||||
|
||||
// ID for this compilation. Useful for setting breakpoints in the debugger.
|
||||
int compile_id() const { return _compile_id; }
|
||||
DirectiveSet* directive() const { return _directive; }
|
||||
|
@ -646,6 +516,7 @@ class Compile : public Phase {
|
|||
address stub_function() const { return _stub_function; }
|
||||
const char* stub_name() const { return _stub_name; }
|
||||
address stub_entry_point() const { return _stub_entry_point; }
|
||||
void set_stub_entry_point(address z) { _stub_entry_point = z; }
|
||||
|
||||
// Control of this compilation.
|
||||
int fixed_slots() const { assert(_fixed_slots >= 0, ""); return _fixed_slots; }
|
||||
|
@ -936,9 +807,6 @@ class Compile : public Phase {
|
|||
void remove_modified_node(Node* n) NOT_DEBUG_RETURN;
|
||||
DEBUG_ONLY( Unique_Node_List* modified_nodes() const { return _modified_nodes; } )
|
||||
|
||||
// Constant table
|
||||
ConstantTable& constant_table() { return _constant_table; }
|
||||
|
||||
MachConstantBaseNode* mach_constant_base_node();
|
||||
bool has_mach_constant_base_node() const { return _mach_constant_base_node != NULL; }
|
||||
// Generated by adlc, true if CallNode requires MachConstantBase.
|
||||
|
@ -1124,26 +992,16 @@ class Compile : public Phase {
|
|||
int inner_loops() const { return _inner_loops; }
|
||||
Matcher* matcher() { return _matcher; }
|
||||
PhaseRegAlloc* regalloc() { return _regalloc; }
|
||||
int frame_slots() const { return _frame_slots; }
|
||||
int frame_size_in_words() const; // frame_slots in units of the polymorphic 'words'
|
||||
int frame_size_in_bytes() const { return _frame_slots << LogBytesPerInt; }
|
||||
RegMask& FIRST_STACK_mask() { return _FIRST_STACK_mask; }
|
||||
Arena* indexSet_arena() { return _indexSet_arena; }
|
||||
void* indexSet_free_block_list() { return _indexSet_free_block_list; }
|
||||
uint node_bundling_limit() { return _node_bundling_limit; }
|
||||
Bundle* node_bundling_base() { return _node_bundling_base; }
|
||||
void set_node_bundling_limit(uint n) { _node_bundling_limit = n; }
|
||||
void set_node_bundling_base(Bundle* b) { _node_bundling_base = b; }
|
||||
bool starts_bundle(const Node *n) const;
|
||||
bool need_stack_bang(int frame_size_in_bytes) const;
|
||||
bool need_register_stack_bang() const;
|
||||
DebugInformationRecorder* debug_info() { return env()->debug_info(); }
|
||||
|
||||
void update_interpreter_frame_size(int size) {
|
||||
if (_interpreter_frame_size < size) {
|
||||
_interpreter_frame_size = size;
|
||||
}
|
||||
}
|
||||
int bang_size_in_bytes() const;
|
||||
|
||||
void set_matcher(Matcher* m) { _matcher = m; }
|
||||
//void set_regalloc(PhaseRegAlloc* ra) { _regalloc = ra; }
|
||||
|
@ -1153,40 +1011,13 @@ class Compile : public Phase {
|
|||
void set_java_calls(int z) { _java_calls = z; }
|
||||
void set_inner_loops(int z) { _inner_loops = z; }
|
||||
|
||||
// Instruction bits passed off to the VM
|
||||
int code_size() { return _method_size; }
|
||||
CodeBuffer* code_buffer() { return &_code_buffer; }
|
||||
int first_block_size() { return _first_block_size; }
|
||||
void set_frame_complete(int off) { if (!in_scratch_emit_size()) { _code_offsets.set_value(CodeOffsets::Frame_Complete, off); } }
|
||||
ExceptionHandlerTable* handler_table() { return &_handler_table; }
|
||||
ImplicitExceptionTable* inc_table() { return &_inc_table; }
|
||||
OopMapSet* oop_map_set() { return _oop_map_set; }
|
||||
DebugInformationRecorder* debug_info() { return env()->debug_info(); }
|
||||
Dependencies* dependencies() { return env()->dependencies(); }
|
||||
BufferBlob* scratch_buffer_blob() { return _scratch_buffer_blob; }
|
||||
void init_scratch_buffer_blob(int const_size);
|
||||
void clear_scratch_buffer_blob();
|
||||
void set_scratch_buffer_blob(BufferBlob* b) { _scratch_buffer_blob = b; }
|
||||
relocInfo* scratch_locs_memory() { return _scratch_locs_memory; }
|
||||
void set_scratch_locs_memory(relocInfo* b) { _scratch_locs_memory = b; }
|
||||
|
||||
// emit to scratch blob, report resulting size
|
||||
uint scratch_emit_size(const Node* n);
|
||||
void set_in_scratch_emit_size(bool x) { _in_scratch_emit_size = x; }
|
||||
bool in_scratch_emit_size() const { return _in_scratch_emit_size; }
|
||||
|
||||
enum ScratchBufferBlob {
|
||||
MAX_inst_size = 2048,
|
||||
MAX_locs_size = 128, // number of relocInfo elements
|
||||
MAX_const_size = 128,
|
||||
MAX_stubs_size = 128
|
||||
};
|
||||
Dependencies* dependencies() { return env()->dependencies(); }
|
||||
|
||||
// Major entry point. Given a Scope, compile the associated method.
|
||||
// For normal compilations, entry_bci is InvocationEntryBci. For on stack
|
||||
// replacement, entry_bci indicates the bytecode for which to compile a
|
||||
// continuation.
|
||||
Compile(ciEnv* ci_env, C2Compiler* compiler, ciMethod* target,
|
||||
Compile(ciEnv* ci_env, ciMethod* target,
|
||||
int entry_bci, bool subsume_loads, bool do_escape_analysis,
|
||||
bool eliminate_boxing, DirectiveSet* directive);
|
||||
|
||||
|
@ -1221,67 +1052,8 @@ class Compile : public Phase {
|
|||
// returns true if adr overlaps with the given alias category
|
||||
bool can_alias(const TypePtr* adr, int alias_idx);
|
||||
|
||||
// Driver for converting compiler's IR into machine code bits
|
||||
void Output();
|
||||
|
||||
// Accessors for node bundling info.
|
||||
Bundle* node_bundling(const Node *n);
|
||||
bool valid_bundle_info(const Node *n);
|
||||
|
||||
// Schedule and Bundle the instructions
|
||||
void ScheduleAndBundle();
|
||||
|
||||
// Build OopMaps for each GC point
|
||||
void BuildOopMaps();
|
||||
|
||||
// Append debug info for the node "local" at safepoint node "sfpt" to the
|
||||
// "array", May also consult and add to "objs", which describes the
|
||||
// scalar-replaced objects.
|
||||
void FillLocArray( int idx, MachSafePointNode* sfpt,
|
||||
Node *local, GrowableArray<ScopeValue*> *array,
|
||||
GrowableArray<ScopeValue*> *objs );
|
||||
|
||||
// If "objs" contains an ObjectValue whose id is "id", returns it, else NULL.
|
||||
static ObjectValue* sv_for_node_id(GrowableArray<ScopeValue*> *objs, int id);
|
||||
// Requres that "objs" does not contains an ObjectValue whose id matches
|
||||
// that of "sv. Appends "sv".
|
||||
static void set_sv_for_object_node(GrowableArray<ScopeValue*> *objs,
|
||||
ObjectValue* sv );
|
||||
|
||||
// Process an OopMap Element while emitting nodes
|
||||
void Process_OopMap_Node(MachNode *mach, int code_offset);
|
||||
|
||||
class BufferSizingData {
|
||||
public:
|
||||
int _stub;
|
||||
int _code;
|
||||
int _const;
|
||||
int _reloc;
|
||||
|
||||
BufferSizingData() :
|
||||
_stub(0),
|
||||
_code(0),
|
||||
_const(0),
|
||||
_reloc(0)
|
||||
{ };
|
||||
};
|
||||
|
||||
// Initialize code buffer
|
||||
void estimate_buffer_size(int& const_req);
|
||||
CodeBuffer* init_buffer(BufferSizingData& buf_sizes);
|
||||
|
||||
// Write out basic block data to code buffer
|
||||
void fill_buffer(CodeBuffer* cb, uint* blk_starts);
|
||||
|
||||
// Determine which variable sized branches can be shortened
|
||||
void shorten_branches(uint* blk_starts, BufferSizingData& buf_sizes);
|
||||
|
||||
// Compute the size of first NumberOfLoopInstrToAlign instructions
|
||||
// at the head of a loop.
|
||||
void compute_loop_first_inst_sizes();
|
||||
|
||||
// Compute the information for the exception tables
|
||||
void FillExceptionTables(uint cnt, uint *call_returns, uint *inct_starts, Label *blk_labels);
|
||||
|
||||
// Stack slots that may be unused by the calling convention but must
|
||||
// otherwise be preserved. On Intel this includes the return address.
|
||||
|
@ -1364,16 +1136,6 @@ class Compile : public Phase {
|
|||
// End-of-run dumps.
|
||||
static void print_statistics() PRODUCT_RETURN;
|
||||
|
||||
// Dump formatted assembly
|
||||
#if defined(SUPPORT_OPTO_ASSEMBLY)
|
||||
void dump_asm_on(outputStream* ost, int* pcs, uint pc_limit);
|
||||
void dump_asm(int* pcs = NULL, uint pc_limit = 0) { dump_asm_on(tty, pcs, pc_limit); }
|
||||
#else
|
||||
void dump_asm_on(outputStream* ost, int* pcs, uint pc_limit) { return; }
|
||||
void dump_asm(int* pcs = NULL, uint pc_limit = 0) { return; }
|
||||
#endif
|
||||
void dump_pc(int *pcs, int pc_limit, Node *n);
|
||||
|
||||
// Verify ADLC assumptions during startup
|
||||
static void adlc_verification() PRODUCT_RETURN;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue