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