src/hotspot/cpu/arm/gc/g1/g1BarrierSetAssembler_arm.cpp
author shade
Wed, 02 May 2018 19:26:42 +0200
changeset 49950 7b916885654d
parent 49938 2c2a722a2c0c
child 50375 bfbe7d8369bb
permissions -rw-r--r--
8201786: Modularize interpreter GC barriers: leftovers for ARM32 Reviewed-by: enevill, eosterlund
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
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
     4
 *
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
     5
 * 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
     6
 * 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
     7
 * published by the Free Software Foundation.
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
     8
 *
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
     9
 * 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
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    12
 * 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
    13
 * accompanied this code).
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    14
 *
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    15
 * 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
    16
 * 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
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    18
 *
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    20
 * 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
    21
 * questions.
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    22
 *
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
#include "precompiled.hpp"
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    26
#include "asm/macroAssembler.inline.hpp"
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    27
#include "gc/g1/g1BarrierSet.hpp"
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    28
#include "gc/g1/g1BarrierSetAssembler.hpp"
49938
2c2a722a2c0c 8202379: ARM32 is broken after JDK-8201543 (Modularize C1 GC barriers)
shade
parents: 49906
diff changeset
    29
#include "gc/g1/g1ThreadLocalData.hpp"
49484
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    30
#include "gc/g1/g1CardTable.hpp"
49950
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
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"
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    34
#include "runtime/sharedRuntime.hpp"
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    35
#include "runtime/thread.hpp"
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    36
#include "utilities/macros.hpp"
49906
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
    37
#ifdef COMPILER1
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
    38
#include "c1/c1_LIRAssembler.hpp"
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
    39
#include "c1/c1_MacroAssembler.hpp"
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
    40
#include "gc/g1/c1/g1BarrierSetC1.hpp"
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
    41
#endif
49484
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
#define __ masm->
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    44
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    45
#ifdef PRODUCT
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    46
#define BLOCK_COMMENT(str) /* nothing */
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    47
#else
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    48
#define BLOCK_COMMENT(str) __ block_comment(str)
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    49
#endif
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    50
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    51
#define BIND(label) bind(label); BLOCK_COMMENT(#label ":")
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    52
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    53
void G1BarrierSetAssembler::gen_write_ref_array_pre_barrier(MacroAssembler* masm, DecoratorSet decorators,
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    54
                                                            Register addr, Register count, int callee_saved_regs) {
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    55
  bool dest_uninitialized = (decorators & AS_DEST_NOT_INITIALIZED) != 0;
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    56
  if (!dest_uninitialized) {
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    57
    assert( addr->encoding() < callee_saved_regs, "addr must be saved");
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    58
    assert(count->encoding() < callee_saved_regs, "count must be saved");
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
    BLOCK_COMMENT("PreBarrier");
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
#ifdef AARCH64
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    63
    callee_saved_regs = align_up(callee_saved_regs, 2);
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    64
    for (int i = 0; i < callee_saved_regs; i += 2) {
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    65
      __ raw_push(as_Register(i), as_Register(i+1));
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    66
    }
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    67
#else
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    68
    RegisterSet saved_regs = RegisterSet(R0, as_Register(callee_saved_regs-1));
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    69
    __ push(saved_regs | R9ifScratched);
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    70
#endif // AARCH64
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    71
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    72
    if (addr != R0) {
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    73
      assert_different_registers(count, R0);
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    74
      __ mov(R0, addr);
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    75
    }
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    76
#ifdef AARCH64
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    77
    __ zero_extend(R1, count, 32); // G1BarrierSet::write_ref_array_pre_*_entry takes size_t
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    78
#else
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    79
    if (count != R1) {
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    80
      __ mov(R1, count);
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    81
    }
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    82
#endif // AARCH64
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
    if (UseCompressedOops) {
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    85
      __ call(CAST_FROM_FN_PTR(address, G1BarrierSet::write_ref_array_pre_narrow_oop_entry));
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    86
    } else {
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    87
      __ call(CAST_FROM_FN_PTR(address, G1BarrierSet::write_ref_array_pre_oop_entry));
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
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    90
#ifdef AARCH64
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    91
    for (int i = callee_saved_regs - 2; i >= 0; i -= 2) {
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    92
      __ raw_pop(as_Register(i), as_Register(i+1));
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    93
    }
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    94
#else
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    95
    __ pop(saved_regs | R9ifScratched);
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    96
#endif // AARCH64
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
}
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    99
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
   100
void G1BarrierSetAssembler::gen_write_ref_array_post_barrier(MacroAssembler* masm, DecoratorSet decorators,
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
   101
                                                             Register addr, Register count, Register tmp) {
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
   102
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
   103
  BLOCK_COMMENT("G1PostBarrier");
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
   104
  if (addr != R0) {
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
   105
    assert_different_registers(count, R0);
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
   106
    __ mov(R0, addr);
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
   107
  }
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
   108
#ifdef AARCH64
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
   109
  __ zero_extend(R1, count, 32); // G1BarrierSet::write_ref_array_post_entry takes size_t
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
   110
#else
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
   111
  if (count != R1) {
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
   112
    __ mov(R1, count);
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
   113
  }
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
   114
#if R9_IS_SCRATCHED
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
   115
  // Safer to save R9 here since callers may have been written
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
   116
  // assuming R9 survives. This is suboptimal but is not in
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
   117
  // general worth optimizing for the few platforms where R9
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
   118
  // is scratched. Note that the optimization might not be to
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
   119
  // difficult for this particular call site.
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
   120
  __ push(R9);
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
   121
#endif // !R9_IS_SCRATCHED
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
   122
#endif // !AARCH64
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
   123
  __ call(CAST_FROM_FN_PTR(address, G1BarrierSet::write_ref_array_post_entry));
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
   124
#ifndef AARCH64
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
   125
#if R9_IS_SCRATCHED
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
   126
  __ pop(R9);
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
   127
#endif // !R9_IS_SCRATCHED
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
   128
#endif // !AARCH64
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
   129
}
49906
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   130
49950
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   131
// G1 pre-barrier.
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   132
// Blows all volatile registers (R0-R3 on 32-bit ARM, R0-R18 on AArch64, Rtemp, LR).
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   133
// If store_addr != noreg, then previous value is loaded from [store_addr];
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   134
// in such case store_addr and new_val registers are preserved;
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   135
// otherwise pre_val register is preserved.
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   136
void G1BarrierSetAssembler::g1_write_barrier_pre(MacroAssembler* masm,
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   137
                                          Register store_addr,
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   138
                                          Register new_val,
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   139
                                          Register pre_val,
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   140
                                          Register tmp1,
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   141
                                          Register tmp2) {
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   142
  Label done;
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   143
  Label runtime;
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   144
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   145
  if (store_addr != noreg) {
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   146
    assert_different_registers(store_addr, new_val, pre_val, tmp1, tmp2, noreg);
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   147
  } else {
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   148
    assert (new_val == noreg, "should be");
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   149
    assert_different_registers(pre_val, tmp1, tmp2, noreg);
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   150
  }
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   151
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   152
  Address in_progress(Rthread, in_bytes(G1ThreadLocalData::satb_mark_queue_active_offset()));
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   153
  Address index(Rthread, in_bytes(G1ThreadLocalData::satb_mark_queue_index_offset()));
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   154
  Address buffer(Rthread, in_bytes(G1ThreadLocalData::satb_mark_queue_buffer_offset()));
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   155
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   156
  // Is marking active?
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   157
  assert(in_bytes(SATBMarkQueue::byte_width_of_active()) == 1, "adjust this code");
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   158
  __ ldrb(tmp1, in_progress);
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   159
  __ cbz(tmp1, done);
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   160
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   161
  // Do we need to load the previous value?
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   162
  if (store_addr != noreg) {
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   163
    __ load_heap_oop(pre_val, Address(store_addr, 0));
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   164
  }
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   165
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   166
  // Is the previous value null?
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   167
  __ cbz(pre_val, done);
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   168
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   169
  // Can we store original value in the thread's buffer?
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   170
  // Is index == 0?
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   171
  // (The index field is typed as size_t.)
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   172
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   173
  __ ldr(tmp1, index);           // tmp1 := *index_adr
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   174
  __ ldr(tmp2, buffer);
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   175
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   176
  __ subs(tmp1, tmp1, wordSize); // tmp1 := tmp1 - wordSize
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   177
  __ b(runtime, lt);             // If negative, goto runtime
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   178
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   179
  __ str(tmp1, index);           // *index_adr := tmp1
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   180
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   181
  // Record the previous value
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   182
  __ str(pre_val, Address(tmp2, tmp1));
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   183
  __ b(done);
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   184
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   185
  __ bind(runtime);
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   186
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   187
  // save the live input values
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   188
#ifdef AARCH64
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   189
  if (store_addr != noreg) {
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   190
    __ raw_push(store_addr, new_val);
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   191
  } else {
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   192
    __ raw_push(pre_val, ZR);
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   193
  }
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   194
#else
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   195
  if (store_addr != noreg) {
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   196
    // avoid raw_push to support any ordering of store_addr and new_val
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   197
    __ push(RegisterSet(store_addr) | RegisterSet(new_val));
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   198
  } else {
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   199
    __ push(pre_val);
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   200
  }
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   201
#endif // AARCH64
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   202
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   203
  if (pre_val != R0) {
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   204
    __ mov(R0, pre_val);
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   205
  }
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   206
  __ mov(R1, Rthread);
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   207
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   208
  __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::g1_wb_pre), R0, R1);
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   209
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   210
#ifdef AARCH64
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   211
  if (store_addr != noreg) {
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   212
    __ raw_pop(store_addr, new_val);
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   213
  } else {
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   214
    __ raw_pop(pre_val, ZR);
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   215
  }
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   216
#else
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   217
  if (store_addr != noreg) {
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   218
    __ pop(RegisterSet(store_addr) | RegisterSet(new_val));
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   219
  } else {
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   220
    __ pop(pre_val);
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   221
  }
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   222
#endif // AARCH64
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   223
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   224
  __ bind(done);
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   225
}
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   226
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   227
// G1 post-barrier.
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   228
// Blows all volatile registers (R0-R3 on 32-bit ARM, R0-R18 on AArch64, Rtemp, LR).
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   229
void G1BarrierSetAssembler::g1_write_barrier_post(MacroAssembler* masm,
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   230
                                           Register store_addr,
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   231
                                           Register new_val,
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   232
                                           Register tmp1,
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   233
                                           Register tmp2,
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   234
                                           Register tmp3) {
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   235
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   236
  Address queue_index(Rthread, in_bytes(G1ThreadLocalData::dirty_card_queue_index_offset()));
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   237
  Address buffer(Rthread, in_bytes(G1ThreadLocalData::dirty_card_queue_buffer_offset()));
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   238
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   239
  BarrierSet* bs = BarrierSet::barrier_set();
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   240
  CardTableBarrierSet* ctbs = barrier_set_cast<CardTableBarrierSet>(bs);
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   241
  CardTable* ct = ctbs->card_table();
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   242
  Label done;
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   243
  Label runtime;
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   244
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   245
  // Does store cross heap regions?
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   246
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   247
  __ eor(tmp1, store_addr, new_val);
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   248
#ifdef AARCH64
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   249
  __ logical_shift_right(tmp1, tmp1, HeapRegion::LogOfHRGrainBytes);
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   250
  __ cbz(tmp1, done);
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   251
#else
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   252
  __ movs(tmp1, AsmOperand(tmp1, lsr, HeapRegion::LogOfHRGrainBytes));
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   253
  __ b(done, eq);
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   254
#endif
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   255
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   256
  // crosses regions, storing NULL?
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   257
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   258
  __ cbz(new_val, done);
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   259
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   260
  // storing region crossing non-NULL, is card already dirty?
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   261
  const Register card_addr = tmp1;
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   262
  assert(sizeof(*ct->byte_map_base()) == sizeof(jbyte), "adjust this code");
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   263
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   264
  __ mov_address(tmp2, (address)ct->byte_map_base(), symbolic_Relocation::card_table_reference);
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   265
  __ add(card_addr, tmp2, AsmOperand(store_addr, lsr, CardTable::card_shift));
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   266
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   267
  __ ldrb(tmp2, Address(card_addr));
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   268
  __ cmp(tmp2, (int)G1CardTable::g1_young_card_val());
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   269
  __ b(done, eq);
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   270
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   271
  __ membar(MacroAssembler::Membar_mask_bits(MacroAssembler::StoreLoad), tmp2);
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   272
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   273
  assert(CardTable::dirty_card_val() == 0, "adjust this code");
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   274
  __ ldrb(tmp2, Address(card_addr));
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   275
  __ cbz(tmp2, done);
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   276
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   277
  // storing a region crossing, non-NULL oop, card is clean.
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   278
  // dirty card and log.
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   279
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   280
  __ strb(__ zero_register(tmp2), Address(card_addr));
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   281
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   282
  __ ldr(tmp2, queue_index);
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   283
  __ ldr(tmp3, buffer);
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   284
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   285
  __ subs(tmp2, tmp2, wordSize);
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   286
  __ b(runtime, lt); // go to runtime if now negative
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   287
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   288
  __ str(tmp2, queue_index);
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   289
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   290
  __ str(card_addr, Address(tmp3, tmp2));
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   291
  __ b(done);
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   292
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   293
  __ bind(runtime);
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   294
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   295
  if (card_addr != R0) {
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   296
    __ mov(R0, card_addr);
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   297
  }
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   298
  __ mov(R1, Rthread);
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   299
  __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::g1_wb_post), R0, R1);
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   300
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   301
  __ bind(done);
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   302
}
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   303
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   304
void G1BarrierSetAssembler::load_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type,
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   305
                                    Register dst, Address src, Register tmp1, Register tmp2, Register tmp3) {
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   306
  bool on_oop = type == T_OBJECT || type == T_ARRAY;
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   307
  bool on_weak = (decorators & ON_WEAK_OOP_REF) != 0;
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   308
  bool on_phantom = (decorators & ON_PHANTOM_OOP_REF) != 0;
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   309
  bool on_reference = on_weak || on_phantom;
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   310
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   311
  ModRefBarrierSetAssembler::load_at(masm, decorators, type, dst, src, tmp1, tmp2, tmp3);
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   312
  if (on_oop && on_reference) {
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   313
    // Generate the G1 pre-barrier code to log the value of
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   314
    // the referent field in an SATB buffer.
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   315
    g1_write_barrier_pre(masm, noreg, noreg, dst, tmp1, tmp2);
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   316
  }
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   317
}
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   318
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   319
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   320
void G1BarrierSetAssembler::oop_store_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type,
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   321
                                         Address obj, Register new_val, Register tmp1, Register tmp2, Register tmp3, bool is_null) {
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   322
  bool in_heap = (decorators & IN_HEAP) != 0;
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   323
  bool in_concurrent_root = (decorators & IN_CONCURRENT_ROOT) != 0;
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   324
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   325
  bool needs_pre_barrier = in_heap || in_concurrent_root;
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   326
  bool needs_post_barrier = (new_val != noreg) && in_heap;
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   327
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   328
  // flatten object address if needed
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   329
  assert (obj.mode() == basic_offset, "pre- or post-indexing is not supported here");
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   330
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   331
  const Register store_addr = obj.base();
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   332
  if (obj.index() != noreg) {
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   333
    assert (obj.disp() == 0, "index or displacement, not both");
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   334
#ifdef AARCH64
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   335
    __ add(store_addr, obj.base(), obj.index(), obj.extend(), obj.shift_imm());
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   336
#else
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   337
    assert(obj.offset_op() == add_offset, "addition is expected");
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   338
    __ add(store_addr, obj.base(), AsmOperand(obj.index(), obj.shift(), obj.shift_imm()));
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   339
#endif // AARCH64
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   340
  } else if (obj.disp() != 0) {
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   341
    __ add(store_addr, obj.base(), obj.disp());
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   342
  }
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   343
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   344
  if (needs_pre_barrier) {
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   345
    g1_write_barrier_pre(masm, store_addr, new_val, tmp1, tmp2, tmp3);
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   346
  }
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   347
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   348
  if (is_null) {
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   349
    BarrierSetAssembler::store_at(masm, decorators, type, Address(store_addr), new_val, tmp1, tmp2, tmp3, true);
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   350
  } else {
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   351
    // G1 barrier needs uncompressed oop for region cross check.
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   352
    Register val_to_store = new_val;
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   353
    if (UseCompressedOops) {
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   354
      val_to_store = tmp1;
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   355
      __ mov(val_to_store, new_val);
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   356
    }
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   357
    BarrierSetAssembler::store_at(masm, decorators, type, Address(store_addr), val_to_store, tmp1, tmp2, tmp3, false);
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   358
    if (needs_post_barrier) {
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   359
      g1_write_barrier_post(masm, store_addr, new_val, tmp1, tmp2, tmp3);
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   360
    }
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   361
  }
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   362
};
7b916885654d 8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents: 49938
diff changeset
   363
49906
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   364
#ifdef COMPILER1
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   365
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   366
#undef __
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   367
#define __ ce->masm()->
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   368
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   369
void G1BarrierSetAssembler::gen_pre_barrier_stub(LIR_Assembler* ce, G1PreBarrierStub* stub) {
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   370
  G1BarrierSetC1* bs = (G1BarrierSetC1*)BarrierSet::barrier_set()->barrier_set_c1();
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   371
  // At this point we know that marking is in progress.
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   372
  // If do_load() is true then we have to emit the
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   373
  // load of the previous value; otherwise it has already
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   374
  // been loaded into _pre_val.
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   375
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   376
  __ bind(*stub->entry());
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   377
  assert(stub->pre_val()->is_register(), "Precondition.");
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   378
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   379
  Register pre_val_reg = stub->pre_val()->as_register();
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   380
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   381
  if (stub->do_load()) {
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   382
    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
   383
  }
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   384
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   385
  __ cbz(pre_val_reg, *stub->continuation());
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   386
  ce->verify_reserved_argument_area_size(1);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   387
  __ str(pre_val_reg, Address(SP));
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   388
  __ call(bs->pre_barrier_c1_runtime_code_blob()->code_begin(), relocInfo::runtime_call_type);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   389
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   390
  __ b(*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
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   393
void G1BarrierSetAssembler::gen_post_barrier_stub(LIR_Assembler* ce, G1PostBarrierStub* stub) {
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   394
  G1BarrierSetC1* bs = (G1BarrierSetC1*)BarrierSet::barrier_set()->barrier_set_c1();
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   395
  __ bind(*stub->entry());
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   396
  assert(stub->addr()->is_register(), "Precondition.");
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   397
  assert(stub->new_val()->is_register(), "Precondition.");
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   398
  Register new_val_reg = stub->new_val()->as_register();
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   399
  __ cbz(new_val_reg, *stub->continuation());
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   400
  ce->verify_reserved_argument_area_size(1);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   401
  __ str(stub->addr()->as_pointer_register(), Address(SP));
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   402
  __ call(bs->post_barrier_c1_runtime_code_blob()->code_begin(), relocInfo::runtime_call_type);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   403
  __ b(*stub->continuation());
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   404
}
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   405
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   406
#undef __
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   407
#define __ sasm->
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   408
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   409
void G1BarrierSetAssembler::generate_c1_pre_barrier_runtime_stub(StubAssembler* sasm) {
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   410
  // Input:
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   411
  // - pre_val pushed on the stack
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   412
49938
2c2a722a2c0c 8202379: ARM32 is broken after JDK-8201543 (Modularize C1 GC barriers)
shade
parents: 49906
diff changeset
   413
  __ set_info("g1_pre_barrier_slow_id", false);
49906
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   414
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   415
  // save at least the registers that need saving if the runtime is called
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   416
#ifdef AARCH64
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   417
  __ raw_push(R0, R1);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   418
  __ raw_push(R2, R3);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   419
  const int nb_saved_regs = 4;
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   420
#else // AARCH64
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   421
  const RegisterSet saved_regs = RegisterSet(R0,R3) | RegisterSet(R12) | RegisterSet(LR);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   422
  const int nb_saved_regs = 6;
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   423
  assert(nb_saved_regs == saved_regs.size(), "fix nb_saved_regs");
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   424
  __ push(saved_regs);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   425
#endif // AARCH64
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   426
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   427
  const Register r_pre_val_0  = R0; // must be R0, to be ready for the runtime call
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   428
  const Register r_index_1    = R1;
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   429
  const Register r_buffer_2   = R2;
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   430
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   431
  Address queue_active(Rthread, in_bytes(G1ThreadLocalData::satb_mark_queue_active_offset()));
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   432
  Address queue_index(Rthread, in_bytes(G1ThreadLocalData::satb_mark_queue_index_offset()));
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   433
  Address buffer(Rthread, in_bytes(G1ThreadLocalData::satb_mark_queue_buffer_offset()));
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   434
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   435
  Label done;
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   436
  Label runtime;
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   437
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   438
  // Is marking still active?
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   439
  assert(in_bytes(SATBMarkQueue::byte_width_of_active()) == 1, "Assumption");
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   440
  __ ldrb(R1, queue_active);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   441
  __ cbz(R1, done);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   442
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   443
  __ ldr(r_index_1, queue_index);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   444
  __ ldr(r_pre_val_0, Address(SP, nb_saved_regs*wordSize));
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   445
  __ ldr(r_buffer_2, buffer);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   446
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   447
  __ subs(r_index_1, r_index_1, wordSize);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   448
  __ b(runtime, lt);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   449
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   450
  __ str(r_index_1, queue_index);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   451
  __ str(r_pre_val_0, Address(r_buffer_2, r_index_1));
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   452
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   453
  __ bind(done);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   454
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   455
#ifdef AARCH64
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   456
  __ raw_pop(R2, R3);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   457
  __ raw_pop(R0, R1);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   458
#else // AARCH64
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   459
  __ pop(saved_regs);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   460
#endif // AARCH64
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   461
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   462
  __ ret();
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   463
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   464
  __ bind(runtime);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   465
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   466
  __ save_live_registers();
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   467
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   468
  assert(r_pre_val_0 == c_rarg0, "pre_val should be in R0");
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   469
  __ mov(c_rarg1, Rthread);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   470
  __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::g1_wb_pre), c_rarg0, c_rarg1);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   471
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   472
  __ restore_live_registers_without_return();
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   473
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   474
  __ b(done);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   475
}
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   476
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   477
void G1BarrierSetAssembler::generate_c1_post_barrier_runtime_stub(StubAssembler* sasm) {
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   478
  // Input:
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   479
  // - store_addr, pushed on the stack
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   480
49938
2c2a722a2c0c 8202379: ARM32 is broken after JDK-8201543 (Modularize C1 GC barriers)
shade
parents: 49906
diff changeset
   481
  __ set_info("g1_post_barrier_slow_id", false);
49906
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   482
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   483
  Label done;
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   484
  Label recheck;
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   485
  Label runtime;
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   486
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   487
  Address queue_index(Rthread, in_bytes(G1ThreadLocalData::dirty_card_queue_index_offset()));
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   488
  Address buffer(Rthread, in_bytes(G1ThreadLocalData::dirty_card_queue_buffer_offset()));
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   489
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   490
  AddressLiteral cardtable(ci_card_table_address_as<address>(), relocInfo::none);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   491
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   492
  // save at least the registers that need saving if the runtime is called
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   493
#ifdef AARCH64
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   494
  __ raw_push(R0, R1);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   495
  __ raw_push(R2, R3);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   496
  const int nb_saved_regs = 4;
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   497
#else // AARCH64
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   498
  const RegisterSet saved_regs = RegisterSet(R0,R3) | RegisterSet(R12) | RegisterSet(LR);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   499
  const int nb_saved_regs = 6;
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   500
  assert(nb_saved_regs == saved_regs.size(), "fix nb_saved_regs");
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   501
  __ push(saved_regs);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   502
#endif // AARCH64
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   503
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   504
  const Register r_card_addr_0 = R0; // must be R0 for the slow case
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   505
  const Register r_obj_0 = R0;
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   506
  const Register r_card_base_1 = R1;
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   507
  const Register r_tmp2 = R2;
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   508
  const Register r_index_2 = R2;
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   509
  const Register r_buffer_3 = R3;
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   510
  const Register tmp1 = Rtemp;
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   511
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   512
  __ ldr(r_obj_0, Address(SP, nb_saved_regs*wordSize));
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   513
  // Note: there is a comment in x86 code about not using
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   514
  // ExternalAddress / lea, due to relocation not working
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   515
  // properly for that address. Should be OK for arm, where we
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   516
  // explicitly specify that 'cardtable' has a relocInfo::none
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   517
  // type.
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   518
  __ lea(r_card_base_1, cardtable);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   519
  __ add(r_card_addr_0, r_card_base_1, AsmOperand(r_obj_0, lsr, CardTable::card_shift));
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   520
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   521
  // first quick check without barrier
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   522
  __ ldrb(r_tmp2, Address(r_card_addr_0));
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   523
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   524
  __ cmp(r_tmp2, (int)G1CardTable::g1_young_card_val());
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   525
  __ b(recheck, ne);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   526
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   527
  __ bind(done);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   528
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   529
#ifdef AARCH64
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   530
  __ raw_pop(R2, R3);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   531
  __ raw_pop(R0, R1);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   532
#else // AARCH64
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   533
  __ pop(saved_regs);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   534
#endif // AARCH64
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   535
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   536
  __ ret();
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   537
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   538
  __ bind(recheck);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   539
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   540
  __ membar(MacroAssembler::Membar_mask_bits(MacroAssembler::StoreLoad), tmp1);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   541
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   542
  // reload card state after the barrier that ensures the stored oop was visible
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   543
  __ ldrb(r_tmp2, Address(r_card_addr_0));
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   544
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   545
  assert(CardTable::dirty_card_val() == 0, "adjust this code");
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   546
  __ cbz(r_tmp2, done);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   547
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   548
  // storing region crossing non-NULL, card is clean.
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   549
  // dirty card and log.
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   550
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   551
  assert(0 == (int)CardTable::dirty_card_val(), "adjust this code");
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   552
  if ((ci_card_table_address_as<intptr_t>() & 0xff) == 0) {
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   553
    // Card table is aligned so the lowest byte of the table address base is zero.
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   554
    __ strb(r_card_base_1, Address(r_card_addr_0));
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   555
  } else {
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   556
    __ strb(__ zero_register(r_tmp2), Address(r_card_addr_0));
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   557
  }
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   558
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   559
  __ ldr(r_index_2, queue_index);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   560
  __ ldr(r_buffer_3, buffer);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   561
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   562
  __ subs(r_index_2, r_index_2, wordSize);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   563
  __ b(runtime, lt); // go to runtime if now negative
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   564
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   565
  __ str(r_index_2, queue_index);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   566
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   567
  __ str(r_card_addr_0, Address(r_buffer_3, r_index_2));
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   568
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   569
  __ b(done);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   570
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   571
  __ bind(runtime);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   572
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   573
  __ save_live_registers();
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   574
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   575
  assert(r_card_addr_0 == c_rarg0, "card_addr should be in R0");
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   576
  __ mov(c_rarg1, Rthread);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   577
  __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::g1_wb_post), c_rarg0, c_rarg1);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   578
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   579
  __ restore_live_registers_without_return();
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   580
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   581
  __ b(done);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   582
}
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   583
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   584
#undef __
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   585
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   586
#endif // COMPILER1