1 /* 2 * Copyright (c) 2000, 2012, 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 */ 24 25 #ifndef SHARE_VM_MEMORY_BARRIERSET_HPP 26 #define SHARE_VM_MEMORY_BARRIERSET_HPP 27 28 #include "memory/memRegion.hpp" 29 #include "oops/oopsHierarchy.hpp" 30 31 // This class provides the interface between a barrier implementation and 32 // the rest of the system. 33 34 class BarrierSet: public CHeapObj<mtGC> { 35 friend class VMStructs; 36 public: 37 enum Name { 38 ModRef, 39 CardTableModRef, 40 CardTableExtension, 41 G1SATBCT, 42 G1SATBCTLogging, 43 Other, 44 Uninit 45 }; 46 47 enum Flags { 48 None = 0, 49 TargetUninitialized = 1 50 }; 51 protected: 52 // Some barrier sets create tables whose elements correspond to parts of 53 // the heap; the CardTableModRefBS is an example. Such barrier sets will 54 // normally reserve space for such tables, and commit parts of the table 55 // "covering" parts of the heap that are committed. At most one covered 56 // region per generation is needed. 57 static const int _max_covered_regions = 2; 58 Name _kind; 59 60 public: 61 62 BarrierSet() { _kind = Uninit; } 63 // To get around prohibition on RTTI. 64 BarrierSet::Name kind() { return _kind; } 65 virtual bool is_a(BarrierSet::Name bsn) = 0; 66 67 // These operations indicate what kind of barriers the BarrierSet has. 68 virtual bool has_read_ref_barrier() = 0; 69 virtual bool has_read_prim_barrier() = 0; 70 virtual bool has_write_ref_barrier() = 0; 71 virtual bool has_write_ref_pre_barrier() = 0; 72 virtual bool has_write_prim_barrier() = 0; 73 74 // These functions indicate whether a particular access of the given 75 // kinds requires a barrier. 76 virtual bool read_ref_needs_barrier(void* field) = 0; 77 virtual bool read_prim_needs_barrier(HeapWord* field, size_t bytes) = 0; 78 virtual bool write_prim_needs_barrier(HeapWord* field, size_t bytes, 79 juint val1, juint val2) = 0; 80 81 // The first four operations provide a direct implementation of the 82 // barrier set. An interpreter loop, for example, could call these | 1 /* 2 * Copyright (c) 2000, 2015, 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 */ 24 25 #ifndef SHARE_VM_MEMORY_BARRIERSET_HPP 26 #define SHARE_VM_MEMORY_BARRIERSET_HPP 27 28 #include "memory/memRegion.hpp" 29 #include "oops/oopsHierarchy.hpp" 30 31 // This class provides the interface between a barrier implementation and 32 // the rest of the system. 33 34 class BarrierSet: public CHeapObj<mtGC> { 35 friend class VMStructs; 36 public: 37 enum Name { 38 ModRef, 39 CardTableModRef, 40 CardTableExtension, 41 G1SATBCT, 42 G1SATBCTLogging, 43 Other 44 }; 45 46 enum Flags { 47 None = 0, 48 TargetUninitialized = 1 49 }; 50 protected: 51 // Some barrier sets create tables whose elements correspond to parts of 52 // the heap; the CardTableModRefBS is an example. Such barrier sets will 53 // normally reserve space for such tables, and commit parts of the table 54 // "covering" parts of the heap that are committed. At most one covered 55 // region per generation is needed. 56 static const int _max_covered_regions = 2; 57 Name _kind; 58 59 BarrierSet(Name kind) : _kind(kind) { } 60 ~BarrierSet() { } 61 62 public: 63 64 // To get around prohibition on RTTI. 65 BarrierSet::Name kind() { return _kind; } 66 virtual bool is_a(BarrierSet::Name bsn) = 0; 67 68 // These operations indicate what kind of barriers the BarrierSet has. 69 virtual bool has_read_ref_barrier() = 0; 70 virtual bool has_read_prim_barrier() = 0; 71 virtual bool has_write_ref_barrier() = 0; 72 virtual bool has_write_ref_pre_barrier() = 0; 73 virtual bool has_write_prim_barrier() = 0; 74 75 // These functions indicate whether a particular access of the given 76 // kinds requires a barrier. 77 virtual bool read_ref_needs_barrier(void* field) = 0; 78 virtual bool read_prim_needs_barrier(HeapWord* field, size_t bytes) = 0; 79 virtual bool write_prim_needs_barrier(HeapWord* field, size_t bytes, 80 juint val1, juint val2) = 0; 81 82 // The first four operations provide a direct implementation of the 83 // barrier set. An interpreter loop, for example, could call these |