Mon, 08 Dec 2014 18:57:33 +0100
8067655: Clean up G1 remembered set oop iteration
Summary: Pass on the static type G1ParPushHeapRSClosure to allow oop_iterate devirtualization
Reviewed-by: jmasa, kbarrett
aoqi@0 | 1 | /* |
aoqi@0 | 2 | * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. |
aoqi@0 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
aoqi@0 | 4 | * |
aoqi@0 | 5 | * This code is free software; you can redistribute it and/or modify it |
aoqi@0 | 6 | * under the terms of the GNU General Public License version 2 only, as |
aoqi@0 | 7 | * published by the Free Software Foundation. |
aoqi@0 | 8 | * |
aoqi@0 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
aoqi@0 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
aoqi@0 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
aoqi@0 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
aoqi@0 | 13 | * accompanied this code). |
aoqi@0 | 14 | * |
aoqi@0 | 15 | * You should have received a copy of the GNU General Public License version |
aoqi@0 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
aoqi@0 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
aoqi@0 | 18 | * |
aoqi@0 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
aoqi@0 | 20 | * or visit www.oracle.com if you need additional information or have any |
aoqi@0 | 21 | * questions. |
aoqi@0 | 22 | * |
aoqi@0 | 23 | */ |
aoqi@0 | 24 | |
aoqi@0 | 25 | #ifndef SHARE_VM_GC_IMPLEMENTATION_G1_G1CODECACHEREMSET_HPP |
aoqi@0 | 26 | #define SHARE_VM_GC_IMPLEMENTATION_G1_G1CODECACHEREMSET_HPP |
aoqi@0 | 27 | |
aoqi@0 | 28 | #include "memory/allocation.hpp" |
aoqi@0 | 29 | |
aoqi@0 | 30 | class CodeBlobClosure; |
mgerdin@7208 | 31 | class CodeRootSetTable; |
mgerdin@7208 | 32 | class HeapRegion; |
mgerdin@7208 | 33 | class nmethod; |
tschatzl@6925 | 34 | |
aoqi@0 | 35 | // Implements storage for a set of code roots. |
aoqi@0 | 36 | // All methods that modify the set are not thread-safe except if otherwise noted. |
aoqi@0 | 37 | class G1CodeRootSet VALUE_OBJ_CLASS_SPEC { |
mgerdin@7208 | 38 | friend class G1CodeRootSetTest; |
aoqi@0 | 39 | private: |
aoqi@0 | 40 | |
mgerdin@7208 | 41 | const static size_t SmallSize = 32; |
mgerdin@7208 | 42 | const static size_t Threshold = 24; |
mgerdin@7208 | 43 | const static size_t LargeSize = 512; |
aoqi@0 | 44 | |
mgerdin@7208 | 45 | CodeRootSetTable* _table; |
mgerdin@7208 | 46 | CodeRootSetTable* load_acquire_table(); |
aoqi@0 | 47 | |
aoqi@0 | 48 | size_t _length; |
mgerdin@7208 | 49 | |
mgerdin@7208 | 50 | void move_to_large(); |
mgerdin@7208 | 51 | void allocate_small_table(); |
aoqi@0 | 52 | |
aoqi@0 | 53 | public: |
mgerdin@7208 | 54 | G1CodeRootSet() : _table(NULL), _length(0) {} |
aoqi@0 | 55 | ~G1CodeRootSet(); |
aoqi@0 | 56 | |
mgerdin@7208 | 57 | static void purge(); |
aoqi@0 | 58 | |
mgerdin@7208 | 59 | static size_t static_mem_size(); |
aoqi@0 | 60 | |
aoqi@0 | 61 | void add(nmethod* method); |
aoqi@0 | 62 | |
mgerdin@7208 | 63 | bool remove(nmethod* method); |
aoqi@0 | 64 | |
mgerdin@7208 | 65 | // Safe to call without synchronization, but may return false negatives. |
aoqi@0 | 66 | bool contains(nmethod* method); |
aoqi@0 | 67 | |
aoqi@0 | 68 | void clear(); |
aoqi@0 | 69 | |
aoqi@0 | 70 | void nmethods_do(CodeBlobClosure* blk) const; |
aoqi@0 | 71 | |
mgerdin@7208 | 72 | // Remove all nmethods which no longer contain pointers into our "owner" region |
mgerdin@7208 | 73 | void clean(HeapRegion* owner); |
mgerdin@7208 | 74 | |
mgerdin@7208 | 75 | bool is_empty() { |
mgerdin@7208 | 76 | bool empty = length() == 0; |
mgerdin@7208 | 77 | assert(empty == (_table == NULL), "is empty only if table is deallocated"); |
mgerdin@7208 | 78 | return empty; |
mgerdin@7208 | 79 | } |
aoqi@0 | 80 | |
aoqi@0 | 81 | // Length in elements |
aoqi@0 | 82 | size_t length() const { return _length; } |
aoqi@0 | 83 | |
aoqi@0 | 84 | // Memory size in bytes taken by this set. |
aoqi@0 | 85 | size_t mem_size(); |
aoqi@0 | 86 | |
aoqi@0 | 87 | }; |
aoqi@0 | 88 | |
aoqi@0 | 89 | #endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1CODECACHEREMSET_HPP |