Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/hotspot/cpu/s390/gc/shared/cardTableBarrierSetAssembler_s390.cpp
41153 views
1
/*
2
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
3
* Copyright (c) 2018 SAP SE. All rights reserved.
4
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5
*
6
* This code is free software; you can redistribute it and/or modify it
7
* under the terms of the GNU General Public License version 2 only, as
8
* published by the Free Software Foundation.
9
*
10
* This code is distributed in the hope that it will be useful, but WITHOUT
11
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13
* version 2 for more details (a copy is included in the LICENSE file that
14
* accompanied this code).
15
*
16
* You should have received a copy of the GNU General Public License version
17
* 2 along with this work; if not, write to the Free Software Foundation,
18
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19
*
20
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21
* or visit www.oracle.com if you need additional information or have any
22
* questions.
23
*
24
*/
25
26
#include "precompiled.hpp"
27
#include "asm/macroAssembler.inline.hpp"
28
#include "gc/shared/barrierSet.hpp"
29
#include "gc/shared/cardTable.hpp"
30
#include "gc/shared/cardTableBarrierSet.hpp"
31
#include "gc/shared/cardTableBarrierSetAssembler.hpp"
32
#include "interpreter/interp_masm.hpp"
33
34
#define __ masm->
35
36
#ifdef PRODUCT
37
#define BLOCK_COMMENT(str) /* nothing */
38
#else
39
#define BLOCK_COMMENT(str) __ block_comment(str)
40
#endif
41
42
#define BIND(label) bind(label); BLOCK_COMMENT(#label ":")
43
44
#define TIMES_OOP (UseCompressedOops ? Address::times_4 : Address::times_8)
45
46
void CardTableBarrierSetAssembler::gen_write_ref_array_post_barrier(MacroAssembler* masm, DecoratorSet decorators, Register addr, Register count,
47
bool do_return) {
48
CardTableBarrierSet* ctbs = barrier_set_cast<CardTableBarrierSet>(BarrierSet::barrier_set());
49
CardTable* ct = ctbs->card_table();
50
51
NearLabel doXC, done;
52
assert_different_registers(Z_R0, Z_R1, addr, count);
53
54
// Nothing to do if count <= 0.
55
if (!do_return) {
56
__ compare64_and_branch(count, (intptr_t) 0, Assembler::bcondNotHigh, done);
57
} else {
58
__ z_ltgr(count, count);
59
__ z_bcr(Assembler::bcondNotPositive, Z_R14);
60
}
61
62
// Note: We can't combine the shifts. We could lose a carry
63
// from calculating the array end address.
64
// count = (count-1)*BytesPerHeapOop + addr
65
// Count holds addr of last oop in array then.
66
__ z_sllg(count, count, LogBytesPerHeapOop);
67
__ add2reg_with_index(count, -BytesPerHeapOop, count, addr);
68
69
// Get base address of card table.
70
__ load_const_optimized(Z_R1, (address)ct->byte_map_base());
71
72
// count = (count>>shift) - (addr>>shift)
73
__ z_srlg(addr, addr, CardTable::card_shift);
74
__ z_srlg(count, count, CardTable::card_shift);
75
76
// Prefetch first elements of card table for update.
77
if (VM_Version::has_Prefetch()) {
78
__ z_pfd(0x02, 0, addr, Z_R1);
79
}
80
81
// Special case: clear just one byte.
82
__ clear_reg(Z_R0, true, false); // Used for doOneByte.
83
__ z_sgr(count, addr); // Count = n-1 now, CC used for brc below.
84
__ z_stc(Z_R0, 0, addr, Z_R1); // Must preserve CC from z_sgr.
85
if (!do_return) {
86
__ z_brz(done);
87
} else {
88
__ z_bcr(Assembler::bcondZero, Z_R14);
89
}
90
91
__ z_cghi(count, 255);
92
__ z_brnh(doXC);
93
94
// MVCLE: clear a long area.
95
// Start addr of card table range = base + addr.
96
// # bytes in card table range = (count + 1)
97
__ add2reg_with_index(Z_R0, 0, Z_R1, addr);
98
__ add2reg(Z_R1, 1, count);
99
100
// dirty hack:
101
// There are just two callers. Both pass
102
// count in Z_ARG3 = Z_R4
103
// addr in Z_ARG2 = Z_R3
104
// ==> use Z_ARG2 as src len reg = 0
105
// Z_ARG1 as src addr (ignored)
106
assert(count == Z_ARG3, "count: unexpected register number");
107
assert(addr == Z_ARG2, "addr: unexpected register number");
108
__ clear_reg(Z_ARG2, true, false);
109
110
__ MacroAssembler::move_long_ext(Z_R0, Z_ARG1, 0);
111
112
if (!do_return) {
113
__ z_bru(done);
114
} else {
115
__ z_bcr(Assembler::bcondAlways, Z_R14);
116
}
117
118
// XC: clear a short area.
119
Label XC_template; // Instr template, never exec directly!
120
__ bind(XC_template);
121
__ z_xc(0, 0, addr, 0, addr);
122
123
__ bind(doXC);
124
// start addr of card table range = base + addr
125
// end addr of card table range = base + addr + count
126
__ add2reg_with_index(addr, 0, Z_R1, addr);
127
128
if (VM_Version::has_ExecuteExtensions()) {
129
__ z_exrl(count, XC_template); // Execute XC with var. len.
130
} else {
131
__ z_larl(Z_R1, XC_template);
132
__ z_ex(count, 0, Z_R0, Z_R1); // Execute XC with var. len.
133
}
134
if (do_return) {
135
__ z_br(Z_R14);
136
}
137
138
__ bind(done);
139
}
140
141
void CardTableBarrierSetAssembler::store_check(MacroAssembler* masm, Register store_addr, Register tmp) {
142
// Does a store check for the oop in register obj. The content of
143
// register obj is destroyed afterwards.
144
CardTableBarrierSet* ctbs = barrier_set_cast<CardTableBarrierSet>(BarrierSet::barrier_set());
145
CardTable* ct = ctbs->card_table();
146
147
assert_different_registers(store_addr, tmp);
148
149
__ z_srlg(store_addr, store_addr, CardTable::card_shift);
150
__ load_absolute_address(tmp, (address)ct->byte_map_base());
151
__ z_agr(store_addr, tmp);
152
__ z_mvi(0, store_addr, CardTable::dirty_card_val());
153
}
154
155
void CardTableBarrierSetAssembler::oop_store_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type,
156
const Address& dst, Register val, Register tmp1, Register tmp2, Register tmp3) {
157
bool is_array = (decorators & IS_ARRAY) != 0;
158
bool on_anonymous = (decorators & ON_UNKNOWN_OOP_REF) != 0;
159
bool precise = is_array || on_anonymous;
160
161
BarrierSetAssembler::store_at(masm, decorators, type, dst, val, tmp1, tmp2, tmp3);
162
163
// No need for post barrier if storing NULL
164
if (val != noreg) {
165
const Register base = dst.base(),
166
idx = dst.index();
167
const intptr_t disp = dst.disp();
168
if (precise && (disp != 0 || idx != noreg)) {
169
__ add2reg_with_index(base, disp, idx, base);
170
}
171
store_check(masm, base, tmp1);
172
}
173
}
174
175