| 1 | /* |
| 2 | * Copyright (c) 2018, 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 | */ |
| 23 | |
| 24 | #ifndef SHARE_GC_G1_G1THREADLOCALDATA_HPP |
| 25 | #define SHARE_GC_G1_G1THREADLOCALDATA_HPP |
| 26 | |
| 27 | #include "gc/g1/g1BarrierSet.hpp" |
| 28 | #include "gc/g1/g1DirtyCardQueue.hpp" |
| 29 | #include "gc/shared/satbMarkQueue.hpp" |
| 30 | #include "runtime/thread.hpp" |
| 31 | #include "utilities/debug.hpp" |
| 32 | #include "utilities/sizes.hpp" |
| 33 | |
| 34 | class G1ThreadLocalData { |
| 35 | private: |
| 36 | SATBMarkQueue _satb_mark_queue; |
| 37 | G1DirtyCardQueue _dirty_card_queue; |
| 38 | |
| 39 | G1ThreadLocalData() : |
| 40 | _satb_mark_queue(&G1BarrierSet::satb_mark_queue_set()), |
| 41 | _dirty_card_queue(&G1BarrierSet::dirty_card_queue_set()) {} |
| 42 | |
| 43 | static G1ThreadLocalData* data(Thread* thread) { |
| 44 | assert(UseG1GC, "Sanity" ); |
| 45 | return thread->gc_data<G1ThreadLocalData>(); |
| 46 | } |
| 47 | |
| 48 | static ByteSize satb_mark_queue_offset() { |
| 49 | return Thread::gc_data_offset() + byte_offset_of(G1ThreadLocalData, _satb_mark_queue); |
| 50 | } |
| 51 | |
| 52 | static ByteSize dirty_card_queue_offset() { |
| 53 | return Thread::gc_data_offset() + byte_offset_of(G1ThreadLocalData, _dirty_card_queue); |
| 54 | } |
| 55 | |
| 56 | public: |
| 57 | static void create(Thread* thread) { |
| 58 | new (data(thread)) G1ThreadLocalData(); |
| 59 | } |
| 60 | |
| 61 | static void destroy(Thread* thread) { |
| 62 | data(thread)->~G1ThreadLocalData(); |
| 63 | } |
| 64 | |
| 65 | static SATBMarkQueue& satb_mark_queue(Thread* thread) { |
| 66 | return data(thread)->_satb_mark_queue; |
| 67 | } |
| 68 | |
| 69 | static G1DirtyCardQueue& dirty_card_queue(Thread* thread) { |
| 70 | return data(thread)->_dirty_card_queue; |
| 71 | } |
| 72 | |
| 73 | static ByteSize satb_mark_queue_active_offset() { |
| 74 | return satb_mark_queue_offset() + SATBMarkQueue::byte_offset_of_active(); |
| 75 | } |
| 76 | |
| 77 | static ByteSize satb_mark_queue_index_offset() { |
| 78 | return satb_mark_queue_offset() + SATBMarkQueue::byte_offset_of_index(); |
| 79 | } |
| 80 | |
| 81 | static ByteSize satb_mark_queue_buffer_offset() { |
| 82 | return satb_mark_queue_offset() + SATBMarkQueue::byte_offset_of_buf(); |
| 83 | } |
| 84 | |
| 85 | static ByteSize dirty_card_queue_index_offset() { |
| 86 | return dirty_card_queue_offset() + G1DirtyCardQueue::byte_offset_of_index(); |
| 87 | } |
| 88 | |
| 89 | static ByteSize dirty_card_queue_buffer_offset() { |
| 90 | return dirty_card_queue_offset() + G1DirtyCardQueue::byte_offset_of_buf(); |
| 91 | } |
| 92 | }; |
| 93 | |
| 94 | #endif // SHARE_GC_G1_G1THREADLOCALDATA_HPP |
| 95 | |