src/share/vm/c1/c1_Optimizer.cpp

changeset 1939
b812ff5abc73
parent 1907
c18cbe5936b8
child 2138
d5d065957597
     1.1 --- a/src/share/vm/c1/c1_Optimizer.cpp	Thu Jun 03 14:20:27 2010 -0700
     1.2 +++ b/src/share/vm/c1/c1_Optimizer.cpp	Fri Jun 04 11:18:04 2010 -0700
     1.3 @@ -437,11 +437,8 @@
     1.4  // Because of a static contained within (for the purpose of iteration
     1.5  // over instructions), it is only valid to have one of these active at
     1.6  // a time
     1.7 -class NullCheckEliminator {
     1.8 +class NullCheckEliminator: public ValueVisitor {
     1.9   private:
    1.10 -  static NullCheckEliminator* _static_nce;
    1.11 -  static void                 do_value(Value* vp);
    1.12 -
    1.13    Optimizer*        _opt;
    1.14  
    1.15    ValueSet*         _visitable_instructions;        // Visit each instruction only once per basic block
    1.16 @@ -504,6 +501,8 @@
    1.17    // Process a graph
    1.18    void iterate(BlockBegin* root);
    1.19  
    1.20 +  void visit(Value* f);
    1.21 +
    1.22    // In some situations (like NullCheck(x); getfield(x)) the debug
    1.23    // information from the explicit NullCheck can be used to populate
    1.24    // the getfield, even if the two instructions are in different
    1.25 @@ -602,14 +601,11 @@
    1.26  void NullCheckVisitor::do_ProfileCounter (ProfileCounter*  x) {}
    1.27  
    1.28  
    1.29 -NullCheckEliminator* NullCheckEliminator::_static_nce = NULL;
    1.30 -
    1.31 -
    1.32 -void NullCheckEliminator::do_value(Value* p) {
    1.33 +void NullCheckEliminator::visit(Value* p) {
    1.34    assert(*p != NULL, "should not find NULL instructions");
    1.35 -  if (_static_nce->visitable(*p)) {
    1.36 -    _static_nce->mark_visited(*p);
    1.37 -    (*p)->visit(&_static_nce->_visitor);
    1.38 +  if (visitable(*p)) {
    1.39 +    mark_visited(*p);
    1.40 +    (*p)->visit(&_visitor);
    1.41    }
    1.42  }
    1.43  
    1.44 @@ -637,7 +633,6 @@
    1.45  
    1.46  
    1.47  void NullCheckEliminator::iterate_one(BlockBegin* block) {
    1.48 -  _static_nce = this;
    1.49    clear_visitable_state();
    1.50    // clear out an old explicit null checks
    1.51    set_last_explicit_null_check(NULL);
    1.52 @@ -712,7 +707,7 @@
    1.53      mark_visitable(instr);
    1.54      if (instr->is_root() || instr->can_trap() || (instr->as_NullCheck() != NULL)) {
    1.55        mark_visited(instr);
    1.56 -      instr->input_values_do(&NullCheckEliminator::do_value);
    1.57 +      instr->input_values_do(this);
    1.58        instr->visit(&_visitor);
    1.59      }
    1.60    }

mercurial