src/share/vm/memory/metaspace.cpp

changeset 4295
59c790074993
parent 4264
6bc207d87e5d
child 4306
5fafdef522c6
     1.1 --- a/src/share/vm/memory/metaspace.cpp	Wed Nov 28 08:43:26 2012 -0800
     1.2 +++ b/src/share/vm/memory/metaspace.cpp	Wed Nov 28 17:50:21 2012 -0500
     1.3 @@ -36,6 +36,7 @@
     1.4  #include "memory/universe.hpp"
     1.5  #include "runtime/globals.hpp"
     1.6  #include "runtime/mutex.hpp"
     1.7 +#include "runtime/orderAccess.hpp"
     1.8  #include "services/memTracker.hpp"
     1.9  #include "utilities/copy.hpp"
    1.10  #include "utilities/debug.hpp"
    1.11 @@ -1007,6 +1008,8 @@
    1.12      delete new_entry;
    1.13      return false;
    1.14    } else {
    1.15 +    // ensure lock-free iteration sees fully initialized node
    1.16 +    OrderAccess::storestore();
    1.17      link_vs(new_entry, vs_word_size);
    1.18      return true;
    1.19    }
    1.20 @@ -1096,7 +1099,6 @@
    1.21    }
    1.22  }
    1.23  
    1.24 -#ifndef PRODUCT
    1.25  bool VirtualSpaceList::contains(const void *ptr) {
    1.26    VirtualSpaceNode* list = virtual_space_list();
    1.27    VirtualSpaceListIterator iter(list);
    1.28 @@ -1108,7 +1110,6 @@
    1.29    }
    1.30    return false;
    1.31  }
    1.32 -#endif // PRODUCT
    1.33  
    1.34  
    1.35  // MetaspaceGC methods
    1.36 @@ -2739,15 +2740,17 @@
    1.37    }
    1.38  }
    1.39  
    1.40 -#ifndef PRODUCT
    1.41 -bool Metaspace::contains(const void * ptr) const {
    1.42 +bool Metaspace::contains(const void * ptr) {
    1.43    if (MetaspaceShared::is_in_shared_space(ptr)) {
    1.44      return true;
    1.45    }
    1.46 -  MutexLockerEx cl(SpaceManager::expand_lock(), Mutex::_no_safepoint_check_flag);
    1.47 +  // This is checked while unlocked.  As long as the virtualspaces are added
    1.48 +  // at the end, the pointer will be in one of them.  The virtual spaces
    1.49 +  // aren't deleted presently.  When they are, some sort of locking might
    1.50 +  // be needed.  Note, locking this can cause inversion problems with the
    1.51 +  // caller in MetaspaceObj::is_metadata() function.
    1.52    return space_list()->contains(ptr) || class_space_list()->contains(ptr);
    1.53  }
    1.54 -#endif
    1.55  
    1.56  void Metaspace::verify() {
    1.57    vsm()->verify();

mercurial