src/hotspot/cpu/s390/interpreterRT_s390.cpp
author coleenp
Fri, 16 Mar 2018 09:12:13 -0400
changeset 49449 ef5d5d343e2a
parent 49359 59f6547e151f
child 49480 d7df2dd501ce
permissions -rw-r--r--
8199263: Split interfaceSupport.hpp to not require including .inline.hpp files Summary: interfaceSupport.hpp is an inline file so moved to interfaceSupport.inline.hpp and stopped including it in .hpp files Reviewed-by: stefank, rehn, kvn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
     1
/*
49359
59f6547e151f 8199264: Remove universe.inline.hpp to simplify include dependencies
stefank
parents: 47216
diff changeset
     2
 * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
42065
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/macroAssembler.inline.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    28
#include "interpreter/interpreter.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    29
#include "interpreter/interpreterRuntime.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    30
#include "memory/allocation.inline.hpp"
49359
59f6547e151f 8199264: Remove universe.inline.hpp to simplify include dependencies
stefank
parents: 47216
diff changeset
    31
#include "memory/universe.hpp"
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    32
#include "oops/oop.inline.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    33
#include "runtime/handles.inline.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    34
#include "runtime/icache.hpp"
49449
ef5d5d343e2a 8199263: Split interfaceSupport.hpp to not require including .inline.hpp files
coleenp
parents: 49359
diff changeset
    35
#include "runtime/interfaceSupport.inline.hpp"
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    36
#include "runtime/signature.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    37
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    38
// Access macros for Java and C arguments.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    39
// First Java argument is at index-1.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    40
#define locals_j_arg_at(index) Address(Z_R1/*locals*/, in_ByteSize((-(index)*wordSize)))
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    41
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    42
#define __ _masm->
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    43
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    44
static int sp_c_int_arg_offset(int arg_nr, int fp_arg_nr) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    45
  int int_arg_nr = arg_nr-fp_arg_nr;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    46
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    47
  // arg_nr, fp_arg_nr start with 1 => int_arg_nr starts with 0
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    48
  if (int_arg_nr < 5) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    49
    return int_arg_nr * wordSize + _z_abi(carg_1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    50
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    51
  int offset = int_arg_nr - 5 + (fp_arg_nr > 4 ? fp_arg_nr - 4 : 0);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    52
  return offset * wordSize + _z_abi(remaining_cargs);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    53
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    54
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    55
static int sp_c_fp_arg_offset(int arg_nr, int fp_arg_nr) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    56
  int int_arg_nr = arg_nr-fp_arg_nr;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    57
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    58
  // Arg_nr, fp_arg_nr start with 1 => int_arg_nr starts with 0.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    59
  if (fp_arg_nr < 5) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    60
    return (fp_arg_nr - 1 ) * wordSize + _z_abi(cfarg_1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    61
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    62
  int offset = fp_arg_nr - 5 + (int_arg_nr > 4 ? int_arg_nr - 4 : 0);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    63
  return offset * wordSize + _z_abi(remaining_cargs);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    64
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    65
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    66
// Implementation of SignatureHandlerGenerator
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    67
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    68
void InterpreterRuntime::SignatureHandlerGenerator::pass_int() {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    69
  int int_arg_nr = jni_offset() - _fp_arg_nr;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    70
  Register r = (int_arg_nr < 5 /*max_int_register_arguments*/) ?
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    71
                 as_Register(int_arg_nr) + Z_ARG1->encoding() : Z_R0;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    72
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    73
  __ z_lgf(r, locals_j_arg_at(offset()));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    74
  if (DEBUG_ONLY(true ||) int_arg_nr >= 5) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    75
    __ z_stg(r, sp_c_int_arg_offset(jni_offset(), _fp_arg_nr), Z_SP);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    76
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    77
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    78
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    79
void InterpreterRuntime::SignatureHandlerGenerator::pass_long() {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    80
  int int_arg_nr = jni_offset() - _fp_arg_nr;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    81
  Register r = (int_arg_nr < 5 /*max_int_register_arguments*/) ?
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    82
                 as_Register(int_arg_nr) + Z_ARG1->encoding() : Z_R0;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    83
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    84
  __ z_lg(r, locals_j_arg_at(offset() + 1)); // Long resides in upper slot.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    85
  if (DEBUG_ONLY(true ||) int_arg_nr >= 5) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    86
    __ z_stg(r, sp_c_int_arg_offset(jni_offset(), _fp_arg_nr), Z_SP);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    87
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    88
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    89
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    90
void InterpreterRuntime::SignatureHandlerGenerator::pass_float() {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    91
  FloatRegister fp_reg = (_fp_arg_nr < 4/*max_fp_register_arguments*/) ?
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    92
                           as_FloatRegister((_fp_arg_nr * 2) + Z_FARG1->encoding()) : Z_F1;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    93
  _fp_arg_nr++;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    94
  __ z_ley(fp_reg, locals_j_arg_at(offset()));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    95
  if (DEBUG_ONLY(true ||) _fp_arg_nr > 4) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    96
    __ z_ste(fp_reg, sp_c_fp_arg_offset(jni_offset(), _fp_arg_nr) + 4, Z_SP);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    97
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    98
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    99
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   100
void InterpreterRuntime::SignatureHandlerGenerator::pass_double() {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   101
  FloatRegister fp_reg = (_fp_arg_nr < 4/*max_fp_register_arguments*/) ?
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   102
                           as_FloatRegister((_fp_arg_nr*2) + Z_FARG1->encoding()) : Z_F1;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   103
  _fp_arg_nr++;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   104
  __ z_ldy(fp_reg, locals_j_arg_at(offset()+1));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   105
  if (DEBUG_ONLY(true ||) _fp_arg_nr > 4) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   106
    __ z_std(fp_reg, sp_c_fp_arg_offset(jni_offset(), _fp_arg_nr), Z_SP);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   107
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   108
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   109
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   110
void InterpreterRuntime::SignatureHandlerGenerator::pass_object() {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   111
  int int_arg_nr = jni_offset() - _fp_arg_nr;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   112
  Register  r = (int_arg_nr < 5 /*max_int_register_arguments*/) ?
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   113
                  as_Register(int_arg_nr) + Z_ARG1->encoding() : Z_R0;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   114
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   115
  // The handle for a receiver will never be null.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   116
  bool do_NULL_check = offset() != 0 || is_static();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   117
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   118
  Label do_null;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   119
  if (do_NULL_check) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   120
    __ clear_reg(r, true, false);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   121
    __ load_and_test_long(Z_R0, locals_j_arg_at(offset()));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   122
    __ z_bre(do_null);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   123
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   124
  __ add2reg(r, -offset() * wordSize, Z_R1 /* locals */);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   125
  __ bind(do_null);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   126
  if (DEBUG_ONLY(true ||) int_arg_nr >= 5) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   127
    __ z_stg(r, sp_c_int_arg_offset(jni_offset(), _fp_arg_nr), Z_SP);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   128
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   129
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   130
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   131
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   132
void InterpreterRuntime::SignatureHandlerGenerator::generate(uint64_t fingerprint) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   133
  __ z_lgr(Z_R1, Z_ARG1); // Z_R1 is used in locals_j_arg_at(index) macro.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   134
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   135
  // Generate code to handle arguments.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   136
  iterate(fingerprint);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   137
  __ load_const_optimized(Z_RET, AbstractInterpreter::result_handler(method()->result_type()));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   138
  __ z_br(Z_R14);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   139
  __ flush();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   140
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   141
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   142
#undef  __
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   143
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   144
// Implementation of SignatureHandlerLibrary
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   145
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   146
void SignatureHandlerLibrary::pd_set_handler(address handler) {}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   147
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   148
IRT_ENTRY(address, InterpreterRuntime::get_signature(JavaThread* thread, Method* method))
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   149
  methodHandle m(thread, method);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   150
  assert(m->is_native(), "sanity check");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   151
  Symbol *s = m->signature();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   152
  return (address) s->base();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   153
IRT_END
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   154
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   155
IRT_ENTRY(address, InterpreterRuntime::get_result_handler(JavaThread* thread, Method* method))
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   156
  methodHandle m(thread, method);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   157
  assert(m->is_native(), "sanity check");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   158
  return AbstractInterpreter::result_handler(m->result_type());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   159
IRT_END