src/hotspot/cpu/s390/gc/shared/barrierSetAssembler_s390.cpp
changeset 49748 6a880e576856
child 49844 fa6f8bce6490
equal deleted inserted replaced
49747:376792a6e9da 49748:6a880e576856
       
     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 "gc/shared/barrierSetAssembler.hpp"
       
    28 #include "interpreter/interp_masm.hpp"
       
    29 
       
    30 #define __ masm->
       
    31 
       
    32 void BarrierSetAssembler::arraycopy_epilogue(MacroAssembler* masm, DecoratorSet decorators, BasicType type,
       
    33                                              Register dst, Register count, bool do_return) {
       
    34   if (do_return) { __ z_br(Z_R14); }
       
    35 }
       
    36 
       
    37 void BarrierSetAssembler::load_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type,
       
    38                                   const Address& addr, Register dst, Register tmp1, Register tmp2, Label *is_null) {
       
    39   bool on_heap = (decorators & IN_HEAP) != 0;
       
    40   bool on_root = (decorators & IN_ROOT) != 0;
       
    41   assert(on_heap || on_root, "where?");
       
    42 
       
    43   switch (type) {
       
    44   case T_ARRAY:
       
    45   case T_OBJECT: {
       
    46     if (UseCompressedOops && on_heap) {
       
    47       __ z_llgf(dst, addr);
       
    48       if (is_null) {
       
    49         __ compareU32_and_branch(dst, (intptr_t)0, Assembler::bcondEqual, *is_null);
       
    50         __ oop_decoder(dst, dst, false);
       
    51       } else {
       
    52         __ oop_decoder(dst, dst, true);
       
    53       }
       
    54     } else {
       
    55       __ z_lg(dst, addr);
       
    56       if (is_null) {
       
    57         __ compareU64_and_branch(dst, (intptr_t)0, Assembler::bcondEqual, *is_null);
       
    58       }
       
    59     }
       
    60     break;
       
    61   }
       
    62   default: Unimplemented();
       
    63   }
       
    64 }
       
    65 
       
    66 void BarrierSetAssembler::store_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type,
       
    67                                    const Address& addr, Register val, Register tmp1, Register tmp2, Register tmp3) {
       
    68   bool on_heap  = (decorators & IN_HEAP) != 0;
       
    69   bool on_root  = (decorators & IN_ROOT) != 0;
       
    70   bool not_null = (decorators & OOP_NOT_NULL) != 0;
       
    71   assert(on_heap || on_root, "where?");
       
    72   assert_different_registers(val, tmp1, tmp2);
       
    73 
       
    74   switch (type) {
       
    75   case T_ARRAY:
       
    76   case T_OBJECT: {
       
    77     if (UseCompressedOops && on_heap) {
       
    78       if (val == noreg) {
       
    79         __ clear_mem(addr, 4);
       
    80       } else if (Universe::narrow_oop_mode() == Universe::UnscaledNarrowOop) {
       
    81         __ z_st(val, addr);
       
    82       } else {
       
    83         Register tmp = (tmp1 != Z_R1) ? tmp1 : tmp2; // Avoid tmp == Z_R1 (see oop_encoder).
       
    84         __ oop_encoder(tmp, val, !not_null);
       
    85         __ z_st(tmp, addr);
       
    86       }
       
    87     } else {
       
    88       if (val == noreg) {
       
    89         __ clear_mem(addr, 8);
       
    90       } else {
       
    91         __ z_stg(val, addr);
       
    92       }
       
    93     }
       
    94     break;
       
    95   }
       
    96   default: Unimplemented();
       
    97   }
       
    98 }
       
    99 
       
   100 void BarrierSetAssembler::resolve_jobject(MacroAssembler* masm, Register value, Register tmp1, Register tmp2) {
       
   101   NearLabel Ldone;
       
   102   __ z_ltgr(tmp1, value);
       
   103   __ z_bre(Ldone);          // Use NULL result as-is.
       
   104 
       
   105   __ z_nill(value, ~JNIHandles::weak_tag_mask);
       
   106   __ z_lg(value, 0, value); // Resolve (untagged) jobject.
       
   107 
       
   108   __ verify_oop(value);
       
   109   __ bind(Ldone);
       
   110 }