author | eosterlund |
Thu, 26 Apr 2018 20:42:43 +0200 | |
changeset 49906 | 4bb58f644e4e |
parent 49754 | ee93c1087584 |
child 49938 | 2c2a722a2c0c |
permissions | -rw-r--r-- |
49484
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
1 |
/* |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
2 |
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
4 |
* |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
8 |
* |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
13 |
* accompanied this code). |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
14 |
* |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
18 |
* |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
21 |
* questions. |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
22 |
* |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
23 |
*/ |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
24 |
|
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
25 |
#include "precompiled.hpp" |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
26 |
#include "asm/macroAssembler.inline.hpp" |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
27 |
#include "gc/g1/g1BarrierSet.hpp" |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
28 |
#include "gc/g1/g1BarrierSetAssembler.hpp" |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
29 |
#include "gc/g1/g1CardTable.hpp" |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
30 |
#include "gc/g1/heapRegion.hpp" |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
31 |
#include "interpreter/interp_masm.hpp" |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
32 |
#include "runtime/sharedRuntime.hpp" |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
33 |
#include "runtime/thread.hpp" |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
34 |
#include "utilities/macros.hpp" |
49906 | 35 |
#ifdef COMPILER1 |
36 |
#include "c1/c1_LIRAssembler.hpp" |
|
37 |
#include "c1/c1_MacroAssembler.hpp" |
|
38 |
#include "gc/g1/c1/g1BarrierSetC1.hpp" |
|
39 |
#endif |
|
49484
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
40 |
|
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
41 |
#define __ masm-> |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
42 |
|
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
43 |
#ifdef PRODUCT |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
44 |
#define BLOCK_COMMENT(str) /* nothing */ |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
45 |
#else |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
46 |
#define BLOCK_COMMENT(str) __ block_comment(str) |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
47 |
#endif |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
48 |
|
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
49 |
#define BIND(label) bind(label); BLOCK_COMMENT(#label ":") |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
50 |
|
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
51 |
void G1BarrierSetAssembler::gen_write_ref_array_pre_barrier(MacroAssembler* masm, DecoratorSet decorators, |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
52 |
Register addr, Register count, int callee_saved_regs) { |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
53 |
bool dest_uninitialized = (decorators & AS_DEST_NOT_INITIALIZED) != 0; |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
54 |
if (!dest_uninitialized) { |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
55 |
assert( addr->encoding() < callee_saved_regs, "addr must be saved"); |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
56 |
assert(count->encoding() < callee_saved_regs, "count must be saved"); |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
57 |
|
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
58 |
BLOCK_COMMENT("PreBarrier"); |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
59 |
|
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
60 |
#ifdef AARCH64 |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
61 |
callee_saved_regs = align_up(callee_saved_regs, 2); |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
62 |
for (int i = 0; i < callee_saved_regs; i += 2) { |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
63 |
__ raw_push(as_Register(i), as_Register(i+1)); |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
64 |
} |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
65 |
#else |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
66 |
RegisterSet saved_regs = RegisterSet(R0, as_Register(callee_saved_regs-1)); |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
67 |
__ push(saved_regs | R9ifScratched); |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
68 |
#endif // AARCH64 |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
69 |
|
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
70 |
if (addr != R0) { |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
71 |
assert_different_registers(count, R0); |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
72 |
__ mov(R0, addr); |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
73 |
} |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
74 |
#ifdef AARCH64 |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
75 |
__ zero_extend(R1, count, 32); // G1BarrierSet::write_ref_array_pre_*_entry takes size_t |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
76 |
#else |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
77 |
if (count != R1) { |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
78 |
__ mov(R1, count); |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
79 |
} |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
80 |
#endif // AARCH64 |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
81 |
|
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
82 |
if (UseCompressedOops) { |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
83 |
__ call(CAST_FROM_FN_PTR(address, G1BarrierSet::write_ref_array_pre_narrow_oop_entry)); |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
84 |
} else { |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
85 |
__ call(CAST_FROM_FN_PTR(address, G1BarrierSet::write_ref_array_pre_oop_entry)); |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
86 |
} |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
87 |
|
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
88 |
#ifdef AARCH64 |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
89 |
for (int i = callee_saved_regs - 2; i >= 0; i -= 2) { |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
90 |
__ raw_pop(as_Register(i), as_Register(i+1)); |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
91 |
} |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
92 |
#else |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
93 |
__ pop(saved_regs | R9ifScratched); |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
94 |
#endif // AARCH64 |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
95 |
} |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
96 |
} |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
97 |
|
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
98 |
void G1BarrierSetAssembler::gen_write_ref_array_post_barrier(MacroAssembler* masm, DecoratorSet decorators, |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
99 |
Register addr, Register count, Register tmp) { |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
100 |
|
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
101 |
BLOCK_COMMENT("G1PostBarrier"); |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
102 |
if (addr != R0) { |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
103 |
assert_different_registers(count, R0); |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
104 |
__ mov(R0, addr); |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
105 |
} |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
106 |
#ifdef AARCH64 |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
107 |
__ zero_extend(R1, count, 32); // G1BarrierSet::write_ref_array_post_entry takes size_t |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
108 |
#else |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
109 |
if (count != R1) { |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
110 |
__ mov(R1, count); |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
111 |
} |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
112 |
#if R9_IS_SCRATCHED |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
113 |
// Safer to save R9 here since callers may have been written |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
114 |
// assuming R9 survives. This is suboptimal but is not in |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
115 |
// general worth optimizing for the few platforms where R9 |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
116 |
// is scratched. Note that the optimization might not be to |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
117 |
// difficult for this particular call site. |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
118 |
__ push(R9); |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
119 |
#endif // !R9_IS_SCRATCHED |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
120 |
#endif // !AARCH64 |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
121 |
__ call(CAST_FROM_FN_PTR(address, G1BarrierSet::write_ref_array_post_entry)); |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
122 |
#ifndef AARCH64 |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
123 |
#if R9_IS_SCRATCHED |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
124 |
__ pop(R9); |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
125 |
#endif // !R9_IS_SCRATCHED |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
126 |
#endif // !AARCH64 |
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff
changeset
|
127 |
} |
49906 | 128 |
|
129 |
#ifdef COMPILER1 |
|
130 |
||
131 |
#undef __ |
|
132 |
#define __ ce->masm()-> |
|
133 |
||
134 |
void G1BarrierSetAssembler::gen_pre_barrier_stub(LIR_Assembler* ce, G1PreBarrierStub* stub) { |
|
135 |
G1BarrierSetC1* bs = (G1BarrierSetC1*)BarrierSet::barrier_set()->barrier_set_c1(); |
|
136 |
// At this point we know that marking is in progress. |
|
137 |
// If do_load() is true then we have to emit the |
|
138 |
// load of the previous value; otherwise it has already |
|
139 |
// been loaded into _pre_val. |
|
140 |
||
141 |
__ bind(*stub->entry()); |
|
142 |
assert(stub->pre_val()->is_register(), "Precondition."); |
|
143 |
||
144 |
Register pre_val_reg = stub->pre_val()->as_register(); |
|
145 |
||
146 |
if (stub->do_load()) { |
|
147 |
ce->mem2reg(stub->addr(), stub->pre_val(), T_OBJECT, stub->patch_code(), stub->info(), false /*wide*/, false /*unaligned*/); |
|
148 |
} |
|
149 |
||
150 |
__ cbz(pre_val_reg, *stub->continuation()); |
|
151 |
ce->verify_reserved_argument_area_size(1); |
|
152 |
__ str(pre_val_reg, Address(SP)); |
|
153 |
__ call(bs->pre_barrier_c1_runtime_code_blob()->code_begin(), relocInfo::runtime_call_type); |
|
154 |
||
155 |
__ b(*stub->continuation()); |
|
156 |
} |
|
157 |
||
158 |
void G1BarrierSetAssembler::gen_post_barrier_stub(LIR_Assembler* ce, G1PostBarrierStub* stub) { |
|
159 |
G1BarrierSetC1* bs = (G1BarrierSetC1*)BarrierSet::barrier_set()->barrier_set_c1(); |
|
160 |
__ bind(*stub->entry()); |
|
161 |
assert(stub->addr()->is_register(), "Precondition."); |
|
162 |
assert(stub->new_val()->is_register(), "Precondition."); |
|
163 |
Register new_val_reg = stub->new_val()->as_register(); |
|
164 |
__ cbz(new_val_reg, *stub->continuation()); |
|
165 |
ce->verify_reserved_argument_area_size(1); |
|
166 |
__ str(stub->addr()->as_pointer_register(), Address(SP)); |
|
167 |
__ call(bs->post_barrier_c1_runtime_code_blob()->code_begin(), relocInfo::runtime_call_type); |
|
168 |
__ b(*stub->continuation()); |
|
169 |
} |
|
170 |
||
171 |
#undef __ |
|
172 |
#define __ sasm-> |
|
173 |
||
174 |
void G1BarrierSetAssembler::generate_c1_pre_barrier_runtime_stub(StubAssembler* sasm) { |
|
175 |
// Input: |
|
176 |
// - pre_val pushed on the stack |
|
177 |
||
178 |
__ set_info("g1_pre_barrier_slow_id", dont_gc_arguments); |
|
179 |
||
180 |
BarrierSet* bs = BarrierSet::barrier_set(); |
|
181 |
if (bs->kind() != BarrierSet::G1BarrierSet) { |
|
182 |
__ mov(R0, (int)id); |
|
183 |
__ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address, unimplemented_entry), R0); |
|
184 |
__ should_not_reach_here(); |
|
185 |
break; |
|
186 |
} |
|
187 |
||
188 |
// save at least the registers that need saving if the runtime is called |
|
189 |
#ifdef AARCH64 |
|
190 |
__ raw_push(R0, R1); |
|
191 |
__ raw_push(R2, R3); |
|
192 |
const int nb_saved_regs = 4; |
|
193 |
#else // AARCH64 |
|
194 |
const RegisterSet saved_regs = RegisterSet(R0,R3) | RegisterSet(R12) | RegisterSet(LR); |
|
195 |
const int nb_saved_regs = 6; |
|
196 |
assert(nb_saved_regs == saved_regs.size(), "fix nb_saved_regs"); |
|
197 |
__ push(saved_regs); |
|
198 |
#endif // AARCH64 |
|
199 |
||
200 |
const Register r_pre_val_0 = R0; // must be R0, to be ready for the runtime call |
|
201 |
const Register r_index_1 = R1; |
|
202 |
const Register r_buffer_2 = R2; |
|
203 |
||
204 |
Address queue_active(Rthread, in_bytes(G1ThreadLocalData::satb_mark_queue_active_offset())); |
|
205 |
Address queue_index(Rthread, in_bytes(G1ThreadLocalData::satb_mark_queue_index_offset())); |
|
206 |
Address buffer(Rthread, in_bytes(G1ThreadLocalData::satb_mark_queue_buffer_offset())); |
|
207 |
||
208 |
Label done; |
|
209 |
Label runtime; |
|
210 |
||
211 |
// Is marking still active? |
|
212 |
assert(in_bytes(SATBMarkQueue::byte_width_of_active()) == 1, "Assumption"); |
|
213 |
__ ldrb(R1, queue_active); |
|
214 |
__ cbz(R1, done); |
|
215 |
||
216 |
__ ldr(r_index_1, queue_index); |
|
217 |
__ ldr(r_pre_val_0, Address(SP, nb_saved_regs*wordSize)); |
|
218 |
__ ldr(r_buffer_2, buffer); |
|
219 |
||
220 |
__ subs(r_index_1, r_index_1, wordSize); |
|
221 |
__ b(runtime, lt); |
|
222 |
||
223 |
__ str(r_index_1, queue_index); |
|
224 |
__ str(r_pre_val_0, Address(r_buffer_2, r_index_1)); |
|
225 |
||
226 |
__ bind(done); |
|
227 |
||
228 |
#ifdef AARCH64 |
|
229 |
__ raw_pop(R2, R3); |
|
230 |
__ raw_pop(R0, R1); |
|
231 |
#else // AARCH64 |
|
232 |
__ pop(saved_regs); |
|
233 |
#endif // AARCH64 |
|
234 |
||
235 |
__ ret(); |
|
236 |
||
237 |
__ bind(runtime); |
|
238 |
||
239 |
__ save_live_registers(); |
|
240 |
||
241 |
assert(r_pre_val_0 == c_rarg0, "pre_val should be in R0"); |
|
242 |
__ mov(c_rarg1, Rthread); |
|
243 |
__ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::g1_wb_pre), c_rarg0, c_rarg1); |
|
244 |
||
245 |
__ restore_live_registers_without_return(); |
|
246 |
||
247 |
__ b(done); |
|
248 |
} |
|
249 |
||
250 |
void G1BarrierSetAssembler::generate_c1_post_barrier_runtime_stub(StubAssembler* sasm) { |
|
251 |
// Input: |
|
252 |
// - store_addr, pushed on the stack |
|
253 |
||
254 |
__ set_info("g1_post_barrier_slow_id", dont_gc_arguments); |
|
255 |
||
256 |
BarrierSet* bs = BarrierSet::barrier_set(); |
|
257 |
if (bs->kind() != BarrierSet::G1BarrierSet) { |
|
258 |
__ mov(R0, (int)id); |
|
259 |
__ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address, unimplemented_entry), R0); |
|
260 |
__ should_not_reach_here(); |
|
261 |
break; |
|
262 |
} |
|
263 |
||
264 |
Label done; |
|
265 |
Label recheck; |
|
266 |
Label runtime; |
|
267 |
||
268 |
Address queue_index(Rthread, in_bytes(G1ThreadLocalData::dirty_card_queue_index_offset())); |
|
269 |
Address buffer(Rthread, in_bytes(G1ThreadLocalData::dirty_card_queue_buffer_offset())); |
|
270 |
||
271 |
AddressLiteral cardtable(ci_card_table_address_as<address>(), relocInfo::none); |
|
272 |
||
273 |
// save at least the registers that need saving if the runtime is called |
|
274 |
#ifdef AARCH64 |
|
275 |
__ raw_push(R0, R1); |
|
276 |
__ raw_push(R2, R3); |
|
277 |
const int nb_saved_regs = 4; |
|
278 |
#else // AARCH64 |
|
279 |
const RegisterSet saved_regs = RegisterSet(R0,R3) | RegisterSet(R12) | RegisterSet(LR); |
|
280 |
const int nb_saved_regs = 6; |
|
281 |
assert(nb_saved_regs == saved_regs.size(), "fix nb_saved_regs"); |
|
282 |
__ push(saved_regs); |
|
283 |
#endif // AARCH64 |
|
284 |
||
285 |
const Register r_card_addr_0 = R0; // must be R0 for the slow case |
|
286 |
const Register r_obj_0 = R0; |
|
287 |
const Register r_card_base_1 = R1; |
|
288 |
const Register r_tmp2 = R2; |
|
289 |
const Register r_index_2 = R2; |
|
290 |
const Register r_buffer_3 = R3; |
|
291 |
const Register tmp1 = Rtemp; |
|
292 |
||
293 |
__ ldr(r_obj_0, Address(SP, nb_saved_regs*wordSize)); |
|
294 |
// Note: there is a comment in x86 code about not using |
|
295 |
// ExternalAddress / lea, due to relocation not working |
|
296 |
// properly for that address. Should be OK for arm, where we |
|
297 |
// explicitly specify that 'cardtable' has a relocInfo::none |
|
298 |
// type. |
|
299 |
__ lea(r_card_base_1, cardtable); |
|
300 |
__ add(r_card_addr_0, r_card_base_1, AsmOperand(r_obj_0, lsr, CardTable::card_shift)); |
|
301 |
||
302 |
// first quick check without barrier |
|
303 |
__ ldrb(r_tmp2, Address(r_card_addr_0)); |
|
304 |
||
305 |
__ cmp(r_tmp2, (int)G1CardTable::g1_young_card_val()); |
|
306 |
__ b(recheck, ne); |
|
307 |
||
308 |
__ bind(done); |
|
309 |
||
310 |
#ifdef AARCH64 |
|
311 |
__ raw_pop(R2, R3); |
|
312 |
__ raw_pop(R0, R1); |
|
313 |
#else // AARCH64 |
|
314 |
__ pop(saved_regs); |
|
315 |
#endif // AARCH64 |
|
316 |
||
317 |
__ ret(); |
|
318 |
||
319 |
__ bind(recheck); |
|
320 |
||
321 |
__ membar(MacroAssembler::Membar_mask_bits(MacroAssembler::StoreLoad), tmp1); |
|
322 |
||
323 |
// reload card state after the barrier that ensures the stored oop was visible |
|
324 |
__ ldrb(r_tmp2, Address(r_card_addr_0)); |
|
325 |
||
326 |
assert(CardTable::dirty_card_val() == 0, "adjust this code"); |
|
327 |
__ cbz(r_tmp2, done); |
|
328 |
||
329 |
// storing region crossing non-NULL, card is clean. |
|
330 |
// dirty card and log. |
|
331 |
||
332 |
assert(0 == (int)CardTable::dirty_card_val(), "adjust this code"); |
|
333 |
if ((ci_card_table_address_as<intptr_t>() & 0xff) == 0) { |
|
334 |
// Card table is aligned so the lowest byte of the table address base is zero. |
|
335 |
__ strb(r_card_base_1, Address(r_card_addr_0)); |
|
336 |
} else { |
|
337 |
__ strb(__ zero_register(r_tmp2), Address(r_card_addr_0)); |
|
338 |
} |
|
339 |
||
340 |
__ ldr(r_index_2, queue_index); |
|
341 |
__ ldr(r_buffer_3, buffer); |
|
342 |
||
343 |
__ subs(r_index_2, r_index_2, wordSize); |
|
344 |
__ b(runtime, lt); // go to runtime if now negative |
|
345 |
||
346 |
__ str(r_index_2, queue_index); |
|
347 |
||
348 |
__ str(r_card_addr_0, Address(r_buffer_3, r_index_2)); |
|
349 |
||
350 |
__ b(done); |
|
351 |
||
352 |
__ bind(runtime); |
|
353 |
||
354 |
__ save_live_registers(); |
|
355 |
||
356 |
assert(r_card_addr_0 == c_rarg0, "card_addr should be in R0"); |
|
357 |
__ mov(c_rarg1, Rthread); |
|
358 |
__ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::g1_wb_post), c_rarg0, c_rarg1); |
|
359 |
||
360 |
__ restore_live_registers_without_return(); |
|
361 |
||
362 |
__ b(done); |
|
363 |
} |
|
364 |
||
365 |
#undef __ |
|
366 |
||
367 |
#endif // COMPILER1 |