src/hotspot/cpu/ppc/gc/g1/g1BarrierSetAssembler_ppc.cpp
author mdoerr
Thu, 17 May 2018 14:19:54 +0200
changeset 50162 f9fe56417050
parent 49906 4bb58f644e4e
child 50375 bfbe7d8369bb
permissions -rw-r--r--
8202713: Create a MacroAssembler::access_load/store_at wrapper for S390 and PPC Reviewed-by: eosterlund, goetz
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"
49906
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
    29
#include "gc/g1/g1BarrierSetAssembler.hpp"
49484
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    30
#include "gc/g1/g1CardTable.hpp"
49752
93d84f667d12 8201318: Introduce GCThreadLocalData to abstract GC-specific data belonging to a thread
pliden
parents: 49748
diff changeset
    31
#include "gc/g1/g1ThreadLocalData.hpp"
49484
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    32
#include "gc/g1/heapRegion.hpp"
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    33
#include "interpreter/interp_masm.hpp"
49753
46f2dc7c4c39 8201475: 8199417 breaks AIX and non-pch on s390 (and presumably aarch64)
stuefe
parents: 49752
diff changeset
    34
#include "runtime/sharedRuntime.hpp"
49906
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
    35
#ifdef COMPILER1
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
    36
#include "c1/c1_LIRAssembler.hpp"
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
    37
#include "c1/c1_MacroAssembler.hpp"
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
    38
#include "gc/g1/c1/g1BarrierSetC1.hpp"
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
    39
#endif
49484
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    40
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    41
#define __ masm->
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    42
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    43
void G1BarrierSetAssembler::gen_write_ref_array_pre_barrier(MacroAssembler* masm, DecoratorSet decorators,
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    44
                                                            Register from, Register to, Register count,
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    45
                                                            Register preserve1, Register preserve2) {
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    46
  bool dest_uninitialized = (decorators & AS_DEST_NOT_INITIALIZED) != 0;
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    47
  // 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
    48
  if (!dest_uninitialized) {
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    49
    int spill_slots = 3;
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    50
    if (preserve1 != noreg) { spill_slots++; }
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    51
    if (preserve2 != noreg) { spill_slots++; }
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    52
    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
    53
    Label filtered;
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    54
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    55
    // Is marking active?
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    56
    if (in_bytes(SATBMarkQueue::byte_width_of_active()) == 4) {
49752
93d84f667d12 8201318: Introduce GCThreadLocalData to abstract GC-specific data belonging to a thread
pliden
parents: 49748
diff changeset
    57
      __ lwz(R0, in_bytes(G1ThreadLocalData::satb_mark_queue_active_offset()), R16_thread);
49484
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    58
    } else {
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    59
      guarantee(in_bytes(SATBMarkQueue::byte_width_of_active()) == 1, "Assumption");
49752
93d84f667d12 8201318: Introduce GCThreadLocalData to abstract GC-specific data belonging to a thread
pliden
parents: 49748
diff changeset
    60
      __ lbz(R0, in_bytes(G1ThreadLocalData::satb_mark_queue_active_offset()), R16_thread);
49484
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    61
    }
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    62
    __ cmpdi(CCR0, R0, 0);
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    63
    __ beq(CCR0, filtered);
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    64
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    65
    __ save_LR_CR(R0);
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    66
    __ push_frame(frame_size, R0);
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    67
    int slot_nr = 0;
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    68
    __ std(from,  frame_size - (++slot_nr) * wordSize, R1_SP);
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    69
    __ std(to,    frame_size - (++slot_nr) * wordSize, R1_SP);
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    70
    __ std(count, frame_size - (++slot_nr) * wordSize, R1_SP);
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    71
    if (preserve1 != noreg) { __ std(preserve1, frame_size - (++slot_nr) * wordSize, R1_SP); }
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    72
    if (preserve2 != noreg) { __ std(preserve2, frame_size - (++slot_nr) * wordSize, R1_SP); }
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
    if (UseCompressedOops) {
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    75
      __ 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
    76
    } else {
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    77
      __ 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
    78
    }
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    79
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    80
    slot_nr = 0;
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    81
    __ ld(from,  frame_size - (++slot_nr) * wordSize, R1_SP);
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    82
    __ ld(to,    frame_size - (++slot_nr) * wordSize, R1_SP);
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    83
    __ ld(count, frame_size - (++slot_nr) * wordSize, R1_SP);
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    84
    if (preserve1 != noreg) { __ ld(preserve1, frame_size - (++slot_nr) * wordSize, R1_SP); }
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    85
    if (preserve2 != noreg) { __ ld(preserve2, frame_size - (++slot_nr) * wordSize, R1_SP); }
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    86
    __ addi(R1_SP, R1_SP, frame_size); // pop_frame()
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    87
    __ restore_LR_CR(R0);
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    88
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    89
    __ bind(filtered);
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    90
  }
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    91
}
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
void G1BarrierSetAssembler::gen_write_ref_array_post_barrier(MacroAssembler* masm, DecoratorSet decorators,
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    94
                                                             Register addr, Register count, Register preserve) {
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    95
  int spill_slots = (preserve != noreg) ? 1 : 0;
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    96
  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
    97
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    98
  __ save_LR_CR(R0);
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    99
  __ push_frame(frame_size, R0);
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
   100
  if (preserve != noreg) { __ std(preserve, frame_size - 1 * wordSize, R1_SP); }
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
   101
  __ 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
   102
  if (preserve != noreg) { __ ld(preserve, frame_size - 1 * wordSize, R1_SP); }
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
   103
  __ addi(R1_SP, R1_SP, frame_size); // pop_frame();
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
   104
  __ restore_LR_CR(R0);
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
   105
}
49748
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   106
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   107
void G1BarrierSetAssembler::g1_write_barrier_pre(MacroAssembler* masm, DecoratorSet decorators, Register obj, RegisterOrConstant ind_or_offs, Register pre_val,
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   108
                                                 Register tmp1, Register tmp2, bool needs_frame) {
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   109
  bool not_null  = (decorators & OOP_NOT_NULL) != 0,
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   110
       preloaded = obj == noreg;
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   111
  Register nv_save = noreg;
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   112
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   113
  if (preloaded) {
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   114
    // We are not loading the previous value so make
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   115
    // sure that we don't trash the value in pre_val
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   116
    // with the code below.
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   117
    assert_different_registers(pre_val, tmp1, tmp2);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   118
    if (pre_val->is_volatile()) {
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   119
      nv_save = !tmp1->is_volatile() ? tmp1 : tmp2;
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   120
      assert(!nv_save->is_volatile(), "need one nv temp register if pre_val lives in volatile register");
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   121
    }
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   122
  }
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   123
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   124
  Label runtime, filtered;
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   125
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   126
  // Is marking active?
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   127
  if (in_bytes(SATBMarkQueue::byte_width_of_active()) == 4) {
49752
93d84f667d12 8201318: Introduce GCThreadLocalData to abstract GC-specific data belonging to a thread
pliden
parents: 49748
diff changeset
   128
    __ lwz(tmp1, in_bytes(G1ThreadLocalData::satb_mark_queue_active_offset()), R16_thread);
49748
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   129
  } else {
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   130
    guarantee(in_bytes(SATBMarkQueue::byte_width_of_active()) == 1, "Assumption");
49752
93d84f667d12 8201318: Introduce GCThreadLocalData to abstract GC-specific data belonging to a thread
pliden
parents: 49748
diff changeset
   131
    __ lbz(tmp1, in_bytes(G1ThreadLocalData::satb_mark_queue_active_offset()), R16_thread);
49748
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   132
  }
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   133
  __ cmpdi(CCR0, tmp1, 0);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   134
  __ beq(CCR0, filtered);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   135
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   136
  // Do we need to load the previous value?
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   137
  if (!preloaded) {
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   138
    // Load the previous value...
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   139
    if (UseCompressedOops) {
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   140
      __ lwz(pre_val, ind_or_offs, obj);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   141
    } else {
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   142
      __ ld(pre_val, ind_or_offs, obj);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   143
    }
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   144
    // Previous value has been loaded into Rpre_val.
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   145
  }
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   146
  assert(pre_val != noreg, "must have a real register");
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   147
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   148
  // Is the previous value null?
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   149
  if (preloaded && not_null) {
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   150
#ifdef ASSERT
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   151
    __ cmpdi(CCR0, pre_val, 0);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   152
    __ asm_assert_ne("null oop not allowed (G1 pre)", 0x321); // Checked by caller.
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   153
#endif
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   154
  } else {
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   155
    __ cmpdi(CCR0, pre_val, 0);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   156
    __ beq(CCR0, filtered);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   157
  }
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   158
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   159
  if (!preloaded && UseCompressedOops) {
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   160
    __ decode_heap_oop_not_null(pre_val);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   161
  }
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   162
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   163
  // OK, it's not filtered, so we'll need to call enqueue. In the normal
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   164
  // case, pre_val will be a scratch G-reg, but there are some cases in
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   165
  // which it's an O-reg. In the first case, do a normal call. In the
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   166
  // latter, do a save here and call the frameless version.
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   167
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   168
  // Can we store original value in the thread's buffer?
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   169
  // Is index == 0?
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   170
  // (The index field is typed as size_t.)
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   171
  const Register Rbuffer = tmp1, Rindex = tmp2;
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   172
49752
93d84f667d12 8201318: Introduce GCThreadLocalData to abstract GC-specific data belonging to a thread
pliden
parents: 49748
diff changeset
   173
  __ ld(Rindex, in_bytes(G1ThreadLocalData::satb_mark_queue_index_offset()), R16_thread);
49748
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   174
  __ cmpdi(CCR0, Rindex, 0);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   175
  __ beq(CCR0, runtime); // If index == 0, goto runtime.
49752
93d84f667d12 8201318: Introduce GCThreadLocalData to abstract GC-specific data belonging to a thread
pliden
parents: 49748
diff changeset
   176
  __ ld(Rbuffer, in_bytes(G1ThreadLocalData::satb_mark_queue_buffer_offset()), R16_thread);
49748
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   177
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   178
  __ addi(Rindex, Rindex, -wordSize); // Decrement index.
49752
93d84f667d12 8201318: Introduce GCThreadLocalData to abstract GC-specific data belonging to a thread
pliden
parents: 49748
diff changeset
   179
  __ std(Rindex, in_bytes(G1ThreadLocalData::satb_mark_queue_index_offset()), R16_thread);
49748
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   180
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   181
  // Record the previous value.
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   182
  __ stdx(pre_val, Rbuffer, Rindex);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   183
  __ b(filtered);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   184
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   185
  __ bind(runtime);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   186
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   187
  // May need to preserve LR. Also needed if current frame is not compatible with C calling convention.
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   188
  if (needs_frame) {
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   189
    __ save_LR_CR(tmp1);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   190
    __ push_frame_reg_args(0, tmp2);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   191
  }
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   192
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   193
  if (pre_val->is_volatile() && preloaded) { __ mr(nv_save, pre_val); } // Save pre_val across C call if it was preloaded.
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   194
  __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::g1_wb_pre), pre_val, R16_thread);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   195
  if (pre_val->is_volatile() && preloaded) { __ mr(pre_val, nv_save); } // restore
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   196
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   197
  if (needs_frame) {
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   198
    __ pop_frame();
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   199
    __ restore_LR_CR(tmp1);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   200
  }
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   201
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   202
  __ bind(filtered);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   203
}
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   204
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   205
void G1BarrierSetAssembler::g1_write_barrier_post(MacroAssembler* masm, DecoratorSet decorators, Register store_addr, Register new_val,
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   206
                                                  Register tmp1, Register tmp2, Register tmp3) {
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   207
  bool not_null = (decorators & OOP_NOT_NULL) != 0;
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   208
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   209
  Label runtime, filtered;
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   210
  assert_different_registers(store_addr, new_val, tmp1, tmp2);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   211
49754
ee93c1087584 8201362: Remove CollectedHeap::barrier_set()
pliden
parents: 49753
diff changeset
   212
  CardTableBarrierSet* ct = barrier_set_cast<CardTableBarrierSet>(BarrierSet::barrier_set());
49748
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   213
  assert(sizeof(*ct->card_table()->byte_map_base()) == sizeof(jbyte), "adjust this code");
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   214
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   215
  // Does store cross heap regions?
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   216
  if (G1RSBarrierRegionFilter) {
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   217
    __ xorr(tmp1, store_addr, new_val);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   218
    __ srdi_(tmp1, tmp1, HeapRegion::LogOfHRGrainBytes);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   219
    __ beq(CCR0, filtered);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   220
  }
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   221
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   222
  // Crosses regions, storing NULL?
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   223
  if (not_null) {
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   224
#ifdef ASSERT
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   225
    __ cmpdi(CCR0, new_val, 0);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   226
    __ asm_assert_ne("null oop not allowed (G1 post)", 0x322); // Checked by caller.
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   227
#endif
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   228
  } else {
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   229
    __ cmpdi(CCR0, new_val, 0);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   230
    __ beq(CCR0, filtered);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   231
  }
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   232
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   233
  // Storing region crossing non-NULL, is card already dirty?
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   234
  const Register Rcard_addr = tmp1;
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   235
  Register Rbase = tmp2;
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   236
  __ load_const_optimized(Rbase, (address)(ct->card_table()->byte_map_base()), /*temp*/ tmp3);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   237
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   238
  __ srdi(Rcard_addr, store_addr, CardTable::card_shift);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   239
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   240
  // Get the address of the card.
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   241
  __ lbzx(/*card value*/ tmp3, Rbase, Rcard_addr);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   242
  __ cmpwi(CCR0, tmp3, (int)G1CardTable::g1_young_card_val());
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   243
  __ beq(CCR0, filtered);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   244
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   245
  __ membar(Assembler::StoreLoad);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   246
  __ lbzx(/*card value*/ tmp3, Rbase, Rcard_addr);  // Reload after membar.
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   247
  __ cmpwi(CCR0, tmp3 /* card value */, (int)G1CardTable::dirty_card_val());
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   248
  __ beq(CCR0, filtered);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   249
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   250
  // Storing a region crossing, non-NULL oop, card is clean.
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   251
  // Dirty card and log.
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   252
  __ li(tmp3, (int)G1CardTable::dirty_card_val());
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   253
  //release(); // G1: oops are allowed to get visible after dirty marking.
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   254
  __ stbx(tmp3, Rbase, Rcard_addr);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   255
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   256
  __ add(Rcard_addr, Rbase, Rcard_addr); // This is the address which needs to get enqueued.
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   257
  Rbase = noreg; // end of lifetime
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   258
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   259
  const Register Rqueue_index = tmp2,
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   260
                 Rqueue_buf   = tmp3;
49752
93d84f667d12 8201318: Introduce GCThreadLocalData to abstract GC-specific data belonging to a thread
pliden
parents: 49748
diff changeset
   261
  __ ld(Rqueue_index, in_bytes(G1ThreadLocalData::dirty_card_queue_index_offset()), R16_thread);
49748
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   262
  __ cmpdi(CCR0, Rqueue_index, 0);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   263
  __ beq(CCR0, runtime); // index == 0 then jump to runtime
49752
93d84f667d12 8201318: Introduce GCThreadLocalData to abstract GC-specific data belonging to a thread
pliden
parents: 49748
diff changeset
   264
  __ ld(Rqueue_buf, in_bytes(G1ThreadLocalData::dirty_card_queue_buffer_offset()), R16_thread);
49748
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   265
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   266
  __ addi(Rqueue_index, Rqueue_index, -wordSize); // decrement index
49752
93d84f667d12 8201318: Introduce GCThreadLocalData to abstract GC-specific data belonging to a thread
pliden
parents: 49748
diff changeset
   267
  __ std(Rqueue_index, in_bytes(G1ThreadLocalData::dirty_card_queue_index_offset()), R16_thread);
49748
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   268
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   269
  __ stdx(Rcard_addr, Rqueue_buf, Rqueue_index); // store card
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   270
  __ b(filtered);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   271
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   272
  __ bind(runtime);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   273
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   274
  // Save the live input values.
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   275
  __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::g1_wb_post), Rcard_addr, R16_thread);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   276
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   277
  __ bind(filtered);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   278
}
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   279
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   280
void G1BarrierSetAssembler::oop_store_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type,
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   281
                                       Register base, RegisterOrConstant ind_or_offs, Register val,
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   282
                                       Register tmp1, Register tmp2, Register tmp3, bool needs_frame) {
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   283
  bool on_array = (decorators & IN_HEAP_ARRAY) != 0;
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   284
  bool on_anonymous = (decorators & ON_UNKNOWN_OOP_REF) != 0;
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   285
  bool precise = on_array || on_anonymous;
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   286
  // Load and record the previous value.
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   287
  g1_write_barrier_pre(masm, decorators, base, ind_or_offs,
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   288
                       tmp1, tmp2, tmp3, needs_frame);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   289
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   290
  BarrierSetAssembler::store_at(masm, decorators, type, base, ind_or_offs, val, tmp1, tmp2, tmp3, needs_frame);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   291
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   292
  // No need for post barrier if storing NULL
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   293
  if (val != noreg) {
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   294
    if (precise) {
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   295
      if (ind_or_offs.is_constant()) {
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   296
        __ add_const_optimized(base, base, ind_or_offs.as_constant(), tmp1);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   297
      } else {
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   298
        __ add(base, ind_or_offs.as_register(), base);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   299
      }
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   300
    }
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   301
    g1_write_barrier_post(masm, decorators, base, val, tmp1, tmp2, tmp3);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   302
  }
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   303
}
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   304
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   305
void G1BarrierSetAssembler::load_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type,
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   306
                                    Register base, RegisterOrConstant ind_or_offs, Register dst,
50162
f9fe56417050 8202713: Create a MacroAssembler::access_load/store_at wrapper for S390 and PPC
mdoerr
parents: 49906
diff changeset
   307
                                    Register tmp1, Register tmp2, bool needs_frame, Label *L_handle_null) {
49748
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   308
  bool on_oop = type == T_OBJECT || type == T_ARRAY;
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   309
  bool on_weak = (decorators & ON_WEAK_OOP_REF) != 0;
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   310
  bool on_phantom = (decorators & ON_PHANTOM_OOP_REF) != 0;
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   311
  bool on_reference = on_weak || on_phantom;
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   312
  Label done;
50162
f9fe56417050 8202713: Create a MacroAssembler::access_load/store_at wrapper for S390 and PPC
mdoerr
parents: 49906
diff changeset
   313
  if (on_oop && on_reference && L_handle_null == NULL) { L_handle_null = &done; }
49748
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   314
  // Load the value of the referent field.
50162
f9fe56417050 8202713: Create a MacroAssembler::access_load/store_at wrapper for S390 and PPC
mdoerr
parents: 49906
diff changeset
   315
  ModRefBarrierSetAssembler::load_at(masm, decorators, type, base, ind_or_offs, dst, tmp1, tmp2, needs_frame, L_handle_null);
49748
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   316
  if (on_oop && on_reference) {
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   317
    // Generate the G1 pre-barrier code to log the value of
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   318
    // the referent field in an SATB buffer. Note with
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   319
    // these parameters the pre-barrier does not generate
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   320
    // the load of the previous value
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   321
    // We only reach here if value is not null.
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   322
    g1_write_barrier_pre(masm, decorators | OOP_NOT_NULL, noreg /* obj */, (intptr_t)0, dst /* pre_val */,
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   323
                         tmp1, tmp2, needs_frame);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   324
  }
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   325
  __ bind(done);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   326
}
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   327
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   328
void G1BarrierSetAssembler::resolve_jobject(MacroAssembler* masm, Register value, Register tmp1, Register tmp2, bool needs_frame) {
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   329
  Label done, not_weak;
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   330
  __ cmpdi(CCR0, value, 0);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   331
  __ beq(CCR0, done);         // Use NULL as-is.
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   332
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   333
  __ clrrdi(tmp1, value, JNIHandles::weak_tag_size);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   334
  __ andi_(tmp2, value, JNIHandles::weak_tag_mask);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   335
  __ ld(value, 0, tmp1);      // Resolve (untagged) jobject.
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   336
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   337
  __ beq(CCR0, not_weak);     // Test for jweak tag.
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   338
  __ verify_oop(value);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   339
  g1_write_barrier_pre(masm, IN_ROOT | ON_PHANTOM_OOP_REF,
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   340
                       noreg, noreg, value,
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   341
                       tmp1, tmp2, needs_frame);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   342
  __ bind(not_weak);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   343
  __ verify_oop(value);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   344
  __ bind(done);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   345
}
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   346
49906
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   347
#ifdef COMPILER1
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   348
49748
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   349
#undef __
49906
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   350
#define __ ce->masm()->
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   351
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   352
void G1BarrierSetAssembler::gen_pre_barrier_stub(LIR_Assembler* ce, G1PreBarrierStub* stub) {
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   353
  G1BarrierSetC1* bs = (G1BarrierSetC1*)BarrierSet::barrier_set()->barrier_set_c1();
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   354
  // At this point we know that marking is in progress.
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   355
  // If do_load() is true then we have to emit the
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   356
  // load of the previous value; otherwise it has already
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   357
  // been loaded into _pre_val.
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   358
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   359
  __ bind(*stub->entry());
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   360
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   361
  assert(stub->pre_val()->is_register(), "Precondition.");
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   362
  Register pre_val_reg = stub->pre_val()->as_register();
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   363
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   364
  if (stub->do_load()) {
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   365
    ce->mem2reg(stub->addr(), stub->pre_val(), T_OBJECT, stub->patch_code(), stub->info(), false /*wide*/, false /*unaligned*/);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   366
  }
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   367
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   368
  __ cmpdi(CCR0, pre_val_reg, 0);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   369
  __ bc_far_optimized(Assembler::bcondCRbiIs1, __ bi0(CCR0, Assembler::equal), *stub->continuation());
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   370
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   371
  address c_code = bs->pre_barrier_c1_runtime_code_blob()->code_begin();
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   372
  //__ load_const_optimized(R0, c_code);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   373
  __ add_const_optimized(R0, R29_TOC, MacroAssembler::offset_to_global_toc(c_code));
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   374
  __ std(pre_val_reg, -8, R1_SP); // Pass pre_val on stack.
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   375
  __ mtctr(R0);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   376
  __ bctrl();
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   377
  __ b(*stub->continuation());
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   378
}
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   379
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   380
void G1BarrierSetAssembler::gen_post_barrier_stub(LIR_Assembler* ce, G1PostBarrierStub* stub) {
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   381
  G1BarrierSetC1* bs = (G1BarrierSetC1*)BarrierSet::barrier_set()->barrier_set_c1();
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   382
  __ bind(*stub->entry());
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   383
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   384
  assert(stub->addr()->is_register(), "Precondition.");
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   385
  assert(stub->new_val()->is_register(), "Precondition.");
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   386
  Register addr_reg = stub->addr()->as_pointer_register();
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   387
  Register new_val_reg = stub->new_val()->as_register();
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   388
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   389
  __ cmpdi(CCR0, new_val_reg, 0);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   390
  __ bc_far_optimized(Assembler::bcondCRbiIs1, __ bi0(CCR0, Assembler::equal), *stub->continuation());
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   391
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   392
  address c_code = bs->post_barrier_c1_runtime_code_blob()->code_begin();
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   393
  //__ load_const_optimized(R0, c_code);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   394
  __ add_const_optimized(R0, R29_TOC, MacroAssembler::offset_to_global_toc(c_code));
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   395
  __ mtctr(R0);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   396
  __ mr(R0, addr_reg); // Pass addr in R0.
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   397
  __ bctrl();
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   398
  __ b(*stub->continuation());
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   399
}
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   400
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   401
#undef __
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   402
#define __ sasm->
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   403
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   404
void G1BarrierSetAssembler::generate_c1_pre_barrier_runtime_stub(StubAssembler* sasm) {
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   405
  BarrierSet* bs = BarrierSet::barrier_set();
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   406
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   407
  __ set_info("g1_pre_barrier_slow_id", false);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   408
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   409
  // Using stack slots: pre_val (pre-pushed), spill tmp, spill tmp2.
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   410
  const int stack_slots = 3;
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   411
  Register pre_val = R0; // previous value of memory
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   412
  Register tmp  = R14;
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   413
  Register tmp2 = R15;
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   414
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   415
  Label refill, restart, marking_not_active;
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   416
  int satb_q_active_byte_offset = in_bytes(G1ThreadLocalData::satb_mark_queue_active_offset());
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   417
  int satb_q_index_byte_offset = in_bytes(G1ThreadLocalData::satb_mark_queue_index_offset());
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   418
  int satb_q_buf_byte_offset = in_bytes(G1ThreadLocalData::satb_mark_queue_buffer_offset());
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   419
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   420
  // Spill
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   421
  __ std(tmp, -16, R1_SP);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   422
  __ std(tmp2, -24, R1_SP);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   423
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   424
  // Is marking still active?
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   425
  if (in_bytes(SATBMarkQueue::byte_width_of_active()) == 4) {
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   426
    __ lwz(tmp, satb_q_active_byte_offset, R16_thread);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   427
  } else {
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   428
    assert(in_bytes(SATBMarkQueue::byte_width_of_active()) == 1, "Assumption");
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   429
    __ lbz(tmp, satb_q_active_byte_offset, R16_thread);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   430
  }
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   431
  __ cmpdi(CCR0, tmp, 0);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   432
  __ beq(CCR0, marking_not_active);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   433
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   434
  __ bind(restart);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   435
  // Load the index into the SATB buffer. SATBMarkQueue::_index is a
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   436
  // size_t so ld_ptr is appropriate.
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   437
  __ ld(tmp, satb_q_index_byte_offset, R16_thread);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   438
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   439
  // index == 0?
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   440
  __ cmpdi(CCR0, tmp, 0);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   441
  __ beq(CCR0, refill);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   442
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   443
  __ ld(tmp2, satb_q_buf_byte_offset, R16_thread);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   444
  __ ld(pre_val, -8, R1_SP); // Load from stack.
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   445
  __ addi(tmp, tmp, -oopSize);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   446
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   447
  __ std(tmp, satb_q_index_byte_offset, R16_thread);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   448
  __ stdx(pre_val, tmp2, tmp); // [_buf + index] := <address_of_card>
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   449
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   450
  __ bind(marking_not_active);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   451
  // Restore temp registers and return-from-leaf.
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   452
  __ ld(tmp2, -24, R1_SP);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   453
  __ ld(tmp, -16, R1_SP);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   454
  __ blr();
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   455
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   456
  __ bind(refill);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   457
  const int nbytes_save = (MacroAssembler::num_volatile_regs + stack_slots) * BytesPerWord;
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   458
  __ save_volatile_gprs(R1_SP, -nbytes_save); // except R0
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   459
  __ mflr(R0);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   460
  __ std(R0, _abi(lr), R1_SP);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   461
  __ push_frame_reg_args(nbytes_save, R0); // dummy frame for C call
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   462
  __ call_VM_leaf(CAST_FROM_FN_PTR(address, SATBMarkQueueSet::handle_zero_index_for_thread), R16_thread);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   463
  __ pop_frame();
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   464
  __ ld(R0, _abi(lr), R1_SP);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   465
  __ mtlr(R0);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   466
  __ restore_volatile_gprs(R1_SP, -nbytes_save); // except R0
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   467
  __ b(restart);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   468
}
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   469
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   470
void G1BarrierSetAssembler::generate_c1_post_barrier_runtime_stub(StubAssembler* sasm) {
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   471
  G1BarrierSet* bs = barrier_set_cast<G1BarrierSet>(BarrierSet::barrier_set());
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   472
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   473
  __ set_info("g1_post_barrier_slow_id", false);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   474
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   475
  // Using stack slots: spill addr, spill tmp2
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   476
  const int stack_slots = 2;
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   477
  Register tmp = R0;
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   478
  Register addr = R14;
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   479
  Register tmp2 = R15;
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   480
  jbyte* byte_map_base = bs->card_table()->byte_map_base();
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   481
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   482
  Label restart, refill, ret;
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   483
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   484
  // Spill
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   485
  __ std(addr, -8, R1_SP);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   486
  __ std(tmp2, -16, R1_SP);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   487
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   488
  __ srdi(addr, R0, CardTable::card_shift); // Addr is passed in R0.
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   489
  __ load_const_optimized(/*cardtable*/ tmp2, byte_map_base, tmp);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   490
  __ add(addr, tmp2, addr);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   491
  __ lbz(tmp, 0, addr); // tmp := [addr + cardtable]
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   492
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   493
  // Return if young card.
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   494
  __ cmpwi(CCR0, tmp, G1CardTable::g1_young_card_val());
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   495
  __ beq(CCR0, ret);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   496
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   497
  // Return if sequential consistent value is already dirty.
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   498
  __ membar(Assembler::StoreLoad);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   499
  __ lbz(tmp, 0, addr); // tmp := [addr + cardtable]
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   500
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   501
  __ cmpwi(CCR0, tmp, G1CardTable::dirty_card_val());
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   502
  __ beq(CCR0, ret);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   503
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   504
  // Not dirty.
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   505
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   506
  // First, dirty it.
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   507
  __ li(tmp, G1CardTable::dirty_card_val());
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   508
  __ stb(tmp, 0, addr);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   509
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   510
  int dirty_card_q_index_byte_offset = in_bytes(G1ThreadLocalData::dirty_card_queue_index_offset());
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   511
  int dirty_card_q_buf_byte_offset = in_bytes(G1ThreadLocalData::dirty_card_queue_buffer_offset());
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   512
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   513
  __ bind(restart);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   514
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   515
  // Get the index into the update buffer. DirtyCardQueue::_index is
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   516
  // a size_t so ld_ptr is appropriate here.
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   517
  __ ld(tmp2, dirty_card_q_index_byte_offset, R16_thread);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   518
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   519
  // index == 0?
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   520
  __ cmpdi(CCR0, tmp2, 0);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   521
  __ beq(CCR0, refill);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   522
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   523
  __ ld(tmp, dirty_card_q_buf_byte_offset, R16_thread);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   524
  __ addi(tmp2, tmp2, -oopSize);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   525
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   526
  __ std(tmp2, dirty_card_q_index_byte_offset, R16_thread);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   527
  __ add(tmp2, tmp, tmp2);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   528
  __ std(addr, 0, tmp2); // [_buf + index] := <address_of_card>
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   529
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   530
  // Restore temp registers and return-from-leaf.
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   531
  __ bind(ret);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   532
  __ ld(tmp2, -16, R1_SP);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   533
  __ ld(addr, -8, R1_SP);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   534
  __ blr();
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   535
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   536
  __ bind(refill);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   537
  const int nbytes_save = (MacroAssembler::num_volatile_regs + stack_slots) * BytesPerWord;
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   538
  __ save_volatile_gprs(R1_SP, -nbytes_save); // except R0
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   539
  __ mflr(R0);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   540
  __ std(R0, _abi(lr), R1_SP);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   541
  __ push_frame_reg_args(nbytes_save, R0); // dummy frame for C call
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   542
  __ call_VM_leaf(CAST_FROM_FN_PTR(address, DirtyCardQueueSet::handle_zero_index_for_thread), R16_thread);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   543
  __ pop_frame();
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   544
  __ ld(R0, _abi(lr), R1_SP);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   545
  __ mtlr(R0);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   546
  __ restore_volatile_gprs(R1_SP, -nbytes_save); // except R0
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   547
  __ b(restart);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   548
}
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   549
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   550
#undef __
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   551
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   552
#endif // COMPILER1