src/hotspot/cpu/ppc/templateInterpreterGenerator_ppc.cpp
author mdoerr
Thu, 14 Dec 2017 13:05:20 +0100
changeset 48332 651a95f30dfb
parent 47916 bdbef8638948
child 48626 9f6f48d4f9a1
permissions -rw-r--r--
8193257: PPC64, s390 implementation for Thread-local handshakes Reviewed-by: goetz, lucy
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
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: 46263
diff changeset
     2
 * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
46317
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
     3
 * Copyright (c) 2015, 2017, SAP SE. All rights reserved.
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
     4
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
     5
 *
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
     6
 * This code is free software; you can redistribute it and/or modify it
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
     7
 * under the terms of the GNU General Public License version 2 only, as
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
     8
 * published by the Free Software Foundation.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
     9
 *
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    10
 * This code is distributed in the hope that it will be useful, but WITHOUT
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    11
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    12
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    13
 * version 2 for more details (a copy is included in the LICENSE file that
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    14
 * accompanied this code).
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    15
 *
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    16
 * You should have received a copy of the GNU General Public License version
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    17
 * 2 along with this work; if not, write to the Free Software Foundation,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    18
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    19
 *
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    20
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    21
 * or visit www.oracle.com if you need additional information or have any
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    22
 * questions.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    23
 *
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    24
 */
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    25
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    26
#include "precompiled.hpp"
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    27
#include "asm/macroAssembler.inline.hpp"
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    28
#include "interpreter/bytecodeHistogram.hpp"
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    29
#include "interpreter/interpreter.hpp"
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    30
#include "interpreter/interpreterRuntime.hpp"
25715
d5a8dbdc5150 8049325: Introduce and clean up umbrella headers for the files in the cpu subdirectories.
goetz
parents: 24349
diff changeset
    31
#include "interpreter/interp_masm.hpp"
35214
d86005e0b4c2 8074457: Remove the non-Zero CPP Interpreter
coleenp
parents: 35166
diff changeset
    32
#include "interpreter/templateInterpreterGenerator.hpp"
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    33
#include "interpreter/templateTable.hpp"
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    34
#include "oops/arrayOop.hpp"
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    35
#include "oops/methodData.hpp"
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    36
#include "oops/method.hpp"
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    37
#include "oops/oop.inline.hpp"
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    38
#include "prims/jvmtiExport.hpp"
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    39
#include "prims/jvmtiThreadState.hpp"
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    40
#include "runtime/arguments.hpp"
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    41
#include "runtime/deoptimization.hpp"
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    42
#include "runtime/frame.inline.hpp"
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    43
#include "runtime/sharedRuntime.hpp"
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    44
#include "runtime/stubRoutines.hpp"
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    45
#include "runtime/synchronizer.hpp"
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    46
#include "runtime/timer.hpp"
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    47
#include "runtime/vframeArray.hpp"
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    48
#include "utilities/debug.hpp"
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    49
#include "utilities/macros.hpp"
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    50
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    51
#undef __
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    52
#define __ _masm->
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    53
35479
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    54
// Size of interpreter code.  Increase if too small.  Interpreter will
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    55
// fail with a guarantee ("not enough space for interpreter generation");
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    56
// if too small.
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    57
// Run with +PrintInterpreter to get the VM to print out the size.
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    58
// Max size with JVMTI
46960
b498e2123d2f 8186667: InterpreterCodeSize overflows on AIX
simonis
parents: 46386
diff changeset
    59
int TemplateInterpreter::InterpreterCodeSize = 256*K;
35479
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    60
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    61
#ifdef PRODUCT
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    62
#define BLOCK_COMMENT(str) /* nothing */
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    63
#else
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    64
#define BLOCK_COMMENT(str) __ block_comment(str)
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    65
#endif
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    66
31861
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
    67
#define BIND(label)        __ bind(label); BLOCK_COMMENT(#label ":")
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    68
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    69
//-----------------------------------------------------------------------------
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    70
35479
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    71
address TemplateInterpreterGenerator::generate_slow_signature_handler() {
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    72
  // Slow_signature handler that respects the PPC C calling conventions.
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    73
  //
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    74
  // We get called by the native entry code with our output register
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    75
  // area == 8. First we call InterpreterRuntime::get_result_handler
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    76
  // to copy the pointer to the signature string temporarily to the
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    77
  // first C-argument and to return the result_handler in
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    78
  // R3_RET. Since native_entry will copy the jni-pointer to the
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    79
  // first C-argument slot later on, it is OK to occupy this slot
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    80
  // temporarilly. Then we copy the argument list on the java
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    81
  // expression stack into native varargs format on the native stack
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    82
  // and load arguments into argument registers. Integer arguments in
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    83
  // the varargs vector will be sign-extended to 8 bytes.
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    84
  //
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    85
  // On entry:
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    86
  //   R3_ARG1        - intptr_t*     Address of java argument list in memory.
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    87
  //   R15_prev_state - BytecodeInterpreter* Address of interpreter state for
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    88
  //     this method
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    89
  //   R19_method
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    90
  //
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    91
  // On exit (just before return instruction):
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    92
  //   R3_RET            - contains the address of the result_handler.
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    93
  //   R4_ARG2           - is not updated for static methods and contains "this" otherwise.
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    94
  //   R5_ARG3-R10_ARG8: - When the (i-2)th Java argument is not of type float or double,
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    95
  //                       ARGi contains this argument. Otherwise, ARGi is not updated.
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    96
  //   F1_ARG1-F13_ARG13 - contain the first 13 arguments of type float or double.
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    97
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    98
  const int LogSizeOfTwoInstructions = 3;
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    99
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   100
  // FIXME: use Argument:: GL: Argument names different numbers!
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   101
  const int max_fp_register_arguments  = 13;
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   102
  const int max_int_register_arguments = 6;  // first 2 are reserved
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   103
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   104
  const Register arg_java       = R21_tmp1;
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   105
  const Register arg_c          = R22_tmp2;
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   106
  const Register signature      = R23_tmp3;  // is string
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   107
  const Register sig_byte       = R24_tmp4;
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   108
  const Register fpcnt          = R25_tmp5;
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   109
  const Register argcnt         = R26_tmp6;
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   110
  const Register intSlot        = R27_tmp7;
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   111
  const Register target_sp      = R28_tmp8;
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   112
  const FloatRegister floatSlot = F0;
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   113
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   114
  address entry = __ function_entry();
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   115
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   116
  __ save_LR_CR(R0);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   117
  __ save_nonvolatile_gprs(R1_SP, _spill_nonvolatiles_neg(r14));
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   118
  // We use target_sp for storing arguments in the C frame.
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   119
  __ mr(target_sp, R1_SP);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   120
  __ push_frame_reg_args_nonvolatiles(0, R11_scratch1);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   121
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   122
  __ mr(arg_java, R3_ARG1);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   123
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   124
  __ call_VM_leaf(CAST_FROM_FN_PTR(address, InterpreterRuntime::get_signature), R16_thread, R19_method);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   125
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   126
  // Signature is in R3_RET. Signature is callee saved.
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   127
  __ mr(signature, R3_RET);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   128
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   129
  // Get the result handler.
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   130
  __ call_VM_leaf(CAST_FROM_FN_PTR(address, InterpreterRuntime::get_result_handler), R16_thread, R19_method);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   131
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   132
  {
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   133
    Label L;
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   134
    // test if static
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   135
    // _access_flags._flags must be at offset 0.
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   136
    // TODO PPC port: requires change in shared code.
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   137
    //assert(in_bytes(AccessFlags::flags_offset()) == 0,
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   138
    //       "MethodDesc._access_flags == MethodDesc._access_flags._flags");
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   139
    // _access_flags must be a 32 bit value.
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   140
    assert(sizeof(AccessFlags) == 4, "wrong size");
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   141
    __ lwa(R11_scratch1/*access_flags*/, method_(access_flags));
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   142
    // testbit with condition register.
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   143
    __ testbitdi(CCR0, R0, R11_scratch1/*access_flags*/, JVM_ACC_STATIC_BIT);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   144
    __ btrue(CCR0, L);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   145
    // For non-static functions, pass "this" in R4_ARG2 and copy it
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   146
    // to 2nd C-arg slot.
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   147
    // We need to box the Java object here, so we use arg_java
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   148
    // (address of current Java stack slot) as argument and don't
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   149
    // dereference it as in case of ints, floats, etc.
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   150
    __ mr(R4_ARG2, arg_java);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   151
    __ addi(arg_java, arg_java, -BytesPerWord);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   152
    __ std(R4_ARG2, _abi(carg_2), target_sp);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   153
    __ bind(L);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   154
  }
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   155
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   156
  // Will be incremented directly after loop_start. argcnt=0
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   157
  // corresponds to 3rd C argument.
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   158
  __ li(argcnt, -1);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   159
  // arg_c points to 3rd C argument
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   160
  __ addi(arg_c, target_sp, _abi(carg_3));
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   161
  // no floating-point args parsed so far
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   162
  __ li(fpcnt, 0);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   163
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   164
  Label move_intSlot_to_ARG, move_floatSlot_to_FARG;
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   165
  Label loop_start, loop_end;
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   166
  Label do_int, do_long, do_float, do_double, do_dontreachhere, do_object, do_array, do_boxed;
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   167
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   168
  // signature points to '(' at entry
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   169
#ifdef ASSERT
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   170
  __ lbz(sig_byte, 0, signature);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   171
  __ cmplwi(CCR0, sig_byte, '(');
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   172
  __ bne(CCR0, do_dontreachhere);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   173
#endif
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   174
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   175
  __ bind(loop_start);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   176
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   177
  __ addi(argcnt, argcnt, 1);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   178
  __ lbzu(sig_byte, 1, signature);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   179
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   180
  __ cmplwi(CCR0, sig_byte, ')'); // end of signature
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   181
  __ beq(CCR0, loop_end);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   182
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   183
  __ cmplwi(CCR0, sig_byte, 'B'); // byte
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   184
  __ beq(CCR0, do_int);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   185
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   186
  __ cmplwi(CCR0, sig_byte, 'C'); // char
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   187
  __ beq(CCR0, do_int);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   188
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   189
  __ cmplwi(CCR0, sig_byte, 'D'); // double
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   190
  __ beq(CCR0, do_double);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   191
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   192
  __ cmplwi(CCR0, sig_byte, 'F'); // float
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   193
  __ beq(CCR0, do_float);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   194
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   195
  __ cmplwi(CCR0, sig_byte, 'I'); // int
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   196
  __ beq(CCR0, do_int);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   197
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   198
  __ cmplwi(CCR0, sig_byte, 'J'); // long
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   199
  __ beq(CCR0, do_long);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   200
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   201
  __ cmplwi(CCR0, sig_byte, 'S'); // short
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   202
  __ beq(CCR0, do_int);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   203
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   204
  __ cmplwi(CCR0, sig_byte, 'Z'); // boolean
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   205
  __ beq(CCR0, do_int);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   206
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   207
  __ cmplwi(CCR0, sig_byte, 'L'); // object
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   208
  __ beq(CCR0, do_object);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   209
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   210
  __ cmplwi(CCR0, sig_byte, '['); // array
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   211
  __ beq(CCR0, do_array);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   212
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   213
  //  __ cmplwi(CCR0, sig_byte, 'V'); // void cannot appear since we do not parse the return type
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   214
  //  __ beq(CCR0, do_void);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   215
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   216
  __ bind(do_dontreachhere);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   217
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   218
  __ unimplemented("ShouldNotReachHere in slow_signature_handler", 120);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   219
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   220
  __ bind(do_array);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   221
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   222
  {
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   223
    Label start_skip, end_skip;
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   224
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   225
    __ bind(start_skip);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   226
    __ lbzu(sig_byte, 1, signature);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   227
    __ cmplwi(CCR0, sig_byte, '[');
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   228
    __ beq(CCR0, start_skip); // skip further brackets
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   229
    __ cmplwi(CCR0, sig_byte, '9');
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   230
    __ bgt(CCR0, end_skip);   // no optional size
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   231
    __ cmplwi(CCR0, sig_byte, '0');
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   232
    __ bge(CCR0, start_skip); // skip optional size
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   233
    __ bind(end_skip);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   234
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   235
    __ cmplwi(CCR0, sig_byte, 'L');
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   236
    __ beq(CCR0, do_object);  // for arrays of objects, the name of the object must be skipped
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   237
    __ b(do_boxed);          // otherwise, go directly to do_boxed
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   238
  }
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   239
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   240
  __ bind(do_object);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   241
  {
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   242
    Label L;
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   243
    __ bind(L);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   244
    __ lbzu(sig_byte, 1, signature);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   245
    __ cmplwi(CCR0, sig_byte, ';');
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   246
    __ bne(CCR0, L);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   247
   }
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   248
  // Need to box the Java object here, so we use arg_java (address of
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   249
  // current Java stack slot) as argument and don't dereference it as
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   250
  // in case of ints, floats, etc.
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   251
  Label do_null;
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   252
  __ bind(do_boxed);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   253
  __ ld(R0,0, arg_java);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   254
  __ cmpdi(CCR0, R0, 0);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   255
  __ li(intSlot,0);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   256
  __ beq(CCR0, do_null);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   257
  __ mr(intSlot, arg_java);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   258
  __ bind(do_null);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   259
  __ std(intSlot, 0, arg_c);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   260
  __ addi(arg_java, arg_java, -BytesPerWord);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   261
  __ addi(arg_c, arg_c, BytesPerWord);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   262
  __ cmplwi(CCR0, argcnt, max_int_register_arguments);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   263
  __ blt(CCR0, move_intSlot_to_ARG);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   264
  __ b(loop_start);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   265
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   266
  __ bind(do_int);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   267
  __ lwa(intSlot, 0, arg_java);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   268
  __ std(intSlot, 0, arg_c);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   269
  __ addi(arg_java, arg_java, -BytesPerWord);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   270
  __ addi(arg_c, arg_c, BytesPerWord);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   271
  __ cmplwi(CCR0, argcnt, max_int_register_arguments);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   272
  __ blt(CCR0, move_intSlot_to_ARG);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   273
  __ b(loop_start);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   274
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   275
  __ bind(do_long);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   276
  __ ld(intSlot, -BytesPerWord, arg_java);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   277
  __ std(intSlot, 0, arg_c);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   278
  __ addi(arg_java, arg_java, - 2 * BytesPerWord);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   279
  __ addi(arg_c, arg_c, BytesPerWord);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   280
  __ cmplwi(CCR0, argcnt, max_int_register_arguments);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   281
  __ blt(CCR0, move_intSlot_to_ARG);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   282
  __ b(loop_start);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   283
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   284
  __ bind(do_float);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   285
  __ lfs(floatSlot, 0, arg_java);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   286
#if defined(LINUX)
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   287
  // Linux uses ELF ABI. Both original ELF and ELFv2 ABIs have float
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   288
  // in the least significant word of an argument slot.
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   289
#if defined(VM_LITTLE_ENDIAN)
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   290
  __ stfs(floatSlot, 0, arg_c);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   291
#else
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   292
  __ stfs(floatSlot, 4, arg_c);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   293
#endif
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   294
#elif defined(AIX)
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   295
  // Although AIX runs on big endian CPU, float is in most significant
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   296
  // word of an argument slot.
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   297
  __ stfs(floatSlot, 0, arg_c);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   298
#else
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   299
#error "unknown OS"
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   300
#endif
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   301
  __ addi(arg_java, arg_java, -BytesPerWord);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   302
  __ addi(arg_c, arg_c, BytesPerWord);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   303
  __ cmplwi(CCR0, fpcnt, max_fp_register_arguments);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   304
  __ blt(CCR0, move_floatSlot_to_FARG);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   305
  __ b(loop_start);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   306
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   307
  __ bind(do_double);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   308
  __ lfd(floatSlot, - BytesPerWord, arg_java);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   309
  __ stfd(floatSlot, 0, arg_c);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   310
  __ addi(arg_java, arg_java, - 2 * BytesPerWord);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   311
  __ addi(arg_c, arg_c, BytesPerWord);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   312
  __ cmplwi(CCR0, fpcnt, max_fp_register_arguments);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   313
  __ blt(CCR0, move_floatSlot_to_FARG);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   314
  __ b(loop_start);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   315
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   316
  __ bind(loop_end);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   317
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   318
  __ pop_frame();
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   319
  __ restore_nonvolatile_gprs(R1_SP, _spill_nonvolatiles_neg(r14));
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   320
  __ restore_LR_CR(R0);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   321
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   322
  __ blr();
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   323
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   324
  Label move_int_arg, move_float_arg;
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   325
  __ bind(move_int_arg); // each case must consist of 2 instructions (otherwise adapt LogSizeOfTwoInstructions)
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   326
  __ mr(R5_ARG3, intSlot);  __ b(loop_start);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   327
  __ mr(R6_ARG4, intSlot);  __ b(loop_start);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   328
  __ mr(R7_ARG5, intSlot);  __ b(loop_start);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   329
  __ mr(R8_ARG6, intSlot);  __ b(loop_start);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   330
  __ mr(R9_ARG7, intSlot);  __ b(loop_start);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   331
  __ mr(R10_ARG8, intSlot); __ b(loop_start);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   332
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   333
  __ bind(move_float_arg); // each case must consist of 2 instructions (otherwise adapt LogSizeOfTwoInstructions)
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   334
  __ fmr(F1_ARG1, floatSlot);   __ b(loop_start);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   335
  __ fmr(F2_ARG2, floatSlot);   __ b(loop_start);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   336
  __ fmr(F3_ARG3, floatSlot);   __ b(loop_start);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   337
  __ fmr(F4_ARG4, floatSlot);   __ b(loop_start);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   338
  __ fmr(F5_ARG5, floatSlot);   __ b(loop_start);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   339
  __ fmr(F6_ARG6, floatSlot);   __ b(loop_start);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   340
  __ fmr(F7_ARG7, floatSlot);   __ b(loop_start);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   341
  __ fmr(F8_ARG8, floatSlot);   __ b(loop_start);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   342
  __ fmr(F9_ARG9, floatSlot);   __ b(loop_start);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   343
  __ fmr(F10_ARG10, floatSlot); __ b(loop_start);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   344
  __ fmr(F11_ARG11, floatSlot); __ b(loop_start);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   345
  __ fmr(F12_ARG12, floatSlot); __ b(loop_start);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   346
  __ fmr(F13_ARG13, floatSlot); __ b(loop_start);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   347
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   348
  __ bind(move_intSlot_to_ARG);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   349
  __ sldi(R0, argcnt, LogSizeOfTwoInstructions);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   350
  __ load_const(R11_scratch1, move_int_arg); // Label must be bound here.
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   351
  __ add(R11_scratch1, R0, R11_scratch1);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   352
  __ mtctr(R11_scratch1/*branch_target*/);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   353
  __ bctr();
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   354
  __ bind(move_floatSlot_to_FARG);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   355
  __ sldi(R0, fpcnt, LogSizeOfTwoInstructions);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   356
  __ addi(fpcnt, fpcnt, 1);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   357
  __ load_const(R11_scratch1, move_float_arg); // Label must be bound here.
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   358
  __ add(R11_scratch1, R0, R11_scratch1);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   359
  __ mtctr(R11_scratch1/*branch_target*/);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   360
  __ bctr();
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   361
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   362
  return entry;
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   363
}
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   364
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   365
address TemplateInterpreterGenerator::generate_result_handler_for(BasicType type) {
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   366
  //
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   367
  // Registers alive
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   368
  //   R3_RET
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   369
  //   LR
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   370
  //
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   371
  // Registers updated
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   372
  //   R3_RET
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   373
  //
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   374
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   375
  Label done;
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   376
  address entry = __ pc();
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   377
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   378
  switch (type) {
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   379
  case T_BOOLEAN:
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   380
    // convert !=0 to 1
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   381
    __ neg(R0, R3_RET);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   382
    __ orr(R0, R3_RET, R0);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   383
    __ srwi(R3_RET, R0, 31);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   384
    break;
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   385
  case T_BYTE:
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   386
     // sign extend 8 bits
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   387
     __ extsb(R3_RET, R3_RET);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   388
     break;
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   389
  case T_CHAR:
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   390
     // zero extend 16 bits
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   391
     __ clrldi(R3_RET, R3_RET, 48);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   392
     break;
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   393
  case T_SHORT:
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   394
     // sign extend 16 bits
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   395
     __ extsh(R3_RET, R3_RET);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   396
     break;
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   397
  case T_INT:
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   398
     // sign extend 32 bits
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   399
     __ extsw(R3_RET, R3_RET);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   400
     break;
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   401
  case T_LONG:
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   402
     break;
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   403
  case T_OBJECT:
44406
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
   404
    // JNIHandles::resolve result.
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
   405
    __ resolve_jobject(R3_RET, R11_scratch1, R12_scratch2, /* needs_frame */ true); // kills R31
35479
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   406
    break;
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   407
  case T_FLOAT:
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   408
     break;
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   409
  case T_DOUBLE:
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   410
     break;
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   411
  case T_VOID:
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   412
     break;
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   413
  default: ShouldNotReachHere();
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   414
  }
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   415
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   416
  BIND(done);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   417
  __ blr();
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   418
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   419
  return entry;
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   420
}
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   421
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   422
// Abstract method entry.
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   423
//
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   424
address TemplateInterpreterGenerator::generate_abstract_entry(void) {
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   425
  address entry = __ pc();
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   426
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   427
  //
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   428
  // Registers alive
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   429
  //   R16_thread     - JavaThread*
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   430
  //   R19_method     - callee's method (method to be invoked)
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   431
  //   R1_SP          - SP prepared such that caller's outgoing args are near top
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   432
  //   LR             - return address to caller
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   433
  //
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   434
  // Stack layout at this point:
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   435
  //
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   436
  //   0       [TOP_IJAVA_FRAME_ABI]         <-- R1_SP
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   437
  //           alignment (optional)
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   438
  //           [outgoing Java arguments]
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   439
  //           ...
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   440
  //   PARENT  [PARENT_IJAVA_FRAME_ABI]
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   441
  //            ...
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   442
  //
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   443
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   444
  // Can't use call_VM here because we have not set up a new
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   445
  // interpreter state. Make the call to the vm and make it look like
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   446
  // our caller set up the JavaFrameAnchor.
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   447
  __ set_top_ijava_frame_at_SP_as_last_Java_frame(R1_SP, R12_scratch2/*tmp*/);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   448
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   449
  // Push a new C frame and save LR.
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   450
  __ save_LR_CR(R0);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   451
  __ push_frame_reg_args(0, R11_scratch1);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   452
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   453
  // This is not a leaf but we have a JavaFrameAnchor now and we will
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   454
  // check (create) exceptions afterward so this is ok.
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   455
  __ call_VM_leaf(CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_AbstractMethodError),
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   456
                  R16_thread);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   457
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   458
  // Pop the C frame and restore LR.
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   459
  __ pop_frame();
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   460
  __ restore_LR_CR(R0);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   461
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   462
  // Reset JavaFrameAnchor from call_VM_leaf above.
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   463
  __ reset_last_Java_frame();
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   464
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   465
  // We don't know our caller, so jump to the general forward exception stub,
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   466
  // which will also pop our full frame off. Satisfy the interface of
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   467
  // SharedRuntime::generate_forward_exception()
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   468
  __ load_const_optimized(R11_scratch1, StubRoutines::forward_exception_entry(), R0);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   469
  __ mtctr(R11_scratch1);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   470
  __ bctr();
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   471
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   472
  return entry;
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   473
}
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   474
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   475
// Interpreter intrinsic for WeakReference.get().
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   476
// 1. Don't push a full blown frame and go on dispatching, but fetch the value
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   477
//    into R8 and return quickly
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   478
// 2. If G1 is active we *must* execute this intrinsic for corrrectness:
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   479
//    It contains a GC barrier which puts the reference into the satb buffer
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   480
//    to indicate that someone holds a strong reference to the object the
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   481
//    weak ref points to!
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   482
address TemplateInterpreterGenerator::generate_Reference_get_entry(void) {
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   483
  // Code: _aload_0, _getfield, _areturn
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   484
  // parameter size = 1
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   485
  //
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   486
  // The code that gets generated by this routine is split into 2 parts:
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   487
  //    1. the "intrinsified" code for G1 (or any SATB based GC),
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   488
  //    2. the slow path - which is an expansion of the regular method entry.
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   489
  //
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   490
  // Notes:
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   491
  // * In the G1 code we do not check whether we need to block for
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   492
  //   a safepoint. If G1 is enabled then we must execute the specialized
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   493
  //   code for Reference.get (except when the Reference object is null)
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   494
  //   so that we can log the value in the referent field with an SATB
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   495
  //   update buffer.
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   496
  //   If the code for the getfield template is modified so that the
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   497
  //   G1 pre-barrier code is executed when the current method is
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   498
  //   Reference.get() then going through the normal method entry
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   499
  //   will be fine.
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   500
  // * The G1 code can, however, check the receiver object (the instance
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   501
  //   of java.lang.Reference) and jump to the slow path if null. If the
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   502
  //   Reference object is null then we obviously cannot fetch the referent
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   503
  //   and so we don't need to call the G1 pre-barrier. Thus we can use the
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   504
  //   regular method entry code to generate the NPE.
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   505
  //
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   506
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   507
  if (UseG1GC) {
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   508
    address entry = __ pc();
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   509
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   510
    const int referent_offset = java_lang_ref_Reference::referent_offset;
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   511
    guarantee(referent_offset > 0, "referent offset not initialized");
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   512
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   513
    Label slow_path;
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   514
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   515
    // Debugging not possible, so can't use __ skip_if_jvmti_mode(slow_path, GR31_SCRATCH);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   516
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   517
    // In the G1 code we don't check if we need to reach a safepoint. We
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   518
    // continue and the thread will safepoint at the next bytecode dispatch.
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   519
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   520
    // If the receiver is null then it is OK to jump to the slow path.
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   521
    __ ld(R3_RET, Interpreter::stackElementSize, R15_esp); // get receiver
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   522
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   523
    // Check if receiver == NULL and go the slow path.
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   524
    __ cmpdi(CCR0, R3_RET, 0);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   525
    __ beq(CCR0, slow_path);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   526
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   527
    // Load the value of the referent field.
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   528
    __ load_heap_oop(R3_RET, referent_offset, R3_RET);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   529
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   530
    // Generate the G1 pre-barrier code to log the value of
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   531
    // the referent field in an SATB buffer. Note with
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   532
    // these parameters the pre-barrier does not generate
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   533
    // the load of the previous value.
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   534
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   535
    // Restore caller sp for c2i case.
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   536
#ifdef ASSERT
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   537
      __ ld(R9_ARG7, 0, R1_SP);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   538
      __ ld(R10_ARG8, 0, R21_sender_SP);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   539
      __ cmpd(CCR0, R9_ARG7, R10_ARG8);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   540
      __ asm_assert_eq("backlink", 0x544);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   541
#endif // ASSERT
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   542
    __ mr(R1_SP, R21_sender_SP); // Cut the stack back to where the caller started.
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   543
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   544
    __ g1_write_barrier_pre(noreg,         // obj
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   545
                            noreg,         // offset
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   546
                            R3_RET,        // pre_val
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   547
                            R11_scratch1,  // tmp
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   548
                            R12_scratch2,  // tmp
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   549
                            true);         // needs_frame
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   550
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   551
    __ blr();
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   552
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   553
    // Generate regular method entry.
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   554
    __ bind(slow_path);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   555
    __ jump_to_entry(Interpreter::entry_for_kind(Interpreter::zerolocals), R11_scratch1);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   556
    return entry;
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   557
  }
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   558
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   559
  return NULL;
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   560
}
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   561
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   562
address TemplateInterpreterGenerator::generate_StackOverflowError_handler() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   563
  address entry = __ pc();
38734
69ced2325f58 8156922: [ppc] Implement template interpreter stack overflow checks as on x86/sparc.
goetz
parents: 38127
diff changeset
   564
69ced2325f58 8156922: [ppc] Implement template interpreter stack overflow checks as on x86/sparc.
goetz
parents: 38127
diff changeset
   565
  // Expression stack must be empty before entering the VM if an
69ced2325f58 8156922: [ppc] Implement template interpreter stack overflow checks as on x86/sparc.
goetz
parents: 38127
diff changeset
   566
  // exception happened.
69ced2325f58 8156922: [ppc] Implement template interpreter stack overflow checks as on x86/sparc.
goetz
parents: 38127
diff changeset
   567
  __ empty_expression_stack();
69ced2325f58 8156922: [ppc] Implement template interpreter stack overflow checks as on x86/sparc.
goetz
parents: 38127
diff changeset
   568
  // Throw exception.
69ced2325f58 8156922: [ppc] Implement template interpreter stack overflow checks as on x86/sparc.
goetz
parents: 38127
diff changeset
   569
  __ call_VM(noreg,
69ced2325f58 8156922: [ppc] Implement template interpreter stack overflow checks as on x86/sparc.
goetz
parents: 38127
diff changeset
   570
             CAST_FROM_FN_PTR(address,
69ced2325f58 8156922: [ppc] Implement template interpreter stack overflow checks as on x86/sparc.
goetz
parents: 38127
diff changeset
   571
                              InterpreterRuntime::throw_StackOverflowError));
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   572
  return entry;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   573
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   574
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   575
address TemplateInterpreterGenerator::generate_ArrayIndexOutOfBounds_handler(const char* name) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   576
  address entry = __ pc();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   577
  __ empty_expression_stack();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   578
  __ load_const_optimized(R4_ARG2, (address) name);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   579
  // Index is in R17_tos.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   580
  __ mr(R5_ARG3, R17_tos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   581
  __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_ArrayIndexOutOfBoundsException));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   582
  return entry;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   583
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   584
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   585
#if 0
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   586
// Call special ClassCastException constructor taking object to cast
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   587
// and target class as arguments.
24349
d8f40e5b392d 8042309: Some bugfixes for the ppc64 port.
goetz
parents: 24018
diff changeset
   588
address TemplateInterpreterGenerator::generate_ClassCastException_verbose_handler() {
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   589
  address entry = __ pc();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   590
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   591
  // Expression stack must be empty before entering the VM if an
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   592
  // exception happened.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   593
  __ empty_expression_stack();
24349
d8f40e5b392d 8042309: Some bugfixes for the ppc64 port.
goetz
parents: 24018
diff changeset
   594
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   595
  // Thread will be loaded to R3_ARG1.
24349
d8f40e5b392d 8042309: Some bugfixes for the ppc64 port.
goetz
parents: 24018
diff changeset
   596
  // Target class oop is in register R5_ARG3 by convention!
28187
fc19df82d6ee 8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents: 25950
diff changeset
   597
  __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_ClassCastException_verbose), R17_tos, R5_ARG3);
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   598
  // Above call must not return here since exception pending.
24349
d8f40e5b392d 8042309: Some bugfixes for the ppc64 port.
goetz
parents: 24018
diff changeset
   599
  DEBUG_ONLY(__ should_not_reach_here();)
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   600
  return entry;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   601
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   602
#endif
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   603
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   604
address TemplateInterpreterGenerator::generate_ClassCastException_handler() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   605
  address entry = __ pc();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   606
  // Expression stack must be empty before entering the VM if an
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   607
  // exception happened.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   608
  __ empty_expression_stack();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   609
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   610
  // Load exception object.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   611
  // Thread will be loaded to R3_ARG1.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   612
  __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_ClassCastException), R17_tos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   613
#ifdef ASSERT
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   614
  // Above call must not return here since exception pending.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   615
  __ should_not_reach_here();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   616
#endif
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   617
  return entry;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   618
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   619
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   620
address TemplateInterpreterGenerator::generate_exception_handler_common(const char* name, const char* message, bool pass_oop) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   621
  address entry = __ pc();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   622
  //__ untested("generate_exception_handler_common");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   623
  Register Rexception = R17_tos;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   624
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   625
  // Expression stack must be empty before entering the VM if an exception happened.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   626
  __ empty_expression_stack();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   627
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   628
  __ load_const_optimized(R4_ARG2, (address) name, R11_scratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   629
  if (pass_oop) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   630
    __ mr(R5_ARG3, Rexception);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   631
    __ call_VM(Rexception, CAST_FROM_FN_PTR(address, InterpreterRuntime::create_klass_exception), false);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   632
  } else {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   633
    __ load_const_optimized(R5_ARG3, (address) message, R11_scratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   634
    __ call_VM(Rexception, CAST_FROM_FN_PTR(address, InterpreterRuntime::create_exception), false);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   635
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   636
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   637
  // Throw exception.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   638
  __ mr(R3_ARG1, Rexception);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   639
  __ load_const_optimized(R11_scratch1, Interpreter::throw_exception_entry(), R12_scratch2);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   640
  __ mtctr(R11_scratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   641
  __ bctr();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   642
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   643
  return entry;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   644
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   645
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   646
// This entry is returned to when a call returns to the interpreter.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   647
// When we arrive here, we expect that the callee stack frame is already popped.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   648
address TemplateInterpreterGenerator::generate_return_entry_for(TosState state, int step, size_t index_size) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   649
  address entry = __ pc();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   650
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   651
  // Move the value out of the return register back to the TOS cache of current frame.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   652
  switch (state) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   653
    case ltos:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   654
    case btos:
37488
ab63cdc0e14e 8154867: PPC64: Better byte behavior
mdoerr
parents: 37152
diff changeset
   655
    case ztos:
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   656
    case ctos:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   657
    case stos:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   658
    case atos:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   659
    case itos: __ mr(R17_tos, R3_RET); break;   // RET -> TOS cache
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   660
    case ftos:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   661
    case dtos: __ fmr(F15_ftos, F1_RET); break; // TOS cache -> GR_FRET
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   662
    case vtos: break;                           // Nothing to do, this was a void return.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   663
    default  : ShouldNotReachHere();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   664
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   665
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   666
  __ restore_interpreter_state(R11_scratch1); // Sets R11_scratch1 = fp.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   667
  __ ld(R12_scratch2, _ijava_state_neg(top_frame_sp), R11_scratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   668
  __ resize_frame_absolute(R12_scratch2, R11_scratch1, R0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   669
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   670
  // Compiled code destroys templateTableBase, reload.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   671
  __ load_const_optimized(R25_templateTableBase, (address)Interpreter::dispatch_table((TosState)0), R12_scratch2);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   672
28187
fc19df82d6ee 8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents: 25950
diff changeset
   673
  if (state == atos) {
fc19df82d6ee 8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents: 25950
diff changeset
   674
    __ profile_return_type(R3_RET, R11_scratch1, R12_scratch2);
fc19df82d6ee 8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents: 25950
diff changeset
   675
  }
fc19df82d6ee 8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents: 25950
diff changeset
   676
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   677
  const Register cache = R11_scratch1;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   678
  const Register size  = R12_scratch2;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   679
  __ get_cache_and_index_at_bcp(cache, 1, index_size);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   680
25916
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 25715
diff changeset
   681
  // Get least significant byte of 64 bit value:
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 25715
diff changeset
   682
#if defined(VM_LITTLE_ENDIAN)
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 25715
diff changeset
   683
  __ lbz(size, in_bytes(ConstantPoolCache::base_offset() + ConstantPoolCacheEntry::flags_offset()), cache);
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 25715
diff changeset
   684
#else
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   685
  __ lbz(size, in_bytes(ConstantPoolCache::base_offset() + ConstantPoolCacheEntry::flags_offset()) + 7, cache);
25916
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 25715
diff changeset
   686
#endif
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   687
  __ sldi(size, size, Interpreter::logStackElementSize);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   688
  __ add(R15_esp, R15_esp, size);
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: 46263
diff changeset
   689
345a46524a19 8172020: Internal Error (cpu/arm/vm/frame_arm.cpp:571): assert(obj == __null || Universe::heap()->is_in(obj)) failed: sanity check #
cjplummer
parents: 46263
diff changeset
   690
 __ check_and_handle_popframe(R11_scratch1);
345a46524a19 8172020: Internal Error (cpu/arm/vm/frame_arm.cpp:571): assert(obj == __null || Universe::heap()->is_in(obj)) failed: sanity check #
cjplummer
parents: 46263
diff changeset
   691
 __ check_and_handle_earlyret(R11_scratch1);
345a46524a19 8172020: Internal Error (cpu/arm/vm/frame_arm.cpp:571): assert(obj == __null || Universe::heap()->is_in(obj)) failed: sanity check #
cjplummer
parents: 46263
diff changeset
   692
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   693
  __ dispatch_next(state, step);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   694
  return entry;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   695
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   696
47916
bdbef8638948 8190817: deopt special-case for _return_register_finalizer is confusing and leads to bugs
dlong
parents: 47586
diff changeset
   697
address TemplateInterpreterGenerator::generate_deopt_entry_for(TosState state, int step, address continuation) {
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   698
  address entry = __ pc();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   699
  // If state != vtos, we're returning from a native method, which put it's result
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   700
  // into the result register. So move the value out of the return register back
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   701
  // to the TOS cache of current frame.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   702
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   703
  switch (state) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   704
    case ltos:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   705
    case btos:
37488
ab63cdc0e14e 8154867: PPC64: Better byte behavior
mdoerr
parents: 37152
diff changeset
   706
    case ztos:
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   707
    case ctos:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   708
    case stos:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   709
    case atos:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   710
    case itos: __ mr(R17_tos, R3_RET); break;   // GR_RET -> TOS cache
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   711
    case ftos:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   712
    case dtos: __ fmr(F15_ftos, F1_RET); break; // TOS cache -> GR_FRET
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   713
    case vtos: break;                           // Nothing to do, this was a void return.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   714
    default  : ShouldNotReachHere();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   715
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   716
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   717
  // Load LcpoolCache @@@ should be already set!
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   718
  __ get_constant_pool_cache(R27_constPoolCache);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   719
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   720
  // Handle a pending exception, fall through if none.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   721
  __ check_and_forward_exception(R11_scratch1, R12_scratch2);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   722
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   723
  // Start executing bytecodes.
47916
bdbef8638948 8190817: deopt special-case for _return_register_finalizer is confusing and leads to bugs
dlong
parents: 47586
diff changeset
   724
  if (continuation == NULL) {
bdbef8638948 8190817: deopt special-case for _return_register_finalizer is confusing and leads to bugs
dlong
parents: 47586
diff changeset
   725
    __ dispatch_next(state, step);
bdbef8638948 8190817: deopt special-case for _return_register_finalizer is confusing and leads to bugs
dlong
parents: 47586
diff changeset
   726
  } else {
bdbef8638948 8190817: deopt special-case for _return_register_finalizer is confusing and leads to bugs
dlong
parents: 47586
diff changeset
   727
    __ jump_to_entry(continuation, R11_scratch1);
bdbef8638948 8190817: deopt special-case for _return_register_finalizer is confusing and leads to bugs
dlong
parents: 47586
diff changeset
   728
  }
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   729
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   730
  return entry;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   731
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   732
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   733
address TemplateInterpreterGenerator::generate_safept_entry_for(TosState state, address runtime_entry) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   734
  address entry = __ pc();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   735
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   736
  __ push(state);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   737
  __ call_VM(noreg, runtime_entry);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   738
  __ dispatch_via(vtos, Interpreter::_normal_table.table_for(vtos));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   739
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   740
  return entry;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   741
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   742
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   743
// Helpers for commoning out cases in the various type of method entries.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   744
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   745
// Increment invocation count & check for overflow.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   746
//
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   747
// Note: checking for negative value instead of overflow
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   748
//       so we have a 'sticky' overflow test.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   749
//
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   750
void TemplateInterpreterGenerator::generate_counter_incr(Label* overflow, Label* profile_method, Label* profile_method_continue) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   751
  // Note: In tiered we increment either counters in method or in MDO depending if we're profiling or not.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   752
  Register Rscratch1   = R11_scratch1;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   753
  Register Rscratch2   = R12_scratch2;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   754
  Register R3_counters = R3_ARG1;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   755
  Label done;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   756
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   757
  if (TieredCompilation) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   758
    const int increment = InvocationCounter::count_increment;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   759
    Label no_mdo;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   760
    if (ProfileInterpreter) {
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 33070
diff changeset
   761
      const Register Rmdo = R3_counters;
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   762
      // If no method data exists, go to profile_continue.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   763
      __ ld(Rmdo, in_bytes(Method::method_data_offset()), R19_method);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   764
      __ cmpdi(CCR0, Rmdo, 0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   765
      __ beq(CCR0, no_mdo);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   766
35156
a06b3d7455d6 8145913: PPC64: add Montgomery multiply intrinsic
mdoerr
parents: 35135
diff changeset
   767
      // Increment invocation counter in the MDO.
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 33070
diff changeset
   768
      const int mdo_ic_offs = in_bytes(MethodData::invocation_counter_offset()) + in_bytes(InvocationCounter::counter_offset());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 33070
diff changeset
   769
      __ lwz(Rscratch2, mdo_ic_offs, Rmdo);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 33070
diff changeset
   770
      __ lwz(Rscratch1, in_bytes(MethodData::invoke_mask_offset()), Rmdo);
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   771
      __ addi(Rscratch2, Rscratch2, increment);
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 33070
diff changeset
   772
      __ stw(Rscratch2, mdo_ic_offs, Rmdo);
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   773
      __ and_(Rscratch1, Rscratch2, Rscratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   774
      __ bne(CCR0, done);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   775
      __ b(*overflow);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   776
    }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   777
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   778
    // Increment counter in MethodCounters*.
35156
a06b3d7455d6 8145913: PPC64: add Montgomery multiply intrinsic
mdoerr
parents: 35135
diff changeset
   779
    const int mo_ic_offs = in_bytes(MethodCounters::invocation_counter_offset()) + in_bytes(InvocationCounter::counter_offset());
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   780
    __ bind(no_mdo);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   781
    __ get_method_counters(R19_method, R3_counters, done);
35156
a06b3d7455d6 8145913: PPC64: add Montgomery multiply intrinsic
mdoerr
parents: 35135
diff changeset
   782
    __ lwz(Rscratch2, mo_ic_offs, R3_counters);
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 33070
diff changeset
   783
    __ lwz(Rscratch1, in_bytes(MethodCounters::invoke_mask_offset()), R3_counters);
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   784
    __ addi(Rscratch2, Rscratch2, increment);
35156
a06b3d7455d6 8145913: PPC64: add Montgomery multiply intrinsic
mdoerr
parents: 35135
diff changeset
   785
    __ stw(Rscratch2, mo_ic_offs, R3_counters);
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   786
    __ and_(Rscratch1, Rscratch2, Rscratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   787
    __ beq(CCR0, *overflow);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   788
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   789
    __ bind(done);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   790
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   791
  } else {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   792
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   793
    // Update standard invocation counters.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   794
    Register Rsum_ivc_bec = R4_ARG2;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   795
    __ get_method_counters(R19_method, R3_counters, done);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   796
    __ increment_invocation_counter(R3_counters, Rsum_ivc_bec, R12_scratch2);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   797
    // Increment interpreter invocation counter.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   798
    if (ProfileInterpreter) {  // %%% Merge this into methodDataOop.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   799
      __ lwz(R12_scratch2, in_bytes(MethodCounters::interpreter_invocation_counter_offset()), R3_counters);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   800
      __ addi(R12_scratch2, R12_scratch2, 1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   801
      __ stw(R12_scratch2, in_bytes(MethodCounters::interpreter_invocation_counter_offset()), R3_counters);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   802
    }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   803
    // Check if we must create a method data obj.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   804
    if (ProfileInterpreter && profile_method != NULL) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   805
      const Register profile_limit = Rscratch1;
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 33070
diff changeset
   806
      __ lwz(profile_limit, in_bytes(MethodCounters::interpreter_profile_limit_offset()), R3_counters);
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   807
      // Test to see if we should create a method data oop.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   808
      __ cmpw(CCR0, Rsum_ivc_bec, profile_limit);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   809
      __ blt(CCR0, *profile_method_continue);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   810
      // If no method data exists, go to profile_method.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   811
      __ test_method_data_pointer(*profile_method);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   812
    }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   813
    // Finally check for counter overflow.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   814
    if (overflow) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   815
      const Register invocation_limit = Rscratch1;
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 33070
diff changeset
   816
      __ lwz(invocation_limit, in_bytes(MethodCounters::interpreter_invocation_limit_offset()), R3_counters);
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   817
      __ cmpw(CCR0, Rsum_ivc_bec, invocation_limit);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   818
      __ bge(CCR0, *overflow);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   819
    }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   820
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   821
    __ bind(done);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   822
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   823
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   824
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   825
// Generate code to initiate compilation on invocation counter overflow.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   826
void TemplateInterpreterGenerator::generate_counter_overflow(Label& continue_entry) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   827
  // Generate code to initiate compilation on the counter overflow.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   828
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   829
  // InterpreterRuntime::frequency_counter_overflow takes one arguments,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   830
  // which indicates if the counter overflow occurs at a backwards branch (NULL bcp)
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   831
  // We pass zero in.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   832
  // The call returns the address of the verified entry point for the method or NULL
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   833
  // if the compilation did not complete (either went background or bailed out).
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   834
  //
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   835
  // Unlike the C++ interpreter above: Check exceptions!
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   836
  // Assumption: Caller must set the flag "do_not_unlock_if_sychronized" if the monitor of a sync'ed
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   837
  // method has not yet been created. Thus, no unlocking of a non-existing monitor can occur.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   838
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   839
  __ li(R4_ARG2, 0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   840
  __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::frequency_counter_overflow), R4_ARG2, true);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   841
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   842
  // Returns verified_entry_point or NULL.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   843
  // We ignore it in any case.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   844
  __ b(continue_entry);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   845
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   846
39390
edf6a424a8b7 8159335: Fix problems with stack overflow handling.
goetz
parents: 38734
diff changeset
   847
// See if we've got enough room on the stack for locals plus overhead below
edf6a424a8b7 8159335: Fix problems with stack overflow handling.
goetz
parents: 38734
diff changeset
   848
// JavaThread::stack_overflow_limit(). If not, throw a StackOverflowError
edf6a424a8b7 8159335: Fix problems with stack overflow handling.
goetz
parents: 38734
diff changeset
   849
// without going through the signal handler, i.e., reserved and yellow zones
edf6a424a8b7 8159335: Fix problems with stack overflow handling.
goetz
parents: 38734
diff changeset
   850
// will not be made usable. The shadow zone must suffice to handle the
edf6a424a8b7 8159335: Fix problems with stack overflow handling.
goetz
parents: 38734
diff changeset
   851
// overflow.
edf6a424a8b7 8159335: Fix problems with stack overflow handling.
goetz
parents: 38734
diff changeset
   852
//
edf6a424a8b7 8159335: Fix problems with stack overflow handling.
goetz
parents: 38734
diff changeset
   853
// Kills Rmem_frame_size, Rscratch1.
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   854
void TemplateInterpreterGenerator::generate_stack_overflow_check(Register Rmem_frame_size, Register Rscratch1) {
39390
edf6a424a8b7 8159335: Fix problems with stack overflow handling.
goetz
parents: 38734
diff changeset
   855
  Label done;
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   856
  assert_different_registers(Rmem_frame_size, Rscratch1);
39390
edf6a424a8b7 8159335: Fix problems with stack overflow handling.
goetz
parents: 38734
diff changeset
   857
edf6a424a8b7 8159335: Fix problems with stack overflow handling.
goetz
parents: 38734
diff changeset
   858
  BLOCK_COMMENT("stack_overflow_check_with_compare {");
edf6a424a8b7 8159335: Fix problems with stack overflow handling.
goetz
parents: 38734
diff changeset
   859
  __ sub(Rmem_frame_size, R1_SP, Rmem_frame_size);
edf6a424a8b7 8159335: Fix problems with stack overflow handling.
goetz
parents: 38734
diff changeset
   860
  __ ld(Rscratch1, thread_(stack_overflow_limit));
edf6a424a8b7 8159335: Fix problems with stack overflow handling.
goetz
parents: 38734
diff changeset
   861
  __ cmpld(CCR0/*is_stack_overflow*/, Rmem_frame_size, Rscratch1);
edf6a424a8b7 8159335: Fix problems with stack overflow handling.
goetz
parents: 38734
diff changeset
   862
  __ bgt(CCR0/*is_stack_overflow*/, done);
edf6a424a8b7 8159335: Fix problems with stack overflow handling.
goetz
parents: 38734
diff changeset
   863
edf6a424a8b7 8159335: Fix problems with stack overflow handling.
goetz
parents: 38734
diff changeset
   864
  // The stack overflows. Load target address of the runtime stub and call it.
edf6a424a8b7 8159335: Fix problems with stack overflow handling.
goetz
parents: 38734
diff changeset
   865
  assert(StubRoutines::throw_StackOverflowError_entry() != NULL, "generated in wrong order");
edf6a424a8b7 8159335: Fix problems with stack overflow handling.
goetz
parents: 38734
diff changeset
   866
  __ load_const_optimized(Rscratch1, (StubRoutines::throw_StackOverflowError_entry()), R0);
edf6a424a8b7 8159335: Fix problems with stack overflow handling.
goetz
parents: 38734
diff changeset
   867
  __ mtctr(Rscratch1);
edf6a424a8b7 8159335: Fix problems with stack overflow handling.
goetz
parents: 38734
diff changeset
   868
  // Restore caller_sp.
edf6a424a8b7 8159335: Fix problems with stack overflow handling.
goetz
parents: 38734
diff changeset
   869
#ifdef ASSERT
edf6a424a8b7 8159335: Fix problems with stack overflow handling.
goetz
parents: 38734
diff changeset
   870
  __ ld(Rscratch1, 0, R1_SP);
edf6a424a8b7 8159335: Fix problems with stack overflow handling.
goetz
parents: 38734
diff changeset
   871
  __ ld(R0, 0, R21_sender_SP);
edf6a424a8b7 8159335: Fix problems with stack overflow handling.
goetz
parents: 38734
diff changeset
   872
  __ cmpd(CCR0, R0, Rscratch1);
edf6a424a8b7 8159335: Fix problems with stack overflow handling.
goetz
parents: 38734
diff changeset
   873
  __ asm_assert_eq("backlink", 0x547);
edf6a424a8b7 8159335: Fix problems with stack overflow handling.
goetz
parents: 38734
diff changeset
   874
#endif // ASSERT
edf6a424a8b7 8159335: Fix problems with stack overflow handling.
goetz
parents: 38734
diff changeset
   875
  __ mr(R1_SP, R21_sender_SP);
edf6a424a8b7 8159335: Fix problems with stack overflow handling.
goetz
parents: 38734
diff changeset
   876
  __ bctr();
edf6a424a8b7 8159335: Fix problems with stack overflow handling.
goetz
parents: 38734
diff changeset
   877
edf6a424a8b7 8159335: Fix problems with stack overflow handling.
goetz
parents: 38734
diff changeset
   878
  __ align(32, 12);
edf6a424a8b7 8159335: Fix problems with stack overflow handling.
goetz
parents: 38734
diff changeset
   879
  __ bind(done);
edf6a424a8b7 8159335: Fix problems with stack overflow handling.
goetz
parents: 38734
diff changeset
   880
  BLOCK_COMMENT("} stack_overflow_check_with_compare");
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   881
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   882
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   883
// Lock the current method, interpreter register window must be set up!
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   884
void TemplateInterpreterGenerator::lock_method(Register Rflags, Register Rscratch1, Register Rscratch2, bool flags_preloaded) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   885
  const Register Robj_to_lock = Rscratch2;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   886
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   887
  {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   888
    if (!flags_preloaded) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   889
      __ lwz(Rflags, method_(access_flags));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   890
    }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   891
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   892
#ifdef ASSERT
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   893
    // Check if methods needs synchronization.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   894
    {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   895
      Label Lok;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   896
      __ testbitdi(CCR0, R0, Rflags, JVM_ACC_SYNCHRONIZED_BIT);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   897
      __ btrue(CCR0,Lok);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   898
      __ stop("method doesn't need synchronization");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   899
      __ bind(Lok);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   900
    }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   901
#endif // ASSERT
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   902
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   903
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   904
  // Get synchronization object to Rscratch2.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   905
  {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   906
    Label Lstatic;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   907
    Label Ldone;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   908
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   909
    __ testbitdi(CCR0, R0, Rflags, JVM_ACC_STATIC_BIT);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   910
    __ btrue(CCR0, Lstatic);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   911
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   912
    // Non-static case: load receiver obj from stack and we're done.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   913
    __ ld(Robj_to_lock, R18_locals);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   914
    __ b(Ldone);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   915
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   916
    __ bind(Lstatic); // Static case: Lock the java mirror
42068
18c8a4d5998e 8168083: PPC64: Cleanup template interpreter after 8154580 and 8154867
mdoerr
parents: 41341
diff changeset
   917
    // Load mirror from interpreter frame.
18c8a4d5998e 8168083: PPC64: Cleanup template interpreter after 8154580 and 8154867
mdoerr
parents: 41341
diff changeset
   918
    __ ld(Robj_to_lock, _abi(callers_sp), R1_SP);
18c8a4d5998e 8168083: PPC64: Cleanup template interpreter after 8154580 and 8154867
mdoerr
parents: 41341
diff changeset
   919
    __ ld(Robj_to_lock, _ijava_state_neg(mirror), Robj_to_lock);
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   920
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   921
    __ bind(Ldone);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   922
    __ verify_oop(Robj_to_lock);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   923
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   924
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   925
  // Got the oop to lock => execute!
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   926
  __ add_monitor_to_stack(true, Rscratch1, R0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   927
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   928
  __ std(Robj_to_lock, BasicObjectLock::obj_offset_in_bytes(), R26_monitor);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   929
  __ lock_object(R26_monitor, Robj_to_lock);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   930
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   931
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   932
// Generate a fixed interpreter frame for pure interpreter
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   933
// and I2N native transition frames.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   934
//
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   935
// Before (stack grows downwards):
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   936
//
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   937
//         |  ...         |
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   938
//         |------------- |
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   939
//         |  java arg0   |
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   940
//         |  ...         |
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   941
//         |  java argn   |
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   942
//         |              |   <-   R15_esp
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   943
//         |              |
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   944
//         |--------------|
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   945
//         | abi_112      |
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   946
//         |              |   <-   R1_SP
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   947
//         |==============|
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   948
//
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   949
//
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   950
// After:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   951
//
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   952
//         |  ...         |
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   953
//         |  java arg0   |<-   R18_locals
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   954
//         |  ...         |
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   955
//         |  java argn   |
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   956
//         |--------------|
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   957
//         |              |
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   958
//         |  java locals |
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   959
//         |              |
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   960
//         |--------------|
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   961
//         |  abi_48      |
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   962
//         |==============|
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   963
//         |              |
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   964
//         |   istate     |
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   965
//         |              |
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   966
//         |--------------|
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   967
//         |   monitor    |<-   R26_monitor
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   968
//         |--------------|
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   969
//         |              |<-   R15_esp
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   970
//         | expression   |
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   971
//         | stack        |
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   972
//         |              |
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   973
//         |--------------|
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   974
//         |              |
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   975
//         | abi_112      |<-   R1_SP
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   976
//         |==============|
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   977
//
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   978
// The top most frame needs an abi space of 112 bytes. This space is needed,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   979
// since we call to c. The c function may spill their arguments to the caller
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   980
// frame. When we call to java, we don't need these spill slots. In order to save
38734
69ced2325f58 8156922: [ppc] Implement template interpreter stack overflow checks as on x86/sparc.
goetz
parents: 38127
diff changeset
   981
// space on the stack, we resize the caller. However, java locals reside in
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   982
// the caller frame and the frame has to be increased. The frame_size for the
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   983
// current frame was calculated based on max_stack as size for the expression
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   984
// stack. At the call, just a part of the expression stack might be used.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   985
// We don't want to waste this space and cut the frame back accordingly.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   986
// The resulting amount for resizing is calculated as follows:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   987
// resize =   (number_of_locals - number_of_arguments) * slot_size
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   988
//          + (R1_SP - R15_esp) + 48
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   989
//
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   990
// The size for the callee frame is calculated:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   991
// framesize = 112 + max_stack + monitor + state_size
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   992
//
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   993
// maxstack:   Max number of slots on the expression stack, loaded from the method.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   994
// monitor:    We statically reserve room for one monitor object.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   995
// state_size: We save the current state of the interpreter to this area.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   996
//
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   997
void TemplateInterpreterGenerator::generate_fixed_frame(bool native_call, Register Rsize_of_parameters, Register Rsize_of_locals) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   998
  Register parent_frame_resize = R6_ARG4, // Frame will grow by this number of bytes.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   999
           top_frame_size      = R7_ARG5,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1000
           Rconst_method       = R8_ARG6;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1001
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1002
  assert_different_registers(Rsize_of_parameters, Rsize_of_locals, parent_frame_resize, top_frame_size);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1003
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1004
  __ ld(Rconst_method, method_(const));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1005
  __ lhz(Rsize_of_parameters /* number of params */,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1006
         in_bytes(ConstMethod::size_of_parameters_offset()), Rconst_method);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1007
  if (native_call) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1008
    // If we're calling a native method, we reserve space for the worst-case signature
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1009
    // handler varargs vector, which is max(Argument::n_register_parameters, parameter_count+2).
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1010
    // We add two slots to the parameter_count, one for the jni
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1011
    // environment and one for a possible native mirror.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1012
    Label skip_native_calculate_max_stack;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1013
    __ addi(top_frame_size, Rsize_of_parameters, 2);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1014
    __ cmpwi(CCR0, top_frame_size, Argument::n_register_parameters);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1015
    __ bge(CCR0, skip_native_calculate_max_stack);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1016
    __ li(top_frame_size, Argument::n_register_parameters);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1017
    __ bind(skip_native_calculate_max_stack);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1018
    __ sldi(Rsize_of_parameters, Rsize_of_parameters, Interpreter::logStackElementSize);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1019
    __ sldi(top_frame_size, top_frame_size, Interpreter::logStackElementSize);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1020
    __ sub(parent_frame_resize, R1_SP, R15_esp); // <0, off by Interpreter::stackElementSize!
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1021
    assert(Rsize_of_locals == noreg, "Rsize_of_locals not initialized"); // Only relevant value is Rsize_of_parameters.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1022
  } else {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1023
    __ lhz(Rsize_of_locals /* number of params */, in_bytes(ConstMethod::size_of_locals_offset()), Rconst_method);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1024
    __ sldi(Rsize_of_parameters, Rsize_of_parameters, Interpreter::logStackElementSize);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1025
    __ sldi(Rsize_of_locals, Rsize_of_locals, Interpreter::logStackElementSize);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1026
    __ lhz(top_frame_size, in_bytes(ConstMethod::max_stack_offset()), Rconst_method);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1027
    __ sub(R11_scratch1, Rsize_of_locals, Rsize_of_parameters); // >=0
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1028
    __ sub(parent_frame_resize, R1_SP, R15_esp); // <0, off by Interpreter::stackElementSize!
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1029
    __ sldi(top_frame_size, top_frame_size, Interpreter::logStackElementSize);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1030
    __ add(parent_frame_resize, parent_frame_resize, R11_scratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1031
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1032
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1033
  // Compute top frame size.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1034
  __ addi(top_frame_size, top_frame_size, frame::abi_reg_args_size + frame::ijava_state_size);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1035
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1036
  // Cut back area between esp and max_stack.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1037
  __ addi(parent_frame_resize, parent_frame_resize, frame::abi_minframe_size - Interpreter::stackElementSize);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1038
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1039
  __ round_to(top_frame_size, frame::alignment_in_bytes);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1040
  __ round_to(parent_frame_resize, frame::alignment_in_bytes);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1041
  // parent_frame_resize = (locals-parameters) - (ESP-SP-ABI48) Rounded to frame alignment size.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1042
  // Enlarge by locals-parameters (not in case of native_call), shrink by ESP-SP-ABI48.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1043
38734
69ced2325f58 8156922: [ppc] Implement template interpreter stack overflow checks as on x86/sparc.
goetz
parents: 38127
diff changeset
  1044
  if (!native_call) {
39390
edf6a424a8b7 8159335: Fix problems with stack overflow handling.
goetz
parents: 38734
diff changeset
  1045
    // Stack overflow check.
edf6a424a8b7 8159335: Fix problems with stack overflow handling.
goetz
parents: 38734
diff changeset
  1046
    // Native calls don't need the stack size check since they have no
edf6a424a8b7 8159335: Fix problems with stack overflow handling.
goetz
parents: 38734
diff changeset
  1047
    // expression stack and the arguments are already on the stack and
edf6a424a8b7 8159335: Fix problems with stack overflow handling.
goetz
parents: 38734
diff changeset
  1048
    // we only add a handful of words to the stack.
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1049
    __ add(R11_scratch1, parent_frame_resize, top_frame_size);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1050
    generate_stack_overflow_check(R11_scratch1, R12_scratch2);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1051
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1052
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1053
  // Set up interpreter state registers.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1054
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1055
  __ add(R18_locals, R15_esp, Rsize_of_parameters);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1056
  __ ld(R27_constPoolCache, in_bytes(ConstMethod::constants_offset()), Rconst_method);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1057
  __ ld(R27_constPoolCache, ConstantPool::cache_offset_in_bytes(), R27_constPoolCache);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1058
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1059
  // Set method data pointer.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1060
  if (ProfileInterpreter) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1061
    Label zero_continue;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1062
    __ ld(R28_mdx, method_(method_data));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1063
    __ cmpdi(CCR0, R28_mdx, 0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1064
    __ beq(CCR0, zero_continue);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1065
    __ addi(R28_mdx, R28_mdx, in_bytes(MethodData::data_offset()));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1066
    __ bind(zero_continue);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1067
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1068
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1069
  if (native_call) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1070
    __ li(R14_bcp, 0); // Must initialize.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1071
  } else {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1072
    __ add(R14_bcp, in_bytes(ConstMethod::codes_offset()), Rconst_method);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1073
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1074
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1075
  // Resize parent frame.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1076
  __ mflr(R12_scratch2);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1077
  __ neg(parent_frame_resize, parent_frame_resize);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1078
  __ resize_frame(parent_frame_resize, R11_scratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1079
  __ std(R12_scratch2, _abi(lr), R1_SP);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1080
42068
18c8a4d5998e 8168083: PPC64: Cleanup template interpreter after 8154580 and 8154867
mdoerr
parents: 41341
diff changeset
  1081
  // Get mirror and store it in the frame as GC root for this Method*.
18c8a4d5998e 8168083: PPC64: Cleanup template interpreter after 8154580 and 8154867
mdoerr
parents: 41341
diff changeset
  1082
  __ load_mirror_from_const_method(R12_scratch2, Rconst_method);
18c8a4d5998e 8168083: PPC64: Cleanup template interpreter after 8154580 and 8154867
mdoerr
parents: 41341
diff changeset
  1083
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1084
  __ addi(R26_monitor, R1_SP, - frame::ijava_state_size);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1085
  __ addi(R15_esp, R26_monitor, - Interpreter::stackElementSize);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1086
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1087
  // Store values.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1088
  // R15_esp, R14_bcp, R26_monitor, R28_mdx are saved at java calls
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1089
  // in InterpreterMacroAssembler::call_from_interpreter.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1090
  __ std(R19_method, _ijava_state_neg(method), R1_SP);
38074
8475fdc6dcc3 8154580: Save mirror in interpreter frame to enable cleanups of CLDClosure
coleenp
parents: 37152
diff changeset
  1091
  __ std(R12_scratch2, _ijava_state_neg(mirror), R1_SP);
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1092
  __ std(R21_sender_SP, _ijava_state_neg(sender_sp), R1_SP);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1093
  __ std(R27_constPoolCache, _ijava_state_neg(cpoolCache), R1_SP);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1094
  __ std(R18_locals, _ijava_state_neg(locals), R1_SP);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1095
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1096
  // Note: esp, bcp, monitor, mdx live in registers. Hence, the correct version can only
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1097
  // be found in the frame after save_interpreter_state is done. This is always true
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1098
  // for non-top frames. But when a signal occurs, dumping the top frame can go wrong,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1099
  // because e.g. frame::interpreter_frame_bcp() will not access the correct value
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1100
  // (Enhanced Stack Trace).
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1101
  // The signal handler does not save the interpreter state into the frame.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1102
  __ li(R0, 0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1103
#ifdef ASSERT
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1104
  // Fill remaining slots with constants.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1105
  __ load_const_optimized(R11_scratch1, 0x5afe);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1106
  __ load_const_optimized(R12_scratch2, 0xdead);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1107
#endif
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1108
  // We have to initialize some frame slots for native calls (accessed by GC).
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1109
  if (native_call) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1110
    __ std(R26_monitor, _ijava_state_neg(monitors), R1_SP);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1111
    __ std(R14_bcp, _ijava_state_neg(bcp), R1_SP);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1112
    if (ProfileInterpreter) { __ std(R28_mdx, _ijava_state_neg(mdx), R1_SP); }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1113
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1114
#ifdef ASSERT
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1115
  else {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1116
    __ std(R12_scratch2, _ijava_state_neg(monitors), R1_SP);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1117
    __ std(R12_scratch2, _ijava_state_neg(bcp), R1_SP);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1118
    __ std(R12_scratch2, _ijava_state_neg(mdx), R1_SP);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1119
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1120
  __ std(R11_scratch1, _ijava_state_neg(ijava_reserved), R1_SP);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1121
  __ std(R12_scratch2, _ijava_state_neg(esp), R1_SP);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1122
  __ std(R12_scratch2, _ijava_state_neg(lresult), R1_SP);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1123
  __ std(R12_scratch2, _ijava_state_neg(fresult), R1_SP);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1124
#endif
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1125
  __ subf(R12_scratch2, top_frame_size, R1_SP);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1126
  __ std(R0, _ijava_state_neg(oop_tmp), R1_SP);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1127
  __ std(R12_scratch2, _ijava_state_neg(top_frame_sp), R1_SP);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1128
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1129
  // Push top frame.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1130
  __ push_frame(top_frame_size, R11_scratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1131
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1132
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1133
// End of helpers
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1134
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1135
address TemplateInterpreterGenerator::generate_math_entry(AbstractInterpreter::MethodKind kind) {
42884
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42068
diff changeset
  1136
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42068
diff changeset
  1137
  // Decide what to do: Use same platform specific instructions and runtime calls as compilers.
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42068
diff changeset
  1138
  bool use_instruction = false;
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42068
diff changeset
  1139
  address runtime_entry = NULL;
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42068
diff changeset
  1140
  int num_args = 1;
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42068
diff changeset
  1141
  bool double_precision = true;
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42068
diff changeset
  1142
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42068
diff changeset
  1143
  // PPC64 specific:
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42068
diff changeset
  1144
  switch (kind) {
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42068
diff changeset
  1145
    case Interpreter::java_lang_math_sqrt: use_instruction = VM_Version::has_fsqrt(); break;
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42068
diff changeset
  1146
    case Interpreter::java_lang_math_abs:  use_instruction = true; break;
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42068
diff changeset
  1147
    case Interpreter::java_lang_math_fmaF:
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42068
diff changeset
  1148
    case Interpreter::java_lang_math_fmaD: use_instruction = UseFMA; break;
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42068
diff changeset
  1149
    default: break; // Fall back to runtime call.
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1150
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1151
42884
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42068
diff changeset
  1152
  switch (kind) {
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42068
diff changeset
  1153
    case Interpreter::java_lang_math_sin  : runtime_entry = CAST_FROM_FN_PTR(address, SharedRuntime::dsin);   break;
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42068
diff changeset
  1154
    case Interpreter::java_lang_math_cos  : runtime_entry = CAST_FROM_FN_PTR(address, SharedRuntime::dcos);   break;
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42068
diff changeset
  1155
    case Interpreter::java_lang_math_tan  : runtime_entry = CAST_FROM_FN_PTR(address, SharedRuntime::dtan);   break;
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42068
diff changeset
  1156
    case Interpreter::java_lang_math_abs  : /* run interpreted */ break;
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42068
diff changeset
  1157
    case Interpreter::java_lang_math_sqrt : runtime_entry = CAST_FROM_FN_PTR(address, SharedRuntime::dsqrt);  break;
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42068
diff changeset
  1158
    case Interpreter::java_lang_math_log  : runtime_entry = CAST_FROM_FN_PTR(address, SharedRuntime::dlog);   break;
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42068
diff changeset
  1159
    case Interpreter::java_lang_math_log10: runtime_entry = CAST_FROM_FN_PTR(address, SharedRuntime::dlog10); break;
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42068
diff changeset
  1160
    case Interpreter::java_lang_math_pow  : runtime_entry = CAST_FROM_FN_PTR(address, SharedRuntime::dpow); num_args = 2; break;
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42068
diff changeset
  1161
    case Interpreter::java_lang_math_exp  : runtime_entry = CAST_FROM_FN_PTR(address, SharedRuntime::dexp);   break;
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42068
diff changeset
  1162
    case Interpreter::java_lang_math_fmaF : /* run interpreted */ num_args = 3; double_precision = false; break;
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42068
diff changeset
  1163
    case Interpreter::java_lang_math_fmaD : /* run interpreted */ num_args = 3; break;
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42068
diff changeset
  1164
    default: ShouldNotReachHere();
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42068
diff changeset
  1165
  }
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42068
diff changeset
  1166
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42068
diff changeset
  1167
  // Use normal entry if neither instruction nor runtime call is used.
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42068
diff changeset
  1168
  if (!use_instruction && runtime_entry == NULL) return NULL;
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42068
diff changeset
  1169
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1170
  address entry = __ pc();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1171
42884
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42068
diff changeset
  1172
  // Load arguments
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42068
diff changeset
  1173
  assert(num_args <= 13, "passed in registers");
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42068
diff changeset
  1174
  if (double_precision) {
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42068
diff changeset
  1175
    int offset = (2 * num_args - 1) * Interpreter::stackElementSize;
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42068
diff changeset
  1176
    for (int i = 0; i < num_args; ++i) {
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42068
diff changeset
  1177
      __ lfd(as_FloatRegister(F1_ARG1->encoding() + i), offset, R15_esp);
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42068
diff changeset
  1178
      offset -= 2 * Interpreter::stackElementSize;
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42068
diff changeset
  1179
    }
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42068
diff changeset
  1180
  } else {
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42068
diff changeset
  1181
    int offset = num_args * Interpreter::stackElementSize;
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42068
diff changeset
  1182
    for (int i = 0; i < num_args; ++i) {
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42068
diff changeset
  1183
      __ lfs(as_FloatRegister(F1_ARG1->encoding() + i), offset, R15_esp);
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42068
diff changeset
  1184
      offset -= Interpreter::stackElementSize;
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42068
diff changeset
  1185
    }
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42068
diff changeset
  1186
  }
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1187
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1188
  // Pop c2i arguments (if any) off when we return.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1189
#ifdef ASSERT
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1190
  __ ld(R9_ARG7, 0, R1_SP);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1191
  __ ld(R10_ARG8, 0, R21_sender_SP);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1192
  __ cmpd(CCR0, R9_ARG7, R10_ARG8);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1193
  __ asm_assert_eq("backlink", 0x545);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1194
#endif // ASSERT
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1195
  __ mr(R1_SP, R21_sender_SP); // Cut the stack back to where the caller started.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1196
42884
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42068
diff changeset
  1197
  if (use_instruction) {
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42068
diff changeset
  1198
    switch (kind) {
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42068
diff changeset
  1199
      case Interpreter::java_lang_math_sqrt: __ fsqrt(F1_RET, F1);          break;
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42068
diff changeset
  1200
      case Interpreter::java_lang_math_abs:  __ fabs(F1_RET, F1);           break;
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42068
diff changeset
  1201
      case Interpreter::java_lang_math_fmaF: __ fmadds(F1_RET, F1, F2, F3); break;
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42068
diff changeset
  1202
      case Interpreter::java_lang_math_fmaD: __ fmadd(F1_RET, F1, F2, F3);  break;
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42068
diff changeset
  1203
      default: ShouldNotReachHere();
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42068
diff changeset
  1204
    }
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1205
  } else {
42884
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42068
diff changeset
  1206
    // Comment: Can use tail call if the unextended frame is always C ABI compliant:
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42068
diff changeset
  1207
    //__ load_const_optimized(R12_scratch2, runtime_entry, R0);
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42068
diff changeset
  1208
    //__ call_c_and_return_to_caller(R12_scratch2);
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42068
diff changeset
  1209
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42068
diff changeset
  1210
    // Push a new C frame and save LR.
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42068
diff changeset
  1211
    __ save_LR_CR(R0);
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42068
diff changeset
  1212
    __ push_frame_reg_args(0, R11_scratch1);
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42068
diff changeset
  1213
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42068
diff changeset
  1214
    __ call_VM_leaf(runtime_entry);
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42068
diff changeset
  1215
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42068
diff changeset
  1216
    // Pop the C frame and restore LR.
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42068
diff changeset
  1217
    __ pop_frame();
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42068
diff changeset
  1218
    __ restore_LR_CR(R0);
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1219
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1220
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1221
  __ blr();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1222
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1223
  __ flush();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1224
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1225
  return entry;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1226
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1227
38734
69ced2325f58 8156922: [ppc] Implement template interpreter stack overflow checks as on x86/sparc.
goetz
parents: 38127
diff changeset
  1228
void TemplateInterpreterGenerator::bang_stack_shadow_pages(bool native_call) {
69ced2325f58 8156922: [ppc] Implement template interpreter stack overflow checks as on x86/sparc.
goetz
parents: 38127
diff changeset
  1229
  // Quick & dirty stack overflow checking: bang the stack & handle trap.
69ced2325f58 8156922: [ppc] Implement template interpreter stack overflow checks as on x86/sparc.
goetz
parents: 38127
diff changeset
  1230
  // Note that we do the banging after the frame is setup, since the exception
69ced2325f58 8156922: [ppc] Implement template interpreter stack overflow checks as on x86/sparc.
goetz
parents: 38127
diff changeset
  1231
  // handling code expects to find a valid interpreter frame on the stack.
69ced2325f58 8156922: [ppc] Implement template interpreter stack overflow checks as on x86/sparc.
goetz
parents: 38127
diff changeset
  1232
  // Doing the banging earlier fails if the caller frame is not an interpreter
69ced2325f58 8156922: [ppc] Implement template interpreter stack overflow checks as on x86/sparc.
goetz
parents: 38127
diff changeset
  1233
  // frame.
69ced2325f58 8156922: [ppc] Implement template interpreter stack overflow checks as on x86/sparc.
goetz
parents: 38127
diff changeset
  1234
  // (Also, the exception throwing code expects to unlock any synchronized
69ced2325f58 8156922: [ppc] Implement template interpreter stack overflow checks as on x86/sparc.
goetz
parents: 38127
diff changeset
  1235
  // method receiever, so do the banging after locking the receiver.)
69ced2325f58 8156922: [ppc] Implement template interpreter stack overflow checks as on x86/sparc.
goetz
parents: 38127
diff changeset
  1236
69ced2325f58 8156922: [ppc] Implement template interpreter stack overflow checks as on x86/sparc.
goetz
parents: 38127
diff changeset
  1237
  // Bang each page in the shadow zone. We can't assume it's been done for
69ced2325f58 8156922: [ppc] Implement template interpreter stack overflow checks as on x86/sparc.
goetz
parents: 38127
diff changeset
  1238
  // an interpreter frame with greater than a page of locals, so each page
69ced2325f58 8156922: [ppc] Implement template interpreter stack overflow checks as on x86/sparc.
goetz
parents: 38127
diff changeset
  1239
  // needs to be checked.  Only true for non-native.
69ced2325f58 8156922: [ppc] Implement template interpreter stack overflow checks as on x86/sparc.
goetz
parents: 38127
diff changeset
  1240
  if (UseStackBanging) {
69ced2325f58 8156922: [ppc] Implement template interpreter stack overflow checks as on x86/sparc.
goetz
parents: 38127
diff changeset
  1241
    const int page_size = os::vm_page_size();
69ced2325f58 8156922: [ppc] Implement template interpreter stack overflow checks as on x86/sparc.
goetz
parents: 38127
diff changeset
  1242
    const int n_shadow_pages = ((int)JavaThread::stack_shadow_zone_size()) / page_size;
69ced2325f58 8156922: [ppc] Implement template interpreter stack overflow checks as on x86/sparc.
goetz
parents: 38127
diff changeset
  1243
    const int start_page = native_call ? n_shadow_pages : 1;
69ced2325f58 8156922: [ppc] Implement template interpreter stack overflow checks as on x86/sparc.
goetz
parents: 38127
diff changeset
  1244
    BLOCK_COMMENT("bang_stack_shadow_pages:");
69ced2325f58 8156922: [ppc] Implement template interpreter stack overflow checks as on x86/sparc.
goetz
parents: 38127
diff changeset
  1245
    for (int pages = start_page; pages <= n_shadow_pages; pages++) {
69ced2325f58 8156922: [ppc] Implement template interpreter stack overflow checks as on x86/sparc.
goetz
parents: 38127
diff changeset
  1246
      __ bang_stack_with_offset(pages*page_size);
69ced2325f58 8156922: [ppc] Implement template interpreter stack overflow checks as on x86/sparc.
goetz
parents: 38127
diff changeset
  1247
    }
69ced2325f58 8156922: [ppc] Implement template interpreter stack overflow checks as on x86/sparc.
goetz
parents: 38127
diff changeset
  1248
  }
69ced2325f58 8156922: [ppc] Implement template interpreter stack overflow checks as on x86/sparc.
goetz
parents: 38127
diff changeset
  1249
}
69ced2325f58 8156922: [ppc] Implement template interpreter stack overflow checks as on x86/sparc.
goetz
parents: 38127
diff changeset
  1250
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1251
// Interpreter stub for calling a native method. (asm interpreter)
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1252
// This sets up a somewhat different looking stack for calling the
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1253
// native method than the typical interpreter frame setup.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1254
//
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1255
// On entry:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1256
//   R19_method    - method
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1257
//   R16_thread    - JavaThread*
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1258
//   R15_esp       - intptr_t* sender tos
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1259
//
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1260
//   abstract stack (grows up)
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1261
//     [  IJava (caller of JNI callee)  ]  <-- ASP
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1262
//        ...
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1263
address TemplateInterpreterGenerator::generate_native_entry(bool synchronized) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1264
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1265
  address entry = __ pc();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1266
31790
4a08476437e8 8025692: Log what methods are touched at run-time
minqi
parents: 30303
diff changeset
  1267
  const bool inc_counter = UseCompiler || CountCompiledCalls || LogTouchedMethods;
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1268
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1269
  // -----------------------------------------------------------------------------
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1270
  // Allocate a new frame that represents the native callee (i2n frame).
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1271
  // This is not a full-blown interpreter frame, but in particular, the
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1272
  // following registers are valid after this:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1273
  // - R19_method
38734
69ced2325f58 8156922: [ppc] Implement template interpreter stack overflow checks as on x86/sparc.
goetz
parents: 38127
diff changeset
  1274
  // - R18_local (points to start of arguments to native function)
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1275
  //
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1276
  //   abstract stack (grows up)
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1277
  //     [  IJava (caller of JNI callee)  ]  <-- ASP
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1278
  //        ...
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1279
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1280
  const Register signature_handler_fd = R11_scratch1;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1281
  const Register pending_exception    = R0;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1282
  const Register result_handler_addr  = R31;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1283
  const Register native_method_fd     = R11_scratch1;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1284
  const Register access_flags         = R22_tmp2;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1285
  const Register active_handles       = R11_scratch1; // R26_monitor saved to state.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1286
  const Register sync_state           = R12_scratch2;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1287
  const Register sync_state_addr      = sync_state;   // Address is dead after use.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1288
  const Register suspend_flags        = R11_scratch1;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1289
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1290
  //=============================================================================
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1291
  // Allocate new frame and initialize interpreter state.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1292
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1293
  Label exception_return;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1294
  Label exception_return_sync_check;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1295
  Label stack_overflow_return;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1296
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1297
  // Generate new interpreter state and jump to stack_overflow_return in case of
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1298
  // a stack overflow.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1299
  //generate_compute_interpreter_state(stack_overflow_return);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1300
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1301
  Register size_of_parameters = R22_tmp2;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1302
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1303
  generate_fixed_frame(true, size_of_parameters, noreg /* unused */);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1304
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1305
  //=============================================================================
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1306
  // Increment invocation counter. On overflow, entry to JNI method
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1307
  // will be compiled.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1308
  Label invocation_counter_overflow, continue_after_compile;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1309
  if (inc_counter) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1310
    if (synchronized) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1311
      // Since at this point in the method invocation the exception handler
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1312
      // would try to exit the monitor of synchronized methods which hasn't
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1313
      // been entered yet, we set the thread local variable
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1314
      // _do_not_unlock_if_synchronized to true. If any exception was thrown by
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1315
      // runtime, exception handling i.e. unlock_if_synchronized_method will
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1316
      // check this thread local flag.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1317
      // This flag has two effects, one is to force an unwind in the topmost
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1318
      // interpreter frame and not perform an unlock while doing so.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1319
      __ li(R0, 1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1320
      __ stb(R0, in_bytes(JavaThread::do_not_unlock_if_synchronized_offset()), R16_thread);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1321
    }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1322
    generate_counter_incr(&invocation_counter_overflow, NULL, NULL);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1323
31861
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1324
    BIND(continue_after_compile);
38734
69ced2325f58 8156922: [ppc] Implement template interpreter stack overflow checks as on x86/sparc.
goetz
parents: 38127
diff changeset
  1325
  }
69ced2325f58 8156922: [ppc] Implement template interpreter stack overflow checks as on x86/sparc.
goetz
parents: 38127
diff changeset
  1326
69ced2325f58 8156922: [ppc] Implement template interpreter stack overflow checks as on x86/sparc.
goetz
parents: 38127
diff changeset
  1327
  bang_stack_shadow_pages(true);
69ced2325f58 8156922: [ppc] Implement template interpreter stack overflow checks as on x86/sparc.
goetz
parents: 38127
diff changeset
  1328
69ced2325f58 8156922: [ppc] Implement template interpreter stack overflow checks as on x86/sparc.
goetz
parents: 38127
diff changeset
  1329
  if (inc_counter) {
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1330
    // Reset the _do_not_unlock_if_synchronized flag.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1331
    if (synchronized) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1332
      __ li(R0, 0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1333
      __ stb(R0, in_bytes(JavaThread::do_not_unlock_if_synchronized_offset()), R16_thread);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1334
    }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1335
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1336
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1337
  // access_flags = method->access_flags();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1338
  // Load access flags.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1339
  assert(access_flags->is_nonvolatile(),
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1340
         "access_flags must be in a non-volatile register");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1341
  // Type check.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1342
  assert(4 == sizeof(AccessFlags), "unexpected field size");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1343
  __ lwz(access_flags, method_(access_flags));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1344
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1345
  // We don't want to reload R19_method and access_flags after calls
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1346
  // to some helper functions.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1347
  assert(R19_method->is_nonvolatile(),
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1348
         "R19_method must be a non-volatile register");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1349
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1350
  // Check for synchronized methods. Must happen AFTER invocation counter
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1351
  // check, so method is not locked if counter overflows.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1352
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1353
  if (synchronized) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1354
    lock_method(access_flags, R11_scratch1, R12_scratch2, true);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1355
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1356
    // Update monitor in state.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1357
    __ ld(R11_scratch1, 0, R1_SP);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1358
    __ std(R26_monitor, _ijava_state_neg(monitors), R11_scratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1359
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1360
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1361
  // jvmti/jvmpi support
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1362
  __ notify_method_entry();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1363
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1364
  //=============================================================================
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1365
  // Get and call the signature handler.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1366
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1367
  __ ld(signature_handler_fd, method_(signature_handler));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1368
  Label call_signature_handler;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1369
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1370
  __ cmpdi(CCR0, signature_handler_fd, 0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1371
  __ bne(CCR0, call_signature_handler);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1372
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1373
  // Method has never been called. Either generate a specialized
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1374
  // handler or point to the slow one.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1375
  //
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1376
  // Pass parameter 'false' to avoid exception check in call_VM.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1377
  __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::prepare_native_call), R19_method, false);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1378
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1379
  // Check for an exception while looking up the target method. If we
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1380
  // incurred one, bail.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1381
  __ ld(pending_exception, thread_(pending_exception));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1382
  __ cmpdi(CCR0, pending_exception, 0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1383
  __ bne(CCR0, exception_return_sync_check); // Has pending exception.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1384
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1385
  // Reload signature handler, it may have been created/assigned in the meanwhile.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1386
  __ ld(signature_handler_fd, method_(signature_handler));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1387
  __ twi_0(signature_handler_fd); // Order wrt. load of klass mirror and entry point (isync is below).
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1388
31861
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1389
  BIND(call_signature_handler);
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1390
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1391
  // Before we call the signature handler we push a new frame to
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1392
  // protect the interpreter frame volatile registers when we return
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1393
  // from jni but before we can get back to Java.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1394
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1395
  // First set the frame anchor while the SP/FP registers are
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1396
  // convenient and the slow signature handler can use this same frame
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1397
  // anchor.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1398
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1399
  // We have a TOP_IJAVA_FRAME here, which belongs to us.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1400
  __ set_top_ijava_frame_at_SP_as_last_Java_frame(R1_SP, R12_scratch2/*tmp*/);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1401
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1402
  // Now the interpreter frame (and its call chain) have been
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1403
  // invalidated and flushed. We are now protected against eager
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1404
  // being enabled in native code. Even if it goes eager the
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1405
  // registers will be reloaded as clean and we will invalidate after
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1406
  // the call so no spurious flush should be possible.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1407
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1408
  // Call signature handler and pass locals address.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1409
  //
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1410
  // Our signature handlers copy required arguments to the C stack
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1411
  // (outgoing C args), R3_ARG1 to R10_ARG8, and FARG1 to FARG13.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1412
  __ mr(R3_ARG1, R18_locals);
25916
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 25715
diff changeset
  1413
#if !defined(ABI_ELFv2)
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1414
  __ ld(signature_handler_fd, 0, signature_handler_fd);
25916
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 25715
diff changeset
  1415
#endif
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1416
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1417
  __ call_stub(signature_handler_fd);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1418
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1419
  // Remove the register parameter varargs slots we allocated in
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1420
  // compute_interpreter_state. SP+16 ends up pointing to the ABI
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1421
  // outgoing argument area.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1422
  //
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1423
  // Not needed on PPC64.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1424
  //__ add(SP, SP, Argument::n_register_parameters*BytesPerWord);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1425
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1426
  assert(result_handler_addr->is_nonvolatile(), "result_handler_addr must be in a non-volatile register");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1427
  // Save across call to native method.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1428
  __ mr(result_handler_addr, R3_RET);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1429
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1430
  __ isync(); // Acquire signature handler before trying to fetch the native entry point and klass mirror.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1431
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1432
  // Set up fixed parameters and call the native method.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1433
  // If the method is static, get mirror into R4_ARG2.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1434
  {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1435
    Label method_is_not_static;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1436
    // Access_flags is non-volatile and still, no need to restore it.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1437
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1438
    // Restore access flags.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1439
    __ testbitdi(CCR0, R0, access_flags, JVM_ACC_STATIC_BIT);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1440
    __ bfalse(CCR0, method_is_not_static);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1441
42068
18c8a4d5998e 8168083: PPC64: Cleanup template interpreter after 8154580 and 8154867
mdoerr
parents: 41341
diff changeset
  1442
    __ ld(R11_scratch1, _abi(callers_sp), R1_SP);
18c8a4d5998e 8168083: PPC64: Cleanup template interpreter after 8154580 and 8154867
mdoerr
parents: 41341
diff changeset
  1443
    // Load mirror from interpreter frame.
18c8a4d5998e 8168083: PPC64: Cleanup template interpreter after 8154580 and 8154867
mdoerr
parents: 41341
diff changeset
  1444
    __ ld(R12_scratch2, _ijava_state_neg(mirror), R11_scratch1);
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1445
    // R4_ARG2 = &state->_oop_temp;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1446
    __ addi(R4_ARG2, R11_scratch1, _ijava_state_neg(oop_tmp));
42068
18c8a4d5998e 8168083: PPC64: Cleanup template interpreter after 8154580 and 8154867
mdoerr
parents: 41341
diff changeset
  1447
    __ std(R12_scratch2/*mirror*/, _ijava_state_neg(oop_tmp), R11_scratch1);
31861
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1448
    BIND(method_is_not_static);
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1449
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1450
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1451
  // At this point, arguments have been copied off the stack into
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1452
  // their JNI positions. Oops are boxed in-place on the stack, with
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1453
  // handles copied to arguments. The result handler address is in a
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1454
  // register.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1455
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1456
  // Pass JNIEnv address as first parameter.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1457
  __ addir(R3_ARG1, thread_(jni_environment));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1458
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1459
  // Load the native_method entry before we change the thread state.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1460
  __ ld(native_method_fd, method_(native_function));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1461
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1462
  //=============================================================================
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1463
  // Transition from _thread_in_Java to _thread_in_native. As soon as
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1464
  // we make this change the safepoint code needs to be certain that
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1465
  // the last Java frame we established is good. The pc in that frame
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1466
  // just needs to be near here not an actual return address.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1467
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1468
  // We use release_store_fence to update values like the thread state, where
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1469
  // we don't want the current thread to continue until all our prior memory
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1470
  // accesses (including the new thread state) are visible to other threads.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1471
  __ li(R0, _thread_in_native);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1472
  __ release();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1473
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1474
  // TODO PPC port assert(4 == JavaThread::sz_thread_state(), "unexpected field size");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1475
  __ stw(R0, thread_(thread_state));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1476
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1477
  //=============================================================================
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1478
  // Call the native method. Argument registers must not have been
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1479
  // overwritten since "__ call_stub(signature_handler);" (except for
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1480
  // ARG1 and ARG2 for static methods).
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1481
  __ call_c(native_method_fd);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1482
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1483
  __ li(R0, 0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1484
  __ ld(R11_scratch1, 0, R1_SP);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1485
  __ std(R3_RET, _ijava_state_neg(lresult), R11_scratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1486
  __ stfd(F1_RET, _ijava_state_neg(fresult), R11_scratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1487
  __ std(R0/*mirror*/, _ijava_state_neg(oop_tmp), R11_scratch1); // reset
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1488
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1489
  // Note: C++ interpreter needs the following here:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1490
  // The frame_manager_lr field, which we use for setting the last
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1491
  // java frame, gets overwritten by the signature handler. Restore
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1492
  // it now.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1493
  //__ get_PC_trash_LR(R11_scratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1494
  //__ std(R11_scratch1, _top_ijava_frame_abi(frame_manager_lr), R1_SP);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1495
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1496
  // Because of GC R19_method may no longer be valid.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1497
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1498
  // Block, if necessary, before resuming in _thread_in_Java state.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1499
  // In order for GC to work, don't clear the last_Java_sp until after
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1500
  // blocking.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1501
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1502
  //=============================================================================
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1503
  // Switch thread to "native transition" state before reading the
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1504
  // synchronization state. This additional state is necessary
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1505
  // because reading and testing the synchronization state is not
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1506
  // atomic w.r.t. GC, as this scenario demonstrates: Java thread A,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1507
  // in _thread_in_native state, loads _not_synchronized and is
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1508
  // preempted. VM thread changes sync state to synchronizing and
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1509
  // suspends threads for GC. Thread A is resumed to finish this
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1510
  // native method, but doesn't block here since it didn't see any
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1511
  // synchronization in progress, and escapes.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1512
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1513
  // We use release_store_fence to update values like the thread state, where
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1514
  // we don't want the current thread to continue until all our prior memory
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1515
  // accesses (including the new thread state) are visible to other threads.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1516
  __ li(R0/*thread_state*/, _thread_in_native_trans);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1517
  __ release();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1518
  __ stw(R0/*thread_state*/, thread_(thread_state));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1519
  if (UseMembar) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1520
    __ fence();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1521
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1522
  // Write serialization page so that the VM thread can do a pseudo remote
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1523
  // membar. We use the current thread pointer to calculate a thread
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1524
  // specific offset to write to within the page. This minimizes bus
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1525
  // traffic due to cache line collision.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1526
  else {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1527
    __ serialize_memory(R16_thread, R11_scratch1, R12_scratch2);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1528
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1529
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1530
  // Now before we return to java we must look for a current safepoint
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1531
  // (a new safepoint can not start since we entered native_trans).
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1532
  // We must check here because a current safepoint could be modifying
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1533
  // the callers registers right this moment.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1534
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1535
  // Acquire isn't strictly necessary here because of the fence, but
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1536
  // sync_state is declared to be volatile, so we do it anyway
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1537
  // (cmp-br-isync on one path, release (same as acquire on PPC64) on the other path).
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1538
48332
651a95f30dfb 8193257: PPC64, s390 implementation for Thread-local handshakes
mdoerr
parents: 47916
diff changeset
  1539
  Label do_safepoint, sync_check_done;
651a95f30dfb 8193257: PPC64, s390 implementation for Thread-local handshakes
mdoerr
parents: 47916
diff changeset
  1540
  // No synchronization in progress nor yet synchronized.
651a95f30dfb 8193257: PPC64, s390 implementation for Thread-local handshakes
mdoerr
parents: 47916
diff changeset
  1541
  __ safepoint_poll(do_safepoint, sync_state);
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1542
48332
651a95f30dfb 8193257: PPC64, s390 implementation for Thread-local handshakes
mdoerr
parents: 47916
diff changeset
  1543
  // Not suspended.
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1544
  // TODO PPC port assert(4 == Thread::sz_suspend_flags(), "unexpected field size");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1545
  __ lwz(suspend_flags, thread_(suspend_flags));
48332
651a95f30dfb 8193257: PPC64, s390 implementation for Thread-local handshakes
mdoerr
parents: 47916
diff changeset
  1546
  __ cmpwi(CCR1, suspend_flags, 0);
651a95f30dfb 8193257: PPC64, s390 implementation for Thread-local handshakes
mdoerr
parents: 47916
diff changeset
  1547
  __ beq(CCR1, sync_check_done);
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1548
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1549
  __ bind(do_safepoint);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1550
  __ isync();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1551
  // Block. We do the call directly and leave the current
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1552
  // last_Java_frame setup undisturbed. We must save any possible
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1553
  // native result across the call. No oop is present.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1554
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1555
  __ mr(R3_ARG1, R16_thread);
25916
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 25715
diff changeset
  1556
#if defined(ABI_ELFv2)
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 25715
diff changeset
  1557
  __ call_c(CAST_FROM_FN_PTR(address, JavaThread::check_special_condition_for_native_trans),
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 25715
diff changeset
  1558
            relocInfo::none);
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 25715
diff changeset
  1559
#else
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1560
  __ call_c(CAST_FROM_FN_PTR(FunctionDescriptor*, JavaThread::check_special_condition_for_native_trans),
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1561
            relocInfo::none);
25916
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 25715
diff changeset
  1562
#endif
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1563
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1564
  __ bind(sync_check_done);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1565
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1566
  //=============================================================================
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1567
  // <<<<<< Back in Interpreter Frame >>>>>
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1568
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1569
  // We are in thread_in_native_trans here and back in the normal
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1570
  // interpreter frame. We don't have to do anything special about
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1571
  // safepoints and we can switch to Java mode anytime we are ready.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1572
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1573
  // Note: frame::interpreter_frame_result has a dependency on how the
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1574
  // method result is saved across the call to post_method_exit. For
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1575
  // native methods it assumes that the non-FPU/non-void result is
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1576
  // saved in _native_lresult and a FPU result in _native_fresult. If
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1577
  // this changes then the interpreter_frame_result implementation
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1578
  // will need to be updated too.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1579
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1580
  // On PPC64, we have stored the result directly after the native call.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1581
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1582
  //=============================================================================
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1583
  // Back in Java
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1584
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1585
  // We use release_store_fence to update values like the thread state, where
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1586
  // we don't want the current thread to continue until all our prior memory
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1587
  // accesses (including the new thread state) are visible to other threads.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1588
  __ li(R0/*thread_state*/, _thread_in_Java);
48332
651a95f30dfb 8193257: PPC64, s390 implementation for Thread-local handshakes
mdoerr
parents: 47916
diff changeset
  1589
  __ lwsync(); // Acquire safepoint and suspend state, release thread state.
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1590
  __ stw(R0/*thread_state*/, thread_(thread_state));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1591
41341
9358c2e16446 8166777: [ppc] port "8164086: Checked JNI pending exception check should be cleared"
goetz
parents: 40071
diff changeset
  1592
  if (CheckJNICalls) {
9358c2e16446 8166777: [ppc] port "8164086: Checked JNI pending exception check should be cleared"
goetz
parents: 40071
diff changeset
  1593
    // clear_pending_jni_exception_check
9358c2e16446 8166777: [ppc] port "8164086: Checked JNI pending exception check should be cleared"
goetz
parents: 40071
diff changeset
  1594
    __ load_const_optimized(R0, 0L);
9358c2e16446 8166777: [ppc] port "8164086: Checked JNI pending exception check should be cleared"
goetz
parents: 40071
diff changeset
  1595
    __ st_ptr(R0, JavaThread::pending_jni_exception_check_fn_offset(), R16_thread);
9358c2e16446 8166777: [ppc] port "8164086: Checked JNI pending exception check should be cleared"
goetz
parents: 40071
diff changeset
  1596
  }
9358c2e16446 8166777: [ppc] port "8164086: Checked JNI pending exception check should be cleared"
goetz
parents: 40071
diff changeset
  1597
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1598
  __ reset_last_Java_frame();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1599
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1600
  // Jvmdi/jvmpi support. Whether we've got an exception pending or
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1601
  // not, and whether unlocking throws an exception or not, we notify
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1602
  // on native method exit. If we do have an exception, we'll end up
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1603
  // in the caller's context to handle it, so if we don't do the
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1604
  // notify here, we'll drop it on the floor.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1605
  __ notify_method_exit(true/*native method*/,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1606
                        ilgl /*illegal state (not used for native methods)*/,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1607
                        InterpreterMacroAssembler::NotifyJVMTI,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1608
                        false /*check_exceptions*/);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1609
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1610
  //=============================================================================
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1611
  // Handle exceptions
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1612
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1613
  if (synchronized) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1614
    // Don't check for exceptions since we're still in the i2n frame. Do that
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1615
    // manually afterwards.
40071
53e12df44b7b 8160245: C1: Clean up platform #defines in c1_LIR.hpp.
goetz
parents: 39390
diff changeset
  1616
    __ unlock_object(R26_monitor, false); // Can also unlock methods.
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1617
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1618
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1619
  // Reset active handles after returning from native.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1620
  // thread->active_handles()->clear();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1621
  __ ld(active_handles, thread_(active_handles));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1622
  // TODO PPC port assert(4 == JNIHandleBlock::top_size_in_bytes(), "unexpected field size");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1623
  __ li(R0, 0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1624
  __ stw(R0, JNIHandleBlock::top_offset_in_bytes(), active_handles);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1625
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1626
  Label exception_return_sync_check_already_unlocked;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1627
  __ ld(R0/*pending_exception*/, thread_(pending_exception));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1628
  __ cmpdi(CCR0, R0/*pending_exception*/, 0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1629
  __ bne(CCR0, exception_return_sync_check_already_unlocked);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1630
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1631
  //-----------------------------------------------------------------------------
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1632
  // No exception pending.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1633
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1634
  // Move native method result back into proper registers and return.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1635
  // Invoke result handler (may unbox/promote).
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1636
  __ ld(R11_scratch1, 0, R1_SP);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1637
  __ ld(R3_RET, _ijava_state_neg(lresult), R11_scratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1638
  __ lfd(F1_RET, _ijava_state_neg(fresult), R11_scratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1639
  __ call_stub(result_handler_addr);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1640
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1641
  __ merge_frames(/*top_frame_sp*/ R21_sender_SP, /*return_pc*/ R0, R11_scratch1, R12_scratch2);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1642
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1643
  // Must use the return pc which was loaded from the caller's frame
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1644
  // as the VM uses return-pc-patching for deoptimization.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1645
  __ mtlr(R0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1646
  __ blr();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1647
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1648
  //-----------------------------------------------------------------------------
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1649
  // An exception is pending. We call into the runtime only if the
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1650
  // caller was not interpreted. If it was interpreted the
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1651
  // interpreter will do the correct thing. If it isn't interpreted
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1652
  // (call stub/compiled code) we will change our return and continue.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1653
31861
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1654
  BIND(exception_return_sync_check);
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1655
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1656
  if (synchronized) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1657
    // Don't check for exceptions since we're still in the i2n frame. Do that
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1658
    // manually afterwards.
40071
53e12df44b7b 8160245: C1: Clean up platform #defines in c1_LIR.hpp.
goetz
parents: 39390
diff changeset
  1659
    __ unlock_object(R26_monitor, false); // Can also unlock methods.
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1660
  }
31861
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1661
  BIND(exception_return_sync_check_already_unlocked);
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1662
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1663
  const Register return_pc = R31;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1664
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1665
  __ ld(return_pc, 0, R1_SP);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1666
  __ ld(return_pc, _abi(lr), return_pc);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1667
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1668
  // Get the address of the exception handler.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1669
  __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::exception_handler_for_return_address),
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1670
                  R16_thread,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1671
                  return_pc /* return pc */);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1672
  __ merge_frames(/*top_frame_sp*/ R21_sender_SP, noreg, R11_scratch1, R12_scratch2);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1673
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1674
  // Load the PC of the the exception handler into LR.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1675
  __ mtlr(R3_RET);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1676
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1677
  // Load exception into R3_ARG1 and clear pending exception in thread.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1678
  __ ld(R3_ARG1/*exception*/, thread_(pending_exception));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1679
  __ li(R4_ARG2, 0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1680
  __ std(R4_ARG2, thread_(pending_exception));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1681
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1682
  // Load the original return pc into R4_ARG2.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1683
  __ mr(R4_ARG2/*issuing_pc*/, return_pc);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1684
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1685
  // Return to exception handler.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1686
  __ blr();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1687
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1688
  //=============================================================================
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1689
  // Counter overflow.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1690
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1691
  if (inc_counter) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1692
    // Handle invocation counter overflow.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1693
    __ bind(invocation_counter_overflow);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1694
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1695
    generate_counter_overflow(continue_after_compile);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1696
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1697
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1698
  return entry;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1699
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1700
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1701
// Generic interpreted method entry to (asm) interpreter.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1702
//
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1703
address TemplateInterpreterGenerator::generate_normal_entry(bool synchronized) {
31790
4a08476437e8 8025692: Log what methods are touched at run-time
minqi
parents: 30303
diff changeset
  1704
  bool inc_counter = UseCompiler || CountCompiledCalls || LogTouchedMethods;
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1705
  address entry = __ pc();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1706
  // Generate the code to allocate the interpreter stack frame.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1707
  Register Rsize_of_parameters = R4_ARG2, // Written by generate_fixed_frame.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1708
           Rsize_of_locals     = R5_ARG3; // Written by generate_fixed_frame.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1709
38734
69ced2325f58 8156922: [ppc] Implement template interpreter stack overflow checks as on x86/sparc.
goetz
parents: 38127
diff changeset
  1710
  // Does also a stack check to assure this frame fits on the stack.
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1711
  generate_fixed_frame(false, Rsize_of_parameters, Rsize_of_locals);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1712
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1713
  // --------------------------------------------------------------------------
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1714
  // Zero out non-parameter locals.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1715
  // Note: *Always* zero out non-parameter locals as Sparc does. It's not
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1716
  // worth to ask the flag, just do it.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1717
  Register Rslot_addr = R6_ARG4,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1718
           Rnum       = R7_ARG5;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1719
  Label Lno_locals, Lzero_loop;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1720
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1721
  // Set up the zeroing loop.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1722
  __ subf(Rnum, Rsize_of_parameters, Rsize_of_locals);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1723
  __ subf(Rslot_addr, Rsize_of_parameters, R18_locals);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1724
  __ srdi_(Rnum, Rnum, Interpreter::logStackElementSize);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1725
  __ beq(CCR0, Lno_locals);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1726
  __ li(R0, 0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1727
  __ mtctr(Rnum);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1728
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1729
  // The zero locals loop.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1730
  __ bind(Lzero_loop);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1731
  __ std(R0, 0, Rslot_addr);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1732
  __ addi(Rslot_addr, Rslot_addr, -Interpreter::stackElementSize);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1733
  __ bdnz(Lzero_loop);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1734
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1735
  __ bind(Lno_locals);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1736
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1737
  // --------------------------------------------------------------------------
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1738
  // Counter increment and overflow check.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1739
  Label invocation_counter_overflow,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1740
        profile_method,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1741
        profile_method_continue;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1742
  if (inc_counter || ProfileInterpreter) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1743
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1744
    Register Rdo_not_unlock_if_synchronized_addr = R11_scratch1;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1745
    if (synchronized) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1746
      // Since at this point in the method invocation the exception handler
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1747
      // would try to exit the monitor of synchronized methods which hasn't
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1748
      // been entered yet, we set the thread local variable
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1749
      // _do_not_unlock_if_synchronized to true. If any exception was thrown by
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1750
      // runtime, exception handling i.e. unlock_if_synchronized_method will
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1751
      // check this thread local flag.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1752
      // This flag has two effects, one is to force an unwind in the topmost
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1753
      // interpreter frame and not perform an unlock while doing so.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1754
      __ li(R0, 1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1755
      __ stb(R0, in_bytes(JavaThread::do_not_unlock_if_synchronized_offset()), R16_thread);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1756
    }
28187
fc19df82d6ee 8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents: 25950
diff changeset
  1757
fc19df82d6ee 8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents: 25950
diff changeset
  1758
    // Argument and return type profiling.
fc19df82d6ee 8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents: 25950
diff changeset
  1759
    __ profile_parameters_type(R3_ARG1, R4_ARG2, R5_ARG3, R6_ARG4);
fc19df82d6ee 8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents: 25950
diff changeset
  1760
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1761
    // Increment invocation counter and check for overflow.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1762
    if (inc_counter) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1763
      generate_counter_incr(&invocation_counter_overflow, &profile_method, &profile_method_continue);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1764
    }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1765
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1766
    __ bind(profile_method_continue);
38734
69ced2325f58 8156922: [ppc] Implement template interpreter stack overflow checks as on x86/sparc.
goetz
parents: 38127
diff changeset
  1767
  }
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1768
38734
69ced2325f58 8156922: [ppc] Implement template interpreter stack overflow checks as on x86/sparc.
goetz
parents: 38127
diff changeset
  1769
  bang_stack_shadow_pages(false);
69ced2325f58 8156922: [ppc] Implement template interpreter stack overflow checks as on x86/sparc.
goetz
parents: 38127
diff changeset
  1770
69ced2325f58 8156922: [ppc] Implement template interpreter stack overflow checks as on x86/sparc.
goetz
parents: 38127
diff changeset
  1771
  if (inc_counter || ProfileInterpreter) {
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1772
    // Reset the _do_not_unlock_if_synchronized flag.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1773
    if (synchronized) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1774
      __ li(R0, 0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1775
      __ stb(R0, in_bytes(JavaThread::do_not_unlock_if_synchronized_offset()), R16_thread);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1776
    }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1777
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1778
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1779
  // --------------------------------------------------------------------------
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1780
  // Locking of synchronized methods. Must happen AFTER invocation_counter
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1781
  // check and stack overflow check, so method is not locked if overflows.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1782
  if (synchronized) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1783
    lock_method(R3_ARG1, R4_ARG2, R5_ARG3);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1784
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1785
#ifdef ASSERT
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1786
  else {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1787
    Label Lok;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1788
    __ lwz(R0, in_bytes(Method::access_flags_offset()), R19_method);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1789
    __ andi_(R0, R0, JVM_ACC_SYNCHRONIZED);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1790
    __ asm_assert_eq("method needs synchronization", 0x8521);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1791
    __ bind(Lok);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1792
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1793
#endif // ASSERT
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1794
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1795
  __ verify_thread();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1796
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1797
  // --------------------------------------------------------------------------
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1798
  // JVMTI support
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1799
  __ notify_method_entry();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1800
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1801
  // --------------------------------------------------------------------------
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1802
  // Start executing instructions.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1803
  __ dispatch_next(vtos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1804
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1805
  // --------------------------------------------------------------------------
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1806
  // Out of line counter overflow and MDO creation code.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1807
  if (ProfileInterpreter) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1808
    // We have decided to profile this method in the interpreter.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1809
    __ bind(profile_method);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1810
    __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::profile_method));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1811
    __ set_method_data_pointer_for_bcp();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1812
    __ b(profile_method_continue);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1813
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1814
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1815
  if (inc_counter) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1816
    // Handle invocation counter overflow.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1817
    __ bind(invocation_counter_overflow);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1818
    generate_counter_overflow(profile_method_continue);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1819
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1820
  return entry;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1821
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1822
31861
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1823
// CRC32 Intrinsics.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1824
//
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1825
// Contract on scratch and work registers.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1826
// =======================================
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1827
//
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1828
// On ppc, the register set {R2..R12} is available in the interpreter as scratch/work registers.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1829
// You should, however, keep in mind that {R3_ARG1..R10_ARG8} is the C-ABI argument register set.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1830
// You can't rely on these registers across calls.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1831
//
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1832
// The generators for CRC32_update and for CRC32_updateBytes use the
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1833
// scratch/work register set internally, passing the work registers
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1834
// as arguments to the MacroAssembler emitters as required.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1835
//
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1836
// R3_ARG1..R6_ARG4 are preset to hold the incoming java arguments.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1837
// Their contents is not constant but may change according to the requirements
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1838
// of the emitted code.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1839
//
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1840
// All other registers from the scratch/work register set are used "internally"
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1841
// and contain garbage (i.e. unpredictable values) once blr() is reached.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1842
// Basically, only R3_RET contains a defined value which is the function result.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1843
//
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1844
/**
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1845
 * Method entry for static native methods:
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1846
 *   int java.util.zip.CRC32.update(int crc, int b)
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1847
 */
35214
d86005e0b4c2 8074457: Remove the non-Zero CPP Interpreter
coleenp
parents: 35166
diff changeset
  1848
address TemplateInterpreterGenerator::generate_CRC32_update_entry() {
31861
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1849
  if (UseCRC32Intrinsics) {
33070
54f3f085b165 8136525: Generate interpreter entries only once and avoid unnecessary jump to jump
mdoerr
parents: 31865
diff changeset
  1850
    address start = __ pc();  // Remember stub start address (is rtn value).
31861
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1851
    Label slow_path;
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1852
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1853
    // Safepoint check
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1854
    const Register sync_state = R11_scratch1;
48332
651a95f30dfb 8193257: PPC64, s390 implementation for Thread-local handshakes
mdoerr
parents: 47916
diff changeset
  1855
    __ safepoint_poll(slow_path, sync_state);
31861
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1856
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1857
    // We don't generate local frame and don't align stack because
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1858
    // we not even call stub code (we generate the code inline)
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1859
    // and there is no safepoint on this path.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1860
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1861
    // Load java parameters.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1862
    // R15_esp is callers operand stack pointer, i.e. it points to the parameters.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1863
    const Register argP    = R15_esp;
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1864
    const Register crc     = R3_ARG1;  // crc value
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1865
    const Register data    = R4_ARG2;  // address of java byte value (kernel_crc32 needs address)
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1866
    const Register dataLen = R5_ARG3;  // source data len (1 byte). Not used because calling the single-byte emitter.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1867
    const Register table   = R6_ARG4;  // address of crc32 table
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1868
    const Register tmp     = dataLen;  // Reuse unused len register to show we don't actually need a separate tmp here.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1869
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1870
    BLOCK_COMMENT("CRC32_update {");
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1871
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1872
    // Arguments are reversed on java expression stack
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1873
#ifdef VM_LITTLE_ENDIAN
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1874
    __ addi(data, argP, 0+1*wordSize); // (stack) address of byte value. Emitter expects address, not value.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1875
                                       // Being passed as an int, the single byte is at offset +0.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1876
#else
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1877
    __ addi(data, argP, 3+1*wordSize); // (stack) address of byte value. Emitter expects address, not value.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1878
                                       // Being passed from java as an int, the single byte is at offset +3.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1879
#endif
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1880
    __ lwz(crc,  2*wordSize, argP);    // Current crc state, zero extend to 64 bit to have a clean register.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1881
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1882
    StubRoutines::ppc64::generate_load_crc_table_addr(_masm, table);
46317
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  1883
    __ kernel_crc32_singleByte(crc, data, dataLen, table, tmp, true);
31861
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1884
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1885
    // Restore caller sp for c2i case and return.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1886
    __ mr(R1_SP, R21_sender_SP); // Cut the stack back to where the caller started.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1887
    __ blr();
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1888
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1889
    // Generate a vanilla native entry as the slow path.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1890
    BLOCK_COMMENT("} CRC32_update");
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1891
    BIND(slow_path);
33070
54f3f085b165 8136525: Generate interpreter entries only once and avoid unnecessary jump to jump
mdoerr
parents: 31865
diff changeset
  1892
    __ jump_to_entry(Interpreter::entry_for_kind(Interpreter::native), R11_scratch1);
54f3f085b165 8136525: Generate interpreter entries only once and avoid unnecessary jump to jump
mdoerr
parents: 31865
diff changeset
  1893
    return start;
31861
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1894
  }
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1895
33070
54f3f085b165 8136525: Generate interpreter entries only once and avoid unnecessary jump to jump
mdoerr
parents: 31865
diff changeset
  1896
  return NULL;
31861
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1897
}
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1898
46317
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  1899
31861
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1900
/**
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1901
 * Method entry for static native methods:
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1902
 *   int java.util.zip.CRC32.updateBytes(     int crc, byte[] b,  int off, int len)
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1903
 *   int java.util.zip.CRC32.updateByteBuffer(int crc, long* buf, int off, int len)
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1904
 */
35214
d86005e0b4c2 8074457: Remove the non-Zero CPP Interpreter
coleenp
parents: 35166
diff changeset
  1905
address TemplateInterpreterGenerator::generate_CRC32_updateBytes_entry(AbstractInterpreter::MethodKind kind) {
31861
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1906
  if (UseCRC32Intrinsics) {
33070
54f3f085b165 8136525: Generate interpreter entries only once and avoid unnecessary jump to jump
mdoerr
parents: 31865
diff changeset
  1907
    address start = __ pc();  // Remember stub start address (is rtn value).
31861
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1908
    Label slow_path;
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1909
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1910
    // Safepoint check
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1911
    const Register sync_state = R11_scratch1;
48332
651a95f30dfb 8193257: PPC64, s390 implementation for Thread-local handshakes
mdoerr
parents: 47916
diff changeset
  1912
    __ safepoint_poll(slow_path, sync_state);
31861
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1913
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1914
    // We don't generate local frame and don't align stack because
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1915
    // we not even call stub code (we generate the code inline)
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1916
    // and there is no safepoint on this path.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1917
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1918
    // Load parameters.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1919
    // Z_esp is callers operand stack pointer, i.e. it points to the parameters.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1920
    const Register argP    = R15_esp;
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1921
    const Register crc     = R3_ARG1;  // crc value
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1922
    const Register data    = R4_ARG2;  // address of java byte array
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1923
    const Register dataLen = R5_ARG3;  // source data len
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1924
    const Register table   = R6_ARG4;  // address of crc32 table
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1925
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1926
    const Register t0      = R9;       // scratch registers for crc calculation
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1927
    const Register t1      = R10;
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1928
    const Register t2      = R11;
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1929
    const Register t3      = R12;
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1930
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1931
    const Register tc0     = R2;       // registers to hold pre-calculated column addresses
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1932
    const Register tc1     = R7;
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1933
    const Register tc2     = R8;
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1934
    const Register tc3     = table;    // table address is reconstructed at the end of kernel_crc32_* emitters
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1935
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1936
    const Register tmp     = t0;       // Only used very locally to calculate byte buffer address.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1937
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1938
    // Arguments are reversed on java expression stack.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1939
    // Calculate address of start element.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1940
    if (kind == Interpreter::java_util_zip_CRC32_updateByteBuffer) { // Used for "updateByteBuffer direct".
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1941
      BLOCK_COMMENT("CRC32_updateByteBuffer {");
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1942
      // crc     @ (SP + 5W) (32bit)
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1943
      // buf     @ (SP + 3W) (64bit ptr to long array)
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1944
      // off     @ (SP + 2W) (32bit)
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1945
      // dataLen @ (SP + 1W) (32bit)
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1946
      // data = buf + off
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1947
      __ ld(  data,    3*wordSize, argP);  // start of byte buffer
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1948
      __ lwa( tmp,     2*wordSize, argP);  // byte buffer offset
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1949
      __ lwa( dataLen, 1*wordSize, argP);  // #bytes to process
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1950
      __ lwz( crc,     5*wordSize, argP);  // current crc state
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1951
      __ add( data, data, tmp);            // Add byte buffer offset.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1952
    } else {                                                         // Used for "updateBytes update".
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1953
      BLOCK_COMMENT("CRC32_updateBytes {");
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1954
      // crc     @ (SP + 4W) (32bit)
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1955
      // buf     @ (SP + 3W) (64bit ptr to byte array)
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1956
      // off     @ (SP + 2W) (32bit)
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1957
      // dataLen @ (SP + 1W) (32bit)
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1958
      // data = buf + off + base_offset
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1959
      __ ld(  data,    3*wordSize, argP);  // start of byte buffer
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1960
      __ lwa( tmp,     2*wordSize, argP);  // byte buffer offset
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1961
      __ lwa( dataLen, 1*wordSize, argP);  // #bytes to process
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1962
      __ add( data, data, tmp);            // add byte buffer offset
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1963
      __ lwz( crc,     4*wordSize, argP);  // current crc state
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1964
      __ addi(data, data, arrayOopDesc::base_offset_in_bytes(T_BYTE));
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1965
    }
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1966
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1967
    StubRoutines::ppc64::generate_load_crc_table_addr(_masm, table);
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1968
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1969
    // Performance measurements show the 1word and 2word variants to be almost equivalent,
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1970
    // with very light advantages for the 1word variant. We chose the 1word variant for
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1971
    // code compactness.
46317
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  1972
    __ kernel_crc32_1word(crc, data, dataLen, table, t0, t1, t2, t3, tc0, tc1, tc2, tc3, true);
31861
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1973
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1974
    // Restore caller sp for c2i case and return.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1975
    __ mr(R1_SP, R21_sender_SP); // Cut the stack back to where the caller started.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1976
    __ blr();
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1977
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1978
    // Generate a vanilla native entry as the slow path.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1979
    BLOCK_COMMENT("} CRC32_updateBytes(Buffer)");
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1980
    BIND(slow_path);
33070
54f3f085b165 8136525: Generate interpreter entries only once and avoid unnecessary jump to jump
mdoerr
parents: 31865
diff changeset
  1981
    __ jump_to_entry(Interpreter::entry_for_kind(Interpreter::native), R11_scratch1);
54f3f085b165 8136525: Generate interpreter entries only once and avoid unnecessary jump to jump
mdoerr
parents: 31865
diff changeset
  1982
    return start;
31861
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1983
  }
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1984
33070
54f3f085b165 8136525: Generate interpreter entries only once and avoid unnecessary jump to jump
mdoerr
parents: 31865
diff changeset
  1985
  return NULL;
31861
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1986
}
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 30303
diff changeset
  1987
46386
742f8b16d00c 8176580: [ppc, s390] CRC32C: wrong checksum result in some cases
simonis
parents: 46369
diff changeset
  1988
46317
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  1989
/**
46386
742f8b16d00c 8176580: [ppc, s390] CRC32C: wrong checksum result in some cases
simonis
parents: 46369
diff changeset
  1990
 * Method entry for intrinsic-candidate (non-native) methods:
742f8b16d00c 8176580: [ppc, s390] CRC32C: wrong checksum result in some cases
simonis
parents: 46369
diff changeset
  1991
 *   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
  1992
 *   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
  1993
 * 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
  1994
 * CRC32C also uses an "end" variable instead of the length variable CRC32 uses
46317
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  1995
 **/
35214
d86005e0b4c2 8074457: Remove the non-Zero CPP Interpreter
coleenp
parents: 35166
diff changeset
  1996
address TemplateInterpreterGenerator::generate_CRC32C_updateBytes_entry(AbstractInterpreter::MethodKind kind) {
46317
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  1997
  if (UseCRC32CIntrinsics) {
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  1998
    address start = __ pc();  // Remember stub start address (is rtn value).
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  1999
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2000
    // We don't generate local frame and don't align stack because
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2001
    // we not even call stub code (we generate the code inline)
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2002
    // and there is no safepoint on this path.
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2003
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2004
    // Load parameters.
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2005
    // Z_esp is callers operand stack pointer, i.e. it points to the parameters.
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2006
    const Register argP    = R15_esp;
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2007
    const Register crc     = R3_ARG1;  // crc value
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2008
    const Register data    = R4_ARG2;  // address of java byte array
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2009
    const Register dataLen = R5_ARG3;  // source data len
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2010
    const Register table   = R6_ARG4;  // address of crc32c table
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2011
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2012
    const Register t0      = R9;       // scratch registers for crc calculation
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2013
    const Register t1      = R10;
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2014
    const Register t2      = R11;
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2015
    const Register t3      = R12;
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2016
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2017
    const Register tc0     = R2;       // registers to hold pre-calculated column addresses
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2018
    const Register tc1     = R7;
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2019
    const Register tc2     = R8;
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2020
    const Register tc3     = table;    // table address is reconstructed at the end of kernel_crc32_* emitters
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2021
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2022
    const Register tmp     = t0;       // Only used very locally to calculate byte buffer address.
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2023
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2024
    // Arguments are reversed on java expression stack.
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2025
    // Calculate address of start element.
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2026
    if (kind == Interpreter::java_util_zip_CRC32C_updateDirectByteBuffer) { // Used for "updateDirectByteBuffer".
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2027
      BLOCK_COMMENT("CRC32C_updateDirectByteBuffer {");
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2028
      // crc     @ (SP + 5W) (32bit)
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2029
      // buf     @ (SP + 3W) (64bit ptr to long array)
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2030
      // off     @ (SP + 2W) (32bit)
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2031
      // dataLen @ (SP + 1W) (32bit)
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2032
      // data = buf + off
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2033
      __ ld(  data,    3*wordSize, argP);  // start of byte buffer
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2034
      __ lwa( tmp,     2*wordSize, argP);  // byte buffer offset
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2035
      __ lwa( dataLen, 1*wordSize, argP);  // #bytes to process
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2036
      __ lwz( crc,     5*wordSize, argP);  // current crc state
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2037
      __ add( data, data, tmp);            // Add byte buffer offset.
46386
742f8b16d00c 8176580: [ppc, s390] CRC32C: wrong checksum result in some cases
simonis
parents: 46369
diff changeset
  2038
      __ sub( dataLen, dataLen, tmp);      // (end_index - offset)
46317
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2039
    } else {                                                         // Used for "updateBytes update".
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2040
      BLOCK_COMMENT("CRC32C_updateBytes {");
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2041
      // crc     @ (SP + 4W) (32bit)
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2042
      // buf     @ (SP + 3W) (64bit ptr to byte array)
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2043
      // off     @ (SP + 2W) (32bit)
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2044
      // dataLen @ (SP + 1W) (32bit)
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2045
      // data = buf + off + base_offset
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2046
      __ ld(  data,    3*wordSize, argP);  // start of byte buffer
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2047
      __ lwa( tmp,     2*wordSize, argP);  // byte buffer offset
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2048
      __ lwa( dataLen, 1*wordSize, argP);  // #bytes to process
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2049
      __ add( data, data, tmp);            // add byte buffer offset
46386
742f8b16d00c 8176580: [ppc, s390] CRC32C: wrong checksum result in some cases
simonis
parents: 46369
diff changeset
  2050
      __ sub( dataLen, dataLen, tmp);      // (end_index - offset)
46317
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2051
      __ lwz( crc,     4*wordSize, argP);  // current crc state
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2052
      __ addi(data, data, arrayOopDesc::base_offset_in_bytes(T_BYTE));
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2053
    }
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2054
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2055
    StubRoutines::ppc64::generate_load_crc32c_table_addr(_masm, table);
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2056
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2057
    // Performance measurements show the 1word and 2word variants to be almost equivalent,
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2058
    // with very light advantages for the 1word variant. We chose the 1word variant for
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2059
    // code compactness.
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2060
    __ kernel_crc32_1word(crc, data, dataLen, table, t0, t1, t2, t3, tc0, tc1, tc2, tc3, false);
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2061
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2062
    // Restore caller sp for c2i case and return.
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2063
    __ mr(R1_SP, R21_sender_SP); // Cut the stack back to where the caller started.
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2064
    __ blr();
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2065
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2066
    BLOCK_COMMENT("} CRC32C_update{Bytes|DirectByteBuffer}");
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2067
    return start;
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2068
  }
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 46294
diff changeset
  2069
35214
d86005e0b4c2 8074457: Remove the non-Zero CPP Interpreter
coleenp
parents: 35166
diff changeset
  2070
  return NULL;
d86005e0b4c2 8074457: Remove the non-Zero CPP Interpreter
coleenp
parents: 35166
diff changeset
  2071
}
d86005e0b4c2 8074457: Remove the non-Zero CPP Interpreter
coleenp
parents: 35166
diff changeset
  2072
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2073
// =============================================================================
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2074
// Exceptions
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2075
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2076
void TemplateInterpreterGenerator::generate_throw_exception() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2077
  Register Rexception    = R17_tos,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2078
           Rcontinuation = R3_RET;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2079
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2080
  // --------------------------------------------------------------------------
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2081
  // Entry point if an method returns with a pending exception (rethrow).
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2082
  Interpreter::_rethrow_exception_entry = __ pc();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2083
  {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2084
    __ restore_interpreter_state(R11_scratch1); // Sets R11_scratch1 = fp.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2085
    __ ld(R12_scratch2, _ijava_state_neg(top_frame_sp), R11_scratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2086
    __ resize_frame_absolute(R12_scratch2, R11_scratch1, R0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2087
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2088
    // Compiled code destroys templateTableBase, reload.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2089
    __ load_const_optimized(R25_templateTableBase, (address)Interpreter::dispatch_table((TosState)0), R11_scratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2090
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2091
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2092
  // Entry point if a interpreted method throws an exception (throw).
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2093
  Interpreter::_throw_exception_entry = __ pc();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2094
  {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2095
    __ mr(Rexception, R3_RET);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2096
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2097
    __ verify_thread();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2098
    __ verify_oop(Rexception);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2099
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2100
    // Expression stack must be empty before entering the VM in case of an exception.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2101
    __ empty_expression_stack();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2102
    // Find exception handler address and preserve exception oop.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2103
    // Call C routine to find handler and jump to it.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2104
    __ call_VM(Rexception, CAST_FROM_FN_PTR(address, InterpreterRuntime::exception_handler_for_exception), Rexception);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2105
    __ mtctr(Rcontinuation);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2106
    // Push exception for exception handler bytecodes.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2107
    __ push_ptr(Rexception);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2108
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2109
    // Jump to exception handler (may be remove activation entry!).
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2110
    __ bctr();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2111
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2112
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2113
  // If the exception is not handled in the current frame the frame is
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2114
  // removed and the exception is rethrown (i.e. exception
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2115
  // continuation is _rethrow_exception).
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2116
  //
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2117
  // Note: At this point the bci is still the bxi for the instruction
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2118
  // which caused the exception and the expression stack is
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2119
  // empty. Thus, for any VM calls at this point, GC will find a legal
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2120
  // oop map (with empty expression stack).
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2121
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2122
  // In current activation
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2123
  // tos: exception
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2124
  // bcp: exception bcp
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2125
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2126
  // --------------------------------------------------------------------------
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2127
  // JVMTI PopFrame support
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2128
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2129
  Interpreter::_remove_activation_preserving_args_entry = __ pc();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2130
  {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2131
    // Set the popframe_processing bit in popframe_condition indicating that we are
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2132
    // currently handling popframe, so that call_VMs that may happen later do not
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2133
    // trigger new popframe handling cycles.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2134
    __ lwz(R11_scratch1, in_bytes(JavaThread::popframe_condition_offset()), R16_thread);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2135
    __ ori(R11_scratch1, R11_scratch1, JavaThread::popframe_processing_bit);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2136
    __ stw(R11_scratch1, in_bytes(JavaThread::popframe_condition_offset()), R16_thread);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2137
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2138
    // Empty the expression stack, as in normal exception handling.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2139
    __ empty_expression_stack();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2140
    __ unlock_if_synchronized_method(vtos, /* throw_monitor_exception */ false, /* install_monitor_exception */ false);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2141
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2142
    // Check to see whether we are returning to a deoptimized frame.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2143
    // (The PopFrame call ensures that the caller of the popped frame is
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2144
    // either interpreted or compiled and deoptimizes it if compiled.)
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2145
    // Note that we don't compare the return PC against the
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2146
    // deoptimization blob's unpack entry because of the presence of
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2147
    // adapter frames in C2.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2148
    Label Lcaller_not_deoptimized;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2149
    Register return_pc = R3_ARG1;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2150
    __ ld(return_pc, 0, R1_SP);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2151
    __ ld(return_pc, _abi(lr), return_pc);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2152
    __ call_VM_leaf(CAST_FROM_FN_PTR(address, InterpreterRuntime::interpreter_contains), return_pc);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2153
    __ cmpdi(CCR0, R3_RET, 0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2154
    __ bne(CCR0, Lcaller_not_deoptimized);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2155
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2156
    // The deoptimized case.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2157
    // In this case, we can't call dispatch_next() after the frame is
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2158
    // popped, but instead must save the incoming arguments and restore
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2159
    // them after deoptimization has occurred.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2160
    __ ld(R4_ARG2, in_bytes(Method::const_offset()), R19_method);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2161
    __ lhz(R4_ARG2 /* number of params */, in_bytes(ConstMethod::size_of_parameters_offset()), R4_ARG2);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2162
    __ slwi(R4_ARG2, R4_ARG2, Interpreter::logStackElementSize);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2163
    __ addi(R5_ARG3, R18_locals, Interpreter::stackElementSize);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2164
    __ subf(R5_ARG3, R4_ARG2, R5_ARG3);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2165
    // Save these arguments.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2166
    __ call_VM_leaf(CAST_FROM_FN_PTR(address, Deoptimization::popframe_preserve_args), R16_thread, R4_ARG2, R5_ARG3);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2167
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2168
    // Inform deoptimization that it is responsible for restoring these arguments.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2169
    __ load_const_optimized(R11_scratch1, JavaThread::popframe_force_deopt_reexecution_bit);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2170
    __ stw(R11_scratch1, in_bytes(JavaThread::popframe_condition_offset()), R16_thread);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2171
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2172
    // Return from the current method into the deoptimization blob. Will eventually
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2173
    // end up in the deopt interpeter entry, deoptimization prepared everything that
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2174
    // we will reexecute the call that called us.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2175
    __ merge_frames(/*top_frame_sp*/ R21_sender_SP, /*reload return_pc*/ return_pc, R11_scratch1, R12_scratch2);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2176
    __ mtlr(return_pc);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2177
    __ blr();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2178
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2179
    // The non-deoptimized case.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2180
    __ bind(Lcaller_not_deoptimized);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2181
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2182
    // Clear the popframe condition flag.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2183
    __ li(R0, 0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2184
    __ stw(R0, in_bytes(JavaThread::popframe_condition_offset()), R16_thread);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2185
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2186
    // Get out of the current method and re-execute the call that called us.
24349
d8f40e5b392d 8042309: Some bugfixes for the ppc64 port.
goetz
parents: 24018
diff changeset
  2187
    __ merge_frames(/*top_frame_sp*/ R21_sender_SP, /*return_pc*/ noreg, R11_scratch1, R12_scratch2);
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2188
    __ restore_interpreter_state(R11_scratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2189
    __ ld(R12_scratch2, _ijava_state_neg(top_frame_sp), R11_scratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2190
    __ resize_frame_absolute(R12_scratch2, R11_scratch1, R0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2191
    if (ProfileInterpreter) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2192
      __ set_method_data_pointer_for_bcp();
28187
fc19df82d6ee 8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents: 25950
diff changeset
  2193
      __ ld(R11_scratch1, 0, R1_SP);
fc19df82d6ee 8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents: 25950
diff changeset
  2194
      __ std(R28_mdx, _ijava_state_neg(mdx), R11_scratch1);
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2195
    }
24349
d8f40e5b392d 8042309: Some bugfixes for the ppc64 port.
goetz
parents: 24018
diff changeset
  2196
#if INCLUDE_JVMTI
d8f40e5b392d 8042309: Some bugfixes for the ppc64 port.
goetz
parents: 24018
diff changeset
  2197
    Label L_done;
d8f40e5b392d 8042309: Some bugfixes for the ppc64 port.
goetz
parents: 24018
diff changeset
  2198
d8f40e5b392d 8042309: Some bugfixes for the ppc64 port.
goetz
parents: 24018
diff changeset
  2199
    __ lbz(R11_scratch1, 0, R14_bcp);
d8f40e5b392d 8042309: Some bugfixes for the ppc64 port.
goetz
parents: 24018
diff changeset
  2200
    __ cmpwi(CCR0, R11_scratch1, Bytecodes::_invokestatic);
d8f40e5b392d 8042309: Some bugfixes for the ppc64 port.
goetz
parents: 24018
diff changeset
  2201
    __ bne(CCR0, L_done);
d8f40e5b392d 8042309: Some bugfixes for the ppc64 port.
goetz
parents: 24018
diff changeset
  2202
d8f40e5b392d 8042309: Some bugfixes for the ppc64 port.
goetz
parents: 24018
diff changeset
  2203
    // The member name argument must be restored if _invokestatic is re-executed after a PopFrame call.
d8f40e5b392d 8042309: Some bugfixes for the ppc64 port.
goetz
parents: 24018
diff changeset
  2204
    // Detect such a case in the InterpreterRuntime function and return the member name argument, or NULL.
d8f40e5b392d 8042309: Some bugfixes for the ppc64 port.
goetz
parents: 24018
diff changeset
  2205
    __ ld(R4_ARG2, 0, R18_locals);
28187
fc19df82d6ee 8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents: 25950
diff changeset
  2206
    __ MacroAssembler::call_VM(R4_ARG2, CAST_FROM_FN_PTR(address, InterpreterRuntime::member_name_arg_or_null), R4_ARG2, R19_method, R14_bcp, false);
fc19df82d6ee 8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents: 25950
diff changeset
  2207
    __ restore_interpreter_state(R11_scratch1, /*bcp_and_mdx_only*/ true);
fc19df82d6ee 8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents: 25950
diff changeset
  2208
    __ cmpdi(CCR0, R4_ARG2, 0);
24349
d8f40e5b392d 8042309: Some bugfixes for the ppc64 port.
goetz
parents: 24018
diff changeset
  2209
    __ beq(CCR0, L_done);
28187
fc19df82d6ee 8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents: 25950
diff changeset
  2210
    __ std(R4_ARG2, wordSize, R15_esp);
24349
d8f40e5b392d 8042309: Some bugfixes for the ppc64 port.
goetz
parents: 24018
diff changeset
  2211
    __ bind(L_done);
d8f40e5b392d 8042309: Some bugfixes for the ppc64 port.
goetz
parents: 24018
diff changeset
  2212
#endif // INCLUDE_JVMTI
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2213
    __ dispatch_next(vtos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2214
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2215
  // end of JVMTI PopFrame support
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2216
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2217
  // --------------------------------------------------------------------------
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2218
  // Remove activation exception entry.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2219
  // This is jumped to if an interpreted method can't handle an exception itself
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2220
  // (we come from the throw/rethrow exception entry above). We're going to call
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2221
  // into the VM to find the exception handler in the caller, pop the current
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2222
  // frame and return the handler we calculated.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2223
  Interpreter::_remove_activation_entry = __ pc();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2224
  {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2225
    __ pop_ptr(Rexception);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2226
    __ verify_thread();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2227
    __ verify_oop(Rexception);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2228
    __ std(Rexception, in_bytes(JavaThread::vm_result_offset()), R16_thread);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2229
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2230
    __ unlock_if_synchronized_method(vtos, /* throw_monitor_exception */ false, true);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2231
    __ notify_method_exit(false, vtos, InterpreterMacroAssembler::SkipNotifyJVMTI, false);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2232
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2233
    __ get_vm_result(Rexception);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2234
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2235
    // We are done with this activation frame; find out where to go next.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2236
    // The continuation point will be an exception handler, which expects
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2237
    // the following registers set up:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2238
    //
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2239
    // RET:  exception oop
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2240
    // ARG2: Issuing PC (see generate_exception_blob()), only used if the caller is compiled.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2241
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2242
    Register return_pc = R31; // Needs to survive the runtime call.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2243
    __ ld(return_pc, 0, R1_SP);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2244
    __ ld(return_pc, _abi(lr), return_pc);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2245
    __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::exception_handler_for_return_address), R16_thread, return_pc);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2246
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2247
    // Remove the current activation.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2248
    __ merge_frames(/*top_frame_sp*/ R21_sender_SP, /*return_pc*/ noreg, R11_scratch1, R12_scratch2);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2249
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2250
    __ mr(R4_ARG2, return_pc);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2251
    __ mtlr(R3_RET);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2252
    __ mr(R3_RET, Rexception);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2253
    __ blr();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2254
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2255
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2256
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2257
// JVMTI ForceEarlyReturn support.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2258
// Returns "in the middle" of a method with a "fake" return value.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2259
address TemplateInterpreterGenerator::generate_earlyret_entry_for(TosState state) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2260
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2261
  Register Rscratch1 = R11_scratch1,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2262
           Rscratch2 = R12_scratch2;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2263
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2264
  address entry = __ pc();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2265
  __ empty_expression_stack();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2266
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2267
  __ load_earlyret_value(state, Rscratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2268
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2269
  __ ld(Rscratch1, in_bytes(JavaThread::jvmti_thread_state_offset()), R16_thread);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2270
  // Clear the earlyret state.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2271
  __ li(R0, 0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2272
  __ stw(R0, in_bytes(JvmtiThreadState::earlyret_state_offset()), Rscratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2273
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2274
  __ remove_activation(state, false, false);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2275
  // Copied from TemplateTable::_return.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2276
  // Restoration of lr done by remove_activation.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2277
  switch (state) {
37488
ab63cdc0e14e 8154867: PPC64: Better byte behavior
mdoerr
parents: 37152
diff changeset
  2278
    // Narrow result if state is itos but result type is smaller.
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2279
    case btos:
37488
ab63cdc0e14e 8154867: PPC64: Better byte behavior
mdoerr
parents: 37152
diff changeset
  2280
    case ztos:
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2281
    case ctos:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2282
    case stos:
42068
18c8a4d5998e 8168083: PPC64: Cleanup template interpreter after 8154580 and 8154867
mdoerr
parents: 41341
diff changeset
  2283
    case itos: __ narrow(R17_tos); /* fall through */
18c8a4d5998e 8168083: PPC64: Cleanup template interpreter after 8154580 and 8154867
mdoerr
parents: 41341
diff changeset
  2284
    case ltos:
37488
ab63cdc0e14e 8154867: PPC64: Better byte behavior
mdoerr
parents: 37152
diff changeset
  2285
    case atos: __ mr(R3_RET, R17_tos); break;
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2286
    case ftos:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2287
    case dtos: __ fmr(F1_RET, F15_ftos); break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2288
    case vtos: // This might be a constructor. Final fields (and volatile fields on PPC64) need
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2289
               // to get visible before the reference to the object gets stored anywhere.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2290
               __ membar(Assembler::StoreStore); break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2291
    default  : ShouldNotReachHere();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2292
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2293
  __ blr();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2294
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2295
  return entry;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2296
} // end of ForceEarlyReturn support
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2297
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2298
//-----------------------------------------------------------------------------
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2299
// Helper for vtos entry point generation
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2300
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2301
void TemplateInterpreterGenerator::set_vtos_entry_points(Template* t,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2302
                                                         address& bep,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2303
                                                         address& cep,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2304
                                                         address& sep,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2305
                                                         address& aep,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2306
                                                         address& iep,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2307
                                                         address& lep,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2308
                                                         address& fep,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2309
                                                         address& dep,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2310
                                                         address& vep) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2311
  assert(t->is_valid() && t->tos_in() == vtos, "illegal template");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2312
  Label L;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2313
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2314
  aep = __ pc();  __ push_ptr();  __ b(L);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2315
  fep = __ pc();  __ push_f();    __ b(L);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2316
  dep = __ pc();  __ push_d();    __ b(L);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2317
  lep = __ pc();  __ push_l();    __ b(L);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2318
  __ align(32, 12, 24); // align L
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2319
  bep = cep = sep =
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2320
  iep = __ pc();  __ push_i();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2321
  vep = __ pc();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2322
  __ bind(L);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2323
  generate_and_dispatch(t);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2324
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2325
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2326
//-----------------------------------------------------------------------------
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2327
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2328
// Non-product code
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2329
#ifndef PRODUCT
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2330
address TemplateInterpreterGenerator::generate_trace_code(TosState state) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2331
  //__ flush_bundle();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2332
  address entry = __ pc();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2333
23522
217a6a90aad3 8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents: 23221
diff changeset
  2334
  const char *bname = NULL;
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2335
  uint tsize = 0;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2336
  switch(state) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2337
  case ftos:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2338
    bname = "trace_code_ftos {";
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2339
    tsize = 2;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2340
    break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2341
  case btos:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2342
    bname = "trace_code_btos {";
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2343
    tsize = 2;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2344
    break;
37488
ab63cdc0e14e 8154867: PPC64: Better byte behavior
mdoerr
parents: 37152
diff changeset
  2345
  case ztos:
ab63cdc0e14e 8154867: PPC64: Better byte behavior
mdoerr
parents: 37152
diff changeset
  2346
    bname = "trace_code_ztos {";
ab63cdc0e14e 8154867: PPC64: Better byte behavior
mdoerr
parents: 37152
diff changeset
  2347
    tsize = 2;
ab63cdc0e14e 8154867: PPC64: Better byte behavior
mdoerr
parents: 37152
diff changeset
  2348
    break;
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2349
  case ctos:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2350
    bname = "trace_code_ctos {";
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2351
    tsize = 2;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2352
    break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2353
  case stos:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2354
    bname = "trace_code_stos {";
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2355
    tsize = 2;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2356
    break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2357
  case itos:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2358
    bname = "trace_code_itos {";
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2359
    tsize = 2;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2360
    break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2361
  case ltos:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2362
    bname = "trace_code_ltos {";
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2363
    tsize = 3;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2364
    break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2365
  case atos:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2366
    bname = "trace_code_atos {";
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2367
    tsize = 2;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2368
    break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2369
  case vtos:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2370
    // Note: In case of vtos, the topmost of stack value could be a int or doubl
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2371
    // In case of a double (2 slots) we won't see the 2nd stack value.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2372
    // Maybe we simply should print the topmost 3 stack slots to cope with the problem.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2373
    bname = "trace_code_vtos {";
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2374
    tsize = 2;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2375
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2376
    break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2377
  case dtos:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2378
    bname = "trace_code_dtos {";
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2379
    tsize = 3;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2380
    break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2381
  default:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2382
    ShouldNotReachHere();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2383
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2384
  BLOCK_COMMENT(bname);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2385
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2386
  // Support short-cut for TraceBytecodesAt.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2387
  // Don't call into the VM if we don't want to trace to speed up things.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2388
  Label Lskip_vm_call;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2389
  if (TraceBytecodesAt > 0 && TraceBytecodesAt < max_intx) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2390
    int offs1 = __ load_const_optimized(R11_scratch1, (address) &TraceBytecodesAt, R0, true);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2391
    int offs2 = __ load_const_optimized(R12_scratch2, (address) &BytecodeCounter::_counter_value, R0, true);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2392
    __ ld(R11_scratch1, offs1, R11_scratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2393
    __ lwa(R12_scratch2, offs2, R12_scratch2);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2394
    __ cmpd(CCR0, R12_scratch2, R11_scratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2395
    __ blt(CCR0, Lskip_vm_call);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2396
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2397
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2398
  __ push(state);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2399
  // Load 2 topmost expression stack values.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2400
  __ ld(R6_ARG4, tsize*Interpreter::stackElementSize, R15_esp);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2401
  __ ld(R5_ARG3, Interpreter::stackElementSize, R15_esp);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2402
  __ mflr(R31);
37152
29e68f1d35bb 8152065: TraceBytecodes breaks the interpreter expression stack
coleenp
parents: 35606
diff changeset
  2403
  __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::trace_bytecode), /* unused */ R4_ARG2, R5_ARG3, R6_ARG4, false);
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2404
  __ mtlr(R31);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2405
  __ pop(state);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2406
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2407
  if (TraceBytecodesAt > 0 && TraceBytecodesAt < max_intx) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2408
    __ bind(Lskip_vm_call);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2409
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2410
  __ blr();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2411
  BLOCK_COMMENT("} trace_code");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2412
  return entry;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2413
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2414
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2415
void TemplateInterpreterGenerator::count_bytecode() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2416
  int offs = __ load_const_optimized(R11_scratch1, (address) &BytecodeCounter::_counter_value, R12_scratch2, true);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2417
  __ lwz(R12_scratch2, offs, R11_scratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2418
  __ addi(R12_scratch2, R12_scratch2, 1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2419
  __ stw(R12_scratch2, offs, R11_scratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2420
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2421
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2422
void TemplateInterpreterGenerator::histogram_bytecode(Template* t) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2423
  int offs = __ load_const_optimized(R11_scratch1, (address) &BytecodeHistogram::_counters[t->bytecode()], R12_scratch2, true);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2424
  __ lwz(R12_scratch2, offs, R11_scratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2425
  __ addi(R12_scratch2, R12_scratch2, 1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2426
  __ stw(R12_scratch2, offs, R11_scratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2427
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2428
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2429
void TemplateInterpreterGenerator::histogram_bytecode_pair(Template* t) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2430
  const Register addr = R11_scratch1,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2431
                 tmp  = R12_scratch2;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2432
  // Get index, shift out old bytecode, bring in new bytecode, and store it.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2433
  // _index = (_index >> log2_number_of_codes) |
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2434
  //          (bytecode << log2_number_of_codes);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2435
  int offs1 = __ load_const_optimized(addr, (address)&BytecodePairHistogram::_index, tmp, true);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2436
  __ lwz(tmp, offs1, addr);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2437
  __ srwi(tmp, tmp, BytecodePairHistogram::log2_number_of_codes);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2438
  __ ori(tmp, tmp, ((int) t->bytecode()) << BytecodePairHistogram::log2_number_of_codes);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2439
  __ stw(tmp, offs1, addr);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2440
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2441
  // Bump bucket contents.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2442
  // _counters[_index] ++;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2443
  int offs2 = __ load_const_optimized(addr, (address)&BytecodePairHistogram::_counters, R0, true);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2444
  __ sldi(tmp, tmp, LogBytesPerInt);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2445
  __ add(addr, tmp, addr);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2446
  __ lwz(tmp, offs2, addr);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2447
  __ addi(tmp, tmp, 1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2448
  __ stw(tmp, offs2, addr);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2449
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2450
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2451
void TemplateInterpreterGenerator::trace_bytecode(Template* t) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2452
  // Call a little run-time stub to avoid blow-up for each bytecode.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2453
  // The run-time runtime saves the right registers, depending on
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2454
  // the tosca in-state for the given template.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2455
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2456
  assert(Interpreter::trace_code(t->tos_in()) != NULL,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2457
         "entry must have been generated");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2458
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2459
  // Note: we destroy LR here.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2460
  __ bl(Interpreter::trace_code(t->tos_in()));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2461
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2462
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2463
void TemplateInterpreterGenerator::stop_interpreter_at() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2464
  Label L;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2465
  int offs1 = __ load_const_optimized(R11_scratch1, (address) &StopInterpreterAt, R0, true);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2466
  int offs2 = __ load_const_optimized(R12_scratch2, (address) &BytecodeCounter::_counter_value, R0, true);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2467
  __ ld(R11_scratch1, offs1, R11_scratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2468
  __ lwa(R12_scratch2, offs2, R12_scratch2);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2469
  __ cmpd(CCR0, R12_scratch2, R11_scratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2470
  __ bne(CCR0, L);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2471
  __ illtrap();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2472
  __ bind(L);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2473
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2474
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2475
#endif // !PRODUCT