author | eosterlund |
Wed, 09 Oct 2019 12:30:06 +0000 | |
changeset 58516 | d376d86b0a01 |
parent 55563 | d56b192c73e9 |
child 58679 | 9c3209ff7550 |
permissions | -rw-r--r-- |
55379 | 1 |
// |
2 |
// Copyright (c) 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 |
source_hpp %{ |
|
25 |
||
26 |
#include "gc/z/c2/zBarrierSetC2.hpp" |
|
58516
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
27 |
#include "gc/z/zThreadLocalData.hpp" |
55379 | 28 |
|
29 |
%} |
|
30 |
||
31 |
source %{ |
|
32 |
||
58516
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
33 |
static void z_load_barrier(MacroAssembler& _masm, const MachNode* node, Address ref_addr, Register ref, Register tmp, bool weak) { |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
34 |
ZLoadBarrierStubC2* const stub = ZLoadBarrierStubC2::create(node, ref_addr, ref, tmp, weak); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
35 |
__ ldr(tmp, Address(rthread, ZThreadLocalData::address_bad_mask_offset())); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
36 |
__ andr(tmp, tmp, ref); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
37 |
__ cbnz(tmp, *stub->entry()); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
38 |
__ bind(*stub->continuation()); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
39 |
} |
55379 | 40 |
|
58516
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
41 |
static void z_load_barrier_slow_path(MacroAssembler& _masm, const MachNode* node, Address ref_addr, Register ref, Register tmp) { |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
42 |
ZLoadBarrierStubC2* const stub = ZLoadBarrierStubC2::create(node, ref_addr, ref, tmp, false /* weak */); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
43 |
__ b(*stub->entry()); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
44 |
__ bind(*stub->continuation()); |
55379 | 45 |
} |
46 |
||
47 |
%} |
|
48 |
||
58516
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
49 |
// Load Pointer |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
50 |
instruct zLoadP(iRegPNoSp dst, memory mem, rFlagsReg cr) |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
51 |
%{ |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
52 |
match(Set dst (LoadP mem)); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
53 |
predicate(UseZGC && !needs_acquiring_load(n) && (n->as_Load()->barrier_data() == ZLoadBarrierStrong)); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
54 |
effect(TEMP dst, KILL cr); |
55379 | 55 |
|
58516
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
56 |
ins_cost(4 * INSN_COST); |
55379 | 57 |
|
58516
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
58 |
format %{ "ldr $dst, $mem" %} |
55563
d56b192c73e9
8225642: ZGC: Crash due to bad oops being spilled to stack in load barriers
eosterlund
parents:
55379
diff
changeset
|
59 |
|
55379 | 60 |
ins_encode %{ |
58516
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
61 |
const Address ref_addr = mem2address($mem->opcode(), as_Register($mem$$base), $mem$$index, $mem$$scale, $mem$$disp); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
62 |
__ ldr($dst$$Register, ref_addr); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
63 |
if (barrier_data() != ZLoadBarrierElided) { |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
64 |
z_load_barrier(_masm, this, ref_addr, $dst$$Register, rscratch2 /* tmp */, false /* weak */); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
65 |
} |
55379 | 66 |
%} |
58516
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
67 |
|
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
68 |
ins_pipe(iload_reg_mem); |
55379 | 69 |
%} |
70 |
||
58516
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
71 |
// Load Weak Pointer |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
72 |
instruct zLoadWeakP(iRegPNoSp dst, memory mem, rFlagsReg cr) |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
73 |
%{ |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
74 |
match(Set dst (LoadP mem)); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
75 |
predicate(UseZGC && !needs_acquiring_load(n) && (n->as_Load()->barrier_data() == ZLoadBarrierWeak)); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
76 |
effect(TEMP dst, KILL cr); |
55379 | 77 |
|
58516
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
78 |
ins_cost(4 * INSN_COST); |
55379 | 79 |
|
58516
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
80 |
format %{ "ldr $dst, $mem" %} |
55563
d56b192c73e9
8225642: ZGC: Crash due to bad oops being spilled to stack in load barriers
eosterlund
parents:
55379
diff
changeset
|
81 |
|
55379 | 82 |
ins_encode %{ |
58516
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
83 |
const Address ref_addr = mem2address($mem->opcode(), as_Register($mem$$base), $mem$$index, $mem$$scale, $mem$$disp); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
84 |
__ ldr($dst$$Register, ref_addr); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
85 |
z_load_barrier(_masm, this, ref_addr, $dst$$Register, rscratch2 /* tmp */, true /* weak */); |
55379 | 86 |
%} |
58516
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
87 |
|
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
88 |
ins_pipe(iload_reg_mem); |
55379 | 89 |
%} |
90 |
||
58516
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
91 |
// Load Pointer Volatile |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
92 |
instruct zLoadPVolatile(iRegPNoSp dst, indirect mem /* sync_memory */, rFlagsReg cr) |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
93 |
%{ |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
94 |
match(Set dst (LoadP mem)); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
95 |
predicate(UseZGC && needs_acquiring_load(n) && n->as_Load()->barrier_data() == ZLoadBarrierStrong); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
96 |
effect(TEMP dst, KILL cr); |
55379 | 97 |
|
58516
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
98 |
ins_cost(VOLATILE_REF_COST); |
55379 | 99 |
|
58516
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
100 |
format %{ "ldar $dst, $mem\t" %} |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
101 |
|
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
102 |
ins_encode %{ |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
103 |
__ ldar($dst$$Register, $mem$$Register); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
104 |
if (barrier_data() != ZLoadBarrierElided) { |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
105 |
z_load_barrier(_masm, this, Address($mem$$Register), $dst$$Register, rscratch2 /* tmp */, false /* weak */); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
106 |
} |
55379 | 107 |
%} |
58516
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
108 |
|
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
109 |
ins_pipe(pipe_serial); |
55379 | 110 |
%} |
111 |
||
58516
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
112 |
instruct zCompareAndSwapP(iRegINoSp res, indirect mem, iRegP oldval, iRegP newval, rFlagsReg cr) %{ |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
113 |
match(Set res (CompareAndSwapP mem (Binary oldval newval))); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
114 |
match(Set res (WeakCompareAndSwapP mem (Binary oldval newval))); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
115 |
predicate(UseZGC && !needs_acquiring_load_exclusive(n) && n->as_LoadStore()->barrier_data() == ZLoadBarrierStrong); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
116 |
effect(KILL cr, TEMP_DEF res); |
55379 | 117 |
|
118 |
ins_cost(2 * VOLATILE_REF_COST); |
|
119 |
||
58516
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
120 |
format %{ "cmpxchg $mem, $oldval, $newval\n\t" |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
121 |
"cset $res, EQ" %} |
55379 | 122 |
|
58516
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
123 |
ins_encode %{ |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
124 |
guarantee($mem$$index == -1 && $mem$$disp == 0, "impossible encoding"); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
125 |
__ cmpxchg($mem$$Register, $oldval$$Register, $newval$$Register, Assembler::xword, |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
126 |
false /* acquire */, true /* release */, false /* weak */, rscratch2); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
127 |
__ cset($res$$Register, Assembler::EQ); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
128 |
if (barrier_data() != ZLoadBarrierElided) { |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
129 |
Label good; |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
130 |
__ ldr(rscratch1, Address(rthread, ZThreadLocalData::address_bad_mask_offset())); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
131 |
__ andr(rscratch1, rscratch1, rscratch2); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
132 |
__ cbz(rscratch1, good); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
133 |
z_load_barrier_slow_path(_masm, this, Address($mem$$Register), rscratch2 /* ref */, rscratch1 /* tmp */); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
134 |
__ cmpxchg($mem$$Register, $oldval$$Register, $newval$$Register, Assembler::xword, |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
135 |
false /* acquire */, true /* release */, false /* weak */, rscratch2); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
136 |
__ cset($res$$Register, Assembler::EQ); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
137 |
__ bind(good); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
138 |
} |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
139 |
%} |
55379 | 140 |
|
141 |
ins_pipe(pipe_slow); |
|
142 |
%} |
|
143 |
||
58516
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
144 |
instruct zCompareAndSwapPAcq(iRegINoSp res, indirect mem, iRegP oldval, iRegP newval, rFlagsReg cr) %{ |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
145 |
match(Set res (CompareAndSwapP mem (Binary oldval newval))); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
146 |
match(Set res (WeakCompareAndSwapP mem (Binary oldval newval))); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
147 |
predicate(UseZGC && needs_acquiring_load_exclusive(n) && (n->as_LoadStore()->barrier_data() == ZLoadBarrierStrong)); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
148 |
effect(KILL cr, TEMP_DEF res); |
55379 | 149 |
|
58516
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
150 |
ins_cost(2 * VOLATILE_REF_COST); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
151 |
|
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
152 |
format %{ "cmpxchg $mem, $oldval, $newval\n\t" |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
153 |
"cset $res, EQ" %} |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
154 |
|
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
155 |
ins_encode %{ |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
156 |
guarantee($mem$$index == -1 && $mem$$disp == 0, "impossible encoding"); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
157 |
__ cmpxchg($mem$$Register, $oldval$$Register, $newval$$Register, Assembler::xword, |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
158 |
true /* acquire */, true /* release */, false /* weak */, rscratch2); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
159 |
__ cset($res$$Register, Assembler::EQ); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
160 |
if (barrier_data() != ZLoadBarrierElided) { |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
161 |
Label good; |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
162 |
__ ldr(rscratch1, Address(rthread, ZThreadLocalData::address_bad_mask_offset())); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
163 |
__ andr(rscratch1, rscratch1, rscratch2); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
164 |
__ cbz(rscratch1, good); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
165 |
z_load_barrier_slow_path(_masm, this, Address($mem$$Register), rscratch2 /* ref */, rscratch1 /* tmp */ ); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
166 |
__ cmpxchg($mem$$Register, $oldval$$Register, $newval$$Register, Assembler::xword, |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
167 |
true /* acquire */, true /* release */, false /* weak */, rscratch2); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
168 |
__ cset($res$$Register, Assembler::EQ); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
169 |
__ bind(good); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
170 |
} |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
171 |
%} |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
172 |
|
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
173 |
ins_pipe(pipe_slow); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
174 |
%} |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
175 |
|
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
176 |
instruct zCompareAndExchangeP(iRegPNoSp res, indirect mem, iRegP oldval, iRegP newval, rFlagsReg cr) %{ |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
177 |
match(Set res (CompareAndExchangeP mem (Binary oldval newval))); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
178 |
predicate(UseZGC && !needs_acquiring_load_exclusive(n) && n->as_LoadStore()->barrier_data() == ZLoadBarrierStrong); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
179 |
effect(TEMP_DEF res, KILL cr); |
55379 | 180 |
|
181 |
ins_cost(2 * VOLATILE_REF_COST); |
|
58516
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
182 |
|
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
183 |
format %{ "cmpxchg $res = $mem, $oldval, $newval" %} |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
184 |
|
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
185 |
ins_encode %{ |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
186 |
guarantee($mem$$index == -1 && $mem$$disp == 0, "impossible encoding"); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
187 |
__ cmpxchg($mem$$Register, $oldval$$Register, $newval$$Register, Assembler::xword, |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
188 |
false /* acquire */, true /* release */, false /* weak */, $res$$Register); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
189 |
if (barrier_data() != ZLoadBarrierElided) { |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
190 |
Label good; |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
191 |
__ ldr(rscratch1, Address(rthread, ZThreadLocalData::address_bad_mask_offset())); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
192 |
__ andr(rscratch1, rscratch1, $res$$Register); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
193 |
__ cbz(rscratch1, good); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
194 |
z_load_barrier_slow_path(_masm, this, Address($mem$$Register), $res$$Register /* ref */, rscratch1 /* tmp */); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
195 |
__ cmpxchg($mem$$Register, $oldval$$Register, $newval$$Register, Assembler::xword, |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
196 |
false /* acquire */, true /* release */, false /* weak */, $res$$Register); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
197 |
__ bind(good); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
198 |
} |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
199 |
%} |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
200 |
|
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
201 |
ins_pipe(pipe_slow); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
202 |
%} |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
203 |
|
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
204 |
instruct zCompareAndExchangePAcq(iRegPNoSp res, indirect mem, iRegP oldval, iRegP newval, rFlagsReg cr) %{ |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
205 |
match(Set res (CompareAndExchangeP mem (Binary oldval newval))); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
206 |
predicate(UseZGC && needs_acquiring_load_exclusive(n) && n->as_LoadStore()->barrier_data() == ZLoadBarrierStrong); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
207 |
effect(TEMP_DEF res, KILL cr); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
208 |
|
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
209 |
ins_cost(2 * VOLATILE_REF_COST); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
210 |
|
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
211 |
format %{ "cmpxchg $res = $mem, $oldval, $newval" %} |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
212 |
|
55379 | 213 |
ins_encode %{ |
58516
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
214 |
guarantee($mem$$index == -1 && $mem$$disp == 0, "impossible encoding"); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
215 |
__ cmpxchg($mem$$Register, $oldval$$Register, $newval$$Register, Assembler::xword, |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
216 |
true /* acquire */, true /* release */, false /* weak */, $res$$Register); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
217 |
if (barrier_data() != ZLoadBarrierElided) { |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
218 |
Label good; |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
219 |
__ ldr(rscratch1, Address(rthread, ZThreadLocalData::address_bad_mask_offset())); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
220 |
__ andr(rscratch1, rscratch1, $res$$Register); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
221 |
__ cbz(rscratch1, good); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
222 |
z_load_barrier_slow_path(_masm, this, Address($mem$$Register), $res$$Register /* ref */, rscratch1 /* tmp */); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
223 |
__ cmpxchg($mem$$Register, $oldval$$Register, $newval$$Register, Assembler::xword, |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
224 |
true /* acquire */, true /* release */, false /* weak */, $res$$Register); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
225 |
__ bind(good); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
226 |
} |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
227 |
%} |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
228 |
|
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
229 |
ins_pipe(pipe_slow); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
230 |
%} |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
231 |
|
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
232 |
instruct zGetAndSetP(indirect mem, iRegP newv, iRegPNoSp prev, rFlagsReg cr) %{ |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
233 |
match(Set prev (GetAndSetP mem newv)); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
234 |
predicate(UseZGC && !needs_acquiring_load_exclusive(n) && n->as_LoadStore()->barrier_data() == ZLoadBarrierStrong); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
235 |
effect(TEMP_DEF prev, KILL cr); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
236 |
|
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
237 |
ins_cost(2 * VOLATILE_REF_COST); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
238 |
|
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
239 |
format %{ "atomic_xchg $prev, $newv, [$mem]" %} |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
240 |
|
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
241 |
ins_encode %{ |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
242 |
__ atomic_xchg($prev$$Register, $newv$$Register, $mem$$Register); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
243 |
if (barrier_data() != ZLoadBarrierElided) { |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
244 |
z_load_barrier(_masm, this, Address(noreg, 0), $prev$$Register, rscratch2 /* tmp */, false /* weak */); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
245 |
} |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
246 |
%} |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
247 |
|
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
248 |
ins_pipe(pipe_serial); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
249 |
%} |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
250 |
|
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
251 |
instruct zGetAndSetPAcq(indirect mem, iRegP newv, iRegPNoSp prev, rFlagsReg cr) %{ |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
252 |
match(Set prev (GetAndSetP mem newv)); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
253 |
predicate(UseZGC && needs_acquiring_load_exclusive(n) && (n->as_LoadStore()->barrier_data() == ZLoadBarrierStrong)); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
254 |
effect(TEMP_DEF prev, KILL cr); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
255 |
|
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
256 |
ins_cost(VOLATILE_REF_COST); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
257 |
|
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
258 |
format %{ "atomic_xchg_acq $prev, $newv, [$mem]" %} |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
259 |
|
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
260 |
ins_encode %{ |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
261 |
__ atomic_xchgal($prev$$Register, $newv$$Register, $mem$$Register); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
262 |
if (barrier_data() != ZLoadBarrierElided) { |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
263 |
z_load_barrier(_masm, this, Address(noreg, 0), $prev$$Register, rscratch2 /* tmp */, false /* weak */); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
55563
diff
changeset
|
264 |
} |
55379 | 265 |
%} |
266 |
ins_pipe(pipe_serial); |
|
267 |
%} |