aboutsummaryrefslogtreecommitdiff
path: root/src/share/vm/opto
diff options
context:
space:
mode:
authorkvn <none@none>2010-08-03 15:55:03 -0700
committerkvn <none@none>2010-08-03 15:55:03 -0700
commit3bb095b17058e4b9bf9aea1fbba9df1b08c33bc7 (patch)
treef07444cd74c053056049c6ee3296e5ee57c1e604 /src/share/vm/opto
parentb9f5734543897b707b858a7b1d8e6a51c93da317 (diff)
6973963: SEGV in ciBlock::start_bci() with EA
Summary: Added more checks into ResourceObj and growableArray to verify correctness of allocation type. Reviewed-by: never, coleenp, dholmes
Diffstat (limited to 'src/share/vm/opto')
-rw-r--r--src/share/vm/opto/block.cpp3
-rw-r--r--src/share/vm/opto/block.hpp2
-rw-r--r--src/share/vm/opto/c2_globals.hpp6
-rw-r--r--src/share/vm/opto/c2compiler.cpp13
-rw-r--r--src/share/vm/opto/chaitin.cpp2
-rw-r--r--src/share/vm/opto/compile.cpp4
-rw-r--r--src/share/vm/opto/gcm.cpp35
-rw-r--r--src/share/vm/opto/lcm.cpp6
8 files changed, 45 insertions, 26 deletions
diff --git a/src/share/vm/opto/block.cpp b/src/share/vm/opto/block.cpp
index d7cf639c9..1d7a84048 100644
--- a/src/share/vm/opto/block.cpp
+++ b/src/share/vm/opto/block.cpp
@@ -353,7 +353,8 @@ void Block::dump( const Block_Array *bbs ) const {
PhaseCFG::PhaseCFG( Arena *a, RootNode *r, Matcher &m ) :
Phase(CFG),
_bbs(a),
- _root(r)
+ _root(r),
+ _node_latency(NULL)
#ifndef PRODUCT
, _trace_opto_pipelining(TraceOptoPipelining || C->method_has_option("TraceOptoPipelining"))
#endif
diff --git a/src/share/vm/opto/block.hpp b/src/share/vm/opto/block.hpp
index 9bd989539..cc06263f1 100644
--- a/src/share/vm/opto/block.hpp
+++ b/src/share/vm/opto/block.hpp
@@ -374,7 +374,7 @@ class PhaseCFG : public Phase {
float _outer_loop_freq; // Outmost loop frequency
// Per node latency estimation, valid only during GCM
- GrowableArray<uint> _node_latency;
+ GrowableArray<uint> *_node_latency;
#ifndef PRODUCT
bool _trace_opto_pipelining; // tracing flag
diff --git a/src/share/vm/opto/c2_globals.hpp b/src/share/vm/opto/c2_globals.hpp
index ac0a991d4..3fdaf8427 100644
--- a/src/share/vm/opto/c2_globals.hpp
+++ b/src/share/vm/opto/c2_globals.hpp
@@ -281,6 +281,12 @@
product(bool, InsertMemBarAfterArraycopy, true, \
"Insert memory barrier after arraycopy call") \
\
+ develop(bool, SubsumeLoads, true, \
+ "Attempt to compile while subsuming loads into machine instructions.") \
+ \
+ develop(bool, StressRecompilation, false, \
+ "Recompile each compiled method without subsuming loads or escape analysis.") \
+ \
/* controls for tier 1 compilations */ \
\
develop(bool, Tier1CountInvocations, true, \
diff --git a/src/share/vm/opto/c2compiler.cpp b/src/share/vm/opto/c2compiler.cpp
index ff4fa6bad..142273b26 100644
--- a/src/share/vm/opto/c2compiler.cpp
+++ b/src/share/vm/opto/c2compiler.cpp
@@ -103,13 +103,14 @@ void C2Compiler::compile_method(ciEnv* env,
if (!is_initialized()) {
initialize();
}
- bool subsume_loads = true;
+ bool subsume_loads = SubsumeLoads;
bool do_escape_analysis = DoEscapeAnalysis &&
!env->jvmti_can_access_local_variables();
while (!env->failing()) {
// Attempt to compile while subsuming loads into machine instructions.
Compile C(env, this, target, entry_bci, subsume_loads, do_escape_analysis);
+
// Check result and retry if appropriate.
if (C.failure_reason() != NULL) {
if (C.failure_reason_is(retry_no_subsuming_loads())) {
@@ -127,6 +128,16 @@ void C2Compiler::compile_method(ciEnv* env,
// on the ciEnv via env->record_method_not_compilable().
env->record_failure(C.failure_reason());
}
+ if (StressRecompilation) {
+ if (subsume_loads) {
+ subsume_loads = false;
+ continue; // retry
+ }
+ if (do_escape_analysis) {
+ do_escape_analysis = false;
+ continue; // retry
+ }
+ }
// No retry; just break the loop.
break;
diff --git a/src/share/vm/opto/chaitin.cpp b/src/share/vm/opto/chaitin.cpp
index ed9124b24..4a8e0e3f5 100644
--- a/src/share/vm/opto/chaitin.cpp
+++ b/src/share/vm/opto/chaitin.cpp
@@ -569,7 +569,7 @@ void PhaseChaitin::gather_lrg_masks( bool after_aggressive ) {
if (trace_spilling() && lrg._def != NULL) {
// collect defs for MultiDef printing
if (lrg._defs == NULL) {
- lrg._defs = new (_ifg->_arena) GrowableArray<Node*>();
+ lrg._defs = new (_ifg->_arena) GrowableArray<Node*>(_ifg->_arena, 2, 0, NULL);
lrg._defs->append(lrg._def);
}
lrg._defs->append(n);
diff --git a/src/share/vm/opto/compile.cpp b/src/share/vm/opto/compile.cpp
index 632066521..e5d3c4fdd 100644
--- a/src/share/vm/opto/compile.cpp
+++ b/src/share/vm/opto/compile.cpp
@@ -904,8 +904,8 @@ void Compile::Init(int aliaslevel) {
probe_alias_cache(NULL)->_index = AliasIdxTop;
_intrinsics = NULL;
- _macro_nodes = new GrowableArray<Node*>(comp_arena(), 8, 0, NULL);
- _predicate_opaqs = new GrowableArray<Node*>(comp_arena(), 8, 0, NULL);
+ _macro_nodes = new(comp_arena()) GrowableArray<Node*>(comp_arena(), 8, 0, NULL);
+ _predicate_opaqs = new(comp_arena()) GrowableArray<Node*>(comp_arena(), 8, 0, NULL);
register_library_intrinsics();
}
diff --git a/src/share/vm/opto/gcm.cpp b/src/share/vm/opto/gcm.cpp
index 5fc0b1c1b..f222001d3 100644
--- a/src/share/vm/opto/gcm.cpp
+++ b/src/share/vm/opto/gcm.cpp
@@ -841,7 +841,7 @@ void PhaseCFG::partial_latency_of_defs(Node *n) {
#ifndef PRODUCT
if (trace_opto_pipelining()) {
tty->print("# latency_to_inputs: node_latency[%d] = %d for node",
- n->_idx, _node_latency.at_grow(n->_idx));
+ n->_idx, _node_latency->at_grow(n->_idx));
dump();
}
#endif
@@ -853,7 +853,7 @@ void PhaseCFG::partial_latency_of_defs(Node *n) {
return;
uint nlen = n->len();
- uint use_latency = _node_latency.at_grow(n->_idx);
+ uint use_latency = _node_latency->at_grow(n->_idx);
uint use_pre_order = _bbs[n->_idx]->_pre_order;
for ( uint j=0; j<nlen; j++ ) {
@@ -884,15 +884,15 @@ void PhaseCFG::partial_latency_of_defs(Node *n) {
uint delta_latency = n->latency(j);
uint current_latency = delta_latency + use_latency;
- if (_node_latency.at_grow(def->_idx) < current_latency) {
- _node_latency.at_put_grow(def->_idx, current_latency);
+ if (_node_latency->at_grow(def->_idx) < current_latency) {
+ _node_latency->at_put_grow(def->_idx, current_latency);
}
#ifndef PRODUCT
if (trace_opto_pipelining()) {
tty->print_cr("# %d + edge_latency(%d) == %d -> %d, node_latency[%d] = %d",
use_latency, j, delta_latency, current_latency, def->_idx,
- _node_latency.at_grow(def->_idx));
+ _node_latency->at_grow(def->_idx));
}
#endif
}
@@ -926,7 +926,7 @@ int PhaseCFG::latency_from_use(Node *n, const Node *def, Node *use) {
return 0;
uint nlen = use->len();
- uint nl = _node_latency.at_grow(use->_idx);
+ uint nl = _node_latency->at_grow(use->_idx);
for ( uint j=0; j<nlen; j++ ) {
if (use->in(j) == n) {
@@ -962,7 +962,7 @@ void PhaseCFG::latency_from_uses(Node *n) {
#ifndef PRODUCT
if (trace_opto_pipelining()) {
tty->print("# latency_from_outputs: node_latency[%d] = %d for node",
- n->_idx, _node_latency.at_grow(n->_idx));
+ n->_idx, _node_latency->at_grow(n->_idx));
dump();
}
#endif
@@ -975,7 +975,7 @@ void PhaseCFG::latency_from_uses(Node *n) {
if (latency < l) latency = l;
}
- _node_latency.at_put_grow(n->_idx, latency);
+ _node_latency->at_put_grow(n->_idx, latency);
}
//------------------------------hoist_to_cheaper_block-------------------------
@@ -985,9 +985,9 @@ Block* PhaseCFG::hoist_to_cheaper_block(Block* LCA, Block* early, Node* self) {
const double delta = 1+PROB_UNLIKELY_MAG(4);
Block* least = LCA;
double least_freq = least->_freq;
- uint target = _node_latency.at_grow(self->_idx);
- uint start_latency = _node_latency.at_grow(LCA->_nodes[0]->_idx);
- uint end_latency = _node_latency.at_grow(LCA->_nodes[LCA->end_idx()]->_idx);
+ uint target = _node_latency->at_grow(self->_idx);
+ uint start_latency = _node_latency->at_grow(LCA->_nodes[0]->_idx);
+ uint end_latency = _node_latency->at_grow(LCA->_nodes[LCA->end_idx()]->_idx);
bool in_latency = (target <= start_latency);
const Block* root_block = _bbs[_root->_idx];
@@ -1005,7 +1005,7 @@ Block* PhaseCFG::hoist_to_cheaper_block(Block* LCA, Block* early, Node* self) {
#ifndef PRODUCT
if (trace_opto_pipelining()) {
tty->print("# Find cheaper block for latency %d: ",
- _node_latency.at_grow(self->_idx));
+ _node_latency->at_grow(self->_idx));
self->dump();
tty->print_cr("# B%d: start latency for [%4d]=%d, end latency for [%4d]=%d, freq=%g",
LCA->_pre_order,
@@ -1032,9 +1032,9 @@ Block* PhaseCFG::hoist_to_cheaper_block(Block* LCA, Block* early, Node* self) {
if (mach && LCA == root_block)
break;
- uint start_lat = _node_latency.at_grow(LCA->_nodes[0]->_idx);
+ uint start_lat = _node_latency->at_grow(LCA->_nodes[0]->_idx);
uint end_idx = LCA->end_idx();
- uint end_lat = _node_latency.at_grow(LCA->_nodes[end_idx]->_idx);
+ uint end_lat = _node_latency->at_grow(LCA->_nodes[end_idx]->_idx);
double LCA_freq = LCA->_freq;
#ifndef PRODUCT
if (trace_opto_pipelining()) {
@@ -1073,7 +1073,7 @@ Block* PhaseCFG::hoist_to_cheaper_block(Block* LCA, Block* early, Node* self) {
tty->print_cr("# Change latency for [%4d] from %d to %d", self->_idx, target, end_latency);
}
#endif
- _node_latency.at_put_grow(self->_idx, end_latency);
+ _node_latency->at_put_grow(self->_idx, end_latency);
partial_latency_of_defs(self);
}
@@ -1255,8 +1255,7 @@ void PhaseCFG::GlobalCodeMotion( Matcher &matcher, uint unique, Node_List &proj_
// Compute the latency information (via backwards walk) for all the
// instructions in the graph
- GrowableArray<uint> node_latency;
- _node_latency = node_latency;
+ _node_latency = new GrowableArray<uint>(); // resource_area allocation
if( C->do_scheduling() )
ComputeLatenciesBackwards(visited, stack);
@@ -1341,6 +1340,8 @@ void PhaseCFG::GlobalCodeMotion( Matcher &matcher, uint unique, Node_List &proj_
}
}
#endif
+ // Dead.
+ _node_latency = (GrowableArray<uint> *)0xdeadbeef;
}
diff --git a/src/share/vm/opto/lcm.cpp b/src/share/vm/opto/lcm.cpp
index 0afde9016..8692746cf 100644
--- a/src/share/vm/opto/lcm.cpp
+++ b/src/share/vm/opto/lcm.cpp
@@ -461,7 +461,7 @@ Node *Block::select(PhaseCFG *cfg, Node_List &worklist, int *ready_cnt, VectorSe
n_choice = 1;
}
- uint n_latency = cfg->_node_latency.at_grow(n->_idx);
+ uint n_latency = cfg->_node_latency->at_grow(n->_idx);
uint n_score = n->req(); // Many inputs get high score to break ties
// Keep best latency found
@@ -738,7 +738,7 @@ bool Block::schedule_local(PhaseCFG *cfg, Matcher &matcher, int *ready_cnt, Vect
Node *n = _nodes[j];
int idx = n->_idx;
tty->print("# ready cnt:%3d ", ready_cnt[idx]);
- tty->print("latency:%3d ", cfg->_node_latency.at_grow(idx));
+ tty->print("latency:%3d ", cfg->_node_latency->at_grow(idx));
tty->print("%4d: %s\n", idx, n->Name());
}
}
@@ -765,7 +765,7 @@ bool Block::schedule_local(PhaseCFG *cfg, Matcher &matcher, int *ready_cnt, Vect
#ifndef PRODUCT
if (cfg->trace_opto_pipelining()) {
tty->print("# select %d: %s", n->_idx, n->Name());
- tty->print(", latency:%d", cfg->_node_latency.at_grow(n->_idx));
+ tty->print(", latency:%d", cfg->_node_latency->at_grow(n->_idx));
n->dump();
if (Verbose) {
tty->print("# ready list:");