# HG changeset patch # User coleenp # Date 1310869299 14400 # Node ID bcc6475bc68f11d240243856d2808c29014aa1b7 # Parent 1f4f4ae84625832048500c3a0832d41496958d95# Parent 5447b2c582ad21d251a9314cc74684dd5e9a7dab Merge diff -r 1f4f4ae84625 -r bcc6475bc68f make/jprt.gmk --- a/make/jprt.gmk Wed Jul 13 10:48:42 2011 -0700 +++ b/make/jprt.gmk Sat Jul 16 22:21:39 2011 -0400 @@ -34,13 +34,13 @@ endif jprt_build_productEmb: - $(MAKE) JAVASE_EMBEDDED=true jprt_build_product + $(MAKE) JAVASE_EMBEDDED=true MINIMIZE_RAM_USAGE=true jprt_build_product jprt_build_debugEmb: - $(MAKE) JAVASE_EMBEDDED=true jprt_build_debug + $(MAKE) JAVASE_EMBEDDED=true MINIMIZE_RAM_USAGE=true jprt_build_debug jprt_build_fastdebugEmb: - $(MAKE) JAVASE_EMBEDDED=true jprt_build_fastdebug + $(MAKE) JAVASE_EMBEDDED=true MINIMIZE_RAM_USAGE=true jprt_build_fastdebug jprt_build_productOpen: $(MAKE) OPENJDK=true jprt_build_product diff -r 1f4f4ae84625 -r bcc6475bc68f src/share/vm/prims/jvmtiTagMap.cpp --- a/src/share/vm/prims/jvmtiTagMap.cpp Wed Jul 13 10:48:42 2011 -0700 +++ b/src/share/vm/prims/jvmtiTagMap.cpp Sat Jul 16 22:21:39 2011 -0400 @@ -1647,6 +1647,7 @@ // saved headers static GrowableArray* _saved_oop_stack; static GrowableArray* _saved_mark_stack; + static bool _needs_reset; // do we need to reset mark bits? public: static void init(); // initialize @@ -1654,10 +1655,14 @@ static inline void mark(oop o); // mark an object static inline bool visited(oop o); // check if object has been visited + + static inline bool needs_reset() { return _needs_reset; } + static inline void set_needs_reset(bool v) { _needs_reset = v; } }; GrowableArray* ObjectMarker::_saved_oop_stack = NULL; GrowableArray* ObjectMarker::_saved_mark_stack = NULL; +bool ObjectMarker::_needs_reset = true; // need to reset mark bits by default // initialize ObjectMarker - prepares for object marking void ObjectMarker::init() { @@ -1680,7 +1685,13 @@ // iterate over all objects and restore the mark bits to // their initial value RestoreMarksClosure blk; - Universe::heap()->object_iterate(&blk); + if (needs_reset()) { + Universe::heap()->object_iterate(&blk); + } else { + // We don't need to reset mark bits on this call, but reset the + // flag to the default for the next call. + set_needs_reset(true); + } // When sharing is enabled we need to restore the headers of the objects // in the readwrite space too. @@ -3023,7 +3034,8 @@ } -// collects all simple (non-stack) roots. +// Collects all simple (non-stack) roots except for threads; +// threads are handled in collect_stack_roots() as an optimization. // if there's a heap root callback provided then the callback is // invoked for each simple root. // if an object reference callback is provided then all simple @@ -3054,16 +3066,7 @@ return false; } - // Threads - for (JavaThread* thread = Threads::first(); thread != NULL ; thread = thread->next()) { - oop threadObj = thread->threadObj(); - if (threadObj != NULL && !thread->is_exiting() && !thread->is_hidden_from_external_view()) { - bool cont = CallbackInvoker::report_simple_root(JVMTI_HEAP_REFERENCE_THREAD, threadObj); - if (!cont) { - return false; - } - } - } + // threads are now handled in collect_stack_roots() // Other kinds of roots maintained by HotSpot // Many of these won't be visible but others (such as instances of important @@ -3175,13 +3178,20 @@ } -// collects all stack roots - for each thread it walks the execution +// Collects the simple roots for all threads and collects all +// stack roots - for each thread it walks the execution // stack to find all references and local JNI refs. inline bool VM_HeapWalkOperation::collect_stack_roots() { JNILocalRootsClosure blk; for (JavaThread* thread = Threads::first(); thread != NULL ; thread = thread->next()) { oop threadObj = thread->threadObj(); if (threadObj != NULL && !thread->is_exiting() && !thread->is_hidden_from_external_view()) { + // Collect the simple root for this thread before we + // collect its stack roots + if (!CallbackInvoker::report_simple_root(JVMTI_HEAP_REFERENCE_THREAD, + threadObj)) { + return false; + } if (!collect_stack_roots(thread, &blk)) { return false; } @@ -3235,8 +3245,20 @@ // the heap walk starts with an initial object or the heap roots if (initial_object().is_null()) { + // If either collect_stack_roots() or collect_simple_roots() + // returns false at this point, then there are no mark bits + // to reset. + ObjectMarker::set_needs_reset(false); + + // Calling collect_stack_roots() before collect_simple_roots() + // can result in a big performance boost for an agent that is + // focused on analyzing references in the thread stacks. + if (!collect_stack_roots()) return; + if (!collect_simple_roots()) return; - if (!collect_stack_roots()) return; + + // no early return so enable heap traversal to reset the mark bits + ObjectMarker::set_needs_reset(true); } else { visit_stack()->push(initial_object()()); }