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/shared/cardTable.hpp"
28 #include "gc/shared/cardTableModRefBS.hpp"
29 #include "interpreter/interpreter.hpp"
30 #include "nativeInst_ppc.hpp"
31 #include "oops/instanceOop.hpp"
32 #include "oops/method.hpp"
33 #include "oops/objArrayKlass.hpp"
34 #include "oops/oop.inline.hpp"
35 #include "prims/methodHandles.hpp"
36 #include "runtime/frame.inline.hpp"
37 #include "runtime/handles.inline.hpp"
38 #include "runtime/sharedRuntime.hpp"
39 #include "runtime/stubCodeGenerator.hpp"
40 #include "runtime/stubRoutines.hpp"
41 #include "runtime/thread.inline.hpp"
42 #include "utilities/align.hpp"
43
44 // Declaration and definition of StubGenerator (no .hpp file).
45 // For a more detailed description of the stub routine structure
46 // see the comment in stubRoutines.hpp.
47
|
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/shared/cardTable.hpp"
28 #include "gc/shared/cardTableBarrierSet.hpp"
29 #include "interpreter/interpreter.hpp"
30 #include "nativeInst_ppc.hpp"
31 #include "oops/instanceOop.hpp"
32 #include "oops/method.hpp"
33 #include "oops/objArrayKlass.hpp"
34 #include "oops/oop.inline.hpp"
35 #include "prims/methodHandles.hpp"
36 #include "runtime/frame.inline.hpp"
37 #include "runtime/handles.inline.hpp"
38 #include "runtime/sharedRuntime.hpp"
39 #include "runtime/stubCodeGenerator.hpp"
40 #include "runtime/stubRoutines.hpp"
41 #include "runtime/thread.inline.hpp"
42 #include "utilities/align.hpp"
43
44 // Declaration and definition of StubGenerator (no .hpp file).
45 // For a more detailed description of the stub routine structure
46 // see the comment in stubRoutines.hpp.
47
|
651 __ std(from, frame_size - (++slot_nr) * wordSize, R1_SP);
652 __ std(to, frame_size - (++slot_nr) * wordSize, R1_SP);
653 __ std(count, frame_size - (++slot_nr) * wordSize, R1_SP);
654 if (preserve1 != noreg) { __ std(preserve1, frame_size - (++slot_nr) * wordSize, R1_SP); }
655 if (preserve2 != noreg) { __ std(preserve2, frame_size - (++slot_nr) * wordSize, R1_SP); }
656
657 __ call_VM_leaf(CAST_FROM_FN_PTR(address, BarrierSet::static_write_ref_array_pre), to, count);
658
659 slot_nr = 0;
660 __ ld(from, frame_size - (++slot_nr) * wordSize, R1_SP);
661 __ ld(to, frame_size - (++slot_nr) * wordSize, R1_SP);
662 __ ld(count, frame_size - (++slot_nr) * wordSize, R1_SP);
663 if (preserve1 != noreg) { __ ld(preserve1, frame_size - (++slot_nr) * wordSize, R1_SP); }
664 if (preserve2 != noreg) { __ ld(preserve2, frame_size - (++slot_nr) * wordSize, R1_SP); }
665 __ addi(R1_SP, R1_SP, frame_size); // pop_frame()
666 __ restore_LR_CR(R0);
667
668 __ bind(filtered);
669 }
670 break;
671 case BarrierSet::CardTableModRef:
672 break;
673 default:
674 ShouldNotReachHere();
675 }
676 }
677
678 // Generate CMS/G1 post-write barrier for array.
679 //
680 // Input:
681 // addr - register containing starting address
682 // count - register containing element count
683 // tmp - scratch register
684 //
685 // The input registers and R0 are overwritten.
686 //
687 void gen_write_ref_array_post_barrier(Register addr, Register count, Register tmp, Register preserve = noreg) {
688 BarrierSet* const bs = Universe::heap()->barrier_set();
689
690 switch (bs->kind()) {
691 case BarrierSet::G1BarrierSet:
692 {
693 int spill_slots = (preserve != noreg) ? 1 : 0;
694 const int frame_size = align_up(frame::abi_reg_args_size + spill_slots * BytesPerWord, frame::alignment_in_bytes);
695
696 __ save_LR_CR(R0);
697 __ push_frame(frame_size, R0);
698 if (preserve != noreg) { __ std(preserve, frame_size - 1 * wordSize, R1_SP); }
699 __ call_VM_leaf(CAST_FROM_FN_PTR(address, BarrierSet::static_write_ref_array_post), addr, count);
700 if (preserve != noreg) { __ ld(preserve, frame_size - 1 * wordSize, R1_SP); }
701 __ addi(R1_SP, R1_SP, frame_size); // pop_frame();
702 __ restore_LR_CR(R0);
703 }
704 break;
705 case BarrierSet::CardTableModRef:
706 {
707 Label Lskip_loop, Lstore_loop;
708 if (UseConcMarkSweepGC) {
709 // TODO PPC port: contribute optimization / requires shared changes
710 __ release();
711 }
712
713 CardTableModRefBS* const ctbs = barrier_set_cast<CardTableModRefBS>(bs);
714 CardTable* const ct = ctbs->card_table();
715 assert(sizeof(*ct->byte_map_base()) == sizeof(jbyte), "adjust this code");
716 assert_different_registers(addr, count, tmp);
717
718 __ sldi(count, count, LogBytesPerHeapOop);
719 __ addi(count, count, -BytesPerHeapOop);
720 __ add(count, addr, count);
721 // Use two shifts to clear out those low order two bits! (Cannot opt. into 1.)
722 __ srdi(addr, addr, CardTable::card_shift);
723 __ srdi(count, count, CardTable::card_shift);
724 __ subf(count, addr, count);
725 assert_different_registers(R0, addr, count, tmp);
726 __ load_const(tmp, (address)ct->byte_map_base());
727 __ addic_(count, count, 1);
728 __ beq(CCR0, Lskip_loop);
729 __ li(R0, 0);
730 __ mtctr(count);
731 // Byte store loop
732 __ bind(Lstore_loop);
|
651 __ std(from, frame_size - (++slot_nr) * wordSize, R1_SP);
652 __ std(to, frame_size - (++slot_nr) * wordSize, R1_SP);
653 __ std(count, frame_size - (++slot_nr) * wordSize, R1_SP);
654 if (preserve1 != noreg) { __ std(preserve1, frame_size - (++slot_nr) * wordSize, R1_SP); }
655 if (preserve2 != noreg) { __ std(preserve2, frame_size - (++slot_nr) * wordSize, R1_SP); }
656
657 __ call_VM_leaf(CAST_FROM_FN_PTR(address, BarrierSet::static_write_ref_array_pre), to, count);
658
659 slot_nr = 0;
660 __ ld(from, frame_size - (++slot_nr) * wordSize, R1_SP);
661 __ ld(to, frame_size - (++slot_nr) * wordSize, R1_SP);
662 __ ld(count, frame_size - (++slot_nr) * wordSize, R1_SP);
663 if (preserve1 != noreg) { __ ld(preserve1, frame_size - (++slot_nr) * wordSize, R1_SP); }
664 if (preserve2 != noreg) { __ ld(preserve2, frame_size - (++slot_nr) * wordSize, R1_SP); }
665 __ addi(R1_SP, R1_SP, frame_size); // pop_frame()
666 __ restore_LR_CR(R0);
667
668 __ bind(filtered);
669 }
670 break;
671 case BarrierSet::CardTableBarrierSet:
672 break;
673 default:
674 ShouldNotReachHere();
675 }
676 }
677
678 // Generate CMS/G1 post-write barrier for array.
679 //
680 // Input:
681 // addr - register containing starting address
682 // count - register containing element count
683 // tmp - scratch register
684 //
685 // The input registers and R0 are overwritten.
686 //
687 void gen_write_ref_array_post_barrier(Register addr, Register count, Register tmp, Register preserve = noreg) {
688 BarrierSet* const bs = Universe::heap()->barrier_set();
689
690 switch (bs->kind()) {
691 case BarrierSet::G1BarrierSet:
692 {
693 int spill_slots = (preserve != noreg) ? 1 : 0;
694 const int frame_size = align_up(frame::abi_reg_args_size + spill_slots * BytesPerWord, frame::alignment_in_bytes);
695
696 __ save_LR_CR(R0);
697 __ push_frame(frame_size, R0);
698 if (preserve != noreg) { __ std(preserve, frame_size - 1 * wordSize, R1_SP); }
699 __ call_VM_leaf(CAST_FROM_FN_PTR(address, BarrierSet::static_write_ref_array_post), addr, count);
700 if (preserve != noreg) { __ ld(preserve, frame_size - 1 * wordSize, R1_SP); }
701 __ addi(R1_SP, R1_SP, frame_size); // pop_frame();
702 __ restore_LR_CR(R0);
703 }
704 break;
705 case BarrierSet::CardTableBarrierSet:
706 {
707 Label Lskip_loop, Lstore_loop;
708 if (UseConcMarkSweepGC) {
709 // TODO PPC port: contribute optimization / requires shared changes
710 __ release();
711 }
712
713 CardTableBarrierSet* const ctbs = barrier_set_cast<CardTableBarrierSet>(bs);
714 CardTable* const ct = ctbs->card_table();
715 assert(sizeof(*ct->byte_map_base()) == sizeof(jbyte), "adjust this code");
716 assert_different_registers(addr, count, tmp);
717
718 __ sldi(count, count, LogBytesPerHeapOop);
719 __ addi(count, count, -BytesPerHeapOop);
720 __ add(count, addr, count);
721 // Use two shifts to clear out those low order two bits! (Cannot opt. into 1.)
722 __ srdi(addr, addr, CardTable::card_shift);
723 __ srdi(count, count, CardTable::card_shift);
724 __ subf(count, addr, count);
725 assert_different_registers(R0, addr, count, tmp);
726 __ load_const(tmp, (address)ct->byte_map_base());
727 __ addic_(count, count, 1);
728 __ beq(CCR0, Lskip_loop);
729 __ li(R0, 0);
730 __ mtctr(count);
731 // Byte store loop
732 __ bind(Lstore_loop);
|