src/hotspot/cpu/s390/gc/shared/cardTableBarrierSetAssembler_s390.cpp
changeset 49484 ee8fa73b90f9
child 49748 6a880e576856
equal deleted inserted replaced
49483:d374b1634589 49484:ee8fa73b90f9
       
     1 /*
       
     2  * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
       
     3  * Copyright (c) 2018, SAP SE. All rights reserved.
       
     4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       
     5  *
       
     6  * This code is free software; you can redistribute it and/or modify it
       
     7  * under the terms of the GNU General Public License version 2 only, as
       
     8  * published by the Free Software Foundation.
       
     9  *
       
    10  * This code is distributed in the hope that it will be useful, but WITHOUT
       
    11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
       
    12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
       
    13  * version 2 for more details (a copy is included in the LICENSE file that
       
    14  * accompanied this code).
       
    15  *
       
    16  * You should have received a copy of the GNU General Public License version
       
    17  * 2 along with this work; if not, write to the Free Software Foundation,
       
    18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
       
    19  *
       
    20  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
       
    21  * or visit www.oracle.com if you need additional information or have any
       
    22  * questions.
       
    23  *
       
    24  */
       
    25 
       
    26 #include "precompiled.hpp"
       
    27 #include "asm/macroAssembler.inline.hpp"
       
    28 #include "gc/shared/barrierSet.hpp"
       
    29 #include "gc/shared/cardTable.hpp"
       
    30 #include "gc/shared/cardTableBarrierSet.hpp"
       
    31 #include "gc/shared/cardTableBarrierSetAssembler.hpp"
       
    32 #include "gc/shared/collectedHeap.hpp"
       
    33 #include "interpreter/interp_masm.hpp"
       
    34 
       
    35 #define __ masm->
       
    36 
       
    37 #ifdef PRODUCT
       
    38 #define BLOCK_COMMENT(str) /* nothing */
       
    39 #else
       
    40 #define BLOCK_COMMENT(str) __ block_comment(str)
       
    41 #endif
       
    42 
       
    43 #define BIND(label) bind(label); BLOCK_COMMENT(#label ":")
       
    44 
       
    45 #define TIMES_OOP (UseCompressedOops ? Address::times_4 : Address::times_8)
       
    46 
       
    47 void CardTableBarrierSetAssembler::gen_write_ref_array_post_barrier(MacroAssembler* masm, DecoratorSet decorators, Register addr, Register count,
       
    48                                                                     bool do_return) {
       
    49   CardTableBarrierSet* ctbs = barrier_set_cast<CardTableBarrierSet>(Universe::heap()->barrier_set());
       
    50   CardTable* ct = ctbs->card_table();
       
    51   assert(sizeof(*ct->byte_map_base()) == sizeof(jbyte), "adjust this code");
       
    52 
       
    53   NearLabel doXC, done;
       
    54   assert_different_registers(Z_R0, Z_R1, addr, count);
       
    55 
       
    56   // Nothing to do if count <= 0.
       
    57   if (!do_return) {
       
    58     __ compare64_and_branch(count, (intptr_t) 0, Assembler::bcondNotHigh, done);
       
    59   } else {
       
    60     __ z_ltgr(count, count);
       
    61     __ z_bcr(Assembler::bcondNotPositive, Z_R14);
       
    62   }
       
    63 
       
    64   // Note: We can't combine the shifts. We could lose a carry
       
    65   // from calculating the array end address.
       
    66   // count = (count-1)*BytesPerHeapOop + addr
       
    67   // Count holds addr of last oop in array then.
       
    68   __ z_sllg(count, count, LogBytesPerHeapOop);
       
    69   __ add2reg_with_index(count, -BytesPerHeapOop, count, addr);
       
    70 
       
    71   // Get base address of card table.
       
    72   __ load_const_optimized(Z_R1, (address)ct->byte_map_base());
       
    73 
       
    74   // count = (count>>shift) - (addr>>shift)
       
    75   __ z_srlg(addr,  addr,  CardTable::card_shift);
       
    76   __ z_srlg(count, count, CardTable::card_shift);
       
    77 
       
    78   // Prefetch first elements of card table for update.
       
    79   if (VM_Version::has_Prefetch()) {
       
    80     __ z_pfd(0x02, 0, addr, Z_R1);
       
    81   }
       
    82 
       
    83   // Special case: clear just one byte.
       
    84   __ clear_reg(Z_R0, true, false);  // Used for doOneByte.
       
    85   __ z_sgr(count, addr);            // Count = n-1 now, CC used for brc below.
       
    86   __ z_stc(Z_R0, 0, addr, Z_R1);    // Must preserve CC from z_sgr.
       
    87   if (!do_return) {
       
    88     __ z_brz(done);
       
    89   } else {
       
    90     __ z_bcr(Assembler::bcondZero, Z_R14);
       
    91   }
       
    92 
       
    93   __ z_cghi(count, 255);
       
    94   __ z_brnh(doXC);
       
    95 
       
    96   // MVCLE: clear a long area.
       
    97   // Start addr of card table range = base + addr.
       
    98   // # bytes in    card table range = (count + 1)
       
    99   __ add2reg_with_index(Z_R0, 0, Z_R1, addr);
       
   100   __ add2reg(Z_R1, 1, count);
       
   101 
       
   102   // dirty hack:
       
   103   // There are just two callers. Both pass
       
   104   // count in Z_ARG3 = Z_R4
       
   105   // addr  in Z_ARG2 = Z_R3
       
   106   // ==> use Z_ARG2 as src len reg = 0
       
   107   //         Z_ARG1 as src addr (ignored)
       
   108   assert(count == Z_ARG3, "count: unexpected register number");
       
   109   assert(addr  == Z_ARG2, "addr:  unexpected register number");
       
   110   __ clear_reg(Z_ARG2, true, false);
       
   111 
       
   112   __ MacroAssembler::move_long_ext(Z_R0, Z_ARG1, 0);
       
   113 
       
   114   if (!do_return) {
       
   115     __ z_bru(done);
       
   116   } else {
       
   117     __ z_bcr(Assembler::bcondAlways, Z_R14);
       
   118   }
       
   119 
       
   120   // XC: clear a short area.
       
   121   Label XC_template; // Instr template, never exec directly!
       
   122   __ bind(XC_template);
       
   123   __ z_xc(0, 0, addr, 0, addr);
       
   124 
       
   125   __ bind(doXC);
       
   126   // start addr of card table range = base + addr
       
   127   // end   addr of card table range = base + addr + count
       
   128   __ add2reg_with_index(addr, 0, Z_R1, addr);
       
   129 
       
   130   if (VM_Version::has_ExecuteExtensions()) {
       
   131     __ z_exrl(count, XC_template);   // Execute XC with var. len.
       
   132   } else {
       
   133     __ z_larl(Z_R1, XC_template);
       
   134     __ z_ex(count, 0, Z_R0, Z_R1);   // Execute XC with var. len.
       
   135   }
       
   136   if (do_return) {
       
   137     __ z_br(Z_R14);
       
   138   }
       
   139 
       
   140   __ bind(done);
       
   141 }