hotspot/src/cpu/s390/vm/assembler_s390.cpp
author kvn
Fri, 12 May 2017 13:14:25 -0700
changeset 46458 3c12af929e7d
parent 42065 6032b31e3719
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
     1
/*
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
     2
 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
     3
 * Copyright (c) 2016 SAP SE. All rights reserved.
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/assembler.inline.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    28
#include "compiler/disassembler.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    29
#include "gc/shared/collectedHeap.inline.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    30
#include "interpreter/interpreter.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    31
#include "gc/shared/cardTableModRefBS.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    32
#include "memory/resourceArea.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    33
#include "prims/methodHandles.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    34
#include "runtime/biasedLocking.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    35
#include "runtime/interfaceSupport.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    36
#include "runtime/objectMonitor.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    37
#include "runtime/os.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    38
#include "runtime/sharedRuntime.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    39
#include "runtime/stubRoutines.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    40
#include "utilities/macros.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    41
#if INCLUDE_ALL_GCS
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    42
#include "gc/g1/g1CollectedHeap.inline.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    43
#include "gc/g1/g1SATBCardTableModRefBS.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    44
#include "gc/g1/heapRegion.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    45
#endif
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    46
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    47
// Convention: Use Z_R0 and Z_R1 instead of Z_scratch_* in all
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    48
// assembler_s390.* files.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    49
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    50
// Convert the raw encoding form into the form expected by the
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    51
// constructor for Address. This is called by adlc generated code.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    52
Address Address::make_raw(int base, int index, int scale, int disp, relocInfo::relocType disp_reloc) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    53
  assert(scale == 0, "Scale should not be used on z/Architecture. The call to make_raw is "
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    54
         "generated by adlc and this must mirror all features of Operands from machnode.hpp.");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    55
  assert(disp_reloc == relocInfo::none, "not implemented on z/Architecture.");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    56
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    57
  Address madr(as_Register(base), as_Register(index), in_ByteSize(disp));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    58
  return madr;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    59
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    60
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    61
int AbstractAssembler::code_fill_byte() {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    62
  return 0x00; // Illegal instruction 0x00000000.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    63
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    64
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    65
// Condition code masks. Details see enum branch_condition.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    66
// Although this method is meant for INT CCs, the Overflow/Ordered
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    67
// bit in the masks has to be considered. The CC might have been set
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    68
// by a float operation, but is evaluated while calculating an integer
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    69
// result. See elementary test TestFloat.isNotEqual(FF)Z for example.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    70
Assembler::branch_condition Assembler::inverse_condition(Assembler::branch_condition cc) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    71
  Assembler::branch_condition unordered_bit = (Assembler::branch_condition)(cc & bcondNotOrdered);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    72
  Assembler::branch_condition inverse_cc;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    73
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    74
  // Some are commented out to avoid duplicate labels.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    75
  switch (cc) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    76
    case bcondNever       : inverse_cc = bcondAlways;      break;  //  0 -> 15
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    77
    case bcondAlways      : inverse_cc = bcondNever;       break;  // 15 ->  0
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    78
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    79
    case bcondOverflow    : inverse_cc = bcondNotOverflow; break;  //  1 -> 14
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    80
    case bcondNotOverflow : inverse_cc = bcondOverflow;    break;  // 14 ->  1
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    81
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    82
    default :
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    83
      switch ((Assembler::branch_condition)(cc & bcondOrdered)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    84
        case bcondEqual       : inverse_cc = bcondNotEqual;  break;  //  8 ->  6
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    85
        // case bcondZero        :
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    86
        // case bcondAllZero     :
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    87
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    88
        case bcondNotEqual    : inverse_cc = bcondEqual;     break;  //  6 ->  8
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    89
        // case bcondNotZero     :
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    90
        // case bcondMixed       :
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    91
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    92
        case bcondLow         : inverse_cc = bcondNotLow;    break;  //  4 -> 10
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    93
        // case bcondNegative    :
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    94
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    95
        case bcondNotLow      : inverse_cc = bcondLow;       break;  // 10 ->  4
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    96
        // case bcondNotNegative :
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    97
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    98
        case bcondHigh        : inverse_cc = bcondNotHigh;   break;  //  2 -> 12
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    99
        // case bcondPositive    :
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   100
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   101
        case bcondNotHigh     : inverse_cc = bcondHigh;      break;  // 12 ->  2
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   102
        // case bcondNotPositive :
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   103
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   104
        default :
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   105
          fprintf(stderr, "inverse_condition(%d)\n", (int)cc);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   106
          fflush(stderr);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   107
          ShouldNotReachHere();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   108
          return bcondNever;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   109
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   110
      // If cc is even, inverse_cc must be odd.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   111
      if (!unordered_bit) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   112
        inverse_cc = (Assembler::branch_condition)(inverse_cc | bcondNotOrdered);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   113
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   114
      break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   115
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   116
  return inverse_cc;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   117
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   118
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   119
Assembler::branch_condition Assembler::inverse_float_condition(Assembler::branch_condition cc) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   120
  Assembler::branch_condition  inverse_cc;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   121
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   122
  switch (cc) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   123
    case bcondNever       : inverse_cc = bcondAlways;      break;  //  0
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   124
    case bcondAlways      : inverse_cc = bcondNever;       break;  // 15
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   125
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   126
    case bcondNotOrdered  : inverse_cc = bcondOrdered;     break;  // 14
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   127
    case bcondOrdered     : inverse_cc = bcondNotOrdered;  break;  //  1
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   128
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   129
    case bcondEqual                      : inverse_cc = (branch_condition)(bcondNotEqual + bcondNotOrdered);  break; //  8
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   130
    case bcondNotEqual + bcondNotOrdered : inverse_cc = bcondEqual;  break;                                          //  7
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   131
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   132
    case bcondLow      + bcondNotOrdered : inverse_cc = (branch_condition)(bcondHigh + bcondEqual);      break;      //  5
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   133
    case bcondNotLow                     : inverse_cc = (branch_condition)(bcondLow  + bcondNotOrdered); break;      // 10
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   134
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   135
    case bcondHigh                       : inverse_cc = (branch_condition)(bcondLow  + bcondNotOrdered + bcondEqual); break;  //  2
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   136
    case bcondNotHigh  + bcondNotOrdered : inverse_cc = bcondHigh; break;                                                     // 13
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   137
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   138
    default :
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   139
      fprintf(stderr, "inverse_float_condition(%d)\n", (int)cc);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   140
      fflush(stderr);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   141
      ShouldNotReachHere();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   142
      return bcondNever;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   143
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   144
  return inverse_cc;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   145
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   146
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   147
#ifdef ASSERT
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   148
void Assembler::print_dbg_msg(outputStream* out, unsigned long inst, const char* msg, int ilen) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   149
  out->flush();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   150
  switch (ilen) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   151
    case 2:  out->print_cr("inst = %4.4x, %s",    (unsigned short)inst, msg); break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   152
    case 4:  out->print_cr("inst = %8.8x, %s\n",    (unsigned int)inst, msg); break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   153
    case 6:  out->print_cr("inst = %12.12lx, %s\n",               inst, msg); break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   154
    default: out->print_cr("inst = %16.16lx, %s\n",               inst, msg); break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   155
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   156
  out->flush();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   157
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   158
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   159
void Assembler::dump_code_range(outputStream* out, address pc, const unsigned int range, const char* msg) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   160
  out->cr();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   161
  out->print_cr("-------------------------------");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   162
  out->print_cr("--  %s", msg);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   163
  out->print_cr("-------------------------------");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   164
  out->print_cr("Hex dump    of +/-%d bytes around %p, interval [%p,%p)", range, pc, pc-range, pc+range);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   165
  os::print_hex_dump(out, pc-range, pc+range, 2);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   166
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   167
  out->cr();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   168
  out->print_cr("Disassembly of +/-%d bytes around %p, interval [%p,%p)", range, pc, pc-range, pc+range);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   169
  Disassembler::decode(pc, pc + range, out);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   170
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   171
#endif