Wed, 26 Jun 2013 16:58:37 +0200
8013590: NPG: Add a memory pool MXBean for Metaspace
Reviewed-by: jmasa, mgerdin
1 /*
2 * Copyright (c) 2001, 2010, 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 *
23 */
25 #ifndef SHARE_VM_MEMORY_DEFNEWGENERATION_INLINE_HPP
26 #define SHARE_VM_MEMORY_DEFNEWGENERATION_INLINE_HPP
28 #include "memory/cardTableRS.hpp"
29 #include "memory/defNewGeneration.hpp"
30 #include "memory/space.hpp"
32 // Methods of protected closure types
34 template <class T>
35 inline void DefNewGeneration::KeepAliveClosure::do_oop_work(T* p) {
36 #ifdef ASSERT
37 {
38 // We never expect to see a null reference being processed
39 // as a weak reference.
40 assert (!oopDesc::is_null(*p), "expected non-null ref");
41 oop obj = oopDesc::load_decode_heap_oop_not_null(p);
42 assert (obj->is_oop(), "expected an oop while scanning weak refs");
43 }
44 #endif // ASSERT
46 _cl->do_oop_nv(p);
48 // Card marking is trickier for weak refs.
49 // This oop is a 'next' field which was filled in while we
50 // were discovering weak references. While we might not need
51 // to take a special action to keep this reference alive, we
52 // will need to dirty a card as the field was modified.
53 //
54 // Alternatively, we could create a method which iterates through
55 // each generation, allowing them in turn to examine the modified
56 // field.
57 //
58 // We could check that p is also in an older generation, but
59 // dirty cards in the youngest gen are never scanned, so the
60 // extra check probably isn't worthwhile.
61 if (Universe::heap()->is_in_reserved(p)) {
62 oop obj = oopDesc::load_decode_heap_oop_not_null(p);
63 _rs->inline_write_ref_field_gc(p, obj);
64 }
65 }
67 template <class T>
68 inline void DefNewGeneration::FastKeepAliveClosure::do_oop_work(T* p) {
69 #ifdef ASSERT
70 {
71 // We never expect to see a null reference being processed
72 // as a weak reference.
73 assert (!oopDesc::is_null(*p), "expected non-null ref");
74 oop obj = oopDesc::load_decode_heap_oop_not_null(p);
75 assert (obj->is_oop(), "expected an oop while scanning weak refs");
76 }
77 #endif // ASSERT
79 _cl->do_oop_nv(p);
81 // Optimized for Defnew generation if it's the youngest generation:
82 // we set a younger_gen card if we have an older->youngest
83 // generation pointer.
84 oop obj = oopDesc::load_decode_heap_oop_not_null(p);
85 if (((HeapWord*)obj < _boundary) && Universe::heap()->is_in_reserved(p)) {
86 _rs->inline_write_ref_field_gc(p, obj);
87 }
88 }
90 #endif // SHARE_VM_MEMORY_DEFNEWGENERATION_INLINE_HPP