hotspot/src/cpu/ppc/vm/stubGenerator_ppc.cpp
author mikael
Tue, 03 May 2016 08:12:25 -0700
changeset 38174 f611c50b8703
parent 37466 287c4ebd11b0
child 38190 ff9ac612c723
permissions -rw-r--r--
8153892: Handle unsafe access error directly in signal handler instead of going through a stub Reviewed-by: stuefe, dholmes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
     1
/*
35541
cba047a086d5 8146613: PPC64: C2 does no longer respect int to long conversion for stub calls
mdoerr
parents: 35156
diff changeset
     2
 * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
35594
cc13089c6327 8147937: Adapt SAP copyrights to new company name.
goetz
parents: 35546
diff changeset
     3
 * Copyright (c) 2012, 2016 SAP SE. All rights reserved.
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
     4
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
     5
 *
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
     6
 * This code is free software; you can redistribute it and/or modify it
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
     7
 * under the terms of the GNU General Public License version 2 only, as
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
     8
 * published by the Free Software Foundation.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
     9
 *
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    10
 * This code is distributed in the hope that it will be useful, but WITHOUT
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    11
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    12
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    13
 * version 2 for more details (a copy is included in the LICENSE file that
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    14
 * accompanied this code).
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    15
 *
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    16
 * You should have received a copy of the GNU General Public License version
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    17
 * 2 along with this work; if not, write to the Free Software Foundation,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    18
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    19
 *
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    20
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    21
 * or visit www.oracle.com if you need additional information or have any
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    22
 * questions.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    23
 *
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    24
 */
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    25
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    26
#include "precompiled.hpp"
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    27
#include "asm/macroAssembler.inline.hpp"
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    28
#include "interpreter/interpreter.hpp"
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    29
#include "nativeInst_ppc.hpp"
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    30
#include "oops/instanceOop.hpp"
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    31
#include "oops/method.hpp"
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    32
#include "oops/objArrayKlass.hpp"
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    33
#include "oops/oop.inline.hpp"
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    34
#include "prims/methodHandles.hpp"
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    35
#include "runtime/frame.inline.hpp"
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    36
#include "runtime/handles.inline.hpp"
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    37
#include "runtime/sharedRuntime.hpp"
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    38
#include "runtime/stubCodeGenerator.hpp"
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    39
#include "runtime/stubRoutines.hpp"
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 23211
diff changeset
    40
#include "runtime/thread.inline.hpp"
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    41
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    42
#define __ _masm->
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    43
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    44
#ifdef PRODUCT
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    45
#define BLOCK_COMMENT(str) // nothing
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    46
#else
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    47
#define BLOCK_COMMENT(str) __ block_comment(str)
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    48
#endif
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    49
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
    50
#if defined(ABI_ELFv2)
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
    51
#define STUB_ENTRY(name) StubRoutines::name()
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
    52
#else
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
    53
#define STUB_ENTRY(name) ((FunctionDescriptor*)StubRoutines::name())->entry()
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
    54
#endif
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
    55
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    56
class StubGenerator: public StubCodeGenerator {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    57
 private:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    58
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    59
  // Call stubs are used to call Java from C
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    60
  //
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    61
  // Arguments:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    62
  //
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    63
  //   R3  - call wrapper address     : address
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    64
  //   R4  - result                   : intptr_t*
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    65
  //   R5  - result type              : BasicType
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    66
  //   R6  - method                   : Method
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    67
  //   R7  - frame mgr entry point    : address
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    68
  //   R8  - parameter block          : intptr_t*
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    69
  //   R9  - parameter count in words : int
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    70
  //   R10 - thread                   : Thread*
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    71
  //
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    72
  address generate_call_stub(address& return_address) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    73
    // Setup a new c frame, copy java arguments, call frame manager or
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    74
    // native_entry, and process result.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    75
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    76
    StubCodeMark mark(this, "StubRoutines", "call_stub");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    77
23211
954e3a81da29 8035647: PPC64: Support for elf v2 abi.
goetz
parents: 22874
diff changeset
    78
    address start = __ function_entry();
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    79
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    80
    // some sanity checks
23211
954e3a81da29 8035647: PPC64: Support for elf v2 abi.
goetz
parents: 22874
diff changeset
    81
    assert((sizeof(frame::abi_minframe) % 16) == 0,           "unaligned");
954e3a81da29 8035647: PPC64: Support for elf v2 abi.
goetz
parents: 22874
diff changeset
    82
    assert((sizeof(frame::abi_reg_args) % 16) == 0,           "unaligned");
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    83
    assert((sizeof(frame::spill_nonvolatiles) % 16) == 0,     "unaligned");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    84
    assert((sizeof(frame::parent_ijava_frame_abi) % 16) == 0, "unaligned");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    85
    assert((sizeof(frame::entry_frame_locals) % 16) == 0,     "unaligned");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    86
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    87
    Register r_arg_call_wrapper_addr        = R3;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    88
    Register r_arg_result_addr              = R4;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    89
    Register r_arg_result_type              = R5;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    90
    Register r_arg_method                   = R6;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    91
    Register r_arg_entry                    = R7;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    92
    Register r_arg_thread                   = R10;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    93
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    94
    Register r_temp                         = R24;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    95
    Register r_top_of_arguments_addr        = R25;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    96
    Register r_entryframe_fp                = R26;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    97
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    98
    {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    99
      // Stack on entry to call_stub:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   100
      //
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   101
      //      F1      [C_FRAME]
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   102
      //              ...
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   103
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   104
      Register r_arg_argument_addr          = R8;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   105
      Register r_arg_argument_count         = R9;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   106
      Register r_frame_alignment_in_bytes   = R27;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   107
      Register r_argument_addr              = R28;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   108
      Register r_argumentcopy_addr          = R29;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   109
      Register r_argument_size_in_bytes     = R30;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   110
      Register r_frame_size                 = R23;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   111
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   112
      Label arguments_copied;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   113
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   114
      // Save LR/CR to caller's C_FRAME.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   115
      __ save_LR_CR(R0);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   116
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   117
      // Zero extend arg_argument_count.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   118
      __ clrldi(r_arg_argument_count, r_arg_argument_count, 32);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   119
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   120
      // Save non-volatiles GPRs to ENTRY_FRAME (not yet pushed, but it's safe).
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   121
      __ save_nonvolatile_gprs(R1_SP, _spill_nonvolatiles_neg(r14));
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   122
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   123
      // Keep copy of our frame pointer (caller's SP).
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   124
      __ mr(r_entryframe_fp, R1_SP);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   125
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   126
      BLOCK_COMMENT("Push ENTRY_FRAME including arguments");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   127
      // Push ENTRY_FRAME including arguments:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   128
      //
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   129
      //      F0      [TOP_IJAVA_FRAME_ABI]
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   130
      //              alignment (optional)
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   131
      //              [outgoing Java arguments]
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   132
      //              [ENTRY_FRAME_LOCALS]
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   133
      //      F1      [C_FRAME]
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   134
      //              ...
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   135
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   136
      // calculate frame size
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   137
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   138
      // unaligned size of arguments
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   139
      __ sldi(r_argument_size_in_bytes,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   140
                  r_arg_argument_count, Interpreter::logStackElementSize);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   141
      // arguments alignment (max 1 slot)
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   142
      // FIXME: use round_to() here
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   143
      __ andi_(r_frame_alignment_in_bytes, r_arg_argument_count, 1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   144
      __ sldi(r_frame_alignment_in_bytes,
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
   145
              r_frame_alignment_in_bytes, Interpreter::logStackElementSize);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   146
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   147
      // size = unaligned size of arguments + top abi's size
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   148
      __ addi(r_frame_size, r_argument_size_in_bytes,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   149
              frame::top_ijava_frame_abi_size);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   150
      // size += arguments alignment
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   151
      __ add(r_frame_size,
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
   152
             r_frame_size, r_frame_alignment_in_bytes);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   153
      // size += size of call_stub locals
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   154
      __ addi(r_frame_size,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   155
              r_frame_size, frame::entry_frame_locals_size);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   156
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   157
      // push ENTRY_FRAME
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   158
      __ push_frame(r_frame_size, r_temp);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   159
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   160
      // initialize call_stub locals (step 1)
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   161
      __ std(r_arg_call_wrapper_addr,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   162
             _entry_frame_locals_neg(call_wrapper_address), r_entryframe_fp);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   163
      __ std(r_arg_result_addr,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   164
             _entry_frame_locals_neg(result_address), r_entryframe_fp);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   165
      __ std(r_arg_result_type,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   166
             _entry_frame_locals_neg(result_type), r_entryframe_fp);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   167
      // we will save arguments_tos_address later
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   168
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   169
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   170
      BLOCK_COMMENT("Copy Java arguments");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   171
      // copy Java arguments
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   172
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   173
      // Calculate top_of_arguments_addr which will be R17_tos (not prepushed) later.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   174
      // FIXME: why not simply use SP+frame::top_ijava_frame_size?
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   175
      __ addi(r_top_of_arguments_addr,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   176
              R1_SP, frame::top_ijava_frame_abi_size);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   177
      __ add(r_top_of_arguments_addr,
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
   178
             r_top_of_arguments_addr, r_frame_alignment_in_bytes);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   179
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   180
      // any arguments to copy?
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   181
      __ cmpdi(CCR0, r_arg_argument_count, 0);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   182
      __ beq(CCR0, arguments_copied);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   183
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   184
      // prepare loop and copy arguments in reverse order
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   185
      {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   186
        // init CTR with arg_argument_count
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   187
        __ mtctr(r_arg_argument_count);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   188
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   189
        // let r_argumentcopy_addr point to last outgoing Java arguments P
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   190
        __ mr(r_argumentcopy_addr, r_top_of_arguments_addr);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   191
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   192
        // let r_argument_addr point to last incoming java argument
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   193
        __ add(r_argument_addr,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   194
                   r_arg_argument_addr, r_argument_size_in_bytes);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   195
        __ addi(r_argument_addr, r_argument_addr, -BytesPerWord);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   196
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   197
        // now loop while CTR > 0 and copy arguments
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   198
        {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   199
          Label next_argument;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   200
          __ bind(next_argument);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   201
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   202
          __ ld(r_temp, 0, r_argument_addr);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   203
          // argument_addr--;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   204
          __ addi(r_argument_addr, r_argument_addr, -BytesPerWord);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   205
          __ std(r_temp, 0, r_argumentcopy_addr);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   206
          // argumentcopy_addr++;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   207
          __ addi(r_argumentcopy_addr, r_argumentcopy_addr, BytesPerWord);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   208
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   209
          __ bdnz(next_argument);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   210
        }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   211
      }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   212
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   213
      // Arguments copied, continue.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   214
      __ bind(arguments_copied);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   215
    }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   216
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   217
    {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   218
      BLOCK_COMMENT("Call frame manager or native entry.");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   219
      // Call frame manager or native entry.
27012
f8fdfab4757b 8059592: Recent bugfixes in ppc64 port.
goetz
parents: 25717
diff changeset
   220
      Register r_new_arg_entry = R14;
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   221
      assert_different_registers(r_new_arg_entry, r_top_of_arguments_addr,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   222
                                 r_arg_method, r_arg_thread);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   223
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   224
      __ mr(r_new_arg_entry, r_arg_entry);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   225
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   226
      // Register state on entry to frame manager / native entry:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   227
      //
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
   228
      //   tos         -  intptr_t*    sender tos (prepushed) Lesp = (SP) + copied_arguments_offset - 8
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   229
      //   R19_method  -  Method
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   230
      //   R16_thread  -  JavaThread*
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   231
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
   232
      // Tos must point to last argument - element_size.
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 23211
diff changeset
   233
      const Register tos = R15_esp;
35166
23125410af16 8145117: PPC64: Remove cpp interpreter implementation
goetz
parents: 34148
diff changeset
   234
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
   235
      __ addi(tos, r_top_of_arguments_addr, -Interpreter::stackElementSize);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   236
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   237
      // initialize call_stub locals (step 2)
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
   238
      // now save tos as arguments_tos_address
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
   239
      __ std(tos, _entry_frame_locals_neg(arguments_tos_address), r_entryframe_fp);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   240
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   241
      // load argument registers for call
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   242
      __ mr(R19_method, r_arg_method);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   243
      __ mr(R16_thread, r_arg_thread);
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
   244
      assert(tos != r_arg_method, "trashed r_arg_method");
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
   245
      assert(tos != r_arg_thread && R19_method != r_arg_thread, "trashed r_arg_thread");
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   246
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   247
      // Set R15_prev_state to 0 for simplifying checks in callee.
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 23211
diff changeset
   248
      __ load_const_optimized(R25_templateTableBase, (address)Interpreter::dispatch_table((TosState)0), R11_scratch1);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   249
      // Stack on entry to frame manager / native entry:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   250
      //
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   251
      //      F0      [TOP_IJAVA_FRAME_ABI]
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   252
      //              alignment (optional)
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   253
      //              [outgoing Java arguments]
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   254
      //              [ENTRY_FRAME_LOCALS]
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   255
      //      F1      [C_FRAME]
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   256
      //              ...
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   257
      //
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   258
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   259
      // global toc register
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
   260
      __ load_const_optimized(R29_TOC, MacroAssembler::global_toc(), R11_scratch1);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   261
      // Remember the senderSP so we interpreter can pop c2i arguments off of the stack
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   262
      // when called via a c2i.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   263
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   264
      // Pass initial_caller_sp to framemanager.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   265
      __ mr(R21_tmp1, R1_SP);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   266
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   267
      // Do a light-weight C-call here, r_new_arg_entry holds the address
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   268
      // of the interpreter entry point (frame manager or native entry)
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   269
      // and save runtime-value of LR in return_address.
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
   270
      assert(r_new_arg_entry != tos && r_new_arg_entry != R19_method && r_new_arg_entry != R16_thread,
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   271
             "trashed r_new_arg_entry");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   272
      return_address = __ call_stub(r_new_arg_entry);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   273
    }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   274
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   275
    {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   276
      BLOCK_COMMENT("Returned from frame manager or native entry.");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   277
      // Returned from frame manager or native entry.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   278
      // Now pop frame, process result, and return to caller.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   279
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   280
      // Stack on exit from frame manager / native entry:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   281
      //
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   282
      //      F0      [ABI]
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   283
      //              ...
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   284
      //              [ENTRY_FRAME_LOCALS]
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   285
      //      F1      [C_FRAME]
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   286
      //              ...
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   287
      //
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   288
      // Just pop the topmost frame ...
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   289
      //
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   290
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   291
      Label ret_is_object;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   292
      Label ret_is_long;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   293
      Label ret_is_float;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   294
      Label ret_is_double;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   295
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   296
      Register r_entryframe_fp = R30;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   297
      Register r_lr            = R7_ARG5;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   298
      Register r_cr            = R8_ARG6;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   299
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   300
      // Reload some volatile registers which we've spilled before the call
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   301
      // to frame manager / native entry.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   302
      // Access all locals via frame pointer, because we know nothing about
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   303
      // the topmost frame's size.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   304
      __ ld(r_entryframe_fp, _abi(callers_sp), R1_SP);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   305
      assert_different_registers(r_entryframe_fp, R3_RET, r_arg_result_addr, r_arg_result_type, r_cr, r_lr);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   306
      __ ld(r_arg_result_addr,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   307
            _entry_frame_locals_neg(result_address), r_entryframe_fp);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   308
      __ ld(r_arg_result_type,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   309
            _entry_frame_locals_neg(result_type), r_entryframe_fp);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   310
      __ ld(r_cr, _abi(cr), r_entryframe_fp);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   311
      __ ld(r_lr, _abi(lr), r_entryframe_fp);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   312
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   313
      // pop frame and restore non-volatiles, LR and CR
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   314
      __ mr(R1_SP, r_entryframe_fp);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   315
      __ mtcr(r_cr);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   316
      __ mtlr(r_lr);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   317
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   318
      // Store result depending on type. Everything that is not
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   319
      // T_OBJECT, T_LONG, T_FLOAT, or T_DOUBLE is treated as T_INT.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   320
      __ cmpwi(CCR0, r_arg_result_type, T_OBJECT);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   321
      __ cmpwi(CCR1, r_arg_result_type, T_LONG);
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
   322
      __ cmpwi(CCR5, r_arg_result_type, T_FLOAT);
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
   323
      __ cmpwi(CCR6, r_arg_result_type, T_DOUBLE);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   324
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   325
      // restore non-volatile registers
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   326
      __ restore_nonvolatile_gprs(R1_SP, _spill_nonvolatiles_neg(r14));
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   327
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   328
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   329
      // Stack on exit from call_stub:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   330
      //
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   331
      //      0       [C_FRAME]
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   332
      //              ...
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   333
      //
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   334
      //  no call_stub frames left.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   335
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   336
      // All non-volatiles have been restored at this point!!
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   337
      assert(R3_RET == R3, "R3_RET should be R3");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   338
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   339
      __ beq(CCR0, ret_is_object);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   340
      __ beq(CCR1, ret_is_long);
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
   341
      __ beq(CCR5, ret_is_float);
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
   342
      __ beq(CCR6, ret_is_double);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   343
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   344
      // default:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   345
      __ stw(R3_RET, 0, r_arg_result_addr);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   346
      __ blr(); // return to caller
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   347
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   348
      // case T_OBJECT:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   349
      __ bind(ret_is_object);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   350
      __ std(R3_RET, 0, r_arg_result_addr);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   351
      __ blr(); // return to caller
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   352
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   353
      // case T_LONG:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   354
      __ bind(ret_is_long);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   355
      __ std(R3_RET, 0, r_arg_result_addr);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   356
      __ blr(); // return to caller
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   357
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   358
      // case T_FLOAT:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   359
      __ bind(ret_is_float);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   360
      __ stfs(F1_RET, 0, r_arg_result_addr);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   361
      __ blr(); // return to caller
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   362
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   363
      // case T_DOUBLE:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   364
      __ bind(ret_is_double);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   365
      __ stfd(F1_RET, 0, r_arg_result_addr);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   366
      __ blr(); // return to caller
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   367
    }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   368
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   369
    return start;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   370
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   371
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   372
  // Return point for a Java call if there's an exception thrown in
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   373
  // Java code.  The exception is caught and transformed into a
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   374
  // pending exception stored in JavaThread that can be tested from
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   375
  // within the VM.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   376
  //
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   377
  address generate_catch_exception() {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   378
    StubCodeMark mark(this, "StubRoutines", "catch_exception");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   379
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   380
    address start = __ pc();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   381
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   382
    // Registers alive
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   383
    //
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   384
    //  R16_thread
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   385
    //  R3_ARG1 - address of pending exception
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   386
    //  R4_ARG2 - return address in call stub
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   387
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   388
    const Register exception_file = R21_tmp1;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   389
    const Register exception_line = R22_tmp2;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   390
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   391
    __ load_const(exception_file, (void*)__FILE__);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   392
    __ load_const(exception_line, (void*)__LINE__);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   393
25715
d5a8dbdc5150 8049325: Introduce and clean up umbrella headers for the files in the cpu subdirectories.
goetz
parents: 23221
diff changeset
   394
    __ std(R3_ARG1, in_bytes(JavaThread::pending_exception_offset()), R16_thread);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   395
    // store into `char *'
25715
d5a8dbdc5150 8049325: Introduce and clean up umbrella headers for the files in the cpu subdirectories.
goetz
parents: 23221
diff changeset
   396
    __ std(exception_file, in_bytes(JavaThread::exception_file_offset()), R16_thread);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   397
    // store into `int'
25715
d5a8dbdc5150 8049325: Introduce and clean up umbrella headers for the files in the cpu subdirectories.
goetz
parents: 23221
diff changeset
   398
    __ stw(exception_line, in_bytes(JavaThread::exception_line_offset()), R16_thread);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   399
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   400
    // complete return to VM
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   401
    assert(StubRoutines::_call_stub_return_address != NULL, "must have been generated before");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   402
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   403
    __ mtlr(R4_ARG2);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   404
    // continue in call stub
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   405
    __ blr();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   406
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   407
    return start;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   408
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   409
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   410
  // Continuation point for runtime calls returning with a pending
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   411
  // exception.  The pending exception check happened in the runtime
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   412
  // or native call stub.  The pending exception in Thread is
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   413
  // converted into a Java-level exception.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   414
  //
30303
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29695
diff changeset
   415
  // Read:
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29695
diff changeset
   416
  //
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29695
diff changeset
   417
  //   LR:     The pc the runtime library callee wants to return to.
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29695
diff changeset
   418
  //           Since the exception occurred in the callee, the return pc
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29695
diff changeset
   419
  //           from the point of view of Java is the exception pc.
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29695
diff changeset
   420
  //   thread: Needed for method handles.
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29695
diff changeset
   421
  //
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29695
diff changeset
   422
  // Invalidate:
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29695
diff changeset
   423
  //
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29695
diff changeset
   424
  //   volatile registers (except below).
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29695
diff changeset
   425
  //
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29695
diff changeset
   426
  // Update:
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29695
diff changeset
   427
  //
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29695
diff changeset
   428
  //   R4_ARG2: exception
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29695
diff changeset
   429
  //
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29695
diff changeset
   430
  // (LR is unchanged and is live out).
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29695
diff changeset
   431
  //
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   432
  address generate_forward_exception() {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   433
    StubCodeMark mark(this, "StubRoutines", "forward_exception");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   434
    address start = __ pc();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   435
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   436
#if !defined(PRODUCT)
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   437
    if (VerifyOops) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   438
      // Get pending exception oop.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   439
      __ ld(R3_ARG1,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   440
                in_bytes(Thread::pending_exception_offset()),
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   441
                R16_thread);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   442
      // Make sure that this code is only executed if there is a pending exception.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   443
      {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   444
        Label L;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   445
        __ cmpdi(CCR0, R3_ARG1, 0);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   446
        __ bne(CCR0, L);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   447
        __ stop("StubRoutines::forward exception: no pending exception (1)");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   448
        __ bind(L);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   449
      }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   450
      __ verify_oop(R3_ARG1, "StubRoutines::forward exception: not an oop");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   451
    }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   452
#endif
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   453
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   454
    // Save LR/CR and copy exception pc (LR) into R4_ARG2.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   455
    __ save_LR_CR(R4_ARG2);
23211
954e3a81da29 8035647: PPC64: Support for elf v2 abi.
goetz
parents: 22874
diff changeset
   456
    __ push_frame_reg_args(0, R0);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   457
    // Find exception handler.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   458
    __ call_VM_leaf(CAST_FROM_FN_PTR(address,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   459
                     SharedRuntime::exception_handler_for_return_address),
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   460
                    R16_thread,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   461
                    R4_ARG2);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   462
    // Copy handler's address.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   463
    __ mtctr(R3_RET);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   464
    __ pop_frame();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   465
    __ restore_LR_CR(R0);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   466
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   467
    // Set up the arguments for the exception handler:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   468
    //  - R3_ARG1: exception oop
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   469
    //  - R4_ARG2: exception pc.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   470
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   471
    // Load pending exception oop.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   472
    __ ld(R3_ARG1,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   473
              in_bytes(Thread::pending_exception_offset()),
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   474
              R16_thread);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   475
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   476
    // The exception pc is the return address in the caller.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   477
    // Must load it into R4_ARG2.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   478
    __ mflr(R4_ARG2);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   479
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   480
#ifdef ASSERT
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   481
    // Make sure exception is set.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   482
    {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   483
      Label L;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   484
      __ cmpdi(CCR0, R3_ARG1, 0);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   485
      __ bne(CCR0, L);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   486
      __ stop("StubRoutines::forward exception: no pending exception (2)");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   487
      __ bind(L);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   488
    }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   489
#endif
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   490
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   491
    // Clear the pending exception.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   492
    __ li(R0, 0);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   493
    __ std(R0,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   494
               in_bytes(Thread::pending_exception_offset()),
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   495
               R16_thread);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   496
    // Jump to exception handler.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   497
    __ bctr();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   498
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   499
    return start;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   500
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   501
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   502
#undef __
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   503
#define __ masm->
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   504
  // Continuation point for throwing of implicit exceptions that are
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   505
  // not handled in the current activation. Fabricates an exception
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   506
  // oop and initiates normal exception dispatching in this
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   507
  // frame. Only callee-saved registers are preserved (through the
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   508
  // normal register window / RegisterMap handling).  If the compiler
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   509
  // needs all registers to be preserved between the fault point and
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   510
  // the exception handler then it must assume responsibility for that
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   511
  // in AbstractCompiler::continuation_for_implicit_null_exception or
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   512
  // continuation_for_implicit_division_by_zero_exception. All other
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   513
  // implicit exceptions (e.g., NullPointerException or
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   514
  // AbstractMethodError on entry) are either at call sites or
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   515
  // otherwise assume that stack unwinding will be initiated, so
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   516
  // caller saved registers were assumed volatile in the compiler.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   517
  //
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   518
  // Note that we generate only this stub into a RuntimeStub, because
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   519
  // it needs to be properly traversed and ignored during GC, so we
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   520
  // change the meaning of the "__" macro within this method.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   521
  //
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   522
  // Note: the routine set_pc_not_at_call_for_caller in
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   523
  // SharedRuntime.cpp requires that this code be generated into a
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   524
  // RuntimeStub.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   525
  address generate_throw_exception(const char* name, address runtime_entry, bool restore_saved_exception_pc,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   526
                                   Register arg1 = noreg, Register arg2 = noreg) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   527
    CodeBuffer code(name, 1024 DEBUG_ONLY(+ 512), 0);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   528
    MacroAssembler* masm = new MacroAssembler(&code);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   529
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   530
    OopMapSet* oop_maps  = new OopMapSet();
23211
954e3a81da29 8035647: PPC64: Support for elf v2 abi.
goetz
parents: 22874
diff changeset
   531
    int frame_size_in_bytes = frame::abi_reg_args_size;
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   532
    OopMap* map = new OopMap(frame_size_in_bytes / sizeof(jint), 0);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   533
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   534
    address start = __ pc();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   535
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   536
    __ save_LR_CR(R11_scratch1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   537
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   538
    // Push a frame.
23211
954e3a81da29 8035647: PPC64: Support for elf v2 abi.
goetz
parents: 22874
diff changeset
   539
    __ push_frame_reg_args(0, R11_scratch1);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   540
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   541
    address frame_complete_pc = __ pc();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   542
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   543
    if (restore_saved_exception_pc) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   544
      __ unimplemented("StubGenerator::throw_exception with restore_saved_exception_pc", 74);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   545
    }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   546
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   547
    // Note that we always have a runtime stub frame on the top of
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   548
    // stack by this point. Remember the offset of the instruction
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   549
    // whose address will be moved to R11_scratch1.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   550
    address gc_map_pc = __ get_PC_trash_LR(R11_scratch1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   551
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   552
    __ set_last_Java_frame(/*sp*/R1_SP, /*pc*/R11_scratch1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   553
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   554
    __ mr(R3_ARG1, R16_thread);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   555
    if (arg1 != noreg) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   556
      __ mr(R4_ARG2, arg1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   557
    }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   558
    if (arg2 != noreg) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   559
      __ mr(R5_ARG3, arg2);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   560
    }
23211
954e3a81da29 8035647: PPC64: Support for elf v2 abi.
goetz
parents: 22874
diff changeset
   561
#if defined(ABI_ELFv2)
954e3a81da29 8035647: PPC64: Support for elf v2 abi.
goetz
parents: 22874
diff changeset
   562
    __ call_c(runtime_entry, relocInfo::none);
954e3a81da29 8035647: PPC64: Support for elf v2 abi.
goetz
parents: 22874
diff changeset
   563
#else
954e3a81da29 8035647: PPC64: Support for elf v2 abi.
goetz
parents: 22874
diff changeset
   564
    __ call_c(CAST_FROM_FN_PTR(FunctionDescriptor*, runtime_entry), relocInfo::none);
954e3a81da29 8035647: PPC64: Support for elf v2 abi.
goetz
parents: 22874
diff changeset
   565
#endif
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   566
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   567
    // Set an oopmap for the call site.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   568
    oop_maps->add_gc_map((int)(gc_map_pc - start), map);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   569
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   570
    __ reset_last_Java_frame();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   571
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   572
#ifdef ASSERT
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   573
    // Make sure that this code is only executed if there is a pending
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   574
    // exception.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   575
    {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   576
      Label L;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   577
      __ ld(R0,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   578
                in_bytes(Thread::pending_exception_offset()),
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   579
                R16_thread);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   580
      __ cmpdi(CCR0, R0, 0);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   581
      __ bne(CCR0, L);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   582
      __ stop("StubRoutines::throw_exception: no pending exception");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   583
      __ bind(L);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   584
    }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   585
#endif
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   586
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   587
    // Pop frame.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   588
    __ pop_frame();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   589
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   590
    __ restore_LR_CR(R11_scratch1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   591
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   592
    __ load_const(R11_scratch1, StubRoutines::forward_exception_entry());
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   593
    __ mtctr(R11_scratch1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   594
    __ bctr();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   595
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   596
    // Create runtime stub with OopMap.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   597
    RuntimeStub* stub =
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   598
      RuntimeStub::new_runtime_stub(name, &code,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   599
                                    /*frame_complete=*/ (int)(frame_complete_pc - start),
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   600
                                    frame_size_in_bytes/wordSize,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   601
                                    oop_maps,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   602
                                    false);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   603
    return stub->entry_point();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   604
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   605
#undef __
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   606
#define __ _masm->
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   607
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   608
  //  Generate G1 pre-write barrier for array.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   609
  //
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   610
  //  Input:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   611
  //     from     - register containing src address (only needed for spilling)
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   612
  //     to       - register containing starting address
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   613
  //     count    - register containing element count
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   614
  //     tmp      - scratch register
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   615
  //
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   616
  //  Kills:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   617
  //     nothing
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   618
  //
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
   619
  void gen_write_ref_array_pre_barrier(Register from, Register to, Register count, bool dest_uninitialized, Register Rtmp1,
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
   620
                                       Register preserve1 = noreg, Register preserve2 = noreg) {
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   621
    BarrierSet* const bs = Universe::heap()->barrier_set();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   622
    switch (bs->kind()) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   623
      case BarrierSet::G1SATBCTLogging:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   624
        // With G1, don't generate the call if we statically know that the target in uninitialized
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   625
        if (!dest_uninitialized) {
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
   626
          int spill_slots = 3;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
   627
          if (preserve1 != noreg) { spill_slots++; }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
   628
          if (preserve2 != noreg) { spill_slots++; }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
   629
          const int frame_size = align_size_up(frame::abi_reg_args_size + spill_slots * BytesPerWord, frame::alignment_in_bytes);
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
   630
          Label filtered;
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
   631
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
   632
          // Is marking active?
34148
6efbc7ffd767 8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents: 33142
diff changeset
   633
          if (in_bytes(SATBMarkQueue::byte_width_of_active()) == 4) {
6efbc7ffd767 8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents: 33142
diff changeset
   634
            __ lwz(Rtmp1, in_bytes(JavaThread::satb_mark_queue_offset() + SATBMarkQueue::byte_offset_of_active()), R16_thread);
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
   635
          } else {
34148
6efbc7ffd767 8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents: 33142
diff changeset
   636
            guarantee(in_bytes(SATBMarkQueue::byte_width_of_active()) == 1, "Assumption");
6efbc7ffd767 8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents: 33142
diff changeset
   637
            __ lbz(Rtmp1, in_bytes(JavaThread::satb_mark_queue_offset() + SATBMarkQueue::byte_offset_of_active()), R16_thread);
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
   638
          }
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
   639
          __ cmpdi(CCR0, Rtmp1, 0);
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
   640
          __ beq(CCR0, filtered);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   641
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   642
          __ save_LR_CR(R0);
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
   643
          __ push_frame(frame_size, R0);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
   644
          int slot_nr = 0;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
   645
          __ std(from,  frame_size - (++slot_nr) * wordSize, R1_SP);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
   646
          __ std(to,    frame_size - (++slot_nr) * wordSize, R1_SP);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
   647
          __ std(count, frame_size - (++slot_nr) * wordSize, R1_SP);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
   648
          if (preserve1 != noreg) { __ std(preserve1, frame_size - (++slot_nr) * wordSize, R1_SP); }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
   649
          if (preserve2 != noreg) { __ std(preserve2, frame_size - (++slot_nr) * wordSize, R1_SP); }
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   650
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   651
          __ call_VM_leaf(CAST_FROM_FN_PTR(address, BarrierSet::static_write_ref_array_pre), to, count);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   652
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
   653
          slot_nr = 0;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
   654
          __ ld(from,  frame_size - (++slot_nr) * wordSize, R1_SP);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
   655
          __ ld(to,    frame_size - (++slot_nr) * wordSize, R1_SP);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
   656
          __ ld(count, frame_size - (++slot_nr) * wordSize, R1_SP);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
   657
          if (preserve1 != noreg) { __ ld(preserve1, frame_size - (++slot_nr) * wordSize, R1_SP); }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
   658
          if (preserve2 != noreg) { __ ld(preserve2, frame_size - (++slot_nr) * wordSize, R1_SP); }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
   659
          __ addi(R1_SP, R1_SP, frame_size); // pop_frame()
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   660
          __ restore_LR_CR(R0);
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
   661
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
   662
          __ bind(filtered);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   663
        }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   664
        break;
32596
8feecdee3156 8072817: CardTableExtension kind() should be BarrierSet::CardTableExtension
kbarrett
parents: 31861
diff changeset
   665
      case BarrierSet::CardTableForRS:
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   666
      case BarrierSet::CardTableExtension:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   667
      case BarrierSet::ModRef:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   668
        break;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   669
      default:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   670
        ShouldNotReachHere();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   671
    }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   672
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   673
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   674
  //  Generate CMS/G1 post-write barrier for array.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   675
  //
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   676
  //  Input:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   677
  //     addr     - register containing starting address
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   678
  //     count    - register containing element count
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   679
  //     tmp      - scratch register
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   680
  //
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   681
  //  The input registers and R0 are overwritten.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   682
  //
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
   683
  void gen_write_ref_array_post_barrier(Register addr, Register count, Register tmp, Register preserve = noreg) {
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   684
    BarrierSet* const bs = Universe::heap()->barrier_set();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   685
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   686
    switch (bs->kind()) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   687
      case BarrierSet::G1SATBCTLogging:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   688
        {
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
   689
          int spill_slots = (preserve != noreg) ? 1 : 0;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
   690
          const int frame_size = align_size_up(frame::abi_reg_args_size + spill_slots * BytesPerWord, frame::alignment_in_bytes);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
   691
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
   692
          __ save_LR_CR(R0);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
   693
          __ push_frame(frame_size, R0);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
   694
          if (preserve != noreg) { __ std(preserve, frame_size - 1 * wordSize, R1_SP); }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
   695
          __ call_VM_leaf(CAST_FROM_FN_PTR(address, BarrierSet::static_write_ref_array_post), addr, count);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
   696
          if (preserve != noreg) { __ ld(preserve, frame_size - 1 * wordSize, R1_SP); }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
   697
          __ addi(R1_SP, R1_SP, frame_size); // pop_frame();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
   698
          __ restore_LR_CR(R0);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   699
        }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   700
        break;
32596
8feecdee3156 8072817: CardTableExtension kind() should be BarrierSet::CardTableExtension
kbarrett
parents: 31861
diff changeset
   701
      case BarrierSet::CardTableForRS:
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   702
      case BarrierSet::CardTableExtension:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   703
        {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   704
          Label Lskip_loop, Lstore_loop;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   705
          if (UseConcMarkSweepGC) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   706
            // TODO PPC port: contribute optimization / requires shared changes
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   707
            __ release();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   708
          }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   709
29325
0e86e64c66e5 8069016: Add BarrierSet downcast support
kbarrett
parents: 28492
diff changeset
   710
          CardTableModRefBS* const ct = barrier_set_cast<CardTableModRefBS>(bs);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   711
          assert(sizeof(*ct->byte_map_base) == sizeof(jbyte), "adjust this code");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   712
          assert_different_registers(addr, count, tmp);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   713
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   714
          __ sldi(count, count, LogBytesPerHeapOop);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   715
          __ addi(count, count, -BytesPerHeapOop);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   716
          __ add(count, addr, count);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   717
          // Use two shifts to clear out those low order two bits! (Cannot opt. into 1.)
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   718
          __ srdi(addr, addr, CardTableModRefBS::card_shift);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   719
          __ srdi(count, count, CardTableModRefBS::card_shift);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   720
          __ subf(count, addr, count);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   721
          assert_different_registers(R0, addr, count, tmp);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   722
          __ load_const(tmp, (address)ct->byte_map_base);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   723
          __ addic_(count, count, 1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   724
          __ beq(CCR0, Lskip_loop);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   725
          __ li(R0, 0);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   726
          __ mtctr(count);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   727
          // Byte store loop
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   728
          __ bind(Lstore_loop);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   729
          __ stbx(R0, tmp, addr);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   730
          __ addi(addr, addr, 1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   731
          __ bdnz(Lstore_loop);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   732
          __ bind(Lskip_loop);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   733
        }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   734
      break;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   735
      case BarrierSet::ModRef:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   736
        break;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   737
      default:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   738
        ShouldNotReachHere();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   739
    }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   740
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   741
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   742
  // Support for void zero_words_aligned8(HeapWord* to, size_t count)
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   743
  //
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   744
  // Arguments:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   745
  //   to:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   746
  //   count:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   747
  //
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   748
  // Destroys:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   749
  //
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   750
  address generate_zero_words_aligned8() {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   751
    StubCodeMark mark(this, "StubRoutines", "zero_words_aligned8");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   752
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   753
    // Implemented as in ClearArray.
23211
954e3a81da29 8035647: PPC64: Support for elf v2 abi.
goetz
parents: 22874
diff changeset
   754
    address start = __ function_entry();
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   755
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   756
    Register base_ptr_reg   = R3_ARG1; // tohw (needs to be 8b aligned)
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   757
    Register cnt_dwords_reg = R4_ARG2; // count (in dwords)
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   758
    Register tmp1_reg       = R5_ARG3;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   759
    Register tmp2_reg       = R6_ARG4;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   760
    Register zero_reg       = R7_ARG5;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   761
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   762
    // Procedure for large arrays (uses data cache block zero instruction).
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   763
    Label dwloop, fast, fastloop, restloop, lastdword, done;
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
   764
    int cl_size = VM_Version::L1_data_cache_line_size();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
   765
    int cl_dwords = cl_size >> 3;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
   766
    int cl_dwordaddr_bits = exact_log2(cl_dwords);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
   767
    int min_dcbz = 2; // Needs to be positive, apply dcbz only to at least min_dcbz cache lines.
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   768
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   769
    // Clear up to 128byte boundary if long enough, dword_cnt=(16-(base>>3))%16.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   770
    __ dcbtst(base_ptr_reg);                    // Indicate write access to first cache line ...
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   771
    __ andi(tmp2_reg, cnt_dwords_reg, 1);       // to check if number of dwords is even.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   772
    __ srdi_(tmp1_reg, cnt_dwords_reg, 1);      // number of double dwords
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   773
    __ load_const_optimized(zero_reg, 0L);      // Use as zero register.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   774
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   775
    __ cmpdi(CCR1, tmp2_reg, 0);                // cnt_dwords even?
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   776
    __ beq(CCR0, lastdword);                    // size <= 1
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   777
    __ mtctr(tmp1_reg);                         // Speculatively preload counter for rest loop (>0).
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   778
    __ cmpdi(CCR0, cnt_dwords_reg, (min_dcbz+1)*cl_dwords-1); // Big enough to ensure >=min_dcbz cache lines are included?
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   779
    __ neg(tmp1_reg, base_ptr_reg);             // bit 0..58: bogus, bit 57..60: (16-(base>>3))%16, bit 61..63: 000
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   780
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   781
    __ blt(CCR0, restloop);                     // Too small. (<31=(2*cl_dwords)-1 is sufficient, but bigger performs better.)
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   782
    __ rldicl_(tmp1_reg, tmp1_reg, 64-3, 64-cl_dwordaddr_bits); // Extract number of dwords to 128byte boundary=(16-(base>>3))%16.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   783
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   784
    __ beq(CCR0, fast);                         // already 128byte aligned
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   785
    __ mtctr(tmp1_reg);                         // Set ctr to hit 128byte boundary (0<ctr<cnt).
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   786
    __ subf(cnt_dwords_reg, tmp1_reg, cnt_dwords_reg); // rest (>0 since size>=256-8)
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   787
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   788
    // Clear in first cache line dword-by-dword if not already 128byte aligned.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   789
    __ bind(dwloop);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   790
      __ std(zero_reg, 0, base_ptr_reg);        // Clear 8byte aligned block.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   791
      __ addi(base_ptr_reg, base_ptr_reg, 8);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   792
    __ bdnz(dwloop);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   793
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   794
    // clear 128byte blocks
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   795
    __ bind(fast);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   796
    __ srdi(tmp1_reg, cnt_dwords_reg, cl_dwordaddr_bits); // loop count for 128byte loop (>0 since size>=256-8)
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   797
    __ andi(tmp2_reg, cnt_dwords_reg, 1);       // to check if rest even
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   798
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   799
    __ mtctr(tmp1_reg);                         // load counter
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   800
    __ cmpdi(CCR1, tmp2_reg, 0);                // rest even?
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   801
    __ rldicl_(tmp1_reg, cnt_dwords_reg, 63, 65-cl_dwordaddr_bits); // rest in double dwords
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   802
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   803
    __ bind(fastloop);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   804
      __ dcbz(base_ptr_reg);                    // Clear 128byte aligned block.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   805
      __ addi(base_ptr_reg, base_ptr_reg, cl_size);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   806
    __ bdnz(fastloop);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   807
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   808
    //__ dcbtst(base_ptr_reg);                  // Indicate write access to last cache line.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   809
    __ beq(CCR0, lastdword);                    // rest<=1
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   810
    __ mtctr(tmp1_reg);                         // load counter
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   811
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   812
    // Clear rest.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   813
    __ bind(restloop);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   814
      __ std(zero_reg, 0, base_ptr_reg);        // Clear 8byte aligned block.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   815
      __ std(zero_reg, 8, base_ptr_reg);        // Clear 8byte aligned block.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   816
      __ addi(base_ptr_reg, base_ptr_reg, 16);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   817
    __ bdnz(restloop);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   818
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   819
    __ bind(lastdword);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   820
    __ beq(CCR1, done);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   821
    __ std(zero_reg, 0, base_ptr_reg);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   822
    __ bind(done);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   823
    __ blr();                                   // return
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   825
    return start;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   826
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   827
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   828
#if !defined(PRODUCT)
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   829
  // Wrapper which calls oopDesc::is_oop_or_null()
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   830
  // Only called by MacroAssembler::verify_oop
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   831
  static void verify_oop_helper(const char* message, oop o) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   832
    if (!o->is_oop_or_null()) {
33142
399fdb935d28 8138733: Fix build: gcc < 4.8 doesn't grok -Wno-format-zero-length added in 8080775
goetz
parents: 32596
diff changeset
   833
      fatal("%s", message);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   834
    }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   835
    ++ StubRoutines::_verify_oop_count;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   836
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   837
#endif
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   838
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   839
  // Return address of code to be called from code generated by
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   840
  // MacroAssembler::verify_oop.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   841
  //
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   842
  // Don't generate, rather use C++ code.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   843
  address generate_verify_oop() {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   844
    // this is actually a `FunctionDescriptor*'.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   845
    address start = 0;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   846
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   847
#if !defined(PRODUCT)
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   848
    start = CAST_FROM_FN_PTR(address, verify_oop_helper);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   849
#endif
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   850
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   851
    return start;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   852
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   853
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   854
  // Fairer handling of safepoints for native methods.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   855
  //
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   856
  // Generate code which reads from the polling page. This special handling is needed as the
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   857
  // linux-ppc64 kernel before 2.6.6 doesn't set si_addr on some segfaults in 64bit mode
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   858
  // (cf. http://www.kernel.org/pub/linux/kernel/v2.6/ChangeLog-2.6.6), especially when we try
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   859
  // to read from the safepoint polling page.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   860
  address generate_load_from_poll() {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   861
    StubCodeMark mark(this, "StubRoutines", "generate_load_from_poll");
23211
954e3a81da29 8035647: PPC64: Support for elf v2 abi.
goetz
parents: 22874
diff changeset
   862
    address start = __ function_entry();
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   863
    __ unimplemented("StubRoutines::verify_oop", 95);  // TODO PPC port
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   864
    return start;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   865
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   866
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   867
  // -XX:+OptimizeFill : convert fill/copy loops into intrinsic
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   868
  //
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   869
  // The code is implemented(ported from sparc) as we believe it benefits JVM98, however
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   870
  // tracing(-XX:+TraceOptimizeFill) shows the intrinsic replacement doesn't happen at all!
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   871
  //
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
   872
  // Source code in function is_range_check_if() shows that OptimizeFill relaxed the condition
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   873
  // for turning on loop predication optimization, and hence the behavior of "array range check"
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   874
  // and "loop invariant check" could be influenced, which potentially boosted JVM98.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   875
  //
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
   876
  // Generate stub for disjoint short fill. If "aligned" is true, the
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
   877
  // "to" address is assumed to be heapword aligned.
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   878
  //
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   879
  // Arguments for generated stub:
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
   880
  //   to:    R3_ARG1
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
   881
  //   value: R4_ARG2
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
   882
  //   count: R5_ARG3 treated as signed
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   883
  //
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   884
  address generate_fill(BasicType t, bool aligned, const char* name) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   885
    StubCodeMark mark(this, "StubRoutines", name);
23211
954e3a81da29 8035647: PPC64: Support for elf v2 abi.
goetz
parents: 22874
diff changeset
   886
    address start = __ function_entry();
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   887
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
   888
    const Register to    = R3_ARG1;   // source array address
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
   889
    const Register value = R4_ARG2;   // fill value
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
   890
    const Register count = R5_ARG3;   // elements count
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
   891
    const Register temp  = R6_ARG4;   // temp register
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   892
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
   893
    //assert_clean_int(count, O3);    // Make sure 'count' is clean int.
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   894
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   895
    Label L_exit, L_skip_align1, L_skip_align2, L_fill_byte;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   896
    Label L_fill_2_bytes, L_fill_4_bytes, L_fill_elements, L_fill_32_bytes;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   897
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   898
    int shift = -1;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   899
    switch (t) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   900
       case T_BYTE:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   901
        shift = 2;
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
   902
        // Clone bytes (zero extend not needed because store instructions below ignore high order bytes).
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   903
        __ rldimi(value, value, 8, 48);     // 8 bit -> 16 bit
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
   904
        __ cmpdi(CCR0, count, 2<<shift);    // Short arrays (< 8 bytes) fill by element.
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   905
        __ blt(CCR0, L_fill_elements);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   906
        __ rldimi(value, value, 16, 32);    // 16 bit -> 32 bit
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   907
        break;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   908
       case T_SHORT:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   909
        shift = 1;
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
   910
        // Clone bytes (zero extend not needed because store instructions below ignore high order bytes).
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   911
        __ rldimi(value, value, 16, 32);    // 16 bit -> 32 bit
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
   912
        __ cmpdi(CCR0, count, 2<<shift);    // Short arrays (< 8 bytes) fill by element.
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   913
        __ blt(CCR0, L_fill_elements);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   914
        break;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   915
      case T_INT:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   916
        shift = 0;
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
   917
        __ cmpdi(CCR0, count, 2<<shift);    // Short arrays (< 8 bytes) fill by element.
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   918
        __ blt(CCR0, L_fill_4_bytes);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   919
        break;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   920
      default: ShouldNotReachHere();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   921
    }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   922
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   923
    if (!aligned && (t == T_BYTE || t == T_SHORT)) {
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
   924
      // Align source address at 4 bytes address boundary.
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   925
      if (t == T_BYTE) {
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
   926
        // One byte misalignment happens only for byte arrays.
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   927
        __ andi_(temp, to, 1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   928
        __ beq(CCR0, L_skip_align1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   929
        __ stb(value, 0, to);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   930
        __ addi(to, to, 1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   931
        __ addi(count, count, -1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   932
        __ bind(L_skip_align1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   933
      }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   934
      // Two bytes misalignment happens only for byte and short (char) arrays.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   935
      __ andi_(temp, to, 2);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   936
      __ beq(CCR0, L_skip_align2);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   937
      __ sth(value, 0, to);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   938
      __ addi(to, to, 2);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   939
      __ addi(count, count, -(1 << (shift - 1)));
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   940
      __ bind(L_skip_align2);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   941
    }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   942
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   943
    if (!aligned) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   944
      // Align to 8 bytes, we know we are 4 byte aligned to start.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   945
      __ andi_(temp, to, 7);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   946
      __ beq(CCR0, L_fill_32_bytes);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   947
      __ stw(value, 0, to);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   948
      __ addi(to, to, 4);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   949
      __ addi(count, count, -(1 << shift));
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   950
      __ bind(L_fill_32_bytes);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   951
    }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   952
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
   953
    __ li(temp, 8<<shift);                  // Prepare for 32 byte loop.
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
   954
    // Clone bytes int->long as above.
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
   955
    __ rldimi(value, value, 32, 0);         // 32 bit -> 64 bit
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   956
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   957
    Label L_check_fill_8_bytes;
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
   958
    // Fill 32-byte chunks.
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   959
    __ subf_(count, temp, count);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   960
    __ blt(CCR0, L_check_fill_8_bytes);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   961
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   962
    Label L_fill_32_bytes_loop;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   963
    __ align(32);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   964
    __ bind(L_fill_32_bytes_loop);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   965
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   966
    __ std(value, 0, to);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   967
    __ std(value, 8, to);
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
   968
    __ subf_(count, temp, count);           // Update count.
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   969
    __ std(value, 16, to);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   970
    __ std(value, 24, to);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   971
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   972
    __ addi(to, to, 32);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   973
    __ bge(CCR0, L_fill_32_bytes_loop);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   974
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   975
    __ bind(L_check_fill_8_bytes);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   976
    __ add_(count, temp, count);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   977
    __ beq(CCR0, L_exit);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   978
    __ addic_(count, count, -(2 << shift));
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   979
    __ blt(CCR0, L_fill_4_bytes);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   980
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   981
    //
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   982
    // Length is too short, just fill 8 bytes at a time.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   983
    //
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   984
    Label L_fill_8_bytes_loop;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   985
    __ bind(L_fill_8_bytes_loop);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   986
    __ std(value, 0, to);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   987
    __ addic_(count, count, -(2 << shift));
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   988
    __ addi(to, to, 8);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   989
    __ bge(CCR0, L_fill_8_bytes_loop);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   990
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
   991
    // Fill trailing 4 bytes.
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   992
    __ bind(L_fill_4_bytes);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   993
    __ andi_(temp, count, 1<<shift);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   994
    __ beq(CCR0, L_fill_2_bytes);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   995
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   996
    __ stw(value, 0, to);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   997
    if (t == T_BYTE || t == T_SHORT) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   998
      __ addi(to, to, 4);
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
   999
      // Fill trailing 2 bytes.
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1000
      __ bind(L_fill_2_bytes);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1001
      __ andi_(temp, count, 1<<(shift-1));
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1002
      __ beq(CCR0, L_fill_byte);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1003
      __ sth(value, 0, to);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1004
      if (t == T_BYTE) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1005
        __ addi(to, to, 2);
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
  1006
        // Fill trailing byte.
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1007
        __ bind(L_fill_byte);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1008
        __ andi_(count, count, 1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1009
        __ beq(CCR0, L_exit);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1010
        __ stb(value, 0, to);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1011
      } else {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1012
        __ bind(L_fill_byte);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1013
      }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1014
    } else {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1015
      __ bind(L_fill_2_bytes);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1016
    }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1017
    __ bind(L_exit);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1018
    __ blr();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1019
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
  1020
    // Handle copies less than 8 bytes. Int is handled elsewhere.
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1021
    if (t == T_BYTE) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1022
      __ bind(L_fill_elements);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1023
      Label L_fill_2, L_fill_4;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1024
      __ andi_(temp, count, 1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1025
      __ beq(CCR0, L_fill_2);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1026
      __ stb(value, 0, to);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1027
      __ addi(to, to, 1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1028
      __ bind(L_fill_2);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1029
      __ andi_(temp, count, 2);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1030
      __ beq(CCR0, L_fill_4);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1031
      __ stb(value, 0, to);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1032
      __ stb(value, 0, to);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1033
      __ addi(to, to, 2);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1034
      __ bind(L_fill_4);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1035
      __ andi_(temp, count, 4);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1036
      __ beq(CCR0, L_exit);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1037
      __ stb(value, 0, to);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1038
      __ stb(value, 1, to);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1039
      __ stb(value, 2, to);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1040
      __ stb(value, 3, to);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1041
      __ blr();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1042
    }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1043
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1044
    if (t == T_SHORT) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1045
      Label L_fill_2;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1046
      __ bind(L_fill_elements);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1047
      __ andi_(temp, count, 1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1048
      __ beq(CCR0, L_fill_2);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1049
      __ sth(value, 0, to);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1050
      __ addi(to, to, 2);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1051
      __ bind(L_fill_2);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1052
      __ andi_(temp, count, 2);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1053
      __ beq(CCR0, L_exit);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1054
      __ sth(value, 0, to);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1055
      __ sth(value, 2, to);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1056
      __ blr();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1057
    }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1058
    return start;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1059
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1060
35541
cba047a086d5 8146613: PPC64: C2 does no longer respect int to long conversion for stub calls
mdoerr
parents: 35156
diff changeset
  1061
  inline void assert_positive_int(Register count) {
cba047a086d5 8146613: PPC64: C2 does no longer respect int to long conversion for stub calls
mdoerr
parents: 35156
diff changeset
  1062
#ifdef ASSERT
cba047a086d5 8146613: PPC64: C2 does no longer respect int to long conversion for stub calls
mdoerr
parents: 35156
diff changeset
  1063
    __ srdi_(R0, count, 31);
cba047a086d5 8146613: PPC64: C2 does no longer respect int to long conversion for stub calls
mdoerr
parents: 35156
diff changeset
  1064
    __ asm_assert_eq("missing zero extend", 0xAFFE);
cba047a086d5 8146613: PPC64: C2 does no longer respect int to long conversion for stub calls
mdoerr
parents: 35156
diff changeset
  1065
#endif
cba047a086d5 8146613: PPC64: C2 does no longer respect int to long conversion for stub calls
mdoerr
parents: 35156
diff changeset
  1066
  }
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1067
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
  1068
  // Generate overlap test for array copy stubs.
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1069
  //
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1070
  // Input:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1071
  //   R3_ARG1    -  from
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1072
  //   R4_ARG2    -  to
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1073
  //   R5_ARG3    -  element count
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1074
  //
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1075
  void array_overlap_test(address no_overlap_target, int log2_elem_size) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1076
    Register tmp1 = R6_ARG4;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1077
    Register tmp2 = R7_ARG5;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1078
35541
cba047a086d5 8146613: PPC64: C2 does no longer respect int to long conversion for stub calls
mdoerr
parents: 35156
diff changeset
  1079
    assert_positive_int(R5_ARG3);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1080
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1081
    __ subf(tmp1, R3_ARG1, R4_ARG2); // distance in bytes
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1082
    __ sldi(tmp2, R5_ARG3, log2_elem_size); // size in bytes
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1083
    __ cmpld(CCR0, R3_ARG1, R4_ARG2); // Use unsigned comparison!
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1084
    __ cmpld(CCR1, tmp1, tmp2);
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1085
    __ crnand(CCR0, Assembler::less, CCR1, Assembler::less);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1086
    // Overlaps if Src before dst and distance smaller than size.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1087
    // Branch to forward copy routine otherwise (within range of 32kB).
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1088
    __ bc(Assembler::bcondCRbiIs1, Assembler::bi0(CCR0, Assembler::less), no_overlap_target);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1089
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1090
    // need to copy backwards
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1091
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1092
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1093
  // The guideline in the implementations of generate_disjoint_xxx_copy
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1094
  // (xxx=byte,short,int,long,oop) is to copy as many elements as possible with
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1095
  // single instructions, but to avoid alignment interrupts (see subsequent
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1096
  // comment). Furthermore, we try to minimize misaligned access, even
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1097
  // though they cause no alignment interrupt.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1098
  //
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1099
  // In Big-Endian mode, the PowerPC architecture requires implementations to
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1100
  // handle automatically misaligned integer halfword and word accesses,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1101
  // word-aligned integer doubleword accesses, and word-aligned floating-point
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1102
  // accesses. Other accesses may or may not generate an Alignment interrupt
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1103
  // depending on the implementation.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1104
  // Alignment interrupt handling may require on the order of hundreds of cycles,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1105
  // so every effort should be made to avoid misaligned memory values.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1106
  //
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1107
  //
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1108
  // Generate stub for disjoint byte copy.  If "aligned" is true, the
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1109
  // "from" and "to" addresses are assumed to be heapword aligned.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1110
  //
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1111
  // Arguments for generated stub:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1112
  //      from:  R3_ARG1
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1113
  //      to:    R4_ARG2
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1114
  //      count: R5_ARG3 treated as signed
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1115
  //
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1116
  address generate_disjoint_byte_copy(bool aligned, const char * name) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1117
    StubCodeMark mark(this, "StubRoutines", name);
23211
954e3a81da29 8035647: PPC64: Support for elf v2 abi.
goetz
parents: 22874
diff changeset
  1118
    address start = __ function_entry();
35541
cba047a086d5 8146613: PPC64: C2 does no longer respect int to long conversion for stub calls
mdoerr
parents: 35156
diff changeset
  1119
    assert_positive_int(R5_ARG3);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1120
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1121
    Register tmp1 = R6_ARG4;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1122
    Register tmp2 = R7_ARG5;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1123
    Register tmp3 = R8_ARG6;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1124
    Register tmp4 = R9_ARG7;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1125
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1126
    Label l_1, l_2, l_3, l_4, l_5, l_6, l_7, l_8, l_9;
35541
cba047a086d5 8146613: PPC64: C2 does no longer respect int to long conversion for stub calls
mdoerr
parents: 35156
diff changeset
  1127
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1128
    // Don't try anything fancy if arrays don't have many elements.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1129
    __ li(tmp3, 0);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1130
    __ cmpwi(CCR0, R5_ARG3, 17);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1131
    __ ble(CCR0, l_6); // copy 4 at a time
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1132
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1133
    if (!aligned) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1134
      __ xorr(tmp1, R3_ARG1, R4_ARG2);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1135
      __ andi_(tmp1, tmp1, 3);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1136
      __ bne(CCR0, l_6); // If arrays don't have the same alignment mod 4, do 4 element copy.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1137
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1138
      // Copy elements if necessary to align to 4 bytes.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1139
      __ neg(tmp1, R3_ARG1); // Compute distance to alignment boundary.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1140
      __ andi_(tmp1, tmp1, 3);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1141
      __ beq(CCR0, l_2);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1142
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1143
      __ subf(R5_ARG3, tmp1, R5_ARG3);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1144
      __ bind(l_9);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1145
      __ lbz(tmp2, 0, R3_ARG1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1146
      __ addic_(tmp1, tmp1, -1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1147
      __ stb(tmp2, 0, R4_ARG2);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1148
      __ addi(R3_ARG1, R3_ARG1, 1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1149
      __ addi(R4_ARG2, R4_ARG2, 1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1150
      __ bne(CCR0, l_9);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1151
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1152
      __ bind(l_2);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1153
    }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1154
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1155
    // copy 8 elements at a time
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1156
    __ xorr(tmp2, R3_ARG1, R4_ARG2); // skip if src & dest have differing alignment mod 8
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1157
    __ andi_(tmp1, tmp2, 7);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1158
    __ bne(CCR0, l_7); // not same alignment -> to or from is aligned -> copy 8
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1159
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1160
    // copy a 2-element word if necessary to align to 8 bytes
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1161
    __ andi_(R0, R3_ARG1, 7);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1162
    __ beq(CCR0, l_7);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1163
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1164
    __ lwzx(tmp2, R3_ARG1, tmp3);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1165
    __ addi(R5_ARG3, R5_ARG3, -4);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1166
    __ stwx(tmp2, R4_ARG2, tmp3);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1167
    { // FasterArrayCopy
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1168
      __ addi(R3_ARG1, R3_ARG1, 4);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1169
      __ addi(R4_ARG2, R4_ARG2, 4);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1170
    }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1171
    __ bind(l_7);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1172
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1173
    { // FasterArrayCopy
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1174
      __ cmpwi(CCR0, R5_ARG3, 31);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1175
      __ ble(CCR0, l_6); // copy 2 at a time if less than 32 elements remain
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1176
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1177
      __ srdi(tmp1, R5_ARG3, 5);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1178
      __ andi_(R5_ARG3, R5_ARG3, 31);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1179
      __ mtctr(tmp1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1180
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1181
      __ bind(l_8);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1182
      // Use unrolled version for mass copying (copy 32 elements a time)
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1183
      // Load feeding store gets zero latency on Power6, however not on Power5.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1184
      // Therefore, the following sequence is made for the good of both.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1185
      __ ld(tmp1, 0, R3_ARG1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1186
      __ ld(tmp2, 8, R3_ARG1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1187
      __ ld(tmp3, 16, R3_ARG1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1188
      __ ld(tmp4, 24, R3_ARG1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1189
      __ std(tmp1, 0, R4_ARG2);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1190
      __ std(tmp2, 8, R4_ARG2);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1191
      __ std(tmp3, 16, R4_ARG2);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1192
      __ std(tmp4, 24, R4_ARG2);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1193
      __ addi(R3_ARG1, R3_ARG1, 32);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1194
      __ addi(R4_ARG2, R4_ARG2, 32);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1195
      __ bdnz(l_8);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1196
    }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1197
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1198
    __ bind(l_6);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1199
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1200
    // copy 4 elements at a time
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1201
    __ cmpwi(CCR0, R5_ARG3, 4);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1202
    __ blt(CCR0, l_1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1203
    __ srdi(tmp1, R5_ARG3, 2);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1204
    __ mtctr(tmp1); // is > 0
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1205
    __ andi_(R5_ARG3, R5_ARG3, 3);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1206
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1207
    { // FasterArrayCopy
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1208
      __ addi(R3_ARG1, R3_ARG1, -4);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1209
      __ addi(R4_ARG2, R4_ARG2, -4);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1210
      __ bind(l_3);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1211
      __ lwzu(tmp2, 4, R3_ARG1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1212
      __ stwu(tmp2, 4, R4_ARG2);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1213
      __ bdnz(l_3);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1214
      __ addi(R3_ARG1, R3_ARG1, 4);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1215
      __ addi(R4_ARG2, R4_ARG2, 4);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1216
    }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1217
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1218
    // do single element copy
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1219
    __ bind(l_1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1220
    __ cmpwi(CCR0, R5_ARG3, 0);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1221
    __ beq(CCR0, l_4);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1222
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1223
    { // FasterArrayCopy
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1224
      __ mtctr(R5_ARG3);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1225
      __ addi(R3_ARG1, R3_ARG1, -1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1226
      __ addi(R4_ARG2, R4_ARG2, -1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1227
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1228
      __ bind(l_5);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1229
      __ lbzu(tmp2, 1, R3_ARG1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1230
      __ stbu(tmp2, 1, R4_ARG2);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1231
      __ bdnz(l_5);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1232
    }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1233
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1234
    __ bind(l_4);
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1235
    __ li(R3_RET, 0); // return 0
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1236
    __ blr();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1237
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1238
    return start;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1239
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1240
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1241
  // Generate stub for conjoint byte copy.  If "aligned" is true, the
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1242
  // "from" and "to" addresses are assumed to be heapword aligned.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1243
  //
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1244
  // Arguments for generated stub:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1245
  //      from:  R3_ARG1
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1246
  //      to:    R4_ARG2
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1247
  //      count: R5_ARG3 treated as signed
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1248
  //
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1249
  address generate_conjoint_byte_copy(bool aligned, const char * name) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1250
    StubCodeMark mark(this, "StubRoutines", name);
23211
954e3a81da29 8035647: PPC64: Support for elf v2 abi.
goetz
parents: 22874
diff changeset
  1251
    address start = __ function_entry();
35541
cba047a086d5 8146613: PPC64: C2 does no longer respect int to long conversion for stub calls
mdoerr
parents: 35156
diff changeset
  1252
    assert_positive_int(R5_ARG3);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1253
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1254
    Register tmp1 = R6_ARG4;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1255
    Register tmp2 = R7_ARG5;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1256
    Register tmp3 = R8_ARG6;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1257
30303
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29695
diff changeset
  1258
    address nooverlap_target = aligned ?
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1259
      STUB_ENTRY(arrayof_jbyte_disjoint_arraycopy) :
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1260
      STUB_ENTRY(jbyte_disjoint_arraycopy);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1261
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1262
    array_overlap_test(nooverlap_target, 0);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1263
    // Do reverse copy. We assume the case of actual overlap is rare enough
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1264
    // that we don't have to optimize it.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1265
    Label l_1, l_2;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1266
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1267
    __ b(l_2);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1268
    __ bind(l_1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1269
    __ stbx(tmp1, R4_ARG2, R5_ARG3);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1270
    __ bind(l_2);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1271
    __ addic_(R5_ARG3, R5_ARG3, -1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1272
    __ lbzx(tmp1, R3_ARG1, R5_ARG3);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1273
    __ bge(CCR0, l_1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1274
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1275
    __ li(R3_RET, 0); // return 0
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1276
    __ blr();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1277
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1278
    return start;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1279
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1280
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1281
  // Generate stub for disjoint short copy.  If "aligned" is true, the
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1282
  // "from" and "to" addresses are assumed to be heapword aligned.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1283
  //
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1284
  // Arguments for generated stub:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1285
  //      from:  R3_ARG1
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1286
  //      to:    R4_ARG2
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1287
  //  elm.count: R5_ARG3 treated as signed
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1288
  //
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1289
  // Strategy for aligned==true:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1290
  //
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1291
  //  If length <= 9:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1292
  //     1. copy 2 elements at a time (l_6)
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1293
  //     2. copy last element if original element count was odd (l_1)
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1294
  //
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1295
  //  If length > 9:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1296
  //     1. copy 4 elements at a time until less than 4 elements are left (l_7)
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1297
  //     2. copy 2 elements at a time until less than 2 elements are left (l_6)
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1298
  //     3. copy last element if one was left in step 2. (l_1)
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1299
  //
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1300
  //
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1301
  // Strategy for aligned==false:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1302
  //
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1303
  //  If length <= 9: same as aligned==true case, but NOTE: load/stores
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1304
  //                  can be unaligned (see comment below)
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1305
  //
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1306
  //  If length > 9:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1307
  //     1. continue with step 6. if the alignment of from and to mod 4
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1308
  //        is different.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1309
  //     2. align from and to to 4 bytes by copying 1 element if necessary
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1310
  //     3. at l_2 from and to are 4 byte aligned; continue with
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1311
  //        5. if they cannot be aligned to 8 bytes because they have
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1312
  //        got different alignment mod 8.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1313
  //     4. at this point we know that both, from and to, have the same
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1314
  //        alignment mod 8, now copy one element if necessary to get
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1315
  //        8 byte alignment of from and to.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1316
  //     5. copy 4 elements at a time until less than 4 elements are
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1317
  //        left; depending on step 3. all load/stores are aligned or
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1318
  //        either all loads or all stores are unaligned.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1319
  //     6. copy 2 elements at a time until less than 2 elements are
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1320
  //        left (l_6); arriving here from step 1., there is a chance
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1321
  //        that all accesses are unaligned.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1322
  //     7. copy last element if one was left in step 6. (l_1)
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1323
  //
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1324
  //  There are unaligned data accesses using integer load/store
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1325
  //  instructions in this stub. POWER allows such accesses.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1326
  //
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1327
  //  According to the manuals (PowerISA_V2.06_PUBLIC, Book II,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1328
  //  Chapter 2: Effect of Operand Placement on Performance) unaligned
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1329
  //  integer load/stores have good performance. Only unaligned
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1330
  //  floating point load/stores can have poor performance.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1331
  //
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1332
  //  TODO:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1333
  //
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1334
  //  1. check if aligning the backbranch target of loops is beneficial
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1335
  //
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1336
  address generate_disjoint_short_copy(bool aligned, const char * name) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1337
    StubCodeMark mark(this, "StubRoutines", name);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1338
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1339
    Register tmp1 = R6_ARG4;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1340
    Register tmp2 = R7_ARG5;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1341
    Register tmp3 = R8_ARG6;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1342
    Register tmp4 = R9_ARG7;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1343
23211
954e3a81da29 8035647: PPC64: Support for elf v2 abi.
goetz
parents: 22874
diff changeset
  1344
    address start = __ function_entry();
35541
cba047a086d5 8146613: PPC64: C2 does no longer respect int to long conversion for stub calls
mdoerr
parents: 35156
diff changeset
  1345
    assert_positive_int(R5_ARG3);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1346
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1347
      Label l_1, l_2, l_3, l_4, l_5, l_6, l_7, l_8;
35541
cba047a086d5 8146613: PPC64: C2 does no longer respect int to long conversion for stub calls
mdoerr
parents: 35156
diff changeset
  1348
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1349
    // don't try anything fancy if arrays don't have many elements
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1350
    __ li(tmp3, 0);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1351
    __ cmpwi(CCR0, R5_ARG3, 9);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1352
    __ ble(CCR0, l_6); // copy 2 at a time
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1353
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1354
    if (!aligned) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1355
      __ xorr(tmp1, R3_ARG1, R4_ARG2);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1356
      __ andi_(tmp1, tmp1, 3);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1357
      __ bne(CCR0, l_6); // if arrays don't have the same alignment mod 4, do 2 element copy
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1358
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1359
      // At this point it is guaranteed that both, from and to have the same alignment mod 4.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1360
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1361
      // Copy 1 element if necessary to align to 4 bytes.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1362
      __ andi_(tmp1, R3_ARG1, 3);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1363
      __ beq(CCR0, l_2);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1364
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1365
      __ lhz(tmp2, 0, R3_ARG1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1366
      __ addi(R3_ARG1, R3_ARG1, 2);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1367
      __ sth(tmp2, 0, R4_ARG2);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1368
      __ addi(R4_ARG2, R4_ARG2, 2);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1369
      __ addi(R5_ARG3, R5_ARG3, -1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1370
      __ bind(l_2);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1371
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1372
      // At this point the positions of both, from and to, are at least 4 byte aligned.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1373
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1374
      // Copy 4 elements at a time.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1375
      // Align to 8 bytes, but only if both, from and to, have same alignment mod 8.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1376
      __ xorr(tmp2, R3_ARG1, R4_ARG2);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1377
      __ andi_(tmp1, tmp2, 7);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1378
      __ bne(CCR0, l_7); // not same alignment mod 8 -> copy 4, either from or to will be unaligned
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1379
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1380
      // Copy a 2-element word if necessary to align to 8 bytes.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1381
      __ andi_(R0, R3_ARG1, 7);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1382
      __ beq(CCR0, l_7);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1383
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1384
      __ lwzx(tmp2, R3_ARG1, tmp3);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1385
      __ addi(R5_ARG3, R5_ARG3, -2);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1386
      __ stwx(tmp2, R4_ARG2, tmp3);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1387
      { // FasterArrayCopy
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1388
        __ addi(R3_ARG1, R3_ARG1, 4);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1389
        __ addi(R4_ARG2, R4_ARG2, 4);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1390
      }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1391
    }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1392
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1393
    __ bind(l_7);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1394
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1395
    // Copy 4 elements at a time; either the loads or the stores can
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1396
    // be unaligned if aligned == false.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1397
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1398
    { // FasterArrayCopy
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1399
      __ cmpwi(CCR0, R5_ARG3, 15);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1400
      __ ble(CCR0, l_6); // copy 2 at a time if less than 16 elements remain
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1401
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1402
      __ srdi(tmp1, R5_ARG3, 4);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1403
      __ andi_(R5_ARG3, R5_ARG3, 15);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1404
      __ mtctr(tmp1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1405
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1406
      __ bind(l_8);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1407
      // Use unrolled version for mass copying (copy 16 elements a time).
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1408
      // Load feeding store gets zero latency on Power6, however not on Power5.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1409
      // Therefore, the following sequence is made for the good of both.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1410
      __ ld(tmp1, 0, R3_ARG1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1411
      __ ld(tmp2, 8, R3_ARG1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1412
      __ ld(tmp3, 16, R3_ARG1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1413
      __ ld(tmp4, 24, R3_ARG1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1414
      __ std(tmp1, 0, R4_ARG2);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1415
      __ std(tmp2, 8, R4_ARG2);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1416
      __ std(tmp3, 16, R4_ARG2);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1417
      __ std(tmp4, 24, R4_ARG2);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1418
      __ addi(R3_ARG1, R3_ARG1, 32);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1419
      __ addi(R4_ARG2, R4_ARG2, 32);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1420
      __ bdnz(l_8);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1421
    }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1422
    __ bind(l_6);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1423
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1424
    // copy 2 elements at a time
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1425
    { // FasterArrayCopy
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1426
      __ cmpwi(CCR0, R5_ARG3, 2);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1427
      __ blt(CCR0, l_1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1428
      __ srdi(tmp1, R5_ARG3, 1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1429
      __ andi_(R5_ARG3, R5_ARG3, 1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1430
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1431
      __ addi(R3_ARG1, R3_ARG1, -4);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1432
      __ addi(R4_ARG2, R4_ARG2, -4);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1433
      __ mtctr(tmp1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1434
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1435
      __ bind(l_3);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1436
      __ lwzu(tmp2, 4, R3_ARG1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1437
      __ stwu(tmp2, 4, R4_ARG2);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1438
      __ bdnz(l_3);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1439
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1440
      __ addi(R3_ARG1, R3_ARG1, 4);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1441
      __ addi(R4_ARG2, R4_ARG2, 4);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1442
    }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1443
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1444
    // do single element copy
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1445
    __ bind(l_1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1446
    __ cmpwi(CCR0, R5_ARG3, 0);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1447
    __ beq(CCR0, l_4);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1448
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1449
    { // FasterArrayCopy
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1450
      __ mtctr(R5_ARG3);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1451
      __ addi(R3_ARG1, R3_ARG1, -2);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1452
      __ addi(R4_ARG2, R4_ARG2, -2);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1453
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1454
      __ bind(l_5);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1455
      __ lhzu(tmp2, 2, R3_ARG1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1456
      __ sthu(tmp2, 2, R4_ARG2);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1457
      __ bdnz(l_5);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1458
    }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1459
    __ bind(l_4);
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1460
    __ li(R3_RET, 0); // return 0
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1461
    __ blr();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1462
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1463
    return start;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1464
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1465
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1466
  // Generate stub for conjoint short copy.  If "aligned" is true, the
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1467
  // "from" and "to" addresses are assumed to be heapword aligned.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1468
  //
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1469
  // Arguments for generated stub:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1470
  //      from:  R3_ARG1
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1471
  //      to:    R4_ARG2
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1472
  //      count: R5_ARG3 treated as signed
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1473
  //
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1474
  address generate_conjoint_short_copy(bool aligned, const char * name) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1475
    StubCodeMark mark(this, "StubRoutines", name);
23211
954e3a81da29 8035647: PPC64: Support for elf v2 abi.
goetz
parents: 22874
diff changeset
  1476
    address start = __ function_entry();
35541
cba047a086d5 8146613: PPC64: C2 does no longer respect int to long conversion for stub calls
mdoerr
parents: 35156
diff changeset
  1477
    assert_positive_int(R5_ARG3);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1478
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1479
    Register tmp1 = R6_ARG4;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1480
    Register tmp2 = R7_ARG5;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1481
    Register tmp3 = R8_ARG6;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1482
23211
954e3a81da29 8035647: PPC64: Support for elf v2 abi.
goetz
parents: 22874
diff changeset
  1483
    address nooverlap_target = aligned ?
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1484
      STUB_ENTRY(arrayof_jshort_disjoint_arraycopy) :
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1485
      STUB_ENTRY(jshort_disjoint_arraycopy);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1486
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1487
    array_overlap_test(nooverlap_target, 1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1488
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1489
    Label l_1, l_2;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1490
    __ sldi(tmp1, R5_ARG3, 1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1491
    __ b(l_2);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1492
    __ bind(l_1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1493
    __ sthx(tmp2, R4_ARG2, tmp1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1494
    __ bind(l_2);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1495
    __ addic_(tmp1, tmp1, -2);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1496
    __ lhzx(tmp2, R3_ARG1, tmp1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1497
    __ bge(CCR0, l_1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1498
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1499
    __ li(R3_RET, 0); // return 0
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1500
    __ blr();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1501
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1502
    return start;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1503
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1504
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1505
  // Generate core code for disjoint int copy (and oop copy on 32-bit).  If "aligned"
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1506
  // is true, the "from" and "to" addresses are assumed to be heapword aligned.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1507
  //
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1508
  // Arguments:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1509
  //      from:  R3_ARG1
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1510
  //      to:    R4_ARG2
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1511
  //      count: R5_ARG3 treated as signed
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1512
  //
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1513
  void generate_disjoint_int_copy_core(bool aligned) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1514
    Register tmp1 = R6_ARG4;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1515
    Register tmp2 = R7_ARG5;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1516
    Register tmp3 = R8_ARG6;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1517
    Register tmp4 = R0;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1518
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1519
    Label l_1, l_2, l_3, l_4, l_5, l_6;
35541
cba047a086d5 8146613: PPC64: C2 does no longer respect int to long conversion for stub calls
mdoerr
parents: 35156
diff changeset
  1520
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1521
    // for short arrays, just do single element copy
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1522
    __ li(tmp3, 0);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1523
    __ cmpwi(CCR0, R5_ARG3, 5);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1524
    __ ble(CCR0, l_2);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1525
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1526
    if (!aligned) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1527
        // check if arrays have same alignment mod 8.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1528
        __ xorr(tmp1, R3_ARG1, R4_ARG2);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1529
        __ andi_(R0, tmp1, 7);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1530
        // Not the same alignment, but ld and std just need to be 4 byte aligned.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1531
        __ bne(CCR0, l_4); // to OR from is 8 byte aligned -> copy 2 at a time
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1532
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1533
        // copy 1 element to align to and from on an 8 byte boundary
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1534
        __ andi_(R0, R3_ARG1, 7);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1535
        __ beq(CCR0, l_4);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1536
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1537
        __ lwzx(tmp2, R3_ARG1, tmp3);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1538
        __ addi(R5_ARG3, R5_ARG3, -1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1539
        __ stwx(tmp2, R4_ARG2, tmp3);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1540
        { // FasterArrayCopy
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1541
          __ addi(R3_ARG1, R3_ARG1, 4);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1542
          __ addi(R4_ARG2, R4_ARG2, 4);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1543
        }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1544
        __ bind(l_4);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1545
      }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1546
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1547
    { // FasterArrayCopy
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1548
      __ cmpwi(CCR0, R5_ARG3, 7);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1549
      __ ble(CCR0, l_2); // copy 1 at a time if less than 8 elements remain
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1550
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1551
      __ srdi(tmp1, R5_ARG3, 3);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1552
      __ andi_(R5_ARG3, R5_ARG3, 7);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1553
      __ mtctr(tmp1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1554
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1555
      __ bind(l_6);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1556
      // Use unrolled version for mass copying (copy 8 elements a time).
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1557
      // Load feeding store gets zero latency on power6, however not on power 5.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1558
      // Therefore, the following sequence is made for the good of both.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1559
      __ ld(tmp1, 0, R3_ARG1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1560
      __ ld(tmp2, 8, R3_ARG1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1561
      __ ld(tmp3, 16, R3_ARG1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1562
      __ ld(tmp4, 24, R3_ARG1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1563
      __ std(tmp1, 0, R4_ARG2);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1564
      __ std(tmp2, 8, R4_ARG2);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1565
      __ std(tmp3, 16, R4_ARG2);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1566
      __ std(tmp4, 24, R4_ARG2);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1567
      __ addi(R3_ARG1, R3_ARG1, 32);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1568
      __ addi(R4_ARG2, R4_ARG2, 32);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1569
      __ bdnz(l_6);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1570
    }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1571
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1572
    // copy 1 element at a time
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1573
    __ bind(l_2);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1574
    __ cmpwi(CCR0, R5_ARG3, 0);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1575
    __ beq(CCR0, l_1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1576
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1577
    { // FasterArrayCopy
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1578
      __ mtctr(R5_ARG3);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1579
      __ addi(R3_ARG1, R3_ARG1, -4);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1580
      __ addi(R4_ARG2, R4_ARG2, -4);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1581
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1582
      __ bind(l_3);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1583
      __ lwzu(tmp2, 4, R3_ARG1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1584
      __ stwu(tmp2, 4, R4_ARG2);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1585
      __ bdnz(l_3);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1586
    }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1587
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1588
    __ bind(l_1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1589
    return;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1590
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1591
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1592
  // Generate stub for disjoint int copy.  If "aligned" is true, the
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1593
  // "from" and "to" addresses are assumed to be heapword aligned.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1594
  //
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1595
  // Arguments for generated stub:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1596
  //      from:  R3_ARG1
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1597
  //      to:    R4_ARG2
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1598
  //      count: R5_ARG3 treated as signed
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1599
  //
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1600
  address generate_disjoint_int_copy(bool aligned, const char * name) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1601
    StubCodeMark mark(this, "StubRoutines", name);
23211
954e3a81da29 8035647: PPC64: Support for elf v2 abi.
goetz
parents: 22874
diff changeset
  1602
    address start = __ function_entry();
35541
cba047a086d5 8146613: PPC64: C2 does no longer respect int to long conversion for stub calls
mdoerr
parents: 35156
diff changeset
  1603
    assert_positive_int(R5_ARG3);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1604
    generate_disjoint_int_copy_core(aligned);
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1605
    __ li(R3_RET, 0); // return 0
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1606
    __ blr();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1607
    return start;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1608
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1609
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1610
  // Generate core code for conjoint int copy (and oop copy on
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1611
  // 32-bit).  If "aligned" is true, the "from" and "to" addresses
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1612
  // are assumed to be heapword aligned.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1613
  //
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1614
  // Arguments:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1615
  //      from:  R3_ARG1
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1616
  //      to:    R4_ARG2
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1617
  //      count: R5_ARG3 treated as signed
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1618
  //
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1619
  void generate_conjoint_int_copy_core(bool aligned) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1620
    // Do reverse copy.  We assume the case of actual overlap is rare enough
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1621
    // that we don't have to optimize it.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1622
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1623
    Label l_1, l_2, l_3, l_4, l_5, l_6;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1624
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1625
    Register tmp1 = R6_ARG4;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1626
    Register tmp2 = R7_ARG5;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1627
    Register tmp3 = R8_ARG6;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1628
    Register tmp4 = R0;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1629
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1630
    { // FasterArrayCopy
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1631
      __ cmpwi(CCR0, R5_ARG3, 0);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1632
      __ beq(CCR0, l_6);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1633
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1634
      __ sldi(R5_ARG3, R5_ARG3, 2);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1635
      __ add(R3_ARG1, R3_ARG1, R5_ARG3);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1636
      __ add(R4_ARG2, R4_ARG2, R5_ARG3);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1637
      __ srdi(R5_ARG3, R5_ARG3, 2);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1638
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1639
      __ cmpwi(CCR0, R5_ARG3, 7);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1640
      __ ble(CCR0, l_5); // copy 1 at a time if less than 8 elements remain
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1641
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1642
      __ srdi(tmp1, R5_ARG3, 3);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1643
      __ andi(R5_ARG3, R5_ARG3, 7);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1644
      __ mtctr(tmp1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1645
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1646
      __ bind(l_4);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1647
      // Use unrolled version for mass copying (copy 4 elements a time).
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1648
      // Load feeding store gets zero latency on Power6, however not on Power5.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1649
      // Therefore, the following sequence is made for the good of both.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1650
      __ addi(R3_ARG1, R3_ARG1, -32);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1651
      __ addi(R4_ARG2, R4_ARG2, -32);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1652
      __ ld(tmp4, 24, R3_ARG1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1653
      __ ld(tmp3, 16, R3_ARG1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1654
      __ ld(tmp2, 8, R3_ARG1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1655
      __ ld(tmp1, 0, R3_ARG1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1656
      __ std(tmp4, 24, R4_ARG2);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1657
      __ std(tmp3, 16, R4_ARG2);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1658
      __ std(tmp2, 8, R4_ARG2);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1659
      __ std(tmp1, 0, R4_ARG2);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1660
      __ bdnz(l_4);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1661
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1662
      __ cmpwi(CCR0, R5_ARG3, 0);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1663
      __ beq(CCR0, l_6);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1664
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1665
      __ bind(l_5);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1666
      __ mtctr(R5_ARG3);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1667
      __ bind(l_3);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1668
      __ lwz(R0, -4, R3_ARG1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1669
      __ stw(R0, -4, R4_ARG2);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1670
      __ addi(R3_ARG1, R3_ARG1, -4);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1671
      __ addi(R4_ARG2, R4_ARG2, -4);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1672
      __ bdnz(l_3);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1673
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1674
      __ bind(l_6);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1675
    }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1676
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1677
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1678
  // Generate stub for conjoint int copy.  If "aligned" is true, the
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1679
  // "from" and "to" addresses are assumed to be heapword aligned.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1680
  //
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1681
  // Arguments for generated stub:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1682
  //      from:  R3_ARG1
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1683
  //      to:    R4_ARG2
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1684
  //      count: R5_ARG3 treated as signed
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1685
  //
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1686
  address generate_conjoint_int_copy(bool aligned, const char * name) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1687
    StubCodeMark mark(this, "StubRoutines", name);
23211
954e3a81da29 8035647: PPC64: Support for elf v2 abi.
goetz
parents: 22874
diff changeset
  1688
    address start = __ function_entry();
35541
cba047a086d5 8146613: PPC64: C2 does no longer respect int to long conversion for stub calls
mdoerr
parents: 35156
diff changeset
  1689
    assert_positive_int(R5_ARG3);
23211
954e3a81da29 8035647: PPC64: Support for elf v2 abi.
goetz
parents: 22874
diff changeset
  1690
    address nooverlap_target = aligned ?
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1691
      STUB_ENTRY(arrayof_jint_disjoint_arraycopy) :
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1692
      STUB_ENTRY(jint_disjoint_arraycopy);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1693
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1694
    array_overlap_test(nooverlap_target, 2);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1695
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1696
    generate_conjoint_int_copy_core(aligned);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1697
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1698
    __ li(R3_RET, 0); // return 0
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1699
    __ blr();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1700
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1701
    return start;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1702
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1703
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1704
  // Generate core code for disjoint long copy (and oop copy on
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1705
  // 64-bit).  If "aligned" is true, the "from" and "to" addresses
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1706
  // are assumed to be heapword aligned.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1707
  //
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1708
  // Arguments:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1709
  //      from:  R3_ARG1
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1710
  //      to:    R4_ARG2
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1711
  //      count: R5_ARG3 treated as signed
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1712
  //
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1713
  void generate_disjoint_long_copy_core(bool aligned) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1714
    Register tmp1 = R6_ARG4;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1715
    Register tmp2 = R7_ARG5;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1716
    Register tmp3 = R8_ARG6;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1717
    Register tmp4 = R0;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1718
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1719
    Label l_1, l_2, l_3, l_4;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1720
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1721
    { // FasterArrayCopy
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1722
      __ cmpwi(CCR0, R5_ARG3, 3);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1723
      __ ble(CCR0, l_3); // copy 1 at a time if less than 4 elements remain
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1724
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1725
      __ srdi(tmp1, R5_ARG3, 2);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1726
      __ andi_(R5_ARG3, R5_ARG3, 3);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1727
      __ mtctr(tmp1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1728
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1729
      __ bind(l_4);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1730
      // Use unrolled version for mass copying (copy 4 elements a time).
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1731
      // Load feeding store gets zero latency on Power6, however not on Power5.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1732
      // Therefore, the following sequence is made for the good of both.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1733
      __ ld(tmp1, 0, R3_ARG1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1734
      __ ld(tmp2, 8, R3_ARG1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1735
      __ ld(tmp3, 16, R3_ARG1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1736
      __ ld(tmp4, 24, R3_ARG1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1737
      __ std(tmp1, 0, R4_ARG2);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1738
      __ std(tmp2, 8, R4_ARG2);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1739
      __ std(tmp3, 16, R4_ARG2);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1740
      __ std(tmp4, 24, R4_ARG2);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1741
      __ addi(R3_ARG1, R3_ARG1, 32);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1742
      __ addi(R4_ARG2, R4_ARG2, 32);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1743
      __ bdnz(l_4);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1744
    }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1745
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1746
    // copy 1 element at a time
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1747
    __ bind(l_3);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1748
    __ cmpwi(CCR0, R5_ARG3, 0);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1749
    __ beq(CCR0, l_1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1750
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1751
    { // FasterArrayCopy
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1752
      __ mtctr(R5_ARG3);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1753
      __ addi(R3_ARG1, R3_ARG1, -8);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1754
      __ addi(R4_ARG2, R4_ARG2, -8);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1755
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1756
      __ bind(l_2);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1757
      __ ldu(R0, 8, R3_ARG1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1758
      __ stdu(R0, 8, R4_ARG2);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1759
      __ bdnz(l_2);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1760
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1761
    }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1762
    __ bind(l_1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1763
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1764
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1765
  // Generate stub for disjoint long copy.  If "aligned" is true, the
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1766
  // "from" and "to" addresses are assumed to be heapword aligned.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1767
  //
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1768
  // Arguments for generated stub:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1769
  //      from:  R3_ARG1
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1770
  //      to:    R4_ARG2
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1771
  //      count: R5_ARG3 treated as signed
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1772
  //
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1773
  address generate_disjoint_long_copy(bool aligned, const char * name) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1774
    StubCodeMark mark(this, "StubRoutines", name);
23211
954e3a81da29 8035647: PPC64: Support for elf v2 abi.
goetz
parents: 22874
diff changeset
  1775
    address start = __ function_entry();
35541
cba047a086d5 8146613: PPC64: C2 does no longer respect int to long conversion for stub calls
mdoerr
parents: 35156
diff changeset
  1776
    assert_positive_int(R5_ARG3);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1777
    generate_disjoint_long_copy_core(aligned);
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1778
    __ li(R3_RET, 0); // return 0
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1779
    __ blr();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1780
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1781
    return start;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1782
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1783
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1784
  // Generate core code for conjoint long copy (and oop copy on
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1785
  // 64-bit).  If "aligned" is true, the "from" and "to" addresses
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1786
  // are assumed to be heapword aligned.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1787
  //
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1788
  // Arguments:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1789
  //      from:  R3_ARG1
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1790
  //      to:    R4_ARG2
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1791
  //      count: R5_ARG3 treated as signed
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1792
  //
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1793
  void generate_conjoint_long_copy_core(bool aligned) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1794
    Register tmp1 = R6_ARG4;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1795
    Register tmp2 = R7_ARG5;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1796
    Register tmp3 = R8_ARG6;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1797
    Register tmp4 = R0;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1798
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1799
    Label l_1, l_2, l_3, l_4, l_5;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1800
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1801
    __ cmpwi(CCR0, R5_ARG3, 0);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1802
    __ beq(CCR0, l_1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1803
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1804
    { // FasterArrayCopy
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1805
      __ sldi(R5_ARG3, R5_ARG3, 3);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1806
      __ add(R3_ARG1, R3_ARG1, R5_ARG3);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1807
      __ add(R4_ARG2, R4_ARG2, R5_ARG3);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1808
      __ srdi(R5_ARG3, R5_ARG3, 3);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1809
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1810
      __ cmpwi(CCR0, R5_ARG3, 3);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1811
      __ ble(CCR0, l_5); // copy 1 at a time if less than 4 elements remain
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1812
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1813
      __ srdi(tmp1, R5_ARG3, 2);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1814
      __ andi(R5_ARG3, R5_ARG3, 3);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1815
      __ mtctr(tmp1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1816
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1817
      __ bind(l_4);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1818
      // Use unrolled version for mass copying (copy 4 elements a time).
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1819
      // Load feeding store gets zero latency on Power6, however not on Power5.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1820
      // Therefore, the following sequence is made for the good of both.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1821
      __ addi(R3_ARG1, R3_ARG1, -32);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1822
      __ addi(R4_ARG2, R4_ARG2, -32);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1823
      __ ld(tmp4, 24, R3_ARG1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1824
      __ ld(tmp3, 16, R3_ARG1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1825
      __ ld(tmp2, 8, R3_ARG1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1826
      __ ld(tmp1, 0, R3_ARG1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1827
      __ std(tmp4, 24, R4_ARG2);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1828
      __ std(tmp3, 16, R4_ARG2);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1829
      __ std(tmp2, 8, R4_ARG2);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1830
      __ std(tmp1, 0, R4_ARG2);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1831
      __ bdnz(l_4);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1832
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1833
      __ cmpwi(CCR0, R5_ARG3, 0);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1834
      __ beq(CCR0, l_1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1835
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1836
      __ bind(l_5);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1837
      __ mtctr(R5_ARG3);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1838
      __ bind(l_3);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1839
      __ ld(R0, -8, R3_ARG1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1840
      __ std(R0, -8, R4_ARG2);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1841
      __ addi(R3_ARG1, R3_ARG1, -8);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1842
      __ addi(R4_ARG2, R4_ARG2, -8);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1843
      __ bdnz(l_3);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1844
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1845
    }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1846
    __ bind(l_1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1847
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1848
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1849
  // Generate stub for conjoint long copy.  If "aligned" is true, the
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1850
  // "from" and "to" addresses are assumed to be heapword aligned.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1851
  //
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1852
  // Arguments for generated stub:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1853
  //      from:  R3_ARG1
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1854
  //      to:    R4_ARG2
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1855
  //      count: R5_ARG3 treated as signed
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1856
  //
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1857
  address generate_conjoint_long_copy(bool aligned, const char * name) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1858
    StubCodeMark mark(this, "StubRoutines", name);
23211
954e3a81da29 8035647: PPC64: Support for elf v2 abi.
goetz
parents: 22874
diff changeset
  1859
    address start = __ function_entry();
35541
cba047a086d5 8146613: PPC64: C2 does no longer respect int to long conversion for stub calls
mdoerr
parents: 35156
diff changeset
  1860
    assert_positive_int(R5_ARG3);
23211
954e3a81da29 8035647: PPC64: Support for elf v2 abi.
goetz
parents: 22874
diff changeset
  1861
    address nooverlap_target = aligned ?
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1862
      STUB_ENTRY(arrayof_jlong_disjoint_arraycopy) :
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1863
      STUB_ENTRY(jlong_disjoint_arraycopy);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1864
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1865
    array_overlap_test(nooverlap_target, 3);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1866
    generate_conjoint_long_copy_core(aligned);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1867
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1868
    __ li(R3_RET, 0); // return 0
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1869
    __ blr();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1870
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1871
    return start;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1872
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1873
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1874
  // Generate stub for conjoint oop copy.  If "aligned" is true, the
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1875
  // "from" and "to" addresses are assumed to be heapword aligned.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1876
  //
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1877
  // Arguments for generated stub:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1878
  //      from:  R3_ARG1
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1879
  //      to:    R4_ARG2
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1880
  //      count: R5_ARG3 treated as signed
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1881
  //      dest_uninitialized: G1 support
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1882
  //
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1883
  address generate_conjoint_oop_copy(bool aligned, const char * name, bool dest_uninitialized) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1884
    StubCodeMark mark(this, "StubRoutines", name);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1885
23211
954e3a81da29 8035647: PPC64: Support for elf v2 abi.
goetz
parents: 22874
diff changeset
  1886
    address start = __ function_entry();
35541
cba047a086d5 8146613: PPC64: C2 does no longer respect int to long conversion for stub calls
mdoerr
parents: 35156
diff changeset
  1887
    assert_positive_int(R5_ARG3);
23211
954e3a81da29 8035647: PPC64: Support for elf v2 abi.
goetz
parents: 22874
diff changeset
  1888
    address nooverlap_target = aligned ?
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1889
      STUB_ENTRY(arrayof_oop_disjoint_arraycopy) :
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1890
      STUB_ENTRY(oop_disjoint_arraycopy);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1891
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1892
    gen_write_ref_array_pre_barrier(R3_ARG1, R4_ARG2, R5_ARG3, dest_uninitialized, R9_ARG7);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1893
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1894
    // Save arguments.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1895
    __ mr(R9_ARG7, R4_ARG2);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1896
    __ mr(R10_ARG8, R5_ARG3);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1897
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1898
    if (UseCompressedOops) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1899
      array_overlap_test(nooverlap_target, 2);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1900
      generate_conjoint_int_copy_core(aligned);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1901
    } else {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1902
      array_overlap_test(nooverlap_target, 3);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1903
      generate_conjoint_long_copy_core(aligned);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1904
    }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1905
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1906
    gen_write_ref_array_post_barrier(R9_ARG7, R10_ARG8, R11_scratch1);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1907
    __ li(R3_RET, 0); // return 0
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1908
    __ blr();
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1909
    return start;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1910
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1911
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1912
  // Generate stub for disjoint oop copy.  If "aligned" is true, the
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1913
  // "from" and "to" addresses are assumed to be heapword aligned.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1914
  //
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1915
  // Arguments for generated stub:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1916
  //      from:  R3_ARG1
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1917
  //      to:    R4_ARG2
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1918
  //      count: R5_ARG3 treated as signed
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1919
  //      dest_uninitialized: G1 support
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1920
  //
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1921
  address generate_disjoint_oop_copy(bool aligned, const char * name, bool dest_uninitialized) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1922
    StubCodeMark mark(this, "StubRoutines", name);
23211
954e3a81da29 8035647: PPC64: Support for elf v2 abi.
goetz
parents: 22874
diff changeset
  1923
    address start = __ function_entry();
35541
cba047a086d5 8146613: PPC64: C2 does no longer respect int to long conversion for stub calls
mdoerr
parents: 35156
diff changeset
  1924
    assert_positive_int(R5_ARG3);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1925
    gen_write_ref_array_pre_barrier(R3_ARG1, R4_ARG2, R5_ARG3, dest_uninitialized, R9_ARG7);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1926
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1927
    // save some arguments, disjoint_long_copy_core destroys them.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1928
    // needed for post barrier
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1929
    __ mr(R9_ARG7, R4_ARG2);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1930
    __ mr(R10_ARG8, R5_ARG3);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1931
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1932
    if (UseCompressedOops) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1933
      generate_disjoint_int_copy_core(aligned);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1934
    } else {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1935
      generate_disjoint_long_copy_core(aligned);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1936
    }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1937
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1938
    gen_write_ref_array_post_barrier(R9_ARG7, R10_ARG8, R11_scratch1);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1939
    __ li(R3_RET, 0); // return 0
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1940
    __ blr();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1941
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1942
    return start;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1943
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1944
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1945
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1946
  // Helper for generating a dynamic type check.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1947
  // Smashes only the given temp registers.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1948
  void generate_type_check(Register sub_klass,
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1949
                           Register super_check_offset,
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1950
                           Register super_klass,
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1951
                           Register temp,
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1952
                           Label& L_success) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1953
    assert_different_registers(sub_klass, super_check_offset, super_klass);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1954
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1955
    BLOCK_COMMENT("type_check:");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1956
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1957
    Label L_miss;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1958
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1959
    __ check_klass_subtype_fast_path(sub_klass, super_klass, temp, R0, &L_success, &L_miss, NULL,
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1960
                                     super_check_offset);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1961
    __ check_klass_subtype_slow_path(sub_klass, super_klass, temp, R0, &L_success, NULL);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1962
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1963
    // Fall through on failure!
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1964
    __ bind(L_miss);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1965
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1966
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1967
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1968
  //  Generate stub for checked oop copy.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1969
  //
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1970
  // Arguments for generated stub:
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1971
  //      from:  R3
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1972
  //      to:    R4
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1973
  //      count: R5 treated as signed
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1974
  //      ckoff: R6 (super_check_offset)
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1975
  //      ckval: R7 (super_klass)
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1976
  //      ret:   R3 zero for success; (-1^K) where K is partial transfer count
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1977
  //
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1978
  address generate_checkcast_copy(const char *name, bool dest_uninitialized) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1979
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1980
    const Register R3_from   = R3_ARG1;      // source array address
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1981
    const Register R4_to     = R4_ARG2;      // destination array address
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1982
    const Register R5_count  = R5_ARG3;      // elements count
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1983
    const Register R6_ckoff  = R6_ARG4;      // super_check_offset
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1984
    const Register R7_ckval  = R7_ARG5;      // super_klass
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1985
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1986
    const Register R8_offset = R8_ARG6;      // loop var, with stride wordSize
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1987
    const Register R9_remain = R9_ARG7;      // loop var, with stride -1
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1988
    const Register R10_oop   = R10_ARG8;     // actual oop copied
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1989
    const Register R11_klass = R11_scratch1; // oop._klass
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1990
    const Register R12_tmp   = R12_scratch2;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1991
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1992
    const Register R2_minus1 = R2;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1993
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1994
    //__ align(CodeEntryAlignment);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1995
    StubCodeMark mark(this, "StubRoutines", name);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1996
    address start = __ function_entry();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1997
35541
cba047a086d5 8146613: PPC64: C2 does no longer respect int to long conversion for stub calls
mdoerr
parents: 35156
diff changeset
  1998
    // Assert that int is 64 bit sign extended and arrays are not conjoint.
cba047a086d5 8146613: PPC64: C2 does no longer respect int to long conversion for stub calls
mdoerr
parents: 35156
diff changeset
  1999
#ifdef ASSERT
cba047a086d5 8146613: PPC64: C2 does no longer respect int to long conversion for stub calls
mdoerr
parents: 35156
diff changeset
  2000
    {
cba047a086d5 8146613: PPC64: C2 does no longer respect int to long conversion for stub calls
mdoerr
parents: 35156
diff changeset
  2001
    assert_positive_int(R5_ARG3);
cba047a086d5 8146613: PPC64: C2 does no longer respect int to long conversion for stub calls
mdoerr
parents: 35156
diff changeset
  2002
    const Register tmp1 = R11_scratch1, tmp2 = R12_scratch2;
cba047a086d5 8146613: PPC64: C2 does no longer respect int to long conversion for stub calls
mdoerr
parents: 35156
diff changeset
  2003
    Label no_overlap;
cba047a086d5 8146613: PPC64: C2 does no longer respect int to long conversion for stub calls
mdoerr
parents: 35156
diff changeset
  2004
    __ subf(tmp1, R3_ARG1, R4_ARG2); // distance in bytes
cba047a086d5 8146613: PPC64: C2 does no longer respect int to long conversion for stub calls
mdoerr
parents: 35156
diff changeset
  2005
    __ sldi(tmp2, R5_ARG3, LogBytesPerHeapOop); // size in bytes
cba047a086d5 8146613: PPC64: C2 does no longer respect int to long conversion for stub calls
mdoerr
parents: 35156
diff changeset
  2006
    __ cmpld(CCR0, R3_ARG1, R4_ARG2); // Use unsigned comparison!
cba047a086d5 8146613: PPC64: C2 does no longer respect int to long conversion for stub calls
mdoerr
parents: 35156
diff changeset
  2007
    __ cmpld(CCR1, tmp1, tmp2);
cba047a086d5 8146613: PPC64: C2 does no longer respect int to long conversion for stub calls
mdoerr
parents: 35156
diff changeset
  2008
    __ crnand(CCR0, Assembler::less, CCR1, Assembler::less);
cba047a086d5 8146613: PPC64: C2 does no longer respect int to long conversion for stub calls
mdoerr
parents: 35156
diff changeset
  2009
    // Overlaps if Src before dst and distance smaller than size.
cba047a086d5 8146613: PPC64: C2 does no longer respect int to long conversion for stub calls
mdoerr
parents: 35156
diff changeset
  2010
    // Branch to forward copy routine otherwise.
cba047a086d5 8146613: PPC64: C2 does no longer respect int to long conversion for stub calls
mdoerr
parents: 35156
diff changeset
  2011
    __ blt(CCR0, no_overlap);
cba047a086d5 8146613: PPC64: C2 does no longer respect int to long conversion for stub calls
mdoerr
parents: 35156
diff changeset
  2012
    __ stop("overlap in checkcast_copy", 0x9543);
cba047a086d5 8146613: PPC64: C2 does no longer respect int to long conversion for stub calls
mdoerr
parents: 35156
diff changeset
  2013
    __ bind(no_overlap);
cba047a086d5 8146613: PPC64: C2 does no longer respect int to long conversion for stub calls
mdoerr
parents: 35156
diff changeset
  2014
    }
cba047a086d5 8146613: PPC64: C2 does no longer respect int to long conversion for stub calls
mdoerr
parents: 35156
diff changeset
  2015
#endif
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2016
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2017
    gen_write_ref_array_pre_barrier(R3_from, R4_to, R5_count, dest_uninitialized, R12_tmp, /* preserve: */ R6_ckoff, R7_ckval);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2018
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2019
    //inc_counter_np(SharedRuntime::_checkcast_array_copy_ctr, R12_tmp, R3_RET);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2020
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2021
    Label load_element, store_element, store_null, success, do_card_marks;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2022
    __ or_(R9_remain, R5_count, R5_count); // Initialize loop index, and test it.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2023
    __ li(R8_offset, 0);                   // Offset from start of arrays.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2024
    __ li(R2_minus1, -1);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2025
    __ bne(CCR0, load_element);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2026
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2027
    // Empty array: Nothing to do.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2028
    __ li(R3_RET, 0);           // Return 0 on (trivial) success.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2029
    __ blr();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2030
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2031
    // ======== begin loop ========
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2032
    // (Entry is load_element.)
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2033
    __ align(OptoLoopAlignment);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2034
    __ bind(store_element);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2035
    if (UseCompressedOops) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2036
      __ encode_heap_oop_not_null(R10_oop);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2037
      __ bind(store_null);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2038
      __ stw(R10_oop, R8_offset, R4_to);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2039
    } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2040
      __ bind(store_null);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2041
      __ std(R10_oop, R8_offset, R4_to);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2042
    }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2043
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2044
    __ addi(R8_offset, R8_offset, heapOopSize);   // Step to next offset.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2045
    __ add_(R9_remain, R2_minus1, R9_remain);     // Decrement the count.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2046
    __ beq(CCR0, success);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2047
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2048
    // ======== loop entry is here ========
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2049
    __ bind(load_element);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2050
    __ load_heap_oop(R10_oop, R8_offset, R3_from, &store_null);  // Load the oop.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2051
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2052
    __ load_klass(R11_klass, R10_oop); // Query the object klass.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2053
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2054
    generate_type_check(R11_klass, R6_ckoff, R7_ckval, R12_tmp,
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2055
                        // Branch to this on success:
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2056
                        store_element);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2057
    // ======== end loop ========
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2058
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2059
    // It was a real error; we must depend on the caller to finish the job.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2060
    // Register R9_remain has number of *remaining* oops, R5_count number of *total* oops.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2061
    // Emit GC store barriers for the oops we have copied (R5_count minus R9_remain),
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2062
    // and report their number to the caller.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2063
    __ subf_(R5_count, R9_remain, R5_count);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2064
    __ nand(R3_RET, R5_count, R5_count);   // report (-1^K) to caller
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2065
    __ bne(CCR0, do_card_marks);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2066
    __ blr();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2067
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2068
    __ bind(success);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2069
    __ li(R3_RET, 0);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2070
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2071
    __ bind(do_card_marks);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2072
    // Store check on R4_to[0..R5_count-1].
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2073
    gen_write_ref_array_post_barrier(R4_to, R5_count, R12_tmp, /* preserve: */ R3_RET);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2074
    __ blr();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2075
    return start;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2076
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2077
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2078
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2079
  //  Generate 'unsafe' array copy stub.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2080
  //  Though just as safe as the other stubs, it takes an unscaled
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2081
  //  size_t argument instead of an element count.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2082
  //
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2083
  // Arguments for generated stub:
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2084
  //      from:  R3
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2085
  //      to:    R4
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2086
  //      count: R5 byte count, treated as ssize_t, can be zero
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2087
  //
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2088
  // Examines the alignment of the operands and dispatches
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2089
  // to a long, int, short, or byte copy loop.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2090
  //
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2091
  address generate_unsafe_copy(const char* name,
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2092
                               address byte_copy_entry,
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2093
                               address short_copy_entry,
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2094
                               address int_copy_entry,
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2095
                               address long_copy_entry) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2096
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2097
    const Register R3_from   = R3_ARG1;      // source array address
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2098
    const Register R4_to     = R4_ARG2;      // destination array address
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2099
    const Register R5_count  = R5_ARG3;      // elements count (as long on PPC64)
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2100
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2101
    const Register R6_bits   = R6_ARG4;      // test copy of low bits
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2102
    const Register R7_tmp    = R7_ARG5;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2103
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2104
    //__ align(CodeEntryAlignment);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2105
    StubCodeMark mark(this, "StubRoutines", name);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2106
    address start = __ function_entry();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2107
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2108
    // Bump this on entry, not on exit:
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2109
    //inc_counter_np(SharedRuntime::_unsafe_array_copy_ctr, R6_bits, R7_tmp);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2110
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2111
    Label short_copy, int_copy, long_copy;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2112
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2113
    __ orr(R6_bits, R3_from, R4_to);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2114
    __ orr(R6_bits, R6_bits, R5_count);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2115
    __ andi_(R0, R6_bits, (BytesPerLong-1));
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2116
    __ beq(CCR0, long_copy);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2117
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2118
    __ andi_(R0, R6_bits, (BytesPerInt-1));
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2119
    __ beq(CCR0, int_copy);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2120
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2121
    __ andi_(R0, R6_bits, (BytesPerShort-1));
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2122
    __ beq(CCR0, short_copy);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2123
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2124
    // byte_copy:
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2125
    __ b(byte_copy_entry);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2126
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2127
    __ bind(short_copy);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2128
    __ srwi(R5_count, R5_count, LogBytesPerShort);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2129
    __ b(short_copy_entry);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2130
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2131
    __ bind(int_copy);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2132
    __ srwi(R5_count, R5_count, LogBytesPerInt);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2133
    __ b(int_copy_entry);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2134
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2135
    __ bind(long_copy);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2136
    __ srwi(R5_count, R5_count, LogBytesPerLong);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2137
    __ b(long_copy_entry);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2138
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2139
    return start;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2140
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2141
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2142
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2143
  // Perform range checks on the proposed arraycopy.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2144
  // Kills the two temps, but nothing else.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2145
  // Also, clean the sign bits of src_pos and dst_pos.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2146
  void arraycopy_range_checks(Register src,     // source array oop
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2147
                              Register src_pos, // source position
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2148
                              Register dst,     // destination array oop
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2149
                              Register dst_pos, // destination position
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2150
                              Register length,  // length of copy
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2151
                              Register temp1, Register temp2,
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2152
                              Label& L_failed) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2153
    BLOCK_COMMENT("arraycopy_range_checks:");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2154
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2155
    const Register array_length = temp1;  // scratch
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2156
    const Register end_pos      = temp2;  // scratch
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2157
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2158
    //  if (src_pos + length > arrayOop(src)->length() ) FAIL;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2159
    __ lwa(array_length, arrayOopDesc::length_offset_in_bytes(), src);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2160
    __ add(end_pos, src_pos, length);  // src_pos + length
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2161
    __ cmpd(CCR0, end_pos, array_length);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2162
    __ bgt(CCR0, L_failed);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2163
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2164
    //  if (dst_pos + length > arrayOop(dst)->length() ) FAIL;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2165
    __ lwa(array_length, arrayOopDesc::length_offset_in_bytes(), dst);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2166
    __ add(end_pos, dst_pos, length);  // src_pos + length
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2167
    __ cmpd(CCR0, end_pos, array_length);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2168
    __ bgt(CCR0, L_failed);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2169
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2170
    BLOCK_COMMENT("arraycopy_range_checks done");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2171
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2172
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2173
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2174
  //
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2175
  //  Generate generic array copy stubs
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2176
  //
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2177
  //  Input:
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2178
  //    R3    -  src oop
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2179
  //    R4    -  src_pos
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2180
  //    R5    -  dst oop
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2181
  //    R6    -  dst_pos
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2182
  //    R7    -  element count
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2183
  //
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2184
  //  Output:
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2185
  //    R3 ==  0  -  success
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2186
  //    R3 == -1  -  need to call System.arraycopy
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2187
  //
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2188
  address generate_generic_copy(const char *name,
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2189
                                address entry_jbyte_arraycopy,
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2190
                                address entry_jshort_arraycopy,
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2191
                                address entry_jint_arraycopy,
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2192
                                address entry_oop_arraycopy,
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2193
                                address entry_disjoint_oop_arraycopy,
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2194
                                address entry_jlong_arraycopy,
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2195
                                address entry_checkcast_arraycopy) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2196
    Label L_failed, L_objArray;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2197
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2198
    // Input registers
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2199
    const Register src       = R3_ARG1;  // source array oop
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2200
    const Register src_pos   = R4_ARG2;  // source position
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2201
    const Register dst       = R5_ARG3;  // destination array oop
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2202
    const Register dst_pos   = R6_ARG4;  // destination position
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2203
    const Register length    = R7_ARG5;  // elements count
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2204
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2205
    // registers used as temp
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2206
    const Register src_klass = R8_ARG6;  // source array klass
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2207
    const Register dst_klass = R9_ARG7;  // destination array klass
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2208
    const Register lh        = R10_ARG8; // layout handler
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2209
    const Register temp      = R2;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2210
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2211
    //__ align(CodeEntryAlignment);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2212
    StubCodeMark mark(this, "StubRoutines", name);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2213
    address start = __ function_entry();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2214
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2215
    // Bump this on entry, not on exit:
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2216
    //inc_counter_np(SharedRuntime::_generic_array_copy_ctr, lh, temp);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2217
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2218
    // In principle, the int arguments could be dirty.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2219
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2220
    //-----------------------------------------------------------------------
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2221
    // Assembler stubs will be used for this call to arraycopy
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2222
    // if the following conditions are met:
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2223
    //
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2224
    // (1) src and dst must not be null.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2225
    // (2) src_pos must not be negative.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2226
    // (3) dst_pos must not be negative.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2227
    // (4) length  must not be negative.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2228
    // (5) src klass and dst klass should be the same and not NULL.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2229
    // (6) src and dst should be arrays.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2230
    // (7) src_pos + length must not exceed length of src.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2231
    // (8) dst_pos + length must not exceed length of dst.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2232
    BLOCK_COMMENT("arraycopy initial argument checks");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2233
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2234
    __ cmpdi(CCR1, src, 0);      // if (src == NULL) return -1;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2235
    __ extsw_(src_pos, src_pos); // if (src_pos < 0) return -1;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2236
    __ cmpdi(CCR5, dst, 0);      // if (dst == NULL) return -1;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2237
    __ cror(CCR1, Assembler::equal, CCR0, Assembler::less);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2238
    __ extsw_(dst_pos, dst_pos); // if (src_pos < 0) return -1;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2239
    __ cror(CCR5, Assembler::equal, CCR0, Assembler::less);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2240
    __ extsw_(length, length);   // if (length < 0) return -1;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2241
    __ cror(CCR1, Assembler::equal, CCR5, Assembler::equal);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2242
    __ cror(CCR1, Assembler::equal, CCR0, Assembler::less);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2243
    __ beq(CCR1, L_failed);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2244
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2245
    BLOCK_COMMENT("arraycopy argument klass checks");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2246
    __ load_klass(src_klass, src);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2247
    __ load_klass(dst_klass, dst);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2248
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2249
    // Load layout helper
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2250
    //
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2251
    //  |array_tag|     | header_size | element_type |     |log2_element_size|
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2252
    // 32        30    24            16              8     2                 0
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2253
    //
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2254
    //   array_tag: typeArray = 0x3, objArray = 0x2, non-array = 0x0
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2255
    //
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2256
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2257
    int lh_offset = in_bytes(Klass::layout_helper_offset());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2258
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2259
    // Load 32-bits signed value. Use br() instruction with it to check icc.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2260
    __ lwz(lh, lh_offset, src_klass);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2261
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2262
    // Handle objArrays completely differently...
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2263
    jint objArray_lh = Klass::array_layout_helper(T_OBJECT);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2264
    __ load_const_optimized(temp, objArray_lh, R0);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2265
    __ cmpw(CCR0, lh, temp);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2266
    __ beq(CCR0, L_objArray);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2267
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2268
    __ cmpd(CCR5, src_klass, dst_klass);          // if (src->klass() != dst->klass()) return -1;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2269
    __ cmpwi(CCR6, lh, Klass::_lh_neutral_value); // if (!src->is_Array()) return -1;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2270
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2271
    __ crnand(CCR5, Assembler::equal, CCR6, Assembler::less);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2272
    __ beq(CCR5, L_failed);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2273
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2274
    // At this point, it is known to be a typeArray (array_tag 0x3).
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2275
#ifdef ASSERT
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2276
    { Label L;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2277
      jint lh_prim_tag_in_place = (Klass::_lh_array_tag_type_value << Klass::_lh_array_tag_shift);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2278
      __ load_const_optimized(temp, lh_prim_tag_in_place, R0);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2279
      __ cmpw(CCR0, lh, temp);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2280
      __ bge(CCR0, L);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2281
      __ stop("must be a primitive array");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2282
      __ bind(L);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2283
    }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2284
#endif
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2285
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2286
    arraycopy_range_checks(src, src_pos, dst, dst_pos, length,
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2287
                           temp, dst_klass, L_failed);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2288
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2289
    // TypeArrayKlass
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2290
    //
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2291
    // src_addr = (src + array_header_in_bytes()) + (src_pos << log2elemsize);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2292
    // dst_addr = (dst + array_header_in_bytes()) + (dst_pos << log2elemsize);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2293
    //
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2294
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2295
    const Register offset = dst_klass;    // array offset
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2296
    const Register elsize = src_klass;    // log2 element size
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2297
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2298
    __ rldicl(offset, lh, 64 - Klass::_lh_header_size_shift, 64 - exact_log2(Klass::_lh_header_size_mask + 1));
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2299
    __ andi(elsize, lh, Klass::_lh_log2_element_size_mask);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2300
    __ add(src, offset, src);       // src array offset
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2301
    __ add(dst, offset, dst);       // dst array offset
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2302
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2303
    // Next registers should be set before the jump to corresponding stub.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2304
    const Register from     = R3_ARG1;  // source array address
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2305
    const Register to       = R4_ARG2;  // destination array address
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2306
    const Register count    = R5_ARG3;  // elements count
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2307
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2308
    // 'from', 'to', 'count' registers should be set in this order
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2309
    // since they are the same as 'src', 'src_pos', 'dst'.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2310
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2311
    BLOCK_COMMENT("scale indexes to element size");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2312
    __ sld(src_pos, src_pos, elsize);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2313
    __ sld(dst_pos, dst_pos, elsize);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2314
    __ add(from, src_pos, src);  // src_addr
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2315
    __ add(to, dst_pos, dst);    // dst_addr
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2316
    __ mr(count, length);        // length
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2317
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2318
    BLOCK_COMMENT("choose copy loop based on element size");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2319
    // Using conditional branches with range 32kB.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2320
    const int bo = Assembler::bcondCRbiIs1, bi = Assembler::bi0(CCR0, Assembler::equal);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2321
    __ cmpwi(CCR0, elsize, 0);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2322
    __ bc(bo, bi, entry_jbyte_arraycopy);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2323
    __ cmpwi(CCR0, elsize, LogBytesPerShort);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2324
    __ bc(bo, bi, entry_jshort_arraycopy);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2325
    __ cmpwi(CCR0, elsize, LogBytesPerInt);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2326
    __ bc(bo, bi, entry_jint_arraycopy);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2327
#ifdef ASSERT
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2328
    { Label L;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2329
      __ cmpwi(CCR0, elsize, LogBytesPerLong);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2330
      __ beq(CCR0, L);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2331
      __ stop("must be long copy, but elsize is wrong");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2332
      __ bind(L);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2333
    }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2334
#endif
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2335
    __ b(entry_jlong_arraycopy);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2336
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2337
    // ObjArrayKlass
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2338
  __ bind(L_objArray);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2339
    // live at this point:  src_klass, dst_klass, src[_pos], dst[_pos], length
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2340
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2341
    Label L_disjoint_plain_copy, L_checkcast_copy;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2342
    //  test array classes for subtyping
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2343
    __ cmpd(CCR0, src_klass, dst_klass);         // usual case is exact equality
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2344
    __ bne(CCR0, L_checkcast_copy);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2345
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2346
    // Identically typed arrays can be copied without element-wise checks.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2347
    arraycopy_range_checks(src, src_pos, dst, dst_pos, length,
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2348
                           temp, lh, L_failed);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2349
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2350
    __ addi(src, src, arrayOopDesc::base_offset_in_bytes(T_OBJECT)); //src offset
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2351
    __ addi(dst, dst, arrayOopDesc::base_offset_in_bytes(T_OBJECT)); //dst offset
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2352
    __ sldi(src_pos, src_pos, LogBytesPerHeapOop);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2353
    __ sldi(dst_pos, dst_pos, LogBytesPerHeapOop);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2354
    __ add(from, src_pos, src);  // src_addr
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2355
    __ add(to, dst_pos, dst);    // dst_addr
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2356
    __ mr(count, length);        // length
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2357
    __ b(entry_oop_arraycopy);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2358
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2359
  __ bind(L_checkcast_copy);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2360
    // live at this point:  src_klass, dst_klass
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2361
    {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2362
      // Before looking at dst.length, make sure dst is also an objArray.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2363
      __ lwz(temp, lh_offset, dst_klass);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2364
      __ cmpw(CCR0, lh, temp);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2365
      __ bne(CCR0, L_failed);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2366
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2367
      // It is safe to examine both src.length and dst.length.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2368
      arraycopy_range_checks(src, src_pos, dst, dst_pos, length,
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2369
                             temp, lh, L_failed);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2370
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2371
      // Marshal the base address arguments now, freeing registers.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2372
      __ addi(src, src, arrayOopDesc::base_offset_in_bytes(T_OBJECT)); //src offset
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2373
      __ addi(dst, dst, arrayOopDesc::base_offset_in_bytes(T_OBJECT)); //dst offset
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2374
      __ sldi(src_pos, src_pos, LogBytesPerHeapOop);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2375
      __ sldi(dst_pos, dst_pos, LogBytesPerHeapOop);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2376
      __ add(from, src_pos, src);  // src_addr
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2377
      __ add(to, dst_pos, dst);    // dst_addr
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2378
      __ mr(count, length);        // length
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2379
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2380
      Register sco_temp = R6_ARG4;             // This register is free now.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2381
      assert_different_registers(from, to, count, sco_temp,
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2382
                                 dst_klass, src_klass);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2383
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2384
      // Generate the type check.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2385
      int sco_offset = in_bytes(Klass::super_check_offset_offset());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2386
      __ lwz(sco_temp, sco_offset, dst_klass);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2387
      generate_type_check(src_klass, sco_temp, dst_klass,
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2388
                          temp, L_disjoint_plain_copy);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2389
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2390
      // Fetch destination element klass from the ObjArrayKlass header.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2391
      int ek_offset = in_bytes(ObjArrayKlass::element_klass_offset());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2392
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2393
      // The checkcast_copy loop needs two extra arguments:
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2394
      __ ld(R7_ARG5, ek_offset, dst_klass);   // dest elem klass
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2395
      __ lwz(R6_ARG4, sco_offset, R7_ARG5);   // sco of elem klass
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2396
      __ b(entry_checkcast_arraycopy);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2397
    }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2398
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2399
    __ bind(L_disjoint_plain_copy);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2400
    __ b(entry_disjoint_oop_arraycopy);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2401
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2402
  __ bind(L_failed);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2403
    __ li(R3_RET, -1); // return -1
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2404
    __ blr();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2405
    return start;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2406
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2407
37275
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2408
  // Arguments for generated stub (little endian only):
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2409
  //   R3_ARG1   - source byte array address
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2410
  //   R4_ARG2   - destination byte array address
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2411
  //   R5_ARG3   - round key array
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2412
  address generate_aescrypt_encryptBlock() {
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2413
    assert(UseAES, "need AES instructions and misaligned SSE support");
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2414
    StubCodeMark mark(this, "StubRoutines", "aescrypt_encryptBlock");
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2415
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2416
    address start = __ function_entry();
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2417
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2418
    Label L_doLast;
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2419
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2420
    Register from           = R3_ARG1;  // source array address
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2421
    Register to             = R4_ARG2;  // destination array address
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2422
    Register key            = R5_ARG3;  // round key array
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2423
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2424
    Register keylen         = R8;
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2425
    Register temp           = R9;
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2426
    Register keypos         = R10;
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2427
    Register hex            = R11;
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2428
    Register fifteen        = R12;
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2429
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2430
    VectorRegister vRet     = VR0;
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2431
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2432
    VectorRegister vKey1    = VR1;
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2433
    VectorRegister vKey2    = VR2;
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2434
    VectorRegister vKey3    = VR3;
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2435
    VectorRegister vKey4    = VR4;
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2436
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2437
    VectorRegister fromPerm = VR5;
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2438
    VectorRegister keyPerm  = VR6;
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2439
    VectorRegister toPerm   = VR7;
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2440
    VectorRegister fSplt    = VR8;
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2441
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2442
    VectorRegister vTmp1    = VR9;
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2443
    VectorRegister vTmp2    = VR10;
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2444
    VectorRegister vTmp3    = VR11;
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2445
    VectorRegister vTmp4    = VR12;
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2446
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2447
    VectorRegister vLow     = VR13;
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2448
    VectorRegister vHigh    = VR14;
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2449
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2450
    __ li              (hex, 16);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2451
    __ li              (fifteen, 15);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2452
    __ vspltisb        (fSplt, 0x0f);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2453
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2454
    // load unaligned from[0-15] to vsRet
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2455
    __ lvx             (vRet, from);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2456
    __ lvx             (vTmp1, fifteen, from);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2457
    __ lvsl            (fromPerm, from);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2458
    __ vxor            (fromPerm, fromPerm, fSplt);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2459
    __ vperm           (vRet, vRet, vTmp1, fromPerm);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2460
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2461
    // load keylen (44 or 52 or 60)
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2462
    __ lwz             (keylen, arrayOopDesc::length_offset_in_bytes() - arrayOopDesc::base_offset_in_bytes(T_INT), key);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2463
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2464
    // to load keys
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2465
    __ lvsr            (keyPerm, key);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2466
    __ vxor            (vTmp2, vTmp2, vTmp2);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2467
    __ vspltisb        (vTmp2, -16);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2468
    __ vrld            (keyPerm, keyPerm, vTmp2);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2469
    __ vrld            (keyPerm, keyPerm, vTmp2);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2470
    __ vsldoi          (keyPerm, keyPerm, keyPerm, -8);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2471
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2472
    // load the 1st round key to vKey1
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2473
    __ li              (keypos, 0);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2474
    __ lvx             (vKey1, keypos, key);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2475
    __ addi            (keypos, keypos, 16);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2476
    __ lvx             (vTmp1, keypos, key);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2477
    __ vperm           (vKey1, vTmp1, vKey1, keyPerm);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2478
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2479
    // 1st round
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2480
    __ vxor (vRet, vRet, vKey1);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2481
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2482
    // load the 2nd round key to vKey1
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2483
    __ addi            (keypos, keypos, 16);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2484
    __ lvx             (vTmp2, keypos, key);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2485
    __ vperm           (vKey1, vTmp2, vTmp1, keyPerm);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2486
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2487
    // load the 3rd round key to vKey2
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2488
    __ addi            (keypos, keypos, 16);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2489
    __ lvx             (vTmp1, keypos, key);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2490
    __ vperm           (vKey2, vTmp1, vTmp2, keyPerm);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2491
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2492
    // load the 4th round key to vKey3
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2493
    __ addi            (keypos, keypos, 16);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2494
    __ lvx             (vTmp2, keypos, key);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2495
    __ vperm           (vKey3, vTmp2, vTmp1, keyPerm);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2496
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2497
    // load the 5th round key to vKey4
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2498
    __ addi            (keypos, keypos, 16);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2499
    __ lvx             (vTmp1, keypos, key);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2500
    __ vperm           (vKey4, vTmp1, vTmp2, keyPerm);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2501
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2502
    // 2nd - 5th rounds
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2503
    __ vcipher (vRet, vRet, vKey1);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2504
    __ vcipher (vRet, vRet, vKey2);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2505
    __ vcipher (vRet, vRet, vKey3);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2506
    __ vcipher (vRet, vRet, vKey4);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2507
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2508
    // load the 6th round key to vKey1
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2509
    __ addi            (keypos, keypos, 16);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2510
    __ lvx             (vTmp2, keypos, key);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2511
    __ vperm           (vKey1, vTmp2, vTmp1, keyPerm);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2512
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2513
    // load the 7th round key to vKey2
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2514
    __ addi            (keypos, keypos, 16);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2515
    __ lvx             (vTmp1, keypos, key);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2516
    __ vperm           (vKey2, vTmp1, vTmp2, keyPerm);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2517
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2518
    // load the 8th round key to vKey3
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2519
    __ addi            (keypos, keypos, 16);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2520
    __ lvx             (vTmp2, keypos, key);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2521
    __ vperm           (vKey3, vTmp2, vTmp1, keyPerm);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2522
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2523
    // load the 9th round key to vKey4
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2524
    __ addi            (keypos, keypos, 16);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2525
    __ lvx             (vTmp1, keypos, key);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2526
    __ vperm           (vKey4, vTmp1, vTmp2, keyPerm);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2527
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2528
    // 6th - 9th rounds
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2529
    __ vcipher (vRet, vRet, vKey1);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2530
    __ vcipher (vRet, vRet, vKey2);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2531
    __ vcipher (vRet, vRet, vKey3);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2532
    __ vcipher (vRet, vRet, vKey4);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2533
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2534
    // load the 10th round key to vKey1
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2535
    __ addi            (keypos, keypos, 16);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2536
    __ lvx             (vTmp2, keypos, key);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2537
    __ vperm           (vKey1, vTmp2, vTmp1, keyPerm);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2538
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2539
    // load the 11th round key to vKey2
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2540
    __ addi            (keypos, keypos, 16);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2541
    __ lvx             (vTmp1, keypos, key);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2542
    __ vperm           (vKey2, vTmp1, vTmp2, keyPerm);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2543
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2544
    // if all round keys are loaded, skip next 4 rounds
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2545
    __ cmpwi           (CCR0, keylen, 44);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2546
    __ beq             (CCR0, L_doLast);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2547
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2548
    // 10th - 11th rounds
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2549
    __ vcipher (vRet, vRet, vKey1);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2550
    __ vcipher (vRet, vRet, vKey2);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2551
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2552
    // load the 12th round key to vKey1
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2553
    __ addi            (keypos, keypos, 16);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2554
    __ lvx             (vTmp2, keypos, key);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2555
    __ vperm           (vKey1, vTmp2, vTmp1, keyPerm);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2556
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2557
    // load the 13th round key to vKey2
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2558
    __ addi            (keypos, keypos, 16);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2559
    __ lvx             (vTmp1, keypos, key);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2560
    __ vperm           (vKey2, vTmp1, vTmp2, keyPerm);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2561
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2562
    // if all round keys are loaded, skip next 2 rounds
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2563
    __ cmpwi           (CCR0, keylen, 52);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2564
    __ beq             (CCR0, L_doLast);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2565
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2566
    // 12th - 13th rounds
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2567
    __ vcipher (vRet, vRet, vKey1);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2568
    __ vcipher (vRet, vRet, vKey2);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2569
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2570
    // load the 14th round key to vKey1
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2571
    __ addi            (keypos, keypos, 16);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2572
    __ lvx             (vTmp2, keypos, key);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2573
    __ vperm           (vKey1, vTmp2, vTmp1, keyPerm);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2574
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2575
    // load the 15th round key to vKey2
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2576
    __ addi            (keypos, keypos, 16);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2577
    __ lvx             (vTmp1, keypos, key);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2578
    __ vperm           (vKey2, vTmp1, vTmp2, keyPerm);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2579
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2580
    __ bind(L_doLast);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2581
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2582
    // last two rounds
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2583
    __ vcipher (vRet, vRet, vKey1);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2584
    __ vcipherlast (vRet, vRet, vKey2);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2585
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2586
    __ neg             (temp, to);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2587
    __ lvsr            (toPerm, temp);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2588
    __ vspltisb        (vTmp2, -1);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2589
    __ vxor            (vTmp1, vTmp1, vTmp1);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2590
    __ vperm           (vTmp2, vTmp2, vTmp1, toPerm);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2591
    __ vxor            (toPerm, toPerm, fSplt);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2592
    __ lvx             (vTmp1, to);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2593
    __ vperm           (vRet, vRet, vRet, toPerm);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2594
    __ vsel            (vTmp1, vTmp1, vRet, vTmp2);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2595
    __ lvx             (vTmp4, fifteen, to);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2596
    __ stvx            (vTmp1, to);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2597
    __ vsel            (vRet, vRet, vTmp4, vTmp2);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2598
    __ stvx            (vRet, fifteen, to);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2599
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2600
    __ blr();
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2601
     return start;
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2602
  }
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2603
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2604
  // Arguments for generated stub (little endian only):
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2605
  //   R3_ARG1   - source byte array address
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2606
  //   R4_ARG2   - destination byte array address
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2607
  //   R5_ARG3   - K (key) in little endian int array
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2608
  address generate_aescrypt_decryptBlock() {
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2609
    assert(UseAES, "need AES instructions and misaligned SSE support");
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2610
    StubCodeMark mark(this, "StubRoutines", "aescrypt_decryptBlock");
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2611
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2612
    address start = __ function_entry();
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2613
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2614
    Label L_doLast;
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2615
    Label L_do44;
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2616
    Label L_do52;
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2617
    Label L_do60;
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2618
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2619
    Register from           = R3_ARG1;  // source array address
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2620
    Register to             = R4_ARG2;  // destination array address
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2621
    Register key            = R5_ARG3;  // round key array
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2622
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2623
    Register keylen         = R8;
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2624
    Register temp           = R9;
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2625
    Register keypos         = R10;
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2626
    Register hex            = R11;
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2627
    Register fifteen        = R12;
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2628
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2629
    VectorRegister vRet     = VR0;
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2630
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2631
    VectorRegister vKey1    = VR1;
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2632
    VectorRegister vKey2    = VR2;
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2633
    VectorRegister vKey3    = VR3;
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2634
    VectorRegister vKey4    = VR4;
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2635
    VectorRegister vKey5    = VR5;
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2636
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2637
    VectorRegister fromPerm = VR6;
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2638
    VectorRegister keyPerm  = VR7;
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2639
    VectorRegister toPerm   = VR8;
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2640
    VectorRegister fSplt    = VR9;
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2641
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2642
    VectorRegister vTmp1    = VR10;
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2643
    VectorRegister vTmp2    = VR11;
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2644
    VectorRegister vTmp3    = VR12;
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2645
    VectorRegister vTmp4    = VR13;
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2646
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2647
    VectorRegister vLow     = VR14;
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2648
    VectorRegister vHigh    = VR15;
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2649
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2650
    __ li              (hex, 16);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2651
    __ li              (fifteen, 15);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2652
    __ vspltisb        (fSplt, 0x0f);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2653
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2654
    // load unaligned from[0-15] to vsRet
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2655
    __ lvx             (vRet, from);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2656
    __ lvx             (vTmp1, fifteen, from);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2657
    __ lvsl            (fromPerm, from);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2658
    __ vxor            (fromPerm, fromPerm, fSplt);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2659
    __ vperm           (vRet, vRet, vTmp1, fromPerm); // align [and byte swap in LE]
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2660
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2661
    // load keylen (44 or 52 or 60)
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2662
    __ lwz             (keylen, arrayOopDesc::length_offset_in_bytes() - arrayOopDesc::base_offset_in_bytes(T_INT), key);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2663
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2664
    // to load keys
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2665
    __ lvsr            (keyPerm, key);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2666
    __ vxor            (vTmp2, vTmp2, vTmp2);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2667
    __ vspltisb        (vTmp2, -16);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2668
    __ vrld            (keyPerm, keyPerm, vTmp2);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2669
    __ vrld            (keyPerm, keyPerm, vTmp2);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2670
    __ vsldoi          (keyPerm, keyPerm, keyPerm, -8);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2671
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2672
    __ cmpwi           (CCR0, keylen, 44);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2673
    __ beq             (CCR0, L_do44);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2674
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2675
    __ cmpwi           (CCR0, keylen, 52);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2676
    __ beq             (CCR0, L_do52);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2677
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2678
    // load the 15th round key to vKey11
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2679
    __ li              (keypos, 240);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2680
    __ lvx             (vTmp1, keypos, key);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2681
    __ addi            (keypos, keypos, -16);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2682
    __ lvx             (vTmp2, keypos, key);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2683
    __ vperm           (vKey1, vTmp1, vTmp2, keyPerm);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2684
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2685
    // load the 14th round key to vKey10
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2686
    __ addi            (keypos, keypos, -16);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2687
    __ lvx             (vTmp1, keypos, key);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2688
    __ vperm           (vKey2, vTmp2, vTmp1, keyPerm);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2689
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2690
    // load the 13th round key to vKey10
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2691
    __ addi            (keypos, keypos, -16);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2692
    __ lvx             (vTmp2, keypos, key);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2693
    __ vperm           (vKey3, vTmp1, vTmp2, keyPerm);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2694
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2695
    // load the 12th round key to vKey10
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2696
    __ addi            (keypos, keypos, -16);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2697
    __ lvx             (vTmp1, keypos, key);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2698
    __ vperm           (vKey4, vTmp2, vTmp1, keyPerm);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2699
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2700
    // load the 11th round key to vKey10
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2701
    __ addi            (keypos, keypos, -16);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2702
    __ lvx             (vTmp2, keypos, key);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2703
    __ vperm           (vKey5, vTmp1, vTmp2, keyPerm);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2704
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2705
    // 1st - 5th rounds
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2706
    __ vxor            (vRet, vRet, vKey1);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2707
    __ vncipher        (vRet, vRet, vKey2);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2708
    __ vncipher        (vRet, vRet, vKey3);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2709
    __ vncipher        (vRet, vRet, vKey4);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2710
    __ vncipher        (vRet, vRet, vKey5);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2711
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2712
    __ b               (L_doLast);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2713
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2714
    __ bind            (L_do52);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2715
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2716
    // load the 13th round key to vKey11
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2717
    __ li              (keypos, 208);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2718
    __ lvx             (vTmp1, keypos, key);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2719
    __ addi            (keypos, keypos, -16);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2720
    __ lvx             (vTmp2, keypos, key);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2721
    __ vperm           (vKey1, vTmp1, vTmp2, keyPerm);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2722
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2723
    // load the 12th round key to vKey10
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2724
    __ addi            (keypos, keypos, -16);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2725
    __ lvx             (vTmp1, keypos, key);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2726
    __ vperm           (vKey2, vTmp2, vTmp1, keyPerm);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2727
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2728
    // load the 11th round key to vKey10
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2729
    __ addi            (keypos, keypos, -16);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2730
    __ lvx             (vTmp2, keypos, key);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2731
    __ vperm           (vKey3, vTmp1, vTmp2, keyPerm);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2732
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2733
    // 1st - 3rd rounds
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2734
    __ vxor            (vRet, vRet, vKey1);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2735
    __ vncipher        (vRet, vRet, vKey2);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2736
    __ vncipher        (vRet, vRet, vKey3);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2737
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2738
    __ b               (L_doLast);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2739
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2740
    __ bind            (L_do44);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2741
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2742
    // load the 11th round key to vKey11
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2743
    __ li              (keypos, 176);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2744
    __ lvx             (vTmp1, keypos, key);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2745
    __ addi            (keypos, keypos, -16);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2746
    __ lvx             (vTmp2, keypos, key);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2747
    __ vperm           (vKey1, vTmp1, vTmp2, keyPerm);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2748
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2749
    // 1st round
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2750
    __ vxor            (vRet, vRet, vKey1);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2751
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2752
    __ bind            (L_doLast);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2753
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2754
    // load the 10th round key to vKey10
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2755
    __ addi            (keypos, keypos, -16);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2756
    __ lvx             (vTmp1, keypos, key);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2757
    __ vperm           (vKey1, vTmp2, vTmp1, keyPerm);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2758
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2759
    // load the 9th round key to vKey10
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2760
    __ addi            (keypos, keypos, -16);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2761
    __ lvx             (vTmp2, keypos, key);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2762
    __ vperm           (vKey2, vTmp1, vTmp2, keyPerm);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2763
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2764
    // load the 8th round key to vKey10
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2765
    __ addi            (keypos, keypos, -16);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2766
    __ lvx             (vTmp1, keypos, key);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2767
    __ vperm           (vKey3, vTmp2, vTmp1, keyPerm);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2768
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2769
    // load the 7th round key to vKey10
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2770
    __ addi            (keypos, keypos, -16);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2771
    __ lvx             (vTmp2, keypos, key);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2772
    __ vperm           (vKey4, vTmp1, vTmp2, keyPerm);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2773
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2774
    // load the 6th round key to vKey10
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2775
    __ addi            (keypos, keypos, -16);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2776
    __ lvx             (vTmp1, keypos, key);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2777
    __ vperm           (vKey5, vTmp2, vTmp1, keyPerm);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2778
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2779
    // last 10th - 6th rounds
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2780
    __ vncipher        (vRet, vRet, vKey1);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2781
    __ vncipher        (vRet, vRet, vKey2);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2782
    __ vncipher        (vRet, vRet, vKey3);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2783
    __ vncipher        (vRet, vRet, vKey4);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2784
    __ vncipher        (vRet, vRet, vKey5);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2785
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2786
    // load the 5th round key to vKey10
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2787
    __ addi            (keypos, keypos, -16);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2788
    __ lvx             (vTmp2, keypos, key);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2789
    __ vperm           (vKey1, vTmp1, vTmp2, keyPerm);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2790
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2791
    // load the 4th round key to vKey10
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2792
    __ addi            (keypos, keypos, -16);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2793
    __ lvx             (vTmp1, keypos, key);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2794
    __ vperm           (vKey2, vTmp2, vTmp1, keyPerm);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2795
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2796
    // load the 3rd round key to vKey10
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2797
    __ addi            (keypos, keypos, -16);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2798
    __ lvx             (vTmp2, keypos, key);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2799
    __ vperm           (vKey3, vTmp1, vTmp2, keyPerm);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2800
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2801
    // load the 2nd round key to vKey10
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2802
    __ addi            (keypos, keypos, -16);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2803
    __ lvx             (vTmp1, keypos, key);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2804
    __ vperm           (vKey4, vTmp2, vTmp1, keyPerm);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2805
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2806
    // load the 1st round key to vKey10
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2807
    __ addi            (keypos, keypos, -16);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2808
    __ lvx             (vTmp2, keypos, key);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2809
    __ vperm           (vKey5, vTmp1, vTmp2, keyPerm);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2810
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2811
    // last 5th - 1th rounds
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2812
    __ vncipher        (vRet, vRet, vKey1);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2813
    __ vncipher        (vRet, vRet, vKey2);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2814
    __ vncipher        (vRet, vRet, vKey3);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2815
    __ vncipher        (vRet, vRet, vKey4);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2816
    __ vncipherlast    (vRet, vRet, vKey5);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2817
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2818
    __ neg             (temp, to);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2819
    __ lvsr            (toPerm, temp);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2820
    __ vspltisb        (vTmp2, -1);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2821
    __ vxor            (vTmp1, vTmp1, vTmp1);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2822
    __ vperm           (vTmp2, vTmp2, vTmp1, toPerm);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2823
    __ vxor            (toPerm, toPerm, fSplt);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2824
    __ lvx             (vTmp1, to);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2825
    __ vperm           (vRet, vRet, vRet, toPerm);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2826
    __ vsel            (vTmp1, vTmp1, vRet, vTmp2);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2827
    __ lvx             (vTmp4, fifteen, to);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2828
    __ stvx            (vTmp1, to);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2829
    __ vsel            (vRet, vRet, vTmp4, vTmp2);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2830
    __ stvx            (vRet, fifteen, to);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2831
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2832
    __ blr();
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2833
     return start;
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  2834
  }
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2835
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2836
  void generate_arraycopy_stubs() {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2837
    // Note: the disjoint stubs must be generated first, some of
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2838
    // the conjoint stubs use them.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2839
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2840
    // non-aligned disjoint versions
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2841
    StubRoutines::_jbyte_disjoint_arraycopy       = generate_disjoint_byte_copy(false, "jbyte_disjoint_arraycopy");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2842
    StubRoutines::_jshort_disjoint_arraycopy      = generate_disjoint_short_copy(false, "jshort_disjoint_arraycopy");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2843
    StubRoutines::_jint_disjoint_arraycopy        = generate_disjoint_int_copy(false, "jint_disjoint_arraycopy");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2844
    StubRoutines::_jlong_disjoint_arraycopy       = generate_disjoint_long_copy(false, "jlong_disjoint_arraycopy");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2845
    StubRoutines::_oop_disjoint_arraycopy         = generate_disjoint_oop_copy(false, "oop_disjoint_arraycopy", false);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2846
    StubRoutines::_oop_disjoint_arraycopy_uninit  = generate_disjoint_oop_copy(false, "oop_disjoint_arraycopy_uninit", true);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2847
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2848
    // aligned disjoint versions
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2849
    StubRoutines::_arrayof_jbyte_disjoint_arraycopy      = generate_disjoint_byte_copy(true, "arrayof_jbyte_disjoint_arraycopy");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2850
    StubRoutines::_arrayof_jshort_disjoint_arraycopy     = generate_disjoint_short_copy(true, "arrayof_jshort_disjoint_arraycopy");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2851
    StubRoutines::_arrayof_jint_disjoint_arraycopy       = generate_disjoint_int_copy(true, "arrayof_jint_disjoint_arraycopy");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2852
    StubRoutines::_arrayof_jlong_disjoint_arraycopy      = generate_disjoint_long_copy(true, "arrayof_jlong_disjoint_arraycopy");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2853
    StubRoutines::_arrayof_oop_disjoint_arraycopy        = generate_disjoint_oop_copy(true, "arrayof_oop_disjoint_arraycopy", false);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2854
    StubRoutines::_arrayof_oop_disjoint_arraycopy_uninit = generate_disjoint_oop_copy(true, "oop_disjoint_arraycopy_uninit", true);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2855
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2856
    // non-aligned conjoint versions
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2857
    StubRoutines::_jbyte_arraycopy      = generate_conjoint_byte_copy(false, "jbyte_arraycopy");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2858
    StubRoutines::_jshort_arraycopy     = generate_conjoint_short_copy(false, "jshort_arraycopy");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2859
    StubRoutines::_jint_arraycopy       = generate_conjoint_int_copy(false, "jint_arraycopy");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2860
    StubRoutines::_jlong_arraycopy      = generate_conjoint_long_copy(false, "jlong_arraycopy");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2861
    StubRoutines::_oop_arraycopy        = generate_conjoint_oop_copy(false, "oop_arraycopy", false);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2862
    StubRoutines::_oop_arraycopy_uninit = generate_conjoint_oop_copy(false, "oop_arraycopy_uninit", true);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2863
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2864
    // aligned conjoint versions
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2865
    StubRoutines::_arrayof_jbyte_arraycopy      = generate_conjoint_byte_copy(true, "arrayof_jbyte_arraycopy");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2866
    StubRoutines::_arrayof_jshort_arraycopy     = generate_conjoint_short_copy(true, "arrayof_jshort_arraycopy");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2867
    StubRoutines::_arrayof_jint_arraycopy       = generate_conjoint_int_copy(true, "arrayof_jint_arraycopy");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2868
    StubRoutines::_arrayof_jlong_arraycopy      = generate_conjoint_long_copy(true, "arrayof_jlong_arraycopy");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2869
    StubRoutines::_arrayof_oop_arraycopy        = generate_conjoint_oop_copy(true, "arrayof_oop_arraycopy", false);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2870
    StubRoutines::_arrayof_oop_arraycopy_uninit = generate_conjoint_oop_copy(true, "arrayof_oop_arraycopy", true);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2871
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2872
    // special/generic versions
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2873
    StubRoutines::_checkcast_arraycopy        = generate_checkcast_copy("checkcast_arraycopy", false);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2874
    StubRoutines::_checkcast_arraycopy_uninit = generate_checkcast_copy("checkcast_arraycopy_uninit", true);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2875
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2876
    StubRoutines::_unsafe_arraycopy  = generate_unsafe_copy("unsafe_arraycopy",
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2877
                                                            STUB_ENTRY(jbyte_arraycopy),
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2878
                                                            STUB_ENTRY(jshort_arraycopy),
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2879
                                                            STUB_ENTRY(jint_arraycopy),
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2880
                                                            STUB_ENTRY(jlong_arraycopy));
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2881
    StubRoutines::_generic_arraycopy = generate_generic_copy("generic_arraycopy",
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2882
                                                             STUB_ENTRY(jbyte_arraycopy),
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2883
                                                             STUB_ENTRY(jshort_arraycopy),
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2884
                                                             STUB_ENTRY(jint_arraycopy),
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2885
                                                             STUB_ENTRY(oop_arraycopy),
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2886
                                                             STUB_ENTRY(oop_disjoint_arraycopy),
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2887
                                                             STUB_ENTRY(jlong_arraycopy),
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2888
                                                             STUB_ENTRY(checkcast_arraycopy));
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2889
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2890
    // fill routines
35541
cba047a086d5 8146613: PPC64: C2 does no longer respect int to long conversion for stub calls
mdoerr
parents: 35156
diff changeset
  2891
    if (OptimizeFill) {
cba047a086d5 8146613: PPC64: C2 does no longer respect int to long conversion for stub calls
mdoerr
parents: 35156
diff changeset
  2892
      StubRoutines::_jbyte_fill          = generate_fill(T_BYTE,  false, "jbyte_fill");
cba047a086d5 8146613: PPC64: C2 does no longer respect int to long conversion for stub calls
mdoerr
parents: 35156
diff changeset
  2893
      StubRoutines::_jshort_fill         = generate_fill(T_SHORT, false, "jshort_fill");
cba047a086d5 8146613: PPC64: C2 does no longer respect int to long conversion for stub calls
mdoerr
parents: 35156
diff changeset
  2894
      StubRoutines::_jint_fill           = generate_fill(T_INT,   false, "jint_fill");
cba047a086d5 8146613: PPC64: C2 does no longer respect int to long conversion for stub calls
mdoerr
parents: 35156
diff changeset
  2895
      StubRoutines::_arrayof_jbyte_fill  = generate_fill(T_BYTE,  true, "arrayof_jbyte_fill");
cba047a086d5 8146613: PPC64: C2 does no longer respect int to long conversion for stub calls
mdoerr
parents: 35156
diff changeset
  2896
      StubRoutines::_arrayof_jshort_fill = generate_fill(T_SHORT, true, "arrayof_jshort_fill");
cba047a086d5 8146613: PPC64: C2 does no longer respect int to long conversion for stub calls
mdoerr
parents: 35156
diff changeset
  2897
      StubRoutines::_arrayof_jint_fill   = generate_fill(T_INT,   true, "arrayof_jint_fill");
cba047a086d5 8146613: PPC64: C2 does no longer respect int to long conversion for stub calls
mdoerr
parents: 35156
diff changeset
  2898
    }
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2899
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2900
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2901
  // Safefetch stubs.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2902
  void generate_safefetch(const char* name, int size, address* entry, address* fault_pc, address* continuation_pc) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2903
    // safefetch signatures:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2904
    //   int      SafeFetch32(int*      adr, int      errValue);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2905
    //   intptr_t SafeFetchN (intptr_t* adr, intptr_t errValue);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2906
    //
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2907
    // arguments:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2908
    //   R3_ARG1 = adr
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2909
    //   R4_ARG2 = errValue
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2910
    //
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2911
    // result:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2912
    //   R3_RET  = *adr or errValue
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2913
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2914
    StubCodeMark mark(this, "StubRoutines", name);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2915
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2916
    // Entry point, pc or function descriptor.
23211
954e3a81da29 8035647: PPC64: Support for elf v2 abi.
goetz
parents: 22874
diff changeset
  2917
    *entry = __ function_entry();
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2918
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2919
    // Load *adr into R4_ARG2, may fault.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2920
    *fault_pc = __ pc();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2921
    switch (size) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2922
      case 4:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2923
        // int32_t, signed extended
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2924
        __ lwa(R4_ARG2, 0, R3_ARG1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2925
        break;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2926
      case 8:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2927
        // int64_t
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2928
        __ ld(R4_ARG2, 0, R3_ARG1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2929
        break;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2930
      default:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2931
        ShouldNotReachHere();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2932
    }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2933
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2934
    // return errValue or *adr
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2935
    *continuation_pc = __ pc();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2936
    __ mr(R3_RET, R4_ARG2);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2937
    __ blr();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2938
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2939
31773
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30303
diff changeset
  2940
  // Stub for BigInteger::multiplyToLen()
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30303
diff changeset
  2941
  //
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30303
diff changeset
  2942
  //  Arguments:
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30303
diff changeset
  2943
  //
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30303
diff changeset
  2944
  //  Input:
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30303
diff changeset
  2945
  //    R3 - x address
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30303
diff changeset
  2946
  //    R4 - x length
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30303
diff changeset
  2947
  //    R5 - y address
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30303
diff changeset
  2948
  //    R6 - y length
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30303
diff changeset
  2949
  //    R7 - z address
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30303
diff changeset
  2950
  //    R8 - z length
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30303
diff changeset
  2951
  //
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30303
diff changeset
  2952
  address generate_multiplyToLen() {
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30303
diff changeset
  2953
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30303
diff changeset
  2954
    StubCodeMark mark(this, "StubRoutines", "multiplyToLen");
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30303
diff changeset
  2955
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30303
diff changeset
  2956
    address start = __ function_entry();
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30303
diff changeset
  2957
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30303
diff changeset
  2958
    const Register x     = R3;
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30303
diff changeset
  2959
    const Register xlen  = R4;
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30303
diff changeset
  2960
    const Register y     = R5;
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30303
diff changeset
  2961
    const Register ylen  = R6;
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30303
diff changeset
  2962
    const Register z     = R7;
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30303
diff changeset
  2963
    const Register zlen  = R8;
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30303
diff changeset
  2964
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30303
diff changeset
  2965
    const Register tmp1  = R2; // TOC not used.
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30303
diff changeset
  2966
    const Register tmp2  = R9;
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30303
diff changeset
  2967
    const Register tmp3  = R10;
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30303
diff changeset
  2968
    const Register tmp4  = R11;
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30303
diff changeset
  2969
    const Register tmp5  = R12;
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30303
diff changeset
  2970
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30303
diff changeset
  2971
    // non-volatile regs
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30303
diff changeset
  2972
    const Register tmp6  = R31;
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30303
diff changeset
  2973
    const Register tmp7  = R30;
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30303
diff changeset
  2974
    const Register tmp8  = R29;
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30303
diff changeset
  2975
    const Register tmp9  = R28;
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30303
diff changeset
  2976
    const Register tmp10 = R27;
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30303
diff changeset
  2977
    const Register tmp11 = R26;
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30303
diff changeset
  2978
    const Register tmp12 = R25;
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30303
diff changeset
  2979
    const Register tmp13 = R24;
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30303
diff changeset
  2980
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30303
diff changeset
  2981
    BLOCK_COMMENT("Entry:");
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30303
diff changeset
  2982
35541
cba047a086d5 8146613: PPC64: C2 does no longer respect int to long conversion for stub calls
mdoerr
parents: 35156
diff changeset
  2983
    // C2 does not respect int to long conversion for stub calls.
cba047a086d5 8146613: PPC64: C2 does no longer respect int to long conversion for stub calls
mdoerr
parents: 35156
diff changeset
  2984
    __ clrldi(xlen, xlen, 32);
cba047a086d5 8146613: PPC64: C2 does no longer respect int to long conversion for stub calls
mdoerr
parents: 35156
diff changeset
  2985
    __ clrldi(ylen, ylen, 32);
cba047a086d5 8146613: PPC64: C2 does no longer respect int to long conversion for stub calls
mdoerr
parents: 35156
diff changeset
  2986
    __ clrldi(zlen, zlen, 32);
cba047a086d5 8146613: PPC64: C2 does no longer respect int to long conversion for stub calls
mdoerr
parents: 35156
diff changeset
  2987
31773
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30303
diff changeset
  2988
    // Save non-volatile regs (frameless).
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30303
diff changeset
  2989
    int current_offs = 8;
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30303
diff changeset
  2990
    __ std(R24, -current_offs, R1_SP); current_offs += 8;
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30303
diff changeset
  2991
    __ std(R25, -current_offs, R1_SP); current_offs += 8;
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30303
diff changeset
  2992
    __ std(R26, -current_offs, R1_SP); current_offs += 8;
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30303
diff changeset
  2993
    __ std(R27, -current_offs, R1_SP); current_offs += 8;
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30303
diff changeset
  2994
    __ std(R28, -current_offs, R1_SP); current_offs += 8;
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30303
diff changeset
  2995
    __ std(R29, -current_offs, R1_SP); current_offs += 8;
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30303
diff changeset
  2996
    __ std(R30, -current_offs, R1_SP); current_offs += 8;
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30303
diff changeset
  2997
    __ std(R31, -current_offs, R1_SP);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30303
diff changeset
  2998
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30303
diff changeset
  2999
    __ multiply_to_len(x, xlen, y, ylen, z, zlen, tmp1, tmp2, tmp3, tmp4, tmp5,
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30303
diff changeset
  3000
                       tmp6, tmp7, tmp8, tmp9, tmp10, tmp11, tmp12, tmp13);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30303
diff changeset
  3001
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30303
diff changeset
  3002
    // Restore non-volatile regs.
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30303
diff changeset
  3003
    current_offs = 8;
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30303
diff changeset
  3004
    __ ld(R24, -current_offs, R1_SP); current_offs += 8;
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30303
diff changeset
  3005
    __ ld(R25, -current_offs, R1_SP); current_offs += 8;
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30303
diff changeset
  3006
    __ ld(R26, -current_offs, R1_SP); current_offs += 8;
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30303
diff changeset
  3007
    __ ld(R27, -current_offs, R1_SP); current_offs += 8;
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30303
diff changeset
  3008
    __ ld(R28, -current_offs, R1_SP); current_offs += 8;
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30303
diff changeset
  3009
    __ ld(R29, -current_offs, R1_SP); current_offs += 8;
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30303
diff changeset
  3010
    __ ld(R30, -current_offs, R1_SP); current_offs += 8;
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30303
diff changeset
  3011
    __ ld(R31, -current_offs, R1_SP);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30303
diff changeset
  3012
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30303
diff changeset
  3013
    __ blr();  // Return to caller.
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30303
diff changeset
  3014
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30303
diff changeset
  3015
    return start;
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30303
diff changeset
  3016
  }
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30303
diff changeset
  3017
31861
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  3018
  /**
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  3019
   * Arguments:
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  3020
   *
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  3021
   * Inputs:
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  3022
   *   R3_ARG1    - int   crc
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  3023
   *   R4_ARG2    - byte* buf
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  3024
   *   R5_ARG3    - int   length (of buffer)
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  3025
   *
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  3026
   * scratch:
36303
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35594
diff changeset
  3027
   *   R2, R6-R12
31861
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  3028
   *
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  3029
   * Ouput:
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  3030
   *   R3_RET     - int   crc result
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  3031
   */
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  3032
  // Compute CRC32 function.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  3033
  address generate_CRC32_updateBytes(const char* name) {
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  3034
    __ align(CodeEntryAlignment);
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  3035
    StubCodeMark mark(this, "StubRoutines", name);
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  3036
    address start = __ function_entry();  // Remember stub start address (is rtn value).
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  3037
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  3038
    // arguments to kernel_crc32:
36303
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35594
diff changeset
  3039
    const Register crc     = R3_ARG1;  // Current checksum, preset by caller or result from previous call.
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35594
diff changeset
  3040
    const Register data    = R4_ARG2;  // source byte array
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35594
diff changeset
  3041
    const Register dataLen = R5_ARG3;  // #bytes to process
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35594
diff changeset
  3042
    const Register table   = R6_ARG4;  // crc table address
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35594
diff changeset
  3043
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35594
diff changeset
  3044
    const Register t0      = R2;
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35594
diff changeset
  3045
    const Register t1      = R7;
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35594
diff changeset
  3046
    const Register t2      = R8;
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35594
diff changeset
  3047
    const Register t3      = R9;
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35594
diff changeset
  3048
    const Register tc0     = R10;
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35594
diff changeset
  3049
    const Register tc1     = R11;
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35594
diff changeset
  3050
    const Register tc2     = R12;
31861
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  3051
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  3052
    BLOCK_COMMENT("Stub body {");
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  3053
    assert_different_registers(crc, data, dataLen, table);
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  3054
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  3055
    StubRoutines::ppc64::generate_load_crc_table_addr(_masm, table);
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  3056
36303
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35594
diff changeset
  3057
    __ kernel_crc32_1word(crc, data, dataLen, table, t0, t1, t2, t3, tc0, tc1, tc2, table);
31861
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  3058
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  3059
    BLOCK_COMMENT("return");
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  3060
    __ mr_if_needed(R3_RET, crc);      // Updated crc is function result. No copying required (R3_ARG1 == R3_RET).
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  3061
    __ blr();
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  3062
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  3063
    BLOCK_COMMENT("} Stub body");
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  3064
    return start;
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  3065
  }
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  3066
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3067
  // Initialization
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3068
  void generate_initial() {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3069
    // Generates all stubs and initializes the entry points
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3070
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3071
    // Entry points that exist in all platforms.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3072
    // Note: This is code that could be shared among different platforms - however the
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3073
    // benefit seems to be smaller than the disadvantage of having a
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3074
    // much more complicated generator structure. See also comment in
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3075
    // stubRoutines.hpp.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3076
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3077
    StubRoutines::_forward_exception_entry          = generate_forward_exception();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3078
    StubRoutines::_call_stub_entry                  = generate_call_stub(StubRoutines::_call_stub_return_address);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3079
    StubRoutines::_catch_exception_entry            = generate_catch_exception();
22867
309bcf262a19 8031319: PPC64: Some fixes in ppc and aix coding.
goetz
parents: 22861
diff changeset
  3080
309bcf262a19 8031319: PPC64: Some fixes in ppc and aix coding.
goetz
parents: 22861
diff changeset
  3081
    // Build this early so it's available for the interpreter.
309bcf262a19 8031319: PPC64: Some fixes in ppc and aix coding.
goetz
parents: 22861
diff changeset
  3082
    StubRoutines::_throw_StackOverflowError_entry   =
309bcf262a19 8031319: PPC64: Some fixes in ppc and aix coding.
goetz
parents: 22861
diff changeset
  3083
      generate_throw_exception("StackOverflowError throw_exception",
309bcf262a19 8031319: PPC64: Some fixes in ppc and aix coding.
goetz
parents: 22861
diff changeset
  3084
                               CAST_FROM_FN_PTR(address, SharedRuntime::throw_StackOverflowError), false);
31861
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  3085
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  3086
    // CRC32 Intrinsics.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  3087
    if (UseCRC32Intrinsics) {
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  3088
      StubRoutines::_crc_table_adr    = (address)StubRoutines::ppc64::_crc_table;
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  3089
      StubRoutines::_updateBytesCRC32 = generate_CRC32_updateBytes("CRC32_updateBytes");
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  3090
    }
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3091
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3092
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3093
  void generate_all() {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3094
    // Generates all stubs and initializes the entry points
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3095
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3096
    // These entry points require SharedInfo::stack0 to be set up in
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3097
    // non-core builds
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3098
    StubRoutines::_throw_AbstractMethodError_entry         = generate_throw_exception("AbstractMethodError throw_exception",          CAST_FROM_FN_PTR(address, SharedRuntime::throw_AbstractMethodError),  false);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3099
    // Handle IncompatibleClassChangeError in itable stubs.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3100
    StubRoutines::_throw_IncompatibleClassChangeError_entry= generate_throw_exception("IncompatibleClassChangeError throw_exception", CAST_FROM_FN_PTR(address, SharedRuntime::throw_IncompatibleClassChangeError),  false);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3101
    StubRoutines::_throw_NullPointerException_at_call_entry= generate_throw_exception("NullPointerException at call throw_exception", CAST_FROM_FN_PTR(address, SharedRuntime::throw_NullPointerException_at_call), false);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3102
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3103
    // support for verify_oop (must happen after universe_init)
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3104
    StubRoutines::_verify_oop_subroutine_entry             = generate_verify_oop();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3105
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3106
    // arraycopy stubs used by compilers
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3107
    generate_arraycopy_stubs();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3108
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 23211
diff changeset
  3109
    // Safefetch stubs.
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3110
    generate_safefetch("SafeFetch32", sizeof(int),     &StubRoutines::_safefetch32_entry,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3111
                                                       &StubRoutines::_safefetch32_fault_pc,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3112
                                                       &StubRoutines::_safefetch32_continuation_pc);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3113
    generate_safefetch("SafeFetchN", sizeof(intptr_t), &StubRoutines::_safefetchN_entry,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3114
                                                       &StubRoutines::_safefetchN_fault_pc,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3115
                                                       &StubRoutines::_safefetchN_continuation_pc);
31773
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30303
diff changeset
  3116
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30303
diff changeset
  3117
#ifdef COMPILER2
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30303
diff changeset
  3118
    if (UseMultiplyToLenIntrinsic) {
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30303
diff changeset
  3119
      StubRoutines::_multiplyToLen = generate_multiplyToLen();
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30303
diff changeset
  3120
    }
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30303
diff changeset
  3121
#endif
35156
a06b3d7455d6 8145913: PPC64: add Montgomery multiply intrinsic
mdoerr
parents: 35085
diff changeset
  3122
a06b3d7455d6 8145913: PPC64: add Montgomery multiply intrinsic
mdoerr
parents: 35085
diff changeset
  3123
    if (UseMontgomeryMultiplyIntrinsic) {
a06b3d7455d6 8145913: PPC64: add Montgomery multiply intrinsic
mdoerr
parents: 35085
diff changeset
  3124
      StubRoutines::_montgomeryMultiply
a06b3d7455d6 8145913: PPC64: add Montgomery multiply intrinsic
mdoerr
parents: 35085
diff changeset
  3125
        = CAST_FROM_FN_PTR(address, SharedRuntime::montgomery_multiply);
a06b3d7455d6 8145913: PPC64: add Montgomery multiply intrinsic
mdoerr
parents: 35085
diff changeset
  3126
    }
a06b3d7455d6 8145913: PPC64: add Montgomery multiply intrinsic
mdoerr
parents: 35085
diff changeset
  3127
    if (UseMontgomerySquareIntrinsic) {
a06b3d7455d6 8145913: PPC64: add Montgomery multiply intrinsic
mdoerr
parents: 35085
diff changeset
  3128
      StubRoutines::_montgomerySquare
a06b3d7455d6 8145913: PPC64: add Montgomery multiply intrinsic
mdoerr
parents: 35085
diff changeset
  3129
        = CAST_FROM_FN_PTR(address, SharedRuntime::montgomery_square);
a06b3d7455d6 8145913: PPC64: add Montgomery multiply intrinsic
mdoerr
parents: 35085
diff changeset
  3130
    }
37275
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  3131
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  3132
    if (UseAESIntrinsics) {
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  3133
      StubRoutines::_aescrypt_encryptBlock = generate_aescrypt_encryptBlock();
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  3134
      StubRoutines::_aescrypt_decryptBlock = generate_aescrypt_decryptBlock();
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  3135
    }
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36303
diff changeset
  3136
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3137
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3138
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3139
 public:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3140
  StubGenerator(CodeBuffer* code, bool all) : StubCodeGenerator(code) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3141
    // replace the standard masm with a special one:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3142
    _masm = new MacroAssembler(code);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3143
    if (all) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3144
      generate_all();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3145
    } else {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3146
      generate_initial();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3147
    }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3148
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3149
};
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3150
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3151
void StubGenerator_generate(CodeBuffer* code, bool all) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3152
  StubGenerator g(code, all);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3153
}