|
1 /* |
|
2 * Copyright (c) 2018, 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 |
|
25 #include "precompiled.hpp" |
|
26 #include "asm/macroAssembler.inline.hpp" |
|
27 #include "gc/g1/g1BarrierSet.hpp" |
|
28 #include "gc/g1/g1BarrierSetAssembler.hpp" |
|
29 #include "gc/g1/g1CardTable.hpp" |
|
30 #include "gc/g1/heapRegion.hpp" |
|
31 #include "gc/shared/collectedHeap.hpp" |
|
32 #include "interpreter/interp_masm.hpp" |
|
33 #include "runtime/sharedRuntime.hpp" |
|
34 #include "runtime/thread.hpp" |
|
35 #include "utilities/macros.hpp" |
|
36 |
|
37 #define __ masm-> |
|
38 |
|
39 void G1BarrierSetAssembler::gen_write_ref_array_pre_barrier(MacroAssembler* masm, DecoratorSet decorators, |
|
40 Register addr, Register count) { |
|
41 bool dest_uninitialized = (decorators & AS_DEST_NOT_INITIALIZED) != 0; |
|
42 |
|
43 if (!dest_uninitialized) { |
|
44 Register thread = NOT_LP64(rax) LP64_ONLY(r15_thread); |
|
45 #ifndef _LP64 |
|
46 __ push(thread); |
|
47 __ get_thread(thread); |
|
48 #endif |
|
49 |
|
50 Label filtered; |
|
51 Address in_progress(thread, in_bytes(JavaThread::satb_mark_queue_offset() + |
|
52 SATBMarkQueue::byte_offset_of_active())); |
|
53 // Is marking active? |
|
54 if (in_bytes(SATBMarkQueue::byte_width_of_active()) == 4) { |
|
55 __ cmpl(in_progress, 0); |
|
56 } else { |
|
57 assert(in_bytes(SATBMarkQueue::byte_width_of_active()) == 1, "Assumption"); |
|
58 __ cmpb(in_progress, 0); |
|
59 } |
|
60 |
|
61 NOT_LP64(__ pop(thread);) |
|
62 |
|
63 __ jcc(Assembler::equal, filtered); |
|
64 |
|
65 __ pusha(); // push registers |
|
66 #ifdef _LP64 |
|
67 if (count == c_rarg0) { |
|
68 if (addr == c_rarg1) { |
|
69 // exactly backwards!! |
|
70 __ xchgptr(c_rarg1, c_rarg0); |
|
71 } else { |
|
72 __ movptr(c_rarg1, count); |
|
73 __ movptr(c_rarg0, addr); |
|
74 } |
|
75 } else { |
|
76 __ movptr(c_rarg0, addr); |
|
77 __ movptr(c_rarg1, count); |
|
78 } |
|
79 if (UseCompressedOops) { |
|
80 __ call_VM_leaf(CAST_FROM_FN_PTR(address, G1BarrierSet::write_ref_array_pre_narrow_oop_entry), 2); |
|
81 } else { |
|
82 __ call_VM_leaf(CAST_FROM_FN_PTR(address, G1BarrierSet::write_ref_array_pre_oop_entry), 2); |
|
83 } |
|
84 #else |
|
85 __ call_VM_leaf(CAST_FROM_FN_PTR(address, G1BarrierSet::write_ref_array_pre_oop_entry), |
|
86 addr, count); |
|
87 #endif |
|
88 __ popa(); |
|
89 |
|
90 __ bind(filtered); |
|
91 } |
|
92 } |
|
93 |
|
94 void G1BarrierSetAssembler::gen_write_ref_array_post_barrier(MacroAssembler* masm, DecoratorSet decorators, |
|
95 Register addr, Register count, Register tmp) { |
|
96 __ pusha(); // push registers (overkill) |
|
97 #ifdef _LP64 |
|
98 if (c_rarg0 == count) { // On win64 c_rarg0 == rcx |
|
99 assert_different_registers(c_rarg1, addr); |
|
100 __ mov(c_rarg1, count); |
|
101 __ mov(c_rarg0, addr); |
|
102 } else { |
|
103 assert_different_registers(c_rarg0, count); |
|
104 __ mov(c_rarg0, addr); |
|
105 __ mov(c_rarg1, count); |
|
106 } |
|
107 __ call_VM_leaf(CAST_FROM_FN_PTR(address, G1BarrierSet::write_ref_array_post_entry), 2); |
|
108 #else |
|
109 __ call_VM_leaf(CAST_FROM_FN_PTR(address, G1BarrierSet::write_ref_array_post_entry), |
|
110 addr, count); |
|
111 #endif |
|
112 __ popa(); |
|
113 } |