Mercurial > hg > truffle
comparison src/share/vm/prims/jvmtiTagMap.cpp @ 3815:d425748f2203
7043987: 3/3 JVMTI FollowReferences is slow
Summary: VM_HeapWalkOperation::doit() should only reset mark bits when necessary.
Reviewed-by: dsamersoff, ysr, dholmes, dcubed
Contributed-by: ashok.srinivasa.murthy@oracle.com
author | dcubed |
---|---|
date | Thu, 23 Jun 2011 20:31:43 -0700 |
parents | 167b70ff3abc |
children | 88dce6a60ac8 |
comparison
equal
deleted
inserted
replaced
3814:1744e37e032b | 3815:d425748f2203 |
---|---|
1645 class ObjectMarker : AllStatic { | 1645 class ObjectMarker : AllStatic { |
1646 private: | 1646 private: |
1647 // saved headers | 1647 // saved headers |
1648 static GrowableArray<oop>* _saved_oop_stack; | 1648 static GrowableArray<oop>* _saved_oop_stack; |
1649 static GrowableArray<markOop>* _saved_mark_stack; | 1649 static GrowableArray<markOop>* _saved_mark_stack; |
1650 static bool _needs_reset; // do we need to reset mark bits? | |
1650 | 1651 |
1651 public: | 1652 public: |
1652 static void init(); // initialize | 1653 static void init(); // initialize |
1653 static void done(); // clean-up | 1654 static void done(); // clean-up |
1654 | 1655 |
1655 static inline void mark(oop o); // mark an object | 1656 static inline void mark(oop o); // mark an object |
1656 static inline bool visited(oop o); // check if object has been visited | 1657 static inline bool visited(oop o); // check if object has been visited |
1658 | |
1659 static inline bool needs_reset() { return _needs_reset; } | |
1660 static inline void set_needs_reset(bool v) { _needs_reset = v; } | |
1657 }; | 1661 }; |
1658 | 1662 |
1659 GrowableArray<oop>* ObjectMarker::_saved_oop_stack = NULL; | 1663 GrowableArray<oop>* ObjectMarker::_saved_oop_stack = NULL; |
1660 GrowableArray<markOop>* ObjectMarker::_saved_mark_stack = NULL; | 1664 GrowableArray<markOop>* ObjectMarker::_saved_mark_stack = NULL; |
1665 bool ObjectMarker::_needs_reset = true; // need to reset mark bits by default | |
1661 | 1666 |
1662 // initialize ObjectMarker - prepares for object marking | 1667 // initialize ObjectMarker - prepares for object marking |
1663 void ObjectMarker::init() { | 1668 void ObjectMarker::init() { |
1664 assert(Thread::current()->is_VM_thread(), "must be VMThread"); | 1669 assert(Thread::current()->is_VM_thread(), "must be VMThread"); |
1665 | 1670 |
1678 // Object marking is done so restore object headers | 1683 // Object marking is done so restore object headers |
1679 void ObjectMarker::done() { | 1684 void ObjectMarker::done() { |
1680 // iterate over all objects and restore the mark bits to | 1685 // iterate over all objects and restore the mark bits to |
1681 // their initial value | 1686 // their initial value |
1682 RestoreMarksClosure blk; | 1687 RestoreMarksClosure blk; |
1683 Universe::heap()->object_iterate(&blk); | 1688 if (needs_reset()) { |
1689 Universe::heap()->object_iterate(&blk); | |
1690 } else { | |
1691 // We don't need to reset mark bits on this call, but reset the | |
1692 // flag to the default for the next call. | |
1693 set_needs_reset(true); | |
1694 } | |
1684 | 1695 |
1685 // When sharing is enabled we need to restore the headers of the objects | 1696 // When sharing is enabled we need to restore the headers of the objects |
1686 // in the readwrite space too. | 1697 // in the readwrite space too. |
1687 if (UseSharedSpaces) { | 1698 if (UseSharedSpaces) { |
1688 GenCollectedHeap* gch = GenCollectedHeap::heap(); | 1699 GenCollectedHeap* gch = GenCollectedHeap::heap(); |
3233 | 3244 |
3234 assert(visit_stack()->is_empty(), "visit stack must be empty"); | 3245 assert(visit_stack()->is_empty(), "visit stack must be empty"); |
3235 | 3246 |
3236 // the heap walk starts with an initial object or the heap roots | 3247 // the heap walk starts with an initial object or the heap roots |
3237 if (initial_object().is_null()) { | 3248 if (initial_object().is_null()) { |
3249 // If either collect_stack_roots() or collect_simple_roots() | |
3250 // returns false at this point, then there are no mark bits | |
3251 // to reset. | |
3252 ObjectMarker::set_needs_reset(false); | |
3253 | |
3238 if (!collect_simple_roots()) return; | 3254 if (!collect_simple_roots()) return; |
3239 if (!collect_stack_roots()) return; | 3255 if (!collect_stack_roots()) return; |
3256 | |
3257 // no early return so enable heap traversal to reset the mark bits | |
3258 ObjectMarker::set_needs_reset(true); | |
3240 } else { | 3259 } else { |
3241 visit_stack()->push(initial_object()()); | 3260 visit_stack()->push(initial_object()()); |
3242 } | 3261 } |
3243 | 3262 |
3244 // object references required | 3263 // object references required |