src/hotspot/cpu/s390/macroAssembler_s390.cpp
author eosterlund
Mon, 19 Mar 2018 07:38:18 +0100
changeset 49455 848864ed9b17
parent 49449 ef5d5d343e2a
child 49592 77fb0be7d19f
permissions -rw-r--r--
8199604: Rename CardTableModRefBS to CardTableBarrierSet Reviewed-by: stefank, pliden
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
     1
/*
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 48585
diff changeset
     2
 * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
46315
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46289
diff changeset
     3
 * Copyright (c) 2016, 2017, SAP SE. All rights reserved.
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
     4
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
     5
 *
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
     6
 * This code is free software; you can redistribute it and/or modify it
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
     7
 * under the terms of the GNU General Public License version 2 only, as
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
     8
 * published by the Free Software Foundation.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
     9
 *
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    10
 * This code is distributed in the hope that it will be useful, but WITHOUT
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    11
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    12
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    13
 * version 2 for more details (a copy is included in the LICENSE file that
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    14
 * accompanied this code).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    15
 *
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    16
 * You should have received a copy of the GNU General Public License version
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    17
 * 2 along with this work; if not, write to the Free Software Foundation,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    18
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    19
 *
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    20
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    21
 * or visit www.oracle.com if you need additional information or have any
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    22
 * questions.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    23
 *
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    24
 */
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    25
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    26
#include "precompiled.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    27
#include "asm/codeBuffer.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    28
#include "asm/macroAssembler.inline.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    29
#include "compiler/disassembler.hpp"
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 48585
diff changeset
    30
#include "gc/shared/cardTable.hpp"
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    31
#include "gc/shared/collectedHeap.inline.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    32
#include "interpreter/interpreter.hpp"
49455
848864ed9b17 8199604: Rename CardTableModRefBS to CardTableBarrierSet
eosterlund
parents: 49449
diff changeset
    33
#include "gc/shared/cardTableBarrierSet.hpp"
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    34
#include "memory/resourceArea.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    35
#include "memory/universe.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    36
#include "oops/klass.inline.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    37
#include "opto/compile.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    38
#include "opto/intrinsicnode.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    39
#include "opto/matcher.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    40
#include "prims/methodHandles.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    41
#include "registerSaver_s390.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    42
#include "runtime/biasedLocking.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    43
#include "runtime/icache.hpp"
49449
ef5d5d343e2a 8199263: Split interfaceSupport.hpp to not require including .inline.hpp files
coleenp
parents: 49347
diff changeset
    44
#include "runtime/interfaceSupport.inline.hpp"
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    45
#include "runtime/objectMonitor.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    46
#include "runtime/os.hpp"
48332
651a95f30dfb 8193257: PPC64, s390 implementation for Thread-local handshakes
mdoerr
parents: 48331
diff changeset
    47
#include "runtime/safepoint.hpp"
651a95f30dfb 8193257: PPC64, s390 implementation for Thread-local handshakes
mdoerr
parents: 48331
diff changeset
    48
#include "runtime/safepointMechanism.hpp"
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    49
#include "runtime/sharedRuntime.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    50
#include "runtime/stubRoutines.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    51
#include "utilities/events.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    52
#include "utilities/macros.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    53
#if INCLUDE_ALL_GCS
49347
edb65305d3ac 8195148: Collapse G1SATBCardTableModRefBS and G1SATBCardTableLoggingModRefBS into a single G1BarrierSet
eosterlund
parents: 49172
diff changeset
    54
#include "gc/g1/g1BarrierSet.hpp"
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 48585
diff changeset
    55
#include "gc/g1/g1CardTable.hpp"
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    56
#include "gc/g1/g1CollectedHeap.inline.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    57
#include "gc/g1/heapRegion.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    58
#endif
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    59
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    60
#include <ucontext.h>
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    61
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    62
#define BLOCK_COMMENT(str) block_comment(str)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    63
#define BIND(label)        bind(label); BLOCK_COMMENT(#label ":")
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    64
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    65
// Move 32-bit register if destination and source are different.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    66
void MacroAssembler::lr_if_needed(Register rd, Register rs) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    67
  if (rs != rd) { z_lr(rd, rs); }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    68
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    69
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    70
// Move register if destination and source are different.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    71
void MacroAssembler::lgr_if_needed(Register rd, Register rs) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    72
  if (rs != rd) { z_lgr(rd, rs); }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    73
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    74
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    75
// Zero-extend 32-bit register into 64-bit register if destination and source are different.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    76
void MacroAssembler::llgfr_if_needed(Register rd, Register rs) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    77
  if (rs != rd) { z_llgfr(rd, rs); }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    78
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    79
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    80
// Move float register if destination and source are different.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    81
void MacroAssembler::ldr_if_needed(FloatRegister rd, FloatRegister rs) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    82
  if (rs != rd) { z_ldr(rd, rs); }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    83
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    84
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    85
// Move integer register if destination and source are different.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    86
// It is assumed that shorter-than-int types are already
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    87
// appropriately sign-extended.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    88
void MacroAssembler::move_reg_if_needed(Register dst, BasicType dst_type, Register src,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    89
                                        BasicType src_type) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    90
  assert((dst_type != T_FLOAT) && (dst_type != T_DOUBLE), "use move_freg for float types");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    91
  assert((src_type != T_FLOAT) && (src_type != T_DOUBLE), "use move_freg for float types");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    92
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    93
  if (dst_type == src_type) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    94
    lgr_if_needed(dst, src); // Just move all 64 bits.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    95
    return;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    96
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    97
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    98
  switch (dst_type) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    99
    // Do not support these types for now.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   100
    //  case T_BOOLEAN:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   101
    case T_BYTE:  // signed byte
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   102
      switch (src_type) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   103
        case T_INT:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   104
          z_lgbr(dst, src);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   105
          break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   106
        default:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   107
          ShouldNotReachHere();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   108
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   109
      return;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   110
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   111
    case T_CHAR:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   112
    case T_SHORT:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   113
      switch (src_type) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   114
        case T_INT:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   115
          if (dst_type == T_CHAR) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   116
            z_llghr(dst, src);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   117
          } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   118
            z_lghr(dst, src);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   119
          }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   120
          break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   121
        default:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   122
          ShouldNotReachHere();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   123
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   124
      return;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   125
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   126
    case T_INT:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   127
      switch (src_type) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   128
        case T_BOOLEAN:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   129
        case T_BYTE:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   130
        case T_CHAR:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   131
        case T_SHORT:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   132
        case T_INT:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   133
        case T_LONG:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   134
        case T_OBJECT:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   135
        case T_ARRAY:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   136
        case T_VOID:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   137
        case T_ADDRESS:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   138
          lr_if_needed(dst, src);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   139
          // llgfr_if_needed(dst, src);  // zero-extend (in case we need to find a bug).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   140
          return;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   141
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   142
        default:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   143
          assert(false, "non-integer src type");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   144
          return;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   145
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   146
    case T_LONG:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   147
      switch (src_type) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   148
        case T_BOOLEAN:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   149
        case T_BYTE:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   150
        case T_CHAR:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   151
        case T_SHORT:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   152
        case T_INT:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   153
          z_lgfr(dst, src); // sign extension
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   154
          return;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   155
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   156
        case T_LONG:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   157
        case T_OBJECT:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   158
        case T_ARRAY:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   159
        case T_VOID:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   160
        case T_ADDRESS:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   161
          lgr_if_needed(dst, src);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   162
          return;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   163
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   164
        default:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   165
          assert(false, "non-integer src type");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   166
          return;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   167
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   168
      return;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   169
    case T_OBJECT:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   170
    case T_ARRAY:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   171
    case T_VOID:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   172
    case T_ADDRESS:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   173
      switch (src_type) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   174
        // These types don't make sense to be converted to pointers:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   175
        //      case T_BOOLEAN:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   176
        //      case T_BYTE:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   177
        //      case T_CHAR:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   178
        //      case T_SHORT:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   179
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   180
        case T_INT:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   181
          z_llgfr(dst, src); // zero extension
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   182
          return;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   183
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   184
        case T_LONG:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   185
        case T_OBJECT:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   186
        case T_ARRAY:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   187
        case T_VOID:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   188
        case T_ADDRESS:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   189
          lgr_if_needed(dst, src);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   190
          return;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   191
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   192
        default:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   193
          assert(false, "non-integer src type");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   194
          return;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   195
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   196
      return;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   197
    default:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   198
      assert(false, "non-integer dst type");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   199
      return;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   200
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   201
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   202
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   203
// Move float register if destination and source are different.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   204
void MacroAssembler::move_freg_if_needed(FloatRegister dst, BasicType dst_type,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   205
                                         FloatRegister src, BasicType src_type) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   206
  assert((dst_type == T_FLOAT) || (dst_type == T_DOUBLE), "use move_reg for int types");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   207
  assert((src_type == T_FLOAT) || (src_type == T_DOUBLE), "use move_reg for int types");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   208
  if (dst_type == src_type) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   209
    ldr_if_needed(dst, src); // Just move all 64 bits.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   210
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   211
    switch (dst_type) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   212
      case T_FLOAT:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   213
        assert(src_type == T_DOUBLE, "invalid float type combination");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   214
        z_ledbr(dst, src);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   215
        return;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   216
      case T_DOUBLE:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   217
        assert(src_type == T_FLOAT, "invalid float type combination");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   218
        z_ldebr(dst, src);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   219
        return;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   220
      default:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   221
        assert(false, "non-float dst type");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   222
        return;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   223
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   224
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   225
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   226
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   227
// Optimized emitter for reg to mem operations.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   228
// Uses modern instructions if running on modern hardware, classic instructions
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   229
// otherwise. Prefers (usually shorter) classic instructions if applicable.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   230
// Data register (reg) cannot be used as work register.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   231
//
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   232
// Don't rely on register locking, instead pass a scratch register (Z_R0 by default).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   233
// CAUTION! Passing registers >= Z_R2 may produce bad results on old CPUs!
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   234
void MacroAssembler::freg2mem_opt(FloatRegister reg,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   235
                                  int64_t       disp,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   236
                                  Register      index,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   237
                                  Register      base,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   238
                                  void (MacroAssembler::*modern) (FloatRegister, int64_t, Register, Register),
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   239
                                  void (MacroAssembler::*classic)(FloatRegister, int64_t, Register, Register),
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   240
                                  Register      scratch) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   241
  index = (index == noreg) ? Z_R0 : index;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   242
  if (Displacement::is_shortDisp(disp)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   243
    (this->*classic)(reg, disp, index, base);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   244
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   245
    if (Displacement::is_validDisp(disp)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   246
      (this->*modern)(reg, disp, index, base);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   247
    } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   248
      if (scratch != Z_R0 && scratch != Z_R1) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   249
        (this->*modern)(reg, disp, index, base);      // Will fail with disp out of range.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   250
      } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   251
        if (scratch != Z_R0) {   // scratch == Z_R1
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   252
          if ((scratch == index) || (index == base)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   253
            (this->*modern)(reg, disp, index, base);  // Will fail with disp out of range.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   254
          } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   255
            add2reg(scratch, disp, base);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   256
            (this->*classic)(reg, 0, index, scratch);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   257
            if (base == scratch) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   258
              add2reg(base, -disp);  // Restore base.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   259
            }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   260
          }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   261
        } else {   // scratch == Z_R0
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   262
          z_lgr(scratch, base);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   263
          add2reg(base, disp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   264
          (this->*classic)(reg, 0, index, base);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   265
          z_lgr(base, scratch);      // Restore base.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   266
        }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   267
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   268
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   269
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   270
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   271
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   272
void MacroAssembler::freg2mem_opt(FloatRegister reg, const Address &a, bool is_double) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   273
  if (is_double) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   274
    freg2mem_opt(reg, a.disp20(), a.indexOrR0(), a.baseOrR0(), MODERN_FFUN(z_stdy), CLASSIC_FFUN(z_std));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   275
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   276
    freg2mem_opt(reg, a.disp20(), a.indexOrR0(), a.baseOrR0(), MODERN_FFUN(z_stey), CLASSIC_FFUN(z_ste));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   277
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   278
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   279
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   280
// Optimized emitter for mem to reg operations.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   281
// Uses modern instructions if running on modern hardware, classic instructions
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   282
// otherwise. Prefers (usually shorter) classic instructions if applicable.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   283
// data register (reg) cannot be used as work register.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   284
//
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   285
// Don't rely on register locking, instead pass a scratch register (Z_R0 by default).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   286
// CAUTION! Passing registers >= Z_R2 may produce bad results on old CPUs!
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   287
void MacroAssembler::mem2freg_opt(FloatRegister reg,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   288
                                  int64_t       disp,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   289
                                  Register      index,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   290
                                  Register      base,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   291
                                  void (MacroAssembler::*modern) (FloatRegister, int64_t, Register, Register),
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   292
                                  void (MacroAssembler::*classic)(FloatRegister, int64_t, Register, Register),
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   293
                                  Register      scratch) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   294
  index = (index == noreg) ? Z_R0 : index;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   295
  if (Displacement::is_shortDisp(disp)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   296
    (this->*classic)(reg, disp, index, base);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   297
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   298
    if (Displacement::is_validDisp(disp)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   299
      (this->*modern)(reg, disp, index, base);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   300
    } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   301
      if (scratch != Z_R0 && scratch != Z_R1) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   302
        (this->*modern)(reg, disp, index, base);      // Will fail with disp out of range.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   303
      } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   304
        if (scratch != Z_R0) {   // scratch == Z_R1
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   305
          if ((scratch == index) || (index == base)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   306
            (this->*modern)(reg, disp, index, base);  // Will fail with disp out of range.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   307
          } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   308
            add2reg(scratch, disp, base);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   309
            (this->*classic)(reg, 0, index, scratch);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   310
            if (base == scratch) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   311
              add2reg(base, -disp);  // Restore base.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   312
            }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   313
          }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   314
        } else {   // scratch == Z_R0
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   315
          z_lgr(scratch, base);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   316
          add2reg(base, disp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   317
          (this->*classic)(reg, 0, index, base);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   318
          z_lgr(base, scratch);      // Restore base.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   319
        }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   320
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   321
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   322
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   323
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   324
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   325
void MacroAssembler::mem2freg_opt(FloatRegister reg, const Address &a, bool is_double) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   326
  if (is_double) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   327
    mem2freg_opt(reg, a.disp20(), a.indexOrR0(), a.baseOrR0(), MODERN_FFUN(z_ldy), CLASSIC_FFUN(z_ld));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   328
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   329
    mem2freg_opt(reg, a.disp20(), a.indexOrR0(), a.baseOrR0(), MODERN_FFUN(z_ley), CLASSIC_FFUN(z_le));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   330
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   331
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   332
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   333
// Optimized emitter for reg to mem operations.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   334
// Uses modern instructions if running on modern hardware, classic instructions
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   335
// otherwise. Prefers (usually shorter) classic instructions if applicable.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   336
// Data register (reg) cannot be used as work register.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   337
//
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   338
// Don't rely on register locking, instead pass a scratch register
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   339
// (Z_R0 by default)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   340
// CAUTION! passing registers >= Z_R2 may produce bad results on old CPUs!
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   341
void MacroAssembler::reg2mem_opt(Register reg,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   342
                                 int64_t  disp,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   343
                                 Register index,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   344
                                 Register base,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   345
                                 void (MacroAssembler::*modern) (Register, int64_t, Register, Register),
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   346
                                 void (MacroAssembler::*classic)(Register, int64_t, Register, Register),
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   347
                                 Register scratch) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   348
  index = (index == noreg) ? Z_R0 : index;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   349
  if (Displacement::is_shortDisp(disp)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   350
    (this->*classic)(reg, disp, index, base);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   351
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   352
    if (Displacement::is_validDisp(disp)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   353
      (this->*modern)(reg, disp, index, base);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   354
    } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   355
      if (scratch != Z_R0 && scratch != Z_R1) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   356
        (this->*modern)(reg, disp, index, base);      // Will fail with disp out of range.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   357
      } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   358
        if (scratch != Z_R0) {   // scratch == Z_R1
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   359
          if ((scratch == index) || (index == base)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   360
            (this->*modern)(reg, disp, index, base);  // Will fail with disp out of range.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   361
          } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   362
            add2reg(scratch, disp, base);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   363
            (this->*classic)(reg, 0, index, scratch);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   364
            if (base == scratch) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   365
              add2reg(base, -disp);  // Restore base.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   366
            }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   367
          }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   368
        } else {   // scratch == Z_R0
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   369
          if ((scratch == reg) || (scratch == base) || (reg == base)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   370
            (this->*modern)(reg, disp, index, base);  // Will fail with disp out of range.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   371
          } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   372
            z_lgr(scratch, base);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   373
            add2reg(base, disp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   374
            (this->*classic)(reg, 0, index, base);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   375
            z_lgr(base, scratch);    // Restore base.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   376
          }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   377
        }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   378
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   379
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   380
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   381
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   382
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   383
int MacroAssembler::reg2mem_opt(Register reg, const Address &a, bool is_double) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   384
  int store_offset = offset();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   385
  if (is_double) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   386
    reg2mem_opt(reg, a.disp20(), a.indexOrR0(), a.baseOrR0(), MODERN_IFUN(z_stg), CLASSIC_IFUN(z_stg));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   387
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   388
    reg2mem_opt(reg, a.disp20(), a.indexOrR0(), a.baseOrR0(), MODERN_IFUN(z_sty), CLASSIC_IFUN(z_st));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   389
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   390
  return store_offset;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   391
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   392
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   393
// Optimized emitter for mem to reg operations.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   394
// Uses modern instructions if running on modern hardware, classic instructions
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   395
// otherwise. Prefers (usually shorter) classic instructions if applicable.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   396
// Data register (reg) will be used as work register where possible.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   397
void MacroAssembler::mem2reg_opt(Register reg,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   398
                                 int64_t  disp,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   399
                                 Register index,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   400
                                 Register base,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   401
                                 void (MacroAssembler::*modern) (Register, int64_t, Register, Register),
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   402
                                 void (MacroAssembler::*classic)(Register, int64_t, Register, Register)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   403
  index = (index == noreg) ? Z_R0 : index;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   404
  if (Displacement::is_shortDisp(disp)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   405
    (this->*classic)(reg, disp, index, base);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   406
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   407
    if (Displacement::is_validDisp(disp)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   408
      (this->*modern)(reg, disp, index, base);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   409
    } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   410
      if ((reg == index) && (reg == base)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   411
        z_sllg(reg, reg, 1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   412
        add2reg(reg, disp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   413
        (this->*classic)(reg, 0, noreg, reg);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   414
      } else if ((reg == index) && (reg != Z_R0)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   415
        add2reg(reg, disp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   416
        (this->*classic)(reg, 0, reg, base);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   417
      } else if (reg == base) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   418
        add2reg(reg, disp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   419
        (this->*classic)(reg, 0, index, reg);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   420
      } else if (reg != Z_R0) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   421
        add2reg(reg, disp, base);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   422
        (this->*classic)(reg, 0, index, reg);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   423
      } else { // reg == Z_R0 && reg != base here
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   424
        add2reg(base, disp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   425
        (this->*classic)(reg, 0, index, base);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   426
        add2reg(base, -disp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   427
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   428
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   429
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   430
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   431
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   432
void MacroAssembler::mem2reg_opt(Register reg, const Address &a, bool is_double) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   433
  if (is_double) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   434
    z_lg(reg, a);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   435
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   436
    mem2reg_opt(reg, a.disp20(), a.indexOrR0(), a.baseOrR0(), MODERN_IFUN(z_ly), CLASSIC_IFUN(z_l));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   437
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   438
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   439
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   440
void MacroAssembler::mem2reg_signed_opt(Register reg, const Address &a) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   441
  mem2reg_opt(reg, a.disp20(), a.indexOrR0(), a.baseOrR0(), MODERN_IFUN(z_lgf), CLASSIC_IFUN(z_lgf));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   442
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   443
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   444
void MacroAssembler::and_imm(Register r, long mask,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   445
                             Register tmp /* = Z_R0 */,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   446
                             bool wide    /* = false */) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   447
  assert(wide || Immediate::is_simm32(mask), "mask value too large");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   448
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   449
  if (!wide) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   450
    z_nilf(r, mask);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   451
    return;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   452
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   453
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   454
  assert(r != tmp, " need a different temporary register !");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   455
  load_const_optimized(tmp, mask);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   456
  z_ngr(r, tmp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   457
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   458
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   459
// Calculate the 1's complement.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   460
// Note: The condition code is neither preserved nor correctly set by this code!!!
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   461
// Note: (wide == false) does not protect the high order half of the target register
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   462
//       from alteration. It only serves as optimization hint for 32-bit results.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   463
void MacroAssembler::not_(Register r1, Register r2, bool wide) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   464
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   465
  if ((r2 == noreg) || (r2 == r1)) { // Calc 1's complement in place.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   466
    z_xilf(r1, -1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   467
    if (wide) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   468
      z_xihf(r1, -1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   469
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   470
  } else { // Distinct src and dst registers.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   471
    if (VM_Version::has_DistinctOpnds()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   472
      load_const_optimized(r1, -1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   473
      z_xgrk(r1, r2, r1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   474
    } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   475
      if (wide) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   476
        z_lgr(r1, r2);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   477
        z_xilf(r1, -1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   478
        z_xihf(r1, -1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   479
      } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   480
        z_lr(r1, r2);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   481
        z_xilf(r1, -1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   482
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   483
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   484
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   485
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   486
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   487
unsigned long MacroAssembler::create_mask(int lBitPos, int rBitPos) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   488
  assert(lBitPos >=  0,      "zero is  leftmost bit position");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   489
  assert(rBitPos <= 63,      "63   is rightmost bit position");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   490
  assert(lBitPos <= rBitPos, "inverted selection interval");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   491
  return (lBitPos == 0 ? (unsigned long)(-1L) : ((1UL<<(63-lBitPos+1))-1)) & (~((1UL<<(63-rBitPos))-1));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   492
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   493
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   494
// Helper function for the "Rotate_then_<logicalOP>" emitters.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   495
// Rotate src, then mask register contents such that only bits in range survive.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   496
// For oneBits == false, all bits not in range are set to 0. Useful for deleting all bits outside range.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   497
// For oneBits == true,  all bits not in range are set to 1. Useful for preserving all bits outside range.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   498
// The caller must ensure that the selected range only contains bits with defined value.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   499
void MacroAssembler::rotate_then_mask(Register dst, Register src, int lBitPos, int rBitPos,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   500
                                      int nRotate, bool src32bit, bool dst32bit, bool oneBits) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   501
  assert(!(dst32bit && lBitPos < 32), "selection interval out of range for int destination");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   502
  bool sll4rll = (nRotate >= 0) && (nRotate <= (63-rBitPos)); // Substitute SLL(G) for RLL(G).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   503
  bool srl4rll = (nRotate <  0) && (-nRotate <= lBitPos);     // Substitute SRL(G) for RLL(G).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   504
  //  Pre-determine which parts of dst will be zero after shift/rotate.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   505
  bool llZero  =  sll4rll && (nRotate >= 16);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   506
  bool lhZero  = (sll4rll && (nRotate >= 32)) || (srl4rll && (nRotate <= -48));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   507
  bool lfZero  = llZero && lhZero;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   508
  bool hlZero  = (sll4rll && (nRotate >= 48)) || (srl4rll && (nRotate <= -32));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   509
  bool hhZero  =                                 (srl4rll && (nRotate <= -16));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   510
  bool hfZero  = hlZero && hhZero;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   511
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   512
  // rotate then mask src operand.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   513
  // if oneBits == true,  all bits outside selected range are 1s.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   514
  // if oneBits == false, all bits outside selected range are 0s.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   515
  if (src32bit) {   // There might be garbage in the upper 32 bits which will get masked away.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   516
    if (dst32bit) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   517
      z_rll(dst, src, nRotate);   // Copy and rotate, upper half of reg remains undisturbed.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   518
    } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   519
      if      (sll4rll) { z_sllg(dst, src,  nRotate); }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   520
      else if (srl4rll) { z_srlg(dst, src, -nRotate); }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   521
      else              { z_rllg(dst, src,  nRotate); }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   522
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   523
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   524
    if      (sll4rll) { z_sllg(dst, src,  nRotate); }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   525
    else if (srl4rll) { z_srlg(dst, src, -nRotate); }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   526
    else              { z_rllg(dst, src,  nRotate); }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   527
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   528
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   529
  unsigned long  range_mask    = create_mask(lBitPos, rBitPos);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   530
  unsigned int   range_mask_h  = (unsigned int)(range_mask >> 32);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   531
  unsigned int   range_mask_l  = (unsigned int)range_mask;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   532
  unsigned short range_mask_hh = (unsigned short)(range_mask >> 48);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   533
  unsigned short range_mask_hl = (unsigned short)(range_mask >> 32);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   534
  unsigned short range_mask_lh = (unsigned short)(range_mask >> 16);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   535
  unsigned short range_mask_ll = (unsigned short)range_mask;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   536
  // Works for z9 and newer H/W.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   537
  if (oneBits) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   538
    if ((~range_mask_l) != 0)                { z_oilf(dst, ~range_mask_l); } // All bits outside range become 1s.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   539
    if (((~range_mask_h) != 0) && !dst32bit) { z_oihf(dst, ~range_mask_h); }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   540
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   541
    // All bits outside range become 0s
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   542
    if (((~range_mask_l) != 0) &&              !lfZero) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   543
      z_nilf(dst, range_mask_l);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   544
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   545
    if (((~range_mask_h) != 0) && !dst32bit && !hfZero) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   546
      z_nihf(dst, range_mask_h);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   547
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   548
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   549
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   550
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   551
// Rotate src, then insert selected range from rotated src into dst.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   552
// Clear dst before, if requested.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   553
void MacroAssembler::rotate_then_insert(Register dst, Register src, int lBitPos, int rBitPos,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   554
                                        int nRotate, bool clear_dst) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   555
  // This version does not depend on src being zero-extended int2long.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   556
  nRotate &= 0x003f;                                       // For risbg, pretend it's an unsigned value.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   557
  z_risbg(dst, src, lBitPos, rBitPos, nRotate, clear_dst); // Rotate, then insert selected, clear the rest.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   558
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   559
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   560
// Rotate src, then and selected range from rotated src into dst.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   561
// Set condition code only if so requested. Otherwise it is unpredictable.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   562
// See performance note in macroAssembler_s390.hpp for important information.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   563
void MacroAssembler::rotate_then_and(Register dst, Register src, int lBitPos, int rBitPos,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   564
                                     int nRotate, bool test_only) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   565
  guarantee(!test_only, "Emitter not fit for test_only instruction variant.");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   566
  // This version does not depend on src being zero-extended int2long.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   567
  nRotate &= 0x003f;                                       // For risbg, pretend it's an unsigned value.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   568
  z_rxsbg(dst, src, lBitPos, rBitPos, nRotate, test_only); // Rotate, then xor selected.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   569
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   570
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   571
// Rotate src, then or selected range from rotated src into dst.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   572
// Set condition code only if so requested. Otherwise it is unpredictable.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   573
// See performance note in macroAssembler_s390.hpp for important information.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   574
void MacroAssembler::rotate_then_or(Register dst, Register src,  int  lBitPos,  int  rBitPos,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   575
                                    int nRotate, bool test_only) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   576
  guarantee(!test_only, "Emitter not fit for test_only instruction variant.");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   577
  // This version does not depend on src being zero-extended int2long.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   578
  nRotate &= 0x003f;                                       // For risbg, pretend it's an unsigned value.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   579
  z_rosbg(dst, src, lBitPos, rBitPos, nRotate, test_only); // Rotate, then xor selected.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   580
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   581
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   582
// Rotate src, then xor selected range from rotated src into dst.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   583
// Set condition code only if so requested. Otherwise it is unpredictable.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   584
// See performance note in macroAssembler_s390.hpp for important information.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   585
void MacroAssembler::rotate_then_xor(Register dst, Register src,  int  lBitPos,  int  rBitPos,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   586
                                     int nRotate, bool test_only) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   587
  guarantee(!test_only, "Emitter not fit for test_only instruction variant.");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   588
    // This version does not depend on src being zero-extended int2long.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   589
  nRotate &= 0x003f;                                       // For risbg, pretend it's an unsigned value.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   590
  z_rxsbg(dst, src, lBitPos, rBitPos, nRotate, test_only); // Rotate, then xor selected.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   591
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   592
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   593
void MacroAssembler::add64(Register r1, RegisterOrConstant inc) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   594
  if (inc.is_register()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   595
    z_agr(r1, inc.as_register());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   596
  } else { // constant
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   597
    intptr_t imm = inc.as_constant();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   598
    add2reg(r1, imm);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   599
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   600
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   601
// Helper function to multiply the 64bit contents of a register by a 16bit constant.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   602
// The optimization tries to avoid the mghi instruction, since it uses the FPU for
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   603
// calculation and is thus rather slow.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   604
//
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   605
// There is no handling for special cases, e.g. cval==0 or cval==1.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   606
//
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   607
// Returns len of generated code block.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   608
unsigned int MacroAssembler::mul_reg64_const16(Register rval, Register work, int cval) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   609
  int block_start = offset();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   610
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   611
  bool sign_flip = cval < 0;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   612
  cval = sign_flip ? -cval : cval;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   613
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   614
  BLOCK_COMMENT("Reg64*Con16 {");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   615
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   616
  int bit1 = cval & -cval;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   617
  if (bit1 == cval) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   618
    z_sllg(rval, rval, exact_log2(bit1));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   619
    if (sign_flip) { z_lcgr(rval, rval); }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   620
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   621
    int bit2 = (cval-bit1) & -(cval-bit1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   622
    if ((bit1+bit2) == cval) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   623
      z_sllg(work, rval, exact_log2(bit1));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   624
      z_sllg(rval, rval, exact_log2(bit2));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   625
      z_agr(rval, work);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   626
      if (sign_flip) { z_lcgr(rval, rval); }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   627
    } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   628
      if (sign_flip) { z_mghi(rval, -cval); }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   629
      else           { z_mghi(rval,  cval); }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   630
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   631
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   632
  BLOCK_COMMENT("} Reg64*Con16");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   633
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   634
  int block_end = offset();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   635
  return block_end - block_start;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   636
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   637
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   638
// Generic operation r1 := r2 + imm.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   639
//
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   640
// Should produce the best code for each supported CPU version.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   641
// r2 == noreg yields r1 := r1 + imm
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   642
// imm == 0 emits either no instruction or r1 := r2 !
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   643
// NOTES: 1) Don't use this function where fixed sized
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   644
//           instruction sequences are required!!!
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   645
//        2) Don't use this function if condition code
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   646
//           setting is required!
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   647
//        3) Despite being declared as int64_t, the parameter imm
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   648
//           must be a simm_32 value (= signed 32-bit integer).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   649
void MacroAssembler::add2reg(Register r1, int64_t imm, Register r2) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   650
  assert(Immediate::is_simm32(imm), "probably an implicit conversion went wrong");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   651
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   652
  if (r2 == noreg) { r2 = r1; }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   653
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   654
  // Handle special case imm == 0.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   655
  if (imm == 0) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   656
    lgr_if_needed(r1, r2);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   657
    // Nothing else to do.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   658
    return;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   659
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   660
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   661
  if (!PreferLAoverADD || (r2 == Z_R0)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   662
    bool distinctOpnds = VM_Version::has_DistinctOpnds();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   663
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   664
    // Can we encode imm in 16 bits signed?
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   665
    if (Immediate::is_simm16(imm)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   666
      if (r1 == r2) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   667
        z_aghi(r1, imm);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   668
        return;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   669
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   670
      if (distinctOpnds) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   671
        z_aghik(r1, r2, imm);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   672
        return;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   673
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   674
      z_lgr(r1, r2);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   675
      z_aghi(r1, imm);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   676
      return;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   677
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   678
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   679
    // Can we encode imm in 12 bits unsigned?
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   680
    if (Displacement::is_shortDisp(imm)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   681
      z_la(r1, imm, r2);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   682
      return;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   683
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   684
    // Can we encode imm in 20 bits signed?
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   685
    if (Displacement::is_validDisp(imm)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   686
      // Always use LAY instruction, so we don't need the tmp register.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   687
      z_lay(r1, imm, r2);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   688
      return;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   689
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   690
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   691
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   692
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   693
  // Can handle it (all possible values) with long immediates.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   694
  lgr_if_needed(r1, r2);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   695
  z_agfi(r1, imm);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   696
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   697
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   698
// Generic operation r := b + x + d
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   699
//
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   700
// Addition of several operands with address generation semantics - sort of:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   701
//  - no restriction on the registers. Any register will do for any operand.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   702
//  - x == noreg: operand will be disregarded.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   703
//  - b == noreg: will use (contents of) result reg as operand (r := r + d).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   704
//  - x == Z_R0:  just disregard
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   705
//  - b == Z_R0:  use as operand. This is not address generation semantics!!!
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   706
//
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   707
// The same restrictions as on add2reg() are valid!!!
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   708
void MacroAssembler::add2reg_with_index(Register r, int64_t d, Register x, Register b) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   709
  assert(Immediate::is_simm32(d), "probably an implicit conversion went wrong");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   710
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   711
  if (x == noreg) { x = Z_R0; }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   712
  if (b == noreg) { b = r; }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   713
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   714
  // Handle special case x == R0.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   715
  if (x == Z_R0) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   716
    // Can simply add the immediate value to the base register.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   717
    add2reg(r, d, b);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   718
    return;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   719
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   720
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   721
  if (!PreferLAoverADD || (b == Z_R0)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   722
    bool distinctOpnds = VM_Version::has_DistinctOpnds();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   723
    // Handle special case d == 0.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   724
    if (d == 0) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   725
      if (b == x)        { z_sllg(r, b, 1); return; }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   726
      if (r == x)        { z_agr(r, b);     return; }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   727
      if (r == b)        { z_agr(r, x);     return; }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   728
      if (distinctOpnds) { z_agrk(r, x, b); return; }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   729
      z_lgr(r, b);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   730
      z_agr(r, x);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   731
    } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   732
      if (x == b)             { z_sllg(r, x, 1); }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   733
      else if (r == x)        { z_agr(r, b); }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   734
      else if (r == b)        { z_agr(r, x); }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   735
      else if (distinctOpnds) { z_agrk(r, x, b); }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   736
      else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   737
        z_lgr(r, b);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   738
        z_agr(r, x);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   739
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   740
      add2reg(r, d);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   741
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   742
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   743
    // Can we encode imm in 12 bits unsigned?
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   744
    if (Displacement::is_shortDisp(d)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   745
      z_la(r, d, x, b);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   746
      return;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   747
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   748
    // Can we encode imm in 20 bits signed?
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   749
    if (Displacement::is_validDisp(d)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   750
      z_lay(r, d, x, b);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   751
      return;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   752
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   753
    z_la(r, 0, x, b);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   754
    add2reg(r, d);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   755
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   756
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   757
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   758
// Generic emitter (32bit) for direct memory increment.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   759
// For optimal code, do not specify Z_R0 as temp register.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   760
void MacroAssembler::add2mem_32(const Address &a, int64_t imm, Register tmp) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   761
  if (VM_Version::has_MemWithImmALUOps() && Immediate::is_simm8(imm)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   762
    z_asi(a, imm);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   763
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   764
    z_lgf(tmp, a);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   765
    add2reg(tmp, imm);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   766
    z_st(tmp, a);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   767
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   768
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   769
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   770
void MacroAssembler::add2mem_64(const Address &a, int64_t imm, Register tmp) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   771
  if (VM_Version::has_MemWithImmALUOps() && Immediate::is_simm8(imm)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   772
    z_agsi(a, imm);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   773
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   774
    z_lg(tmp, a);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   775
    add2reg(tmp, imm);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   776
    z_stg(tmp, a);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   777
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   778
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   779
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   780
void MacroAssembler::load_sized_value(Register dst, Address src, size_t size_in_bytes, bool is_signed) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   781
  switch (size_in_bytes) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   782
    case  8: z_lg(dst, src); break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   783
    case  4: is_signed ? z_lgf(dst, src) : z_llgf(dst, src); break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   784
    case  2: is_signed ? z_lgh(dst, src) : z_llgh(dst, src); break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   785
    case  1: is_signed ? z_lgb(dst, src) : z_llgc(dst, src); break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   786
    default: ShouldNotReachHere();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   787
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   788
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   789
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   790
void MacroAssembler::store_sized_value(Register src, Address dst, size_t size_in_bytes) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   791
  switch (size_in_bytes) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   792
    case  8: z_stg(src, dst); break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   793
    case  4: z_st(src, dst); break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   794
    case  2: z_sth(src, dst); break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   795
    case  1: z_stc(src, dst); break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   796
    default: ShouldNotReachHere();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   797
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   798
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   799
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   800
// Split a si20 offset (20bit, signed) into an ui12 offset (12bit, unsigned) and
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   801
// a high-order summand in register tmp.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   802
//
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   803
// return value: <  0: No split required, si20 actually has property uimm12.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   804
//               >= 0: Split performed. Use return value as uimm12 displacement and
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   805
//                     tmp as index register.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   806
int MacroAssembler::split_largeoffset(int64_t si20_offset, Register tmp, bool fixed_codelen, bool accumulate) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   807
  assert(Immediate::is_simm20(si20_offset), "sanity");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   808
  int lg_off = (int)si20_offset &  0x0fff; // Punch out low-order 12 bits, always positive.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   809
  int ll_off = (int)si20_offset & ~0x0fff; // Force low-order 12 bits to zero.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   810
  assert((Displacement::is_shortDisp(si20_offset) && (ll_off == 0)) ||
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   811
         !Displacement::is_shortDisp(si20_offset), "unexpected offset values");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   812
  assert((lg_off+ll_off) == si20_offset, "offset splitup error");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   813
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   814
  Register work = accumulate? Z_R0 : tmp;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   815
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   816
  if (fixed_codelen) {          // Len of code = 10 = 4 + 6.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   817
    z_lghi(work, ll_off>>12);   // Implicit sign extension.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   818
    z_slag(work, work, 12);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   819
  } else {                      // Len of code = 0..10.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   820
    if (ll_off == 0) { return -1; }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   821
    // ll_off has 8 significant bits (at most) plus sign.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   822
    if ((ll_off & 0x0000f000) == 0) {    // Non-zero bits only in upper halfbyte.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   823
      z_llilh(work, ll_off >> 16);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   824
      if (ll_off < 0) {                  // Sign-extension required.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   825
        z_lgfr(work, work);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   826
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   827
    } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   828
      if ((ll_off & 0x000f0000) == 0) {  // Non-zero bits only in lower halfbyte.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   829
        z_llill(work, ll_off);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   830
      } else {                           // Non-zero bits in both halfbytes.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   831
        z_lghi(work, ll_off>>12);        // Implicit sign extension.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   832
        z_slag(work, work, 12);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   833
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   834
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   835
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   836
  if (accumulate) { z_algr(tmp, work); } // len of code += 4
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   837
  return lg_off;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   838
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   839
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   840
void MacroAssembler::load_float_largeoffset(FloatRegister t, int64_t si20, Register a, Register tmp) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   841
  if (Displacement::is_validDisp(si20)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   842
    z_ley(t, si20, a);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   843
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   844
    // Fixed_codelen = true is a simple way to ensure that the size of load_float_largeoffset
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   845
    // does not depend on si20 (scratch buffer emit size == code buffer emit size for constant
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   846
    // pool loads).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   847
    bool accumulate    = true;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   848
    bool fixed_codelen = true;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   849
    Register work;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   850
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   851
    if (fixed_codelen) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   852
      z_lgr(tmp, a);  // Lgr_if_needed not applicable due to fixed_codelen.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   853
    } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   854
      accumulate = (a == tmp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   855
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   856
    work = tmp;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   857
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   858
    int disp12 = split_largeoffset(si20, work, fixed_codelen, accumulate);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   859
    if (disp12 < 0) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   860
      z_le(t, si20, work);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   861
    } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   862
      if (accumulate) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   863
        z_le(t, disp12, work);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   864
      } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   865
        z_le(t, disp12, work, a);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   866
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   867
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   868
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   869
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   870
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   871
void MacroAssembler::load_double_largeoffset(FloatRegister t, int64_t si20, Register a, Register tmp) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   872
  if (Displacement::is_validDisp(si20)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   873
    z_ldy(t, si20, a);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   874
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   875
    // Fixed_codelen = true is a simple way to ensure that the size of load_double_largeoffset
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   876
    // does not depend on si20 (scratch buffer emit size == code buffer emit size for constant
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   877
    // pool loads).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   878
    bool accumulate    = true;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   879
    bool fixed_codelen = true;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   880
    Register work;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   881
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   882
    if (fixed_codelen) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   883
      z_lgr(tmp, a);  // Lgr_if_needed not applicable due to fixed_codelen.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   884
    } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   885
      accumulate = (a == tmp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   886
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   887
    work = tmp;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   888
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   889
    int disp12 = split_largeoffset(si20, work, fixed_codelen, accumulate);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   890
    if (disp12 < 0) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   891
      z_ld(t, si20, work);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   892
    } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   893
      if (accumulate) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   894
        z_ld(t, disp12, work);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   895
      } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   896
        z_ld(t, disp12, work, a);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   897
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   898
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   899
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   900
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   901
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   902
// PCrelative TOC access.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   903
// Returns distance (in bytes) from current position to start of consts section.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   904
// Returns 0 (zero) if no consts section exists or if it has size zero.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   905
long MacroAssembler::toc_distance() {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   906
  CodeSection* cs = code()->consts();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   907
  return (long)((cs != NULL) ? cs->start()-pc() : 0);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   908
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   909
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   910
// Implementation on x86/sparc assumes that constant and instruction section are
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   911
// adjacent, but this doesn't hold. Two special situations may occur, that we must
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   912
// be able to handle:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   913
//   1. const section may be located apart from the inst section.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   914
//   2. const section may be empty
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   915
// In both cases, we use the const section's start address to compute the "TOC",
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   916
// this seems to occur only temporarily; in the final step we always seem to end up
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   917
// with the pc-relatice variant.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   918
//
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   919
// PC-relative offset could be +/-2**32 -> use long for disp
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   920
// Furthermore: makes no sense to have special code for
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   921
// adjacent const and inst sections.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   922
void MacroAssembler::load_toc(Register Rtoc) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   923
  // Simply use distance from start of const section (should be patched in the end).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   924
  long disp = toc_distance();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   925
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   926
  RelocationHolder rspec = internal_word_Relocation::spec(pc() + disp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   927
  relocate(rspec);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   928
  z_larl(Rtoc, RelAddr::pcrel_off32(disp));  // Offset is in halfwords.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   929
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   930
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   931
// PCrelative TOC access.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   932
// Load from anywhere pcrelative (with relocation of load instr)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   933
void MacroAssembler::load_long_pcrelative(Register Rdst, address dataLocation) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   934
  address          pc             = this->pc();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   935
  ptrdiff_t        total_distance = dataLocation - pc;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   936
  RelocationHolder rspec          = internal_word_Relocation::spec(dataLocation);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   937
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   938
  assert((total_distance & 0x01L) == 0, "halfword alignment is mandatory");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   939
  assert(total_distance != 0, "sanity");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   940
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   941
  // Some extra safety net.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   942
  if (!RelAddr::is_in_range_of_RelAddr32(total_distance)) {
48094
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
   943
    guarantee(RelAddr::is_in_range_of_RelAddr32(total_distance), "load_long_pcrelative can't handle distance " INTPTR_FORMAT, total_distance);
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   944
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   945
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   946
  (this)->relocate(rspec, relocInfo::pcrel_addr_format);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   947
  z_lgrl(Rdst, RelAddr::pcrel_off32(total_distance));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   948
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   949
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   950
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   951
// PCrelative TOC access.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   952
// Load from anywhere pcrelative (with relocation of load instr)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   953
// loaded addr has to be relocated when added to constant pool.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   954
void MacroAssembler::load_addr_pcrelative(Register Rdst, address addrLocation) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   955
  address          pc             = this->pc();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   956
  ptrdiff_t        total_distance = addrLocation - pc;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   957
  RelocationHolder rspec          = internal_word_Relocation::spec(addrLocation);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   958
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   959
  assert((total_distance & 0x01L) == 0, "halfword alignment is mandatory");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   960
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   961
  // Some extra safety net.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   962
  if (!RelAddr::is_in_range_of_RelAddr32(total_distance)) {
48094
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
   963
    guarantee(RelAddr::is_in_range_of_RelAddr32(total_distance), "load_long_pcrelative can't handle distance " INTPTR_FORMAT, total_distance);
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   964
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   965
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   966
  (this)->relocate(rspec, relocInfo::pcrel_addr_format);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   967
  z_lgrl(Rdst, RelAddr::pcrel_off32(total_distance));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   968
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   969
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   970
// Generic operation: load a value from memory and test.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   971
// CondCode indicates the sign (<0, ==0, >0) of the loaded value.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   972
void MacroAssembler::load_and_test_byte(Register dst, const Address &a) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   973
  z_lb(dst, a);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   974
  z_ltr(dst, dst);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   975
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   976
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   977
void MacroAssembler::load_and_test_short(Register dst, const Address &a) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   978
  int64_t disp = a.disp20();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   979
  if (Displacement::is_shortDisp(disp)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   980
    z_lh(dst, a);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   981
  } else if (Displacement::is_longDisp(disp)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   982
    z_lhy(dst, a);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   983
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   984
    guarantee(false, "displacement out of range");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   985
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   986
  z_ltr(dst, dst);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   987
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   988
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   989
void MacroAssembler::load_and_test_int(Register dst, const Address &a) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   990
  z_lt(dst, a);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   991
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   992
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   993
void MacroAssembler::load_and_test_int2long(Register dst, const Address &a) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   994
  z_ltgf(dst, a);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   995
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   996
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   997
void MacroAssembler::load_and_test_long(Register dst, const Address &a) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   998
  z_ltg(dst, a);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   999
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1000
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1001
// Test a bit in memory.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1002
void MacroAssembler::testbit(const Address &a, unsigned int bit) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1003
  assert(a.index() == noreg, "no index reg allowed in testbit");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1004
  if (bit <= 7) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1005
    z_tm(a.disp() + 3, a.base(), 1 << bit);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1006
  } else if (bit <= 15) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1007
    z_tm(a.disp() + 2, a.base(), 1 << (bit - 8));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1008
  } else if (bit <= 23) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1009
    z_tm(a.disp() + 1, a.base(), 1 << (bit - 16));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1010
  } else if (bit <= 31) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1011
    z_tm(a.disp() + 0, a.base(), 1 << (bit - 24));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1012
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1013
    ShouldNotReachHere();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1014
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1015
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1016
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1017
// Test a bit in a register. Result is reflected in CC.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1018
void MacroAssembler::testbit(Register r, unsigned int bitPos) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1019
  if (bitPos < 16) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1020
    z_tmll(r, 1U<<bitPos);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1021
  } else if (bitPos < 32) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1022
    z_tmlh(r, 1U<<(bitPos-16));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1023
  } else if (bitPos < 48) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1024
    z_tmhl(r, 1U<<(bitPos-32));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1025
  } else if (bitPos < 64) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1026
    z_tmhh(r, 1U<<(bitPos-48));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1027
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1028
    ShouldNotReachHere();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1029
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1030
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1031
48094
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  1032
void MacroAssembler::prefetch_read(Address a) {
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  1033
  z_pfd(1, a.disp20(), a.indexOrR0(), a.base());
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  1034
}
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  1035
void MacroAssembler::prefetch_update(Address a) {
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  1036
  z_pfd(2, a.disp20(), a.indexOrR0(), a.base());
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  1037
}
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  1038
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1039
// Clear a register, i.e. load const zero into reg.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1040
// Return len (in bytes) of generated instruction(s).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1041
// whole_reg: Clear 64 bits if true, 32 bits otherwise.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1042
// set_cc:    Use instruction that sets the condition code, if true.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1043
int MacroAssembler::clear_reg(Register r, bool whole_reg, bool set_cc) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1044
  unsigned int start_off = offset();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1045
  if (whole_reg) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1046
    set_cc ? z_xgr(r, r) : z_laz(r, 0, Z_R0);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1047
  } else {  // Only 32bit register.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1048
    set_cc ? z_xr(r, r) : z_lhi(r, 0);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1049
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1050
  return offset() - start_off;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1051
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1052
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1053
#ifdef ASSERT
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1054
int MacroAssembler::preset_reg(Register r, unsigned long pattern, int pattern_len) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1055
  switch (pattern_len) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1056
    case 1:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1057
      pattern = (pattern & 0x000000ff)  | ((pattern & 0x000000ff)<<8);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1058
    case 2:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1059
      pattern = (pattern & 0x0000ffff)  | ((pattern & 0x0000ffff)<<16);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1060
    case 4:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1061
      pattern = (pattern & 0xffffffffL) | ((pattern & 0xffffffffL)<<32);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1062
    case 8:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1063
      return load_const_optimized_rtn_len(r, pattern, true);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1064
      break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1065
    default:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1066
      guarantee(false, "preset_reg: bad len");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1067
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1068
  return 0;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1069
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1070
#endif
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1071
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1072
// addr: Address descriptor of memory to clear index register will not be used !
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1073
// size: Number of bytes to clear.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1074
//    !!! DO NOT USE THEM FOR ATOMIC MEMORY CLEARING !!!
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1075
//    !!! Use store_const() instead                  !!!
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1076
void MacroAssembler::clear_mem(const Address& addr, unsigned size) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1077
  guarantee(size <= 256, "MacroAssembler::clear_mem: size too large");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1078
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1079
  if (size == 1) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1080
    z_mvi(addr, 0);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1081
    return;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1082
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1083
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1084
  switch (size) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1085
    case 2: z_mvhhi(addr, 0);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1086
      return;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1087
    case 4: z_mvhi(addr, 0);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1088
      return;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1089
    case 8: z_mvghi(addr, 0);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1090
      return;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1091
    default: ; // Fallthru to xc.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1092
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1093
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1094
  z_xc(addr, size, addr);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1095
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1096
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1097
void MacroAssembler::align(int modulus) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1098
  while (offset() % modulus != 0) z_nop();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1099
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1100
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1101
// Special version for non-relocateable code if required alignment
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1102
// is larger than CodeEntryAlignment.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1103
void MacroAssembler::align_address(int modulus) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1104
  while ((uintptr_t)pc() % modulus != 0) z_nop();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1105
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1106
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1107
Address MacroAssembler::argument_address(RegisterOrConstant arg_slot,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1108
                                         Register temp_reg,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1109
                                         int64_t extra_slot_offset) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1110
  // On Z, we can have index and disp in an Address. So don't call argument_offset,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1111
  // which issues an unnecessary add instruction.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1112
  int stackElementSize = Interpreter::stackElementSize;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1113
  int64_t offset = extra_slot_offset * stackElementSize;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1114
  const Register argbase = Z_esp;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1115
  if (arg_slot.is_constant()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1116
    offset += arg_slot.as_constant() * stackElementSize;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1117
    return Address(argbase, offset);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1118
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1119
  // else
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1120
  assert(temp_reg != noreg, "must specify");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1121
  assert(temp_reg != Z_ARG1, "base and index are conflicting");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1122
  z_sllg(temp_reg, arg_slot.as_register(), exact_log2(stackElementSize)); // tempreg = arg_slot << 3
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1123
  return Address(argbase, temp_reg, offset);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1124
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1125
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1126
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1127
//===================================================================
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1128
//===   START   C O N S T A N T S   I N   C O D E   S T R E A M   ===
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1129
//===================================================================
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1130
//===            P A T CH A B L E   C O N S T A N T S             ===
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1131
//===================================================================
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1132
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1133
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1134
//---------------------------------------------------
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1135
//  Load (patchable) constant into register
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1136
//---------------------------------------------------
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1137
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1138
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1139
// Load absolute address (and try to optimize).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1140
//   Note: This method is usable only for position-fixed code,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1141
//         referring to a position-fixed target location.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1142
//         If not so, relocations and patching must be used.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1143
void MacroAssembler::load_absolute_address(Register d, address addr) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1144
  assert(addr != NULL, "should not happen");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1145
  BLOCK_COMMENT("load_absolute_address:");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1146
  if (addr == NULL) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1147
    z_larl(d, pc()); // Dummy emit for size calc.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1148
    return;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1149
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1150
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1151
  if (RelAddr::is_in_range_of_RelAddr32(addr, pc())) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1152
    z_larl(d, addr);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1153
    return;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1154
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1155
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1156
  load_const_optimized(d, (long)addr);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1157
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1158
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1159
// Load a 64bit constant.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1160
// Patchable code sequence, but not atomically patchable.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1161
// Make sure to keep code size constant -> no value-dependent optimizations.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1162
// Do not kill condition code.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1163
void MacroAssembler::load_const(Register t, long x) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1164
  Assembler::z_iihf(t, (int)(x >> 32));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1165
  Assembler::z_iilf(t, (int)(x & 0xffffffff));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1166
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1167
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1168
// Load a 32bit constant into a 64bit register, sign-extend or zero-extend.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1169
// Patchable code sequence, but not atomically patchable.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1170
// Make sure to keep code size constant -> no value-dependent optimizations.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1171
// Do not kill condition code.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1172
void MacroAssembler::load_const_32to64(Register t, int64_t x, bool sign_extend) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1173
  if (sign_extend) { Assembler::z_lgfi(t, x); }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1174
  else             { Assembler::z_llilf(t, x); }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1175
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1176
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1177
// Load narrow oop constant, no decompression.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1178
void MacroAssembler::load_narrow_oop(Register t, narrowOop a) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1179
  assert(UseCompressedOops, "must be on to call this method");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1180
  load_const_32to64(t, a, false /*sign_extend*/);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1181
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1182
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1183
// Load narrow klass constant, compression required.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1184
void MacroAssembler::load_narrow_klass(Register t, Klass* k) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1185
  assert(UseCompressedClassPointers, "must be on to call this method");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1186
  narrowKlass encoded_k = Klass::encode_klass(k);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1187
  load_const_32to64(t, encoded_k, false /*sign_extend*/);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1188
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1189
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1190
//------------------------------------------------------
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1191
//  Compare (patchable) constant with register.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1192
//------------------------------------------------------
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1193
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1194
// Compare narrow oop in reg with narrow oop constant, no decompression.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1195
void MacroAssembler::compare_immediate_narrow_oop(Register oop1, narrowOop oop2) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1196
  assert(UseCompressedOops, "must be on to call this method");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1197
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1198
  Assembler::z_clfi(oop1, oop2);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1199
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1200
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1201
// Compare narrow oop in reg with narrow oop constant, no decompression.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1202
void MacroAssembler::compare_immediate_narrow_klass(Register klass1, Klass* klass2) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1203
  assert(UseCompressedClassPointers, "must be on to call this method");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1204
  narrowKlass encoded_k = Klass::encode_klass(klass2);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1205
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1206
  Assembler::z_clfi(klass1, encoded_k);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1207
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1208
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1209
//----------------------------------------------------------
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1210
//  Check which kind of load_constant we have here.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1211
//----------------------------------------------------------
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1212
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1213
// Detection of CPU version dependent load_const sequence.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1214
// The detection is valid only for code sequences generated by load_const,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1215
// not load_const_optimized.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1216
bool MacroAssembler::is_load_const(address a) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1217
  unsigned long inst1, inst2;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1218
  unsigned int  len1,  len2;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1219
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1220
  len1 = get_instruction(a, &inst1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1221
  len2 = get_instruction(a + len1, &inst2);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1222
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1223
  return is_z_iihf(inst1) && is_z_iilf(inst2);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1224
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1225
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1226
// Detection of CPU version dependent load_const_32to64 sequence.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1227
// Mostly used for narrow oops and narrow Klass pointers.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1228
// The detection is valid only for code sequences generated by load_const_32to64.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1229
bool MacroAssembler::is_load_const_32to64(address pos) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1230
  unsigned long inst1, inst2;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1231
  unsigned int len1;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1232
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1233
  len1 = get_instruction(pos, &inst1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1234
  return is_z_llilf(inst1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1235
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1236
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1237
// Detection of compare_immediate_narrow sequence.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1238
// The detection is valid only for code sequences generated by compare_immediate_narrow_oop.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1239
bool MacroAssembler::is_compare_immediate32(address pos) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1240
  return is_equal(pos, CLFI_ZOPC, RIL_MASK);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1241
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1242
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1243
// Detection of compare_immediate_narrow sequence.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1244
// The detection is valid only for code sequences generated by compare_immediate_narrow_oop.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1245
bool MacroAssembler::is_compare_immediate_narrow_oop(address pos) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1246
  return is_compare_immediate32(pos);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1247
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1248
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1249
// Detection of compare_immediate_narrow sequence.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1250
// The detection is valid only for code sequences generated by compare_immediate_narrow_klass.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1251
bool MacroAssembler::is_compare_immediate_narrow_klass(address pos) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1252
  return is_compare_immediate32(pos);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1253
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1254
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1255
//-----------------------------------
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1256
//  patch the load_constant
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1257
//-----------------------------------
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1258
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1259
// CPU-version dependend patching of load_const.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1260
void MacroAssembler::patch_const(address a, long x) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1261
  assert(is_load_const(a), "not a load of a constant");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1262
  set_imm32((address)a, (int) ((x >> 32) & 0xffffffff));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1263
  set_imm32((address)(a + 6), (int)(x & 0xffffffff));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1264
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1265
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1266
// Patching the value of CPU version dependent load_const_32to64 sequence.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1267
// The passed ptr MUST be in compressed format!
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1268
int MacroAssembler::patch_load_const_32to64(address pos, int64_t np) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1269
  assert(is_load_const_32to64(pos), "not a load of a narrow ptr (oop or klass)");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1270
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1271
  set_imm32(pos, np);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1272
  return 6;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1273
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1274
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1275
// Patching the value of CPU version dependent compare_immediate_narrow sequence.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1276
// The passed ptr MUST be in compressed format!
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1277
int MacroAssembler::patch_compare_immediate_32(address pos, int64_t np) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1278
  assert(is_compare_immediate32(pos), "not a compressed ptr compare");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1279
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1280
  set_imm32(pos, np);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1281
  return 6;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1282
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1283
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1284
// Patching the immediate value of CPU version dependent load_narrow_oop sequence.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1285
// The passed ptr must NOT be in compressed format!
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1286
int MacroAssembler::patch_load_narrow_oop(address pos, oop o) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1287
  assert(UseCompressedOops, "Can only patch compressed oops");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1288
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1289
  narrowOop no = oopDesc::encode_heap_oop(o);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1290
  return patch_load_const_32to64(pos, no);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1291
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1292
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1293
// Patching the immediate value of CPU version dependent load_narrow_klass sequence.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1294
// The passed ptr must NOT be in compressed format!
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1295
int MacroAssembler::patch_load_narrow_klass(address pos, Klass* k) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1296
  assert(UseCompressedClassPointers, "Can only patch compressed klass pointers");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1297
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1298
  narrowKlass nk = Klass::encode_klass(k);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1299
  return patch_load_const_32to64(pos, nk);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1300
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1301
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1302
// Patching the immediate value of CPU version dependent compare_immediate_narrow_oop sequence.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1303
// The passed ptr must NOT be in compressed format!
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1304
int MacroAssembler::patch_compare_immediate_narrow_oop(address pos, oop o) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1305
  assert(UseCompressedOops, "Can only patch compressed oops");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1306
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1307
  narrowOop no = oopDesc::encode_heap_oop(o);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1308
  return patch_compare_immediate_32(pos, no);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1309
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1310
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1311
// Patching the immediate value of CPU version dependent compare_immediate_narrow_klass sequence.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1312
// The passed ptr must NOT be in compressed format!
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1313
int MacroAssembler::patch_compare_immediate_narrow_klass(address pos, Klass* k) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1314
  assert(UseCompressedClassPointers, "Can only patch compressed klass pointers");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1315
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1316
  narrowKlass nk = Klass::encode_klass(k);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1317
  return patch_compare_immediate_32(pos, nk);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1318
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1319
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1320
//------------------------------------------------------------------------
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1321
//  Extract the constant from a load_constant instruction stream.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1322
//------------------------------------------------------------------------
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1323
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1324
// Get constant from a load_const sequence.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1325
long MacroAssembler::get_const(address a) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1326
  assert(is_load_const(a), "not a load of a constant");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1327
  unsigned long x;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1328
  x =  (((unsigned long) (get_imm32(a,0) & 0xffffffff)) << 32);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1329
  x |= (((unsigned long) (get_imm32(a,1) & 0xffffffff)));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1330
  return (long) x;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1331
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1332
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1333
//--------------------------------------
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1334
//  Store a constant in memory.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1335
//--------------------------------------
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1336
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1337
// General emitter to move a constant to memory.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1338
// The store is atomic.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1339
//  o Address must be given in RS format (no index register)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1340
//  o Displacement should be 12bit unsigned for efficiency. 20bit signed also supported.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1341
//  o Constant can be 1, 2, 4, or 8 bytes, signed or unsigned.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1342
//  o Memory slot can be 1, 2, 4, or 8 bytes, signed or unsigned.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1343
//  o Memory slot must be at least as wide as constant, will assert otherwise.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1344
//  o Signed constants will sign-extend, unsigned constants will zero-extend to slot width.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1345
int MacroAssembler::store_const(const Address &dest, long imm,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1346
                                unsigned int lm, unsigned int lc,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1347
                                Register scratch) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1348
  int64_t  disp = dest.disp();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1349
  Register base = dest.base();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1350
  assert(!dest.has_index(), "not supported");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1351
  assert((lm==1)||(lm==2)||(lm==4)||(lm==8), "memory   length not supported");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1352
  assert((lc==1)||(lc==2)||(lc==4)||(lc==8), "constant length not supported");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1353
  assert(lm>=lc, "memory slot too small");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1354
  assert(lc==8 || Immediate::is_simm(imm, lc*8), "const out of range");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1355
  assert(Displacement::is_validDisp(disp), "displacement out of range");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1356
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1357
  bool is_shortDisp = Displacement::is_shortDisp(disp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1358
  int store_offset = -1;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1359
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1360
  // For target len == 1 it's easy.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1361
  if (lm == 1) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1362
    store_offset = offset();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1363
    if (is_shortDisp) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1364
      z_mvi(disp, base, imm);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1365
      return store_offset;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1366
    } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1367
      z_mviy(disp, base, imm);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1368
      return store_offset;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1369
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1370
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1371
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1372
  // All the "good stuff" takes an unsigned displacement.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1373
  if (is_shortDisp) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1374
    // NOTE: Cannot use clear_mem for imm==0, because it is not atomic.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1375
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1376
    store_offset = offset();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1377
    switch (lm) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1378
      case 2:  // Lc == 1 handled correctly here, even for unsigned. Instruction does no widening.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1379
        z_mvhhi(disp, base, imm);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1380
        return store_offset;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1381
      case 4:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1382
        if (Immediate::is_simm16(imm)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1383
          z_mvhi(disp, base, imm);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1384
          return store_offset;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1385
        }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1386
        break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1387
      case 8:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1388
        if (Immediate::is_simm16(imm)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1389
          z_mvghi(disp, base, imm);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1390
          return store_offset;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1391
        }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1392
        break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1393
      default:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1394
        ShouldNotReachHere();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1395
        break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1396
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1397
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1398
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1399
  //  Can't optimize, so load value and store it.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1400
  guarantee(scratch != noreg, " need a scratch register here !");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1401
  if (imm != 0) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1402
    load_const_optimized(scratch, imm);  // Preserves CC anyway.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1403
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1404
    // Leave CC alone!!
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1405
    (void) clear_reg(scratch, true, false); // Indicate unused result.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1406
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1407
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1408
  store_offset = offset();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1409
  if (is_shortDisp) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1410
    switch (lm) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1411
      case 2:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1412
        z_sth(scratch, disp, Z_R0, base);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1413
        return store_offset;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1414
      case 4:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1415
        z_st(scratch, disp, Z_R0, base);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1416
        return store_offset;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1417
      case 8:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1418
        z_stg(scratch, disp, Z_R0, base);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1419
        return store_offset;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1420
      default:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1421
        ShouldNotReachHere();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1422
        break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1423
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1424
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1425
    switch (lm) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1426
      case 2:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1427
        z_sthy(scratch, disp, Z_R0, base);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1428
        return store_offset;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1429
      case 4:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1430
        z_sty(scratch, disp, Z_R0, base);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1431
        return store_offset;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1432
      case 8:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1433
        z_stg(scratch, disp, Z_R0, base);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1434
        return store_offset;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1435
      default:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1436
        ShouldNotReachHere();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1437
        break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1438
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1439
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1440
  return -1; // should not reach here
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1441
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1442
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1443
//===================================================================
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1444
//===       N O T   P A T CH A B L E   C O N S T A N T S          ===
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1445
//===================================================================
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1446
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1447
// Load constant x into register t with a fast instrcution sequence
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1448
// depending on the bits in x. Preserves CC under all circumstances.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1449
int MacroAssembler::load_const_optimized_rtn_len(Register t, long x, bool emit) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1450
  if (x == 0) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1451
    int len;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1452
    if (emit) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1453
      len = clear_reg(t, true, false);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1454
    } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1455
      len = 4;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1456
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1457
    return len;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1458
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1459
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1460
  if (Immediate::is_simm16(x)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1461
    if (emit) { z_lghi(t, x); }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1462
    return 4;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1463
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1464
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1465
  // 64 bit value: | part1 | part2 | part3 | part4 |
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1466
  // At least one part is not zero!
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1467
  int part1 = ((x >> 32) & 0xffff0000) >> 16;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1468
  int part2 = (x >> 32) & 0x0000ffff;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1469
  int part3 = (x & 0xffff0000) >> 16;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1470
  int part4 = (x & 0x0000ffff);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1471
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1472
  // Lower word only (unsigned).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1473
  if ((part1 == 0) && (part2 == 0)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1474
    if (part3 == 0) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1475
      if (emit) z_llill(t, part4);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1476
      return 4;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1477
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1478
    if (part4 == 0) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1479
      if (emit) z_llilh(t, part3);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1480
      return 4;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1481
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1482
    if (emit) z_llilf(t, (int)(x & 0xffffffff));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1483
    return 6;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1484
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1485
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1486
  // Upper word only.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1487
  if ((part3 == 0) && (part4 == 0)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1488
    if (part1 == 0) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1489
      if (emit) z_llihl(t, part2);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1490
      return 4;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1491
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1492
    if (part2 == 0) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1493
      if (emit) z_llihh(t, part1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1494
      return 4;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1495
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1496
    if (emit) z_llihf(t, (int)(x >> 32));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1497
    return 6;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1498
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1499
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1500
  // Lower word only (signed).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1501
  if ((part1 == 0x0000ffff) && (part2 == 0x0000ffff) && ((part3 & 0x00008000) != 0)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1502
    if (emit) z_lgfi(t, (int)(x & 0xffffffff));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1503
    return 6;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1504
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1505
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1506
  int len = 0;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1507
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1508
  if ((part1 == 0) || (part2 == 0)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1509
    if (part1 == 0) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1510
      if (emit) z_llihl(t, part2);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1511
      len += 4;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1512
    } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1513
      if (emit) z_llihh(t, part1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1514
      len += 4;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1515
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1516
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1517
    if (emit) z_llihf(t, (int)(x >> 32));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1518
    len += 6;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1519
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1520
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1521
  if ((part3 == 0) || (part4 == 0)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1522
    if (part3 == 0) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1523
      if (emit) z_iill(t, part4);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1524
      len += 4;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1525
    } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1526
      if (emit) z_iilh(t, part3);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1527
      len += 4;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1528
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1529
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1530
    if (emit) z_iilf(t, (int)(x & 0xffffffff));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1531
    len += 6;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1532
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1533
  return len;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1534
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1535
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1536
//=====================================================================
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1537
//===     H I G H E R   L E V E L   B R A N C H   E M I T T E R S   ===
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1538
//=====================================================================
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1539
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1540
// Note: In the worst case, one of the scratch registers is destroyed!!!
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1541
void MacroAssembler::compare32_and_branch(Register r1, RegisterOrConstant x2, branch_condition cond, Label& lbl) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1542
  // Right operand is constant.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1543
  if (x2.is_constant()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1544
    jlong value = x2.as_constant();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1545
    compare_and_branch_optimized(r1, value, cond, lbl, /*len64=*/false, /*has_sign=*/true);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1546
    return;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1547
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1548
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1549
  // Right operand is in register.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1550
  compare_and_branch_optimized(r1, x2.as_register(), cond, lbl, /*len64=*/false, /*has_sign=*/true);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1551
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1552
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1553
// Note: In the worst case, one of the scratch registers is destroyed!!!
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1554
void MacroAssembler::compareU32_and_branch(Register r1, RegisterOrConstant x2, branch_condition cond, Label& lbl) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1555
  // Right operand is constant.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1556
  if (x2.is_constant()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1557
    jlong value = x2.as_constant();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1558
    compare_and_branch_optimized(r1, value, cond, lbl, /*len64=*/false, /*has_sign=*/false);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1559
    return;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1560
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1561
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1562
  // Right operand is in register.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1563
  compare_and_branch_optimized(r1, x2.as_register(), cond, lbl, /*len64=*/false, /*has_sign=*/false);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1564
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1565
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1566
// Note: In the worst case, one of the scratch registers is destroyed!!!
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1567
void MacroAssembler::compare64_and_branch(Register r1, RegisterOrConstant x2, branch_condition cond, Label& lbl) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1568
  // Right operand is constant.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1569
  if (x2.is_constant()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1570
    jlong value = x2.as_constant();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1571
    compare_and_branch_optimized(r1, value, cond, lbl, /*len64=*/true, /*has_sign=*/true);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1572
    return;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1573
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1574
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1575
  // Right operand is in register.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1576
  compare_and_branch_optimized(r1, x2.as_register(), cond, lbl, /*len64=*/true, /*has_sign=*/true);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1577
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1578
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1579
void MacroAssembler::compareU64_and_branch(Register r1, RegisterOrConstant x2, branch_condition cond, Label& lbl) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1580
  // Right operand is constant.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1581
  if (x2.is_constant()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1582
    jlong value = x2.as_constant();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1583
    compare_and_branch_optimized(r1, value, cond, lbl, /*len64=*/true, /*has_sign=*/false);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1584
    return;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1585
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1586
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1587
  // Right operand is in register.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1588
  compare_and_branch_optimized(r1, x2.as_register(), cond, lbl, /*len64=*/true, /*has_sign=*/false);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1589
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1590
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1591
// Generate an optimal branch to the branch target.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1592
// Optimal means that a relative branch (brc or brcl) is used if the
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1593
// branch distance is short enough. Loading the target address into a
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1594
// register and branching via reg is used as fallback only.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1595
//
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1596
// Used registers:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1597
//   Z_R1 - work reg. Holds branch target address.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1598
//          Used in fallback case only.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1599
//
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1600
// This version of branch_optimized is good for cases where the target address is known
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1601
// and constant, i.e. is never changed (no relocation, no patching).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1602
void MacroAssembler::branch_optimized(Assembler::branch_condition cond, address branch_addr) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1603
  address branch_origin = pc();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1604
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1605
  if (RelAddr::is_in_range_of_RelAddr16(branch_addr, branch_origin)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1606
    z_brc(cond, branch_addr);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1607
  } else if (RelAddr::is_in_range_of_RelAddr32(branch_addr, branch_origin)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1608
    z_brcl(cond, branch_addr);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1609
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1610
    load_const_optimized(Z_R1, branch_addr);  // CC must not get killed by load_const_optimized.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1611
    z_bcr(cond, Z_R1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1612
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1613
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1614
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1615
// This version of branch_optimized is good for cases where the target address
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1616
// is potentially not yet known at the time the code is emitted.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1617
//
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1618
// One very common case is a branch to an unbound label which is handled here.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1619
// The caller might know (or hope) that the branch distance is short enough
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1620
// to be encoded in a 16bit relative address. In this case he will pass a
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1621
// NearLabel branch_target.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1622
// Care must be taken with unbound labels. Each call to target(label) creates
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1623
// an entry in the patch queue for that label to patch all references of the label
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1624
// once it gets bound. Those recorded patch locations must be patchable. Otherwise,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1625
// an assertion fires at patch time.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1626
void MacroAssembler::branch_optimized(Assembler::branch_condition cond, Label& branch_target) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1627
  if (branch_target.is_bound()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1628
    address branch_addr = target(branch_target);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1629
    branch_optimized(cond, branch_addr);
46272
3cee5c1f3459 8173465: Introduce NearLabel for branches known to be short.
goetz
parents: 42065
diff changeset
  1630
  } else if (branch_target.is_near()) {
3cee5c1f3459 8173465: Introduce NearLabel for branches known to be short.
goetz
parents: 42065
diff changeset
  1631
    z_brc(cond, branch_target);  // Caller assures that the target will be in range for z_brc.
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1632
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1633
    z_brcl(cond, branch_target); // Let's hope target is in range. Otherwise, we will abort at patch time.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1634
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1635
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1636
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1637
// Generate an optimal compare and branch to the branch target.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1638
// Optimal means that a relative branch (clgrj, brc or brcl) is used if the
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1639
// branch distance is short enough. Loading the target address into a
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1640
// register and branching via reg is used as fallback only.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1641
//
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1642
// Input:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1643
//   r1 - left compare operand
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1644
//   r2 - right compare operand
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1645
void MacroAssembler::compare_and_branch_optimized(Register r1,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1646
                                                  Register r2,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1647
                                                  Assembler::branch_condition cond,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1648
                                                  address  branch_addr,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1649
                                                  bool     len64,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1650
                                                  bool     has_sign) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1651
  unsigned int casenum = (len64?2:0)+(has_sign?0:1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1652
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1653
  address branch_origin = pc();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1654
  if (VM_Version::has_CompareBranch() && RelAddr::is_in_range_of_RelAddr16(branch_addr, branch_origin)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1655
    switch (casenum) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1656
      case 0: z_crj( r1, r2, cond, branch_addr); break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1657
      case 1: z_clrj (r1, r2, cond, branch_addr); break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1658
      case 2: z_cgrj(r1, r2, cond, branch_addr); break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1659
      case 3: z_clgrj(r1, r2, cond, branch_addr); break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1660
      default: ShouldNotReachHere(); break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1661
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1662
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1663
    switch (casenum) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1664
      case 0: z_cr( r1, r2); break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1665
      case 1: z_clr(r1, r2); break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1666
      case 2: z_cgr(r1, r2); break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1667
      case 3: z_clgr(r1, r2); break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1668
      default: ShouldNotReachHere(); break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1669
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1670
    branch_optimized(cond, branch_addr);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1671
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1672
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1673
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1674
// Generate an optimal compare and branch to the branch target.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1675
// Optimal means that a relative branch (clgij, brc or brcl) is used if the
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1676
// branch distance is short enough. Loading the target address into a
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1677
// register and branching via reg is used as fallback only.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1678
//
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1679
// Input:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1680
//   r1 - left compare operand (in register)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1681
//   x2 - right compare operand (immediate)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1682
void MacroAssembler::compare_and_branch_optimized(Register r1,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1683
                                                  jlong    x2,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1684
                                                  Assembler::branch_condition cond,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1685
                                                  Label&   branch_target,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1686
                                                  bool     len64,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1687
                                                  bool     has_sign) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1688
  address      branch_origin = pc();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1689
  bool         x2_imm8       = (has_sign && Immediate::is_simm8(x2)) || (!has_sign && Immediate::is_uimm8(x2));
46272
3cee5c1f3459 8173465: Introduce NearLabel for branches known to be short.
goetz
parents: 42065
diff changeset
  1690
  bool         is_RelAddr16  = branch_target.is_near() ||
3cee5c1f3459 8173465: Introduce NearLabel for branches known to be short.
goetz
parents: 42065
diff changeset
  1691
                               (branch_target.is_bound() &&
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1692
                                RelAddr::is_in_range_of_RelAddr16(target(branch_target), branch_origin));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1693
  unsigned int casenum       = (len64?2:0)+(has_sign?0:1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1694
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1695
  if (VM_Version::has_CompareBranch() && is_RelAddr16 && x2_imm8) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1696
    switch (casenum) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1697
      case 0: z_cij( r1, x2, cond, branch_target); break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1698
      case 1: z_clij(r1, x2, cond, branch_target); break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1699
      case 2: z_cgij(r1, x2, cond, branch_target); break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1700
      case 3: z_clgij(r1, x2, cond, branch_target); break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1701
      default: ShouldNotReachHere(); break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1702
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1703
    return;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1704
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1705
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1706
  if (x2 == 0) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1707
    switch (casenum) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1708
      case 0: z_ltr(r1, r1); break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1709
      case 1: z_ltr(r1, r1); break; // Caution: unsigned test only provides zero/notZero indication!
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1710
      case 2: z_ltgr(r1, r1); break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1711
      case 3: z_ltgr(r1, r1); break; // Caution: unsigned test only provides zero/notZero indication!
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1712
      default: ShouldNotReachHere(); break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1713
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1714
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1715
    if ((has_sign && Immediate::is_simm16(x2)) || (!has_sign && Immediate::is_uimm(x2, 15))) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1716
      switch (casenum) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1717
        case 0: z_chi(r1, x2); break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1718
        case 1: z_chi(r1, x2); break; // positive immediate < 2**15
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1719
        case 2: z_cghi(r1, x2); break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1720
        case 3: z_cghi(r1, x2); break; // positive immediate < 2**15
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1721
        default: break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1722
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1723
    } else if ( (has_sign && Immediate::is_simm32(x2)) || (!has_sign && Immediate::is_uimm32(x2)) ) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1724
      switch (casenum) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1725
        case 0: z_cfi( r1, x2); break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1726
        case 1: z_clfi(r1, x2); break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1727
        case 2: z_cgfi(r1, x2); break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1728
        case 3: z_clgfi(r1, x2); break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1729
        default: ShouldNotReachHere(); break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1730
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1731
    } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1732
      // No instruction with immediate operand possible, so load into register.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1733
      Register scratch = (r1 != Z_R0) ? Z_R0 : Z_R1;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1734
      load_const_optimized(scratch, x2);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1735
      switch (casenum) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1736
        case 0: z_cr( r1, scratch); break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1737
        case 1: z_clr(r1, scratch); break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1738
        case 2: z_cgr(r1, scratch); break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1739
        case 3: z_clgr(r1, scratch); break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1740
        default: ShouldNotReachHere(); break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1741
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1742
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1743
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1744
  branch_optimized(cond, branch_target);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1745
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1746
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1747
// Generate an optimal compare and branch to the branch target.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1748
// Optimal means that a relative branch (clgrj, brc or brcl) is used if the
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1749
// branch distance is short enough. Loading the target address into a
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1750
// register and branching via reg is used as fallback only.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1751
//
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1752
// Input:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1753
//   r1 - left compare operand
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1754
//   r2 - right compare operand
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1755
void MacroAssembler::compare_and_branch_optimized(Register r1,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1756
                                                  Register r2,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1757
                                                  Assembler::branch_condition cond,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1758
                                                  Label&   branch_target,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1759
                                                  bool     len64,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1760
                                                  bool     has_sign) {
46272
3cee5c1f3459 8173465: Introduce NearLabel for branches known to be short.
goetz
parents: 42065
diff changeset
  1761
  unsigned int casenum = (len64 ? 2 : 0) + (has_sign ? 0 : 1);
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1762
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1763
  if (branch_target.is_bound()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1764
    address branch_addr = target(branch_target);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1765
    compare_and_branch_optimized(r1, r2, cond, branch_addr, len64, has_sign);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1766
  } else {
46272
3cee5c1f3459 8173465: Introduce NearLabel for branches known to be short.
goetz
parents: 42065
diff changeset
  1767
    if (VM_Version::has_CompareBranch() && branch_target.is_near()) {
3cee5c1f3459 8173465: Introduce NearLabel for branches known to be short.
goetz
parents: 42065
diff changeset
  1768
      switch (casenum) {
3cee5c1f3459 8173465: Introduce NearLabel for branches known to be short.
goetz
parents: 42065
diff changeset
  1769
        case 0: z_crj(  r1, r2, cond, branch_target); break;
3cee5c1f3459 8173465: Introduce NearLabel for branches known to be short.
goetz
parents: 42065
diff changeset
  1770
        case 1: z_clrj( r1, r2, cond, branch_target); break;
3cee5c1f3459 8173465: Introduce NearLabel for branches known to be short.
goetz
parents: 42065
diff changeset
  1771
        case 2: z_cgrj( r1, r2, cond, branch_target); break;
3cee5c1f3459 8173465: Introduce NearLabel for branches known to be short.
goetz
parents: 42065
diff changeset
  1772
        case 3: z_clgrj(r1, r2, cond, branch_target); break;
3cee5c1f3459 8173465: Introduce NearLabel for branches known to be short.
goetz
parents: 42065
diff changeset
  1773
        default: ShouldNotReachHere(); break;
3cee5c1f3459 8173465: Introduce NearLabel for branches known to be short.
goetz
parents: 42065
diff changeset
  1774
      }
3cee5c1f3459 8173465: Introduce NearLabel for branches known to be short.
goetz
parents: 42065
diff changeset
  1775
    } else {
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1776
      switch (casenum) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1777
        case 0: z_cr( r1, r2); break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1778
        case 1: z_clr(r1, r2); break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1779
        case 2: z_cgr(r1, r2); break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1780
        case 3: z_clgr(r1, r2); break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1781
        default: ShouldNotReachHere(); break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1782
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1783
      branch_optimized(cond, branch_target);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1784
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1785
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1786
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1787
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1788
//===========================================================================
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1789
//===   END     H I G H E R   L E V E L   B R A N C H   E M I T T E R S   ===
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1790
//===========================================================================
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1791
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1792
AddressLiteral MacroAssembler::allocate_metadata_address(Metadata* obj) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1793
  assert(oop_recorder() != NULL, "this assembler needs an OopRecorder");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1794
  int index = oop_recorder()->allocate_metadata_index(obj);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1795
  RelocationHolder rspec = metadata_Relocation::spec(index);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1796
  return AddressLiteral((address)obj, rspec);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1797
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1798
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1799
AddressLiteral MacroAssembler::constant_metadata_address(Metadata* obj) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1800
  assert(oop_recorder() != NULL, "this assembler needs an OopRecorder");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1801
  int index = oop_recorder()->find_index(obj);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1802
  RelocationHolder rspec = metadata_Relocation::spec(index);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1803
  return AddressLiteral((address)obj, rspec);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1804
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1805
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1806
AddressLiteral MacroAssembler::allocate_oop_address(jobject obj) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1807
  assert(oop_recorder() != NULL, "this assembler needs an OopRecorder");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1808
  int oop_index = oop_recorder()->allocate_oop_index(obj);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1809
  return AddressLiteral(address(obj), oop_Relocation::spec(oop_index));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1810
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1811
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1812
AddressLiteral MacroAssembler::constant_oop_address(jobject obj) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1813
  assert(oop_recorder() != NULL, "this assembler needs an OopRecorder");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1814
  int oop_index = oop_recorder()->find_index(obj);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1815
  return AddressLiteral(address(obj), oop_Relocation::spec(oop_index));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1816
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1817
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1818
// NOTE: destroys r
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1819
void MacroAssembler::c2bool(Register r, Register t) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1820
  z_lcr(t, r);   // t = -r
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1821
  z_or(r, t);    // r = -r OR r
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1822
  z_srl(r, 31);  // Yields 0 if r was 0, 1 otherwise.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1823
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1824
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1825
RegisterOrConstant MacroAssembler::delayed_value_impl(intptr_t* delayed_value_addr,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1826
                                                      Register tmp,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1827
                                                      int offset) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1828
  intptr_t value = *delayed_value_addr;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1829
  if (value != 0) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1830
    return RegisterOrConstant(value + offset);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1831
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1832
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1833
  BLOCK_COMMENT("delayed_value {");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1834
  // Load indirectly to solve generation ordering problem.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1835
  load_absolute_address(tmp, (address) delayed_value_addr); // tmp = a;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1836
  z_lg(tmp, 0, tmp);                   // tmp = *tmp;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1837
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1838
#ifdef ASSERT
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1839
  NearLabel L;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1840
  compare64_and_branch(tmp, (intptr_t)0L, Assembler::bcondNotEqual, L);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1841
  z_illtrap();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1842
  bind(L);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1843
#endif
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1844
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1845
  if (offset != 0) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1846
    z_agfi(tmp, offset);               // tmp = tmp + offset;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1847
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1848
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1849
  BLOCK_COMMENT("} delayed_value");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1850
  return RegisterOrConstant(tmp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1851
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1852
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1853
// Patch instruction `inst' at offset `inst_pos' to refer to `dest_pos'
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1854
// and return the resulting instruction.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1855
// Dest_pos and inst_pos are 32 bit only. These parms can only designate
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1856
// relative positions.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1857
// Use correct argument types. Do not pre-calculate distance.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1858
unsigned long MacroAssembler::patched_branch(address dest_pos, unsigned long inst, address inst_pos) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1859
  int c = 0;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1860
  unsigned long patched_inst = 0;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1861
  if (is_call_pcrelative_short(inst) ||
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1862
      is_branch_pcrelative_short(inst) ||
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1863
      is_branchoncount_pcrelative_short(inst) ||
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1864
      is_branchonindex32_pcrelative_short(inst)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1865
    c = 1;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1866
    int m = fmask(15, 0);    // simm16(-1, 16, 32);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1867
    int v = simm16(RelAddr::pcrel_off16(dest_pos, inst_pos), 16, 32);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1868
    patched_inst = (inst & ~m) | v;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1869
  } else if (is_compareandbranch_pcrelative_short(inst)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1870
    c = 2;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1871
    long m = fmask(31, 16);  // simm16(-1, 16, 48);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1872
    long v = simm16(RelAddr::pcrel_off16(dest_pos, inst_pos), 16, 48);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1873
    patched_inst = (inst & ~m) | v;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1874
  } else if (is_branchonindex64_pcrelative_short(inst)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1875
    c = 3;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1876
    long m = fmask(31, 16);  // simm16(-1, 16, 48);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1877
    long v = simm16(RelAddr::pcrel_off16(dest_pos, inst_pos), 16, 48);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1878
    patched_inst = (inst & ~m) | v;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1879
  } else if (is_call_pcrelative_long(inst) || is_branch_pcrelative_long(inst)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1880
    c = 4;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1881
    long m = fmask(31, 0);  // simm32(-1, 16, 48);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1882
    long v = simm32(RelAddr::pcrel_off32(dest_pos, inst_pos), 16, 48);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1883
    patched_inst = (inst & ~m) | v;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1884
  } else if (is_pcrelative_long(inst)) { // These are the non-branch pc-relative instructions.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1885
    c = 5;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1886
    long m = fmask(31, 0);  // simm32(-1, 16, 48);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1887
    long v = simm32(RelAddr::pcrel_off32(dest_pos, inst_pos), 16, 48);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1888
    patched_inst = (inst & ~m) | v;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1889
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1890
    print_dbg_msg(tty, inst, "not a relative branch", 0);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1891
    dump_code_range(tty, inst_pos, 32, "not a pcrelative branch");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1892
    ShouldNotReachHere();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1893
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1894
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1895
  long new_off = get_pcrel_offset(patched_inst);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1896
  if (new_off != (dest_pos-inst_pos)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1897
    tty->print_cr("case %d: dest_pos = %p, inst_pos = %p, disp = %ld(%12.12lx)", c, dest_pos, inst_pos, new_off, new_off);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1898
    print_dbg_msg(tty, inst,         "<- original instruction: branch patching error", 0);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1899
    print_dbg_msg(tty, patched_inst, "<- patched  instruction: branch patching error", 0);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1900
#ifdef LUCY_DBG
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1901
    VM_Version::z_SIGSEGV();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1902
#endif
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1903
    ShouldNotReachHere();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1904
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1905
  return patched_inst;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1906
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1907
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1908
// Only called when binding labels (share/vm/asm/assembler.cpp)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1909
// Pass arguments as intended. Do not pre-calculate distance.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1910
void MacroAssembler::pd_patch_instruction(address branch, address target) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1911
  unsigned long stub_inst;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1912
  int           inst_len = get_instruction(branch, &stub_inst);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1913
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1914
  set_instruction(branch, patched_branch(target, stub_inst, branch), inst_len);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1915
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1916
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1917
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1918
// Extract relative address (aka offset).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1919
// inv_simm16 works for 4-byte instructions only.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1920
// compare and branch instructions are 6-byte and have a 16bit offset "in the middle".
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1921
long MacroAssembler::get_pcrel_offset(unsigned long inst) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1922
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1923
  if (MacroAssembler::is_pcrelative_short(inst)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1924
    if (((inst&0xFFFFffff00000000UL) == 0) && ((inst&0x00000000FFFF0000UL) != 0)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1925
      return RelAddr::inv_pcrel_off16(inv_simm16(inst));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1926
    } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1927
      return RelAddr::inv_pcrel_off16(inv_simm16_48(inst));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1928
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1929
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1930
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1931
  if (MacroAssembler::is_pcrelative_long(inst)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1932
    return RelAddr::inv_pcrel_off32(inv_simm32(inst));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1933
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1934
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1935
  print_dbg_msg(tty, inst, "not a pcrelative instruction", 6);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1936
#ifdef LUCY_DBG
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1937
  VM_Version::z_SIGSEGV();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1938
#else
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1939
  ShouldNotReachHere();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1940
#endif
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1941
  return -1;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1942
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1943
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1944
long MacroAssembler::get_pcrel_offset(address pc) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1945
  unsigned long inst;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1946
  unsigned int  len = get_instruction(pc, &inst);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1947
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1948
#ifdef ASSERT
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1949
  long offset;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1950
  if (MacroAssembler::is_pcrelative_short(inst) || MacroAssembler::is_pcrelative_long(inst)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1951
    offset = get_pcrel_offset(inst);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1952
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1953
    offset = -1;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1954
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1955
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1956
  if (offset == -1) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1957
    dump_code_range(tty, pc, 32, "not a pcrelative instruction");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1958
#ifdef LUCY_DBG
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1959
    VM_Version::z_SIGSEGV();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1960
#else
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1961
    ShouldNotReachHere();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1962
#endif
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1963
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1964
  return offset;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1965
#else
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1966
  return get_pcrel_offset(inst);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1967
#endif // ASSERT
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1968
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1969
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1970
// Get target address from pc-relative instructions.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1971
address MacroAssembler::get_target_addr_pcrel(address pc) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1972
  assert(is_pcrelative_long(pc), "not a pcrelative instruction");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1973
  return pc + get_pcrel_offset(pc);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1974
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1975
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1976
// Patch pc relative load address.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1977
void MacroAssembler::patch_target_addr_pcrel(address pc, address con) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1978
  unsigned long inst;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1979
  // Offset is +/- 2**32 -> use long.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1980
  ptrdiff_t distance = con - pc;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1981
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1982
  get_instruction(pc, &inst);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1983
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1984
  if (is_pcrelative_short(inst)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1985
    *(short *)(pc+2) = RelAddr::pcrel_off16(con, pc);  // Instructions are at least 2-byte aligned, no test required.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1986
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1987
    // Some extra safety net.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1988
    if (!RelAddr::is_in_range_of_RelAddr16(distance)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1989
      print_dbg_msg(tty, inst, "distance out of range (16bit)", 4);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1990
      dump_code_range(tty, pc, 32, "distance out of range (16bit)");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1991
      guarantee(RelAddr::is_in_range_of_RelAddr16(distance), "too far away (more than +/- 2**16");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1992
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1993
    return;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1994
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1995
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1996
  if (is_pcrelative_long(inst)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1997
    *(int *)(pc+2)   = RelAddr::pcrel_off32(con, pc);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1998
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1999
    // Some Extra safety net.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2000
    if (!RelAddr::is_in_range_of_RelAddr32(distance)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2001
      print_dbg_msg(tty, inst, "distance out of range (32bit)", 6);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2002
      dump_code_range(tty, pc, 32, "distance out of range (32bit)");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2003
      guarantee(RelAddr::is_in_range_of_RelAddr32(distance), "too far away (more than +/- 2**32");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2004
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2005
    return;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2006
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2007
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2008
  guarantee(false, "not a pcrelative instruction to patch!");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2009
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2010
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2011
// "Current PC" here means the address just behind the basr instruction.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2012
address MacroAssembler::get_PC(Register result) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2013
  z_basr(result, Z_R0); // Don't branch, just save next instruction address in result.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2014
  return pc();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2015
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2016
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2017
// Get current PC + offset.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2018
// Offset given in bytes, must be even!
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2019
// "Current PC" here means the address of the larl instruction plus the given offset.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2020
address MacroAssembler::get_PC(Register result, int64_t offset) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2021
  address here = pc();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2022
  z_larl(result, offset/2); // Save target instruction address in result.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2023
  return here + offset;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2024
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2025
48332
651a95f30dfb 8193257: PPC64, s390 implementation for Thread-local handshakes
mdoerr
parents: 48331
diff changeset
  2026
void MacroAssembler::instr_size(Register size, Register pc) {
651a95f30dfb 8193257: PPC64, s390 implementation for Thread-local handshakes
mdoerr
parents: 48331
diff changeset
  2027
  // Extract 2 most significant bits of current instruction.
651a95f30dfb 8193257: PPC64, s390 implementation for Thread-local handshakes
mdoerr
parents: 48331
diff changeset
  2028
  z_llgc(size, Address(pc));
651a95f30dfb 8193257: PPC64, s390 implementation for Thread-local handshakes
mdoerr
parents: 48331
diff changeset
  2029
  z_srl(size, 6);
651a95f30dfb 8193257: PPC64, s390 implementation for Thread-local handshakes
mdoerr
parents: 48331
diff changeset
  2030
  // Compute (x+3)&6 which translates 0->2, 1->4, 2->4, 3->6.
651a95f30dfb 8193257: PPC64, s390 implementation for Thread-local handshakes
mdoerr
parents: 48331
diff changeset
  2031
  z_ahi(size, 3);
651a95f30dfb 8193257: PPC64, s390 implementation for Thread-local handshakes
mdoerr
parents: 48331
diff changeset
  2032
  z_nill(size, 6);
651a95f30dfb 8193257: PPC64, s390 implementation for Thread-local handshakes
mdoerr
parents: 48331
diff changeset
  2033
}
651a95f30dfb 8193257: PPC64, s390 implementation for Thread-local handshakes
mdoerr
parents: 48331
diff changeset
  2034
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2035
// Resize_frame with SP(new) = SP(old) - [offset].
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2036
void MacroAssembler::resize_frame_sub(Register offset, Register fp, bool load_fp)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2037
{
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2038
  assert_different_registers(offset, fp, Z_SP);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2039
  if (load_fp) { z_lg(fp, _z_abi(callers_sp), Z_SP); }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2040
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2041
  z_sgr(Z_SP, offset);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2042
  z_stg(fp, _z_abi(callers_sp), Z_SP);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2043
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2044
46726
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  2045
// Resize_frame with SP(new) = [newSP] + offset.
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  2046
//   This emitter is useful if we already have calculated a pointer
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  2047
//   into the to-be-allocated stack space, e.g. with special alignment properties,
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  2048
//   but need some additional space, e.g. for spilling.
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  2049
//   newSP    is the pre-calculated pointer. It must not be modified.
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  2050
//   fp       holds, or is filled with, the frame pointer.
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  2051
//   offset   is the additional increment which is added to addr to form the new SP.
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  2052
//            Note: specify a negative value to reserve more space!
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  2053
//   load_fp == true  only indicates that fp is not pre-filled with the frame pointer.
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  2054
//                    It does not guarantee that fp contains the frame pointer at the end.
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  2055
void MacroAssembler::resize_frame_abs_with_offset(Register newSP, Register fp, int offset, bool load_fp) {
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  2056
  assert_different_registers(newSP, fp, Z_SP);
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  2057
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  2058
  if (load_fp) {
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  2059
    z_lg(fp, _z_abi(callers_sp), Z_SP);
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  2060
  }
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  2061
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  2062
  add2reg(Z_SP, offset, newSP);
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  2063
  z_stg(fp, _z_abi(callers_sp), Z_SP);
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  2064
}
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  2065
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  2066
// Resize_frame with SP(new) = [newSP].
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  2067
//   load_fp == true  only indicates that fp is not pre-filled with the frame pointer.
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  2068
//                    It does not guarantee that fp contains the frame pointer at the end.
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  2069
void MacroAssembler::resize_frame_absolute(Register newSP, Register fp, bool load_fp) {
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  2070
  assert_different_registers(newSP, fp, Z_SP);
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  2071
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  2072
  if (load_fp) {
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  2073
    z_lg(fp, _z_abi(callers_sp), Z_SP); // need to use load/store.
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  2074
  }
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  2075
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  2076
  z_lgr(Z_SP, newSP);
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  2077
  if (newSP != Z_R0) { // make sure we generate correct code, no matter what register newSP uses.
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  2078
    z_stg(fp, _z_abi(callers_sp), newSP);
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2079
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2080
    z_stg(fp, _z_abi(callers_sp), Z_SP);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2081
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2082
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2083
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2084
// Resize_frame with SP(new) = SP(old) + offset.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2085
void MacroAssembler::resize_frame(RegisterOrConstant offset, Register fp, bool load_fp) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2086
  assert_different_registers(fp, Z_SP);
46726
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  2087
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  2088
  if (load_fp) {
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  2089
    z_lg(fp, _z_abi(callers_sp), Z_SP);
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  2090
  }
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  2091
  add64(Z_SP, offset);
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  2092
  z_stg(fp, _z_abi(callers_sp), Z_SP);
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2093
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2094
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2095
void MacroAssembler::push_frame(Register bytes, Register old_sp, bool copy_sp, bool bytes_with_inverted_sign) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2096
#ifdef ASSERT
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2097
  assert_different_registers(bytes, old_sp, Z_SP);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2098
  if (!copy_sp) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2099
    z_cgr(old_sp, Z_SP);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2100
    asm_assert_eq("[old_sp]!=[Z_SP]", 0x211);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2101
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2102
#endif
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2103
  if (copy_sp) { z_lgr(old_sp, Z_SP); }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2104
  if (bytes_with_inverted_sign) {
46726
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  2105
    z_agr(Z_SP, bytes);
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2106
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2107
    z_sgr(Z_SP, bytes); // Z_sgfr sufficient, but probably not faster.
46726
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  2108
  }
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  2109
  z_stg(old_sp, _z_abi(callers_sp), Z_SP);
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2110
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2111
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2112
unsigned int MacroAssembler::push_frame(unsigned int bytes, Register scratch) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2113
  long offset = Assembler::align(bytes, frame::alignment_in_bytes);
46726
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  2114
  assert(offset > 0, "should push a frame with positive size, size = %ld.", offset);
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  2115
  assert(Displacement::is_validDisp(-offset), "frame size out of range, size = %ld", offset);
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  2116
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  2117
  // We must not write outside the current stack bounds (given by Z_SP).
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  2118
  // Thus, we have to first update Z_SP and then store the previous SP as stack linkage.
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  2119
  // We rely on Z_R0 by default to be available as scratch.
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  2120
  z_lgr(scratch, Z_SP);
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  2121
  add2reg(Z_SP, -offset);
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  2122
  z_stg(scratch, _z_abi(callers_sp), Z_SP);
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  2123
#ifdef ASSERT
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  2124
  // Just make sure nobody uses the value in the default scratch register.
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  2125
  // When another register is used, the caller might rely on it containing the frame pointer.
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  2126
  if (scratch == Z_R0) {
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  2127
    z_iihf(scratch, 0xbaadbabe);
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  2128
    z_iilf(scratch, 0xdeadbeef);
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  2129
  }
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  2130
#endif
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2131
  return offset;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2132
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2133
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2134
// Push a frame of size `bytes' plus abi160 on top.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2135
unsigned int MacroAssembler::push_frame_abi160(unsigned int bytes) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2136
  BLOCK_COMMENT("push_frame_abi160 {");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2137
  unsigned int res = push_frame(bytes + frame::z_abi_160_size);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2138
  BLOCK_COMMENT("} push_frame_abi160");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2139
  return res;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2140
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2141
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2142
// Pop current C frame.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2143
void MacroAssembler::pop_frame() {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2144
  BLOCK_COMMENT("pop_frame:");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2145
  Assembler::z_lg(Z_SP, _z_abi(callers_sp), Z_SP);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2146
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2147
46726
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  2148
// Pop current C frame and restore return PC register (Z_R14).
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  2149
void MacroAssembler::pop_frame_restore_retPC(int frame_size_in_bytes) {
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  2150
  BLOCK_COMMENT("pop_frame_restore_retPC:");
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  2151
  int retPC_offset = _z_abi16(return_pc) + frame_size_in_bytes;
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  2152
  // If possible, pop frame by add instead of load (a penny saved is a penny got :-).
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  2153
  if (Displacement::is_validDisp(retPC_offset)) {
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  2154
    z_lg(Z_R14, retPC_offset, Z_SP);
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  2155
    add2reg(Z_SP, frame_size_in_bytes);
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  2156
  } else {
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  2157
    add2reg(Z_SP, frame_size_in_bytes);
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  2158
    restore_return_pc();
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  2159
  }
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  2160
}
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  2161
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2162
void MacroAssembler::call_VM_leaf_base(address entry_point, bool allow_relocation) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2163
  if (allow_relocation) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2164
    call_c(entry_point);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2165
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2166
    call_c_static(entry_point);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2167
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2168
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2169
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2170
void MacroAssembler::call_VM_leaf_base(address entry_point) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2171
  bool allow_relocation = true;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2172
  call_VM_leaf_base(entry_point, allow_relocation);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2173
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2174
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2175
void MacroAssembler::call_VM_base(Register oop_result,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2176
                                  Register last_java_sp,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2177
                                  address  entry_point,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2178
                                  bool     allow_relocation,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2179
                                  bool     check_exceptions) { // Defaults to true.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2180
  // Allow_relocation indicates, if true, that the generated code shall
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2181
  // be fit for code relocation or referenced data relocation. In other
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2182
  // words: all addresses must be considered variable. PC-relative addressing
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2183
  // is not possible then.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2184
  // On the other hand, if (allow_relocation == false), addresses and offsets
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2185
  // may be considered stable, enabling us to take advantage of some PC-relative
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2186
  // addressing tweaks. These might improve performance and reduce code size.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2187
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2188
  // Determine last_java_sp register.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2189
  if (!last_java_sp->is_valid()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2190
    last_java_sp = Z_SP;  // Load Z_SP as SP.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2191
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2192
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2193
  set_top_ijava_frame_at_SP_as_last_Java_frame(last_java_sp, Z_R1, allow_relocation);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2194
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2195
  // ARG1 must hold thread address.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2196
  z_lgr(Z_ARG1, Z_thread);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2197
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2198
  address return_pc = NULL;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2199
  if (allow_relocation) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2200
    return_pc = call_c(entry_point);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2201
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2202
    return_pc = call_c_static(entry_point);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2203
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2204
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2205
  reset_last_Java_frame(allow_relocation);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2206
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2207
  // C++ interp handles this in the interpreter.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2208
  check_and_handle_popframe(Z_thread);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2209
  check_and_handle_earlyret(Z_thread);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2210
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2211
  // Check for pending exceptions.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2212
  if (check_exceptions) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2213
    // Check for pending exceptions (java_thread is set upon return).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2214
    load_and_test_long(Z_R0_scratch, Address(Z_thread, Thread::pending_exception_offset()));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2215
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2216
    // This used to conditionally jump to forward_exception however it is
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2217
    // possible if we relocate that the branch will not reach. So we must jump
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2218
    // around so we can always reach.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2219
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2220
    Label ok;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2221
    z_bre(ok); // Bcondequal is the same as bcondZero.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2222
    call_stub(StubRoutines::forward_exception_entry());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2223
    bind(ok);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2224
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2225
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2226
  // Get oop result if there is one and reset the value in the thread.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2227
  if (oop_result->is_valid()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2228
    get_vm_result(oop_result);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2229
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2230
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2231
  _last_calls_return_pc = return_pc;  // Wipe out other (error handling) calls.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2232
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2233
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2234
void MacroAssembler::call_VM_base(Register oop_result,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2235
                                  Register last_java_sp,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2236
                                  address  entry_point,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2237
                                  bool     check_exceptions) { // Defaults to true.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2238
  bool allow_relocation = true;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2239
  call_VM_base(oop_result, last_java_sp, entry_point, allow_relocation, check_exceptions);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2240
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2241
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2242
// VM calls without explicit last_java_sp.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2243
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2244
void MacroAssembler::call_VM(Register oop_result, address entry_point, bool check_exceptions) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2245
  // Call takes possible detour via InterpreterMacroAssembler.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2246
  call_VM_base(oop_result, noreg, entry_point, true, check_exceptions);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2247
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2248
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2249
void MacroAssembler::call_VM(Register oop_result, address entry_point, Register arg_1, bool check_exceptions) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2250
  // Z_ARG1 is reserved for the thread.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2251
  lgr_if_needed(Z_ARG2, arg_1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2252
  call_VM(oop_result, entry_point, check_exceptions);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2253
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2254
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2255
void MacroAssembler::call_VM(Register oop_result, address entry_point, Register arg_1, Register arg_2, bool check_exceptions) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2256
  // Z_ARG1 is reserved for the thread.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2257
  lgr_if_needed(Z_ARG2, arg_1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2258
  assert(arg_2 != Z_ARG2, "smashed argument");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2259
  lgr_if_needed(Z_ARG3, arg_2);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2260
  call_VM(oop_result, entry_point, check_exceptions);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2261
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2262
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2263
void MacroAssembler::call_VM(Register oop_result, address entry_point, Register arg_1, Register arg_2,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2264
                             Register arg_3, bool check_exceptions) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2265
  // Z_ARG1 is reserved for the thread.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2266
  lgr_if_needed(Z_ARG2, arg_1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2267
  assert(arg_2 != Z_ARG2, "smashed argument");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2268
  lgr_if_needed(Z_ARG3, arg_2);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2269
  assert(arg_3 != Z_ARG2 && arg_3 != Z_ARG3, "smashed argument");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2270
  lgr_if_needed(Z_ARG4, arg_3);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2271
  call_VM(oop_result, entry_point, check_exceptions);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2272
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2273
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2274
// VM static calls without explicit last_java_sp.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2275
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2276
void MacroAssembler::call_VM_static(Register oop_result, address entry_point, bool check_exceptions) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2277
  // Call takes possible detour via InterpreterMacroAssembler.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2278
  call_VM_base(oop_result, noreg, entry_point, false, check_exceptions);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2279
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2280
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2281
void MacroAssembler::call_VM_static(Register oop_result, address entry_point, Register arg_1, Register arg_2,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2282
                                    Register arg_3, bool check_exceptions) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2283
  // Z_ARG1 is reserved for the thread.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2284
  lgr_if_needed(Z_ARG2, arg_1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2285
  assert(arg_2 != Z_ARG2, "smashed argument");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2286
  lgr_if_needed(Z_ARG3, arg_2);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2287
  assert(arg_3 != Z_ARG2 && arg_3 != Z_ARG3, "smashed argument");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2288
  lgr_if_needed(Z_ARG4, arg_3);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2289
  call_VM_static(oop_result, entry_point, check_exceptions);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2290
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2291
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2292
// VM calls with explicit last_java_sp.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2293
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2294
void MacroAssembler::call_VM(Register oop_result, Register last_java_sp, address entry_point, bool check_exceptions) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2295
  // Call takes possible detour via InterpreterMacroAssembler.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2296
  call_VM_base(oop_result, last_java_sp, entry_point, true, check_exceptions);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2297
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2298
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2299
void MacroAssembler::call_VM(Register oop_result, Register last_java_sp, address entry_point, Register arg_1, bool check_exceptions) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2300
   // Z_ARG1 is reserved for the thread.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2301
   lgr_if_needed(Z_ARG2, arg_1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2302
   call_VM(oop_result, last_java_sp, entry_point, check_exceptions);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2303
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2304
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2305
void MacroAssembler::call_VM(Register oop_result, Register last_java_sp, address entry_point, Register arg_1,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2306
                             Register arg_2, bool check_exceptions) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2307
   // Z_ARG1 is reserved for the thread.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2308
   lgr_if_needed(Z_ARG2, arg_1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2309
   assert(arg_2 != Z_ARG2, "smashed argument");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2310
   lgr_if_needed(Z_ARG3, arg_2);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2311
   call_VM(oop_result, last_java_sp, entry_point, check_exceptions);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2312
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2313
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2314
void MacroAssembler::call_VM(Register oop_result, Register last_java_sp, address entry_point, Register arg_1,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2315
                             Register arg_2, Register arg_3, bool check_exceptions) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2316
  // Z_ARG1 is reserved for the thread.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2317
  lgr_if_needed(Z_ARG2, arg_1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2318
  assert(arg_2 != Z_ARG2, "smashed argument");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2319
  lgr_if_needed(Z_ARG3, arg_2);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2320
  assert(arg_3 != Z_ARG2 && arg_3 != Z_ARG3, "smashed argument");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2321
  lgr_if_needed(Z_ARG4, arg_3);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2322
  call_VM(oop_result, last_java_sp, entry_point, check_exceptions);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2323
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2324
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2325
// VM leaf calls.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2326
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2327
void MacroAssembler::call_VM_leaf(address entry_point) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2328
  // Call takes possible detour via InterpreterMacroAssembler.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2329
  call_VM_leaf_base(entry_point, true);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2330
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2331
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2332
void MacroAssembler::call_VM_leaf(address entry_point, Register arg_1) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2333
  if (arg_1 != noreg) lgr_if_needed(Z_ARG1, arg_1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2334
  call_VM_leaf(entry_point);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2335
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2336
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2337
void MacroAssembler::call_VM_leaf(address entry_point, Register arg_1, Register arg_2) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2338
  if (arg_1 != noreg) lgr_if_needed(Z_ARG1, arg_1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2339
  assert(arg_2 != Z_ARG1, "smashed argument");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2340
  if (arg_2 != noreg) lgr_if_needed(Z_ARG2, arg_2);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2341
  call_VM_leaf(entry_point);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2342
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2343
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2344
void MacroAssembler::call_VM_leaf(address entry_point, Register arg_1, Register arg_2, Register arg_3) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2345
  if (arg_1 != noreg) lgr_if_needed(Z_ARG1, arg_1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2346
  assert(arg_2 != Z_ARG1, "smashed argument");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2347
  if (arg_2 != noreg) lgr_if_needed(Z_ARG2, arg_2);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2348
  assert(arg_3 != Z_ARG1 && arg_3 != Z_ARG2, "smashed argument");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2349
  if (arg_3 != noreg) lgr_if_needed(Z_ARG3, arg_3);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2350
  call_VM_leaf(entry_point);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2351
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2352
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2353
// Static VM leaf calls.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2354
// Really static VM leaf calls are never patched.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2355
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2356
void MacroAssembler::call_VM_leaf_static(address entry_point) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2357
  // Call takes possible detour via InterpreterMacroAssembler.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2358
  call_VM_leaf_base(entry_point, false);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2359
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2360
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2361
void MacroAssembler::call_VM_leaf_static(address entry_point, Register arg_1) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2362
  if (arg_1 != noreg) lgr_if_needed(Z_ARG1, arg_1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2363
  call_VM_leaf_static(entry_point);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2364
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2365
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2366
void MacroAssembler::call_VM_leaf_static(address entry_point, Register arg_1, Register arg_2) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2367
  if (arg_1 != noreg) lgr_if_needed(Z_ARG1, arg_1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2368
  assert(arg_2 != Z_ARG1, "smashed argument");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2369
  if (arg_2 != noreg) lgr_if_needed(Z_ARG2, arg_2);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2370
  call_VM_leaf_static(entry_point);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2371
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2372
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2373
void MacroAssembler::call_VM_leaf_static(address entry_point, Register arg_1, Register arg_2, Register arg_3) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2374
  if (arg_1 != noreg) lgr_if_needed(Z_ARG1, arg_1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2375
  assert(arg_2 != Z_ARG1, "smashed argument");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2376
  if (arg_2 != noreg) lgr_if_needed(Z_ARG2, arg_2);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2377
  assert(arg_3 != Z_ARG1 && arg_3 != Z_ARG2, "smashed argument");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2378
  if (arg_3 != noreg) lgr_if_needed(Z_ARG3, arg_3);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2379
  call_VM_leaf_static(entry_point);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2380
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2381
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2382
// Don't use detour via call_c(reg).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2383
address MacroAssembler::call_c(address function_entry) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2384
  load_const(Z_R1, function_entry);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2385
  return call(Z_R1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2386
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2387
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2388
// Variant for really static (non-relocatable) calls which are never patched.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2389
address MacroAssembler::call_c_static(address function_entry) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2390
  load_absolute_address(Z_R1, function_entry);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2391
#if 0 // def ASSERT
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2392
  // Verify that call site did not move.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2393
  load_const_optimized(Z_R0, function_entry);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2394
  z_cgr(Z_R1, Z_R0);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2395
  z_brc(bcondEqual, 3);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2396
  z_illtrap(0xba);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2397
#endif
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2398
  return call(Z_R1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2399
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2400
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2401
address MacroAssembler::call_c_opt(address function_entry) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2402
  bool success = call_far_patchable(function_entry, -2 /* emit relocation + constant */);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2403
  _last_calls_return_pc = success ? pc() : NULL;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2404
  return _last_calls_return_pc;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2405
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2406
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2407
// Identify a call_far_patchable instruction: LARL + LG + BASR
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2408
//
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2409
//    nop                   ; optionally, if required for alignment
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2410
//    lgrl rx,A(TOC entry)  ; PC-relative access into constant pool
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2411
//    basr Z_R14,rx         ; end of this instruction must be aligned to a word boundary
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2412
//
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2413
// Code pattern will eventually get patched into variant2 (see below for detection code).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2414
//
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2415
bool MacroAssembler::is_call_far_patchable_variant0_at(address instruction_addr) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2416
  address iaddr = instruction_addr;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2417
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2418
  // Check for the actual load instruction.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2419
  if (!is_load_const_from_toc(iaddr)) { return false; }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2420
  iaddr += load_const_from_toc_size();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2421
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2422
  // Check for the call (BASR) instruction, finally.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2423
  assert(iaddr-instruction_addr+call_byregister_size() == call_far_patchable_size(), "size mismatch");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2424
  return is_call_byregister(iaddr);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2425
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2426
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2427
// Identify a call_far_patchable instruction: BRASL
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2428
//
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2429
// Code pattern to suits atomic patching:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2430
//    nop                       ; Optionally, if required for alignment.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2431
//    nop    ...                ; Multiple filler nops to compensate for size difference (variant0 is longer).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2432
//    nop                       ; For code pattern detection: Prepend each BRASL with a nop.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2433
//    brasl  Z_R14,<reladdr>    ; End of code must be 4-byte aligned !
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2434
bool MacroAssembler::is_call_far_patchable_variant2_at(address instruction_addr) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2435
  const address call_addr = (address)((intptr_t)instruction_addr + call_far_patchable_size() - call_far_pcrelative_size());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2436
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2437
  // Check for correct number of leading nops.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2438
  address iaddr;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2439
  for (iaddr = instruction_addr; iaddr < call_addr; iaddr += nop_size()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2440
    if (!is_z_nop(iaddr)) { return false; }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2441
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2442
  assert(iaddr == call_addr, "sanity");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2443
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2444
  // --> Check for call instruction.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2445
  if (is_call_far_pcrelative(call_addr)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2446
    assert(call_addr-instruction_addr+call_far_pcrelative_size() == call_far_patchable_size(), "size mismatch");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2447
    return true;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2448
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2449
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2450
  return false;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2451
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2452
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2453
// Emit a NOT mt-safely patchable 64 bit absolute call.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2454
// If toc_offset == -2, then the destination of the call (= target) is emitted
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2455
//                      to the constant pool and a runtime_call relocation is added
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2456
//                      to the code buffer.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2457
// If toc_offset != -2, target must already be in the constant pool at
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2458
//                      _ctableStart+toc_offset (a caller can retrieve toc_offset
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2459
//                      from the runtime_call relocation).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2460
// Special handling of emitting to scratch buffer when there is no constant pool.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2461
// Slightly changed code pattern. We emit an additional nop if we would
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2462
// not end emitting at a word aligned address. This is to ensure
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2463
// an atomically patchable displacement in brasl instructions.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2464
//
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2465
// A call_far_patchable comes in different flavors:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2466
//  - LARL(CP) / LG(CP) / BR (address in constant pool, access via CP register)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2467
//  - LGRL(CP) / BR          (address in constant pool, pc-relative accesss)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2468
//  - BRASL                  (relative address of call target coded in instruction)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2469
// All flavors occupy the same amount of space. Length differences are compensated
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2470
// by leading nops, such that the instruction sequence always ends at the same
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2471
// byte offset. This is required to keep the return offset constant.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2472
// Furthermore, the return address (the end of the instruction sequence) is forced
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2473
// to be on a 4-byte boundary. This is required for atomic patching, should we ever
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2474
// need to patch the call target of the BRASL flavor.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2475
// RETURN value: false, if no constant pool entry could be allocated, true otherwise.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2476
bool MacroAssembler::call_far_patchable(address target, int64_t tocOffset) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2477
  // Get current pc and ensure word alignment for end of instr sequence.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2478
  const address start_pc = pc();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2479
  const intptr_t       start_off = offset();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2480
  assert(!call_far_patchable_requires_alignment_nop(start_pc), "call_far_patchable requires aligned address");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2481
  const ptrdiff_t      dist      = (ptrdiff_t)(target - (start_pc + 2)); // Prepend each BRASL with a nop.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2482
  const bool emit_target_to_pool = (tocOffset == -2) && !code_section()->scratch_emit();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2483
  const bool emit_relative_call  = !emit_target_to_pool &&
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2484
                                   RelAddr::is_in_range_of_RelAddr32(dist) &&
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2485
                                   ReoptimizeCallSequences &&
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2486
                                   !code_section()->scratch_emit();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2487
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2488
  if (emit_relative_call) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2489
    // Add padding to get the same size as below.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2490
    const unsigned int padding = call_far_patchable_size() - call_far_pcrelative_size();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2491
    unsigned int current_padding;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2492
    for (current_padding = 0; current_padding < padding; current_padding += nop_size()) { z_nop(); }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2493
    assert(current_padding == padding, "sanity");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2494
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2495
    // relative call: len = 2(nop) + 6 (brasl)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2496
    // CodeBlob resize cannot occur in this case because
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2497
    // this call is emitted into pre-existing space.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2498
    z_nop(); // Prepend each BRASL with a nop.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2499
    z_brasl(Z_R14, target);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2500
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2501
    // absolute call: Get address from TOC.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2502
    // len = (load TOC){6|0} + (load from TOC){6} + (basr){2} = {14|8}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2503
    if (emit_target_to_pool) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2504
      // When emitting the call for the first time, we do not need to use
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2505
      // the pc-relative version. It will be patched anyway, when the code
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2506
      // buffer is copied.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2507
      // Relocation is not needed when !ReoptimizeCallSequences.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2508
      relocInfo::relocType rt = ReoptimizeCallSequences ? relocInfo::runtime_call_w_cp_type : relocInfo::none;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2509
      AddressLiteral dest(target, rt);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2510
      // Store_oop_in_toc() adds dest to the constant table. As side effect, this kills
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2511
      // inst_mark(). Reset if possible.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2512
      bool reset_mark = (inst_mark() == pc());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2513
      tocOffset = store_oop_in_toc(dest);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2514
      if (reset_mark) { set_inst_mark(); }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2515
      if (tocOffset == -1) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2516
        return false; // Couldn't create constant pool entry.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2517
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2518
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2519
    assert(offset() == start_off, "emit no code before this point!");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2520
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2521
    address tocPos = pc() + tocOffset;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2522
    if (emit_target_to_pool) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2523
      tocPos = code()->consts()->start() + tocOffset;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2524
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2525
    load_long_pcrelative(Z_R14, tocPos);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2526
    z_basr(Z_R14, Z_R14);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2527
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2528
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2529
#ifdef ASSERT
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2530
  // Assert that we can identify the emitted call.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2531
  assert(is_call_far_patchable_at(addr_at(start_off)), "can't identify emitted call");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2532
  assert(offset() == start_off+call_far_patchable_size(), "wrong size");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2533
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2534
  if (emit_target_to_pool) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2535
    assert(get_dest_of_call_far_patchable_at(addr_at(start_off), code()->consts()->start()) == target,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2536
           "wrong encoding of dest address");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2537
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2538
#endif
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2539
  return true; // success
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2540
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2541
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2542
// Identify a call_far_patchable instruction.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2543
// For more detailed information see header comment of call_far_patchable.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2544
bool MacroAssembler::is_call_far_patchable_at(address instruction_addr) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2545
  return is_call_far_patchable_variant2_at(instruction_addr)  || // short version: BRASL
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2546
         is_call_far_patchable_variant0_at(instruction_addr);    // long version LARL + LG + BASR
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2547
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2548
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2549
// Does the call_far_patchable instruction use a pc-relative encoding
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2550
// of the call destination?
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2551
bool MacroAssembler::is_call_far_patchable_pcrelative_at(address instruction_addr) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2552
  // Variant 2 is pc-relative.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2553
  return is_call_far_patchable_variant2_at(instruction_addr);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2554
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2555
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2556
bool MacroAssembler::is_call_far_pcrelative(address instruction_addr) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2557
  // Prepend each BRASL with a nop.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2558
  return is_z_nop(instruction_addr) && is_z_brasl(instruction_addr + nop_size());  // Match at position after one nop required.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2559
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2560
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2561
// Set destination address of a call_far_patchable instruction.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2562
void MacroAssembler::set_dest_of_call_far_patchable_at(address instruction_addr, address dest, int64_t tocOffset) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2563
  ResourceMark rm;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2564
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2565
  // Now that CP entry is verified, patch call to a pc-relative call (if circumstances permit).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2566
  int code_size = MacroAssembler::call_far_patchable_size();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2567
  CodeBuffer buf(instruction_addr, code_size);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2568
  MacroAssembler masm(&buf);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2569
  masm.call_far_patchable(dest, tocOffset);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2570
  ICache::invalidate_range(instruction_addr, code_size); // Empty on z.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2571
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2572
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2573
// Get dest address of a call_far_patchable instruction.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2574
address MacroAssembler::get_dest_of_call_far_patchable_at(address instruction_addr, address ctable) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2575
  // Dynamic TOC: absolute address in constant pool.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2576
  // Check variant2 first, it is more frequent.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2577
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2578
  // Relative address encoded in call instruction.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2579
  if (is_call_far_patchable_variant2_at(instruction_addr)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2580
    return MacroAssembler::get_target_addr_pcrel(instruction_addr + nop_size()); // Prepend each BRASL with a nop.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2581
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2582
  // Absolute address in constant pool.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2583
  } else if (is_call_far_patchable_variant0_at(instruction_addr)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2584
    address iaddr = instruction_addr;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2585
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2586
    long    tocOffset = get_load_const_from_toc_offset(iaddr);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2587
    address tocLoc    = iaddr + tocOffset;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2588
    return *(address *)(tocLoc);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2589
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2590
    fprintf(stderr, "MacroAssembler::get_dest_of_call_far_patchable_at has a problem at %p:\n", instruction_addr);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2591
    fprintf(stderr, "not a call_far_patchable: %16.16lx %16.16lx, len = %d\n",
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2592
            *(unsigned long*)instruction_addr,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2593
            *(unsigned long*)(instruction_addr+8),
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2594
            call_far_patchable_size());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2595
    Disassembler::decode(instruction_addr, instruction_addr+call_far_patchable_size());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2596
    ShouldNotReachHere();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2597
    return NULL;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2598
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2599
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2600
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2601
void MacroAssembler::align_call_far_patchable(address pc) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2602
  if (call_far_patchable_requires_alignment_nop(pc)) { z_nop(); }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2603
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2604
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2605
void MacroAssembler::check_and_handle_earlyret(Register java_thread) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2606
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2607
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2608
void MacroAssembler::check_and_handle_popframe(Register java_thread) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2609
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2610
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2611
// Read from the polling page.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2612
// Use TM or TMY instruction, depending on read offset.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2613
//   offset = 0: Use TM, safepoint polling.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2614
//   offset < 0: Use TMY, profiling safepoint polling.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2615
void MacroAssembler::load_from_polling_page(Register polling_page_address, int64_t offset) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2616
  if (Immediate::is_uimm12(offset)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2617
    z_tm(offset, polling_page_address, mask_safepoint);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2618
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2619
    z_tmy(offset, polling_page_address, mask_profiling);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2620
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2621
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2622
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2623
// Check whether z_instruction is a read access to the polling page
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2624
// which was emitted by load_from_polling_page(..).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2625
bool MacroAssembler::is_load_from_polling_page(address instr_loc) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2626
  unsigned long z_instruction;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2627
  unsigned int  ilen = get_instruction(instr_loc, &z_instruction);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2628
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2629
  if (ilen == 2) { return false; } // It's none of the allowed instructions.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2630
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2631
  if (ilen == 4) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2632
    if (!is_z_tm(z_instruction)) { return false; } // It's len=4, but not a z_tm. fail.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2633
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2634
    int ms = inv_mask(z_instruction,8,32);  // mask
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2635
    int ra = inv_reg(z_instruction,16,32);  // base register
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2636
    int ds = inv_uimm12(z_instruction);     // displacement
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2637
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2638
    if (!(ds == 0 && ra != 0 && ms == mask_safepoint)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2639
      return false; // It's not a z_tm(0, ra, mask_safepoint). Fail.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2640
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2641
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2642
  } else { /* if (ilen == 6) */
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2643
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2644
    assert(!is_z_lg(z_instruction), "old form (LG) polling page access. Please fix and use TM(Y).");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2645
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2646
    if (!is_z_tmy(z_instruction)) { return false; } // It's len=6, but not a z_tmy. fail.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2647
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2648
    int ms = inv_mask(z_instruction,8,48);  // mask
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2649
    int ra = inv_reg(z_instruction,16,48);  // base register
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2650
    int ds = inv_simm20(z_instruction);     // displacement
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2651
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2652
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2653
  return true;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2654
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2655
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2656
// Extract poll address from instruction and ucontext.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2657
address MacroAssembler::get_poll_address(address instr_loc, void* ucontext) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2658
  assert(ucontext != NULL, "must have ucontext");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2659
  ucontext_t* uc = (ucontext_t*) ucontext;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2660
  unsigned long z_instruction;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2661
  unsigned int ilen = get_instruction(instr_loc, &z_instruction);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2662
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2663
  if (ilen == 4 && is_z_tm(z_instruction)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2664
    int ra = inv_reg(z_instruction, 16, 32);  // base register
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2665
    int ds = inv_uimm12(z_instruction);       // displacement
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2666
    address addr = (address)uc->uc_mcontext.gregs[ra];
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2667
    return addr + ds;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2668
  } else if (ilen == 6 && is_z_tmy(z_instruction)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2669
    int ra = inv_reg(z_instruction, 16, 48);  // base register
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2670
    int ds = inv_simm20(z_instruction);       // displacement
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2671
    address addr = (address)uc->uc_mcontext.gregs[ra];
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2672
    return addr + ds;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2673
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2674
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2675
  ShouldNotReachHere();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2676
  return NULL;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2677
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2678
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2679
// Extract poll register from instruction.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2680
uint MacroAssembler::get_poll_register(address instr_loc) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2681
  unsigned long z_instruction;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2682
  unsigned int ilen = get_instruction(instr_loc, &z_instruction);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2683
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2684
  if (ilen == 4 && is_z_tm(z_instruction)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2685
    return (uint)inv_reg(z_instruction, 16, 32);  // base register
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2686
  } else if (ilen == 6 && is_z_tmy(z_instruction)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2687
    return (uint)inv_reg(z_instruction, 16, 48);  // base register
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2688
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2689
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2690
  ShouldNotReachHere();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2691
  return 0;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2692
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2693
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2694
bool MacroAssembler::is_memory_serialization(int instruction, JavaThread* thread, void* ucontext) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2695
  ShouldNotCallThis();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2696
  return false;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2697
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2698
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2699
// Write serialization page so VM thread can do a pseudo remote membar
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2700
// We use the current thread pointer to calculate a thread specific
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2701
// offset to write to within the page. This minimizes bus traffic
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2702
// due to cache line collision.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2703
void MacroAssembler::serialize_memory(Register thread, Register tmp1, Register tmp2) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2704
  assert_different_registers(tmp1, tmp2);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2705
  z_sllg(tmp2, thread, os::get_serialize_page_shift_count());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2706
  load_const_optimized(tmp1, (long) os::get_memory_serialize_page());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2707
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2708
  int mask = os::get_serialize_page_mask();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2709
  if (Immediate::is_uimm16(mask)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2710
    z_nill(tmp2, mask);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2711
    z_llghr(tmp2, tmp2);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2712
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2713
    z_nilf(tmp2, mask);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2714
    z_llgfr(tmp2, tmp2);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2715
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2716
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2717
  z_release();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2718
  z_st(Z_R0, 0, tmp2, tmp1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2719
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2720
48332
651a95f30dfb 8193257: PPC64, s390 implementation for Thread-local handshakes
mdoerr
parents: 48331
diff changeset
  2721
void MacroAssembler::safepoint_poll(Label& slow_path, Register temp_reg) {
651a95f30dfb 8193257: PPC64, s390 implementation for Thread-local handshakes
mdoerr
parents: 48331
diff changeset
  2722
  if (SafepointMechanism::uses_thread_local_poll()) {
651a95f30dfb 8193257: PPC64, s390 implementation for Thread-local handshakes
mdoerr
parents: 48331
diff changeset
  2723
    const Address poll_byte_addr(Z_thread, in_bytes(Thread::polling_page_offset()) + 7 /* Big Endian */);
651a95f30dfb 8193257: PPC64, s390 implementation for Thread-local handshakes
mdoerr
parents: 48331
diff changeset
  2724
    // Armed page has poll_bit set.
651a95f30dfb 8193257: PPC64, s390 implementation for Thread-local handshakes
mdoerr
parents: 48331
diff changeset
  2725
    z_tm(poll_byte_addr, SafepointMechanism::poll_bit());
651a95f30dfb 8193257: PPC64, s390 implementation for Thread-local handshakes
mdoerr
parents: 48331
diff changeset
  2726
    z_brnaz(slow_path);
651a95f30dfb 8193257: PPC64, s390 implementation for Thread-local handshakes
mdoerr
parents: 48331
diff changeset
  2727
  } else {
651a95f30dfb 8193257: PPC64, s390 implementation for Thread-local handshakes
mdoerr
parents: 48331
diff changeset
  2728
    load_const_optimized(temp_reg, SafepointSynchronize::address_of_state());
651a95f30dfb 8193257: PPC64, s390 implementation for Thread-local handshakes
mdoerr
parents: 48331
diff changeset
  2729
    z_cli(/*SafepointSynchronize::sz_state()*/4-1, temp_reg, SafepointSynchronize::_not_synchronized);
651a95f30dfb 8193257: PPC64, s390 implementation for Thread-local handshakes
mdoerr
parents: 48331
diff changeset
  2730
    z_brne(slow_path);
651a95f30dfb 8193257: PPC64, s390 implementation for Thread-local handshakes
mdoerr
parents: 48331
diff changeset
  2731
  }
651a95f30dfb 8193257: PPC64, s390 implementation for Thread-local handshakes
mdoerr
parents: 48331
diff changeset
  2732
}
651a95f30dfb 8193257: PPC64, s390 implementation for Thread-local handshakes
mdoerr
parents: 48331
diff changeset
  2733
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2734
// Don't rely on register locking, always use Z_R1 as scratch register instead.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2735
void MacroAssembler::bang_stack_with_offset(int offset) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2736
  // Stack grows down, caller passes positive offset.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2737
  assert(offset > 0, "must bang with positive offset");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2738
  if (Displacement::is_validDisp(-offset)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2739
    z_tmy(-offset, Z_SP, mask_stackbang);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2740
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2741
    add2reg(Z_R1, -offset, Z_SP);    // Do not destroy Z_SP!!!
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2742
    z_tm(0, Z_R1, mask_stackbang);  // Just banging.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2743
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2744
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2745
43420
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42065
diff changeset
  2746
void MacroAssembler::reserved_stack_check(Register return_pc) {
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42065
diff changeset
  2747
  // Test if reserved zone needs to be enabled.
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42065
diff changeset
  2748
  Label no_reserved_zone_enabling;
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42065
diff changeset
  2749
  assert(return_pc == Z_R14, "Return pc must be in R14 before z_br() to StackOverflow stub.");
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42065
diff changeset
  2750
  BLOCK_COMMENT("reserved_stack_check {");
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42065
diff changeset
  2751
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42065
diff changeset
  2752
  z_clg(Z_SP, Address(Z_thread, JavaThread::reserved_stack_activation_offset()));
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42065
diff changeset
  2753
  z_brl(no_reserved_zone_enabling);
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42065
diff changeset
  2754
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42065
diff changeset
  2755
  // Enable reserved zone again, throw stack overflow exception.
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42065
diff changeset
  2756
  save_return_pc();
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42065
diff changeset
  2757
  push_frame_abi160(0);
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42065
diff changeset
  2758
  call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::enable_stack_reserved_zone), Z_thread);
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42065
diff changeset
  2759
  pop_frame();
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42065
diff changeset
  2760
  restore_return_pc();
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42065
diff changeset
  2761
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42065
diff changeset
  2762
  load_const_optimized(Z_R1, StubRoutines::throw_delayed_StackOverflowError_entry());
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42065
diff changeset
  2763
  // Don't use call() or z_basr(), they will invalidate Z_R14 which contains the return pc.
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42065
diff changeset
  2764
  z_br(Z_R1);
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42065
diff changeset
  2765
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42065
diff changeset
  2766
  should_not_reach_here();
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42065
diff changeset
  2767
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42065
diff changeset
  2768
  bind(no_reserved_zone_enabling);
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42065
diff changeset
  2769
  BLOCK_COMMENT("} reserved_stack_check");
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42065
diff changeset
  2770
}
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42065
diff changeset
  2771
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2772
// Defines obj, preserves var_size_in_bytes, okay for t2 == var_size_in_bytes.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2773
void MacroAssembler::tlab_allocate(Register obj,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2774
                                   Register var_size_in_bytes,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2775
                                   int con_size_in_bytes,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2776
                                   Register t1,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2777
                                   Label& slow_case) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2778
  assert_different_registers(obj, var_size_in_bytes, t1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2779
  Register end = t1;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2780
  Register thread = Z_thread;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2781
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2782
  z_lg(obj, Address(thread, JavaThread::tlab_top_offset()));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2783
  if (var_size_in_bytes == noreg) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2784
    z_lay(end, Address(obj, con_size_in_bytes));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2785
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2786
    z_lay(end, Address(obj, var_size_in_bytes));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2787
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2788
  z_cg(end, Address(thread, JavaThread::tlab_end_offset()));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2789
  branch_optimized(bcondHigh, slow_case);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2790
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2791
  // Update the tlab top pointer.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2792
  z_stg(end, Address(thread, JavaThread::tlab_top_offset()));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2793
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2794
  // Recover var_size_in_bytes if necessary.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2795
  if (var_size_in_bytes == end) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2796
    z_sgr(var_size_in_bytes, obj);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2797
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2798
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2799
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2800
// Emitter for interface method lookup.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2801
//   input: recv_klass, intf_klass, itable_index
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2802
//   output: method_result
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2803
//   kills: itable_index, temp1_reg, Z_R0, Z_R1
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2804
// TODO: Temp2_reg is unused. we may use this emitter also in the itable stubs.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2805
// If the register is still not needed then, remove it.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2806
void MacroAssembler::lookup_interface_method(Register           recv_klass,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2807
                                             Register           intf_klass,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2808
                                             RegisterOrConstant itable_index,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2809
                                             Register           method_result,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2810
                                             Register           temp1_reg,
48585
d9fcb7ba8133 8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents: 48332
diff changeset
  2811
                                             Label&             no_such_interface,
d9fcb7ba8133 8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents: 48332
diff changeset
  2812
                                             bool               return_method) {
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2813
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2814
  const Register vtable_len = temp1_reg;    // Used to compute itable_entry_addr.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2815
  const Register itable_entry_addr = Z_R1_scratch;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2816
  const Register itable_interface = Z_R0_scratch;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2817
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2818
  BLOCK_COMMENT("lookup_interface_method {");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2819
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2820
  // Load start of itable entries into itable_entry_addr.
46280
6eef3d367beb 8175269: [s390] cleanup calls to vtable_start_offset() and vtable_length_offset()
lucy
parents: 46272
diff changeset
  2821
  z_llgf(vtable_len, Address(recv_klass, Klass::vtable_length_offset()));
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2822
  z_sllg(vtable_len, vtable_len, exact_log2(vtableEntry::size_in_bytes()));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2823
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2824
  // Loop over all itable entries until desired interfaceOop(Rinterface) found.
46280
6eef3d367beb 8175269: [s390] cleanup calls to vtable_start_offset() and vtable_length_offset()
lucy
parents: 46272
diff changeset
  2825
  const int vtable_base_offset = in_bytes(Klass::vtable_start_offset());
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2826
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2827
  add2reg_with_index(itable_entry_addr,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2828
                     vtable_base_offset + itableOffsetEntry::interface_offset_in_bytes(),
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2829
                     recv_klass, vtable_len);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2830
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2831
  const int itable_offset_search_inc = itableOffsetEntry::size() * wordSize;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2832
  Label     search;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2833
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2834
  bind(search);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2835
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2836
  // Handle IncompatibleClassChangeError.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2837
  // If the entry is NULL then we've reached the end of the table
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2838
  // without finding the expected interface, so throw an exception.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2839
  load_and_test_long(itable_interface, Address(itable_entry_addr));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2840
  z_bre(no_such_interface);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2841
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2842
  add2reg(itable_entry_addr, itable_offset_search_inc);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2843
  z_cgr(itable_interface, intf_klass);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2844
  z_brne(search);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2845
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2846
  // Entry found and itable_entry_addr points to it, get offset of vtable for interface.
48585
d9fcb7ba8133 8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents: 48332
diff changeset
  2847
  if (return_method) {
d9fcb7ba8133 8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents: 48332
diff changeset
  2848
    const int vtable_offset_offset = (itableOffsetEntry::offset_offset_in_bytes() -
d9fcb7ba8133 8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents: 48332
diff changeset
  2849
                                      itableOffsetEntry::interface_offset_in_bytes()) -
d9fcb7ba8133 8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents: 48332
diff changeset
  2850
                                     itable_offset_search_inc;
d9fcb7ba8133 8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents: 48332
diff changeset
  2851
d9fcb7ba8133 8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents: 48332
diff changeset
  2852
    // Compute itableMethodEntry and get method and entry point
d9fcb7ba8133 8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents: 48332
diff changeset
  2853
    // we use addressing with index and displacement, since the formula
d9fcb7ba8133 8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents: 48332
diff changeset
  2854
    // for computing the entry's offset has a fixed and a dynamic part,
d9fcb7ba8133 8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents: 48332
diff changeset
  2855
    // the latter depending on the matched interface entry and on the case,
d9fcb7ba8133 8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents: 48332
diff changeset
  2856
    // that the itable index has been passed as a register, not a constant value.
d9fcb7ba8133 8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents: 48332
diff changeset
  2857
    int method_offset = itableMethodEntry::method_offset_in_bytes();
d9fcb7ba8133 8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents: 48332
diff changeset
  2858
                             // Fixed part (displacement), common operand.
d9fcb7ba8133 8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents: 48332
diff changeset
  2859
    Register itable_offset = method_result;  // Dynamic part (index register).
d9fcb7ba8133 8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents: 48332
diff changeset
  2860
d9fcb7ba8133 8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents: 48332
diff changeset
  2861
    if (itable_index.is_register()) {
d9fcb7ba8133 8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents: 48332
diff changeset
  2862
       // Compute the method's offset in that register, for the formula, see the
d9fcb7ba8133 8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents: 48332
diff changeset
  2863
       // else-clause below.
d9fcb7ba8133 8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents: 48332
diff changeset
  2864
       z_sllg(itable_offset, itable_index.as_register(), exact_log2(itableMethodEntry::size() * wordSize));
d9fcb7ba8133 8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents: 48332
diff changeset
  2865
       z_agf(itable_offset, vtable_offset_offset, itable_entry_addr);
d9fcb7ba8133 8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents: 48332
diff changeset
  2866
    } else {
d9fcb7ba8133 8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents: 48332
diff changeset
  2867
      // Displacement increases.
d9fcb7ba8133 8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents: 48332
diff changeset
  2868
      method_offset += itableMethodEntry::size() * wordSize * itable_index.as_constant();
d9fcb7ba8133 8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents: 48332
diff changeset
  2869
d9fcb7ba8133 8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents: 48332
diff changeset
  2870
      // Load index from itable.
d9fcb7ba8133 8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents: 48332
diff changeset
  2871
      z_llgf(itable_offset, vtable_offset_offset, itable_entry_addr);
d9fcb7ba8133 8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents: 48332
diff changeset
  2872
    }
d9fcb7ba8133 8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents: 48332
diff changeset
  2873
d9fcb7ba8133 8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents: 48332
diff changeset
  2874
    // Finally load the method's oop.
d9fcb7ba8133 8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents: 48332
diff changeset
  2875
    z_lg(method_result, method_offset, itable_offset, recv_klass);
d9fcb7ba8133 8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents: 48332
diff changeset
  2876
  }
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2877
  BLOCK_COMMENT("} lookup_interface_method");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2878
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2879
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2880
// Lookup for virtual method invocation.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2881
void MacroAssembler::lookup_virtual_method(Register           recv_klass,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2882
                                           RegisterOrConstant vtable_index,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2883
                                           Register           method_result) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2884
  assert_different_registers(recv_klass, vtable_index.register_or_noreg());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2885
  assert(vtableEntry::size() * wordSize == wordSize,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2886
         "else adjust the scaling in the code below");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2887
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2888
  BLOCK_COMMENT("lookup_virtual_method {");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2889
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2890
  const int base = in_bytes(Klass::vtable_start_offset());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2891
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2892
  if (vtable_index.is_constant()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2893
    // Load with base + disp.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2894
    Address vtable_entry_addr(recv_klass,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2895
                              vtable_index.as_constant() * wordSize +
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2896
                              base +
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2897
                              vtableEntry::method_offset_in_bytes());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2898
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2899
    z_lg(method_result, vtable_entry_addr);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2900
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2901
    // Shift index properly and load with base + index + disp.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2902
    Register vindex = vtable_index.as_register();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2903
    Address  vtable_entry_addr(recv_klass, vindex,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2904
                               base + vtableEntry::method_offset_in_bytes());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2905
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2906
    z_sllg(vindex, vindex, exact_log2(wordSize));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2907
    z_lg(method_result, vtable_entry_addr);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2908
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2909
  BLOCK_COMMENT("} lookup_virtual_method");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2910
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2911
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2912
// Factor out code to call ic_miss_handler.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2913
// Generate code to call the inline cache miss handler.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2914
//
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2915
// In most cases, this code will be generated out-of-line.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2916
// The method parameters are intended to provide some variability.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2917
//   ICM          - Label which has to be bound to the start of useful code (past any traps).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2918
//   trapMarker   - Marking byte for the generated illtrap instructions (if any).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2919
//                  Any value except 0x00 is supported.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2920
//                  = 0x00 - do not generate illtrap instructions.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2921
//                         use nops to fill ununsed space.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2922
//   requiredSize - required size of the generated code. If the actually
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2923
//                  generated code is smaller, use padding instructions to fill up.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2924
//                  = 0 - no size requirement, no padding.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2925
//   scratch      - scratch register to hold branch target address.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2926
//
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2927
//  The method returns the code offset of the bound label.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2928
unsigned int MacroAssembler::call_ic_miss_handler(Label& ICM, int trapMarker, int requiredSize, Register scratch) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2929
  intptr_t startOffset = offset();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2930
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2931
  // Prevent entry at content_begin().
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2932
  if (trapMarker != 0) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2933
    z_illtrap(trapMarker);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2934
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2935
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2936
  // Load address of inline cache miss code into scratch register
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2937
  // and branch to cache miss handler.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2938
  BLOCK_COMMENT("IC miss handler {");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2939
  BIND(ICM);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2940
  unsigned int   labelOffset = offset();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2941
  AddressLiteral icmiss(SharedRuntime::get_ic_miss_stub());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2942
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2943
  load_const_optimized(scratch, icmiss);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2944
  z_br(scratch);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2945
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2946
  // Fill unused space.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2947
  if (requiredSize > 0) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2948
    while ((offset() - startOffset) < requiredSize) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2949
      if (trapMarker == 0) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2950
        z_nop();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2951
      } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2952
        z_illtrap(trapMarker);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2953
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2954
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2955
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2956
  BLOCK_COMMENT("} IC miss handler");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2957
  return labelOffset;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2958
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2959
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2960
void MacroAssembler::nmethod_UEP(Label& ic_miss) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2961
  Register ic_reg       = as_Register(Matcher::inline_cache_reg_encode());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2962
  int      klass_offset = oopDesc::klass_offset_in_bytes();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2963
  if (!ImplicitNullChecks || MacroAssembler::needs_explicit_null_check(klass_offset)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2964
    if (VM_Version::has_CompareBranch()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2965
      z_cgij(Z_ARG1, 0, Assembler::bcondEqual, ic_miss);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2966
    } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2967
      z_ltgr(Z_ARG1, Z_ARG1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2968
      z_bre(ic_miss);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2969
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2970
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2971
  // Compare cached class against klass from receiver.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2972
  compare_klass_ptr(ic_reg, klass_offset, Z_ARG1, false);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2973
  z_brne(ic_miss);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2974
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2975
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2976
void MacroAssembler::check_klass_subtype_fast_path(Register   sub_klass,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2977
                                                   Register   super_klass,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2978
                                                   Register   temp1_reg,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2979
                                                   Label*     L_success,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2980
                                                   Label*     L_failure,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2981
                                                   Label*     L_slow_path,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2982
                                                   RegisterOrConstant super_check_offset) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2983
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2984
  const int sc_offset  = in_bytes(Klass::secondary_super_cache_offset());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2985
  const int sco_offset = in_bytes(Klass::super_check_offset_offset());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2986
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2987
  bool must_load_sco = (super_check_offset.constant_or_zero() == -1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2988
  bool need_slow_path = (must_load_sco ||
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2989
                         super_check_offset.constant_or_zero() == sc_offset);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2990
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2991
  // Input registers must not overlap.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2992
  assert_different_registers(sub_klass, super_klass, temp1_reg);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2993
  if (super_check_offset.is_register()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2994
    assert_different_registers(sub_klass, super_klass,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2995
                               super_check_offset.as_register());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2996
  } else if (must_load_sco) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2997
    assert(temp1_reg != noreg, "supply either a temp or a register offset");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2998
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2999
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3000
  const Register Rsuper_check_offset = temp1_reg;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3001
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3002
  NearLabel L_fallthrough;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3003
  int label_nulls = 0;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3004
  if (L_success == NULL)   { L_success   = &L_fallthrough; label_nulls++; }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3005
  if (L_failure == NULL)   { L_failure   = &L_fallthrough; label_nulls++; }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3006
  if (L_slow_path == NULL) { L_slow_path = &L_fallthrough; label_nulls++; }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3007
  assert(label_nulls <= 1 ||
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3008
         (L_slow_path == &L_fallthrough && label_nulls <= 2 && !need_slow_path),
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3009
         "at most one NULL in the batch, usually");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3010
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3011
  BLOCK_COMMENT("check_klass_subtype_fast_path {");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3012
  // If the pointers are equal, we are done (e.g., String[] elements).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3013
  // This self-check enables sharing of secondary supertype arrays among
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3014
  // non-primary types such as array-of-interface. Otherwise, each such
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3015
  // type would need its own customized SSA.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3016
  // We move this check to the front of the fast path because many
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3017
  // type checks are in fact trivially successful in this manner,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3018
  // so we get a nicely predicted branch right at the start of the check.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3019
  compare64_and_branch(sub_klass, super_klass, bcondEqual, *L_success);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3020
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3021
  // Check the supertype display, which is uint.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3022
  if (must_load_sco) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3023
    z_llgf(Rsuper_check_offset, sco_offset, super_klass);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3024
    super_check_offset = RegisterOrConstant(Rsuper_check_offset);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3025
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3026
  Address super_check_addr(sub_klass, super_check_offset, 0);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3027
  z_cg(super_klass, super_check_addr); // compare w/ displayed supertype
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3028
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3029
  // This check has worked decisively for primary supers.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3030
  // Secondary supers are sought in the super_cache ('super_cache_addr').
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3031
  // (Secondary supers are interfaces and very deeply nested subtypes.)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3032
  // This works in the same check above because of a tricky aliasing
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3033
  // between the super_cache and the primary super display elements.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3034
  // (The 'super_check_addr' can address either, as the case requires.)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3035
  // Note that the cache is updated below if it does not help us find
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3036
  // what we need immediately.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3037
  // So if it was a primary super, we can just fail immediately.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3038
  // Otherwise, it's the slow path for us (no success at this point).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3039
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3040
  // Hacked jmp, which may only be used just before L_fallthrough.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3041
#define final_jmp(label)                                                \
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3042
  if (&(label) == &L_fallthrough) { /*do nothing*/ }                    \
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3043
  else                            { branch_optimized(Assembler::bcondAlways, label); } /*omit semicolon*/
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3044
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3045
  if (super_check_offset.is_register()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3046
    branch_optimized(Assembler::bcondEqual, *L_success);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3047
    z_cfi(super_check_offset.as_register(), sc_offset);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3048
    if (L_failure == &L_fallthrough) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3049
      branch_optimized(Assembler::bcondEqual, *L_slow_path);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3050
    } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3051
      branch_optimized(Assembler::bcondNotEqual, *L_failure);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3052
      final_jmp(*L_slow_path);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3053
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3054
  } else if (super_check_offset.as_constant() == sc_offset) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3055
    // Need a slow path; fast failure is impossible.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3056
    if (L_slow_path == &L_fallthrough) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3057
      branch_optimized(Assembler::bcondEqual, *L_success);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3058
    } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3059
      branch_optimized(Assembler::bcondNotEqual, *L_slow_path);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3060
      final_jmp(*L_success);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3061
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3062
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3063
    // No slow path; it's a fast decision.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3064
    if (L_failure == &L_fallthrough) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3065
      branch_optimized(Assembler::bcondEqual, *L_success);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3066
    } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3067
      branch_optimized(Assembler::bcondNotEqual, *L_failure);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3068
      final_jmp(*L_success);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3069
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3070
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3071
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3072
  bind(L_fallthrough);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3073
#undef local_brc
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3074
#undef final_jmp
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3075
  BLOCK_COMMENT("} check_klass_subtype_fast_path");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3076
  // fallthru (to slow path)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3077
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3078
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3079
void MacroAssembler::check_klass_subtype_slow_path(Register Rsubklass,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3080
                                                   Register Rsuperklass,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3081
                                                   Register Rarray_ptr,  // tmp
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3082
                                                   Register Rlength,     // tmp
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3083
                                                   Label* L_success,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3084
                                                   Label* L_failure) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3085
  // Input registers must not overlap.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3086
  // Also check for R1 which is explicitely used here.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3087
  assert_different_registers(Z_R1, Rsubklass, Rsuperklass, Rarray_ptr, Rlength);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3088
  NearLabel L_fallthrough, L_loop;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3089
  int label_nulls = 0;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3090
  if (L_success == NULL) { L_success = &L_fallthrough; label_nulls++; }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3091
  if (L_failure == NULL) { L_failure = &L_fallthrough; label_nulls++; }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3092
  assert(label_nulls <= 1, "at most one NULL in the batch");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3093
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3094
  const int ss_offset = in_bytes(Klass::secondary_supers_offset());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3095
  const int sc_offset = in_bytes(Klass::secondary_super_cache_offset());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3096
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3097
  const int length_offset = Array<Klass*>::length_offset_in_bytes();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3098
  const int base_offset   = Array<Klass*>::base_offset_in_bytes();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3099
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3100
  // Hacked jmp, which may only be used just before L_fallthrough.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3101
#define final_jmp(label)                                                \
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3102
  if (&(label) == &L_fallthrough) { /*do nothing*/ }                    \
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3103
  else                            branch_optimized(Assembler::bcondAlways, label) /*omit semicolon*/
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3104
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3105
  NearLabel loop_iterate, loop_count, match;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3106
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3107
  BLOCK_COMMENT("check_klass_subtype_slow_path {");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3108
  z_lg(Rarray_ptr, ss_offset, Rsubklass);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3109
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3110
  load_and_test_int(Rlength, Address(Rarray_ptr, length_offset));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3111
  branch_optimized(Assembler::bcondZero, *L_failure);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3112
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3113
  // Oops in table are NO MORE compressed.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3114
  z_cg(Rsuperklass, base_offset, Rarray_ptr); // Check array element for match.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3115
  z_bre(match);                               // Shortcut for array length = 1.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3116
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3117
  // No match yet, so we must walk the array's elements.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3118
  z_lngfr(Rlength, Rlength);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3119
  z_sllg(Rlength, Rlength, LogBytesPerWord); // -#bytes of cache array
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3120
  z_llill(Z_R1, BytesPerWord);               // Set increment/end index.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3121
  add2reg(Rlength, 2 * BytesPerWord);        // start index  = -(n-2)*BytesPerWord
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3122
  z_slgr(Rarray_ptr, Rlength);               // start addr: +=  (n-2)*BytesPerWord
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3123
  z_bru(loop_count);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3124
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3125
  BIND(loop_iterate);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3126
  z_cg(Rsuperklass, base_offset, Rlength, Rarray_ptr); // Check array element for match.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3127
  z_bre(match);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3128
  BIND(loop_count);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3129
  z_brxlg(Rlength, Z_R1, loop_iterate);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3130
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3131
  // Rsuperklass not found among secondary super classes -> failure.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3132
  branch_optimized(Assembler::bcondAlways, *L_failure);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3133
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3134
  // Got a hit. Return success (zero result). Set cache.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3135
  // Cache load doesn't happen here. For speed it is directly emitted by the compiler.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3136
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3137
  BIND(match);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3138
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3139
  z_stg(Rsuperklass, sc_offset, Rsubklass); // Save result to cache.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3140
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3141
  final_jmp(*L_success);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3142
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3143
  // Exit to the surrounding code.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3144
  BIND(L_fallthrough);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3145
#undef local_brc
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3146
#undef final_jmp
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3147
  BLOCK_COMMENT("} check_klass_subtype_slow_path");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3148
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3149
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3150
// Emitter for combining fast and slow path.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3151
void MacroAssembler::check_klass_subtype(Register sub_klass,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3152
                                         Register super_klass,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3153
                                         Register temp1_reg,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3154
                                         Register temp2_reg,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3155
                                         Label&   L_success) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3156
  NearLabel failure;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3157
  BLOCK_COMMENT(err_msg("check_klass_subtype(%s subclass of %s) {", sub_klass->name(), super_klass->name()));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3158
  check_klass_subtype_fast_path(sub_klass, super_klass, temp1_reg,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3159
                                &L_success, &failure, NULL);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3160
  check_klass_subtype_slow_path(sub_klass, super_klass,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3161
                                temp1_reg, temp2_reg, &L_success, NULL);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3162
  BIND(failure);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3163
  BLOCK_COMMENT("} check_klass_subtype");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3164
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3165
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3166
// Increment a counter at counter_address when the eq condition code is
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3167
// set. Kills registers tmp1_reg and tmp2_reg and preserves the condition code.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3168
void MacroAssembler::increment_counter_eq(address counter_address, Register tmp1_reg, Register tmp2_reg) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3169
  Label l;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3170
  z_brne(l);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3171
  load_const(tmp1_reg, counter_address);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3172
  add2mem_32(Address(tmp1_reg), 1, tmp2_reg);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3173
  z_cr(tmp1_reg, tmp1_reg); // Set cc to eq.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3174
  bind(l);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3175
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3176
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3177
// Semantics are dependent on the slow_case label:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3178
//   If the slow_case label is not NULL, failure to biased-lock the object
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3179
//   transfers control to the location of the slow_case label. If the
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3180
//   object could be biased-locked, control is transferred to the done label.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3181
//   The condition code is unpredictable.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3182
//
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3183
//   If the slow_case label is NULL, failure to biased-lock the object results
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3184
//   in a transfer of control to the done label with a condition code of not_equal.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3185
//   If the biased-lock could be successfully obtained, control is transfered to
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3186
//   the done label with a condition code of equal.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3187
//   It is mandatory to react on the condition code At the done label.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3188
//
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3189
void MacroAssembler::biased_locking_enter(Register  obj_reg,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3190
                                          Register  mark_reg,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3191
                                          Register  temp_reg,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3192
                                          Register  temp2_reg,    // May be Z_RO!
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3193
                                          Label    &done,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3194
                                          Label    *slow_case) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3195
  assert(UseBiasedLocking, "why call this otherwise?");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3196
  assert_different_registers(obj_reg, mark_reg, temp_reg, temp2_reg);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3197
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3198
  Label cas_label; // Try, if implemented, CAS locking. Fall thru to slow path otherwise.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3199
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3200
  BLOCK_COMMENT("biased_locking_enter {");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3201
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3202
  // Biased locking
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3203
  // See whether the lock is currently biased toward our thread and
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3204
  // whether the epoch is still valid.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3205
  // Note that the runtime guarantees sufficient alignment of JavaThread
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3206
  // pointers to allow age to be placed into low bits.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3207
  assert(markOopDesc::age_shift == markOopDesc::lock_bits + markOopDesc::biased_lock_bits,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3208
         "biased locking makes assumptions about bit layout");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3209
  z_lr(temp_reg, mark_reg);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3210
  z_nilf(temp_reg, markOopDesc::biased_lock_mask_in_place);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3211
  z_chi(temp_reg, markOopDesc::biased_lock_pattern);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3212
  z_brne(cas_label);  // Try cas if object is not biased, i.e. cannot be biased locked.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3213
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3214
  load_prototype_header(temp_reg, obj_reg);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3215
  load_const_optimized(temp2_reg, ~((int) markOopDesc::age_mask_in_place));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3216
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3217
  z_ogr(temp_reg, Z_thread);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3218
  z_xgr(temp_reg, mark_reg);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3219
  z_ngr(temp_reg, temp2_reg);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3220
  if (PrintBiasedLockingStatistics) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3221
    increment_counter_eq((address) BiasedLocking::biased_lock_entry_count_addr(), mark_reg, temp2_reg);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3222
    // Restore mark_reg.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3223
    z_lg(mark_reg, oopDesc::mark_offset_in_bytes(), obj_reg);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3224
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3225
  branch_optimized(Assembler::bcondEqual, done);  // Biased lock obtained, return success.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3226
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3227
  Label try_revoke_bias;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3228
  Label try_rebias;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3229
  Address mark_addr = Address(obj_reg, oopDesc::mark_offset_in_bytes());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3230
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3231
  //----------------------------------------------------------------------------
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3232
  // At this point we know that the header has the bias pattern and
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3233
  // that we are not the bias owner in the current epoch. We need to
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3234
  // figure out more details about the state of the header in order to
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3235
  // know what operations can be legally performed on the object's
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3236
  // header.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3237
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3238
  // If the low three bits in the xor result aren't clear, that means
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3239
  // the prototype header is no longer biased and we have to revoke
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3240
  // the bias on this object.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3241
  z_tmll(temp_reg, markOopDesc::biased_lock_mask_in_place);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3242
  z_brnaz(try_revoke_bias);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3243
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3244
  // Biasing is still enabled for this data type. See whether the
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3245
  // epoch of the current bias is still valid, meaning that the epoch
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3246
  // bits of the mark word are equal to the epoch bits of the
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3247
  // prototype header. (Note that the prototype header's epoch bits
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3248
  // only change at a safepoint.) If not, attempt to rebias the object
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3249
  // toward the current thread. Note that we must be absolutely sure
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3250
  // that the current epoch is invalid in order to do this because
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3251
  // otherwise the manipulations it performs on the mark word are
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3252
  // illegal.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3253
  z_tmll(temp_reg, markOopDesc::epoch_mask_in_place);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3254
  z_brnaz(try_rebias);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3255
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3256
  //----------------------------------------------------------------------------
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3257
  // The epoch of the current bias is still valid but we know nothing
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3258
  // about the owner; it might be set or it might be clear. Try to
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3259
  // acquire the bias of the object using an atomic operation. If this
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3260
  // fails we will go in to the runtime to revoke the object's bias.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3261
  // Note that we first construct the presumed unbiased header so we
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3262
  // don't accidentally blow away another thread's valid bias.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3263
  z_nilf(mark_reg, markOopDesc::biased_lock_mask_in_place | markOopDesc::age_mask_in_place |
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3264
         markOopDesc::epoch_mask_in_place);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3265
  z_lgr(temp_reg, Z_thread);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3266
  z_llgfr(mark_reg, mark_reg);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3267
  z_ogr(temp_reg, mark_reg);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3268
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3269
  assert(oopDesc::mark_offset_in_bytes() == 0, "offset of _mark is not 0");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3270
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3271
  z_csg(mark_reg, temp_reg, 0, obj_reg);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3272
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3273
  // If the biasing toward our thread failed, this means that
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3274
  // another thread succeeded in biasing it toward itself and we
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3275
  // need to revoke that bias. The revocation will occur in the
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3276
  // interpreter runtime in the slow case.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3277
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3278
  if (PrintBiasedLockingStatistics) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3279
    increment_counter_eq((address) BiasedLocking::anonymously_biased_lock_entry_count_addr(),
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3280
                         temp_reg, temp2_reg);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3281
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3282
  if (slow_case != NULL) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3283
    branch_optimized(Assembler::bcondNotEqual, *slow_case); // Biased lock not obtained, need to go the long way.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3284
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3285
  branch_optimized(Assembler::bcondAlways, done);           // Biased lock status given in condition code.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3286
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3287
  //----------------------------------------------------------------------------
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3288
  bind(try_rebias);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3289
  // At this point we know the epoch has expired, meaning that the
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3290
  // current "bias owner", if any, is actually invalid. Under these
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3291
  // circumstances _only_, we are allowed to use the current header's
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3292
  // value as the comparison value when doing the cas to acquire the
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3293
  // bias in the current epoch. In other words, we allow transfer of
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3294
  // the bias from one thread to another directly in this situation.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3295
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3296
  z_nilf(mark_reg, markOopDesc::biased_lock_mask_in_place | markOopDesc::age_mask_in_place | markOopDesc::epoch_mask_in_place);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3297
  load_prototype_header(temp_reg, obj_reg);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3298
  z_llgfr(mark_reg, mark_reg);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3299
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3300
  z_ogr(temp_reg, Z_thread);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3301
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3302
  assert(oopDesc::mark_offset_in_bytes() == 0, "offset of _mark is not 0");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3303
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3304
  z_csg(mark_reg, temp_reg, 0, obj_reg);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3305
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3306
  // If the biasing toward our thread failed, this means that
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3307
  // another thread succeeded in biasing it toward itself and we
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3308
  // need to revoke that bias. The revocation will occur in the
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3309
  // interpreter runtime in the slow case.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3310
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3311
  if (PrintBiasedLockingStatistics) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3312
    increment_counter_eq((address) BiasedLocking::rebiased_lock_entry_count_addr(), temp_reg, temp2_reg);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3313
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3314
  if (slow_case != NULL) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3315
    branch_optimized(Assembler::bcondNotEqual, *slow_case);  // Biased lock not obtained, need to go the long way.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3316
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3317
  z_bru(done);           // Biased lock status given in condition code.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3318
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3319
  //----------------------------------------------------------------------------
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3320
  bind(try_revoke_bias);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3321
  // The prototype mark in the klass doesn't have the bias bit set any
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3322
  // more, indicating that objects of this data type are not supposed
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3323
  // to be biased any more. We are going to try to reset the mark of
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3324
  // this object to the prototype value and fall through to the
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3325
  // CAS-based locking scheme. Note that if our CAS fails, it means
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3326
  // that another thread raced us for the privilege of revoking the
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3327
  // bias of this particular object, so it's okay to continue in the
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3328
  // normal locking code.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3329
  load_prototype_header(temp_reg, obj_reg);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3330
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3331
  assert(oopDesc::mark_offset_in_bytes() == 0, "offset of _mark is not 0");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3332
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3333
  z_csg(mark_reg, temp_reg, 0, obj_reg);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3334
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3335
  // Fall through to the normal CAS-based lock, because no matter what
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3336
  // the result of the above CAS, some thread must have succeeded in
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3337
  // removing the bias bit from the object's header.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3338
  if (PrintBiasedLockingStatistics) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3339
    // z_cgr(mark_reg, temp2_reg);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3340
    increment_counter_eq((address) BiasedLocking::revoked_lock_entry_count_addr(), temp_reg, temp2_reg);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3341
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3342
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3343
  bind(cas_label);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3344
  BLOCK_COMMENT("} biased_locking_enter");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3345
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3346
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3347
void MacroAssembler::biased_locking_exit(Register mark_addr, Register temp_reg, Label& done) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3348
  // Check for biased locking unlock case, which is a no-op
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3349
  // Note: we do not have to check the thread ID for two reasons.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3350
  // First, the interpreter checks for IllegalMonitorStateException at
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3351
  // a higher level. Second, if the bias was revoked while we held the
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3352
  // lock, the object could not be rebiased toward another thread, so
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3353
  // the bias bit would be clear.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3354
  BLOCK_COMMENT("biased_locking_exit {");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3355
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3356
  z_lg(temp_reg, 0, mark_addr);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3357
  z_nilf(temp_reg, markOopDesc::biased_lock_mask_in_place);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3358
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3359
  z_chi(temp_reg, markOopDesc::biased_lock_pattern);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3360
  z_bre(done);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3361
  BLOCK_COMMENT("} biased_locking_exit");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3362
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3363
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3364
void MacroAssembler::compiler_fast_lock_object(Register oop, Register box, Register temp1, Register temp2, bool try_bias) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3365
  Register displacedHeader = temp1;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3366
  Register currentHeader = temp1;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3367
  Register temp = temp2;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3368
  NearLabel done, object_has_monitor;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3369
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3370
  BLOCK_COMMENT("compiler_fast_lock_object {");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3371
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3372
  // Load markOop from oop into mark.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3373
  z_lg(displacedHeader, 0, oop);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3374
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3375
  if (try_bias) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3376
    biased_locking_enter(oop, displacedHeader, temp, Z_R0, done);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3377
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3378
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3379
  // Handle existing monitor.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3380
  if ((EmitSync & 0x01) == 0) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3381
    // The object has an existing monitor iff (mark & monitor_value) != 0.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3382
    guarantee(Immediate::is_uimm16(markOopDesc::monitor_value), "must be half-word");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3383
    z_lr(temp, displacedHeader);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3384
    z_nill(temp, markOopDesc::monitor_value);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3385
    z_brne(object_has_monitor);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3386
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3387
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3388
  // Set mark to markOop | markOopDesc::unlocked_value.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3389
  z_oill(displacedHeader, markOopDesc::unlocked_value);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3390
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3391
  // Load Compare Value application register.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3392
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3393
  // Initialize the box (must happen before we update the object mark).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3394
  z_stg(displacedHeader, BasicLock::displaced_header_offset_in_bytes(), box);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3395
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3396
  // Memory Fence (in cmpxchgd)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3397
  // Compare object markOop with mark and if equal exchange scratch1 with object markOop.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3398
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3399
  // If the compare-and-swap succeeded, then we found an unlocked object and we
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3400
  // have now locked it.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3401
  z_csg(displacedHeader, box, 0, oop);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3402
  assert(currentHeader==displacedHeader, "must be same register"); // Identified two registers from z/Architecture.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3403
  z_bre(done);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3404
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3405
  // We did not see an unlocked object so try the fast recursive case.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3406
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3407
  z_sgr(currentHeader, Z_SP);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3408
  load_const_optimized(temp, (~(os::vm_page_size()-1) | markOopDesc::lock_mask_in_place));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3409
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3410
  z_ngr(currentHeader, temp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3411
  //   z_brne(done);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3412
  //   z_release();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3413
  z_stg(currentHeader/*==0 or not 0*/, BasicLock::displaced_header_offset_in_bytes(), box);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3414
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3415
  z_bru(done);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3416
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3417
  if ((EmitSync & 0x01) == 0) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3418
    Register zero = temp;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3419
    Register monitor_tagged = displacedHeader; // Tagged with markOopDesc::monitor_value.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3420
    bind(object_has_monitor);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3421
    // The object's monitor m is unlocked iff m->owner == NULL,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3422
    // otherwise m->owner may contain a thread or a stack address.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3423
    //
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3424
    // Try to CAS m->owner from NULL to current thread.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3425
    z_lghi(zero, 0);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3426
    // If m->owner is null, then csg succeeds and sets m->owner=THREAD and CR=EQ.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3427
    z_csg(zero, Z_thread, OM_OFFSET_NO_MONITOR_VALUE_TAG(owner), monitor_tagged);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3428
    // Store a non-null value into the box.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3429
    z_stg(box, BasicLock::displaced_header_offset_in_bytes(), box);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3430
#ifdef ASSERT
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3431
      z_brne(done);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3432
      // We've acquired the monitor, check some invariants.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3433
      // Invariant 1: _recursions should be 0.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3434
      asm_assert_mem8_is_zero(OM_OFFSET_NO_MONITOR_VALUE_TAG(recursions), monitor_tagged,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3435
                              "monitor->_recursions should be 0", -1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3436
      z_ltgr(zero, zero); // Set CR=EQ.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3437
#endif
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3438
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3439
  bind(done);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3440
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3441
  BLOCK_COMMENT("} compiler_fast_lock_object");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3442
  // If locking was successful, CR should indicate 'EQ'.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3443
  // The compiler or the native wrapper generates a branch to the runtime call
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3444
  // _complete_monitor_locking_Java.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3445
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3446
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3447
void MacroAssembler::compiler_fast_unlock_object(Register oop, Register box, Register temp1, Register temp2, bool try_bias) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3448
  Register displacedHeader = temp1;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3449
  Register currentHeader = temp2;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3450
  Register temp = temp1;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3451
  Register monitor = temp2;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3452
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3453
  Label done, object_has_monitor;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3454
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3455
  BLOCK_COMMENT("compiler_fast_unlock_object {");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3456
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3457
  if (try_bias) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3458
    biased_locking_exit(oop, currentHeader, done);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3459
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3460
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3461
  // Find the lock address and load the displaced header from the stack.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3462
  // if the displaced header is zero, we have a recursive unlock.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3463
  load_and_test_long(displacedHeader, Address(box, BasicLock::displaced_header_offset_in_bytes()));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3464
  z_bre(done);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3465
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3466
  // Handle existing monitor.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3467
  if ((EmitSync & 0x02) == 0) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3468
    // The object has an existing monitor iff (mark & monitor_value) != 0.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3469
    z_lg(currentHeader, oopDesc::mark_offset_in_bytes(), oop);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3470
    guarantee(Immediate::is_uimm16(markOopDesc::monitor_value), "must be half-word");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3471
    z_nill(currentHeader, markOopDesc::monitor_value);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3472
    z_brne(object_has_monitor);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3473
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3474
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3475
  // Check if it is still a light weight lock, this is true if we see
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3476
  // the stack address of the basicLock in the markOop of the object
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3477
  // copy box to currentHeader such that csg does not kill it.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3478
  z_lgr(currentHeader, box);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3479
  z_csg(currentHeader, displacedHeader, 0, oop);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3480
  z_bru(done); // Csg sets CR as desired.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3481
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3482
  // Handle existing monitor.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3483
  if ((EmitSync & 0x02) == 0) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3484
    bind(object_has_monitor);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3485
    z_lg(currentHeader, oopDesc::mark_offset_in_bytes(), oop);    // CurrentHeader is tagged with monitor_value set.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3486
    load_and_test_long(temp, Address(currentHeader, OM_OFFSET_NO_MONITOR_VALUE_TAG(recursions)));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3487
    z_brne(done);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3488
    load_and_test_long(temp, Address(currentHeader, OM_OFFSET_NO_MONITOR_VALUE_TAG(owner)));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3489
    z_brne(done);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3490
    load_and_test_long(temp, Address(currentHeader, OM_OFFSET_NO_MONITOR_VALUE_TAG(EntryList)));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3491
    z_brne(done);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3492
    load_and_test_long(temp, Address(currentHeader, OM_OFFSET_NO_MONITOR_VALUE_TAG(cxq)));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3493
    z_brne(done);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3494
    z_release();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3495
    z_stg(temp/*=0*/, OM_OFFSET_NO_MONITOR_VALUE_TAG(owner), currentHeader);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3496
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3497
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3498
  bind(done);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3499
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3500
  BLOCK_COMMENT("} compiler_fast_unlock_object");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3501
  // flag == EQ indicates success
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3502
  // flag == NE indicates failure
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3503
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3504
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3505
// Write to card table for modification at store_addr - register is destroyed afterwards.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3506
void MacroAssembler::card_write_barrier_post(Register store_addr, Register tmp) {
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 48585
diff changeset
  3507
  BarrierSet* bs = Universe::heap()->barrier_set();
49455
848864ed9b17 8199604: Rename CardTableModRefBS to CardTableBarrierSet
eosterlund
parents: 49449
diff changeset
  3508
  CardTableBarrierSet* ctbs = barrier_set_cast<CardTableBarrierSet>(bs);
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 48585
diff changeset
  3509
  CardTable* ct = ctbs->card_table();
49455
848864ed9b17 8199604: Rename CardTableModRefBS to CardTableBarrierSet
eosterlund
parents: 49449
diff changeset
  3510
  assert(bs->kind() == BarrierSet::CardTableBarrierSet, "wrong barrier");
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3511
  assert_different_registers(store_addr, tmp);
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 48585
diff changeset
  3512
  z_srlg(store_addr, store_addr, CardTable::card_shift);
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 48585
diff changeset
  3513
  load_absolute_address(tmp, (address)ct->byte_map_base());
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3514
  z_agr(store_addr, tmp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3515
  z_mvi(0, store_addr, 0); // Store byte 0.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3516
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3517
44406
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
  3518
void MacroAssembler::resolve_jobject(Register value, Register tmp1, Register tmp2) {
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
  3519
  NearLabel Ldone;
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
  3520
  z_ltgr(tmp1, value);
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
  3521
  z_bre(Ldone);          // Use NULL result as-is.
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
  3522
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
  3523
  z_nill(value, ~JNIHandles::weak_tag_mask);
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
  3524
  z_lg(value, 0, value); // Resolve (untagged) jobject.
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
  3525
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
  3526
#if INCLUDE_ALL_GCS
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
  3527
  if (UseG1GC) {
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
  3528
    NearLabel Lnot_weak;
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
  3529
    z_tmll(tmp1, JNIHandles::weak_tag_mask); // Test for jweak tag.
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
  3530
    z_braz(Lnot_weak);
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
  3531
    verify_oop(value);
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
  3532
    g1_write_barrier_pre(noreg /* obj */,
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
  3533
                         noreg /* offset */,
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
  3534
                         value /* pre_val */,
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
  3535
                         noreg /* val */,
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
  3536
                         tmp1  /* tmp1 */,
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
  3537
                         tmp2  /* tmp2 */,
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
  3538
                         true  /* pre_val_needed */);
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
  3539
    bind(Lnot_weak);
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
  3540
  }
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
  3541
#endif // INCLUDE_ALL_GCS
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
  3542
  verify_oop(value);
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
  3543
  bind(Ldone);
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
  3544
}
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
  3545
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3546
#if INCLUDE_ALL_GCS
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3547
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3548
//------------------------------------------------------
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3549
// General G1 pre-barrier generator.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3550
// Purpose: record the previous value if it is not null.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3551
// All non-tmps are preserved.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3552
//------------------------------------------------------
46726
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  3553
// Note: Rpre_val needs special attention.
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  3554
//   The flag pre_val_needed indicated that the caller of this emitter function
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  3555
//   relies on Rpre_val containing the correct value, that is:
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  3556
//     either the value it contained on entry to this code segment
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  3557
//     or the value that was loaded into the register from (Robj+offset).
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  3558
//
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  3559
//   Independent from this requirement, the contents of Rpre_val must survive
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  3560
//   the push_frame() operation. push_frame() uses Z_R0_scratch by default
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  3561
//   to temporarily remember the frame pointer.
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  3562
//   If Rpre_val is assigned Z_R0_scratch by the caller, code must be emitted to
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  3563
//   save it's value.
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3564
void MacroAssembler::g1_write_barrier_pre(Register           Robj,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3565
                                          RegisterOrConstant offset,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3566
                                          Register           Rpre_val,      // Ideally, this is a non-volatile register.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3567
                                          Register           Rval,          // Will be preserved.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3568
                                          Register           Rtmp1,         // If Rpre_val is volatile, either Rtmp1
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3569
                                          Register           Rtmp2,         // or Rtmp2 has to be non-volatile..
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3570
                                          bool               pre_val_needed // Save Rpre_val across runtime call, caller uses it.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3571
                                       ) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3572
  Label callRuntime, filtered;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3573
  const int active_offset = in_bytes(JavaThread::satb_mark_queue_offset() + SATBMarkQueue::byte_offset_of_active());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3574
  const int buffer_offset = in_bytes(JavaThread::satb_mark_queue_offset() + SATBMarkQueue::byte_offset_of_buf());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3575
  const int index_offset  = in_bytes(JavaThread::satb_mark_queue_offset() + SATBMarkQueue::byte_offset_of_index());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3576
  assert_different_registers(Rtmp1, Rtmp2, Z_R0_scratch); // None of the Rtmp<i> must be Z_R0!!
46726
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  3577
  assert_different_registers(Robj, Z_R0_scratch);         // Used for addressing. Furthermore, push_frame destroys Z_R0!!
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  3578
  assert_different_registers(Rval, Z_R0_scratch);         // push_frame destroys Z_R0!!
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  3579
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  3580
#ifdef ASSERT
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  3581
  // make sure the register is not Z_R0. Used for addressing. Furthermore, would be destroyed by push_frame.
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  3582
  if (offset.is_register() && offset.as_register()->encoding() == 0) {
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  3583
    tty->print_cr("Roffset(g1_write_barrier_pre)  = %%r%d", offset.as_register()->encoding());
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  3584
    assert(false, "bad register for offset");
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  3585
  }
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  3586
#endif
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3587
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3588
  BLOCK_COMMENT("g1_write_barrier_pre {");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3589
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3590
  // Is marking active?
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3591
  // Note: value is loaded for test purposes only. No further use here.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3592
  if (in_bytes(SATBMarkQueue::byte_width_of_active()) == 4) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3593
    load_and_test_int(Rtmp1, Address(Z_thread, active_offset));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3594
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3595
    guarantee(in_bytes(SATBMarkQueue::byte_width_of_active()) == 1, "Assumption");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3596
    load_and_test_byte(Rtmp1, Address(Z_thread, active_offset));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3597
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3598
  z_bre(filtered); // Activity indicator is zero, so there is no marking going on currently.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3599
46726
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  3600
  assert(Rpre_val != noreg, "must have a real register");
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  3601
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  3602
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  3603
  // If an object is given, we need to load the previous value into Rpre_val.
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3604
  if (Robj != noreg) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3605
    // Load the previous value...
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3606
    Register ixReg = offset.is_register() ? offset.register_or_noreg() : Z_R0;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3607
    if (UseCompressedOops) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3608
      z_llgf(Rpre_val, offset.constant_or_zero(), ixReg, Robj);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3609
    } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3610
      z_lg(Rpre_val, offset.constant_or_zero(), ixReg, Robj);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3611
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3612
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3613
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3614
  // Is the previous value NULL?
46726
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  3615
  // If so, we don't need to record it and we're done.
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3616
  // Note: pre_val is loaded, decompressed and stored (directly or via runtime call).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3617
  //       Register contents is preserved across runtime call if caller requests to do so.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3618
  z_ltgr(Rpre_val, Rpre_val);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3619
  z_bre(filtered); // previous value is NULL, so we don't need to record it.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3620
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3621
  // Decode the oop now. We know it's not NULL.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3622
  if (Robj != noreg && UseCompressedOops) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3623
    oop_decoder(Rpre_val, Rpre_val, /*maybeNULL=*/false);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3624
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3625
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3626
  // OK, it's not filtered, so we'll need to call enqueue.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3627
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3628
  // We can store the original value in the thread's buffer
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3629
  // only if index > 0. Otherwise, we need runtime to handle.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3630
  // (The index field is typed as size_t.)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3631
  Register Rbuffer = Rtmp1, Rindex = Rtmp2;
46726
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  3632
  assert_different_registers(Rbuffer, Rindex, Rpre_val);
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3633
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3634
  z_lg(Rbuffer, buffer_offset, Z_thread);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3635
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3636
  load_and_test_long(Rindex, Address(Z_thread, index_offset));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3637
  z_bre(callRuntime); // If index == 0, goto runtime.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3638
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3639
  add2reg(Rindex, -wordSize); // Decrement index.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3640
  z_stg(Rindex, index_offset, Z_thread);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3641
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3642
  // Record the previous value.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3643
  z_stg(Rpre_val, 0, Rbuffer, Rindex);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3644
  z_bru(filtered);  // We are done.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3645
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3646
  Rbuffer = noreg;  // end of life
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3647
  Rindex  = noreg;  // end of life
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3648
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3649
  bind(callRuntime);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3650
46726
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  3651
  // Save some registers (inputs and result) over runtime call
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  3652
  // by spilling them into the top frame.
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3653
  if (Robj != noreg && Robj->is_volatile()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3654
    z_stg(Robj, Robj->encoding()*BytesPerWord, Z_SP);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3655
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3656
  if (offset.is_register() && offset.as_register()->is_volatile()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3657
    Register Roff = offset.as_register();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3658
    z_stg(Roff, Roff->encoding()*BytesPerWord, Z_SP);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3659
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3660
  if (Rval != noreg && Rval->is_volatile()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3661
    z_stg(Rval, Rval->encoding()*BytesPerWord, Z_SP);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3662
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3663
46726
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  3664
  // Save Rpre_val (result) over runtime call.
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  3665
  Register Rpre_save = Rpre_val;
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  3666
  if ((Rpre_val == Z_R0_scratch) || (pre_val_needed && Rpre_val->is_volatile())) {
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  3667
    guarantee(!Rtmp1->is_volatile() || !Rtmp2->is_volatile(), "oops!");
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  3668
    Rpre_save = !Rtmp1->is_volatile() ? Rtmp1 : Rtmp2;
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  3669
  }
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  3670
  lgr_if_needed(Rpre_save, Rpre_val);
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  3671
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3672
  // Push frame to protect top frame with return pc and spilled register values.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3673
  save_return_pc();
46726
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  3674
  push_frame_abi160(0); // Will use Z_R0 as tmp.
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  3675
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  3676
  // Rpre_val may be destroyed by push_frame().
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  3677
  call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::g1_wb_pre), Rpre_save, Z_thread);
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3678
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3679
  pop_frame();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3680
  restore_return_pc();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3681
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3682
  // Restore spilled values.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3683
  if (Robj != noreg && Robj->is_volatile()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3684
    z_lg(Robj, Robj->encoding()*BytesPerWord, Z_SP);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3685
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3686
  if (offset.is_register() && offset.as_register()->is_volatile()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3687
    Register Roff = offset.as_register();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3688
    z_lg(Roff, Roff->encoding()*BytesPerWord, Z_SP);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3689
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3690
  if (Rval != noreg && Rval->is_volatile()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3691
    z_lg(Rval, Rval->encoding()*BytesPerWord, Z_SP);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3692
  }
46726
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  3693
  if (pre_val_needed && Rpre_val->is_volatile()) {
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  3694
    lgr_if_needed(Rpre_val, Rpre_save);
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  3695
  }
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3696
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3697
  bind(filtered);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3698
  BLOCK_COMMENT("} g1_write_barrier_pre");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3699
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3700
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3701
// General G1 post-barrier generator.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3702
// Purpose: Store cross-region card.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3703
void MacroAssembler::g1_write_barrier_post(Register Rstore_addr,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3704
                                           Register Rnew_val,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3705
                                           Register Rtmp1,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3706
                                           Register Rtmp2,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3707
                                           Register Rtmp3) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3708
  Label callRuntime, filtered;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3709
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3710
  assert_different_registers(Rstore_addr, Rnew_val, Rtmp1, Rtmp2); // Most probably, Rnew_val == Rtmp3.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3711
49347
edb65305d3ac 8195148: Collapse G1SATBCardTableModRefBS and G1SATBCardTableLoggingModRefBS into a single G1BarrierSet
eosterlund
parents: 49172
diff changeset
  3712
  G1BarrierSet* bs = barrier_set_cast<G1BarrierSet>(Universe::heap()->barrier_set());
49172
f047fae0169c 8198750: [s390+x86_32+aarch64] Fix build after jdk-8195142
mdoerr
parents: 49164
diff changeset
  3713
  CardTable* ct = bs->card_table();
49347
edb65305d3ac 8195148: Collapse G1SATBCardTableModRefBS and G1SATBCardTableLoggingModRefBS into a single G1BarrierSet
eosterlund
parents: 49172
diff changeset
  3714
  assert(bs->kind() == BarrierSet::G1BarrierSet, "wrong barrier");
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3715
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3716
  BLOCK_COMMENT("g1_write_barrier_post {");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3717
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3718
  // Does store cross heap regions?
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3719
  // It does if the two addresses specify different grain addresses.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3720
  if (G1RSBarrierRegionFilter) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3721
    if (VM_Version::has_DistinctOpnds()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3722
      z_xgrk(Rtmp1, Rstore_addr, Rnew_val);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3723
    } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3724
      z_lgr(Rtmp1, Rstore_addr);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3725
      z_xgr(Rtmp1, Rnew_val);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3726
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3727
    z_srag(Rtmp1, Rtmp1, HeapRegion::LogOfHRGrainBytes);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3728
    z_bre(filtered);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3729
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3730
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3731
  // Crosses regions, storing NULL?
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3732
#ifdef ASSERT
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3733
  z_ltgr(Rnew_val, Rnew_val);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3734
  asm_assert_ne("null oop not allowed (G1)", 0x255); // TODO: also on z? Checked by caller on PPC64, so following branch is obsolete:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3735
  z_bre(filtered);  // Safety net: don't break if we have a NULL oop.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3736
#endif
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3737
  Rnew_val = noreg; // end of lifetime
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3738
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3739
  // Storing region crossing non-NULL, is card already dirty?
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 48585
diff changeset
  3740
  assert(sizeof(*ct->byte_map_base()) == sizeof(jbyte), "adjust this code");
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3741
  assert_different_registers(Rtmp1, Rtmp2, Rtmp3);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3742
  // Make sure not to use Z_R0 for any of these registers.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3743
  Register Rcard_addr = (Rtmp1 != Z_R0_scratch) ? Rtmp1 : Rtmp3;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3744
  Register Rbase      = (Rtmp2 != Z_R0_scratch) ? Rtmp2 : Rtmp3;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3745
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3746
  // calculate address of card
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 48585
diff changeset
  3747
  load_const_optimized(Rbase, (address)ct->byte_map_base());      // Card table base.
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 48585
diff changeset
  3748
  z_srlg(Rcard_addr, Rstore_addr, CardTable::card_shift);         // Index into card table.
46726
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  3749
  z_algr(Rcard_addr, Rbase);                                      // Explicit calculation needed for cli.
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3750
  Rbase = noreg; // end of lifetime
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3751
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3752
  // Filter young.
49172
f047fae0169c 8198750: [s390+x86_32+aarch64] Fix build after jdk-8195142
mdoerr
parents: 49164
diff changeset
  3753
  assert((unsigned int)G1CardTable::g1_young_card_val() <= 255, "otherwise check this code");
f047fae0169c 8198750: [s390+x86_32+aarch64] Fix build after jdk-8195142
mdoerr
parents: 49164
diff changeset
  3754
  z_cli(0, Rcard_addr, (int)G1CardTable::g1_young_card_val());
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3755
  z_bre(filtered);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3756
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3757
  // Check the card value. If dirty, we're done.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3758
  // This also avoids false sharing of the (already dirty) card.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3759
  z_sync(); // Required to support concurrent cleaning.
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 48585
diff changeset
  3760
  assert((unsigned int)CardTable::dirty_card_val() <= 255, "otherwise check this code");
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 48585
diff changeset
  3761
  z_cli(0, Rcard_addr, CardTable::dirty_card_val()); // Reload after membar.
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3762
  z_bre(filtered);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3763
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3764
  // Storing a region crossing, non-NULL oop, card is clean.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3765
  // Dirty card and log.
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 48585
diff changeset
  3766
  z_mvi(0, Rcard_addr, CardTable::dirty_card_val());
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3767
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3768
  Register Rcard_addr_x = Rcard_addr;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3769
  Register Rqueue_index = (Rtmp2 != Z_R0_scratch) ? Rtmp2 : Rtmp1;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3770
  Register Rqueue_buf   = (Rtmp3 != Z_R0_scratch) ? Rtmp3 : Rtmp1;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3771
  const int qidx_off    = in_bytes(JavaThread::dirty_card_queue_offset() + SATBMarkQueue::byte_offset_of_index());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3772
  const int qbuf_off    = in_bytes(JavaThread::dirty_card_queue_offset() + SATBMarkQueue::byte_offset_of_buf());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3773
  if ((Rcard_addr == Rqueue_buf) || (Rcard_addr == Rqueue_index)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3774
    Rcard_addr_x = Z_R0_scratch;  // Register shortage. We have to use Z_R0.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3775
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3776
  lgr_if_needed(Rcard_addr_x, Rcard_addr);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3777
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3778
  load_and_test_long(Rqueue_index, Address(Z_thread, qidx_off));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3779
  z_bre(callRuntime); // Index == 0 then jump to runtime.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3780
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3781
  z_lg(Rqueue_buf, qbuf_off, Z_thread);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3782
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3783
  add2reg(Rqueue_index, -wordSize); // Decrement index.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3784
  z_stg(Rqueue_index, qidx_off, Z_thread);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3785
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3786
  z_stg(Rcard_addr_x, 0, Rqueue_index, Rqueue_buf); // Store card.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3787
  z_bru(filtered);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3788
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3789
  bind(callRuntime);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3790
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3791
  // TODO: do we need a frame? Introduced to be on the safe side.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3792
  bool needs_frame = true;
46726
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  3793
  lgr_if_needed(Rcard_addr, Rcard_addr_x); // copy back asap. push_frame will destroy Z_R0_scratch!
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3794
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3795
  // VM call need frame to access(write) O register.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3796
  if (needs_frame) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3797
    save_return_pc();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3798
    push_frame_abi160(0); // Will use Z_R0 as tmp on old CPUs.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3799
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3800
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3801
  // Save the live input values.
46726
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  3802
  call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::g1_wb_post), Rcard_addr, Z_thread);
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3803
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3804
  if (needs_frame) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3805
    pop_frame();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3806
    restore_return_pc();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3807
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3808
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3809
  bind(filtered);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3810
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3811
  BLOCK_COMMENT("} g1_write_barrier_post");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3812
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3813
#endif // INCLUDE_ALL_GCS
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3814
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3815
// Last_Java_sp must comply to the rules in frame_s390.hpp.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3816
void MacroAssembler::set_last_Java_frame(Register last_Java_sp, Register last_Java_pc, bool allow_relocation) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3817
  BLOCK_COMMENT("set_last_Java_frame {");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3818
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3819
  // Always set last_Java_pc and flags first because once last_Java_sp
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3820
  // is visible has_last_Java_frame is true and users will look at the
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3821
  // rest of the fields. (Note: flags should always be zero before we
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3822
  // get here so doesn't need to be set.)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3823
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3824
  // Verify that last_Java_pc was zeroed on return to Java.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3825
  if (allow_relocation) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3826
    asm_assert_mem8_is_zero(in_bytes(JavaThread::last_Java_pc_offset()),
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3827
                            Z_thread,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3828
                            "last_Java_pc not zeroed before leaving Java",
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3829
                            0x200);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3830
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3831
    asm_assert_mem8_is_zero_static(in_bytes(JavaThread::last_Java_pc_offset()),
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3832
                                   Z_thread,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3833
                                   "last_Java_pc not zeroed before leaving Java",
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3834
                                   0x200);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3835
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3836
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3837
  // When returning from calling out from Java mode the frame anchor's
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3838
  // last_Java_pc will always be set to NULL. It is set here so that
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3839
  // if we are doing a call to native (not VM) that we capture the
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3840
  // known pc and don't have to rely on the native call having a
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3841
  // standard frame linkage where we can find the pc.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3842
  if (last_Java_pc!=noreg) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3843
    z_stg(last_Java_pc, Address(Z_thread, JavaThread::last_Java_pc_offset()));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3844
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3845
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3846
  // This membar release is not required on z/Architecture, since the sequence of stores
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3847
  // in maintained. Nevertheless, we leave it in to document the required ordering.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3848
  // The implementation of z_release() should be empty.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3849
  // z_release();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3850
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3851
  z_stg(last_Java_sp, Address(Z_thread, JavaThread::last_Java_sp_offset()));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3852
  BLOCK_COMMENT("} set_last_Java_frame");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3853
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3854
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3855
void MacroAssembler::reset_last_Java_frame(bool allow_relocation) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3856
  BLOCK_COMMENT("reset_last_Java_frame {");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3857
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3858
  if (allow_relocation) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3859
    asm_assert_mem8_isnot_zero(in_bytes(JavaThread::last_Java_sp_offset()),
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3860
                               Z_thread,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3861
                               "SP was not set, still zero",
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3862
                               0x202);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3863
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3864
    asm_assert_mem8_isnot_zero_static(in_bytes(JavaThread::last_Java_sp_offset()),
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3865
                                      Z_thread,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3866
                                      "SP was not set, still zero",
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3867
                                      0x202);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3868
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3869
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3870
  // _last_Java_sp = 0
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3871
  // Clearing storage must be atomic here, so don't use clear_mem()!
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3872
  store_const(Address(Z_thread, JavaThread::last_Java_sp_offset()), 0);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3873
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3874
  // _last_Java_pc = 0
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3875
  store_const(Address(Z_thread, JavaThread::last_Java_pc_offset()), 0);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3876
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3877
  BLOCK_COMMENT("} reset_last_Java_frame");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3878
  return;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3879
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3880
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3881
void MacroAssembler::set_top_ijava_frame_at_SP_as_last_Java_frame(Register sp, Register tmp1, bool allow_relocation) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3882
  assert_different_registers(sp, tmp1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3883
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3884
  // We cannot trust that code generated by the C++ compiler saves R14
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3885
  // to z_abi_160.return_pc, because sometimes it spills R14 using stmg at
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3886
  // z_abi_160.gpr14 (e.g. InterpreterRuntime::_new()).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3887
  // Therefore we load the PC into tmp1 and let set_last_Java_frame() save
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3888
  // it into the frame anchor.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3889
  get_PC(tmp1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3890
  set_last_Java_frame(/*sp=*/sp, /*pc=*/tmp1, allow_relocation);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3891
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3892
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3893
void MacroAssembler::set_thread_state(JavaThreadState new_state) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3894
  z_release();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3895
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3896
  assert(Immediate::is_uimm16(_thread_max_state), "enum value out of range for instruction");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3897
  assert(sizeof(JavaThreadState) == sizeof(int), "enum value must have base type int");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3898
  store_const(Address(Z_thread, JavaThread::thread_state_offset()), new_state, Z_R0, false);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3899
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3900
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3901
void MacroAssembler::get_vm_result(Register oop_result) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3902
  verify_thread();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3903
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3904
  z_lg(oop_result, Address(Z_thread, JavaThread::vm_result_offset()));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3905
  clear_mem(Address(Z_thread, JavaThread::vm_result_offset()), sizeof(void*));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3906
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3907
  verify_oop(oop_result);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3908
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3909
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3910
void MacroAssembler::get_vm_result_2(Register result) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3911
  verify_thread();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3912
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3913
  z_lg(result, Address(Z_thread, JavaThread::vm_result_2_offset()));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3914
  clear_mem(Address(Z_thread, JavaThread::vm_result_2_offset()), sizeof(void*));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3915
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3916
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3917
// We require that C code which does not return a value in vm_result will
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3918
// leave it undisturbed.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3919
void MacroAssembler::set_vm_result(Register oop_result) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3920
  z_stg(oop_result, Address(Z_thread, JavaThread::vm_result_offset()));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3921
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3922
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3923
// Explicit null checks (used for method handle code).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3924
void MacroAssembler::null_check(Register reg, Register tmp, int64_t offset) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3925
  if (!ImplicitNullChecks) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3926
    NearLabel ok;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3927
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3928
    compare64_and_branch(reg, (intptr_t) 0, Assembler::bcondNotEqual, ok);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3929
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3930
    // We just put the address into reg if it was 0 (tmp==Z_R0 is allowed so we can't use it for the address).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3931
    address exception_entry = Interpreter::throw_NullPointerException_entry();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3932
    load_absolute_address(reg, exception_entry);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3933
    z_br(reg);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3934
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3935
    bind(ok);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3936
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3937
    if (needs_explicit_null_check((intptr_t)offset)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3938
      // Provoke OS NULL exception if reg = NULL by
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3939
      // accessing M[reg] w/o changing any registers.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3940
      z_lg(tmp, 0, reg);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3941
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3942
    // else
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3943
      // Nothing to do, (later) access of M[reg + offset]
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3944
      // will provoke OS NULL exception if reg = NULL.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3945
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3946
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3947
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3948
//-------------------------------------
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3949
//  Compressed Klass Pointers
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3950
//-------------------------------------
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3951
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3952
// Klass oop manipulations if compressed.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3953
void MacroAssembler::encode_klass_not_null(Register dst, Register src) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3954
  Register current = (src != noreg) ? src : dst; // Klass is in dst if no src provided. (dst == src) also possible.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3955
  address  base    = Universe::narrow_klass_base();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3956
  int      shift   = Universe::narrow_klass_shift();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3957
  assert(UseCompressedClassPointers, "only for compressed klass ptrs");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3958
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3959
  BLOCK_COMMENT("cKlass encoder {");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3960
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3961
#ifdef ASSERT
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3962
  Label ok;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3963
  z_tmll(current, KlassAlignmentInBytes-1); // Check alignment.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3964
  z_brc(Assembler::bcondAllZero, ok);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3965
  // The plain disassembler does not recognize illtrap. It instead displays
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3966
  // a 32-bit value. Issueing two illtraps assures the disassembler finds
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3967
  // the proper beginning of the next instruction.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3968
  z_illtrap(0xee);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3969
  z_illtrap(0xee);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3970
  bind(ok);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3971
#endif
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3972
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3973
  if (base != NULL) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3974
    unsigned int base_h = ((unsigned long)base)>>32;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3975
    unsigned int base_l = (unsigned int)((unsigned long)base);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3976
    if ((base_h != 0) && (base_l == 0) && VM_Version::has_HighWordInstr()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3977
      lgr_if_needed(dst, current);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3978
      z_aih(dst, -((int)base_h));     // Base has no set bits in lower half.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3979
    } else if ((base_h == 0) && (base_l != 0)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3980
      lgr_if_needed(dst, current);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3981
      z_agfi(dst, -(int)base_l);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3982
    } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3983
      load_const(Z_R0, base);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3984
      lgr_if_needed(dst, current);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3985
      z_sgr(dst, Z_R0);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3986
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3987
    current = dst;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3988
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3989
  if (shift != 0) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3990
    assert (LogKlassAlignmentInBytes == shift, "decode alg wrong");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3991
    z_srlg(dst, current, shift);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3992
    current = dst;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3993
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3994
  lgr_if_needed(dst, current); // Move may be required (if neither base nor shift != 0).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3995
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3996
  BLOCK_COMMENT("} cKlass encoder");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3997
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3998
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  3999
// This function calculates the size of the code generated by
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4000
//   decode_klass_not_null(register dst, Register src)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4001
// when (Universe::heap() != NULL). Hence, if the instructions
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4002
// it generates change, then this method needs to be updated.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4003
int MacroAssembler::instr_size_for_decode_klass_not_null() {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4004
  address  base    = Universe::narrow_klass_base();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4005
  int shift_size   = Universe::narrow_klass_shift() == 0 ? 0 : 6; /* sllg */
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4006
  int addbase_size = 0;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4007
  assert(UseCompressedClassPointers, "only for compressed klass ptrs");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4008
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4009
  if (base != NULL) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4010
    unsigned int base_h = ((unsigned long)base)>>32;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4011
    unsigned int base_l = (unsigned int)((unsigned long)base);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4012
    if ((base_h != 0) && (base_l == 0) && VM_Version::has_HighWordInstr()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4013
      addbase_size += 6; /* aih */
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4014
    } else if ((base_h == 0) && (base_l != 0)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4015
      addbase_size += 6; /* algfi */
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4016
    } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4017
      addbase_size += load_const_size();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4018
      addbase_size += 4; /* algr */
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4019
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4020
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4021
#ifdef ASSERT
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4022
  addbase_size += 10;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4023
  addbase_size += 2; // Extra sigill.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4024
#endif
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4025
  return addbase_size + shift_size;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4026
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4027
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4028
// !!! If the instructions that get generated here change
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4029
//     then function instr_size_for_decode_klass_not_null()
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4030
//     needs to get updated.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4031
// This variant of decode_klass_not_null() must generate predictable code!
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4032
// The code must only depend on globally known parameters.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4033
void MacroAssembler::decode_klass_not_null(Register dst) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4034
  address  base    = Universe::narrow_klass_base();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4035
  int      shift   = Universe::narrow_klass_shift();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4036
  int      beg_off = offset();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4037
  assert(UseCompressedClassPointers, "only for compressed klass ptrs");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4038
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4039
  BLOCK_COMMENT("cKlass decoder (const size) {");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4040
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4041
  if (shift != 0) { // Shift required?
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4042
    z_sllg(dst, dst, shift);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4043
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4044
  if (base != NULL) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4045
    unsigned int base_h = ((unsigned long)base)>>32;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4046
    unsigned int base_l = (unsigned int)((unsigned long)base);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4047
    if ((base_h != 0) && (base_l == 0) && VM_Version::has_HighWordInstr()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4048
      z_aih(dst, base_h);     // Base has no set bits in lower half.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4049
    } else if ((base_h == 0) && (base_l != 0)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4050
      z_algfi(dst, base_l);   // Base has no set bits in upper half.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4051
    } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4052
      load_const(Z_R0, base); // Base has set bits everywhere.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4053
      z_algr(dst, Z_R0);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4054
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4055
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4056
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4057
#ifdef ASSERT
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4058
  Label ok;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4059
  z_tmll(dst, KlassAlignmentInBytes-1); // Check alignment.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4060
  z_brc(Assembler::bcondAllZero, ok);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4061
  // The plain disassembler does not recognize illtrap. It instead displays
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4062
  // a 32-bit value. Issueing two illtraps assures the disassembler finds
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4063
  // the proper beginning of the next instruction.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4064
  z_illtrap(0xd1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4065
  z_illtrap(0xd1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4066
  bind(ok);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4067
#endif
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4068
  assert(offset() == beg_off + instr_size_for_decode_klass_not_null(), "Code gen mismatch.");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4069
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4070
  BLOCK_COMMENT("} cKlass decoder (const size)");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4071
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4072
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4073
// This variant of decode_klass_not_null() is for cases where
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4074
//  1) the size of the generated instructions may vary
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4075
//  2) the result is (potentially) stored in a register different from the source.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4076
void MacroAssembler::decode_klass_not_null(Register dst, Register src) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4077
  address base  = Universe::narrow_klass_base();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4078
  int     shift = Universe::narrow_klass_shift();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4079
  assert(UseCompressedClassPointers, "only for compressed klass ptrs");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4080
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4081
  BLOCK_COMMENT("cKlass decoder {");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4082
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4083
  if (src == noreg) src = dst;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4084
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4085
  if (shift != 0) { // Shift or at least move required?
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4086
    z_sllg(dst, src, shift);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4087
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4088
    lgr_if_needed(dst, src);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4089
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4090
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4091
  if (base != NULL) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4092
    unsigned int base_h = ((unsigned long)base)>>32;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4093
    unsigned int base_l = (unsigned int)((unsigned long)base);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4094
    if ((base_h != 0) && (base_l == 0) && VM_Version::has_HighWordInstr()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4095
      z_aih(dst, base_h);     // Base has not set bits in lower half.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4096
    } else if ((base_h == 0) && (base_l != 0)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4097
      z_algfi(dst, base_l);   // Base has no set bits in upper half.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4098
    } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4099
      load_const_optimized(Z_R0, base); // Base has set bits everywhere.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4100
      z_algr(dst, Z_R0);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4101
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4102
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4103
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4104
#ifdef ASSERT
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4105
  Label ok;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4106
  z_tmll(dst, KlassAlignmentInBytes-1); // Check alignment.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4107
  z_brc(Assembler::bcondAllZero, ok);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4108
  // The plain disassembler does not recognize illtrap. It instead displays
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4109
  // a 32-bit value. Issueing two illtraps assures the disassembler finds
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4110
  // the proper beginning of the next instruction.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4111
  z_illtrap(0xd2);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4112
  z_illtrap(0xd2);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4113
  bind(ok);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4114
#endif
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4115
  BLOCK_COMMENT("} cKlass decoder");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4116
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4117
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4118
void MacroAssembler::load_klass(Register klass, Address mem) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4119
  if (UseCompressedClassPointers) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4120
    z_llgf(klass, mem);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4121
    // Attention: no null check here!
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4122
    decode_klass_not_null(klass);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4123
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4124
    z_lg(klass, mem);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4125
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4126
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4127
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4128
void MacroAssembler::load_klass(Register klass, Register src_oop) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4129
  if (UseCompressedClassPointers) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4130
    z_llgf(klass, oopDesc::klass_offset_in_bytes(), src_oop);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4131
    // Attention: no null check here!
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4132
    decode_klass_not_null(klass);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4133
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4134
    z_lg(klass, oopDesc::klass_offset_in_bytes(), src_oop);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4135
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4136
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4137
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4138
void MacroAssembler::load_prototype_header(Register Rheader, Register Rsrc_oop) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4139
  assert_different_registers(Rheader, Rsrc_oop);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4140
  load_klass(Rheader, Rsrc_oop);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4141
  z_lg(Rheader, Address(Rheader, Klass::prototype_header_offset()));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4142
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4143
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4144
void MacroAssembler::store_klass(Register klass, Register dst_oop, Register ck) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4145
  if (UseCompressedClassPointers) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4146
    assert_different_registers(dst_oop, klass, Z_R0);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4147
    if (ck == noreg) ck = klass;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4148
    encode_klass_not_null(ck, klass);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4149
    z_st(ck, Address(dst_oop, oopDesc::klass_offset_in_bytes()));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4150
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4151
    z_stg(klass, Address(dst_oop, oopDesc::klass_offset_in_bytes()));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4152
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4153
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4154
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4155
void MacroAssembler::store_klass_gap(Register s, Register d) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4156
  if (UseCompressedClassPointers) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4157
    assert(s != d, "not enough registers");
46726
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  4158
    // Support s = noreg.
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  4159
    if (s != noreg) {
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  4160
      z_st(s, Address(d, oopDesc::klass_gap_offset_in_bytes()));
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  4161
    } else {
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  4162
      z_mvhi(Address(d, oopDesc::klass_gap_offset_in_bytes()), 0);
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  4163
    }
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4164
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4165
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4166
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4167
// Compare klass ptr in memory against klass ptr in register.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4168
//
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4169
// Rop1            - klass in register, always uncompressed.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4170
// disp            - Offset of klass in memory, compressed/uncompressed, depending on runtime flag.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4171
// Rbase           - Base address of cKlass in memory.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4172
// maybeNULL       - True if Rop1 possibly is a NULL.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4173
void MacroAssembler::compare_klass_ptr(Register Rop1, int64_t disp, Register Rbase, bool maybeNULL) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4174
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4175
  BLOCK_COMMENT("compare klass ptr {");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4176
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4177
  if (UseCompressedClassPointers) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4178
    const int shift = Universe::narrow_klass_shift();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4179
    address   base  = Universe::narrow_klass_base();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4180
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4181
    assert((shift == 0) || (shift == LogKlassAlignmentInBytes), "cKlass encoder detected bad shift");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4182
    assert_different_registers(Rop1, Z_R0);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4183
    assert_different_registers(Rop1, Rbase, Z_R1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4184
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4185
    // First encode register oop and then compare with cOop in memory.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4186
    // This sequence saves an unnecessary cOop load and decode.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4187
    if (base == NULL) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4188
      if (shift == 0) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4189
        z_cl(Rop1, disp, Rbase);     // Unscaled
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4190
      } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4191
        z_srlg(Z_R0, Rop1, shift);   // ZeroBased
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4192
        z_cl(Z_R0, disp, Rbase);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4193
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4194
    } else {                         // HeapBased
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4195
#ifdef ASSERT
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4196
      bool     used_R0 = true;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4197
      bool     used_R1 = true;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4198
#endif
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4199
      Register current = Rop1;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4200
      Label    done;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4201
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4202
      if (maybeNULL) {       // NULL ptr must be preserved!
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4203
        z_ltgr(Z_R0, current);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4204
        z_bre(done);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4205
        current = Z_R0;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4206
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4207
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4208
      unsigned int base_h = ((unsigned long)base)>>32;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4209
      unsigned int base_l = (unsigned int)((unsigned long)base);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4210
      if ((base_h != 0) && (base_l == 0) && VM_Version::has_HighWordInstr()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4211
        lgr_if_needed(Z_R0, current);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4212
        z_aih(Z_R0, -((int)base_h));     // Base has no set bits in lower half.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4213
      } else if ((base_h == 0) && (base_l != 0)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4214
        lgr_if_needed(Z_R0, current);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4215
        z_agfi(Z_R0, -(int)base_l);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4216
      } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4217
        int pow2_offset = get_oop_base_complement(Z_R1, ((uint64_t)(intptr_t)base));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4218
        add2reg_with_index(Z_R0, pow2_offset, Z_R1, Rop1); // Subtract base by adding complement.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4219
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4220
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4221
      if (shift != 0) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4222
        z_srlg(Z_R0, Z_R0, shift);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4223
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4224
      bind(done);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4225
      z_cl(Z_R0, disp, Rbase);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4226
#ifdef ASSERT
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4227
      if (used_R0) preset_reg(Z_R0, 0xb05bUL, 2);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4228
      if (used_R1) preset_reg(Z_R1, 0xb06bUL, 2);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4229
#endif
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4230
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4231
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4232
    z_clg(Rop1, disp, Z_R0, Rbase);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4233
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4234
  BLOCK_COMMENT("} compare klass ptr");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4235
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4236
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4237
//---------------------------
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4238
//  Compressed oops
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4239
//---------------------------
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4240
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4241
void MacroAssembler::encode_heap_oop(Register oop) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4242
  oop_encoder(oop, oop, true /*maybe null*/);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4243
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4244
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4245
void MacroAssembler::encode_heap_oop_not_null(Register oop) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4246
  oop_encoder(oop, oop, false /*not null*/);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4247
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4248
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4249
// Called with something derived from the oop base. e.g. oop_base>>3.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4250
int MacroAssembler::get_oop_base_pow2_offset(uint64_t oop_base) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4251
  unsigned int oop_base_ll = ((unsigned int)(oop_base >>  0)) & 0xffff;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4252
  unsigned int oop_base_lh = ((unsigned int)(oop_base >> 16)) & 0xffff;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4253
  unsigned int oop_base_hl = ((unsigned int)(oop_base >> 32)) & 0xffff;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4254
  unsigned int oop_base_hh = ((unsigned int)(oop_base >> 48)) & 0xffff;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4255
  unsigned int n_notzero_parts = (oop_base_ll == 0 ? 0:1)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4256
                               + (oop_base_lh == 0 ? 0:1)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4257
                               + (oop_base_hl == 0 ? 0:1)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4258
                               + (oop_base_hh == 0 ? 0:1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4259
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4260
  assert(oop_base != 0, "This is for HeapBased cOops only");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4261
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4262
  if (n_notzero_parts != 1) { //  Check if oop_base is just a few pages shy of a power of 2.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4263
    uint64_t pow2_offset = 0x10000 - oop_base_ll;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4264
    if (pow2_offset < 0x8000) {  // This might not be necessary.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4265
      uint64_t oop_base2 = oop_base + pow2_offset;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4266
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4267
      oop_base_ll = ((unsigned int)(oop_base2 >>  0)) & 0xffff;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4268
      oop_base_lh = ((unsigned int)(oop_base2 >> 16)) & 0xffff;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4269
      oop_base_hl = ((unsigned int)(oop_base2 >> 32)) & 0xffff;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4270
      oop_base_hh = ((unsigned int)(oop_base2 >> 48)) & 0xffff;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4271
      n_notzero_parts = (oop_base_ll == 0 ? 0:1) +
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4272
                        (oop_base_lh == 0 ? 0:1) +
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4273
                        (oop_base_hl == 0 ? 0:1) +
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4274
                        (oop_base_hh == 0 ? 0:1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4275
      if (n_notzero_parts == 1) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4276
        assert(-(int64_t)pow2_offset != (int64_t)-1, "We use -1 to signal uninitialized base register");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4277
        return -pow2_offset;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4278
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4279
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4280
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4281
  return 0;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4282
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4283
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4284
// If base address is offset from a straight power of two by just a few pages,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4285
// return this offset to the caller for a possible later composite add.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4286
// TODO/FIX: will only work correctly for 4k pages.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4287
int MacroAssembler::get_oop_base(Register Rbase, uint64_t oop_base) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4288
  int pow2_offset = get_oop_base_pow2_offset(oop_base);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4289
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4290
  load_const_optimized(Rbase, oop_base - pow2_offset); // Best job possible.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4291
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4292
  return pow2_offset;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4293
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4294
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4295
int MacroAssembler::get_oop_base_complement(Register Rbase, uint64_t oop_base) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4296
  int offset = get_oop_base(Rbase, oop_base);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4297
  z_lcgr(Rbase, Rbase);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4298
  return -offset;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4299
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4300
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4301
// Compare compressed oop in memory against oop in register.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4302
// Rop1            - Oop in register.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4303
// disp            - Offset of cOop in memory.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4304
// Rbase           - Base address of cOop in memory.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4305
// maybeNULL       - True if Rop1 possibly is a NULL.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4306
// maybeNULLtarget - Branch target for Rop1 == NULL, if flow control shall NOT continue with compare instruction.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4307
void MacroAssembler::compare_heap_oop(Register Rop1, Address mem, bool maybeNULL) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4308
  Register Rbase  = mem.baseOrR0();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4309
  Register Rindex = mem.indexOrR0();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4310
  int64_t  disp   = mem.disp();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4311
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4312
  const int shift = Universe::narrow_oop_shift();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4313
  address   base  = Universe::narrow_oop_base();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4314
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4315
  assert(UseCompressedOops, "must be on to call this method");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4316
  assert(Universe::heap() != NULL, "java heap must be initialized to call this method");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4317
  assert((shift == 0) || (shift == LogMinObjAlignmentInBytes), "cOop encoder detected bad shift");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4318
  assert_different_registers(Rop1, Z_R0);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4319
  assert_different_registers(Rop1, Rbase, Z_R1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4320
  assert_different_registers(Rop1, Rindex, Z_R1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4321
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4322
  BLOCK_COMMENT("compare heap oop {");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4323
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4324
  // First encode register oop and then compare with cOop in memory.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4325
  // This sequence saves an unnecessary cOop load and decode.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4326
  if (base == NULL) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4327
    if (shift == 0) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4328
      z_cl(Rop1, disp, Rindex, Rbase);  // Unscaled
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4329
    } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4330
      z_srlg(Z_R0, Rop1, shift);        // ZeroBased
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4331
      z_cl(Z_R0, disp, Rindex, Rbase);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4332
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4333
  } else {                              // HeapBased
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4334
#ifdef ASSERT
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4335
    bool  used_R0 = true;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4336
    bool  used_R1 = true;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4337
#endif
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4338
    Label done;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4339
    int   pow2_offset = get_oop_base_complement(Z_R1, ((uint64_t)(intptr_t)base));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4340
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4341
    if (maybeNULL) {       // NULL ptr must be preserved!
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4342
      z_ltgr(Z_R0, Rop1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4343
      z_bre(done);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4344
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4345
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4346
    add2reg_with_index(Z_R0, pow2_offset, Z_R1, Rop1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4347
    z_srlg(Z_R0, Z_R0, shift);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4348
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4349
    bind(done);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4350
    z_cl(Z_R0, disp, Rindex, Rbase);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4351
#ifdef ASSERT
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4352
    if (used_R0) preset_reg(Z_R0, 0xb05bUL, 2);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4353
    if (used_R1) preset_reg(Z_R1, 0xb06bUL, 2);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4354
#endif
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4355
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4356
  BLOCK_COMMENT("} compare heap oop");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4357
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4358
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4359
// Load heap oop and decompress, if necessary.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4360
void  MacroAssembler::load_heap_oop(Register dest, const Address &a) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4361
  if (UseCompressedOops) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4362
    z_llgf(dest, a.disp(), a.indexOrR0(), a.baseOrR0());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4363
    oop_decoder(dest, dest, true);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4364
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4365
    z_lg(dest, a.disp(), a.indexOrR0(), a.baseOrR0());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4366
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4367
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4368
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4369
// Load heap oop and decompress, if necessary.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4370
void MacroAssembler::load_heap_oop(Register dest, int64_t disp, Register base) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4371
  if (UseCompressedOops) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4372
    z_llgf(dest, disp, base);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4373
    oop_decoder(dest, dest, true);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4374
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4375
    z_lg(dest, disp, base);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4376
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4377
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4378
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4379
// Load heap oop and decompress, if necessary.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4380
void MacroAssembler::load_heap_oop_not_null(Register dest, int64_t disp, Register base) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4381
  if (UseCompressedOops) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4382
    z_llgf(dest, disp, base);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4383
    oop_decoder(dest, dest, false);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4384
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4385
    z_lg(dest, disp, base);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4386
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4387
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4388
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4389
// Compress, if necessary, and store oop to heap.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4390
void MacroAssembler::store_heap_oop(Register Roop, RegisterOrConstant offset, Register base) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4391
  Register Ridx = offset.is_register() ? offset.register_or_noreg() : Z_R0;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4392
  if (UseCompressedOops) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4393
    assert_different_registers(Roop, offset.register_or_noreg(), base);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4394
    encode_heap_oop(Roop);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4395
    z_st(Roop, offset.constant_or_zero(), Ridx, base);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4396
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4397
    z_stg(Roop, offset.constant_or_zero(), Ridx, base);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4398
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4399
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4400
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4401
// Compress, if necessary, and store oop to heap. Oop is guaranteed to be not NULL.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4402
void MacroAssembler::store_heap_oop_not_null(Register Roop, RegisterOrConstant offset, Register base) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4403
  Register Ridx = offset.is_register() ? offset.register_or_noreg() : Z_R0;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4404
  if (UseCompressedOops) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4405
    assert_different_registers(Roop, offset.register_or_noreg(), base);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4406
    encode_heap_oop_not_null(Roop);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4407
    z_st(Roop, offset.constant_or_zero(), Ridx, base);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4408
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4409
    z_stg(Roop, offset.constant_or_zero(), Ridx, base);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4410
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4411
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4412
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4413
// Store NULL oop to heap.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4414
void MacroAssembler::store_heap_oop_null(Register zero, RegisterOrConstant offset, Register base) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4415
  Register Ridx = offset.is_register() ? offset.register_or_noreg() : Z_R0;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4416
  if (UseCompressedOops) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4417
    z_st(zero, offset.constant_or_zero(), Ridx, base);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4418
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4419
    z_stg(zero, offset.constant_or_zero(), Ridx, base);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4420
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4421
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4422
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4423
//-------------------------------------------------
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4424
// Encode compressed oop. Generally usable encoder.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4425
//-------------------------------------------------
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4426
// Rsrc - contains regular oop on entry. It remains unchanged.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4427
// Rdst - contains compressed oop on exit.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4428
// Rdst and Rsrc may indicate same register, in which case Rsrc does not remain unchanged.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4429
//
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4430
// Rdst must not indicate scratch register Z_R1 (Z_R1_scratch) for functionality.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4431
// Rdst should not indicate scratch register Z_R0 (Z_R0_scratch) for performance.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4432
//
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4433
// only32bitValid is set, if later code only uses the lower 32 bits. In this
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4434
// case we must not fix the upper 32 bits.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4435
void MacroAssembler::oop_encoder(Register Rdst, Register Rsrc, bool maybeNULL,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4436
                                 Register Rbase, int pow2_offset, bool only32bitValid) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4437
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4438
  const address oop_base  = Universe::narrow_oop_base();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4439
  const int     oop_shift = Universe::narrow_oop_shift();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4440
  const bool    disjoint  = Universe::narrow_oop_base_disjoint();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4441
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4442
  assert(UseCompressedOops, "must be on to call this method");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4443
  assert(Universe::heap() != NULL, "java heap must be initialized to call this encoder");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4444
  assert((oop_shift == 0) || (oop_shift == LogMinObjAlignmentInBytes), "cOop encoder detected bad shift");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4445
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4446
  if (disjoint || (oop_base == NULL)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4447
    BLOCK_COMMENT("cOop encoder zeroBase {");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4448
    if (oop_shift == 0) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4449
      if (oop_base != NULL && !only32bitValid) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4450
        z_llgfr(Rdst, Rsrc); // Clear upper bits in case the register will be decoded again.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4451
      } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4452
        lgr_if_needed(Rdst, Rsrc);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4453
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4454
    } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4455
      z_srlg(Rdst, Rsrc, oop_shift);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4456
      if (oop_base != NULL && !only32bitValid) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4457
        z_llgfr(Rdst, Rdst); // Clear upper bits in case the register will be decoded again.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4458
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4459
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4460
    BLOCK_COMMENT("} cOop encoder zeroBase");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4461
    return;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4462
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4463
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4464
  bool used_R0 = false;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4465
  bool used_R1 = false;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4466
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4467
  BLOCK_COMMENT("cOop encoder general {");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4468
  assert_different_registers(Rdst, Z_R1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4469
  assert_different_registers(Rsrc, Rbase);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4470
  if (maybeNULL) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4471
    Label done;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4472
    // We reorder shifting and subtracting, so that we can compare
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4473
    // and shift in parallel:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4474
    //
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4475
    // cycle 0:  potential LoadN, base = <const>
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4476
    // cycle 1:  base = !base     dst = src >> 3,    cmp cr = (src != 0)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4477
    // cycle 2:  if (cr) br,      dst = dst + base + offset
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4478
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4479
    // Get oop_base components.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4480
    if (pow2_offset == -1) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4481
      if (Rdst == Rbase) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4482
        if (Rdst == Z_R1 || Rsrc == Z_R1) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4483
          Rbase = Z_R0;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4484
          used_R0 = true;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4485
        } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4486
          Rdst = Z_R1;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4487
          used_R1 = true;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4488
        }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4489
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4490
      if (Rbase == Z_R1) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4491
        used_R1 = true;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4492
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4493
      pow2_offset = get_oop_base_complement(Rbase, ((uint64_t)(intptr_t)oop_base) >> oop_shift);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4494
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4495
    assert_different_registers(Rdst, Rbase);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4496
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4497
    // Check for NULL oop (must be left alone) and shift.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4498
    if (oop_shift != 0) {  // Shift out alignment bits
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4499
      if (((intptr_t)oop_base&0xc000000000000000L) == 0L) { // We are sure: no single address will have the leftmost bit set.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4500
        z_srag(Rdst, Rsrc, oop_shift);  // Arithmetic shift sets the condition code.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4501
      } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4502
        z_srlg(Rdst, Rsrc, oop_shift);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4503
        z_ltgr(Rsrc, Rsrc);  // This is the recommended way of testing for zero.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4504
        // This probably is faster, as it does not write a register. No!
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4505
        // z_cghi(Rsrc, 0);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4506
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4507
    } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4508
      z_ltgr(Rdst, Rsrc);   // Move NULL to result register.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4509
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4510
    z_bre(done);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4511
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4512
    // Subtract oop_base components.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4513
    if ((Rdst == Z_R0) || (Rbase == Z_R0)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4514
      z_algr(Rdst, Rbase);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4515
      if (pow2_offset != 0) { add2reg(Rdst, pow2_offset); }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4516
    } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4517
      add2reg_with_index(Rdst, pow2_offset, Rbase, Rdst);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4518
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4519
    if (!only32bitValid) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4520
      z_llgfr(Rdst, Rdst); // Clear upper bits in case the register will be decoded again.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4521
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4522
    bind(done);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4523
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4524
  } else {  // not null
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4525
    // Get oop_base components.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4526
    if (pow2_offset == -1) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4527
      pow2_offset = get_oop_base_complement(Rbase, (uint64_t)(intptr_t)oop_base);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4528
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4529
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4530
    // Subtract oop_base components and shift.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4531
    if (Rdst == Z_R0 || Rsrc == Z_R0 || Rbase == Z_R0) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4532
      // Don't use lay instruction.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4533
      if (Rdst == Rsrc) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4534
        z_algr(Rdst, Rbase);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4535
      } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4536
        lgr_if_needed(Rdst, Rbase);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4537
        z_algr(Rdst, Rsrc);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4538
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4539
      if (pow2_offset != 0) add2reg(Rdst, pow2_offset);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4540
    } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4541
      add2reg_with_index(Rdst, pow2_offset, Rbase, Rsrc);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4542
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4543
    if (oop_shift != 0) {   // Shift out alignment bits.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4544
      z_srlg(Rdst, Rdst, oop_shift);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4545
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4546
    if (!only32bitValid) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4547
      z_llgfr(Rdst, Rdst); // Clear upper bits in case the register will be decoded again.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4548
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4549
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4550
#ifdef ASSERT
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4551
  if (used_R0 && Rdst != Z_R0 && Rsrc != Z_R0) { preset_reg(Z_R0, 0xb01bUL, 2); }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4552
  if (used_R1 && Rdst != Z_R1 && Rsrc != Z_R1) { preset_reg(Z_R1, 0xb02bUL, 2); }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4553
#endif
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4554
  BLOCK_COMMENT("} cOop encoder general");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4555
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4556
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4557
//-------------------------------------------------
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4558
// decode compressed oop. Generally usable decoder.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4559
//-------------------------------------------------
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4560
// Rsrc - contains compressed oop on entry.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4561
// Rdst - contains regular oop on exit.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4562
// Rdst and Rsrc may indicate same register.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4563
// Rdst must not be the same register as Rbase, if Rbase was preloaded (before call).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4564
// Rdst can be the same register as Rbase. Then, either Z_R0 or Z_R1 must be available as scratch.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4565
// Rbase - register to use for the base
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4566
// pow2_offset - offset of base to nice value. If -1, base must be loaded.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4567
// For performance, it is good to
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4568
//  - avoid Z_R0 for any of the argument registers.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4569
//  - keep Rdst and Rsrc distinct from Rbase. Rdst == Rsrc is ok for performance.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4570
//  - avoid Z_R1 for Rdst if Rdst == Rbase.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4571
void MacroAssembler::oop_decoder(Register Rdst, Register Rsrc, bool maybeNULL, Register Rbase, int pow2_offset) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4572
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4573
  const address oop_base  = Universe::narrow_oop_base();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4574
  const int     oop_shift = Universe::narrow_oop_shift();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4575
  const bool    disjoint  = Universe::narrow_oop_base_disjoint();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4576
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4577
  assert(UseCompressedOops, "must be on to call this method");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4578
  assert(Universe::heap() != NULL, "java heap must be initialized to call this decoder");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4579
  assert((oop_shift == 0) || (oop_shift == LogMinObjAlignmentInBytes),
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4580
         "cOop encoder detected bad shift");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4581
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4582
  // cOops are always loaded zero-extended from memory. No explicit zero-extension necessary.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4583
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4584
  if (oop_base != NULL) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4585
    unsigned int oop_base_hl = ((unsigned int)((uint64_t)(intptr_t)oop_base >> 32)) & 0xffff;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4586
    unsigned int oop_base_hh = ((unsigned int)((uint64_t)(intptr_t)oop_base >> 48)) & 0xffff;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4587
    unsigned int oop_base_hf = ((unsigned int)((uint64_t)(intptr_t)oop_base >> 32)) & 0xFFFFffff;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4588
    if (disjoint && (oop_base_hl == 0 || oop_base_hh == 0)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4589
      BLOCK_COMMENT("cOop decoder disjointBase {");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4590
      // We do not need to load the base. Instead, we can install the upper bits
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4591
      // with an OR instead of an ADD.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4592
      Label done;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4593
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4594
      // Rsrc contains a narrow oop. Thus we are sure the leftmost <oop_shift> bits will never be set.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4595
      if (maybeNULL) {  // NULL ptr must be preserved!
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4596
        z_slag(Rdst, Rsrc, oop_shift);  // Arithmetic shift sets the condition code.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4597
        z_bre(done);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4598
      } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4599
        z_sllg(Rdst, Rsrc, oop_shift);  // Logical shift leaves condition code alone.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4600
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4601
      if ((oop_base_hl != 0) && (oop_base_hh != 0)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4602
        z_oihf(Rdst, oop_base_hf);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4603
      } else if (oop_base_hl != 0) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4604
        z_oihl(Rdst, oop_base_hl);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4605
      } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4606
        assert(oop_base_hh != 0, "not heapbased mode");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4607
        z_oihh(Rdst, oop_base_hh);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4608
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4609
      bind(done);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4610
      BLOCK_COMMENT("} cOop decoder disjointBase");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4611
    } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4612
      BLOCK_COMMENT("cOop decoder general {");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4613
      // There are three decode steps:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4614
      //   scale oop offset (shift left)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4615
      //   get base (in reg) and pow2_offset (constant)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4616
      //   add base, pow2_offset, and oop offset
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4617
      // The following register overlap situations may exist:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4618
      // Rdst == Rsrc,  Rbase any other
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4619
      //   not a problem. Scaling in-place leaves Rbase undisturbed.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4620
      //   Loading Rbase does not impact the scaled offset.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4621
      // Rdst == Rbase, Rsrc  any other
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4622
      //   scaling would destroy a possibly preloaded Rbase. Loading Rbase
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4623
      //   would destroy the scaled offset.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4624
      //   Remedy: use Rdst_tmp if Rbase has been preloaded.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4625
      //           use Rbase_tmp if base has to be loaded.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4626
      // Rsrc == Rbase, Rdst  any other
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4627
      //   Only possible without preloaded Rbase.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4628
      //   Loading Rbase does not destroy compressed oop because it was scaled into Rdst before.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4629
      // Rsrc == Rbase, Rdst == Rbase
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4630
      //   Only possible without preloaded Rbase.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4631
      //   Loading Rbase would destroy compressed oop. Scaling in-place is ok.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4632
      //   Remedy: use Rbase_tmp.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4633
      //
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4634
      Label    done;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4635
      Register Rdst_tmp       = Rdst;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4636
      Register Rbase_tmp      = Rbase;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4637
      bool     used_R0        = false;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4638
      bool     used_R1        = false;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4639
      bool     base_preloaded = pow2_offset >= 0;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4640
      guarantee(!(base_preloaded && (Rsrc == Rbase)), "Register clash, check caller");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4641
      assert(oop_shift != 0, "room for optimization");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4642
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4643
      // Check if we need to use scratch registers.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4644
      if (Rdst == Rbase) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4645
        assert(!(((Rdst == Z_R0) && (Rsrc == Z_R1)) || ((Rdst == Z_R1) && (Rsrc == Z_R0))), "need a scratch reg");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4646
        if (Rdst != Rsrc) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4647
          if (base_preloaded) { Rdst_tmp  = (Rdst == Z_R1) ? Z_R0 : Z_R1; }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4648
          else                { Rbase_tmp = (Rdst == Z_R1) ? Z_R0 : Z_R1; }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4649
        } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4650
          Rbase_tmp = (Rdst == Z_R1) ? Z_R0 : Z_R1;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4651
        }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4652
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4653
      if (base_preloaded) lgr_if_needed(Rbase_tmp, Rbase);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4654
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4655
      // Scale oop and check for NULL.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4656
      // Rsrc contains a narrow oop. Thus we are sure the leftmost <oop_shift> bits will never be set.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4657
      if (maybeNULL) {  // NULL ptr must be preserved!
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4658
        z_slag(Rdst_tmp, Rsrc, oop_shift);  // Arithmetic shift sets the condition code.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4659
        z_bre(done);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4660
      } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4661
        z_sllg(Rdst_tmp, Rsrc, oop_shift);  // Logical shift leaves condition code alone.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4662
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4663
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4664
      // Get oop_base components.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4665
      if (!base_preloaded) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4666
        pow2_offset = get_oop_base(Rbase_tmp, (uint64_t)(intptr_t)oop_base);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4667
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4668
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4669
      // Add up all components.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4670
      if ((Rbase_tmp == Z_R0) || (Rdst_tmp == Z_R0)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4671
        z_algr(Rdst_tmp, Rbase_tmp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4672
        if (pow2_offset != 0) { add2reg(Rdst_tmp, pow2_offset); }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4673
      } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4674
        add2reg_with_index(Rdst_tmp, pow2_offset, Rbase_tmp, Rdst_tmp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4675
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4676
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4677
      bind(done);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4678
      lgr_if_needed(Rdst, Rdst_tmp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4679
#ifdef ASSERT
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4680
      if (used_R0 && Rdst != Z_R0 && Rsrc != Z_R0) { preset_reg(Z_R0, 0xb03bUL, 2); }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4681
      if (used_R1 && Rdst != Z_R1 && Rsrc != Z_R1) { preset_reg(Z_R1, 0xb04bUL, 2); }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4682
#endif
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4683
      BLOCK_COMMENT("} cOop decoder general");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4684
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4685
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4686
    BLOCK_COMMENT("cOop decoder zeroBase {");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4687
    if (oop_shift == 0) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4688
      lgr_if_needed(Rdst, Rsrc);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4689
    } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4690
      z_sllg(Rdst, Rsrc, oop_shift);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4691
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4692
    BLOCK_COMMENT("} cOop decoder zeroBase");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4693
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4694
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4695
46961
c9094b1e5f87 8186088: ConstantPoolCache::_resolved_references is not a JNIHandle
coleenp
parents: 46726
diff changeset
  4696
// ((OopHandle)result).resolve();
c9094b1e5f87 8186088: ConstantPoolCache::_resolved_references is not a JNIHandle
coleenp
parents: 46726
diff changeset
  4697
void MacroAssembler::resolve_oop_handle(Register result) {
c9094b1e5f87 8186088: ConstantPoolCache::_resolved_references is not a JNIHandle
coleenp
parents: 46726
diff changeset
  4698
  // OopHandle::resolve is an indirection.
c9094b1e5f87 8186088: ConstantPoolCache::_resolved_references is not a JNIHandle
coleenp
parents: 46726
diff changeset
  4699
  z_lg(result, 0, result);
c9094b1e5f87 8186088: ConstantPoolCache::_resolved_references is not a JNIHandle
coleenp
parents: 46726
diff changeset
  4700
}
c9094b1e5f87 8186088: ConstantPoolCache::_resolved_references is not a JNIHandle
coleenp
parents: 46726
diff changeset
  4701
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4702
void MacroAssembler::load_mirror(Register mirror, Register method) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4703
  mem2reg_opt(mirror, Address(method, Method::const_offset()));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4704
  mem2reg_opt(mirror, Address(mirror, ConstMethod::constants_offset()));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4705
  mem2reg_opt(mirror, Address(mirror, ConstantPool::pool_holder_offset_in_bytes()));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4706
  mem2reg_opt(mirror, Address(mirror, Klass::java_mirror_offset()));
47580
96392e113a0a 8186777: Make Klass::_java_mirror an OopHandle
coleenp
parents: 47216
diff changeset
  4707
  resolve_oop_handle(mirror);
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4708
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4709
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4710
//---------------------------------------------------------------
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4711
//---  Operations on arrays.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4712
//---------------------------------------------------------------
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4713
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4714
// Compiler ensures base is doubleword aligned and cnt is #doublewords.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4715
// Emitter does not KILL cnt and base arguments, since they need to be copied to
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4716
// work registers anyway.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4717
// Actually, only r0, r1, and r5 are killed.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4718
unsigned int MacroAssembler::Clear_Array(Register cnt_arg, Register base_pointer_arg, Register src_addr, Register src_len) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4719
  // Src_addr is evenReg.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4720
  // Src_len is odd_Reg.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4721
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4722
  int      block_start = offset();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4723
  Register tmp_reg  = src_len; // Holds target instr addr for EX.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4724
  Register dst_len  = Z_R1;    // Holds dst len  for MVCLE.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4725
  Register dst_addr = Z_R0;    // Holds dst addr for MVCLE.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4726
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4727
  Label doXC, doMVCLE, done;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4728
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4729
  BLOCK_COMMENT("Clear_Array {");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4730
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4731
  // Check for zero len and convert to long.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4732
  z_ltgfr(src_len, cnt_arg);      // Remember casted value for doSTG case.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4733
  z_bre(done);                    // Nothing to do if len == 0.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4734
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4735
  // Prefetch data to be cleared.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4736
  if (VM_Version::has_Prefetch()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4737
    z_pfd(0x02,   0, Z_R0, base_pointer_arg);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4738
    z_pfd(0x02, 256, Z_R0, base_pointer_arg);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4739
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4740
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4741
  z_sllg(dst_len, src_len, 3);    // #bytes to clear.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4742
  z_cghi(src_len, 32);            // Check for len <= 256 bytes (<=32 DW).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4743
  z_brnh(doXC);                   // If so, use executed XC to clear.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4744
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4745
  // MVCLE: initialize long arrays (general case).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4746
  bind(doMVCLE);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4747
  z_lgr(dst_addr, base_pointer_arg);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4748
  clear_reg(src_len, true, false); // Src len of MVCLE is zero.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4749
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4750
  MacroAssembler::move_long_ext(dst_addr, src_addr, 0);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4751
  z_bru(done);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4752
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4753
  // XC: initialize short arrays.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4754
  Label XC_template; // Instr template, never exec directly!
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4755
    bind(XC_template);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4756
    z_xc(0,0,base_pointer_arg,0,base_pointer_arg);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4757
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4758
  bind(doXC);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4759
    add2reg(dst_len, -1);             // Get #bytes-1 for EXECUTE.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4760
    if (VM_Version::has_ExecuteExtensions()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4761
      z_exrl(dst_len, XC_template);   // Execute XC with var. len.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4762
    } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4763
      z_larl(tmp_reg, XC_template);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4764
      z_ex(dst_len,0,Z_R0,tmp_reg);   // Execute XC with var. len.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4765
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4766
    // z_bru(done);      // fallthru
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4767
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4768
  bind(done);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4769
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4770
  BLOCK_COMMENT("} Clear_Array");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4771
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4772
  int block_end = offset();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4773
  return block_end - block_start;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4774
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4775
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4776
// Compiler ensures base is doubleword aligned and cnt is count of doublewords.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4777
// Emitter does not KILL any arguments nor work registers.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4778
// Emitter generates up to 16 XC instructions, depending on the array length.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4779
unsigned int MacroAssembler::Clear_Array_Const(long cnt, Register base) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4780
  int  block_start    = offset();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4781
  int  off;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4782
  int  lineSize_Bytes = AllocatePrefetchStepSize;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4783
  int  lineSize_DW    = AllocatePrefetchStepSize>>LogBytesPerWord;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4784
  bool doPrefetch     = VM_Version::has_Prefetch();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4785
  int  XC_maxlen      = 256;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4786
  int  numXCInstr     = cnt > 0 ? (cnt*BytesPerWord-1)/XC_maxlen+1 : 0;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4787
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4788
  BLOCK_COMMENT("Clear_Array_Const {");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4789
  assert(cnt*BytesPerWord <= 4096, "ClearArrayConst can handle 4k only");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4790
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4791
  // Do less prefetching for very short arrays.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4792
  if (numXCInstr > 0) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4793
    // Prefetch only some cache lines, then begin clearing.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4794
    if (doPrefetch) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4795
      if (cnt*BytesPerWord <= lineSize_Bytes/4) {  // If less than 1/4 of a cache line to clear,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4796
        z_pfd(0x02, 0, Z_R0, base);                // prefetch just the first cache line.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4797
      } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4798
        assert(XC_maxlen == lineSize_Bytes, "ClearArrayConst needs 256B cache lines");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4799
        for (off = 0; (off < AllocatePrefetchLines) && (off <= numXCInstr); off ++) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4800
          z_pfd(0x02, off*lineSize_Bytes, Z_R0, base);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4801
        }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4802
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4803
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4804
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4805
    for (off=0; off<(numXCInstr-1); off++) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4806
      z_xc(off*XC_maxlen, XC_maxlen-1, base, off*XC_maxlen, base);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4807
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4808
      // Prefetch some cache lines in advance.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4809
      if (doPrefetch && (off <= numXCInstr-AllocatePrefetchLines)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4810
        z_pfd(0x02, (off+AllocatePrefetchLines)*lineSize_Bytes, Z_R0, base);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4811
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4812
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4813
    if (off*XC_maxlen < cnt*BytesPerWord) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4814
      z_xc(off*XC_maxlen, (cnt*BytesPerWord-off*XC_maxlen)-1, base, off*XC_maxlen, base);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4815
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4816
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4817
  BLOCK_COMMENT("} Clear_Array_Const");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4818
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4819
  int block_end = offset();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4820
  return block_end - block_start;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4821
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4822
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4823
// Compiler ensures base is doubleword aligned and cnt is #doublewords.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4824
// Emitter does not KILL cnt and base arguments, since they need to be copied to
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4825
// work registers anyway.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4826
// Actually, only r0, r1, r4, and r5 (which are work registers) are killed.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4827
//
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4828
// For very large arrays, exploit MVCLE H/W support.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4829
// MVCLE instruction automatically exploits H/W-optimized page mover.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4830
// - Bytes up to next page boundary are cleared with a series of XC to self.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4831
// - All full pages are cleared with the page mover H/W assist.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4832
// - Remaining bytes are again cleared by a series of XC to self.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4833
//
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4834
unsigned int MacroAssembler::Clear_Array_Const_Big(long cnt, Register base_pointer_arg, Register src_addr, Register src_len) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4835
  // Src_addr is evenReg.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4836
  // Src_len is odd_Reg.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4837
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4838
  int      block_start = offset();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4839
  Register dst_len  = Z_R1;      // Holds dst len  for MVCLE.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4840
  Register dst_addr = Z_R0;      // Holds dst addr for MVCLE.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4841
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4842
  BLOCK_COMMENT("Clear_Array_Const_Big {");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4843
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4844
  // Get len to clear.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4845
  load_const_optimized(dst_len, (long)cnt*8L);  // in Bytes = #DW*8
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4846
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4847
  // Prepare other args to MVCLE.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4848
  z_lgr(dst_addr, base_pointer_arg);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4849
  // Indicate unused result.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4850
  (void) clear_reg(src_len, true, false);  // Src len of MVCLE is zero.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4851
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4852
  // Clear.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4853
  MacroAssembler::move_long_ext(dst_addr, src_addr, 0);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4854
  BLOCK_COMMENT("} Clear_Array_Const_Big");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4855
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4856
  int block_end = offset();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4857
  return block_end - block_start;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4858
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4859
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4860
// Allocator.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4861
unsigned int MacroAssembler::CopyRawMemory_AlignedDisjoint(Register src_reg, Register dst_reg,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4862
                                                           Register cnt_reg,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4863
                                                           Register tmp1_reg, Register tmp2_reg) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4864
  // Tmp1 is oddReg.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4865
  // Tmp2 is evenReg.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4866
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4867
  int block_start = offset();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4868
  Label doMVC, doMVCLE, done, MVC_template;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4869
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4870
  BLOCK_COMMENT("CopyRawMemory_AlignedDisjoint {");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4871
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4872
  // Check for zero len and convert to long.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4873
  z_ltgfr(cnt_reg, cnt_reg);      // Remember casted value for doSTG case.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4874
  z_bre(done);                    // Nothing to do if len == 0.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4875
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4876
  z_sllg(Z_R1, cnt_reg, 3);       // Dst len in bytes. calc early to have the result ready.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4877
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4878
  z_cghi(cnt_reg, 32);            // Check for len <= 256 bytes (<=32 DW).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4879
  z_brnh(doMVC);                  // If so, use executed MVC to clear.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4880
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4881
  bind(doMVCLE);                  // A lot of data (more than 256 bytes).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4882
  // Prep dest reg pair.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4883
  z_lgr(Z_R0, dst_reg);           // dst addr
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4884
  // Dst len already in Z_R1.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4885
  // Prep src reg pair.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4886
  z_lgr(tmp2_reg, src_reg);       // src addr
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4887
  z_lgr(tmp1_reg, Z_R1);          // Src len same as dst len.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4888
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4889
  // Do the copy.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4890
  move_long_ext(Z_R0, tmp2_reg, 0xb0); // Bypass cache.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4891
  z_bru(done);                         // All done.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4892
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4893
  bind(MVC_template);             // Just some data (not more than 256 bytes).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4894
  z_mvc(0, 0, dst_reg, 0, src_reg);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4895
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4896
  bind(doMVC);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4897
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4898
  if (VM_Version::has_ExecuteExtensions()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4899
    add2reg(Z_R1, -1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4900
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4901
    add2reg(tmp1_reg, -1, Z_R1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4902
    z_larl(Z_R1, MVC_template);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4903
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4904
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4905
  if (VM_Version::has_Prefetch()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4906
    z_pfd(1,  0,Z_R0,src_reg);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4907
    z_pfd(2,  0,Z_R0,dst_reg);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4908
    //    z_pfd(1,256,Z_R0,src_reg);    // Assume very short copy.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4909
    //    z_pfd(2,256,Z_R0,dst_reg);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4910
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4911
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4912
  if (VM_Version::has_ExecuteExtensions()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4913
    z_exrl(Z_R1, MVC_template);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4914
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4915
    z_ex(tmp1_reg, 0, Z_R0, Z_R1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4916
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4917
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4918
  bind(done);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4919
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4920
  BLOCK_COMMENT("} CopyRawMemory_AlignedDisjoint");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4921
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4922
  int block_end = offset();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4923
  return block_end - block_start;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4924
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4925
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4926
//------------------------------------------------------
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4927
//   Special String Intrinsics. Implementation
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4928
//------------------------------------------------------
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4929
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4930
// Intrinsics for CompactStrings
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4931
48094
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  4932
// Compress char[] to byte[].
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  4933
//   Restores: src, dst
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  4934
//   Uses:     cnt
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  4935
//   Kills:    tmp, Z_R0, Z_R1.
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  4936
//   Early clobber: result.
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  4937
// Note:
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  4938
//   cnt is signed int. Do not rely on high word!
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  4939
//       counts # characters, not bytes.
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4940
// The result is the number of characters copied before the first incompatible character was found.
48094
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  4941
// If precise is true, the processing stops exactly at this point. Otherwise, the result may be off
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  4942
// by a few bytes. The result always indicates the number of copied characters.
48331
a8e39cc7b88f 8193443: [s390]: EncodeISOArray generates wrong vector code
lucy
parents: 48186
diff changeset
  4943
// When used as a character index, the returned value points to the first incompatible character.
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4944
//
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4945
// Note: Does not behave exactly like package private StringUTF16 compress java implementation in case of failure:
48094
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  4946
// - Different number of characters may have been written to dead array (if precise is false).
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4947
// - Returns a number <cnt instead of 0. (Result gets compared with cnt.)
48094
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  4948
unsigned int MacroAssembler::string_compress(Register result, Register src, Register dst, Register cnt,
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  4949
                                             Register tmp,    bool precise) {
48331
a8e39cc7b88f 8193443: [s390]: EncodeISOArray generates wrong vector code
lucy
parents: 48186
diff changeset
  4950
  assert_different_registers(Z_R0, Z_R1, result, src, dst, cnt, tmp);
48094
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  4951
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  4952
  if (precise) {
48094
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  4953
    BLOCK_COMMENT("encode_iso_array {");
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  4954
  } else {
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  4955
    BLOCK_COMMENT("string_compress {");
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  4956
  }
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  4957
  int  block_start = offset();
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  4958
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  4959
  Register       Rsrc  = src;
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  4960
  Register       Rdst  = dst;
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  4961
  Register       Rix   = tmp;
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  4962
  Register       Rcnt  = cnt;
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  4963
  Register       Rmask = result;  // holds incompatibility check mask until result value is stored.
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  4964
  Label          ScalarShortcut, AllDone;
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  4965
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  4966
  z_iilf(Rmask, 0xFF00FF00);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  4967
  z_iihf(Rmask, 0xFF00FF00);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  4968
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  4969
#if 0  // Sacrifice shortcuts for code compactness
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  4970
  {
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  4971
    //---<  shortcuts for short strings (very frequent)   >---
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  4972
    //   Strings with 4 and 8 characters were fond to occur very frequently.
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  4973
    //   Therefore, we handle them right away with minimal overhead.
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  4974
    Label     skipShortcut, skip4Shortcut, skip8Shortcut;
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  4975
    Register  Rout = Z_R0;
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  4976
    z_chi(Rcnt, 4);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  4977
    z_brne(skip4Shortcut);                 // 4 characters are very frequent
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  4978
      z_lg(Z_R0, 0, Rsrc);                 // Treat exactly 4 characters specially.
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  4979
      if (VM_Version::has_DistinctOpnds()) {
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  4980
        Rout = Z_R0;
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  4981
        z_ngrk(Rix, Z_R0, Rmask);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  4982
      } else {
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  4983
        Rout = Rix;
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  4984
        z_lgr(Rix, Z_R0);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  4985
        z_ngr(Z_R0, Rmask);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  4986
      }
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  4987
      z_brnz(skipShortcut);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  4988
      z_stcmh(Rout, 5, 0, Rdst);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  4989
      z_stcm(Rout,  5, 2, Rdst);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  4990
      z_lgfr(result, Rcnt);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  4991
      z_bru(AllDone);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  4992
    bind(skip4Shortcut);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  4993
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  4994
    z_chi(Rcnt, 8);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  4995
    z_brne(skip8Shortcut);                 // There's more to do...
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  4996
      z_lmg(Z_R0, Z_R1, 0, Rsrc);          // Treat exactly 8 characters specially.
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  4997
      if (VM_Version::has_DistinctOpnds()) {
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  4998
        Rout = Z_R0;
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  4999
        z_ogrk(Rix, Z_R0, Z_R1);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5000
        z_ngr(Rix, Rmask);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5001
      } else {
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5002
        Rout = Rix;
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5003
        z_lgr(Rix, Z_R0);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5004
        z_ogr(Z_R0, Z_R1);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5005
        z_ngr(Z_R0, Rmask);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5006
      }
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5007
      z_brnz(skipShortcut);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5008
      z_stcmh(Rout, 5, 0, Rdst);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5009
      z_stcm(Rout,  5, 2, Rdst);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5010
      z_stcmh(Z_R1, 5, 4, Rdst);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5011
      z_stcm(Z_R1,  5, 6, Rdst);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5012
      z_lgfr(result, Rcnt);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5013
      z_bru(AllDone);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5014
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5015
    bind(skip8Shortcut);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5016
    clear_reg(Z_R0, true, false);          // #characters already processed (none). Precond for scalar loop.
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5017
    z_brl(ScalarShortcut);                 // Just a few characters
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5018
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5019
    bind(skipShortcut);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5020
  }
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5021
#endif
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5022
  clear_reg(Z_R0);                         // make sure register is properly initialized.
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5023
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5024
  if (VM_Version::has_VectorFacility()) {
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5025
    const int  min_vcnt     = 32;          // Minimum #characters required to use vector instructions.
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5026
                                           // Otherwise just do nothing in vector mode.
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5027
                                           // Must be multiple of 2*(vector register length in chars (8 HW = 128 bits)).
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5028
    const int  log_min_vcnt = exact_log2(min_vcnt);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5029
    Label      VectorLoop, VectorDone, VectorBreak;
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5030
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5031
    VectorRegister Vtmp1      = Z_V16;
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5032
    VectorRegister Vtmp2      = Z_V17;
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5033
    VectorRegister Vmask      = Z_V18;
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5034
    VectorRegister Vzero      = Z_V19;
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5035
    VectorRegister Vsrc_first = Z_V20;
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5036
    VectorRegister Vsrc_last  = Z_V23;
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5037
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5038
    assert((Vsrc_last->encoding() - Vsrc_first->encoding() + 1) == min_vcnt/8, "logic error");
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5039
    assert(VM_Version::has_DistinctOpnds(), "Assumption when has_VectorFacility()");
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5040
    z_srak(Rix, Rcnt, log_min_vcnt);       // # vector loop iterations
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5041
    z_brz(VectorDone);                     // not enough data for vector loop
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5042
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5043
    z_vzero(Vzero);                        // all zeroes
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5044
    z_vgmh(Vmask, 0, 7);                   // generate 0xff00 mask for all 2-byte elements
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5045
    z_sllg(Z_R0, Rix, log_min_vcnt);       // remember #chars that will be processed by vector loop
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5046
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5047
    bind(VectorLoop);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5048
      z_vlm(Vsrc_first, Vsrc_last, 0, Rsrc);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5049
      add2reg(Rsrc, min_vcnt*2);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5050
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5051
      //---<  check for incompatible character  >---
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5052
      z_vo(Vtmp1, Z_V20, Z_V21);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5053
      z_vo(Vtmp2, Z_V22, Z_V23);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5054
      z_vo(Vtmp1, Vtmp1, Vtmp2);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5055
      z_vn(Vtmp1, Vtmp1, Vmask);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5056
      z_vceqhs(Vtmp1, Vtmp1, Vzero);       // high half of all chars must be zero for successful compress.
48331
a8e39cc7b88f 8193443: [s390]: EncodeISOArray generates wrong vector code
lucy
parents: 48186
diff changeset
  5057
      z_bvnt(VectorBreak);                 // break vector loop if not all vector elements compare eq -> incompatible character found.
48094
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5058
                                           // re-process data from current iteration in break handler.
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5059
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5060
      //---<  pack & store characters  >---
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5061
      z_vpkh(Vtmp1, Z_V20, Z_V21);         // pack (src1, src2) -> tmp1
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5062
      z_vpkh(Vtmp2, Z_V22, Z_V23);         // pack (src3, src4) -> tmp2
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5063
      z_vstm(Vtmp1, Vtmp2, 0, Rdst);       // store packed string
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5064
      add2reg(Rdst, min_vcnt);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5065
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5066
      z_brct(Rix, VectorLoop);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5067
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5068
    z_bru(VectorDone);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5069
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5070
    bind(VectorBreak);
48186
c722887b75a2 8192818: [s390]: restoring register contents calculates wrong value
lucy
parents: 48094
diff changeset
  5071
      add2reg(Rsrc, -min_vcnt*2);          // Fix Rsrc. Rsrc was already updated, but Rdst and Rix are not.
48094
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5072
      z_sll(Rix, log_min_vcnt);            // # chars processed so far in VectorLoop, excl. current iteration.
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5073
      z_sr(Z_R0, Rix);                     // correct # chars processed in total.
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5074
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5075
    bind(VectorDone);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5076
  }
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5077
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5078
  {
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5079
    const int  min_cnt     =  8;           // Minimum #characters required to use unrolled loop.
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5080
                                           // Otherwise just do nothing in unrolled loop.
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5081
                                           // Must be multiple of 8.
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5082
    const int  log_min_cnt = exact_log2(min_cnt);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5083
    Label      UnrolledLoop, UnrolledDone, UnrolledBreak;
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5084
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5085
    if (VM_Version::has_DistinctOpnds()) {
48094
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5086
      z_srk(Rix, Rcnt, Z_R0);              // remaining # chars to compress in unrolled loop
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5087
    } else {
48094
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5088
      z_lr(Rix, Rcnt);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5089
      z_sr(Rix, Z_R0);
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5090
    }
48094
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5091
    z_sra(Rix, log_min_cnt);             // unrolled loop count
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5092
    z_brz(UnrolledDone);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5093
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5094
    bind(UnrolledLoop);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5095
      z_lmg(Z_R0, Z_R1, 0, Rsrc);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5096
      if (precise) {
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5097
        z_ogr(Z_R1, Z_R0);                 // check all 8 chars for incompatibility
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5098
        z_ngr(Z_R1, Rmask);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5099
        z_brnz(UnrolledBreak);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5100
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5101
        z_lg(Z_R1, 8, Rsrc);               // reload destroyed register
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5102
        z_stcmh(Z_R0, 5, 0, Rdst);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5103
        z_stcm(Z_R0,  5, 2, Rdst);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5104
      } else {
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5105
        z_stcmh(Z_R0, 5, 0, Rdst);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5106
        z_stcm(Z_R0,  5, 2, Rdst);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5107
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5108
        z_ogr(Z_R0, Z_R1);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5109
        z_ngr(Z_R0, Rmask);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5110
        z_brnz(UnrolledBreak);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5111
      }
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5112
      z_stcmh(Z_R1, 5, 4, Rdst);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5113
      z_stcm(Z_R1,  5, 6, Rdst);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5114
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5115
      add2reg(Rsrc, min_cnt*2);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5116
      add2reg(Rdst, min_cnt);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5117
      z_brct(Rix, UnrolledLoop);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5118
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5119
    z_lgfr(Z_R0, Rcnt);                    // # chars processed in total after unrolled loop.
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5120
    z_nilf(Z_R0, ~(min_cnt-1));
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5121
    z_tmll(Rcnt, min_cnt-1);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5122
    z_brnaz(ScalarShortcut);               // if all bits zero, there is nothing left to do for scalar loop.
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5123
                                           // Rix == 0 in all cases.
48331
a8e39cc7b88f 8193443: [s390]: EncodeISOArray generates wrong vector code
lucy
parents: 48186
diff changeset
  5124
    z_sllg(Z_R1, Rcnt, 1);                 // # src bytes already processed. Only lower 32 bits are valid!
a8e39cc7b88f 8193443: [s390]: EncodeISOArray generates wrong vector code
lucy
parents: 48186
diff changeset
  5125
                                           //   Z_R1 contents must be treated as unsigned operand! For huge strings,
a8e39cc7b88f 8193443: [s390]: EncodeISOArray generates wrong vector code
lucy
parents: 48186
diff changeset
  5126
                                           //   (Rcnt >= 2**30), the value may spill into the sign bit by sllg.
48094
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5127
    z_lgfr(result, Rcnt);                  // all characters processed.
48331
a8e39cc7b88f 8193443: [s390]: EncodeISOArray generates wrong vector code
lucy
parents: 48186
diff changeset
  5128
    z_slgfr(Rdst, Rcnt);                   // restore ptr
a8e39cc7b88f 8193443: [s390]: EncodeISOArray generates wrong vector code
lucy
parents: 48186
diff changeset
  5129
    z_slgfr(Rsrc, Z_R1);                   // restore ptr, double the element count for Rsrc restore
48094
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5130
    z_bru(AllDone);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5131
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5132
    bind(UnrolledBreak);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5133
    z_lgfr(Z_R0, Rcnt);                    // # chars processed in total after unrolled loop
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5134
    z_nilf(Z_R0, ~(min_cnt-1));
48331
a8e39cc7b88f 8193443: [s390]: EncodeISOArray generates wrong vector code
lucy
parents: 48186
diff changeset
  5135
    z_sll(Rix, log_min_cnt);               // # chars not yet processed in UnrolledLoop (due to break), broken iteration not included.
a8e39cc7b88f 8193443: [s390]: EncodeISOArray generates wrong vector code
lucy
parents: 48186
diff changeset
  5136
    z_sr(Z_R0, Rix);                       // fix # chars processed OK so far.
48094
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5137
    if (!precise) {
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5138
      z_lgfr(result, Z_R0);
48331
a8e39cc7b88f 8193443: [s390]: EncodeISOArray generates wrong vector code
lucy
parents: 48186
diff changeset
  5139
      z_sllg(Z_R1, Z_R0, 1);               // # src bytes already processed. Only lower 32 bits are valid!
a8e39cc7b88f 8193443: [s390]: EncodeISOArray generates wrong vector code
lucy
parents: 48186
diff changeset
  5140
                                           //   Z_R1 contents must be treated as unsigned operand! For huge strings,
a8e39cc7b88f 8193443: [s390]: EncodeISOArray generates wrong vector code
lucy
parents: 48186
diff changeset
  5141
                                           //   (Rcnt >= 2**30), the value may spill into the sign bit by sllg.
48094
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5142
      z_aghi(result, min_cnt/2);           // min_cnt/2 characters have already been written
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5143
                                           // but ptrs were not updated yet.
48331
a8e39cc7b88f 8193443: [s390]: EncodeISOArray generates wrong vector code
lucy
parents: 48186
diff changeset
  5144
      z_slgfr(Rdst, Z_R0);                 // restore ptr
a8e39cc7b88f 8193443: [s390]: EncodeISOArray generates wrong vector code
lucy
parents: 48186
diff changeset
  5145
      z_slgfr(Rsrc, Z_R1);                 // restore ptr, double the element count for Rsrc restore
48094
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5146
      z_bru(AllDone);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5147
    }
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5148
    bind(UnrolledDone);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5149
  }
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5150
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5151
  {
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5152
    Label     ScalarLoop, ScalarDone, ScalarBreak;
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5153
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5154
    bind(ScalarShortcut);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5155
    z_ltgfr(result, Rcnt);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5156
    z_brz(AllDone);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5157
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5158
#if 0  // Sacrifice shortcuts for code compactness
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5159
    {
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5160
      //---<  Special treatment for very short strings (one or two characters)  >---
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5161
      //   For these strings, we are sure that the above code was skipped.
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5162
      //   Thus, no registers were modified, register restore is not required.
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5163
      Label     ScalarDoit, Scalar2Char;
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5164
      z_chi(Rcnt, 2);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5165
      z_brh(ScalarDoit);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5166
      z_llh(Z_R1,  0, Z_R0, Rsrc);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5167
      z_bre(Scalar2Char);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5168
      z_tmll(Z_R1, 0xff00);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5169
      z_lghi(result, 0);                   // cnt == 1, first char invalid, no chars successfully processed
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5170
      z_brnaz(AllDone);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5171
      z_stc(Z_R1,  0, Z_R0, Rdst);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5172
      z_lghi(result, 1);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5173
      z_bru(AllDone);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5174
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5175
      bind(Scalar2Char);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5176
      z_llh(Z_R0,  2, Z_R0, Rsrc);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5177
      z_tmll(Z_R1, 0xff00);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5178
      z_lghi(result, 0);                   // cnt == 2, first char invalid, no chars successfully processed
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5179
      z_brnaz(AllDone);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5180
      z_stc(Z_R1,  0, Z_R0, Rdst);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5181
      z_tmll(Z_R0, 0xff00);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5182
      z_lghi(result, 1);                   // cnt == 2, second char invalid, one char successfully processed
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5183
      z_brnaz(AllDone);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5184
      z_stc(Z_R0,  1, Z_R0, Rdst);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5185
      z_lghi(result, 2);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5186
      z_bru(AllDone);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5187
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5188
      bind(ScalarDoit);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5189
    }
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5190
#endif
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5191
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5192
    if (VM_Version::has_DistinctOpnds()) {
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5193
      z_srk(Rix, Rcnt, Z_R0);              // remaining # chars to compress in unrolled loop
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5194
    } else {
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5195
      z_lr(Rix, Rcnt);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5196
      z_sr(Rix, Z_R0);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5197
    }
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5198
    z_lgfr(result, Rcnt);                  // # processed characters (if all runs ok).
48331
a8e39cc7b88f 8193443: [s390]: EncodeISOArray generates wrong vector code
lucy
parents: 48186
diff changeset
  5199
    z_brz(ScalarDone);                     // uses CC from Rix calculation
48094
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5200
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5201
    bind(ScalarLoop);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5202
      z_llh(Z_R1, 0, Z_R0, Rsrc);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5203
      z_tmll(Z_R1, 0xff00);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5204
      z_brnaz(ScalarBreak);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5205
      z_stc(Z_R1, 0, Z_R0, Rdst);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5206
      add2reg(Rsrc, 2);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5207
      add2reg(Rdst, 1);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5208
      z_brct(Rix, ScalarLoop);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5209
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5210
    z_bru(ScalarDone);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5211
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5212
    bind(ScalarBreak);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5213
    z_sr(result, Rix);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5214
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5215
    bind(ScalarDone);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5216
    z_sgfr(Rdst, result);                  // restore ptr
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5217
    z_sgfr(Rsrc, result);                  // restore ptr, double the element count for Rsrc restore
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5218
    z_sgfr(Rsrc, result);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5219
  }
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5220
  bind(AllDone);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5221
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5222
  if (precise) {
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5223
    BLOCK_COMMENT("} encode_iso_array");
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5224
  } else {
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5225
    BLOCK_COMMENT("} string_compress");
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5226
  }
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5227
  return offset() - block_start;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5228
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5229
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5230
// Inflate byte[] to char[].
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5231
unsigned int MacroAssembler::string_inflate_trot(Register src, Register dst, Register cnt, Register tmp) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5232
  int block_start = offset();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5233
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5234
  BLOCK_COMMENT("string_inflate {");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5235
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5236
  Register stop_char = Z_R0;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5237
  Register table     = Z_R1;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5238
  Register src_addr  = tmp;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5239
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5240
  assert_different_registers(Z_R0, Z_R1, tmp, src, dst, cnt);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5241
  assert(dst->encoding()%2 == 0, "must be even reg");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5242
  assert(cnt->encoding()%2 == 1, "must be odd reg");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5243
  assert(cnt->encoding() - dst->encoding() == 1, "must be even/odd pair");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5244
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5245
  StubRoutines::zarch::generate_load_trot_table_addr(this, table);  // kills Z_R0 (if ASSERT)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5246
  clear_reg(stop_char);  // Stop character. Not used here, but initialized to have a defined value.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5247
  lgr_if_needed(src_addr, src);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5248
  z_llgfr(cnt, cnt);     // # src characters, must be a positive simm32.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5249
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5250
  translate_ot(dst, src_addr, /* mask = */ 0x0001);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5251
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5252
  BLOCK_COMMENT("} string_inflate");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5253
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5254
  return offset() - block_start;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5255
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5256
48094
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5257
// Inflate byte[] to char[].
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5258
//   Restores: src, dst
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5259
//   Uses:     cnt
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5260
//   Kills:    tmp, Z_R0, Z_R1.
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5261
// Note:
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5262
//   cnt is signed int. Do not rely on high word!
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5263
//       counts # characters, not bytes.
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5264
unsigned int MacroAssembler::string_inflate(Register src, Register dst, Register cnt, Register tmp) {
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5265
  assert_different_registers(Z_R0, Z_R1, src, dst, cnt, tmp);
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5266
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5267
  BLOCK_COMMENT("string_inflate {");
48094
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5268
  int block_start = offset();
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5269
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5270
  Register   Rcnt = cnt;   // # characters (src: bytes, dst: char (2-byte)), remaining after current loop.
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5271
  Register   Rix  = tmp;   // loop index
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5272
  Register   Rsrc = src;   // addr(src array)
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5273
  Register   Rdst = dst;   // addr(dst array)
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5274
  Label      ScalarShortcut, AllDone;
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5275
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5276
#if 0  // Sacrifice shortcuts for code compactness
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5277
  {
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5278
    //---<  shortcuts for short strings (very frequent)   >---
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5279
    Label   skipShortcut, skip4Shortcut;
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5280
    z_ltr(Rcnt, Rcnt);                     // absolutely nothing to do for strings of len == 0.
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5281
    z_brz(AllDone);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5282
    clear_reg(Z_R0);                       // make sure registers are properly initialized.
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5283
    clear_reg(Z_R1);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5284
    z_chi(Rcnt, 4);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5285
    z_brne(skip4Shortcut);                 // 4 characters are very frequent
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5286
      z_icm(Z_R0, 5,    0, Rsrc);          // Treat exactly 4 characters specially.
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5287
      z_icm(Z_R1, 5,    2, Rsrc);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5288
      z_stm(Z_R0, Z_R1, 0, Rdst);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5289
      z_bru(AllDone);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5290
    bind(skip4Shortcut);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5291
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5292
    z_chi(Rcnt, 8);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5293
    z_brh(skipShortcut);                   // There's a lot to do...
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5294
    z_lgfr(Z_R0, Rcnt);                    // remaining #characters (<= 8). Precond for scalar loop.
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5295
                                           // This does not destroy the "register cleared" state of Z_R0.
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5296
    z_brl(ScalarShortcut);                 // Just a few characters
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5297
      z_icmh(Z_R0, 5, 0, Rsrc);            // Treat exactly 8 characters specially.
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5298
      z_icmh(Z_R1, 5, 4, Rsrc);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5299
      z_icm(Z_R0,  5, 2, Rsrc);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5300
      z_icm(Z_R1,  5, 6, Rsrc);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5301
      z_stmg(Z_R0, Z_R1, 0, Rdst);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5302
      z_bru(AllDone);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5303
    bind(skipShortcut);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5304
  }
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5305
#endif
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5306
  clear_reg(Z_R0);                         // make sure register is properly initialized.
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5307
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5308
  if (VM_Version::has_VectorFacility()) {
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5309
    const int  min_vcnt     = 32;          // Minimum #characters required to use vector instructions.
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5310
                                           // Otherwise just do nothing in vector mode.
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5311
                                           // Must be multiple of vector register length (16 bytes = 128 bits).
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5312
    const int  log_min_vcnt = exact_log2(min_vcnt);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5313
    Label      VectorLoop, VectorDone;
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5314
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5315
    assert(VM_Version::has_DistinctOpnds(), "Assumption when has_VectorFacility()");
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5316
    z_srak(Rix, Rcnt, log_min_vcnt);       // calculate # vector loop iterations
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5317
    z_brz(VectorDone);                     // skip if none
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5318
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5319
    z_sllg(Z_R0, Rix, log_min_vcnt);       // remember #chars that will be processed by vector loop
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5320
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5321
    bind(VectorLoop);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5322
      z_vlm(Z_V20, Z_V21, 0, Rsrc);        // get next 32 characters (single-byte)
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5323
      add2reg(Rsrc, min_vcnt);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5324
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5325
      z_vuplhb(Z_V22, Z_V20);              // V2 <- (expand) V0(high)
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5326
      z_vupllb(Z_V23, Z_V20);              // V3 <- (expand) V0(low)
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5327
      z_vuplhb(Z_V24, Z_V21);              // V4 <- (expand) V1(high)
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5328
      z_vupllb(Z_V25, Z_V21);              // V5 <- (expand) V1(low)
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5329
      z_vstm(Z_V22, Z_V25, 0, Rdst);       // store next 32 bytes
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5330
      add2reg(Rdst, min_vcnt*2);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5331
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5332
      z_brct(Rix, VectorLoop);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5333
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5334
    bind(VectorDone);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5335
  }
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5336
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5337
  const int  min_cnt     =  8;             // Minimum #characters required to use unrolled scalar loop.
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5338
                                           // Otherwise just do nothing in unrolled scalar mode.
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5339
                                           // Must be multiple of 8.
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5340
  {
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5341
    const int  log_min_cnt = exact_log2(min_cnt);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5342
    Label      UnrolledLoop, UnrolledDone;
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5343
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5344
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5345
    if (VM_Version::has_DistinctOpnds()) {
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5346
      z_srk(Rix, Rcnt, Z_R0);              // remaining # chars to process in unrolled loop
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5347
    } else {
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5348
      z_lr(Rix, Rcnt);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5349
      z_sr(Rix, Z_R0);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5350
    }
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5351
    z_sra(Rix, log_min_cnt);               // unrolled loop count
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5352
    z_brz(UnrolledDone);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5353
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5354
    clear_reg(Z_R0);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5355
    clear_reg(Z_R1);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5356
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5357
    bind(UnrolledLoop);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5358
      z_icmh(Z_R0, 5, 0, Rsrc);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5359
      z_icmh(Z_R1, 5, 4, Rsrc);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5360
      z_icm(Z_R0,  5, 2, Rsrc);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5361
      z_icm(Z_R1,  5, 6, Rsrc);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5362
      add2reg(Rsrc, min_cnt);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5363
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5364
      z_stmg(Z_R0, Z_R1, 0, Rdst);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5365
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5366
      add2reg(Rdst, min_cnt*2);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5367
      z_brct(Rix, UnrolledLoop);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5368
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5369
    bind(UnrolledDone);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5370
    z_lgfr(Z_R0, Rcnt);                    // # chars left over after unrolled loop.
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5371
    z_nilf(Z_R0, min_cnt-1);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5372
    z_brnz(ScalarShortcut);                // if zero, there is nothing left to do for scalar loop.
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5373
                                           // Rix == 0 in all cases.
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5374
    z_sgfr(Z_R0, Rcnt);                    // negative # characters the ptrs have been advanced previously.
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5375
    z_agr(Rdst, Z_R0);                     // restore ptr, double the element count for Rdst restore.
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5376
    z_agr(Rdst, Z_R0);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5377
    z_agr(Rsrc, Z_R0);                     // restore ptr.
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5378
    z_bru(AllDone);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5379
  }
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5380
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5381
  {
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5382
    bind(ScalarShortcut);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5383
    // Z_R0 must contain remaining # characters as 64-bit signed int here.
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5384
    //      register contents is preserved over scalar processing (for register fixup).
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5385
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5386
#if 0  // Sacrifice shortcuts for code compactness
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5387
    {
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5388
      Label      ScalarDefault;
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5389
      z_chi(Rcnt, 2);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5390
      z_brh(ScalarDefault);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5391
      z_llc(Z_R0,  0, Z_R0, Rsrc);     // 6 bytes
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5392
      z_sth(Z_R0,  0, Z_R0, Rdst);     // 4 bytes
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5393
      z_brl(AllDone);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5394
      z_llc(Z_R0,  1, Z_R0, Rsrc);     // 6 bytes
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5395
      z_sth(Z_R0,  2, Z_R0, Rdst);     // 4 bytes
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5396
      z_bru(AllDone);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5397
      bind(ScalarDefault);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5398
    }
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5399
#endif
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5400
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5401
    Label   CodeTable;
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5402
    // Some comments on Rix calculation:
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5403
    //  - Rcnt is small, therefore no bits shifted out of low word (sll(g) instructions).
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5404
    //  - high word of both Rix and Rcnt may contain garbage
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5405
    //  - the final lngfr takes care of that garbage, extending the sign to high word
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5406
    z_sllg(Rix, Z_R0, 2);                // calculate 10*Rix = (4*Rix + Rix)*2
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5407
    z_ar(Rix, Z_R0);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5408
    z_larl(Z_R1, CodeTable);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5409
    z_sll(Rix, 1);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5410
    z_lngfr(Rix, Rix);      // ix range: [0..7], after inversion & mult: [-(7*12)..(0*12)].
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5411
    z_bc(Assembler::bcondAlways, 0, Rix, Z_R1);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5412
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5413
    z_llc(Z_R1,  6, Z_R0, Rsrc);  // 6 bytes
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5414
    z_sth(Z_R1, 12, Z_R0, Rdst);  // 4 bytes
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5415
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5416
    z_llc(Z_R1,  5, Z_R0, Rsrc);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5417
    z_sth(Z_R1, 10, Z_R0, Rdst);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5418
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5419
    z_llc(Z_R1,  4, Z_R0, Rsrc);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5420
    z_sth(Z_R1,  8, Z_R0, Rdst);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5421
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5422
    z_llc(Z_R1,  3, Z_R0, Rsrc);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5423
    z_sth(Z_R1,  6, Z_R0, Rdst);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5424
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5425
    z_llc(Z_R1,  2, Z_R0, Rsrc);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5426
    z_sth(Z_R1,  4, Z_R0, Rdst);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5427
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5428
    z_llc(Z_R1,  1, Z_R0, Rsrc);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5429
    z_sth(Z_R1,  2, Z_R0, Rdst);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5430
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5431
    z_llc(Z_R1,  0, Z_R0, Rsrc);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5432
    z_sth(Z_R1,  0, Z_R0, Rdst);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5433
    bind(CodeTable);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5434
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5435
    z_chi(Rcnt, 8);                        // no fixup for small strings. Rdst, Rsrc were not modified.
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5436
    z_brl(AllDone);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5437
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5438
    z_sgfr(Z_R0, Rcnt);                    // # characters the ptrs have been advanced previously.
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5439
    z_agr(Rdst, Z_R0);                     // restore ptr, double the element count for Rdst restore.
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5440
    z_agr(Rdst, Z_R0);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5441
    z_agr(Rsrc, Z_R0);                     // restore ptr.
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5442
  }
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5443
  bind(AllDone);
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5444
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5445
  BLOCK_COMMENT("} string_inflate");
48094
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5446
  return offset() - block_start;
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5447
}
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5448
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5449
// Inflate byte[] to char[], length known at compile time.
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5450
//   Restores: src, dst
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5451
//   Kills:    tmp, Z_R0, Z_R1.
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5452
// Note:
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5453
//   len is signed int. Counts # characters, not bytes.
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5454
unsigned int MacroAssembler::string_inflate_const(Register src, Register dst, Register tmp, int len) {
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5455
  assert_different_registers(Z_R0, Z_R1, src, dst, tmp);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5456
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5457
  BLOCK_COMMENT("string_inflate_const {");
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5458
  int block_start = offset();
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5459
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5460
  Register   Rix  = tmp;   // loop index
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5461
  Register   Rsrc = src;   // addr(src array)
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5462
  Register   Rdst = dst;   // addr(dst array)
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5463
  Label      ScalarShortcut, AllDone;
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5464
  int        nprocessed = 0;
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5465
  int        src_off    = 0;  // compensate for saved (optimized away) ptr advancement.
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5466
  int        dst_off    = 0;  // compensate for saved (optimized away) ptr advancement.
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5467
  bool       restore_inputs = false;
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5468
  bool       workreg_clear  = false;
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5469
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5470
  if ((len >= 32) && VM_Version::has_VectorFacility()) {
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5471
    const int  min_vcnt     = 32;          // Minimum #characters required to use vector instructions.
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5472
                                           // Otherwise just do nothing in vector mode.
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5473
                                           // Must be multiple of vector register length (16 bytes = 128 bits).
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5474
    const int  log_min_vcnt = exact_log2(min_vcnt);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5475
    const int  iterations   = (len - nprocessed) >> log_min_vcnt;
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5476
    nprocessed             += iterations << log_min_vcnt;
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5477
    Label      VectorLoop;
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5478
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5479
    if (iterations == 1) {
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5480
      z_vlm(Z_V20, Z_V21, 0+src_off, Rsrc);  // get next 32 characters (single-byte)
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5481
      z_vuplhb(Z_V22, Z_V20);                // V2 <- (expand) V0(high)
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5482
      z_vupllb(Z_V23, Z_V20);                // V3 <- (expand) V0(low)
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5483
      z_vuplhb(Z_V24, Z_V21);                // V4 <- (expand) V1(high)
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5484
      z_vupllb(Z_V25, Z_V21);                // V5 <- (expand) V1(low)
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5485
      z_vstm(Z_V22, Z_V25, 0+dst_off, Rdst); // store next 32 bytes
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5486
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5487
      src_off += min_vcnt;
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5488
      dst_off += min_vcnt*2;
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5489
    } else {
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5490
      restore_inputs = true;
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5491
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5492
      z_lgfi(Rix, len>>log_min_vcnt);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5493
      bind(VectorLoop);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5494
        z_vlm(Z_V20, Z_V21, 0, Rsrc);        // get next 32 characters (single-byte)
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5495
        add2reg(Rsrc, min_vcnt);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5496
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5497
        z_vuplhb(Z_V22, Z_V20);              // V2 <- (expand) V0(high)
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5498
        z_vupllb(Z_V23, Z_V20);              // V3 <- (expand) V0(low)
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5499
        z_vuplhb(Z_V24, Z_V21);              // V4 <- (expand) V1(high)
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5500
        z_vupllb(Z_V25, Z_V21);              // V5 <- (expand) V1(low)
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5501
        z_vstm(Z_V22, Z_V25, 0, Rdst);       // store next 32 bytes
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5502
        add2reg(Rdst, min_vcnt*2);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5503
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5504
        z_brct(Rix, VectorLoop);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5505
    }
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5506
  }
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5507
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5508
  if (((len-nprocessed) >= 16) && VM_Version::has_VectorFacility()) {
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5509
    const int  min_vcnt     = 16;          // Minimum #characters required to use vector instructions.
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5510
                                           // Otherwise just do nothing in vector mode.
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5511
                                           // Must be multiple of vector register length (16 bytes = 128 bits).
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5512
    const int  log_min_vcnt = exact_log2(min_vcnt);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5513
    const int  iterations   = (len - nprocessed) >> log_min_vcnt;
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5514
    nprocessed             += iterations << log_min_vcnt;
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5515
    assert(iterations == 1, "must be!");
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5516
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5517
    z_vl(Z_V20, 0+src_off, Z_R0, Rsrc);    // get next 16 characters (single-byte)
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5518
    z_vuplhb(Z_V22, Z_V20);                // V2 <- (expand) V0(high)
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5519
    z_vupllb(Z_V23, Z_V20);                // V3 <- (expand) V0(low)
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5520
    z_vstm(Z_V22, Z_V23, 0+dst_off, Rdst); // store next 32 bytes
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5521
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5522
    src_off += min_vcnt;
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5523
    dst_off += min_vcnt*2;
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5524
  }
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5525
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5526
  if ((len-nprocessed) > 8) {
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5527
    const int  min_cnt     =  8;           // Minimum #characters required to use unrolled scalar loop.
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5528
                                           // Otherwise just do nothing in unrolled scalar mode.
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5529
                                           // Must be multiple of 8.
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5530
    const int  log_min_cnt = exact_log2(min_cnt);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5531
    const int  iterations  = (len - nprocessed) >> log_min_cnt;
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5532
    nprocessed     += iterations << log_min_cnt;
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5533
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5534
    //---<  avoid loop overhead/ptr increment for small # iterations  >---
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5535
    if (iterations <= 2) {
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5536
      clear_reg(Z_R0);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5537
      clear_reg(Z_R1);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5538
      workreg_clear = true;
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5539
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5540
      z_icmh(Z_R0, 5, 0+src_off, Rsrc);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5541
      z_icmh(Z_R1, 5, 4+src_off, Rsrc);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5542
      z_icm(Z_R0,  5, 2+src_off, Rsrc);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5543
      z_icm(Z_R1,  5, 6+src_off, Rsrc);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5544
      z_stmg(Z_R0, Z_R1, 0+dst_off, Rdst);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5545
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5546
      src_off += min_cnt;
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5547
      dst_off += min_cnt*2;
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5548
    }
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5549
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5550
    if (iterations == 2) {
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5551
      z_icmh(Z_R0, 5, 0+src_off, Rsrc);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5552
      z_icmh(Z_R1, 5, 4+src_off, Rsrc);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5553
      z_icm(Z_R0,  5, 2+src_off, Rsrc);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5554
      z_icm(Z_R1,  5, 6+src_off, Rsrc);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5555
      z_stmg(Z_R0, Z_R1, 0+dst_off, Rdst);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5556
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5557
      src_off += min_cnt;
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5558
      dst_off += min_cnt*2;
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5559
    }
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5560
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5561
    if (iterations > 2) {
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5562
      Label      UnrolledLoop;
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5563
      restore_inputs  = true;
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5564
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5565
      clear_reg(Z_R0);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5566
      clear_reg(Z_R1);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5567
      workreg_clear = true;
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5568
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5569
      z_lgfi(Rix, iterations);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5570
      bind(UnrolledLoop);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5571
        z_icmh(Z_R0, 5, 0, Rsrc);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5572
        z_icmh(Z_R1, 5, 4, Rsrc);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5573
        z_icm(Z_R0,  5, 2, Rsrc);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5574
        z_icm(Z_R1,  5, 6, Rsrc);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5575
        add2reg(Rsrc, min_cnt);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5576
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5577
        z_stmg(Z_R0, Z_R1, 0, Rdst);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5578
        add2reg(Rdst, min_cnt*2);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5579
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5580
        z_brct(Rix, UnrolledLoop);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5581
    }
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5582
  }
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5583
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5584
  if ((len-nprocessed) > 0) {
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5585
    switch (len-nprocessed) {
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5586
      case 8:
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5587
        if (!workreg_clear) {
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5588
          clear_reg(Z_R0);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5589
          clear_reg(Z_R1);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5590
        }
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5591
        z_icmh(Z_R0, 5, 0+src_off, Rsrc);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5592
        z_icmh(Z_R1, 5, 4+src_off, Rsrc);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5593
        z_icm(Z_R0,  5, 2+src_off, Rsrc);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5594
        z_icm(Z_R1,  5, 6+src_off, Rsrc);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5595
        z_stmg(Z_R0, Z_R1, 0+dst_off, Rdst);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5596
        break;
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5597
      case 7:
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5598
        if (!workreg_clear) {
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5599
          clear_reg(Z_R0);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5600
          clear_reg(Z_R1);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5601
        }
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5602
        clear_reg(Rix);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5603
        z_icm(Z_R0,  5, 0+src_off, Rsrc);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5604
        z_icm(Z_R1,  5, 2+src_off, Rsrc);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5605
        z_icm(Rix,   5, 4+src_off, Rsrc);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5606
        z_stm(Z_R0,  Z_R1, 0+dst_off, Rdst);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5607
        z_llc(Z_R0,  6+src_off, Z_R0, Rsrc);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5608
        z_st(Rix,    8+dst_off, Z_R0, Rdst);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5609
        z_sth(Z_R0, 12+dst_off, Z_R0, Rdst);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5610
        break;
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5611
      case 6:
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5612
        if (!workreg_clear) {
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5613
          clear_reg(Z_R0);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5614
          clear_reg(Z_R1);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5615
        }
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5616
        clear_reg(Rix);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5617
        z_icm(Z_R0, 5, 0+src_off, Rsrc);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5618
        z_icm(Z_R1, 5, 2+src_off, Rsrc);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5619
        z_icm(Rix,  5, 4+src_off, Rsrc);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5620
        z_stm(Z_R0, Z_R1, 0+dst_off, Rdst);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5621
        z_st(Rix,   8+dst_off, Z_R0, Rdst);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5622
        break;
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5623
      case 5:
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5624
        if (!workreg_clear) {
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5625
          clear_reg(Z_R0);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5626
          clear_reg(Z_R1);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5627
        }
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5628
        z_icm(Z_R0, 5, 0+src_off, Rsrc);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5629
        z_icm(Z_R1, 5, 2+src_off, Rsrc);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5630
        z_llc(Rix,  4+src_off, Z_R0, Rsrc);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5631
        z_stm(Z_R0, Z_R1, 0+dst_off, Rdst);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5632
        z_sth(Rix,  8+dst_off, Z_R0, Rdst);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5633
        break;
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5634
      case 4:
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5635
        if (!workreg_clear) {
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5636
          clear_reg(Z_R0);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5637
          clear_reg(Z_R1);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5638
        }
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5639
        z_icm(Z_R0, 5, 0+src_off, Rsrc);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5640
        z_icm(Z_R1, 5, 2+src_off, Rsrc);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5641
        z_stm(Z_R0, Z_R1, 0+dst_off, Rdst);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5642
        break;
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5643
      case 3:
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5644
        if (!workreg_clear) {
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5645
          clear_reg(Z_R0);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5646
        }
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5647
        z_llc(Z_R1, 2+src_off, Z_R0, Rsrc);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5648
        z_icm(Z_R0, 5, 0+src_off, Rsrc);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5649
        z_sth(Z_R1, 4+dst_off, Z_R0, Rdst);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5650
        z_st(Z_R0,  0+dst_off, Rdst);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5651
        break;
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5652
      case 2:
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5653
        z_llc(Z_R0, 0+src_off, Z_R0, Rsrc);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5654
        z_llc(Z_R1, 1+src_off, Z_R0, Rsrc);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5655
        z_sth(Z_R0, 0+dst_off, Z_R0, Rdst);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5656
        z_sth(Z_R1, 2+dst_off, Z_R0, Rdst);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5657
        break;
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5658
      case 1:
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5659
        z_llc(Z_R0, 0+src_off, Z_R0, Rsrc);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5660
        z_sth(Z_R0, 0+dst_off, Z_R0, Rdst);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5661
        break;
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5662
      default:
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5663
        guarantee(false, "Impossible");
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5664
        break;
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5665
    }
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5666
    src_off   +=  len-nprocessed;
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5667
    dst_off   += (len-nprocessed)*2;
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5668
    nprocessed = len;
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5669
  }
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5670
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5671
  //---< restore modified input registers  >---
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5672
  if ((nprocessed > 0) && restore_inputs) {
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5673
    z_agfi(Rsrc, -(nprocessed-src_off));
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5674
    if (nprocessed < 1000000000) { // avoid int overflow
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5675
      z_agfi(Rdst, -(nprocessed*2-dst_off));
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5676
    } else {
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5677
      z_agfi(Rdst, -(nprocessed-dst_off));
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5678
      z_agfi(Rdst, -nprocessed);
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5679
    }
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5680
  }
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5681
bca569f79fa1 8189793: [s390]: Improve String compress/inflate by exploiting vector instructions
lucy
parents: 47580
diff changeset
  5682
  BLOCK_COMMENT("} string_inflate_const");
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5683
  return offset() - block_start;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5684
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5685
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5686
// Kills src.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5687
unsigned int MacroAssembler::has_negatives(Register result, Register src, Register cnt,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5688
                                           Register odd_reg, Register even_reg, Register tmp) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5689
  int block_start = offset();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5690
  Label Lloop1, Lloop2, Lslow, Lnotfound, Ldone;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5691
  const Register addr = src, mask = tmp;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5692
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5693
  BLOCK_COMMENT("has_negatives {");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5694
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5695
  z_llgfr(Z_R1, cnt);      // Number of bytes to read. (Must be a positive simm32.)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5696
  z_llilf(mask, 0x80808080);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5697
  z_lhi(result, 1);        // Assume true.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5698
  // Last possible addr for fast loop.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5699
  z_lay(odd_reg, -16, Z_R1, src);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5700
  z_chi(cnt, 16);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5701
  z_brl(Lslow);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5702
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5703
  // ind1: index, even_reg: index increment, odd_reg: index limit
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5704
  z_iihf(mask, 0x80808080);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5705
  z_lghi(even_reg, 16);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5706
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5707
  bind(Lloop1); // 16 bytes per iteration.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5708
  z_lg(Z_R0, Address(addr));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5709
  z_lg(Z_R1, Address(addr, 8));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5710
  z_ogr(Z_R0, Z_R1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5711
  z_ngr(Z_R0, mask);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5712
  z_brne(Ldone);           // If found return 1.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5713
  z_brxlg(addr, even_reg, Lloop1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5714
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5715
  bind(Lslow);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5716
  z_aghi(odd_reg, 16-1);   // Last possible addr for slow loop.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5717
  z_lghi(even_reg, 1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5718
  z_cgr(addr, odd_reg);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5719
  z_brh(Lnotfound);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5720
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5721
  bind(Lloop2); // 1 byte per iteration.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5722
  z_cli(Address(addr), 0x80);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5723
  z_brnl(Ldone);           // If found return 1.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5724
  z_brxlg(addr, even_reg, Lloop2);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5725
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5726
  bind(Lnotfound);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5727
  z_lhi(result, 0);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5728
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5729
  bind(Ldone);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5730
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5731
  BLOCK_COMMENT("} has_negatives");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5732
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5733
  return offset() - block_start;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5734
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5735
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5736
// kill: cnt1, cnt2, odd_reg, even_reg; early clobber: result
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5737
unsigned int MacroAssembler::string_compare(Register str1, Register str2,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5738
                                            Register cnt1, Register cnt2,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5739
                                            Register odd_reg, Register even_reg, Register result, int ae) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5740
  int block_start = offset();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5741
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5742
  assert_different_registers(str1, cnt1, cnt2, odd_reg, even_reg, result);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5743
  assert_different_registers(str2, cnt1, cnt2, odd_reg, even_reg, result);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5744
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5745
  // If strings are equal up to min length, return the length difference.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5746
  const Register diff = result, // Pre-set result with length difference.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5747
                 min  = cnt1,   // min number of bytes
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5748
                 tmp  = cnt2;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5749
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5750
  // Note: Making use of the fact that compareTo(a, b) == -compareTo(b, a)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5751
  // we interchange str1 and str2 in the UL case and negate the result.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5752
  // Like this, str1 is always latin1 encoded, except for the UU case.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5753
  // In addition, we need 0 (or sign which is 0) extend when using 64 bit register.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5754
  const bool used_as_LU = (ae == StrIntrinsicNode::LU || ae == StrIntrinsicNode::UL);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5755
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5756
  BLOCK_COMMENT("string_compare {");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5757
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5758
  if (used_as_LU) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5759
    z_srl(cnt2, 1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5760
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5761
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5762
  // See if the lengths are different, and calculate min in cnt1.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5763
  // Save diff in case we need it for a tie-breaker.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5764
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5765
  // diff = cnt1 - cnt2
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5766
  if (VM_Version::has_DistinctOpnds()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5767
    z_srk(diff, cnt1, cnt2);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5768
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5769
    z_lr(diff, cnt1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5770
    z_sr(diff, cnt2);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5771
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5772
  if (str1 != str2) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5773
    if (VM_Version::has_LoadStoreConditional()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5774
      z_locr(min, cnt2, Assembler::bcondHigh);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5775
    } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5776
      Label Lskip;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5777
      z_brl(Lskip);    // min ok if cnt1 < cnt2
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5778
      z_lr(min, cnt2); // min = cnt2
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5779
      bind(Lskip);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5780
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5781
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5782
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5783
  if (ae == StrIntrinsicNode::UU) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5784
    z_sra(diff, 1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5785
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5786
  if (str1 != str2) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5787
    Label Ldone;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5788
    if (used_as_LU) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5789
      // Loop which searches the first difference character by character.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5790
      Label Lloop;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5791
      const Register ind1 = Z_R1,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5792
                     ind2 = min;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5793
      int stride1 = 1, stride2 = 2; // See comment above.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5794
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5795
      // ind1: index, even_reg: index increment, odd_reg: index limit
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5796
      z_llilf(ind1, (unsigned int)(-stride1));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5797
      z_lhi(even_reg, stride1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5798
      add2reg(odd_reg, -stride1, min);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5799
      clear_reg(ind2); // kills min
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5800
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5801
      bind(Lloop);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5802
      z_brxh(ind1, even_reg, Ldone);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5803
      z_llc(tmp, Address(str1, ind1));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5804
      z_llh(Z_R0, Address(str2, ind2));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5805
      z_ahi(ind2, stride2);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5806
      z_sr(tmp, Z_R0);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5807
      z_bre(Lloop);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5808
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5809
      z_lr(result, tmp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5810
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5811
    } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5812
      // Use clcle in fast loop (only for same encoding).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5813
      z_lgr(Z_R0, str1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5814
      z_lgr(even_reg, str2);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5815
      z_llgfr(Z_R1, min);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5816
      z_llgfr(odd_reg, min);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5817
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5818
      if (ae == StrIntrinsicNode::LL) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5819
        compare_long_ext(Z_R0, even_reg, 0);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5820
      } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5821
        compare_long_uni(Z_R0, even_reg, 0);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5822
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5823
      z_bre(Ldone);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5824
      z_lgr(Z_R1, Z_R0);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5825
      if (ae == StrIntrinsicNode::LL) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5826
        z_llc(Z_R0, Address(even_reg));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5827
        z_llc(result, Address(Z_R1));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5828
      } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5829
        z_llh(Z_R0, Address(even_reg));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5830
        z_llh(result, Address(Z_R1));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5831
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5832
      z_sr(result, Z_R0);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5833
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5834
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5835
    // Otherwise, return the difference between the first mismatched chars.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5836
    bind(Ldone);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5837
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5838
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5839
  if (ae == StrIntrinsicNode::UL) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5840
    z_lcr(result, result); // Negate result (see note above).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5841
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5842
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5843
  BLOCK_COMMENT("} string_compare");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5844
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5845
  return offset() - block_start;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5846
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5847
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5848
unsigned int MacroAssembler::array_equals(bool is_array_equ, Register ary1, Register ary2, Register limit,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5849
                                          Register odd_reg, Register even_reg, Register result, bool is_byte) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5850
  int block_start = offset();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5851
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5852
  BLOCK_COMMENT("array_equals {");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5853
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5854
  assert_different_registers(ary1, limit, odd_reg, even_reg);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5855
  assert_different_registers(ary2, limit, odd_reg, even_reg);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5856
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5857
  Label Ldone, Ldone_true, Ldone_false, Lclcle, CLC_template;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5858
  int base_offset = 0;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5859
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5860
  if (ary1 != ary2) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5861
    if (is_array_equ) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5862
      base_offset = arrayOopDesc::base_offset_in_bytes(is_byte ? T_BYTE : T_CHAR);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5863
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5864
      // Return true if the same array.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5865
      compareU64_and_branch(ary1, ary2, Assembler::bcondEqual, Ldone_true);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5866
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5867
      // Return false if one of them is NULL.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5868
      compareU64_and_branch(ary1, (intptr_t)0, Assembler::bcondEqual, Ldone_false);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5869
      compareU64_and_branch(ary2, (intptr_t)0, Assembler::bcondEqual, Ldone_false);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5870
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5871
      // Load the lengths of arrays.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5872
      z_llgf(odd_reg, Address(ary1, arrayOopDesc::length_offset_in_bytes()));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5873
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5874
      // Return false if the two arrays are not equal length.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5875
      z_c(odd_reg, Address(ary2, arrayOopDesc::length_offset_in_bytes()));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5876
      z_brne(Ldone_false);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5877
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5878
      // string len in bytes (right operand)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5879
      if (!is_byte) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5880
        z_chi(odd_reg, 128);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5881
        z_sll(odd_reg, 1); // preserves flags
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5882
        z_brh(Lclcle);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5883
      } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5884
        compareU32_and_branch(odd_reg, (intptr_t)256, Assembler::bcondHigh, Lclcle);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5885
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5886
    } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5887
      z_llgfr(odd_reg, limit); // Need to zero-extend prior to using the value.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5888
      compareU32_and_branch(limit, (intptr_t)256, Assembler::bcondHigh, Lclcle);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5889
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5890
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5891
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5892
    // Use clc instruction for up to 256 bytes.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5893
    {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5894
      Register str1_reg = ary1,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5895
          str2_reg = ary2;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5896
      if (is_array_equ) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5897
        str1_reg = Z_R1;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5898
        str2_reg = even_reg;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5899
        add2reg(str1_reg, base_offset, ary1); // string addr (left operand)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5900
        add2reg(str2_reg, base_offset, ary2); // string addr (right operand)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5901
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5902
      z_ahi(odd_reg, -1); // Clc uses decremented limit. Also compare result to 0.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5903
      z_brl(Ldone_true);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5904
      // Note: We could jump to the template if equal.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5905
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5906
      assert(VM_Version::has_ExecuteExtensions(), "unsupported hardware");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5907
      z_exrl(odd_reg, CLC_template);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5908
      z_bre(Ldone_true);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5909
      // fall through
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5910
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5911
      bind(Ldone_false);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5912
      clear_reg(result);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5913
      z_bru(Ldone);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5914
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5915
      bind(CLC_template);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5916
      z_clc(0, 0, str1_reg, 0, str2_reg);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5917
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5918
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5919
    // Use clcle instruction.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5920
    {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5921
      bind(Lclcle);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5922
      add2reg(even_reg, base_offset, ary2); // string addr (right operand)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5923
      add2reg(Z_R0, base_offset, ary1);     // string addr (left operand)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5924
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5925
      z_lgr(Z_R1, odd_reg); // string len in bytes (left operand)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5926
      if (is_byte) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5927
        compare_long_ext(Z_R0, even_reg, 0);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5928
      } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5929
        compare_long_uni(Z_R0, even_reg, 0);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5930
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5931
      z_lghi(result, 0); // Preserve flags.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5932
      z_brne(Ldone);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5933
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5934
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5935
  // fall through
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5936
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5937
  bind(Ldone_true);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5938
  z_lghi(result, 1); // All characters are equal.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5939
  bind(Ldone);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5940
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5941
  BLOCK_COMMENT("} array_equals");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5942
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5943
  return offset() - block_start;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5944
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5945
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5946
// kill: haycnt, needlecnt, odd_reg, even_reg; early clobber: result
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5947
unsigned int MacroAssembler::string_indexof(Register result, Register haystack, Register haycnt,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5948
                                            Register needle, Register needlecnt, int needlecntval,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5949
                                            Register odd_reg, Register even_reg, int ae) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5950
  int block_start = offset();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5951
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5952
  // Ensure 0<needlecnt<=haycnt in ideal graph as prerequisite!
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5953
  assert(ae != StrIntrinsicNode::LU, "Invalid encoding");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5954
  const int h_csize = (ae == StrIntrinsicNode::LL) ? 1 : 2;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5955
  const int n_csize = (ae == StrIntrinsicNode::UU) ? 2 : 1;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5956
  Label L_needle1, L_Found, L_NotFound;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5957
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5958
  BLOCK_COMMENT("string_indexof {");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5959
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5960
  if (needle == haystack) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5961
    z_lhi(result, 0);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5962
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5963
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5964
  // Load first character of needle (R0 used by search_string instructions).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5965
  if (n_csize == 2) { z_llgh(Z_R0, Address(needle)); } else { z_llgc(Z_R0, Address(needle)); }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5966
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5967
  // Compute last haystack addr to use if no match gets found.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5968
  if (needlecnt != noreg) { // variable needlecnt
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5969
    z_ahi(needlecnt, -1); // Remaining characters after first one.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5970
    z_sr(haycnt, needlecnt); // Compute index succeeding last element to compare.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5971
    if (n_csize == 2) { z_sll(needlecnt, 1); } // In bytes.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5972
  } else { // constant needlecnt
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5973
    assert((needlecntval & 0x7fff) == needlecntval, "must be positive simm16 immediate");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5974
    // Compute index succeeding last element to compare.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5975
    if (needlecntval != 1) { z_ahi(haycnt, 1 - needlecntval); }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5976
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5977
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5978
  z_llgfr(haycnt, haycnt); // Clear high half.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5979
  z_lgr(result, haystack); // Final result will be computed from needle start pointer.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5980
  if (h_csize == 2) { z_sll(haycnt, 1); } // Scale to number of bytes.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5981
  z_agr(haycnt, haystack); // Point to address succeeding last element (haystack+scale*(haycnt-needlecnt+1)).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5982
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5983
  if (h_csize != n_csize) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5984
    assert(ae == StrIntrinsicNode::UL, "Invalid encoding");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5985
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5986
    if (needlecnt != noreg || needlecntval != 1) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5987
      if (needlecnt != noreg) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5988
        compare32_and_branch(needlecnt, (intptr_t)0, Assembler::bcondEqual, L_needle1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5989
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5990
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5991
      // Main Loop: UL version (now we have at least 2 characters).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5992
      Label L_OuterLoop, L_InnerLoop, L_Skip;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5993
      bind(L_OuterLoop); // Search for 1st 2 characters.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5994
      z_lgr(Z_R1, haycnt);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5995
      MacroAssembler::search_string_uni(Z_R1, result);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5996
      z_brc(Assembler::bcondNotFound, L_NotFound);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5997
      z_lgr(result, Z_R1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5998
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  5999
      z_lghi(Z_R1, n_csize);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6000
      z_lghi(even_reg, h_csize);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6001
      bind(L_InnerLoop);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6002
      z_llgc(odd_reg, Address(needle, Z_R1));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6003
      z_ch(odd_reg, Address(result, even_reg));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6004
      z_brne(L_Skip);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6005
      if (needlecnt != noreg) { z_cr(Z_R1, needlecnt); } else { z_chi(Z_R1, needlecntval - 1); }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6006
      z_brnl(L_Found);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6007
      z_aghi(Z_R1, n_csize);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6008
      z_aghi(even_reg, h_csize);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6009
      z_bru(L_InnerLoop);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6010
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6011
      bind(L_Skip);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6012
      z_aghi(result, h_csize); // This is the new address we want to use for comparing.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6013
      z_bru(L_OuterLoop);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6014
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6015
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6016
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6017
    const intptr_t needle_bytes = (n_csize == 2) ? ((needlecntval - 1) << 1) : (needlecntval - 1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6018
    Label L_clcle;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6019
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6020
    if (needlecnt != noreg || (needlecntval != 1 && needle_bytes <= 256)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6021
      if (needlecnt != noreg) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6022
        compare32_and_branch(needlecnt, 256, Assembler::bcondHigh, L_clcle);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6023
        z_ahi(needlecnt, -1); // remaining bytes -1 (for CLC)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6024
        z_brl(L_needle1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6025
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6026
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6027
      // Main Loop: clc version (now we have at least 2 characters).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6028
      Label L_OuterLoop, CLC_template;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6029
      bind(L_OuterLoop); // Search for 1st 2 characters.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6030
      z_lgr(Z_R1, haycnt);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6031
      if (h_csize == 1) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6032
        MacroAssembler::search_string(Z_R1, result);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6033
      } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6034
        MacroAssembler::search_string_uni(Z_R1, result);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6035
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6036
      z_brc(Assembler::bcondNotFound, L_NotFound);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6037
      z_lgr(result, Z_R1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6038
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6039
      if (needlecnt != noreg) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6040
        assert(VM_Version::has_ExecuteExtensions(), "unsupported hardware");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6041
        z_exrl(needlecnt, CLC_template);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6042
      } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6043
        z_clc(h_csize, needle_bytes -1, Z_R1, n_csize, needle);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6044
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6045
      z_bre(L_Found);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6046
      z_aghi(result, h_csize); // This is the new address we want to use for comparing.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6047
      z_bru(L_OuterLoop);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6048
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6049
      if (needlecnt != noreg) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6050
        bind(CLC_template);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6051
        z_clc(h_csize, 0, Z_R1, n_csize, needle);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6052
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6053
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6054
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6055
    if (needlecnt != noreg || needle_bytes > 256) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6056
      bind(L_clcle);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6057
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6058
      // Main Loop: clcle version (now we have at least 256 bytes).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6059
      Label L_OuterLoop, CLC_template;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6060
      bind(L_OuterLoop); // Search for 1st 2 characters.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6061
      z_lgr(Z_R1, haycnt);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6062
      if (h_csize == 1) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6063
        MacroAssembler::search_string(Z_R1, result);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6064
      } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6065
        MacroAssembler::search_string_uni(Z_R1, result);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6066
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6067
      z_brc(Assembler::bcondNotFound, L_NotFound);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6068
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6069
      add2reg(Z_R0, n_csize, needle);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6070
      add2reg(even_reg, h_csize, Z_R1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6071
      z_lgr(result, Z_R1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6072
      if (needlecnt != noreg) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6073
        z_llgfr(Z_R1, needlecnt); // needle len in bytes (left operand)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6074
        z_llgfr(odd_reg, needlecnt);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6075
      } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6076
        load_const_optimized(Z_R1, needle_bytes);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6077
        if (Immediate::is_simm16(needle_bytes)) { z_lghi(odd_reg, needle_bytes); } else { z_lgr(odd_reg, Z_R1); }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6078
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6079
      if (h_csize == 1) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6080
        compare_long_ext(Z_R0, even_reg, 0);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6081
      } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6082
        compare_long_uni(Z_R0, even_reg, 0);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6083
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6084
      z_bre(L_Found);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6085
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6086
      if (n_csize == 2) { z_llgh(Z_R0, Address(needle)); } else { z_llgc(Z_R0, Address(needle)); } // Reload.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6087
      z_aghi(result, h_csize); // This is the new address we want to use for comparing.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6088
      z_bru(L_OuterLoop);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6089
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6090
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6091
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6092
  if (needlecnt != noreg || needlecntval == 1) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6093
    bind(L_needle1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6094
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6095
    // Single needle character version.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6096
    if (h_csize == 1) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6097
      MacroAssembler::search_string(haycnt, result);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6098
    } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6099
      MacroAssembler::search_string_uni(haycnt, result);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6100
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6101
    z_lgr(result, haycnt);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6102
    z_brc(Assembler::bcondFound, L_Found);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6103
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6104
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6105
  bind(L_NotFound);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6106
  add2reg(result, -1, haystack); // Return -1.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6107
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6108
  bind(L_Found); // Return index (or -1 in fallthrough case).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6109
  z_sgr(result, haystack);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6110
  if (h_csize == 2) { z_srag(result, result, exact_log2(sizeof(jchar))); }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6111
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6112
  BLOCK_COMMENT("} string_indexof");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6113
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6114
  return offset() - block_start;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6115
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6116
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6117
// early clobber: result
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6118
unsigned int MacroAssembler::string_indexof_char(Register result, Register haystack, Register haycnt,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6119
                                                 Register needle, jchar needleChar, Register odd_reg, Register even_reg, bool is_byte) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6120
  int block_start = offset();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6121
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6122
  BLOCK_COMMENT("string_indexof_char {");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6123
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6124
  if (needle == haystack) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6125
    z_lhi(result, 0);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6126
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6127
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6128
  Label Ldone;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6129
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6130
  z_llgfr(odd_reg, haycnt);  // Preset loop ctr/searchrange end.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6131
  if (needle == noreg) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6132
    load_const_optimized(Z_R0, (unsigned long)needleChar);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6133
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6134
    if (is_byte) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6135
      z_llgcr(Z_R0, needle); // First (and only) needle char.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6136
    } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6137
      z_llghr(Z_R0, needle); // First (and only) needle char.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6138
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6139
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6140
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6141
  if (!is_byte) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6142
    z_agr(odd_reg, odd_reg); // Calc #bytes to be processed with SRSTU.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6143
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6144
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6145
  z_lgr(even_reg, haystack); // haystack addr
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6146
  z_agr(odd_reg, haystack);  // First char after range end.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6147
  z_lghi(result, -1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6148
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6149
  if (is_byte) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6150
    MacroAssembler::search_string(odd_reg, even_reg);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6151
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6152
    MacroAssembler::search_string_uni(odd_reg, even_reg);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6153
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6154
  z_brc(Assembler::bcondNotFound, Ldone);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6155
  if (is_byte) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6156
    if (VM_Version::has_DistinctOpnds()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6157
      z_sgrk(result, odd_reg, haystack);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6158
    } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6159
      z_sgr(odd_reg, haystack);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6160
      z_lgr(result, odd_reg);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6161
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6162
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6163
    z_slgr(odd_reg, haystack);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6164
    z_srlg(result, odd_reg, exact_log2(sizeof(jchar)));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6165
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6166
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6167
  bind(Ldone);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6168
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6169
  BLOCK_COMMENT("} string_indexof_char");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6170
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6171
  return offset() - block_start;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6172
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6173
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6174
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6175
//-------------------------------------------------
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6176
//   Constants (scalar and oop) in constant pool
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6177
//-------------------------------------------------
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6178
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6179
// Add a non-relocated constant to the CP.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6180
int MacroAssembler::store_const_in_toc(AddressLiteral& val) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6181
  long    value  = val.value();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6182
  address tocPos = long_constant(value);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6183
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6184
  if (tocPos != NULL) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6185
    int tocOffset = (int)(tocPos - code()->consts()->start());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6186
    return tocOffset;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6187
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6188
  // Address_constant returned NULL, so no constant entry has been created.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6189
  // In that case, we return a "fatal" offset, just in case that subsequently
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6190
  // generated access code is executed.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6191
  return -1;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6192
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6193
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6194
// Returns the TOC offset where the address is stored.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6195
// Add a relocated constant to the CP.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6196
int MacroAssembler::store_oop_in_toc(AddressLiteral& oop) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6197
  // Use RelocationHolder::none for the constant pool entry.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6198
  // Otherwise we will end up with a failing NativeCall::verify(x),
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6199
  // where x is the address of the constant pool entry.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6200
  address tocPos = address_constant((address)oop.value(), RelocationHolder::none);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6201
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6202
  if (tocPos != NULL) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6203
    int              tocOffset = (int)(tocPos - code()->consts()->start());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6204
    RelocationHolder rsp = oop.rspec();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6205
    Relocation      *rel = rsp.reloc();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6206
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6207
    // Store toc_offset in relocation, used by call_far_patchable.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6208
    if ((relocInfo::relocType)rel->type() == relocInfo::runtime_call_w_cp_type) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6209
      ((runtime_call_w_cp_Relocation *)(rel))->set_constant_pool_offset(tocOffset);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6210
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6211
    // Relocate at the load's pc.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6212
    relocate(rsp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6213
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6214
    return tocOffset;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6215
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6216
  // Address_constant returned NULL, so no constant entry has been created
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6217
  // in that case, we return a "fatal" offset, just in case that subsequently
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6218
  // generated access code is executed.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6219
  return -1;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6220
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6221
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6222
bool MacroAssembler::load_const_from_toc(Register dst, AddressLiteral& a, Register Rtoc) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6223
  int     tocOffset = store_const_in_toc(a);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6224
  if (tocOffset == -1) return false;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6225
  address tocPos    = tocOffset + code()->consts()->start();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6226
  assert((address)code()->consts()->start() != NULL, "Please add CP address");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6227
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6228
  load_long_pcrelative(dst, tocPos);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6229
  return true;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6230
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6231
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6232
bool MacroAssembler::load_oop_from_toc(Register dst, AddressLiteral& a, Register Rtoc) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6233
  int     tocOffset = store_oop_in_toc(a);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6234
  if (tocOffset == -1) return false;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6235
  address tocPos    = tocOffset + code()->consts()->start();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6236
  assert((address)code()->consts()->start() != NULL, "Please add CP address");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6237
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6238
  load_addr_pcrelative(dst, tocPos);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6239
  return true;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6240
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6241
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6242
// If the instruction sequence at the given pc is a load_const_from_toc
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6243
// sequence, return the value currently stored at the referenced position
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6244
// in the TOC.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6245
intptr_t MacroAssembler::get_const_from_toc(address pc) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6246
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6247
  assert(is_load_const_from_toc(pc), "must be load_const_from_pool");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6248
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6249
  long    offset  = get_load_const_from_toc_offset(pc);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6250
  address dataLoc = NULL;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6251
  if (is_load_const_from_toc_pcrelative(pc)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6252
    dataLoc = pc + offset;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6253
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6254
    CodeBlob* cb = CodeCache::find_blob_unsafe(pc);   // Else we get assertion if nmethod is zombie.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6255
    assert(cb && cb->is_nmethod(), "sanity");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6256
    nmethod* nm = (nmethod*)cb;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6257
    dataLoc = nm->ctable_begin() + offset;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6258
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6259
  return *(intptr_t *)dataLoc;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6260
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6261
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6262
// If the instruction sequence at the given pc is a load_const_from_toc
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6263
// sequence, copy the passed-in new_data value into the referenced
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6264
// position in the TOC.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6265
void MacroAssembler::set_const_in_toc(address pc, unsigned long new_data, CodeBlob *cb) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6266
  assert(is_load_const_from_toc(pc), "must be load_const_from_pool");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6267
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6268
  long    offset = MacroAssembler::get_load_const_from_toc_offset(pc);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6269
  address dataLoc = NULL;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6270
  if (is_load_const_from_toc_pcrelative(pc)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6271
    dataLoc = pc+offset;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6272
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6273
    nmethod* nm = CodeCache::find_nmethod(pc);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6274
    assert((cb == NULL) || (nm == (nmethod*)cb), "instruction address should be in CodeBlob");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6275
    dataLoc = nm->ctable_begin() + offset;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6276
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6277
  if (*(unsigned long *)dataLoc != new_data) { // Prevent cache invalidation: update only if necessary.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6278
    *(unsigned long *)dataLoc = new_data;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6279
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6280
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6281
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6282
// Dynamic TOC. Getter must only be called if "a" is a load_const_from_toc
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6283
// site. Verify by calling is_load_const_from_toc() before!!
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6284
// Offset is +/- 2**32 -> use long.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6285
long MacroAssembler::get_load_const_from_toc_offset(address a) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6286
  assert(is_load_const_from_toc_pcrelative(a), "expected pc relative load");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6287
  //  expected code sequence:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6288
  //    z_lgrl(t, simm32);    len = 6
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6289
  unsigned long inst;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6290
  unsigned int  len = get_instruction(a, &inst);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6291
  return get_pcrel_offset(inst);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6292
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6293
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6294
//**********************************************************************************
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6295
//  inspection of generated instruction sequences for a particular pattern
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6296
//**********************************************************************************
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6297
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6298
bool MacroAssembler::is_load_const_from_toc_pcrelative(address a) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6299
#ifdef ASSERT
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6300
  unsigned long inst;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6301
  unsigned int  len = get_instruction(a+2, &inst);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6302
  if ((len == 6) && is_load_pcrelative_long(a) && is_call_pcrelative_long(inst)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6303
    const int range = 128;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6304
    Assembler::dump_code_range(tty, a, range, "instr(a) == z_lgrl && instr(a+2) == z_brasl");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6305
    VM_Version::z_SIGSEGV();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6306
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6307
#endif
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6308
  // expected code sequence:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6309
  //   z_lgrl(t, relAddr32);    len = 6
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6310
  //TODO: verify accessed data is in CP, if possible.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6311
  return is_load_pcrelative_long(a);  // TODO: might be too general. Currently, only lgrl is used.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6312
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6313
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6314
bool MacroAssembler::is_load_const_from_toc_call(address a) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6315
  return is_load_const_from_toc(a) && is_call_byregister(a + load_const_from_toc_size());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6316
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6317
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6318
bool MacroAssembler::is_load_const_call(address a) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6319
  return is_load_const(a) && is_call_byregister(a + load_const_size());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6320
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6321
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6322
//-------------------------------------------------
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6323
//   Emitters for some really CICS instructions
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6324
//-------------------------------------------------
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6325
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6326
void MacroAssembler::move_long_ext(Register dst, Register src, unsigned int pad) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6327
  assert(dst->encoding()%2==0, "must be an even/odd register pair");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6328
  assert(src->encoding()%2==0, "must be an even/odd register pair");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6329
  assert(pad<256, "must be a padding BYTE");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6330
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6331
  Label retry;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6332
  bind(retry);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6333
  Assembler::z_mvcle(dst, src, pad);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6334
  Assembler::z_brc(Assembler::bcondOverflow /* CC==3 (iterate) */, retry);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6335
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6336
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6337
void MacroAssembler::compare_long_ext(Register left, Register right, unsigned int pad) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6338
  assert(left->encoding() % 2 == 0, "must be an even/odd register pair");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6339
  assert(right->encoding() % 2 == 0, "must be an even/odd register pair");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6340
  assert(pad<256, "must be a padding BYTE");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6341
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6342
  Label retry;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6343
  bind(retry);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6344
  Assembler::z_clcle(left, right, pad, Z_R0);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6345
  Assembler::z_brc(Assembler::bcondOverflow /* CC==3 (iterate) */, retry);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6346
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6347
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6348
void MacroAssembler::compare_long_uni(Register left, Register right, unsigned int pad) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6349
  assert(left->encoding() % 2 == 0, "must be an even/odd register pair");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6350
  assert(right->encoding() % 2 == 0, "must be an even/odd register pair");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6351
  assert(pad<=0xfff, "must be a padding HALFWORD");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6352
  assert(VM_Version::has_ETF2(), "instruction must be available");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6353
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6354
  Label retry;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6355
  bind(retry);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6356
  Assembler::z_clclu(left, right, pad, Z_R0);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6357
  Assembler::z_brc(Assembler::bcondOverflow /* CC==3 (iterate) */, retry);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6358
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6359
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6360
void MacroAssembler::search_string(Register end, Register start) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6361
  assert(end->encoding() != 0, "end address must not be in R0");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6362
  assert(start->encoding() != 0, "start address must not be in R0");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6363
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6364
  Label retry;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6365
  bind(retry);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6366
  Assembler::z_srst(end, start);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6367
  Assembler::z_brc(Assembler::bcondOverflow /* CC==3 (iterate) */, retry);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6368
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6369
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6370
void MacroAssembler::search_string_uni(Register end, Register start) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6371
  assert(end->encoding() != 0, "end address must not be in R0");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6372
  assert(start->encoding() != 0, "start address must not be in R0");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6373
  assert(VM_Version::has_ETF3(), "instruction must be available");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6374
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6375
  Label retry;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6376
  bind(retry);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6377
  Assembler::z_srstu(end, start);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6378
  Assembler::z_brc(Assembler::bcondOverflow /* CC==3 (iterate) */, retry);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6379
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6380
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6381
void MacroAssembler::kmac(Register srcBuff) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6382
  assert(srcBuff->encoding()     != 0, "src buffer address can't be in Z_R0");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6383
  assert(srcBuff->encoding() % 2 == 0, "src buffer/len must be an even/odd register pair");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6384
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6385
  Label retry;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6386
  bind(retry);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6387
  Assembler::z_kmac(Z_R0, srcBuff);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6388
  Assembler::z_brc(Assembler::bcondOverflow /* CC==3 (iterate) */, retry);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6389
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6390
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6391
void MacroAssembler::kimd(Register srcBuff) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6392
  assert(srcBuff->encoding()     != 0, "src buffer address can't be in Z_R0");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6393
  assert(srcBuff->encoding() % 2 == 0, "src buffer/len must be an even/odd register pair");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6394
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6395
  Label retry;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6396
  bind(retry);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6397
  Assembler::z_kimd(Z_R0, srcBuff);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6398
  Assembler::z_brc(Assembler::bcondOverflow /* CC==3 (iterate) */, retry);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6399
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6400
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6401
void MacroAssembler::klmd(Register srcBuff) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6402
  assert(srcBuff->encoding()     != 0, "src buffer address can't be in Z_R0");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6403
  assert(srcBuff->encoding() % 2 == 0, "src buffer/len must be an even/odd register pair");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6404
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6405
  Label retry;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6406
  bind(retry);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6407
  Assembler::z_klmd(Z_R0, srcBuff);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6408
  Assembler::z_brc(Assembler::bcondOverflow /* CC==3 (iterate) */, retry);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6409
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6410
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6411
void MacroAssembler::km(Register dstBuff, Register srcBuff) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6412
  // DstBuff and srcBuff are allowed to be the same register (encryption in-place).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6413
  // DstBuff and srcBuff storage must not overlap destructively, and neither must overlap the parameter block.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6414
  assert(srcBuff->encoding()     != 0, "src buffer address can't be in Z_R0");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6415
  assert(dstBuff->encoding() % 2 == 0, "dst buffer addr must be an even register");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6416
  assert(srcBuff->encoding() % 2 == 0, "src buffer addr/len must be an even/odd register pair");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6417
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6418
  Label retry;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6419
  bind(retry);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6420
  Assembler::z_km(dstBuff, srcBuff);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6421
  Assembler::z_brc(Assembler::bcondOverflow /* CC==3 (iterate) */, retry);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6422
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6423
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6424
void MacroAssembler::kmc(Register dstBuff, Register srcBuff) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6425
  // DstBuff and srcBuff are allowed to be the same register (encryption in-place).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6426
  // DstBuff and srcBuff storage must not overlap destructively, and neither must overlap the parameter block.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6427
  assert(srcBuff->encoding()     != 0, "src buffer address can't be in Z_R0");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6428
  assert(dstBuff->encoding() % 2 == 0, "dst buffer addr must be an even register");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6429
  assert(srcBuff->encoding() % 2 == 0, "src buffer addr/len must be an even/odd register pair");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6430
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6431
  Label retry;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6432
  bind(retry);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6433
  Assembler::z_kmc(dstBuff, srcBuff);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6434
  Assembler::z_brc(Assembler::bcondOverflow /* CC==3 (iterate) */, retry);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6435
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6436
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6437
void MacroAssembler::cksm(Register crcBuff, Register srcBuff) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6438
  assert(srcBuff->encoding() % 2 == 0, "src buffer addr/len must be an even/odd register pair");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6439
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6440
  Label retry;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6441
  bind(retry);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6442
  Assembler::z_cksm(crcBuff, srcBuff);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6443
  Assembler::z_brc(Assembler::bcondOverflow /* CC==3 (iterate) */, retry);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6444
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6445
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6446
void MacroAssembler::translate_oo(Register r1, Register r2, uint m3) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6447
  assert(r1->encoding() % 2 == 0, "dst addr/src len must be an even/odd register pair");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6448
  assert((m3 & 0b1110) == 0, "Unused mask bits must be zero");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6449
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6450
  Label retry;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6451
  bind(retry);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6452
  Assembler::z_troo(r1, r2, m3);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6453
  Assembler::z_brc(Assembler::bcondOverflow /* CC==3 (iterate) */, retry);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6454
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6455
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6456
void MacroAssembler::translate_ot(Register r1, Register r2, uint m3) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6457
  assert(r1->encoding() % 2 == 0, "dst addr/src len must be an even/odd register pair");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6458
  assert((m3 & 0b1110) == 0, "Unused mask bits must be zero");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6459
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6460
  Label retry;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6461
  bind(retry);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6462
  Assembler::z_trot(r1, r2, m3);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6463
  Assembler::z_brc(Assembler::bcondOverflow /* CC==3 (iterate) */, retry);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6464
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6465
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6466
void MacroAssembler::translate_to(Register r1, Register r2, uint m3) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6467
  assert(r1->encoding() % 2 == 0, "dst addr/src len must be an even/odd register pair");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6468
  assert((m3 & 0b1110) == 0, "Unused mask bits must be zero");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6469
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6470
  Label retry;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6471
  bind(retry);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6472
  Assembler::z_trto(r1, r2, m3);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6473
  Assembler::z_brc(Assembler::bcondOverflow /* CC==3 (iterate) */, retry);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6474
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6475
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6476
void MacroAssembler::translate_tt(Register r1, Register r2, uint m3) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6477
  assert(r1->encoding() % 2 == 0, "dst addr/src len must be an even/odd register pair");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6478
  assert((m3 & 0b1110) == 0, "Unused mask bits must be zero");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6479
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6480
  Label retry;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6481
  bind(retry);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6482
  Assembler::z_trtt(r1, r2, m3);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6483
  Assembler::z_brc(Assembler::bcondOverflow /* CC==3 (iterate) */, retry);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6484
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6485
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6486
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6487
void MacroAssembler::generate_type_profiling(const Register Rdata,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6488
                                             const Register Rreceiver_klass,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6489
                                             const Register Rwanted_receiver_klass,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6490
                                             const Register Rmatching_row,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6491
                                             bool is_virtual_call) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6492
  const int row_size = in_bytes(ReceiverTypeData::receiver_offset(1)) -
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6493
                       in_bytes(ReceiverTypeData::receiver_offset(0));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6494
  const int num_rows = ReceiverTypeData::row_limit();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6495
  NearLabel found_free_row;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6496
  NearLabel do_increment;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6497
  NearLabel found_no_slot;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6498
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6499
  BLOCK_COMMENT("type profiling {");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6500
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6501
  // search for:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6502
  //    a) The type given in Rwanted_receiver_klass.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6503
  //    b) The *first* empty row.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6504
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6505
  // First search for a) only, just running over b) with no regard.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6506
  // This is possible because
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6507
  //    wanted_receiver_class == receiver_class  &&  wanted_receiver_class == 0
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6508
  // is never true (receiver_class can't be zero).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6509
  for (int row_num = 0; row_num < num_rows; row_num++) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6510
    // Row_offset should be a well-behaved positive number. The generated code relies
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6511
    // on that wrt constant code size. Add2reg can handle all row_offset values, but
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6512
    // will have to vary generated code size.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6513
    int row_offset = in_bytes(ReceiverTypeData::receiver_offset(row_num));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6514
    assert(Displacement::is_shortDisp(row_offset), "Limitation of generated code");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6515
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6516
    // Is Rwanted_receiver_klass in this row?
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6517
    if (VM_Version::has_CompareBranch()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6518
      z_lg(Rwanted_receiver_klass, row_offset, Z_R0, Rdata);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6519
      // Rmatching_row = Rdata + row_offset;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6520
      add2reg(Rmatching_row, row_offset, Rdata);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6521
      // if (*row_recv == (intptr_t) receiver_klass) goto fill_existing_slot;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6522
      compare64_and_branch(Rwanted_receiver_klass, Rreceiver_klass, Assembler::bcondEqual, do_increment);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6523
    } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6524
      add2reg(Rmatching_row, row_offset, Rdata);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6525
      z_cg(Rreceiver_klass, row_offset, Z_R0, Rdata);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6526
      z_bre(do_increment);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6527
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6528
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6529
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6530
  // Now that we did not find a match, let's search for b).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6531
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6532
  // We could save the first calculation of Rmatching_row if we woud search for a) in reverse order.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6533
  // We would then end up here with Rmatching_row containing the value for row_num == 0.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6534
  // We would not see much benefit, if any at all, because the CPU can schedule
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6535
  // two instructions together with a branch anyway.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6536
  for (int row_num = 0; row_num < num_rows; row_num++) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6537
    int row_offset = in_bytes(ReceiverTypeData::receiver_offset(row_num));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6538
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6539
    // Has this row a zero receiver_klass, i.e. is it empty?
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6540
    if (VM_Version::has_CompareBranch()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6541
      z_lg(Rwanted_receiver_klass, row_offset, Z_R0, Rdata);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6542
      // Rmatching_row = Rdata + row_offset
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6543
      add2reg(Rmatching_row, row_offset, Rdata);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6544
      // if (*row_recv == (intptr_t) 0) goto found_free_row
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6545
      compare64_and_branch(Rwanted_receiver_klass, (intptr_t)0, Assembler::bcondEqual, found_free_row);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6546
    } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6547
      add2reg(Rmatching_row, row_offset, Rdata);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6548
      load_and_test_long(Rwanted_receiver_klass, Address(Rdata, row_offset));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6549
      z_bre(found_free_row);  // zero -> Found a free row.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6550
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6551
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6552
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6553
  // No match, no empty row found.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6554
  // Increment total counter to indicate polymorphic case.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6555
  if (is_virtual_call) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6556
    add2mem_64(Address(Rdata, CounterData::count_offset()), 1, Rmatching_row);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6557
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6558
  z_bru(found_no_slot);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6559
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6560
  // Here we found an empty row, but we have not found Rwanted_receiver_klass.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6561
  // Rmatching_row holds the address to the first empty row.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6562
  bind(found_free_row);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6563
  // Store receiver_klass into empty slot.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6564
  z_stg(Rreceiver_klass, 0, Z_R0, Rmatching_row);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6565
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6566
  // Increment the counter of Rmatching_row.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6567
  bind(do_increment);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6568
  ByteSize counter_offset = ReceiverTypeData::receiver_count_offset(0) - ReceiverTypeData::receiver_offset(0);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6569
  add2mem_64(Address(Rmatching_row, counter_offset), 1, Rdata);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6570
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6571
  bind(found_no_slot);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6572
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6573
  BLOCK_COMMENT("} type profiling");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6574
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6575
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6576
//---------------------------------------
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6577
// Helpers for Intrinsic Emitters
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6578
//---------------------------------------
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6579
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6580
/**
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6581
 * uint32_t crc;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6582
 * timesXtoThe32[crc & 0xFF] ^ (crc >> 8);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6583
 */
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6584
void MacroAssembler::fold_byte_crc32(Register crc, Register val, Register table, Register tmp) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6585
  assert_different_registers(crc, table, tmp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6586
  assert_different_registers(val, table);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6587
  if (crc == val) {      // Must rotate first to use the unmodified value.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6588
    rotate_then_insert(tmp, val, 56-2, 63-2, 2, true);  // Insert byte 7 of val, shifted left by 2, into byte 6..7 of tmp, clear the rest.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6589
    z_srl(crc, 8);       // Unsigned shift, clear leftmost 8 bits.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6590
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6591
    z_srl(crc, 8);       // Unsigned shift, clear leftmost 8 bits.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6592
    rotate_then_insert(tmp, val, 56-2, 63-2, 2, true);  // Insert byte 7 of val, shifted left by 2, into byte 6..7 of tmp, clear the rest.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6593
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6594
  z_x(crc, Address(table, tmp, 0));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6595
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6596
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6597
/**
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6598
 * uint32_t crc;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6599
 * timesXtoThe32[crc & 0xFF] ^ (crc >> 8);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6600
 */
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6601
void MacroAssembler::fold_8bit_crc32(Register crc, Register table, Register tmp) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6602
  fold_byte_crc32(crc, crc, table, tmp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6603
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6604
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6605
/**
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6606
 * Emits code to update CRC-32 with a byte value according to constants in table.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6607
 *
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6608
 * @param [in,out]crc Register containing the crc.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6609
 * @param [in]val     Register containing the byte to fold into the CRC.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6610
 * @param [in]table   Register containing the table of crc constants.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6611
 *
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6612
 * uint32_t crc;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6613
 * val = crc_table[(val ^ crc) & 0xFF];
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6614
 * crc = val ^ (crc >> 8);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6615
 */
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6616
void MacroAssembler::update_byte_crc32(Register crc, Register val, Register table) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6617
  z_xr(val, crc);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6618
  fold_byte_crc32(crc, val, table, val);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6619
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6620
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6621
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6622
/**
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6623
 * @param crc   register containing existing CRC (32-bit)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6624
 * @param buf   register pointing to input byte buffer (byte*)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6625
 * @param len   register containing number of bytes
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6626
 * @param table register pointing to CRC table
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6627
 */
46315
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46289
diff changeset
  6628
void MacroAssembler::update_byteLoop_crc32(Register crc, Register buf, Register len, Register table, Register data) {
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6629
  assert_different_registers(crc, buf, len, table, data);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6630
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6631
  Label L_mainLoop, L_done;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6632
  const int mainLoop_stepping = 1;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6633
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6634
  // Process all bytes in a single-byte loop.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6635
  z_ltr(len, len);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6636
  z_brnh(L_done);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6637
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6638
  bind(L_mainLoop);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6639
    z_llgc(data, Address(buf, (intptr_t)0));// Current byte of input buffer (zero extended). Avoids garbage in upper half of register.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6640
    add2reg(buf, mainLoop_stepping);        // Advance buffer position.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6641
    update_byte_crc32(crc, data, table);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6642
    z_brct(len, L_mainLoop);                // Iterate.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6643
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6644
  bind(L_done);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6645
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6646
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6647
/**
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6648
 * Emits code to update CRC-32 with a 4-byte value according to constants in table.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6649
 * Implementation according to jdk/src/share/native/java/util/zip/zlib-1.2.8/crc32.c.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6650
 *
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6651
 */
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6652
void MacroAssembler::update_1word_crc32(Register crc, Register buf, Register table, int bufDisp, int bufInc,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6653
                                        Register t0,  Register t1,  Register t2,    Register t3) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6654
  // This is what we implement (the DOBIG4 part):
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6655
  //
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6656
  // #define DOBIG4 c ^= *++buf4; \
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6657
  //         c = crc_table[4][c & 0xff] ^ crc_table[5][(c >> 8) & 0xff] ^ \
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6658
  //             crc_table[6][(c >> 16) & 0xff] ^ crc_table[7][c >> 24]
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6659
  // #define DOBIG32 DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4
46315
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46289
diff changeset
  6660
  // Pre-calculate (constant) column offsets, use columns 4..7 for big-endian.
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6661
  const int ix0 = 4*(4*CRC32_COLUMN_SIZE);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6662
  const int ix1 = 5*(4*CRC32_COLUMN_SIZE);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6663
  const int ix2 = 6*(4*CRC32_COLUMN_SIZE);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6664
  const int ix3 = 7*(4*CRC32_COLUMN_SIZE);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6665
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6666
  // XOR crc with next four bytes of buffer.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6667
  lgr_if_needed(t0, crc);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6668
  z_x(t0, Address(buf, bufDisp));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6669
  if (bufInc != 0) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6670
    add2reg(buf, bufInc);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6671
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6672
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6673
  // Chop crc into 4 single-byte pieces, shifted left 2 bits, to form the table indices.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6674
  rotate_then_insert(t3, t0, 56-2, 63-2, 2,    true);  // ((c >>  0) & 0xff) << 2
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6675
  rotate_then_insert(t2, t0, 56-2, 63-2, 2-8,  true);  // ((c >>  8) & 0xff) << 2
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6676
  rotate_then_insert(t1, t0, 56-2, 63-2, 2-16, true);  // ((c >> 16) & 0xff) << 2
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6677
  rotate_then_insert(t0, t0, 56-2, 63-2, 2-24, true);  // ((c >> 24) & 0xff) << 2
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6678
46315
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46289
diff changeset
  6679
  // XOR indexed table values to calculate updated crc.
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6680
  z_ly(t2, Address(table, t2, (intptr_t)ix1));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6681
  z_ly(t0, Address(table, t0, (intptr_t)ix3));
46315
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46289
diff changeset
  6682
  z_xy(t2, Address(table, t3, (intptr_t)ix0));
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46289
diff changeset
  6683
  z_xy(t0, Address(table, t1, (intptr_t)ix2));
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46289
diff changeset
  6684
  z_xr(t0, t2);           // Now t0 contains the updated CRC value.
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6685
  lgr_if_needed(crc, t0);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6686
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6687
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6688
/**
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6689
 * @param crc   register containing existing CRC (32-bit)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6690
 * @param buf   register pointing to input byte buffer (byte*)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6691
 * @param len   register containing number of bytes
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6692
 * @param table register pointing to CRC table
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6693
 *
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6694
 * uses Z_R10..Z_R13 as work register. Must be saved/restored by caller!
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6695
 */
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6696
void MacroAssembler::kernel_crc32_2word(Register crc, Register buf, Register len, Register table,
46315
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46289
diff changeset
  6697
                                        Register t0,  Register t1,  Register t2,  Register t3,
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46289
diff changeset
  6698
                                        bool invertCRC) {
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6699
  assert_different_registers(crc, buf, len, table);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6700
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6701
  Label L_mainLoop, L_tail;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6702
  Register  data = t0;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6703
  Register  ctr  = Z_R0;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6704
  const int mainLoop_stepping = 8;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6705
  const int tailLoop_stepping = 1;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6706
  const int log_stepping      = exact_log2(mainLoop_stepping);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6707
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6708
  // Don't test for len <= 0 here. This pathological case should not occur anyway.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6709
  // Optimizing for it by adding a test and a branch seems to be a waste of CPU cycles.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6710
  // The situation itself is detected and handled correctly by the conditional branches
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6711
  // following aghi(len, -stepping) and aghi(len, +stepping).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6712
46315
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46289
diff changeset
  6713
  if (invertCRC) {
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46289
diff changeset
  6714
    not_(crc, noreg, false);           // 1s complement of crc
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46289
diff changeset
  6715
  }
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6716
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6717
#if 0
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6718
  {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6719
    // Pre-mainLoop alignment did not show any positive effect on performance.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6720
    // We leave the code in for reference. Maybe the vector instructions in z13 depend on alignment.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6721
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6722
    z_cghi(len, mainLoop_stepping);    // Alignment is useless for short data streams.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6723
    z_brnh(L_tail);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6724
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6725
    // Align buf to word (4-byte) boundary.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6726
    z_lcr(ctr, buf);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6727
    rotate_then_insert(ctr, ctr, 62, 63, 0, true); // TODO: should set cc
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6728
    z_sgfr(len, ctr);                  // Remaining len after alignment.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6729
46315
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46289
diff changeset
  6730
    update_byteLoop_crc32(crc, buf, ctr, table, data);
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6731
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6732
#endif
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6733
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6734
  // Check for short (<mainLoop_stepping bytes) buffer.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6735
  z_srag(ctr, len, log_stepping);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6736
  z_brnh(L_tail);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6737
46315
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46289
diff changeset
  6738
  z_lrvr(crc, crc);          // Revert byte order because we are dealing with big-endian data.
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6739
  rotate_then_insert(len, len, 64-log_stepping, 63, 0, true); // #bytes for tailLoop
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6740
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6741
  BIND(L_mainLoop);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6742
    update_1word_crc32(crc, buf, table, 0, 0, crc, t1, t2, t3);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6743
    update_1word_crc32(crc, buf, table, 4, mainLoop_stepping, crc, t1, t2, t3);
46315
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46289
diff changeset
  6744
    z_brct(ctr, L_mainLoop); // Iterate.
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46289
diff changeset
  6745
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46289
diff changeset
  6746
  z_lrvr(crc, crc);          // Revert byte order back to original.
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6747
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6748
  // Process last few (<8) bytes of buffer.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6749
  BIND(L_tail);
46315
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46289
diff changeset
  6750
  update_byteLoop_crc32(crc, buf, len, table, data);
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46289
diff changeset
  6751
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46289
diff changeset
  6752
  if (invertCRC) {
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46289
diff changeset
  6753
    not_(crc, noreg, false);           // 1s complement of crc
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46289
diff changeset
  6754
  }
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6755
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6756
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6757
/**
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6758
 * @param crc   register containing existing CRC (32-bit)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6759
 * @param buf   register pointing to input byte buffer (byte*)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6760
 * @param len   register containing number of bytes
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6761
 * @param table register pointing to CRC table
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6762
 *
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6763
 * uses Z_R10..Z_R13 as work register. Must be saved/restored by caller!
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6764
 */
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6765
void MacroAssembler::kernel_crc32_1word(Register crc, Register buf, Register len, Register table,
46315
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46289
diff changeset
  6766
                                        Register t0,  Register t1,  Register t2,  Register t3,
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46289
diff changeset
  6767
                                        bool invertCRC) {
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6768
  assert_different_registers(crc, buf, len, table);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6769
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6770
  Label L_mainLoop, L_tail;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6771
  Register  data = t0;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6772
  Register  ctr  = Z_R0;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6773
  const int mainLoop_stepping = 4;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6774
  const int log_stepping      = exact_log2(mainLoop_stepping);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6775
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6776
  // Don't test for len <= 0 here. This pathological case should not occur anyway.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6777
  // Optimizing for it by adding a test and a branch seems to be a waste of CPU cycles.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6778
  // The situation itself is detected and handled correctly by the conditional branches
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6779
  // following aghi(len, -stepping) and aghi(len, +stepping).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6780
46315
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46289
diff changeset
  6781
  if (invertCRC) {
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46289
diff changeset
  6782
    not_(crc, noreg, false);           // 1s complement of crc
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46289
diff changeset
  6783
  }
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6784
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6785
  // Check for short (<4 bytes) buffer.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6786
  z_srag(ctr, len, log_stepping);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6787
  z_brnh(L_tail);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6788
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6789
  z_lrvr(crc, crc);          // Revert byte order because we are dealing with big-endian data.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6790
  rotate_then_insert(len, len, 64-log_stepping, 63, 0, true); // #bytes for tailLoop
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6791
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6792
  BIND(L_mainLoop);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6793
    update_1word_crc32(crc, buf, table, 0, mainLoop_stepping, crc, t1, t2, t3);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6794
    z_brct(ctr, L_mainLoop); // Iterate.
46315
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46289
diff changeset
  6795
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6796
  z_lrvr(crc, crc);          // Revert byte order back to original.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6797
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6798
  // Process last few (<8) bytes of buffer.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6799
  BIND(L_tail);
46315
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46289
diff changeset
  6800
  update_byteLoop_crc32(crc, buf, len, table, data);
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46289
diff changeset
  6801
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46289
diff changeset
  6802
  if (invertCRC) {
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46289
diff changeset
  6803
    not_(crc, noreg, false);           // 1s complement of crc
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46289
diff changeset
  6804
  }
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6805
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6806
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6807
/**
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6808
 * @param crc   register containing existing CRC (32-bit)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6809
 * @param buf   register pointing to input byte buffer (byte*)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6810
 * @param len   register containing number of bytes
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6811
 * @param table register pointing to CRC table
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6812
 */
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6813
void MacroAssembler::kernel_crc32_1byte(Register crc, Register buf, Register len, Register table,
46315
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46289
diff changeset
  6814
                                        Register t0,  Register t1,  Register t2,  Register t3,
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46289
diff changeset
  6815
                                        bool invertCRC) {
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6816
  assert_different_registers(crc, buf, len, table);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6817
  Register data = t0;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6818
46315
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46289
diff changeset
  6819
  if (invertCRC) {
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46289
diff changeset
  6820
    not_(crc, noreg, false);           // 1s complement of crc
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46289
diff changeset
  6821
  }
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46289
diff changeset
  6822
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46289
diff changeset
  6823
  update_byteLoop_crc32(crc, buf, len, table, data);
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46289
diff changeset
  6824
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46289
diff changeset
  6825
  if (invertCRC) {
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46289
diff changeset
  6826
    not_(crc, noreg, false);           // 1s complement of crc
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46289
diff changeset
  6827
  }
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46289
diff changeset
  6828
}
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46289
diff changeset
  6829
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46289
diff changeset
  6830
void MacroAssembler::kernel_crc32_singleByte(Register crc, Register buf, Register len, Register table, Register tmp,
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46289
diff changeset
  6831
                                             bool invertCRC) {
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6832
  assert_different_registers(crc, buf, len, table, tmp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6833
46315
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46289
diff changeset
  6834
  if (invertCRC) {
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46289
diff changeset
  6835
    not_(crc, noreg, false);           // 1s complement of crc
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46289
diff changeset
  6836
  }
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6837
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6838
  z_llgc(tmp, Address(buf, (intptr_t)0));  // Current byte of input buffer (zero extended). Avoids garbage in upper half of register.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6839
  update_byte_crc32(crc, tmp, table);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6840
46315
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46289
diff changeset
  6841
  if (invertCRC) {
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46289
diff changeset
  6842
    not_(crc, noreg, false);           // 1s complement of crc
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46289
diff changeset
  6843
  }
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46289
diff changeset
  6844
}
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46289
diff changeset
  6845
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46289
diff changeset
  6846
void MacroAssembler::kernel_crc32_singleByteReg(Register crc, Register val, Register table,
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46289
diff changeset
  6847
                                                bool invertCRC) {
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46289
diff changeset
  6848
  assert_different_registers(crc, val, table);
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46289
diff changeset
  6849
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46289
diff changeset
  6850
  if (invertCRC) {
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46289
diff changeset
  6851
    not_(crc, noreg, false);           // 1s complement of crc
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46289
diff changeset
  6852
  }
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46289
diff changeset
  6853
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46289
diff changeset
  6854
  update_byte_crc32(crc, val, table);
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46289
diff changeset
  6855
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46289
diff changeset
  6856
  if (invertCRC) {
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46289
diff changeset
  6857
    not_(crc, noreg, false);           // 1s complement of crc
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46289
diff changeset
  6858
  }
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6859
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6860
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6861
//
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6862
// Code for BigInteger::multiplyToLen() intrinsic.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6863
//
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6864
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6865
// dest_lo += src1 + src2
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6866
// dest_hi += carry1 + carry2
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6867
// Z_R7 is destroyed !
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6868
void MacroAssembler::add2_with_carry(Register dest_hi, Register dest_lo,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6869
                                     Register src1, Register src2) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6870
  clear_reg(Z_R7);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6871
  z_algr(dest_lo, src1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6872
  z_alcgr(dest_hi, Z_R7);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6873
  z_algr(dest_lo, src2);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6874
  z_alcgr(dest_hi, Z_R7);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6875
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6876
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6877
// Multiply 64 bit by 64 bit first loop.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6878
void MacroAssembler::multiply_64_x_64_loop(Register x, Register xstart,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6879
                                           Register x_xstart,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6880
                                           Register y, Register y_idx,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6881
                                           Register z,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6882
                                           Register carry,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6883
                                           Register product,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6884
                                           Register idx, Register kdx) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6885
  // jlong carry, x[], y[], z[];
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6886
  // for (int idx=ystart, kdx=ystart+1+xstart; idx >= 0; idx--, kdx--) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6887
  //   huge_128 product = y[idx] * x[xstart] + carry;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6888
  //   z[kdx] = (jlong)product;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6889
  //   carry  = (jlong)(product >>> 64);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6890
  // }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6891
  // z[xstart] = carry;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6892
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6893
  Label L_first_loop, L_first_loop_exit;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6894
  Label L_one_x, L_one_y, L_multiply;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6895
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6896
  z_aghi(xstart, -1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6897
  z_brl(L_one_x);   // Special case: length of x is 1.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6898
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6899
  // Load next two integers of x.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6900
  z_sllg(Z_R1_scratch, xstart, LogBytesPerInt);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6901
  mem2reg_opt(x_xstart, Address(x, Z_R1_scratch, 0));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6902
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6903
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6904
  bind(L_first_loop);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6905
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6906
  z_aghi(idx, -1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6907
  z_brl(L_first_loop_exit);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6908
  z_aghi(idx, -1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6909
  z_brl(L_one_y);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6910
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6911
  // Load next two integers of y.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6912
  z_sllg(Z_R1_scratch, idx, LogBytesPerInt);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6913
  mem2reg_opt(y_idx, Address(y, Z_R1_scratch, 0));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6914
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6915
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6916
  bind(L_multiply);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6917
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6918
  Register multiplicand = product->successor();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6919
  Register product_low = multiplicand;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6920
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6921
  lgr_if_needed(multiplicand, x_xstart);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6922
  z_mlgr(product, y_idx);     // multiplicand * y_idx -> product::multiplicand
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6923
  clear_reg(Z_R7);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6924
  z_algr(product_low, carry); // Add carry to result.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6925
  z_alcgr(product, Z_R7);     // Add carry of the last addition.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6926
  add2reg(kdx, -2);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6927
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6928
  // Store result.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6929
  z_sllg(Z_R7, kdx, LogBytesPerInt);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6930
  reg2mem_opt(product_low, Address(z, Z_R7, 0));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6931
  lgr_if_needed(carry, product);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6932
  z_bru(L_first_loop);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6933
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6934
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6935
  bind(L_one_y); // Load one 32 bit portion of y as (0,value).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6936
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6937
  clear_reg(y_idx);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6938
  mem2reg_opt(y_idx, Address(y, (intptr_t) 0), false);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6939
  z_bru(L_multiply);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6940
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6941
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6942
  bind(L_one_x); // Load one 32 bit portion of x as (0,value).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6943
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6944
  clear_reg(x_xstart);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6945
  mem2reg_opt(x_xstart, Address(x, (intptr_t) 0), false);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6946
  z_bru(L_first_loop);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6947
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6948
  bind(L_first_loop_exit);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6949
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6950
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6951
// Multiply 64 bit by 64 bit and add 128 bit.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6952
void MacroAssembler::multiply_add_128_x_128(Register x_xstart, Register y,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6953
                                            Register z,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6954
                                            Register yz_idx, Register idx,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6955
                                            Register carry, Register product,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6956
                                            int offset) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6957
  // huge_128 product = (y[idx] * x_xstart) + z[kdx] + carry;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6958
  // z[kdx] = (jlong)product;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6959
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6960
  Register multiplicand = product->successor();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6961
  Register product_low = multiplicand;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6962
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6963
  z_sllg(Z_R7, idx, LogBytesPerInt);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6964
  mem2reg_opt(yz_idx, Address(y, Z_R7, offset));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6965
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6966
  lgr_if_needed(multiplicand, x_xstart);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6967
  z_mlgr(product, yz_idx); // multiplicand * yz_idx -> product::multiplicand
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6968
  mem2reg_opt(yz_idx, Address(z, Z_R7, offset));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6969
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6970
  add2_with_carry(product, product_low, carry, yz_idx);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6971
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6972
  z_sllg(Z_R7, idx, LogBytesPerInt);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6973
  reg2mem_opt(product_low, Address(z, Z_R7, offset));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6974
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6975
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6976
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6977
// Multiply 128 bit by 128 bit. Unrolled inner loop.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6978
void MacroAssembler::multiply_128_x_128_loop(Register x_xstart,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6979
                                             Register y, Register z,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6980
                                             Register yz_idx, Register idx,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6981
                                             Register jdx,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6982
                                             Register carry, Register product,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6983
                                             Register carry2) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6984
  // jlong carry, x[], y[], z[];
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6985
  // int kdx = ystart+1;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6986
  // for (int idx=ystart-2; idx >= 0; idx -= 2) { // Third loop
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6987
  //   huge_128 product = (y[idx+1] * x_xstart) + z[kdx+idx+1] + carry;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6988
  //   z[kdx+idx+1] = (jlong)product;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6989
  //   jlong carry2 = (jlong)(product >>> 64);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6990
  //   product = (y[idx] * x_xstart) + z[kdx+idx] + carry2;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6991
  //   z[kdx+idx] = (jlong)product;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6992
  //   carry = (jlong)(product >>> 64);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6993
  // }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6994
  // idx += 2;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6995
  // if (idx > 0) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6996
  //   product = (y[idx] * x_xstart) + z[kdx+idx] + carry;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6997
  //   z[kdx+idx] = (jlong)product;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6998
  //   carry = (jlong)(product >>> 64);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  6999
  // }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7000
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7001
  Label L_third_loop, L_third_loop_exit, L_post_third_loop_done;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7002
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7003
  // scale the index
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7004
  lgr_if_needed(jdx, idx);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7005
  and_imm(jdx, 0xfffffffffffffffcL);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7006
  rshift(jdx, 2);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7007
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7008
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7009
  bind(L_third_loop);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7010
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7011
  z_aghi(jdx, -1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7012
  z_brl(L_third_loop_exit);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7013
  add2reg(idx, -4);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7014
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7015
  multiply_add_128_x_128(x_xstart, y, z, yz_idx, idx, carry, product, 8);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7016
  lgr_if_needed(carry2, product);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7017
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7018
  multiply_add_128_x_128(x_xstart, y, z, yz_idx, idx, carry2, product, 0);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7019
  lgr_if_needed(carry, product);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7020
  z_bru(L_third_loop);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7021
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7022
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7023
  bind(L_third_loop_exit);  // Handle any left-over operand parts.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7024
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7025
  and_imm(idx, 0x3);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7026
  z_brz(L_post_third_loop_done);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7027
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7028
  Label L_check_1;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7029
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7030
  z_aghi(idx, -2);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7031
  z_brl(L_check_1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7032
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7033
  multiply_add_128_x_128(x_xstart, y, z, yz_idx, idx, carry, product, 0);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7034
  lgr_if_needed(carry, product);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7035
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7036
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7037
  bind(L_check_1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7038
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7039
  add2reg(idx, 0x2);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7040
  and_imm(idx, 0x1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7041
  z_aghi(idx, -1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7042
  z_brl(L_post_third_loop_done);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7043
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7044
  Register   multiplicand = product->successor();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7045
  Register   product_low = multiplicand;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7046
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7047
  z_sllg(Z_R7, idx, LogBytesPerInt);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7048
  clear_reg(yz_idx);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7049
  mem2reg_opt(yz_idx, Address(y, Z_R7, 0), false);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7050
  lgr_if_needed(multiplicand, x_xstart);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7051
  z_mlgr(product, yz_idx); // multiplicand * yz_idx -> product::multiplicand
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7052
  clear_reg(yz_idx);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7053
  mem2reg_opt(yz_idx, Address(z, Z_R7, 0), false);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7054
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7055
  add2_with_carry(product, product_low, yz_idx, carry);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7056
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7057
  z_sllg(Z_R7, idx, LogBytesPerInt);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7058
  reg2mem_opt(product_low, Address(z, Z_R7, 0), false);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7059
  rshift(product_low, 32);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7060
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7061
  lshift(product, 32);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7062
  z_ogr(product_low, product);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7063
  lgr_if_needed(carry, product_low);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7064
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7065
  bind(L_post_third_loop_done);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7066
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7067
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7068
void MacroAssembler::multiply_to_len(Register x, Register xlen,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7069
                                     Register y, Register ylen,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7070
                                     Register z,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7071
                                     Register tmp1, Register tmp2,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7072
                                     Register tmp3, Register tmp4,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7073
                                     Register tmp5) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7074
  ShortBranchVerifier sbv(this);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7075
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7076
  assert_different_registers(x, xlen, y, ylen, z,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7077
                             tmp1, tmp2, tmp3, tmp4, tmp5, Z_R1_scratch, Z_R7);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7078
  assert_different_registers(x, xlen, y, ylen, z,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7079
                             tmp1, tmp2, tmp3, tmp4, tmp5, Z_R8);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7080
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7081
  z_stmg(Z_R7, Z_R13, _z_abi(gpr7), Z_SP);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7082
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7083
  // In openJdk, we store the argument as 32-bit value to slot.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7084
  Address zlen(Z_SP, _z_abi(remaining_cargs));  // Int in long on big endian.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7085
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7086
  const Register idx = tmp1;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7087
  const Register kdx = tmp2;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7088
  const Register xstart = tmp3;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7089
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7090
  const Register y_idx = tmp4;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7091
  const Register carry = tmp5;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7092
  const Register product  = Z_R0_scratch;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7093
  const Register x_xstart = Z_R8;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7094
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7095
  // First Loop.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7096
  //
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7097
  //   final static long LONG_MASK = 0xffffffffL;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7098
  //   int xstart = xlen - 1;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7099
  //   int ystart = ylen - 1;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7100
  //   long carry = 0;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7101
  //   for (int idx=ystart, kdx=ystart+1+xstart; idx >= 0; idx-, kdx--) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7102
  //     long product = (y[idx] & LONG_MASK) * (x[xstart] & LONG_MASK) + carry;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7103
  //     z[kdx] = (int)product;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7104
  //     carry = product >>> 32;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7105
  //   }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7106
  //   z[xstart] = (int)carry;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7107
  //
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7108
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7109
  lgr_if_needed(idx, ylen);  // idx = ylen
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7110
  z_llgf(kdx, zlen);         // C2 does not respect int to long conversion for stub calls, thus load zero-extended.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7111
  clear_reg(carry);          // carry = 0
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7112
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7113
  Label L_done;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7114
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7115
  lgr_if_needed(xstart, xlen);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7116
  z_aghi(xstart, -1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7117
  z_brl(L_done);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7118
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7119
  multiply_64_x_64_loop(x, xstart, x_xstart, y, y_idx, z, carry, product, idx, kdx);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7120
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7121
  NearLabel L_second_loop;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7122
  compare64_and_branch(kdx, RegisterOrConstant((intptr_t) 0), bcondEqual, L_second_loop);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7123
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7124
  NearLabel L_carry;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7125
  z_aghi(kdx, -1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7126
  z_brz(L_carry);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7127
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7128
  // Store lower 32 bits of carry.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7129
  z_sllg(Z_R1_scratch, kdx, LogBytesPerInt);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7130
  reg2mem_opt(carry, Address(z, Z_R1_scratch, 0), false);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7131
  rshift(carry, 32);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7132
  z_aghi(kdx, -1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7133
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7134
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7135
  bind(L_carry);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7136
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7137
  // Store upper 32 bits of carry.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7138
  z_sllg(Z_R1_scratch, kdx, LogBytesPerInt);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7139
  reg2mem_opt(carry, Address(z, Z_R1_scratch, 0), false);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7140
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7141
  // Second and third (nested) loops.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7142
  //
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7143
  // for (int i = xstart-1; i >= 0; i--) { // Second loop
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7144
  //   carry = 0;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7145
  //   for (int jdx=ystart, k=ystart+1+i; jdx >= 0; jdx--, k--) { // Third loop
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7146
  //     long product = (y[jdx] & LONG_MASK) * (x[i] & LONG_MASK) +
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7147
  //                    (z[k] & LONG_MASK) + carry;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7148
  //     z[k] = (int)product;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7149
  //     carry = product >>> 32;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7150
  //   }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7151
  //   z[i] = (int)carry;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7152
  // }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7153
  //
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7154
  // i = xlen, j = tmp1, k = tmp2, carry = tmp5, x[i] = rdx
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7155
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7156
  const Register jdx = tmp1;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7157
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7158
  bind(L_second_loop);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7159
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7160
  clear_reg(carry);           // carry = 0;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7161
  lgr_if_needed(jdx, ylen);   // j = ystart+1
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7162
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7163
  z_aghi(xstart, -1);         // i = xstart-1;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7164
  z_brl(L_done);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7165
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7166
  // Use free slots in the current stackframe instead of push/pop.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7167
  Address zsave(Z_SP, _z_abi(carg_1));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7168
  reg2mem_opt(z, zsave);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7169
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7170
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7171
  Label L_last_x;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7172
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7173
  z_sllg(Z_R1_scratch, xstart, LogBytesPerInt);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7174
  load_address(z, Address(z, Z_R1_scratch, 4)); // z = z + k - j
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7175
  z_aghi(xstart, -1);                           // i = xstart-1;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7176
  z_brl(L_last_x);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7177
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7178
  z_sllg(Z_R1_scratch, xstart, LogBytesPerInt);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7179
  mem2reg_opt(x_xstart, Address(x, Z_R1_scratch, 0));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7180
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7181
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7182
  Label L_third_loop_prologue;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7183
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7184
  bind(L_third_loop_prologue);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7185
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7186
  Address xsave(Z_SP, _z_abi(carg_2));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7187
  Address xlensave(Z_SP, _z_abi(carg_3));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7188
  Address ylensave(Z_SP, _z_abi(carg_4));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7189
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7190
  reg2mem_opt(x, xsave);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7191
  reg2mem_opt(xstart, xlensave);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7192
  reg2mem_opt(ylen, ylensave);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7193
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7194
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7195
  multiply_128_x_128_loop(x_xstart, y, z, y_idx, jdx, ylen, carry, product, x);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7196
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7197
  mem2reg_opt(z, zsave);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7198
  mem2reg_opt(x, xsave);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7199
  mem2reg_opt(xlen, xlensave);   // This is the decrement of the loop counter!
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7200
  mem2reg_opt(ylen, ylensave);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7201
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7202
  add2reg(tmp3, 1, xlen);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7203
  z_sllg(Z_R1_scratch, tmp3, LogBytesPerInt);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7204
  reg2mem_opt(carry, Address(z, Z_R1_scratch, 0), false);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7205
  z_aghi(tmp3, -1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7206
  z_brl(L_done);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7207
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7208
  rshift(carry, 32);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7209
  z_sllg(Z_R1_scratch, tmp3, LogBytesPerInt);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7210
  reg2mem_opt(carry, Address(z, Z_R1_scratch, 0), false);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7211
  z_bru(L_second_loop);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7212
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7213
  // Next infrequent code is moved outside loops.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7214
  bind(L_last_x);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7215
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7216
  clear_reg(x_xstart);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7217
  mem2reg_opt(x_xstart, Address(x, (intptr_t) 0), false);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7218
  z_bru(L_third_loop_prologue);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7219
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7220
  bind(L_done);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7221
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7222
  z_lmg(Z_R7, Z_R13, _z_abi(gpr7), Z_SP);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7223
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7224
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7225
#ifndef PRODUCT
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7226
// Assert if CC indicates "not equal" (check_equal==true) or "equal" (check_equal==false).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7227
void MacroAssembler::asm_assert(bool check_equal, const char *msg, int id) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7228
  Label ok;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7229
  if (check_equal) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7230
    z_bre(ok);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7231
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7232
    z_brne(ok);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7233
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7234
  stop(msg, id);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7235
  bind(ok);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7236
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7237
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7238
// Assert if CC indicates "low".
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7239
void MacroAssembler::asm_assert_low(const char *msg, int id) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7240
  Label ok;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7241
  z_brnl(ok);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7242
  stop(msg, id);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7243
  bind(ok);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7244
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7245
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7246
// Assert if CC indicates "high".
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7247
void MacroAssembler::asm_assert_high(const char *msg, int id) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7248
  Label ok;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7249
  z_brnh(ok);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7250
  stop(msg, id);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7251
  bind(ok);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7252
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7253
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7254
// Assert if CC indicates "not equal" (check_equal==true) or "equal" (check_equal==false)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7255
// generate non-relocatable code.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7256
void MacroAssembler::asm_assert_static(bool check_equal, const char *msg, int id) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7257
  Label ok;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7258
  if (check_equal) { z_bre(ok); }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7259
  else             { z_brne(ok); }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7260
  stop_static(msg, id);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7261
  bind(ok);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7262
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7263
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7264
void MacroAssembler::asm_assert_mems_zero(bool check_equal, bool allow_relocation, int size, int64_t mem_offset,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7265
                                          Register mem_base, const char* msg, int id) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7266
  switch (size) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7267
    case 4:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7268
      load_and_test_int(Z_R0, Address(mem_base, mem_offset));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7269
      break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7270
    case 8:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7271
      load_and_test_long(Z_R0,  Address(mem_base, mem_offset));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7272
      break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7273
    default:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7274
      ShouldNotReachHere();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7275
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7276
  if (allow_relocation) { asm_assert(check_equal, msg, id); }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7277
  else                  { asm_assert_static(check_equal, msg, id); }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7278
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7279
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7280
// Check the condition
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7281
//   expected_size == FP - SP
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7282
// after transformation:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7283
//   expected_size - FP + SP == 0
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7284
// Destroys Register expected_size if no tmp register is passed.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7285
void MacroAssembler::asm_assert_frame_size(Register expected_size, Register tmp, const char* msg, int id) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7286
  if (tmp == noreg) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7287
    tmp = expected_size;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7288
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7289
    if (tmp != expected_size) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7290
      z_lgr(tmp, expected_size);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7291
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7292
    z_algr(tmp, Z_SP);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7293
    z_slg(tmp, 0, Z_R0, Z_SP);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7294
    asm_assert_eq(msg, id);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7295
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7296
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7297
#endif // !PRODUCT
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7298
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7299
void MacroAssembler::verify_thread() {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7300
  if (VerifyThread) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7301
    unimplemented("", 117);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7302
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7303
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7304
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7305
// Plausibility check for oops.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7306
void MacroAssembler::verify_oop(Register oop, const char* msg) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7307
  if (!VerifyOops) return;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7308
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7309
  BLOCK_COMMENT("verify_oop {");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7310
  Register tmp = Z_R0;
46726
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  7311
  unsigned int nbytes_save = 5*BytesPerWord;
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7312
  address entry = StubRoutines::verify_oop_subroutine_entry_address();
46726
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  7313
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7314
  save_return_pc();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7315
  push_frame_abi160(nbytes_save);
46726
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  7316
  z_stmg(Z_R1, Z_R5, frame::z_abi_160_size, Z_SP);
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7317
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7318
  z_lgr(Z_ARG2, oop);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7319
  load_const(Z_ARG1, (address) msg);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7320
  load_const(Z_R1, entry);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7321
  z_lg(Z_R1, 0, Z_R1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7322
  call_c(Z_R1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7323
46726
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  7324
  z_lmg(Z_R1, Z_R5, frame::z_abi_160_size, Z_SP);
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7325
  pop_frame();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7326
  restore_return_pc();
46726
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  7327
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7328
  BLOCK_COMMENT("} verify_oop ");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7329
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7330
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7331
const char* MacroAssembler::stop_types[] = {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7332
  "stop",
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7333
  "untested",
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7334
  "unimplemented",
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7335
  "shouldnotreachhere"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7336
};
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7337
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7338
static void stop_on_request(const char* tp, const char* msg) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7339
  tty->print("Z assembly code requires stop: (%s) %s\n", tp, msg);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7340
  guarantee(false, "Z assembly code requires stop: %s", msg);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7341
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7342
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7343
void MacroAssembler::stop(int type, const char* msg, int id) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7344
  BLOCK_COMMENT(err_msg("stop: %s {", msg));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7345
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7346
  // Setup arguments.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7347
  load_const(Z_ARG1, (void*) stop_types[type%stop_end]);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7348
  load_const(Z_ARG2, (void*) msg);
46726
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  7349
  get_PC(Z_R14);     // Following code pushes a frame without entering a new function. Use current pc as return address.
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46369
diff changeset
  7350
  save_return_pc();  // Saves return pc Z_R14.
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7351
  push_frame_abi160(0);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7352
  call_VM_leaf(CAST_FROM_FN_PTR(address, stop_on_request), Z_ARG1, Z_ARG2);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7353
  // The plain disassembler does not recognize illtrap. It instead displays
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7354
  // a 32-bit value. Issueing two illtraps assures the disassembler finds
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7355
  // the proper beginning of the next instruction.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7356
  z_illtrap(); // Illegal instruction.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7357
  z_illtrap(); // Illegal instruction.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7358
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7359
  BLOCK_COMMENT(" } stop");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7360
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7361
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7362
// Special version of stop() for code size reduction.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7363
// Reuses the previously generated call sequence, if any.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7364
// Generates the call sequence on its own, if necessary.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7365
// Note: This code will work only in non-relocatable code!
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7366
//       The relative address of the data elements (arg1, arg2) must not change.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7367
//       The reentry point must not move relative to it's users. This prerequisite
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7368
//       should be given for "hand-written" code, if all chain calls are in the same code blob.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7369
//       Generated code must not undergo any transformation, e.g. ShortenBranches, to be safe.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7370
address MacroAssembler::stop_chain(address reentry, int type, const char* msg, int id, bool allow_relocation) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7371
  BLOCK_COMMENT(err_msg("stop_chain(%s,%s): %s {", reentry==NULL?"init":"cont", allow_relocation?"reloc ":"static", msg));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7372
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7373
  // Setup arguments.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7374
  if (allow_relocation) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7375
    // Relocatable version (for comparison purposes). Remove after some time.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7376
    load_const(Z_ARG1, (void*) stop_types[type%stop_end]);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7377
    load_const(Z_ARG2, (void*) msg);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7378
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7379
    load_absolute_address(Z_ARG1, (address)stop_types[type%stop_end]);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7380
    load_absolute_address(Z_ARG2, (address)msg);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7381
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7382
  if ((reentry != NULL) && RelAddr::is_in_range_of_RelAddr16(reentry, pc())) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7383
    BLOCK_COMMENT("branch to reentry point:");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7384
    z_brc(bcondAlways, reentry);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7385
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7386
    BLOCK_COMMENT("reentry point:");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7387
    reentry = pc();      // Re-entry point for subsequent stop calls.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7388
    save_return_pc();    // Saves return pc Z_R14.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7389
    push_frame_abi160(0);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7390
    if (allow_relocation) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7391
      reentry = NULL;    // Prevent reentry if code relocation is allowed.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7392
      call_VM_leaf(CAST_FROM_FN_PTR(address, stop_on_request), Z_ARG1, Z_ARG2);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7393
    } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7394
      call_VM_leaf_static(CAST_FROM_FN_PTR(address, stop_on_request), Z_ARG1, Z_ARG2);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7395
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7396
    z_illtrap(); // Illegal instruction as emergency stop, should the above call return.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7397
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7398
  BLOCK_COMMENT(" } stop_chain");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7399
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7400
  return reentry;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7401
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7402
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7403
// Special version of stop() for code size reduction.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7404
// Assumes constant relative addresses for data and runtime call.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7405
void MacroAssembler::stop_static(int type, const char* msg, int id) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7406
  stop_chain(NULL, type, msg, id, false);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7407
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7408
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7409
void MacroAssembler::stop_subroutine() {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7410
  unimplemented("stop_subroutine", 710);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7411
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7412
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7413
// Prints msg to stdout from within generated code..
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7414
void MacroAssembler::warn(const char* msg) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7415
  RegisterSaver::save_live_registers(this, RegisterSaver::all_registers, Z_R14);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7416
  load_absolute_address(Z_R1, (address) warning);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7417
  load_absolute_address(Z_ARG1, (address) msg);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7418
  (void) call(Z_R1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7419
  RegisterSaver::restore_live_registers(this, RegisterSaver::all_registers);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7420
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7421
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7422
#ifndef PRODUCT
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7423
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7424
// Write pattern 0x0101010101010101 in region [low-before, high+after].
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7425
void MacroAssembler::zap_from_to(Register low, Register high, Register val, Register addr, int before, int after) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7426
  if (!ZapEmptyStackFields) return;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7427
  BLOCK_COMMENT("zap memory region {");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7428
  load_const_optimized(val, 0x0101010101010101);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7429
  int size = before + after;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7430
  if (low == high && size < 5 && size > 0) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7431
    int offset = -before*BytesPerWord;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7432
    for (int i = 0; i < size; ++i) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7433
      z_stg(val, Address(low, offset));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7434
      offset +=(1*BytesPerWord);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7435
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7436
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7437
    add2reg(addr, -before*BytesPerWord, low);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7438
    if (after) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7439
#ifdef ASSERT
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7440
      jlong check = after * BytesPerWord;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7441
      assert(Immediate::is_simm32(check) && Immediate::is_simm32(-check), "value not encodable !");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7442
#endif
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7443
      add2reg(high, after * BytesPerWord);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7444
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7445
    NearLabel loop;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7446
    bind(loop);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7447
    z_stg(val, Address(addr));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7448
    add2reg(addr, 8);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7449
    compare64_and_branch(addr, high, bcondNotHigh, loop);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7450
    if (after) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7451
      add2reg(high, -after * BytesPerWord);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7452
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7453
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7454
  BLOCK_COMMENT("} zap memory region");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7455
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7456
#endif // !PRODUCT
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7457
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7458
SkipIfEqual::SkipIfEqual(MacroAssembler* masm, const bool* flag_addr, bool value, Register _rscratch) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7459
  _masm = masm;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7460
  _masm->load_absolute_address(_rscratch, (address)flag_addr);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7461
  _masm->load_and_test_int(_rscratch, Address(_rscratch));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7462
  if (value) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7463
    _masm->z_brne(_label); // Skip if true, i.e. != 0.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7464
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7465
    _masm->z_bre(_label);  // Skip if false, i.e. == 0.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7466
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7467
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7468
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7469
SkipIfEqual::~SkipIfEqual() {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7470
  _masm->bind(_label);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  7471
}