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 #include "ci/ciUtilities.hpp"
26 #include "gc/shared/c2/cardTableBarrierSetC2.hpp"
27 #include "gc/shared/cardTable.hpp"
28 #include "gc/shared/cardTableBarrierSet.hpp"
29 #include "gc/shared/gc_globals.hpp"
30 #include "opto/arraycopynode.hpp"
31 #include "opto/graphKit.hpp"
32 #include "opto/idealKit.hpp"
33 #include "opto/macro.hpp"
34 #include "utilities/macros.hpp"
35
36 #define __ ideal.
37
38 Node* CardTableBarrierSetC2::byte_map_base_node(GraphKit* kit) const {
39 // Get base of card map
40 CardTable::CardValue* card_table_base = ci_card_table_address();
41 if (card_table_base != nullptr) {
42 return kit->makecon(TypeRawPtr::make((address)card_table_base));
43 } else {
44 return kit->null();
45 }
46 }
47
48 // vanilla post barrier
49 // Insert a write-barrier store. This is to let generational GC work; we have
50 // to flag all oop-stores before the next GC point.
51 void CardTableBarrierSetC2::post_barrier(GraphKit* kit,
52 Node* obj,
53 Node* adr,
54 Node* val,
55 bool use_precise) const {
56 // No store check needed if we're storing a null.
57 if (val != nullptr && val->is_Con()) {
58 const Type* t = val->bottom_type();
59 if (t == TypePtr::NULL_PTR || t == Type::TOP) {
60 return;
61 }
62 }
63
64 if (use_ReduceInitialCardMarks()
65 && obj == kit->just_allocated_object(kit->control())) {
72 }
73
74 if (!use_precise) {
75 // All card marks for a (non-array) instance are in one place:
76 adr = obj;
77 } else {
78 // Else it's an array (or unknown), and we want more precise card marks.
79 }
80
81 assert(adr != nullptr, "");
82
83 IdealKit ideal(kit, true);
84
85 // Convert the pointer to an int prior to doing math on it
86 Node* cast = __ CastPX(__ ctrl(), adr);
87
88 // Divide by card size
89 Node* card_offset = __ URShiftX(cast, __ ConI(CardTable::card_shift()));
90
91 // Combine card table base and card offset
92 Node* card_adr = __ AddP(__ top(), byte_map_base_node(kit), card_offset);
93
94 // Get the alias_index for raw card-mark memory
95 int adr_type = Compile::AliasIdxRaw;
96
97 // Dirty card value to store
98 Node* dirty = __ ConI(CardTable::dirty_card_val());
99
100 if (UseCondCardMark) {
101 // The classic GC reference write barrier is typically implemented
102 // as a store into the global card mark table. Unfortunately
103 // unconditional stores can result in false sharing and excessive
104 // coherence traffic as well as false transactional aborts.
105 // UseCondCardMark enables MP "polite" conditional card mark
106 // stores. In theory we could relax the load from ctrl() to
107 // no_ctrl, but that doesn't buy much latitude.
108 Node* card_val = __ load( __ ctrl(), card_adr, TypeInt::BYTE, T_BYTE, adr_type);
109 __ if_then(card_val, BoolTest::ne, dirty);
110 }
111
112 // Smash dirty value into card
|
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 #include "ci/ciUtilities.hpp"
26 #include "code/aotCodeCache.hpp"
27 #include "gc/shared/c2/cardTableBarrierSetC2.hpp"
28 #include "gc/shared/cardTable.hpp"
29 #include "gc/shared/cardTableBarrierSet.hpp"
30 #include "gc/shared/gc_globals.hpp"
31 #include "opto/arraycopynode.hpp"
32 #include "opto/graphKit.hpp"
33 #include "opto/idealKit.hpp"
34 #include "opto/macro.hpp"
35 #include "utilities/macros.hpp"
36
37 #define __ ideal.
38
39 Node* CardTableBarrierSetC2::byte_map_base_node(IdealKit* kit) const {
40 // Get base of card map
41 #if INCLUDE_CDS
42 if (AOTCodeCache::is_on_for_dump()) {
43 // load the card table address from the AOT Runtime Constants area
44 Node* byte_map_base_adr = kit->makecon(TypeRawPtr::make(AOTRuntimeConstants::card_table_address()));
45 return kit->load_aot_const(byte_map_base_adr, TypeRawPtr::NOTNULL);
46 }
47 #endif
48 CardTable::CardValue* card_table_base = ci_card_table_address();
49 if (card_table_base != nullptr) {
50 return kit->makecon(TypeRawPtr::make((address)card_table_base));
51 } else {
52 return kit->makecon(Type::get_zero_type(T_ADDRESS));
53 }
54 }
55
56 // vanilla post barrier
57 // Insert a write-barrier store. This is to let generational GC work; we have
58 // to flag all oop-stores before the next GC point.
59 void CardTableBarrierSetC2::post_barrier(GraphKit* kit,
60 Node* obj,
61 Node* adr,
62 Node* val,
63 bool use_precise) const {
64 // No store check needed if we're storing a null.
65 if (val != nullptr && val->is_Con()) {
66 const Type* t = val->bottom_type();
67 if (t == TypePtr::NULL_PTR || t == Type::TOP) {
68 return;
69 }
70 }
71
72 if (use_ReduceInitialCardMarks()
73 && obj == kit->just_allocated_object(kit->control())) {
80 }
81
82 if (!use_precise) {
83 // All card marks for a (non-array) instance are in one place:
84 adr = obj;
85 } else {
86 // Else it's an array (or unknown), and we want more precise card marks.
87 }
88
89 assert(adr != nullptr, "");
90
91 IdealKit ideal(kit, true);
92
93 // Convert the pointer to an int prior to doing math on it
94 Node* cast = __ CastPX(__ ctrl(), adr);
95
96 // Divide by card size
97 Node* card_offset = __ URShiftX(cast, __ ConI(CardTable::card_shift()));
98
99 // Combine card table base and card offset
100 Node* card_adr = __ AddP(__ top(), byte_map_base_node(&ideal), card_offset);
101
102 // Get the alias_index for raw card-mark memory
103 int adr_type = Compile::AliasIdxRaw;
104
105 // Dirty card value to store
106 Node* dirty = __ ConI(CardTable::dirty_card_val());
107
108 if (UseCondCardMark) {
109 // The classic GC reference write barrier is typically implemented
110 // as a store into the global card mark table. Unfortunately
111 // unconditional stores can result in false sharing and excessive
112 // coherence traffic as well as false transactional aborts.
113 // UseCondCardMark enables MP "polite" conditional card mark
114 // stores. In theory we could relax the load from ctrl() to
115 // no_ctrl, but that doesn't buy much latitude.
116 Node* card_val = __ load( __ ctrl(), card_adr, TypeInt::BYTE, T_BYTE, adr_type);
117 __ if_then(card_val, BoolTest::ne, dirty);
118 }
119
120 // Smash dirty value into card
|