src/hotspot/cpu/s390/templateInterpreterGenerator_s390.cpp
author goetz
Thu, 08 Feb 2018 09:23:49 +0100
changeset 49368 2ed1c37df3a5
parent 48332 651a95f30dfb
child 49748 6a880e576856
permissions -rw-r--r--
8197405: Improve messages of AbstractMethodErrors and IncompatibleClassChangeErrors. Reviewed-by: coleenp, dholmes, mdoerr, njian
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
     1
/*
46294
345a46524a19 8172020: Internal Error (cpu/arm/vm/frame_arm.cpp:571): assert(obj == __null || Universe::heap()->is_in(obj)) failed: sanity check #
cjplummer
parents: 46289
diff changeset
     2
 * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
46315
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
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/macroAssembler.inline.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    28
#include "interpreter/abstractInterpreter.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    29
#include "interpreter/bytecodeHistogram.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 "interpreter/interpreterRuntime.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    32
#include "interpreter/interp_masm.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    33
#include "interpreter/templateInterpreterGenerator.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    34
#include "interpreter/templateTable.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    35
#include "oops/arrayOop.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    36
#include "oops/oop.inline.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    37
#include "prims/jvmtiExport.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    38
#include "prims/jvmtiThreadState.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    39
#include "runtime/arguments.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    40
#include "runtime/deoptimization.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    41
#include "runtime/frame.inline.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    42
#include "runtime/sharedRuntime.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    43
#include "runtime/stubRoutines.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    44
#include "runtime/synchronizer.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    45
#include "runtime/timer.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    46
#include "runtime/vframeArray.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    47
#include "utilities/debug.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    48
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    49
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    50
// Size of interpreter code.  Increase if too small.  Interpreter will
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    51
// fail with a guarantee ("not enough space for interpreter generation");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    52
// if too small.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    53
// Run with +PrintInterpreter to get the VM to print out the size.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    54
// Max size with JVMTI
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    55
int TemplateInterpreter::InterpreterCodeSize = 320*K;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    56
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    57
#undef  __
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    58
#ifdef PRODUCT
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    59
  #define __ _masm->
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    60
#else
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    61
  #define __ _masm->
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    62
//  #define __ (Verbose ? (_masm->block_comment(FILE_AND_LINE),_masm):_masm)->
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    63
#endif
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    64
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    65
#define BLOCK_COMMENT(str) __ block_comment(str)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    66
#define BIND(label)        __ bind(label); BLOCK_COMMENT(#label ":")
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    67
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    68
#define oop_tmp_offset     _z_ijava_state_neg(oop_tmp)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    69
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    70
//-----------------------------------------------------------------------------
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    71
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    72
address TemplateInterpreterGenerator::generate_slow_signature_handler() {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    73
  //
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    74
  // New slow_signature handler that respects the z/Architecture
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    75
  // C calling conventions.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    76
  //
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    77
  // We get called by the native entry code with our output register
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    78
  // area == 8. First we call InterpreterRuntime::get_result_handler
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    79
  // to copy the pointer to the signature string temporarily to the
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    80
  // first C-argument and to return the result_handler in
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    81
  // Z_RET. Since native_entry will copy the jni-pointer to the
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    82
  // first C-argument slot later on, it's OK to occupy this slot
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    83
  // temporarily. Then we copy the argument list on the java
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    84
  // expression stack into native varargs format on the native stack
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    85
  // and load arguments into argument registers. Integer arguments in
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    86
  // the varargs vector will be sign-extended to 8 bytes.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    87
  //
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    88
  // On entry:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    89
  //   Z_ARG1  - intptr_t*       Address of java argument list in memory.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    90
  //   Z_state - cppInterpreter* Address of interpreter state for
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    91
  //                               this method
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    92
  //   Z_method
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    93
  //
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    94
  // On exit (just before return instruction):
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    95
  //   Z_RET contains the address of the result_handler.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    96
  //   Z_ARG2 is not updated for static methods and contains "this" otherwise.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    97
  //   Z_ARG3-Z_ARG5 contain the first 3 arguments of types other than float and double.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    98
  //   Z_FARG1-Z_FARG4 contain the first 4 arguments of type float or double.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    99
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   100
  const int LogSizeOfCase = 3;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   101
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   102
  const int max_fp_register_arguments   = Argument::n_float_register_parameters;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   103
  const int max_int_register_arguments  = Argument::n_register_parameters - 2;  // First 2 are reserved.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   104
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   105
  const Register arg_java       = Z_tmp_2;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   106
  const Register arg_c          = Z_tmp_3;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   107
  const Register signature      = Z_R1_scratch; // Is a string.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   108
  const Register fpcnt          = Z_R0_scratch;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   109
  const Register argcnt         = Z_tmp_4;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   110
  const Register intSlot        = Z_tmp_1;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   111
  const Register sig_end        = Z_tmp_1; // Assumed end of signature (only used in do_object).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   112
  const Register target_sp      = Z_tmp_1;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   113
  const FloatRegister floatSlot = Z_F1;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   114
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   115
  const int d_signature         = _z_abi(gpr6); // Only spill space, register contents not affected.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   116
  const int d_fpcnt             = _z_abi(gpr7); // Only spill space, register contents not affected.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   117
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   118
  unsigned int entry_offset = __ offset();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   119
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   120
  BLOCK_COMMENT("slow_signature_handler {");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   121
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   122
  // We use target_sp for storing arguments in the C frame.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   123
  __ save_return_pc();
46726
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46461
diff changeset
   124
  __ push_frame_abi160(4*BytesPerWord);                 // Reserve space to save the tmp_[1..4] registers.
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46461
diff changeset
   125
  __ z_stmg(Z_R10, Z_R13, frame::z_abi_160_size, Z_SP); // Save registers only after frame is pushed.
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   126
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   127
  __ z_lgr(arg_java, Z_ARG1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   128
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   129
  Register   method = Z_ARG2; // Directly load into correct argument register.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   130
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   131
  __ get_method(method);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   132
  __ call_VM_leaf(CAST_FROM_FN_PTR(address, InterpreterRuntime::get_signature), Z_thread, method);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   133
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   134
  // Move signature to callee saved register.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   135
  // Don't directly write to stack. Frame is used by VM call.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   136
  __ z_lgr(Z_tmp_1, Z_RET);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   137
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   138
  // Reload method. Register may have been altered by VM call.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   139
  __ get_method(method);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   140
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   141
  // Get address of result handler.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   142
  __ call_VM_leaf(CAST_FROM_FN_PTR(address, InterpreterRuntime::get_result_handler), Z_thread, method);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   143
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   144
  // Save signature address to stack.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   145
  __ z_stg(Z_tmp_1, d_signature, Z_SP);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   146
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   147
  // Don't overwrite return value (Z_RET, Z_ARG1) in rest of the method !
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   148
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   149
  {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   150
    Label   isStatic;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   151
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   152
    // Test if static.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   153
    // We can test the bit directly.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   154
    // Path is Z_method->_access_flags._flags.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   155
    // We only support flag bits in the least significant byte (assert !).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   156
    // Therefore add 3 to address that byte within "_flags".
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   157
    // Reload method. VM call above may have destroyed register contents
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   158
    __ get_method(method);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   159
    __ testbit(method2_(method, access_flags), JVM_ACC_STATIC_BIT);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   160
    method = noreg;  // end of life
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   161
    __ z_btrue(isStatic);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   162
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   163
    // For non-static functions, pass "this" in Z_ARG2 and copy it to 2nd C-arg slot.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   164
    // Need to box the Java object here, so we use arg_java
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   165
    // (address of current Java stack slot) as argument and
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   166
    // don't dereference it as in case of ints, floats, etc..
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   167
    __ z_lgr(Z_ARG2, arg_java);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   168
    __ add2reg(arg_java, -BytesPerWord);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   169
    __ bind(isStatic);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   170
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   171
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   172
  // argcnt == 0 corresponds to 3rd C argument.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   173
  //   arg #1 (result handler) and
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   174
  //   arg #2 (this, for non-statics), unused else
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   175
  // are reserved and pre-filled above.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   176
  // arg_java points to the corresponding Java argument here. It
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   177
  // has been decremented by one argument (this) in case of non-static.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   178
  __ clear_reg(argcnt, true, false);  // Don't set CC.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   179
  __ z_lg(target_sp, 0, Z_SP);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   180
  __ add2reg(arg_c, _z_abi(remaining_cargs), target_sp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   181
  // No floating-point args parsed so far.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   182
  __ clear_mem(Address(Z_SP, d_fpcnt), 8);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   183
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   184
  NearLabel   move_intSlot_to_ARG, move_floatSlot_to_FARG;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   185
  NearLabel   loop_start, loop_start_restore, loop_end;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   186
  NearLabel   do_int, do_long, do_float, do_double;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   187
  NearLabel   do_dontreachhere, do_object, do_array, do_boxed;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   188
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   189
#ifdef ASSERT
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   190
  // Signature needs to point to '(' (== 0x28) at entry.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   191
  __ z_lg(signature, d_signature, Z_SP);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   192
  __ z_cli(0, signature, (int) '(');
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   193
  __ z_brne(do_dontreachhere);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   194
#endif
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   195
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   196
  __ bind(loop_start_restore);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   197
  __ z_lg(signature, d_signature, Z_SP);  // Restore signature ptr, destroyed by move_XX_to_ARG.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   198
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   199
  BIND(loop_start);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   200
  // Advance to next argument type token from the signature.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   201
  __ add2reg(signature, 1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   202
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   203
  // Use CLI, works well on all CPU versions.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   204
    __ z_cli(0, signature, (int) ')');
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   205
    __ z_bre(loop_end);                // end of signature
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   206
    __ z_cli(0, signature, (int) 'L');
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   207
    __ z_bre(do_object);               // object     #9
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   208
    __ z_cli(0, signature, (int) 'F');
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   209
    __ z_bre(do_float);                // float      #7
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   210
    __ z_cli(0, signature, (int) 'J');
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   211
    __ z_bre(do_long);                 // long       #6
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   212
    __ z_cli(0, signature, (int) 'B');
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   213
    __ z_bre(do_int);                  // byte       #1
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   214
    __ z_cli(0, signature, (int) 'Z');
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   215
    __ z_bre(do_int);                  // boolean    #2
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   216
    __ z_cli(0, signature, (int) 'C');
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   217
    __ z_bre(do_int);                  // char       #3
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   218
    __ z_cli(0, signature, (int) 'S');
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   219
    __ z_bre(do_int);                  // short      #4
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   220
    __ z_cli(0, signature, (int) 'I');
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   221
    __ z_bre(do_int);                  // int        #5
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   222
    __ z_cli(0, signature, (int) 'D');
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   223
    __ z_bre(do_double);               // double     #8
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   224
    __ z_cli(0, signature, (int) '[');
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   225
    __ z_bre(do_array);                // array      #10
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   226
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   227
  __ bind(do_dontreachhere);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   228
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   229
  __ unimplemented("ShouldNotReachHere in slow_signature_handler", 120);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   230
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   231
  // Array argument
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   232
  BIND(do_array);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   233
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   234
  {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   235
    Label   start_skip, end_skip;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   236
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   237
    __ bind(start_skip);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   238
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   239
    // Advance to next type tag from signature.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   240
    __ add2reg(signature, 1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   241
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   242
    // Use CLI, works well on all CPU versions.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   243
    __ z_cli(0, signature, (int) '[');
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   244
    __ z_bre(start_skip);               // Skip further brackets.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   245
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   246
    __ z_cli(0, signature, (int) '9');
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   247
    __ z_brh(end_skip);                 // no optional size
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   248
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   249
    __ z_cli(0, signature, (int) '0');
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   250
    __ z_brnl(start_skip);              // Skip optional size.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   251
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   252
    __ bind(end_skip);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   253
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   254
    __ z_cli(0, signature, (int) 'L');
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   255
    __ z_brne(do_boxed);                // If not array of objects: go directly to do_boxed.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   256
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   257
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   258
  //  OOP argument
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   259
  BIND(do_object);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   260
  // Pass by an object's type name.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   261
  {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   262
    Label   L;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   263
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   264
    __ add2reg(sig_end, 4095, signature);     // Assume object type name is shorter than 4k.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   265
    __ load_const_optimized(Z_R0, (int) ';'); // Type name terminator (must be in Z_R0!).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   266
    __ MacroAssembler::search_string(sig_end, signature);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   267
    __ z_brl(L);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   268
    __ z_illtrap();  // No semicolon found: internal error or object name too long.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   269
    __ bind(L);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   270
    __ z_lgr(signature, sig_end);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   271
    // fallthru to do_boxed
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   272
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   273
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   274
  // Need to box the Java object here, so we use arg_java
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   275
  // (address of current Java stack slot) as argument and
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   276
  // don't dereference it as in case of ints, floats, etc..
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   277
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   278
  // UNBOX argument
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   279
  // Load reference and check for NULL.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   280
  Label  do_int_Entry4Boxed;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   281
  __ bind(do_boxed);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   282
  {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   283
    __ load_and_test_long(intSlot, Address(arg_java));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   284
    __ z_bre(do_int_Entry4Boxed);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   285
    __ z_lgr(intSlot, arg_java);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   286
    __ z_bru(do_int_Entry4Boxed);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   287
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   288
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   289
  // INT argument
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   290
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   291
  // (also for byte, boolean, char, short)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   292
  // Use lgf for load (sign-extend) and stg for store.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   293
  BIND(do_int);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   294
  __ z_lgf(intSlot, 0, arg_java);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   295
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   296
  __ bind(do_int_Entry4Boxed);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   297
  __ add2reg(arg_java, -BytesPerWord);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   298
  // If argument fits into argument register, go and handle it, otherwise continue.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   299
  __ compare32_and_branch(argcnt, max_int_register_arguments,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   300
                          Assembler::bcondLow, move_intSlot_to_ARG);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   301
  __ z_stg(intSlot, 0, arg_c);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   302
  __ add2reg(arg_c, BytesPerWord);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   303
  __ z_bru(loop_start);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   304
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   305
  // LONG argument
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   306
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   307
  BIND(do_long);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   308
  __ add2reg(arg_java, -2*BytesPerWord);  // Decrement first to have positive displacement for lg.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   309
  __ z_lg(intSlot, BytesPerWord, arg_java);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   310
  // If argument fits into argument register, go and handle it, otherwise continue.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   311
  __ compare32_and_branch(argcnt, max_int_register_arguments,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   312
                          Assembler::bcondLow, move_intSlot_to_ARG);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   313
  __ z_stg(intSlot, 0, arg_c);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   314
  __ add2reg(arg_c, BytesPerWord);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   315
  __ z_bru(loop_start);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   316
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   317
  // FLOAT argumen
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   318
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   319
  BIND(do_float);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   320
  __ z_le(floatSlot, 0, arg_java);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   321
  __ add2reg(arg_java, -BytesPerWord);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   322
  assert(max_fp_register_arguments <= 255, "always true");  // safety net
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   323
  __ z_cli(d_fpcnt+7, Z_SP, max_fp_register_arguments);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   324
  __ z_brl(move_floatSlot_to_FARG);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   325
  __ z_ste(floatSlot, 4, arg_c);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   326
  __ add2reg(arg_c, BytesPerWord);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   327
  __ z_bru(loop_start);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   328
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   329
  // DOUBLE argument
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   330
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   331
  BIND(do_double);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   332
  __ add2reg(arg_java, -2*BytesPerWord);  // Decrement first to have positive displacement for lg.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   333
  __ z_ld(floatSlot, BytesPerWord, arg_java);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   334
  assert(max_fp_register_arguments <= 255, "always true");  // safety net
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   335
  __ z_cli(d_fpcnt+7, Z_SP, max_fp_register_arguments);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   336
  __ z_brl(move_floatSlot_to_FARG);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   337
  __ z_std(floatSlot, 0, arg_c);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   338
  __ add2reg(arg_c, BytesPerWord);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   339
  __ z_bru(loop_start);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   340
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   341
  // Method exit, all arguments proocessed.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   342
  __ bind(loop_end);
46726
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46461
diff changeset
   343
  __ z_lmg(Z_R10, Z_R13, frame::z_abi_160_size, Z_SP); // restore registers before frame is popped.
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   344
  __ pop_frame();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   345
  __ restore_return_pc();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   346
  __ z_br(Z_R14);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   347
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   348
  // Copy int arguments.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   349
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   350
  Label  iarg_caselist;   // Distance between each case has to be a power of 2
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   351
                          // (= 1 << LogSizeOfCase).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   352
  __ align(16);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   353
  BIND(iarg_caselist);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   354
  __ z_lgr(Z_ARG3, intSlot);    // 4 bytes
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   355
  __ z_bru(loop_start_restore); // 4 bytes
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   356
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   357
  __ z_lgr(Z_ARG4, intSlot);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   358
  __ z_bru(loop_start_restore);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   359
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   360
  __ z_lgr(Z_ARG5, intSlot);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   361
  __ z_bru(loop_start_restore);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   362
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   363
  __ align(16);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   364
  __ bind(move_intSlot_to_ARG);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   365
  __ z_stg(signature, d_signature, Z_SP);       // Spill since signature == Z_R1_scratch.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   366
  __ z_larl(Z_R1_scratch, iarg_caselist);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   367
  __ z_sllg(Z_R0_scratch, argcnt, LogSizeOfCase);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   368
  __ add2reg(argcnt, 1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   369
  __ z_agr(Z_R1_scratch, Z_R0_scratch);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   370
  __ z_bcr(Assembler::bcondAlways, Z_R1_scratch);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   371
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   372
  // Copy float arguments.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   373
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   374
  Label  farg_caselist;   // Distance between each case has to be a power of 2
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   375
                          // (= 1 << logSizeOfCase, padded with nop.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   376
  __ align(16);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   377
  BIND(farg_caselist);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   378
  __ z_ldr(Z_FARG1, floatSlot); // 2 bytes
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   379
  __ z_bru(loop_start_restore); // 4 bytes
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   380
  __ z_nop();                   // 2 bytes
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   381
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   382
  __ z_ldr(Z_FARG2, floatSlot);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   383
  __ z_bru(loop_start_restore);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   384
  __ z_nop();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   385
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   386
  __ z_ldr(Z_FARG3, floatSlot);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   387
  __ z_bru(loop_start_restore);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   388
  __ z_nop();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   389
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   390
  __ z_ldr(Z_FARG4, floatSlot);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   391
  __ z_bru(loop_start_restore);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   392
  __ z_nop();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   393
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   394
  __ align(16);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   395
  __ bind(move_floatSlot_to_FARG);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   396
  __ z_stg(signature, d_signature, Z_SP);        // Spill since signature == Z_R1_scratch.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   397
  __ z_lg(Z_R0_scratch, d_fpcnt, Z_SP);          // Need old value for indexing.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   398
  __ add2mem_64(Address(Z_SP, d_fpcnt), 1, Z_R1_scratch); // Increment index.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   399
  __ z_larl(Z_R1_scratch, farg_caselist);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   400
  __ z_sllg(Z_R0_scratch, Z_R0_scratch, LogSizeOfCase);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   401
  __ z_agr(Z_R1_scratch, Z_R0_scratch);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   402
  __ z_bcr(Assembler::bcondAlways, Z_R1_scratch);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   403
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   404
  BLOCK_COMMENT("} slow_signature_handler");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   405
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   406
  return __ addr_at(entry_offset);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   407
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   408
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   409
address TemplateInterpreterGenerator::generate_result_handler_for (BasicType type) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   410
  address entry = __ pc();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   411
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   412
  assert(Z_tos == Z_RET, "Result handler: must move result!");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   413
  assert(Z_ftos == Z_FRET, "Result handler: must move float result!");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   414
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   415
  switch (type) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   416
    case T_BOOLEAN:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   417
      __ c2bool(Z_tos);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   418
      break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   419
    case T_CHAR:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   420
      __ and_imm(Z_tos, 0xffff);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   421
      break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   422
    case T_BYTE:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   423
      __ z_lbr(Z_tos, Z_tos);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   424
      break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   425
    case T_SHORT:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   426
      __ z_lhr(Z_tos, Z_tos);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   427
      break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   428
    case T_INT:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   429
    case T_LONG:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   430
    case T_VOID:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   431
    case T_FLOAT:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   432
    case T_DOUBLE:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   433
      break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   434
    case T_OBJECT:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   435
      // Retrieve result from frame...
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   436
      __ mem2reg_opt(Z_tos, Address(Z_fp, oop_tmp_offset));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   437
      // and verify it.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   438
      __ verify_oop(Z_tos);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   439
      break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   440
    default:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   441
      ShouldNotReachHere();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   442
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   443
  __ z_br(Z_R14);      // Return from result handler.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   444
  return entry;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   445
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   446
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   447
// Abstract method entry.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   448
// Attempt to execute abstract method. Throw exception.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   449
address TemplateInterpreterGenerator::generate_abstract_entry(void) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   450
  unsigned int entry_offset = __ offset();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   451
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   452
  // Caller could be the call_stub or a compiled method (x86 version is wrong!).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   453
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   454
  BLOCK_COMMENT("abstract_entry {");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   455
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   456
  // Implement call of InterpreterRuntime::throw_AbstractMethodError.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   457
  __ set_top_ijava_frame_at_SP_as_last_Java_frame(Z_SP, Z_R1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   458
  __ save_return_pc();       // Save Z_R14.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   459
  __ push_frame_abi160(0);   // Without new frame the RT call could overwrite the saved Z_R14.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   460
49368
2ed1c37df3a5 8197405: Improve messages of AbstractMethodErrors and IncompatibleClassChangeErrors.
goetz
parents: 48332
diff changeset
   461
  __ call_VM_leaf(CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_AbstractMethodErrorWithMethod),
2ed1c37df3a5 8197405: Improve messages of AbstractMethodErrors and IncompatibleClassChangeErrors.
goetz
parents: 48332
diff changeset
   462
                  Z_thread, Z_method);
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   463
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   464
  __ pop_frame();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   465
  __ restore_return_pc();    // Restore Z_R14.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   466
  __ reset_last_Java_frame();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   467
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   468
  // Restore caller sp for c2i case.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   469
  __ resize_frame_absolute(Z_R10, Z_R0, true); // Cut the stack back to where the caller started.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   470
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   471
  // branch to SharedRuntime::generate_forward_exception() which handles all possible callers,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   472
  // i.e. call stub, compiled method, interpreted method.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   473
  __ load_absolute_address(Z_tmp_1, StubRoutines::forward_exception_entry());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   474
  __ z_br(Z_tmp_1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   475
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   476
  BLOCK_COMMENT("} abstract_entry");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   477
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   478
  return __ addr_at(entry_offset);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   479
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   480
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   481
address TemplateInterpreterGenerator::generate_Reference_get_entry(void) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   482
#if INCLUDE_ALL_GCS
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   483
  if (UseG1GC) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   484
    // Inputs:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   485
    //  Z_ARG1 - receiver
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   486
    //
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   487
    // What we do:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   488
    //  - Load the referent field address.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   489
    //  - Load the value in the referent field.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   490
    //  - Pass that value to the pre-barrier.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   491
    //
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   492
    // In the case of G1 this will record the value of the
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   493
    // referent in an SATB buffer if marking is active.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   494
    // This will cause concurrent marking to mark the referent
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   495
    // field as live.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   496
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   497
    Register  scratch1 = Z_tmp_2;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   498
    Register  scratch2 = Z_tmp_3;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   499
    Register  pre_val  = Z_RET;   // return value
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   500
    // Z_esp is callers operand stack pointer, i.e. it points to the parameters.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   501
    Register  Rargp    = Z_esp;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   502
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   503
    Label     slow_path;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   504
    address   entry = __ pc();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   505
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   506
    const int referent_offset = java_lang_ref_Reference::referent_offset;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   507
    guarantee(referent_offset > 0, "referent offset not initialized");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   508
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   509
    BLOCK_COMMENT("Reference_get {");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   510
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   511
    //  If the receiver is null then it is OK to jump to the slow path.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   512
    __ load_and_test_long(pre_val, Address(Rargp, Interpreter::stackElementSize)); // Get receiver.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   513
    __ z_bre(slow_path);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   514
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   515
    //  Load the value of the referent field.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   516
    __ load_heap_oop(pre_val, referent_offset, pre_val);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   517
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   518
    // Restore caller sp for c2i case.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   519
    __ resize_frame_absolute(Z_R10, Z_R0, true); // Cut the stack back to where the caller started.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   520
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   521
    // Generate the G1 pre-barrier code to log the value of
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   522
    // the referent field in an SATB buffer.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   523
    // Note:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   524
    //   With these parameters the write_barrier_pre does not
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   525
    //   generate instructions to load the previous value.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   526
    __ g1_write_barrier_pre(noreg,      // obj
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   527
                            noreg,      // offset
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   528
                            pre_val,    // pre_val
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   529
                            noreg,      // no new val to preserve
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   530
                            scratch1,   // tmp
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   531
                            scratch2,   // tmp
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   532
                            true);      // pre_val_needed
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   533
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   534
    __ z_br(Z_R14);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   535
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   536
    // Branch to previously generated regular method entry.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   537
    __ bind(slow_path);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   538
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   539
    address meth_entry = Interpreter::entry_for_kind(Interpreter::zerolocals);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   540
    __ jump_to_entry(meth_entry, Z_R1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   541
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   542
    BLOCK_COMMENT("} Reference_get");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   543
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   544
    return entry;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   545
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   546
#endif // INCLUDE_ALL_GCS
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   547
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   548
  return NULL;
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
address TemplateInterpreterGenerator::generate_StackOverflowError_handler() {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   552
  address entry = __ pc();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   553
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   554
  DEBUG_ONLY(__ verify_esp(Z_esp, Z_ARG5));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   555
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   556
  // Restore bcp under the assumption that the current frame is still
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   557
  // interpreted.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   558
  __ restore_bcp();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   559
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   560
  // Expression stack must be empty before entering the VM if an
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   561
  // exception happened.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   562
  __ empty_expression_stack();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   563
  // Throw exception.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   564
  __ call_VM(noreg,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   565
             CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_StackOverflowError));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   566
  return entry;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   567
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   568
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   569
//
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   570
// Args:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   571
//   Z_ARG3: aberrant index
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   572
//
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   573
address TemplateInterpreterGenerator::generate_ArrayIndexOutOfBounds_handler(const char * name) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   574
  address entry = __ pc();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   575
  address excp = CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_ArrayIndexOutOfBoundsException);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   576
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   577
  // Expression stack must be empty before entering the VM if an
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   578
  // exception happened.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   579
  __ empty_expression_stack();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   580
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   581
  // Setup parameters.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   582
  // Leave out the name and use register for array to create more detailed exceptions.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   583
  __ load_absolute_address(Z_ARG2, (address) name);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   584
  __ call_VM(noreg, excp, Z_ARG2, Z_ARG3);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   585
  return entry;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   586
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   587
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   588
address TemplateInterpreterGenerator::generate_ClassCastException_handler() {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   589
  address entry = __ pc();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   590
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   591
  // Object is at TOS.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   592
  __ pop_ptr(Z_ARG2);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   593
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   594
  // Expression stack must be empty before entering the VM if an
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   595
  // exception happened.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   596
  __ empty_expression_stack();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   597
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   598
  __ call_VM(Z_ARG1,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   599
             CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_ClassCastException),
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   600
             Z_ARG2);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   601
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   602
  DEBUG_ONLY(__ should_not_reach_here();)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   603
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   604
  return entry;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   605
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   606
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   607
address TemplateInterpreterGenerator::generate_exception_handler_common(const char* name, const char* message, bool pass_oop) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   608
  assert(!pass_oop || message == NULL, "either oop or message but not both");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   609
  address entry = __ pc();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   610
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   611
  BLOCK_COMMENT("exception_handler_common {");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   612
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   613
  // Expression stack must be empty before entering the VM if an
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   614
  // exception happened.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   615
  __ empty_expression_stack();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   616
  if (name != NULL) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   617
    __ load_absolute_address(Z_ARG2, (address)name);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   618
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   619
    __ clear_reg(Z_ARG2, true, false);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   620
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   621
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   622
  if (pass_oop) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   623
    __ call_VM(Z_tos,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   624
               CAST_FROM_FN_PTR(address, InterpreterRuntime::create_klass_exception),
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   625
               Z_ARG2, Z_tos /*object (see TT::aastore())*/);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   626
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   627
    if (message != NULL) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   628
      __ load_absolute_address(Z_ARG3, (address)message);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   629
    } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   630
      __ clear_reg(Z_ARG3, true, false);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   631
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   632
    __ call_VM(Z_tos,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   633
               CAST_FROM_FN_PTR(address, InterpreterRuntime::create_exception),
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   634
               Z_ARG2, Z_ARG3);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   635
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   636
  // Throw exception.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   637
  __ load_absolute_address(Z_R1_scratch, Interpreter::throw_exception_entry());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   638
  __ z_br(Z_R1_scratch);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   639
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   640
  BLOCK_COMMENT("} exception_handler_common");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   641
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   642
  return entry;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   643
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   644
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   645
address TemplateInterpreterGenerator::generate_return_entry_for (TosState state, int step, size_t index_size) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   646
  address entry = __ pc();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   647
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   648
  BLOCK_COMMENT("return_entry {");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   649
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   650
  // Pop i2c extension or revert top-2-parent-resize done by interpreted callees.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   651
  Register sp_before_i2c_extension = Z_bcp;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   652
  __ z_lg(Z_fp, _z_abi(callers_sp), Z_SP); // Restore frame pointer.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   653
  __ z_lg(sp_before_i2c_extension, Address(Z_fp, _z_ijava_state_neg(top_frame_sp)));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   654
  __ resize_frame_absolute(sp_before_i2c_extension, Z_locals/*tmp*/, true/*load_fp*/);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   655
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   656
  // TODO(ZASM): necessary??
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   657
  //  // and NULL it as marker that esp is now tos until next java call
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   658
  //  __ movptr(Address(rbp, frame::interpreter_frame_last_sp_offset * wordSize), (int32_t)NULL_WORD);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   659
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   660
  __ restore_bcp();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   661
  __ restore_locals();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   662
  __ restore_esp();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   663
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   664
  if (state == atos) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   665
    __ profile_return_type(Z_tmp_1, Z_tos, Z_tmp_2);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   666
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   667
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   668
  Register cache  = Z_tmp_1;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   669
  Register size   = Z_tmp_1;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   670
  Register offset = Z_tmp_2;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   671
  const int flags_offset = in_bytes(ConstantPoolCache::base_offset() +
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   672
                                    ConstantPoolCacheEntry::flags_offset());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   673
  __ get_cache_and_index_at_bcp(cache, offset, 1, index_size);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   674
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   675
  // #args is in rightmost byte of the _flags field.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   676
  __ z_llgc(size, Address(cache, offset, flags_offset+(sizeof(size_t)-1)));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   677
  __ z_sllg(size, size, Interpreter::logStackElementSize); // Each argument size in bytes.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   678
  __ z_agr(Z_esp, size);                                   // Pop arguments.
46294
345a46524a19 8172020: Internal Error (cpu/arm/vm/frame_arm.cpp:571): assert(obj == __null || Universe::heap()->is_in(obj)) failed: sanity check #
cjplummer
parents: 46289
diff changeset
   679
345a46524a19 8172020: Internal Error (cpu/arm/vm/frame_arm.cpp:571): assert(obj == __null || Universe::heap()->is_in(obj)) failed: sanity check #
cjplummer
parents: 46289
diff changeset
   680
  __ check_and_handle_popframe(Z_thread);
345a46524a19 8172020: Internal Error (cpu/arm/vm/frame_arm.cpp:571): assert(obj == __null || Universe::heap()->is_in(obj)) failed: sanity check #
cjplummer
parents: 46289
diff changeset
   681
  __ check_and_handle_earlyret(Z_thread);
345a46524a19 8172020: Internal Error (cpu/arm/vm/frame_arm.cpp:571): assert(obj == __null || Universe::heap()->is_in(obj)) failed: sanity check #
cjplummer
parents: 46289
diff changeset
   682
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   683
  __ dispatch_next(state, step);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   684
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   685
  BLOCK_COMMENT("} return_entry");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   686
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   687
  return entry;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   688
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   689
49368
2ed1c37df3a5 8197405: Improve messages of AbstractMethodErrors and IncompatibleClassChangeErrors.
goetz
parents: 48332
diff changeset
   690
address TemplateInterpreterGenerator::generate_deopt_entry_for(TosState state,
47916
bdbef8638948 8190817: deopt special-case for _return_register_finalizer is confusing and leads to bugs
dlong
parents: 47762
diff changeset
   691
                                                               int step,
bdbef8638948 8190817: deopt special-case for _return_register_finalizer is confusing and leads to bugs
dlong
parents: 47762
diff changeset
   692
                                                               address continuation) {
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   693
  address entry = __ pc();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   694
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   695
  BLOCK_COMMENT("deopt_entry {");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   696
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   697
  // TODO(ZASM): necessary? NULL last_sp until next java call
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   698
  // __ movptr(Address(rbp, frame::interpreter_frame_last_sp_offset * wordSize), (int32_t)NULL_WORD);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   699
  __ z_lg(Z_fp, _z_abi(callers_sp), Z_SP); // Restore frame pointer.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   700
  __ restore_bcp();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   701
  __ restore_locals();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   702
  __ restore_esp();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   703
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   704
  // Handle exceptions.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   705
  {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   706
    Label L;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   707
    __ load_and_test_long(Z_R0/*pending_exception*/, thread_(pending_exception));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   708
    __ z_bre(L);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   709
    __ call_VM(noreg,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   710
               CAST_FROM_FN_PTR(address,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   711
                                InterpreterRuntime::throw_pending_exception));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   712
    __ should_not_reach_here();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   713
    __ bind(L);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   714
  }
47916
bdbef8638948 8190817: deopt special-case for _return_register_finalizer is confusing and leads to bugs
dlong
parents: 47762
diff changeset
   715
  if (continuation == NULL) {
bdbef8638948 8190817: deopt special-case for _return_register_finalizer is confusing and leads to bugs
dlong
parents: 47762
diff changeset
   716
    __ dispatch_next(state, step);
bdbef8638948 8190817: deopt special-case for _return_register_finalizer is confusing and leads to bugs
dlong
parents: 47762
diff changeset
   717
  } else {
bdbef8638948 8190817: deopt special-case for _return_register_finalizer is confusing and leads to bugs
dlong
parents: 47762
diff changeset
   718
    __ jump_to_entry(continuation, Z_R1_scratch);
bdbef8638948 8190817: deopt special-case for _return_register_finalizer is confusing and leads to bugs
dlong
parents: 47762
diff changeset
   719
  }
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   720
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   721
  BLOCK_COMMENT("} deopt_entry");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   722
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   723
  return entry;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   724
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   725
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   726
address TemplateInterpreterGenerator::generate_safept_entry_for (TosState state,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   727
                                                                address runtime_entry) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   728
  address entry = __ pc();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   729
  __ push(state);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   730
  __ call_VM(noreg, runtime_entry);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   731
  __ dispatch_via(vtos, Interpreter::_normal_table.table_for (vtos));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   732
  return entry;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   733
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   734
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   735
//
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   736
// Helpers for commoning out cases in the various type of method entries.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   737
//
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   738
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   739
// Increment invocation count & check for overflow.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   740
//
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   741
// Note: checking for negative value instead of overflow
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   742
// so we have a 'sticky' overflow test.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   743
//
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   744
// Z_ARG2: method (see generate_fixed_frame())
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   745
//
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   746
void TemplateInterpreterGenerator::generate_counter_incr(Label* overflow, Label* profile_method, Label* profile_method_continue) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   747
  Label done;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   748
  Register method = Z_ARG2; // Generate_fixed_frame() copies Z_method into Z_ARG2.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   749
  Register m_counters = Z_ARG4;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   750
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   751
  BLOCK_COMMENT("counter_incr {");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   752
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   753
  // Note: In tiered we increment either counters in method or in MDO depending
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   754
  // if we are profiling or not.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   755
  if (TieredCompilation) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   756
    int increment = InvocationCounter::count_increment;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   757
    if (ProfileInterpreter) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   758
      NearLabel no_mdo;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   759
      Register mdo = m_counters;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   760
      // Are we profiling?
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   761
      __ load_and_test_long(mdo, method2_(method, method_data));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   762
      __ branch_optimized(Assembler::bcondZero, no_mdo);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   763
      // Increment counter in the MDO.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   764
      const Address mdo_invocation_counter(mdo, MethodData::invocation_counter_offset() +
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   765
                                           InvocationCounter::counter_offset());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   766
      const Address mask(mdo, MethodData::invoke_mask_offset());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   767
      __ increment_mask_and_jump(mdo_invocation_counter, increment, mask,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   768
                                 Z_R1_scratch, false, Assembler::bcondZero,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   769
                                 overflow);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   770
      __ z_bru(done);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   771
      __ bind(no_mdo);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   772
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   773
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   774
    // Increment counter in MethodCounters.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   775
    const Address invocation_counter(m_counters,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   776
                                     MethodCounters::invocation_counter_offset() +
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   777
                                     InvocationCounter::counter_offset());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   778
    // Get address of MethodCounters object.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   779
    __ get_method_counters(method, m_counters, done);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   780
    const Address mask(m_counters, MethodCounters::invoke_mask_offset());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   781
    __ increment_mask_and_jump(invocation_counter,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   782
                               increment, mask,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   783
                               Z_R1_scratch, false, Assembler::bcondZero,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   784
                               overflow);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   785
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   786
    Register counter_sum = Z_ARG3; // The result of this piece of code.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   787
    Register tmp         = Z_R1_scratch;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   788
#ifdef ASSERT
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   789
    {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   790
      NearLabel ok;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   791
      __ get_method(tmp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   792
      __ compare64_and_branch(method, tmp, Assembler::bcondEqual, ok);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   793
      __ z_illtrap(0x66);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   794
      __ bind(ok);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   795
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   796
#endif
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   797
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   798
    // Get address of MethodCounters object.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   799
    __ get_method_counters(method, m_counters, done);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   800
    // Update standard invocation counters.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   801
    __ increment_invocation_counter(m_counters, counter_sum);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   802
    if (ProfileInterpreter) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   803
      __ add2mem_32(Address(m_counters, MethodCounters::interpreter_invocation_counter_offset()), 1, tmp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   804
      if (profile_method != NULL) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   805
        const Address profile_limit(m_counters, MethodCounters::interpreter_profile_limit_offset());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   806
        __ z_cl(counter_sum, profile_limit);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   807
        __ branch_optimized(Assembler::bcondLow, *profile_method_continue);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   808
        // If no method data exists, go to profile_method.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   809
        __ test_method_data_pointer(tmp, *profile_method);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   810
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   811
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   812
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   813
    const Address invocation_limit(m_counters, MethodCounters::interpreter_invocation_limit_offset());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   814
    __ z_cl(counter_sum, invocation_limit);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   815
    __ branch_optimized(Assembler::bcondNotLow, *overflow);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   816
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   817
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   818
  __ bind(done);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   819
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   820
  BLOCK_COMMENT("} counter_incr");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   821
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   822
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   823
void TemplateInterpreterGenerator::generate_counter_overflow(Label& do_continue) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   824
  // InterpreterRuntime::frequency_counter_overflow takes two
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   825
  // arguments, the first (thread) is passed by call_VM, the second
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   826
  // indicates if the counter overflow occurs at a backwards branch
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   827
  // (NULL bcp). We pass zero for it. The call returns the address
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   828
  // of the verified entry point for the method or NULL if the
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   829
  // compilation did not complete (either went background or bailed
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   830
  // out).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   831
  __ clear_reg(Z_ARG2);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   832
  __ call_VM(noreg,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   833
             CAST_FROM_FN_PTR(address, InterpreterRuntime::frequency_counter_overflow),
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   834
             Z_ARG2);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   835
  __ z_bru(do_continue);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   836
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   837
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   838
void TemplateInterpreterGenerator::generate_stack_overflow_check(Register frame_size, Register tmp1) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   839
  Register tmp2 = Z_R1_scratch;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   840
  const int page_size = os::vm_page_size();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   841
  NearLabel after_frame_check;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   842
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   843
  BLOCK_COMMENT("counter_overflow {");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   844
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   845
  assert_different_registers(frame_size, tmp1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   846
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   847
  // Stack banging is sufficient overflow check if frame_size < page_size.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   848
  if (Immediate::is_uimm(page_size, 15)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   849
    __ z_chi(frame_size, page_size);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   850
    __ z_brl(after_frame_check);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   851
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   852
    __ load_const_optimized(tmp1, page_size);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   853
    __ compareU32_and_branch(frame_size, tmp1, Assembler::bcondLow, after_frame_check);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   854
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   855
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   856
  // Get the stack base, and in debug, verify it is non-zero.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   857
  __ z_lg(tmp1, thread_(stack_base));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   858
#ifdef ASSERT
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   859
  address reentry = NULL;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   860
  NearLabel base_not_zero;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   861
  __ compareU64_and_branch(tmp1, (intptr_t)0L, Assembler::bcondNotEqual, base_not_zero);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   862
  reentry = __ stop_chain_static(reentry, "stack base is zero in generate_stack_overflow_check");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   863
  __ bind(base_not_zero);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   864
#endif
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   865
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   866
  // Get the stack size, and in debug, verify it is non-zero.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   867
  assert(sizeof(size_t) == sizeof(intptr_t), "wrong load size");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   868
  __ z_lg(tmp2, thread_(stack_size));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   869
#ifdef ASSERT
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   870
  NearLabel size_not_zero;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   871
  __ compareU64_and_branch(tmp2, (intptr_t)0L, Assembler::bcondNotEqual, size_not_zero);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   872
  reentry = __ stop_chain_static(reentry, "stack size is zero in generate_stack_overflow_check");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   873
  __ bind(size_not_zero);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   874
#endif
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   875
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   876
  // Compute the beginning of the protected zone minus the requested frame size.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   877
  __ z_sgr(tmp1, tmp2);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   878
  __ add2reg(tmp1, JavaThread::stack_guard_zone_size());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   879
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   880
  // Add in the size of the frame (which is the same as subtracting it from the
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   881
  // SP, which would take another register.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   882
  __ z_agr(tmp1, frame_size);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   883
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   884
  // The frame is greater than one page in size, so check against
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   885
  // the bottom of the stack.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   886
  __ compareU64_and_branch(Z_SP, tmp1, Assembler::bcondHigh, after_frame_check);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   887
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   888
  // The stack will overflow, throw an exception.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   889
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   890
  // Restore SP to sender's sp. This is necessary if the sender's frame is an
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   891
  // extended compiled frame (see gen_c2i_adapter()) and safer anyway in case of
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   892
  // JSR292 adaptations.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   893
  __ resize_frame_absolute(Z_R10, tmp1, true/*load_fp*/);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   894
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   895
  // Note also that the restored frame is not necessarily interpreted.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   896
  // Use the shared runtime version of the StackOverflowError.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   897
  assert(StubRoutines::throw_StackOverflowError_entry() != NULL, "stub not yet generated");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   898
  AddressLiteral stub(StubRoutines::throw_StackOverflowError_entry());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   899
  __ load_absolute_address(tmp1, StubRoutines::throw_StackOverflowError_entry());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   900
  __ z_br(tmp1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   901
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   902
  // If you get to here, then there is enough stack space.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   903
  __ bind(after_frame_check);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   904
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   905
  BLOCK_COMMENT("} counter_overflow");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   906
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   907
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   908
// Allocate monitor and lock method (asm interpreter).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   909
//
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   910
// Args:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   911
//   Z_locals: locals
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   912
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   913
void TemplateInterpreterGenerator::lock_method(void) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   914
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   915
  BLOCK_COMMENT("lock_method {");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   916
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   917
  // Synchronize method.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   918
  const Register method = Z_tmp_2;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   919
  __ get_method(method);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   920
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   921
#ifdef ASSERT
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   922
  address reentry = NULL;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   923
  {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   924
    Label L;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   925
    __ testbit(method2_(method, access_flags), JVM_ACC_SYNCHRONIZED_BIT);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   926
    __ z_btrue(L);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   927
    reentry = __ stop_chain_static(reentry, "method doesn't need synchronization");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   928
    __ bind(L);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   929
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   930
#endif // ASSERT
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   931
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   932
  // Get synchronization object.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   933
  const Register object = Z_tmp_2;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   934
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   935
  {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   936
    Label     done;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   937
    Label     static_method;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   938
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   939
    __ testbit(method2_(method, access_flags), JVM_ACC_STATIC_BIT);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   940
    __ z_btrue(static_method);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   941
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   942
    // non-static method: Load receiver obj from stack.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   943
    __ mem2reg_opt(object, Address(Z_locals, Interpreter::local_offset_in_bytes(0)));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   944
    __ z_bru(done);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   945
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   946
    __ bind(static_method);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   947
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   948
    // Lock the java mirror.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   949
    __ load_mirror(object, method);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   950
#ifdef ASSERT
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   951
    {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   952
      NearLabel L;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   953
      __ compare64_and_branch(object, (intptr_t) 0, Assembler::bcondNotEqual, L);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   954
      reentry = __ stop_chain_static(reentry, "synchronization object is NULL");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   955
      __ bind(L);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   956
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   957
#endif // ASSERT
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   958
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   959
    __ bind(done);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   960
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   961
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   962
  __ add_monitor_to_stack(true, Z_ARG3, Z_ARG4, Z_ARG5); // Allocate monitor elem.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   963
  // Store object and lock it.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   964
  __ get_monitors(Z_tmp_1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   965
  __ reg2mem_opt(object, Address(Z_tmp_1, BasicObjectLock::obj_offset_in_bytes()));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   966
  __ lock_object(Z_tmp_1, object);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   967
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   968
  BLOCK_COMMENT("} lock_method");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   969
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   970
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   971
// Generate a fixed interpreter frame. This is identical setup for
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   972
// interpreted methods and for native methods hence the shared code.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   973
//
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   974
// Registers alive
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   975
//   Z_thread   - JavaThread*
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   976
//   Z_SP       - old stack pointer
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   977
//   Z_method   - callee's method
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   978
//   Z_esp      - parameter list (slot 'above' last param)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   979
//   Z_R14      - return pc, to be stored in caller's frame
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   980
//   Z_R10      - sender sp, note: Z_tmp_1 is Z_R10!
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   981
//
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   982
// Registers updated
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   983
//   Z_SP       - new stack pointer
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   984
//   Z_esp      - callee's operand stack pointer
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   985
//                points to the slot above the value on top
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   986
//   Z_locals   - used to access locals: locals[i] := *(Z_locals - i*BytesPerWord)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   987
//   Z_bcp      - the bytecode pointer
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   988
//   Z_fp       - the frame pointer, thereby killing Z_method
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   989
//   Z_ARG2     - copy of Z_method
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   990
//
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   991
void TemplateInterpreterGenerator::generate_fixed_frame(bool native_call) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   992
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   993
  //  stack layout
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   994
  //
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   995
  //   F1 [TOP_IJAVA_FRAME_ABI]              <-- Z_SP, Z_R10 (see note below)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   996
  //      [F1's operand stack (unused)]
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   997
  //      [F1's outgoing Java arguments]     <-- Z_esp
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   998
  //      [F1's operand stack (non args)]
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   999
  //      [monitors]      (optional)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1000
  //      [IJAVA_STATE]
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1001
  //
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1002
  //   F2 [PARENT_IJAVA_FRAME_ABI]
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1003
  //      ...
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1004
  //
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1005
  //  0x000
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1006
  //
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1007
  // Note: Z_R10, the sender sp, will be below Z_SP if F1 was extended by a c2i adapter.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1008
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1009
  //=============================================================================
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1010
  // Allocate space for locals other than the parameters, the
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1011
  // interpreter state, monitors, and the expression stack.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1012
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1013
  const Register local_count     = Z_ARG5;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1014
  const Register fp              = Z_tmp_2;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1015
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1016
  BLOCK_COMMENT("generate_fixed_frame {");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1017
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1018
  {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1019
  // local registers
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1020
  const Register top_frame_size  = Z_ARG2;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1021
  const Register sp_after_resize = Z_ARG3;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1022
  const Register max_stack       = Z_ARG4;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1023
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1024
  // local_count = method->constMethod->max_locals();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1025
  __ z_lg(Z_R1_scratch, Address(Z_method, Method::const_offset()));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1026
  __ z_llgh(local_count, Address(Z_R1_scratch, ConstMethod::size_of_locals_offset()));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1027
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1028
  if (native_call) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1029
    // If we're calling a native method, we replace max_stack (which is
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1030
    // zero) with space for the worst-case signature handler varargs
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1031
    // vector, which is:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1032
    //   max_stack = max(Argument::n_register_parameters, parameter_count+2);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1033
    //
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1034
    // We add two slots to the parameter_count, one for the jni
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1035
    // environment and one for a possible native mirror. We allocate
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1036
    // space for at least the number of ABI registers, even though
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1037
    // InterpreterRuntime::slow_signature_handler won't write more than
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1038
    // parameter_count+2 words when it creates the varargs vector at the
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1039
    // top of the stack. The generated slow signature handler will just
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1040
    // load trash into registers beyond the necessary number. We're
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1041
    // still going to cut the stack back by the ABI register parameter
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1042
    // count so as to get SP+16 pointing at the ABI outgoing parameter
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1043
    // area, so we need to allocate at least that much even though we're
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1044
    // going to throw it away.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1045
    //
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1046
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1047
    __ z_lg(Z_R1_scratch, Address(Z_method, Method::const_offset()));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1048
    __ z_llgh(max_stack,  Address(Z_R1_scratch, ConstMethod::size_of_parameters_offset()));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1049
    __ add2reg(max_stack, 2);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1050
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1051
    NearLabel passing_args_on_stack;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1052
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1053
    // max_stack in bytes
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1054
    __ z_sllg(max_stack, max_stack, LogBytesPerWord);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1055
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1056
    int argument_registers_in_bytes = Argument::n_register_parameters << LogBytesPerWord;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1057
    __ compare64_and_branch(max_stack, argument_registers_in_bytes, Assembler::bcondNotLow, passing_args_on_stack);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1058
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1059
    __ load_const_optimized(max_stack, argument_registers_in_bytes);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1060
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1061
    __ bind(passing_args_on_stack);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1062
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1063
    // !native_call
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1064
    __ z_lg(max_stack, method_(const));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1066
    // Calculate number of non-parameter locals (in slots):
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1067
    __ z_lg(Z_R1_scratch, Address(Z_method, Method::const_offset()));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1068
    __ z_sh(local_count, Address(Z_R1_scratch, ConstMethod::size_of_parameters_offset()));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1069
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1070
    // max_stack = method->max_stack();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1071
    __ z_llgh(max_stack, Address(max_stack, ConstMethod::max_stack_offset()));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1072
    // max_stack in bytes
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1073
    __ z_sllg(max_stack, max_stack, LogBytesPerWord);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1074
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1075
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1076
  // Resize (i.e. normally shrink) the top frame F1 ...
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1077
  //   F1      [TOP_IJAVA_FRAME_ABI]          <-- Z_SP, Z_R10
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1078
  //           F1's operand stack (free)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1079
  //           ...
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1080
  //           F1's operand stack (free)      <-- Z_esp
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1081
  //           F1's outgoing Java arg m
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1082
  //           ...
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1083
  //           F1's outgoing Java arg 0
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1084
  //           ...
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1085
  //
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1086
  //  ... into a parent frame (Z_R10 holds F1's SP before any modification, see also above)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1087
  //
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1088
  //           +......................+
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1089
  //           :                      :        <-- Z_R10, saved below as F0's z_ijava_state.sender_sp
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1090
  //           :                      :
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1091
  //   F1      [PARENT_IJAVA_FRAME_ABI]        <-- Z_SP       \
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1092
  //           F0's non arg local                             | = delta
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1093
  //           ...                                            |
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1094
  //           F0's non arg local              <-- Z_esp      /
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1095
  //           F1's outgoing Java arg m
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1096
  //           ...
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1097
  //           F1's outgoing Java arg 0
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1098
  //           ...
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1099
  //
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1100
  // then push the new top frame F0.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1101
  //
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1102
  //   F0      [TOP_IJAVA_FRAME_ABI]    = frame::z_top_ijava_frame_abi_size \
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1103
  //           [operand stack]          = max_stack                          | = top_frame_size
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1104
  //           [IJAVA_STATE]            = frame::z_ijava_state_size         /
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1105
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1106
  // sp_after_resize = Z_esp - delta
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1107
  //
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1108
  // delta = PARENT_IJAVA_FRAME_ABI + (locals_count - params_count)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1109
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1110
  __ add2reg(sp_after_resize, (Interpreter::stackElementSize) - (frame::z_parent_ijava_frame_abi_size), Z_esp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1111
  __ z_sllg(Z_R0_scratch, local_count, LogBytesPerWord); // Params have already been subtracted from local_count.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1112
  __ z_slgr(sp_after_resize, Z_R0_scratch);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1113
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1114
  // top_frame_size = TOP_IJAVA_FRAME_ABI + max_stack + size of interpreter state
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1115
  __ add2reg(top_frame_size,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1116
             frame::z_top_ijava_frame_abi_size +
43420
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42897
diff changeset
  1117
             frame::z_ijava_state_size +
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42897
diff changeset
  1118
             frame::interpreter_frame_monitor_size() * wordSize,
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1119
             max_stack);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1120
43420
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42897
diff changeset
  1121
  if (!native_call) {
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42897
diff changeset
  1122
    // Stack overflow check.
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42897
diff changeset
  1123
    // Native calls don't need the stack size check since they have no
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42897
diff changeset
  1124
    // expression stack and the arguments are already on the stack and
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42897
diff changeset
  1125
    // we only add a handful of words to the stack.
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42897
diff changeset
  1126
    Register frame_size = max_stack; // Reuse the regiser for max_stack.
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42897
diff changeset
  1127
    __ z_lgr(frame_size, Z_SP);
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42897
diff changeset
  1128
    __ z_sgr(frame_size, sp_after_resize);
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42897
diff changeset
  1129
    __ z_agr(frame_size, top_frame_size);
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42897
diff changeset
  1130
    generate_stack_overflow_check(frame_size, fp/*tmp1*/);
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42897
diff changeset
  1131
  }
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1132
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1133
  DEBUG_ONLY(__ z_cg(Z_R14, _z_abi16(return_pc), Z_SP));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1134
  __ asm_assert_eq("killed Z_R14", 0);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1135
  __ resize_frame_absolute(sp_after_resize, fp, true);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1136
  __ save_return_pc(Z_R14);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1137
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1138
  // ... and push the new frame F0.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1139
  __ push_frame(top_frame_size, fp, true /*copy_sp*/, false);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1140
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1141
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1142
  //=============================================================================
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1143
  // Initialize the new frame F0: initialize interpreter state.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1144
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1145
  {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1146
  // locals
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1147
  const Register local_addr = Z_ARG4;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1148
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1149
  BLOCK_COMMENT("generate_fixed_frame: initialize interpreter state {");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1150
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1151
#ifdef ASSERT
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1152
  // Set the magic number (using local_addr as tmp register).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1153
  __ load_const_optimized(local_addr, frame::z_istate_magic_number);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1154
  __ z_stg(local_addr, _z_ijava_state_neg(magic), fp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1155
#endif
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1156
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1157
  // Save sender SP from F1 (i.e. before it was potentially modified by an
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1158
  // adapter) into F0's interpreter state. We us it as well to revert
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1159
  // resizing the frame above.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1160
  __ z_stg(Z_R10, _z_ijava_state_neg(sender_sp), fp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1161
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1162
  // Load cp cache and save it at the and of this block.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1163
  __ z_lg(Z_R1_scratch, Address(Z_method,    Method::const_offset()));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1164
  __ z_lg(Z_R1_scratch, Address(Z_R1_scratch, ConstMethod::constants_offset()));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1165
  __ z_lg(Z_R1_scratch, Address(Z_R1_scratch, ConstantPool::cache_offset_in_bytes()));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1166
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1167
  // z_ijava_state->method = method;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1168
  __ z_stg(Z_method, _z_ijava_state_neg(method), fp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1169
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1170
  // Point locals at the first argument. Method's locals are the
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1171
  // parameters on top of caller's expression stack.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1172
  // Tos points past last Java argument.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1173
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1174
  __ z_lg(Z_locals, Address(Z_method, Method::const_offset()));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1175
  __ z_llgh(Z_locals /*parameter_count words*/,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1176
            Address(Z_locals, ConstMethod::size_of_parameters_offset()));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1177
  __ z_sllg(Z_locals /*parameter_count bytes*/, Z_locals /*parameter_count*/, LogBytesPerWord);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1178
  __ z_agr(Z_locals, Z_esp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1179
  // z_ijava_state->locals - i*BytesPerWord points to i-th Java local (i starts at 0)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1180
  // z_ijava_state->locals = Z_esp + parameter_count bytes
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1181
  __ z_stg(Z_locals, _z_ijava_state_neg(locals), fp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1182
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1183
  // z_ijava_state->oop_temp = NULL;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1184
  __ store_const(Address(fp, oop_tmp_offset), 0);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1185
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1186
  // Initialize z_ijava_state->mdx.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1187
  Register Rmdp = Z_bcp;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1188
  // native_call: assert that mdo == NULL
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1189
  const bool check_for_mdo = !native_call DEBUG_ONLY(|| native_call);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1190
  if (ProfileInterpreter && check_for_mdo) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1191
    Label get_continue;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1192
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1193
    __ load_and_test_long(Rmdp, method_(method_data));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1194
    __ z_brz(get_continue);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1195
    DEBUG_ONLY(if (native_call) __ stop("native methods don't have a mdo"));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1196
    __ add2reg(Rmdp, in_bytes(MethodData::data_offset()));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1197
    __ bind(get_continue);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1198
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1199
  __ z_stg(Rmdp, _z_ijava_state_neg(mdx), fp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1200
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1201
  // Initialize z_ijava_state->bcp and Z_bcp.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1202
  if (native_call) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1203
    __ clear_reg(Z_bcp); // Must initialize. Will get written into frame where GC reads it.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1204
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1205
    __ z_lg(Z_bcp, method_(const));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1206
    __ add2reg(Z_bcp, in_bytes(ConstMethod::codes_offset()));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1207
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1208
  __ z_stg(Z_bcp, _z_ijava_state_neg(bcp), fp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1209
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1210
  // no monitors and empty operand stack
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1211
  // => z_ijava_state->monitors points to the top slot in IJAVA_STATE.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1212
  // => Z_ijava_state->esp points one slot above into the operand stack.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1213
  // z_ijava_state->monitors = fp - frame::z_ijava_state_size - Interpreter::stackElementSize;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1214
  // z_ijava_state->esp = Z_esp = z_ijava_state->monitors;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1215
  __ add2reg(Z_esp, -frame::z_ijava_state_size, fp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1216
  __ z_stg(Z_esp, _z_ijava_state_neg(monitors), fp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1217
  __ add2reg(Z_esp, -Interpreter::stackElementSize);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1218
  __ z_stg(Z_esp, _z_ijava_state_neg(esp), fp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1219
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1220
  // z_ijava_state->cpoolCache = Z_R1_scratch (see load above);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1221
  __ z_stg(Z_R1_scratch, _z_ijava_state_neg(cpoolCache), fp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1222
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1223
  // Get mirror and store it in the frame as GC root for this Method*.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1224
  __ load_mirror(Z_R1_scratch, Z_method);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1225
  __ z_stg(Z_R1_scratch, _z_ijava_state_neg(mirror), fp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1226
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1227
  BLOCK_COMMENT("} generate_fixed_frame: initialize interpreter state");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1228
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1229
  //=============================================================================
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1230
  if (!native_call) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1231
    // Fill locals with 0x0s.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1232
    NearLabel locals_zeroed;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1233
    NearLabel doXC;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1234
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1235
    // Local_count is already num_locals_slots - num_param_slots.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1236
    __ compare64_and_branch(local_count, (intptr_t)0L, Assembler::bcondNotHigh, locals_zeroed);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1237
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1238
    // Advance local_addr to point behind locals (creates positive incr. in loop).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1239
    __ z_lg(Z_R1_scratch, Address(Z_method, Method::const_offset()));
46726
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46461
diff changeset
  1240
    __ z_llgh(Z_R0_scratch, Address(Z_R1_scratch, ConstMethod::size_of_locals_offset()));
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46461
diff changeset
  1241
    __ add2reg(Z_R0_scratch, -1);
7801367e3cc9 8180659: [s390] micro-optimization in resize_frame_absolute()
lucy
parents: 46461
diff changeset
  1242
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1243
    __ z_lgr(local_addr/*locals*/, Z_locals);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1244
    __ z_sllg(Z_R0_scratch, Z_R0_scratch, LogBytesPerWord);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1245
    __ z_sllg(local_count, local_count, LogBytesPerWord); // Local_count are non param locals.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1246
    __ z_sgr(local_addr, Z_R0_scratch);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1247
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1248
    if (VM_Version::has_Prefetch()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1249
      __ z_pfd(0x02, 0, Z_R0, local_addr);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1250
      __ z_pfd(0x02, 256, Z_R0, local_addr);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1251
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1252
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1253
    // Can't optimise for Z10 using "compare and branch" (immediate value is too big).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1254
    __ z_cghi(local_count, 256);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1255
    __ z_brnh(doXC);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1256
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1257
    // MVCLE: Initialize if quite a lot locals.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1258
    //  __ bind(doMVCLE);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1259
    __ z_lgr(Z_R0_scratch, local_addr);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1260
    __ z_lgr(Z_R1_scratch, local_count);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1261
    __ clear_reg(Z_ARG2);        // Src len of MVCLE is zero.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1262
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1263
    __ MacroAssembler::move_long_ext(Z_R0_scratch, Z_ARG1, 0);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1264
    __ z_bru(locals_zeroed);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1265
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1266
    Label  XC_template;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1267
    __ bind(XC_template);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1268
    __ z_xc(0, 0, local_addr, 0, local_addr);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1269
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1270
    __ bind(doXC);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1271
    __ z_bctgr(local_count, Z_R0);                  // Get #bytes-1 for EXECUTE.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1272
    if (VM_Version::has_ExecuteExtensions()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1273
      __ z_exrl(local_count, XC_template);          // Execute XC with variable length.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1274
    } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1275
      __ z_larl(Z_R1_scratch, XC_template);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1276
      __ z_ex(local_count, 0, Z_R0, Z_R1_scratch);  // Execute XC with variable length.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1277
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1278
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1279
    __ bind(locals_zeroed);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1280
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1281
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1282
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1283
  // Finally set the frame pointer, destroying Z_method.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1284
  assert(Z_fp == Z_method, "maybe set Z_fp earlier if other register than Z_method");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1285
  // Oprofile analysis suggests to keep a copy in a register to be used by
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1286
  // generate_counter_incr().
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1287
  __ z_lgr(Z_ARG2, Z_method);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1288
  __ z_lgr(Z_fp, fp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1289
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1290
  BLOCK_COMMENT("} generate_fixed_frame");
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
// Various method entries
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1294
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1295
// Math function, frame manager must set up an interpreter state, etc.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1296
address TemplateInterpreterGenerator::generate_math_entry(AbstractInterpreter::MethodKind kind) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1297
42897
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1298
  // Decide what to do: Use same platform specific instructions and runtime calls as compilers.
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1299
  bool use_instruction = false;
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1300
  address runtime_entry = NULL;
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1301
  int num_args = 1;
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1302
  bool double_precision = true;
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1303
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1304
  // s390 specific:
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1305
  switch (kind) {
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1306
    case Interpreter::java_lang_math_sqrt:
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1307
    case Interpreter::java_lang_math_abs:  use_instruction = true; break;
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1308
    case Interpreter::java_lang_math_fmaF:
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1309
    case Interpreter::java_lang_math_fmaD: use_instruction = UseFMA; break;
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1310
    default: break; // Fall back to runtime call.
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1311
  }
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1312
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1313
  switch (kind) {
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1314
    case Interpreter::java_lang_math_sin  : runtime_entry = CAST_FROM_FN_PTR(address, SharedRuntime::dsin);   break;
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1315
    case Interpreter::java_lang_math_cos  : runtime_entry = CAST_FROM_FN_PTR(address, SharedRuntime::dcos);   break;
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1316
    case Interpreter::java_lang_math_tan  : runtime_entry = CAST_FROM_FN_PTR(address, SharedRuntime::dtan);   break;
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1317
    case Interpreter::java_lang_math_abs  : /* run interpreted */ break;
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1318
    case Interpreter::java_lang_math_sqrt : /* runtime_entry = CAST_FROM_FN_PTR(address, SharedRuntime::dsqrt); not available */ break;
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1319
    case Interpreter::java_lang_math_log  : runtime_entry = CAST_FROM_FN_PTR(address, SharedRuntime::dlog);   break;
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1320
    case Interpreter::java_lang_math_log10: runtime_entry = CAST_FROM_FN_PTR(address, SharedRuntime::dlog10); break;
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1321
    case Interpreter::java_lang_math_pow  : runtime_entry = CAST_FROM_FN_PTR(address, SharedRuntime::dpow); num_args = 2; break;
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1322
    case Interpreter::java_lang_math_exp  : runtime_entry = CAST_FROM_FN_PTR(address, SharedRuntime::dexp);   break;
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1323
    case Interpreter::java_lang_math_fmaF : /* run interpreted */ num_args = 3; double_precision = false; break;
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1324
    case Interpreter::java_lang_math_fmaD : /* run interpreted */ num_args = 3; break;
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1325
    default: ShouldNotReachHere();
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1326
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1327
42897
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1328
  // Use normal entry if neither instruction nor runtime call is used.
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1329
  if (!use_instruction && runtime_entry == NULL) return NULL;
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1330
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1331
  address entry = __ pc();
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1332
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1333
  if (use_instruction) {
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1334
    switch (kind) {
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1335
      case Interpreter::java_lang_math_sqrt:
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1336
        // Can use memory operand directly.
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1337
        __ z_sqdb(Z_FRET, Interpreter::stackElementSize, Z_esp);
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1338
        break;
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1339
      case Interpreter::java_lang_math_abs:
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1340
        // Load operand from stack.
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1341
        __ mem2freg_opt(Z_FRET, Address(Z_esp, Interpreter::stackElementSize));
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1342
        __ z_lpdbr(Z_FRET);
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1343
        break;
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1344
      case Interpreter::java_lang_math_fmaF:
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1345
        __ mem2freg_opt(Z_FRET,  Address(Z_esp,     Interpreter::stackElementSize)); // result reg = arg3
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1346
        __ mem2freg_opt(Z_FARG2, Address(Z_esp, 3 * Interpreter::stackElementSize)); // arg1
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1347
        __ z_maeb(Z_FRET, Z_FARG2, Address(Z_esp, 2 * Interpreter::stackElementSize));
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1348
        break;
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1349
      case Interpreter::java_lang_math_fmaD:
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1350
        __ mem2freg_opt(Z_FRET,  Address(Z_esp,     Interpreter::stackElementSize)); // result reg = arg3
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1351
        __ mem2freg_opt(Z_FARG2, Address(Z_esp, 5 * Interpreter::stackElementSize)); // arg1
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1352
        __ z_madb(Z_FRET, Z_FARG2, Address(Z_esp, 3 * Interpreter::stackElementSize));
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1353
        break;
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1354
      default: ShouldNotReachHere();
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1355
    }
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1356
  } else {
42897
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1357
    // Load arguments
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1358
    assert(num_args <= 4, "passed in registers");
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1359
    if (double_precision) {
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1360
      int offset = (2 * num_args - 1) * Interpreter::stackElementSize;
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1361
      for (int i = 0; i < num_args; ++i) {
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1362
        __ mem2freg_opt(as_FloatRegister(Z_FARG1->encoding() + 2 * i), Address(Z_esp, offset));
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1363
        offset -= 2 * Interpreter::stackElementSize;
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1364
      }
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1365
    } else {
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1366
      int offset = num_args * Interpreter::stackElementSize;
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1367
      for (int i = 0; i < num_args; ++i) {
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1368
        __ mem2freg_opt(as_FloatRegister(Z_FARG1->encoding() + 2 * i), Address(Z_esp, offset));
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1369
        offset -= Interpreter::stackElementSize;
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1370
      }
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1371
    }
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1372
    // Call runtime
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1373
    __ save_return_pc();       // Save Z_R14.
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1374
    __ push_frame_abi160(0);   // Without new frame the RT call could overwrite the saved Z_R14.
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1375
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1376
    __ call_VM_leaf(runtime_entry);
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1377
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1378
    __ pop_frame();
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1379
    __ restore_return_pc();    // Restore Z_R14.
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1380
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1381
42897
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1382
  // Pop c2i arguments (if any) off when we return.
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1383
  __ resize_frame_absolute(Z_R10, Z_R0, true); // Cut the stack back to where the caller started.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1384
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1385
  __ z_br(Z_R14);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1386
42897
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1387
  return entry;
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1388
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1389
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1390
// Interpreter stub for calling a native method. (asm interpreter).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1391
// This sets up a somewhat different looking stack for calling the
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1392
// native method than the typical interpreter frame setup.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1393
address TemplateInterpreterGenerator::generate_native_entry(bool synchronized) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1394
  // Determine code generation flags.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1395
  bool inc_counter = UseCompiler || CountCompiledCalls || LogTouchedMethods;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1396
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1397
  // Interpreter entry for ordinary Java methods.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1398
  //
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1399
  // Registers alive
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1400
  //   Z_SP          - stack pointer
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1401
  //   Z_thread      - JavaThread*
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1402
  //   Z_method      - callee's method (method to be invoked)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1403
  //   Z_esp         - operand (or expression) stack pointer of caller. one slot above last arg.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1404
  //   Z_R10         - sender sp (before modifications, e.g. by c2i adapter
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1405
  //                   and as well by generate_fixed_frame below)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1406
  //   Z_R14         - return address to caller (call_stub or c2i_adapter)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1407
  //
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1408
  // Registers updated
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1409
  //   Z_SP          - stack pointer
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1410
  //   Z_fp          - callee's framepointer
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1411
  //   Z_esp         - callee's operand stack pointer
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1412
  //                   points to the slot above the value on top
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1413
  //   Z_locals      - used to access locals: locals[i] := *(Z_locals - i*BytesPerWord)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1414
  //   Z_tos         - integer result, if any
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1415
  //   z_ftos        - floating point result, if any
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1416
  //
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1417
  // Stack layout at this point:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1418
  //
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1419
  //   F1      [TOP_IJAVA_FRAME_ABI]         <-- Z_SP, Z_R10 (Z_R10 will be below Z_SP if
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1420
  //                                                          frame was extended by c2i adapter)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1421
  //           [outgoing Java arguments]     <-- Z_esp
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1422
  //           ...
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1423
  //   PARENT  [PARENT_IJAVA_FRAME_ABI]
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1424
  //           ...
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1425
  //
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1426
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1427
  address entry_point = __ pc();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1428
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1429
  // Make sure registers are different!
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1430
  assert_different_registers(Z_thread, Z_method, Z_esp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1431
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1432
  BLOCK_COMMENT("native_entry {");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1433
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1434
  // Make sure method is native and not abstract.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1435
#ifdef ASSERT
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1436
  address reentry = NULL;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1437
  { Label L;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1438
    __ testbit(method_(access_flags), JVM_ACC_NATIVE_BIT);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1439
    __ z_btrue(L);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1440
    reentry = __ stop_chain_static(reentry, "tried to execute non-native method as native");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1441
    __ bind(L);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1442
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1443
  { Label L;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1444
    __ testbit(method_(access_flags), JVM_ACC_ABSTRACT_BIT);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1445
    __ z_bfalse(L);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1446
    reentry = __ stop_chain_static(reentry, "tried to execute abstract method as non-abstract");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1447
    __ bind(L);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1448
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1449
#endif // ASSERT
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1450
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1451
#ifdef ASSERT
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1452
  // Save the return PC into the callers frame for assertion in generate_fixed_frame.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1453
  __ save_return_pc(Z_R14);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1454
#endif
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1455
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1456
  // Generate the code to allocate the interpreter stack frame.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1457
  generate_fixed_frame(true);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1458
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1459
  const Address do_not_unlock_if_synchronized(Z_thread, JavaThread::do_not_unlock_if_synchronized_offset());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1460
  // Since at this point in the method invocation the exception handler
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1461
  // would try to exit the monitor of synchronized methods which hasn't
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1462
  // been entered yet, we set the thread local variable
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1463
  // _do_not_unlock_if_synchronized to true. If any exception was thrown by
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1464
  // runtime, exception handling i.e. unlock_if_synchronized_method will
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1465
  // check this thread local flag.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1466
  __ z_mvi(do_not_unlock_if_synchronized, true);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1467
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1468
  // Increment invocation count and check for overflow.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1469
  NearLabel invocation_counter_overflow;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1470
  if (inc_counter) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1471
    generate_counter_incr(&invocation_counter_overflow, NULL, NULL);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1472
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1473
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1474
  Label continue_after_compile;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1475
  __ bind(continue_after_compile);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1476
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1477
  bang_stack_shadow_pages(true);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1478
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1479
  // Reset the _do_not_unlock_if_synchronized flag.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1480
  __ z_mvi(do_not_unlock_if_synchronized, false);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1481
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1482
  // Check for synchronized methods.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1483
  // This mst happen AFTER invocation_counter check and stack overflow check,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1484
  // so method is not locked if overflows.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1485
  if (synchronized) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1486
    lock_method();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1487
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1488
    // No synchronization necessary.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1489
#ifdef ASSERT
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1490
    { Label L;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1491
      __ get_method(Z_R1_scratch);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1492
      __ testbit(method2_(Z_R1_scratch, access_flags), JVM_ACC_SYNCHRONIZED_BIT);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1493
      __ z_bfalse(L);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1494
      reentry = __ stop_chain_static(reentry, "method needs synchronization");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1495
      __ bind(L);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1496
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1497
#endif // ASSERT
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
  // start execution
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1501
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1502
  // jvmti support
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1503
  __ notify_method_entry();
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
  // Get and call the signature handler.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1507
  const Register Rmethod                 = Z_tmp_2;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1508
  const Register signature_handler_entry = Z_tmp_1;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1509
  const Register Rresult_handler         = Z_tmp_3;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1510
  Label call_signature_handler;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1511
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1512
  assert_different_registers(Z_fp, Rmethod, signature_handler_entry, Rresult_handler);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1513
  assert(Rresult_handler->is_nonvolatile(), "Rresult_handler must be in a non-volatile register");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1514
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1515
  // Reload method.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1516
  __ get_method(Rmethod);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1517
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1518
  // Check for signature handler.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1519
  __ load_and_test_long(signature_handler_entry, method2_(Rmethod, signature_handler));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1520
  __ z_brne(call_signature_handler);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1521
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1522
  // Method has never been called. Either generate a specialized
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1523
  // handler or point to the slow one.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1524
  __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::prepare_native_call),
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1525
             Rmethod);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1526
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1527
  // Reload method.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1528
  __ get_method(Rmethod);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1529
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1530
  // Reload signature handler, it must have been created/assigned in the meantime.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1531
  __ z_lg(signature_handler_entry, method2_(Rmethod, signature_handler));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1532
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1533
  __ bind(call_signature_handler);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1534
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1535
  // We have a TOP_IJAVA_FRAME here, which belongs to us.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1536
  __ set_top_ijava_frame_at_SP_as_last_Java_frame(Z_SP, Z_R1/*tmp*/);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1537
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1538
  // Call signature handler and pass locals address in Z_ARG1.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1539
  __ z_lgr(Z_ARG1, Z_locals);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1540
  __ call_stub(signature_handler_entry);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1541
  // Save result handler returned by signature handler.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1542
  __ z_lgr(Rresult_handler, Z_RET);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1543
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1544
  // Reload method (the slow signature handler may block for GC).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1545
  __ get_method(Rmethod);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1546
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1547
  // Pass mirror handle if static call.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1548
  {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1549
    Label method_is_not_static;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1550
    __ testbit(method2_(Rmethod, access_flags), JVM_ACC_STATIC_BIT);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1551
    __ z_bfalse(method_is_not_static);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1552
    // Get mirror.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1553
    __ load_mirror(Z_R1, Rmethod);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1554
    // z_ijava_state.oop_temp = pool_holder->klass_part()->java_mirror();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1555
    __ z_stg(Z_R1, oop_tmp_offset, Z_fp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1556
    // Pass handle to mirror as 2nd argument to JNI method.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1557
    __ add2reg(Z_ARG2, oop_tmp_offset, Z_fp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1558
    __ bind(method_is_not_static);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1559
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1560
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1561
  // Pass JNIEnv address as first parameter.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1562
  __ add2reg(Z_ARG1, in_bytes(JavaThread::jni_environment_offset()), Z_thread);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1563
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1564
  // Note: last java frame has been set above already. The pc from there
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1565
  // is precise enough.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1566
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1567
  // Get native function entry point before we change the thread state.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1568
  __ z_lg(Z_R1/*native_method_entry*/, method2_(Rmethod, native_function));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1569
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1570
  //=============================================================================
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1571
  // Transition from _thread_in_Java to _thread_in_native. As soon as
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1572
  // we make this change the safepoint code needs to be certain that
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1573
  // the last Java frame we established is good. The pc in that frame
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1574
  // just need to be near here not an actual return address.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1575
#ifdef ASSERT
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1576
  {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1577
    NearLabel L;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1578
    __ mem2reg_opt(Z_R14, Address(Z_thread, JavaThread::thread_state_offset()), false /*32 bits*/);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1579
    __ compareU32_and_branch(Z_R14, _thread_in_Java, Assembler::bcondEqual, L);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1580
    reentry = __ stop_chain_static(reentry, "Wrong thread state in native stub");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1581
    __ bind(L);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1582
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1583
#endif
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1584
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1585
  // Memory ordering: Z does not reorder store/load with subsequent load. That's strong enough.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1586
  __ set_thread_state(_thread_in_native);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1587
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1588
  //=============================================================================
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1589
  // Call the native method. Argument registers must not have been
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1590
  // overwritten since "__ call_stub(signature_handler);" (except for
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1591
  // ARG1 and ARG2 for static methods).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1592
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1593
  __ call_c(Z_R1/*native_method_entry*/);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1594
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1595
  // NOTE: frame::interpreter_frame_result() depends on these stores.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1596
  __ z_stg(Z_RET, _z_ijava_state_neg(lresult), Z_fp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1597
  __ freg2mem_opt(Z_FRET, Address(Z_fp, _z_ijava_state_neg(fresult)));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1598
  const Register Rlresult = signature_handler_entry;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1599
  assert(Rlresult->is_nonvolatile(), "Rlresult must be in a non-volatile register");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1600
  __ z_lgr(Rlresult, Z_RET);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1601
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1602
  // Z_method may no longer be valid, because of GC.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1603
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1604
  // Block, if necessary, before resuming in _thread_in_Java state.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1605
  // In order for GC to work, don't clear the last_Java_sp until after
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1606
  // blocking.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1607
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1608
  //=============================================================================
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1609
  // Switch thread to "native transition" state before reading the
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1610
  // synchronization state. This additional state is necessary
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1611
  // because reading and testing the synchronization state is not
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1612
  // atomic w.r.t. GC, as this scenario demonstrates: Java thread A,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1613
  // in _thread_in_native state, loads _not_synchronized and is
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1614
  // preempted. VM thread changes sync state to synchronizing and
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1615
  // suspends threads for GC. Thread A is resumed to finish this
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1616
  // native method, but doesn't block here since it didn't see any
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1617
  // synchronization is progress, and escapes.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1618
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1619
  __ set_thread_state(_thread_in_native_trans);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1620
  if (UseMembar) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1621
    __ z_fence();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1622
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1623
    // Write serialization page so VM thread can do a pseudo remote
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1624
    // membar. We use the current thread pointer to calculate a thread
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1625
    // specific offset to write to within the page. This minimizes bus
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1626
    // traffic due to cache line collision.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1627
    __ serialize_memory(Z_thread, Z_R1, Z_R0);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1628
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1629
  // Now before we return to java we must look for a current safepoint
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1630
  // (a new safepoint can not start since we entered native_trans).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1631
  // We must check here because a current safepoint could be modifying
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1632
  // the callers registers right this moment.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1633
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1634
  // Check for safepoint operation in progress and/or pending suspend requests.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1635
  {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1636
    Label Continue, do_safepoint;
48332
651a95f30dfb 8193257: PPC64, s390 implementation for Thread-local handshakes
mdoerr
parents: 47916
diff changeset
  1637
    __ safepoint_poll(do_safepoint, Z_R1);
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1638
    // Check for suspend.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1639
    __ load_and_test_int(Z_R0/*suspend_flags*/, thread_(suspend_flags));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1640
    __ z_bre(Continue); // 0 -> no flag set -> not suspended
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1641
    __ bind(do_safepoint);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1642
    __ z_lgr(Z_ARG1, Z_thread);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1643
    __ call_c(CAST_FROM_FN_PTR(address, JavaThread::check_special_condition_for_native_trans));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1644
    __ bind(Continue);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1645
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1646
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1647
  //=============================================================================
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1648
  // Back in Interpreter Frame.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1649
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1650
  // We are in thread_in_native_trans here and back in the normal
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1651
  // interpreter frame. We don't have to do anything special about
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1652
  // safepoints and we can switch to Java mode anytime we are ready.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1653
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1654
  // Note: frame::interpreter_frame_result has a dependency on how the
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1655
  // method result is saved across the call to post_method_exit. For
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1656
  // native methods it assumes that the non-FPU/non-void result is
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1657
  // saved in z_ijava_state.lresult and a FPU result in z_ijava_state.fresult. If
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1658
  // this changes then the interpreter_frame_result implementation
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1659
  // will need to be updated too.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1660
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1661
  //=============================================================================
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1662
  // Back in Java.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1663
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1664
  // Memory ordering: Z does not reorder store/load with subsequent
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1665
  // load. That's strong enough.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1666
  __ set_thread_state(_thread_in_Java);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1667
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1668
  __ reset_last_Java_frame();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1669
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1670
  // We reset the JNI handle block only after unboxing the result; see below.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1671
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1672
  // The method register is junk from after the thread_in_native transition
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1673
  // until here. Also can't call_VM until the bcp has been
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1674
  // restored. Need bcp for throwing exception below so get it now.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1675
  __ get_method(Rmethod);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1676
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1677
  // Restore Z_bcp to have legal interpreter frame,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1678
  // i.e., bci == 0 <=> Z_bcp == code_base().
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1679
  __ z_lg(Z_bcp, Address(Rmethod, Method::const_offset())); // get constMethod
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1680
  __ add2reg(Z_bcp, in_bytes(ConstMethod::codes_offset())); // get codebase
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1681
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1682
  if (CheckJNICalls) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1683
    // clear_pending_jni_exception_check
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1684
    __ clear_mem(Address(Z_thread, JavaThread::pending_jni_exception_check_fn_offset()), sizeof(oop));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1685
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1686
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1687
  // Check if the native method returns an oop, and if so, move it
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1688
  // from the jni handle to z_ijava_state.oop_temp. This is
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1689
  // necessary, because we reset the jni handle block below.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1690
  // NOTE: frame::interpreter_frame_result() depends on this, too.
44406
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
  1691
  { NearLabel no_oop_result;
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1692
  __ load_absolute_address(Z_R1, AbstractInterpreter::result_handler(T_OBJECT));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1693
  __ compareU64_and_branch(Z_R1, Rresult_handler, Assembler::bcondNotEqual, no_oop_result);
44406
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
  1694
  __ resolve_jobject(Rlresult, /* tmp1 */ Rmethod, /* tmp2 */ Z_R1);
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1695
  __ z_stg(Rlresult, oop_tmp_offset, Z_fp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1696
  __ bind(no_oop_result);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1697
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1698
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1699
  // Reset handle block.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1700
  __ z_lg(Z_R1/*active_handles*/, thread_(active_handles));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1701
  __ clear_mem(Address(Z_R1, JNIHandleBlock::top_offset_in_bytes()), 4);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1702
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1703
  // Bandle exceptions (exception handling will handle unlocking!).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1704
  {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1705
    Label L;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1706
    __ load_and_test_long(Z_R0/*pending_exception*/, thread_(pending_exception));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1707
    __ z_bre(L);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1708
    __ MacroAssembler::call_VM(noreg,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1709
                               CAST_FROM_FN_PTR(address,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1710
                               InterpreterRuntime::throw_pending_exception));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1711
    __ should_not_reach_here();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1712
    __ bind(L);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1713
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1714
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1715
  if (synchronized) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1716
    Register Rfirst_monitor = Z_ARG2;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1717
    __ add2reg(Rfirst_monitor, -(frame::z_ijava_state_size + (int)sizeof(BasicObjectLock)), Z_fp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1718
#ifdef ASSERT
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1719
    NearLabel ok;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1720
    __ z_lg(Z_R1, _z_ijava_state_neg(monitors), Z_fp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1721
    __ compareU64_and_branch(Rfirst_monitor, Z_R1, Assembler::bcondEqual, ok);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1722
    reentry = __ stop_chain_static(reentry, "native_entry:unlock: inconsistent z_ijava_state.monitors");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1723
    __ bind(ok);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1724
#endif
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1725
    __ unlock_object(Rfirst_monitor);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1726
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1727
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1728
  // JVMTI support. Result has already been saved above to the frame.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1729
  __ notify_method_exit(true/*native_method*/, ilgl, InterpreterMacroAssembler::NotifyJVMTI);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1730
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1731
  // Move native method result back into proper registers and return.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1732
  // C++ interpreter does not use result handler. So do we need to here? TODO(ZASM): check if correct.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1733
  { NearLabel no_oop_or_null;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1734
  __ mem2freg_opt(Z_FRET, Address(Z_fp, _z_ijava_state_neg(fresult)));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1735
  __ load_and_test_long(Z_RET, Address(Z_fp, _z_ijava_state_neg(lresult)));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1736
  __ z_bre(no_oop_or_null); // No unboxing if the result is NULL.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1737
  __ load_absolute_address(Z_R1, AbstractInterpreter::result_handler(T_OBJECT));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1738
  __ compareU64_and_branch(Z_R1, Rresult_handler, Assembler::bcondNotEqual, no_oop_or_null);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1739
  __ z_lg(Z_RET, oop_tmp_offset, Z_fp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1740
  __ verify_oop(Z_RET);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1741
  __ bind(no_oop_or_null);
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
  // Pop the native method's interpreter frame.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1745
  __ pop_interpreter_frame(Z_R14 /*return_pc*/, Z_ARG2/*tmp1*/, Z_ARG3/*tmp2*/);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1746
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1747
  // Return to caller.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1748
  __ z_br(Z_R14);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1749
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1750
  if (inc_counter) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1751
    // Handle overflow of counter and compile method.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1752
    __ bind(invocation_counter_overflow);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1753
    generate_counter_overflow(continue_after_compile);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1754
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1755
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1756
  BLOCK_COMMENT("} native_entry");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1757
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1758
  return entry_point;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1759
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1760
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1761
//
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1762
// Generic interpreted method entry to template interpreter.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1763
//
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1764
address TemplateInterpreterGenerator::generate_normal_entry(bool synchronized) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1765
  address entry_point = __ pc();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1766
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1767
  bool inc_counter = UseCompiler || CountCompiledCalls || LogTouchedMethods;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1768
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1769
  // Interpreter entry for ordinary Java methods.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1770
  //
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1771
  // Registers alive
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1772
  //   Z_SP       - stack pointer
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1773
  //   Z_thread   - JavaThread*
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1774
  //   Z_method   - callee's method (method to be invoked)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1775
  //   Z_esp      - operand (or expression) stack pointer of caller. one slot above last arg.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1776
  //   Z_R10      - sender sp (before modifications, e.g. by c2i adapter
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1777
  //                           and as well by generate_fixed_frame below)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1778
  //   Z_R14      - return address to caller (call_stub or c2i_adapter)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1779
  //
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1780
  // Registers updated
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1781
  //   Z_SP       - stack pointer
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1782
  //   Z_fp       - callee's framepointer
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1783
  //   Z_esp      - callee's operand stack pointer
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1784
  //                points to the slot above the value on top
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1785
  //   Z_locals   - used to access locals: locals[i] := *(Z_locals - i*BytesPerWord)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1786
  //   Z_tos      - integer result, if any
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1787
  //   z_ftos     - floating point result, if any
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1788
  //
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1789
  //
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1790
  // stack layout at this point:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1791
  //
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1792
  //   F1      [TOP_IJAVA_FRAME_ABI]         <-- Z_SP, Z_R10 (Z_R10 will be below Z_SP if
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1793
  //                                                          frame was extended by c2i adapter)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1794
  //           [outgoing Java arguments]     <-- Z_esp
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1795
  //           ...
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1796
  //   PARENT  [PARENT_IJAVA_FRAME_ABI]
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
  // stack layout before dispatching the first bytecode:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1800
  //
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1801
  //   F0      [TOP_IJAVA_FRAME_ABI]         <-- Z_SP
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1802
  //           [operand stack]               <-- Z_esp
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1803
  //           monitor (optional, can grow)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1804
  //           [IJAVA_STATE]
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1805
  //   F1      [PARENT_IJAVA_FRAME_ABI]      <-- Z_fp (== *Z_SP)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1806
  //           [F0's locals]                 <-- Z_locals
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1807
  //           [F1's operand stack]
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1808
  //           [F1's monitors] (optional)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1809
  //           [IJAVA_STATE]
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1810
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1811
  // Make sure registers are different!
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1812
  assert_different_registers(Z_thread, Z_method, Z_esp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1813
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1814
  BLOCK_COMMENT("normal_entry {");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1815
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1816
  // Make sure method is not native and not abstract.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1817
  // Rethink these assertions - they can be simplified and shared.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1818
#ifdef ASSERT
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1819
  address reentry = NULL;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1820
  { Label L;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1821
    __ testbit(method_(access_flags), JVM_ACC_NATIVE_BIT);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1822
    __ z_bfalse(L);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1823
    reentry = __ stop_chain_static(reentry, "tried to execute native method as non-native");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1824
    __ bind(L);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1825
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1826
  { Label L;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1827
    __ testbit(method_(access_flags), JVM_ACC_ABSTRACT_BIT);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1828
    __ z_bfalse(L);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1829
    reentry = __ stop_chain_static(reentry, "tried to execute abstract method as non-abstract");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1830
    __ bind(L);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1831
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1832
#endif // ASSERT
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1833
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1834
#ifdef ASSERT
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1835
  // Save the return PC into the callers frame for assertion in generate_fixed_frame.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1836
  __ save_return_pc(Z_R14);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1837
#endif
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1838
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1839
  // Generate the code to allocate the interpreter stack frame.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1840
  generate_fixed_frame(false);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1841
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1842
  const Address do_not_unlock_if_synchronized(Z_thread, JavaThread::do_not_unlock_if_synchronized_offset());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1843
  // Since at this point in the method invocation the exception handler
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1844
  // would try to exit the monitor of synchronized methods which hasn't
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1845
  // been entered yet, we set the thread local variable
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1846
  // _do_not_unlock_if_synchronized to true. If any exception was thrown by
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1847
  // runtime, exception handling i.e. unlock_if_synchronized_method will
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1848
  // check this thread local flag.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1849
  __ z_mvi(do_not_unlock_if_synchronized, true);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1850
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1851
  __ profile_parameters_type(Z_tmp_2, Z_ARG3, Z_ARG4);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1852
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1853
  // Increment invocation counter and check for overflow.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1854
  //
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1855
  // Note: checking for negative value instead of overflow so we have a 'sticky'
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1856
  // overflow test (may be of importance as soon as we have true MT/MP).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1857
  NearLabel invocation_counter_overflow;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1858
  NearLabel profile_method;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1859
  NearLabel profile_method_continue;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1860
  NearLabel Lcontinue;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1861
  if (inc_counter) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1862
    generate_counter_incr(&invocation_counter_overflow, &profile_method, &profile_method_continue);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1863
    if (ProfileInterpreter) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1864
      __ bind(profile_method_continue);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1865
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1866
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1867
  __ bind(Lcontinue);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1868
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1869
  bang_stack_shadow_pages(false);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1870
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1871
  // Reset the _do_not_unlock_if_synchronized flag.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1872
  __ z_mvi(do_not_unlock_if_synchronized, false);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1873
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1874
  // Check for synchronized methods.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1875
  // Must happen AFTER invocation_counter check and stack overflow check,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1876
  // so method is not locked if overflows.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1877
  if (synchronized) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1878
    // Allocate monitor and lock method.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1879
    lock_method();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1880
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1881
#ifdef ASSERT
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1882
    { Label L;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1883
      __ get_method(Z_R1_scratch);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1884
      __ testbit(method2_(Z_R1_scratch, access_flags), JVM_ACC_SYNCHRONIZED_BIT);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1885
      __ z_bfalse(L);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1886
      reentry = __ stop_chain_static(reentry, "method needs synchronization");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1887
      __ bind(L);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1888
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1889
#endif // ASSERT
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1890
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1891
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1892
  // start execution
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1893
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1894
#ifdef ASSERT
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1895
  __ verify_esp(Z_esp, Z_R1_scratch);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1896
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1897
  __ verify_thread();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1898
#endif
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1899
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1900
  // jvmti support
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1901
  __ notify_method_entry();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1902
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1903
  // Start executing instructions.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1904
  __ dispatch_next(vtos);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1905
  // Dispatch_next does not return.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1906
  DEBUG_ONLY(__ should_not_reach_here());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1907
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1908
  // Invocation counter overflow.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1909
  if (inc_counter) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1910
    if (ProfileInterpreter) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1911
      // We have decided to profile this method in the interpreter.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1912
      __ bind(profile_method);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1913
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1914
      __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::profile_method));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1915
      __ set_method_data_pointer_for_bcp();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1916
      __ z_bru(profile_method_continue);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1917
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1918
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1919
    // Handle invocation counter overflow.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1920
    __ bind(invocation_counter_overflow);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1921
    generate_counter_overflow(Lcontinue);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1922
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1923
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1924
  BLOCK_COMMENT("} normal_entry");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1925
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1926
  return entry_point;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1927
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1928
46386
742f8b16d00c 8176580: [ppc, s390] CRC32C: wrong checksum result in some cases
simonis
parents: 46369
diff changeset
  1929
742f8b16d00c 8176580: [ppc, s390] CRC32C: wrong checksum result in some cases
simonis
parents: 46369
diff changeset
  1930
/**
742f8b16d00c 8176580: [ppc, s390] CRC32C: wrong checksum result in some cases
simonis
parents: 46369
diff changeset
  1931
 * Method entry for static native methods:
742f8b16d00c 8176580: [ppc, s390] CRC32C: wrong checksum result in some cases
simonis
parents: 46369
diff changeset
  1932
 *   int java.util.zip.CRC32.update(int crc, int b)
742f8b16d00c 8176580: [ppc, s390] CRC32C: wrong checksum result in some cases
simonis
parents: 46369
diff changeset
  1933
 */
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1934
address TemplateInterpreterGenerator::generate_CRC32_update_entry() {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1935
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1936
  if (UseCRC32Intrinsics) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1937
    uint64_t entry_off = __ offset();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1938
    Label    slow_path;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1939
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1940
    // If we need a safepoint check, generate full interpreter entry.
48332
651a95f30dfb 8193257: PPC64, s390 implementation for Thread-local handshakes
mdoerr
parents: 47916
diff changeset
  1941
    __ safepoint_poll(slow_path, Z_R1);
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1942
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1943
    BLOCK_COMMENT("CRC32_update {");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1944
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1945
    // We don't generate local frame and don't align stack because
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1946
    // we not even call stub code (we generate the code inline)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1947
    // and there is no safepoint on this path.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1948
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1949
    // Load java parameters.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1950
    // Z_esp is callers operand stack pointer, i.e. it points to the parameters.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1951
    const Register argP    = Z_esp;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1952
    const Register crc     = Z_ARG1;  // crc value
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1953
    const Register data    = Z_ARG2;  // address of java byte value (kernel_crc32 needs address)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1954
    const Register dataLen = Z_ARG3;  // source data len (1 byte). Not used because calling the single-byte emitter.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1955
    const Register table   = Z_ARG4;  // address of crc32 table
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1956
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1957
    // Arguments are reversed on java expression stack.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1958
    __ z_la(data, 3+1*wordSize, argP);  // byte value (stack address).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1959
                                        // Being passed as an int, the single byte is at offset +3.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1960
    __ z_llgf(crc, 2 * wordSize, argP); // Current crc state, zero extend to 64 bit to have a clean register.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1961
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1962
    StubRoutines::zarch::generate_load_crc_table_addr(_masm, table);
46315
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  1963
    __ kernel_crc32_singleByte(crc, data, dataLen, table, Z_R1, true);
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1964
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1965
    // Restore caller sp for c2i case.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1966
    __ resize_frame_absolute(Z_R10, Z_R0, true); // Cut the stack back to where the caller started.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1967
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1968
    __ z_br(Z_R14);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1969
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1970
    BLOCK_COMMENT("} CRC32_update");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1971
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1972
    // Use a previously generated vanilla native entry as the slow path.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1973
    BIND(slow_path);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1974
    __ jump_to_entry(Interpreter::entry_for_kind(Interpreter::native), Z_R1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1975
    return __ addr_at(entry_off);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1976
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1977
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1978
  return NULL;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1979
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1980
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1981
46386
742f8b16d00c 8176580: [ppc, s390] CRC32C: wrong checksum result in some cases
simonis
parents: 46369
diff changeset
  1982
/**
742f8b16d00c 8176580: [ppc, s390] CRC32C: wrong checksum result in some cases
simonis
parents: 46369
diff changeset
  1983
 * Method entry for static native methods:
742f8b16d00c 8176580: [ppc, s390] CRC32C: wrong checksum result in some cases
simonis
parents: 46369
diff changeset
  1984
 *   int java.util.zip.CRC32.updateBytes(     int crc, byte[] b,  int off, int len)
742f8b16d00c 8176580: [ppc, s390] CRC32C: wrong checksum result in some cases
simonis
parents: 46369
diff changeset
  1985
 *   int java.util.zip.CRC32.updateByteBuffer(int crc, long* buf, int off, int len)
742f8b16d00c 8176580: [ppc, s390] CRC32C: wrong checksum result in some cases
simonis
parents: 46369
diff changeset
  1986
 */
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1987
address TemplateInterpreterGenerator::generate_CRC32_updateBytes_entry(AbstractInterpreter::MethodKind kind) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1988
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1989
  if (UseCRC32Intrinsics) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1990
    uint64_t entry_off = __ offset();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1991
    Label    slow_path;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1992
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1993
    // If we need a safepoint check, generate full interpreter entry.
48332
651a95f30dfb 8193257: PPC64, s390 implementation for Thread-local handshakes
mdoerr
parents: 47916
diff changeset
  1994
    __ safepoint_poll(slow_path, Z_R1);
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1995
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1996
    // We don't generate local frame and don't align stack because
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1997
    // we call stub code and there is no safepoint on this path.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1998
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1999
    // Load parameters.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2000
    // Z_esp is callers operand stack pointer, i.e. it points to the parameters.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2001
    const Register argP    = Z_esp;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2002
    const Register crc     = Z_ARG1;  // crc value
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2003
    const Register data    = Z_ARG2;  // address of java byte array
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2004
    const Register dataLen = Z_ARG3;  // source data len
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2005
    const Register table   = Z_ARG4;  // address of crc32 table
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2006
    const Register t0      = Z_R10;   // work reg for kernel* emitters
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2007
    const Register t1      = Z_R11;   // work reg for kernel* emitters
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2008
    const Register t2      = Z_R12;   // work reg for kernel* emitters
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2009
    const Register t3      = Z_R13;   // work reg for kernel* emitters
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2010
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2011
    // Arguments are reversed on java expression stack.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2012
    // Calculate address of start element.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2013
    if (kind == Interpreter::java_util_zip_CRC32_updateByteBuffer) { // Used for "updateByteBuffer direct".
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2014
      // crc     @ (SP + 5W) (32bit)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2015
      // buf     @ (SP + 3W) (64bit ptr to long array)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2016
      // off     @ (SP + 2W) (32bit)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2017
      // dataLen @ (SP + 1W) (32bit)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2018
      // data = buf + off
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2019
      BLOCK_COMMENT("CRC32_updateByteBuffer {");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2020
      __ z_llgf(crc,    5*wordSize, argP);  // current crc state
46315
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2021
      __ z_lg(data,     3*wordSize, argP);  // start of byte buffer
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2022
      __ z_agf(data,    2*wordSize, argP);  // Add byte buffer offset.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2023
      __ z_lgf(dataLen, 1*wordSize, argP);  // #bytes to process
46315
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2024
    } else {                                                         // Used for "updateBytes update".
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2025
      // crc     @ (SP + 4W) (32bit)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2026
      // buf     @ (SP + 3W) (64bit ptr to byte array)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2027
      // off     @ (SP + 2W) (32bit)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2028
      // dataLen @ (SP + 1W) (32bit)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2029
      // data = buf + off + base_offset
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2030
      BLOCK_COMMENT("CRC32_updateBytes {");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2031
      __ z_llgf(crc,    4*wordSize, argP);  // current crc state
46315
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2032
      __ z_lg(data,     3*wordSize, argP);  // start of byte buffer
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2033
      __ z_agf(data,    2*wordSize, argP);  // Add byte buffer offset.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2034
      __ z_lgf(dataLen, 1*wordSize, argP);  // #bytes to process
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2035
      __ z_aghi(data, arrayOopDesc::base_offset_in_bytes(T_BYTE));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2036
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2037
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2038
    StubRoutines::zarch::generate_load_crc_table_addr(_masm, table);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2039
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2040
    __ resize_frame(-(6*8), Z_R0, true); // Resize frame to provide add'l space to spill 5 registers.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2041
    __ z_stmg(t0, t3, 1*8, Z_SP);        // Spill regs 10..13 to make them available as work registers.
46315
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2042
    __ kernel_crc32_1word(crc, data, dataLen, table, t0, t1, t2, t3, true);
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2043
    __ z_lmg(t0, t3, 1*8, Z_SP);         // Spill regs 10..13 back from stack.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2044
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2045
    // Restore caller sp for c2i case.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2046
    __ resize_frame_absolute(Z_R10, Z_R0, true); // Cut the stack back to where the caller started.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2047
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2048
    __ z_br(Z_R14);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2049
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2050
    BLOCK_COMMENT("} CRC32_update{Bytes|ByteBuffer}");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2051
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2052
    // Use a previously generated vanilla native entry as the slow path.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2053
    BIND(slow_path);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2054
    __ jump_to_entry(Interpreter::entry_for_kind(Interpreter::native), Z_R1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2055
    return __ addr_at(entry_off);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2056
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2057
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2058
  return NULL;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2059
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2060
46315
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2061
46386
742f8b16d00c 8176580: [ppc, s390] CRC32C: wrong checksum result in some cases
simonis
parents: 46369
diff changeset
  2062
/**
742f8b16d00c 8176580: [ppc, s390] CRC32C: wrong checksum result in some cases
simonis
parents: 46369
diff changeset
  2063
 * Method entry for intrinsic-candidate (non-native) methods:
742f8b16d00c 8176580: [ppc, s390] CRC32C: wrong checksum result in some cases
simonis
parents: 46369
diff changeset
  2064
 *   int java.util.zip.CRC32C.updateBytes(           int crc, byte[] b,  int off, int end)
742f8b16d00c 8176580: [ppc, s390] CRC32C: wrong checksum result in some cases
simonis
parents: 46369
diff changeset
  2065
 *   int java.util.zip.CRC32C.updateDirectByteBuffer(int crc, long* buf, int off, int end)
742f8b16d00c 8176580: [ppc, s390] CRC32C: wrong checksum result in some cases
simonis
parents: 46369
diff changeset
  2066
 * Unlike CRC32, CRC32C does not have any methods marked as native
742f8b16d00c 8176580: [ppc, s390] CRC32C: wrong checksum result in some cases
simonis
parents: 46369
diff changeset
  2067
 * CRC32C also uses an "end" variable instead of the length variable CRC32 uses
742f8b16d00c 8176580: [ppc, s390] CRC32C: wrong checksum result in some cases
simonis
parents: 46369
diff changeset
  2068
 */
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2069
address TemplateInterpreterGenerator::generate_CRC32C_updateBytes_entry(AbstractInterpreter::MethodKind kind) {
46315
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2070
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2071
  if (UseCRC32CIntrinsics) {
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2072
    uint64_t entry_off = __ offset();
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2073
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2074
    // We don't generate local frame and don't align stack because
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2075
    // we call stub code and there is no safepoint on this path.
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2076
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2077
    // Load parameters.
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2078
    // Z_esp is callers operand stack pointer, i.e. it points to the parameters.
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2079
    const Register argP    = Z_esp;
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2080
    const Register crc     = Z_ARG1;  // crc value
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2081
    const Register data    = Z_ARG2;  // address of java byte array
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2082
    const Register dataLen = Z_ARG3;  // source data len
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2083
    const Register table   = Z_ARG4;  // address of crc32 table
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2084
    const Register t0      = Z_R10;   // work reg for kernel* emitters
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2085
    const Register t1      = Z_R11;   // work reg for kernel* emitters
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2086
    const Register t2      = Z_R12;   // work reg for kernel* emitters
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2087
    const Register t3      = Z_R13;   // work reg for kernel* emitters
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2088
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2089
    // Arguments are reversed on java expression stack.
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2090
    // Calculate address of start element.
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2091
    if (kind == Interpreter::java_util_zip_CRC32C_updateDirectByteBuffer) { // Used for "updateByteBuffer direct".
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2092
      // crc     @ (SP + 5W) (32bit)
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2093
      // buf     @ (SP + 3W) (64bit ptr to long array)
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2094
      // off     @ (SP + 2W) (32bit)
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2095
      // dataLen @ (SP + 1W) (32bit)
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2096
      // data = buf + off
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2097
      BLOCK_COMMENT("CRC32C_updateDirectByteBuffer {");
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2098
      __ z_llgf(crc,    5*wordSize, argP);  // current crc state
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2099
      __ z_lg(data,     3*wordSize, argP);  // start of byte buffer
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2100
      __ z_agf(data,    2*wordSize, argP);  // Add byte buffer offset.
46386
742f8b16d00c 8176580: [ppc, s390] CRC32C: wrong checksum result in some cases
simonis
parents: 46369
diff changeset
  2101
      __ z_lgf(dataLen, 1*wordSize, argP);  // #bytes to process, calculated as
742f8b16d00c 8176580: [ppc, s390] CRC32C: wrong checksum result in some cases
simonis
parents: 46369
diff changeset
  2102
      __ z_sgf(dataLen, Address(argP, 2*wordSize));  // (end_index - offset)
46315
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2103
    } else {                                                                // Used for "updateBytes update".
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2104
      // crc     @ (SP + 4W) (32bit)
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2105
      // buf     @ (SP + 3W) (64bit ptr to byte array)
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2106
      // off     @ (SP + 2W) (32bit)
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2107
      // dataLen @ (SP + 1W) (32bit)
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2108
      // data = buf + off + base_offset
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2109
      BLOCK_COMMENT("CRC32C_updateBytes {");
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2110
      __ z_llgf(crc,    4*wordSize, argP);  // current crc state
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2111
      __ z_lg(data,     3*wordSize, argP);  // start of byte buffer
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2112
      __ z_agf(data,    2*wordSize, argP);  // Add byte buffer offset.
46386
742f8b16d00c 8176580: [ppc, s390] CRC32C: wrong checksum result in some cases
simonis
parents: 46369
diff changeset
  2113
      __ z_lgf(dataLen, 1*wordSize, argP);  // #bytes to process, calculated as
742f8b16d00c 8176580: [ppc, s390] CRC32C: wrong checksum result in some cases
simonis
parents: 46369
diff changeset
  2114
      __ z_sgf(dataLen, Address(argP, 2*wordSize));  // (end_index - offset)
46315
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2115
      __ z_aghi(data, arrayOopDesc::base_offset_in_bytes(T_BYTE));
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2116
    }
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2117
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2118
    StubRoutines::zarch::generate_load_crc32c_table_addr(_masm, table);
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2119
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2120
    __ resize_frame(-(6*8), Z_R0, true); // Resize frame to provide add'l space to spill 5 registers.
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2121
    __ z_stmg(t0, t3, 1*8, Z_SP);        // Spill regs 10..13 to make them available as work registers.
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2122
    __ kernel_crc32_1word(crc, data, dataLen, table, t0, t1, t2, t3, false);
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2123
    __ z_lmg(t0, t3, 1*8, Z_SP);         // Spill regs 10..13 back from stack.
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2124
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2125
    // Restore caller sp for c2i case.
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2126
    __ resize_frame_absolute(Z_R10, Z_R0, true); // Cut the stack back to where the caller started.
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2127
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2128
    __ z_br(Z_R14);
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2129
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2130
    BLOCK_COMMENT("} CRC32C_update{Bytes|DirectByteBuffer}");
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2131
    return __ addr_at(entry_off);
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2132
  }
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2133
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2134
  return NULL;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2135
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2136
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2137
void TemplateInterpreterGenerator::bang_stack_shadow_pages(bool native_call) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2138
  // Quick & dirty stack overflow checking: bang the stack & handle trap.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2139
  // Note that we do the banging after the frame is setup, since the exception
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2140
  // handling code expects to find a valid interpreter frame on the stack.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2141
  // Doing the banging earlier fails if the caller frame is not an interpreter
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2142
  // frame.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2143
  // (Also, the exception throwing code expects to unlock any synchronized
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2144
  // method receiver, so do the banging after locking the receiver.)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2145
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2146
  // Bang each page in the shadow zone. We can't assume it's been done for
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2147
  // an interpreter frame with greater than a page of locals, so each page
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2148
  // needs to be checked. Only true for non-native. For native, we only bang the last page.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2149
  if (UseStackBanging) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2150
    const int page_size      = os::vm_page_size();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2151
    const int n_shadow_pages = (int)(JavaThread::stack_shadow_zone_size()/page_size);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2152
    const int start_page_num = native_call ? n_shadow_pages : 1;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2153
    for (int pages = start_page_num; pages <= n_shadow_pages; pages++) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2154
      __ bang_stack_with_offset(pages*page_size);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2155
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2156
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2157
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2158
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2159
//-----------------------------------------------------------------------------
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2160
// Exceptions
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2161
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2162
void TemplateInterpreterGenerator::generate_throw_exception() {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2163
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2164
  BLOCK_COMMENT("throw_exception {");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2165
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2166
  // Entry point in previous activation (i.e., if the caller was interpreted).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2167
  Interpreter::_rethrow_exception_entry = __ pc();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2168
  __ z_lg(Z_fp, _z_abi(callers_sp), Z_SP); // Frame accessors use Z_fp.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2169
  // Z_ARG1 (==Z_tos): exception
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2170
  // Z_ARG2          : Return address/pc that threw exception.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2171
  __ restore_bcp();    // R13 points to call/send.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2172
  __ restore_locals();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2173
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2174
  // Fallthrough, no need to restore Z_esp.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2175
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2176
  // Entry point for exceptions thrown within interpreter code.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2177
  Interpreter::_throw_exception_entry = __ pc();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2178
  // Expression stack is undefined here.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2179
  // Z_ARG1 (==Z_tos): exception
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2180
  // Z_bcp: exception bcp
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2181
  __ verify_oop(Z_ARG1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2182
  __ z_lgr(Z_ARG2, Z_ARG1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2183
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2184
  // Expression stack must be empty before entering the VM in case of
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2185
  // an exception.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2186
  __ empty_expression_stack();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2187
  // Find exception handler address and preserve exception oop.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2188
  const Register Rpreserved_exc_oop = Z_tmp_1;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2189
  __ call_VM(Rpreserved_exc_oop,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2190
             CAST_FROM_FN_PTR(address, InterpreterRuntime::exception_handler_for_exception),
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2191
             Z_ARG2);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2192
  // Z_RET: exception handler entry point
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2193
  // Z_bcp: bcp for exception handler
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2194
  __ push_ptr(Rpreserved_exc_oop); // Push exception which is now the only value on the stack.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2195
  __ z_br(Z_RET); // Jump to exception handler (may be _remove_activation_entry!).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2196
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2197
  // If the exception is not handled in the current frame the frame is
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2198
  // removed and the exception is rethrown (i.e. exception
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2199
  // continuation is _rethrow_exception).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2200
  //
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2201
  // Note: At this point the bci is still the bci for the instruction
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2202
  // which caused the exception and the expression stack is
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2203
  // empty. Thus, for any VM calls at this point, GC will find a legal
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2204
  // oop map (with empty expression stack).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2205
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2206
  //
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2207
  // JVMTI PopFrame support
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2208
  //
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2209
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2210
  Interpreter::_remove_activation_preserving_args_entry = __ pc();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2211
  __ z_lg(Z_fp, _z_parent_ijava_frame_abi(callers_sp), Z_SP);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2212
  __ empty_expression_stack();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2213
  // Set the popframe_processing bit in pending_popframe_condition
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2214
  // indicating that we are currently handling popframe, so that
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2215
  // call_VMs that may happen later do not trigger new popframe
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2216
  // handling cycles.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2217
  __ load_sized_value(Z_tmp_1, Address(Z_thread, JavaThread::popframe_condition_offset()), 4, false /*signed*/);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2218
  __ z_oill(Z_tmp_1, JavaThread::popframe_processing_bit);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2219
  __ z_sty(Z_tmp_1, thread_(popframe_condition));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2220
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2221
  {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2222
    // Check to see whether we are returning to a deoptimized frame.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2223
    // (The PopFrame call ensures that the caller of the popped frame is
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2224
    // either interpreted or compiled and deoptimizes it if compiled.)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2225
    // In this case, we can't call dispatch_next() after the frame is
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2226
    // popped, but instead must save the incoming arguments and restore
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2227
    // them after deoptimization has occurred.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2228
    //
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2229
    // Note that we don't compare the return PC against the
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2230
    // deoptimization blob's unpack entry because of the presence of
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2231
    // adapter frames in C2.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2232
    NearLabel caller_not_deoptimized;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2233
    __ z_lg(Z_ARG1, _z_parent_ijava_frame_abi(return_pc), Z_fp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2234
    __ call_VM_leaf(CAST_FROM_FN_PTR(address, InterpreterRuntime::interpreter_contains), Z_ARG1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2235
    __ compareU64_and_branch(Z_RET, (intptr_t)0, Assembler::bcondNotEqual, caller_not_deoptimized);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2236
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2237
    // Compute size of arguments for saving when returning to
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2238
    // deoptimized caller.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2239
    __ get_method(Z_ARG2);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2240
    __ z_lg(Z_ARG2, Address(Z_ARG2, Method::const_offset()));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2241
    __ z_llgh(Z_ARG2, Address(Z_ARG2, ConstMethod::size_of_parameters_offset()));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2242
    __ z_sllg(Z_ARG2, Z_ARG2, Interpreter::logStackElementSize); // slots 2 bytes
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2243
    __ restore_locals();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2244
    // Compute address of args to be saved.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2245
    __ z_lgr(Z_ARG3, Z_locals);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2246
    __ z_slgr(Z_ARG3, Z_ARG2);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2247
    __ add2reg(Z_ARG3, wordSize);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2248
    // Save these arguments.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2249
    __ call_VM_leaf(CAST_FROM_FN_PTR(address, Deoptimization::popframe_preserve_args),
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2250
                    Z_thread, Z_ARG2, Z_ARG3);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2251
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2252
    __ remove_activation(vtos, Z_R14,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2253
                         /* throw_monitor_exception */ false,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2254
                         /* install_monitor_exception */ false,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2255
                         /* notify_jvmdi */ false);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2256
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2257
    // Inform deoptimization that it is responsible for restoring
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2258
    // these arguments.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2259
    __ store_const(thread_(popframe_condition),
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2260
                   JavaThread::popframe_force_deopt_reexecution_bit,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2261
                   Z_tmp_1, false);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2262
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2263
    // Continue in deoptimization handler.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2264
    __ z_br(Z_R14);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2265
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2266
    __ bind(caller_not_deoptimized);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2267
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2268
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2269
  // Clear the popframe condition flag.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2270
  __ clear_mem(thread_(popframe_condition), sizeof(int));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2271
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2272
  __ remove_activation(vtos,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2273
                       noreg,  // Retaddr is not used.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2274
                       false,  // throw_monitor_exception
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2275
                       false,  // install_monitor_exception
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2276
                       false); // notify_jvmdi
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2277
  __ z_lg(Z_fp, _z_abi(callers_sp), Z_SP); // Restore frame pointer.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2278
  __ restore_bcp();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2279
  __ restore_locals();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2280
  __ restore_esp();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2281
  // The method data pointer was incremented already during
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2282
  // call profiling. We have to restore the mdp for the current bcp.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2283
  if (ProfileInterpreter) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2284
    __ set_method_data_pointer_for_bcp();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2285
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2286
#if INCLUDE_JVMTI
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2287
  {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2288
    Label L_done;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2289
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2290
    __ z_cli(0, Z_bcp, Bytecodes::_invokestatic);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2291
    __ z_brc(Assembler::bcondNotEqual, L_done);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2292
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2293
    // The member name argument must be restored if _invokestatic is
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2294
    // re-executed after a PopFrame call.  Detect such a case in the
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2295
    // InterpreterRuntime function and return the member name
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2296
    // argument, or NULL.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2297
    __ z_lg(Z_ARG2, Address(Z_locals));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2298
    __ get_method(Z_ARG3);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2299
    __ call_VM(Z_tmp_1,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2300
               CAST_FROM_FN_PTR(address, InterpreterRuntime::member_name_arg_or_null),
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2301
               Z_ARG2, Z_ARG3, Z_bcp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2302
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2303
    __ z_ltgr(Z_tmp_1, Z_tmp_1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2304
    __ z_brc(Assembler::bcondEqual, L_done);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2305
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2306
    __ z_stg(Z_tmp_1, Address(Z_esp, wordSize));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2307
    __ bind(L_done);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2308
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2309
#endif // INCLUDE_JVMTI
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2310
  __ dispatch_next(vtos);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2311
  // End of PopFrame support.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2312
  Interpreter::_remove_activation_entry = __ pc();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2313
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2314
  // In between activations - previous activation type unknown yet
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2315
  // compute continuation point - the continuation point expects the
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2316
  // following registers set up:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2317
  //
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2318
  // Z_ARG1 (==Z_tos): exception
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2319
  // Z_ARG2          : return address/pc that threw exception
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2320
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2321
  Register return_pc = Z_tmp_1;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2322
  Register handler   = Z_tmp_2;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2323
   assert(return_pc->is_nonvolatile(), "use non-volatile reg. to preserve exception pc");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2324
   assert(handler->is_nonvolatile(),   "use non-volatile reg. to handler pc");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2325
  __ asm_assert_ijava_state_magic(return_pc/*tmp*/); // The top frame should be an interpreter frame.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2326
  __ z_lg(return_pc, _z_parent_ijava_frame_abi(return_pc), Z_fp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2327
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2328
  // Moved removing the activation after VM call, because the new top
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2329
  // frame does not necessarily have the z_abi_160 required for a VM
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2330
  // call (e.g. if it is compiled).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2331
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2332
  __ super_call_VM_leaf(CAST_FROM_FN_PTR(address,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2333
                                         SharedRuntime::exception_handler_for_return_address),
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2334
                        Z_thread, return_pc);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2335
  __ z_lgr(handler, Z_RET); // Save exception handler.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2336
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2337
  // Preserve exception over this code sequence.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2338
  __ pop_ptr(Z_ARG1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2339
  __ set_vm_result(Z_ARG1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2340
  // Remove the activation (without doing throws on illegalMonitorExceptions).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2341
  __ remove_activation(vtos, noreg/*ret.pc already loaded*/, false/*throw exc*/, true/*install exc*/, false/*notify jvmti*/);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2342
  __ z_lg(Z_fp, _z_abi(callers_sp), Z_SP); // Restore frame pointer.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2343
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2344
  __ get_vm_result(Z_ARG1);     // Restore exception.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2345
  __ verify_oop(Z_ARG1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2346
  __ z_lgr(Z_ARG2, return_pc);  // Restore return address.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2347
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2348
#ifdef ASSERT
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2349
  // The return_pc in the new top frame is dead... at least that's my
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2350
  // current understanding. To assert this I overwrite it.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2351
  // Note: for compiled frames the handler is the deopt blob
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2352
  // which writes Z_ARG2 into the return_pc slot.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2353
  __ load_const_optimized(return_pc, 0xb00b1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2354
  __ z_stg(return_pc, _z_parent_ijava_frame_abi(return_pc), Z_SP);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2355
#endif
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2356
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2357
  // Z_ARG1 (==Z_tos): exception
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2358
  // Z_ARG2          : return address/pc that threw exception
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2359
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2360
  // Note that an "issuing PC" is actually the next PC after the call.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2361
  __ z_br(handler);         // Jump to exception handler of caller.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2362
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2363
  BLOCK_COMMENT("} throw_exception");
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
//
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2367
// JVMTI ForceEarlyReturn support
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2368
//
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2369
address TemplateInterpreterGenerator::generate_earlyret_entry_for (TosState state) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2370
  address entry = __ pc();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2371
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2372
  BLOCK_COMMENT("earlyret_entry {");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2373
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2374
  __ z_lg(Z_fp, _z_parent_ijava_frame_abi(callers_sp), Z_SP);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2375
  __ restore_bcp();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2376
  __ restore_locals();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2377
  __ restore_esp();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2378
  __ empty_expression_stack();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2379
  __ load_earlyret_value(state);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2380
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2381
  Register RjvmtiState = Z_tmp_1;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2382
  __ z_lg(RjvmtiState, thread_(jvmti_thread_state));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2383
  __ store_const(Address(RjvmtiState, JvmtiThreadState::earlyret_state_offset()),
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2384
                 JvmtiThreadState::earlyret_inactive, 4, 4, Z_R0_scratch);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2385
47762
9ccaa4e79030 8190285: s390: Some java boolean checks are not correct
mdoerr
parents: 47216
diff changeset
  2386
  if (state == itos) {
9ccaa4e79030 8190285: s390: Some java boolean checks are not correct
mdoerr
parents: 47216
diff changeset
  2387
    // Narrow result if state is itos but result type is smaller.
9ccaa4e79030 8190285: s390: Some java boolean checks are not correct
mdoerr
parents: 47216
diff changeset
  2388
    // Need to narrow in the return bytecode rather than in generate_return_entry
9ccaa4e79030 8190285: s390: Some java boolean checks are not correct
mdoerr
parents: 47216
diff changeset
  2389
    // since compiled code callers expect the result to already be narrowed.
9ccaa4e79030 8190285: s390: Some java boolean checks are not correct
mdoerr
parents: 47216
diff changeset
  2390
    __ narrow(Z_tos, Z_tmp_1); /* fall through */
9ccaa4e79030 8190285: s390: Some java boolean checks are not correct
mdoerr
parents: 47216
diff changeset
  2391
  }
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2392
  __ remove_activation(state,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2393
                       Z_tmp_1, // retaddr
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2394
                       false,   // throw_monitor_exception
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2395
                       false,   // install_monitor_exception
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2396
                       true);   // notify_jvmdi
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2397
  __ z_br(Z_tmp_1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2398
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2399
  BLOCK_COMMENT("} earlyret_entry");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2400
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2401
  return entry;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2402
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2403
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2404
//-----------------------------------------------------------------------------
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2405
// Helper for vtos entry point generation.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2406
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2407
void TemplateInterpreterGenerator::set_vtos_entry_points(Template* t,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2408
                                                         address& bep,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2409
                                                         address& cep,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2410
                                                         address& sep,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2411
                                                         address& aep,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2412
                                                         address& iep,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2413
                                                         address& lep,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2414
                                                         address& fep,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2415
                                                         address& dep,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2416
                                                         address& vep) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2417
  assert(t->is_valid() && t->tos_in() == vtos, "illegal template");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2418
  Label L;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2419
  aep = __ pc(); __ push_ptr(); __ z_bru(L);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2420
  fep = __ pc(); __ push_f();   __ z_bru(L);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2421
  dep = __ pc(); __ push_d();   __ z_bru(L);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2422
  lep = __ pc(); __ push_l();   __ z_bru(L);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2423
  bep = cep = sep =
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2424
  iep = __ pc(); __ push_i();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2425
  vep = __ pc();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2426
  __ bind(L);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2427
  generate_and_dispatch(t);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2428
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2429
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2430
//-----------------------------------------------------------------------------
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2431
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2432
#ifndef PRODUCT
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2433
address TemplateInterpreterGenerator::generate_trace_code(TosState state) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2434
  address entry = __ pc();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2435
  NearLabel counter_below_trace_threshold;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2436
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2437
  if (TraceBytecodesAt > 0) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2438
    // Skip runtime call, if the trace threshold is not yet reached.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2439
    __ load_absolute_address(Z_tmp_1, (address)&BytecodeCounter::_counter_value);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2440
    __ load_absolute_address(Z_tmp_2, (address)&TraceBytecodesAt);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2441
    __ load_sized_value(Z_tmp_1, Address(Z_tmp_1), 4, false /*signed*/);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2442
    __ load_sized_value(Z_tmp_2, Address(Z_tmp_2), 8, false /*signed*/);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2443
    __ compareU64_and_branch(Z_tmp_1, Z_tmp_2, Assembler::bcondLow, counter_below_trace_threshold);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2444
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2445
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2446
  int offset2 = state == ltos || state == dtos ? 2 : 1;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2447
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2448
  __ push(state);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2449
  // Preserved return pointer is in Z_R14.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2450
  // InterpreterRuntime::trace_bytecode() preserved and returns the value passed as second argument.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2451
  __ z_lgr(Z_ARG2, Z_R14);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2452
  __ z_lg(Z_ARG3, Address(Z_esp, Interpreter::expr_offset_in_bytes(0)));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2453
  if (WizardMode) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2454
    __ z_lgr(Z_ARG4, Z_esp); // Trace Z_esp in WizardMode.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2455
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2456
    __ z_lg(Z_ARG4, Address(Z_esp, Interpreter::expr_offset_in_bytes(offset2)));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2457
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2458
  __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::trace_bytecode), Z_ARG2, Z_ARG3, Z_ARG4);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2459
  __ z_lgr(Z_R14, Z_RET); // Estore return address (see above).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2460
  __ pop(state);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2461
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2462
  __ bind(counter_below_trace_threshold);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2463
  __ z_br(Z_R14); // return
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2464
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2465
  return entry;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2466
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2467
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2468
// Make feasible for old CPUs.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2469
void TemplateInterpreterGenerator::count_bytecode() {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2470
  __ load_absolute_address(Z_R1_scratch, (address) &BytecodeCounter::_counter_value);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2471
  __ add2mem_32(Address(Z_R1_scratch), 1, Z_R0_scratch);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2472
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2473
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2474
void TemplateInterpreterGenerator::histogram_bytecode(Template * t) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2475
  __ load_absolute_address(Z_R1_scratch, (address)&BytecodeHistogram::_counters[ t->bytecode() ]);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2476
  __ add2mem_32(Address(Z_R1_scratch), 1, Z_tmp_1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2477
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2478
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2479
void TemplateInterpreterGenerator::histogram_bytecode_pair(Template * t) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2480
  Address  index_addr(Z_tmp_1, (intptr_t) 0);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2481
  Register index = Z_tmp_2;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2482
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2483
  // Load previous index.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2484
  __ load_absolute_address(Z_tmp_1, (address) &BytecodePairHistogram::_index);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2485
  __ mem2reg_opt(index, index_addr, false);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2486
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2487
  // Mask with current bytecode and store as new previous index.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2488
  __ z_srl(index, BytecodePairHistogram::log2_number_of_codes);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2489
  __ load_const_optimized(Z_R0_scratch,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2490
                          (int)t->bytecode() << BytecodePairHistogram::log2_number_of_codes);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2491
  __ z_or(index, Z_R0_scratch);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2492
  __ reg2mem_opt(index, index_addr, false);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2493
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2494
  // Load counter array's address.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2495
  __ z_lgfr(index, index);   // Sign extend for addressing.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2496
  __ z_sllg(index, index, LogBytesPerInt);  // index2bytes
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2497
  __ load_absolute_address(Z_R1_scratch,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2498
                           (address) &BytecodePairHistogram::_counters);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2499
  // Add index and increment counter.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2500
  __ z_agr(Z_R1_scratch, index);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2501
  __ add2mem_32(Address(Z_R1_scratch), 1, Z_tmp_1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2502
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2503
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2504
void TemplateInterpreterGenerator::trace_bytecode(Template* t) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2505
  // Call a little run-time stub to avoid blow-up for each bytecode.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2506
  // The run-time runtime saves the right registers, depending on
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2507
  // the tosca in-state for the given template.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2508
  address entry = Interpreter::trace_code(t->tos_in());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2509
  guarantee(entry != NULL, "entry must have been generated");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2510
  __ call_stub(entry);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2511
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2512
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2513
void TemplateInterpreterGenerator::stop_interpreter_at() {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2514
  NearLabel L;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2515
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2516
  __ load_absolute_address(Z_tmp_1, (address)&BytecodeCounter::_counter_value);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2517
  __ load_absolute_address(Z_tmp_2, (address)&StopInterpreterAt);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2518
  __ load_sized_value(Z_tmp_1, Address(Z_tmp_1), 4, false /*signed*/);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2519
  __ load_sized_value(Z_tmp_2, Address(Z_tmp_2), 8, false /*signed*/);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2520
  __ compareU64_and_branch(Z_tmp_1, Z_tmp_2, Assembler::bcondLow, L);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2521
  assert(Z_tmp_1->is_nonvolatile(), "must be nonvolatile to preserve Z_tos");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2522
  assert(Z_F8->is_nonvolatile(), "must be nonvolatile to preserve Z_ftos");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2523
  __ z_lgr(Z_tmp_1, Z_tos);      // Save tos.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2524
  __ z_lgr(Z_tmp_2, Z_bytecode); // Save Z_bytecode.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2525
  __ z_ldr(Z_F8, Z_ftos);        // Save ftos.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2526
  // Use -XX:StopInterpreterAt=<num> to set the limit
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2527
  // and break at breakpoint().
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2528
  __ call_VM(noreg, CAST_FROM_FN_PTR(address, breakpoint), false);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2529
  __ z_lgr(Z_tos, Z_tmp_1);      // Restore tos.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2530
  __ z_lgr(Z_bytecode, Z_tmp_2); // Save Z_bytecode.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2531
  __ z_ldr(Z_ftos, Z_F8);        // Restore ftos.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2532
  __ bind(L);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2533
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2534
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2535
#endif // !PRODUCT