diff -r 02e771df338e -r b812ff5abc73 src/share/vm/c1/c1_Optimizer.cpp --- a/src/share/vm/c1/c1_Optimizer.cpp Thu Jun 03 14:20:27 2010 -0700 +++ b/src/share/vm/c1/c1_Optimizer.cpp Fri Jun 04 11:18:04 2010 -0700 @@ -437,11 +437,8 @@ // Because of a static contained within (for the purpose of iteration // over instructions), it is only valid to have one of these active at // a time -class NullCheckEliminator { +class NullCheckEliminator: public ValueVisitor { private: - static NullCheckEliminator* _static_nce; - static void do_value(Value* vp); - Optimizer* _opt; ValueSet* _visitable_instructions; // Visit each instruction only once per basic block @@ -504,6 +501,8 @@ // Process a graph void iterate(BlockBegin* root); + void visit(Value* f); + // In some situations (like NullCheck(x); getfield(x)) the debug // information from the explicit NullCheck can be used to populate // the getfield, even if the two instructions are in different @@ -602,14 +601,11 @@ void NullCheckVisitor::do_ProfileCounter (ProfileCounter* x) {} -NullCheckEliminator* NullCheckEliminator::_static_nce = NULL; - - -void NullCheckEliminator::do_value(Value* p) { +void NullCheckEliminator::visit(Value* p) { assert(*p != NULL, "should not find NULL instructions"); - if (_static_nce->visitable(*p)) { - _static_nce->mark_visited(*p); - (*p)->visit(&_static_nce->_visitor); + if (visitable(*p)) { + mark_visited(*p); + (*p)->visit(&_visitor); } } @@ -637,7 +633,6 @@ void NullCheckEliminator::iterate_one(BlockBegin* block) { - _static_nce = this; clear_visitable_state(); // clear out an old explicit null checks set_last_explicit_null_check(NULL); @@ -712,7 +707,7 @@ mark_visitable(instr); if (instr->is_root() || instr->can_trap() || (instr->as_NullCheck() != NULL)) { mark_visited(instr); - instr->input_values_do(&NullCheckEliminator::do_value); + instr->input_values_do(this); instr->visit(&_visitor); } }