src/hotspot/cpu/arm/gc/g1/g1BarrierSetAssembler_arm.cpp
author shade
Tue, 01 May 2018 19:13:31 +0200
changeset 49938 2c2a722a2c0c
parent 49906 4bb58f644e4e
child 49950 7b916885654d
permissions -rw-r--r--
8202379: ARM32 is broken after JDK-8201543 (Modularize C1 GC barriers) Reviewed-by: aph, 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"
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    31
#include "gc/g1/heapRegion.hpp"
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    32
#include "interpreter/interp_masm.hpp"
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    33
#include "runtime/sharedRuntime.hpp"
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    34
#include "runtime/thread.hpp"
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    35
#include "utilities/macros.hpp"
49906
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
    36
#ifdef COMPILER1
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
    37
#include "c1/c1_LIRAssembler.hpp"
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
    38
#include "c1/c1_MacroAssembler.hpp"
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
    39
#include "gc/g1/c1/g1BarrierSetC1.hpp"
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
    40
#endif
49484
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    41
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    42
#define __ masm->
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    43
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    44
#ifdef PRODUCT
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    45
#define BLOCK_COMMENT(str) /* nothing */
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    46
#else
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    47
#define BLOCK_COMMENT(str) __ block_comment(str)
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    48
#endif
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
#define BIND(label) bind(label); BLOCK_COMMENT(#label ":")
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    51
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    52
void G1BarrierSetAssembler::gen_write_ref_array_pre_barrier(MacroAssembler* masm, DecoratorSet decorators,
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    53
                                                            Register addr, Register count, int callee_saved_regs) {
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    54
  bool dest_uninitialized = (decorators & AS_DEST_NOT_INITIALIZED) != 0;
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    55
  if (!dest_uninitialized) {
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    56
    assert( addr->encoding() < callee_saved_regs, "addr must be saved");
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    57
    assert(count->encoding() < callee_saved_regs, "count must be saved");
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    58
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    59
    BLOCK_COMMENT("PreBarrier");
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    60
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    61
#ifdef AARCH64
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    62
    callee_saved_regs = align_up(callee_saved_regs, 2);
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    63
    for (int i = 0; i < callee_saved_regs; i += 2) {
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    64
      __ raw_push(as_Register(i), as_Register(i+1));
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    65
    }
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    66
#else
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    67
    RegisterSet saved_regs = RegisterSet(R0, as_Register(callee_saved_regs-1));
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    68
    __ push(saved_regs | R9ifScratched);
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    69
#endif // AARCH64
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    70
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    71
    if (addr != R0) {
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    72
      assert_different_registers(count, R0);
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    73
      __ mov(R0, addr);
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
#ifdef AARCH64
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    76
    __ 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
    77
#else
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    78
    if (count != R1) {
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    79
      __ mov(R1, count);
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    80
    }
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    81
#endif // AARCH64
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    82
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    83
    if (UseCompressedOops) {
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    84
      __ 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
    85
    } else {
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    86
      __ 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
    87
    }
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
#ifdef AARCH64
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    90
    for (int i = callee_saved_regs - 2; i >= 0; i -= 2) {
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    91
      __ raw_pop(as_Register(i), as_Register(i+1));
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
#else
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    94
    __ pop(saved_regs | R9ifScratched);
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    95
#endif // AARCH64
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    96
  }
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
void G1BarrierSetAssembler::gen_write_ref_array_post_barrier(MacroAssembler* masm, DecoratorSet decorators,
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
   100
                                                             Register addr, Register count, Register tmp) {
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
   101
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
   102
  BLOCK_COMMENT("G1PostBarrier");
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
   103
  if (addr != R0) {
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
   104
    assert_different_registers(count, R0);
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
   105
    __ mov(R0, addr);
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
   106
  }
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
   107
#ifdef AARCH64
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
   108
  __ 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
   109
#else
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
   110
  if (count != R1) {
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
   111
    __ mov(R1, count);
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
   112
  }
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
   113
#if R9_IS_SCRATCHED
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
   114
  // Safer to save R9 here since callers may have been written
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
   115
  // assuming R9 survives. This is suboptimal but is not in
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
   116
  // general worth optimizing for the few platforms where R9
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
   117
  // is scratched. Note that the optimization might not be to
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
   118
  // difficult for this particular call site.
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
   119
  __ push(R9);
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
   120
#endif // !R9_IS_SCRATCHED
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
   121
#endif // !AARCH64
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
   122
  __ call(CAST_FROM_FN_PTR(address, G1BarrierSet::write_ref_array_post_entry));
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
   123
#ifndef AARCH64
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
   124
#if R9_IS_SCRATCHED
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
   125
  __ pop(R9);
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
   126
#endif // !R9_IS_SCRATCHED
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
   127
#endif // !AARCH64
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
   128
}
49906
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   129
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   130
#ifdef COMPILER1
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   131
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   132
#undef __
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   133
#define __ ce->masm()->
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   134
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   135
void G1BarrierSetAssembler::gen_pre_barrier_stub(LIR_Assembler* ce, G1PreBarrierStub* stub) {
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   136
  G1BarrierSetC1* bs = (G1BarrierSetC1*)BarrierSet::barrier_set()->barrier_set_c1();
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   137
  // At this point we know that marking is in progress.
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   138
  // If do_load() is true then we have to emit the
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   139
  // load of the previous value; otherwise it has already
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   140
  // been loaded into _pre_val.
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   141
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   142
  __ bind(*stub->entry());
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   143
  assert(stub->pre_val()->is_register(), "Precondition.");
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   144
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   145
  Register pre_val_reg = stub->pre_val()->as_register();
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   146
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   147
  if (stub->do_load()) {
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   148
    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
   149
  }
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   150
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   151
  __ cbz(pre_val_reg, *stub->continuation());
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   152
  ce->verify_reserved_argument_area_size(1);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   153
  __ str(pre_val_reg, Address(SP));
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   154
  __ 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
   155
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   156
  __ b(*stub->continuation());
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   157
}
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   158
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   159
void G1BarrierSetAssembler::gen_post_barrier_stub(LIR_Assembler* ce, G1PostBarrierStub* stub) {
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   160
  G1BarrierSetC1* bs = (G1BarrierSetC1*)BarrierSet::barrier_set()->barrier_set_c1();
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   161
  __ bind(*stub->entry());
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   162
  assert(stub->addr()->is_register(), "Precondition.");
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   163
  assert(stub->new_val()->is_register(), "Precondition.");
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   164
  Register new_val_reg = stub->new_val()->as_register();
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   165
  __ cbz(new_val_reg, *stub->continuation());
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   166
  ce->verify_reserved_argument_area_size(1);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   167
  __ str(stub->addr()->as_pointer_register(), Address(SP));
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   168
  __ 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
   169
  __ b(*stub->continuation());
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   170
}
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   171
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   172
#undef __
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   173
#define __ sasm->
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   174
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   175
void G1BarrierSetAssembler::generate_c1_pre_barrier_runtime_stub(StubAssembler* sasm) {
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   176
  // Input:
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   177
  // - pre_val pushed on the stack
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   178
49938
2c2a722a2c0c 8202379: ARM32 is broken after JDK-8201543 (Modularize C1 GC barriers)
shade
parents: 49906
diff changeset
   179
  __ set_info("g1_pre_barrier_slow_id", false);
49906
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   180
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   181
  // save at least the registers that need saving if the runtime is called
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   182
#ifdef AARCH64
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   183
  __ raw_push(R0, R1);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   184
  __ raw_push(R2, R3);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   185
  const int nb_saved_regs = 4;
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   186
#else // AARCH64
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   187
  const RegisterSet saved_regs = RegisterSet(R0,R3) | RegisterSet(R12) | RegisterSet(LR);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   188
  const int nb_saved_regs = 6;
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   189
  assert(nb_saved_regs == saved_regs.size(), "fix nb_saved_regs");
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   190
  __ push(saved_regs);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   191
#endif // AARCH64
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   192
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   193
  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
   194
  const Register r_index_1    = R1;
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   195
  const Register r_buffer_2   = R2;
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   196
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   197
  Address queue_active(Rthread, in_bytes(G1ThreadLocalData::satb_mark_queue_active_offset()));
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   198
  Address queue_index(Rthread, in_bytes(G1ThreadLocalData::satb_mark_queue_index_offset()));
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   199
  Address buffer(Rthread, in_bytes(G1ThreadLocalData::satb_mark_queue_buffer_offset()));
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   200
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   201
  Label done;
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   202
  Label runtime;
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   203
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   204
  // Is marking still active?
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   205
  assert(in_bytes(SATBMarkQueue::byte_width_of_active()) == 1, "Assumption");
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   206
  __ ldrb(R1, queue_active);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   207
  __ cbz(R1, done);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   208
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   209
  __ ldr(r_index_1, queue_index);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   210
  __ ldr(r_pre_val_0, Address(SP, nb_saved_regs*wordSize));
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   211
  __ ldr(r_buffer_2, buffer);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   212
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   213
  __ subs(r_index_1, r_index_1, wordSize);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   214
  __ b(runtime, lt);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   215
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   216
  __ str(r_index_1, queue_index);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   217
  __ str(r_pre_val_0, Address(r_buffer_2, r_index_1));
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   218
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   219
  __ bind(done);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   220
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   221
#ifdef AARCH64
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   222
  __ raw_pop(R2, R3);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   223
  __ raw_pop(R0, R1);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   224
#else // AARCH64
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   225
  __ pop(saved_regs);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   226
#endif // AARCH64
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   227
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   228
  __ ret();
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   229
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   230
  __ bind(runtime);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   231
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   232
  __ save_live_registers();
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   233
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   234
  assert(r_pre_val_0 == c_rarg0, "pre_val should be in R0");
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   235
  __ mov(c_rarg1, Rthread);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   236
  __ 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
   237
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   238
  __ restore_live_registers_without_return();
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   239
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   240
  __ b(done);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   241
}
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   242
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   243
void G1BarrierSetAssembler::generate_c1_post_barrier_runtime_stub(StubAssembler* sasm) {
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   244
  // Input:
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   245
  // - store_addr, pushed on the stack
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   246
49938
2c2a722a2c0c 8202379: ARM32 is broken after JDK-8201543 (Modularize C1 GC barriers)
shade
parents: 49906
diff changeset
   247
  __ set_info("g1_post_barrier_slow_id", false);
49906
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   248
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   249
  Label done;
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   250
  Label recheck;
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   251
  Label runtime;
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   252
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   253
  Address queue_index(Rthread, in_bytes(G1ThreadLocalData::dirty_card_queue_index_offset()));
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   254
  Address buffer(Rthread, in_bytes(G1ThreadLocalData::dirty_card_queue_buffer_offset()));
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   255
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   256
  AddressLiteral cardtable(ci_card_table_address_as<address>(), relocInfo::none);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   257
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   258
  // save at least the registers that need saving if the runtime is called
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   259
#ifdef AARCH64
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   260
  __ raw_push(R0, R1);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   261
  __ raw_push(R2, R3);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   262
  const int nb_saved_regs = 4;
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   263
#else // AARCH64
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   264
  const RegisterSet saved_regs = RegisterSet(R0,R3) | RegisterSet(R12) | RegisterSet(LR);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   265
  const int nb_saved_regs = 6;
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   266
  assert(nb_saved_regs == saved_regs.size(), "fix nb_saved_regs");
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   267
  __ push(saved_regs);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   268
#endif // AARCH64
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   269
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   270
  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
   271
  const Register r_obj_0 = R0;
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   272
  const Register r_card_base_1 = R1;
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   273
  const Register r_tmp2 = R2;
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   274
  const Register r_index_2 = R2;
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   275
  const Register r_buffer_3 = R3;
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   276
  const Register tmp1 = Rtemp;
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   277
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   278
  __ ldr(r_obj_0, Address(SP, nb_saved_regs*wordSize));
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   279
  // Note: there is a comment in x86 code about not using
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   280
  // ExternalAddress / lea, due to relocation not working
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   281
  // properly for that address. Should be OK for arm, where we
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   282
  // explicitly specify that 'cardtable' has a relocInfo::none
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   283
  // type.
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   284
  __ lea(r_card_base_1, cardtable);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   285
  __ 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
   286
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   287
  // first quick check without barrier
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   288
  __ ldrb(r_tmp2, Address(r_card_addr_0));
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   289
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   290
  __ cmp(r_tmp2, (int)G1CardTable::g1_young_card_val());
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   291
  __ b(recheck, ne);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   292
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   293
  __ bind(done);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   294
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   295
#ifdef AARCH64
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   296
  __ raw_pop(R2, R3);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   297
  __ raw_pop(R0, R1);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   298
#else // AARCH64
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   299
  __ pop(saved_regs);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   300
#endif // AARCH64
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   301
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   302
  __ ret();
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   303
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   304
  __ bind(recheck);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   305
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   306
  __ membar(MacroAssembler::Membar_mask_bits(MacroAssembler::StoreLoad), tmp1);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   307
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   308
  // reload card state after the barrier that ensures the stored oop was visible
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   309
  __ ldrb(r_tmp2, Address(r_card_addr_0));
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   310
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   311
  assert(CardTable::dirty_card_val() == 0, "adjust this code");
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   312
  __ cbz(r_tmp2, done);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   313
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   314
  // storing region crossing non-NULL, card is clean.
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   315
  // dirty card and log.
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   316
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   317
  assert(0 == (int)CardTable::dirty_card_val(), "adjust this code");
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   318
  if ((ci_card_table_address_as<intptr_t>() & 0xff) == 0) {
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   319
    // 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
   320
    __ strb(r_card_base_1, Address(r_card_addr_0));
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   321
  } else {
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   322
    __ strb(__ zero_register(r_tmp2), Address(r_card_addr_0));
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   323
  }
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   324
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   325
  __ ldr(r_index_2, queue_index);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   326
  __ ldr(r_buffer_3, buffer);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   327
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   328
  __ subs(r_index_2, r_index_2, wordSize);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   329
  __ b(runtime, lt); // go to runtime if now negative
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   330
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   331
  __ str(r_index_2, queue_index);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   332
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   333
  __ str(r_card_addr_0, Address(r_buffer_3, r_index_2));
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   334
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   335
  __ b(done);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   336
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   337
  __ bind(runtime);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   338
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   339
  __ save_live_registers();
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   340
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   341
  assert(r_card_addr_0 == c_rarg0, "card_addr should be in R0");
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   342
  __ mov(c_rarg1, Rthread);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   343
  __ 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
   344
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   345
  __ restore_live_registers_without_return();
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   346
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   347
  __ b(done);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   348
}
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   349
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   350
#undef __
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   351
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49754
diff changeset
   352
#endif // COMPILER1