< prev index next >

src/hotspot/share/jfr/leakprofiler/chains/objectSampleMarker.hpp

Print this page
rev 57531 : [mq]: 8234173.0
rev 57532 : [mq]: 8234173.1
   1 /*
   2  * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


  50 
  51   GrowableArray<ObjectSampleMarkWord>* _store;
  52 
  53  public:
  54   ObjectSampleMarker() :
  55        _store(new GrowableArray<ObjectSampleMarkWord>(16)) {}
  56   ~ObjectSampleMarker() {
  57     assert(_store != NULL, "invariant");
  58     // restore the saved, original, markWord for sample objects
  59     while (_store->is_nonempty()) {
  60       ObjectSampleMarkWord sample_oop = _store->pop();
  61       sample_oop._obj->set_mark(sample_oop._mark_word);
  62       assert(sample_oop._obj->mark() == sample_oop._mark_word, "invariant");
  63     }
  64   }
  65 
  66   void mark(oop obj) {
  67     assert(obj != NULL, "invariant");
  68     // save the original markWord
  69     _store->push(ObjectSampleMarkWord(obj, obj->mark()));
  70     // now we will "poison" the mark word of the sample object
  71     // to marked.
  72     // This will be used to quickly identify sample objects
  73     // during the reachability search from gc roots.
  74     assert(!obj->mark().is_marked(), "should only mark an object once");
  75     obj->set_mark(markWord::prototype().set_marked());
  76     assert(obj->mark().is_marked(), "invariant");
  77   }
  78 };
  79 
  80 #endif // SHARE_JFR_LEAKPROFILER_CHAINS_OBJECTSAMPLEMARKER_HPP
   1 /*
   2  * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


  50 
  51   GrowableArray<ObjectSampleMarkWord>* _store;
  52 
  53  public:
  54   ObjectSampleMarker() :
  55        _store(new GrowableArray<ObjectSampleMarkWord>(16)) {}
  56   ~ObjectSampleMarker() {
  57     assert(_store != NULL, "invariant");
  58     // restore the saved, original, markWord for sample objects
  59     while (_store->is_nonempty()) {
  60       ObjectSampleMarkWord sample_oop = _store->pop();
  61       sample_oop._obj->set_mark(sample_oop._mark_word);
  62       assert(sample_oop._obj->mark() == sample_oop._mark_word, "invariant");
  63     }
  64   }
  65 
  66   void mark(oop obj) {
  67     assert(obj != NULL, "invariant");
  68     // save the original markWord
  69     _store->push(ObjectSampleMarkWord(obj, obj->mark()));
  70     // now we will set the mark word to "marked" in order to quickly
  71     // identify sample objects during the reachability search from gc roots.


  72     assert(!obj->mark().is_marked(), "should only mark an object once");
  73     obj->set_mark(markWord::prototype().set_marked());
  74     assert(obj->mark().is_marked(), "invariant");
  75   }
  76 };
  77 
  78 #endif // SHARE_JFR_LEAKPROFILER_CHAINS_OBJECTSAMPLEMARKER_HPP
< prev index next >