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
38
39 #define __ masm->
40
41 void BarrierSetAssembler::load_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type,
42 Register dst, Address src, Register tmp1, Register tmp2) {
43
44 // LR is live. It must be saved around calls.
45
46 bool in_heap = (decorators & IN_HEAP) != 0;
47 bool in_native = (decorators & IN_NATIVE) != 0;
48 bool is_not_null = (decorators & IS_NOT_NULL) != 0;
49 switch (type) {
50 case T_OBJECT:
51 case T_ARRAY: {
52 if (in_heap) {
53 if (UseCompressedOops) {
54 __ ldrw(dst, src);
55 if (is_not_null) {
56 __ decode_heap_oop_not_null(dst);
57 } else {
58 __ decode_heap_oop(dst);
59 }
60 } else {
61 __ ldr(dst, src);
62 }
63 } else {
64 assert(in_native, "why else?");
65 __ ldr(dst, src);
66 }
67 break;
68 }
69 case T_BOOLEAN: __ load_unsigned_byte (dst, src); break;
70 case T_BYTE: __ load_signed_byte (dst, src); break;
71 case T_CHAR: __ load_unsigned_short(dst, src); break;
72 case T_SHORT: __ load_signed_short (dst, src); break;
73 case T_INT: __ ldrw (dst, src); break;
74 case T_LONG: __ ldr (dst, src); break;
75 case T_ADDRESS: __ ldr (dst, src); break;
76 case T_FLOAT: __ ldrs (v0, src); break;
77 case T_DOUBLE: __ ldrd (v0, src); break;
78 default: Unimplemented();
79 }
80 }
81
82 void BarrierSetAssembler::store_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type,
83 Address dst, Register val, Register tmp1, Register tmp2, Register tmp3) {
84 bool in_heap = (decorators & IN_HEAP) != 0;
85 bool in_native = (decorators & IN_NATIVE) != 0;
86 switch (type) {
87 case T_OBJECT:
88 case T_ARRAY: {
89 val = val == noreg ? zr : val;
90 if (in_heap) {
91 if (UseCompressedOops) {
92 assert(!dst.uses(val), "not enough registers");
93 if (val != zr) {
94 __ encode_heap_oop(val);
95 }
96 __ strw(val, dst);
97 } else {
98 __ str(val, dst);
99 }
100 } else {
101 assert(in_native, "why else?");
102 __ str(val, dst);
103 }
104 break;
105 }
106 case T_BOOLEAN:
107 __ andw(val, val, 0x1); // boolean is true if LSB is 1
108 __ strb(val, dst);
109 break;
110 case T_BYTE: __ strb(val, dst); break;
111 case T_CHAR: __ strh(val, dst); break;
112 case T_SHORT: __ strh(val, dst); break;
113 case T_INT: __ strw(val, dst); break;
114 case T_LONG: __ str (val, dst); break;
115 case T_ADDRESS: __ str (val, dst); break;
116 case T_FLOAT: __ strs(v0, dst); break;
117 case T_DOUBLE: __ strd(v0, dst); break;
118 default: Unimplemented();
119 }
120 }
121
122 void BarrierSetAssembler::try_resolve_jobject_in_native(MacroAssembler* masm, Register jni_env,
123 Register obj, Register tmp, Label& slowpath) {
124 // If mask changes we need to ensure that the inverse is still encodable as an immediate
125 STATIC_ASSERT(JNIHandles::weak_tag_mask == 1);
126 __ andr(obj, obj, ~JNIHandles::weak_tag_mask);
127 __ ldr(obj, Address(obj, 0)); // *obj
128 }
129
130 // Defines obj, preserves var_size_in_bytes, okay for t2 == var_size_in_bytes.
131 void BarrierSetAssembler::tlab_allocate(MacroAssembler* masm, Register obj,
132 Register var_size_in_bytes,
133 int con_size_in_bytes,
134 Register t1,
135 Register t2,
136 Label& slow_case) {
137 assert_different_registers(obj, t2);
138 assert_different_registers(obj, var_size_in_bytes);
139 Register end = t2;
140
141 // verify_tlab();
281 __ load_method_holder_cld(rscratch1, rmethod);
282
283 // Is it a strong CLD?
284 __ ldrw(rscratch2, Address(rscratch1, ClassLoaderData::keep_alive_offset()));
285 __ cbnz(rscratch2, method_live);
286
287 // Is it a weak but alive CLD?
288 __ push(RegSet::of(r10), sp);
289 __ ldr(r10, Address(rscratch1, ClassLoaderData::holder_offset()));
290
291 __ resolve_weak_handle(r10, rscratch1, rscratch2);
292 __ mov(rscratch1, r10);
293 __ pop(RegSet::of(r10), sp);
294 __ cbnz(rscratch1, method_live);
295
296 __ bind(bad_call);
297
298 __ far_jump(RuntimeAddress(SharedRuntime::get_handle_wrong_method_stub()));
299 __ bind(method_live);
300 }
301
|
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
39
40 #define __ masm->
41
42 void BarrierSetAssembler::load_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type,
43 Register dst, Address src, Register tmp1, Register tmp2) {
44
45 // LR is live. It must be saved around calls.
46
47 bool in_heap = (decorators & IN_HEAP) != 0;
48 bool in_native = (decorators & IN_NATIVE) != 0;
49 bool is_not_null = (decorators & IS_NOT_NULL) != 0;
50
51 assert(type != T_PRIMITIVE_OBJECT, "Not supported yet");
52 switch (type) {
53 case T_OBJECT:
54 case T_ARRAY: {
55 if (in_heap) {
56 if (UseCompressedOops) {
57 __ ldrw(dst, src);
58 if (is_not_null) {
59 __ decode_heap_oop_not_null(dst);
60 } else {
61 __ decode_heap_oop(dst);
62 }
63 } else {
64 __ ldr(dst, src);
65 }
66 } else {
67 assert(in_native, "why else?");
68 __ ldr(dst, src);
69 }
70 break;
71 }
72 case T_BOOLEAN: __ load_unsigned_byte (dst, src); break;
73 case T_BYTE: __ load_signed_byte (dst, src); break;
74 case T_CHAR: __ load_unsigned_short(dst, src); break;
75 case T_SHORT: __ load_signed_short (dst, src); break;
76 case T_INT: __ ldrw (dst, src); break;
77 case T_LONG: __ ldr (dst, src); break;
78 case T_ADDRESS: __ ldr (dst, src); break;
79 case T_FLOAT: __ ldrs (v0, src); break;
80 case T_DOUBLE: __ ldrd (v0, src); break;
81 default: Unimplemented();
82 }
83 }
84
85 void BarrierSetAssembler::store_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type,
86 Address dst, Register val, Register tmp1, Register tmp2, Register tmp3) {
87 bool in_heap = (decorators & IN_HEAP) != 0;
88 bool in_native = (decorators & IN_NATIVE) != 0;
89 bool is_not_null = (decorators & IS_NOT_NULL) != 0;
90
91 assert(type != T_PRIMITIVE_OBJECT, "Not supported yet");
92 switch (type) {
93 case T_OBJECT:
94 case T_ARRAY: {
95 if (in_heap) {
96 if (val == noreg) {
97 assert(!is_not_null, "inconsistent access");
98 if (UseCompressedOops) {
99 __ strw(zr, dst);
100 } else {
101 __ str(zr, dst);
102 }
103 } else {
104 if (UseCompressedOops) {
105 assert(!dst.uses(val), "not enough registers");
106 if (is_not_null) {
107 __ encode_heap_oop_not_null(val);
108 } else {
109 __ encode_heap_oop(val);
110 }
111 __ strw(val, dst);
112 } else {
113 __ str(val, dst);
114 }
115 }
116 } else {
117 assert(in_native, "why else?");
118 assert(val != noreg, "not supported");
119 __ str(val, dst);
120 }
121 break;
122 }
123 case T_BOOLEAN:
124 __ andw(val, val, 0x1); // boolean is true if LSB is 1
125 __ strb(val, dst);
126 break;
127 case T_BYTE: __ strb(val, dst); break;
128 case T_CHAR: __ strh(val, dst); break;
129 case T_SHORT: __ strh(val, dst); break;
130 case T_INT: __ strw(val, dst); break;
131 case T_LONG: __ str (val, dst); break;
132 case T_ADDRESS: __ str (val, dst); break;
133 case T_FLOAT: __ strs(v0, dst); break;
134 case T_DOUBLE: __ strd(v0, dst); break;
135 default: Unimplemented();
136 }
137 }
138
139 void BarrierSetAssembler::value_copy(MacroAssembler* masm, DecoratorSet decorators,
140 Register src, Register dst, Register value_klass) {
141 // value_copy implementation is fairly complex, and there are not any
142 // "short-cuts" to be made from asm. What there is, appears to have the same
143 // cost in C++, so just "call_VM_leaf" for now rather than maintain hundreds
144 // of hand-rolled instructions...
145 if (decorators & IS_DEST_UNINITIALIZED) {
146 __ call_VM_leaf(CAST_FROM_FN_PTR(address, BarrierSetRuntime::value_copy_is_dest_uninitialized), src, dst, value_klass);
147 } else {
148 __ call_VM_leaf(CAST_FROM_FN_PTR(address, BarrierSetRuntime::value_copy), src, dst, value_klass);
149 }
150 }
151
152 void BarrierSetAssembler::try_resolve_jobject_in_native(MacroAssembler* masm, Register jni_env,
153 Register obj, Register tmp, Label& slowpath) {
154 // If mask changes we need to ensure that the inverse is still encodable as an immediate
155 STATIC_ASSERT(JNIHandles::weak_tag_mask == 1);
156 __ andr(obj, obj, ~JNIHandles::weak_tag_mask);
157 __ ldr(obj, Address(obj, 0)); // *obj
158 }
159
160 // Defines obj, preserves var_size_in_bytes, okay for t2 == var_size_in_bytes.
161 void BarrierSetAssembler::tlab_allocate(MacroAssembler* masm, Register obj,
162 Register var_size_in_bytes,
163 int con_size_in_bytes,
164 Register t1,
165 Register t2,
166 Label& slow_case) {
167 assert_different_registers(obj, t2);
168 assert_different_registers(obj, var_size_in_bytes);
169 Register end = t2;
170
171 // verify_tlab();
311 __ load_method_holder_cld(rscratch1, rmethod);
312
313 // Is it a strong CLD?
314 __ ldrw(rscratch2, Address(rscratch1, ClassLoaderData::keep_alive_offset()));
315 __ cbnz(rscratch2, method_live);
316
317 // Is it a weak but alive CLD?
318 __ push(RegSet::of(r10), sp);
319 __ ldr(r10, Address(rscratch1, ClassLoaderData::holder_offset()));
320
321 __ resolve_weak_handle(r10, rscratch1, rscratch2);
322 __ mov(rscratch1, r10);
323 __ pop(RegSet::of(r10), sp);
324 __ cbnz(rscratch1, method_live);
325
326 __ bind(bad_call);
327
328 __ far_jump(RuntimeAddress(SharedRuntime::get_handle_wrong_method_stub()));
329 __ bind(method_live);
330 }
|