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 "precompiled.hpp"
26 #include "classfile/classLoaderData.hpp"
27 #include "gc/shared/barrierSet.hpp"
28 #include "gc/shared/barrierSetAssembler.hpp"
29 #include "gc/shared/barrierSetNMethod.hpp"
30 #include "gc/shared/collectedHeap.hpp"
31 #include "interpreter/interp_masm.hpp"
32 #include "memory/universe.hpp"
33 #include "runtime/javaThread.hpp"
34 #include "runtime/jniHandles.hpp"
35 #include "runtime/sharedRuntime.hpp"
36 #include "runtime/stubRoutines.hpp"
37 #ifdef COMPILER2
38 #include "code/vmreg.inline.hpp"
39 #include "gc/shared/c2/barrierSetC2.hpp"
40 #endif // COMPILER2
41
42
43 #define __ masm->
44
45 void BarrierSetAssembler::load_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type,
46 Register dst, Address src, Register tmp1, Register tmp2) {
47
48 // LR is live. It must be saved around calls.
49
50 bool in_heap = (decorators & IN_HEAP) != 0;
51 bool in_native = (decorators & IN_NATIVE) != 0;
52 bool is_not_null = (decorators & IS_NOT_NULL) != 0;
53 switch (type) {
54 case T_OBJECT:
55 case T_ARRAY: {
56 if (in_heap) {
57 if (UseCompressedOops) {
58 __ ldrw(dst, src);
59 if (is_not_null) {
60 __ decode_heap_oop_not_null(dst);
61 } else {
62 __ decode_heap_oop(dst);
63 }
64 } else {
65 __ ldr(dst, src);
66 }
67 } else {
68 assert(in_native, "why else?");
69 __ ldr(dst, src);
70 }
71 break;
72 }
73 case T_BOOLEAN: __ load_unsigned_byte (dst, src); break;
74 case T_BYTE: __ load_signed_byte (dst, src); break;
75 case T_CHAR: __ load_unsigned_short(dst, src); break;
76 case T_SHORT: __ load_signed_short (dst, src); break;
77 case T_INT: __ ldrw (dst, src); break;
78 case T_LONG: __ ldr (dst, src); break;
79 case T_ADDRESS: __ ldr (dst, src); break;
80 case T_FLOAT: __ ldrs (v0, src); break;
81 case T_DOUBLE: __ ldrd (v0, src); break;
82 default: Unimplemented();
83 }
84 }
85
86 void BarrierSetAssembler::store_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type,
87 Address dst, Register val, Register tmp1, Register tmp2, Register tmp3) {
88 bool in_heap = (decorators & IN_HEAP) != 0;
89 bool in_native = (decorators & IN_NATIVE) != 0;
90 switch (type) {
91 case T_OBJECT:
92 case T_ARRAY: {
93 val = val == noreg ? zr : val;
94 if (in_heap) {
95 if (UseCompressedOops) {
96 assert(!dst.uses(val), "not enough registers");
97 if (val != zr) {
98 __ encode_heap_oop(val);
99 }
100 __ strw(val, dst);
101 } else {
102 __ str(val, dst);
103 }
104 } else {
105 assert(in_native, "why else?");
106 __ str(val, dst);
107 }
108 break;
109 }
110 case T_BOOLEAN:
111 __ andw(val, val, 0x1); // boolean is true if LSB is 1
112 __ strb(val, dst);
113 break;
114 case T_BYTE: __ strb(val, dst); break;
115 case T_CHAR: __ strh(val, dst); break;
116 case T_SHORT: __ strh(val, dst); break;
117 case T_INT: __ strw(val, dst); break;
118 case T_LONG: __ str (val, dst); break;
119 case T_ADDRESS: __ str (val, dst); break;
120 case T_FLOAT: __ strs(v0, dst); break;
121 case T_DOUBLE: __ strd(v0, dst); break;
122 default: Unimplemented();
123 }
124 }
125
126 void BarrierSetAssembler::copy_load_at(MacroAssembler* masm,
127 DecoratorSet decorators,
128 BasicType type,
129 size_t bytes,
130 Register dst1,
131 Register dst2,
132 Address src,
133 Register tmp) {
134 if (bytes == 1) {
135 assert(dst2 == noreg, "invariant");
136 __ ldrb(dst1, src);
137 } else if (bytes == 2) {
138 assert(dst2 == noreg, "invariant");
139 __ ldrh(dst1, src);
140 } else if (bytes == 4) {
141 assert(dst2 == noreg, "invariant");
142 __ ldrw(dst1, src);
143 } else if (bytes == 8) {
144 assert(dst2 == noreg, "invariant");
145 __ ldr(dst1, src);
|
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 "precompiled.hpp"
26 #include "classfile/classLoaderData.hpp"
27 #include "gc/shared/barrierSet.hpp"
28 #include "gc/shared/barrierSetAssembler.hpp"
29 #include "gc/shared/barrierSetNMethod.hpp"
30 #include "gc/shared/barrierSetRuntime.hpp"
31 #include "gc/shared/collectedHeap.hpp"
32 #include "interpreter/interp_masm.hpp"
33 #include "memory/universe.hpp"
34 #include "runtime/javaThread.hpp"
35 #include "runtime/jniHandles.hpp"
36 #include "runtime/sharedRuntime.hpp"
37 #include "runtime/stubRoutines.hpp"
38 #ifdef COMPILER2
39 #include "code/vmreg.inline.hpp"
40 #include "gc/shared/c2/barrierSetC2.hpp"
41 #endif // COMPILER2
42
43
44 #define __ masm->
45
46 void BarrierSetAssembler::load_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type,
47 Register dst, Address src, Register tmp1, Register tmp2) {
48
49 // LR is live. It must be saved around calls.
50
51 bool in_heap = (decorators & IN_HEAP) != 0;
52 bool in_native = (decorators & IN_NATIVE) != 0;
53 bool is_not_null = (decorators & IS_NOT_NULL) != 0;
54
55 switch (type) {
56 case T_OBJECT:
57 case T_ARRAY: {
58 if (in_heap) {
59 if (UseCompressedOops) {
60 __ ldrw(dst, src);
61 if (is_not_null) {
62 __ decode_heap_oop_not_null(dst);
63 } else {
64 __ decode_heap_oop(dst);
65 }
66 } else {
67 __ ldr(dst, src);
68 }
69 } else {
70 assert(in_native, "why else?");
71 __ ldr(dst, src);
72 }
73 break;
74 }
75 case T_BOOLEAN: __ load_unsigned_byte (dst, src); break;
76 case T_BYTE: __ load_signed_byte (dst, src); break;
77 case T_CHAR: __ load_unsigned_short(dst, src); break;
78 case T_SHORT: __ load_signed_short (dst, src); break;
79 case T_INT: __ ldrw (dst, src); break;
80 case T_LONG: __ ldr (dst, src); break;
81 case T_ADDRESS: __ ldr (dst, src); break;
82 case T_FLOAT: __ ldrs (v0, src); break;
83 case T_DOUBLE: __ ldrd (v0, src); break;
84 default: Unimplemented();
85 }
86 }
87
88 void BarrierSetAssembler::store_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type,
89 Address dst, Register val, Register tmp1, Register tmp2, Register tmp3) {
90 bool in_heap = (decorators & IN_HEAP) != 0;
91 bool in_native = (decorators & IN_NATIVE) != 0;
92 bool is_not_null = (decorators & IS_NOT_NULL) != 0;
93
94 switch (type) {
95 case T_OBJECT:
96 case T_ARRAY: {
97 if (in_heap) {
98 if (val == noreg) {
99 assert(!is_not_null, "inconsistent access");
100 if (UseCompressedOops) {
101 __ strw(zr, dst);
102 } else {
103 __ str(zr, dst);
104 }
105 } else {
106 if (UseCompressedOops) {
107 assert(!dst.uses(val), "not enough registers");
108 if (is_not_null) {
109 __ encode_heap_oop_not_null(val);
110 } else {
111 __ encode_heap_oop(val);
112 }
113 __ strw(val, dst);
114 } else {
115 __ str(val, dst);
116 }
117 }
118 } else {
119 assert(in_native, "why else?");
120 assert(val != noreg, "not supported");
121 __ str(val, dst);
122 }
123 break;
124 }
125 case T_BOOLEAN:
126 __ andw(val, val, 0x1); // boolean is true if LSB is 1
127 __ strb(val, dst);
128 break;
129 case T_BYTE: __ strb(val, dst); break;
130 case T_CHAR: __ strh(val, dst); break;
131 case T_SHORT: __ strh(val, dst); break;
132 case T_INT: __ strw(val, dst); break;
133 case T_LONG: __ str (val, dst); break;
134 case T_ADDRESS: __ str (val, dst); break;
135 case T_FLOAT: __ strs(v0, dst); break;
136 case T_DOUBLE: __ strd(v0, dst); break;
137 default: Unimplemented();
138 }
139 }
140
141 void BarrierSetAssembler::value_copy(MacroAssembler* masm, DecoratorSet decorators,
142 Register src, Register dst, Register value_klass) {
143 // value_copy implementation is fairly complex, and there are not any
144 // "short-cuts" to be made from asm. What there is, appears to have the same
145 // cost in C++, so just "call_VM_leaf" for now rather than maintain hundreds
146 // of hand-rolled instructions...
147 if (decorators & IS_DEST_UNINITIALIZED) {
148 __ call_VM_leaf(CAST_FROM_FN_PTR(address, BarrierSetRuntime::value_copy_is_dest_uninitialized), src, dst, value_klass);
149 } else {
150 __ call_VM_leaf(CAST_FROM_FN_PTR(address, BarrierSetRuntime::value_copy), src, dst, value_klass);
151 }
152 }
153
154 void BarrierSetAssembler::flat_field_copy(MacroAssembler* masm, DecoratorSet decorators,
155 Register src, Register dst, Register inline_layout_info) {
156 // flat_field_copy implementation is fairly complex, and there are not any
157 // "short-cuts" to be made from asm. What there is, appears to have the same
158 // cost in C++, so just "call_VM_leaf" for now rather than maintain hundreds
159 // of hand-rolled instructions...
160 if (decorators & IS_DEST_UNINITIALIZED) {
161 __ call_VM_leaf(CAST_FROM_FN_PTR(address, BarrierSetRuntime::value_copy_is_dest_uninitialized2), src, dst, inline_layout_info);
162 } else {
163 __ call_VM_leaf(CAST_FROM_FN_PTR(address, BarrierSetRuntime::value_copy2), src, dst, inline_layout_info);
164 }
165 }
166
167 void BarrierSetAssembler::copy_load_at(MacroAssembler* masm,
168 DecoratorSet decorators,
169 BasicType type,
170 size_t bytes,
171 Register dst1,
172 Register dst2,
173 Address src,
174 Register tmp) {
175 if (bytes == 1) {
176 assert(dst2 == noreg, "invariant");
177 __ ldrb(dst1, src);
178 } else if (bytes == 2) {
179 assert(dst2 == noreg, "invariant");
180 __ ldrh(dst1, src);
181 } else if (bytes == 4) {
182 assert(dst2 == noreg, "invariant");
183 __ ldrw(dst1, src);
184 } else if (bytes == 8) {
185 assert(dst2 == noreg, "invariant");
186 __ ldr(dst1, src);
|