src/share/vm/code/nmethod.cpp

changeset 1376
8b46c4d82093
parent 1040
98cb887364d3
child 1378
b1606b3c0a8a
     1.1 --- a/src/share/vm/code/nmethod.cpp	Mon Aug 31 05:27:29 2009 -0700
     1.2 +++ b/src/share/vm/code/nmethod.cpp	Wed Sep 02 00:04:29 2009 -0700
     1.3 @@ -1079,6 +1079,10 @@
     1.4                    this, (address)_method, (address)cause);
     1.5      cause->klass()->print();
     1.6    }
     1.7 +  // Unlink the osr method, so we do not look this up again
     1.8 +  if (is_osr_method()) {
     1.9 +    invalidate_osr_method();
    1.10 +  }
    1.11    // If _method is already NULL the methodOop is about to be unloaded,
    1.12    // so we don't have to break the cycle. Note that it is possible to
    1.13    // have the methodOop live here, in case we unload the nmethod because
    1.14 @@ -1148,7 +1152,7 @@
    1.15    // will never be used anymore. That the nmethods only gets removed when class unloading
    1.16    // happens, make life much simpler, since the nmethods are not just going to disappear
    1.17    // out of the blue.
    1.18 -  if (is_osr_only_method()) {
    1.19 +  if (is_osr_method()) {
    1.20      if (osr_entry_bci() != InvalidOSREntryBci) {
    1.21        // only log this once
    1.22        log_state_change(state);
    1.23 @@ -1520,6 +1524,17 @@
    1.24  #endif // !PRODUCT
    1.25  }
    1.26  
    1.27 +// This method is called twice during GC -- once while
    1.28 +// tracing the "active" nmethods on thread stacks during
    1.29 +// the (strong) marking phase, and then again when walking
    1.30 +// the code cache contents during the weak roots processing
    1.31 +// phase. The two uses are distinguished by means of the
    1.32 +// do_nmethods() method in the closure "f" below -- which
    1.33 +// answers "yes" in the first case, and "no" in the second
    1.34 +// case. We want to walk the weak roots in the nmethod
    1.35 +// only in the second case. The weak roots in the nmethod
    1.36 +// are the oops in the ExceptionCache and the InlineCache
    1.37 +// oops.
    1.38  void nmethod::oops_do(OopClosure* f) {
    1.39    // make sure the oops ready to receive visitors
    1.40    assert(!is_zombie() && !is_unloaded(),
    1.41 @@ -1538,19 +1553,25 @@
    1.42  
    1.43    // Compiled code
    1.44    f->do_oop((oop*) &_method);
    1.45 -  ExceptionCache* ec = exception_cache();
    1.46 -  while(ec != NULL) {
    1.47 -    f->do_oop((oop*)ec->exception_type_addr());
    1.48 -    ec = ec->next();
    1.49 -  }
    1.50 +  if (!f->do_nmethods()) {
    1.51 +    // weak roots processing phase -- update ExceptionCache oops
    1.52 +    ExceptionCache* ec = exception_cache();
    1.53 +    while(ec != NULL) {
    1.54 +      f->do_oop((oop*)ec->exception_type_addr());
    1.55 +      ec = ec->next();
    1.56 +    }
    1.57 +  } // Else strong roots phase -- skip oops in ExceptionCache
    1.58  
    1.59    RelocIterator iter(this, low_boundary);
    1.60 +
    1.61    while (iter.next()) {
    1.62      if (iter.type() == relocInfo::oop_type ) {
    1.63        oop_Relocation* r = iter.oop_reloc();
    1.64        // In this loop, we must only follow those oops directly embedded in
    1.65        // the code.  Other oops (oop_index>0) are seen as part of scopes_oops.
    1.66 -      assert(1 == (r->oop_is_immediate()) + (r->oop_addr() >= oops_begin() && r->oop_addr() < oops_end()), "oop must be found in exactly one place");
    1.67 +      assert(1 == (r->oop_is_immediate()) +
    1.68 +                   (r->oop_addr() >= oops_begin() && r->oop_addr() < oops_end()),
    1.69 +             "oop must be found in exactly one place");
    1.70        if (r->oop_is_immediate() && r->oop_value() != NULL) {
    1.71          f->do_oop(r->oop_addr());
    1.72        }

mercurial