src/hotspot/cpu/ppc/gc/g1/g1BarrierSetAssembler_ppc.cpp
author eosterlund
Wed, 21 Mar 2018 14:38:32 +0100
changeset 49484 ee8fa73b90f9
child 49748 6a880e576856
permissions -rw-r--r--
8198949: Modularize arraycopy stub routine GC barriers Reviewed-by: rkennke, pliden
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
49484
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
     1
/*
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
     2
 * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
     3
 * Copyright (c) 2018, SAP SE. All rights reserved.
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
     4
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
     5
 *
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
     6
 * This code is free software; you can redistribute it and/or modify it
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
     7
 * under the terms of the GNU General Public License version 2 only, as
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
     8
 * published by the Free Software Foundation.
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
     9
 *
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    10
 * This code is distributed in the hope that it will be useful, but WITHOUT
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    11
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    12
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    13
 * version 2 for more details (a copy is included in the LICENSE file that
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    14
 * accompanied this code).
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    15
 *
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    16
 * You should have received a copy of the GNU General Public License version
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    17
 * 2 along with this work; if not, write to the Free Software Foundation,
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    18
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    19
 *
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    20
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    21
 * or visit www.oracle.com if you need additional information or have any
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    22
 * questions.
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    23
 *
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    24
 */
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    25
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    26
#include "precompiled.hpp"
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    27
#include "asm/macroAssembler.inline.hpp"
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    28
#include "gc/g1/g1BarrierSet.hpp"
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    29
#include "gc/g1/g1CardTable.hpp"
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    30
#include "gc/g1/g1BarrierSetAssembler.hpp"
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    31
#include "gc/g1/heapRegion.hpp"
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    32
#include "gc/shared/collectedHeap.hpp"
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    33
#include "runtime/thread.hpp"
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    34
#include "interpreter/interp_masm.hpp"
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    35
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    36
#define __ masm->
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    37
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    38
void G1BarrierSetAssembler::gen_write_ref_array_pre_barrier(MacroAssembler* masm, DecoratorSet decorators,
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    39
                                                            Register from, Register to, Register count,
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    40
                                                            Register preserve1, Register preserve2) {
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    41
  bool dest_uninitialized = (decorators & AS_DEST_NOT_INITIALIZED) != 0;
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    42
  // With G1, don't generate the call if we statically know that the target in uninitialized
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    43
  if (!dest_uninitialized) {
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    44
    int spill_slots = 3;
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    45
    if (preserve1 != noreg) { spill_slots++; }
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    46
    if (preserve2 != noreg) { spill_slots++; }
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    47
    const int frame_size = align_up(frame::abi_reg_args_size + spill_slots * BytesPerWord, frame::alignment_in_bytes);
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    48
    Label filtered;
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    49
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    50
    // Is marking active?
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    51
    if (in_bytes(SATBMarkQueue::byte_width_of_active()) == 4) {
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    52
      __ lwz(R0, in_bytes(JavaThread::satb_mark_queue_offset() + SATBMarkQueue::byte_offset_of_active()), R16_thread);
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    53
    } else {
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    54
      guarantee(in_bytes(SATBMarkQueue::byte_width_of_active()) == 1, "Assumption");
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    55
      __ lbz(R0, in_bytes(JavaThread::satb_mark_queue_offset() + SATBMarkQueue::byte_offset_of_active()), R16_thread);
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    56
    }
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    57
    __ cmpdi(CCR0, R0, 0);
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    58
    __ beq(CCR0, filtered);
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    59
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    60
    __ save_LR_CR(R0);
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    61
    __ push_frame(frame_size, R0);
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    62
    int slot_nr = 0;
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    63
    __ std(from,  frame_size - (++slot_nr) * wordSize, R1_SP);
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    64
    __ std(to,    frame_size - (++slot_nr) * wordSize, R1_SP);
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    65
    __ std(count, frame_size - (++slot_nr) * wordSize, R1_SP);
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    66
    if (preserve1 != noreg) { __ std(preserve1, frame_size - (++slot_nr) * wordSize, R1_SP); }
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    67
    if (preserve2 != noreg) { __ std(preserve2, frame_size - (++slot_nr) * wordSize, R1_SP); }
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    68
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    69
    if (UseCompressedOops) {
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    70
      __ call_VM_leaf(CAST_FROM_FN_PTR(address, G1BarrierSet::write_ref_array_pre_narrow_oop_entry), to, count);
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    71
    } else {
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    72
      __ call_VM_leaf(CAST_FROM_FN_PTR(address, G1BarrierSet::write_ref_array_pre_oop_entry), to, count);
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    73
    }
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    74
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    75
    slot_nr = 0;
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    76
    __ ld(from,  frame_size - (++slot_nr) * wordSize, R1_SP);
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    77
    __ ld(to,    frame_size - (++slot_nr) * wordSize, R1_SP);
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    78
    __ ld(count, frame_size - (++slot_nr) * wordSize, R1_SP);
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    79
    if (preserve1 != noreg) { __ ld(preserve1, frame_size - (++slot_nr) * wordSize, R1_SP); }
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    80
    if (preserve2 != noreg) { __ ld(preserve2, frame_size - (++slot_nr) * wordSize, R1_SP); }
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    81
    __ addi(R1_SP, R1_SP, frame_size); // pop_frame()
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    82
    __ restore_LR_CR(R0);
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    83
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    84
    __ bind(filtered);
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    85
  }
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    86
}
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    87
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    88
void G1BarrierSetAssembler::gen_write_ref_array_post_barrier(MacroAssembler* masm, DecoratorSet decorators,
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    89
                                                             Register addr, Register count, Register preserve) {
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    90
  int spill_slots = (preserve != noreg) ? 1 : 0;
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    91
  const int frame_size = align_up(frame::abi_reg_args_size + spill_slots * BytesPerWord, frame::alignment_in_bytes);
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    92
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    93
  __ save_LR_CR(R0);
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    94
  __ push_frame(frame_size, R0);
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    95
  if (preserve != noreg) { __ std(preserve, frame_size - 1 * wordSize, R1_SP); }
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    96
  __ call_VM_leaf(CAST_FROM_FN_PTR(address, G1BarrierSet::write_ref_array_post_entry), addr, count);
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    97
  if (preserve != noreg) { __ ld(preserve, frame_size - 1 * wordSize, R1_SP); }
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    98
  __ addi(R1_SP, R1_SP, frame_size); // pop_frame();
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    99
  __ restore_LR_CR(R0);
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
   100
}