6384206: Phis which are later unneeded are impairing our ability to inline based on static types
Reviewed-by: rasbold, jrose
This commit is contained in:
parent
eee15b163e
commit
4b1e242299
@ -49,7 +49,7 @@ bool ciMethodBlocks::is_block_start(int bci) {
|
||||
// first half. Returns the range beginning at bci.
|
||||
ciBlock *ciMethodBlocks::split_block_at(int bci) {
|
||||
ciBlock *former_block = block_containing(bci);
|
||||
ciBlock *new_block = new(_arena) ciBlock(_method, _num_blocks++, this, former_block->start_bci());
|
||||
ciBlock *new_block = new(_arena) ciBlock(_method, _num_blocks++, former_block->start_bci());
|
||||
_blocks->append(new_block);
|
||||
assert(former_block != NULL, "must not be NULL");
|
||||
new_block->set_limit_bci(bci);
|
||||
@ -83,7 +83,7 @@ ciBlock *ciMethodBlocks::make_block_at(int bci) {
|
||||
if (cb == NULL ) {
|
||||
// This is our first time visiting this bytecode. Create
|
||||
// a fresh block and assign it this starting point.
|
||||
ciBlock *nb = new(_arena) ciBlock(_method, _num_blocks++, this, bci);
|
||||
ciBlock *nb = new(_arena) ciBlock(_method, _num_blocks++, bci);
|
||||
_blocks->append(nb);
|
||||
_bci_to_block[bci] = nb;
|
||||
return nb;
|
||||
@ -98,6 +98,11 @@ ciBlock *ciMethodBlocks::make_block_at(int bci) {
|
||||
}
|
||||
}
|
||||
|
||||
ciBlock *ciMethodBlocks::make_dummy_block() {
|
||||
ciBlock *dum = new(_arena) ciBlock(_method, -1, 0);
|
||||
return dum;
|
||||
}
|
||||
|
||||
void ciMethodBlocks::do_analysis() {
|
||||
ciBytecodeStream s(_method);
|
||||
ciBlock *cur_block = block_containing(0);
|
||||
@ -253,7 +258,7 @@ ciMethodBlocks::ciMethodBlocks(Arena *arena, ciMethod *meth): _method(meth),
|
||||
Copy::zero_to_words((HeapWord*) _bci_to_block, b2bsize / sizeof(HeapWord));
|
||||
|
||||
// create initial block covering the entire method
|
||||
ciBlock *b = new(arena) ciBlock(_method, _num_blocks++, this, 0);
|
||||
ciBlock *b = new(arena) ciBlock(_method, _num_blocks++, 0);
|
||||
_blocks->append(b);
|
||||
_bci_to_block[0] = b;
|
||||
|
||||
@ -334,7 +339,7 @@ void ciMethodBlocks::dump() {
|
||||
#endif
|
||||
|
||||
|
||||
ciBlock::ciBlock(ciMethod *method, int index, ciMethodBlocks *mb, int start_bci) :
|
||||
ciBlock::ciBlock(ciMethod *method, int index, int start_bci) :
|
||||
#ifndef PRODUCT
|
||||
_method(method),
|
||||
#endif
|
||||
|
@ -48,6 +48,8 @@ public:
|
||||
int num_blocks() { return _num_blocks;}
|
||||
void clear_processed();
|
||||
|
||||
ciBlock *make_dummy_block(); // a block not associated with a bci
|
||||
|
||||
#ifndef PRODUCT
|
||||
void dump();
|
||||
#endif
|
||||
@ -81,7 +83,7 @@ public:
|
||||
fall_through_bci = -1
|
||||
};
|
||||
|
||||
ciBlock(ciMethod *method, int index, ciMethodBlocks *mb, int start_bci);
|
||||
ciBlock(ciMethod *method, int index, int start_bci);
|
||||
int start_bci() const { return _start_bci; }
|
||||
int limit_bci() const { return _limit_bci; }
|
||||
int control_bci() const { return _control_bci; }
|
||||
@ -94,7 +96,6 @@ public:
|
||||
int ex_limit_bci() const { return _ex_limit_bci; }
|
||||
bool contains(int bci) const { return start_bci() <= bci && bci < limit_bci(); }
|
||||
|
||||
|
||||
// flag handling
|
||||
bool processed() const { return (_flags & Processed) != 0; }
|
||||
bool is_handler() const { return (_flags & Handler) != 0; }
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -34,11 +34,13 @@ private:
|
||||
int _max_locals;
|
||||
int _max_stack;
|
||||
int _code_size;
|
||||
bool _has_irreducible_entry;
|
||||
|
||||
const char* _failure_reason;
|
||||
|
||||
public:
|
||||
class StateVector;
|
||||
class Loop;
|
||||
class Block;
|
||||
|
||||
// Build a type flow analyzer
|
||||
@ -55,6 +57,7 @@ public:
|
||||
int max_stack() const { return _max_stack; }
|
||||
int max_cells() const { return _max_locals + _max_stack; }
|
||||
int code_size() const { return _code_size; }
|
||||
bool has_irreducible_entry() const { return _has_irreducible_entry; }
|
||||
|
||||
// Represents information about an "active" jsr call. This
|
||||
// class represents a call to the routine at some entry address
|
||||
@ -125,6 +128,19 @@ public:
|
||||
void print_on(outputStream* st) const PRODUCT_RETURN;
|
||||
};
|
||||
|
||||
class LocalSet VALUE_OBJ_CLASS_SPEC {
|
||||
private:
|
||||
enum Constants { max = 63 };
|
||||
uint64_t _bits;
|
||||
public:
|
||||
LocalSet() : _bits(0) {}
|
||||
void add(uint32_t i) { if (i < (uint32_t)max) _bits |= (1LL << i); }
|
||||
void add(LocalSet* ls) { _bits |= ls->_bits; }
|
||||
bool test(uint32_t i) const { return i < (uint32_t)max ? (_bits>>i)&1U : true; }
|
||||
void clear() { _bits = 0; }
|
||||
void print_on(outputStream* st, int limit) const PRODUCT_RETURN;
|
||||
};
|
||||
|
||||
// Used as a combined index for locals and temps
|
||||
enum Cell {
|
||||
Cell_0, Cell_max = INT_MAX
|
||||
@ -142,6 +158,8 @@ public:
|
||||
int _trap_bci;
|
||||
int _trap_index;
|
||||
|
||||
LocalSet _def_locals; // For entire block
|
||||
|
||||
static ciType* type_meet_internal(ciType* t1, ciType* t2, ciTypeFlow* analyzer);
|
||||
|
||||
public:
|
||||
@ -181,6 +199,9 @@ public:
|
||||
int monitor_count() const { return _monitor_count; }
|
||||
void set_monitor_count(int mc) { _monitor_count = mc; }
|
||||
|
||||
LocalSet* def_locals() { return &_def_locals; }
|
||||
const LocalSet* def_locals() const { return &_def_locals; }
|
||||
|
||||
static Cell start_cell() { return (Cell)0; }
|
||||
static Cell next_cell(Cell c) { return (Cell)(((int)c) + 1); }
|
||||
Cell limit_cell() const {
|
||||
@ -250,6 +271,10 @@ public:
|
||||
return type->basic_type() == T_DOUBLE;
|
||||
}
|
||||
|
||||
void store_to_local(int lnum) {
|
||||
_def_locals.add((uint) lnum);
|
||||
}
|
||||
|
||||
void push_translate(ciType* type);
|
||||
|
||||
void push_int() {
|
||||
@ -358,6 +383,7 @@ public:
|
||||
"must be reference type or return address");
|
||||
overwrite_local_double_long(index);
|
||||
set_type_at(local(index), type);
|
||||
store_to_local(index);
|
||||
}
|
||||
|
||||
void load_local_double(int index) {
|
||||
@ -376,6 +402,8 @@ public:
|
||||
overwrite_local_double_long(index);
|
||||
set_type_at(local(index), type);
|
||||
set_type_at(local(index+1), type2);
|
||||
store_to_local(index);
|
||||
store_to_local(index+1);
|
||||
}
|
||||
|
||||
void load_local_float(int index) {
|
||||
@ -388,6 +416,7 @@ public:
|
||||
assert(is_float(type), "must be float type");
|
||||
overwrite_local_double_long(index);
|
||||
set_type_at(local(index), type);
|
||||
store_to_local(index);
|
||||
}
|
||||
|
||||
void load_local_int(int index) {
|
||||
@ -400,6 +429,7 @@ public:
|
||||
assert(is_int(type), "must be int type");
|
||||
overwrite_local_double_long(index);
|
||||
set_type_at(local(index), type);
|
||||
store_to_local(index);
|
||||
}
|
||||
|
||||
void load_local_long(int index) {
|
||||
@ -418,6 +448,8 @@ public:
|
||||
overwrite_local_double_long(index);
|
||||
set_type_at(local(index), type);
|
||||
set_type_at(local(index+1), type2);
|
||||
store_to_local(index);
|
||||
store_to_local(index+1);
|
||||
}
|
||||
|
||||
// Stop interpretation of this path with a trap.
|
||||
@ -450,13 +482,31 @@ public:
|
||||
};
|
||||
|
||||
// Parameter for "find_block" calls:
|
||||
// Describes the difference between a public and private copy.
|
||||
// Describes the difference between a public and backedge copy.
|
||||
enum CreateOption {
|
||||
create_public_copy,
|
||||
create_private_copy,
|
||||
create_backedge_copy,
|
||||
no_create
|
||||
};
|
||||
|
||||
// Successor iterator
|
||||
class SuccIter : public StackObj {
|
||||
private:
|
||||
Block* _pred;
|
||||
int _index;
|
||||
Block* _succ;
|
||||
public:
|
||||
SuccIter() : _pred(NULL), _index(-1), _succ(NULL) {}
|
||||
SuccIter(Block* pred) : _pred(pred), _index(-1), _succ(NULL) { next(); }
|
||||
int index() { return _index; }
|
||||
Block* pred() { return _pred; } // Return predecessor
|
||||
bool done() { return _index < 0; } // Finished?
|
||||
Block* succ() { return _succ; } // Return current successor
|
||||
void next(); // Advance
|
||||
void set_succ(Block* succ); // Update current successor
|
||||
bool is_normal_ctrl() { return index() < _pred->successors()->length(); }
|
||||
};
|
||||
|
||||
// A basic block
|
||||
class Block : public ResourceObj {
|
||||
private:
|
||||
@ -470,15 +520,24 @@ public:
|
||||
int _trap_bci;
|
||||
int _trap_index;
|
||||
|
||||
// A reasonable approximation to pre-order, provided.to the client.
|
||||
// pre_order, assigned at first visit. Used as block ID and "visited" tag
|
||||
int _pre_order;
|
||||
|
||||
// Has this block been cloned for some special purpose?
|
||||
bool _private_copy;
|
||||
// A post-order, used to compute the reverse post order (RPO) provided to the client
|
||||
int _post_order; // used to compute rpo
|
||||
|
||||
// Has this block been cloned for a loop backedge?
|
||||
bool _backedge_copy;
|
||||
|
||||
// A pointer used for our internal work list
|
||||
Block* _next;
|
||||
bool _on_work_list;
|
||||
Block* _next;
|
||||
bool _on_work_list; // on the work list
|
||||
Block* _rpo_next; // Reverse post order list
|
||||
|
||||
// Loop info
|
||||
Loop* _loop; // nearest loop
|
||||
bool _irreducible_entry; // entry to irreducible loop
|
||||
bool _exception_entry; // entry to exception handler
|
||||
|
||||
ciBlock* ciblock() const { return _ciblock; }
|
||||
StateVector* state() const { return _state; }
|
||||
@ -504,10 +563,11 @@ public:
|
||||
int start() const { return _ciblock->start_bci(); }
|
||||
int limit() const { return _ciblock->limit_bci(); }
|
||||
int control() const { return _ciblock->control_bci(); }
|
||||
JsrSet* jsrs() const { return _jsrs; }
|
||||
|
||||
bool is_private_copy() const { return _private_copy; }
|
||||
void set_private_copy(bool z);
|
||||
int private_copy_count() const { return outer()->private_copy_count(ciblock()->index(), _jsrs); }
|
||||
bool is_backedge_copy() const { return _backedge_copy; }
|
||||
void set_backedge_copy(bool z);
|
||||
int backedge_copy_count() const { return outer()->backedge_copy_count(ciblock()->index(), _jsrs); }
|
||||
|
||||
// access to entry state
|
||||
int stack_size() const { return _state->stack_size(); }
|
||||
@ -515,6 +575,20 @@ public:
|
||||
ciType* local_type_at(int i) const { return _state->local_type_at(i); }
|
||||
ciType* stack_type_at(int i) const { return _state->stack_type_at(i); }
|
||||
|
||||
// Data flow on locals
|
||||
bool is_invariant_local(uint v) const {
|
||||
assert(is_loop_head(), "only loop heads");
|
||||
// Find outermost loop with same loop head
|
||||
Loop* lp = loop();
|
||||
while (lp->parent() != NULL) {
|
||||
if (lp->parent()->head() != lp->head()) break;
|
||||
lp = lp->parent();
|
||||
}
|
||||
return !lp->def_locals()->test(v);
|
||||
}
|
||||
LocalSet* def_locals() { return _state->def_locals(); }
|
||||
const LocalSet* def_locals() const { return _state->def_locals(); }
|
||||
|
||||
// Get the successors for this Block.
|
||||
GrowableArray<Block*>* successors(ciBytecodeStream* str,
|
||||
StateVector* state,
|
||||
@ -524,13 +598,6 @@ public:
|
||||
return _successors;
|
||||
}
|
||||
|
||||
// Helper function for "successors" when making private copies of
|
||||
// loop heads for C2.
|
||||
Block * clone_loop_head(ciTypeFlow* analyzer,
|
||||
int branch_bci,
|
||||
Block* target,
|
||||
JsrSet* jsrs);
|
||||
|
||||
// Get the exceptional successors for this Block.
|
||||
GrowableArray<Block*>* exceptions() {
|
||||
if (_exceptions == NULL) {
|
||||
@ -584,17 +651,126 @@ public:
|
||||
bool is_on_work_list() const { return _on_work_list; }
|
||||
|
||||
bool has_pre_order() const { return _pre_order >= 0; }
|
||||
void set_pre_order(int po) { assert(!has_pre_order() && po >= 0, ""); _pre_order = po; }
|
||||
void set_pre_order(int po) { assert(!has_pre_order(), ""); _pre_order = po; }
|
||||
int pre_order() const { assert(has_pre_order(), ""); return _pre_order; }
|
||||
void set_next_pre_order() { set_pre_order(outer()->inc_next_pre_order()); }
|
||||
bool is_start() const { return _pre_order == outer()->start_block_num(); }
|
||||
|
||||
// A ranking used in determining order within the work list.
|
||||
bool is_simpler_than(Block* other);
|
||||
// Reverse post order
|
||||
void df_init();
|
||||
bool has_post_order() const { return _post_order >= 0; }
|
||||
void set_post_order(int po) { assert(!has_post_order() && po >= 0, ""); _post_order = po; }
|
||||
void reset_post_order(int o){ _post_order = o; }
|
||||
int post_order() const { assert(has_post_order(), ""); return _post_order; }
|
||||
|
||||
bool has_rpo() const { return has_post_order() && outer()->have_block_count(); }
|
||||
int rpo() const { assert(has_rpo(), ""); return outer()->block_count() - post_order() - 1; }
|
||||
void set_rpo_next(Block* b) { _rpo_next = b; }
|
||||
Block* rpo_next() { return _rpo_next; }
|
||||
|
||||
// Loops
|
||||
Loop* loop() const { return _loop; }
|
||||
void set_loop(Loop* lp) { _loop = lp; }
|
||||
bool is_loop_head() const { return _loop && _loop->head() == this; }
|
||||
void set_irreducible_entry(bool c) { _irreducible_entry = c; }
|
||||
bool is_irreducible_entry() const { return _irreducible_entry; }
|
||||
bool is_visited() const { return has_pre_order(); }
|
||||
bool is_post_visited() const { return has_post_order(); }
|
||||
bool is_clonable_exit(Loop* lp);
|
||||
Block* looping_succ(Loop* lp); // Successor inside of loop
|
||||
bool is_single_entry_loop_head() const {
|
||||
if (!is_loop_head()) return false;
|
||||
for (Loop* lp = loop(); lp != NULL && lp->head() == this; lp = lp->parent())
|
||||
if (lp->is_irreducible()) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
void print_value_on(outputStream* st) const PRODUCT_RETURN;
|
||||
void print_on(outputStream* st) const PRODUCT_RETURN;
|
||||
};
|
||||
|
||||
// Loop
|
||||
class Loop : public ResourceObj {
|
||||
private:
|
||||
Loop* _parent;
|
||||
Loop* _sibling; // List of siblings, null terminated
|
||||
Loop* _child; // Head of child list threaded thru sibling pointer
|
||||
Block* _head; // Head of loop
|
||||
Block* _tail; // Tail of loop
|
||||
bool _irreducible;
|
||||
LocalSet _def_locals;
|
||||
|
||||
public:
|
||||
Loop(Block* head, Block* tail) :
|
||||
_head(head), _tail(tail),
|
||||
_parent(NULL), _sibling(NULL), _child(NULL),
|
||||
_irreducible(false), _def_locals() {}
|
||||
|
||||
Loop* parent() const { return _parent; }
|
||||
Loop* sibling() const { return _sibling; }
|
||||
Loop* child() const { return _child; }
|
||||
Block* head() const { return _head; }
|
||||
Block* tail() const { return _tail; }
|
||||
void set_parent(Loop* p) { _parent = p; }
|
||||
void set_sibling(Loop* s) { _sibling = s; }
|
||||
void set_child(Loop* c) { _child = c; }
|
||||
void set_head(Block* hd) { _head = hd; }
|
||||
void set_tail(Block* tl) { _tail = tl; }
|
||||
|
||||
int depth() const; // nesting depth
|
||||
|
||||
// Returns true if lp is a nested loop or us.
|
||||
bool contains(Loop* lp) const;
|
||||
bool contains(Block* blk) const { return contains(blk->loop()); }
|
||||
|
||||
// Data flow on locals
|
||||
LocalSet* def_locals() { return &_def_locals; }
|
||||
const LocalSet* def_locals() const { return &_def_locals; }
|
||||
|
||||
// Merge the branch lp into this branch, sorting on the loop head
|
||||
// pre_orders. Returns the new branch.
|
||||
Loop* sorted_merge(Loop* lp);
|
||||
|
||||
// Mark non-single entry to loop
|
||||
void set_irreducible(Block* entry) {
|
||||
_irreducible = true;
|
||||
entry->set_irreducible_entry(true);
|
||||
}
|
||||
bool is_irreducible() const { return _irreducible; }
|
||||
|
||||
bool is_root() const { return _tail->pre_order() == max_jint; }
|
||||
|
||||
void print(outputStream* st = tty, int indent = 0) const PRODUCT_RETURN;
|
||||
};
|
||||
|
||||
// Postorder iteration over the loop tree.
|
||||
class PostorderLoops : public StackObj {
|
||||
private:
|
||||
Loop* _root;
|
||||
Loop* _current;
|
||||
public:
|
||||
PostorderLoops(Loop* root) : _root(root), _current(root) {
|
||||
while (_current->child() != NULL) {
|
||||
_current = _current->child();
|
||||
}
|
||||
}
|
||||
bool done() { return _current == NULL; } // Finished iterating?
|
||||
void next(); // Advance to next loop
|
||||
Loop* current() { return _current; } // Return current loop.
|
||||
};
|
||||
|
||||
// Preorder iteration over the loop tree.
|
||||
class PreorderLoops : public StackObj {
|
||||
private:
|
||||
Loop* _root;
|
||||
Loop* _current;
|
||||
public:
|
||||
PreorderLoops(Loop* root) : _root(root), _current(root) {}
|
||||
bool done() { return _current == NULL; } // Finished iterating?
|
||||
void next(); // Advance to next loop
|
||||
Loop* current() { return _current; } // Return current loop.
|
||||
};
|
||||
|
||||
// Standard indexes of successors, for various bytecodes.
|
||||
enum {
|
||||
FALL_THROUGH = 0, // normal control
|
||||
@ -619,6 +795,12 @@ private:
|
||||
// Tells if a given instruction is able to generate an exception edge.
|
||||
bool can_trap(ciBytecodeStream& str);
|
||||
|
||||
// Clone the loop heads. Returns true if any cloning occurred.
|
||||
bool clone_loop_heads(Loop* lp, StateVector* temp_vector, JsrSet* temp_set);
|
||||
|
||||
// Clone lp's head and replace tail's successors with clone.
|
||||
Block* clone_loop_head(Loop* lp, StateVector* temp_vector, JsrSet* temp_set);
|
||||
|
||||
public:
|
||||
// Return the block beginning at bci which has a JsrSet compatible
|
||||
// with jsrs.
|
||||
@ -627,8 +809,8 @@ public:
|
||||
// block factory
|
||||
Block* get_block_for(int ciBlockIndex, JsrSet* jsrs, CreateOption option = create_public_copy);
|
||||
|
||||
// How many of the blocks have the private_copy bit set?
|
||||
int private_copy_count(int ciBlockIndex, JsrSet* jsrs) const;
|
||||
// How many of the blocks have the backedge_copy bit set?
|
||||
int backedge_copy_count(int ciBlockIndex, JsrSet* jsrs) const;
|
||||
|
||||
// Return an existing block containing bci which has a JsrSet compatible
|
||||
// with jsrs, or NULL if there is none.
|
||||
@ -651,11 +833,18 @@ public:
|
||||
return _block_map[po]; }
|
||||
Block* start_block() const { return pre_order_at(start_block_num()); }
|
||||
int start_block_num() const { return 0; }
|
||||
Block* rpo_at(int rpo) const { assert(0 <= rpo && rpo < block_count(), "out of bounds");
|
||||
return _block_map[rpo]; }
|
||||
int next_pre_order() { return _next_pre_order; }
|
||||
int inc_next_pre_order() { return _next_pre_order++; }
|
||||
|
||||
private:
|
||||
// A work list used during flow analysis.
|
||||
Block* _work_list;
|
||||
|
||||
// List of blocks in reverse post order
|
||||
Block* _rpo_list;
|
||||
|
||||
// Next Block::_pre_order. After mapping, doubles as block_count.
|
||||
int _next_pre_order;
|
||||
|
||||
@ -668,6 +857,15 @@ private:
|
||||
// Add a basic block to our work list.
|
||||
void add_to_work_list(Block* block);
|
||||
|
||||
// Prepend a basic block to rpo list.
|
||||
void prepend_to_rpo_list(Block* blk) {
|
||||
blk->set_rpo_next(_rpo_list);
|
||||
_rpo_list = blk;
|
||||
}
|
||||
|
||||
// Root of the loop tree
|
||||
Loop* _loop_tree_root;
|
||||
|
||||
// State used for make_jsr_record
|
||||
int _jsr_count;
|
||||
GrowableArray<JsrRecord*>* _jsr_records;
|
||||
@ -677,6 +875,9 @@ public:
|
||||
// does not already exist.
|
||||
JsrRecord* make_jsr_record(int entry_address, int return_address);
|
||||
|
||||
void set_loop_tree_root(Loop* ltr) { _loop_tree_root = ltr; }
|
||||
Loop* loop_tree_root() { return _loop_tree_root; }
|
||||
|
||||
private:
|
||||
// Get the initial state for start_bci:
|
||||
const StateVector* get_start_state();
|
||||
@ -703,6 +904,15 @@ private:
|
||||
// necessary.
|
||||
void flow_types();
|
||||
|
||||
// Perform the depth first type flow analysis. Helper for flow_types.
|
||||
void df_flow_types(Block* start,
|
||||
bool do_flow,
|
||||
StateVector* temp_vector,
|
||||
JsrSet* temp_set);
|
||||
|
||||
// Incrementally build loop tree.
|
||||
void build_loop_tree(Block* blk);
|
||||
|
||||
// Create the block map, which indexes blocks in pre_order.
|
||||
void map_blocks();
|
||||
|
||||
@ -711,4 +921,6 @@ public:
|
||||
void do_flow();
|
||||
|
||||
void print_on(outputStream* st) const PRODUCT_RETURN;
|
||||
|
||||
void rpo_print_on(outputStream* st) const PRODUCT_RETURN;
|
||||
};
|
||||
|
@ -582,6 +582,7 @@ locknode.hpp subnode.hpp
|
||||
loopTransform.cpp addnode.hpp
|
||||
loopTransform.cpp allocation.inline.hpp
|
||||
loopTransform.cpp connode.hpp
|
||||
loopTransform.cpp compileLog.hpp
|
||||
loopTransform.cpp divnode.hpp
|
||||
loopTransform.cpp loopnode.hpp
|
||||
loopTransform.cpp mulnode.hpp
|
||||
@ -597,6 +598,7 @@ loopnode.cpp addnode.hpp
|
||||
loopnode.cpp allocation.inline.hpp
|
||||
loopnode.cpp callnode.hpp
|
||||
loopnode.cpp ciMethodData.hpp
|
||||
loopnode.cpp compileLog.hpp
|
||||
loopnode.cpp connode.hpp
|
||||
loopnode.cpp divnode.hpp
|
||||
loopnode.cpp loopnode.hpp
|
||||
|
@ -25,19 +25,6 @@
|
||||
#include "incls/_precompiled.incl"
|
||||
#include "incls/_bytecodeInfo.cpp.incl"
|
||||
|
||||
// These variables are declared in parse1.cpp
|
||||
extern int explicit_null_checks_inserted;
|
||||
extern int explicit_null_checks_elided;
|
||||
extern int explicit_null_checks_inserted_old;
|
||||
extern int explicit_null_checks_elided_old;
|
||||
extern int nodes_created_old;
|
||||
extern int nodes_created;
|
||||
extern int methods_parsed_old;
|
||||
extern int methods_parsed;
|
||||
extern int methods_seen;
|
||||
extern int methods_seen_old;
|
||||
|
||||
|
||||
//=============================================================================
|
||||
//------------------------------InlineTree-------------------------------------
|
||||
InlineTree::InlineTree( Compile* c, const InlineTree *caller_tree, ciMethod* callee, JVMState* caller_jvms, int caller_bci, float site_invoke_ratio )
|
||||
@ -517,27 +504,3 @@ InlineTree* InlineTree::find_subtree_from_root(InlineTree* root, JVMState* jvms,
|
||||
}
|
||||
return iltp;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
#ifndef PRODUCT
|
||||
|
||||
static void per_method_stats() {
|
||||
// Compute difference between this method's cumulative totals and old totals
|
||||
int explicit_null_checks_cur = explicit_null_checks_inserted - explicit_null_checks_inserted_old;
|
||||
int elided_null_checks_cur = explicit_null_checks_elided - explicit_null_checks_elided_old;
|
||||
|
||||
// Print differences
|
||||
if( explicit_null_checks_cur )
|
||||
tty->print_cr("XXX Explicit NULL checks inserted: %d", explicit_null_checks_cur);
|
||||
if( elided_null_checks_cur )
|
||||
tty->print_cr("XXX Explicit NULL checks removed at parse time: %d", elided_null_checks_cur);
|
||||
|
||||
// Store the current cumulative totals
|
||||
nodes_created_old = nodes_created;
|
||||
methods_parsed_old = methods_parsed;
|
||||
methods_seen_old = methods_seen;
|
||||
explicit_null_checks_inserted_old = explicit_null_checks_inserted;
|
||||
explicit_null_checks_elided_old = explicit_null_checks_elided;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1665,7 +1665,11 @@ Node *PhiNode::Ideal(PhaseGVN *phase, bool can_reshape) {
|
||||
// compress paths and change unreachable cycles to TOP
|
||||
// If not, we can update the input infinitely along a MergeMem cycle
|
||||
// Equivalent code is in MemNode::Ideal_common
|
||||
Node *m = phase->transform(n);
|
||||
Node *m = phase->transform(n);
|
||||
if (outcnt() == 0) { // Above transform() may kill us!
|
||||
progress = phase->C->top();
|
||||
break;
|
||||
}
|
||||
// If tranformed to a MergeMem, get the desired slice
|
||||
// Otherwise the returned node represents memory for every slice
|
||||
Node *new_mem = (m->is_MergeMem()) ?
|
||||
|
@ -467,6 +467,7 @@ Compile::Compile( ciEnv* ci_env, C2Compiler* compiler, ciMethod* target, int osr
|
||||
}
|
||||
}
|
||||
set_print_assembly(print_opto_assembly);
|
||||
set_parsed_irreducible_loop(false);
|
||||
#endif
|
||||
|
||||
if (ProfileTraps) {
|
||||
@ -550,6 +551,8 @@ Compile::Compile( ciEnv* ci_env, C2Compiler* compiler, ciMethod* target, int osr
|
||||
rethrow_exceptions(kit.transfer_exceptions_into_jvms());
|
||||
}
|
||||
|
||||
print_method("Before RemoveUseless");
|
||||
|
||||
// Remove clutter produced by parsing.
|
||||
if (!failing()) {
|
||||
ResourceMark rm;
|
||||
@ -615,8 +618,6 @@ Compile::Compile( ciEnv* ci_env, C2Compiler* compiler, ciMethod* target, int osr
|
||||
if (failing()) return;
|
||||
NOT_PRODUCT( verify_graph_edges(); )
|
||||
|
||||
print_method("Before Matching");
|
||||
|
||||
#ifndef PRODUCT
|
||||
if (PrintIdeal) {
|
||||
ttyLocker ttyl; // keep the following output all in one block
|
||||
@ -720,6 +721,7 @@ Compile::Compile( ciEnv* ci_env,
|
||||
TraceTime t1(NULL, &_t_totalCompilation, TimeCompiler, false);
|
||||
TraceTime t2(NULL, &_t_stubCompilation, TimeCompiler, false);
|
||||
set_print_assembly(PrintFrameConverterAssembly);
|
||||
set_parsed_irreducible_loop(false);
|
||||
#endif
|
||||
CompileWrapper cw(this);
|
||||
Init(/*AliasLevel=*/ 0);
|
||||
|
@ -160,6 +160,7 @@ class Compile : public Phase {
|
||||
bool _print_assembly; // True if we should dump assembly code for this compilation
|
||||
#ifndef PRODUCT
|
||||
bool _trace_opto_output;
|
||||
bool _parsed_irreducible_loop; // True if ciTypeFlow detected irreducible loops during parsing
|
||||
#endif
|
||||
|
||||
// Compilation environment.
|
||||
@ -319,6 +320,8 @@ class Compile : public Phase {
|
||||
}
|
||||
#ifndef PRODUCT
|
||||
bool trace_opto_output() const { return _trace_opto_output; }
|
||||
bool parsed_irreducible_loop() const { return _parsed_irreducible_loop; }
|
||||
void set_parsed_irreducible_loop(bool z) { _parsed_irreducible_loop = z; }
|
||||
#endif
|
||||
|
||||
void begin_method() {
|
||||
|
@ -795,7 +795,7 @@ ciMethod* Parse::optimize_inlining(ciMethod* caller, int bci, ciInstanceKlass* k
|
||||
|
||||
ciInstanceKlass *ikl = receiver_type->klass()->as_instance_klass();
|
||||
if (ikl->is_loaded() && ikl->is_initialized() && !ikl->is_interface() &&
|
||||
(ikl == actual_receiver || ikl->is_subclass_of(actual_receiver))) {
|
||||
(ikl == actual_receiver || ikl->is_subtype_of(actual_receiver))) {
|
||||
// ikl is a same or better type than the original actual_receiver,
|
||||
// e.g. static receiver from bytecodes.
|
||||
actual_receiver = ikl;
|
||||
|
@ -587,7 +587,7 @@ PreserveJVMState::PreserveJVMState(GraphKit* kit, bool clone_map) {
|
||||
#ifdef ASSERT
|
||||
_bci = kit->bci();
|
||||
Parse* parser = kit->is_Parse();
|
||||
int block = (parser == NULL || parser->block() == NULL) ? -1 : parser->block()->pre_order();
|
||||
int block = (parser == NULL || parser->block() == NULL) ? -1 : parser->block()->rpo();
|
||||
_block = block;
|
||||
#endif
|
||||
}
|
||||
@ -596,7 +596,7 @@ PreserveJVMState::~PreserveJVMState() {
|
||||
#ifdef ASSERT
|
||||
assert(kit->bci() == _bci, "bci must not shift");
|
||||
Parse* parser = kit->is_Parse();
|
||||
int block = (parser == NULL || parser->block() == NULL) ? -1 : parser->block()->pre_order();
|
||||
int block = (parser == NULL || parser->block() == NULL) ? -1 : parser->block()->rpo();
|
||||
assert(block == _block, "block must not shift");
|
||||
#endif
|
||||
kit->set_map(_map);
|
||||
|
@ -1012,6 +1012,8 @@ void PhaseIdealLoop::do_unroll( IdealLoopTree *loop, Node_List &old_new, bool ad
|
||||
if (!has_ctrl(old))
|
||||
set_loop(nnn, loop);
|
||||
}
|
||||
|
||||
loop->record_for_igvn();
|
||||
}
|
||||
|
||||
//------------------------------do_maximally_unroll----------------------------
|
||||
|
@ -1279,7 +1279,7 @@ void IdealLoopTree::counted_loop( PhaseIdealLoop *phase ) {
|
||||
// Visit all children, looking for Phis
|
||||
for (DUIterator i = cl->outs(); cl->has_out(i); i++) {
|
||||
Node *out = cl->out(i);
|
||||
if (!out->is_Phi()) continue; // Looking for phis
|
||||
if (!out->is_Phi() || out == phi) continue; // Looking for other phis
|
||||
PhiNode* phi2 = out->as_Phi();
|
||||
Node *incr2 = phi2->in( LoopNode::LoopBackControl );
|
||||
// Look for induction variables of the form: X += constant
|
||||
@ -1388,6 +1388,37 @@ void IdealLoopTree::dump( ) const {
|
||||
|
||||
#endif
|
||||
|
||||
static void log_loop_tree(IdealLoopTree* root, IdealLoopTree* loop, CompileLog* log) {
|
||||
if (loop == root) {
|
||||
if (loop->_child != NULL) {
|
||||
log->begin_head("loop_tree");
|
||||
log->end_head();
|
||||
if( loop->_child ) log_loop_tree(root, loop->_child, log);
|
||||
log->tail("loop_tree");
|
||||
assert(loop->_next == NULL, "what?");
|
||||
}
|
||||
} else {
|
||||
Node* head = loop->_head;
|
||||
log->begin_head("loop");
|
||||
log->print(" idx='%d' ", head->_idx);
|
||||
if (loop->_irreducible) log->print("irreducible='1' ");
|
||||
if (head->is_Loop()) {
|
||||
if (head->as_Loop()->is_inner_loop()) log->print("inner_loop='1' ");
|
||||
if (head->as_Loop()->is_partial_peel_loop()) log->print("partial_peel_loop='1' ");
|
||||
}
|
||||
if (head->is_CountedLoop()) {
|
||||
CountedLoopNode* cl = head->as_CountedLoop();
|
||||
if (cl->is_pre_loop()) log->print("pre_loop='%d' ", cl->main_idx());
|
||||
if (cl->is_main_loop()) log->print("main_loop='%d' ", cl->_idx);
|
||||
if (cl->is_post_loop()) log->print("post_loop='%d' ", cl->main_idx());
|
||||
}
|
||||
log->end_head();
|
||||
if( loop->_child ) log_loop_tree(root, loop->_child, log);
|
||||
log->tail("loop");
|
||||
if( loop->_next ) log_loop_tree(root, loop->_next, log);
|
||||
}
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//------------------------------PhaseIdealLoop---------------------------------
|
||||
// Create a PhaseLoop. Build the ideal Loop tree. Map each Ideal Node to
|
||||
@ -1624,10 +1655,13 @@ PhaseIdealLoop::PhaseIdealLoop( PhaseIterGVN &igvn, const PhaseIdealLoop *verify
|
||||
// Cleanup any modified bits
|
||||
_igvn.optimize();
|
||||
|
||||
// Do not repeat loop optimizations if irreducible loops are present
|
||||
// by claiming no-progress.
|
||||
if( _has_irreducible_loops )
|
||||
C->clear_major_progress();
|
||||
// disable assert until issue with split_flow_path is resolved (6742111)
|
||||
// assert(!_has_irreducible_loops || C->parsed_irreducible_loop() || C->is_osr_compilation(),
|
||||
// "shouldn't introduce irreducible loops");
|
||||
|
||||
if (C->log() != NULL) {
|
||||
log_loop_tree(_ltree_root, _ltree_root, C->log());
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef PRODUCT
|
||||
@ -2732,11 +2766,7 @@ void PhaseIdealLoop::dump( ) const {
|
||||
}
|
||||
|
||||
void PhaseIdealLoop::dump( IdealLoopTree *loop, uint idx, Node_List &rpo_list ) const {
|
||||
|
||||
// Indent by loop nesting depth
|
||||
for( uint x = 0; x < loop->_nest; x++ )
|
||||
tty->print(" ");
|
||||
tty->print_cr("---- Loop N%d-N%d ----", loop->_head->_idx,loop->_tail->_idx);
|
||||
loop->dump_head();
|
||||
|
||||
// Now scan for CFG nodes in the same loop
|
||||
for( uint j=idx; j > 0; j-- ) {
|
||||
|
@ -192,6 +192,8 @@ public:
|
||||
int is_main_no_pre_loop() const { return _loop_flags & Main_Has_No_Pre_Loop; }
|
||||
void set_main_no_pre_loop() { _loop_flags |= Main_Has_No_Pre_Loop; }
|
||||
|
||||
int main_idx() const { return _main_idx; }
|
||||
|
||||
|
||||
void set_pre_loop (CountedLoopNode *main) { assert(is_normal_loop(),""); _loop_flags |= Pre ; _main_idx = main->_idx; }
|
||||
void set_main_loop ( ) { assert(is_normal_loop(),""); _loop_flags |= Main; }
|
||||
|
@ -2667,6 +2667,10 @@ void PhaseIdealLoop::reorg_offsets( IdealLoopTree *loop ) {
|
||||
// Fix this by adjusting to use the post-increment trip counter.
|
||||
Node *phi = cl->phi();
|
||||
if( !phi ) return; // Dead infinite loop
|
||||
|
||||
// Shape messed up, probably by iteration_split_impl
|
||||
if (phi->in(LoopNode::LoopBackControl) != cl->incr()) return;
|
||||
|
||||
bool progress = true;
|
||||
while (progress) {
|
||||
progress = false;
|
||||
|
@ -273,7 +273,7 @@ void Matcher::match( ) {
|
||||
find_shared( C->root() );
|
||||
find_shared( C->top() );
|
||||
|
||||
C->print_method("Before Matching", 2);
|
||||
C->print_method("Before Matching");
|
||||
|
||||
// Swap out to old-space; emptying new-space
|
||||
Arena *old = C->node_arena()->move_contents(C->old_arena());
|
||||
|
@ -167,9 +167,19 @@ class Parse : public GraphKit {
|
||||
|
||||
int start() const { return flow()->start(); }
|
||||
int limit() const { return flow()->limit(); }
|
||||
int pre_order() const { return flow()->pre_order(); }
|
||||
int rpo() const { return flow()->rpo(); }
|
||||
int start_sp() const { return flow()->stack_size(); }
|
||||
|
||||
bool is_loop_head() const { return flow()->is_loop_head(); }
|
||||
bool is_SEL_head() const { return flow()->is_single_entry_loop_head(); }
|
||||
bool is_SEL_backedge(Block* pred) const{ return is_SEL_head() && pred->rpo() >= rpo(); }
|
||||
bool is_invariant_local(uint i) const {
|
||||
const JVMState* jvms = start_map()->jvms();
|
||||
if (!jvms->is_loc(i)) return false;
|
||||
return flow()->is_invariant_local(i - jvms->locoff());
|
||||
}
|
||||
bool can_elide_SEL_phi(uint i) const { assert(is_SEL_head(),""); return is_invariant_local(i); }
|
||||
|
||||
const Type* peek(int off=0) const { return stack_type_at(start_sp() - (off+1)); }
|
||||
|
||||
const Type* stack_type_at(int i) const;
|
||||
@ -305,7 +315,7 @@ class Parse : public GraphKit {
|
||||
// entry_bci() -- see osr_bci, etc.
|
||||
|
||||
ciTypeFlow* flow() const { return _flow; }
|
||||
// blocks() -- see pre_order_at, start_block, etc.
|
||||
// blocks() -- see rpo_at, start_block, etc.
|
||||
int block_count() const { return _block_count; }
|
||||
|
||||
GraphKit& exits() { return _exits; }
|
||||
@ -330,12 +340,12 @@ class Parse : public GraphKit {
|
||||
// Must this parse be aborted?
|
||||
bool failing() { return C->failing(); }
|
||||
|
||||
Block* pre_order_at(int po) {
|
||||
assert(0 <= po && po < _block_count, "oob");
|
||||
return &_blocks[po];
|
||||
Block* rpo_at(int rpo) {
|
||||
assert(0 <= rpo && rpo < _block_count, "oob");
|
||||
return &_blocks[rpo];
|
||||
}
|
||||
Block* start_block() {
|
||||
return pre_order_at(flow()->start_block()->pre_order());
|
||||
return rpo_at(flow()->start_block()->rpo());
|
||||
}
|
||||
// Can return NULL if the flow pass did not complete a block.
|
||||
Block* successor_for_bci(int bci) {
|
||||
@ -359,9 +369,6 @@ class Parse : public GraphKit {
|
||||
// Parse all the basic blocks.
|
||||
void do_all_blocks();
|
||||
|
||||
// Helper for do_all_blocks; makes one pass in pre-order.
|
||||
void visit_blocks();
|
||||
|
||||
// Parse the current basic block
|
||||
void do_one_block();
|
||||
|
||||
|
@ -29,17 +29,17 @@
|
||||
// the most. Some of the non-static variables are needed in bytecodeInfo.cpp
|
||||
// and eventually should be encapsulated in a proper class (gri 8/18/98).
|
||||
|
||||
int nodes_created = 0; int nodes_created_old = 0;
|
||||
int methods_parsed = 0; int methods_parsed_old = 0;
|
||||
int methods_seen = 0; int methods_seen_old = 0;
|
||||
int nodes_created = 0;
|
||||
int methods_parsed = 0;
|
||||
int methods_seen = 0;
|
||||
int blocks_parsed = 0;
|
||||
int blocks_seen = 0;
|
||||
|
||||
int explicit_null_checks_inserted = 0, explicit_null_checks_inserted_old = 0;
|
||||
int explicit_null_checks_elided = 0, explicit_null_checks_elided_old = 0;
|
||||
int explicit_null_checks_inserted = 0;
|
||||
int explicit_null_checks_elided = 0;
|
||||
int all_null_checks_found = 0, implicit_null_checks = 0;
|
||||
int implicit_null_throws = 0;
|
||||
|
||||
int parse_idx = 0;
|
||||
size_t parse_arena = 0;
|
||||
int reclaim_idx = 0;
|
||||
int reclaim_in = 0;
|
||||
int reclaim_node = 0;
|
||||
@ -61,6 +61,7 @@ void Parse::print_statistics() {
|
||||
tty->cr();
|
||||
if (methods_seen != methods_parsed)
|
||||
tty->print_cr("Reasons for parse failures (NOT cumulative):");
|
||||
tty->print_cr("Blocks parsed: %d Blocks seen: %d", blocks_parsed, blocks_seen);
|
||||
|
||||
if( explicit_null_checks_inserted )
|
||||
tty->print_cr("%d original NULL checks - %d elided (%2d%%); optimizer leaves %d,", explicit_null_checks_inserted, explicit_null_checks_elided, (100*explicit_null_checks_elided)/explicit_null_checks_inserted, all_null_checks_found);
|
||||
@ -373,6 +374,12 @@ Parse::Parse(JVMState* caller, ciMethod* parse_method, float expected_uses)
|
||||
C->record_method_not_compilable_all_tiers(_flow->failure_reason());
|
||||
}
|
||||
|
||||
#ifndef PRODUCT
|
||||
if (_flow->has_irreducible_entry()) {
|
||||
C->set_parsed_irreducible_loop(true);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (_expected_uses <= 0) {
|
||||
_prof_factor = 1;
|
||||
} else {
|
||||
@ -556,118 +563,93 @@ Parse::Parse(JVMState* caller, ciMethod* parse_method, float expected_uses)
|
||||
set_map(entry_map);
|
||||
do_exits();
|
||||
|
||||
// Collect a few more statistics.
|
||||
parse_idx += C->unique();
|
||||
parse_arena += C->node_arena()->used();
|
||||
|
||||
if (log) log->done("parse nodes='%d' memory='%d'",
|
||||
C->unique(), C->node_arena()->used());
|
||||
}
|
||||
|
||||
//---------------------------do_all_blocks-------------------------------------
|
||||
void Parse::do_all_blocks() {
|
||||
_blocks_merged = 0;
|
||||
_blocks_parsed = 0;
|
||||
bool has_irreducible = flow()->has_irreducible_entry();
|
||||
|
||||
int old_blocks_merged = -1;
|
||||
int old_blocks_parsed = -1;
|
||||
// Walk over all blocks in Reverse Post-Order.
|
||||
while (true) {
|
||||
bool progress = false;
|
||||
for (int rpo = 0; rpo < block_count(); rpo++) {
|
||||
Block* block = rpo_at(rpo);
|
||||
|
||||
for (int tries = 0; ; tries++) {
|
||||
visit_blocks();
|
||||
if (failing()) return; // Check for bailout
|
||||
if (block->is_parsed()) continue;
|
||||
|
||||
// No need for a work list. The outer loop is hardly ever repeated.
|
||||
// The following loop traverses the blocks in a reasonable pre-order,
|
||||
// as produced by the ciTypeFlow pass.
|
||||
|
||||
// This loop can be taken more than once if there are two entries to
|
||||
// a loop (irreduceable CFG), and the edge which ciTypeFlow chose
|
||||
// as the first predecessor to the loop goes dead in the parser,
|
||||
// due to parse-time optimization. (Could happen with obfuscated code.)
|
||||
|
||||
// Look for progress, or the lack of it:
|
||||
if (_blocks_parsed == block_count()) {
|
||||
// That's all, folks.
|
||||
if (TraceOptoParse) {
|
||||
tty->print_cr("All blocks parsed.");
|
||||
if (!block->is_merged()) {
|
||||
// Dead block, no state reaches this block
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
|
||||
// Prepare to parse this block.
|
||||
load_state_from(block);
|
||||
|
||||
if (stopped()) {
|
||||
// Block is dead.
|
||||
continue;
|
||||
}
|
||||
|
||||
blocks_parsed++;
|
||||
|
||||
progress = true;
|
||||
if (block->is_loop_head() || block->is_handler() || has_irreducible && !block->is_ready()) {
|
||||
// Not all preds have been parsed. We must build phis everywhere.
|
||||
// (Note that dead locals do not get phis built, ever.)
|
||||
ensure_phis_everywhere();
|
||||
|
||||
// Leave behind an undisturbed copy of the map, for future merges.
|
||||
set_map(clone_map());
|
||||
}
|
||||
|
||||
if (control()->is_Region() && !block->is_loop_head() && !has_irreducible && !block->is_handler()) {
|
||||
// In the absence of irreducible loops, the Region and Phis
|
||||
// associated with a merge that doesn't involve a backedge can
|
||||
// be simplfied now since the RPO parsing order guarantees
|
||||
// that any path which was supposed to reach here has already
|
||||
// been parsed or must be dead.
|
||||
Node* c = control();
|
||||
Node* result = _gvn.transform_no_reclaim(control());
|
||||
if (c != result && TraceOptoParse) {
|
||||
tty->print_cr("Block #%d replace %d with %d", block->rpo(), c->_idx, result->_idx);
|
||||
}
|
||||
if (result != top()) {
|
||||
record_for_igvn(result);
|
||||
}
|
||||
}
|
||||
|
||||
// Parse the block.
|
||||
do_one_block();
|
||||
|
||||
// Check for bailouts.
|
||||
if (failing()) return;
|
||||
}
|
||||
|
||||
// How much work was done this time around?
|
||||
int new_blocks_merged = _blocks_merged - old_blocks_merged;
|
||||
int new_blocks_parsed = _blocks_parsed - old_blocks_parsed;
|
||||
if (new_blocks_merged == 0) {
|
||||
if (TraceOptoParse) {
|
||||
tty->print_cr("All live blocks parsed; %d dead blocks.", block_count() - _blocks_parsed);
|
||||
}
|
||||
// No new blocks have become parseable. Some blocks are just dead.
|
||||
// with irreducible loops multiple passes might be necessary to parse everything
|
||||
if (!has_irreducible || !progress) {
|
||||
break;
|
||||
}
|
||||
assert(new_blocks_parsed > 0, "must make progress");
|
||||
assert(tries < block_count(), "the pre-order cannot be this bad!");
|
||||
|
||||
old_blocks_merged = _blocks_merged;
|
||||
old_blocks_parsed = _blocks_parsed;
|
||||
}
|
||||
|
||||
blocks_seen += block_count();
|
||||
|
||||
#ifndef PRODUCT
|
||||
// Make sure there are no half-processed blocks remaining.
|
||||
// Every remaining unprocessed block is dead and may be ignored now.
|
||||
for (int po = 0; po < block_count(); po++) {
|
||||
Block* block = pre_order_at(po);
|
||||
for (int rpo = 0; rpo < block_count(); rpo++) {
|
||||
Block* block = rpo_at(rpo);
|
||||
if (!block->is_parsed()) {
|
||||
if (TraceOptoParse) {
|
||||
tty->print("Skipped dead block %d at bci:%d", po, block->start());
|
||||
assert(!block->is_merged(), "no half-processed blocks");
|
||||
tty->print_cr("Skipped dead block %d at bci:%d", rpo, block->start());
|
||||
}
|
||||
assert(!block->is_merged(), "no half-processed blocks");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
//---------------------------visit_blocks--------------------------------------
|
||||
void Parse::visit_blocks() {
|
||||
// Walk over all blocks, parsing every one that has been reached (merged).
|
||||
for (int po = 0; po < block_count(); po++) {
|
||||
Block* block = pre_order_at(po);
|
||||
|
||||
if (block->is_parsed()) {
|
||||
// Do not parse twice.
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!block->is_merged()) {
|
||||
// No state on this block. It had not yet been reached.
|
||||
// Delay reaching it until later.
|
||||
continue;
|
||||
}
|
||||
|
||||
// Prepare to parse this block.
|
||||
load_state_from(block);
|
||||
|
||||
if (stopped()) {
|
||||
// Block is dead.
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!block->is_ready() || block->is_handler()) {
|
||||
// Not all preds have been parsed. We must build phis everywhere.
|
||||
// (Note that dead locals do not get phis built, ever.)
|
||||
ensure_phis_everywhere();
|
||||
|
||||
// Leave behind an undisturbed copy of the map, for future merges.
|
||||
set_map(clone_map());
|
||||
}
|
||||
|
||||
// Ready or not, parse the block.
|
||||
do_one_block();
|
||||
|
||||
// Check for bailouts.
|
||||
if (failing()) return;
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------build_exits----------------------------------
|
||||
// Build normal and exceptional exit merge points.
|
||||
void Parse::build_exits() {
|
||||
@ -1134,24 +1116,24 @@ void Parse::init_blocks() {
|
||||
_blocks = NEW_RESOURCE_ARRAY(Block, _block_count);
|
||||
Copy::zero_to_bytes(_blocks, sizeof(Block)*_block_count);
|
||||
|
||||
int po;
|
||||
int rpo;
|
||||
|
||||
// Initialize the structs.
|
||||
for (po = 0; po < block_count(); po++) {
|
||||
Block* block = pre_order_at(po);
|
||||
block->init_node(this, po);
|
||||
for (rpo = 0; rpo < block_count(); rpo++) {
|
||||
Block* block = rpo_at(rpo);
|
||||
block->init_node(this, rpo);
|
||||
}
|
||||
|
||||
// Collect predecessor and successor information.
|
||||
for (po = 0; po < block_count(); po++) {
|
||||
Block* block = pre_order_at(po);
|
||||
for (rpo = 0; rpo < block_count(); rpo++) {
|
||||
Block* block = rpo_at(rpo);
|
||||
block->init_graph(this);
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------init_node-------------------------------------
|
||||
void Parse::Block::init_node(Parse* outer, int po) {
|
||||
_flow = outer->flow()->pre_order_at(po);
|
||||
void Parse::Block::init_node(Parse* outer, int rpo) {
|
||||
_flow = outer->flow()->rpo_at(rpo);
|
||||
_pred_count = 0;
|
||||
_preds_parsed = 0;
|
||||
_count = 0;
|
||||
@ -1177,7 +1159,7 @@ void Parse::Block::init_graph(Parse* outer) {
|
||||
int p = 0;
|
||||
for (int i = 0; i < ns+ne; i++) {
|
||||
ciTypeFlow::Block* tf2 = (i < ns) ? tfs->at(i) : tfe->at(i-ns);
|
||||
Block* block2 = outer->pre_order_at(tf2->pre_order());
|
||||
Block* block2 = outer->rpo_at(tf2->rpo());
|
||||
_successors[i] = block2;
|
||||
|
||||
// Accumulate pred info for the other block, too.
|
||||
@ -1368,10 +1350,11 @@ void Parse::do_one_block() {
|
||||
int nt = b->all_successors();
|
||||
|
||||
tty->print("Parsing block #%d at bci [%d,%d), successors: ",
|
||||
block()->pre_order(), block()->start(), block()->limit());
|
||||
block()->rpo(), block()->start(), block()->limit());
|
||||
for (int i = 0; i < nt; i++) {
|
||||
tty->print((( i < ns) ? " %d" : " %d(e)"), b->successor_at(i)->pre_order());
|
||||
tty->print((( i < ns) ? " %d" : " %d(e)"), b->successor_at(i)->rpo());
|
||||
}
|
||||
if (b->is_loop_head()) tty->print(" lphd");
|
||||
tty->print_cr("");
|
||||
}
|
||||
|
||||
@ -1501,7 +1484,7 @@ void Parse::handle_missing_successor(int target_bci) {
|
||||
#ifndef PRODUCT
|
||||
Block* b = block();
|
||||
int trap_bci = b->flow()->has_trap()? b->flow()->trap_bci(): -1;
|
||||
tty->print_cr("### Missing successor at bci:%d for block #%d (trap_bci:%d)", target_bci, b->pre_order(), trap_bci);
|
||||
tty->print_cr("### Missing successor at bci:%d for block #%d (trap_bci:%d)", target_bci, b->rpo(), trap_bci);
|
||||
#endif
|
||||
ShouldNotReachHere();
|
||||
}
|
||||
@ -1509,7 +1492,7 @@ void Parse::handle_missing_successor(int target_bci) {
|
||||
//--------------------------merge_common---------------------------------------
|
||||
void Parse::merge_common(Parse::Block* target, int pnum) {
|
||||
if (TraceOptoParse) {
|
||||
tty->print("Merging state at block #%d bci:%d", target->pre_order(), target->start());
|
||||
tty->print("Merging state at block #%d bci:%d", target->rpo(), target->start());
|
||||
}
|
||||
|
||||
// Zap extra stack slots to top
|
||||
@ -1534,6 +1517,7 @@ void Parse::merge_common(Parse::Block* target, int pnum) {
|
||||
// which must not be allowed into this block's map.)
|
||||
if (pnum > PhiNode::Input // Known multiple inputs.
|
||||
|| target->is_handler() // These have unpredictable inputs.
|
||||
|| target->is_loop_head() // Known multiple inputs
|
||||
|| control()->is_Region()) { // We must hide this guy.
|
||||
// Add a Region to start the new basic block. Phis will be added
|
||||
// later lazily.
|
||||
@ -1575,15 +1559,21 @@ void Parse::merge_common(Parse::Block* target, int pnum) {
|
||||
|
||||
// Compute where to merge into
|
||||
// Merge incoming control path
|
||||
r->set_req(pnum, newin->control());
|
||||
r->init_req(pnum, newin->control());
|
||||
|
||||
if (pnum == 1) { // Last merge for this Region?
|
||||
_gvn.transform_no_reclaim(r);
|
||||
if (!block()->flow()->is_irreducible_entry()) {
|
||||
Node* result = _gvn.transform_no_reclaim(r);
|
||||
if (r != result && TraceOptoParse) {
|
||||
tty->print_cr("Block #%d replace %d with %d", block()->rpo(), r->_idx, result->_idx);
|
||||
}
|
||||
}
|
||||
record_for_igvn(r);
|
||||
}
|
||||
|
||||
// Update all the non-control inputs to map:
|
||||
assert(TypeFunc::Parms == newin->jvms()->locoff(), "parser map should contain only youngest jvms");
|
||||
bool check_elide_phi = target->is_SEL_backedge(save_block);
|
||||
for (uint j = 1; j < newin->req(); j++) {
|
||||
Node* m = map()->in(j); // Current state of target.
|
||||
Node* n = newin->in(j); // Incoming change to target state.
|
||||
@ -1603,7 +1593,11 @@ void Parse::merge_common(Parse::Block* target, int pnum) {
|
||||
merge_memory_edges(n->as_MergeMem(), pnum, nophi);
|
||||
continue;
|
||||
default: // All normal stuff
|
||||
if (phi == NULL) phi = ensure_phi(j, nophi);
|
||||
if (phi == NULL) {
|
||||
if (!check_elide_phi || !target->can_elide_SEL_phi(j)) {
|
||||
phi = ensure_phi(j, nophi);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1736,9 +1730,13 @@ void Parse::ensure_phis_everywhere() {
|
||||
uint nof_monitors = map()->jvms()->nof_monitors();
|
||||
|
||||
assert(TypeFunc::Parms == map()->jvms()->locoff(), "parser map should contain only youngest jvms");
|
||||
bool check_elide_phi = block()->is_SEL_head();
|
||||
for (uint i = TypeFunc::Parms; i < monoff; i++) {
|
||||
ensure_phi(i);
|
||||
if (!check_elide_phi || !block()->can_elide_SEL_phi(i)) {
|
||||
ensure_phi(i);
|
||||
}
|
||||
}
|
||||
|
||||
// Even monitors need Phis, though they are well-structured.
|
||||
// This is true for OSR methods, and also for the rare cases where
|
||||
// a monitor object is the subject of a replace_in_map operation.
|
||||
|
Loading…
Reference in New Issue
Block a user