src/hotspot/cpu/arm/gc/g1/g1BarrierSetAssembler_arm.cpp
author eosterlund
Wed, 21 Mar 2018 14:38:32 +0100
changeset 49484 ee8fa73b90f9
child 49754 ee93c1087584
permissions -rw-r--r--
8198949: Modularize arraycopy stub routine GC barriers Reviewed-by: rkennke, pliden
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
49484
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
     1
/*
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
     2
 * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
     3
 * 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"
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    29
#include "gc/g1/g1CardTable.hpp"
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    30
#include "gc/g1/heapRegion.hpp"
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    31
#include "gc/shared/collectedHeap.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"
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    36
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    37
#define __ masm->
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    38
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    39
#ifdef PRODUCT
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    40
#define BLOCK_COMMENT(str) /* nothing */
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    41
#else
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    42
#define BLOCK_COMMENT(str) __ block_comment(str)
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    43
#endif
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
#define BIND(label) bind(label); BLOCK_COMMENT(#label ":")
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    46
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    47
void G1BarrierSetAssembler::gen_write_ref_array_pre_barrier(MacroAssembler* masm, DecoratorSet decorators,
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    48
                                                            Register addr, Register count, int callee_saved_regs) {
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    49
  bool dest_uninitialized = (decorators & AS_DEST_NOT_INITIALIZED) != 0;
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    50
  if (!dest_uninitialized) {
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    51
    assert( addr->encoding() < callee_saved_regs, "addr must be saved");
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    52
    assert(count->encoding() < callee_saved_regs, "count must be saved");
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    53
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    54
    BLOCK_COMMENT("PreBarrier");
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    55
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    56
#ifdef AARCH64
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    57
    callee_saved_regs = align_up(callee_saved_regs, 2);
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    58
    for (int i = 0; i < callee_saved_regs; i += 2) {
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    59
      __ raw_push(as_Register(i), as_Register(i+1));
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
#else
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    62
    RegisterSet saved_regs = RegisterSet(R0, as_Register(callee_saved_regs-1));
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    63
    __ push(saved_regs | R9ifScratched);
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    64
#endif // AARCH64
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
    if (addr != R0) {
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    67
      assert_different_registers(count, R0);
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    68
      __ mov(R0, addr);
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    69
    }
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    70
#ifdef AARCH64
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    71
    __ 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
    72
#else
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    73
    if (count != R1) {
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    74
      __ mov(R1, count);
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
#endif // AARCH64
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    77
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    78
    if (UseCompressedOops) {
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    79
      __ 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
    80
    } else {
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    81
      __ 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
    82
    }
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
#ifdef AARCH64
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    85
    for (int i = callee_saved_regs - 2; i >= 0; i -= 2) {
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    86
      __ raw_pop(as_Register(i), as_Register(i+1));
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
#else
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    89
    __ pop(saved_regs | R9ifScratched);
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    90
#endif // AARCH64
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    91
  }
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    92
}
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    93
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    94
void G1BarrierSetAssembler::gen_write_ref_array_post_barrier(MacroAssembler* masm, DecoratorSet decorators,
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    95
                                                             Register addr, Register count, Register tmp) {
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
  BLOCK_COMMENT("G1PostBarrier");
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    98
  if (addr != R0) {
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
    99
    assert_different_registers(count, R0);
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
   100
    __ mov(R0, addr);
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
#ifdef AARCH64
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
   103
  __ 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
   104
#else
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
   105
  if (count != R1) {
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
   106
    __ mov(R1, count);
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
#if R9_IS_SCRATCHED
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
   109
  // Safer to save R9 here since callers may have been written
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
   110
  // assuming R9 survives. This is suboptimal but is not in
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
   111
  // general worth optimizing for the few platforms where R9
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
   112
  // is scratched. Note that the optimization might not be to
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
   113
  // difficult for this particular call site.
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
   114
  __ push(R9);
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
   115
#endif // !R9_IS_SCRATCHED
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
   116
#endif // !AARCH64
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
   117
  __ call(CAST_FROM_FN_PTR(address, G1BarrierSet::write_ref_array_post_entry));
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
   118
#ifndef AARCH64
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
   119
#if R9_IS_SCRATCHED
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
diff changeset
   120
  __ pop(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
}