Merge

Thu, 07 Jul 2011 22:34:34 -0400

author
coleenp
date
Thu, 07 Jul 2011 22:34:34 -0400
changeset 3016
5447b2c582ad
parent 2992
b16582d6c7db
parent 3015
109d1d265924
child 3017
bcc6475bc68f

Merge

     1.1 --- a/make/jprt.gmk	Thu Jul 07 10:51:07 2011 -0700
     1.2 +++ b/make/jprt.gmk	Thu Jul 07 22:34:34 2011 -0400
     1.3 @@ -34,13 +34,13 @@
     1.4  endif
     1.5  
     1.6  jprt_build_productEmb:
     1.7 -	$(MAKE) JAVASE_EMBEDDED=true jprt_build_product
     1.8 +	$(MAKE) JAVASE_EMBEDDED=true MINIMIZE_RAM_USAGE=true jprt_build_product
     1.9  
    1.10  jprt_build_debugEmb:
    1.11 -	$(MAKE) JAVASE_EMBEDDED=true jprt_build_debug
    1.12 +	$(MAKE) JAVASE_EMBEDDED=true MINIMIZE_RAM_USAGE=true jprt_build_debug
    1.13  
    1.14  jprt_build_fastdebugEmb:
    1.15 -	$(MAKE) JAVASE_EMBEDDED=true jprt_build_fastdebug
    1.16 +	$(MAKE) JAVASE_EMBEDDED=true MINIMIZE_RAM_USAGE=true jprt_build_fastdebug
    1.17  
    1.18  jprt_build_productOpen:
    1.19  	$(MAKE) OPENJDK=true jprt_build_product
     2.1 --- a/src/share/vm/prims/jvmtiTagMap.cpp	Thu Jul 07 10:51:07 2011 -0700
     2.2 +++ b/src/share/vm/prims/jvmtiTagMap.cpp	Thu Jul 07 22:34:34 2011 -0400
     2.3 @@ -1647,6 +1647,7 @@
     2.4    // saved headers
     2.5    static GrowableArray<oop>* _saved_oop_stack;
     2.6    static GrowableArray<markOop>* _saved_mark_stack;
     2.7 +  static bool _needs_reset;                  // do we need to reset mark bits?
     2.8  
     2.9   public:
    2.10    static void init();                       // initialize
    2.11 @@ -1654,10 +1655,14 @@
    2.12  
    2.13    static inline void mark(oop o);           // mark an object
    2.14    static inline bool visited(oop o);        // check if object has been visited
    2.15 +
    2.16 +  static inline bool needs_reset()            { return _needs_reset; }
    2.17 +  static inline void set_needs_reset(bool v)  { _needs_reset = v; }
    2.18  };
    2.19  
    2.20  GrowableArray<oop>* ObjectMarker::_saved_oop_stack = NULL;
    2.21  GrowableArray<markOop>* ObjectMarker::_saved_mark_stack = NULL;
    2.22 +bool ObjectMarker::_needs_reset = true;  // need to reset mark bits by default
    2.23  
    2.24  // initialize ObjectMarker - prepares for object marking
    2.25  void ObjectMarker::init() {
    2.26 @@ -1680,7 +1685,13 @@
    2.27    // iterate over all objects and restore the mark bits to
    2.28    // their initial value
    2.29    RestoreMarksClosure blk;
    2.30 -  Universe::heap()->object_iterate(&blk);
    2.31 +  if (needs_reset()) {
    2.32 +    Universe::heap()->object_iterate(&blk);
    2.33 +  } else {
    2.34 +    // We don't need to reset mark bits on this call, but reset the
    2.35 +    // flag to the default for the next call.
    2.36 +    set_needs_reset(true);
    2.37 +  }
    2.38  
    2.39    // When sharing is enabled we need to restore the headers of the objects
    2.40    // in the readwrite space too.
    2.41 @@ -3023,7 +3034,8 @@
    2.42  }
    2.43  
    2.44  
    2.45 -// collects all simple (non-stack) roots.
    2.46 +// Collects all simple (non-stack) roots except for threads;
    2.47 +// threads are handled in collect_stack_roots() as an optimization.
    2.48  // if there's a heap root callback provided then the callback is
    2.49  // invoked for each simple root.
    2.50  // if an object reference callback is provided then all simple
    2.51 @@ -3054,16 +3066,7 @@
    2.52      return false;
    2.53    }
    2.54  
    2.55 -  // Threads
    2.56 -  for (JavaThread* thread = Threads::first(); thread != NULL ; thread = thread->next()) {
    2.57 -    oop threadObj = thread->threadObj();
    2.58 -    if (threadObj != NULL && !thread->is_exiting() && !thread->is_hidden_from_external_view()) {
    2.59 -      bool cont = CallbackInvoker::report_simple_root(JVMTI_HEAP_REFERENCE_THREAD, threadObj);
    2.60 -      if (!cont) {
    2.61 -        return false;
    2.62 -      }
    2.63 -    }
    2.64 -  }
    2.65 +  // threads are now handled in collect_stack_roots()
    2.66  
    2.67    // Other kinds of roots maintained by HotSpot
    2.68    // Many of these won't be visible but others (such as instances of important
    2.69 @@ -3175,13 +3178,20 @@
    2.70  }
    2.71  
    2.72  
    2.73 -// collects all stack roots - for each thread it walks the execution
    2.74 +// Collects the simple roots for all threads and collects all
    2.75 +// stack roots - for each thread it walks the execution
    2.76  // stack to find all references and local JNI refs.
    2.77  inline bool VM_HeapWalkOperation::collect_stack_roots() {
    2.78    JNILocalRootsClosure blk;
    2.79    for (JavaThread* thread = Threads::first(); thread != NULL ; thread = thread->next()) {
    2.80      oop threadObj = thread->threadObj();
    2.81      if (threadObj != NULL && !thread->is_exiting() && !thread->is_hidden_from_external_view()) {
    2.82 +      // Collect the simple root for this thread before we
    2.83 +      // collect its stack roots
    2.84 +      if (!CallbackInvoker::report_simple_root(JVMTI_HEAP_REFERENCE_THREAD,
    2.85 +                                               threadObj)) {
    2.86 +        return false;
    2.87 +      }
    2.88        if (!collect_stack_roots(thread, &blk)) {
    2.89          return false;
    2.90        }
    2.91 @@ -3235,8 +3245,20 @@
    2.92  
    2.93    // the heap walk starts with an initial object or the heap roots
    2.94    if (initial_object().is_null()) {
    2.95 +    // If either collect_stack_roots() or collect_simple_roots()
    2.96 +    // returns false at this point, then there are no mark bits
    2.97 +    // to reset.
    2.98 +    ObjectMarker::set_needs_reset(false);
    2.99 +
   2.100 +    // Calling collect_stack_roots() before collect_simple_roots()
   2.101 +    // can result in a big performance boost for an agent that is
   2.102 +    // focused on analyzing references in the thread stacks.
   2.103 +    if (!collect_stack_roots()) return;
   2.104 +
   2.105      if (!collect_simple_roots()) return;
   2.106 -    if (!collect_stack_roots()) return;
   2.107 +
   2.108 +    // no early return so enable heap traversal to reset the mark bits
   2.109 +    ObjectMarker::set_needs_reset(true);
   2.110    } else {
   2.111      visit_stack()->push(initial_object()());
   2.112    }

mercurial