src/hotspot/cpu/ppc/gc/g1/g1BarrierSetAssembler_ppc.cpp
author pliden
Thu, 12 Apr 2018 11:22:24 +0200
changeset 49754 ee93c1087584
parent 49753 46f2dc7c4c39
child 49906 4bb58f644e4e
permissions -rw-r--r--
8201362: Remove CollectedHeap::barrier_set() Reviewed-by: shade, rkennke
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"
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"
49484
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) {
49752
93d84f667d12 8201318: Introduce GCThreadLocalData to abstract GC-specific data belonging to a thread
pliden
parents: 49748
diff changeset
    52
      __ 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
    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");
49752
93d84f667d12 8201318: Introduce GCThreadLocalData to abstract GC-specific data belonging to a thread
pliden
parents: 49748
diff changeset
    55
      __ 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
    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
}
49748
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   101
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   102
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
   103
                                                 Register tmp1, Register tmp2, bool needs_frame) {
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   104
  bool not_null  = (decorators & OOP_NOT_NULL) != 0,
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   105
       preloaded = obj == noreg;
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   106
  Register nv_save = noreg;
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   107
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   108
  if (preloaded) {
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   109
    // We are not loading the previous value so make
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   110
    // sure that we don't trash the value in pre_val
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   111
    // with the code below.
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   112
    assert_different_registers(pre_val, tmp1, tmp2);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   113
    if (pre_val->is_volatile()) {
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   114
      nv_save = !tmp1->is_volatile() ? tmp1 : tmp2;
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   115
      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
   116
    }
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   117
  }
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   118
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   119
  Label runtime, filtered;
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   120
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   121
  // Is marking active?
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   122
  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
   123
    __ lwz(tmp1, in_bytes(G1ThreadLocalData::satb_mark_queue_active_offset()), R16_thread);
49748
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   124
  } else {
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   125
    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
   126
    __ lbz(tmp1, in_bytes(G1ThreadLocalData::satb_mark_queue_active_offset()), R16_thread);
49748
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   127
  }
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   128
  __ cmpdi(CCR0, tmp1, 0);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   129
  __ beq(CCR0, filtered);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   130
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   131
  // Do we need to load the previous value?
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   132
  if (!preloaded) {
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   133
    // Load the previous value...
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   134
    if (UseCompressedOops) {
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   135
      __ lwz(pre_val, ind_or_offs, obj);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   136
    } else {
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   137
      __ ld(pre_val, ind_or_offs, obj);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   138
    }
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   139
    // Previous value has been loaded into Rpre_val.
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   140
  }
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   141
  assert(pre_val != noreg, "must have a real register");
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   142
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   143
  // Is the previous value null?
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   144
  if (preloaded && not_null) {
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   145
#ifdef ASSERT
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   146
    __ cmpdi(CCR0, pre_val, 0);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   147
    __ asm_assert_ne("null oop not allowed (G1 pre)", 0x321); // Checked by caller.
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   148
#endif
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   149
  } else {
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   150
    __ cmpdi(CCR0, pre_val, 0);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   151
    __ beq(CCR0, filtered);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   152
  }
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   153
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   154
  if (!preloaded && UseCompressedOops) {
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   155
    __ decode_heap_oop_not_null(pre_val);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   156
  }
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   157
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   158
  // 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
   159
  // 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
   160
  // 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
   161
  // latter, do a save here and call the frameless version.
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   162
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   163
  // Can we store original value in the thread's buffer?
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   164
  // Is index == 0?
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   165
  // (The index field is typed as size_t.)
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   166
  const Register Rbuffer = tmp1, Rindex = tmp2;
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   167
49752
93d84f667d12 8201318: Introduce GCThreadLocalData to abstract GC-specific data belonging to a thread
pliden
parents: 49748
diff changeset
   168
  __ ld(Rindex, in_bytes(G1ThreadLocalData::satb_mark_queue_index_offset()), R16_thread);
49748
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   169
  __ cmpdi(CCR0, Rindex, 0);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   170
  __ 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
   171
  __ ld(Rbuffer, in_bytes(G1ThreadLocalData::satb_mark_queue_buffer_offset()), R16_thread);
49748
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   172
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   173
  __ 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
   174
  __ std(Rindex, in_bytes(G1ThreadLocalData::satb_mark_queue_index_offset()), R16_thread);
49748
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   175
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   176
  // Record the previous value.
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   177
  __ stdx(pre_val, Rbuffer, Rindex);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   178
  __ b(filtered);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   179
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   180
  __ bind(runtime);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   181
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   182
  // 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
   183
  if (needs_frame) {
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   184
    __ save_LR_CR(tmp1);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   185
    __ push_frame_reg_args(0, tmp2);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   186
  }
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   187
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   188
  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
   189
  __ 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
   190
  if (pre_val->is_volatile() && preloaded) { __ mr(pre_val, nv_save); } // restore
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   191
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   192
  if (needs_frame) {
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   193
    __ pop_frame();
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   194
    __ restore_LR_CR(tmp1);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   195
  }
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   196
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   197
  __ bind(filtered);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   198
}
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   199
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   200
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
   201
                                                  Register tmp1, Register tmp2, Register tmp3) {
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   202
  bool not_null = (decorators & OOP_NOT_NULL) != 0;
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   203
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   204
  Label runtime, filtered;
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   205
  assert_different_registers(store_addr, new_val, tmp1, tmp2);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   206
49754
ee93c1087584 8201362: Remove CollectedHeap::barrier_set()
pliden
parents: 49753
diff changeset
   207
  CardTableBarrierSet* ct = barrier_set_cast<CardTableBarrierSet>(BarrierSet::barrier_set());
49748
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   208
  assert(sizeof(*ct->card_table()->byte_map_base()) == sizeof(jbyte), "adjust this code");
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   209
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   210
  // Does store cross heap regions?
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   211
  if (G1RSBarrierRegionFilter) {
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   212
    __ xorr(tmp1, store_addr, new_val);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   213
    __ srdi_(tmp1, tmp1, HeapRegion::LogOfHRGrainBytes);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   214
    __ beq(CCR0, filtered);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   215
  }
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   216
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   217
  // Crosses regions, storing NULL?
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   218
  if (not_null) {
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   219
#ifdef ASSERT
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   220
    __ cmpdi(CCR0, new_val, 0);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   221
    __ asm_assert_ne("null oop not allowed (G1 post)", 0x322); // Checked by caller.
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   222
#endif
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   223
  } else {
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   224
    __ cmpdi(CCR0, new_val, 0);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   225
    __ beq(CCR0, filtered);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   226
  }
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   227
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   228
  // Storing region crossing non-NULL, is card already dirty?
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   229
  const Register Rcard_addr = tmp1;
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   230
  Register Rbase = tmp2;
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   231
  __ load_const_optimized(Rbase, (address)(ct->card_table()->byte_map_base()), /*temp*/ tmp3);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   232
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   233
  __ srdi(Rcard_addr, store_addr, CardTable::card_shift);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   234
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   235
  // Get the address of the card.
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   236
  __ lbzx(/*card value*/ tmp3, Rbase, Rcard_addr);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   237
  __ cmpwi(CCR0, tmp3, (int)G1CardTable::g1_young_card_val());
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   238
  __ beq(CCR0, filtered);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   239
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   240
  __ membar(Assembler::StoreLoad);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   241
  __ lbzx(/*card value*/ tmp3, Rbase, Rcard_addr);  // Reload after membar.
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   242
  __ cmpwi(CCR0, tmp3 /* card value */, (int)G1CardTable::dirty_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
  // Storing a region crossing, non-NULL oop, card is clean.
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   246
  // Dirty card and log.
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   247
  __ li(tmp3, (int)G1CardTable::dirty_card_val());
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   248
  //release(); // G1: oops are allowed to get visible after dirty marking.
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   249
  __ stbx(tmp3, Rbase, Rcard_addr);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   250
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   251
  __ 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
   252
  Rbase = noreg; // end of lifetime
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   253
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   254
  const Register Rqueue_index = tmp2,
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   255
                 Rqueue_buf   = tmp3;
49752
93d84f667d12 8201318: Introduce GCThreadLocalData to abstract GC-specific data belonging to a thread
pliden
parents: 49748
diff changeset
   256
  __ 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
   257
  __ cmpdi(CCR0, Rqueue_index, 0);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   258
  __ 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
   259
  __ 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
   260
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   261
  __ 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
   262
  __ 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
   263
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   264
  __ stdx(Rcard_addr, Rqueue_buf, Rqueue_index); // store card
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   265
  __ b(filtered);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   266
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   267
  __ bind(runtime);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   268
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   269
  // Save the live input values.
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   270
  __ 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
   271
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   272
  __ bind(filtered);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   273
}
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   274
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   275
void G1BarrierSetAssembler::oop_store_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type,
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   276
                                       Register base, RegisterOrConstant ind_or_offs, Register val,
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   277
                                       Register tmp1, Register tmp2, Register tmp3, bool needs_frame) {
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   278
  bool on_array = (decorators & IN_HEAP_ARRAY) != 0;
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   279
  bool on_anonymous = (decorators & ON_UNKNOWN_OOP_REF) != 0;
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   280
  bool precise = on_array || on_anonymous;
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   281
  // Load and record the previous value.
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   282
  g1_write_barrier_pre(masm, decorators, base, ind_or_offs,
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   283
                       tmp1, tmp2, tmp3, needs_frame);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   284
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   285
  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
   286
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   287
  // No need for post barrier if storing NULL
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   288
  if (val != noreg) {
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   289
    if (precise) {
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   290
      if (ind_or_offs.is_constant()) {
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   291
        __ add_const_optimized(base, base, ind_or_offs.as_constant(), tmp1);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   292
      } else {
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   293
        __ add(base, ind_or_offs.as_register(), base);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   294
      }
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   295
    }
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   296
    g1_write_barrier_post(masm, decorators, base, val, tmp1, tmp2, tmp3);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   297
  }
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   298
}
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   299
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   300
void G1BarrierSetAssembler::load_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type,
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   301
                                    Register base, RegisterOrConstant ind_or_offs, Register dst,
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   302
                                    Register tmp1, Register tmp2, bool needs_frame, Label *is_null) {
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   303
  bool on_oop = type == T_OBJECT || type == T_ARRAY;
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   304
  bool on_weak = (decorators & ON_WEAK_OOP_REF) != 0;
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   305
  bool on_phantom = (decorators & ON_PHANTOM_OOP_REF) != 0;
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   306
  bool on_reference = on_weak || on_phantom;
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   307
  Label done;
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   308
  if (on_oop && on_reference && is_null == NULL) { is_null = &done; }
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   309
  // Load the value of the referent field.
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   310
  ModRefBarrierSetAssembler::load_at(masm, decorators, type, base, ind_or_offs, dst, tmp1, tmp2, needs_frame, is_null);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   311
  if (on_oop && on_reference) {
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   312
    // Generate the G1 pre-barrier code to log the value of
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   313
    // the referent field in an SATB buffer. Note with
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   314
    // these parameters the pre-barrier does not generate
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   315
    // the load of the previous value
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   316
    // We only reach here if value is not null.
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   317
    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
   318
                         tmp1, tmp2, needs_frame);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   319
  }
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   320
  __ bind(done);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   321
}
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   322
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   323
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
   324
  Label done, not_weak;
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   325
  __ cmpdi(CCR0, value, 0);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   326
  __ beq(CCR0, done);         // Use NULL as-is.
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   327
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   328
  __ clrrdi(tmp1, value, JNIHandles::weak_tag_size);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   329
  __ andi_(tmp2, value, JNIHandles::weak_tag_mask);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   330
  __ ld(value, 0, tmp1);      // Resolve (untagged) jobject.
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   331
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   332
  __ beq(CCR0, not_weak);     // Test for jweak tag.
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   333
  __ verify_oop(value);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   334
  g1_write_barrier_pre(masm, IN_ROOT | ON_PHANTOM_OOP_REF,
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   335
                       noreg, noreg, value,
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   336
                       tmp1, tmp2, needs_frame);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   337
  __ bind(not_weak);
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
  __ bind(done);
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   340
}
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   341
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
   342
#undef __